@alexaegis/predicate 0.3.2 → 0.4.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/index.cjs +1 -2
- package/index.d.ts.map +1 -1
- package/index.js +1 -2
- package/index.spec.d.ts +2 -0
- package/index.spec.d.ts.map +1 -0
- package/internal/predicates.d.ts.map +1 -1
- package/internal/predicates.spec.d.ts +2 -0
- package/internal/predicates.spec.d.ts.map +1 -0
- package/package.json +9 -9
- package/readme.md +4 -4
- package/index.cjs.map +0 -1
- package/index.js.map +0 -1
package/index.cjs
CHANGED
|
@@ -13,7 +13,7 @@ const or = (...predicates) => {
|
|
|
13
13
|
return (value) => predicates.some((predicate2) => predicate2(value));
|
|
14
14
|
};
|
|
15
15
|
const contains = (criteria) => {
|
|
16
|
-
return (value) =>
|
|
16
|
+
return (value) => value?.includes(criteria) ?? false;
|
|
17
17
|
};
|
|
18
18
|
const matchRegExp = (criteria) => {
|
|
19
19
|
return (value) => typeof value === "string" ? criteria.test(value) : false;
|
|
@@ -33,4 +33,3 @@ exports.matchRegExp = matchRegExp;
|
|
|
33
33
|
exports.not = not;
|
|
34
34
|
exports.or = or;
|
|
35
35
|
exports.predicate = predicate;
|
|
36
|
-
//# sourceMappingURL=index.cjs.map
|
package/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,0BAA0B,CAAC"}
|
package/index.js
CHANGED
|
@@ -11,7 +11,7 @@ const or = (...predicates) => {
|
|
|
11
11
|
return (value) => predicates.some((predicate2) => predicate2(value));
|
|
12
12
|
};
|
|
13
13
|
const contains = (criteria) => {
|
|
14
|
-
return (value) =>
|
|
14
|
+
return (value) => value?.includes(criteria) ?? false;
|
|
15
15
|
};
|
|
16
16
|
const matchRegExp = (criteria) => {
|
|
17
17
|
return (value) => typeof value === "string" ? criteria.test(value) : false;
|
|
@@ -33,4 +33,3 @@ export {
|
|
|
33
33
|
or,
|
|
34
34
|
predicate
|
|
35
35
|
};
|
|
36
|
-
//# sourceMappingURL=index.js.map
|
package/index.spec.d.ts
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.spec.d.ts","sourceRoot":"","sources":["../../../src/index.spec.ts"],"names":[],"mappings":""}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"predicates.d.ts","sourceRoot":"","sources":["
|
|
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,GAAG,SAAS,GAAG,IAAI,KAAK,OAAO,CAAC;AAErE,eAAO,MAAM,GAAG,8CAEf,CAAC;AAEF,eAAO,MAAM,KAAK,kEAEjB,CAAC;AAEF,eAAO,MAAM,GAAG,oDAGf,CAAC;AAEF,eAAO,MAAM,EAAE,oDAGd,CAAC;AAEF,eAAO,MAAM,QAAQ,qCAAoC,UAAU,MAAM,CAGxE,CAAC;AAEF,eAAO,MAAM,WAAW,+BAAgC,MAAM,KAAG,UAAU,MAAM,CAGhF,CAAC;AAEF,eAAO,MAAM,SAAS;;;;;8DAVmC,UAAU,MAAM,CAAC;yDAKlB,MAAM,KAAG,UAAU,MAAM,CAAC;CAYxE,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"predicates.spec.d.ts","sourceRoot":"","sources":["../../../../src/internal/predicates.spec.ts"],"names":[],"mappings":""}
|
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.4.0",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"private": false,
|
|
7
7
|
"archetype": {
|
|
@@ -24,13 +24,13 @@
|
|
|
24
24
|
"url": "https://github.com/AlexAegis"
|
|
25
25
|
},
|
|
26
26
|
"repository": {
|
|
27
|
-
"url": "https://github.com/AlexAegis/
|
|
27
|
+
"url": "https://github.com/AlexAegis/common",
|
|
28
28
|
"type": "git",
|
|
29
29
|
"directory": "packages/predicate"
|
|
30
30
|
},
|
|
31
31
|
"bugs": {
|
|
32
32
|
"email": "alexaegis@gmail.com",
|
|
33
|
-
"url": "https://github.com/AlexAegis/
|
|
33
|
+
"url": "https://github.com/AlexAegis/common/issues"
|
|
34
34
|
},
|
|
35
35
|
"type": "module",
|
|
36
36
|
"config": {
|
|
@@ -53,15 +53,15 @@
|
|
|
53
53
|
"./readme": "./readme.md"
|
|
54
54
|
},
|
|
55
55
|
"devDependencies": {
|
|
56
|
-
"@alexaegis/eslint-config-vitest": "^0.3.
|
|
57
|
-
"@alexaegis/ts": "^0.3.
|
|
58
|
-
"@alexaegis/vite": "^0.3.
|
|
59
|
-
"@alexaegis/vitest": "^0.3.
|
|
56
|
+
"@alexaegis/eslint-config-vitest": "^0.3.4",
|
|
57
|
+
"@alexaegis/ts": "^0.3.4",
|
|
58
|
+
"@alexaegis/vite": "^0.3.4",
|
|
59
|
+
"@alexaegis/vitest": "^0.3.4",
|
|
60
60
|
"@types/node": "^20.3.3",
|
|
61
|
-
"publint": "^0.1.
|
|
61
|
+
"publint": "^0.1.15",
|
|
62
62
|
"typescript": "^5.1.6",
|
|
63
63
|
"vite": "^4.3.9",
|
|
64
|
-
"vitest": "^0.32.
|
|
64
|
+
"vitest": "^0.32.4"
|
|
65
65
|
},
|
|
66
66
|
"scripts": {
|
|
67
67
|
"build": "turbo run build-lib_ --concurrency 16 --cache-dir .cache/turbo --filter @alexaegis/predicate",
|
package/readme.md
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
# [@alexaegis/predicate](https://github.com/AlexAegis/
|
|
1
|
+
# [@alexaegis/predicate](https://github.com/AlexAegis/common/tree/master/packages/predicate)
|
|
2
2
|
|
|
3
3
|
[](https://www.npmjs.com/package/@alexaegis/predicate)
|
|
4
|
-
[](https://www.codacy.com/gh/AlexAegis/
|
|
6
|
-
[](https://github.com/AlexAegis/common/actions/workflows/cicd.yml)
|
|
5
|
+
[](https://www.codacy.com/gh/AlexAegis/common/dashboard?utm_source=github.com&utm_medium=referral&utm_content=AlexAegis/common&utm_campaign=Badge_Grade)
|
|
6
|
+
[](https://codecov.io/gh/AlexAegis/common)
|
|
7
7
|
|
|
8
8
|
Dead simple declarative predicates
|
|
9
9
|
|
package/index.cjs.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"index.cjs","sources":["../src/internal/predicates.ts"],"sourcesContent":["export type Predicate<T> = (value?: T | undefined | null) => boolean;\n\nexport const not = <T>(predicate: Predicate<T>): Predicate<T> => {\n\treturn (value?: T | undefined | null): boolean => !predicate(value);\n};\n\nexport const equal = <T>(criteria: T) => {\n\treturn (value?: T | undefined | null): value is T => value === criteria;\n};\n\nexport const and = <T>(...predicates: Predicate<T>[]): Predicate<T> => {\n\treturn (value?: T | undefined | null): boolean =>\n\t\tpredicates.every((predicate) => predicate(value));\n};\n\nexport const or = <T>(...predicates: Predicate<T>[]): Predicate<T> => {\n\treturn (value?: T | undefined | null): boolean =>\n\t\tpredicates.some((predicate) => predicate(value));\n};\n\nexport const contains = <T extends string>(criteria: T): Predicate<string> => {\n\treturn (value?: T | string | undefined | null): value is string =>\n\t\tvalue?.includes(criteria) ?? false;\n};\n\nexport const matchRegExp = <T extends string>(criteria: RegExp): Predicate<string> => {\n\treturn (value?: T | string | undefined | null): value is string =>\n\t\ttypeof value === 'string' ? criteria.test(value) : false;\n};\n\nexport const predicate = {\n\tnot,\n\tequal,\n\tand,\n\tor,\n\tcontains,\n\tmatchRegExp,\n} as const;\n"],"names":["predicate"],"mappings":";;AAEa,MAAA,MAAM,CAAIA,eAA0C;AAChE,SAAO,CAAC,UAA0C,CAACA,WAAU,KAAK;AACnE;AAEa,MAAA,QAAQ,CAAI,aAAgB;AACjC,SAAA,CAAC,UAA6C,UAAU;AAChE;AAEa,MAAA,MAAM,IAAO,eAA6C;AAC/D,SAAA,CAAC,UACP,WAAW,MAAM,CAACA,eAAcA,WAAU,KAAK,CAAC;AAClD;AAEa,MAAA,KAAK,IAAO,eAA6C;AAC9D,SAAA,CAAC,UACP,WAAW,KAAK,CAACA,eAAcA,WAAU,KAAK,CAAC;AACjD;AAEa,MAAA,WAAW,CAAmB,aAAmC;AAC7E,SAAO,CAAC,WACP,+BAAO,SAAS,cAAa;AAC/B;AAEa,MAAA,cAAc,CAAmB,aAAwC;AAC9E,SAAA,CAAC,UACP,OAAO,UAAU,WAAW,SAAS,KAAK,KAAK,IAAI;AACrD;AAEO,MAAM,YAAY;AAAA,EACxB;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AACD;;;;;;;;"}
|
package/index.js.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sources":["../src/internal/predicates.ts"],"sourcesContent":["export type Predicate<T> = (value?: T | undefined | null) => boolean;\n\nexport const not = <T>(predicate: Predicate<T>): Predicate<T> => {\n\treturn (value?: T | undefined | null): boolean => !predicate(value);\n};\n\nexport const equal = <T>(criteria: T) => {\n\treturn (value?: T | undefined | null): value is T => value === criteria;\n};\n\nexport const and = <T>(...predicates: Predicate<T>[]): Predicate<T> => {\n\treturn (value?: T | undefined | null): boolean =>\n\t\tpredicates.every((predicate) => predicate(value));\n};\n\nexport const or = <T>(...predicates: Predicate<T>[]): Predicate<T> => {\n\treturn (value?: T | undefined | null): boolean =>\n\t\tpredicates.some((predicate) => predicate(value));\n};\n\nexport const contains = <T extends string>(criteria: T): Predicate<string> => {\n\treturn (value?: T | string | undefined | null): value is string =>\n\t\tvalue?.includes(criteria) ?? false;\n};\n\nexport const matchRegExp = <T extends string>(criteria: RegExp): Predicate<string> => {\n\treturn (value?: T | string | undefined | null): value is string =>\n\t\ttypeof value === 'string' ? criteria.test(value) : false;\n};\n\nexport const predicate = {\n\tnot,\n\tequal,\n\tand,\n\tor,\n\tcontains,\n\tmatchRegExp,\n} as const;\n"],"names":["predicate"],"mappings":"AAEa,MAAA,MAAM,CAAIA,eAA0C;AAChE,SAAO,CAAC,UAA0C,CAACA,WAAU,KAAK;AACnE;AAEa,MAAA,QAAQ,CAAI,aAAgB;AACjC,SAAA,CAAC,UAA6C,UAAU;AAChE;AAEa,MAAA,MAAM,IAAO,eAA6C;AAC/D,SAAA,CAAC,UACP,WAAW,MAAM,CAACA,eAAcA,WAAU,KAAK,CAAC;AAClD;AAEa,MAAA,KAAK,IAAO,eAA6C;AAC9D,SAAA,CAAC,UACP,WAAW,KAAK,CAACA,eAAcA,WAAU,KAAK,CAAC;AACjD;AAEa,MAAA,WAAW,CAAmB,aAAmC;AAC7E,SAAO,CAAC,WACP,+BAAO,SAAS,cAAa;AAC/B;AAEa,MAAA,cAAc,CAAmB,aAAwC;AAC9E,SAAA,CAAC,UACP,OAAO,UAAU,WAAW,SAAS,KAAK,KAAK,IAAI;AACrD;AAEO,MAAM,YAAY;AAAA,EACxB;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AACD;"}
|