Comparing version 0.2.0 to 0.3.0
@@ -8,2 +8,2 @@ import { Predicate } from '../predicates/predicate'; | ||
*/ | ||
export declare const not: <T extends Predicate<any>>(predicate: T) => T; | ||
export declare const not: <T, P extends Predicate<T>>(predicate: P) => P; |
import { Predicate, Context } from './predicate'; | ||
export declare class ArrayPredicate extends Predicate<any[]> { | ||
export declare class ArrayPredicate<T = any> extends Predicate<T[]> { | ||
/** | ||
* @hidden | ||
*/ | ||
constructor(context?: Context); | ||
constructor(context?: Context<T[]>); | ||
/** | ||
@@ -30,3 +30,3 @@ * Test an array to have a specific length. | ||
*/ | ||
startsWith(searchElement: any): this; | ||
startsWith(searchElement: T): this; | ||
/** | ||
@@ -37,3 +37,3 @@ * Test an array to end with a specific value. The value is tested by identity, not structure. | ||
*/ | ||
endsWith(searchElement: any): this; | ||
endsWith(searchElement: T): this; | ||
/** | ||
@@ -44,3 +44,3 @@ * Test an array to include all the provided elements. The values are tested by identity, not structure. | ||
*/ | ||
includes(...searchElements: any[]): this; | ||
includes(...searchElements: T[]): this; | ||
/** | ||
@@ -51,3 +51,3 @@ * Test an array to include any of the provided elements. The values are tested by identity, not structure. | ||
*/ | ||
includesAny(...searchElements: any[]): this; | ||
includesAny(...searchElements: T[]): this; | ||
/** | ||
@@ -66,3 +66,3 @@ * Test an array to be empty. | ||
*/ | ||
deepEqual(expected: any[]): this; | ||
deepEqual(expected: T[]): this; | ||
/** | ||
@@ -73,3 +73,3 @@ * Test all elements in the array to match to provided predicate. | ||
*/ | ||
ofType<T>(predicate: Predicate<T>): this; | ||
ofType(predicate: Predicate<T>): this; | ||
} |
@@ -6,3 +6,3 @@ import { Predicate, Context } from './predicate'; | ||
*/ | ||
constructor(context?: Context); | ||
constructor(context?: Context<boolean>); | ||
/** | ||
@@ -9,0 +9,0 @@ * Test a boolean to be true. |
@@ -6,3 +6,3 @@ import { Predicate, Context } from './predicate'; | ||
*/ | ||
constructor(context?: Context); | ||
constructor(context?: Context<Date>); | ||
/** | ||
@@ -9,0 +9,0 @@ * Test a date to be before another date. |
@@ -6,3 +6,3 @@ import { Predicate, Context } from './predicate'; | ||
*/ | ||
constructor(context?: Context); | ||
constructor(context?: Context<Error>); | ||
/** | ||
@@ -9,0 +9,0 @@ * Test an error to have a specific name. |
import { Predicate, Context } from './predicate'; | ||
export declare class MapPredicate extends Predicate<Map<any, any>> { | ||
export declare class MapPredicate<T1 = any, T2 = any> extends Predicate<Map<T1, T2>> { | ||
/** | ||
* @hidden | ||
*/ | ||
constructor(context?: Context); | ||
constructor(context?: Context<Map<T1, T2>>); | ||
/** | ||
@@ -30,3 +30,3 @@ * Test a Map to have a specific size. | ||
*/ | ||
hasKeys(...keys: any[]): this; | ||
hasKeys(...keys: T1[]): this; | ||
/** | ||
@@ -37,3 +37,3 @@ * Test a Map to include any of the provided keys. The keys are tested by identity, not structure. | ||
*/ | ||
hasAnyKeys(...keys: any[]): this; | ||
hasAnyKeys(...keys: T1[]): this; | ||
/** | ||
@@ -44,3 +44,3 @@ * Test a Map to include all the provided values. The values are tested by identity, not structure. | ||
*/ | ||
hasValues(...values: any[]): this; | ||
hasValues(...values: T2[]): this; | ||
/** | ||
@@ -51,3 +51,3 @@ * Test a Map to include any of the provided values. The values are tested by identity, not structure. | ||
*/ | ||
hasAnyValues(...values: any[]): this; | ||
hasAnyValues(...values: T2[]): this; | ||
/** | ||
@@ -58,3 +58,3 @@ * Test all the keys in the Map to match the provided predicate. | ||
*/ | ||
keysOfType<T>(predicate: Predicate<T>): this; | ||
keysOfType(predicate: Predicate<T1>): this; | ||
/** | ||
@@ -65,3 +65,3 @@ * Test all the values in the Map to match the provided predicate. | ||
*/ | ||
valuesOfType<T>(predicate: Predicate<T>): this; | ||
valuesOfType(predicate: Predicate<T2>): this; | ||
/** | ||
@@ -80,3 +80,3 @@ * Test a Map to be empty. | ||
*/ | ||
deepEqual(expected: Map<any, any>): this; | ||
deepEqual(expected: Map<T1, T2>): this; | ||
} |
@@ -6,3 +6,3 @@ import { Predicate, Context } from './predicate'; | ||
*/ | ||
constructor(context?: Context); | ||
constructor(context?: Context<number>); | ||
/** | ||
@@ -9,0 +9,0 @@ * Test a number to be in a specified range. |
@@ -6,3 +6,3 @@ import { Predicate, Context } from './predicate'; | ||
*/ | ||
constructor(context?: Context); | ||
constructor(context?: Context<object>); | ||
/** | ||
@@ -9,0 +9,0 @@ * Test if an Object is a plain object. |
@@ -13,4 +13,4 @@ import { Ow } from '../..'; | ||
*/ | ||
export interface Context { | ||
validators: Validator<any>[]; | ||
export interface Context<T> { | ||
validators: Validator<T>[]; | ||
} | ||
@@ -26,3 +26,3 @@ /** | ||
private readonly context; | ||
constructor(type: string, context?: Context); | ||
constructor(type: string, context?: Context<T>); | ||
/** | ||
@@ -35,3 +35,3 @@ * @hidden | ||
*/ | ||
readonly [validatorSymbol]: Validator<any>[]; | ||
readonly [validatorSymbol]: Validator<T>[]; | ||
/** | ||
@@ -38,0 +38,0 @@ * Invert the following validators. |
import { Predicate, Context } from './predicate'; | ||
export declare class SetPredicate extends Predicate<Set<any>> { | ||
export declare class SetPredicate<T = any> extends Predicate<Set<T>> { | ||
/** | ||
* @hidden | ||
*/ | ||
constructor(context?: Context); | ||
constructor(context?: Context<Set<T>>); | ||
/** | ||
@@ -30,3 +30,3 @@ * Test a Set to have a specific size. | ||
*/ | ||
has(...items: any[]): this; | ||
has(...items: T[]): this; | ||
/** | ||
@@ -37,3 +37,3 @@ * Test a Set to include any of the provided items. The items are tested by identity, not structure. | ||
*/ | ||
hasAny(...items: any[]): this; | ||
hasAny(...items: T[]): this; | ||
/** | ||
@@ -44,3 +44,3 @@ * Test all the items in the Set to match the provided predicate. | ||
*/ | ||
ofType<T>(predicate: Predicate<T>): this; | ||
ofType(predicate: Predicate<T>): this; | ||
/** | ||
@@ -59,3 +59,3 @@ * Test a Set to be empty. | ||
*/ | ||
deepEqual(expected: Set<any>): this; | ||
deepEqual(expected: Set<T>): this; | ||
} |
@@ -6,3 +6,3 @@ import { Predicate, Context } from './predicate'; | ||
*/ | ||
constructor(context?: Context); | ||
constructor(context?: Context<string>); | ||
/** | ||
@@ -9,0 +9,0 @@ * Test a string to have a specific length. |
import { Predicate, Context } from './predicate'; | ||
export declare class WeakMapPredicate extends Predicate<WeakMap<any, any>> { | ||
export declare class WeakMapPredicate<T1 extends object = any, T2 = any> extends Predicate<WeakMap<T1, T2>> { | ||
/** | ||
* @hidden | ||
*/ | ||
constructor(context?: Context); | ||
constructor(context?: Context<WeakMap<T1, T2>>); | ||
/** | ||
@@ -12,3 +12,3 @@ * Test a WeakMap to include all the provided keys. The keys are tested by identity, not structure. | ||
*/ | ||
hasKeys(...keys: any[]): this; | ||
hasKeys(...keys: T1[]): this; | ||
/** | ||
@@ -19,3 +19,3 @@ * Test a WeakMap to include any of the provided keys. The keys are tested by identity, not structure. | ||
*/ | ||
hasAnyKeys(...keys: any[]): this; | ||
hasAnyKeys(...keys: T1[]): this; | ||
} |
import { Predicate, Context } from './predicate'; | ||
export declare class WeakSetPredicate extends Predicate<WeakSet<any>> { | ||
export declare class WeakSetPredicate<T extends object = any> extends Predicate<WeakSet<T>> { | ||
/** | ||
* @hidden | ||
*/ | ||
constructor(context?: Context); | ||
constructor(context?: Context<WeakSet<T>>); | ||
/** | ||
@@ -12,3 +12,3 @@ * Test a WeakSet to include all the provided items. The items are tested by identity, not structure. | ||
*/ | ||
has(...items: any[]): this; | ||
has(...items: T[]): this; | ||
/** | ||
@@ -19,3 +19,3 @@ * Test a WeakSet to include any of the provided items. The items are tested by identity, not structure. | ||
*/ | ||
hasAny(...items: any[]): this; | ||
hasAny(...items: T[]): this; | ||
} |
@@ -7,3 +7,3 @@ /** | ||
} | ||
declare const _default: (source: CollectionLike<any>, items: any[], maxValues?: number) => true | any[]; | ||
declare const _default: <T>(source: CollectionLike<T>, items: T[], maxValues?: number) => true | T[]; | ||
export default _default; |
import { Predicate } from '../predicates/predicate'; | ||
declare const _default: (source: any[] | IterableIterator<any> | Set<any>, predicate: Predicate<any>) => string | boolean; | ||
declare const _default: <T>(source: IterableIterator<T> | Set<T> | T[], predicate: Predicate<T>) => string | boolean; | ||
export default _default; |
{ | ||
"name": "ow", | ||
"version": "0.2.0", | ||
"description": "Argument type validation", | ||
"version": "0.3.0", | ||
"description": "Function argument validation for humans", | ||
"license": "MIT", | ||
@@ -6,0 +6,0 @@ "repository": "sindresorhus/ow", |
@@ -9,7 +9,13 @@ <p align="center"> | ||
> Argument type validation | ||
> Function argument validation for humans | ||
[View documentation](https://sindresorhus.com/ow) | ||
## Highlights | ||
- Expressive chainable API | ||
- Lots of built-in validations | ||
- Supports custom validations | ||
- Written in TypeScript | ||
## Install | ||
@@ -43,2 +49,4 @@ | ||
[Complete API documentation](https://sindresorhus.com/ow) | ||
### ow(value, predicate) | ||
@@ -45,0 +53,0 @@ |
Sorry, the diff of this file is not supported yet
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
Major refactor
Supply chain riskPackage has recently undergone a major refactor. It may be unstable or indicate significant internal changes. Use caution when updating to versions that include significant changes.
Found 1 instance in 1 package
229345
177
1