@alexaegis/predicate 0.3.1 → 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 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) => (value == null ? void 0 : value.includes(criteria)) ?? false;
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":["../../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,0BAA0B,CAAC"}
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) => (value == null ? void 0 : value.includes(criteria)) ?? false;
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
@@ -0,0 +1,2 @@
1
+ export {};
2
+ //# sourceMappingURL=index.spec.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.spec.d.ts","sourceRoot":"","sources":["../../../src/index.spec.ts"],"names":[],"mappings":""}
@@ -1,13 +1,13 @@
1
- export type Predicate<T> = (value?: T) => boolean;
1
+ export type Predicate<T> = (value?: T | undefined | null) => boolean;
2
2
  export declare const not: <T>(predicate: Predicate<T>) => Predicate<T>;
3
- export declare const equal: <T>(criteria: T) => (value?: T | undefined) => value is T;
3
+ export declare const equal: <T>(criteria: T) => (value?: T | null | undefined) => 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_1>(criteria: T_1) => (value?: T_1 | undefined) => value is T_1;
10
+ readonly equal: <T_1>(criteria: T_1) => (value?: T_1 | null | undefined) => value is T_1;
11
11
  readonly and: <T_2>(...predicates: Predicate<T_2>[]) => Predicate<T_2>;
12
12
  readonly or: <T_3>(...predicates: Predicate<T_3>[]) => Predicate<T_3>;
13
13
  readonly contains: <T_4 extends string>(criteria: T_4) => 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,KAAK,OAAO,CAAC;AAElD,eAAO,MAAM,GAAG,8CAEf,CAAC;AAEF,eAAO,MAAM,KAAK,2DAEjB,CAAC;AAEF,eAAO,MAAM,GAAG,oDAEf,CAAC;AAEF,eAAO,MAAM,EAAE,oDAEd,CAAC;AAEF,eAAO,MAAM,QAAQ,qCAAoC,UAAU,MAAM,CAExE,CAAC;AAEF,eAAO,MAAM,WAAW,+BAAgC,MAAM,KAAG,UAAU,MAAM,CAGhF,CAAC;AAEF,eAAO,MAAM,SAAS;;;;;8DATmC,UAAU,MAAM,CAAC;yDAIlB,MAAM,KAAG,UAAU,MAAM,CAAC;CAYxE,CAAC"}
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,2 @@
1
+ export {};
2
+ //# sourceMappingURL=predicates.spec.d.ts.map
@@ -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.3.1",
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/js-core",
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/js-core/issues"
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.3",
57
- "@alexaegis/ts": "^0.3.3",
58
- "@alexaegis/vite": "^0.3.3",
59
- "@alexaegis/vitest": "^0.3.3",
60
- "@types/node": "^20.3.2",
61
- "publint": "^0.1.13",
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
+ "@types/node": "^20.3.3",
61
+ "publint": "^0.1.15",
62
62
  "typescript": "^5.1.6",
63
63
  "vite": "^4.3.9",
64
- "vitest": "^0.32.2"
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/js-core/tree/master/packages/predicate)
1
+ # [@alexaegis/predicate](https://github.com/AlexAegis/common/tree/master/packages/predicate)
2
2
 
