@webdeveric/utils 0.41.0 → 0.43.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 +3 -0
- package/dist/cjs/iterateForever.js +8 -0
- package/dist/cjs/predicate-factory/createIsTuplePredicate.js +12 -0
- package/dist/cjs/predicate-factory/index.js +1 -0
- package/dist/cjs/prefix.js +10 -0
- package/dist/cjs/suffix.js +10 -0
- package/dist/mjs/index.js +3 -0
- package/dist/mjs/iterateForever.js +5 -0
- package/dist/mjs/predicate-factory/createIsTuplePredicate.js +8 -0
- package/dist/mjs/predicate-factory/index.js +1 -0
- package/dist/mjs/prefix.js +6 -0
- package/dist/mjs/suffix.js +6 -0
- package/dist/types/index.d.ts +3 -0
- package/dist/types/iterateForever.d.ts +1 -0
- package/dist/types/predicate-factory/createIsTuplePredicate.d.ts +7 -0
- package/dist/types/predicate-factory/index.d.ts +1 -0
- package/dist/types/prefix.d.ts +2 -0
- package/dist/types/suffix.d.ts +2 -0
- package/package.json +9 -9
package/dist/cjs/index.js
CHANGED
|
@@ -45,15 +45,18 @@ __exportStar(require("./getOwnProperties.js"), exports);
|
|
|
45
45
|
__exportStar(require("./getType.js"), exports);
|
|
46
46
|
__exportStar(require("./inRange.js"), exports);
|
|
47
47
|
__exportStar(require("./isEmpty.js"), exports);
|
|
48
|
+
__exportStar(require("./iterateForever.js"), exports);
|
|
48
49
|
__exportStar(require("./joinStrings.js"), exports);
|
|
49
50
|
__exportStar(require("./looksLikeURL.js"), exports);
|
|
50
51
|
__exportStar(require("./normalize.js"), exports);
|
|
51
52
|
__exportStar(require("./parseNumber.js"), exports);
|
|
53
|
+
__exportStar(require("./prefix.js"), exports);
|
|
52
54
|
__exportStar(require("./redactCredentialsInURL.js"), exports);
|
|
53
55
|
__exportStar(require("./resultify.js"), exports);
|
|
54
56
|
__exportStar(require("./secToString.js"), exports);
|
|
55
57
|
__exportStar(require("./sort-factory.js"), exports);
|
|
56
58
|
__exportStar(require("./sort.js"), exports);
|
|
59
|
+
__exportStar(require("./suffix.js"), exports);
|
|
57
60
|
__exportStar(require("./toPascalCase.js"), exports);
|
|
58
61
|
__exportStar(require("./trimEnd.js"), exports);
|
|
59
62
|
__exportStar(require("./trimIndentation.js"), exports);
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.createIsTuplePredicate = void 0;
|
|
4
|
+
const createIsTuplePredicate = (tupleShape) => {
|
|
5
|
+
return (input) => Array.isArray(input) && input.length === tupleShape.length
|
|
6
|
+
? input.every((value, index) => {
|
|
7
|
+
const item = tupleShape[index];
|
|
8
|
+
return typeof item === 'function' ? item(value) : Object.is(value, item);
|
|
9
|
+
})
|
|
10
|
+
: false;
|
|
11
|
+
};
|
|
12
|
+
exports.createIsTuplePredicate = createIsTuplePredicate;
|
|
@@ -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("./createIsTuplePredicate.js"), exports);
|
|
20
21
|
__exportStar(require("./createStringMatchingPredicate.js"), exports);
|
|
21
22
|
__exportStar(require("./everyItem.js"), exports);
|
|
22
23
|
__exportStar(require("./maybeArray.js"), exports);
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.prefix = void 0;
|
|
4
|
+
const prefix = (prefixString, value, defaultValue = '') => {
|
|
5
|
+
if (value == null || (typeof value == 'string' && value.length === 0)) {
|
|
6
|
+
return defaultValue;
|
|
7
|
+
}
|
|
8
|
+
return `${prefixString}${value}`;
|
|
9
|
+
};
|
|
10
|
+
exports.prefix = prefix;
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.suffix = void 0;
|
|
4
|
+
const suffix = (suffixString, value, defaultValue = '') => {
|
|
5
|
+
if (value == null || (typeof value == 'string' && value.length === 0)) {
|
|
6
|
+
return defaultValue;
|
|
7
|
+
}
|
|
8
|
+
return `${value}${suffixString}`;
|
|
9
|
+
};
|
|
10
|
+
exports.suffix = suffix;
|
package/dist/mjs/index.js
CHANGED
|
@@ -29,15 +29,18 @@ export * from './getOwnProperties.js';
|
|
|
29
29
|
export * from './getType.js';
|
|
30
30
|
export * from './inRange.js';
|
|
31
31
|
export * from './isEmpty.js';
|
|
32
|
+
export * from './iterateForever.js';
|
|
32
33
|
export * from './joinStrings.js';
|
|
33
34
|
export * from './looksLikeURL.js';
|
|
34
35
|
export * from './normalize.js';
|
|
35
36
|
export * from './parseNumber.js';
|
|
37
|
+
export * from './prefix.js';
|
|
36
38
|
export * from './redactCredentialsInURL.js';
|
|
37
39
|
export * from './resultify.js';
|
|
38
40
|
export * from './secToString.js';
|
|
39
41
|
export * from './sort-factory.js';
|
|
40
42
|
export * from './sort.js';
|
|
43
|
+
export * from './suffix.js';
|
|
41
44
|
export * from './toPascalCase.js';
|
|
42
45
|
export * from './trimEnd.js';
|
|
43
46
|
export * from './trimIndentation.js';
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
export const createIsTuplePredicate = (tupleShape) => {
|
|
2
|
+
return (input) => Array.isArray(input) && input.length === tupleShape.length
|
|
3
|
+
? input.every((value, index) => {
|
|
4
|
+
const item = tupleShape[index];
|
|
5
|
+
return typeof item === 'function' ? item(value) : Object.is(value, item);
|
|
6
|
+
})
|
|
7
|
+
: false;
|
|
8
|
+
};
|
|
@@ -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 './createIsTuplePredicate.js';
|
|
4
5
|
export * from './createStringMatchingPredicate.js';
|
|
5
6
|
export * from './everyItem.js';
|
|
6
7
|
export * from './maybeArray.js';
|
package/dist/types/index.d.ts
CHANGED
|
@@ -29,15 +29,18 @@ export * from './getOwnProperties.js';
|
|
|
29
29
|
export * from './getType.js';
|
|
30
30
|
export * from './inRange.js';
|
|
31
31
|
export * from './isEmpty.js';
|
|
32
|
+
export * from './iterateForever.js';
|
|
32
33
|
export * from './joinStrings.js';
|
|
33
34
|
export * from './looksLikeURL.js';
|
|
34
35
|
export * from './normalize.js';
|
|
35
36
|
export * from './parseNumber.js';
|
|
37
|
+
export * from './prefix.js';
|
|
36
38
|
export * from './redactCredentialsInURL.js';
|
|
37
39
|
export * from './resultify.js';
|
|
38
40
|
export * from './secToString.js';
|
|
39
41
|
export * from './sort-factory.js';
|
|
40
42
|
export * from './sort.js';
|
|
43
|
+
export * from './suffix.js';
|
|
41
44
|
export * from './toPascalCase.js';
|
|
42
45
|
export * from './trimEnd.js';
|
|
43
46
|
export * from './trimIndentation.js';
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare function iterateForever<T>(items: Iterable<T>): Generator<T, undefined, undefined>;
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import type { Primitive } from '../types/common.js';
|
|
2
|
+
import type { TypePredicateFn } from '../types/functions.js';
|
|
3
|
+
export type TuplePredicateInput = (Primitive | TypePredicateFn<unknown>)[];
|
|
4
|
+
export type GetTupleFromInput<Type extends TuplePredicateInput> = {
|
|
5
|
+
[Property in keyof Type]: Type[Property] extends TypePredicateFn<infer T> ? T : Type[Property];
|
|
6
|
+
};
|
|
7
|
+
export declare const createIsTuplePredicate: <const Input extends TuplePredicateInput>(tupleShape: Input) => TypePredicateFn<GetTupleFromInput<Input>>;
|
|
@@ -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 './createIsTuplePredicate.js';
|
|
4
5
|
export * from './createStringMatchingPredicate.js';
|
|
5
6
|
export * from './everyItem.js';
|
|
6
7
|
export * from './maybeArray.js';
|
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.43.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.
|
|
69
|
+
"packageManager": "pnpm@9.15.3+sha512.1f79bc245a66eb0b07c5d4d83131240774642caaa86ef7d0434ab47c0d16f66b04e21e0c086eb61e62c77efc4d7f7ec071afad3796af64892fae66509173893a",
|
|
70
70
|
"scripts": {
|
|
71
71
|
"clean": "rimraf ./dist/",
|
|
72
72
|
"prebuild": "pnpm clean",
|
|
@@ -87,25 +87,25 @@
|
|
|
87
87
|
"devDependencies": {
|
|
88
88
|
"@commitlint/config-conventional": "^19.6.0",
|
|
89
89
|
"@commitlint/types": "^19.5.0",
|
|
90
|
-
"@types/node": "^22.10.
|
|
90
|
+
"@types/node": "^22.10.5",
|
|
91
91
|
"@vitest/coverage-v8": "^2.1.8",
|
|
92
92
|
"@webdeveric/eslint-config-ts": "^0.11.0",
|
|
93
93
|
"@webdeveric/prettier-config": "^0.3.0",
|
|
94
|
-
"commitlint": "^19.6.
|
|
94
|
+
"commitlint": "^19.6.1",
|
|
95
95
|
"commitlint-plugin-cspell": "^0.1.1",
|
|
96
96
|
"conventional-changelog-conventionalcommits": "^8.0.0",
|
|
97
|
-
"cspell": "^8.
|
|
97
|
+
"cspell": "^8.17.1",
|
|
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
|
-
"jsdom": "^
|
|
104
|
-
"lint-staged": "^15.
|
|
103
|
+
"jsdom": "^26.0.0",
|
|
104
|
+
"lint-staged": "^15.3.0",
|
|
105
105
|
"prettier": "^3.4.2",
|
|
106
106
|
"rimraf": "^6.0.1",
|
|
107
|
-
"semantic-release": "^24.2.
|
|
108
|
-
"typescript": "^5.7.
|
|
107
|
+
"semantic-release": "^24.2.1",
|
|
108
|
+
"typescript": "^5.7.3",
|
|
109
109
|
"validate-package-exports": "^0.8.0",
|
|
110
110
|
"vitest": "^2.1.8"
|
|
111
111
|
}
|