@webdeveric/utils 0.45.1 → 0.46.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.
@@ -16,6 +16,7 @@ var __exportStar = (this && this.__exportStar) || function(m, exports) {
16
16
  Object.defineProperty(exports, "__esModule", { value: true });
17
17
  __exportStar(require("./isAnyObject.js"), exports);
18
18
  __exportStar(require("./isAnyObjectWith.js"), exports);
19
+ __exportStar(require("./isAnyObjectWithOwn.js"), exports);
19
20
  __exportStar(require("./isAsyncIterable.js"), exports);
20
21
  __exportStar(require("./isBigInt.js"), exports);
21
22
  __exportStar(require("./isBigIntArray.js"), exports);
@@ -0,0 +1,9 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.isAnyObjectWithOwn = void 0;
4
+ const asArray_js_1 = require("../asArray.js");
5
+ const isAnyObject_js_1 = require("./isAnyObject.js");
6
+ const isAnyObjectWithOwn = (input, properties) => {
7
+ return (0, isAnyObject_js_1.isAnyObject)(input) && (0, asArray_js_1.asArray)(properties).every((property) => Object.hasOwn(input, property));
8
+ };
9
+ exports.isAnyObjectWithOwn = isAnyObjectWithOwn;
@@ -0,0 +1,10 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.createStringLengthRangePredicate = void 0;
4
+ const createStringLengthRangePredicate = (min, max = Number.POSITIVE_INFINITY) => {
5
+ if (min < 0) {
6
+ throw new RangeError('min must be >= 0');
7
+ }
8
+ return (input) => typeof input === 'string' && input.length >= min && input.length <= max;
9
+ };
10
+ exports.createStringLengthRangePredicate = createStringLengthRangePredicate;
@@ -19,6 +19,7 @@ __exportStar(require("./anyOf.js"), exports);
19
19
  __exportStar(require("./createIsEnumPredicate.js"), exports);
20
20
  __exportStar(require("./createIsInstanceOfPredicate.js"), exports);
21
21
  __exportStar(require("./createIsTuplePredicate.js"), exports);
22
+ __exportStar(require("./createStringLengthRangePredicate.js"), exports);
22
23
  __exportStar(require("./createStringMatchingPredicate.js"), exports);
23
24
  __exportStar(require("./everyItem.js"), exports);
24
25
  __exportStar(require("./maybeArray.js"), exports);
@@ -1,5 +1,6 @@
1
1
  export * from './isAnyObject.js';
2
2
  export * from './isAnyObjectWith.js';
3
+ export * from './isAnyObjectWithOwn.js';
3
4
  export * from './isAsyncIterable.js';
4
5
  export * from './isBigInt.js';
5
6
  export * from './isBigIntArray.js';
@@ -0,0 +1,5 @@
1
+ import { asArray } from '../asArray.js';
2
+ import { isAnyObject } from './isAnyObject.js';
3
+ export const isAnyObjectWithOwn = (input, properties) => {
4
+ return isAnyObject(input) && asArray(properties).every((property) => Object.hasOwn(input, property));
5
+ };
@@ -0,0 +1,6 @@
1
+ export const createStringLengthRangePredicate = (min, max = Number.POSITIVE_INFINITY) => {
2
+ if (min < 0) {
3
+ throw new RangeError('min must be >= 0');
4
+ }
5
+ return (input) => typeof input === 'string' && input.length >= min && input.length <= max;
6
+ };
@@ -3,6 +3,7 @@ export * from './anyOf.js';
3
3
  export * from './createIsEnumPredicate.js';
4
4
  export * from './createIsInstanceOfPredicate.js';
5
5
  export * from './createIsTuplePredicate.js';
6
+ export * from './createStringLengthRangePredicate.js';
6
7
  export * from './createStringMatchingPredicate.js';
7
8
  export * from './everyItem.js';
8
9
  export * from './maybeArray.js';
@@ -1,5 +1,6 @@
1
1
  export * from './isAnyObject.js';
2
2
  export * from './isAnyObjectWith.js';
3
+ export * from './isAnyObjectWithOwn.js';
3
4
  export * from './isAsyncIterable.js';
4
5
  export * from './isBigInt.js';
5
6
  export * from './isBigIntArray.js';
@@ -0,0 +1 @@
1
+ export declare const isAnyObjectWithOwn: <T, P extends PropertyKey>(input: T, properties: P | P[]) => input is T & Record<P, unknown>;
@@ -1 +1 @@
1
- export declare const isNonNullable: <T>(input: unknown) => input is NonNullable<T>;
1
+ export declare const isNonNullable: <T>(input: T) => input is NonNullable<T>;
@@ -0,0 +1,2 @@
1
+ import type { TypePredicateFn } from '../types/functions.js';
2
+ export declare const createStringLengthRangePredicate: (min: number, max?: number) => TypePredicateFn<string>;
@@ -3,6 +3,7 @@ export * from './anyOf.js';
3
3
  export * from './createIsEnumPredicate.js';
4
4
  export * from './createIsInstanceOfPredicate.js';
5
5
  export * from './createIsTuplePredicate.js';
6
+ export * from './createStringLengthRangePredicate.js';
6
7
  export * from './createStringMatchingPredicate.js';
7
8
  export * from './everyItem.js';
8
9
  export * from './maybeArray.js';
@@ -1,8 +1,9 @@
1
+ export type IfNever<Type, T, F> = [Type] extends [never] ? T : F;
1
2
  export type IfCommonKeys<Target, Source, T, F> = IfNever<keyof (Target | Source), F, T>;
2
- export type IfDefined<Type, D, U> = undefined extends Type ? U : D;
3
+ export type IfDefined<Type, T, F> = undefined extends Type ? F : T;
4
+ export type IfUnknown<Type, T, F> = unknown extends Type ? T : F;
3
5
  export type IfPromise<Type, T, F> = Type extends Promise<any> ? T : F;
4
- export type NotPromise<T> = T extends Promise<any> ? never : T;
5
- export type IfNever<Type, N, O> = [Type] extends [never] ? N : O;
6
+ export type NotPromise<Type> = Type extends Promise<any> ? never : Type;
6
7
  export type CanBeUndefined<Type, T, F> = Type | undefined extends Type ? T : F;
7
8
  export type ReturnTypeDefault<Func, Default = undefined> = Func extends (...args: any[]) => infer R ? R : Default;
8
9
  export type DeepNonNullable<Type> = Type extends Record<PropertyKey, unknown> ? {
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.45.1",
4
+ "version": "0.46.0",
5
5
  "publishConfig": {
6
6
  "access": "public"
7
7
  },
@@ -87,26 +87,26 @@
87
87
  "devDependencies": {
88
88
  "@commitlint/config-conventional": "^19.6.0",
89
89
  "@commitlint/types": "^19.5.0",
90
- "@types/node": "^22.10.7",
91
- "@vitest/coverage-v8": "^3.0.3",
90
+ "@types/node": "^22.12.0",
91
+ "@vitest/coverage-v8": "^3.0.4",
92
92
  "@webdeveric/eslint-config-ts": "^0.11.0",
93
93
  "@webdeveric/prettier-config": "^0.3.0",
94
94
  "commitlint": "^19.6.1",
95
95
  "commitlint-plugin-cspell": "^0.1.1",
96
96
  "conventional-changelog-conventionalcommits": "^8.0.0",
97
- "cspell": "^8.17.2",
97
+ "cspell": "^8.17.3",
98
98
  "eslint": "^8.57.1",
99
99
  "eslint-config-prettier": "^10.0.1",
100
100
  "eslint-import-resolver-typescript": "^3.7.0",
101
101
  "eslint-plugin-import": "^2.31.0",
102
102
  "husky": "^9.1.7",
103
103
  "jsdom": "^26.0.0",
104
- "lint-staged": "^15.4.1",
104
+ "lint-staged": "^15.4.3",
105
105
  "prettier": "^3.4.2",
106
106
  "rimraf": "^6.0.1",
107
107
  "semantic-release": "^24.2.1",
108
108
  "typescript": "^5.7.3",
109
109
  "validate-package-exports": "^0.8.0",
110
- "vitest": "^3.0.3"
110
+ "vitest": "^3.0.4"
111
111
  }
112
112
  }