@hypernym/utils 0.1.0 → 0.2.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/dist/utils.d.ts +10 -2
- package/dist/utils.mjs +3 -1
- package/package.json +5 -4
package/dist/utils.d.ts
CHANGED
|
@@ -112,10 +112,18 @@ declare const isElement: (v: any) => v is Element;
|
|
|
112
112
|
* Returns a boolean if the given value is a `NodeList`.
|
|
113
113
|
*/
|
|
114
114
|
declare const isNodeList: (v: any) => v is NodeList;
|
|
115
|
+
/**
|
|
116
|
+
* Returns a boolean if the given value is an empty `NodeList`.
|
|
117
|
+
*/
|
|
118
|
+
declare const isNodeListEmpty: (v: any) => v is NodeList;
|
|
115
119
|
/**
|
|
116
120
|
* Returns a boolean if the given value is a `HTMLCollection`.
|
|
117
121
|
*/
|
|
118
122
|
declare const isHtmlCollection: (v: any) => v is HTMLCollection;
|
|
123
|
+
/**
|
|
124
|
+
* Returns a boolean if the given value is an empty `HTMLCollection`.
|
|
125
|
+
*/
|
|
126
|
+
declare const isHtmlCollectionEmpty: (v: any) => v is HTMLCollection;
|
|
119
127
|
|
|
120
128
|
/**
|
|
121
129
|
* Returns a boolean if the given type is a `null`.
|
|
@@ -146,7 +154,7 @@ type OptionsDeep = {
|
|
|
146
154
|
*/
|
|
147
155
|
type PartialDeep<T, Options extends OptionsDeep = {
|
|
148
156
|
arrays: true;
|
|
149
|
-
}> = T extends BuiltIn ? T : T extends Map<infer K, infer V> ? Map<PartialDeep<K, Options>, PartialDeep<V, Options>> : T extends ReadonlyMap<infer K, infer V> ? ReadonlyMap<PartialDeep<K, Options>, PartialDeep<V, Options>> : T extends WeakMap<infer K, infer V> ? WeakMap<PartialDeep<K, Options>, PartialDeep<V, Options>> : T extends Set<infer V> ? Set<PartialDeep<V, Options>> : T extends ReadonlySet<infer V> ? ReadonlySet<PartialDeep<V, Options>> : T extends WeakSet<infer V> ? WeakSet<PartialDeep<V, Options>> : T extends Promise<infer V> ? Promise<PartialDeep<V, Options>> : T extends (...args: any[]) => unknown ? T | undefined : T extends object ? T extends ReadonlyArray<infer V> ? Options['arrays'] extends true ? V[] extends T ? readonly V[] extends T ? ReadonlyArray<PartialDeep<V
|
|
157
|
+
}> = T extends BuiltIn ? T | undefined : T extends Map<infer K, infer V> ? Map<PartialDeep<K, Options>, PartialDeep<V, Options>> : T extends ReadonlyMap<infer K, infer V> ? ReadonlyMap<PartialDeep<K, Options>, PartialDeep<V, Options>> : T extends WeakMap<infer K, infer V> ? WeakMap<PartialDeep<K, Options>, PartialDeep<V, Options>> : T extends Set<infer V> ? Set<PartialDeep<V, Options>> : T extends ReadonlySet<infer V> ? ReadonlySet<PartialDeep<V, Options>> : T extends WeakSet<infer V> ? WeakSet<PartialDeep<V, Options>> : T extends Promise<infer V> ? Promise<PartialDeep<V, Options>> : T extends (...args: any[]) => unknown ? T | undefined : T extends object ? T extends ReadonlyArray<infer V> ? Options['arrays'] extends true ? V[] extends T ? readonly V[] extends T ? ReadonlyArray<PartialDeep<V, Options>> : Array<PartialDeep<V, Options>> : PartialObjectDeep<T, Options> : T | undefined : PartialObjectDeep<T, Options> : unknown;
|
|
150
158
|
type PartialObjectDeep<T extends object, Options extends OptionsDeep = {
|
|
151
159
|
arrays: true;
|
|
152
160
|
}> = {
|
|
@@ -167,4 +175,4 @@ type RequiredObjectDeep<T extends object, Options extends OptionsDeep = {
|
|
|
167
175
|
[K in keyof T]-?: RequiredDeep<T[K], Options>;
|
|
168
176
|
};
|
|
169
177
|
|
|
170
|
-
export { BuiltIn, IsAny, IsNever, IsNull, PartialDeep, Primitive, RequiredDeep, isArray, isArrayEmpty, isBigint, isBoolean, isClient, isDate, isElement, isError, isFunction, isHtmlCollection, isInfinity, isMap, isNaNValue, isNodeList, isNull, isNumber, isObject, isObjectEmpty, isPrimitive, isRegExp, isSet, isString, isStringEmpty, isSymbol, isURL, isUndefined, noop };
|
|
178
|
+
export { BuiltIn, IsAny, IsNever, IsNull, PartialDeep, Primitive, RequiredDeep, isArray, isArrayEmpty, isBigint, isBoolean, isClient, isDate, isElement, isError, isFunction, isHtmlCollection, isHtmlCollectionEmpty, isInfinity, isMap, isNaNValue, isNodeList, isNodeListEmpty, isNull, isNumber, isObject, isObjectEmpty, isPrimitive, isRegExp, isSet, isString, isStringEmpty, isSymbol, isURL, isUndefined, noop };
|
package/dist/utils.mjs
CHANGED
|
@@ -26,6 +26,8 @@ const isError = (v) => v instanceof Error;
|
|
|
26
26
|
const isPrimitive = (v) => isString(v) || isNumber(v) || isBigint(v) || isBoolean(v) || isSymbol(v) || isNull(v) || isUndefined(v);
|
|
27
27
|
const isElement = (v) => v instanceof Element;
|
|
28
28
|
const isNodeList = (v) => v instanceof NodeList;
|
|
29
|
+
const isNodeListEmpty = (v) => isNodeList(v) && v.length === 0;
|
|
29
30
|
const isHtmlCollection = (v) => v instanceof HTMLCollection;
|
|
31
|
+
const isHtmlCollectionEmpty = (v) => isHtmlCollection(v) && v.length === 0;
|
|
30
32
|
|
|
31
|
-
export { isArray, isArrayEmpty, isBigint, isBoolean, isClient, isDate, isElement, isError, isFunction, isHtmlCollection, isInfinity, isMap, isNaNValue, isNodeList, isNull, isNumber, isObject, isObjectEmpty, isPrimitive, isRegExp, isSet, isString, isStringEmpty, isSymbol, isURL, isUndefined, noop };
|
|
33
|
+
export { isArray, isArrayEmpty, isBigint, isBoolean, isClient, isDate, isElement, isError, isFunction, isHtmlCollection, isHtmlCollectionEmpty, isInfinity, isMap, isNaNValue, isNodeList, isNodeListEmpty, isNull, isNumber, isObject, isObjectEmpty, isPrimitive, isRegExp, isSet, isString, isStringEmpty, isSymbol, isURL, isUndefined, noop };
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@hypernym/utils",
|
|
3
|
-
"version": "0.1
|
|
3
|
+
"version": "0.2.1",
|
|
4
4
|
"author": "Hypernym Studio",
|
|
5
5
|
"description": "A collection of reusable utilities.",
|
|
6
6
|
"license": "MIT",
|
|
@@ -37,11 +37,12 @@
|
|
|
37
37
|
"fix": "eslint --fix ."
|
|
38
38
|
},
|
|
39
39
|
"devDependencies": {
|
|
40
|
-
"@types/node": "^20.2.
|
|
41
|
-
"@typescript-eslint/eslint-plugin": "^5.59.
|
|
42
|
-
"@typescript-eslint/parser": "^5.59.
|
|
40
|
+
"@types/node": "^20.2.5",
|
|
41
|
+
"@typescript-eslint/eslint-plugin": "^5.59.8",
|
|
42
|
+
"@typescript-eslint/parser": "^5.59.8",
|
|
43
43
|
"eslint": "^8.41.0",
|
|
44
44
|
"eslint-config-prettier": "^8.8.0",
|
|
45
|
+
"expect-type": "^0.16.0",
|
|
45
46
|
"prettier": "^2.8.8",
|
|
46
47
|
"rollup": "^3.23.0",
|
|
47
48
|
"rollup-plugin-dts": "^5.3.0",
|