@typed/lambda
Advanced tools
Comparing version 1.0.5 to 2.0.0
@@ -8,5 +8,5 @@ import { Apply, Fn } from './types'; | ||
export declare const apply: { | ||
<Args extends any[], T extends Fn<any[], any>>(args: Args, fn: T): Apply<Args, T>; | ||
<Args_1 extends any[]>(args: Args_1): <T_1 extends Fn<Args_1, any>>(fn: T_1) => Apply<Args_1, T_1>; | ||
<Args extends readonly any[], T extends Fn<Args, any>>(args: Args, fn: T): Apply<Args, T>; | ||
<Args_1 extends readonly any[]>(args: Args_1): <T_1 extends Fn<Args_1, any>>(fn: T_1) => Apply<Args_1, T_1>; | ||
}; | ||
//# sourceMappingURL=apply.d.ts.map |
@@ -6,3 +6,3 @@ import { Curry, Fn } from './types'; | ||
*/ | ||
export declare const curry: <F extends Fn<any[], any>>(f: F) => Curry<F>; | ||
export declare const curry: <F extends Fn<readonly any[], any>>(f: F) => Curry<F>; | ||
//# sourceMappingURL=curry.d.ts.map |
@@ -7,3 +7,3 @@ import { Flip, Fn } from './types'; | ||
*/ | ||
export declare const flip: <T extends Fn<any[], any>>(fn: T) => Flip<T>; | ||
export declare const flip: <T extends Fn<readonly any[], any>>(fn: T) => Flip<T>; | ||
//# sourceMappingURL=flip.d.ts.map |
@@ -1,2 +0,1 @@ | ||
import { Fn } from './types'; | ||
/** | ||
@@ -6,3 +5,3 @@ * Memoize a function | ||
*/ | ||
export declare const memoize: <F extends Fn<any[], any>>(f: F) => F; | ||
export declare const memoize: <F extends (...args: any[]) => any>(f: F) => F; | ||
//# sourceMappingURL=memoize.d.ts.map |
@@ -12,3 +12,3 @@ export declare type Primitive = undefined | null | boolean | string | number | Function; | ||
export declare type ComparisonNumbers = -1 | 0 | 1; | ||
export declare type ComparableValues = keyof any | boolean; | ||
export declare type ComparableValues = keyof any | boolean | Date; | ||
export interface Curry2<A, B, C> extends Arity2<A, B, C>, Arity1<A, Arity1<B, C>> { | ||
@@ -22,3 +22,3 @@ } | ||
} | ||
export declare type Fn<Args extends readonly any[] = any[], R = any> = (...args: Args) => R; | ||
export declare type Fn<Args extends readonly any[] = readonly any[], R = any> = (...args: Args) => R; | ||
export declare type Curry<T extends Fn> = ArgsOf<T> extends [infer A] ? Arity1<A, ReturnType<T>> : ArgsOf<T> extends [infer A, infer B] ? Curry2<A, B, ReturnType<T>> : ArgsOf<T> extends [infer A, infer B, infer C] ? Curry3<A, B, C, ReturnType<T>> : ArgsOf<T> extends [infer A, infer B, infer C, infer D] ? Curry4<A, B, C, D, ReturnType<T>> : ArgsOf<T> extends [infer A, infer B, infer C, infer D, infer E] ? Curry5<A, B, C, D, E, ReturnType<T>> : ArgsOf<T> extends never[] ? IO<ReturnType<T>> : never; | ||
@@ -31,9 +31,9 @@ export declare type ArgsOf<T extends Fn> = T extends Fn<infer Args, any> ? Args : []; | ||
export declare type Flip<T extends Fn> = ArgsOf<T> extends [] ? Fn<[], ReturnType<T>> : ArgsOf<T> extends [infer A] ? Fn<[A], ReturnType<T>> : ArgsOf<T> extends [infer A, infer B] ? Fn<[B, A], ReturnType<T>> : ArgsOf<T> extends [infer A, infer B, infer C] ? Fn<[B, A, C], ReturnType<T>> : ArgsOf<T> extends [infer A, infer B, infer C, infer D] ? Fn<[B, A, C, D], ReturnType<T>> : ArgsOf<T> extends [infer A, infer B, infer C, infer D, infer E] ? Fn<[B, A, C, D, E], ReturnType<T>> : never; | ||
export declare type Apply<Args extends any[] = any[], T extends Fn<Args> = Fn<Args>> = T extends (...args: Args) => infer R ? R : never; | ||
export declare type Apply<Args extends readonly any[] = readonly any[], T extends Fn<Args> = Fn<Args>> = T extends (...args: Args) => infer R ? R : never; | ||
export declare type Uncurry<Fun extends Fn> = Fun extends (a: infer A) => (b: infer B) => (c: infer C) => (d: infer D) => (e: infer E) => infer F ? (a: A, b: B, c: C, d: D, e: E) => F : Fun extends (a: infer A) => (b: infer B) => (c: infer C) => (d: infer D) => infer E ? (a: A, b: B, c: C, d: D) => E : Fun extends (a: infer A) => (b: infer B) => (c: infer C) => infer D ? (a: A, b: B, c: C) => D : Fun extends (a: infer A) => (b: infer B) => infer C ? (a: A, b: B) => C : Fun; | ||
export declare type Init<A extends any[], B extends any[] = Tail<A>> = CastArray<{ | ||
export declare type Init<A extends readonly any[], B extends readonly any[] = Tail<A>> = CastArray<{ | ||
[K in keyof B]: A[keyof A & K]; | ||
}>; | ||
export declare type Tail<A extends any[]> = TailArgsOf<Fn<A>>; | ||
export declare type Head<A extends any[]> = HeadArg<Fn<A>>; | ||
export declare type Tail<A extends readonly any[]> = TailArgsOf<Fn<A>>; | ||
export declare type Head<A extends readonly any[]> = HeadArg<Fn<A>>; | ||
export declare type Defined<T> = T extends undefined ? never : T; | ||
@@ -43,4 +43,4 @@ export declare type OrToAnd<A> = (A extends any ? (u: A) => void : never) extends ((i: infer B) => void) ? B : never; | ||
export declare type TypeGuard<A, B extends A> = (value: A) => value is B; | ||
declare type CastArray<T> = T extends any[] ? T : []; | ||
declare type CastArray<T> = T extends readonly any[] ? T : []; | ||
export {}; | ||
//# sourceMappingURL=types.d.ts.map |
@@ -8,5 +8,5 @@ import { Apply, Fn } from './types'; | ||
export declare const apply: { | ||
<Args extends any[], T extends Fn<any[], any>>(args: Args, fn: T): Apply<Args, T>; | ||
<Args_1 extends any[]>(args: Args_1): <T_1 extends Fn<Args_1, any>>(fn: T_1) => Apply<Args_1, T_1>; | ||
<Args extends readonly any[], T extends Fn<Args, any>>(args: Args, fn: T): Apply<Args, T>; | ||
<Args_1 extends readonly any[]>(args: Args_1): <T_1 extends Fn<Args_1, any>>(fn: T_1) => Apply<Args_1, T_1>; | ||
}; | ||
//# sourceMappingURL=apply.d.ts.map |
@@ -6,3 +6,3 @@ import { Curry, Fn } from './types'; | ||
*/ | ||
export declare const curry: <F extends Fn<any[], any>>(f: F) => Curry<F>; | ||
export declare const curry: <F extends Fn<readonly any[], any>>(f: F) => Curry<F>; | ||
//# sourceMappingURL=curry.d.ts.map |
@@ -7,3 +7,3 @@ import { Flip, Fn } from './types'; | ||
*/ | ||
export declare const flip: <T extends Fn<any[], any>>(fn: T) => Flip<T>; | ||
export declare const flip: <T extends Fn<readonly any[], any>>(fn: T) => Flip<T>; | ||
//# sourceMappingURL=flip.d.ts.map |
@@ -1,2 +0,1 @@ | ||
import { Fn } from './types'; | ||
/** | ||
@@ -6,3 +5,3 @@ * Memoize a function | ||
*/ | ||
export declare const memoize: <F extends Fn<any[], any>>(f: F) => F; | ||
export declare const memoize: <F extends (...args: any[]) => any>(f: F) => F; | ||
//# sourceMappingURL=memoize.d.ts.map |
@@ -12,3 +12,3 @@ export declare type Primitive = undefined | null | boolean | string | number | Function; | ||
export declare type ComparisonNumbers = -1 | 0 | 1; | ||
export declare type ComparableValues = keyof any | boolean; | ||
export declare type ComparableValues = keyof any | boolean | Date; | ||
export interface Curry2<A, B, C> extends Arity2<A, B, C>, Arity1<A, Arity1<B, C>> { | ||
@@ -22,3 +22,3 @@ } | ||
} | ||
export declare type Fn<Args extends readonly any[] = any[], R = any> = (...args: Args) => R; | ||
export declare type Fn<Args extends readonly any[] = readonly any[], R = any> = (...args: Args) => R; | ||
export declare type Curry<T extends Fn> = ArgsOf<T> extends [infer A] ? Arity1<A, ReturnType<T>> : ArgsOf<T> extends [infer A, infer B] ? Curry2<A, B, ReturnType<T>> : ArgsOf<T> extends [infer A, infer B, infer C] ? Curry3<A, B, C, ReturnType<T>> : ArgsOf<T> extends [infer A, infer B, infer C, infer D] ? Curry4<A, B, C, D, ReturnType<T>> : ArgsOf<T> extends [infer A, infer B, infer C, infer D, infer E] ? Curry5<A, B, C, D, E, ReturnType<T>> : ArgsOf<T> extends never[] ? IO<ReturnType<T>> : never; | ||
@@ -31,9 +31,9 @@ export declare type ArgsOf<T extends Fn> = T extends Fn<infer Args, any> ? Args : []; | ||
export declare type Flip<T extends Fn> = ArgsOf<T> extends [] ? Fn<[], ReturnType<T>> : ArgsOf<T> extends [infer A] ? Fn<[A], ReturnType<T>> : ArgsOf<T> extends [infer A, infer B] ? Fn<[B, A], ReturnType<T>> : ArgsOf<T> extends [infer A, infer B, infer C] ? Fn<[B, A, C], ReturnType<T>> : ArgsOf<T> extends [infer A, infer B, infer C, infer D] ? Fn<[B, A, C, D], ReturnType<T>> : ArgsOf<T> extends [infer A, infer B, infer C, infer D, infer E] ? Fn<[B, A, C, D, E], ReturnType<T>> : never; | ||
export declare type Apply<Args extends any[] = any[], T extends Fn<Args> = Fn<Args>> = T extends (...args: Args) => infer R ? R : never; | ||
export declare type Apply<Args extends readonly any[] = readonly any[], T extends Fn<Args> = Fn<Args>> = T extends (...args: Args) => infer R ? R : never; | ||
export declare type Uncurry<Fun extends Fn> = Fun extends (a: infer A) => (b: infer B) => (c: infer C) => (d: infer D) => (e: infer E) => infer F ? (a: A, b: B, c: C, d: D, e: E) => F : Fun extends (a: infer A) => (b: infer B) => (c: infer C) => (d: infer D) => infer E ? (a: A, b: B, c: C, d: D) => E : Fun extends (a: infer A) => (b: infer B) => (c: infer C) => infer D ? (a: A, b: B, c: C) => D : Fun extends (a: infer A) => (b: infer B) => infer C ? (a: A, b: B) => C : Fun; | ||
export declare type Init<A extends any[], B extends any[] = Tail<A>> = CastArray<{ | ||
export declare type Init<A extends readonly any[], B extends readonly any[] = Tail<A>> = CastArray<{ | ||
[K in keyof B]: A[keyof A & K]; | ||
}>; | ||
export declare type Tail<A extends any[]> = TailArgsOf<Fn<A>>; | ||
export declare type Head<A extends any[]> = HeadArg<Fn<A>>; | ||
export declare type Tail<A extends readonly any[]> = TailArgsOf<Fn<A>>; | ||
export declare type Head<A extends readonly any[]> = HeadArg<Fn<A>>; | ||
export declare type Defined<T> = T extends undefined ? never : T; | ||
@@ -43,4 +43,4 @@ export declare type OrToAnd<A> = (A extends any ? (u: A) => void : never) extends ((i: infer B) => void) ? B : never; | ||
export declare type TypeGuard<A, B extends A> = (value: A) => value is B; | ||
declare type CastArray<T> = T extends any[] ? T : []; | ||
declare type CastArray<T> = T extends readonly any[] ? T : []; | ||
export {}; | ||
//# sourceMappingURL=types.d.ts.map |
{ | ||
"name": "@typed/lambda", | ||
"version": "1.0.5", | ||
"version": "2.0.0", | ||
"description": "Helpful functions for working in a functional style", | ||
@@ -29,3 +29,3 @@ "main": "./cjs/index.js", | ||
"dependencies": { | ||
"@typed/common": "^1.0.3" | ||
"@typed/common": "^2.0.0" | ||
}, | ||
@@ -39,4 +39,7 @@ "publishConfig": { | ||
"sideEffects": false, | ||
"gitHead": "1182d7f246d79718d84a58f75a2d9e7e129875b8", | ||
"unpkg": "./umd/index.js" | ||
"gitHead": "cf1bf36aefe0f8968036149e65eba567cde9d23a", | ||
"unpkg": "./umd/index.js", | ||
"exports": { | ||
".": "./esm/index.js" | ||
} | ||
} |
@@ -10,6 +10,7 @@ import { curry } from './curry' | ||
export const apply = curry( | ||
<Args extends any[], T extends Fn>(args: Args, fn: T): Apply<Args, T> => fn(...args), | ||
<Args extends readonly any[], T extends Fn<Args>>(args: Args, fn: T): Apply<Args, T> => | ||
fn(...args), | ||
) as { | ||
<Args extends any[], T extends Fn>(args: Args, fn: T): Apply<Args, T> | ||
<Args extends any[]>(args: Args): <T extends Fn<Args>>(fn: T) => Apply<Args, T> | ||
<Args extends readonly any[], T extends Fn<Args>>(args: Args, fn: T): Apply<Args, T> | ||
<Args extends readonly any[]>(args: Args): <T extends Fn<Args>>(fn: T) => Apply<Args, T> | ||
} |
import { toString } from '@typed/common' | ||
import { ArgsOf, Fn } from './types' | ||
import { ArgsOf } from './types' | ||
@@ -8,3 +8,3 @@ /** | ||
*/ | ||
export const memoize = <F extends Fn>(f: F): F => { | ||
export const memoize = <F extends (...args: any[]) => any>(f: F): F => { | ||
const cache = new Map<any, any>() | ||
@@ -11,0 +11,0 @@ |
@@ -20,3 +20,3 @@ export type Primitive = undefined | null | boolean | string | number | Function | ||
export type ComparisonNumbers = -1 | 0 | 1 | ||
export type ComparableValues = keyof any | boolean | ||
export type ComparableValues = keyof any | boolean | Date | ||
@@ -40,3 +40,3 @@ export interface Curry2<A, B, C> extends Arity2<A, B, C>, Arity1<A, Arity1<B, C>> {} | ||
export type Fn<Args extends readonly any[] = any[], R = any> = (...args: Args) => R | ||
export type Fn<Args extends readonly any[] = readonly any[], R = any> = (...args: Args) => R | ||
@@ -84,7 +84,6 @@ // tslint:disable:no-shadowed-variable | ||
export type Apply<Args extends any[] = any[], T extends Fn<Args> = Fn<Args>> = T extends ( | ||
...args: Args | ||
) => infer R | ||
? R | ||
: never | ||
export type Apply< | ||
Args extends readonly any[] = readonly any[], | ||
T extends Fn<Args> = Fn<Args> | ||
> = T extends (...args: Args) => infer R ? R : never | ||
@@ -103,7 +102,7 @@ export type Uncurry<Fun extends Fn> = Fun extends ( | ||
export type Init<A extends any[], B extends any[] = Tail<A>> = CastArray< | ||
export type Init<A extends readonly any[], B extends readonly any[] = Tail<A>> = CastArray< | ||
{ [K in keyof B]: A[keyof A & K] } | ||
> | ||
export type Tail<A extends any[]> = TailArgsOf<Fn<A>> | ||
export type Head<A extends any[]> = HeadArg<Fn<A>> | ||
export type Tail<A extends readonly any[]> = TailArgsOf<Fn<A>> | ||
export type Head<A extends readonly any[]> = HeadArg<Fn<A>> | ||
@@ -120,2 +119,2 @@ export type Defined<T> = T extends undefined ? never : T | ||
// Internal | ||
type CastArray<T> = T extends any[] ? T : [] | ||
type CastArray<T> = T extends readonly any[] ? T : [] |
@@ -8,5 +8,5 @@ import { Apply, Fn } from './types'; | ||
export declare const apply: { | ||
<Args extends any[], T extends Fn<any[], any>>(args: Args, fn: T): Apply<Args, T>; | ||
<Args_1 extends any[]>(args: Args_1): <T_1 extends Fn<Args_1, any>>(fn: T_1) => Apply<Args_1, T_1>; | ||
<Args extends readonly any[], T extends Fn<Args, any>>(args: Args, fn: T): Apply<Args, T>; | ||
<Args_1 extends readonly any[]>(args: Args_1): <T_1 extends Fn<Args_1, any>>(fn: T_1) => Apply<Args_1, T_1>; | ||
}; | ||
//# sourceMappingURL=apply.d.ts.map |
@@ -6,3 +6,3 @@ import { Curry, Fn } from './types'; | ||
*/ | ||
export declare const curry: <F extends Fn<any[], any>>(f: F) => Curry<F>; | ||
export declare const curry: <F extends Fn<readonly any[], any>>(f: F) => Curry<F>; | ||
//# sourceMappingURL=curry.d.ts.map |
@@ -7,3 +7,3 @@ import { Flip, Fn } from './types'; | ||
*/ | ||
export declare const flip: <T extends Fn<any[], any>>(fn: T) => Flip<T>; | ||
export declare const flip: <T extends Fn<readonly any[], any>>(fn: T) => Flip<T>; | ||
//# sourceMappingURL=flip.d.ts.map |
@@ -1,2 +0,1 @@ | ||
import { Fn } from './types'; | ||
/** | ||
@@ -6,3 +5,3 @@ * Memoize a function | ||
*/ | ||
export declare const memoize: <F extends Fn<any[], any>>(f: F) => F; | ||
export declare const memoize: <F extends (...args: any[]) => any>(f: F) => F; | ||
//# sourceMappingURL=memoize.d.ts.map |
@@ -12,3 +12,3 @@ export declare type Primitive = undefined | null | boolean | string | number | Function; | ||
export declare type ComparisonNumbers = -1 | 0 | 1; | ||
export declare type ComparableValues = keyof any | boolean; | ||
export declare type ComparableValues = keyof any | boolean | Date; | ||
export interface Curry2<A, B, C> extends Arity2<A, B, C>, Arity1<A, Arity1<B, C>> { | ||
@@ -22,3 +22,3 @@ } | ||
} | ||
export declare type Fn<Args extends readonly any[] = any[], R = any> = (...args: Args) => R; | ||
export declare type Fn<Args extends readonly any[] = readonly any[], R = any> = (...args: Args) => R; | ||
export declare type Curry<T extends Fn> = ArgsOf<T> extends [infer A] ? Arity1<A, ReturnType<T>> : ArgsOf<T> extends [infer A, infer B] ? Curry2<A, B, ReturnType<T>> : ArgsOf<T> extends [infer A, infer B, infer C] ? Curry3<A, B, C, ReturnType<T>> : ArgsOf<T> extends [infer A, infer B, infer C, infer D] ? Curry4<A, B, C, D, ReturnType<T>> : ArgsOf<T> extends [infer A, infer B, infer C, infer D, infer E] ? Curry5<A, B, C, D, E, ReturnType<T>> : ArgsOf<T> extends never[] ? IO<ReturnType<T>> : never; | ||
@@ -31,9 +31,9 @@ export declare type ArgsOf<T extends Fn> = T extends Fn<infer Args, any> ? Args : []; | ||
export declare type Flip<T extends Fn> = ArgsOf<T> extends [] ? Fn<[], ReturnType<T>> : ArgsOf<T> extends [infer A] ? Fn<[A], ReturnType<T>> : ArgsOf<T> extends [infer A, infer B] ? Fn<[B, A], ReturnType<T>> : ArgsOf<T> extends [infer A, infer B, infer C] ? Fn<[B, A, C], ReturnType<T>> : ArgsOf<T> extends [infer A, infer B, infer C, infer D] ? Fn<[B, A, C, D], ReturnType<T>> : ArgsOf<T> extends [infer A, infer B, infer C, infer D, infer E] ? Fn<[B, A, C, D, E], ReturnType<T>> : never; | ||
export declare type Apply<Args extends any[] = any[], T extends Fn<Args> = Fn<Args>> = T extends (...args: Args) => infer R ? R : never; | ||
export declare type Apply<Args extends readonly any[] = readonly any[], T extends Fn<Args> = Fn<Args>> = T extends (...args: Args) => infer R ? R : never; | ||
export declare type Uncurry<Fun extends Fn> = Fun extends (a: infer A) => (b: infer B) => (c: infer C) => (d: infer D) => (e: infer E) => infer F ? (a: A, b: B, c: C, d: D, e: E) => F : Fun extends (a: infer A) => (b: infer B) => (c: infer C) => (d: infer D) => infer E ? (a: A, b: B, c: C, d: D) => E : Fun extends (a: infer A) => (b: infer B) => (c: infer C) => infer D ? (a: A, b: B, c: C) => D : Fun extends (a: infer A) => (b: infer B) => infer C ? (a: A, b: B) => C : Fun; | ||
export declare type Init<A extends any[], B extends any[] = Tail<A>> = CastArray<{ | ||
export declare type Init<A extends readonly any[], B extends readonly any[] = Tail<A>> = CastArray<{ | ||
[K in keyof B]: A[keyof A & K]; | ||
}>; | ||
export declare type Tail<A extends any[]> = TailArgsOf<Fn<A>>; | ||
export declare type Head<A extends any[]> = HeadArg<Fn<A>>; | ||
export declare type Tail<A extends readonly any[]> = TailArgsOf<Fn<A>>; | ||
export declare type Head<A extends readonly any[]> = HeadArg<Fn<A>>; | ||
export declare type Defined<T> = T extends undefined ? never : T; | ||
@@ -43,4 +43,4 @@ export declare type OrToAnd<A> = (A extends any ? (u: A) => void : never) extends ((i: infer B) => void) ? B : never; | ||
export declare type TypeGuard<A, B extends A> = (value: A) => value is B; | ||
declare type CastArray<T> = T extends any[] ? T : []; | ||
declare type CastArray<T> = T extends readonly any[] ? T : []; | ||
export {}; | ||
//# sourceMappingURL=types.d.ts.map |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
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
315301
1319
+ Added@typed/common@2.1.0(transitive)
- Removed@typed/common@1.0.3(transitive)
Updated@typed/common@^2.0.0