@alexaegis/predicate 0.16.1 → 0.18.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/index.cjs +1 -1
- package/dist/index.cjs.map +1 -1
- package/dist/index.js +1 -1
- package/dist/index.js.map +1 -1
- package/dist/internal/predicates.d.ts +3 -3
- package/dist/internal/predicates.d.ts.map +1 -1
- package/package.json +12 -10
- package/dist/index.spec.d.ts +0 -2
- package/dist/index.spec.d.ts.map +0 -1
- package/dist/internal/predicates.spec.d.ts +0 -2
- package/dist/internal/predicates.spec.d.ts.map +0 -1
- package/dist/vite.config.d.ts +0 -3
- package/dist/vite.config.d.ts.map +0 -1
- package/dist/vitest.config.d.ts +0 -2
- package/dist/vitest.config.d.ts.map +0 -1
package/dist/index.cjs
CHANGED
|
@@ -16,7 +16,7 @@ var contains = (criteria) => {
|
|
|
16
16
|
return (value) => value?.includes(criteria) ?? false;
|
|
17
17
|
};
|
|
18
18
|
var matchRegExp = (criteria) => {
|
|
19
|
-
return (value) => typeof value === "string"
|
|
19
|
+
return (value) => typeof value === "string" && criteria.test(value);
|
|
20
20
|
};
|
|
21
21
|
var predicate = {
|
|
22
22
|
not,
|
package/dist/index.cjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.cjs","names":[],"sources":["../src/internal/predicates.ts"],"sourcesContent":["export type Predicate<T> = (value?: T |
|
|
1
|
+
{"version":3,"file":"index.cjs","names":[],"sources":["../src/internal/predicates.ts"],"sourcesContent":["export type Predicate<T> = (value?: T | null) => boolean;\n\nexport const not = <T>(predicate: Predicate<T>): Predicate<T> => {\n\treturn (value?: T | null): boolean => !predicate(value);\n};\n\nexport const equal = <T>(criteria: T) => {\n\treturn (value?: T | null): value is T => value === criteria;\n};\n\nexport const and = <T>(...predicates: Predicate<T>[]): Predicate<T> => {\n\treturn (value?: T | null): boolean => predicates.every((predicate) => predicate(value));\n};\n\nexport const or = <T>(...predicates: Predicate<T>[]): Predicate<T> => {\n\treturn (value?: T | null): boolean => predicates.some((predicate) => predicate(value));\n};\n\n// eslint-disable-next-line @typescript-eslint/no-unnecessary-type-parameters -- removing T would break callers that pass a type argument\nexport const contains = <T extends string>(criteria: T): Predicate<string> => {\n\treturn (value?: T | string | null): value is string => value?.includes(criteria) ?? false;\n};\n\n// eslint-disable-next-line @typescript-eslint/no-unnecessary-type-parameters -- removing T would break callers that pass a type argument\nexport const matchRegExp = <T extends string>(criteria: RegExp): Predicate<string> => {\n\treturn (value?: T | string | null): value is string =>\n\t\ttypeof value === 'string' && criteria.test(value);\n};\n\nexport const predicate = {\n\tnot,\n\tequal,\n\tand,\n\tor,\n\tcontains,\n\tmatchRegExp,\n} as const;\n"],"mappings":";;AAEA,IAAa,OAAU,cAA0C;CAChE,QAAQ,UAA8B,CAAC,UAAU,KAAK;AACvD;AAEA,IAAa,SAAY,aAAgB;CACxC,QAAQ,UAAiC,UAAU;AACpD;AAEA,IAAa,OAAU,GAAG,eAA6C;CACtE,QAAQ,UAA8B,WAAW,OAAO,cAAc,UAAU,KAAK,CAAC;AACvF;AAEA,IAAa,MAAS,GAAG,eAA6C;CACrE,QAAQ,UAA8B,WAAW,MAAM,cAAc,UAAU,KAAK,CAAC;AACtF;AAGA,IAAa,YAA8B,aAAmC;CAC7E,QAAQ,UAA+C,OAAO,SAAS,QAAQ,KAAK;AACrF;AAGA,IAAa,eAAiC,aAAwC;CACrF,QAAQ,UACP,OAAO,UAAU,YAAY,SAAS,KAAK,KAAK;AAClD;AAEA,IAAa,YAAY;CACxB;CACA;CACA;CACA;CACA;CACA;AACD"}
|
package/dist/index.js
CHANGED
|
@@ -15,7 +15,7 @@ var contains = (criteria) => {
|
|
|
15
15
|
return (value) => value?.includes(criteria) ?? false;
|
|
16
16
|
};
|
|
17
17
|
var matchRegExp = (criteria) => {
|
|
18
|
-
return (value) => typeof value === "string"
|
|
18
|
+
return (value) => typeof value === "string" && criteria.test(value);
|
|
19
19
|
};
|
|
20
20
|
var predicate = {
|
|
21
21
|
not,
|
package/dist/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","names":[],"sources":["../src/internal/predicates.ts"],"sourcesContent":["export type Predicate<T> = (value?: T |
|
|
1
|
+
{"version":3,"file":"index.js","names":[],"sources":["../src/internal/predicates.ts"],"sourcesContent":["export type Predicate<T> = (value?: T | null) => boolean;\n\nexport const not = <T>(predicate: Predicate<T>): Predicate<T> => {\n\treturn (value?: T | null): boolean => !predicate(value);\n};\n\nexport const equal = <T>(criteria: T) => {\n\treturn (value?: T | null): value is T => value === criteria;\n};\n\nexport const and = <T>(...predicates: Predicate<T>[]): Predicate<T> => {\n\treturn (value?: T | null): boolean => predicates.every((predicate) => predicate(value));\n};\n\nexport const or = <T>(...predicates: Predicate<T>[]): Predicate<T> => {\n\treturn (value?: T | null): boolean => predicates.some((predicate) => predicate(value));\n};\n\n// eslint-disable-next-line @typescript-eslint/no-unnecessary-type-parameters -- removing T would break callers that pass a type argument\nexport const contains = <T extends string>(criteria: T): Predicate<string> => {\n\treturn (value?: T | string | null): value is string => value?.includes(criteria) ?? false;\n};\n\n// eslint-disable-next-line @typescript-eslint/no-unnecessary-type-parameters -- removing T would break callers that pass a type argument\nexport const matchRegExp = <T extends string>(criteria: RegExp): Predicate<string> => {\n\treturn (value?: T | string | null): value is string =>\n\t\ttypeof value === 'string' && criteria.test(value);\n};\n\nexport const predicate = {\n\tnot,\n\tequal,\n\tand,\n\tor,\n\tcontains,\n\tmatchRegExp,\n} as const;\n"],"mappings":";AAEA,IAAa,OAAU,cAA0C;CAChE,QAAQ,UAA8B,CAAC,UAAU,KAAK;AACvD;AAEA,IAAa,SAAY,aAAgB;CACxC,QAAQ,UAAiC,UAAU;AACpD;AAEA,IAAa,OAAU,GAAG,eAA6C;CACtE,QAAQ,UAA8B,WAAW,OAAO,cAAc,UAAU,KAAK,CAAC;AACvF;AAEA,IAAa,MAAS,GAAG,eAA6C;CACrE,QAAQ,UAA8B,WAAW,MAAM,cAAc,UAAU,KAAK,CAAC;AACtF;AAGA,IAAa,YAA8B,aAAmC;CAC7E,QAAQ,UAA+C,OAAO,SAAS,QAAQ,KAAK;AACrF;AAGA,IAAa,eAAiC,aAAwC;CACrF,QAAQ,UACP,OAAO,UAAU,YAAY,SAAS,KAAK,KAAK;AAClD;AAEA,IAAa,YAAY;CACxB;CACA;CACA;CACA;CACA;CACA;AACD"}
|
|
@@ -1,13 +1,13 @@
|
|
|
1
|
-
export type Predicate<T> = (value?: T |
|
|
1
|
+
export type Predicate<T> = (value?: T | null) => boolean;
|
|
2
2
|
export declare const not: <T>(predicate: Predicate<T>) => Predicate<T>;
|
|
3
|
-
export declare const equal: <T>(criteria: T) => (value?: T |
|
|
3
|
+
export declare const equal: <T>(criteria: T) => (value?: T | null) => value is T;
|
|
4
4
|
export declare const and: <T>(...predicates: Predicate<T>[]) => Predicate<T>;
|
|
5
5
|
export declare const or: <T>(...predicates: Predicate<T>[]) => Predicate<T>;
|
|
6
6
|
export declare const contains: <T extends string>(criteria: T) => Predicate<string>;
|
|
7
7
|
export declare const matchRegExp: <T extends string>(criteria: RegExp) => Predicate<string>;
|
|
8
8
|
export declare const predicate: {
|
|
9
9
|
readonly not: <T>(predicate: Predicate<T>) => Predicate<T>;
|
|
10
|
-
readonly equal: <T>(criteria: T) => (value?: T |
|
|
10
|
+
readonly equal: <T>(criteria: T) => (value?: T | null) => value is T;
|
|
11
11
|
readonly and: <T>(...predicates: Predicate<T>[]) => Predicate<T>;
|
|
12
12
|
readonly or: <T>(...predicates: Predicate<T>[]) => Predicate<T>;
|
|
13
13
|
readonly contains: <T extends string>(criteria: T) => Predicate<string>;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"predicates.d.ts","sourceRoot":"","sources":["../../src/internal/predicates.ts"],"names":[],"mappings":"AAAA,MAAM,MAAM,SAAS,CAAC,CAAC,IAAI,CAAC,KAAK,CAAC,EAAE,CAAC,G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AS,MAAM,YAAY,CAAC,KAAG,SAAS,CAAC,MAAM,CAAC;2BAK9C,CAAC,SAAS,MAAM,YAAY,MAAM,KAAG,SAAS,CAAC,MAAM,CAAC;CAYxE,CAAC"}
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@alexaegis/predicate",
|
|
3
3
|
"description": "Dead simple declarative predicates",
|
|
4
|
-
"version": "0.
|
|
4
|
+
"version": "0.18.0",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"private": false,
|
|
7
7
|
"archetype": {
|
|
@@ -30,7 +30,7 @@
|
|
|
30
30
|
"dist"
|
|
31
31
|
],
|
|
32
32
|
"engines": {
|
|
33
|
-
"node": ">=
|
|
33
|
+
"node": ">=24.0.0"
|
|
34
34
|
},
|
|
35
35
|
"exports": {
|
|
36
36
|
".": {
|
|
@@ -43,11 +43,11 @@
|
|
|
43
43
|
"./readme": "./readme.md"
|
|
44
44
|
},
|
|
45
45
|
"devDependencies": {
|
|
46
|
-
"@alexaegis/eslint-config-vitest": "^0.
|
|
47
|
-
"@alexaegis/ts": "^0.
|
|
48
|
-
"@alexaegis/vite": "^0.
|
|
49
|
-
"@alexaegis/vitest": "^0.
|
|
50
|
-
"@types/node": "^
|
|
46
|
+
"@alexaegis/eslint-config-vitest": "^0.18.0",
|
|
47
|
+
"@alexaegis/ts": "^0.18.0",
|
|
48
|
+
"@alexaegis/vite": "^0.18.0",
|
|
49
|
+
"@alexaegis/vitest": "^0.18.0",
|
|
50
|
+
"@types/node": "^24.19.2",
|
|
51
51
|
"publint": "^0.3.25",
|
|
52
52
|
"typescript": "^6.0.3",
|
|
53
53
|
"vite": "^8.3.5",
|
|
@@ -55,10 +55,14 @@
|
|
|
55
55
|
"vitest": "^5.0.5"
|
|
56
56
|
},
|
|
57
57
|
"scripts": {
|
|
58
|
+
"build": "turbo run build-lib_ --concurrency 16 --filter @alexaegis/predicate",
|
|
59
|
+
"build-lib_": "vite build",
|
|
58
60
|
"lint:depcheck": "turbo run lint:depcheck_ --concurrency 16 --filter @alexaegis/predicate",
|
|
59
61
|
"lint:depcheck_": "depcheck",
|
|
60
62
|
"lint:es": "turbo run lint:es_ --concurrency 16 --filter @alexaegis/predicate",
|
|
61
|
-
"lint:es_": "eslint --max-warnings=0 --
|
|
63
|
+
"lint:es_": "eslint --max-warnings=0 --no-error-on-unmatched-pattern .",
|
|
64
|
+
"lint:es:fix": "turbo run lint:es:fix_ --concurrency 16 --filter @alexaegis/predicate",
|
|
65
|
+
"lint:es:fix_": "eslint --fix --no-error-on-unmatched-pattern .",
|
|
62
66
|
"lint:format": "turbo run lint:format_ --concurrency 16 --filter @alexaegis/predicate",
|
|
63
67
|
"lint:format_": "prettier --cache-location .cache/prettier --plugin prettier-plugin-svelte --plugin prettier-plugin-tailwindcss --check .",
|
|
64
68
|
"lint:md": "turbo run lint:md_ --concurrency 16 --filter @alexaegis/predicate",
|
|
@@ -71,8 +75,6 @@
|
|
|
71
75
|
"test_": "vitest --passWithNoTests --coverage --run",
|
|
72
76
|
"test:watch": "vitest --passWithNoTests --coverage",
|
|
73
77
|
"all": "BUILD_REASON='publish' turbo run all_ --concurrency 16 --filter @alexaegis/predicate",
|
|
74
|
-
"build": "turbo run build-lib_ --concurrency 16 --filter @alexaegis/predicate",
|
|
75
|
-
"build-lib_": "vite build",
|
|
76
78
|
"format": "turbo run format_ --concurrency 16 --filter @alexaegis/predicate",
|
|
77
79
|
"format_": "prettier --cache-location .cache/prettier --plugin prettier-plugin-svelte --plugin prettier-plugin-tailwindcss --write ."
|
|
78
80
|
}
|
package/dist/index.spec.d.ts
DELETED
package/dist/index.spec.d.ts.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"index.spec.d.ts","sourceRoot":"","sources":["../src/index.spec.ts"],"names":[],"mappings":""}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"predicates.spec.d.ts","sourceRoot":"","sources":["../../src/internal/predicates.spec.ts"],"names":[],"mappings":""}
|
package/dist/vite.config.d.ts
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"vite.config.d.ts","sourceRoot":"","sources":["../vite.config.ts"],"names":[],"mappings":";AAMA,wBAOE"}
|
package/dist/vitest.config.d.ts
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"vitest.config.d.ts","sourceRoot":"","sources":["../vitest.config.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,gBAAgB,IAAI,OAAO,EAAE,MAAM,mBAAmB,CAAC"}
|