is-what 3.10.0 → 3.11.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.cjs.js +10 -0
- package/dist/index.esm.js +10 -1
- package/package.json +20 -15
- package/src/index.ts +10 -0
- package/test/ava.ts +19 -0
- package/tsconfig.json +1 -0
- package/types/index.d.ts +7 -0
package/dist/index.cjs.js
CHANGED
@@ -97,6 +97,15 @@ function isFunction(payload) {
|
|
97
97
|
function isArray(payload) {
|
98
98
|
return getType(payload) === 'Array';
|
99
99
|
}
|
100
|
+
/**
|
101
|
+
* Returns whether the payload is a an empty array
|
102
|
+
*
|
103
|
+
* @param {*} payload
|
104
|
+
* @returns {payload is []}
|
105
|
+
*/
|
106
|
+
function isEmptyArray(payload) {
|
107
|
+
return isArray(payload) && payload.length === 0;
|
108
|
+
}
|
100
109
|
/**
|
101
110
|
* Returns whether the payload is a string
|
102
111
|
*
|
@@ -304,6 +313,7 @@ exports.isArray = isArray;
|
|
304
313
|
exports.isBlob = isBlob;
|
305
314
|
exports.isBoolean = isBoolean;
|
306
315
|
exports.isDate = isDate;
|
316
|
+
exports.isEmptyArray = isEmptyArray;
|
307
317
|
exports.isEmptyObject = isEmptyObject;
|
308
318
|
exports.isEmptyString = isEmptyString;
|
309
319
|
exports.isError = isError;
|
package/dist/index.esm.js
CHANGED
@@ -93,6 +93,15 @@ function isFunction(payload) {
|
|
93
93
|
function isArray(payload) {
|
94
94
|
return getType(payload) === 'Array';
|
95
95
|
}
|
96
|
+
/**
|
97
|
+
* Returns whether the payload is a an empty array
|
98
|
+
*
|
99
|
+
* @param {*} payload
|
100
|
+
* @returns {payload is []}
|
101
|
+
*/
|
102
|
+
function isEmptyArray(payload) {
|
103
|
+
return isArray(payload) && payload.length === 0;
|
104
|
+
}
|
96
105
|
/**
|
97
106
|
* Returns whether the payload is a string
|
98
107
|
*
|
@@ -294,4 +303,4 @@ function isType(payload, type) {
|
|
294
303
|
return getType(payload) === name || Boolean(payload && payload.constructor === type);
|
295
304
|
}
|
296
305
|
|
297
|
-
export { getType, isAnyObject, isArray, isBlob, isBoolean, isDate, isEmptyObject, isEmptyString, isError, isFile, isFullString, isFunction, isMap, isNaNValue, isNull, isNullOrUndefined, isNumber, isObject, isObjectLike, isPlainObject, isPrimitive, isPromise, isRegExp, isSet, isString, isSymbol, isType, isUndefined, isWeakMap, isWeakSet };
|
306
|
+
export { getType, isAnyObject, isArray, isBlob, isBoolean, isDate, isEmptyArray, isEmptyObject, isEmptyString, isError, isFile, isFullString, isFunction, isMap, isNaNValue, 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.11.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,28 +47,33 @@
|
|
47
47
|
"homepage": "https://github.com/mesqueeb/is-what#readme",
|
48
48
|
"dependencies": {},
|
49
49
|
"devDependencies": {
|
50
|
-
"@babel/core": "^7.
|
50
|
+
"@babel/core": "^7.11.0",
|
51
51
|
"@types/babel-core": "^6.25.6",
|
52
|
-
"@types/jest": "^25.2.
|
53
|
-
"@typescript-eslint/eslint-plugin": "^2.
|
54
|
-
"@typescript-eslint/parser": "^2.
|
55
|
-
"ava": "^3.
|
52
|
+
"@types/jest": "^25.2.3",
|
53
|
+
"@typescript-eslint/eslint-plugin": "^2.34.0",
|
54
|
+
"@typescript-eslint/parser": "^2.34.0",
|
55
|
+
"ava": "^3.11.0",
|
56
56
|
"babel-core": "^7.0.0-bridge.0",
|
57
|
-
"babel-jest": "^25.
|
57
|
+
"babel-jest": "^25.5.1",
|
58
58
|
"babel-preset-env": "^1.7.0",
|
59
59
|
"eslint": "^6.8.0",
|
60
|
-
"eslint-config-prettier": "^6.
|
60
|
+
"eslint-config-prettier": "^6.11.0",
|
61
61
|
"eslint-plugin-tree-shaking": "^1.8.0",
|
62
|
-
"jest": "^25.
|
63
|
-
"regenerator-runtime": "^0.13.
|
62
|
+
"jest": "^25.5.4",
|
63
|
+
"regenerator-runtime": "^0.13.7",
|
64
64
|
"rollup": "^1.32.1",
|
65
|
-
"rollup-plugin-typescript2": "^0.
|
65
|
+
"rollup-plugin-typescript2": "^0.27.1",
|
66
66
|
"tsconfig-paths": "^3.9.0",
|
67
|
-
"ts-node": "^8.
|
68
|
-
"typescript": "^3.
|
67
|
+
"ts-node": "^8.10.2",
|
68
|
+
"typescript": "^3.9.7"
|
69
69
|
},
|
70
70
|
"ava": {
|
71
|
-
"extensions": [
|
72
|
-
|
71
|
+
"extensions": [
|
72
|
+
"ts"
|
73
|
+
],
|
74
|
+
"require": [
|
75
|
+
"tsconfig-paths/register",
|
76
|
+
"ts-node/register"
|
77
|
+
]
|
73
78
|
}
|
74
79
|
}
|
package/src/index.ts
CHANGED
@@ -102,6 +102,16 @@ export function isArray (payload: any): payload is any[] {
|
|
102
102
|
return getType(payload) === 'Array'
|
103
103
|
}
|
104
104
|
|
105
|
+
/**
|
106
|
+
* Returns whether the payload is a an empty array
|
107
|
+
*
|
108
|
+
* @param {*} payload
|
109
|
+
* @returns {payload is []}
|
110
|
+
*/
|
111
|
+
export function isEmptyArray (payload: any): payload is [] {
|
112
|
+
return isArray(payload) && payload.length === 0
|
113
|
+
}
|
114
|
+
|
105
115
|
/**
|
106
116
|
* Returns whether the payload is a string
|
107
117
|
*
|
package/test/ava.ts
CHANGED
@@ -1,6 +1,7 @@
|
|
1
1
|
import test from 'ava'
|
2
2
|
import {
|
3
3
|
isError,
|
4
|
+
isEmptyArray,
|
4
5
|
isObject,
|
5
6
|
isPlainObject,
|
6
7
|
isAnyObject,
|
@@ -107,6 +108,24 @@ test('isEmptyObject', t => {
|
|
107
108
|
t.is(isEmptyObject(new WeakSet()), false)
|
108
109
|
})
|
109
110
|
|
111
|
+
test('isEmptyArray', t => {
|
112
|
+
t.is(isEmptyArray([]), true)
|
113
|
+
t.is(isEmptyArray(new Array()), true)
|
114
|
+
t.is(isEmptyArray(new Array(0)), true)
|
115
|
+
|
116
|
+
t.is(isEmptyArray(new Array(1)), false)
|
117
|
+
t.is(isEmptyArray([undefined]), false)
|
118
|
+
t.is(isEmptyArray(null), false)
|
119
|
+
t.is(isEmptyArray(new Date()), false)
|
120
|
+
t.is(isEmptyArray(new Error('')), false)
|
121
|
+
t.is(isEmptyArray(new Date()), false)
|
122
|
+
t.is(isEmptyArray(Symbol()), false)
|
123
|
+
t.is(isEmptyArray(new Map()), false)
|
124
|
+
t.is(isEmptyArray(new WeakMap()), false)
|
125
|
+
t.is(isEmptyArray(new Set()), false)
|
126
|
+
t.is(isEmptyArray(new WeakSet()), false)
|
127
|
+
})
|
128
|
+
|
110
129
|
test('NaN tests', t => {
|
111
130
|
t.is(isNaNValue(NaN), true)
|
112
131
|
t.is(isNaNValue(new Error('')), false)
|
package/tsconfig.json
CHANGED
package/types/index.d.ts
CHANGED
@@ -77,6 +77,13 @@ export declare function isFunction(payload: any): payload is Function;
|
|
77
77
|
* @returns {payload is undefined}
|
78
78
|
*/
|
79
79
|
export declare function isArray(payload: any): payload is any[];
|
80
|
+
/**
|
81
|
+
* Returns whether the payload is a an empty array
|
82
|
+
*
|
83
|
+
* @param {*} payload
|
84
|
+
* @returns {payload is []}
|
85
|
+
*/
|
86
|
+
export declare function isEmptyArray(payload: any): payload is [];
|
80
87
|
/**
|
81
88
|
* Returns whether the payload is a string
|
82
89
|
*
|