@hypernym/utils 0.2.0 → 0.3.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/README.md +1 -0
- package/dist/utils.d.ts +11 -6
- package/dist/utils.mjs +5 -3
- package/package.json +5 -4
package/README.md
CHANGED
package/dist/utils.d.ts
CHANGED
|
@@ -12,10 +12,6 @@ type BuiltIn = Primitive | Date | RegExp;
|
|
|
12
12
|
* Checks if the code is running in the browser.
|
|
13
13
|
*/
|
|
14
14
|
declare const isClient: boolean;
|
|
15
|
-
/**
|
|
16
|
-
* An empty arrow function that performs no operation.
|
|
17
|
-
*/
|
|
18
|
-
declare const noop: () => void;
|
|
19
15
|
/**
|
|
20
16
|
* Returns a boolean if the given value is a `null`.
|
|
21
17
|
*/
|
|
@@ -154,7 +150,7 @@ type OptionsDeep = {
|
|
|
154
150
|
*/
|
|
155
151
|
type PartialDeep<T, Options extends OptionsDeep = {
|
|
156
152
|
arrays: true;
|
|
157
|
-
}> = 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
|
|
153
|
+
}> = 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;
|
|
158
154
|
type PartialObjectDeep<T extends object, Options extends OptionsDeep = {
|
|
159
155
|
arrays: true;
|
|
160
156
|
}> = {
|
|
@@ -175,4 +171,13 @@ type RequiredObjectDeep<T extends object, Options extends OptionsDeep = {
|
|
|
175
171
|
[K in keyof T]-?: RequiredDeep<T[K], Options>;
|
|
176
172
|
};
|
|
177
173
|
|
|
178
|
-
|
|
174
|
+
/**
|
|
175
|
+
* Returns a high resolution timestamp in milliseconds using the `performance.now()` method.
|
|
176
|
+
*/
|
|
177
|
+
declare const now: number;
|
|
178
|
+
/**
|
|
179
|
+
* An empty arrow function that performs no operation.
|
|
180
|
+
*/
|
|
181
|
+
declare const noop: () => void;
|
|
182
|
+
|
|
183
|
+
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, now };
|
package/dist/utils.mjs
CHANGED
|
@@ -1,7 +1,9 @@
|
|
|
1
|
-
const
|
|
2
|
-
const isClient = typeof window !== "undefined";
|
|
1
|
+
const now = performance.now();
|
|
3
2
|
const noop = () => {
|
|
4
3
|
};
|
|
4
|
+
|
|
5
|
+
const getType = (v) => Object.prototype.toString.call(v).slice(8, -1);
|
|
6
|
+
const isClient = typeof window !== "undefined";
|
|
5
7
|
const isNull = (v) => v === null;
|
|
6
8
|
const isUndefined = (v) => typeof v === "undefined";
|
|
7
9
|
const isString = (v) => typeof v === "string";
|
|
@@ -30,4 +32,4 @@ const isNodeListEmpty = (v) => isNodeList(v) && v.length === 0;
|
|
|
30
32
|
const isHtmlCollection = (v) => v instanceof HTMLCollection;
|
|
31
33
|
const isHtmlCollectionEmpty = (v) => isHtmlCollection(v) && v.length === 0;
|
|
32
34
|
|
|
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 };
|
|
35
|
+
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, now };
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@hypernym/utils",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.3.0",
|
|
4
4
|
"author": "Hypernym Studio",
|
|
5
5
|
"description": "A collection of reusable utilities.",
|
|
6
6
|
"license": "MIT",
|
|
@@ -38,17 +38,18 @@
|
|
|
38
38
|
},
|
|
39
39
|
"devDependencies": {
|
|
40
40
|
"@types/node": "^20.2.5",
|
|
41
|
-
"@typescript-eslint/eslint-plugin": "^5.59.
|
|
42
|
-
"@typescript-eslint/parser": "^5.59.
|
|
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",
|
|
48
49
|
"rollup-plugin-esbuild": "^5.0.0",
|
|
49
50
|
"typescript": "^5.0.4",
|
|
50
51
|
"vite": "^4.3.9",
|
|
51
|
-
"vite-node": "^0.31.
|
|
52
|
+
"vite-node": "^0.31.4"
|
|
52
53
|
},
|
|
53
54
|
"publishConfig": {
|
|
54
55
|
"access": "public"
|