@webdeveric/utils 0.52.0 → 0.53.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.
@@ -1,8 +1,23 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.createIsEnumPredicate = void 0;
4
+ const getEnumValues = (enumObject) => {
5
+ const entries = Object.entries(enumObject);
6
+ const ignoreKeys = entries.reduce((keys, [, value]) => {
7
+ if (typeof value === 'number') {
8
+ keys.add(String(value));
9
+ }
10
+ return keys;
11
+ }, new Set());
12
+ return entries.reduce((values, [key, value]) => {
13
+ if (!ignoreKeys.has(key)) {
14
+ values.add(value);
15
+ }
16
+ return values;
17
+ }, new Set());
18
+ };
4
19
  const createIsEnumPredicate = (enumObject) => {
5
- const values = new Set(Object.values(enumObject));
20
+ const values = getEnumValues(enumObject);
6
21
  return (input) => values.has(input);
7
22
  };
8
23
  exports.createIsEnumPredicate = createIsEnumPredicate;
@@ -24,6 +24,7 @@ __exportStar(require("./createObjectShapePredicate.js"), exports);
24
24
  __exportStar(require("./createStringLengthRangePredicate.js"), exports);
25
25
  __exportStar(require("./createStringMatchingPredicate.js"), exports);
26
26
  __exportStar(require("./everyItem.js"), exports);
27
+ __exportStar(require("./is.js"), exports);
27
28
  __exportStar(require("./maybeArray.js"), exports);
28
29
  __exportStar(require("./maybeNull.js"), exports);
29
30
  __exportStar(require("./maybeUndefined.js"), exports);
@@ -0,0 +1,5 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.is = void 0;
4
+ const is = (...options) => (input) => options.some((option) => Object.is(input, option));
5
+ exports.is = is;
@@ -1,4 +1,19 @@
1
+ const getEnumValues = (enumObject) => {
2
+ const entries = Object.entries(enumObject);
3
+ const ignoreKeys = entries.reduce((keys, [, value]) => {
4
+ if (typeof value === 'number') {
5
+ keys.add(String(value));
6
+ }
7
+ return keys;
8
+ }, new Set());
9
+ return entries.reduce((values, [key, value]) => {
10
+ if (!ignoreKeys.has(key)) {
11
+ values.add(value);
12
+ }
13
+ return values;
14
+ }, new Set());
15
+ };
1
16
  export const createIsEnumPredicate = (enumObject) => {
2
- const values = new Set(Object.values(enumObject));
17
+ const values = getEnumValues(enumObject);
3
18
  return (input) => values.has(input);
4
19
  };
@@ -8,6 +8,7 @@ export * from './createObjectShapePredicate.js';
8
8
  export * from './createStringLengthRangePredicate.js';
9
9
  export * from './createStringMatchingPredicate.js';
10
10
  export * from './everyItem.js';
11
+ export * from './is.js';
11
12
  export * from './maybeArray.js';
12
13
  export * from './maybeNull.js';
13
14
  export * from './maybeUndefined.js';
@@ -0,0 +1 @@
1
+ export const is = (...options) => (input) => options.some((option) => Object.is(input, option));
@@ -8,6 +8,7 @@ export * from './createObjectShapePredicate.js';
8
8
  export * from './createStringLengthRangePredicate.js';
9
9
  export * from './createStringMatchingPredicate.js';
10
10
  export * from './everyItem.js';
11
+ export * from './is.js';
11
12
  export * from './maybeArray.js';
12
13
  export * from './maybeNull.js';
13
14
  export * from './maybeUndefined.js';
@@ -0,0 +1,3 @@
1
+ import type { TypePredicateFn } from '../types/functions.js';
2
+ import type { Pretty, Writable } from '../types/utils.js';
3
+ export declare const is: <const T extends unknown[]>(...options: T) => TypePredicateFn<Pretty<Writable<T[number]>>>;
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.52.0",
4
+ "version": "0.53.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@10.5.0+sha512.11106a5916c7406fe4b8cb8e3067974b8728f47308a4f5ac5e850304afa6f57e2847d7950dfe78877d8d36bfb401d381c4215db3a4c3547ffa63c14333a6fa51",
69
+ "packageManager": "pnpm@10.6.1+sha512.40ee09af407fa9fbb5fbfb8e1cb40fbb74c0af0c3e10e9224d7b53c7658528615b2c92450e74cfad91e3a2dcafe3ce4050d80bda71d757756d2ce2b66213e9a3",
70
70
  "scripts": {
71
71
  "clean": "rimraf ./dist/",
72
72
  "prebuild": "pnpm clean",
@@ -85,28 +85,28 @@
85
85
  },
86
86
  "prettier": "@webdeveric/prettier-config",
87
87
  "devDependencies": {
88
- "@commitlint/config-conventional": "^19.7.1",
89
- "@commitlint/types": "^19.5.0",
90
- "@types/node": "^22.13.8",
91
- "@vitest/coverage-v8": "^3.0.7",
88
+ "@commitlint/config-conventional": "^19.8.0",
89
+ "@commitlint/types": "^19.8.0",
90
+ "@types/node": "^22.13.10",
91
+ "@vitest/coverage-v8": "^3.0.8",
92
92
  "@webdeveric/eslint-config-ts": "^0.11.0",
93
93
  "@webdeveric/prettier-config": "^0.3.0",
94
- "commitlint": "^19.7.1",
94
+ "commitlint": "^19.8.0",
95
95
  "commitlint-plugin-cspell": "^0.1.1",
96
96
  "conventional-changelog-conventionalcommits": "^8.0.0",
97
97
  "cspell": "^8.17.5",
98
98
  "eslint": "^8.57.1",
99
- "eslint-config-prettier": "^10.0.2",
99
+ "eslint-config-prettier": "^10.1.1",
100
100
  "eslint-import-resolver-typescript": "^3.8.3",
101
101
  "eslint-plugin-import": "^2.31.0",
102
102
  "husky": "^9.1.7",
103
103
  "jsdom": "^26.0.0",
104
104
  "lint-staged": "^15.4.3",
105
- "prettier": "^3.5.2",
105
+ "prettier": "^3.5.3",
106
106
  "rimraf": "^6.0.1",
107
107
  "semantic-release": "^24.2.3",
108
108
  "typescript": "^5.8.2",
109
109
  "validate-package-exports": "^0.8.0",
110
- "vitest": "^3.0.7"
110
+ "vitest": "^3.0.8"
111
111
  }
112
112
  }