is-what 4.1.16 → 5.0.1
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/README.md +7 -7
- package/dist/getType.d.ts +2 -0
- package/dist/getType.js +4 -0
- package/dist/index.d.ts +41 -380
- package/dist/index.js +37 -171
- package/dist/isAnyObject.d.ts +6 -0
- package/dist/isAnyObject.js +8 -0
- package/dist/isArray.d.ts +2 -0
- package/dist/isArray.js +5 -0
- package/dist/isBlob.d.ts +2 -0
- package/dist/isBlob.js +5 -0
- package/dist/isBoolean.d.ts +2 -0
- package/dist/isBoolean.js +5 -0
- package/dist/isDate.d.ts +2 -0
- package/dist/isDate.js +5 -0
- package/dist/isEmptyArray.d.ts +2 -0
- package/dist/isEmptyArray.js +5 -0
- package/dist/isEmptyObject.d.ts +7 -0
- package/dist/isEmptyObject.js +8 -0
- package/dist/isEmptyString.d.ts +2 -0
- package/dist/isEmptyString.js +4 -0
- package/dist/isError.d.ts +2 -0
- package/dist/isError.js +5 -0
- package/dist/isFile.d.ts +2 -0
- package/dist/isFile.js +5 -0
- package/dist/isFullArray.d.ts +2 -0
- package/dist/isFullArray.js +5 -0
- package/dist/isFullObject.d.ts +6 -0
- package/dist/isFullObject.js +8 -0
- package/dist/isFullString.d.ts +2 -0
- package/dist/isFullString.js +5 -0
- package/dist/isFunction.d.ts +3 -0
- package/dist/isFunction.js +4 -0
- package/dist/isInstanceOf.d.ts +23 -0
- package/dist/isInstanceOf.js +20 -0
- package/dist/isMap.d.ts +2 -0
- package/dist/isMap.js +5 -0
- package/dist/isNaNValue.d.ts +2 -0
- package/dist/isNaNValue.js +5 -0
- package/dist/isNegativeNumber.d.ts +2 -0
- package/dist/isNegativeNumber.js +5 -0
- package/dist/isNull.d.ts +2 -0
- package/dist/isNull.js +5 -0
- package/dist/isNullOrUndefined.d.ts +2 -0
- package/dist/isNullOrUndefined.js +5 -0
- package/dist/isNumber.d.ts +6 -0
- package/dist/isNumber.js +9 -0
- package/dist/isObject.d.ts +6 -0
- package/dist/isObject.js +8 -0
- package/dist/isObjectLike.d.ts +9 -0
- package/dist/isObjectLike.js +11 -0
- package/dist/isOneOf.d.ts +54 -0
- package/dist/isOneOf.js +15 -0
- package/dist/isPlainObject.d.ts +8 -0
- package/dist/isPlainObject.js +11 -0
- package/dist/isPositiveNumber.d.ts +2 -0
- package/dist/isPositiveNumber.js +5 -0
- package/dist/isPrimitive.d.ts +6 -0
- package/dist/isPrimitive.js +19 -0
- package/dist/isPromise.d.ts +2 -0
- package/dist/isPromise.js +5 -0
- package/dist/isRegExp.d.ts +2 -0
- package/dist/isRegExp.js +5 -0
- package/dist/isSet.d.ts +2 -0
- package/dist/isSet.js +5 -0
- package/dist/isString.d.ts +2 -0
- package/dist/isString.js +5 -0
- package/dist/isSymbol.d.ts +2 -0
- package/dist/isSymbol.js +5 -0
- package/dist/isType.d.ts +10 -0
- package/dist/isType.js +19 -0
- package/dist/isUndefined.d.ts +2 -0
- package/dist/isUndefined.js +5 -0
- package/dist/isWeakMap.d.ts +2 -0
- package/dist/isWeakMap.js +5 -0
- package/dist/isWeakSet.d.ts +2 -0
- package/dist/isWeakSet.js +5 -0
- package/package.json +22 -88
- package/dist/cjs/index.cjs +0 -209
- package/dist/cjs/index.d.cts +0 -380
package/package.json
CHANGED
@@ -1,41 +1,34 @@
|
|
1
1
|
{
|
2
2
|
"name": "is-what",
|
3
|
-
"version": "
|
3
|
+
"version": "5.0.1",
|
4
4
|
"description": "JS type check (TypeScript supported) functions like `isPlainObject() isArray()` etc. A simple & small integration.",
|
5
5
|
"type": "module",
|
6
6
|
"sideEffects": false,
|
7
|
-
"types": "./dist/index.d.ts",
|
8
|
-
"module": "./dist/index.js",
|
9
|
-
"main": "./dist/index.js",
|
10
7
|
"exports": {
|
11
|
-
".":
|
12
|
-
|
13
|
-
"types": "./dist/cjs/index.d.cts",
|
14
|
-
"default": "./dist/cjs/index.cjs"
|
15
|
-
},
|
16
|
-
"import": {
|
17
|
-
"types": "./dist/index.d.ts",
|
18
|
-
"default": "./dist/index.js"
|
19
|
-
}
|
20
|
-
}
|
8
|
+
".": "./dist/index.js",
|
9
|
+
"./*": "./dist/*"
|
21
10
|
},
|
22
|
-
"files": [
|
23
|
-
"dist"
|
24
|
-
],
|
25
11
|
"engines": {
|
26
|
-
"node": ">=
|
12
|
+
"node": ">=18"
|
27
13
|
},
|
28
14
|
"scripts": {
|
29
15
|
"test": "vitest run",
|
30
|
-
"lint": "tsc --noEmit && eslint ./src
|
31
|
-
"build": "
|
16
|
+
"lint": "tsc --noEmit && eslint ./src",
|
17
|
+
"build": "del-cli dist && tsc",
|
32
18
|
"build:docs": "typedoc",
|
33
|
-
"release": "npm run lint &&
|
19
|
+
"release": "npm run lint && npm run build && np"
|
34
20
|
},
|
35
|
-
"
|
36
|
-
"
|
37
|
-
"
|
21
|
+
"devDependencies": {
|
22
|
+
"@cycraft/eslint": "^0.3.0",
|
23
|
+
"@cycraft/tsconfig": "^0.1.2",
|
24
|
+
"del-cli": "^5.1.0",
|
25
|
+
"np": "^10.0.5",
|
26
|
+
"typedoc": "^0.25.13",
|
27
|
+
"vitest": "^1.6.0"
|
38
28
|
},
|
29
|
+
"files": [
|
30
|
+
"dist"
|
31
|
+
],
|
39
32
|
"keywords": [
|
40
33
|
"javascript",
|
41
34
|
"typescript",
|
@@ -57,72 +50,13 @@
|
|
57
50
|
"is-plain-obj",
|
58
51
|
"is-plain-object"
|
59
52
|
],
|
60
|
-
"author": "Luca Ban - Mesqueeb",
|
53
|
+
"author": "Luca Ban - Mesqueeb (https://cycraft.co)",
|
61
54
|
"funding": "https://github.com/sponsors/mesqueeb",
|
62
55
|
"license": "MIT",
|
63
|
-
"
|
64
|
-
"
|
56
|
+
"repository": {
|
57
|
+
"type": "git",
|
58
|
+
"url": "https://github.com/mesqueeb/is-what.git"
|
65
59
|
},
|
66
60
|
"homepage": "https://github.com/mesqueeb/is-what#readme",
|
67
|
-
"
|
68
|
-
"@typescript-eslint/eslint-plugin": "^5.62.0",
|
69
|
-
"@typescript-eslint/parser": "^5.62.0",
|
70
|
-
"del-cli": "^5.1.0",
|
71
|
-
"eslint-config-prettier": "^8.10.0",
|
72
|
-
"eslint-plugin-tree-shaking": "^1.10.1",
|
73
|
-
"eslint": "^8.52.0",
|
74
|
-
"np": "^8.0.4",
|
75
|
-
"prettier-plugin-jsdoc": "^0.4.2",
|
76
|
-
"prettier": "^2.8.8",
|
77
|
-
"rollup-plugin-dts": "^5.3.1",
|
78
|
-
"rollup-plugin-esbuild": "^5.0.0",
|
79
|
-
"rollup": "^3.29.4",
|
80
|
-
"typedoc": "^0.25.2",
|
81
|
-
"typescript": "^5.2.2",
|
82
|
-
"vitest": "^0.34.6"
|
83
|
-
},
|
84
|
-
"np": {
|
85
|
-
"branch": "production",
|
86
|
-
"publish": false,
|
87
|
-
"yarn": false
|
88
|
-
},
|
89
|
-
"eslintConfig": {
|
90
|
-
"ignorePatterns": [
|
91
|
-
"node_modules",
|
92
|
-
"dist",
|
93
|
-
"scripts",
|
94
|
-
"test"
|
95
|
-
],
|
96
|
-
"root": true,
|
97
|
-
"parser": "@typescript-eslint/parser",
|
98
|
-
"plugins": [
|
99
|
-
"@typescript-eslint",
|
100
|
-
"tree-shaking"
|
101
|
-
],
|
102
|
-
"extends": [
|
103
|
-
"eslint:recommended",
|
104
|
-
"plugin:@typescript-eslint/eslint-recommended",
|
105
|
-
"plugin:@typescript-eslint/recommended",
|
106
|
-
"prettier"
|
107
|
-
],
|
108
|
-
"rules": {
|
109
|
-
"@typescript-eslint/no-empty-function": "off",
|
110
|
-
"@typescript-eslint/no-explicit-any": "off",
|
111
|
-
"@typescript-eslint/ban-ts-ignore": "off",
|
112
|
-
"tree-shaking/no-side-effects-in-initialization": "error",
|
113
|
-
"@typescript-eslint/ban-ts-comment": "off"
|
114
|
-
}
|
115
|
-
},
|
116
|
-
"prettier": {
|
117
|
-
"printWidth": 100,
|
118
|
-
"tabWidth": 2,
|
119
|
-
"singleQuote": true,
|
120
|
-
"trailingComma": "es5",
|
121
|
-
"semi": false,
|
122
|
-
"bracketSpacing": true,
|
123
|
-
"quoteProps": "consistent",
|
124
|
-
"plugins": [
|
125
|
-
"prettier-plugin-jsdoc"
|
126
|
-
]
|
127
|
-
}
|
61
|
+
"bugs": "https://github.com/mesqueeb/is-what/issues"
|
128
62
|
}
|
package/dist/cjs/index.cjs
DELETED
@@ -1,209 +0,0 @@
|
|
1
|
-
'use strict';
|
2
|
-
|
3
|
-
function getType(payload) {
|
4
|
-
return Object.prototype.toString.call(payload).slice(8, -1);
|
5
|
-
}
|
6
|
-
|
7
|
-
function isAnyObject(payload) {
|
8
|
-
return getType(payload) === "Object";
|
9
|
-
}
|
10
|
-
|
11
|
-
function isArray(payload) {
|
12
|
-
return getType(payload) === "Array";
|
13
|
-
}
|
14
|
-
|
15
|
-
function isBlob(payload) {
|
16
|
-
return getType(payload) === "Blob";
|
17
|
-
}
|
18
|
-
|
19
|
-
function isBoolean(payload) {
|
20
|
-
return getType(payload) === "Boolean";
|
21
|
-
}
|
22
|
-
|
23
|
-
function isDate(payload) {
|
24
|
-
return getType(payload) === "Date" && !isNaN(payload);
|
25
|
-
}
|
26
|
-
|
27
|
-
function isEmptyArray(payload) {
|
28
|
-
return isArray(payload) && payload.length === 0;
|
29
|
-
}
|
30
|
-
|
31
|
-
function isPlainObject(payload) {
|
32
|
-
if (getType(payload) !== "Object")
|
33
|
-
return false;
|
34
|
-
const prototype = Object.getPrototypeOf(payload);
|
35
|
-
return !!prototype && prototype.constructor === Object && prototype === Object.prototype;
|
36
|
-
}
|
37
|
-
|
38
|
-
function isEmptyObject(payload) {
|
39
|
-
return isPlainObject(payload) && Object.keys(payload).length === 0;
|
40
|
-
}
|
41
|
-
|
42
|
-
function isEmptyString(payload) {
|
43
|
-
return payload === "";
|
44
|
-
}
|
45
|
-
|
46
|
-
function isError(payload) {
|
47
|
-
return getType(payload) === "Error" || payload instanceof Error;
|
48
|
-
}
|
49
|
-
|
50
|
-
function isFile(payload) {
|
51
|
-
return getType(payload) === "File";
|
52
|
-
}
|
53
|
-
|
54
|
-
function isFullArray(payload) {
|
55
|
-
return isArray(payload) && payload.length > 0;
|
56
|
-
}
|
57
|
-
|
58
|
-
function isFullObject(payload) {
|
59
|
-
return isPlainObject(payload) && Object.keys(payload).length > 0;
|
60
|
-
}
|
61
|
-
|
62
|
-
function isString(payload) {
|
63
|
-
return getType(payload) === "String";
|
64
|
-
}
|
65
|
-
|
66
|
-
function isFullString(payload) {
|
67
|
-
return isString(payload) && payload !== "";
|
68
|
-
}
|
69
|
-
|
70
|
-
function isFunction(payload) {
|
71
|
-
return typeof payload === "function";
|
72
|
-
}
|
73
|
-
|
74
|
-
function isType(payload, type) {
|
75
|
-
if (!(type instanceof Function)) {
|
76
|
-
throw new TypeError("Type must be a function");
|
77
|
-
}
|
78
|
-
if (!Object.prototype.hasOwnProperty.call(type, "prototype")) {
|
79
|
-
throw new TypeError("Type is not a class");
|
80
|
-
}
|
81
|
-
const name = type.name;
|
82
|
-
return getType(payload) === name || Boolean(payload && payload.constructor === type);
|
83
|
-
}
|
84
|
-
|
85
|
-
function isInstanceOf(value, classOrClassName) {
|
86
|
-
if (typeof classOrClassName === "function") {
|
87
|
-
for (let p = value; p; p = Object.getPrototypeOf(p)) {
|
88
|
-
if (isType(p, classOrClassName)) {
|
89
|
-
return true;
|
90
|
-
}
|
91
|
-
}
|
92
|
-
return false;
|
93
|
-
} else {
|
94
|
-
for (let p = value; p; p = Object.getPrototypeOf(p)) {
|
95
|
-
if (getType(p) === classOrClassName) {
|
96
|
-
return true;
|
97
|
-
}
|
98
|
-
}
|
99
|
-
return false;
|
100
|
-
}
|
101
|
-
}
|
102
|
-
|
103
|
-
function isMap(payload) {
|
104
|
-
return getType(payload) === "Map";
|
105
|
-
}
|
106
|
-
|
107
|
-
function isNaNValue(payload) {
|
108
|
-
return getType(payload) === "Number" && isNaN(payload);
|
109
|
-
}
|
110
|
-
|
111
|
-
function isNumber(payload) {
|
112
|
-
return getType(payload) === "Number" && !isNaN(payload);
|
113
|
-
}
|
114
|
-
|
115
|
-
function isNegativeNumber(payload) {
|
116
|
-
return isNumber(payload) && payload < 0;
|
117
|
-
}
|
118
|
-
|
119
|
-
function isNull(payload) {
|
120
|
-
return getType(payload) === "Null";
|
121
|
-
}
|
122
|
-
|
123
|
-
function isOneOf(a, b, c, d, e) {
|
124
|
-
return (value) => a(value) || b(value) || !!c && c(value) || !!d && d(value) || !!e && e(value);
|
125
|
-
}
|
126
|
-
|
127
|
-
function isUndefined(payload) {
|
128
|
-
return getType(payload) === "Undefined";
|
129
|
-
}
|
130
|
-
|
131
|
-
const isNullOrUndefined = isOneOf(isNull, isUndefined);
|
132
|
-
|
133
|
-
function isObject(payload) {
|
134
|
-
return isPlainObject(payload);
|
135
|
-
}
|
136
|
-
|
137
|
-
function isObjectLike(payload) {
|
138
|
-
return isAnyObject(payload);
|
139
|
-
}
|
140
|
-
|
141
|
-
function isPositiveNumber(payload) {
|
142
|
-
return isNumber(payload) && payload > 0;
|
143
|
-
}
|
144
|
-
|
145
|
-
function isSymbol(payload) {
|
146
|
-
return getType(payload) === "Symbol";
|
147
|
-
}
|
148
|
-
|
149
|
-
function isPrimitive(payload) {
|
150
|
-
return isBoolean(payload) || isNull(payload) || isUndefined(payload) || isNumber(payload) || isString(payload) || isSymbol(payload);
|
151
|
-
}
|
152
|
-
|
153
|
-
function isPromise(payload) {
|
154
|
-
return getType(payload) === "Promise";
|
155
|
-
}
|
156
|
-
|
157
|
-
function isRegExp(payload) {
|
158
|
-
return getType(payload) === "RegExp";
|
159
|
-
}
|
160
|
-
|
161
|
-
function isSet(payload) {
|
162
|
-
return getType(payload) === "Set";
|
163
|
-
}
|
164
|
-
|
165
|
-
function isWeakMap(payload) {
|
166
|
-
return getType(payload) === "WeakMap";
|
167
|
-
}
|
168
|
-
|
169
|
-
function isWeakSet(payload) {
|
170
|
-
return getType(payload) === "WeakSet";
|
171
|
-
}
|
172
|
-
|
173
|
-
exports.getType = getType;
|
174
|
-
exports.isAnyObject = isAnyObject;
|
175
|
-
exports.isArray = isArray;
|
176
|
-
exports.isBlob = isBlob;
|
177
|
-
exports.isBoolean = isBoolean;
|
178
|
-
exports.isDate = isDate;
|
179
|
-
exports.isEmptyArray = isEmptyArray;
|
180
|
-
exports.isEmptyObject = isEmptyObject;
|
181
|
-
exports.isEmptyString = isEmptyString;
|
182
|
-
exports.isError = isError;
|
183
|
-
exports.isFile = isFile;
|
184
|
-
exports.isFullArray = isFullArray;
|
185
|
-
exports.isFullObject = isFullObject;
|
186
|
-
exports.isFullString = isFullString;
|
187
|
-
exports.isFunction = isFunction;
|
188
|
-
exports.isInstanceOf = isInstanceOf;
|
189
|
-
exports.isMap = isMap;
|
190
|
-
exports.isNaNValue = isNaNValue;
|
191
|
-
exports.isNegativeNumber = isNegativeNumber;
|
192
|
-
exports.isNull = isNull;
|
193
|
-
exports.isNullOrUndefined = isNullOrUndefined;
|
194
|
-
exports.isNumber = isNumber;
|
195
|
-
exports.isObject = isObject;
|
196
|
-
exports.isObjectLike = isObjectLike;
|
197
|
-
exports.isOneOf = isOneOf;
|
198
|
-
exports.isPlainObject = isPlainObject;
|
199
|
-
exports.isPositiveNumber = isPositiveNumber;
|
200
|
-
exports.isPrimitive = isPrimitive;
|
201
|
-
exports.isPromise = isPromise;
|
202
|
-
exports.isRegExp = isRegExp;
|
203
|
-
exports.isSet = isSet;
|
204
|
-
exports.isString = isString;
|
205
|
-
exports.isSymbol = isSymbol;
|
206
|
-
exports.isType = isType;
|
207
|
-
exports.isUndefined = isUndefined;
|
208
|
-
exports.isWeakMap = isWeakMap;
|
209
|
-
exports.isWeakSet = isWeakSet;
|