Comparing version 1.0.0 to 1.1.0
@@ -1,4 +0,4 @@ | ||
import { BasePredicate } from './predicates/base-predicate.js'; | ||
import { Modifiers } from './modifiers.js'; | ||
import { Predicates } from './predicates.js'; | ||
import { type BasePredicate } from './predicates/base-predicate.js'; | ||
import { type Modifiers } from './modifiers.js'; | ||
import { type Predicates } from './predicates.js'; | ||
/** | ||
@@ -23,3 +23,3 @@ @hidden | ||
export declare type Infer<P> = P extends BasePredicate<infer T> ? T : never; | ||
export interface Ow extends Modifiers, Predicates { | ||
export declare type Ow = { | ||
/** | ||
@@ -53,7 +53,7 @@ Test if the value matches the predicate. Throws an `ArgumentError` if the test fails. | ||
create: (<T>(predicate: BasePredicate<T>) => ReusableValidator<T>) & (<T>(label: string, predicate: BasePredicate<T>) => ReusableValidator<T>); | ||
} | ||
} & Modifiers & Predicates; | ||
/** | ||
A reusable validator. | ||
*/ | ||
export interface ReusableValidator<T> { | ||
export declare type ReusableValidator<T> = { | ||
/** | ||
@@ -66,3 +66,3 @@ Test if the value matches the predicate. Throws an `ArgumentError` if the test fails. | ||
(value: unknown | T, label?: string): void; | ||
} | ||
}; | ||
/** | ||
@@ -69,0 +69,0 @@ Turn a `ReusableValidator` into one with a type assertion. |
@@ -1,5 +0,5 @@ | ||
import { Predicates } from './predicates.js'; | ||
import { BasePredicate } from './index.js'; | ||
import { type Predicates } from './predicates.js'; | ||
import type { BasePredicate } from './index.js'; | ||
declare type Optionalify<P> = P extends BasePredicate<infer X> ? P & BasePredicate<X | undefined> : P; | ||
export interface Modifiers { | ||
export declare type Modifiers = { | ||
/** | ||
@@ -11,4 +11,4 @@ Make the following predicate optional so it doesn't fail when the value is `undefined`. | ||
}; | ||
} | ||
}; | ||
declare const modifiers: <T>(object: T) => T & Modifiers; | ||
export default modifiers; |
/// <reference types="node" resolution-mode="require"/> | ||
import type { Buffer } from 'node:buffer'; | ||
import { TypedArray } from 'type-fest'; | ||
import type { TypedArray } from './typed-array.js'; | ||
import { StringPredicate } from './predicates/string.js'; | ||
@@ -8,3 +8,3 @@ import { NumberPredicate } from './predicates/number.js'; | ||
import { BooleanPredicate } from './predicates/boolean.js'; | ||
import { Predicate, PredicateOptions } from './predicates/predicate.js'; | ||
import { Predicate, type PredicateOptions } from './predicates/predicate.js'; | ||
import { ArrayPredicate } from './predicates/array.js'; | ||
@@ -21,5 +21,5 @@ import { ObjectPredicate } from './predicates/object.js'; | ||
import { DataViewPredicate } from './predicates/data-view.js'; | ||
import { BasePredicate } from './predicates/base-predicate.js'; | ||
import type { BasePredicate } from './predicates/base-predicate.js'; | ||
import { AnyPredicate } from './predicates/any.js'; | ||
export interface Predicates { | ||
export declare type Predicates = { | ||
/** | ||
@@ -169,3 +169,3 @@ Test the value to be a string. | ||
any: (<T1>(p1: BasePredicate<T1>) => AnyPredicate<T1>) & (<T1, T2>(p1: BasePredicate<T1>, p2: BasePredicate<T2>) => AnyPredicate<T1 | T2>) & (<T1, T2, T3>(p1: BasePredicate<T1>, p2: BasePredicate<T2>, p3: BasePredicate<T3>) => AnyPredicate<T1 | T2 | T3>) & (<T1, T2, T3, T4>(p1: BasePredicate<T1>, p2: BasePredicate<T2>, p3: BasePredicate<T3>, p4: BasePredicate<T4>) => AnyPredicate<T1 | T2 | T3 | T4>) & (<T1, T2, T3, T4, T5>(p1: BasePredicate<T1>, p2: BasePredicate<T2>, p3: BasePredicate<T3>, p4: BasePredicate<T4>, p5: BasePredicate<T5>) => AnyPredicate<T1 | T2 | T3 | T4 | T5>) & (<T1, T2, T3, T4, T5, T6>(p1: BasePredicate<T1>, p2: BasePredicate<T2>, p3: BasePredicate<T3>, p4: BasePredicate<T4>, p5: BasePredicate<T5>, p6: BasePredicate<T6>) => AnyPredicate<T1 | T2 | T3 | T4 | T5 | T6>) & (<T1, T2, T3, T4, T5, T6, T7>(p1: BasePredicate<T1>, p2: BasePredicate<T2>, p3: BasePredicate<T3>, p4: BasePredicate<T4>, p5: BasePredicate<T5>, p6: BasePredicate<T6>, p7: BasePredicate<T7>) => AnyPredicate<T1 | T2 | T3 | T4 | T5 | T6 | T7>) & (<T1, T2, T3, T4, T5, T6, T7, T8>(p1: BasePredicate<T1>, p2: BasePredicate<T2>, p3: BasePredicate<T3>, p4: BasePredicate<T4>, p5: BasePredicate<T5>, p6: BasePredicate<T6>, p7: BasePredicate<T7>, p8: BasePredicate<T8>) => AnyPredicate<T1 | T2 | T3 | T4 | T5 | T6 | T7 | T8>) & (<T1, T2, T3, T4, T5, T6, T7, T8, T9>(p1: BasePredicate<T1>, p2: BasePredicate<T2>, p3: BasePredicate<T3>, p4: BasePredicate<T4>, p5: BasePredicate<T5>, p6: BasePredicate<T6>, p7: BasePredicate<T7>, p8: BasePredicate<T8>, p9: BasePredicate<T9>) => AnyPredicate<T1 | T2 | T3 | T4 | T5 | T6 | T7 | T8 | T9>) & (<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10>(p1: BasePredicate<T1>, p2: BasePredicate<T2>, p3: BasePredicate<T3>, p4: BasePredicate<T4>, p5: BasePredicate<T5>, p6: BasePredicate<T6>, p7: BasePredicate<T7>, p8: BasePredicate<T8>, p9: BasePredicate<T9>, p10: BasePredicate<T10>) => AnyPredicate<T1 | T2 | T3 | T4 | T5 | T6 | T7 | T8 | T9 | T10>) & ((...predicate: BasePredicate[]) => AnyPredicate); | ||
} | ||
}; | ||
declare const predicates: <T>(object: T, options?: PredicateOptions) => T & Predicates; | ||
@@ -172,0 +172,0 @@ export default predicates; |
@@ -1,4 +0,4 @@ | ||
import { Main } from '../index.js'; | ||
import { BasePredicate, testSymbol } from './base-predicate.js'; | ||
import { PredicateOptions } from './predicate.js'; | ||
import type { Main } from '../index.js'; | ||
import { testSymbol, type BasePredicate } from './base-predicate.js'; | ||
import type { PredicateOptions } from './predicate.js'; | ||
/** | ||
@@ -5,0 +5,0 @@ @hidden |
@@ -1,3 +0,3 @@ | ||
import { BasePredicate } from './base-predicate.js'; | ||
import { Predicate, PredicateOptions } from './predicate.js'; | ||
import type { BasePredicate } from './base-predicate.js'; | ||
import { Predicate, type PredicateOptions } from './predicate.js'; | ||
export declare class ArrayPredicate<T = unknown> extends Predicate<T[]> { | ||
@@ -4,0 +4,0 @@ /** |
@@ -1,2 +0,2 @@ | ||
import { Main } from '../index.js'; | ||
import type { Main } from '../index.js'; | ||
/** | ||
@@ -13,4 +13,4 @@ @hidden | ||
*/ | ||
export interface BasePredicate<T = unknown> { | ||
export declare type BasePredicate<T = unknown> = { | ||
[testSymbol](value: T, main: Main, label: string | Function, idLabel?: boolean): void; | ||
} | ||
}; |
@@ -1,2 +0,2 @@ | ||
import { Predicate, PredicateOptions } from './predicate.js'; | ||
import { Predicate, type PredicateOptions } from './predicate.js'; | ||
export declare class BigIntPredicate extends Predicate<bigint> { | ||
@@ -3,0 +3,0 @@ /** |
@@ -1,2 +0,2 @@ | ||
import { Predicate, PredicateOptions } from './predicate.js'; | ||
import { Predicate, type PredicateOptions } from './predicate.js'; | ||
export declare class BooleanPredicate extends Predicate<boolean> { | ||
@@ -3,0 +3,0 @@ /** |
@@ -1,2 +0,2 @@ | ||
import { Predicate, PredicateOptions } from './predicate.js'; | ||
import { Predicate, type PredicateOptions } from './predicate.js'; | ||
export declare class DataViewPredicate extends Predicate<DataView> { | ||
@@ -3,0 +3,0 @@ /** |
@@ -1,2 +0,2 @@ | ||
import { Predicate, PredicateOptions } from './predicate.js'; | ||
import { Predicate, type PredicateOptions } from './predicate.js'; | ||
export declare class DatePredicate extends Predicate<Date> { | ||
@@ -3,0 +3,0 @@ /** |
@@ -1,2 +0,2 @@ | ||
import { Predicate, PredicateOptions } from './predicate.js'; | ||
import { Predicate, type PredicateOptions } from './predicate.js'; | ||
export declare class ErrorPredicate extends Predicate<Error> { | ||
@@ -3,0 +3,0 @@ /** |
@@ -1,2 +0,2 @@ | ||
import { Predicate, PredicateOptions } from './predicate.js'; | ||
import { Predicate, type PredicateOptions } from './predicate.js'; | ||
export declare class MapPredicate<T1 = unknown, T2 = unknown> extends Predicate<Map<T1, T2>> { | ||
@@ -3,0 +3,0 @@ /** |
@@ -1,2 +0,2 @@ | ||
import { Predicate, PredicateOptions } from './predicate.js'; | ||
import { Predicate, type PredicateOptions } from './predicate.js'; | ||
export declare class NumberPredicate extends Predicate<number> { | ||
@@ -3,0 +3,0 @@ /** |
@@ -1,4 +0,4 @@ | ||
import { Shape, TypeOfShape } from '../utils/match-shape.js'; | ||
import { Predicate, PredicateOptions } from './predicate.js'; | ||
import { BasePredicate } from './base-predicate.js'; | ||
import { type Shape, type TypeOfShape } from '../utils/match-shape.js'; | ||
import { Predicate, type PredicateOptions } from './predicate.js'; | ||
import type { BasePredicate } from './base-predicate.js'; | ||
export declare class ObjectPredicate<T extends object = object> extends Predicate<T> { | ||
@@ -5,0 +5,0 @@ /** |
@@ -1,3 +0,3 @@ | ||
import { Main } from '../index.js'; | ||
import { BasePredicate, testSymbol } from './base-predicate.js'; | ||
import type { Main } from '../index.js'; | ||
import { testSymbol, type BasePredicate } from './base-predicate.js'; | ||
/** | ||
@@ -15,3 +15,3 @@ Function executed when the provided validation fails. | ||
*/ | ||
export interface Validator<T> { | ||
export declare type Validator<T> = { | ||
message(value: T, label?: string, result?: any): string; | ||
@@ -25,15 +25,15 @@ validator(value: T): unknown; | ||
negatedMessage?(value: T, label: string): string; | ||
} | ||
}; | ||
/** | ||
@hidden | ||
*/ | ||
export interface PredicateOptions { | ||
export declare type PredicateOptions = { | ||
optional?: boolean; | ||
} | ||
}; | ||
/** | ||
@hidden | ||
*/ | ||
export interface Context<T = unknown> extends PredicateOptions { | ||
export declare type Context<T = unknown> = { | ||
validators: Array<Validator<T>>; | ||
} | ||
} & PredicateOptions; | ||
/** | ||
@@ -40,0 +40,0 @@ @hidden |
@@ -1,2 +0,2 @@ | ||
import { Predicate, PredicateOptions } from './predicate.js'; | ||
import { Predicate, type PredicateOptions } from './predicate.js'; | ||
export declare class SetPredicate<T = any> extends Predicate<Set<T>> { | ||
@@ -3,0 +3,0 @@ /** |
@@ -1,2 +0,2 @@ | ||
import { Predicate, PredicateOptions } from './predicate.js'; | ||
import { Predicate, type PredicateOptions } from './predicate.js'; | ||
export declare class StringPredicate extends Predicate<string> { | ||
@@ -3,0 +3,0 @@ /** |
@@ -1,2 +0,2 @@ | ||
import { TypedArray } from 'type-fest'; | ||
import type { TypedArray } from '../typed-array.js'; | ||
import { Predicate } from './predicate.js'; | ||
@@ -3,0 +3,0 @@ export declare class TypedArrayPredicate<T extends TypedArray> extends Predicate<T> { |
@@ -1,2 +0,2 @@ | ||
import { Predicate, PredicateOptions } from './predicate.js'; | ||
import { Predicate, type PredicateOptions } from './predicate.js'; | ||
export declare class WeakMapPredicate<KeyType extends object = object> extends Predicate<WeakMap<KeyType, unknown>> { | ||
@@ -3,0 +3,0 @@ /** |
@@ -1,2 +0,2 @@ | ||
import { Predicate, PredicateOptions } from './predicate.js'; | ||
import { Predicate, type PredicateOptions } from './predicate.js'; | ||
export declare class WeakSetPredicate<T extends object = object> extends Predicate<WeakSet<T>> { | ||
@@ -3,0 +3,0 @@ /** |
@@ -1,2 +0,2 @@ | ||
import { BasePredicate } from './predicates/base-predicate.js'; | ||
import { type BasePredicate } from './predicates/base-predicate.js'; | ||
/** | ||
@@ -3,0 +3,0 @@ Validate the value against the provided predicate. |
/** | ||
@hidden | ||
*/ | ||
export interface CollectionLike<T> { | ||
export declare type CollectionLike<T> = { | ||
has: (item: T) => boolean; | ||
} | ||
}; | ||
/** | ||
@@ -8,0 +8,0 @@ Retrieve the missing values in a collection based on an array of items. |
@@ -1,2 +0,2 @@ | ||
import { CallSite } from 'callsites'; | ||
import type { CallSite } from 'callsites'; | ||
/** | ||
@@ -3,0 +3,0 @@ Infer the label of the caller. |
@@ -1,2 +0,2 @@ | ||
import * as fs from 'node:fs'; | ||
import fs from 'node:fs'; | ||
import isValidIdentifier from './is-valid-identifier.js'; | ||
@@ -48,3 +48,3 @@ import isNode from './node/is-node.js'; | ||
} | ||
if (isValidIdentifier(token) || isValidIdentifier(token.split('.').pop())) { | ||
if (isValidIdentifier(token) || isValidIdentifier(token.split('.').pop() ?? '')) { | ||
return token; | ||
@@ -51,0 +51,0 @@ } |
@@ -6,3 +6,3 @@ /** | ||
*/ | ||
declare const isValidIdentifier: (string: string | undefined) => string | boolean | undefined; | ||
declare const isValidIdentifier: (string: string) => boolean; | ||
export default isValidIdentifier; |
@@ -17,3 +17,3 @@ const identifierRegex = /^[a-z$_][$\w]*$/i; | ||
*/ | ||
const isValidIdentifier = (string) => string && !reservedSet.has(string) && identifierRegex.test(string); | ||
const isValidIdentifier = (string) => Boolean(string?.length > 0 && !reservedSet.has(string) && identifierRegex.test(string)); | ||
export default isValidIdentifier; |
@@ -1,5 +0,5 @@ | ||
import { BasePredicate } from '../index.js'; | ||
export interface Shape { | ||
import type { BasePredicate } from '../index.js'; | ||
export declare type Shape = { | ||
[key: string]: BasePredicate | Shape; | ||
} | ||
}; | ||
/** | ||
@@ -6,0 +6,0 @@ Extracts a regular type from a shape definition. |
@@ -1,2 +0,2 @@ | ||
import { Predicate } from '../predicates/predicate.js'; | ||
import type { Predicate } from '../predicates/predicate.js'; | ||
/** | ||
@@ -3,0 +3,0 @@ Test all the values in the object against a provided predicate. |
@@ -1,2 +0,2 @@ | ||
import { BasePredicate } from '../predicates/base-predicate.js'; | ||
import type { BasePredicate } from '../predicates/base-predicate.js'; | ||
/** | ||
@@ -3,0 +3,0 @@ Test all the values in the collection against a provided predicate. |
{ | ||
"name": "ow", | ||
"version": "1.0.0", | ||
"version": "1.1.0", | ||
"description": "Function argument validation for humans", | ||
@@ -24,2 +24,3 @@ "license": "MIT", | ||
}, | ||
"sideEffects": false, | ||
"engines": { | ||
@@ -61,7 +62,6 @@ "node": ">=14.16" | ||
"dependencies": { | ||
"@sindresorhus/is": "^5.1.0", | ||
"@sindresorhus/is": "^5.3.0", | ||
"callsites": "^4.0.0", | ||
"dot-prop": "^7.2.0", | ||
"lodash.isequal": "^4.5.0", | ||
"type-fest": "^2.13.0", | ||
"vali-date": "^1.0.0" | ||
@@ -72,13 +72,13 @@ }, | ||
"@types/lodash.isequal": "^4.5.6", | ||
"@types/node": "^17.0.42", | ||
"@types/node": "^18.8.0", | ||
"@types/vali-date": "^1.0.0", | ||
"ava": "^4.3.0", | ||
"c8": "^7.11.3", | ||
"del-cli": "^4.0.1", | ||
"expect-type": "^0.13.0", | ||
"ava": "^4.3.3", | ||
"c8": "^7.12.0", | ||
"del-cli": "^5.0.0", | ||
"expect-type": "^0.14.2", | ||
"gh-pages": "^4.0.0", | ||
"ts-node": "^10.8.1", | ||
"typedoc": "^0.22.17", | ||
"typescript": "^4.7.3", | ||
"xo": "^0.50.0" | ||
"ts-node": "^10.9.1", | ||
"typedoc": "^0.23.15", | ||
"typescript": "^4.8.4", | ||
"xo": "^0.52.3" | ||
}, | ||
@@ -88,3 +88,2 @@ "browser": { | ||
}, | ||
"sideEffects": false, | ||
"xo": { | ||
@@ -98,3 +97,2 @@ "ignores": [ | ||
"no-useless-return": "off", | ||
"ava/no-ignored-test-files": "off", | ||
"@typescript-eslint/explicit-function-return-type": "error", | ||
@@ -104,4 +102,3 @@ "@typescript-eslint/ban-types": "off", | ||
"@typescript-eslint/no-empty-function": "off", | ||
"@typescript-eslint/restrict-template-expressions": "off", | ||
"@typescript-eslint/no-unused-vars": "off" | ||
"@typescript-eslint/restrict-template-expressions": "off" | ||
} | ||
@@ -108,0 +105,0 @@ }, |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
130518
5
76
3237
- Removedtype-fest@^2.13.0
Updated@sindresorhus/is@^5.3.0