is-what 3.7.1 → 3.8.0
Sign up to get free protection for your applications and to get access to all the features.
- package/dist/index.cjs.js +40 -0
- package/dist/index.esm.js +37 -1
- package/package.json +16 -12
- package/src/index.ts +40 -0
- package/test/ava.ts +12 -0
- package/types/index.d.ts +28 -0
package/dist/index.cjs.js
CHANGED
@@ -144,6 +144,42 @@ function isBoolean(payload) {
|
|
144
144
|
function isRegExp(payload) {
|
145
145
|
return getType(payload) === 'RegExp';
|
146
146
|
}
|
147
|
+
/**
|
148
|
+
* Returns whether the payload is a Map
|
149
|
+
*
|
150
|
+
* @param {*} payload
|
151
|
+
* @returns {payload is Map}
|
152
|
+
*/
|
153
|
+
function isMap(payload) {
|
154
|
+
return getType(payload) === 'Map';
|
155
|
+
}
|
156
|
+
/**
|
157
|
+
* Returns whether the payload is a WeakMap
|
158
|
+
*
|
159
|
+
* @param {*} payload
|
160
|
+
* @returns {payload is WeakMap}
|
161
|
+
*/
|
162
|
+
function isWeakMap(payload) {
|
163
|
+
return getType(payload) === 'WeakMap';
|
164
|
+
}
|
165
|
+
/**
|
166
|
+
* Returns whether the payload is a Set
|
167
|
+
*
|
168
|
+
* @param {*} payload
|
169
|
+
* @returns {payload is Set}
|
170
|
+
*/
|
171
|
+
function isSet(payload) {
|
172
|
+
return getType(payload) === 'Set';
|
173
|
+
}
|
174
|
+
/**
|
175
|
+
* Returns whether the payload is a WeakSet
|
176
|
+
*
|
177
|
+
* @param {*} payload
|
178
|
+
* @returns {payload is WeakSet}
|
179
|
+
*/
|
180
|
+
function isWeakSet(payload) {
|
181
|
+
return getType(payload) === 'WeakSet';
|
182
|
+
}
|
147
183
|
/**
|
148
184
|
* Returns whether the payload is a Symbol
|
149
185
|
*
|
@@ -255,6 +291,7 @@ exports.isError = isError;
|
|
255
291
|
exports.isFile = isFile;
|
256
292
|
exports.isFullString = isFullString;
|
257
293
|
exports.isFunction = isFunction;
|
294
|
+
exports.isMap = isMap;
|
258
295
|
exports.isNull = isNull;
|
259
296
|
exports.isNullOrUndefined = isNullOrUndefined;
|
260
297
|
exports.isNumber = isNumber;
|
@@ -264,7 +301,10 @@ exports.isPlainObject = isPlainObject;
|
|
264
301
|
exports.isPrimitive = isPrimitive;
|
265
302
|
exports.isPromise = isPromise;
|
266
303
|
exports.isRegExp = isRegExp;
|
304
|
+
exports.isSet = isSet;
|
267
305
|
exports.isString = isString;
|
268
306
|
exports.isSymbol = isSymbol;
|
269
307
|
exports.isType = isType;
|
270
308
|
exports.isUndefined = isUndefined;
|
309
|
+
exports.isWeakMap = isWeakMap;
|
310
|
+
exports.isWeakSet = isWeakSet;
|
package/dist/index.esm.js
CHANGED
@@ -140,6 +140,42 @@ function isBoolean(payload) {
|
|
140
140
|
function isRegExp(payload) {
|
141
141
|
return getType(payload) === 'RegExp';
|
142
142
|
}
|
143
|
+
/**
|
144
|
+
* Returns whether the payload is a Map
|
145
|
+
*
|
146
|
+
* @param {*} payload
|
147
|
+
* @returns {payload is Map}
|
148
|
+
*/
|
149
|
+
function isMap(payload) {
|
150
|
+
return getType(payload) === 'Map';
|
151
|
+
}
|
152
|
+
/**
|
153
|
+
* Returns whether the payload is a WeakMap
|
154
|
+
*
|
155
|
+
* @param {*} payload
|
156
|
+
* @returns {payload is WeakMap}
|
157
|
+
*/
|
158
|
+
function isWeakMap(payload) {
|
159
|
+
return getType(payload) === 'WeakMap';
|
160
|
+
}
|
161
|
+
/**
|
162
|
+
* Returns whether the payload is a Set
|
163
|
+
*
|
164
|
+
* @param {*} payload
|
165
|
+
* @returns {payload is Set}
|
166
|
+
*/
|
167
|
+
function isSet(payload) {
|
168
|
+
return getType(payload) === 'Set';
|
169
|
+
}
|
170
|
+
/**
|
171
|
+
* Returns whether the payload is a WeakSet
|
172
|
+
*
|
173
|
+
* @param {*} payload
|
174
|
+
* @returns {payload is WeakSet}
|
175
|
+
*/
|
176
|
+
function isWeakSet(payload) {
|
177
|
+
return getType(payload) === 'WeakSet';
|
178
|
+
}
|
143
179
|
/**
|
144
180
|
* Returns whether the payload is a Symbol
|
145
181
|
*
|
@@ -240,4 +276,4 @@ function isType(payload, type) {
|
|
240
276
|
return getType(payload) === name || Boolean(payload && payload.constructor === type);
|
241
277
|
}
|
242
278
|
|
243
|
-
export { getType, isAnyObject, isArray, isBlob, isBoolean, isDate, isEmptyString, isError, isFile, isFullString, isFunction, isNull, isNullOrUndefined, isNumber, isObject, isObjectLike, isPlainObject, isPrimitive, isPromise, isRegExp, isString, isSymbol, isType, isUndefined };
|
279
|
+
export { getType, isAnyObject, isArray, isBlob, isBoolean, isDate, isEmptyString, isError, isFile, isFullString, isFunction, isMap, isNull, isNullOrUndefined, isNumber, isObject, isObjectLike, isPlainObject, isPrimitive, isPromise, isRegExp, isSet, isString, isSymbol, isType, isUndefined, isWeakMap, isWeakSet };
|
package/package.json
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
{
|
2
2
|
"name": "is-what",
|
3
3
|
"sideEffects": false,
|
4
|
-
"version": "3.
|
4
|
+
"version": "3.8.0",
|
5
5
|
"description": "JS type check (TypeScript supported) functions like `isPlainObject() isArray()` etc. A simple & small integration.",
|
6
6
|
"main": "dist/index.cjs.js",
|
7
7
|
"module": "dist/index.esm.js",
|
@@ -47,27 +47,31 @@
|
|
47
47
|
"homepage": "https://github.com/mesqueeb/is-what#readme",
|
48
48
|
"dependencies": {},
|
49
49
|
"devDependencies": {
|
50
|
-
"@babel/core": "^7.
|
50
|
+
"@babel/core": "^7.9.0",
|
51
51
|
"@types/babel-core": "^6.25.6",
|
52
|
-
"@types/jest": "^25.1
|
53
|
-
"@typescript-eslint/eslint-plugin": "^2.
|
54
|
-
"@typescript-eslint/parser": "^2.
|
55
|
-
"ava": "^3.
|
52
|
+
"@types/jest": "^25.2.1",
|
53
|
+
"@typescript-eslint/eslint-plugin": "^2.27.0",
|
54
|
+
"@typescript-eslint/parser": "^2.27.0",
|
55
|
+
"ava": "^3.6.0",
|
56
56
|
"babel-core": "^7.0.0-bridge.0",
|
57
|
-
"babel-jest": "^25.
|
57
|
+
"babel-jest": "^25.3.0",
|
58
58
|
"babel-preset-env": "^1.7.0",
|
59
59
|
"eslint": "^6.8.0",
|
60
|
-
"eslint-config-prettier": "^6.10.
|
60
|
+
"eslint-config-prettier": "^6.10.1",
|
61
61
|
"eslint-plugin-tree-shaking": "^1.8.0",
|
62
|
-
"jest": "^25.
|
62
|
+
"jest": "^25.3.0",
|
63
63
|
"regenerator-runtime": "^0.13.5",
|
64
64
|
"rollup": "^1.32.1",
|
65
65
|
"rollup-plugin-typescript2": "^0.26.0",
|
66
|
-
"ts-node": "^8.
|
66
|
+
"ts-node": "^8.8.2",
|
67
67
|
"typescript": "^3.8.3"
|
68
68
|
},
|
69
69
|
"ava": {
|
70
|
-
"extensions": [
|
71
|
-
|
70
|
+
"extensions": [
|
71
|
+
"ts"
|
72
|
+
],
|
73
|
+
"require": [
|
74
|
+
"ts-node/register"
|
75
|
+
]
|
72
76
|
}
|
73
77
|
}
|
package/src/index.ts
CHANGED
@@ -154,6 +154,46 @@ export function isRegExp (payload: any): payload is RegExp {
|
|
154
154
|
return getType(payload) === 'RegExp'
|
155
155
|
}
|
156
156
|
|
157
|
+
/**
|
158
|
+
* Returns whether the payload is a Map
|
159
|
+
*
|
160
|
+
* @param {*} payload
|
161
|
+
* @returns {payload is Map}
|
162
|
+
*/
|
163
|
+
export function isMap (payload: any): payload is Map<any, any> {
|
164
|
+
return getType(payload) === 'Map'
|
165
|
+
}
|
166
|
+
|
167
|
+
/**
|
168
|
+
* Returns whether the payload is a WeakMap
|
169
|
+
*
|
170
|
+
* @param {*} payload
|
171
|
+
* @returns {payload is WeakMap}
|
172
|
+
*/
|
173
|
+
export function isWeakMap (payload: any): payload is WeakMap<any, any> {
|
174
|
+
return getType(payload) === 'WeakMap'
|
175
|
+
}
|
176
|
+
|
177
|
+
/**
|
178
|
+
* Returns whether the payload is a Set
|
179
|
+
*
|
180
|
+
* @param {*} payload
|
181
|
+
* @returns {payload is Set}
|
182
|
+
*/
|
183
|
+
export function isSet (payload: any): payload is Set<any> {
|
184
|
+
return getType(payload) === 'Set'
|
185
|
+
}
|
186
|
+
|
187
|
+
/**
|
188
|
+
* Returns whether the payload is a WeakSet
|
189
|
+
*
|
190
|
+
* @param {*} payload
|
191
|
+
* @returns {payload is WeakSet}
|
192
|
+
*/
|
193
|
+
export function isWeakSet (payload: any): payload is WeakSet<any> {
|
194
|
+
return getType(payload) === 'WeakSet'
|
195
|
+
}
|
196
|
+
|
157
197
|
/**
|
158
198
|
* Returns whether the payload is a Symbol
|
159
199
|
*
|
package/test/ava.ts
CHANGED
@@ -19,6 +19,10 @@ import {
|
|
19
19
|
isSymbol,
|
20
20
|
isPrimitive,
|
21
21
|
isType,
|
22
|
+
isMap,
|
23
|
+
isWeakMap,
|
24
|
+
isSet,
|
25
|
+
isWeakSet,
|
22
26
|
// isBlob,
|
23
27
|
// isFile,
|
24
28
|
isPromise,
|
@@ -52,6 +56,10 @@ test('Basic true tests', t => {
|
|
52
56
|
t.is(isNumber(1), true)
|
53
57
|
t.is(isDate(new Date()), true)
|
54
58
|
t.is(isSymbol(Symbol()), true)
|
59
|
+
t.is(isMap(new Map()), true)
|
60
|
+
t.is(isWeakMap(new WeakMap()), true)
|
61
|
+
t.is(isSet(new Set()), true)
|
62
|
+
t.is(isWeakSet(new WeakSet()), true)
|
55
63
|
// t.is(isBlob(blob), true)
|
56
64
|
// t.is(isFile(new File([''], '', { type: 'text/html' })), true)
|
57
65
|
t.is(isPromise(new Promise((resolve, reject) => {})), true)
|
@@ -73,6 +81,10 @@ test('Basic false tests', t => {
|
|
73
81
|
t.is(isBoolean(NaN), false)
|
74
82
|
t.is(isRegExp(NaN), false)
|
75
83
|
t.is(isSymbol(NaN), false)
|
84
|
+
t.is(isMap(new WeakMap()), false)
|
85
|
+
t.is(isWeakMap(new Map()), false)
|
86
|
+
t.is(isSet(new WeakSet()), false)
|
87
|
+
t.is(isWeakSet(new Set()), false)
|
76
88
|
t.is(isNullOrUndefined(NaN), false)
|
77
89
|
})
|
78
90
|
|
package/types/index.d.ts
CHANGED
@@ -114,6 +114,34 @@ export declare function isBoolean(payload: any): payload is boolean;
|
|
114
114
|
* @returns {payload is RegExp}
|
115
115
|
*/
|
116
116
|
export declare function isRegExp(payload: any): payload is RegExp;
|
117
|
+
/**
|
118
|
+
* Returns whether the payload is a Map
|
119
|
+
*
|
120
|
+
* @param {*} payload
|
121
|
+
* @returns {payload is Map}
|
122
|
+
*/
|
123
|
+
export declare function isMap(payload: any): payload is Map<any, any>;
|
124
|
+
/**
|
125
|
+
* Returns whether the payload is a WeakMap
|
126
|
+
*
|
127
|
+
* @param {*} payload
|
128
|
+
* @returns {payload is WeakMap}
|
129
|
+
*/
|
130
|
+
export declare function isWeakMap(payload: any): payload is WeakMap<any, any>;
|
131
|
+
/**
|
132
|
+
* Returns whether the payload is a Set
|
133
|
+
*
|
134
|
+
* @param {*} payload
|
135
|
+
* @returns {payload is Set}
|
136
|
+
*/
|
137
|
+
export declare function isSet(payload: any): payload is Set<any>;
|
138
|
+
/**
|
139
|
+
* Returns whether the payload is a WeakSet
|
140
|
+
*
|
141
|
+
* @param {*} payload
|
142
|
+
* @returns {payload is WeakSet}
|
143
|
+
*/
|
144
|
+
export declare function isWeakSet(payload: any): payload is WeakSet<any>;
|
117
145
|
/**
|
118
146
|
* Returns whether the payload is a Symbol
|
119
147
|
*
|