isBasicValue

说明

判断是否基本类型的值

源码

用法

isBasicValue.test.ts
1
import { isBasicValue } from "../../utility/others/isBasicValue";
2
3
describe('isBasicValue', () => {
4
test('isBasicValue should return `true` if received a basic value', () => {
5
const received = [
6
0,
7
Number.MAX_SAFE_INTEGER,
8
'',
9
'ddzy',
10
Symbol('ddzy'),
11
null,
12
undefined,
13
];
14
15
for (const v of received) {
16
expect(isBasicValue(v)).toBeTruthy();
17
}
18
});
19
20
test('isBasicValue should return `false` if received a non basic value', () => {
21
const received = [
22
{ name: 'duan', age: 20 },
23
document.body,
24
[1, 2, 3],
25
function () { },
26
];
27
28
for (const v of received) {
29
expect(isBasicValue(v)).toBeFalsy();
30
}
31
});
32
})
Copied!
最近更新 1yr ago
复制链接