3
3
  [![npm](https://img.shields.io/npm/v/@alexaegis/predicate/latest)](https://www.npmjs.com/package/@alexaegis/predicate)
4
- [![ci](https://github.com/AlexAegis/js-core/actions/workflows/cicd.yml/badge.svg)](https://github.com/AlexAegis/js-core/actions/workflows/cicd.yml)
5
- [![codacy](https://app.codacy.com/project/badge/Grade/402dd6d7fcbd4cde86fdf8e7d948fcde)](https://www.codacy.com/gh/AlexAegis/js-core/dashboard?utm_source=github.com&utm_medium=referral&utm_content=AlexAegis/js-core&utm_campaign=Badge_Grade)
6
- [![codecov](https://codecov.io/gh/AlexAegis/js-core/branch/master/graph/badge.svg?token=kw8ZeoPbUh)](https://codecov.io/gh/AlexAegis/js-core)
4
+ [![ci](https://github.com/AlexAegis/common/actions/workflows/cicd.yml/badge.svg)](https://github.com/AlexAegis/common/actions/workflows/cicd.yml)
5
+ [![codacy](https://app.codacy.com/project/badge/Grade/402dd6d7fcbd4cde86fdf8e7d948fcde)](https://www.codacy.com/gh/AlexAegis/common/dashboard?utm_source=github.com&utm_medium=referral&utm_content=AlexAegis/common&utm_campaign=Badge_Grade)
6
+ [![codecov](https://codecov.io/gh/AlexAegis/common/branch/master/graph/badge.svg?token=kw8ZeoPbUh)](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) => boolean;\n\nexport const not = <T>(predicate: Predicate<T>): Predicate<T> => {\n\treturn (value?: T): boolean => !predicate(value);\n};\n\nexport const equal = <T>(criteria: T) => {\n\treturn (value?: T): value is T => value === criteria;\n};\n\nexport const and = <T>(...predicates: Predicate<T>[]): Predicate<T> => {\n\treturn (value?: T): boolean => predicates.every((predicate) => predicate(value));\n};\n\nexport const or = <T>(...predicates: Predicate<T>[]): Predicate<T> => {\n\treturn (value?: T): boolean => predicates.some((predicate) => predicate(value));\n};\n\nexport const contains = <T extends string>(criteria: T): Predicate<string> => {\n\treturn (value?: T | string): value is string => value?.includes(criteria) ?? false;\n};\n\nexport const matchRegExp = <T extends string>(criteria: RegExp): Predicate<string> => {\n\treturn (value?: T | string): 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,UAAuB,CAACA,WAAU,KAAK;AAChD;AAEa,MAAA,QAAQ,CAAI,aAAgB;AACjC,SAAA,CAAC,UAA0B,UAAU;AAC7C;AAEa,MAAA,MAAM,IAAO,eAA6C;AAC/D,SAAA,CAAC,UAAuB,WAAW,MAAM,CAACA,eAAcA,WAAU,KAAK,CAAC;AAChF;AAEa,MAAA,KAAK,IAAO,eAA6C;AAC9D,SAAA,CAAC,UAAuB,WAAW,KAAK,CAACA,eAAcA,WAAU,KAAK,CAAC;AAC/E;AAEa,MAAA,WAAW,CAAmB,aAAmC;AAC7E,SAAO,CAAC,WAAwC,+BAAO,SAAS,cAAa;AAC9E;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) => boolean;\n\nexport const not = <T>(predicate: Predicate<T>): Predicate<T> => {\n\treturn (value?: T): boolean => !predicate(value);\n};\n\nexport const equal = <T>(criteria: T) => {\n\treturn (value?: T): value is T => value === criteria;\n};\n\nexport const and = <T>(...predicates: Predicate<T>[]): Predicate<T> => {\n\treturn (value?: T): boolean => predicates.every((predicate) => predicate(value));\n};\n\nexport const or = <T>(...predicates: Predicate<T>[]): Predicate<T> => {\n\treturn (value?: T): boolean => predicates.some((predicate) => predicate(value));\n};\n\nexport const contains = <T extends string>(criteria: T): Predicate<string> => {\n\treturn (value?: T | string): value is string => value?.includes(criteria) ?? false;\n};\n\nexport const matchRegExp = <T extends string>(criteria: RegExp): Predicate<string> => {\n\treturn (value?: T | string): 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,UAAuB,CAACA,WAAU,KAAK;AAChD;AAEa,MAAA,QAAQ,CAAI,aAAgB;AACjC,SAAA,CAAC,UAA0B,UAAU;AAC7C;AAEa,MAAA,MAAM,IAAO,eAA6C;AAC/D,SAAA,CAAC,UAAuB,WAAW,MAAM,CAACA,eAAcA,WAAU,KAAK,CAAC;AAChF;AAEa,MAAA,KAAK,IAAO,eAA6C;AAC9D,SAAA,CAAC,UAAuB,WAAW,KAAK,CAACA,eAAcA,WAAU,KAAK,CAAC;AAC/E;AAEa,MAAA,WAAW,CAAmB,aAAmC;AAC7E,SAAO,CAAC,WAAwC,+BAAO,SAAS,cAAa;AAC9E;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;"}