@webdeveric/utils 0.43.0 → 0.44.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/cjs/index.js +1 -0
- package/dist/cjs/isEmpty.js +2 -2
- package/dist/cjs/predicate-factory/createIsInstanceOfPredicate.js +5 -0
- package/dist/cjs/predicate-factory/index.js +1 -0
- package/dist/cjs/stripWhitespace.js +5 -0
- package/dist/cjs/until.js +2 -1
- package/dist/mjs/index.js +1 -0
- package/dist/mjs/isEmpty.js +2 -2
- package/dist/mjs/predicate-factory/createIsInstanceOfPredicate.js +1 -0
- package/dist/mjs/predicate-factory/index.js +1 -0
- package/dist/mjs/stripWhitespace.js +1 -0
- package/dist/mjs/until.js +2 -1
- package/dist/types/index.d.ts +1 -0
- package/dist/types/predicate-factory/createIsInstanceOfPredicate.d.ts +3 -0
- package/dist/types/predicate-factory/index.d.ts +1 -0
- package/dist/types/stripWhitespace.d.ts +2 -0
- package/dist/types/types/strings.d.ts +1 -1
- package/package.json +7 -7
package/dist/cjs/index.js
CHANGED
|
@@ -56,6 +56,7 @@ __exportStar(require("./resultify.js"), exports);
|
|
|
56
56
|
__exportStar(require("./secToString.js"), exports);
|
|
57
57
|
__exportStar(require("./sort-factory.js"), exports);
|
|
58
58
|
__exportStar(require("./sort.js"), exports);
|
|
59
|
+
__exportStar(require("./stripWhitespace.js"), exports);
|
|
59
60
|
__exportStar(require("./suffix.js"), exports);
|
|
60
61
|
__exportStar(require("./toPascalCase.js"), exports);
|
|
61
62
|
__exportStar(require("./trimEnd.js"), exports);
|
package/dist/cjs/isEmpty.js
CHANGED
|
@@ -3,7 +3,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
3
3
|
exports.isEmpty = isEmpty;
|
|
4
4
|
const isLengthAware_js_1 = require("./predicate/isLengthAware.js");
|
|
5
5
|
function isEmpty(input) {
|
|
6
|
-
if (
|
|
6
|
+
if (input == null || (typeof input === 'string' && !input.length)) {
|
|
7
7
|
return true;
|
|
8
8
|
}
|
|
9
9
|
if (input instanceof Set || input instanceof Map) {
|
|
@@ -13,7 +13,7 @@ function isEmpty(input) {
|
|
|
13
13
|
return input.length === 0;
|
|
14
14
|
}
|
|
15
15
|
if (typeof input === 'object') {
|
|
16
|
-
return
|
|
16
|
+
return Reflect.ownKeys(input).length === 0;
|
|
17
17
|
}
|
|
18
18
|
return false;
|
|
19
19
|
}
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.createIsInstanceOfPredicate = void 0;
|
|
4
|
+
const createIsInstanceOfPredicate = (constructor) => (input) => input instanceof constructor;
|
|
5
|
+
exports.createIsInstanceOfPredicate = createIsInstanceOfPredicate;
|
|
@@ -17,6 +17,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
17
17
|
__exportStar(require("./allOf.js"), exports);
|
|
18
18
|
__exportStar(require("./anyOf.js"), exports);
|
|
19
19
|
__exportStar(require("./createIsEnumPredicate.js"), exports);
|
|
20
|
+
__exportStar(require("./createIsInstanceOfPredicate.js"), exports);
|
|
20
21
|
__exportStar(require("./createIsTuplePredicate.js"), exports);
|
|
21
22
|
__exportStar(require("./createStringMatchingPredicate.js"), exports);
|
|
22
23
|
__exportStar(require("./everyItem.js"), exports);
|
package/dist/cjs/until.js
CHANGED
|
@@ -2,6 +2,7 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.getDelay = exports.isDelay = void 0;
|
|
4
4
|
exports.until = until;
|
|
5
|
+
const asError_js_1 = require("./asError.js");
|
|
5
6
|
const getType_js_1 = require("./getType.js");
|
|
6
7
|
const defaultOptions = {
|
|
7
8
|
delay: 10,
|
|
@@ -71,7 +72,7 @@ function until(fn, options = defaultOptions) {
|
|
|
71
72
|
}
|
|
72
73
|
}
|
|
73
74
|
catch (error) {
|
|
74
|
-
rejectFn(
|
|
75
|
+
rejectFn((0, asError_js_1.asError)(error));
|
|
75
76
|
}
|
|
76
77
|
};
|
|
77
78
|
callUntilDone(fn, delay, resolve, reject);
|
package/dist/mjs/index.js
CHANGED
|
@@ -40,6 +40,7 @@ export * from './resultify.js';
|
|
|
40
40
|
export * from './secToString.js';
|
|
41
41
|
export * from './sort-factory.js';
|
|
42
42
|
export * from './sort.js';
|
|
43
|
+
export * from './stripWhitespace.js';
|
|
43
44
|
export * from './suffix.js';
|
|
44
45
|
export * from './toPascalCase.js';
|
|
45
46
|
export * from './trimEnd.js';
|
package/dist/mjs/isEmpty.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { isLengthAware } from './predicate/isLengthAware.js';
|
|
2
2
|
export function isEmpty(input) {
|
|
3
|
-
if (
|
|
3
|
+
if (input == null || (typeof input === 'string' && !input.length)) {
|
|
4
4
|
return true;
|
|
5
5
|
}
|
|
6
6
|
if (input instanceof Set || input instanceof Map) {
|
|
@@ -10,7 +10,7 @@ export function isEmpty(input) {
|
|
|
10
10
|
return input.length === 0;
|
|
11
11
|
}
|
|
12
12
|
if (typeof input === 'object') {
|
|
13
|
-
return
|
|
13
|
+
return Reflect.ownKeys(input).length === 0;
|
|
14
14
|
}
|
|
15
15
|
return false;
|
|
16
16
|
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export const createIsInstanceOfPredicate = (constructor) => (input) => input instanceof constructor;
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
export * from './allOf.js';
|
|
2
2
|
export * from './anyOf.js';
|
|
3
3
|
export * from './createIsEnumPredicate.js';
|
|
4
|
+
export * from './createIsInstanceOfPredicate.js';
|
|
4
5
|
export * from './createIsTuplePredicate.js';
|
|
5
6
|
export * from './createStringMatchingPredicate.js';
|
|
6
7
|
export * from './everyItem.js';
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export const stripWhitespace = (input) => input.replace(/\s+/g, '');
|
package/dist/mjs/until.js
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { asError } from './asError.js';
|
|
1
2
|
import { getType } from './getType.js';
|
|
2
3
|
const defaultOptions = {
|
|
3
4
|
delay: 10,
|
|
@@ -65,7 +66,7 @@ export function until(fn, options = defaultOptions) {
|
|
|
65
66
|
}
|
|
66
67
|
}
|
|
67
68
|
catch (error) {
|
|
68
|
-
rejectFn(
|
|
69
|
+
rejectFn(asError(error));
|
|
69
70
|
}
|
|
70
71
|
};
|
|
71
72
|
callUntilDone(fn, delay, resolve, reject);
|
package/dist/types/index.d.ts
CHANGED
|
@@ -40,6 +40,7 @@ export * from './resultify.js';
|
|
|
40
40
|
export * from './secToString.js';
|
|
41
41
|
export * from './sort-factory.js';
|
|
42
42
|
export * from './sort.js';
|
|
43
|
+
export * from './stripWhitespace.js';
|
|
43
44
|
export * from './suffix.js';
|
|
44
45
|
export * from './toPascalCase.js';
|
|
45
46
|
export * from './trimEnd.js';
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
export * from './allOf.js';
|
|
2
2
|
export * from './anyOf.js';
|
|
3
3
|
export * from './createIsEnumPredicate.js';
|
|
4
|
+
export * from './createIsInstanceOfPredicate.js';
|
|
4
5
|
export * from './createIsTuplePredicate.js';
|
|
5
6
|
export * from './createStringMatchingPredicate.js';
|
|
6
7
|
export * from './everyItem.js';
|
|
@@ -4,7 +4,7 @@ export type AlphaCharacter = 'a' | 'b' | 'c' | 'd' | 'e' | 'f' | 'g' | 'h' | 'i'
|
|
|
4
4
|
export type NumericCharacter = '0' | '1' | '2' | '3' | '4' | '5' | '6' | '7' | '8' | '9';
|
|
5
5
|
export type AlphanumericCharacter = AlphaCharacter | Capitalize<AlphaCharacter> | NumericCharacter;
|
|
6
6
|
export type MaybePlural<T extends string> = T | `${T}s`;
|
|
7
|
-
export type StripWhitespace<Type extends string> = Type extends `${infer First}${infer Rest}` ? First extends Space ? StripWhitespace<Rest> : `${First}${StripWhitespace<Rest>}` : EmptyString;
|
|
7
|
+
export type StripWhitespace<Type extends string> = string extends Type ? Type : Type extends `${infer First}${infer Rest}` ? First extends Space ? StripWhitespace<Rest> : `${First}${StripWhitespace<Rest>}` : EmptyString;
|
|
8
8
|
export type AlphanumericOnly<Type extends string> = Type extends EmptyString ? EmptyString : Type extends `${infer First}${infer Rest}` ? First extends AlphanumericCharacter | Space ? `${First}${AlphanumericOnly<Rest>}` : Rest extends EmptyString ? Rest : `${Space}${AlphanumericOnly<Rest>}` : never;
|
|
9
9
|
export type Replace<Type extends string, Remove extends string, Replacement extends string> = Type extends `${infer First}${infer Rest}` ? First extends Remove ? `${Replacement}${Replace<Rest, Remove, Replacement>}` : `${First}${Replace<Rest, Remove, Replacement>}` : EmptyString;
|
|
10
10
|
export type Strip<Type extends string, Remove extends string> = Replace<Type, Remove, EmptyString>;
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@webdeveric/utils",
|
|
3
3
|
"description": "Just another collection of utilities.",
|
|
4
|
-
"version": "0.
|
|
4
|
+
"version": "0.44.0",
|
|
5
5
|
"publishConfig": {
|
|
6
6
|
"access": "public"
|
|
7
7
|
},
|
|
@@ -66,7 +66,7 @@
|
|
|
66
66
|
"url": "https://github.com/webdeveric/utils/issues"
|
|
67
67
|
},
|
|
68
68
|
"homepage": "https://github.com/webdeveric/utils/#readme",
|
|
69
|
-
"packageManager": "pnpm@9.15.
|
|
69
|
+
"packageManager": "pnpm@9.15.4+sha512.b2dc20e2fc72b3e18848459b37359a32064663e5627a51e4c74b2c29dd8e8e0491483c3abb40789cfd578bf362fb6ba8261b05f0387d76792ed6e23ea3b1b6a0",
|
|
70
70
|
"scripts": {
|
|
71
71
|
"clean": "rimraf ./dist/",
|
|
72
72
|
"prebuild": "pnpm clean",
|
|
@@ -87,26 +87,26 @@
|
|
|
87
87
|
"devDependencies": {
|
|
88
88
|
"@commitlint/config-conventional": "^19.6.0",
|
|
89
89
|
"@commitlint/types": "^19.5.0",
|
|
90
|
-
"@types/node": "^22.10.
|
|
91
|
-
"@vitest/coverage-v8": "^
|
|
90
|
+
"@types/node": "^22.10.7",
|
|
91
|
+
"@vitest/coverage-v8": "^3.0.2",
|
|
92
92
|
"@webdeveric/eslint-config-ts": "^0.11.0",
|
|
93
93
|
"@webdeveric/prettier-config": "^0.3.0",
|
|
94
94
|
"commitlint": "^19.6.1",
|
|
95
95
|
"commitlint-plugin-cspell": "^0.1.1",
|
|
96
96
|
"conventional-changelog-conventionalcommits": "^8.0.0",
|
|
97
|
-
"cspell": "^8.17.
|
|
97
|
+
"cspell": "^8.17.2",
|
|
98
98
|
"eslint": "^8.57.1",
|
|
99
99
|
"eslint-config-prettier": "^9.1.0",
|
|
100
100
|
"eslint-import-resolver-typescript": "^3.7.0",
|
|
101
101
|
"eslint-plugin-import": "^2.31.0",
|
|
102
102
|
"husky": "^9.1.7",
|
|
103
103
|
"jsdom": "^26.0.0",
|
|
104
|
-
"lint-staged": "^15.
|
|
104
|
+
"lint-staged": "^15.4.1",
|
|
105
105
|
"prettier": "^3.4.2",
|
|
106
106
|
"rimraf": "^6.0.1",
|
|
107
107
|
"semantic-release": "^24.2.1",
|
|
108
108
|
"typescript": "^5.7.3",
|
|
109
109
|
"validate-package-exports": "^0.8.0",
|
|
110
|
-
"vitest": "^
|
|
110
|
+
"vitest": "^3.0.2"
|
|
111
111
|
}
|
|
112
112
|
}
|