@hypernym/utils 2.1.0 → 2.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/LICENSE.txt +1 -1
- package/README.md +9 -3
- package/dist/index.mjs +7 -1
- package/dist/types/index.d.ts +27 -3
- package/package.json +28 -11
package/LICENSE.txt
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
MIT License
|
|
2
2
|
|
|
3
|
-
Copyright (c)
|
|
3
|
+
Copyright (c) 2024 Ivo Dolenc, Hypernym Studio
|
|
4
4
|
|
|
5
5
|
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
6
|
of this software and associated documentation files (the "Software"), to deal
|
package/README.md
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
#
|
|
1
|
+
# Utils
|
|
2
2
|
|
|
3
3
|
A collection of reusable utilities.
|
|
4
4
|
|
|
@@ -26,11 +26,17 @@ import type { IsAny, RequiredDeep, ... } from '@hypernym/utils'
|
|
|
26
26
|
|
|
27
27
|
## Community
|
|
28
28
|
|
|
29
|
-
Feel free to
|
|
29
|
+
Feel free to ask questions or share new ideas.
|
|
30
|
+
|
|
31
|
+
Use the official [discussions](https://github.com/hypernym-studio/utils/discussions) to get involved.
|
|
32
|
+
|
|
33
|
+
## Contributing
|
|
34
|
+
|
|
35
|
+
Check out the [guide](.github/CONTRIBUTING.md) for more info.
|
|
30
36
|
|
|
31
37
|
## License
|
|
32
38
|
|
|
33
|
-
Developed in 🇭🇷 Croatia
|
|
39
|
+
Developed in 🇭🇷 Croatia.
|
|
34
40
|
|
|
35
41
|
Released under the [MIT](LICENSE.txt) license.
|
|
36
42
|
|
package/dist/index.mjs
CHANGED
|
@@ -8,6 +8,8 @@ const isUndefined = (v) => typeof v === "undefined";
|
|
|
8
8
|
const isString = (v) => typeof v === "string";
|
|
9
9
|
const isStringEmpty = (v) => isString(v) && v.trim().length === 0;
|
|
10
10
|
const isBoolean = (v) => typeof v === "boolean";
|
|
11
|
+
const isTrue = (v) => v === true;
|
|
12
|
+
const isFalse = (v) => v === false;
|
|
11
13
|
const isNumber = (v) => typeof v === "number" && !isNaN(v);
|
|
12
14
|
const isArray = (v) => Array.isArray(v);
|
|
13
15
|
const isArrayEmpty = (v) => isArray(v) && v.length === 0;
|
|
@@ -17,7 +19,9 @@ const isFunction = (v) => v instanceof Function;
|
|
|
17
19
|
const isNaNValue = (v) => typeof v === "number" && isNaN(v);
|
|
18
20
|
const isRegExp = (v) => v instanceof RegExp;
|
|
19
21
|
const isMap = (v) => v instanceof Map;
|
|
22
|
+
const isWeakMap = (v) => v instanceof WeakMap;
|
|
20
23
|
const isSet = (v) => v instanceof Set;
|
|
24
|
+
const isWeakSet = (v) => v instanceof WeakSet;
|
|
21
25
|
const isSymbol = (v) => toString(v) === "Symbol";
|
|
22
26
|
const isDate = (v) => v instanceof Date && !isNaN(v.valueOf());
|
|
23
27
|
const isBigint = (v) => typeof v === "bigint";
|
|
@@ -26,9 +30,11 @@ const isURL = (v) => v instanceof URL;
|
|
|
26
30
|
const isError = (v) => v instanceof Error;
|
|
27
31
|
const isPrimitive = (v) => isString(v) || isNumber(v) || isBigint(v) || isBoolean(v) || isSymbol(v) || isNull(v) || isUndefined(v);
|
|
28
32
|
const isElement = (v) => v instanceof Element;
|
|
33
|
+
const isHtmlElement = (v) => v instanceof HTMLElement;
|
|
34
|
+
const isSvgElement = (v) => v instanceof SVGElement;
|
|
29
35
|
const isNodeList = (v) => v instanceof NodeList;
|
|
30
36
|
const isNodeListEmpty = (v) => isNodeList(v) && v.length === 0;
|
|
31
37
|
const isHtmlCollection = (v) => v instanceof HTMLCollection;
|
|
32
38
|
const isHtmlCollectionEmpty = (v) => isHtmlCollection(v) && v.length === 0;
|
|
33
39
|
|
|
34
|
-
export { isArray, isArrayEmpty, isBigint, isBoolean, isBrowser, isDate, isElement, isError, isFunction, isHtmlCollection, isHtmlCollectionEmpty, isInfinity, isMap, isNaNValue, isNodeList, isNodeListEmpty, isNull, isNumber, isObject, isObjectEmpty, isPrimitive, isRegExp, isSet, isString, isStringEmpty, isSymbol, isURL, isUndefined, noop, toString };
|
|
40
|
+
export { isArray, isArrayEmpty, isBigint, isBoolean, isBrowser, isDate, isElement, isError, isFalse, isFunction, isHtmlCollection, isHtmlCollectionEmpty, isHtmlElement, isInfinity, isMap, isNaNValue, isNodeList, isNodeListEmpty, isNull, isNumber, isObject, isObjectEmpty, isPrimitive, isRegExp, isSet, isString, isStringEmpty, isSvgElement, isSymbol, isTrue, isURL, isUndefined, isWeakMap, isWeakSet, noop, toString };
|
package/dist/types/index.d.ts
CHANGED
|
@@ -40,6 +40,14 @@ declare const isStringEmpty: (v: any) => v is string;
|
|
|
40
40
|
* Returns a boolean if the given value is a `boolean`.
|
|
41
41
|
*/
|
|
42
42
|
declare const isBoolean: (v: any) => v is boolean;
|
|
43
|
+
/**
|
|
44
|
+
* Returns a boolean if the given value is a `true`.
|
|
45
|
+
*/
|
|
46
|
+
declare const isTrue: (v: any) => v is true;
|
|
47
|
+
/**
|
|
48
|
+
* Returns a boolean if the given value is a `false`.
|
|
49
|
+
*/
|
|
50
|
+
declare const isFalse: (v: any) => v is false;
|
|
43
51
|
/**
|
|
44
52
|
* Returns a boolean if the given value is a `number`.
|
|
45
53
|
*/
|
|
@@ -73,13 +81,21 @@ declare const isNaNValue: (v: any) => v is number;
|
|
|
73
81
|
*/
|
|
74
82
|
declare const isRegExp: (v: any) => v is RegExp;
|
|
75
83
|
/**
|
|
76
|
-
* Returns a boolean if the given value is a `
|
|
84
|
+
* Returns a boolean if the given value is a `Map`.
|
|
77
85
|
*/
|
|
78
86
|
declare const isMap: (v: any) => v is Map<any, any>;
|
|
79
87
|
/**
|
|
80
|
-
* Returns a boolean if the given value is a `
|
|
88
|
+
* Returns a boolean if the given value is a `WeakMap`.
|
|
89
|
+
*/
|
|
90
|
+
declare const isWeakMap: (v: any) => v is WeakMap<any, any>;
|
|
91
|
+
/**
|
|
92
|
+
* Returns a boolean if the given value is a `Set`.
|
|
81
93
|
*/
|
|
82
94
|
declare const isSet: (v: any) => v is Set<any>;
|
|
95
|
+
/**
|
|
96
|
+
* Returns a boolean if the given value is a `WeakSet`.
|
|
97
|
+
*/
|
|
98
|
+
declare const isWeakSet: (v: any) => v is WeakSet<any>;
|
|
83
99
|
/**
|
|
84
100
|
* Returns a boolean if the given value is a `symbol`.
|
|
85
101
|
*/
|
|
@@ -112,6 +128,14 @@ declare const isPrimitive: (v: any) => v is Primitive;
|
|
|
112
128
|
* Returns a boolean if the given value is a `Element`.
|
|
113
129
|
*/
|
|
114
130
|
declare const isElement: (v: any) => v is Element;
|
|
131
|
+
/**
|
|
132
|
+
* Returns a boolean if the given value is a `HTMLElement`.
|
|
133
|
+
*/
|
|
134
|
+
declare const isHtmlElement: (v: any) => v is HTMLElement;
|
|
135
|
+
/**
|
|
136
|
+
* Returns a boolean if the given value is a `SVGElement`.
|
|
137
|
+
*/
|
|
138
|
+
declare const isSvgElement: (v: any) => v is SVGElement;
|
|
115
139
|
/**
|
|
116
140
|
* Returns a boolean if the given value is a `NodeList`.
|
|
117
141
|
*/
|
|
@@ -186,4 +210,4 @@ type RequiredObjectDeep<T extends object, Options extends RequiredOptions = {
|
|
|
186
210
|
[K in keyof T]-?: RequiredDeep<T[K], Options>;
|
|
187
211
|
};
|
|
188
212
|
|
|
189
|
-
export { type BuiltIn, type IsAny, type IsNever, type IsNull, type PartialDeep, type Primitive, type RequiredDeep, isArray, isArrayEmpty, isBigint, isBoolean, isBrowser, isDate, isElement, isError, isFunction, isHtmlCollection, isHtmlCollectionEmpty, isInfinity, isMap, isNaNValue, isNodeList, isNodeListEmpty, isNull, isNumber, isObject, isObjectEmpty, isPrimitive, isRegExp, isSet, isString, isStringEmpty, isSymbol, isURL, isUndefined, noop, toString };
|
|
213
|
+
export { type BuiltIn, type IsAny, type IsNever, type IsNull, type PartialDeep, type Primitive, type RequiredDeep, isArray, isArrayEmpty, isBigint, isBoolean, isBrowser, isDate, isElement, isError, isFalse, isFunction, isHtmlCollection, isHtmlCollectionEmpty, isHtmlElement, isInfinity, isMap, isNaNValue, isNodeList, isNodeListEmpty, isNull, isNumber, isObject, isObjectEmpty, isPrimitive, isRegExp, isSet, isString, isStringEmpty, isSvgElement, isSymbol, isTrue, isURL, isUndefined, isWeakMap, isWeakSet, noop, toString };
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@hypernym/utils",
|
|
3
|
-
"version": "2.
|
|
3
|
+
"version": "2.3.0",
|
|
4
4
|
"author": "Hypernym Studio",
|
|
5
5
|
"description": "A collection of reusable utilities.",
|
|
6
6
|
"license": "MIT",
|
|
@@ -31,6 +31,7 @@
|
|
|
31
31
|
"collection",
|
|
32
32
|
"utilities",
|
|
33
33
|
"helpers",
|
|
34
|
+
"shared",
|
|
34
35
|
"utils",
|
|
35
36
|
"types",
|
|
36
37
|
"kit",
|
|
@@ -38,24 +39,40 @@
|
|
|
38
39
|
"ts"
|
|
39
40
|
],
|
|
40
41
|
"scripts": {
|
|
41
|
-
"dev": "vite playgrounds/
|
|
42
|
+
"dev:browser": "vite playgrounds/browser",
|
|
42
43
|
"dev:node": "vite-node -w playgrounds/node/main.ts",
|
|
43
44
|
"build": "hyperbundler",
|
|
44
|
-
"test:types": "vitest -c .config/vitest.config.ts typecheck",
|
|
45
|
+
"test:types": "vitest -c .config/vitest.config.ts --typecheck.only",
|
|
45
46
|
"lint": "ESLINT_USE_FLAT_CONFIG=true eslint -c .config/eslint.config.js .",
|
|
46
47
|
"lint:fix": "ESLINT_USE_FLAT_CONFIG=true eslint -c .config/eslint.config.js --fix .",
|
|
47
48
|
"format": "prettier --config .config/prettier.config.js --write .",
|
|
48
49
|
"prepublishOnly": "npm run build"
|
|
49
50
|
},
|
|
51
|
+
"sideEffects": false,
|
|
52
|
+
"engines": {
|
|
53
|
+
"node": ">=v18.0.0"
|
|
54
|
+
},
|
|
55
|
+
"peerDependencies": {
|
|
56
|
+
"@types/node": ">=20.0.0",
|
|
57
|
+
"typescript": ">=5.0.0"
|
|
58
|
+
},
|
|
59
|
+
"peerDependenciesMeta": {
|
|
60
|
+
"@types/node": {
|
|
61
|
+
"optional": true
|
|
62
|
+
},
|
|
63
|
+
"typescript": {
|
|
64
|
+
"optional": true
|
|
65
|
+
}
|
|
66
|
+
},
|
|
50
67
|
"devDependencies": {
|
|
51
|
-
"@hypernym/bundler": "^0.
|
|
52
|
-
"@hypernym/eslint-config": "^2.0.
|
|
53
|
-
"@hypernym/prettier-config": "^2.0.
|
|
68
|
+
"@hypernym/bundler": "^0.6.3",
|
|
69
|
+
"@hypernym/eslint-config": "^2.0.3",
|
|
70
|
+
"@hypernym/prettier-config": "^2.0.3",
|
|
54
71
|
"@hypernym/tsconfig": "^1.1.0",
|
|
55
|
-
"@types/node": "^20.
|
|
56
|
-
"eslint": "^8.
|
|
57
|
-
"prettier": "^3.
|
|
58
|
-
"typescript": "^5.
|
|
59
|
-
"vitest": "^
|
|
72
|
+
"@types/node": "^20.10.6",
|
|
73
|
+
"eslint": "^8.56.0",
|
|
74
|
+
"prettier": "^3.1.1",
|
|
75
|
+
"typescript": "^5.3.3",
|
|
76
|
+
"vitest": "^1.1.3"
|
|
60
77
|
}
|
|
61
78
|
}
|