From 911b971b84982f646d7537c6f9ef0c7e85e656fd Mon Sep 17 00:00:00 2001 From: whitecolor Date: Sun, 2 Apr 2017 18:04:41 +0500 Subject: [PATCH 01/19] initial merge and curry --- index.d.ts | 29 ++++------------- src/curry.d.ts | 84 ++++++++++++++++++++++++++++++++++++++++++++++++++ src/merge.d.ts | 11 +++++++ tests/merge.ts | 10 ++++++ 4 files changed, 111 insertions(+), 23 deletions(-) create mode 100644 src/curry.d.ts create mode 100644 src/merge.d.ts create mode 100644 tests/merge.ts diff --git a/index.d.ts b/index.d.ts index 221c309..0a5ff76 100644 --- a/index.d.ts +++ b/index.d.ts @@ -3,6 +3,9 @@ // Definitions by: Erwin Poeze // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped +import curry from './src/curry' +import merge from './src/merge' + declare var R: R.Static; declare namespace R { @@ -1727,20 +1730,7 @@ declare namespace R { countBy(fn: (a: T) => Prop): (list: List) => Obj; // countBy: CurriedFunction2<(a: T) => Prop, List, Obj>; - /** - * Returns a curried equivalent of the provided function. - */ - curry(fn: (a: T1) => TResult): CurriedFunction1; - curry(fn: (a: T1, b: T2) => TResult): CurriedFunction2; - curry(fn: (a: T1, b: T2, c: T3) => TResult): CurriedFunction3; - curry(fn: (a: T1, b: T2, c: T3, d: T4) => TResult): CurriedFunction4; - curry(fn: (a: T1, b: T2, c: T3, d: T4, e: T5) => TResult): CurriedFunction5; - curry(fn: (a: T1, b: T2, c: T3, d: T4, e: T5, f: T6) => TResult): CurriedFunction6; - curry(fn: (a: T1, b: T2, c: T3, d: T4, e: T5, f: T6, g: T7) => TResult): CurriedFunction7; - curry(fn: (a: T1, b: T2, c: T3, d: T4, e: T5, f: T6, g: T7, h: T8) => TResult): CurriedFunction8; - curry(fn: (a: T1, b: T2, c: T3, d: T4, e: T5, f: T6, g: T7, h: T8, i: T9) => TResult): CurriedFunction9; - // curry(fn: Function): Function - + curry: typeof curry /** * Returns a curried equivalent of the provided function, with the specified arity. @@ -2758,15 +2748,8 @@ declare namespace R { */ memoize(fn: Variadic): Variadic; - /** - * Create a new object with the own properties of a - * merged with the own properties of object b. - * This function will *not* mutate passed-in objects. - */ - merge, T2 extends Struct>(a: T1, b: T2): T1 & T2; - merge>(a: T1): >(b: T2) => T1 & T2; - // merge, T2 extends Struct>: CurriedFunction2; - + merge: typeof merge + /** * Merges a list of objects together into one object. diff --git a/src/curry.d.ts b/src/curry.d.ts new file mode 100644 index 0000000..fc5c44a --- /dev/null +++ b/src/curry.d.ts @@ -0,0 +1,84 @@ + +type CurriedFunction1 = (v1: T1) => R; + +interface CurriedFunction2 { + (v1: T1): (v2: T2) => R; + (v1: T1, v2: T2): R; +} + +interface CurriedFunction3 { + (v1: T1): CurriedFunction2; + (v1: T1, v2: T2): (v3: T3) => R; + (v1: T1, v2: T2, v3: T3): R; +} + +interface CurriedFunction4 { + (v1: T1): CurriedFunction3; + (v1: T1, v2: T2): CurriedFunction2; + (v1: T1, v2: T2, v3: T3): (v4: T4) => R; + (v1: T1, v2: T2, v3: T3, v4: T4): R; +} + +interface CurriedFunction5 { + (v1: T1): CurriedFunction4; + (v1: T1, v2: T2): CurriedFunction3; + (v1: T1, v2: T2, v3: T3): CurriedFunction2; + (v1: T1, v2: T2, v3: T3, v4: T4): (v5: T5) => R; + (v1: T1, v2: T2, v3: T3, v4: T4, v5: T5): R; +} + +interface CurriedFunction6 { + (v1: T1): CurriedFunction5; + (v1: T1, v2: T2): CurriedFunction4; + (v1: T1, v2: T2, v3: T3): CurriedFunction3; + (v1: T1, v2: T2, v3: T3, v4: T4): CurriedFunction2; + (v1: T1, v2: T2, v3: T3, v4: T4, v5: T5): (v6: T6) => R; + (v1: T1, v2: T2, v3: T3, v4: T4, v5: T5, v6: T6): R; +} + +interface CurriedFunction7 { + (v1: T1): CurriedFunction6; + (v1: T1, v2: T2): CurriedFunction5; + (v1: T1, v2: T2, v3: T3): CurriedFunction4; + (v1: T1, v2: T2, v3: T3, v4: T4): CurriedFunction3; + (v1: T1, v2: T2, v3: T3, v4: T4, v5: T5): CurriedFunction2; + (v1: T1, v2: T2, v3: T3, v4: T4, v5: T5, v6: T6): (v7: T7) => R; + (v1: T1, v2: T2, v3: T3, v4: T4, v5: T5, v6: T6, v7: T7): R; +} + +interface CurriedFunction8 { + (v1: T1): CurriedFunction7; + (v1: T1, v2: T2): CurriedFunction6; + (v1: T1, v2: T2, v3: T3): CurriedFunction5; + (v1: T1, v2: T2, v3: T3, v4: T4): CurriedFunction4; + (v1: T1, v2: T2, v3: T3, v4: T4, v5: T5): CurriedFunction3; + (v1: T1, v2: T2, v3: T3, v4: T4, v5: T5, v6: T6): CurriedFunction2; + (v1: T1, v2: T2, v3: T3, v4: T4, v5: T5, v6: T6, v7: T7): (v8: T8) => R; + (v1: T1, v2: T2, v3: T3, v4: T4, v5: T5, v6: T6, v7: T7, v8: T8): R; +} + +interface CurriedFunction9 { + (v1: T1): CurriedFunction8; + (v1: T1, v2: T2): CurriedFunction7; + (v1: T1, v2: T2, v3: T3): CurriedFunction6; + (v1: T1, v2: T2, v3: T3, v4: T4): CurriedFunction5; + (v1: T1, v2: T2, v3: T3, v4: T4, v5: T5): CurriedFunction4; + (v1: T1, v2: T2, v3: T3, v4: T4, v5: T5, v6: T6): CurriedFunction3; + (v1: T1, v2: T2, v3: T3, v4: T4, v5: T5, v6: T6, v7: T7): CurriedFunction2; + (v1: T1, v2: T2, v3: T3, v4: T4, v5: T5, v6: T6, v7: T7, v8: T8): (v9: T9) => R; + (v1: T1, v2: T2, v3: T3, v4: T4, v5: T5, v6: T6, v7: T7, v8: T8, v9: T9): R; +} + +/** + * Returns a curried equivalent of the provided function. + */ +declare function curry(fn: (a: T1) => TResult): CurriedFunction1; +declare function curry(fn: (a: T1, b: T2) => TResult): CurriedFunction2; +declare function curry(fn: (a: T1, b: T2, c: T3, d: T4) => TResult): CurriedFunction4; +declare function curry(fn: (a: T1, b: T2, c: T3, d: T4, e: T5) => TResult): CurriedFunction5; +declare function curry(fn: (a: T1, b: T2, c: T3, d: T4, e: T5, f: T6) => TResult): CurriedFunction6; +declare function curry(fn: (a: T1, b: T2, c: T3, d: T4, e: T5, f: T6, g: T7) => TResult): CurriedFunction7; +declare function curry(fn: (a: T1, b: T2, c: T3, d: T4, e: T5, f: T6, g: T7, h: T8) => TResult): CurriedFunction8; +declare function curry(fn: (a: T1, b: T2, c: T3, d: T4, e: T5, f: T6, g: T7, h: T8, i: T9) => TResult): CurriedFunction9; + +export default curry; diff --git a/src/merge.d.ts b/src/merge.d.ts new file mode 100644 index 0000000..a64c50b --- /dev/null +++ b/src/merge.d.ts @@ -0,0 +1,11 @@ +import { Struct } from '..' + +/** + * Create a new object with the own properties of a + * merged with the own properties of object b. + * This function will *not* mutate passed-in objects. + */ +declare function merge, T2 extends Struct>(a: T1, b: T2): T1 & T2; +declare function merge>(a: T1): >(b: T2) => T1 & T2; + +export default merge; diff --git a/tests/merge.ts b/tests/merge.ts new file mode 100644 index 0000000..f58ffc3 --- /dev/null +++ b/tests/merge.ts @@ -0,0 +1,10 @@ +import * as R from '..'; + +() => { + // $ExpectType Dictionary + R.merge({ 'name': 'fred', 'age': 10 }, { 'age': 40 }); + // => { 'name': 'fred', 'age': 40 } + let resetToDefault = R.flip(R.merge)({ x: 0 }); + // $ExpectType Dictionary + resetToDefault({ x: 5, y: 2 }); // => {x: 0, y: 2} +}; \ No newline at end of file From cd12c462702226e2c66721a832af9bc496685342 Mon Sep 17 00:00:00 2001 From: whitecolor Date: Wed, 5 Apr 2017 13:40:13 +0500 Subject: [PATCH 02/19] move interfaces --- index.d.ts | 7902 +++++++++++++++++++-------------------------- interfaces.d.ts | 223 ++ src/__.d.ts | 14 + src/add.d.ts | 7 + src/addIndex.d.ts | 20 + src/curry.d.ts | 81 +- src/props.d.ts | 31 + 7 files changed, 3619 insertions(+), 4659 deletions(-) create mode 100644 interfaces.d.ts create mode 100644 src/__.d.ts create mode 100644 src/add.d.ts create mode 100644 src/addIndex.d.ts create mode 100644 src/props.d.ts diff --git a/index.d.ts b/index.d.ts index 0a5ff76..176d3a7 100644 --- a/index.d.ts +++ b/index.d.ts @@ -3,4637 +3,3361 @@ // Definitions by: Erwin Poeze // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped +import __ from './src/__' +import add from './src/add' +import addIndex from './src/addIndex' import curry from './src/curry' import merge from './src/merge' declare var R: R.Static; declare namespace R { + + interface Reduced { } + + interface Static { + + __: typeof __ + add: typeof add + addIndex: typeof addIndex + + /** + * Applies a function to the value at the given index of an array, returning a new copy of the array with the + * element at the given index replaced with the result of the function application. + */ + // adjust(fn: (a: T) => T, index: number, list: List): T[]; + // adjust(fn: (a: T) => T, index: number): (list: List) => T[]; + // adjust(fn: (a: T) => T): CurriedFunction2, T[]>; + // adjust: CurriedFunction3<(a: T) => T, number, List, T[]>; + + // base + adjust(fn: (a: T) => T, index: number, list: List): T[]; + adjust(fn: (a: T) => T, index: number): { + (list: List): T[]; + }; + adjust(fn: (a: T) => T): { + (index: number, list: List): T[]; + (index: number): { + (list: List): T[]; + }; + }; + + /** + * Returns true if all elements of the list match the predicate, false if there are any that don't. + */ + all(pred: Pred, list: List): boolean; + all(pred: Pred): (list: List) => boolean; + // all: CurriedFunction2, List, boolean>; + + /** + * Given a list of predicates, returns a new predicate that will be true exactly when all of them are. + */ + allPass(preds: Pred[]): Pred; + + /** + * Returns a function that always returns the given value. + */ + always(val: T): () => T; + + /** + * A function that returns the first argument if it's falsy otherwise the second argument. Note that this is + * NOT short-circuited, meaning that if expressions are passed they are both evaluated. + */ + // dispatch to some `and` method: + and(fn1: T, val2: boolean | any): boolean; + and(fn1: T): (val2: boolean | any) => boolean; + // and: CurriedFunction2; + // // functions, does this still exist? + // and boolean>(fn1: T, fn2: T): T; + // and boolean>(fn1: T): (fn2: T) => T; + // no generics: + and(v1: any, v2: any): boolean; + and(v1: any): (v2: any) => boolean; + // and: CurriedFunction2; + + /** + * Returns true if at least one of elements of the list match the predicate, false otherwise. + */ + any(pred: Pred, list: List): boolean; + any(fnpred: Pred): (list: List) => boolean; + // any: CurriedFunction2, List, boolean>; + + /** + * Given a list of predicates returns a new predicate that will be true exactly when any one of them is. + */ + anyPass(preds: Pred[]): Pred; + + /** + * ap applies a list of functions to a list of values. + */ + ap(fns: ((a: T) => U)[], vs: List): U[]; + ap(fns: ((a: T) => U)[]): (vs: List) => U[]; + // ap: CurriedFunction2<((a: T) => U)[], List, U[]>; + + + /** + * Returns a new list, composed of n-tuples of consecutive elements If n is greater than the length of the list, + * an empty list is returned. + */ + aperture(n: number, list: List): T[][]; + aperture(n: number): (list: List) => T[][]; + // aperture: CurriedFunction2, T[][]>; + + /** + * Returns a new list containing the contents of the given list, followed by the given element. + */ + append(el: U, list: List): (T & U)[]; + append(el: U): (list: List) => (T & U)[]; + // append: CurriedFunction2, (T & U)[]>; + + /** + * Applies function fn to the argument list args. This is useful for creating a fixed-arity function from + * a variadic function. fn should be a bound function if context is significant. + */ + apply(fn: (...args: any[]) => TResult, args: any[]): TResult; + apply(fn: (...args: any[]) => TResult): (args: any[]) => TResult; + // apply: CurriedFunction2<(...args: any[]) => TResult, any[], TResult>; + + /** + * Given a spec object recursively mapping properties to functions, creates a function producing an object + * of the same structure, by mapping each property to the result of calling its associated function with + * the supplied arguments. + */ + applySpec(obj: any): Variadic; + + /** + * Makes an ascending comparator function out of a function that returns a value that can be compared with `<` and `>`. + */ + ascend(comparator: (val: T) => V, a: T, b: T): number; + ascend(comparator: (val: T) => V, a: T): (b: T) => number; + ascend(comparator: (val: T) => V): CurriedFunction2; + // ascend: CurriedFunction3<(val: T) => V, T, T, number>; + + /** + * Makes a shallow clone of an object, setting or overriding the specified property with the given value. + */ + // hard to mix cuz different initial generics? + + // extend object with new property + // assoc, K extends keyof U>(prop: K, val: T, obj: U): {[P in K]: T} & U; + // assoc, K extends keyof U>(prop: K, val: T): (obj: U) => {[P in K]: T} & U; // generics too early? + // assoc, K extends keyof U>(prop: K): CurriedFunction2; // generics too early? + // assoc, K extends keyof U>: CurriedFunction3; + + // // extend object with new property + // assoc>(prop: K, val: T, obj: U): {[P in K]: T} & U; + // assoc(prop: K, val: T):{ + // >(obj: U): {[P in K]: T} & U; + // }; + // assoc(prop: K):{ + // >(val: T, obj: U): {[P in K]: T} & U; + // (val: T):{ + // >(obj: U): {[P in K]: T} & U; + // }; + // }; + + + + // homogeneous object + assoc>(prop: Prop, val: T, obj: U): U; + assoc(prop: Prop, val: T): >(obj: U) => U; + assoc>(prop: Prop): CurriedFunction2; // generics too early? + // assoc>: CurriedFunction3; + + // any object as long as the type remains unchanged + assoc(prop: Prop, val: any, obj: T): T; + assoc(prop: Prop, val: any): (obj: T) => T; + assoc(prop: Prop): CurriedFunction2; // generics too early? + // assoc: CurriedFunction3; + + // any object as long as the type remains unchanged + assoc(prop: Prop, val: any, obj: T): T; + assoc(prop: Prop, val: any): { + (obj: T): T; + }; + assoc(prop: Prop): { + (val: any, obj: T): T; + (val: any): { + (obj: T): T; + }; + }; + + + /** + * Makes a shallow clone of an object, setting or overriding the nodes required to create the given path, and + * placing the specific value at the tail end of that path. + */ + // assocPath(path: Path, val: T, obj: U): U; + // assocPath(path: Path, val: T): (obj: U) => U; + // assocPath(path: Path): CurriedFunction2; + // assocPath: CurriedFunction3; + + // base + assocPath(path: Path, val: T, obj: U): U; + assocPath(path: Path, val: T): { + (obj: U): U; + }; + assocPath(path: Path): { + (val: T, obj: U): U; + (val: T): { + (obj: U): U; + }; + }; + + + /** + * Wraps a function of any arity (including nullary) in a function that accepts exactly 2 + * parameters. Any extraneous parameters will not be passed to the supplied function. + */ + binary(fn: (a: A, b: T, ...args: any[]) => T): (a: A, b: B) => T; + binary(fn: Variadic): (a: any, b: any) => T; + + /** + * Creates a function that is bound to a context. Note: R.bind does not provide the additional argument-binding + * capabilities of Function.prototype.bind. + */ + bind(fn: Variadic, thisObj: {}): Variadic; + bind(fn: Variadic): (thisObj: {}) => Variadic; + // bind: CurriedFunction2, {}, Variadic>; + + + /** + * A function wrapping calls to the two functions in an && operation, returning the result of the first function + * if it is false-y and the result of the second function otherwise. Note that this is short-circuited, meaning + * that the second function will not be invoked if the first returns a false-y value. + */ + both(pred1: Pred, pred2: Pred): Pred; + both(pred1: Pred): (pred2: Pred) => Pred; + // both: CurriedFunction2, Pred, Pred>; + + /** + * Returns the result of calling its first argument with the remaining arguments. This is occasionally useful + * as a converging function for R.converge: the left branch can produce a function while the right branch + * produces a value to be passed to that function as an argument. + */ + // not curried! + call(fn: Variadic, ...args: any[]): T; + + /** + * `chain` maps a function over a list and concatenates the results. + * This implementation is compatible with the Fantasy-land Chain spec + */ + + // List version + chain(fn: (n: T) => U[], list: List): U[]; + chain(fn: (n: T) => U[]): (list: List) => U[]; + // chain: CurriedFunction2<(n: T) => U[], List, U[]>; + + // generic Chain version + chain(fn: (n: T) => Chain, list: Chain): Chain; + chain(fn: (n: T) => Chain): (list: Chain) => Chain; + // chain: CurriedFunction2<(n: T) => Chain, Chain, Chain>; + + // function argument + chain(fn: (v: V) => (list: Chain) => Chain, monad: (chain: Chain) => V): (list: Chain) => Chain; + chain(fn: (v: V) => (list: Chain) => Chain): (monad: (chain: Chain) => V) => (list: Chain) => Chain; + // chain: CurriedFunction2<(v: V) => (list: Chain) => Chain, (chain: Chain) => V, (list: Chain) => Chain>; + + /** + * Restricts a number to be within a range. + * Also works for other ordered types such as Strings and Date + */ + // clamp(min: T, max: T, value: T): T; + // clamp(min: T, max: T): (value: T) => T; + // clamp(min: T): CurriedFunction2; + // clamp: CurriedFunction3; + + // base + clamp(min: T, max: T, value: T): T; + clamp(min: T, max: T): { + (value: T): T; + }; + clamp(min: T): { + (max: T, value: T): T; + (max: T): { + (value: T): T; + }; + }; + + + /** + * Creates a deep copy of the value which may contain (nested) Arrays and Objects, Numbers, Strings, Booleans and Dates. + */ + clone(value: T): T; + clone(value: List): T[]; + + /** + * Makes a comparator function out of a function that reports whether the first element is less than the second. + */ + comparator(pred: (a: T, b: T) => boolean): (x: T, y: T) => number; + + /** + * Takes a function f and returns a function g such that: + * - applying g to zero or more arguments will give true if applying the same arguments to f gives + * a logical false value; and + * - applying g to zero or more arguments will give false if applying the same arguments to f gives + * a logical true value. + */ + complement(pred: Variadic): Variadic; + + /** + * Performs right-to-left function composition. The rightmost function may have any arity; the remaining + * functions must be unary. + */ + compose(fn0: (x0: V0) => T1): (x0: V0) => T1; + compose(fn0: (x0: V0, x1: V1) => T1): (x0: V0, x1: V1) => T1; + compose(fn0: (x0: V0, x1: V1, x2: V2) => T1): (x0: V0, x1: V1, x2: V2) => T1; + compose(fn0: (x0: V0, x1: V1, x2: V2, x3: V3) => T1): (x0: V0, x1: V1, x2: V2, x3: V3) => T1; + compose(fn1: (x: T1) => T2, fn0: (x0: V0) => T1): (x0: V0) => T2; + compose(fn1: (x: T1) => T2, fn0: (x0: V0, x1: V1) => T1): (x0: V0, x1: V1) => T2; + compose(fn1: (x: T1) => T2, fn0: (x0: V0, x1: V1, x2: V2) => T1): (x0: V0, x1: V1, x2: V2) => T2; + compose(fn1: (x: T1) => T2, fn0: (x0: V0, x1: V1, x2: V2, x3: V3) => T1): (x0: V0, x1: V1, x2: V2, x3: V3) => T2; + compose(fn2: (x: T2) => T3, fn1: (x: T1) => T2, fn0: (x0: V0) => T1): (x0: V0) => T3; + compose(fn2: (x: T2) => T3, fn1: (x: T1) => T2, fn0: (x0: V0, x1: V1) => T1): (x0: V0, x1: V1) => T3; + compose(fn2: (x: T2) => T3, fn1: (x: T1) => T2, fn0: (x0: V0, x1: V1, x2: V2) => T1): (x0: V0, x1: V1, x2: V2) => T3; + compose(fn2: (x: T2) => T3, fn1: (x: T1) => T2, fn0: (x0: V0, x1: V1, x2: V2, x3: V3) => T1): (x0: V0, x1: V1, x2: V2, x3: V3) => T3; + compose(fn3: (x: T3) => T4, fn2: (x: T2) => T3, fn1: (x: T1) => T2, fn0: (x0: V0) => T1): (x0: V0) => T4; + compose(fn3: (x: T3) => T4, fn2: (x: T2) => T3, fn1: (x: T1) => T2, fn0: (x0: V0, x1: V1) => T1): (x0: V0, x1: V1) => T4; + compose(fn3: (x: T3) => T4, fn2: (x: T2) => T3, fn1: (x: T1) => T2, fn0: (x0: V0, x1: V1, x2: V2) => T1): (x0: V0, x1: V1, x2: V2) => T4; + compose(fn3: (x: T3) => T4, fn2: (x: T2) => T3, fn1: (x: T1) => T2, fn0: (x0: V0, x1: V1, x2: V2, x3: V3) => T1): (x0: V0, x1: V1, x2: V2, x3: V3) => T4; + compose(fn4: (x: T4) => T5, fn3: (x: T3) => T4, fn2: (x: T2) => T3, fn1: (x: T1) => T2, fn0: (x0: V0) => T1): (x0: V0) => T5; + compose(fn4: (x: T4) => T5, fn3: (x: T3) => T4, fn2: (x: T2) => T3, fn1: (x: T1) => T2, fn0: (x0: V0, x1: V1) => T1): (x0: V0, x1: V1) => T5; + compose(fn4: (x: T4) => T5, fn3: (x: T3) => T4, fn2: (x: T2) => T3, fn1: (x: T1) => T2, fn0: (x0: V0, x1: V1, x2: V2) => T1): (x0: V0, x1: V1, x2: V2) => T5; + compose(fn4: (x: T4) => T5, fn3: (x: T3) => T4, fn2: (x: T2) => T3, fn1: (x: T1) => T2, fn0: (x0: V0, x1: V1, x2: V2, x3: V3) => T1): (x0: V0, x1: V1, x2: V2, x3: V3) => T5; + compose(fn5: (x: T5) => T6, fn4: (x: T4) => T5, fn3: (x: T3) => T4, fn2: (x: T2) => T3, fn1: (x: T1) => T2, fn0: (x0: V0) => T1): (x0: V0) => T6; + compose(fn5: (x: T5) => T6, fn4: (x: T4) => T5, fn3: (x: T3) => T4, fn2: (x: T2) => T3, fn1: (x: T1) => T2, fn0: (x0: V0, x1: V1) => T1): (x0: V0, x1: V1) => T6; + compose(fn5: (x: T5) => T6, fn4: (x: T4) => T5, fn3: (x: T3) => T4, fn2: (x: T2) => T3, fn1: (x: T1) => T2, fn0: (x0: V0, x1: V1, x2: V2) => T1): (x0: V0, x1: V1, x2: V2) => T6; + compose(fn5: (x: T5) => T6, fn4: (x: T4) => T5, fn3: (x: T3) => T4, fn2: (x: T2) => T3, fn1: (x: T1) => T2, fn0: (x0: V0, x1: V1, x2: V2, x3: V3) => T1): (x0: V0, x1: V1, x2: V2, x3: V3) => T6; + compose(fn6: (x: T6) => T7, fn5: (x: T5) => T6, fn4: (x: T4) => T5, fn3: (x: T3) => T4, fn2: (x: T2) => T3, fn1: (x: T1) => T2, fn0: (x0: V0) => T1): (x0: V0) => T7; + compose(fn6: (x: T6) => T7, fn5: (x: T5) => T6, fn4: (x: T4) => T5, fn3: (x: T3) => T4, fn2: (x: T2) => T3, fn1: (x: T1) => T2, fn0: (x0: V0, x1: V1) => T1): (x0: V0, x1: V1) => T7; + compose(fn6: (x: T6) => T7, fn5: (x: T5) => T6, fn4: (x: T4) => T5, fn3: (x: T3) => T4, fn2: (x: T2) => T3, fn1: (x: T1) => T2, fn0: (x0: V0, x1: V1, x2: V2) => T1): (x0: V0, x1: V1, x2: V2) => T7; + compose(fn6: (x: T6) => T7, fn5: (x: T5) => T6, fn4: (x: T4) => T5, fn3: (x: T3) => T4, fn2: (x: T2) => T3, fn1: (x: T1) => T2, fn0: (x0: V0, x1: V1, x2: V2, x3: V3) => T1): (x0: V0, x1: V1, x2: V2, x3: V3) => T7; + compose(fn7: (x: T7) => T8, fn6: (x: T6) => T7, fn5: (x: T5) => T6, fn4: (x: T4) => T5, fn3: (x: T3) => T4, fn2: (x: T2) => T3, fn1: (x: T1) => T2, fn0: (x0: V0) => T1): (x0: V0) => T8; + compose(fn7: (x: T7) => T8, fn6: (x: T6) => T7, fn5: (x: T5) => T6, fn4: (x: T4) => T5, fn3: (x: T3) => T4, fn2: (x: T2) => T3, fn1: (x: T1) => T2, fn0: (x0: V0, x1: V1) => T1): (x0: V0, x1: V1) => T8; + compose(fn7: (x: T7) => T8, fn6: (x: T6) => T7, fn5: (x: T5) => T6, fn4: (x: T4) => T5, fn3: (x: T3) => T4, fn2: (x: T2) => T3, fn1: (x: T1) => T2, fn0: (x0: V0, x1: V1, x2: V2) => T1): (x0: V0, x1: V1, x2: V2) => T8; + compose(fn7: (x: T7) => T8, fn6: (x: T6) => T7, fn5: (x: T5) => T6, fn4: (x: T4) => T5, fn3: (x: T3) => T4, fn2: (x: T2) => T3, fn1: (x: T1) => T2, fn0: (x0: V0, x1: V1, x2: V2, x3: V3) => T1): (x0: V0, x1: V1, x2: V2, x3: V3) => T8; + compose(fn8: (x: T8) => T9, fn7: (x: T7) => T8, fn6: (x: T6) => T7, fn5: (x: T5) => T6, fn4: (x: T4) => T5, fn3: (x: T3) => T4, fn2: (x: T2) => T3, fn1: (x: T1) => T2, fn0: (x0: V0) => T1): (x0: V0) => T9; + compose(fn8: (x: T8) => T9, fn7: (x: T7) => T8, fn6: (x: T6) => T7, fn5: (x: T5) => T6, fn4: (x: T4) => T5, fn3: (x: T3) => T4, fn2: (x: T2) => T3, fn1: (x: T1) => T2, fn0: (x0: V0, x1: V1) => T1): (x0: V0, x1: V1) => T9; + compose(fn8: (x: T8) => T9, fn7: (x: T7) => T8, fn6: (x: T6) => T7, fn5: (x: T5) => T6, fn4: (x: T4) => T5, fn3: (x: T3) => T4, fn2: (x: T2) => T3, fn1: (x: T1) => T2, fn0: (x0: V0, x1: V1, x2: V2) => T1): (x0: V0, x1: V1, x2: V2) => T9; + compose(fn8: (x: T8) => T9, fn7: (x: T7) => T8, fn6: (x: T6) => T7, fn5: (x: T5) => T6, fn4: (x: T4) => T5, fn3: (x: T3) => T4, fn2: (x: T2) => T3, fn1: (x: T1) => T2, fn0: (x0: V0, x1: V1, x2: V2, x3: V3) => T1): (x0: V0, x1: V1, x2: V2, x3: V3) => T9; + + /** + * Returns the right-to-left Kleisli composition of the provided functions, each of which must return a value of a type supported by chain. + */ + composeK(fn0: (v: Chain) => Chain): (v: V) => Chain; + composeK(fn1: (x: T1) => Chain, fn0: (v: Chain) => Chain): (v: V) => Chain; + composeK(fn2: (x: T2) => Chain, fn1: (x: T1) => Chain, fn0: (v: Chain) => Chain): (v: V) => Chain; + composeK(fn3: (x: T3) => Chain, fn2: (x: T2) => Chain, fn1: (x: T1) => Chain, fn0: (v: Chain) => Chain): (v: V) => Chain; + composeK(fn4: (x: T4) => Chain, fn3: (x: T3) => Chain, fn2: (x: T2) => Chain, fn1: (x: T1) => Chain, fn0: (v: Chain) => Chain): (v: V) => Chain; + composeK(fn5: (x: T5) => Chain, fn4: (x: T4) => Chain, fn3: (x: T3) => Chain, fn2: (x: T2) => Chain, fn1: (x: T1) => Chain, fn0: (v: Chain) => Chain): (v: V) => Chain; + composeK(fn6: (x: T6) => Chain, fn5: (x: T5) => Chain, fn4: (x: T4) => Chain, fn3: (x: T3) => Chain, fn2: (x: T2) => Chain, fn1: (x: T1) => Chain, fn0: (v: Chain) => Chain): (v: V) => Chain; + composeK(fn7: (x: T7) => Chain, fn6: (x: T6) => Chain, fn5: (x: T5) => Chain, fn4: (x: T4) => Chain, fn3: (x: T3) => Chain, fn2: (x: T2) => Chain, fn1: (x: T1) => Chain, fn0: (v: Chain) => Chain): (v: V) => Chain; + composeK(fn8: (x: T8) => Chain, fn7: (x: T7) => Chain, fn6: (x: T6) => Chain, fn5: (x: T5) => Chain, fn4: (x: T4) => Chain, fn3: (x: T3) => Chain, fn2: (x: T2) => Chain, fn1: (x: T1) => Chain, fn0: (v: Chain) => Chain): (v: V) => Chain; + + /** + * Performs right-to-left composition of one or more Promise-returning functions. The rightmost function may have any arity; the remaining functions must be unary. + */ + composeP(fn0: (x0: V0) => Promise): (x0: V0) => Promise; + composeP(fn0: (x0: V0, x1: V1) => Promise): (x0: V0, x1: V1) => Promise; + composeP(fn0: (x0: V0, x1: V1, x2: V2) => Promise): (x0: V0, x1: V1, x2: V2) => Promise; + composeP(fn0: (x0: V0, x1: V1, x2: V2, x3: V3) => Promise): (x0: V0, x1: V1, x2: V2, x3: V3) => Promise; + composeP(fn1: (x: T1) => Promise | T2, fn0: (x0: V0) => Promise): (x0: V0) => Promise; + composeP(fn1: (x: T1) => Promise | T2, fn0: (x0: V0, x1: V1) => Promise): (x0: V0, x1: V1) => Promise; + composeP(fn1: (x: T1) => Promise | T2, fn0: (x0: V0, x1: V1, x2: V2) => Promise): (x0: V0, x1: V1, x2: V2) => Promise; + composeP(fn1: (x: T1) => Promise | T2, fn0: (x0: V0, x1: V1, x2: V2, x3: V3) => Promise): (x0: V0, x1: V1, x2: V2, x3: V3) => Promise; + composeP(fn2: (x: T2) => Promise | T3, fn1: (x: T1) => Promise | T2, fn0: (x0: V0) => Promise): (x0: V0) => Promise; + composeP(fn2: (x: T2) => Promise | T3, fn1: (x: T1) => Promise | T2, fn0: (x0: V0, x1: V1) => Promise): (x0: V0, x1: V1) => Promise; + composeP(fn2: (x: T2) => Promise | T3, fn1: (x: T1) => Promise | T2, fn0: (x0: V0, x1: V1, x2: V2) => Promise): (x0: V0, x1: V1, x2: V2) => Promise; + composeP(fn2: (x: T2) => Promise | T3, fn1: (x: T1) => Promise | T2, fn0: (x0: V0, x1: V1, x2: V2, x3: V3) => Promise): (x0: V0, x1: V1, x2: V2, x3: V3) => Promise; + composeP(fn3: (x: T3) => Promise | T4, fn2: (x: T2) => Promise | T3, fn1: (x: T1) => Promise | T2, fn0: (x0: V0) => Promise): (x0: V0) => Promise; + composeP(fn3: (x: T3) => Promise | T4, fn2: (x: T2) => Promise | T3, fn1: (x: T1) => Promise | T2, fn0: (x0: V0, x1: V1) => Promise): (x0: V0, x1: V1) => Promise; + composeP(fn3: (x: T3) => Promise | T4, fn2: (x: T2) => Promise | T3, fn1: (x: T1) => Promise | T2, fn0: (x0: V0, x1: V1, x2: V2) => Promise): (x0: V0, x1: V1, x2: V2) => Promise; + composeP(fn3: (x: T3) => Promise | T4, fn2: (x: T2) => Promise | T3, fn1: (x: T1) => Promise | T2, fn0: (x0: V0, x1: V1, x2: V2, x3: V3) => Promise): (x0: V0, x1: V1, x2: V2, x3: V3) => Promise; + composeP(fn4: (x: T4) => Promise | T5, fn3: (x: T3) => Promise | T4, fn2: (x: T2) => Promise | T3, fn1: (x: T1) => Promise | T2, fn0: (x0: V0) => Promise): (x0: V0) => Promise; + composeP(fn4: (x: T4) => Promise | T5, fn3: (x: T3) => Promise | T4, fn2: (x: T2) => Promise | T3, fn1: (x: T1) => Promise | T2, fn0: (x0: V0, x1: V1) => Promise): (x0: V0, x1: V1) => Promise; + composeP(fn4: (x: T4) => Promise | T5, fn3: (x: T3) => Promise | T4, fn2: (x: T2) => Promise | T3, fn1: (x: T1) => Promise | T2, fn0: (x0: V0, x1: V1, x2: V2) => Promise): (x0: V0, x1: V1, x2: V2) => Promise; + composeP(fn4: (x: T4) => Promise | T5, fn3: (x: T3) => Promise | T4, fn2: (x: T2) => Promise | T3, fn1: (x: T1) => Promise | T2, fn0: (x0: V0, x1: V1, x2: V2, x3: V3) => Promise): (x0: V0, x1: V1, x2: V2, x3: V3) => Promise; + composeP(fn5: (x: T5) => Promise | T6, fn4: (x: T4) => Promise | T5, fn3: (x: T3) => Promise | T4, fn2: (x: T2) => Promise | T3, fn1: (x: T1) => Promise | T2, fn0: (x0: V0) => Promise): (x0: V0) => Promise; + composeP(fn5: (x: T5) => Promise | T6, fn4: (x: T4) => Promise | T5, fn3: (x: T3) => Promise | T4, fn2: (x: T2) => Promise | T3, fn1: (x: T1) => Promise | T2, fn0: (x0: V0, x1: V1) => Promise): (x0: V0, x1: V1) => Promise; + composeP(fn5: (x: T5) => Promise | T6, fn4: (x: T4) => Promise | T5, fn3: (x: T3) => Promise | T4, fn2: (x: T2) => Promise | T3, fn1: (x: T1) => Promise | T2, fn0: (x0: V0, x1: V1, x2: V2) => Promise): (x0: V0, x1: V1, x2: V2) => Promise; + composeP(fn5: (x: T5) => Promise | T6, fn4: (x: T4) => Promise | T5, fn3: (x: T3) => Promise | T4, fn2: (x: T2) => Promise | T3, fn1: (x: T1) => Promise | T2, fn0: (x0: V0, x1: V1, x2: V2, x3: V3) => Promise): (x0: V0, x1: V1, x2: V2, x3: V3) => Promise; + composeP(fn6: (x: T6) => Promise | T7, fn5: (x: T5) => Promise | T6, fn4: (x: T4) => Promise | T5, fn3: (x: T3) => Promise | T4, fn2: (x: T2) => Promise | T3, fn1: (x: T1) => Promise | T2, fn0: (x0: V0) => Promise): (x0: V0) => Promise; + composeP(fn6: (x: T6) => Promise | T7, fn5: (x: T5) => Promise | T6, fn4: (x: T4) => Promise | T5, fn3: (x: T3) => Promise | T4, fn2: (x: T2) => Promise | T3, fn1: (x: T1) => Promise | T2, fn0: (x0: V0, x1: V1) => Promise): (x0: V0, x1: V1) => Promise; + composeP(fn6: (x: T6) => Promise | T7, fn5: (x: T5) => Promise | T6, fn4: (x: T4) => Promise | T5, fn3: (x: T3) => Promise | T4, fn2: (x: T2) => Promise | T3, fn1: (x: T1) => Promise | T2, fn0: (x0: V0, x1: V1, x2: V2) => Promise): (x0: V0, x1: V1, x2: V2) => Promise; + composeP(fn6: (x: T6) => Promise | T7, fn5: (x: T5) => Promise | T6, fn4: (x: T4) => Promise | T5, fn3: (x: T3) => Promise | T4, fn2: (x: T2) => Promise | T3, fn1: (x: T1) => Promise | T2, fn0: (x0: V0, x1: V1, x2: V2, x3: V3) => Promise): (x0: V0, x1: V1, x2: V2, x3: V3) => Promise; + composeP(fn7: (x: T7) => Promise | T8, fn6: (x: T6) => Promise | T7, fn5: (x: T5) => Promise | T6, fn4: (x: T4) => Promise | T5, fn3: (x: T3) => Promise | T4, fn2: (x: T2) => Promise | T3, fn1: (x: T1) => Promise | T2, fn0: (x0: V0) => Promise): (x0: V0) => Promise; + composeP(fn7: (x: T7) => Promise | T8, fn6: (x: T6) => Promise | T7, fn5: (x: T5) => Promise | T6, fn4: (x: T4) => Promise | T5, fn3: (x: T3) => Promise | T4, fn2: (x: T2) => Promise | T3, fn1: (x: T1) => Promise | T2, fn0: (x0: V0, x1: V1) => Promise): (x0: V0, x1: V1) => Promise; + composeP(fn7: (x: T7) => Promise | T8, fn6: (x: T6) => Promise | T7, fn5: (x: T5) => Promise | T6, fn4: (x: T4) => Promise | T5, fn3: (x: T3) => Promise | T4, fn2: (x: T2) => Promise | T3, fn1: (x: T1) => Promise | T2, fn0: (x0: V0, x1: V1, x2: V2) => Promise): (x0: V0, x1: V1, x2: V2) => Promise; + composeP(fn7: (x: T7) => Promise | T8, fn6: (x: T6) => Promise | T7, fn5: (x: T5) => Promise | T6, fn4: (x: T4) => Promise | T5, fn3: (x: T3) => Promise | T4, fn2: (x: T2) => Promise | T3, fn1: (x: T1) => Promise | T2, fn0: (x0: V0, x1: V1, x2: V2, x3: V3) => Promise): (x0: V0, x1: V1, x2: V2, x3: V3) => Promise; + composeP(fn8: (x: T8) => Promise | T9, fn7: (x: T7) => Promise | T8, fn6: (x: T6) => Promise | T7, fn5: (x: T5) => Promise | T6, fn4: (x: T4) => Promise | T5, fn3: (x: T3) => Promise | T4, fn2: (x: T2) => Promise | T3, fn1: (x: T1) => Promise | T2, fn0: (x0: V0) => Promise): (x0: V0) => Promise; + composeP(fn8: (x: T8) => Promise | T9, fn7: (x: T7) => Promise | T8, fn6: (x: T6) => Promise | T7, fn5: (x: T5) => Promise | T6, fn4: (x: T4) => Promise | T5, fn3: (x: T3) => Promise | T4, fn2: (x: T2) => Promise | T3, fn1: (x: T1) => Promise | T2, fn0: (x0: V0, x1: V1) => Promise): (x0: V0, x1: V1) => Promise; + composeP(fn8: (x: T8) => Promise | T9, fn7: (x: T7) => Promise | T8, fn6: (x: T6) => Promise | T7, fn5: (x: T5) => Promise | T6, fn4: (x: T4) => Promise | T5, fn3: (x: T3) => Promise | T4, fn2: (x: T2) => Promise | T3, fn1: (x: T1) => Promise | T2, fn0: (x0: V0, x1: V1, x2: V2) => Promise): (x0: V0, x1: V1, x2: V2) => Promise; + composeP(fn8: (x: T8) => Promise | T9, fn7: (x: T7) => Promise | T8, fn6: (x: T6) => Promise | T7, fn5: (x: T5) => Promise | T6, fn4: (x: T4) => Promise | T5, fn3: (x: T3) => Promise | T4, fn2: (x: T2) => Promise | T3, fn1: (x: T1) => Promise | T2, fn0: (x0: V0, x1: V1, x2: V2, x3: V3) => Promise): (x0: V0, x1: V1, x2: V2, x3: V3) => Promise; + + /** + * Returns a new list consisting of the elements of the first list followed by the elements + * of the second. + */ + concat>(list1: T, list2: T): T; + concat>(list1: T): (list2: T) => T; + // concat>: CurriedFunction2; + + /** + * Returns a function, fn, which encapsulates if/else-if/else logic. R.cond takes a list of [predicate, transform] pairs. + * All of the arguments to fn are applied to each of the predicates in turn until one returns a "truthy" value, at which + * point fn returns the result of applying its arguments to the corresponding transformer. If none of the predicates + * matches, fn returns undefined. + */ + cond(fns: [Pred, (v: T) => U][]): (v: T) => U; + + /** + * Wraps a constructor function inside a curried function that can be called with the same arguments and returns the same type. + */ + construct(fn: Function): Function; + + /** + * Wraps a constructor function inside a curried function that can be called with the same arguments and returns the same type. + * The arity of the function returned is specified to allow using variadic constructor functions. + */ + constructN(n: number, fn: Function): Function; + // constructN: CurriedFunction2; + + + /** + * Returns `true` if the specified item is somewhere in the list, `false` otherwise. + * Equivalent to `indexOf(a)(list) > -1`. Uses strict (`===`) equality checking. + */ + contains(a: string, list: string): boolean; + contains(a: string): (list: string) => boolean; + // contains: CurriedFunction2; + contains>(a: T, list: R): boolean; + contains>(a: T): (list: R) => boolean; + // contains>: CurriedFunction2; + + /** + * Accepts a converging function and a list of branching functions and returns a new + * function. When invoked, this new function is applied to some arguments, each branching + * function is applied to those same arguments. The results of each branching function + * are passed as arguments to the converging function to produce the return value. + */ + converge(after: Variadic, fns: List>): Variadic; + // converge: CurriedFunction2, List>, Variadic>; + + /** + * Counts the elements of a list according to how many match each value + * of a key generated by the supplied function. Returns an object + * mapping the keys produced by `fn` to the number of occurrences in + * the list. Note that all keys are coerced to strings because of how + * JavaScript objects work. + */ + countBy(fn: (a: T) => Prop, list: List): Obj; + countBy(fn: (a: T) => Prop): (list: List) => Obj; + // countBy: CurriedFunction2<(a: T) => Prop, List, Obj>; + + curry: typeof curry + + /** + * Returns a curried equivalent of the provided function, with the specified arity. + */ + curryN(length: number, fn: Variadic): Variadic; + // curryN: CurriedFunction2, Variadic>; + + + /** + * Decrements its argument. + */ + dec(n: number): number; + + /** + * Returns the second argument if it is not null or undefined. If it is null or undefined, the + * first (default) argument is returned. + */ + defaultTo(a: T, b: U): T | U; + defaultTo(a: T): (b: U) => T | U; + // defaultTo: CurriedFunction2; + + /** + * Makes a descending comparator function out of a function that returns a value that can be compared with `<` and `>`. + */ + descend(comparator: (val: T) => V, a: T, b: T): number; + descend(comparator: (val: T) => V, a: T): (b: T) => number; + descend(comparator: (val: T) => V): CurriedFunction2; + // descend: CurriedFunction3<(val: T) => V, T, T, number>; + + /** + * Finds the set (i.e. no duplicates) of all elements in the first list not contained in the second list. + */ + difference(list1: List, list2: List): T[]; + difference(list1: List): (list2: List) => T[]; + // difference: CurriedFunction2, List, T[]>; + + /** + * Finds the set (i.e. no duplicates) of all elements in the first list not contained in the second list. + * Duplication is determined according to the value returned by applying the supplied predicate to two list + * elements. + */ + // differenceWith(pred: (a: T, b: T) => boolean, list1: List, list2: List): T[]; + // differenceWith(pred: (a: T, b: T) => boolean, list1: List): (list2: List) => T[]; + // differenceWith(pred: (a: T, b: T) => boolean): CurriedFunction2,List,T>; + // differenceWith: CurriedFunction3<(a: T, b: T) => boolean, List, List, T[]>; + + // base + differenceWith(pred: (a: T, b: T) => boolean, list1: List, list2: List): T[]; + differenceWith(pred: (a: T, b: T) => boolean, list1: List): { + (list2: List): T[]; + }; + differenceWith(pred: (a: T, b: T) => boolean): { + (list1: List, list2: List): T[]; + (list1: List): { + (list2: List): T[]; + }; + }; + + + /* + * Returns a new object that does not contain a prop property. + */ + + // TODO: fix, can't yet calculate type of object minus this key + // dissoc(prop: Prop, obj: T & { [prop: Prop]: any }): T; // wanna say the original object is the same with the extra key, but can't bind it to prop + // dissoc>(prop: keyof U, obj: U): T; + + // simplified but inferrable: leave the key in + // dissoc(prop: keyof T, obj: T): T; + dissoc(prop: Prop): (obj: T) => T; // mix + // dissoc: CurriedFunction2; + // dissoc: CurriedFunction2; + + // It seems impossible to infer the return type, so this may have to be specified explicitly + dissoc(prop: Prop, obj: Struct): T; + // dissoc(prop: Prop): (obj: Struct) => T; // mix + // dissoc: CurriedFunction2, T>; + // dissoc>(prop: keyof U): (obj: U) => T; // can't do this, don't know U in time + + // mixed curry: + dissoc(prop: Prop): { + (obj: T): T; // infer + (obj: Struct): T; // manual + }; + + /** + * Makes a shallow clone of an object, omitting the property at the given path. + */ + dissocPath(path: Path, obj: Struct): T; + dissocPath(path: Path): (obj: Struct) => T; + // dissocPath: CurriedFunction2, T>; + + /** + * Divides two numbers. Equivalent to a / b. + */ + divide(a: number, b: number): number; + divide(a: number): (b: number) => number; + // divide: CurriedFunction2; + + /** + * Returns a new list containing all but the first n elements of the given list. + */ + drop>(n: number, xs: T): T; + drop>(n: number): (xs: T) => T; + // drop>: CurriedFunction2; + + /** + * Returns a list containing all but the last n elements of the given list. + */ + // = drop + dropLast>(n: number, xs: T): T; + dropLast>(n: number): (xs: T) => T; + // dropLast>: CurriedFunction2; + + /** + * Returns a new list containing all but last then elements of a given list, passing each value from the + * right to the supplied predicate function, skipping elements while the predicate function returns true. + */ + // = dropWhile + dropLastWhile>(pred: Pred, list: R): T[]; + dropLastWhile>(pred: Pred): (list: R) => T[]; + // dropLastWhile>: CurriedFunction2, R, T[]>; + + /** + * Returns a new list containing the last n elements of a given list, passing each value to the supplied + * predicate function, skipping elements while the predicate function returns true. + */ + dropWhile>(pred: Pred, list: R): T[]; + dropWhile>(pred: Pred): (list: R) => T[]; + // dropWhile>: CurriedFunction2, R, T[]>; + + /** + * A function wrapping calls to the two functions in an || operation, returning the result of the first + * function if it is truth-y and the result of the second function otherwise. Note that this is + * short-circuited, meaning that the second function will not be invoked if the first returns a truth-y value. + */ + either(pred1: Pred, pred2: Pred): Pred; + either(pred1: Pred): (pred2: Pred) => Pred; + // either: CurriedFunction2, Pred, Pred>; + + /** + * Returns the empty value of its argument's type. Ramda defines the empty value of Array ([]), Object ({}), + * String (''), and Arguments. Other types are supported if they define .empty and/or .prototype.empty. + * Dispatches to the empty method of the first argument, if present. + */ + empty(x: T): T; + + /** + * Takes a function and two values in its domain and returns true if the values map to the same value in the + * codomain; false otherwise. + */ + // eqBy(fn: (a: T) => T, a: T, b: T): boolean; + // eqBy(fn: (a: T) => T, a: T): (b: T) => boolean; + // eqBy(fn: (a: T) => T): CurriedFunction2; + // eqBy: CurriedFunction3<(a: T) => T, T, T, boolean>; + + // base + eqBy(fn: (a: T) => T, a: T, b: T): boolean; + eqBy(fn: (a: T) => T, a: T): { + (b: T): boolean; + }; + eqBy(fn: (a: T) => T): { + (a: T, b: T): boolean; + (a: T): { + (b: T): boolean; + }; + }; + + + /** + * Reports whether two functions have the same value for the specified property. + */ + // hard to mix cuz different initial generics? + + // more generics + // eqProps(prop: Prop, obj1: T, obj2: U): boolean; + // eqProps(prop: Prop, obj1: T): (obj2: U) => boolean; + // eqProps(prop: Prop): CurriedFunction2; + // eqProps(prop: Prop): (obj1: T, obj2: U) => boolean; + // eqProps: CurriedFunction3; + + // less generics + // eqProps(prop: Prop, obj1: any, obj2: any): boolean; + // eqProps(prop: Prop, obj1: any): (obj2: any) => boolean; + // eqProps(prop: Prop): CurriedFunction2; + // eqProps(prop: Prop): (obj1: any, obj2: any) => boolean; + // eqProps(prop: Prop): (obj1: any) => (obj2: any) => boolean; + // eqProps: CurriedFunction3; + + // base + eqProps(prop: Prop, obj1: T, obj2: U): boolean; + eqProps(prop: Prop, obj1: T): { + (obj2: U): boolean; + }; + eqProps(prop: Prop): { + (obj1: T, obj2: U): boolean; + (obj1: T): { + (obj2: U): boolean; + }; + }; + + // less generics + eqProps(prop: Prop, obj1: any, obj2: any): boolean; + eqProps(prop: Prop, obj1: any): { + (obj2: any): boolean; + }; + eqProps(prop: Prop): { + (obj1: any, obj2: any): boolean; + (obj1: any): { + (obj2: any): boolean; + }; + }; + + + /** + * Returns true if its arguments are equivalent, false otherwise. Dispatches to an equals method if present. + * Handles cyclical data structures. + */ + equals(a: T, b: T): boolean; + equals(a: T): (b: T) => boolean; + // equals: CurriedFunction2; + + /** + * Creates a new object by evolving a shallow copy of object, according to the transformation functions. + */ + // hard to mix cuz different generics + + // NestedObj + evolve(transformations: NestedObj<(v: any) => any>, obj: V): V; + evolve(transformations: NestedObj<(v: any) => any>): (obj: V) => V; + // evolve: CurriedFunction2 any>, V, V>; + + // no inference, manually supply result type + evolve(transformations: Obj, obj: any): T; + evolve(transformations: Obj): (obj: any) => T; + // evolve: CurriedFunction2, any, T>; + + /* + * A function that always returns false. Any passed in parameters are ignored. + */ + F(): false; + + /** + * Returns a new list containing only those items that match a given predicate function. The predicate function is passed one argument: (value). + */ + + // array + filter(pred: Pred, list: List): T[]; + // filter(pred: Pred): (list: List) => T[]; // should disable for mixing, but this somehow makes #73 fail + // filter: CurriedFunction2, List, T[]>; + + // functor to functor + filter(pred: Pred, list: Functor): Functor; + // filter(pred: Pred): (list: Functor) => Functor; // mix + // filter: CurriedFunction2<(value: T) => boolean, Functor, Functor>; + + // functor to array + filter(pred: Pred, list: Functor): T[]; + // filter(pred: Pred): (list: Functor) => T[]; // mix + // filter: CurriedFunction2<(value: T) => boolean, Functor, T[]>; + + // object + // filter>(pred: Pred, obj: U) : Partial; + filter(pred: Pred): >(obj: U) => U; // mix + // filter>: CurriedFunction2<(value: T) => boolean, U, Partial>; + + // mixed + filter(pred: Pred): { + (list: List): T[]; + (list: Functor): Functor; + (list: Functor): T[]; + >(obj: U): U; + }; + + /** + * Returns the first element of the list which matches the predicate, or `undefined` if no + * element matches. + */ + find(fn: (a: T) => boolean, list: List): T; + find(fn: (a: T) => boolean): (list: List) => T; + // find: CurriedFunction2<(a: T) => boolean, List, T>; + + + /** + * Returns the index of the first element of the list which matches the predicate, or `-1` + * if no element matches. + */ + findIndex(fn: (a: T) => boolean, list: List): number; + findIndex(fn: (a: T) => boolean): (list: List) => number; + // findIndex: CurriedFunction2<(a: T) => boolean, List, number>; + + /** + * Returns the last element of the list which matches the predicate, or `undefined` if no + * element matches. + */ + findLast(fn: (a: T) => boolean, list: List): T; + findLast(fn: (a: T) => boolean): (list: List) => T; + // findLast: CurriedFunction2<(a: T) => boolean, List, T>; + + /** + * Returns the index of the last element of the list which matches the predicate, or + * `-1` if no element matches. + */ + findLastIndex(fn: (a: T) => boolean, list: List): number; + findLastIndex(fn: (a: T) => boolean): (list: List) => number; + // findLastIndex: CurriedFunction2<(a: T) => boolean, List, number>; + + /** + * Returns a new list by pulling every item out of it (and all its sub-arrays) and putting + * them in a new array, depth-first. + */ + // flatten(x: ArrayLike>>>>>>): T[]; + // flatten(x: ArrayLike>>>>>): T[]; + // flatten(x: ArrayLike>>>>): T[]; + // flatten(x: ArrayLike>>>): T[]; + // flatten(x: ArrayLike>>): T[]; + // flatten(x: ArrayLike>): T[]; + // flatten(x: ArrayLike): T[]; + // TODO: figure out how to handle arrays using different levels of nesting + // flatten(x: ListOfRecursiveArraysOrValues): T[]; + flatten(x: NestedArray): T[]; + + /** + * Returns a new function much like the supplied one, except that the first two arguments' + * order is reversed. + */ + flip(fn: (arg0: T, arg1: U) => TResult): (arg1: U, arg0?: T) => TResult; + flip(fn: (arg0: T, arg1: U, ...args: Rest[]) => TResult): (arg1: U, arg0?: T, ...args: Rest[]) => TResult; + + + /** + * Iterate over an input list, calling a provided function fn for each element in the list. + */ + forEach(fn: (x: T) => void, list: List): T[]; + forEach(fn: (x: T) => void): (list: List) => T[]; + // forEach: CurriedFunction2<(x: T) => void, List, T[]>; + + /** + * Iterate over an input object, calling a provided function fn for each key and value in the object. + */ + forEachObjIndexed>(fn: (val: T, key: string, obj?: Inp) => void, o: Inp): Inp; + forEachObjIndexed>(fn: (val: T, key: string, obj?: Inp) => void): (o: Inp) => Inp; + // forEachObjIndexed>: CurriedFunction2<(val: T, key: string, obj?: Inp) => void, Inp, Inp>; + + /** + * Creates a new object out of a list key-value pairs. + */ + fromPairs(pairs: List>): Obj; + + /** + * Splits a list into sublists stored in an object, based on the result of + * calling a String-returning function + * on each element, and grouping the results according to values returned. + */ + groupBy(fn: (a: T) => Prop, list: List): Obj; + groupBy(fn: (a: T) => Prop): (list: List) => Obj; + // groupBy: CurriedFunction2<(a: T) => Prop, List, Obj>; + + /** + * Takes a list and returns a list of lists where each sublist's elements are all "equal" according to the provided equality function + */ + groupWith>(fn: (x: T, y: T) => boolean, list: R): R[]; + groupWith>(fn: (x: T, y: T) => boolean): (list: R) => R[]; + // groupWith>: CurriedFunction2<(x: T, y: T) => boolean, R, R[]>; + + /** + * Returns true if the first parameter is greater than the second. + */ + gt(a: number, b: number): boolean; + gt(a: number): (b: number) => boolean; + // gt: CurriedFunction2; + + /** + * Returns true if the first parameter is greater than or equal to the second. + */ + gte(a: number, b: number): boolean; + gte(a: number): (b: number) => boolean; + // gte: CurriedFunction2; + + /** + * Returns whether or not an object has an own property with the specified name. + */ + + // no generics + has(s: Prop, obj: Struct): boolean; + has(s: Prop): (obj: Struct) => boolean; + // has: CurriedFunction2, boolean>; + + // // bound generic, hopefully gives a hint as to what goes into obj + // has>(s: Prop, obj: T): boolean; + // // has(s: Prop): >(obj: T) => boolean; // mix + // // has>: CurriedFunction2; + + // // free generic, helps make a few tests pass. TODO: kill this workaround? + // has(s: Prop, obj: T): boolean; + // // has(s: Prop): (obj: T) => boolean; // mix + // // has: CurriedFunction2; + + // // mixed + // has(s: Prop): { + // >(obj: T): boolean; + // (obj: T): boolean; + // } + /** + * Returns whether or not an object or its prototype chain has a property with the specified name + */ + // = has + + // no generics + hasIn(s: Prop, obj: Struct): boolean; + hasIn(s: Prop): (obj: Struct) => boolean; + // hasIn: CurriedFunction2, boolean>; + + // // bound generic, hopefully gives a hint as to what goes into obj + // hasIn>(s: Prop, obj: T): boolean; + // // hasIn(s: Prop): >(obj: T) => boolean; // mix + // // hasIn>: CurriedFunction2; + + // // free generic, helps make a few tests pass. TODO: kill this workaround? + // hasIn(s: Prop, obj: T): boolean; + // // hasIn(s: Prop): (obj: T) => boolean; // mix + // // hasIn: CurriedFunction2; + + // // mixed + // hasIn(s: Prop): { + // >(obj: T): boolean; + // (obj: T): boolean; + // } - // Fantasyland interfaces - - // TODO: incorporate generalized inheritance e.g.: ``; possibly needs [rank 2 - // polymorphism](https://github.com/Microsoft/TypeScript/issues/1213). - - interface Setoid { - equals(b: Setoid): boolean; - } - - interface Semigroup { - concat(b: Semigroup): Semigroup; - } - - interface Monoid extends Semigroup { - /* static */ empty(): Monoid; - } - - interface Functor { - map(fn: (t: T) => U): Functor; - } - - interface Apply extends Functor { - apply(fn: Apply<(t: T) => U>): Apply; - } - - interface Applicative extends Apply { - /* static */ of(a: U): Applicative; - } - - interface Alt extends Functor { - alt(b: T): Alt; - } - - interface Plus extends Alt { - /* static */ zero(): Plus; - } - - interface Alternative extends Plus, Applicative { - } - - interface Foldable { - reduce(fn: (u: U, t: T) => U, u: U): U; - } - - interface Traversable extends Functor, Foldable { - traverse(fn: (t: T) => Applicative, of: (v: V) => Applicative): Applicative>; - } - - interface Chain extends Apply { - chain(fn: (t: T) => Chain): Chain; - } - - interface ChainRec extends Chain { - /* static */ chainRec(f: (next: (a: A) => C, done: (b: B) => C, value: A) => ChainRec, i: A): ChainRec; - } - - interface Monad extends Applicative, Chain { - } - - interface Extend { - extend(f: (v: Extend) => U): Extend; - } - - interface Comonad extends Functor, Extend { - extract(): U; // 'same U as in extend's f -- how to bind? - } - - interface Bifunctor extends Functor /*, Functor*/ { - bimap(f: (v: T) => B, g: (v: U) => D): Bifunctor; - } - - interface Profunctor extends Functor /*, Functor*/ { - promap(f: (v: T) => B, g: (v: U) => D): Profunctor; - } - - // simple types - - type Index = string | number; - type Primitive = string | number | boolean; - type Ord = string | number | boolean | Date; - - interface Dictionary { - [index: string]: T; - } + /** + * Returns the first element in a list. + * In some libraries this function is named `first`. + */ + // head>(list: T): T[0]; + // tuple attempts; it doesn't like these. + head(list: [T]): T; + head(list: [T0, T1]): T0; + head(list: [T0, T1, T2]): T0; + + /** + * Returns true if its arguments are identical, false otherwise. Values are identical if they reference the + * same memory. NaN is identical to NaN; 0 and -0 are not identical. + */ + identical(a: T, b: T): boolean; + identical(a: T): (b: T) => boolean; + // identical: CurriedFunction2; + + /** + * A function that does nothing but return the parameter supplied to it. Good as a default + * or placeholder function. + */ + identity(a: T): T; + + /** + * Creates a function that will process either the onTrue or the onFalse function depending upon the result + * of the condition predicate. + */ + ifElse(fn: Pred, onTrue: (v: T) => U, onFalse: (v: T) => V): (v: T) => U | V; + // ifElse: CurriedFunction3, (v: T) => U, (v: T) => V, (v: T) => U|V>; + + + /** + * Increments its argument. + */ + inc(n: number): number; + + /** + * Given a function that generates a key, turns a list of objects into an object indexing the objects + * by the given key. + */ + indexBy(fn: (a: T) => Prop, list: List): Obj; + indexBy(fn: (a: T) => Prop): (list: List) => Obj; + // indexBy: CurriedFunction2<(a: T) => Prop, List, Obj>; + + /** + * Returns the position of the first occurrence of an item in an array + * (by strict equality), + * or -1 if the item is not included in the array. + */ + indexOf(target: T, list: List): number; + indexOf(target: T): (list: List) => number; + // indexOf: CurriedFunction2, number>; + + /** + * Returns all but the last element of a list. + */ + init>(list: T): T; + + /** + * Inserts the supplied element into the list, at index index. Note that + * this is not destructive: it returns a copy of the list with the changes. + */ + + // homogeneous list + // insert(index: number, elt: T, list: List): T[]; + // insert(index: number, elt: T): (list: List) => T[]; + // insert(index: number): CurriedFunction2, T[]>; + // insert(index: number): (elt: T, list: List) => T[]; + // insert(index: number): (elt: T) => (list: List) => T[]; + // insert: CurriedFunction3, T[]>; + + // base + insert(index: number, elt: T, list: List): T[]; + insert(index: number, elt: T): { + (list: List): T[]; + }; + insert(index: number): { + (elt: T, list: List): T[]; + (elt: T): { + (list: List): T[]; + }; + }; + + + // TODO: tuples? + + /** + * Inserts the sub-list into the list, at index `index`. _Note that this + * is not destructive_: it returns a copy of the list with the changes. + */ + + // homogeneous lists (different types) + // insertAll(index: number, elts: List, list: List): Array; + // insertAll(index: number, elts: List): (list: List) => Array; + // insertAll(index: number): CurriedFunction2, List, Array>; + // insertAll(index: number): (elts: List, list: List) => Array; + // insertAll(index: number): (elts: List) => (list: List) => Array; + // insertAll: CurriedFunction3, List, Array>; + + // homogeneous lists (same type) + // insertAll>(index: number): CurriedFunction2; + + // TODO: allowing either or both arrays to be tuples? + + // base + insertAll(index: number, elts: List, list: List): Array; + insertAll(index: number, elts: List): { + (list: List): Array; + }; + insertAll(index: number): { + (elts: List, list: List): Array; + (elts: List): { + (list: List): Array; + }; + }; + + + /** + * Combines two lists into a set (i.e. no duplicates) composed of those elements common to both lists. + */ + intersection(list1: List, list2: List): Array; + intersection(list1: List): (list2: List) => Array; + // intersection: CurriedFunction2, List, Array>; + + + /** + * Combines two lists into a set (i.e. no duplicates) composed of those + * elements common to both lists. Duplication is determined according + * to the value returned by applying the supplied predicate to two list + * elements. + */ + // intersectionWith(pred: (a: T, b: T) => boolean, list1: List, list2: List): T[]; + // intersectionWith(pred: (a: T, b: T) => boolean): CurriedFunction2, List, T[]>; + // intersectionWith: CurriedFunction3<(a: T, b: T) => boolean, List, List, T[]>; + + // base + intersectionWith(pred: (a: T, b: T) => boolean, list1: List, list2: List): T[]; + intersectionWith(pred: (a: T, b: T) => boolean, list1: List): { + (list2: List): T[]; + }; + intersectionWith(pred: (a: T, b: T) => boolean): { + (list1: List, list2: List): T[]; + (list1: List): { + (list2: List): T[]; + }; + }; + + + /** + * Creates a new list with the separator interposed between elements. + */ + intersperse(separator: T, list: List): T[]; + intersperse(separator: T): (list: List) => T[]; + // intersperse: CurriedFunction2, T[]>; + + /** + * Transforms the items of the list with the transducer and appends the transformed items to the accumulator + * using an appropriate iterator function based on the accumulator type. + */ + // into>(acc: V, xf: (list: List) => U, list: List): U; + // into>(acc: V, xf: (list: List) => U): (list: List) => U; + // into>(acc: V): CurriedFunction2<(list: List) => U, List, U>; + // into>(acc: V): (xf: (list: List) => U, list: List) => U; + // into>(acc: V): (xf: (list: List) => U) => (list: List) => U; + // into>: CurriedFunction3) => U, List, U>; + + // base + into, T, U>(acc: V, xf: (list: List) => U, list: List): U; + into, T, U>(acc: V, xf: (list: List) => U): { + (list: List): U; + }; + into, T, U>(acc: V): { + (xf: (list: List) => U, list: List): U; + (xf: (list: List) => U): { + (list: List): U; + }; + }; + + + /** + * Same as R.invertObj, however this accounts for objects with duplicate values by putting the values into an array. + */ + invert(obj: Struct): Obj>; + + /** + * Returns a new object with the keys of the given object as values, and the values of the given object as keys. + */ + invertObj(obj: Struct): Obj; + + /** + * Turns a named method of an object (or object prototype) into a function that can be + * called directly. Passing the optional `len` parameter restricts the returned function to + * the initial `len` parameters of the method. + * + * The returned function is curried and accepts `len + 1` parameters (or `method.length + 1` + * when `len` is not specified), and the final parameter is the target object. + */ + // with keyof -- currently can't seem do to function application like this yet + // invoker (len: number /* = 0 */, name: K, obj: T): obj[K](); + // // invoker: CurriedFunction3; + // invoker(len: number /* = 1 */, name: K, x1: P1, obj: T): obj[K](x1); + // // invoker: CurriedFunction4; + // invoker(len: number /* = 2 */, name: K, x1: P1, x2: P2, obj: T): obj[K](x1, x2); + // // invoker: CurriedFunction5; + // invoker(len: number /* = 3 */, name: K, x1: P1, x2: P2, x3: P3, obj: T): obj[K](x1, x2, x3); + // // invoker: CurriedFunction6; + // invoker(len: number /* = 4 */, name: K, x1: P1, x2: P2, x3: P3, x4: P4, obj: T): obj[K](x1, x2, x3, x4); + // // invoker: CurriedFunction7; + // invoker(len: number /* = 5 */, name: K, x1: P1, x2: P2, x3: P3, x4: P4, x5: P5, obj: T): obj[K](x1, x2, x3, x4, x5); + // // invoker: CurriedFunction8; + + // manually type results + invoker(len: number /* = 0 */, name: Prop, obj: T): R; + invoker(len: number/* = 0 */, name: Prop): (obj: T) => R; + + invoker(len: number /* = 1 */, name: Prop, x1: P1, obj: T): R; + invoker(len: number /* = 1 */, name: Prop): CurriedFunction2; + + invoker(len: number /* = 2 */, name: Prop, x1: P1, x2: P2, obj: T): R; + invoker(len: number /* = 2 */, name: Prop): CurriedFunction3; + + invoker(len: number /* = 3 */, name: Prop, x1: P1, x2: P2, x3: P3, obj: T): R; + invoker(len: number /* = 3 */, name: Prop): CurriedFunction4; + + invoker(len: number /* = 4 */, name: Prop, x1: P1, x2: P2, x3: P3, x4: P4, obj: T): R; + invoker(len: number /* = 4 */, name: Prop): CurriedFunction5; + + invoker(len: number /* = 5 */, name: Prop, x1: P1, x2: P2, x3: P3, x4: P4, x5: P5, obj: T): R; + invoker(len: number /* = 5 */, name: Prop): CurriedFunction6; + + /** + * See if an object (`val`) is an instance of the supplied constructor. + * This function will check up the inheritance chain, if any. + */ + is(ctor: Type, val: any): val is T; + is(ctor: Type): (val: any) => val is T; + // is: CurriedFunction2; // um, val undefined + + /** + * Tests whether or not an object is similar to an array. + * @deprecated: 0.23.0 + */ + isArrayLike(val: any): val is List; + // isArrayLike(val: any): boolean; + + /** + * Reports whether the list has zero elements. + */ + isEmpty(value: any): boolean; + + + /** + * Returns true if the input value is NaN. + */ + isNaN(x: any): boolean; + + /** + * Checks if the input value is null or undefined. + */ + isNil(value: any): boolean; + + /** + * Returns a string made by inserting the `separator` between each + * element and concatenating all the elements into a single string. + */ + join(x: Prop, xs: Array): string; + join(x: Prop): (xs: Array) => string; + // join: CurriedFunction2, string>; + + /** + * Applies a list of functions to a list of values. + */ + juxt(fns: { (...args: T[]): U }[]): (...args: T[]) => U[]; + + + /** + * Returns a list containing the names of all the enumerable own + * properties of the supplied object. + */ + keys(x: Struct): string[]; + + /** + * Returns a list containing the names of all the + * properties of the supplied object, including prototype properties. + */ + keysIn(obj: Struct): string[]; + + /** + * Returns the last element from a list. + */ + last>(list: R): T; + + /** + * Returns the position of the last occurrence of an item (by strict equality) in + * an array, or -1 if the item is not included in the array. + */ + // = indexOf + lastIndexOf(target: T, list: List): number; + lastIndexOf(target: T): (list: List) => number; + // lastIndexOf: CurriedFunction2, number>; + + /** + * Returns the number of elements in the array by returning list.length. + */ + length(list: List): number; + + /** + * Returns a lens for the given getter and setter functions. The getter + * "gets" the value of the focus; the setter "sets" the value of the focus. + * The setter should not mutate the data structure. + */ + // hard to mix cuz different generics + + // assume setter doesn't change the type + lens>(getter: (s: U) => V, setter: (a: V, s: U) => U): ManualLens; + lens>(getter: (s: U) => V): (setter: (a: V, s: U) => U) => ManualLens; + lens(getter: (s: Struct) => V): >(setter: (a: V, s: U) => U) => ManualLens; + // ^ ignore getter param being `U` so I can get away with 1 manual generic rather than having to add the inferred `U`. Useful if the getter doesn't have an explicit return type. + // lens>: CurriedFunction2<(s: U) => V, (a: V, s: U) => U, ManualLens>; + + // allows setter to change value type + lens(getter: (s: T) => U, setter: (a: U, s: T) => V): Lens; + lens(getter: (s: T) => U): (setter: (a: U, s: T) => V) => Lens; + // lens: CurriedFunction2<(s: T) => U, (a: U, s: T) => V, Lens>; + + /** + * Creates a lens that will focus on index n of the source array. + */ + // lensIndex(n: K): KeyLens; + lensIndex(n: number): ManualLens; + lensIndex(n: number): UnknownLens; + + /** + * Returns a lens whose focus is the specified path. + * See also view, set, over. + */ + lensPath(path: Path): ManualLens; + lensPath(path: Path): UnknownLens; + + /** + * lensProp creates a lens that will focus on property k of the source object. + */ + // lensProp(n: K): KeyLens; + lensProp(prop: Prop): ManualLens; + lensProp(prop: Prop): UnknownLens; + + /** + * "lifts" a function of arity > 1 so that it may "map over" a list, Function or other object that satisfies + * the FantasyLand Apply spec. + */ + lift(fn: () => TResult): () => TResult[]; + lift(fn: (v1: T1) => TResult): (v1: List) => TResult[]; + lift(fn: (v1: T1, v2: T2) => TResult): (v1: List, v2: List) => TResult[]; + lift(fn: (v1: T1, v2: T2, v3: T3) => TResult): (v1: List, v2: List, v3: List) => TResult[]; + lift(fn: (v1: T1, v2: T2, v3: T3, v4: T4) => TResult): (v1: List, v2: List, v3: List, v4: List) => TResult[]; + lift(fn: (v1: T1, v2: T2, v3: T3, v4: T4, v5: T5) => TResult): (v1: List, v2: List, v3: List, v4: List, v5: List) => TResult[]; + lift(fn: (v1: T1, v2: T2, v3: T3, v4: T4, v5: T5, v6: T6) => TResult): (v1: List, v2: List, v3: List, v4: List, v5: List, v6: List) => TResult[]; + lift(fn: (v1: T1, v2: T2, v3: T3, v4: T4, v5: T5, v6: T6, v7: T7) => TResult): (v1: List, v2: List, v3: List, v4: List, v5: List, v6: List, v7: List) => TResult[]; + lift(fn: (v1: T1, v2: T2, v3: T3, v4: T4, v5: T5, v6: T6, v7: T7, v8: T8) => TResult): (v1: List, v2: List, v3: List, v4: List, v5: List, v6: List, v7: List, v8: List) => TResult[]; + lift(fn: Variadic): (...argLists: any[][]) => T[]; + + /** + * "lifts" a function to be the specified arity, so that it may "map over" that many lists, Functions or other + * objects that satisfy the FantasyLand Apply spec. + */ + liftN(n: number, fn: () => TResult): () => TResult[]; + liftN(n: number, fn: (v1: T1) => TResult): (v1: List) => TResult[]; + liftN(n: number, fn: (v1: T1, v2: T2) => TResult): (v1: List, v2: List) => TResult[]; + liftN(n: number, fn: (v1: T1, v2: T2, v3: T3) => TResult): (v1: List, v2: List, v3: List) => TResult[]; + liftN(n: number, fn: (v1: T1, v2: T2, v3: T3, v4: T4) => TResult): (v1: List, v2: List, v3: List, v4: List) => TResult[]; + liftN(n: number, fn: (v1: T1, v2: T2, v3: T3, v4: T4, v5: T5) => TResult): (v1: List, v2: List, v3: List, v4: List, v5: List) => TResult[]; + liftN(n: number, fn: (v1: T1, v2: T2, v3: T3, v4: T4, v5: T5, v6: T6) => TResult): (v1: List, v2: List, v3: List, v4: List, v5: List, v6: List) => TResult[]; + liftN(n: number, fn: (v1: T1, v2: T2, v3: T3, v4: T4, v5: T5, v6: T6, v7: T7) => TResult): (v1: List, v2: List, v3: List, v4: List, v5: List, v6: List, v7: List) => TResult[]; + liftN(n: number, fn: (v1: T1, v2: T2, v3: T3, v4: T4, v5: T5, v6: T6, v7: T7, v8: T8) => TResult): (v1: List, v2: List, v3: List, v4: List, v5: List, v6: List, v7: List, v8: List) => TResult[]; + + liftN(n: number): { + (fn: () => TResult): () => TResult[]; + (fn: (v1: T1) => TResult): (v1: List) => TResult[]; + (fn: (v1: T1, v2: T2) => TResult): (v1: List, v2: List) => TResult[]; + (fn: (v1: T1, v2: T2, v3: T3) => TResult): (v1: List, v2: List, v3: List) => TResult[]; + (fn: (v1: T1, v2: T2, v3: T3, v4: T4) => TResult): (v1: List, v2: List, v3: List, v4: List) => TResult[]; + (fn: (v1: T1, v2: T2, v3: T3, v4: T4, v5: T5) => TResult): (v1: List, v2: List, v3: List, v4: List, v5: List) => TResult[]; + (fn: (v1: T1, v2: T2, v3: T3, v4: T4, v5: T5, v6: T6) => TResult): (v1: List, v2: List, v3: List, v4: List, v5: List, v6: List) => TResult[]; + (fn: (v1: T1, v2: T2, v3: T3, v4: T4, v5: T5, v6: T6, v7: T7) => TResult): (v1: List, v2: List, v3: List, v4: List, v5: List, v6: List, v7: List) => TResult[]; + (fn: (v1: T1, v2: T2, v3: T3, v4: T4, v5: T5, v6: T6, v7: T7, v8: T8) => TResult): (v1: List, v2: List, v3: List, v4: List, v5: List, v6: List, v7: List, v8: List) => TResult[]; + + (fn: Variadic): (...argLists: any[][]) => T[]; + }; + + liftN(n: number, fn: Variadic): (...argLists: any[][]) => T[]; + // liftN: CurriedFunction2, (...argLists: any[][]) => T[]>; + + /** + * Returns true if the first parameter is less than the second. + */ + lt(a: number, b: number): boolean; + lt(a: number): (b: number) => boolean; + // lt: CurriedFunction2; + + /** + * Returns true if the first parameter is less than or equal to the second. + */ + lte(a: number, b: number): boolean; + lte(a: number): (b: number) => boolean; + // lte: CurriedFunction2; + + /** + * Returns a new list, constructed by applying the supplied function to every element of the supplied list. + */ + + // homogeneous: + + // array-like + map(fn: (x: T) => U, list: List): U[]; + // map(fn: (x: T) => U): (list: List) => U[]; // disabling for mix breaks a few tests? + // map: CurriedFunction2<(x: T) => U, List, U[]>; + + // object: keyof version + map>(fn: (value: T) => U, obj: M): Obj; + map>(fn: (value: T) => U, obj: M): Obj; + // map(fn: (value: T) => U): >(obj: M) => {[K in keyof M]: U}; // mix + // map>: CurriedFunction2<(value: T) => U, M, {[K in keyof M]: U}>; + + // object: Record version + map(f: (x: T) => U, obj: Obj): Obj; + // map(f: (x: T) => U): (obj: Record) => Record; // mix + // map: CurriedFunction2<(x: T) => U, Record), Record>; + + // functor + map(fn: (x: T) => U, obj: Functor): Functor; + // map(fn: (x: T) => U): (obj: Functor) => Functor; // mix + // map: CurriedFunction2<(x: T) => U, Functor, Functor>; + + // separating values: https://github.com/Microsoft/TypeScript/issues/12342 + // map(fn: (a: A) => B, tpl: [T,U]): [ typeof fn(T), typeof fn(U) ]; + // obj. version? + + // TODO: heterogeneous versions + + // array-like + // map(fn: (x: T) => U, list: [T1, T2]): [fn(T1), fn(T1)]; + // map(fn: F, list: [T1, T2]): [F(T1), F(T1)]; + // map(fn: (x: T) => U, list: [T1, T2]): [typeof fn(T1), typeof fn(T1)]; + // map(fn: F, list: [T1, T2]): [typeof F(T1), typeof F(T1)]; + // (list: [T1, T2]): [fn(T1), fn(T1)]; + + // object + + // mixed: + map(fn: (x: T) => U): { + >(obj: M): Obj; + (obj: Obj): Obj; + (obj: Functor): Functor; + (list: List): U[]; + }; + + /** + * The mapAccum function behaves like a combination of map and reduce. + */ + // mapAccum(fn: (acc: U, value: T) => [U, TResult], acc: U, list: List): [U, TResult[]]; + // mapAccum(fn: (acc: U, value: T) => [U, TResult], acc: U): (list: List) => [U, TResult[]]; + // mapAccum(fn: (acc: U, value: T) => [U, TResult]): CurriedFunction2,[U, TResult[]]>; + // mapAccum: CurriedFunction3<(acc: U, value: T) => [U, TResult], U, List, [U, TResult[]]>; + + // base + mapAccum(fn: (acc: U, value: T) => [U, TResult], acc: U, list: List): [U, TResult[]]; + mapAccum(fn: (acc: U, value: T) => [U, TResult], acc: U): { + (list: List): [U, TResult[]]; + }; + mapAccum(fn: (acc: U, value: T) => [U, TResult]): { + (acc: U, list: List): [U, TResult[]]; + (acc: U): { + (list: List): [U, TResult[]]; + }; + }; + + + /** + * The mapAccumRight function behaves like a combination of map and reduce. + */ + // mapAccumRight(fn: (value: T, acc: U) => [TResult, U], acc: U, list: List): [TResult[], U]; + // mapAccumRight(fn: (value: T, acc: U) => [TResult, U], acc: U): (list: List) => [TResult[], U]; + // mapAccumRight(fn: (value: T, acc: U) => [TResult, U]): CurriedFunction2, [TResult[], U]>; + // mapAccumRight: CurriedFunction3<(value: T, acc: U) => [TResult, U], U, List, [TResult[], U]>; + + // base + mapAccumRight(fn: (value: T, acc: U) => [TResult, U], acc: U, list: List): [TResult[], U]; + mapAccumRight(fn: (value: T, acc: U) => [TResult, U], acc: U): { + (list: List): [TResult[], U]; + }; + mapAccumRight(fn: (value: T, acc: U) => [TResult, U]): { + (acc: U, list: List): [TResult[], U]; + (acc: U): { + (list: List): [TResult[], U]; + }; + }; + + + /** + * Like map, but but passes additional parameters to the mapping function. + */ + mapIndexed>(fn: (val: T, key: number, list: V) => U, list: V): U[]; + mapIndexed>(fn: (val: T, key: number, list: V) => U): (list: V) => U[]; + // mapIndexed>: CurriedFunction2<(val: T, key: number, list: V) => U, V, U[]>; + + + /** + * Like mapObj, but but passes additional arguments to the predicate function. + */ + // hard to mix cuz different generics + + // keyof + mapObjIndexed>(fn: (value: T, key: string, obj?: M) => V, obj: M): Obj; + mapObjIndexed>(fn: (value: T, key: string, obj?: M) => V): (obj: M) => Obj; + // mapObjIndexed>: CurriedFunction2<(value: T, key: string, obj?: M) => V, M, {[K in keyof M]: V}>; + + // Record + mapObjIndexed(f: (value: T, key: string, obj?: Record) => U, obj: Obj): Obj; + mapObjIndexed(f: (value: T, key: string, obj?: Record) => U): (obj: Obj) => Obj; // potentially overwriting K but whatever + // mapObjIndexed: CurriedFunction2<(value: T, key: string, obj?: Record) => U, Record), Record>; + + /** + * Tests a regular expression agains a String + */ + match(regexp: RegExp, str: string): string[]; + match(regexp: RegExp): (str: string) => string[]; + // match: CurriedFunction2; + + + /** + * mathMod behaves like the modulo operator should mathematically, unlike the `%` + * operator (and by extension, R.modulo). So while "-17 % 5" is -2, + * mathMod(-17, 5) is 3. mathMod requires Integer arguments, and returns NaN + * when the modulus is zero or negative. + */ + // |NaN? what's its type? + mathMod(a: number, b: number): number; + mathMod(a: number): (b: number) => number; + // mathMod: CurriedFunction2; + + + /** + * Returns the larger of its two arguments. + */ + max(a: T, b: T): T; + max(a: T): (b: T) => T; + // max: CurriedFunction2; + + /** + * Takes a function and two values, and returns whichever value produces + * the larger result when passed to the provided function. + */ + // maxBy(keyFn: (a: T) => Ord, a: T, b: T): T; + // maxBy(keyFn: (a: T) => Ord): CurriedFunction2; + // maxBy: CurriedFunction3<(a: T) => Ord, T, T, T>; + + // base + maxBy(keyFn: (a: T) => Ord, a: T, b: T): T; + maxBy(keyFn: (a: T) => Ord, a: T): { + (b: T): T; + }; + maxBy(keyFn: (a: T) => Ord): { + (a: T, b: T): T; + (a: T): { + (b: T): T; + }; + }; + + + /** + * Returns the mean of the given list of numbers. + */ + mean(list: List): number; + + /** + * Returns the median of the given list of numbers. + */ + median(list: List): number; + + /** + * Creates a new function that, when invoked, caches the result of calling fn for a given argument set and + * returns the result. Subsequent calls to the memoized fn with the same argument set will not result in an + * additional call to fn; instead, the cached result for that set of arguments will be returned. + */ + memoize(fn: Variadic): Variadic; + + merge: typeof merge + + + /** + * Merges a list of objects together into one object. + */ + mergeAll(list: List): T; + + /** + * Creates a new object with the own properties of the two provided objects. If a key exists in both objects, + * the provided function is applied to the values associated with the key in each object, with the result being used as + * the value associated with the key in the returned object. The key will be excluded from the returned object if the + * resulting value is undefined. + */ + // mergeWith(fn: (x: any, z: any) => any, a: U, b: V): U & V; + // mergeWith(fn: (x: any, z: any) => any, a: U): (b: V) => U & V; + // // mergeWith(fn: (x: any, z: any) => any): (a: U, b: V) => U & V; + // mergeWith(fn: (x: any, z: any) => any): CurriedFunction2; + // // mergeWith: CurriedFunction3<(x: any, z: any) => any, U, V, U & V>; + + // base + mergeWith(fn: (x: any, z: any) => any, a: U, b: V): U & V; + mergeWith(fn: (x: any, z: any) => any, a: U): { + (b: V): U & V; + }; + mergeWith(fn: (x: any, z: any) => any): { + (a: U, b: V): U & V; + (a: U): { + (b: V): U & V; + }; + }; + + + /** + * Creates a new object with the own properties of the two provided objects. If a key exists in both objects, + * the provided function is applied to the key and the values associated with the key in each object, with the + * result being used as the value associated with the key in the returned object. The key will be excluded from + * the returned object if the resulting value is undefined. + */ + // mergeWithKey(fn: (str: string, x: any, z: any) => any, a: U, b: V): U & V; + // mergeWithKey(fn: (str: string, x: any, z: any) => any, a: U): (b: V) => U & V; + // // mergeWithKey(fn: (str: string, x: any, z: any) => any): (a: U, b: V) => U & V; + // mergeWithKey(fn: (str: string, x: any, z: any) => any): CurriedFunction2; + // // mergeWithKey: CurriedFunction3<(str: string, x: any, z: any) => any, U, V, U & V>; + + // mergeWithKey + mergeWithKey(fn: (str: string, x: any, z: any) => any, a: U, b: V): U & V; + mergeWithKey(fn: (str: string, x: any, z: any) => any, a: U): { + (b: V): U & V; + }; + mergeWithKey(fn: (str: string, x: any, z: any) => any): { + (a: U, b: V): U & V; + (a: U): { + (b: V): U & V; + }; + }; + + + /** + * Returns the smaller of its two arguments. + */ + min(a: T, b: T): T; + min(a: T): (b: T) => T; + // min: CurriedFunction2; + + /** + * Takes a function and two values, and returns whichever value produces + * the smaller result when passed to the provided function. + */ + // minBy(keyFn: (a: T) => Ord, a: T, b: T): T; + // minBy(keyFn: (a: T) => Ord): CurriedFunction2; + // // minBy: CurriedFunction3<(a: T) => Ord, T, T, T>; + + // base + minBy(keyFn: (a: T) => Ord, a: T, b: T): T; + minBy(keyFn: (a: T) => Ord, a: T): { + (b: T): T; + }; + minBy(keyFn: (a: T) => Ord): { + (a: T, b: T): T; + (a: T): { + (b: T): T; + }; + }; + + + /** + * Divides the second parameter by the first and returns the remainder. + * The flipped version (`moduloBy`) may be more useful curried. + * Note that this functions preserves the JavaScript-style behavior for + * modulo. For mathematical modulo see `mathMod` + */ + modulo(a: number, b: number): number; + modulo(a: number): (b: number) => number; + // modulo: CurriedFunction2; + + /** + * Multiplies two numbers. Equivalent to a * b but curried. + */ + multiply(a: number, b: number): number; + multiply(a: number): (b: number) => number; + // multiply: CurriedFunction2; + + + /** + * Wraps a function of any arity (including nullary) in a function that accepts exactly n parameters. + * Any extraneous parameters will not be passed to the supplied function. + */ + nAry(n: number, fn: Variadic): Variadic; + nAry(n: number): (fn: Variadic) => Variadic; + // nAry: CurriedFunction2, Variadic>; + + /** + * Negates its argument. + */ + negate(n: number): number; + + + /** + * Returns true if no elements of the list match the predicate, false otherwise. + */ + none(fn: (a: T) => boolean, list: List): boolean; + none(fn: (a: T) => boolean): (list: List) => boolean; + // none: CurriedFunction2<(a: T) => boolean, List, boolean>; + + + /** + * A function wrapping a call to the given function in a `!` operation. It will return `true` when the + * underlying function would return a false-y value, and `false` when it would return a truth-y one. + */ + not(value: any): boolean; + + /** + * Returns the nth element in a list. + */ + nth(n: number, list: List): T; + nth(n: number): (list: List) => T; + // nth: CurriedFunction2, T>; + + /** + * Returns a function which returns its nth argument. + */ + nthArg(n: number): (...a: T[]) => T; + + /** + * Creates an object containing a single key:value pair. + */ + + // Record-based, key intact + objOf>(key: K, value: V): T; + objOf(key: K): >(value: V) => T; + // objOf>: CurriedFunction2; + + // // Obj-based, loses key + // objOf(key: Prop, value: T): Obj; + // objOf(key: Prop): (value: T) => Obj; + // // objOf: CurriedFunction2>; + + /** + * Returns a singleton array containing the value provided. + */ + of(x: T): T[]; + + /** + * Returns a partial copy of an object omitting the keys specified. + */ + omit(names: List, obj: T): T; + omit(names: List): (obj: T) => T; + // omit: CurriedFunction2, T, T>; + + /** + * Accepts a function fn and returns a function that guards invocation of fn such that fn can only ever be + * called once, no matter how many times the returned function is invoked. The first value calculated is + * returned in subsequent invocations. + */ + once(fn: Variadic): Variadic; + + /** + * A function that returns the first truthy of two arguments otherwise the last argument. Note that this is + * NOT short-circuited, meaning that if expressions are passed they are both evaluated. + * Dispatches to the or method of the first argument if applicable. + */ + // hard to mix cuz different generics + + // values + or(a: T, b: U): T | U; + or(a: T): (b: U) => T | U; + // or: CurriedFunction2; + + // dispatch to some `or` method: + or T | U; }, U>(fn1: T, val2: U): T | U; + or T | U; }, U>(fn1: T): (val2: U) => T | U; + // or T|U;}, U>: CurriedFunction2; + + /** + * Returns the result of "setting" the portion of the given data structure + * focused by the given lens to the given value. + */ + // hard to mix cuz different generics + + // key lens: + over(lens: UnknownLens, fn: (v: any) => any, value: T): T; + over(lens: UnknownLens, fn: (v: any) => any): (value: T) => T; + // over(lens: KeyLens): (fn: (v: T[K]) => T[K], value: T) => T; + over(lens: UnknownLens): CurriedFunction2<(v: any) => any, T, T>; + // over: CurriedFunction3, (v: T[K]) => T[K], T, T>; + + // regular lenses: + + // // Functor version: + // over>(lens: Lens|ManualLens|UnknownLens, fn: (v: V) => V, value: T): T; + // over(lens: ManualLens|UnknownLens, fn: (v: V) => V): >(value: T) => T; + // over>(lens: Lens|ManualLens|UnknownLens): CurriedFunction2<(v: V) => V, T, T>; + // // over>(lens: Lens|ManualLens|UnknownLens): (fn: (v: V) => V, value: T) => T; + // // over>: CurriedFunction3, (v: V) => V, T, T>; + + // // Functor version applied to array: + // over>(lens: Lens|ManualLens|UnknownLens, fn: (v: V) => V, value: T): V[]; + // over>(lens: Lens|ManualLens|UnknownLens, fn: (v: V) => V): (value: T) => V[]; + // over>(lens: Lens|ManualLens|UnknownLens): CurriedFunction2<(v: V) => V, T, V[]>; + // // over>(lens: Lens|ManualLens|UnknownLens): (fn: (v: V) => V, value: T) => V[]; + // // over>: CurriedFunction3|ManualLens|UnknownLens, (v: V) => V, T, V[]>; + + // // unbound value: + // over(lens: Lens|ManualLens|UnknownLens, fn: (v: V) => V, value: T): T; + // over(lens: ManualLens|UnknownLens, fn: (v: V) => V): (value: T) => T; + // // over(lens: UnknownLens): (fn: (v: V) => V, value: T) => T; + // over(lens: UnknownLens): CurriedFunction2<(v: V) => V, T, T>; + // // over: CurriedFunction3, (v: V) => V, T, T>; + + // Functor version + over>(lens: Lens | ManualLens | UnknownLens, fn: (v: V) => V, value: T): T; + over>(lens: Lens | ManualLens | UnknownLens, fn: (v: V) => V): { + (value: T): T; + }; + over>(lens: Lens | ManualLens | UnknownLens): { + (fn: (v: V) => V, value: T): T; + (fn: (v: V) => V): { + (value: T): T; + }; + }; + + // Functor version applied to array + over>(lens: Lens | ManualLens | UnknownLens, fn: (v: V) => V, value: T): V[]; + over>(lens: Lens | ManualLens | UnknownLens, fn: (v: V) => V): { + (value: T): V[]; + }; + over>(lens: Lens | ManualLens | UnknownLens): { + (fn: (v: V) => V, value: T): V[]; + (fn: (v: V) => V): { + (value: T): V[]; + }; + }; + + // unbound value + over(lens: Lens | ManualLens | UnknownLens, fn: (v: V) => V, value: T): T; + over(lens: Lens | ManualLens | UnknownLens, fn: (v: V) => V): { + (value: T): T; + }; + over(lens: Lens | ManualLens | UnknownLens): { + (fn: (v: V) => V, value: T): T; + (fn: (v: V) => V): { + (value: T): T; + }; + }; + + + /** + * Takes two arguments, fst and snd, and returns [fst, snd]. + */ + pair(fst: F, snd: S): [F, S]; + pair(fst: F): (snd: S) => [F, S]; + // pair: CurriedFunction2; + + /** + * Accepts as its arguments a function and any number of values and returns a function that, + * when invoked, calls the original function with all of the values prepended to the + * original function's arguments list. In some libraries this function is named `applyLeft`. + */ + partial(fn: Variadic, args: any[]): Variadic; + partial(fn: Variadic): (args: any[]) => Variadic; + // partial: CurriedFunction2, args: any[], Variadic>; + // TODO: fixed-arity versions + + /** + * Accepts as its arguments a function and any number of values and returns a function that, + * when invoked, calls the original function with all of the values appended to the original + * function's arguments list. + */ + partialRight(fn: Variadic, args: any[]): Variadic; + partialRight(fn: Variadic): (args: any[]) => Variadic; + // partialRight: CurriedFunction2, args: any[], Variadic>; + // TODO: fixed-arity versions + + /** + * Takes a predicate and a list and returns the pair of lists of elements + * which do and do not satisfy the predicate, respectively. + */ + // arrays + partition(fn: (a: T) => boolean, list: List): [T[], T[]]; + partition(fn: (a: T) => boolean): (list: List) => [T[], T[]]; + // partition: CurriedFunction2<(a: T) => boolean, List, [T[], T[]]>; + // objects + partition, U extends Obj, V>(fn: (a: V) => boolean, obj: T & U): [T, U]; + // partition,U extends Obj,V>: CurriedFunction2<(a: T) => boolean, obj: T & U, [T,U]>; + // objects, alternative notation + partition>(fn: (a: T) => boolean, obj: U): [Obj, Obj]; + // partition>: CurriedFunction2<(a: T) => boolean, U, [Partial,Partial]>; + + /** + * Retrieve the value at a given path. + */ + + // fixed-length versions + + // simpler versions, able to deal only with objects, not arrays: + + // // in-based + // path(path: [T1, T2], obj: {[K1 in T1]: {[K2 in T2]: TResult}}): TResult; + // path(path: [T1, T2, T3], obj: {[K1 in T1]: {[K2 in T2]: {[K3 in T3]: TResult}}}): TResult; + // path(path: [T1, T2, T3, T4], obj: {[K1 in T1]: {[K2 in T2]: {[K3 in T3]: {[K4 in T4]: TResult}}}}): TResult; + // path(path: [T1, T2, T3, T4, T5], obj: {[K1 in T1]: {[K2 in T2]: {[K3 in T3]: {[K4 in T4]: {[K5 in T5]: TResult}}}}}): TResult; + // path(path: [T1, T2, T3, T4, T5, T6], obj: {[K1 in T1]: {[K2 in T2]: {[K3 in T3]: {[K4 in T4]: {[K5 in T5]: {[K6 in T6]: TResult}}}}}}): TResult; + // path(path: [T1, T2, T3, T4, T5, T6, T7], obj: {[K1 in T1]: {[K2 in T2]: {[K3 in T3]: {[K4 in T4]: {[K5 in T5]: {[K6 in T6]: {[K7 in T7]: TResult}}}}}}}): TResult; + // path(path: [T1, T2, T3, T4, T5, T6, T7, T8], obj: {[K1 in T1]: {[K2 in T2]: {[K3 in T3]: {[K4 in T4]: {[K5 in T5]: {[K6 in T6]: {[K7 in T7]: {[K8 in T8]: TResult}}}}}}}}): TResult; + // path(path: [T1, T2, T3, T4, T5, T6, T7, T8, T9], obj: {[K1 in T1]: {[K2 in T2]: {[K3 in T3]: {[K4 in T4]: {[K5 in T5]: {[K6 in T6]: {[K7 in T7]: {[K8 in T8]: {[K9 in T9]: TResult}}}}}}}}}): TResult; + + // // Record-based + // path(path: [K1, K2], obj: Record>): TResult; + // path(path: [K1, K2, K3], obj: Record>>): TResult; + // path(path: [K1, K2, K3, K4], obj: Record>>>): TResult; + // path(path: [K1, K2, K3, K4, K5], obj: Record>>>>): TResult; + // path(path: [K1, K2, K3, K4, K5, K6], obj: Record>>>>>): TResult; + // path(path: [K1, K2, K3, K4, K5, K6, K7], obj: Record>>>>>>): TResult; + // path(path: [K1, K2, K3, K4, K5, K6, K7, K8], obj: Record>>>>>>>): TResult; + // path(path: [K1, K2, K3, K4, K5, K6, K7, K8, K9], obj: Record>>>>>>>>): TResult; + + // // for each path length list all combinations of objects and homogeneous arrays... tuples not supported yet. + + // path(path: [T1], obj: {[K1 in T1]: TResult}): TResult; + // path(path: [T1], obj: TResult[]): TResult; + // path(path: [T1, T2], obj: {[K1 in T1]: {[K2 in T2]: TResult}}): TResult; + // path(path: [T1, T2], obj: {[K1 in T1]: TResult[]}): TResult; + // path(path: [T1, T2], obj: {[K2 in T2]: TResult}[]): TResult; + // path(path: [T1, T2], obj: TResult[][]): TResult; + // path(path: [T1, T2, T3], obj: {[K1 in T1]: {[K2 in T2]: {[K3 in T3]: TResult}}}): TResult; + // path(path: [T1, T2, T3], obj: {[K1 in T1]: {[K2 in T2]: TResult[]}}): TResult; + // path(path: [T1, T2, T3], obj: {[K1 in T1]: {[K3 in T3]: TResult}[]}): TResult; + // path(path: [T1, T2, T3], obj: {[K1 in T1]: TResult[][]}): TResult; + // path(path: [T1, T2, T3], obj: {[K2 in T2]: {[K3 in T3]: TResult}}[]): TResult; + // path(path: [T1, T2, T3], obj: {[K2 in T2]: TResult[]}[]): TResult; + // path(path: [T1, T2, T3], obj: {[K3 in T3]: TResult}[][]): TResult; + // path(path: [T1, T2, T3], obj: TResult[][][]): TResult; + // path(path: [T1, T2, T3, T4], obj: {[K1 in T1]: {[K2 in T2]: {[K3 in T3]: {[K4 in T4]: TResult}}}}): TResult; + // path(path: [T1, T2, T3, T4], obj: {[K1 in T1]: {[K2 in T2]: {[K3 in T3]: TResult[]}}}): TResult; + // path(path: [T1, T2, T3, T4], obj: {[K1 in T1]: {[K2 in T2]: {[K4 in T4]: TResult}[]}}): TResult; + // path(path: [T1, T2, T3, T4], obj: {[K1 in T1]: {[K2 in T2]: TResult[][]}}): TResult; + // path(path: [T1, T2, T3, T4], obj: {[K1 in T1]: {[K3 in T3]: {[K4 in T4]: TResult}}[]}): TResult; + // path(path: [T1, T2, T3, T4], obj: {[K1 in T1]: {[K3 in T3]: TResult[]}[]}): TResult; + // path(path: [T1, T2, T3, T4], obj: {[K1 in T1]: {[K4 in T4]: TResult}[][]}): TResult; + // path(path: [T1, T2, T3, T4], obj: {[K1 in T1]: TResult[][][]}): TResult; + // path(path: [T1, T2, T3, T4], obj: {[K2 in T2]: {[K3 in T3]: {[K4 in T4]: TResult}}}[]): TResult; + // path(path: [T1, T2, T3, T4], obj: {[K2 in T2]: {[K3 in T3]: TResult[]}}[]): TResult; + // path(path: [T1, T2, T3, T4], obj: {[K2 in T2]: {[K4 in T4]: TResult}[]}[]): TResult; + // path(path: [T1, T2, T3, T4], obj: {[K2 in T2]: TResult[][]}[]): TResult; + // path(path: [T1, T2, T3, T4], obj: {[K3 in T3]: {[K4 in T4]: TResult}}[][]): TResult; + // path(path: [T1, T2, T3, T4], obj: {[K3 in T3]: TResult[]}[][]): TResult; + // path(path: [T1, T2, T3, T4], obj: {[K4 in T4]: TResult}[][][]): TResult; + // path(path: [T1, T2, T3, T4], obj: TResult[][][][]): TResult; + // path(path: [T1, T2, T3, T4, T5], obj: {[K1 in T1]: {[K2 in T2]: {[K3 in T3]: {[K4 in T4]: {[K5 in T5]: TResult}}}}}): TResult; + // path(path: [T1, T2, T3, T4, T5], obj: {[K1 in T1]: {[K2 in T2]: {[K3 in T3]: {[K4 in T4]: TResult[]}}}}): TResult; + // path(path: [T1, T2, T3, T4, T5], obj: {[K1 in T1]: {[K2 in T2]: {[K3 in T3]: {[K5 in T5]: TResult}[]}}}): TResult; + // path(path: [T1, T2, T3, T4, T5], obj: {[K1 in T1]: {[K2 in T2]: {[K3 in T3]: TResult[][]}}}): TResult; + // path(path: [T1, T2, T3, T4, T5], obj: {[K1 in T1]: {[K2 in T2]: {[K4 in T4]: {[K5 in T5]: TResult}}[]}}): TResult; + // path(path: [T1, T2, T3, T4, T5], obj: {[K1 in T1]: {[K2 in T2]: {[K4 in T4]: TResult[]}[]}}): TResult; + // path(path: [T1, T2, T3, T4, T5], obj: {[K1 in T1]: {[K2 in T2]: {[K5 in T5]: TResult}[][]}}): TResult; + // path(path: [T1, T2, T3, T4, T5], obj: {[K1 in T1]: {[K2 in T2]: TResult[][][]}}): TResult; + // path(path: [T1, T2, T3, T4, T5], obj: {[K1 in T1]: {[K3 in T3]: {[K4 in T4]: {[K5 in T5]: TResult}}}[]}): TResult; + // path(path: [T1, T2, T3, T4, T5], obj: {[K1 in T1]: {[K3 in T3]: {[K4 in T4]: TResult[]}}[]}): TResult; + // path(path: [T1, T2, T3, T4, T5], obj: {[K1 in T1]: {[K3 in T3]: {[K5 in T5]: TResult}[]}[]}): TResult; + // path(path: [T1, T2, T3, T4, T5], obj: {[K1 in T1]: {[K3 in T3]: TResult[][]}[]}): TResult; + // path(path: [T1, T2, T3, T4, T5], obj: {[K1 in T1]: {[K4 in T4]: {[K5 in T5]: TResult}}[][]}): TResult; + // path(path: [T1, T2, T3, T4, T5], obj: {[K1 in T1]: {[K4 in T4]: TResult[]}[][]}): TResult; + // path(path: [T1, T2, T3, T4, T5], obj: {[K1 in T1]: {[K5 in T5]: TResult}[][][]}): TResult; + // path(path: [T1, T2, T3, T4, T5], obj: {[K1 in T1]: TResult[][][][]}): TResult; + // path(path: [T1, T2, T3, T4, T5], obj: {[K2 in T2]: {[K3 in T3]: {[K4 in T4]: {[K5 in T5]: TResult}}}}[]): TResult; + // path(path: [T1, T2, T3, T4, T5], obj: {[K2 in T2]: {[K3 in T3]: {[K4 in T4]: TResult[]}}}[]): TResult; + // path(path: [T1, T2, T3, T4, T5], obj: {[K2 in T2]: {[K3 in T3]: {[K5 in T5]: TResult}[]}}[]): TResult; + // path(path: [T1, T2, T3, T4, T5], obj: {[K2 in T2]: {[K3 in T3]: TResult[][]}}[]): TResult; + // path(path: [T1, T2, T3, T4, T5], obj: {[K2 in T2]: {[K4 in T4]: {[K5 in T5]: TResult}}[]}[]): TResult; + // path(path: [T1, T2, T3, T4, T5], obj: {[K2 in T2]: {[K4 in T4]: TResult[]}[]}[]): TResult; + // path(path: [T1, T2, T3, T4, T5], obj: {[K2 in T2]: {[K5 in T5]: TResult}[][]}[]): TResult; + // path(path: [T1, T2, T3, T4, T5], obj: {[K2 in T2]: TResult[][][]}[]): TResult; + // path(path: [T1, T2, T3, T4, T5], obj: {[K3 in T3]: {[K4 in T4]: {[K5 in T5]: TResult}}}[][]): TResult; + // path(path: [T1, T2, T3, T4, T5], obj: {[K3 in T3]: {[K4 in T4]: TResult[]}}[][]): TResult; + // path(path: [T1, T2, T3, T4, T5], obj: {[K3 in T3]: {[K5 in T5]: TResult}[]}[][]): TResult; + // path(path: [T1, T2, T3, T4, T5], obj: {[K3 in T3]: TResult[][]}[][]): TResult; + // path(path: [T1, T2, T3, T4, T5], obj: {[K4 in T4]: {[K5 in T5]: TResult}}[][][]): TResult; + // path(path: [T1, T2, T3, T4, T5], obj: {[K4 in T4]: TResult[]}[][][]): TResult; + // path(path: [T1, T2, T3, T4, T5], obj: {[K5 in T5]: TResult}[][][][]): TResult; + // path(path: [T1, T2, T3, T4, T5], obj: TResult[][][][][]): TResult; + // path(path: [T1, T2, T3, T4, T5, T6], obj: {[K1 in T1]: {[K2 in T2]: {[K3 in T3]: {[K4 in T4]: {[K5 in T5]: {[K6 in T6]: TResult}}}}}}): TResult; + // path(path: [T1, T2, T3, T4, T5, T6], obj: {[K1 in T1]: {[K2 in T2]: {[K3 in T3]: {[K4 in T4]: {[K5 in T5]: TResult[]}}}}}): TResult; + // path(path: [T1, T2, T3, T4, T5, T6], obj: {[K1 in T1]: {[K2 in T2]: {[K3 in T3]: {[K4 in T4]: {[K6 in T6]: TResult}[]}}}}): TResult; + // path(path: [T1, T2, T3, T4, T5, T6], obj: {[K1 in T1]: {[K2 in T2]: {[K3 in T3]: {[K4 in T4]: TResult[][]}}}}): TResult; + // path(path: [T1, T2, T3, T4, T5, T6], obj: {[K1 in T1]: {[K2 in T2]: {[K3 in T3]: {[K5 in T5]: {[K6 in T6]: TResult}}[]}}}): TResult; + // path(path: [T1, T2, T3, T4, T5, T6], obj: {[K1 in T1]: {[K2 in T2]: {[K3 in T3]: {[K5 in T5]: TResult[]}[]}}}): TResult; + // path(path: [T1, T2, T3, T4, T5, T6], obj: {[K1 in T1]: {[K2 in T2]: {[K3 in T3]: {[K6 in T6]: TResult}[][]}}}): TResult; + // path(path: [T1, T2, T3, T4, T5, T6], obj: {[K1 in T1]: {[K2 in T2]: {[K3 in T3]: TResult[][][]}}}): TResult; + // path(path: [T1, T2, T3, T4, T5, T6], obj: {[K1 in T1]: {[K2 in T2]: {[K4 in T4]: {[K5 in T5]: {[K6 in T6]: TResult}}}[]}}): TResult; + // path(path: [T1, T2, T3, T4, T5, T6], obj: {[K1 in T1]: {[K2 in T2]: {[K4 in T4]: {[K5 in T5]: TResult[]}}[]}}): TResult; + // path(path: [T1, T2, T3, T4, T5, T6], obj: {[K1 in T1]: {[K2 in T2]: {[K4 in T4]: {[K6 in T6]: TResult}[]}[]}}): TResult; + // path(path: [T1, T2, T3, T4, T5, T6], obj: {[K1 in T1]: {[K2 in T2]: {[K4 in T4]: TResult[][]}[]}}): TResult; + // path(path: [T1, T2, T3, T4, T5, T6], obj: {[K1 in T1]: {[K2 in T2]: {[K5 in T5]: {[K6 in T6]: TResult}}[][]}}): TResult; + // path(path: [T1, T2, T3, T4, T5, T6], obj: {[K1 in T1]: {[K2 in T2]: {[K5 in T5]: TResult[]}[][]}}): TResult; + // path(path: [T1, T2, T3, T4, T5, T6], obj: {[K1 in T1]: {[K2 in T2]: {[K6 in T6]: TResult}[][][]}}): TResult; + // path(path: [T1, T2, T3, T4, T5, T6], obj: {[K1 in T1]: {[K2 in T2]: TResult[][][][]}}): TResult; + // path(path: [T1, T2, T3, T4, T5, T6], obj: {[K1 in T1]: {[K3 in T3]: {[K4 in T4]: {[K5 in T5]: {[K6 in T6]: TResult}}}}[]}): TResult; + // path(path: [T1, T2, T3, T4, T5, T6], obj: {[K1 in T1]: {[K3 in T3]: {[K4 in T4]: {[K5 in T5]: TResult[]}}}[]}): TResult; + // path(path: [T1, T2, T3, T4, T5, T6], obj: {[K1 in T1]: {[K3 in T3]: {[K4 in T4]: {[K6 in T6]: TResult}[]}}[]}): TResult; + // path(path: [T1, T2, T3, T4, T5, T6], obj: {[K1 in T1]: {[K3 in T3]: {[K4 in T4]: TResult[][]}}[]}): TResult; + // path(path: [T1, T2, T3, T4, T5, T6], obj: {[K1 in T1]: {[K3 in T3]: {[K5 in T5]: {[K6 in T6]: TResult}}[]}[]}): TResult; + // path(path: [T1, T2, T3, T4, T5, T6], obj: {[K1 in T1]: {[K3 in T3]: {[K5 in T5]: TResult[]}[]}[]}): TResult; + // path(path: [T1, T2, T3, T4, T5, T6], obj: {[K1 in T1]: {[K3 in T3]: {[K6 in T6]: TResult}[][]}[]}): TResult; + // path(path: [T1, T2, T3, T4, T5, T6], obj: {[K1 in T1]: {[K3 in T3]: TResult[][][]}[]}): TResult; + // path(path: [T1, T2, T3, T4, T5, T6], obj: {[K1 in T1]: {[K4 in T4]: {[K5 in T5]: {[K6 in T6]: TResult}}}[][]}): TResult; + // path(path: [T1, T2, T3, T4, T5, T6], obj: {[K1 in T1]: {[K4 in T4]: {[K5 in T5]: TResult[]}}[][]}): TResult; + // path(path: [T1, T2, T3, T4, T5, T6], obj: {[K1 in T1]: {[K4 in T4]: {[K6 in T6]: TResult}[]}[][]}): TResult; + // path(path: [T1, T2, T3, T4, T5, T6], obj: {[K1 in T1]: {[K4 in T4]: TResult[][]}[][]}): TResult; + // path(path: [T1, T2, T3, T4, T5, T6], obj: {[K1 in T1]: {[K5 in T5]: {[K6 in T6]: TResult}}[][][]}): TResult; + // path(path: [T1, T2, T3, T4, T5, T6], obj: {[K1 in T1]: {[K5 in T5]: TResult[]}[][][]}): TResult; + // path(path: [T1, T2, T3, T4, T5, T6], obj: {[K1 in T1]: {[K6 in T6]: TResult}[][][][]}): TResult; + // path(path: [T1, T2, T3, T4, T5, T6], obj: {[K1 in T1]: TResult[][][][][]}): TResult; + // path(path: [T1, T2, T3, T4, T5, T6], obj: {[K2 in T2]: {[K3 in T3]: {[K4 in T4]: {[K5 in T5]: {[K6 in T6]: TResult}}}}}[]): TResult; + // path(path: [T1, T2, T3, T4, T5, T6], obj: {[K2 in T2]: {[K3 in T3]: {[K4 in T4]: {[K5 in T5]: TResult[]}}}}[]): TResult; + // path(path: [T1, T2, T3, T4, T5, T6], obj: {[K2 in T2]: {[K3 in T3]: {[K4 in T4]: {[K6 in T6]: TResult}[]}}}[]): TResult; + // path(path: [T1, T2, T3, T4, T5, T6], obj: {[K2 in T2]: {[K3 in T3]: {[K4 in T4]: TResult[][]}}}[]): TResult; + // path(path: [T1, T2, T3, T4, T5, T6], obj: {[K2 in T2]: {[K3 in T3]: {[K5 in T5]: {[K6 in T6]: TResult}}[]}}[]): TResult; + // path(path: [T1, T2, T3, T4, T5, T6], obj: {[K2 in T2]: {[K3 in T3]: {[K5 in T5]: TResult[]}[]}}[]): TResult; + // path(path: [T1, T2, T3, T4, T5, T6], obj: {[K2 in T2]: {[K3 in T3]: {[K6 in T6]: TResult}[][]}}[]): TResult; + // path(path: [T1, T2, T3, T4, T5, T6], obj: {[K2 in T2]: {[K3 in T3]: TResult[][][]}}[]): TResult; + // path(path: [T1, T2, T3, T4, T5, T6], obj: {[K2 in T2]: {[K4 in T4]: {[K5 in T5]: {[K6 in T6]: TResult}}}[]}[]): TResult; + // path(path: [T1, T2, T3, T4, T5, T6], obj: {[K2 in T2]: {[K4 in T4]: {[K5 in T5]: TResult[]}}[]}[]): TResult; + // path(path: [T1, T2, T3, T4, T5, T6], obj: {[K2 in T2]: {[K4 in T4]: {[K6 in T6]: TResult}[]}[]}[]): TResult; + // path(path: [T1, T2, T3, T4, T5, T6], obj: {[K2 in T2]: {[K4 in T4]: TResult[][]}[]}[]): TResult; + // path(path: [T1, T2, T3, T4, T5, T6], obj: {[K2 in T2]: {[K5 in T5]: {[K6 in T6]: TResult}}[][]}[]): TResult; + // path(path: [T1, T2, T3, T4, T5, T6], obj: {[K2 in T2]: {[K5 in T5]: TResult[]}[][]}[]): TResult; + // path(path: [T1, T2, T3, T4, T5, T6], obj: {[K2 in T2]: {[K6 in T6]: TResult}[][][]}[]): TResult; + // path(path: [T1, T2, T3, T4, T5, T6], obj: {[K2 in T2]: TResult[][][][]}[]): TResult; + // path(path: [T1, T2, T3, T4, T5, T6], obj: {[K3 in T3]: {[K4 in T4]: {[K5 in T5]: {[K6 in T6]: TResult}}}}[][]): TResult; + // path(path: [T1, T2, T3, T4, T5, T6], obj: {[K3 in T3]: {[K4 in T4]: {[K5 in T5]: TResult[]}}}[][]): TResult; + // path(path: [T1, T2, T3, T4, T5, T6], obj: {[K3 in T3]: {[K4 in T4]: {[K6 in T6]: TResult}[]}}[][]): TResult; + // path(path: [T1, T2, T3, T4, T5, T6], obj: {[K3 in T3]: {[K4 in T4]: TResult[][]}}[][]): TResult; + // path(path: [T1, T2, T3, T4, T5, T6], obj: {[K3 in T3]: {[K5 in T5]: {[K6 in T6]: TResult}}[]}[][]): TResult; + // path(path: [T1, T2, T3, T4, T5, T6], obj: {[K3 in T3]: {[K5 in T5]: TResult[]}[]}[][]): TResult; + // path(path: [T1, T2, T3, T4, T5, T6], obj: {[K3 in T3]: {[K6 in T6]: TResult}[][]}[][]): TResult; + // path(path: [T1, T2, T3, T4, T5, T6], obj: {[K3 in T3]: TResult[][][]}[][]): TResult; + // path(path: [T1, T2, T3, T4, T5, T6], obj: {[K4 in T4]: {[K5 in T5]: {[K6 in T6]: TResult}}}[][][]): TResult; + // path(path: [T1, T2, T3, T4, T5, T6], obj: {[K4 in T4]: {[K5 in T5]: TResult[]}}[][][]): TResult; + // path(path: [T1, T2, T3, T4, T5, T6], obj: {[K4 in T4]: {[K6 in T6]: TResult}[]}[][][]): TResult; + // path(path: [T1, T2, T3, T4, T5, T6], obj: {[K4 in T4]: TResult[][]}[][][]): TResult; + // path(path: [T1, T2, T3, T4, T5, T6], obj: {[K5 in T5]: {[K6 in T6]: TResult}}[][][][]): TResult; + // path(path: [T1, T2, T3, T4, T5, T6], obj: {[K5 in T5]: TResult[]}[][][][]): TResult; + // path(path: [T1, T2, T3, T4, T5, T6], obj: {[K6 in T6]: TResult}[][][][][]): TResult; + // path(path: [T1, T2, T3, T4, T5, T6], obj: TResult[][][][][][]): TResult; + + // fallback, prevents errors but lacks inference; expected result must be supplied manually. + path(path: Path, obj: Struct): T; + path(path: Path): (obj: Struct) => T; + + // path: CurriedFunction2, T>; + // failed attempt at proper typing, see https://github.com/Microsoft/TypeScript/issues/12393 : + // path(keys: [K1, K2], obj: T): U; + // path(keys: [K1, K2], obj: T): T[K1][K2]; + + /** + * Determines whether a nested path on an object has a specific value, + * in `R.equals` terms. Most likely used to filter a list. + */ + // pathEq(path: Path, val: any, obj: Struct): boolean; + // pathEq(path: Path, val: any): (obj: Struct) => boolean; + // pathEq(path: Path): CurriedFunction2, boolean>; + // // pathEq: CurriedFunction3, boolean>; + + // base + pathEq(p: Path, v: any, o: any): boolean; + pathEq(p: Path, v: any): { + (o: any): boolean; + }; + pathEq(p: Path): { + (v: any, o: any): boolean; + (v: any): { + (o: any): boolean; + }; + }; + + + /** + * If the given, non-null object has a value at the given path, returns the value at that path. + * Otherwise returns the provided default value. + */ + // pathOr(d: T, p: Path, obj: Struct): T|any; + // pathOr(d: T, p: Path): (obj: Struct) => T|any; + // pathOr(d: T): CurriedFunction2, T|any>; + // // pathOr(d: T, p: Path): (obj: Struct) => T|any; + // // pathOr(d: T): (p: Path, obj: Struct) => T|any; + // // pathOr: CurriedFunction3, T|any>; + + // base + pathOr(d: T, p: Path, obj: Struct): T | any; + pathOr(d: T, p: Path): { + (obj: Struct): T | any; + }; + pathOr(d: T): { + (p: Path, obj: Struct): T | any; + (p: Path): { + (obj: Struct): T | any; + }; + }; + + + /** + * Returns `true` if the specified object property at given path satisfies the given predicate; `false` + * otherwise. + */ + // pathSatisfies(fn: Pred, p: Path, obj: any): boolean; + // pathSatisfies(fn: Pred, p: Path): (obj: any) => boolean; + // pathSatisfies(fn: Pred): CurriedFunction2; + // // pathSatisfies: CurriedFunction3, Path, any, boolean>; + + // base + pathSatisfies(fn: Pred, p: Path, obj: any): boolean; + pathSatisfies(fn: Pred, p: Path): { + (obj: any): boolean; + }; + pathSatisfies(fn: Pred): { + (p: Path, obj: any): boolean; + (p: Path): { + (obj: any): boolean; + }; + }; + + + /** + * Returns a partial copy of an object containing only the keys specified. If the key does not exist, the + * property is ignored. + */ + pick(names: List, obj: T): T; + pick(names: List): (obj: T) => T; + // pick: CurriedFunction2, T, Pick>; + + // pick(names: List, obj: T): Partial; + // pick(names: List): (obj: T) => Partial; + // // pick: CurriedFunction2, T, Partial>; + + // /** + // * Similar to `pick` except that this one includes a `key: undefined` pair for properties that don't exist. + // */ + // pickAll(names: List, obj: T): Partial; + // pickAll(names: List): (obj: T) => Partial; + // // pickAll: CurriedFunction2, T, Partial>; + + + // /** + // * Returns a partial copy of an object containing only the keys that satisfy the supplied predicate. + // */ + // pickBy(pred: ObjPred, obj: T): Partial; + // pickBy(pred: ObjPred): (obj: T) => Partial; + // // pickBy: CurriedFunction2, T, Partial>; + + + /** + * Performs left-to-right function composition. + * The leftmost function may have any arity; the remaining functions must be unary. + * In some libraries this function is named sequence. + * Note: The result of pipe is not automatically curried. + */ + pipe(fn0: (x0: V0) => T1): (x0: V0) => T1; + pipe(fn0: (x0: V0, x1: V1) => T1): (x0: V0, x1: V1) => T1; + pipe(fn0: (x0: V0, x1: V1, x2: V2) => T1): (x0: V0, x1: V1, x2: V2) => T1; + pipe(fn0: (x0: V0, x1: V1, x2: V2, x3: V3) => T1): (x0: V0, x1: V1, x2: V2, x3: V3) => T1; + pipe(fn0: (x0: V0) => T1, fn1: (x: T1) => T2): (x0: V0) => T2; + pipe(fn0: (x0: V0, x1: V1) => T1, fn1: (x: T1) => T2): (x0: V0, x1: V1) => T2; + pipe(fn0: (x0: V0, x1: V1, x2: V2) => T1, fn1: (x: T1) => T2): (x0: V0, x1: V1, x2: V2) => T2; + pipe(fn0: (x0: V0, x1: V1, x2: V2, x3: V3) => T1, fn1: (x: T1) => T2): (x0: V0, x1: V1, x2: V2, x3: V3) => T2; + pipe(fn0: (x0: V0) => T1, fn1: (x: T1) => T2, fn2: (x: T2) => T3): (x0: V0) => T3; + pipe(fn0: (x0: V0, x1: V1) => T1, fn1: (x: T1) => T2, fn2: (x: T2) => T3): (x0: V0, x1: V1) => T3; + pipe(fn0: (x0: V0, x1: V1, x2: V2) => T1, fn1: (x: T1) => T2, fn2: (x: T2) => T3): (x0: V0, x1: V1, x2: V2) => T3; + pipe(fn0: (x0: V0, x1: V1, x2: V2, x3: V3) => T1, fn1: (x: T1) => T2, fn2: (x: T2) => T3): (x0: V0, x1: V1, x2: V2, x3: V3) => T3; + pipe(fn0: (x0: V0) => T1, fn1: (x: T1) => T2, fn2: (x: T2) => T3, fn3: (x: T3) => T4): (x0: V0) => T4; + pipe(fn0: (x0: V0, x1: V1) => T1, fn1: (x: T1) => T2, fn2: (x: T2) => T3, fn3: (x: T3) => T4): (x0: V0, x1: V1) => T4; + pipe(fn0: (x0: V0, x1: V1, x2: V2) => T1, fn1: (x: T1) => T2, fn2: (x: T2) => T3, fn3: (x: T3) => T4): (x0: V0, x1: V1, x2: V2) => T4; + pipe(fn0: (x0: V0, x1: V1, x2: V2, x3: V3) => T1, fn1: (x: T1) => T2, fn2: (x: T2) => T3, fn3: (x: T3) => T4): (x0: V0, x1: V1, x2: V2, x3: V3) => T4; + pipe(fn0: (x0: V0) => T1, fn1: (x: T1) => T2, fn2: (x: T2) => T3, fn3: (x: T3) => T4, fn4: (x: T4) => T5): (x0: V0) => T5; + pipe(fn0: (x0: V0, x1: V1) => T1, fn1: (x: T1) => T2, fn2: (x: T2) => T3, fn3: (x: T3) => T4, fn4: (x: T4) => T5): (x0: V0, x1: V1) => T5; + pipe(fn0: (x0: V0, x1: V1, x2: V2) => T1, fn1: (x: T1) => T2, fn2: (x: T2) => T3, fn3: (x: T3) => T4, fn4: (x: T4) => T5): (x0: V0, x1: V1, x2: V2) => T5; + pipe(fn0: (x0: V0, x1: V1, x2: V2, x3: V3) => T1, fn1: (x: T1) => T2, fn2: (x: T2) => T3, fn3: (x: T3) => T4, fn4: (x: T4) => T5): (x0: V0, x1: V1, x2: V2, x3: V3) => T5; + pipe(fn0: (x0: V0) => T1, fn1: (x: T1) => T2, fn2: (x: T2) => T3, fn3: (x: T3) => T4, fn4: (x: T4) => T5, fn5: (x: T5) => T6): (x0: V0) => T6; + pipe(fn0: (x0: V0, x1: V1) => T1, fn1: (x: T1) => T2, fn2: (x: T2) => T3, fn3: (x: T3) => T4, fn4: (x: T4) => T5, fn5: (x: T5) => T6): (x0: V0, x1: V1) => T6; + pipe(fn0: (x0: V0, x1: V1, x2: V2) => T1, fn1: (x: T1) => T2, fn2: (x: T2) => T3, fn3: (x: T3) => T4, fn4: (x: T4) => T5, fn5: (x: T5) => T6): (x0: V0, x1: V1, x2: V2) => T6; + pipe(fn0: (x0: V0, x1: V1, x2: V2, x3: V3) => T1, fn1: (x: T1) => T2, fn2: (x: T2) => T3, fn3: (x: T3) => T4, fn4: (x: T4) => T5, fn5: (x: T5) => T6): (x0: V0, x1: V1, x2: V2, x3: V3) => T6; + pipe(fn0: (x0: V0) => T1, fn1: (x: T1) => T2, fn2: (x: T2) => T3, fn3: (x: T3) => T4, fn4: (x: T4) => T5, fn5: (x: T5) => T6, fn6: (x: T6) => T7): (x0: V0) => T7; + pipe(fn0: (x0: V0, x1: V1) => T1, fn1: (x: T1) => T2, fn2: (x: T2) => T3, fn3: (x: T3) => T4, fn4: (x: T4) => T5, fn5: (x: T5) => T6, fn6: (x: T6) => T7): (x0: V0, x1: V1) => T7; + pipe(fn0: (x0: V0, x1: V1, x2: V2) => T1, fn1: (x: T1) => T2, fn2: (x: T2) => T3, fn3: (x: T3) => T4, fn4: (x: T4) => T5, fn5: (x: T5) => T6, fn6: (x: T6) => T7): (x0: V0, x1: V1, x2: V2) => T7; + pipe(fn0: (x0: V0, x1: V1, x2: V2, x3: V3) => T1, fn1: (x: T1) => T2, fn2: (x: T2) => T3, fn3: (x: T3) => T4, fn4: (x: T4) => T5, fn5: (x: T5) => T6, fn6: (x: T6) => T7): (x0: V0, x1: V1, x2: V2, x3: V3) => T7; + pipe(fn0: (x0: V0) => T1, fn1: (x: T1) => T2, fn2: (x: T2) => T3, fn3: (x: T3) => T4, fn4: (x: T4) => T5, fn5: (x: T5) => T6, fn6: (x: T6) => T7, fn7: (x: T7) => T8): (x0: V0) => T8; + pipe(fn0: (x0: V0, x1: V1) => T1, fn1: (x: T1) => T2, fn2: (x: T2) => T3, fn3: (x: T3) => T4, fn4: (x: T4) => T5, fn5: (x: T5) => T6, fn6: (x: T6) => T7, fn7: (x: T7) => T8): (x0: V0, x1: V1) => T8; + pipe(fn0: (x0: V0, x1: V1, x2: V2) => T1, fn1: (x: T1) => T2, fn2: (x: T2) => T3, fn3: (x: T3) => T4, fn4: (x: T4) => T5, fn5: (x: T5) => T6, fn6: (x: T6) => T7, fn7: (x: T7) => T8): (x0: V0, x1: V1, x2: V2) => T8; + pipe(fn0: (x0: V0, x1: V1, x2: V2, x3: V3) => T1, fn1: (x: T1) => T2, fn2: (x: T2) => T3, fn3: (x: T3) => T4, fn4: (x: T4) => T5, fn5: (x: T5) => T6, fn6: (x: T6) => T7, fn7: (x: T7) => T8): (x0: V0, x1: V1, x2: V2, x3: V3) => T8; + pipe(fn0: (x0: V0) => T1, fn1: (x: T1) => T2, fn2: (x: T2) => T3, fn3: (x: T3) => T4, fn4: (x: T4) => T5, fn5: (x: T5) => T6, fn6: (x: T6) => T7, fn7: (x: T7) => T8, fn8: (x: T8) => T9): (x0: V0) => T9; + pipe(fn0: (x0: V0, x1: V1) => T1, fn1: (x: T1) => T2, fn2: (x: T2) => T3, fn3: (x: T3) => T4, fn4: (x: T4) => T5, fn5: (x: T5) => T6, fn6: (x: T6) => T7, fn7: (x: T7) => T8, fn8: (x: T8) => T9): (x0: V0, x1: V1) => T9; + pipe(fn0: (x0: V0, x1: V1, x2: V2) => T1, fn1: (x: T1) => T2, fn2: (x: T2) => T3, fn3: (x: T3) => T4, fn4: (x: T4) => T5, fn5: (x: T5) => T6, fn6: (x: T6) => T7, fn7: (x: T7) => T8, fn8: (x: T8) => T9): (x0: V0, x1: V1, x2: V2) => T9; + pipe(fn0: (x0: V0, x1: V1, x2: V2, x3: V3) => T1, fn1: (x: T1) => T2, fn2: (x: T2) => T3, fn3: (x: T3) => T4, fn4: (x: T4) => T5, fn5: (x: T5) => T6, fn6: (x: T6) => T7, fn7: (x: T7) => T8, fn8: (x: T8) => T9): (x0: V0, x1: V1, x2: V2, x3: V3) => T9; + + /** + * Performs left-to-right composition of one or more Promise-returning functions. The leftmost function may have any arity; the remaining functions must be unary. + */ + pipeP(fn0: (x0: V0) => Promise): (x0: V0) => Promise; + pipeP(fn0: (x0: V0, x1: V1) => Promise): (x0: V0, x1: V1) => Promise; + pipeP(fn0: (x0: V0, x1: V1, x2: V2) => Promise): (x0: V0, x1: V1, x2: V2) => Promise; + pipeP(fn0: (x0: V0, x1: V1, x2: V2, x3: V3) => Promise): (x0: V0, x1: V1, x2: V2, x3: V3) => Promise; + pipeP(fn0: (x0: V0) => Promise, fn1: (x: T1) => Promise | T2): (x0: V0) => Promise; + pipeP(fn0: (x0: V0, x1: V1) => Promise, fn1: (x: T1) => Promise | T2): (x0: V0, x1: V1) => Promise; + pipeP(fn0: (x0: V0, x1: V1, x2: V2) => Promise, fn1: (x: T1) => Promise | T2): (x0: V0, x1: V1, x2: V2) => Promise; + pipeP(fn0: (x0: V0, x1: V1, x2: V2, x3: V3) => Promise, fn1: (x: T1) => Promise | T2): (x0: V0, x1: V1, x2: V2, x3: V3) => Promise; + pipeP(fn0: (x0: V0) => Promise, fn1: (x: T1) => Promise | T2, fn2: (x: T2) => Promise | T3): (x0: V0) => Promise; + pipeP(fn0: (x0: V0, x1: V1) => Promise, fn1: (x: T1) => Promise | T2, fn2: (x: T2) => Promise | T3): (x0: V0, x1: V1) => Promise; + pipeP(fn0: (x0: V0, x1: V1, x2: V2) => Promise, fn1: (x: T1) => Promise | T2, fn2: (x: T2) => Promise | T3): (x0: V0, x1: V1, x2: V2) => Promise; + pipeP(fn0: (x0: V0, x1: V1, x2: V2, x3: V3) => Promise, fn1: (x: T1) => Promise | T2, fn2: (x: T2) => Promise | T3): (x0: V0, x1: V1, x2: V2, x3: V3) => Promise; + pipeP(fn0: (x0: V0) => Promise, fn1: (x: T1) => Promise | T2, fn2: (x: T2) => Promise | T3, fn3: (x: T3) => Promise | T4): (x0: V0) => Promise; + pipeP(fn0: (x0: V0, x1: V1) => Promise, fn1: (x: T1) => Promise | T2, fn2: (x: T2) => Promise | T3, fn3: (x: T3) => Promise | T4): (x0: V0, x1: V1) => Promise; + pipeP(fn0: (x0: V0, x1: V1, x2: V2) => Promise, fn1: (x: T1) => Promise | T2, fn2: (x: T2) => Promise | T3, fn3: (x: T3) => Promise | T4): (x0: V0, x1: V1, x2: V2) => Promise; + pipeP(fn0: (x0: V0, x1: V1, x2: V2, x3: V3) => Promise, fn1: (x: T1) => Promise | T2, fn2: (x: T2) => Promise | T3, fn3: (x: T3) => Promise | T4): (x0: V0, x1: V1, x2: V2, x3: V3) => Promise; + pipeP(fn0: (x0: V0) => Promise, fn1: (x: T1) => Promise | T2, fn2: (x: T2) => Promise | T3, fn3: (x: T3) => Promise | T4, fn4: (x: T4) => Promise | T5): (x0: V0) => Promise; + pipeP(fn0: (x0: V0, x1: V1) => Promise, fn1: (x: T1) => Promise | T2, fn2: (x: T2) => Promise | T3, fn3: (x: T3) => Promise | T4, fn4: (x: T4) => Promise | T5): (x0: V0, x1: V1) => Promise; + pipeP(fn0: (x0: V0, x1: V1, x2: V2) => Promise, fn1: (x: T1) => Promise | T2, fn2: (x: T2) => Promise | T3, fn3: (x: T3) => Promise | T4, fn4: (x: T4) => Promise | T5): (x0: V0, x1: V1, x2: V2) => Promise; + pipeP(fn0: (x0: V0, x1: V1, x2: V2, x3: V3) => Promise, fn1: (x: T1) => Promise | T2, fn2: (x: T2) => Promise | T3, fn3: (x: T3) => Promise | T4, fn4: (x: T4) => Promise | T5): (x0: V0, x1: V1, x2: V2, x3: V3) => Promise; + pipeP(fn0: (x0: V0) => Promise, fn1: (x: T1) => Promise | T2, fn2: (x: T2) => Promise | T3, fn3: (x: T3) => Promise | T4, fn4: (x: T4) => Promise | T5, fn5: (x: T5) => Promise | T6): (x0: V0) => Promise; + pipeP(fn0: (x0: V0, x1: V1) => Promise, fn1: (x: T1) => Promise | T2, fn2: (x: T2) => Promise | T3, fn3: (x: T3) => Promise | T4, fn4: (x: T4) => Promise | T5, fn5: (x: T5) => Promise | T6): (x0: V0, x1: V1) => Promise; + pipeP(fn0: (x0: V0, x1: V1, x2: V2) => Promise, fn1: (x: T1) => Promise | T2, fn2: (x: T2) => Promise | T3, fn3: (x: T3) => Promise | T4, fn4: (x: T4) => Promise | T5, fn5: (x: T5) => Promise | T6): (x0: V0, x1: V1, x2: V2) => Promise; + pipeP(fn0: (x0: V0, x1: V1, x2: V2, x3: V3) => Promise, fn1: (x: T1) => Promise | T2, fn2: (x: T2) => Promise | T3, fn3: (x: T3) => Promise | T4, fn4: (x: T4) => Promise | T5, fn5: (x: T5) => Promise | T6): (x0: V0, x1: V1, x2: V2, x3: V3) => Promise; + pipeP(fn0: (x0: V0) => Promise, fn1: (x: T1) => Promise | T2, fn2: (x: T2) => Promise | T3, fn3: (x: T3) => Promise | T4, fn4: (x: T4) => Promise | T5, fn5: (x: T5) => Promise | T6, fn6: (x: T6) => Promise | T7): (x0: V0) => Promise; + pipeP(fn0: (x0: V0, x1: V1) => Promise, fn1: (x: T1) => Promise | T2, fn2: (x: T2) => Promise | T3, fn3: (x: T3) => Promise | T4, fn4: (x: T4) => Promise | T5, fn5: (x: T5) => Promise | T6, fn6: (x: T6) => Promise | T7): (x0: V0, x1: V1) => Promise; + pipeP(fn0: (x0: V0, x1: V1, x2: V2) => Promise, fn1: (x: T1) => Promise | T2, fn2: (x: T2) => Promise | T3, fn3: (x: T3) => Promise | T4, fn4: (x: T4) => Promise | T5, fn5: (x: T5) => Promise | T6, fn6: (x: T6) => Promise | T7): (x0: V0, x1: V1, x2: V2) => Promise; + pipeP(fn0: (x0: V0, x1: V1, x2: V2, x3: V3) => Promise, fn1: (x: T1) => Promise | T2, fn2: (x: T2) => Promise | T3, fn3: (x: T3) => Promise | T4, fn4: (x: T4) => Promise | T5, fn5: (x: T5) => Promise | T6, fn6: (x: T6) => Promise | T7): (x0: V0, x1: V1, x2: V2, x3: V3) => Promise; + pipeP(fn0: (x0: V0) => Promise, fn1: (x: T1) => Promise | T2, fn2: (x: T2) => Promise | T3, fn3: (x: T3) => Promise | T4, fn4: (x: T4) => Promise | T5, fn5: (x: T5) => Promise | T6, fn6: (x: T6) => Promise | T7, fn7: (x: T7) => Promise | T8): (x0: V0) => Promise; + pipeP(fn0: (x0: V0, x1: V1) => Promise, fn1: (x: T1) => Promise | T2, fn2: (x: T2) => Promise | T3, fn3: (x: T3) => Promise | T4, fn4: (x: T4) => Promise | T5, fn5: (x: T5) => Promise | T6, fn6: (x: T6) => Promise | T7, fn7: (x: T7) => Promise | T8): (x0: V0, x1: V1) => Promise; + pipeP(fn0: (x0: V0, x1: V1, x2: V2) => Promise, fn1: (x: T1) => Promise | T2, fn2: (x: T2) => Promise | T3, fn3: (x: T3) => Promise | T4, fn4: (x: T4) => Promise | T5, fn5: (x: T5) => Promise | T6, fn6: (x: T6) => Promise | T7, fn7: (x: T7) => Promise | T8): (x0: V0, x1: V1, x2: V2) => Promise; + pipeP(fn0: (x0: V0, x1: V1, x2: V2, x3: V3) => Promise, fn1: (x: T1) => Promise | T2, fn2: (x: T2) => Promise | T3, fn3: (x: T3) => Promise | T4, fn4: (x: T4) => Promise | T5, fn5: (x: T5) => Promise | T6, fn6: (x: T6) => Promise | T7, fn7: (x: T7) => Promise | T8): (x0: V0, x1: V1, x2: V2, x3: V3) => Promise; + pipeP(fn0: (x0: V0) => Promise, fn1: (x: T1) => Promise | T2, fn2: (x: T2) => Promise | T3, fn3: (x: T3) => Promise | T4, fn4: (x: T4) => Promise | T5, fn5: (x: T5) => Promise | T6, fn6: (x: T6) => Promise | T7, fn7: (x: T7) => Promise | T8, fn8: (x: T8) => Promise | T9): (x0: V0) => Promise; + pipeP(fn0: (x0: V0, x1: V1) => Promise, fn1: (x: T1) => Promise | T2, fn2: (x: T2) => Promise | T3, fn3: (x: T3) => Promise | T4, fn4: (x: T4) => Promise | T5, fn5: (x: T5) => Promise | T6, fn6: (x: T6) => Promise | T7, fn7: (x: T7) => Promise | T8, fn8: (x: T8) => Promise | T9): (x0: V0, x1: V1) => Promise; + pipeP(fn0: (x0: V0, x1: V1, x2: V2) => Promise, fn1: (x: T1) => Promise | T2, fn2: (x: T2) => Promise | T3, fn3: (x: T3) => Promise | T4, fn4: (x: T4) => Promise | T5, fn5: (x: T5) => Promise | T6, fn6: (x: T6) => Promise | T7, fn7: (x: T7) => Promise | T8, fn8: (x: T8) => Promise | T9): (x0: V0, x1: V1, x2: V2) => Promise; + pipeP(fn0: (x0: V0, x1: V1, x2: V2, x3: V3) => Promise, fn1: (x: T1) => Promise | T2, fn2: (x: T2) => Promise | T3, fn3: (x: T3) => Promise | T4, fn4: (x: T4) => Promise | T5, fn5: (x: T5) => Promise | T6, fn6: (x: T6) => Promise | T7, fn7: (x: T7) => Promise | T8, fn8: (x: T8) => Promise | T9): (x0: V0, x1: V1, x2: V2, x3: V3) => Promise; + + /** + * Returns the left-to-right Kleisli composition of the provided functions, each of which must return a value of a type supported by chain. + */ + // skipped extra params on fn0 -- not mentioned in the docs! + pipeK(fn0: (v: Chain) => Chain): (v: V) => Chain; + pipeK(fn0: (v: Chain) => Chain, fn1: (x: T1) => Chain): (v: V) => Chain; + pipeK(fn0: (v: Chain) => Chain, fn1: (x: T1) => Chain, fn2: (x: T2) => Chain): (v: V) => Chain; + pipeK(fn0: (v: Chain) => Chain, fn1: (x: T1) => Chain, fn2: (x: T2) => Chain, fn3: (x: T3) => Chain): (v: V) => Chain; + pipeK(fn0: (v: Chain) => Chain, fn1: (x: T1) => Chain, fn2: (x: T2) => Chain, fn3: (x: T3) => Chain, fn4: (x: T4) => Chain): (v: V) => Chain; + pipeK(fn0: (v: Chain) => Chain, fn1: (x: T1) => Chain, fn2: (x: T2) => Chain, fn3: (x: T3) => Chain, fn4: (x: T4) => Chain, fn5: (x: T5) => Chain): (v: V) => Chain; + pipeK(fn0: (v: Chain) => Chain, fn1: (x: T1) => Chain, fn2: (x: T2) => Chain, fn3: (x: T3) => Chain, fn4: (x: T4) => Chain, fn5: (x: T5) => Chain, fn6: (x: T6) => Chain): (v: V) => Chain; + pipeK(fn0: (v: Chain) => Chain, fn1: (x: T1) => Chain, fn2: (x: T2) => Chain, fn3: (x: T3) => Chain, fn4: (x: T4) => Chain, fn5: (x: T5) => Chain, fn6: (x: T6) => Chain, fn7: (x: T7) => Chain): (v: V) => Chain; + pipeK(fn0: (v: Chain) => Chain, fn1: (x: T1) => Chain, fn2: (x: T2) => Chain, fn3: (x: T3) => Chain, fn4: (x: T4) => Chain, fn5: (x: T5) => Chain, fn6: (x: T6) => Chain, fn7: (x: T7) => Chain, fn8: (x: T8) => Chain): (v: V) => Chain; + + /** + * Returns a new list by plucking the same named property off all objects in the list supplied. + */ + // hard to mix cuz different generics + + // infer + pluck, K extends keyof T>(p: K, list: List): U[]; // fails on number keys + pluck, K extends keyof T>(p: K): (list: List) => U[]; // doesn't work, T info late + // pluck, K extends keyof T>: CurriedFunction2, T[K][]>; + + // supply return object type manually when unable to infer it... + pluck(p: Prop, list: Struct[]): T[]; + pluck(p: Prop): (list: Struct[]) => T[]; + // pluck: CurriedFunction2[], T[]>; + + /** + * Returns a new list with the given element at the front, followed by the contents of the + * list. + */ + prepend(el: T, list: List): T[]; + prepend(el: T): (list: List) => T[]; + // prepend: CurriedFunction2, T[]>; + + /** + * Multiplies together all the elements of a list. + */ + product(list: List): number; + + + /** + * Reasonable analog to SQL `select` statement. + */ + // hard to mix cuz different generics + + // infer + project(props: List, objs: List): T[]; + project(props: List): (objs: List) => T[]; // T info probably too late + // project: CurriedFunction2, List, Pick[]>; + + // supply return object type manually when unable to infer it... + project(props: List, objs: List): U[]; + project(props: List): (objs: List) => U[]; + // project: CurriedFunction2, List, U[]>; + + /** + * Returns a function that when supplied an object returns the indicated property of that object, if it exists. + */ + + // keyof version + prop(p: Prop, obj: T): T; + // prop(p: K): (obj: T) => T[K]; // T info late + // prop: CurriedFunction2; + // prop(p: K): (obj: T) => T[K]; // K redefined, fails + // prop: CurriedFunction2; + + // Record version, more curry-friendly + prop>(p: K, obj: T): V; // uncurried adds value only for {} from e.g. degeneration + prop(p: K): >(obj: T) => V; + // prop>: CurriedFunction2; + + /** + * Determines whether the given property of an object has a specific + * value according to strict equality (`===`). Most likely used to + * filter a list. + */ + // propEq>(name: Prop, val: any, obj: T): boolean; + // propEq>(name: Prop, val: any): (obj: T) => boolean; + // propEq>(name: Prop): CurriedFunction2; + // // propEq>(name: Prop): (val: any, obj: T) => boolean; + // // propEq>(name: Prop): (val: any) => (obj: T) => boolean; + // // propEq>: CurriedFunction3; + + // base + propEq>(name: Prop, val: any, obj: T): boolean; + propEq(name: Prop, val: any): { + >(obj: T): boolean; + }; + propEq(name: Prop): { + >(val: any, obj: T): boolean; + (val: any): { + >(obj: T): boolean; + }; + }; - type Obj = Dictionary; - type List = ArrayLike; - type StringLike = string | StringRepresentable; - type Prop = Index | StringRepresentable; - type Path = List; - type Struct = Obj | List; - type AccOpts = List|Obj|Transformer; - type Pred = (v: T) => boolean; - type ObjPred = (value: T, key: string) => boolean; - // Ramda interfaces + /** + * Returns true if the specified object property is of the given type; false otherwise. + */ - interface Type extends Function { - new (...args: any[]): T; - } - - interface Variadic { - (...args: any[]): T; - } - - interface KeyValuePair extends Array { 0 : K; 1 : V; } - - interface Transformer { - step: (acc: Acc, v: T) => Acc; - init: () => Acc; - result: (acc: Acc) => Res; // = R.identity - } - - interface NumericDictionary { - [index: number]: T; - } - - interface StringRepresentable { - toString(): T; - } - - interface NestedObj { - [index: string]: T|NestedObj; - } - - // interface RecursiveArray extends Array> {} - // interface ListOfRecursiveArraysOrValues extends List> {} - interface NestedArray { - [index: number]: T | NestedArray; - length: number; - } - - // // an unfortunate compromise -- while the actual lens should be generic, for the purpose of TS the structure should be supplied beforehand - // interface KeyLens, K extends keyof T> { - // // > - // (obj: T): T[K]; // get - // set(v: T[K], obj: T): T; - // // map(fn: (v: T[K]) => T[K], obj: T): T + // Record + propIs>(type: T, name: K, obj: U): obj is (U & Obj); + propIs(type: T, name: K): >(obj: U) => obj is (U & Obj); + // propIs(type: T): { + // >(name: K, obj: U): obj is (U & Record); + // (name: K): >(obj: U) => obj is (U & Record); // } - interface Lens { - (obj: T): U; // get - set(v: U, obj: T): T; - // map(fn: (v: U) => U, obj: T): T - } - interface ManualLens { - >(obj: T): U; // get - set>(v: U, obj: T): T; - // >map(fn: (v: U) => U, obj: T): T - } - interface UnknownLens { - (obj: T): U; // get - set(v: U, obj: T): T; - // map(fn: (v: U) => U, obj: T): T - } - - // @see https://gist.github.com/donnut/fd56232da58d25ceecf1, comment by @albrow - - // interface CurriedFunction1 { - // (v1: T1): R; + // propIs>: CurriedFunction3)>; // obj is? name unavailable... + + // inference, fails if name and object are supplied separately + propIs(type: T, name: Prop, obj: V): obj is (V & Obj); + // propIs(type: T, name: K): (obj: V) => obj is (V & Record); // object info not available in time :( + // propIs(type: T): { + // (name: K, obj: V): obj is (V & Record); + // (name: K): (obj: V) => obj is (V & Record); // object info not available in time :( // } - type CurriedFunction1 = (v1: T1) => R; - - interface CurriedFunction2 { - (v1: T1): (v2: T2) => R; - (v1: T1, v2: T2): R; - } - interface CurriedFunction3 { - (v1: T1): CurriedFunction2; - (v1: T1, v2: T2): (v3: T3) => R; - (v1: T1, v2: T2, v3: T3): R; - } - interface CurriedFunction4 { - (v1: T1): CurriedFunction3; - (v1: T1, v2: T2): CurriedFunction2; - (v1: T1, v2: T2, v3: T3): (v4: T4) => R; - (v1: T1, v2: T2, v3: T3, v4: T4): R; - } - interface CurriedFunction5 { - (v1: T1): CurriedFunction4; - (v1: T1, v2: T2): CurriedFunction3; - (v1: T1, v2: T2, v3: T3): CurriedFunction2; - (v1: T1, v2: T2, v3: T3, v4: T4): (v5: T5) => R; - (v1: T1, v2: T2, v3: T3, v4: T4, v5: T5): R; - } - interface CurriedFunction6 { - (v1: T1): CurriedFunction5; - (v1: T1, v2: T2): CurriedFunction4; - (v1: T1, v2: T2, v3: T3): CurriedFunction3; - (v1: T1, v2: T2, v3: T3, v4: T4): CurriedFunction2; - (v1: T1, v2: T2, v3: T3, v4: T4, v5: T5): (v6: T6) => R; - (v1: T1, v2: T2, v3: T3, v4: T4, v5: T5, v6: T6): R; - } - interface CurriedFunction7 { - (v1: T1): CurriedFunction6; - (v1: T1, v2: T2): CurriedFunction5; - (v1: T1, v2: T2, v3: T3): CurriedFunction4; - (v1: T1, v2: T2, v3: T3, v4: T4): CurriedFunction3; - (v1: T1, v2: T2, v3: T3, v4: T4, v5: T5): CurriedFunction2; - (v1: T1, v2: T2, v3: T3, v4: T4, v5: T5, v6: T6): (v7: T7) => R; - (v1: T1, v2: T2, v3: T3, v4: T4, v5: T5, v6: T6, v7: T7): R; - } - interface CurriedFunction8 { - (v1: T1): CurriedFunction7; - (v1: T1, v2: T2): CurriedFunction6; - (v1: T1, v2: T2, v3: T3): CurriedFunction5; - (v1: T1, v2: T2, v3: T3, v4: T4): CurriedFunction4; - (v1: T1, v2: T2, v3: T3, v4: T4, v5: T5): CurriedFunction3; - (v1: T1, v2: T2, v3: T3, v4: T4, v5: T5, v6: T6): CurriedFunction2; - (v1: T1, v2: T2, v3: T3, v4: T4, v5: T5, v6: T6, v7: T7): (v8: T8) => R; - (v1: T1, v2: T2, v3: T3, v4: T4, v5: T5, v6: T6, v7: T7, v8: T8): R; - } - interface CurriedFunction9 { - (v1: T1): CurriedFunction8; - (v1: T1, v2: T2): CurriedFunction7; - (v1: T1, v2: T2, v3: T3): CurriedFunction6; - (v1: T1, v2: T2, v3: T3, v4: T4): CurriedFunction5; - (v1: T1, v2: T2, v3: T3, v4: T4, v5: T5): CurriedFunction4; - (v1: T1, v2: T2, v3: T3, v4: T4, v5: T5, v6: T6): CurriedFunction3; - (v1: T1, v2: T2, v3: T3, v4: T4, v5: T5, v6: T6, v7: T7): CurriedFunction2; - (v1: T1, v2: T2, v3: T3, v4: T4, v5: T5, v6: T6, v7: T7, v8: T8): (v9: T9) => R; - (v1: T1, v2: T2, v3: T3, v4: T4, v5: T5, v6: T6, v7: T7, v8: T8, v9: T9): R; - } - - - interface CurriedFn1 { - (v1: T1): R; - } - interface CurriedFn2 { - (v1: T1, v2: T2): R; - (v1: T1): (v2: T2) => R; - } - interface CurriedFn3 { - (v1: T1, v2: T2, v3: T3): R; - (v1: T1, v2: T2): (v3: T3) => R; - (v1: T1): { - (v2: T2, v3: T3): R; - (v2: T2): (v3: T3) => R; + // propIs: CurriedFunction3)>; // obj is? name unavailable... + + // curry-friendlier fallback + propIs(type: Function, name: Prop, obj: Struct): boolean; + propIs(type: Function, name: Prop): (obj: Struct) => boolean; + propIs(type: Function): CurriedFunction2, boolean>; + // propIs(type: Function): { + // (name: Prop, obj: Struct): boolean; + // (name: Prop): (obj: Struct) => boolean; + // } + // propIs: CurriedFunction3, boolean>; + + // mixed: + propIs(type: T): { + // record + >(name: K, obj: U): obj is (U & Obj); + (name: K): >(obj: U) => obj is (U & Obj); + // keyof + (name: Prop, obj: V): obj is (V & Obj); + // (name: K): (obj: V) => obj is (V & Record); // object info not available in time :( + }; + + /** + * If the given, non-null object has an own property with the specified name, returns the value of that property. + * Otherwise returns the provided default value. + */ + + // // infer with Record (curry-friendly) -- can't use here: it'd error whenever the default should trigger + // propOr>(val: T, p: K, obj: U): V|T; + // propOr(val: T, p: K): >(obj: U) => V|T; + // propOr>(val: T): CurriedFunction2; + // // propOr>: CurriedFunction3; + + // infer with keyof (not curry-friendly), allowing a default value with a type different from the actual one + propOr(val: T, p: K, obj: Obj): K | T; // obj[K]? + propOr(val: T, p: K): (obj: Obj) => K | T; // generics too early? + propOr(val: T): CurriedFunction2, K | T>; // generics too early? + // propOr(val: T): (p: K, obj: U) => U[K]|T; + // propOr(val: T): (p: K) => (obj: U) => U[K]|T; // U too early? + // propOr: CurriedFunction3; + + // presume the value at the given key matches the type of the default value, bad but less likely to fail with currying + propOr(val: T, p: Prop, obj: Struct): T; // adds value only to protect against {} from e.g. generic degeneration + // propOr(val: T, p: Prop): (obj: Struct) => T; + // // propOr(val: T): (p: Prop, obj: Struct) => T; + // propOr(val: T): CurriedFunction2, T>; + // // propOr: CurriedFunction3, T>; + propOr(val: T, p: Prop): Struct; + propOr(val: T): { + (p: Prop): Struct; + }; + + + // // useless unbound generics? + // propOr(val: T, p: Prop, obj: U): V; + // propOr(val: T, p: Prop): (obj: U) => V; + // // propOr(val: T): (p: Prop, obj: U) => V; + // propOr(val: T): CurriedFunction2; + // // propOr: CurriedFunction3; + + /** + * Acts as multiple `prop`: array of keys in, array of values out. Preserves order. + */ + + // generic version + props(ps: List, obj: Struct): T[]; + props(ps: List): (obj: Struct) => T[]; + // props: CurriedFunction2, Struct, T[]>; + + // TODO: heterogeneous version + // Record-based? + // props>(ps: List, obj: Struct): ???; + + /** + * Returns true if the specified object property satisfies the given predicate; false otherwise. + */ + + // // Record (curry-friendly) + // propSatisfies>(pred: Pred, name: K, obj: U): boolean; + // propSatisfies(pred: Pred, name: K): >(obj: U) => boolean; + // propSatisfies>(pred: Pred): CurriedFunction2; + // // propSatisfies>: CurriedFunction3, K, U, boolean>; + + // // keyof, info too late on currying + // propSatisfies, K extends keyof U>(pred: Pred, name: Prop, obj: U): boolean; + // propSatisfies(pred: Pred, name: Prop): (obj: U) => boolean; + // propSatisfies(pred: Pred): CurriedFunction2; + // // propSatisfies: CurriedFunction3, Prop, U, boolean>; + + // Record (curry-friendly) + propSatisfies>(pred: Pred, name: K, obj: U): boolean; + propSatisfies(pred: Pred, name: K): { + >(obj: U): boolean; + }; + propSatisfies(pred: Pred): { + >(name: K, obj: U): boolean; + (name: K): { + >(obj: U): boolean; }; - } - interface CurriedFn4 { - (v1: T1, v2: T2, v3: T3, v4: T4): R; - (v1: T1, v2: T2, v3: T3): (v4: T4) => R; - (v1: T1, v2: T2): { - (v3: T3, v4: T4): R; - (v3: T3): (v4: T4) => R; + }; + + // keyof, info too late on currying + propSatisfies(pred: Pred, name: Prop, obj: U): boolean; + propSatisfies(pred: Pred, name: Prop): { + (obj: U): boolean; + }; + propSatisfies(pred: Pred): { + (name: Prop, obj: U): boolean; + (name: Prop): { + (obj: U): boolean; }; - (v1: T1): { - (v2: T2, v3: T3, v4: T4): R; - (v2: T2, v3: T3): (v4: T4) => R; - (v2: T2): { - (v3: T3, v4: T4): R; - (v3: T3): (v4: T4) => R; - }; + }; + + + /** + * Returns a list of numbers from `from` (inclusive) to `to` + * (exclusive). In mathematical terms, `range(a, b)` is equivalent to + * the half-open interval `[a, b)`. + */ + range(from: number, to: number): number[]; + range(from: number): (to: number) => number[]; + // range: CurriedFunction2; + + /** + * Returns a single item by iterating through the list, successively calling the iterator + * function and passing it an accumulator value and the current value from the array, and + * then passing the result to the next call. + */ + // reduce>(fn: (acc: TResult, elem: T, idx: Number, list: R) => TResult|Reduced, acc: TResult, list: R): TResult; + // reduce>(fn: (acc: TResult, elem: T, idx: Number, list: R) => TResult|Reduced, acc: TResult): (list: R) => TResult; + // reduce>(fn: (acc: TResult, elem: T, idx: Number, list: R) => TResult|Reduced): CurriedFunction2; + // // reduce>(fn: (acc: TResult, elem: T, idx: Number, list: R) => TResult|Reduced): (acc: TResult, list: R) => TResult; + // // reduce>: CurriedFunction3<(acc: TResult, elem: T, idx: Number, list: R) => TResult|Reduced, TResult, R, TResult>; + // base + reduce>(fn: (acc: TResult, elem: T, idx: number, list: R) => TResult | Reduced, acc: TResult, list: R): TResult; + reduce>(fn: (acc: TResult, elem: T, idx: number, list: R) => TResult | Reduced, acc: TResult): { + (list: R): TResult; + }; + reduce>(fn: (acc: TResult, elem: T, idx: number, list: R) => TResult | Reduced): { + (acc: TResult, list: R): TResult; + (acc: TResult): { + (list: R): TResult; }; - } - interface CurriedFn5 { - (v1: T1, v2: T2, v3: T3, v4: T4, v5: T5): R; - (v1: T1, v2: T2, v3: T3, v4: T4): (v5: T5) => R; - (v1: T1, v2: T2, v3: T3): { - (v4: T4, v5: T5): R; - (v4: T4): (v5: T5) => R; + }; + + + /** + * Groups the elements of the list according to the result of calling the String-returning function keyFn on each + * element and reduces the elements of each group to a single value via the reducer function valueFn. + */ + // // reason for 'any' on acc: somehow empty accumulators like '[]' won't work well when matching + // reduceBy>(valueFn: (acc: TResult, elem: T, idx: number, list: R) => TResult, acc: TResult|any, keyFn: (elem: T) => string, list: R): TResult; + // reduceBy>(valueFn: (acc: TResult, elem: T, idx: number, list: R) => TResult, acc: TResult|any, keyFn: (elem: T) => string): (list: R) => TResult; + // reduceBy>(valueFn: (acc: TResult, elem: T, idx: number, list: R) => TResult, acc: TResult|any): CurriedFunction2<(elem: T) => string, R, TResult>; + // reduceBy>(valueFn: (acc: TResult, elem: T, idx: number, list: R) => TResult): CurriedFunction3 string, R, TResult>; + // // reduceBy>: CurriedFunction4<(acc: TResult, elem: T, idx: number, list: R) => TResult, TResult|any, (elem: T) => string, R, TResult>; + // base + reduceBy>(valueFn: (acc: TResult, elem: T, idx: number, list: R) => TResult, acc: TResult | any, keyFn: (elem: T) => string, list: R): TResult; + reduceBy>(valueFn: (acc: TResult, elem: T, idx: number, list: R) => TResult, acc: TResult | any, keyFn: (elem: T) => string): { + (list: R): TResult; + }; + reduceBy>(valueFn: (acc: TResult, elem: T, idx: number, list: R) => TResult, acc: TResult | any): { + (keyFn: (elem: T) => string, list: R): TResult; + (keyFn: (elem: T) => string): { + (list: R): TResult; }; - (v1: T1, v2: T2): { - (v3: T3, v4: T4, v5: T5): R; - (v3: T3, v4: T4): (v5: T5) => R; - (v3: T3): { - (v4: T4, v5: T5): R; - (v4: T4): (v5: T5) => R; - }; + }; + reduceBy>(valueFn: (acc: TResult, elem: T, idx: number, list: R) => TResult): { + (acc: TResult | any, keyFn: (elem: T) => string, list: R): TResult; + (acc: TResult | any, keyFn: (elem: T) => string): { + (list: R): TResult; }; - (v1: T1): { - (v2: T2, v3: T3, v4: T4, v5: T5): R; - (v2: T2, v3: T3, v4: T4): (v5: T5) => R; - (v2: T2, v3: T3): { - (v4: T4, v5: T5): R; - (v4: T4): (v5: T5) => R; - }; - (v2: T2): { - (v3: T3, v4: T4, v5: T5): R; - (v3: T3, v4: T4): (v5: T5) => R; - (v3: T3): { - (v4: T4, v5: T5): R; - (v4: T4): (v5: T5) => R; - }; + (acc: TResult | any): { + (keyFn: (elem: T) => string, list: R): TResult; + (keyFn: (elem: T) => string): { + (list: R): TResult; }; }; - } - interface CurriedFn6 { - (v1: T1, v2: T2, v3: T3, v4: T4, v5: T5, v6: T6): R; - (v1: T1, v2: T2, v3: T3, v4: T4, v5: T5): (v6: T6) => R; - (v1: T1, v2: T2, v3: T3, v4: T4): { - (v5: T5, v6: T6): R; - (v5: T5): (v6: T6) => R; + }; + + + /** + * Returns a value wrapped to indicate that it is the final value of the reduce and + * transduce functions. The returned value should be considered a black box: the internal + * structure is not guaranteed to be stable. + */ + reduced(elem: T): Reduced; + + /** + * Returns a single item by iterating through the list, successively calling the iterator + * function and passing it an accumulator value and the current value from the array, and + * then passing the result to the next call. + */ + // // reason for 'any' on acc: somehow empty accumulators like '[]' won't work well when matching + // reduceRight(fn: (elem: T, acc: TResult) => TResult|Reduced, acc: TResult|any, list: List): TResult; + // reduceRight(fn: (elem: T, acc: TResult) => TResult|Reduced, acc: TResult|any): (list: List) => TResult; + // reduceRight(fn: (elem: T, acc: TResult) => TResult|Reduced): CurriedFunction2, TResult>; + // // reduceRight(fn: (elem: T, acc: TResult) => TResult|Reduced): (acc: TResult|any, list: List) => TResult; + // // reduceRight(fn: (elem: T, acc: TResult) => TResult|Reduced): (acc: TResult|any) => (list: List) => TResult; + // // reduceRight: CurriedFunction3<(elem: T, acc: TResult) => TResult|Reduced, TResult|any, List, TResult>; + // base + reduceRight(fn: (elem: T, acc: TResult) => TResult | Reduced, acc: TResult | any, list: List): TResult; + reduceRight(fn: (elem: T, acc: TResult) => TResult | Reduced, acc: TResult | any): { + (list: List): TResult; + }; + reduceRight(fn: (elem: T, acc: TResult) => TResult | Reduced): { + (acc: TResult | any, list: List): TResult; + (acc: TResult | any): { + (list: List): TResult; }; - (v1: T1, v2: T2, v3: T3): { - (v4: T4, v5: T5, v6: T6): R; - (v4: T4, v5: T5): (v6: T6) => R; - (v4: T4): { - (v5: T5, v6: T6): R; - (v5: T5): (v6: T6) => R; - }; + }; + + + /** + * Like reduce, reduceWhile returns a single item by iterating through the list, successively calling the iterator function. + * reduceWhile also takes a predicate that is evaluated before each step. If the predicate returns false, it "short-circuits" + * the iteration and returns the current value of the accumulator. + */ + // reduceWhile(pred: (acc: TResult, elem: T) => boolean, fn: (acc: TResult, elem: T) => TResult|Reduced, acc: TResult, list: List): TResult; + // reduceWhile(pred: (acc: TResult, elem: T) => boolean, fn: (acc: TResult, elem: T) => TResult|Reduced, acc: TResult): (list: List) => TResult; + // reduceWhile(pred: (acc: TResult, elem: T) => boolean, fn: (acc: TResult, elem: T) => TResult|Reduced): CurriedFunction2, TResult>; + // reduceWhile(pred: (acc: TResult, elem: T) => boolean): CurriedFunction3<(acc: TResult, elem: T) => TResult|Reduced, TResult, List, TResult>; + // // reduceWhile: CurriedFunction4<(acc: TResult, elem: T) => boolean, (acc: TResult, elem: T) => TResult|Reduced, TResult, List, TResult>; + + // base + reduceWhile(pred: (acc: TResult, elem: T) => boolean, fn: (acc: TResult, elem: T) => TResult | Reduced, acc: TResult, list: List): TResult; + reduceWhile(pred: (acc: TResult, elem: T) => boolean, fn: (acc: TResult, elem: T) => TResult | Reduced, acc: TResult): { + (list: List): TResult; + }; + reduceWhile(pred: (acc: TResult, elem: T) => boolean, fn: (acc: TResult, elem: T) => TResult | Reduced): { + (acc: TResult, list: List): TResult; + (acc: TResult): { + (list: List): TResult; }; - (v1: T1, v2: T2): { - (v3: T3, v4: T4, v5: T5, v6: T6): R; - (v3: T3, v4: T4, v5: T5): (v6: T6) => R; - (v3: T3, v4: T4): { - (v5: T5, v6: T6): R; - (v5: T5): (v6: T6) => R; - }; - (v3: T3): { - (v4: T4, v5: T5, v6: T6): R; - (v4: T4, v5: T5): (v6: T6) => R; - (v4: T4): { - (v5: T5, v6: T6): R; - (v5: T5): (v6: T6) => R; - }; - }; + }; + reduceWhile(pred: (acc: TResult, elem: T) => boolean): { + (fn: (acc: TResult, elem: T) => TResult | Reduced, acc: TResult, list: List): TResult; + (fn: (acc: TResult, elem: T) => TResult | Reduced, acc: TResult): { + (list: List): TResult; }; - (v1: T1): { - (v2: T2, v3: T3, v4: T4, v5: T5, v6: T6): R; - (v2: T2, v3: T3, v4: T4, v5: T5): (v6: T6) => R; - (v2: T2, v3: T3, v4: T4): { - (v5: T5, v6: T6): R; - (v5: T5): (v6: T6) => R; - }; - (v2: T2, v3: T3): { - (v4: T4, v5: T5, v6: T6): R; - (v4: T4, v5: T5): (v6: T6) => R; - (v4: T4): { - (v5: T5, v6: T6): R; - (v5: T5): (v6: T6) => R; - }; - }; - (v2: T2): { - (v3: T3, v4: T4, v5: T5, v6: T6): R; - (v3: T3, v4: T4, v5: T5): (v6: T6) => R; - (v3: T3, v4: T4): { - (v5: T5, v6: T6): R; - (v5: T5): (v6: T6) => R; - }; - (v3: T3): { - (v4: T4, v5: T5, v6: T6): R; - (v4: T4, v5: T5): (v6: T6) => R; - (v4: T4): { - (v5: T5, v6: T6): R; - (v5: T5): (v6: T6) => R; - }; - }; + (fn: (acc: TResult, elem: T) => TResult | Reduced): { + (acc: TResult, list: List): TResult; + (acc: TResult): { + (list: List): TResult; }; }; - } - interface CurriedFn7 { - (v1: T1, v2: T2, v3: T3, v4: T4, v5: T5, v6: T6, v7: T7): R; - (v1: T1, v2: T2, v3: T3, v4: T4, v5: T5, v6: T6): (v7: T7) => R; - (v1: T1, v2: T2, v3: T3, v4: T4, v5: T5): { - (v6: T6, v7: T7): R; - (v6: T6): (v7: T7) => R; + }; + + + /** + * Similar to `filter`, except that it keeps only values for which the given predicate + * function returns falsy. + */ + // = filter + + // array + reject(pred: Pred, list: List): T[]; + // reject(pred: Pred): (list: List) => T[]; // mix + // reject: CurriedFunction2, List, T[]>; + + // functor to functor + reject(pred: Pred, list: Functor): Functor; + // reject(pred: Pred): (list: Functor) => Functor; // mix + // reject: CurriedFunction2, Functor, Functor>; + + // functor to array + reject(pred: Pred, list: Functor): T[]; + // reject(pred: Pred): (list: Functor) => T[]; // mix + // reject: CurriedFunction2, Functor, T[]>; + + // object + reject>(pred: Pred, obj: U): U; + // reject(pred: Pred): >(obj: U) => Partial; // mix + // reject>: CurriedFunction2, U, Partial>; + + // mixed + reject(pred: Pred): { + (list: List): T[]; + (list: Functor): Functor; + (list: Functor): T[]; + >(obj: U): U; + }; + + /** + * Removes the sub-list of `list` starting at index `start` and containing `count` elements. + */ + // remove(start: number, count: number, list: List): T[]; + // remove(start: number, count: number): (list: List) => T[]; + // remove(start: number): CurriedFunction2,T[]>; + // // remove: CurriedFunction3, T[]>; + + // base + remove(start: number, count: number, list: List): T[]; + remove(start: number, count: number): { + (list: List): T[]; + }; + remove(start: number): { + (count: number, list: List): T[]; + (count: number): { + (list: List): T[]; }; - (v1: T1, v2: T2, v3: T3, v4: T4): { - (v5: T5, v6: T6, v7: T7): R; - (v5: T5, v6: T6): (v7: T7) => R; - (v5: T5): { - (v6: T6, v7: T7): R; - (v6: T6): (v7: T7) => R; - }; - }; - (v1: T1, v2: T2, v3: T3): { - (v4: T4, v5: T5, v6: T6, v7: T7): R; - (v4: T4, v5: T5, v6: T6): (v7: T7) => R; - (v4: T4, v5: T5): { - (v6: T6, v7: T7): R; - (v6: T6): (v7: T7) => R; - }; - (v4: T4): { - (v5: T5, v6: T6, v7: T7): R; - (v5: T5, v6: T6): (v7: T7) => R; - (v5: T5): { - (v6: T6, v7: T7): R; - (v6: T6): (v7: T7) => R; - }; - }; + }; + + + /** + * Returns a fixed list of size n containing a specified identical value. + */ + repeat(a: T, n: number): T[]; + repeat(a: T): (n: number) => T[]; + // repeat: CurriedFunction2; + + + /** + * Replace a substring or regex match in a string with a replacement. + */ + // replace(pattern: RegExp|Prop, replacement: Prop, str: string): string; + // replace(pattern: RegExp|Prop, replacement: Prop): (str: string) => string; + // replace(pattern: RegExp|Prop): CurriedFunction2; + // // replace(pattern: RegExp|Prop): (replacement: Prop, str: string) => string; + // // replace(pattern: RegExp|Prop): (replacement: Prop) => (str: string) => string; + // // replace: CurriedFunction3; + + // base + replace(pattern: RegExp | Prop, replacement: Prop, str: string): string; + replace(pattern: RegExp | Prop, replacement: Prop): { + (str: string): string; + }; + replace(pattern: RegExp | Prop): { + (replacement: Prop, str: string): string; + (replacement: Prop): { + (str: string): string; }; - (v1: T1, v2: T2): { - (v3: T3, v4: T4, v5: T5, v6: T6, v7: T7): R; - (v3: T3, v4: T4, v5: T5, v6: T6): (v7: T7) => R; - (v3: T3, v4: T4, v5: T5): { - (v6: T6, v7: T7): R; - (v6: T6): (v7: T7) => R; - }; - (v3: T3, v4: T4): { - (v5: T5, v6: T6, v7: T7): R; - (v5: T5, v6: T6): (v7: T7) => R; - (v5: T5): { - (v6: T6, v7: T7): R; - (v6: T6): (v7: T7) => R; - }; - }; - (v3: T3): { - (v4: T4, v5: T5, v6: T6, v7: T7): R; - (v4: T4, v5: T5, v6: T6): (v7: T7) => R; - (v4: T4, v5: T5): { - (v6: T6, v7: T7): R; - (v6: T6): (v7: T7) => R; - }; - (v4: T4): { - (v5: T5, v6: T6, v7: T7): R; - (v5: T5, v6: T6): (v7: T7) => R; - (v5: T5): { - (v6: T6, v7: T7): R; - (v6: T6): (v7: T7) => R; - }; - }; - }; + }; + + + + /** + * Returns a new list with the same elements as the original list, just in the reverse order. + */ + reverse(list: List): T[]; + + /** + * Scan is similar to reduce, but returns a list of successively reduced values from the left. + */ + // scan(fn: (acc: TResult, elem: T) => TResult|Reduced, acc: TResult, list: List): TResult[]; + // scan(fn: (acc: TResult, elem: T) => TResult|Reduced, acc: TResult): (list: List) => TResult[]; + // scan(fn: (acc: TResult, elem: T) => TResult|Reduced): CurriedFunction2, TResult[]>; + // // scan: CurriedFunction3<(acc: TResult, elem: T) => TResult|Reduced, TResult, List, TResult[]>; + + // base + scan(fn: (acc: TResult, elem: T) => TResult | Reduced, acc: TResult, list: List): TResult[]; + scan(fn: (acc: TResult, elem: T) => TResult | Reduced, acc: TResult): { + (list: List): TResult[]; + }; + scan(fn: (acc: TResult, elem: T) => TResult | Reduced): { + (acc: TResult, list: List): TResult[]; + (acc: TResult): { + (list: List): TResult[]; }; - (v1: T1): { - (v2: T2, v3: T3, v4: T4, v5: T5, v6: T6, v7: T7): R; - (v2: T2, v3: T3, v4: T4, v5: T5, v6: T6): (v7: T7) => R; - (v2: T2, v3: T3, v4: T4, v5: T5): { - (v6: T6, v7: T7): R; - (v6: T6): (v7: T7) => R; - }; - (v2: T2, v3: T3, v4: T4): { - (v5: T5, v6: T6, v7: T7): R; - (v5: T5, v6: T6): (v7: T7) => R; - (v5: T5): { - (v6: T6, v7: T7): R; - (v6: T6): (v7: T7) => R; - }; - }; - (v2: T2, v3: T3): { - (v4: T4, v5: T5, v6: T6, v7: T7): R; - (v4: T4, v5: T5, v6: T6): (v7: T7) => R; - (v4: T4, v5: T5): { - (v6: T6, v7: T7): R; - (v6: T6): (v7: T7) => R; - }; - (v4: T4): { - (v5: T5, v6: T6, v7: T7): R; - (v5: T5, v6: T6): (v7: T7) => R; - (v5: T5): { - (v6: T6, v7: T7): R; - (v6: T6): (v7: T7) => R; - }; - }; - }; - (v2: T2): { - (v3: T3, v4: T4, v5: T5, v6: T6, v7: T7): R; - (v3: T3, v4: T4, v5: T5, v6: T6): (v7: T7) => R; - (v3: T3, v4: T4, v5: T5): { - (v6: T6, v7: T7): R; - (v6: T6): (v7: T7) => R; - }; - (v3: T3, v4: T4): { - (v5: T5, v6: T6, v7: T7): R; - (v5: T5, v6: T6): (v7: T7) => R; - (v5: T5): { - (v6: T6, v7: T7): R; - (v6: T6): (v7: T7) => R; - }; - }; - (v3: T3): { - (v4: T4, v5: T5, v6: T6, v7: T7): R; - (v4: T4, v5: T5, v6: T6): (v7: T7) => R; - (v4: T4, v5: T5): { - (v6: T6, v7: T7): R; - (v6: T6): (v7: T7) => R; - }; - (v4: T4): { - (v5: T5, v6: T6, v7: T7): R; - (v5: T5, v6: T6): (v7: T7) => R; - (v5: T5): { - (v6: T6, v7: T7): R; - (v6: T6): (v7: T7) => R; - }; - }; - }; - }; + }; + + + /** + * Transforms a Traversable of Applicative into an Applicative of Traversable. + */ + + // common case of array as traversable: + sequence(f: (v: T) => Applicative, traversable: List>): Applicative>; + // sequence(f: (v: T) => Applicative): (traversable: List>) => Applicative>; // mix + // sequence: CurriedFunction2<(v: T) => Applicative, List>, Applicative>>; + + // general ADT case: + sequence(f: (v: T) => Applicative, traversable: Traversable>): Applicative>; + // sequence(f: (v: T) => Applicative): (traversable: Traversable>) => Applicative>; // mix + // sequence: CurriedFunction2<(v: T) => Applicative, Traversable>, Applicative>>; + + // mixed: + sequence(f: (v: T) => Applicative): { + (traversable: List>): Applicative>; + (traversable: Traversable>): Applicative>; + }; + + + /** + * Returns the result of "setting" the portion of the given data structure focused by the given lens to the + * given value. + */ + // hard to mix cuz different generics + + // // key lens: + // set(lens: KeyLens, a: T[K], obj: T): T; + // set(lens: KeyLens, a: T[K]): (obj: T) => T; + // set(lens: KeyLens): CurriedFunction2; + // // set: CurriedFunction3, T[K], T, T>; + + // regular lenses: + + // // smart approach, unreliable: + // set(lens: Lens, a: U, obj: T): T; + // set(lens: Lens, a: U): (obj: T) => T; + // // set(lens: Lens): (a: U, obj: T) => T; + // set(lens: Lens): CurriedFunction2; + // // set: CurriedFunction3, U, T, T>; + + // // // manually set lens; is this useful? + // // set(lens: ManualLens, a: U, obj: T): T; + // // set(lens: ManualLens, a: U): (obj: T) => T; + // // set(lens: ManualLens): CurriedFunction2; + // // // set: CurriedFunction3, U, T, T>; + + // // assume result type equal to input object: + // set(lens: UnknownLens, a: any, obj: T): T; + // set(lens: UnknownLens, a: any): (obj: T) => T; + // // set(lens: UnknownLens): (a: any, obj: T) => T; + // set(lens: UnknownLens): CurriedFunction2; + // // set: CurriedFunction3; + + // // // old version, with value as an unbound generic; is this useful? + // // set(lens: UnknownLens, a: U, obj: T): T; + // // set(lens: UnknownLens, a: U): (obj: T) => T; + // // set(lens: UnknownLens): CurriedFunction2; + // // // set: CurriedFunction3; + // base + set(lens: Lens, a: U, obj: T): T; + set(lens: Lens, a: U): { + (obj: T): T; + }; + set(lens: Lens): { + (a: U, obj: T): T; + (a: U): { + (obj: T): T; }; - } - interface CurriedFn8 { - (v1: T1, v2: T2, v3: T3, v4: T4, v5: T5, v6: T6, v7: T7, v8: T8): R; - (v1: T1, v2: T2, v3: T3, v4: T4, v5: T5, v6: T6, v7: T7): (v8: T8) => R; - (v1: T1, v2: T2, v3: T3, v4: T4, v5: T5, v6: T6): { - (v7: T7, v8: T8): R; - (v7: T7): (v8: T8) => R; + }; + + // unknow + set(lens: UnknownLens, a: any, obj: T): T; + set(lens: UnknownLens, a: any): { + (obj: T): T; + }; + set(lens: UnknownLens): { + (a: any, obj: T): T; + (a: any): { + (obj: T): T; }; - (v1: T1, v2: T2, v3: T3, v4: T4, v5: T5): { - (v6: T6, v7: T7, v8: T8): R; - (v6: T6, v7: T7): (v8: T8) => R; - (v6: T6): { - (v7: T7, v8: T8): R; - (v7: T7): (v8: T8) => R; - }; + }; + + + /** + * Returns the elements from `xs` starting at `a` and ending at `b - 1`. + */ + // slice>(a: number, b: number, list: T): T; + // slice(a: number, b: number): >(list: T) => T; + // slice>(a: number): CurriedFunction2; + // // slice(a: number): >(b: number, list: T) => T; + // // slice(a: number): >(b: number) => (list: T) => T; + // // slice>: CurriedFunction3; + + // base + slice>(a: number, b: number, list: T): T; + slice(a: number, b: number): { + >(list: T): T; + }; + slice(a: number): { + >(b: number, list: T): T; + (b: number): { + >(list: T): T; }; - (v1: T1, v2: T2, v3: T3, v4: T4): { - (v5: T5, v6: T6, v7: T7, v8: T8): R; - (v5: T5, v6: T6, v7: T7): (v8: T8) => R; - (v5: T5, v6: T6): { - (v7: T7, v8: T8): R; - (v7: T7): (v8: T8) => R; - }; - (v5: T5): { - (v6: T6, v7: T7, v8: T8): R; - (v6: T6, v7: T7): (v8: T8) => R; - (v6: T6): { - (v7: T7, v8: T8): R; - (v7: T7): (v8: T8) => R; - }; - }; + }; + + + /** + * Returns a copy of the list, sorted according to the comparator function, which should accept two values at a + * time and return a negative number if the first value is smaller, a positive number if it's larger, and zero + * if they are equal. + */ + sort(fn: (a: T, b: T) => number, list: List): T[]; + sort(fn: (a: T, b: T) => number): (list: List) => T[]; + // sort: CurriedFunction2<(a: T, b: T) => number, List, T[]>; + + + /** + * Sorts the list according to a key generated by the supplied function. + */ + sortBy(fn: (a: T) => K, list: List): T[]; + sortBy(fn: (a: T) => K): (list: List) => T[]; + // sortBy: CurriedFunction2<(a: T) => K, List, T[]>; + + /** + * Sorts a list according to a list of comparators. + */ + sortWith(comparators: List<(a: T, b: T) => number>, list: List): T[]; + sortWith(comparators: List<(a: T, b: T) => number>): (list: List) => T[]; + // sortWith: CurriedFunction2 number>, List, T[]>; + + /** + * Splits a string into an array of strings based on the given + * separator. + */ + split(sep: RegExp | Prop, str: string): string[]; + split(sep: RegExp | Prop): (str: string) => string[]; + // split: CurriedFunction2; + + /** + * Splits a given list or string at a given index. + */ + // string + splitAt(index: number, list: string): [string, string]; + // splitAt(index: number): (list: string) => [string, string]; + // splitAt: CurriedFunction2; + // array + splitAt(index: number, list: List): T[][]; + // splitAt(index: number): (list: List) => T[][]; + // splitAt: CurriedFunction2, T[][]>; + // mixed + splitAt(index: number): { + (list: string): [string, string]; + (list: List): T[][]; + }; + + /** + * Splits a collection into slices of the specified length. + */ + splitEvery>(a: number, list: R): R[]; + splitEvery(a: number): >(list: R) => R[]; + // splitEvery>: CurriedFunction2; + + /** + * Takes a list and a predicate and returns a pair of lists with the following properties: + * - the result of concatenating the two output lists is equivalent to the input list; + * - none of the elements of the first output list satisfies the predicate; and + * - if the second output list is non-empty, its first element satisfies the predicate. + */ + splitWhen>(pred: Pred, list: R): R[]; + splitWhen(pred: Pred): >(list: R) => R[]; + // splitWhen>: CurriedFunction2, R, R[]>; + + /** + * Subtracts two numbers. Equivalent to `a - b` but curried. + */ + subtract(a: number, b: number): number; + subtract(a: number): (b: number) => number; + // subtract: CurriedFunction2; + + /** + * Adds together all the elements of a list. + */ + sum(list: List): number; + + /** + * Finds the set (i.e. no duplicates) of all elements contained in the first or second list, but not both. + */ + symmetricDifference(list1: List, list2: List): T[]; + symmetricDifference(list: List): (list: List) => T[]; + // symmetricDifference: CurriedFunction2, List, T[]>; + + /** + * Finds the set (i.e. no duplicates) of all elements contained in the first or second list, but not both. + * Duplication is determined according to the value returned by applying the supplied predicate to two list elements. + */ + // symmetricDifferenceWith(pred: (a: T, b: T) => boolean, list1: List, list2: List): T[]; + // symmetricDifferenceWith(pred: (a: T, b: T) => boolean): CurriedFunction2, List, T[]>; + // // symmetricDifferenceWith: CurriedFunction3<(a: T, b: T) => boolean, List, List, T[]>; + + // base + symmetricDifferenceWith(pred: (a: T, b: T) => boolean, list1: List, list2: List): T[]; + symmetricDifferenceWith(pred: (a: T, b: T) => boolean, list1: List): { + (list2: List): T[]; + }; + symmetricDifferenceWith(pred: (a: T, b: T) => boolean): { + (list1: List, list2: List): T[]; + (list1: List): { + (list2: List): T[]; }; - (v1: T1, v2: T2, v3: T3): { - (v4: T4, v5: T5, v6: T6, v7: T7, v8: T8): R; - (v4: T4, v5: T5, v6: T6, v7: T7): (v8: T8) => R; - (v4: T4, v5: T5, v6: T6): { - (v7: T7, v8: T8): R; - (v7: T7): (v8: T8) => R; - }; - (v4: T4, v5: T5): { - (v6: T6, v7: T7, v8: T8): R; - (v6: T6, v7: T7): (v8: T8) => R; - (v6: T6): { - (v7: T7, v8: T8): R; - (v7: T7): (v8: T8) => R; - }; - }; - (v4: T4): { - (v5: T5, v6: T6, v7: T7, v8: T8): R; - (v5: T5, v6: T6, v7: T7): (v8: T8) => R; - (v5: T5, v6: T6): { - (v7: T7, v8: T8): R; - (v7: T7): (v8: T8) => R; - }; - (v5: T5): { - (v6: T6, v7: T7, v8: T8): R; - (v6: T6, v7: T7): (v8: T8) => R; - (v6: T6): { - (v7: T7, v8: T8): R; - (v7: T7): (v8: T8) => R; - }; - }; - }; + }; + + + /** + * A function that always returns true. Any passed in parameters are ignored. + */ + T(): true; + + /** + * Returns all but the first element of a list. + */ + tail>(list: T): T; + + /** + * Returns a new list containing the first `n` elements of the given list. If + * `n > * list.length`, returns a list of `list.length` elements. + */ + take>(n: number, xs: T): T; + take(n: number): >(xs: T) => T; + // take>: CurriedFunction2; + + + /** + * Returns a new list containing the last n elements of the given list. If n > list.length, + * returns a list of list.length elements. + */ + // = take + takeLast>(n: number, xs: T): T; + takeLast(n: number): >(xs: T) => T; + // takeLast>: CurriedFunction2; + + /** + * Returns a new list containing the last n elements of a given list, passing each value + * to the supplied predicate function, and terminating when the predicate function returns + * false. Excludes the element that caused the predicate function to fail. The predicate + * function is passed one argument: (value). + */ + // = takeWhile + takeLastWhile>(pred: Pred, list: R): R; + takeLastWhile(pred: Pred): >(list: R) => R; + // takeLastWhile>: CurriedFunction2, R, R>; + + /** + * Returns a new list containing the first `n` elements of a given list, passing each value + * to the supplied predicate function, and terminating when the predicate function returns + * `false`. + */ + takeWhile>(pred: Pred, list: R): R; + takeWhile(pred: Pred): >(list: R) => R; + // takeWhile>: CurriedFunction2, R, R>; + + /** + * The function to call with x. The return value of fn will be thrown away. + */ + tap(fn: (a: T) => any, value: T): T; + tap(fn: (a: T) => any): (value: T) => T; + // tap: CurriedFunction2<(a: T) => any, T, T>; + + /** + * Determines whether a given string matches a given regular expression. + */ + test(regexp: RegExp, str: Prop): boolean; + test(regexp: RegExp): (str: Prop) => boolean; + // test: CurriedFunction2; + + /** + * Calls an input function `n` times, returning an array containing the results of those + * function calls. + */ + times(fn: (i: number) => T, n: number): T[]; + times(fn: (i: number) => T): (n: number) => T[]; + // times: CurriedFunction2<(i: number) => T, number, T[]>; + + + /** + * The lower case version of a string. + */ + toLower(str: string): string; + + /** + * Converts an object into an array of key, value arrays. + * Only the object's own properties are used. + * Note that the order of the output array is not guaranteed to be + * consistent across different JS platforms. + */ + toPairs(obj: Obj): [string, T][]; + + /** + * Converts an object into an array of key, value arrays. + * The object's own properties and prototype properties are used. + * Note that the order of the output array is not guaranteed to be + * consistent across different JS platforms. + */ + toPairsIn(obj: Obj): [string, T][]; + toPairsIn(obj: Object): [string, any][]; + + /** + * Returns the string representation of the given value. eval'ing the output should + * result in a value equivalent to the input value. Many of the built-in toString + * methods do not satisfy this requirement. + * + * If the given value is an [object Object] with a toString method other than + * Object.prototype.toString, this method is invoked with no arguments to produce the + * return value. This means user-defined constructor functions can provide a suitable + * toString method. + */ + toString(val: StringRepresentable | any): string; + + /** + * The upper case version of a string. + */ + toUpper(str: string): string; + + /** + * Initializes a transducer using supplied iterator function. Returns a single item by iterating through the + * list, successively calling the transformed iterator function and passing it an accumulator value and the + * current value from the array, and then passing the result to the next call. + */ + // transduce(xf: (arg: List) => List, fn: (acc: List, val: U) => List, acc: List, list: List): U; + // transduce(xf: (arg: List) => List, fn: (acc: List, val: U) => List, acc: List): (list: List) => U; + // transduce(xf: (arg: List) => List, fn: (acc: List, val: U) => List): CurriedFunction2,List,U>; + // transduce(xf: (arg: List) => List): CurriedFunction3<(acc: List, val: U) => List,List,List,U>; + // // transduce: CurriedFunction4<(arg: List) => List, (acc: List, val: U) => List, List, List, U>; + + // base + transduce(xf: (arg: List) => List, fn: (acc: List, val: U) => List, acc: List, list: List): U; + transduce(xf: (arg: List) => List, fn: (acc: List, val: U) => List, acc: List): { + (list: List): U; + }; + transduce(xf: (arg: List) => List, fn: (acc: List, val: U) => List): { + (acc: List, list: List): U; + (acc: List): { + (list: List): U; }; - (v1: T1, v2: T2): { - (v3: T3, v4: T4, v5: T5, v6: T6, v7: T7, v8: T8): R; - (v3: T3, v4: T4, v5: T5, v6: T6, v7: T7): (v8: T8) => R; - (v3: T3, v4: T4, v5: T5, v6: T6): { - (v7: T7, v8: T8): R; - (v7: T7): (v8: T8) => R; - }; - (v3: T3, v4: T4, v5: T5): { - (v6: T6, v7: T7, v8: T8): R; - (v6: T6, v7: T7): (v8: T8) => R; - (v6: T6): { - (v7: T7, v8: T8): R; - (v7: T7): (v8: T8) => R; - }; - }; - (v3: T3, v4: T4): { - (v5: T5, v6: T6, v7: T7, v8: T8): R; - (v5: T5, v6: T6, v7: T7): (v8: T8) => R; - (v5: T5, v6: T6): { - (v7: T7, v8: T8): R; - (v7: T7): (v8: T8) => R; - }; - (v5: T5): { - (v6: T6, v7: T7, v8: T8): R; - (v6: T6, v7: T7): (v8: T8) => R; - (v6: T6): { - (v7: T7, v8: T8): R; - (v7: T7): (v8: T8) => R; - }; - }; - }; - (v3: T3): { - (v4: T4, v5: T5, v6: T6, v7: T7, v8: T8): R; - (v4: T4, v5: T5, v6: T6, v7: T7): (v8: T8) => R; - (v4: T4, v5: T5, v6: T6): { - (v7: T7, v8: T8): R; - (v7: T7): (v8: T8) => R; - }; - (v4: T4, v5: T5): { - (v6: T6, v7: T7, v8: T8): R; - (v6: T6, v7: T7): (v8: T8) => R; - (v6: T6): { - (v7: T7, v8: T8): R; - (v7: T7): (v8: T8) => R; - }; - }; - (v4: T4): { - (v5: T5, v6: T6, v7: T7, v8: T8): R; - (v5: T5, v6: T6, v7: T7): (v8: T8) => R; - (v5: T5, v6: T6): { - (v7: T7, v8: T8): R; - (v7: T7): (v8: T8) => R; - }; - (v5: T5): { - (v6: T6, v7: T7, v8: T8): R; - (v6: T6, v7: T7): (v8: T8) => R; - (v6: T6): { - (v7: T7, v8: T8): R; - (v7: T7): (v8: T8) => R; - }; - }; - }; - }; + }; + transduce(xf: (arg: List) => List): { + (fn: (acc: List, val: U) => List, acc: List, list: List): U; + (fn: (acc: List, val: U) => List, acc: List): { + (list: List): U; }; - (v1: T1): { - (v2: T2, v3: T3, v4: T4, v5: T5, v6: T6, v7: T7, v8: T8): R; - (v2: T2, v3: T3, v4: T4, v5: T5, v6: T6, v7: T7): (v8: T8) => R; - (v2: T2, v3: T3, v4: T4, v5: T5, v6: T6): { - (v7: T7, v8: T8): R; - (v7: T7): (v8: T8) => R; - }; - (v2: T2, v3: T3, v4: T4, v5: T5): { - (v6: T6, v7: T7, v8: T8): R; - (v6: T6, v7: T7): (v8: T8) => R; - (v6: T6): { - (v7: T7, v8: T8): R; - (v7: T7): (v8: T8) => R; - }; - }; - (v2: T2, v3: T3, v4: T4): { - (v5: T5, v6: T6, v7: T7, v8: T8): R; - (v5: T5, v6: T6, v7: T7): (v8: T8) => R; - (v5: T5, v6: T6): { - (v7: T7, v8: T8): R; - (v7: T7): (v8: T8) => R; - }; - (v5: T5): { - (v6: T6, v7: T7, v8: T8): R; - (v6: T6, v7: T7): (v8: T8) => R; - (v6: T6): { - (v7: T7, v8: T8): R; - (v7: T7): (v8: T8) => R; - }; - }; - }; - (v2: T2, v3: T3): { - (v4: T4, v5: T5, v6: T6, v7: T7, v8: T8): R; - (v4: T4, v5: T5, v6: T6, v7: T7): (v8: T8) => R; - (v4: T4, v5: T5, v6: T6): { - (v7: T7, v8: T8): R; - (v7: T7): (v8: T8) => R; - }; - (v4: T4, v5: T5): { - (v6: T6, v7: T7, v8: T8): R; - (v6: T6, v7: T7): (v8: T8) => R; - (v6: T6): { - (v7: T7, v8: T8): R; - (v7: T7): (v8: T8) => R; - }; - }; - (v4: T4): { - (v5: T5, v6: T6, v7: T7, v8: T8): R; - (v5: T5, v6: T6, v7: T7): (v8: T8) => R; - (v5: T5, v6: T6): { - (v7: T7, v8: T8): R; - (v7: T7): (v8: T8) => R; - }; - (v5: T5): { - (v6: T6, v7: T7, v8: T8): R; - (v6: T6, v7: T7): (v8: T8) => R; - (v6: T6): { - (v7: T7, v8: T8): R; - (v7: T7): (v8: T8) => R; - }; - }; - }; - }; - (v2: T2): { - (v3: T3, v4: T4, v5: T5, v6: T6, v7: T7, v8: T8): R; - (v3: T3, v4: T4, v5: T5, v6: T6, v7: T7): (v8: T8) => R; - (v3: T3, v4: T4, v5: T5, v6: T6): { - (v7: T7, v8: T8): R; - (v7: T7): (v8: T8) => R; - }; - (v3: T3, v4: T4, v5: T5): { - (v6: T6, v7: T7, v8: T8): R; - (v6: T6, v7: T7): (v8: T8) => R; - (v6: T6): { - (v7: T7, v8: T8): R; - (v7: T7): (v8: T8) => R; - }; - }; - (v3: T3, v4: T4): { - (v5: T5, v6: T6, v7: T7, v8: T8): R; - (v5: T5, v6: T6, v7: T7): (v8: T8) => R; - (v5: T5, v6: T6): { - (v7: T7, v8: T8): R; - (v7: T7): (v8: T8) => R; - }; - (v5: T5): { - (v6: T6, v7: T7, v8: T8): R; - (v6: T6, v7: T7): (v8: T8) => R; - (v6: T6): { - (v7: T7, v8: T8): R; - (v7: T7): (v8: T8) => R; - }; - }; - }; - (v3: T3): { - (v4: T4, v5: T5, v6: T6, v7: T7, v8: T8): R; - (v4: T4, v5: T5, v6: T6, v7: T7): (v8: T8) => R; - (v4: T4, v5: T5, v6: T6): { - (v7: T7, v8: T8): R; - (v7: T7): (v8: T8) => R; - }; - (v4: T4, v5: T5): { - (v6: T6, v7: T7, v8: T8): R; - (v6: T6, v7: T7): (v8: T8) => R; - (v6: T6): { - (v7: T7, v8: T8): R; - (v7: T7): (v8: T8) => R; - }; - }; - (v4: T4): { - (v5: T5, v6: T6, v7: T7, v8: T8): R; - (v5: T5, v6: T6, v7: T7): (v8: T8) => R; - (v5: T5, v6: T6): { - (v7: T7, v8: T8): R; - (v7: T7): (v8: T8) => R; - }; - (v5: T5): { - (v6: T6, v7: T7, v8: T8): R; - (v6: T6, v7: T7): (v8: T8) => R; - (v6: T6): { - (v7: T7, v8: T8): R; - (v7: T7): (v8: T8) => R; - }; - }; - }; - }; + (fn: (acc: List, val: U) => List): { + (acc: List, list: List): U; + (acc: List): { + (list: List): U; }; }; - } - interface CurriedFn9 { - (v1: T1, v2: T2, v3: T3, v4: T4, v5: T5, v6: T6, v7: T7, v8: T8, v9: T9): R; - (v1: T1, v2: T2, v3: T3, v4: T4, v5: T5, v6: T6, v7: T7, v8: T8): (v9: T9) => R; - (v1: T1, v2: T2, v3: T3, v4: T4, v5: T5, v6: T6, v7: T7): { - (v8: T8, v9: T9): R; - (v8: T8): (v9: T9) => R; + }; + + + /** + * Transposes the rows and columns of a 2D list. When passed a list of n lists of length x, returns a list of x lists of length n. + */ + transpose(list: List>): T[][]; + transpose(list: List>): any[][]; + + /** + * Maps an Applicative-returning function over a Traversable, then uses + * `sequence` to transform the resulting Traversable of Applicative into + * an Applicative of Traversable. + */ + + // // common case of array as traversable: + // traverse(ap: (v: T) => Applicative, fn: (v: T) => Applicative, traversable: List): Applicative>; + // // traverse(ap: (v: T) => Applicative, fn: (v: T) => Applicative): (traversable: List) => Applicative>; // mix + // traverse(ap: (v: T) => Applicative): CurriedFunction2<(v: T) => Applicative, List, Applicative>>; + // // traverse: CurriedFunction3<(v: T) => Applicative, (v: T) => Applicative, List, Applicative>>; + + // // general ADT case: + // traverse(ap: (v: T) => Applicative, fn: (v: T) => Applicative, traversable: Traversable): Applicative>; + // // traverse(ap: (v: T) => Applicative, fn: (v: T) => Applicative): (traversable: Traversable) => Applicative>; // mix + // traverse(ap: (v: T) => Applicative): CurriedFunction2<(v: T) => Applicative, Traversable, Applicative>>; + // // traverse: CurriedFunction3<(v: T) => Applicative, (v: T) => Applicative, Traversable, Applicative>>; + + // // mixed: + // traverse(ap: (v: T) => Applicative, fn: (v: T) => Applicative): { + // (traversable: List): Applicative>; + // (traversable: Traversable): Applicative>; + // }; + + // base + traverse(ap: (v: T) => Applicative, fn: (v: T) => Applicative, traversable: List): Applicative>; + traverse(ap: (v: T) => Applicative, fn: (v: T) => Applicative): { + (traversable: List): Applicative>; + }; + traverse(ap: (v: T) => Applicative): { + (fn: (v: T) => Applicative, traversable: List): Applicative>; + (fn: (v: T) => Applicative): { + (traversable: List): Applicative>; }; - (v1: T1, v2: T2, v3: T3, v4: T4, v5: T5, v6: T6): { - (v7: T7, v8: T8, v9: T9): R; - (v7: T7, v8: T8): (v9: T9) => R; - (v7: T7): { - (v8: T8, v9: T9): R; - (v8: T8): (v9: T9) => R; - }; + }; + + // general ADT case + traverse(ap: (v: T) => Applicative, fn: (v: T) => Applicative, traversable: List): Applicative>; + traverse(ap: (v: T) => Applicative, fn: (v: T) => Applicative): { + (traversable: List): Applicative>; + }; + traverse(ap: (v: T) => Applicative): { + (fn: (v: T) => Applicative, traversable: List): Applicative>; + (fn: (v: T) => Applicative): { + (traversable: List): Applicative>; }; - (v1: T1, v2: T2, v3: T3, v4: T4, v5: T5): { - (v6: T6, v7: T7, v8: T8, v9: T9): R; - (v6: T6, v7: T7, v8: T8): (v9: T9) => R; - (v6: T6, v7: T7): { - (v8: T8, v9: T9): R; - (v8: T8): (v9: T9) => R; - }; - (v6: T6): { - (v7: T7, v8: T8, v9: T9): R; - (v7: T7, v8: T8): (v9: T9) => R; - (v7: T7): { - (v8: T8, v9: T9): R; - (v8: T8): (v9: T9) => R; - }; - }; + }; + + + /** + * Removes (strips) whitespace from both ends of the string. + */ + trim(str: string): string; + + /** + * tryCatch takes two functions, a tryer and a catcher. The returned function evaluates the tryer; if it does + * not throw, it simply returns the result. If the tryer does throw, the returned function evaluates the catcher + * function and returns its result. Note that for effective composition with this function, both the tryer and + * catcher functions must return the same type of results. + */ + tryCatch(tryer: Variadic, catcher: Variadic): Variadic; + // tryCatch: CurriedFunction2, Variadic, Variadic>; + + /** + * Gives a single-word string description of the (native) type of a value, returning such answers as 'Object', + * 'Number', 'Array', or 'Null'. Does not attempt to distinguish user Object types any further, reporting them + * all as 'Object'. + */ + type(val: any): string; + + /** + * Takes a function fn, which takes a single array argument, and returns a function which: + * - takes any number of positional arguments; + * - passes these arguments to fn as an array; and + * - returns the result. + * In other words, R.unapply derives a variadic function from a function which takes an array. + * R.unapply is the inverse of R.apply. + */ + unapply(fn: (args: any[]) => T): Variadic; + + /** + * Wraps a function of any arity (including nullary) in a function that accepts exactly 1 parameter. + * Any extraneous parameters will not be passed to the supplied function. + */ + unary(fn: (a: T, ...args: any[]) => U): (a: T) => U; + + /** + * Returns a function of arity n from a (manually) curried function. + */ + uncurryN(len: number, fn: (a: any) => any): Variadic; + // uncurryN: CurriedFunction2 any, Variadic>; + + /** + * Builds a list from a seed value. Accepts an iterator function, which returns either false + * to stop iteration or an array of length 2 containing the value to add to the resulting + * list and the seed to be used in the next call to the iterator function. + */ + unfold(fn: (seed: T) => [TResult, T] | false, seed: T): TResult[]; + unfold(fn: (seed: T) => [TResult, T] | false): (seed: T) => TResult[]; + // unfold: CurriedFunction2<(seed: T) => TResult[]|boolean, T, TResult[]>; + + /** + * Combines two lists into a set (i.e. no duplicates) composed of the + * elements of each list. + */ + union(as: List, bs: List): T[]; + union(as: List): (bs: List) => T[]; + // union: CurriedFunction2, List, T[]>; + + /** + * Combines two lists into a set (i.e. no duplicates) composed of the elements of each list. Duplication is + * determined according to the value returned by applying the supplied predicate to two list elements. + */ + // unionWith(pred: (a: T, b: T) => boolean, list1: List, list2: List): T[]; + // unionWith(pred: (a: T, b: T) => boolean, list1: List): (list2: List) => T[]; + // unionWith(pred: (a: T, b: T) => boolean): CurriedFunction2, List, T[]>; + // // unionWith: CurriedFunction3<(a: T, b: T) => boolean, List, List, T[]>; + + // base + unionWith(pred: (a: T, b: T) => boolean, list1: List, list2: List): T[]; + unionWith(pred: (a: T, b: T) => boolean, list1: List): { + (list2: List): T[]; + }; + unionWith(pred: (a: T, b: T) => boolean): { + (list1: List, list2: List): T[]; + (list1: List): { + (list2: List): T[]; }; - (v1: T1, v2: T2, v3: T3, v4: T4): { - (v5: T5, v6: T6, v7: T7, v8: T8, v9: T9): R; - (v5: T5, v6: T6, v7: T7, v8: T8): (v9: T9) => R; - (v5: T5, v6: T6, v7: T7): { - (v8: T8, v9: T9): R; - (v8: T8): (v9: T9) => R; - }; - (v5: T5, v6: T6): { - (v7: T7, v8: T8, v9: T9): R; - (v7: T7, v8: T8): (v9: T9) => R; - (v7: T7): { - (v8: T8, v9: T9): R; - (v8: T8): (v9: T9) => R; - }; - }; - (v5: T5): { - (v6: T6, v7: T7, v8: T8, v9: T9): R; - (v6: T6, v7: T7, v8: T8): (v9: T9) => R; - (v6: T6, v7: T7): { - (v8: T8, v9: T9): R; - (v8: T8): (v9: T9) => R; - }; - (v6: T6): { - (v7: T7, v8: T8, v9: T9): R; - (v7: T7, v8: T8): (v9: T9) => R; - (v7: T7): { - (v8: T8, v9: T9): R; - (v8: T8): (v9: T9) => R; - }; - }; - }; + }; + + + /** + * Returns a new list containing only one copy of each element in the original list. + */ + uniq(list: List): T[]; + + /** + * Returns a new list containing only one copy of each element in the original list, based upon the value returned by applying the supplied function to each list element. Prefers the first item if the supplied function produces the same value on two items. R.equals is used for comparison. + */ + uniqBy(fn: (a: T) => U, list: List): T[]; + uniqBy(fn: (a: T) => U): (list: List) => T[]; + // uniqBy: CurriedFunction2<(a: T) => U, List, T[]>; + + /** + * Returns a new list containing only one copy of each element in the original list, based upon the value + * returned by applying the supplied predicate to two list elements. + */ + uniqWith(pred: (x: T, y: T) => boolean, list: List): T[]; + uniqWith(pred: (x: T, y: T) => boolean): (list: List) => T[]; + // uniqWith: CurriedFunction2<(x: T, y: T) => boolean, List, T[]>; + + /** + * Tests the final argument by passing it to the given predicate function. If the predicate is not satisfied, + * the function will return the result of calling the whenFalseFn function with the same argument. If the + * predicate is satisfied, the argument is returned as is. + */ + unless(pred: Pred, whenFalseFn: (a: T) => U, obj: T): U; + unless(pred: Pred, whenFalseFn: (a: T) => U): (obj: T) => U; + // unless: CurriedFunction3, (a: T) => U, T, U>; + + /** + * Returns a new list by pulling every item at the first level of nesting out, and putting + * them in a new array. + */ + unnest(x: List>): T[]; + unnest(x: List): T[]; + + /** + * Takes a predicate, a transformation function, and an initial value, and returns a value of the same type as + * the initial value. It does so by applying the transformation until the predicate is satisfied, at which point + * it returns the satisfactory value. + */ + // until(pred: Pred, fn: (val: T) => U, init: U): U; + // until(pred: Pred, fn: (val: T) => U): (init: U) => U; + // until(pred: Pred): CurriedFunction2<(val: T) => U, U, U>; + // // until: CurriedFunction3, (val: T) => U, U, U>; + + // base + until(pred: Pred, fn: (val: T) => U, init: U): U; + until(pred: Pred, fn: (val: T) => U): { + (init: U): U; + }; + until(pred: Pred): { + (fn: (val: T) => U, init: U): U; + (fn: (val: T) => U): { + (init: U): U; }; - (v1: T1, v2: T2, v3: T3): { - (v4: T4, v5: T5, v6: T6, v7: T7, v8: T8, v9: T9): R; - (v4: T4, v5: T5, v6: T6, v7: T7, v8: T8): (v9: T9) => R; - (v4: T4, v5: T5, v6: T6, v7: T7): { - (v8: T8, v9: T9): R; - (v8: T8): (v9: T9) => R; - }; - (v4: T4, v5: T5, v6: T6): { - (v7: T7, v8: T8, v9: T9): R; - (v7: T7, v8: T8): (v9: T9) => R; - (v7: T7): { - (v8: T8, v9: T9): R; - (v8: T8): (v9: T9) => R; - }; - }; - (v4: T4, v5: T5): { - (v6: T6, v7: T7, v8: T8, v9: T9): R; - (v6: T6, v7: T7, v8: T8): (v9: T9) => R; - (v6: T6, v7: T7): { - (v8: T8, v9: T9): R; - (v8: T8): (v9: T9) => R; - }; - (v6: T6): { - (v7: T7, v8: T8, v9: T9): R; - (v7: T7, v8: T8): (v9: T9) => R; - (v7: T7): { - (v8: T8, v9: T9): R; - (v8: T8): (v9: T9) => R; - }; - }; - }; - (v4: T4): { - (v5: T5, v6: T6, v7: T7, v8: T8, v9: T9): R; - (v5: T5, v6: T6, v7: T7, v8: T8): (v9: T9) => R; - (v5: T5, v6: T6, v7: T7): { - (v8: T8, v9: T9): R; - (v8: T8): (v9: T9) => R; - }; - (v5: T5, v6: T6): { - (v7: T7, v8: T8, v9: T9): R; - (v7: T7, v8: T8): (v9: T9) => R; - (v7: T7): { - (v8: T8, v9: T9): R; - (v8: T8): (v9: T9) => R; - }; - }; - (v5: T5): { - (v6: T6, v7: T7, v8: T8, v9: T9): R; - (v6: T6, v7: T7, v8: T8): (v9: T9) => R; - (v6: T6, v7: T7): { - (v8: T8, v9: T9): R; - (v8: T8): (v9: T9) => R; - }; - (v6: T6): { - (v7: T7, v8: T8, v9: T9): R; - (v7: T7, v8: T8): (v9: T9) => R; - (v7: T7): { - (v8: T8, v9: T9): R; - (v8: T8): (v9: T9) => R; - }; - }; - }; - }; + }; + + + /** + * Returns a new copy of the array with the element at the provided index replaced with the given value. + */ + // update(index: number, value: T, list: List): T[]; + // update(index: number, value: T): (list: List) => T[]; + // update(index: number): CurriedFunction2,T[]>; + // // update: CurriedFunction3, T[]>; + + // base + update(index: number, value: T, list: List): T[]; + update(index: number, value: T): { + (list: List): T[]; + }; + update(index: number): { + (value: T, list: List): T[]; + (value: T): { + (list: List): T[]; }; - (v1: T1, v2: T2): { - (v3: T3, v4: T4, v5: T5, v6: T6, v7: T7, v8: T8, v9: T9): R; - (v3: T3, v4: T4, v5: T5, v6: T6, v7: T7, v8: T8): (v9: T9) => R; - (v3: T3, v4: T4, v5: T5, v6: T6, v7: T7): { - (v8: T8, v9: T9): R; - (v8: T8): (v9: T9) => R; - }; - (v3: T3, v4: T4, v5: T5, v6: T6): { - (v7: T7, v8: T8, v9: T9): R; - (v7: T7, v8: T8): (v9: T9) => R; - (v7: T7): { - (v8: T8, v9: T9): R; - (v8: T8): (v9: T9) => R; - }; - }; - (v3: T3, v4: T4, v5: T5): { - (v6: T6, v7: T7, v8: T8, v9: T9): R; - (v6: T6, v7: T7, v8: T8): (v9: T9) => R; - (v6: T6, v7: T7): { - (v8: T8, v9: T9): R; - (v8: T8): (v9: T9) => R; - }; - (v6: T6): { - (v7: T7, v8: T8, v9: T9): R; - (v7: T7, v8: T8): (v9: T9) => R; - (v7: T7): { - (v8: T8, v9: T9): R; - (v8: T8): (v9: T9) => R; - }; - }; - }; - (v3: T3, v4: T4): { - (v5: T5, v6: T6, v7: T7, v8: T8, v9: T9): R; - (v5: T5, v6: T6, v7: T7, v8: T8): (v9: T9) => R; - (v5: T5, v6: T6, v7: T7): { - (v8: T8, v9: T9): R; - (v8: T8): (v9: T9) => R; - }; - (v5: T5, v6: T6): { - (v7: T7, v8: T8, v9: T9): R; - (v7: T7, v8: T8): (v9: T9) => R; - (v7: T7): { - (v8: T8, v9: T9): R; - (v8: T8): (v9: T9) => R; - }; - }; - (v5: T5): { - (v6: T6, v7: T7, v8: T8, v9: T9): R; - (v6: T6, v7: T7, v8: T8): (v9: T9) => R; - (v6: T6, v7: T7): { - (v8: T8, v9: T9): R; - (v8: T8): (v9: T9) => R; - }; - (v6: T6): { - (v7: T7, v8: T8, v9: T9): R; - (v7: T7, v8: T8): (v9: T9) => R; - (v7: T7): { - (v8: T8, v9: T9): R; - (v8: T8): (v9: T9) => R; - }; - }; - }; - }; - (v3: T3): { - (v4: T4, v5: T5, v6: T6, v7: T7, v8: T8, v9: T9): R; - (v4: T4, v5: T5, v6: T6, v7: T7, v8: T8): (v9: T9) => R; - (v4: T4, v5: T5, v6: T6, v7: T7): { - (v8: T8, v9: T9): R; - (v8: T8): (v9: T9) => R; - }; - (v4: T4, v5: T5, v6: T6): { - (v7: T7, v8: T8, v9: T9): R; - (v7: T7, v8: T8): (v9: T9) => R; - (v7: T7): { - (v8: T8, v9: T9): R; - (v8: T8): (v9: T9) => R; - }; - }; - (v4: T4, v5: T5): { - (v6: T6, v7: T7, v8: T8, v9: T9): R; - (v6: T6, v7: T7, v8: T8): (v9: T9) => R; - (v6: T6, v7: T7): { - (v8: T8, v9: T9): R; - (v8: T8): (v9: T9) => R; - }; - (v6: T6): { - (v7: T7, v8: T8, v9: T9): R; - (v7: T7, v8: T8): (v9: T9) => R; - (v7: T7): { - (v8: T8, v9: T9): R; - (v8: T8): (v9: T9) => R; - }; - }; - }; - (v4: T4): { - (v5: T5, v6: T6, v7: T7, v8: T8, v9: T9): R; - (v5: T5, v6: T6, v7: T7, v8: T8): (v9: T9) => R; - (v5: T5, v6: T6, v7: T7): { - (v8: T8, v9: T9): R; - (v8: T8): (v9: T9) => R; - }; - (v5: T5, v6: T6): { - (v7: T7, v8: T8, v9: T9): R; - (v7: T7, v8: T8): (v9: T9) => R; - (v7: T7): { - (v8: T8, v9: T9): R; - (v8: T8): (v9: T9) => R; - }; - }; - (v5: T5): { - (v6: T6, v7: T7, v8: T8, v9: T9): R; - (v6: T6, v7: T7, v8: T8): (v9: T9) => R; - (v6: T6, v7: T7): { - (v8: T8, v9: T9): R; - (v8: T8): (v9: T9) => R; - }; - (v6: T6): { - (v7: T7, v8: T8, v9: T9): R; - (v7: T7, v8: T8): (v9: T9) => R; - (v7: T7): { - (v8: T8, v9: T9): R; - (v8: T8): (v9: T9) => R; - }; - }; - }; - }; - }; + }; + + + /** + * Accepts a function fn and a list of transformer functions and returns a new curried function. + * When the new function is invoked, it calls the function fn with parameters consisting of the + * result of calling each supplied handler on successive arguments to the new function. + * + * If more arguments are passed to the returned function than transformer functions, those arguments + * are passed directly to fn as additional parameters. If you expect additional arguments that don't + * need to be transformed, although you can ignore them, it's best to pass an identity function so + * that the new function reports the correct arity. + */ + useWith(fn: Variadic, transformers: List): Variadic; + useWith(fn: Variadic): (transformers: List) => Variadic; + // useWith: CurriedFunction2, List, Variadic>; + + /** + * Returns a list of all the enumerable own properties of the supplied object. + * Note that the order of the output array is not guaranteed across + * different JS platforms. + */ + values(obj: Struct): T[]; + values(obj: Object): any[]; + + /** + * Returns a list of all the properties, including prototype properties, of the supplied + * object. Note that the order of the output array is not guaranteed to be consistent across different JS platforms. + */ + valuesIn(obj: Struct): T[]; + valuesIn(obj: Object): any[]; + + /** + * Returns a "view" of the given data structure, determined by the given lens. The lens's focus determines which + * portion of the data structure is visible. + */ + // hard to mix cuz different generics + + // // key lens: + // view(lens: KeyLens, obj: T): T[K]; + // view(lens: KeyLens): (obj: T) => T[K]; + // // view: CurriedFunction2, T, T[K]>; + + // regular lenses: + + // smart approach, unreliable: + view(lens: Lens, obj: T): U; + view(lens: Lens): (obj: T) => U; + // view: CurriedFunction2, T, U>; + + // lens with type manually set + view(lens: ManualLens, obj: Struct): T; + view(lens: ManualLens): (obj: Struct) => T; + // view: CurriedFunction2, Struct, T>; + + // unknown lens, manually supply return type. does this add to the above case? + view(lens: UnknownLens, obj: Struct): T; + view(lens: UnknownLens): (obj: Struct) => T; + // view: CurriedFunction2, T>; + + /** + * Tests the final argument by passing it to the given predicate function. If the predicate is satisfied, the function + * will return the result of calling the whenTrueFn function with the same argument. If the predicate is not satisfied, + * the argument is returned as is. + */ + // when(pred: Pred, whenTrueFn: (a: T) => U, obj: T): U; + // when(pred: Pred, whenTrueFn: (a: T) => U): (obj: T) => U; + // when(pred: Pred): CurriedFunction2<(a: T) => U, T, U>; + // // when: CurriedFunction3, (a: T) => U, T, U>; + + // base + when(pred: Pred, whenTrueFn: (a: T) => U, obj: T): U; + when(pred: Pred, whenTrueFn: (a: T) => U): { + (obj: T): U; + }; + when(pred: Pred): { + (whenTrueFn: (a: T) => U, obj: T): U; + (whenTrueFn: (a: T) => U): { + (obj: T): U; }; - (v1: T1): { - (v2: T2, v3: T3, v4: T4, v5: T5, v6: T6, v7: T7, v8: T8, v9: T9): R; - (v2: T2, v3: T3, v4: T4, v5: T5, v6: T6, v7: T7, v8: T8): (v9: T9) => R; - (v2: T2, v3: T3, v4: T4, v5: T5, v6: T6, v7: T7): { - (v8: T8, v9: T9): R; - (v8: T8): (v9: T9) => R; - }; - (v2: T2, v3: T3, v4: T4, v5: T5, v6: T6): { - (v7: T7, v8: T8, v9: T9): R; - (v7: T7, v8: T8): (v9: T9) => R; - (v7: T7): { - (v8: T8, v9: T9): R; - (v8: T8): (v9: T9) => R; - }; - }; - (v2: T2, v3: T3, v4: T4, v5: T5): { - (v6: T6, v7: T7, v8: T8, v9: T9): R; - (v6: T6, v7: T7, v8: T8): (v9: T9) => R; - (v6: T6, v7: T7): { - (v8: T8, v9: T9): R; - (v8: T8): (v9: T9) => R; - }; - (v6: T6): { - (v7: T7, v8: T8, v9: T9): R; - (v7: T7, v8: T8): (v9: T9) => R; - (v7: T7): { - (v8: T8, v9: T9): R; - (v8: T8): (v9: T9) => R; - }; - }; - }; - (v2: T2, v3: T3, v4: T4): { - (v5: T5, v6: T6, v7: T7, v8: T8, v9: T9): R; - (v5: T5, v6: T6, v7: T7, v8: T8): (v9: T9) => R; - (v5: T5, v6: T6, v7: T7): { - (v8: T8, v9: T9): R; - (v8: T8): (v9: T9) => R; - }; - (v5: T5, v6: T6): { - (v7: T7, v8: T8, v9: T9): R; - (v7: T7, v8: T8): (v9: T9) => R; - (v7: T7): { - (v8: T8, v9: T9): R; - (v8: T8): (v9: T9) => R; - }; - }; - (v5: T5): { - (v6: T6, v7: T7, v8: T8, v9: T9): R; - (v6: T6, v7: T7, v8: T8): (v9: T9) => R; - (v6: T6, v7: T7): { - (v8: T8, v9: T9): R; - (v8: T8): (v9: T9) => R; - }; - (v6: T6): { - (v7: T7, v8: T8, v9: T9): R; - (v7: T7, v8: T8): (v9: T9) => R; - (v7: T7): { - (v8: T8, v9: T9): R; - (v8: T8): (v9: T9) => R; - }; - }; - }; - }; - (v2: T2, v3: T3): { - (v4: T4, v5: T5, v6: T6, v7: T7, v8: T8, v9: T9): R; - (v4: T4, v5: T5, v6: T6, v7: T7, v8: T8): (v9: T9) => R; - (v4: T4, v5: T5, v6: T6, v7: T7): { - (v8: T8, v9: T9): R; - (v8: T8): (v9: T9) => R; - }; - (v4: T4, v5: T5, v6: T6): { - (v7: T7, v8: T8, v9: T9): R; - (v7: T7, v8: T8): (v9: T9) => R; - (v7: T7): { - (v8: T8, v9: T9): R; - (v8: T8): (v9: T9) => R; - }; - }; - (v4: T4, v5: T5): { - (v6: T6, v7: T7, v8: T8, v9: T9): R; - (v6: T6, v7: T7, v8: T8): (v9: T9) => R; - (v6: T6, v7: T7): { - (v8: T8, v9: T9): R; - (v8: T8): (v9: T9) => R; - }; - (v6: T6): { - (v7: T7, v8: T8, v9: T9): R; - (v7: T7, v8: T8): (v9: T9) => R; - (v7: T7): { - (v8: T8, v9: T9): R; - (v8: T8): (v9: T9) => R; - }; - }; - }; - (v4: T4): { - (v5: T5, v6: T6, v7: T7, v8: T8, v9: T9): R; - (v5: T5, v6: T6, v7: T7, v8: T8): (v9: T9) => R; - (v5: T5, v6: T6, v7: T7): { - (v8: T8, v9: T9): R; - (v8: T8): (v9: T9) => R; - }; - (v5: T5, v6: T6): { - (v7: T7, v8: T8, v9: T9): R; - (v7: T7, v8: T8): (v9: T9) => R; - (v7: T7): { - (v8: T8, v9: T9): R; - (v8: T8): (v9: T9) => R; - }; - }; - (v5: T5): { - (v6: T6, v7: T7, v8: T8, v9: T9): R; - (v6: T6, v7: T7, v8: T8): (v9: T9) => R; - (v6: T6, v7: T7): { - (v8: T8, v9: T9): R; - (v8: T8): (v9: T9) => R; - }; - (v6: T6): { - (v7: T7, v8: T8, v9: T9): R; - (v7: T7, v8: T8): (v9: T9) => R; - (v7: T7): { - (v8: T8, v9: T9): R; - (v8: T8): (v9: T9) => R; - }; - }; - }; - }; - }; - (v2: T2): { - (v3: T3, v4: T4, v5: T5, v6: T6, v7: T7, v8: T8, v9: T9): R; - (v3: T3, v4: T4, v5: T5, v6: T6, v7: T7, v8: T8): (v9: T9) => R; - (v3: T3, v4: T4, v5: T5, v6: T6, v7: T7): { - (v8: T8, v9: T9): R; - (v8: T8): (v9: T9) => R; - }; - (v3: T3, v4: T4, v5: T5, v6: T6): { - (v7: T7, v8: T8, v9: T9): R; - (v7: T7, v8: T8): (v9: T9) => R; - (v7: T7): { - (v8: T8, v9: T9): R; - (v8: T8): (v9: T9) => R; - }; - }; - (v3: T3, v4: T4, v5: T5): { - (v6: T6, v7: T7, v8: T8, v9: T9): R; - (v6: T6, v7: T7, v8: T8): (v9: T9) => R; - (v6: T6, v7: T7): { - (v8: T8, v9: T9): R; - (v8: T8): (v9: T9) => R; - }; - (v6: T6): { - (v7: T7, v8: T8, v9: T9): R; - (v7: T7, v8: T8): (v9: T9) => R; - (v7: T7): { - (v8: T8, v9: T9): R; - (v8: T8): (v9: T9) => R; - }; - }; - }; - (v3: T3, v4: T4): { - (v5: T5, v6: T6, v7: T7, v8: T8, v9: T9): R; - (v5: T5, v6: T6, v7: T7, v8: T8): (v9: T9) => R; - (v5: T5, v6: T6, v7: T7): { - (v8: T8, v9: T9): R; - (v8: T8): (v9: T9) => R; - }; - (v5: T5, v6: T6): { - (v7: T7, v8: T8, v9: T9): R; - (v7: T7, v8: T8): (v9: T9) => R; - (v7: T7): { - (v8: T8, v9: T9): R; - (v8: T8): (v9: T9) => R; - }; - }; - (v5: T5): { - (v6: T6, v7: T7, v8: T8, v9: T9): R; - (v6: T6, v7: T7, v8: T8): (v9: T9) => R; - (v6: T6, v7: T7): { - (v8: T8, v9: T9): R; - (v8: T8): (v9: T9) => R; - }; - (v6: T6): { - (v7: T7, v8: T8, v9: T9): R; - (v7: T7, v8: T8): (v9: T9) => R; - (v7: T7): { - (v8: T8, v9: T9): R; - (v8: T8): (v9: T9) => R; - }; - }; - }; - }; - (v3: T3): { - (v4: T4, v5: T5, v6: T6, v7: T7, v8: T8, v9: T9): R; - (v4: T4, v5: T5, v6: T6, v7: T7, v8: T8): (v9: T9) => R; - (v4: T4, v5: T5, v6: T6, v7: T7): { - (v8: T8, v9: T9): R; - (v8: T8): (v9: T9) => R; - }; - (v4: T4, v5: T5, v6: T6): { - (v7: T7, v8: T8, v9: T9): R; - (v7: T7, v8: T8): (v9: T9) => R; - (v7: T7): { - (v8: T8, v9: T9): R; - (v8: T8): (v9: T9) => R; - }; - }; - (v4: T4, v5: T5): { - (v6: T6, v7: T7, v8: T8, v9: T9): R; - (v6: T6, v7: T7, v8: T8): (v9: T9) => R; - (v6: T6, v7: T7): { - (v8: T8, v9: T9): R; - (v8: T8): (v9: T9) => R; - }; - (v6: T6): { - (v7: T7, v8: T8, v9: T9): R; - (v7: T7, v8: T8): (v9: T9) => R; - (v7: T7): { - (v8: T8, v9: T9): R; - (v8: T8): (v9: T9) => R; - }; - }; - }; - (v4: T4): { - (v5: T5, v6: T6, v7: T7, v8: T8, v9: T9): R; - (v5: T5, v6: T6, v7: T7, v8: T8): (v9: T9) => R; - (v5: T5, v6: T6, v7: T7): { - (v8: T8, v9: T9): R; - (v8: T8): (v9: T9) => R; - }; - (v5: T5, v6: T6): { - (v7: T7, v8: T8, v9: T9): R; - (v7: T7, v8: T8): (v9: T9) => R; - (v7: T7): { - (v8: T8, v9: T9): R; - (v8: T8): (v9: T9) => R; - }; - }; - (v5: T5): { - (v6: T6, v7: T7, v8: T8, v9: T9): R; - (v6: T6, v7: T7, v8: T8): (v9: T9) => R; - (v6: T6, v7: T7): { - (v8: T8, v9: T9): R; - (v8: T8): (v9: T9) => R; - }; - (v6: T6): { - (v7: T7, v8: T8, v9: T9): R; - (v7: T7, v8: T8): (v9: T9) => R; - (v7: T7): { - (v8: T8, v9: T9): R; - (v8: T8): (v9: T9) => R; - }; - }; - }; - }; - }; - }; - }; - } - - interface Reduced {} - - interface Static { - - /** - * A special placeholder value used to specify "gaps" within curried - * functions, allowing partial application of any combination of - * arguments, regardless of their positions. - * NOTE: can't type this yet, for binary functions consider R.flip! - */ - __: any; // { "@@functional/placeholder": boolean }; - // ^ don't type by value, since it can be inserted anywhere... - // Note this is still not useful, as it doesn't take into account how it changes formulas (leaving holes!). - // This remains TODO, and should be done on the level of curried functions, but that - // pretty much requires being able to express the separate functions as a single curried function... - // until that moment handling this would mean having to handle each possible combination for each function. :( - - /** - * Adds two numbers. Equivalent to a + b but curried. - */ - add(a: number, b: number): number; - add(a: number): (b: number) => number; - // add: CurriedFunction2; - - /** - * Creates a new list iteration function from an existing one by adding two new parameters to its callback - * function: the current index, and the entire list. - */ - addIndex(fn: (f: (item: T) => U, list: List) => U[]): CurriedFunction2<(item: T, idx: number, list?: List) => U, List, U[]>; - /* Special case for forEach */ - addIndex(fn: (f: (item: T) => void, list: List) => T[]): CurriedFunction2<(item: T, idx: number, list?: List) => void, List, T[]>; - /* Special case for reduce */ - addIndex(fn: (f: (acc:U, item: T) => U, aci:U, list: List) => U): CurriedFunction3<(acc:U, item: T, idx: number, list?: List) => U, U, List, U>; - // addIndex: CurriedFunction3<(f: (item: T) => U, list: List) => U[], (item: T, idx: number, list?: List) => U, List, U[]>; - - /** - * Applies a function to the value at the given index of an array, returning a new copy of the array with the - * element at the given index replaced with the result of the function application. - */ - // adjust(fn: (a: T) => T, index: number, list: List): T[]; - // adjust(fn: (a: T) => T, index: number): (list: List) => T[]; - // adjust(fn: (a: T) => T): CurriedFunction2, T[]>; - // adjust: CurriedFunction3<(a: T) => T, number, List, T[]>; - - // base - adjust(fn: (a: T) => T, index: number, list: List): T[]; - adjust(fn: (a: T) => T, index: number):{ - (list: List): T[]; - }; - adjust(fn: (a: T) => T):{ - (index: number, list: List): T[]; - (index: number):{ - (list: List): T[]; - }; - }; - - - - /** - * Returns true if all elements of the list match the predicate, false if there are any that don't. - */ - all(pred: Pred, list: List): boolean; - all(pred: Pred): (list: List) => boolean; - // all: CurriedFunction2, List, boolean>; - - /** - * Given a list of predicates, returns a new predicate that will be true exactly when all of them are. - */ - allPass(preds: Pred[]): Pred; - - /** - * Returns a function that always returns the given value. - */ - always(val: T): () => T; - - /** - * A function that returns the first argument if it's falsy otherwise the second argument. Note that this is - * NOT short-circuited, meaning that if expressions are passed they are both evaluated. - */ - // dispatch to some `and` method: - and(fn1: T, val2: boolean|any): boolean; - and(fn1: T): (val2: boolean|any) => boolean; - // and: CurriedFunction2; - // // functions, does this still exist? - // and boolean>(fn1: T, fn2: T): T; - // and boolean>(fn1: T): (fn2: T) => T; - // no generics: - and(v1: any, v2: any): boolean; - and(v1: any): (v2: any) => boolean; - // and: CurriedFunction2; - - /** - * Returns true if at least one of elements of the list match the predicate, false otherwise. - */ - any(pred: Pred, list: List): boolean; - any(fnpred: Pred): (list: List) => boolean; - // any: CurriedFunction2, List, boolean>; - - /** - * Given a list of predicates returns a new predicate that will be true exactly when any one of them is. - */ - anyPass(preds: Pred[]): Pred; - - /** - * ap applies a list of functions to a list of values. - */ - ap(fns: ((a: T) => U)[], vs: List): U[]; - ap(fns: ((a: T) => U)[]): (vs: List) => U[]; - // ap: CurriedFunction2<((a: T) => U)[], List, U[]>; - - - /** - * Returns a new list, composed of n-tuples of consecutive elements If n is greater than the length of the list, - * an empty list is returned. - */ - aperture(n: number, list: List): T[][]; - aperture(n: number): (list: List) => T[][]; - // aperture: CurriedFunction2, T[][]>; - - /** - * Returns a new list containing the contents of the given list, followed by the given element. - */ - append(el: U, list: List): (T & U)[]; - append(el: U): (list: List) => (T & U)[]; - // append: CurriedFunction2, (T & U)[]>; - - /** - * Applies function fn to the argument list args. This is useful for creating a fixed-arity function from - * a variadic function. fn should be a bound function if context is significant. - */ - apply(fn: (...args: any[]) => TResult, args: any[]): TResult; - apply(fn: (...args: any[]) => TResult): (args: any[]) => TResult; - // apply: CurriedFunction2<(...args: any[]) => TResult, any[], TResult>; - - /** - * Given a spec object recursively mapping properties to functions, creates a function producing an object - * of the same structure, by mapping each property to the result of calling its associated function with - * the supplied arguments. - */ - applySpec(obj: any): Variadic; - - /** - * Makes an ascending comparator function out of a function that returns a value that can be compared with `<` and `>`. - */ - ascend(comparator: (val: T) => V, a: T, b: T): number; - ascend(comparator: (val: T) => V, a: T): (b: T) => number; - ascend(comparator: (val: T) => V): CurriedFunction2; - // ascend: CurriedFunction3<(val: T) => V, T, T, number>; - - /** - * Makes a shallow clone of an object, setting or overriding the specified property with the given value. - */ - // hard to mix cuz different initial generics? - - // extend object with new property - // assoc, K extends keyof U>(prop: K, val: T, obj: U): {[P in K]: T} & U; - // assoc, K extends keyof U>(prop: K, val: T): (obj: U) => {[P in K]: T} & U; // generics too early? - // assoc, K extends keyof U>(prop: K): CurriedFunction2; // generics too early? - // assoc, K extends keyof U>: CurriedFunction3; - - // // extend object with new property - // assoc>(prop: K, val: T, obj: U): {[P in K]: T} & U; - // assoc(prop: K, val: T):{ - // >(obj: U): {[P in K]: T} & U; - // }; - // assoc(prop: K):{ - // >(val: T, obj: U): {[P in K]: T} & U; - // (val: T):{ - // >(obj: U): {[P in K]: T} & U; - // }; - // }; - - - - // homogeneous object - assoc>(prop: Prop, val: T, obj: U): U; - assoc(prop: Prop, val: T): >(obj: U) => U; - assoc>(prop: Prop): CurriedFunction2; // generics too early? - // assoc>: CurriedFunction3; - - // any object as long as the type remains unchanged - assoc(prop: Prop, val: any, obj: T): T; - assoc(prop: Prop, val: any): (obj: T) => T; - assoc(prop: Prop): CurriedFunction2; // generics too early? - // assoc: CurriedFunction3; - - // any object as long as the type remains unchanged - assoc(prop: Prop, val: any, obj: T): T; - assoc(prop: Prop, val: any):{ - (obj: T): T; - }; - assoc(prop: Prop):{ - (val: any, obj: T): T; - (val: any):{ - (obj: T): T; - }; - }; - - - /** - * Makes a shallow clone of an object, setting or overriding the nodes required to create the given path, and - * placing the specific value at the tail end of that path. - */ - // assocPath(path: Path, val: T, obj: U): U; - // assocPath(path: Path, val: T): (obj: U) => U; - // assocPath(path: Path): CurriedFunction2; - // assocPath: CurriedFunction3; - - // base - assocPath(path: Path, val: T, obj: U): U; - assocPath(path: Path, val: T):{ - (obj: U): U; - }; - assocPath(path: Path):{ - (val: T, obj: U): U; - (val: T):{ - (obj: U): U; - }; - }; - - - /** - * Wraps a function of any arity (including nullary) in a function that accepts exactly 2 - * parameters. Any extraneous parameters will not be passed to the supplied function. - */ - binary(fn: (a: A, b: T, ...args: any[]) => T): (a: A, b: B) => T; - binary(fn: Variadic): (a: any, b: any) => T; - - /** - * Creates a function that is bound to a context. Note: R.bind does not provide the additional argument-binding - * capabilities of Function.prototype.bind. - */ - bind(fn: Variadic, thisObj: {}): Variadic; - bind(fn: Variadic): (thisObj: {}) => Variadic; - // bind: CurriedFunction2, {}, Variadic>; - - - /** - * A function wrapping calls to the two functions in an && operation, returning the result of the first function - * if it is false-y and the result of the second function otherwise. Note that this is short-circuited, meaning - * that the second function will not be invoked if the first returns a false-y value. - */ - both(pred1: Pred, pred2: Pred): Pred; - both(pred1: Pred): (pred2: Pred) => Pred; - // both: CurriedFunction2, Pred, Pred>; - - /** - * Returns the result of calling its first argument with the remaining arguments. This is occasionally useful - * as a converging function for R.converge: the left branch can produce a function while the right branch - * produces a value to be passed to that function as an argument. - */ - // not curried! - call(fn: Variadic, ...args: any[]): T; - - /** - * `chain` maps a function over a list and concatenates the results. - * This implementation is compatible with the Fantasy-land Chain spec - */ - - // List version - chain(fn: (n: T) => U[], list: List): U[]; - chain(fn: (n: T) => U[]): (list: List) => U[]; - // chain: CurriedFunction2<(n: T) => U[], List, U[]>; - - // generic Chain version - chain(fn: (n: T) => Chain, list: Chain): Chain; - chain(fn: (n: T) => Chain): (list: Chain) => Chain; - // chain: CurriedFunction2<(n: T) => Chain, Chain, Chain>; - - // function argument - chain(fn: (v: V) => (list: Chain) => Chain, monad: (chain: Chain) => V): (list: Chain) => Chain; - chain(fn: (v: V) => (list: Chain) => Chain): (monad: (chain: Chain) => V) => (list: Chain) => Chain; - // chain: CurriedFunction2<(v: V) => (list: Chain) => Chain, (chain: Chain) => V, (list: Chain) => Chain>; - - /** - * Restricts a number to be within a range. - * Also works for other ordered types such as Strings and Date - */ - // clamp(min: T, max: T, value: T): T; - // clamp(min: T, max: T): (value: T) => T; - // clamp(min: T): CurriedFunction2; - // clamp: CurriedFunction3; - - // base - clamp(min: T, max: T, value: T): T; - clamp(min: T, max: T):{ - (value: T): T; - }; - clamp(min: T):{ - (max: T, value: T): T; - (max: T):{ - (value: T): T; - }; - }; - - - /** - * Creates a deep copy of the value which may contain (nested) Arrays and Objects, Numbers, Strings, Booleans and Dates. - */ - clone(value: T): T; - clone(value: List): T[]; - - /** - * Makes a comparator function out of a function that reports whether the first element is less than the second. - */ - comparator(pred: (a: T, b: T) => boolean): (x: T, y: T) => number; - - /** - * Takes a function f and returns a function g such that: - * - applying g to zero or more arguments will give true if applying the same arguments to f gives - * a logical false value; and - * - applying g to zero or more arguments will give false if applying the same arguments to f gives - * a logical true value. - */ - complement(pred: Variadic): Variadic; - - /** - * Performs right-to-left function composition. The rightmost function may have any arity; the remaining - * functions must be unary. - */ - compose(fn0: (x0: V0) => T1): (x0: V0) => T1; - compose(fn0: (x0: V0, x1: V1) => T1): (x0: V0, x1: V1) => T1; - compose(fn0: (x0: V0, x1: V1, x2: V2) => T1): (x0: V0, x1: V1, x2: V2) => T1; - compose(fn0: (x0: V0, x1: V1, x2: V2, x3: V3) => T1): (x0: V0, x1: V1, x2: V2, x3: V3) => T1; - compose(fn1: (x: T1) => T2, fn0: (x0: V0) => T1): (x0: V0) => T2; - compose(fn1: (x: T1) => T2, fn0: (x0: V0, x1: V1) => T1): (x0: V0, x1: V1) => T2; - compose(fn1: (x: T1) => T2, fn0: (x0: V0, x1: V1, x2: V2) => T1): (x0: V0, x1: V1, x2: V2) => T2; - compose(fn1: (x: T1) => T2, fn0: (x0: V0, x1: V1, x2: V2, x3: V3) => T1): (x0: V0, x1: V1, x2: V2, x3: V3) => T2; - compose(fn2: (x: T2) => T3, fn1: (x: T1) => T2, fn0: (x0: V0) => T1): (x0: V0) => T3; - compose(fn2: (x: T2) => T3, fn1: (x: T1) => T2, fn0: (x0: V0, x1: V1) => T1): (x0: V0, x1: V1) => T3; - compose(fn2: (x: T2) => T3, fn1: (x: T1) => T2, fn0: (x0: V0, x1: V1, x2: V2) => T1): (x0: V0, x1: V1, x2: V2) => T3; - compose(fn2: (x: T2) => T3, fn1: (x: T1) => T2, fn0: (x0: V0, x1: V1, x2: V2, x3: V3) => T1): (x0: V0, x1: V1, x2: V2, x3: V3) => T3; - compose(fn3: (x: T3) => T4, fn2: (x: T2) => T3, fn1: (x: T1) => T2, fn0: (x0: V0) => T1): (x0: V0) => T4; - compose(fn3: (x: T3) => T4, fn2: (x: T2) => T3, fn1: (x: T1) => T2, fn0: (x0: V0, x1: V1) => T1): (x0: V0, x1: V1) => T4; - compose(fn3: (x: T3) => T4, fn2: (x: T2) => T3, fn1: (x: T1) => T2, fn0: (x0: V0, x1: V1, x2: V2) => T1): (x0: V0, x1: V1, x2: V2) => T4; - compose(fn3: (x: T3) => T4, fn2: (x: T2) => T3, fn1: (x: T1) => T2, fn0: (x0: V0, x1: V1, x2: V2, x3: V3) => T1): (x0: V0, x1: V1, x2: V2, x3: V3) => T4; - compose(fn4: (x: T4) => T5, fn3: (x: T3) => T4, fn2: (x: T2) => T3, fn1: (x: T1) => T2, fn0: (x0: V0) => T1): (x0: V0) => T5; - compose(fn4: (x: T4) => T5, fn3: (x: T3) => T4, fn2: (x: T2) => T3, fn1: (x: T1) => T2, fn0: (x0: V0, x1: V1) => T1): (x0: V0, x1: V1) => T5; - compose(fn4: (x: T4) => T5, fn3: (x: T3) => T4, fn2: (x: T2) => T3, fn1: (x: T1) => T2, fn0: (x0: V0, x1: V1, x2: V2) => T1): (x0: V0, x1: V1, x2: V2) => T5; - compose(fn4: (x: T4) => T5, fn3: (x: T3) => T4, fn2: (x: T2) => T3, fn1: (x: T1) => T2, fn0: (x0: V0, x1: V1, x2: V2, x3: V3) => T1): (x0: V0, x1: V1, x2: V2, x3: V3) => T5; - compose(fn5: (x: T5) => T6, fn4: (x: T4) => T5, fn3: (x: T3) => T4, fn2: (x: T2) => T3, fn1: (x: T1) => T2, fn0: (x0: V0) => T1): (x0: V0) => T6; - compose(fn5: (x: T5) => T6, fn4: (x: T4) => T5, fn3: (x: T3) => T4, fn2: (x: T2) => T3, fn1: (x: T1) => T2, fn0: (x0: V0, x1: V1) => T1): (x0: V0, x1: V1) => T6; - compose(fn5: (x: T5) => T6, fn4: (x: T4) => T5, fn3: (x: T3) => T4, fn2: (x: T2) => T3, fn1: (x: T1) => T2, fn0: (x0: V0, x1: V1, x2: V2) => T1): (x0: V0, x1: V1, x2: V2) => T6; - compose(fn5: (x: T5) => T6, fn4: (x: T4) => T5, fn3: (x: T3) => T4, fn2: (x: T2) => T3, fn1: (x: T1) => T2, fn0: (x0: V0, x1: V1, x2: V2, x3: V3) => T1): (x0: V0, x1: V1, x2: V2, x3: V3) => T6; - compose(fn6: (x: T6) => T7, fn5: (x: T5) => T6, fn4: (x: T4) => T5, fn3: (x: T3) => T4, fn2: (x: T2) => T3, fn1: (x: T1) => T2, fn0: (x0: V0) => T1): (x0: V0) => T7; - compose(fn6: (x: T6) => T7, fn5: (x: T5) => T6, fn4: (x: T4) => T5, fn3: (x: T3) => T4, fn2: (x: T2) => T3, fn1: (x: T1) => T2, fn0: (x0: V0, x1: V1) => T1): (x0: V0, x1: V1) => T7; - compose(fn6: (x: T6) => T7, fn5: (x: T5) => T6, fn4: (x: T4) => T5, fn3: (x: T3) => T4, fn2: (x: T2) => T3, fn1: (x: T1) => T2, fn0: (x0: V0, x1: V1, x2: V2) => T1): (x0: V0, x1: V1, x2: V2) => T7; - compose(fn6: (x: T6) => T7, fn5: (x: T5) => T6, fn4: (x: T4) => T5, fn3: (x: T3) => T4, fn2: (x: T2) => T3, fn1: (x: T1) => T2, fn0: (x0: V0, x1: V1, x2: V2, x3: V3) => T1): (x0: V0, x1: V1, x2: V2, x3: V3) => T7; - compose(fn7: (x: T7) => T8, fn6: (x: T6) => T7, fn5: (x: T5) => T6, fn4: (x: T4) => T5, fn3: (x: T3) => T4, fn2: (x: T2) => T3, fn1: (x: T1) => T2, fn0: (x0: V0) => T1): (x0: V0) => T8; - compose(fn7: (x: T7) => T8, fn6: (x: T6) => T7, fn5: (x: T5) => T6, fn4: (x: T4) => T5, fn3: (x: T3) => T4, fn2: (x: T2) => T3, fn1: (x: T1) => T2, fn0: (x0: V0, x1: V1) => T1): (x0: V0, x1: V1) => T8; - compose(fn7: (x: T7) => T8, fn6: (x: T6) => T7, fn5: (x: T5) => T6, fn4: (x: T4) => T5, fn3: (x: T3) => T4, fn2: (x: T2) => T3, fn1: (x: T1) => T2, fn0: (x0: V0, x1: V1, x2: V2) => T1): (x0: V0, x1: V1, x2: V2) => T8; - compose(fn7: (x: T7) => T8, fn6: (x: T6) => T7, fn5: (x: T5) => T6, fn4: (x: T4) => T5, fn3: (x: T3) => T4, fn2: (x: T2) => T3, fn1: (x: T1) => T2, fn0: (x0: V0, x1: V1, x2: V2, x3: V3) => T1): (x0: V0, x1: V1, x2: V2, x3: V3) => T8; - compose(fn8: (x: T8) => T9, fn7: (x: T7) => T8, fn6: (x: T6) => T7, fn5: (x: T5) => T6, fn4: (x: T4) => T5, fn3: (x: T3) => T4, fn2: (x: T2) => T3, fn1: (x: T1) => T2, fn0: (x0: V0) => T1): (x0: V0) => T9; - compose(fn8: (x: T8) => T9, fn7: (x: T7) => T8, fn6: (x: T6) => T7, fn5: (x: T5) => T6, fn4: (x: T4) => T5, fn3: (x: T3) => T4, fn2: (x: T2) => T3, fn1: (x: T1) => T2, fn0: (x0: V0, x1: V1) => T1): (x0: V0, x1: V1) => T9; - compose(fn8: (x: T8) => T9, fn7: (x: T7) => T8, fn6: (x: T6) => T7, fn5: (x: T5) => T6, fn4: (x: T4) => T5, fn3: (x: T3) => T4, fn2: (x: T2) => T3, fn1: (x: T1) => T2, fn0: (x0: V0, x1: V1, x2: V2) => T1): (x0: V0, x1: V1, x2: V2) => T9; - compose(fn8: (x: T8) => T9, fn7: (x: T7) => T8, fn6: (x: T6) => T7, fn5: (x: T5) => T6, fn4: (x: T4) => T5, fn3: (x: T3) => T4, fn2: (x: T2) => T3, fn1: (x: T1) => T2, fn0: (x0: V0, x1: V1, x2: V2, x3: V3) => T1): (x0: V0, x1: V1, x2: V2, x3: V3) => T9; - - /** - * Returns the right-to-left Kleisli composition of the provided functions, each of which must return a value of a type supported by chain. - */ - composeK(fn0: (v: Chain) => Chain): (v: V) => Chain; - composeK(fn1: (x: T1) => Chain, fn0: (v: Chain) => Chain): (v: V) => Chain; - composeK(fn2: (x: T2) => Chain, fn1: (x: T1) => Chain, fn0: (v: Chain) => Chain): (v: V) => Chain; - composeK(fn3: (x: T3) => Chain, fn2: (x: T2) => Chain, fn1: (x: T1) => Chain, fn0: (v: Chain) => Chain): (v: V) => Chain; - composeK(fn4: (x: T4) => Chain, fn3: (x: T3) => Chain, fn2: (x: T2) => Chain, fn1: (x: T1) => Chain, fn0: (v: Chain) => Chain): (v: V) => Chain; - composeK(fn5: (x: T5) => Chain, fn4: (x: T4) => Chain, fn3: (x: T3) => Chain, fn2: (x: T2) => Chain, fn1: (x: T1) => Chain, fn0: (v: Chain) => Chain): (v: V) => Chain; - composeK(fn6: (x: T6) => Chain, fn5: (x: T5) => Chain, fn4: (x: T4) => Chain, fn3: (x: T3) => Chain, fn2: (x: T2) => Chain, fn1: (x: T1) => Chain, fn0: (v: Chain) => Chain): (v: V) => Chain; - composeK(fn7: (x: T7) => Chain, fn6: (x: T6) => Chain, fn5: (x: T5) => Chain, fn4: (x: T4) => Chain, fn3: (x: T3) => Chain, fn2: (x: T2) => Chain, fn1: (x: T1) => Chain, fn0: (v: Chain) => Chain): (v: V) => Chain; - composeK(fn8: (x: T8) => Chain, fn7: (x: T7) => Chain, fn6: (x: T6) => Chain, fn5: (x: T5) => Chain, fn4: (x: T4) => Chain, fn3: (x: T3) => Chain, fn2: (x: T2) => Chain, fn1: (x: T1) => Chain, fn0: (v: Chain) => Chain): (v: V) => Chain; - - /** - * Performs right-to-left composition of one or more Promise-returning functions. The rightmost function may have any arity; the remaining functions must be unary. - */ - composeP(fn0: (x0: V0) => Promise): (x0: V0) => Promise; - composeP(fn0: (x0: V0, x1: V1) => Promise): (x0: V0, x1: V1) => Promise; - composeP(fn0: (x0: V0, x1: V1, x2: V2) => Promise): (x0: V0, x1: V1, x2: V2) => Promise; - composeP(fn0: (x0: V0, x1: V1, x2: V2, x3: V3) => Promise): (x0: V0, x1: V1, x2: V2, x3: V3) => Promise; - composeP(fn1: (x: T1) => Promise|T2, fn0: (x0: V0) => Promise): (x0: V0) => Promise; - composeP(fn1: (x: T1) => Promise|T2, fn0: (x0: V0, x1: V1) => Promise): (x0: V0, x1: V1) => Promise; - composeP(fn1: (x: T1) => Promise|T2, fn0: (x0: V0, x1: V1, x2: V2) => Promise): (x0: V0, x1: V1, x2: V2) => Promise; - composeP(fn1: (x: T1) => Promise|T2, fn0: (x0: V0, x1: V1, x2: V2, x3: V3) => Promise): (x0: V0, x1: V1, x2: V2, x3: V3) => Promise; - composeP(fn2: (x: T2) => Promise|T3, fn1: (x: T1) => Promise|T2, fn0: (x0: V0) => Promise): (x0: V0) => Promise; - composeP(fn2: (x: T2) => Promise|T3, fn1: (x: T1) => Promise|T2, fn0: (x0: V0, x1: V1) => Promise): (x0: V0, x1: V1) => Promise; - composeP(fn2: (x: T2) => Promise|T3, fn1: (x: T1) => Promise|T2, fn0: (x0: V0, x1: V1, x2: V2) => Promise): (x0: V0, x1: V1, x2: V2) => Promise; - composeP(fn2: (x: T2) => Promise|T3, fn1: (x: T1) => Promise|T2, fn0: (x0: V0, x1: V1, x2: V2, x3: V3) => Promise): (x0: V0, x1: V1, x2: V2, x3: V3) => Promise; - composeP(fn3: (x: T3) => Promise|T4, fn2: (x: T2) => Promise|T3, fn1: (x: T1) => Promise|T2, fn0: (x0: V0) => Promise): (x0: V0) => Promise; - composeP(fn3: (x: T3) => Promise|T4, fn2: (x: T2) => Promise|T3, fn1: (x: T1) => Promise|T2, fn0: (x0: V0, x1: V1) => Promise): (x0: V0, x1: V1) => Promise; - composeP(fn3: (x: T3) => Promise|T4, fn2: (x: T2) => Promise|T3, fn1: (x: T1) => Promise|T2, fn0: (x0: V0, x1: V1, x2: V2) => Promise): (x0: V0, x1: V1, x2: V2) => Promise; - composeP(fn3: (x: T3) => Promise|T4, fn2: (x: T2) => Promise|T3, fn1: (x: T1) => Promise|T2, fn0: (x0: V0, x1: V1, x2: V2, x3: V3) => Promise): (x0: V0, x1: V1, x2: V2, x3: V3) => Promise; - composeP(fn4: (x: T4) => Promise|T5, fn3: (x: T3) => Promise|T4, fn2: (x: T2) => Promise|T3, fn1: (x: T1) => Promise|T2, fn0: (x0: V0) => Promise): (x0: V0) => Promise; - composeP(fn4: (x: T4) => Promise|T5, fn3: (x: T3) => Promise|T4, fn2: (x: T2) => Promise|T3, fn1: (x: T1) => Promise|T2, fn0: (x0: V0, x1: V1) => Promise): (x0: V0, x1: V1) => Promise; - composeP(fn4: (x: T4) => Promise|T5, fn3: (x: T3) => Promise|T4, fn2: (x: T2) => Promise|T3, fn1: (x: T1) => Promise|T2, fn0: (x0: V0, x1: V1, x2: V2) => Promise): (x0: V0, x1: V1, x2: V2) => Promise; - composeP(fn4: (x: T4) => Promise|T5, fn3: (x: T3) => Promise|T4, fn2: (x: T2) => Promise|T3, fn1: (x: T1) => Promise|T2, fn0: (x0: V0, x1: V1, x2: V2, x3: V3) => Promise): (x0: V0, x1: V1, x2: V2, x3: V3) => Promise; - composeP(fn5: (x: T5) => Promise|T6, fn4: (x: T4) => Promise|T5, fn3: (x: T3) => Promise|T4, fn2: (x: T2) => Promise|T3, fn1: (x: T1) => Promise|T2, fn0: (x0: V0) => Promise): (x0: V0) => Promise; - composeP(fn5: (x: T5) => Promise|T6, fn4: (x: T4) => Promise|T5, fn3: (x: T3) => Promise|T4, fn2: (x: T2) => Promise|T3, fn1: (x: T1) => Promise|T2, fn0: (x0: V0, x1: V1) => Promise): (x0: V0, x1: V1) => Promise; - composeP(fn5: (x: T5) => Promise|T6, fn4: (x: T4) => Promise|T5, fn3: (x: T3) => Promise|T4, fn2: (x: T2) => Promise|T3, fn1: (x: T1) => Promise|T2, fn0: (x0: V0, x1: V1, x2: V2) => Promise): (x0: V0, x1: V1, x2: V2) => Promise; - composeP(fn5: (x: T5) => Promise|T6, fn4: (x: T4) => Promise|T5, fn3: (x: T3) => Promise|T4, fn2: (x: T2) => Promise|T3, fn1: (x: T1) => Promise|T2, fn0: (x0: V0, x1: V1, x2: V2, x3: V3) => Promise): (x0: V0, x1: V1, x2: V2, x3: V3) => Promise; - composeP(fn6: (x: T6) => Promise|T7, fn5: (x: T5) => Promise|T6, fn4: (x: T4) => Promise|T5, fn3: (x: T3) => Promise|T4, fn2: (x: T2) => Promise|T3, fn1: (x: T1) => Promise|T2, fn0: (x0: V0) => Promise): (x0: V0) => Promise; - composeP(fn6: (x: T6) => Promise|T7, fn5: (x: T5) => Promise|T6, fn4: (x: T4) => Promise|T5, fn3: (x: T3) => Promise|T4, fn2: (x: T2) => Promise|T3, fn1: (x: T1) => Promise|T2, fn0: (x0: V0, x1: V1) => Promise): (x0: V0, x1: V1) => Promise; - composeP(fn6: (x: T6) => Promise|T7, fn5: (x: T5) => Promise|T6, fn4: (x: T4) => Promise|T5, fn3: (x: T3) => Promise|T4, fn2: (x: T2) => Promise|T3, fn1: (x: T1) => Promise|T2, fn0: (x0: V0, x1: V1, x2: V2) => Promise): (x0: V0, x1: V1, x2: V2) => Promise; - composeP(fn6: (x: T6) => Promise|T7, fn5: (x: T5) => Promise|T6, fn4: (x: T4) => Promise|T5, fn3: (x: T3) => Promise|T4, fn2: (x: T2) => Promise|T3, fn1: (x: T1) => Promise|T2, fn0: (x0: V0, x1: V1, x2: V2, x3: V3) => Promise): (x0: V0, x1: V1, x2: V2, x3: V3) => Promise; - composeP(fn7: (x: T7) => Promise|T8, fn6: (x: T6) => Promise|T7, fn5: (x: T5) => Promise|T6, fn4: (x: T4) => Promise|T5, fn3: (x: T3) => Promise|T4, fn2: (x: T2) => Promise|T3, fn1: (x: T1) => Promise|T2, fn0: (x0: V0) => Promise): (x0: V0) => Promise; - composeP(fn7: (x: T7) => Promise|T8, fn6: (x: T6) => Promise|T7, fn5: (x: T5) => Promise|T6, fn4: (x: T4) => Promise|T5, fn3: (x: T3) => Promise|T4, fn2: (x: T2) => Promise|T3, fn1: (x: T1) => Promise|T2, fn0: (x0: V0, x1: V1) => Promise): (x0: V0, x1: V1) => Promise; - composeP(fn7: (x: T7) => Promise|T8, fn6: (x: T6) => Promise|T7, fn5: (x: T5) => Promise|T6, fn4: (x: T4) => Promise|T5, fn3: (x: T3) => Promise|T4, fn2: (x: T2) => Promise|T3, fn1: (x: T1) => Promise|T2, fn0: (x0: V0, x1: V1, x2: V2) => Promise): (x0: V0, x1: V1, x2: V2) => Promise; - composeP(fn7: (x: T7) => Promise|T8, fn6: (x: T6) => Promise|T7, fn5: (x: T5) => Promise|T6, fn4: (x: T4) => Promise|T5, fn3: (x: T3) => Promise|T4, fn2: (x: T2) => Promise|T3, fn1: (x: T1) => Promise|T2, fn0: (x0: V0, x1: V1, x2: V2, x3: V3) => Promise): (x0: V0, x1: V1, x2: V2, x3: V3) => Promise; - composeP(fn8: (x: T8) => Promise|T9, fn7: (x: T7) => Promise|T8, fn6: (x: T6) => Promise|T7, fn5: (x: T5) => Promise|T6, fn4: (x: T4) => Promise|T5, fn3: (x: T3) => Promise|T4, fn2: (x: T2) => Promise|T3, fn1: (x: T1) => Promise|T2, fn0: (x0: V0) => Promise): (x0: V0) => Promise; - composeP(fn8: (x: T8) => Promise|T9, fn7: (x: T7) => Promise|T8, fn6: (x: T6) => Promise|T7, fn5: (x: T5) => Promise|T6, fn4: (x: T4) => Promise|T5, fn3: (x: T3) => Promise|T4, fn2: (x: T2) => Promise|T3, fn1: (x: T1) => Promise|T2, fn0: (x0: V0, x1: V1) => Promise): (x0: V0, x1: V1) => Promise; - composeP(fn8: (x: T8) => Promise|T9, fn7: (x: T7) => Promise|T8, fn6: (x: T6) => Promise|T7, fn5: (x: T5) => Promise|T6, fn4: (x: T4) => Promise|T5, fn3: (x: T3) => Promise|T4, fn2: (x: T2) => Promise|T3, fn1: (x: T1) => Promise|T2, fn0: (x0: V0, x1: V1, x2: V2) => Promise): (x0: V0, x1: V1, x2: V2) => Promise; - composeP(fn8: (x: T8) => Promise|T9, fn7: (x: T7) => Promise|T8, fn6: (x: T6) => Promise|T7, fn5: (x: T5) => Promise|T6, fn4: (x: T4) => Promise|T5, fn3: (x: T3) => Promise|T4, fn2: (x: T2) => Promise|T3, fn1: (x: T1) => Promise|T2, fn0: (x0: V0, x1: V1, x2: V2, x3: V3) => Promise): (x0: V0, x1: V1, x2: V2, x3: V3) => Promise; - - /** - * Returns a new list consisting of the elements of the first list followed by the elements - * of the second. - */ - concat>(list1: T, list2: T): T; - concat>(list1: T): (list2: T) => T; - // concat>: CurriedFunction2; - - /** - * Returns a function, fn, which encapsulates if/else-if/else logic. R.cond takes a list of [predicate, transform] pairs. - * All of the arguments to fn are applied to each of the predicates in turn until one returns a "truthy" value, at which - * point fn returns the result of applying its arguments to the corresponding transformer. If none of the predicates - * matches, fn returns undefined. - */ - cond(fns: [Pred, (v: T) => U][]): (v: T) => U; - - /** - * Wraps a constructor function inside a curried function that can be called with the same arguments and returns the same type. - */ - construct(fn: Function): Function; - - /** - * Wraps a constructor function inside a curried function that can be called with the same arguments and returns the same type. - * The arity of the function returned is specified to allow using variadic constructor functions. - */ - constructN(n: number, fn: Function): Function; - // constructN: CurriedFunction2; - - - /** - * Returns `true` if the specified item is somewhere in the list, `false` otherwise. - * Equivalent to `indexOf(a)(list) > -1`. Uses strict (`===`) equality checking. - */ - contains(a: string, list: string): boolean; - contains(a: string): (list: string) => boolean; - // contains: CurriedFunction2; - contains>(a: T, list: R): boolean; - contains>(a: T): (list: R) => boolean; - // contains>: CurriedFunction2; - - /** - * Accepts a converging function and a list of branching functions and returns a new - * function. When invoked, this new function is applied to some arguments, each branching - * function is applied to those same arguments. The results of each branching function - * are passed as arguments to the converging function to produce the return value. - */ - converge(after: Variadic, fns: List>): Variadic; - // converge: CurriedFunction2, List>, Variadic>; - - /** - * Counts the elements of a list according to how many match each value - * of a key generated by the supplied function. Returns an object - * mapping the keys produced by `fn` to the number of occurrences in - * the list. Note that all keys are coerced to strings because of how - * JavaScript objects work. - */ - countBy(fn: (a: T) => Prop, list: List): Obj; - countBy(fn: (a: T) => Prop): (list: List) => Obj; - // countBy: CurriedFunction2<(a: T) => Prop, List, Obj>; - - curry: typeof curry - - /** - * Returns a curried equivalent of the provided function, with the specified arity. - */ - curryN(length: number, fn: Variadic): Variadic; - // curryN: CurriedFunction2, Variadic>; - - - /** - * Decrements its argument. - */ - dec(n: number): number; - - /** - * Returns the second argument if it is not null or undefined. If it is null or undefined, the - * first (default) argument is returned. - */ - defaultTo(a: T, b: U): T|U; - defaultTo(a: T): (b: U) => T|U; - // defaultTo: CurriedFunction2; - - /** - * Makes a descending comparator function out of a function that returns a value that can be compared with `<` and `>`. - */ - descend(comparator: (val: T) => V, a: T, b: T): number; - descend(comparator: (val: T) => V, a: T): (b: T) => number; - descend(comparator: (val: T) => V): CurriedFunction2; - // descend: CurriedFunction3<(val: T) => V, T, T, number>; - - /** - * Finds the set (i.e. no duplicates) of all elements in the first list not contained in the second list. - */ - difference(list1: List, list2: List): T[]; - difference(list1: List): (list2: List) => T[]; - // difference: CurriedFunction2, List, T[]>; - - /** - * Finds the set (i.e. no duplicates) of all elements in the first list not contained in the second list. - * Duplication is determined according to the value returned by applying the supplied predicate to two list - * elements. - */ - // differenceWith(pred: (a: T, b: T) => boolean, list1: List, list2: List): T[]; - // differenceWith(pred: (a: T, b: T) => boolean, list1: List): (list2: List) => T[]; - // differenceWith(pred: (a: T, b: T) => boolean): CurriedFunction2,List,T>; - // differenceWith: CurriedFunction3<(a: T, b: T) => boolean, List, List, T[]>; - - // base - differenceWith(pred: (a: T, b: T) => boolean, list1: List, list2: List): T[]; - differenceWith(pred: (a: T, b: T) => boolean, list1: List):{ - (list2: List): T[]; - }; - differenceWith(pred: (a: T, b: T) => boolean):{ - (list1: List, list2: List): T[]; - (list1: List):{ - (list2: List): T[]; - }; - }; - - - /* - * Returns a new object that does not contain a prop property. - */ - - // TODO: fix, can't yet calculate type of object minus this key - // dissoc(prop: Prop, obj: T & { [prop: Prop]: any }): T; // wanna say the original object is the same with the extra key, but can't bind it to prop - // dissoc>(prop: keyof U, obj: U): T; - - // simplified but inferrable: leave the key in - // dissoc(prop: keyof T, obj: T): T; - dissoc(prop: Prop): (obj: T) => T; // mix - // dissoc: CurriedFunction2; - // dissoc: CurriedFunction2; - - // It seems impossible to infer the return type, so this may have to be specified explicitly - dissoc(prop: Prop, obj: Struct): T; - // dissoc(prop: Prop): (obj: Struct) => T; // mix - // dissoc: CurriedFunction2, T>; - // dissoc>(prop: keyof U): (obj: U) => T; // can't do this, don't know U in time - - // mixed curry: - dissoc(prop: Prop): { - (obj: T): T; // infer - (obj: Struct): T; // manual - }; - - /** - * Makes a shallow clone of an object, omitting the property at the given path. - */ - dissocPath(path: Path, obj: Struct): T; - dissocPath(path: Path): (obj: Struct) => T; - // dissocPath: CurriedFunction2, T>; - - /** - * Divides two numbers. Equivalent to a / b. - */ - divide(a: number, b: number): number; - divide(a: number): (b: number) => number; - // divide: CurriedFunction2; - - /** - * Returns a new list containing all but the first n elements of the given list. - */ - drop>(n: number, xs: T): T; - drop>(n: number): (xs: T) => T; - // drop>: CurriedFunction2; - - /** - * Returns a list containing all but the last n elements of the given list. - */ - // = drop - dropLast>(n: number, xs: T): T; - dropLast>(n: number): (xs: T) => T; - // dropLast>: CurriedFunction2; - - /** - * Returns a new list containing all but last then elements of a given list, passing each value from the - * right to the supplied predicate function, skipping elements while the predicate function returns true. - */ - // = dropWhile - dropLastWhile>(pred: Pred, list: R): T[]; - dropLastWhile>(pred: Pred): (list: R) => T[]; - // dropLastWhile>: CurriedFunction2, R, T[]>; - - /** - * Returns a new list containing the last n elements of a given list, passing each value to the supplied - * predicate function, skipping elements while the predicate function returns true. - */ - dropWhile>(pred: Pred, list: R): T[]; - dropWhile>(pred: Pred): (list: R) => T[]; - // dropWhile>: CurriedFunction2, R, T[]>; - - /** - * A function wrapping calls to the two functions in an || operation, returning the result of the first - * function if it is truth-y and the result of the second function otherwise. Note that this is - * short-circuited, meaning that the second function will not be invoked if the first returns a truth-y value. - */ - either(pred1: Pred, pred2: Pred): Pred; - either(pred1: Pred): (pred2: Pred) => Pred; - // either: CurriedFunction2, Pred, Pred>; - - /** - * Returns the empty value of its argument's type. Ramda defines the empty value of Array ([]), Object ({}), - * String (''), and Arguments. Other types are supported if they define .empty and/or .prototype.empty. - * Dispatches to the empty method of the first argument, if present. - */ - empty(x: T): T; - - /** - * Takes a function and two values in its domain and returns true if the values map to the same value in the - * codomain; false otherwise. - */ - // eqBy(fn: (a: T) => T, a: T, b: T): boolean; - // eqBy(fn: (a: T) => T, a: T): (b: T) => boolean; - // eqBy(fn: (a: T) => T): CurriedFunction2; - // eqBy: CurriedFunction3<(a: T) => T, T, T, boolean>; - - // base - eqBy(fn: (a: T) => T, a: T, b: T): boolean; - eqBy(fn: (a: T) => T, a: T):{ - (b: T): boolean; - }; - eqBy(fn: (a: T) => T):{ - (a: T, b: T): boolean; - (a: T):{ - (b: T): boolean; - }; - }; - - - /** - * Reports whether two functions have the same value for the specified property. - */ - // hard to mix cuz different initial generics? - - // more generics - // eqProps(prop: Prop, obj1: T, obj2: U): boolean; - // eqProps(prop: Prop, obj1: T): (obj2: U) => boolean; - // eqProps(prop: Prop): CurriedFunction2; - // eqProps(prop: Prop): (obj1: T, obj2: U) => boolean; - // eqProps: CurriedFunction3; - - // less generics - // eqProps(prop: Prop, obj1: any, obj2: any): boolean; - // eqProps(prop: Prop, obj1: any): (obj2: any) => boolean; - // eqProps(prop: Prop): CurriedFunction2; - // eqProps(prop: Prop): (obj1: any, obj2: any) => boolean; - // eqProps(prop: Prop): (obj1: any) => (obj2: any) => boolean; - // eqProps: CurriedFunction3; - - // base - eqProps(prop: Prop, obj1: T, obj2: U): boolean; - eqProps(prop: Prop, obj1: T):{ - (obj2: U): boolean; - }; - eqProps(prop: Prop):{ - (obj1: T, obj2: U): boolean; - (obj1: T):{ - (obj2: U): boolean; - }; - }; - - // less generics - eqProps(prop: Prop, obj1: any, obj2: any): boolean; - eqProps(prop: Prop, obj1: any):{ - (obj2: any): boolean; - }; - eqProps(prop: Prop):{ - (obj1: any, obj2: any): boolean; - (obj1: any):{ - (obj2: any): boolean; - }; - }; - - - /** - * Returns true if its arguments are equivalent, false otherwise. Dispatches to an equals method if present. - * Handles cyclical data structures. - */ - equals(a: T, b: T): boolean; - equals(a: T): (b: T) => boolean; - // equals: CurriedFunction2; - - /** - * Creates a new object by evolving a shallow copy of object, according to the transformation functions. - */ - // hard to mix cuz different generics - - // NestedObj - evolve(transformations: NestedObj<(v: any) => any>, obj: V): V; - evolve(transformations: NestedObj<(v: any) => any>): (obj: V) => V; - // evolve: CurriedFunction2 any>, V, V>; - - // no inference, manually supply result type - evolve(transformations: Obj, obj: any): T; - evolve(transformations: Obj): (obj: any) => T; - // evolve: CurriedFunction2, any, T>; - - /* - * A function that always returns false. Any passed in parameters are ignored. - */ - F(): false; - - /** - * Returns a new list containing only those items that match a given predicate function. The predicate function is passed one argument: (value). - */ - - // array - filter(pred: Pred, list: List): T[]; - // filter(pred: Pred): (list: List) => T[]; // should disable for mixing, but this somehow makes #73 fail - // filter: CurriedFunction2, List, T[]>; - - // functor to functor - filter(pred: Pred, list: Functor): Functor; - // filter(pred: Pred): (list: Functor) => Functor; // mix - // filter: CurriedFunction2<(value: T) => boolean, Functor, Functor>; - - // functor to array - filter(pred: Pred, list: Functor): T[]; - // filter(pred: Pred): (list: Functor) => T[]; // mix - // filter: CurriedFunction2<(value: T) => boolean, Functor, T[]>; - - // object - // filter>(pred: Pred, obj: U) : Partial; - filter(pred: Pred): >(obj: U) => U; // mix - // filter>: CurriedFunction2<(value: T) => boolean, U, Partial>; - - // mixed - filter(pred: Pred): { - (list: List): T[]; - (list: Functor): Functor; - (list: Functor): T[]; - >(obj: U): U; - }; - - /** - * Returns the first element of the list which matches the predicate, or `undefined` if no - * element matches. - */ - find(fn: (a: T) => boolean, list: List): T; - find(fn: (a: T) => boolean): (list: List) => T; - // find: CurriedFunction2<(a: T) => boolean, List, T>; - - - /** - * Returns the index of the first element of the list which matches the predicate, or `-1` - * if no element matches. - */ - findIndex(fn: (a: T) => boolean, list: List): number; - findIndex(fn: (a: T) => boolean): (list: List) => number; - // findIndex: CurriedFunction2<(a: T) => boolean, List, number>; - - /** - * Returns the last element of the list which matches the predicate, or `undefined` if no - * element matches. - */ - findLast(fn: (a: T) => boolean, list: List): T; - findLast(fn: (a: T) => boolean): (list: List) => T; - // findLast: CurriedFunction2<(a: T) => boolean, List, T>; - - /** - * Returns the index of the last element of the list which matches the predicate, or - * `-1` if no element matches. - */ - findLastIndex(fn: (a: T) => boolean, list: List): number; - findLastIndex(fn: (a: T) => boolean): (list: List) => number; - // findLastIndex: CurriedFunction2<(a: T) => boolean, List, number>; - - /** - * Returns a new list by pulling every item out of it (and all its sub-arrays) and putting - * them in a new array, depth-first. - */ - // flatten(x: ArrayLike>>>>>>): T[]; - // flatten(x: ArrayLike>>>>>): T[]; - // flatten(x: ArrayLike>>>>): T[]; - // flatten(x: ArrayLike>>>): T[]; - // flatten(x: ArrayLike>>): T[]; - // flatten(x: ArrayLike>): T[]; - // flatten(x: ArrayLike): T[]; - // TODO: figure out how to handle arrays using different levels of nesting - // flatten(x: ListOfRecursiveArraysOrValues): T[]; - flatten(x: NestedArray): T[]; - - /** - * Returns a new function much like the supplied one, except that the first two arguments' - * order is reversed. - */ - flip(fn: (arg0: T, arg1: U) => TResult): (arg1: U, arg0?: T) => TResult; - flip(fn: (arg0: T, arg1: U, ...args: Rest[]) => TResult): (arg1: U, arg0?: T, ...args: Rest[]) => TResult; - - - /** - * Iterate over an input list, calling a provided function fn for each element in the list. - */ - forEach(fn: (x: T) => void, list: List): T[]; - forEach(fn: (x: T) => void): (list: List) => T[]; - // forEach: CurriedFunction2<(x: T) => void, List, T[]>; - - /** - * Iterate over an input object, calling a provided function fn for each key and value in the object. - */ - forEachObjIndexed>(fn: (val: T, key: string, obj?: Inp) => void, o: Inp): Inp; - forEachObjIndexed>(fn: (val: T, key: string, obj?: Inp) => void): (o: Inp) => Inp; - // forEachObjIndexed>: CurriedFunction2<(val: T, key: string, obj?: Inp) => void, Inp, Inp>; - - /** - * Creates a new object out of a list key-value pairs. - */ - fromPairs(pairs: List>): Obj; - - /** - * Splits a list into sublists stored in an object, based on the result of - * calling a String-returning function - * on each element, and grouping the results according to values returned. - */ - groupBy(fn: (a: T) => Prop, list: List): Obj; - groupBy(fn: (a: T) => Prop): (list: List) => Obj; - // groupBy: CurriedFunction2<(a: T) => Prop, List, Obj>; - - /** - * Takes a list and returns a list of lists where each sublist's elements are all "equal" according to the provided equality function - */ - groupWith>(fn: (x: T, y: T) => boolean, list: R): R[]; - groupWith>(fn: (x: T, y: T) => boolean): (list: R) => R[]; - // groupWith>: CurriedFunction2<(x: T, y: T) => boolean, R, R[]>; - - /** - * Returns true if the first parameter is greater than the second. - */ - gt(a: number, b: number): boolean; - gt(a: number): (b: number) => boolean; - // gt: CurriedFunction2; - - /** - * Returns true if the first parameter is greater than or equal to the second. - */ - gte(a: number, b: number): boolean; - gte(a: number): (b: number) => boolean; - // gte: CurriedFunction2; - - /** - * Returns whether or not an object has an own property with the specified name. - */ - - // no generics - has(s: Prop, obj: Struct): boolean; - has(s: Prop): (obj: Struct) => boolean; - // has: CurriedFunction2, boolean>; - - // // bound generic, hopefully gives a hint as to what goes into obj - // has>(s: Prop, obj: T): boolean; - // // has(s: Prop): >(obj: T) => boolean; // mix - // // has>: CurriedFunction2; - - // // free generic, helps make a few tests pass. TODO: kill this workaround? - // has(s: Prop, obj: T): boolean; - // // has(s: Prop): (obj: T) => boolean; // mix - // // has: CurriedFunction2; - - // // mixed - // has(s: Prop): { - // >(obj: T): boolean; - // (obj: T): boolean; - // } - - /** - * Returns whether or not an object or its prototype chain has a property with the specified name - */ - // = has - - // no generics - hasIn(s: Prop, obj: Struct): boolean; - hasIn(s: Prop): (obj: Struct) => boolean; - // hasIn: CurriedFunction2, boolean>; - - // // bound generic, hopefully gives a hint as to what goes into obj - // hasIn>(s: Prop, obj: T): boolean; - // // hasIn(s: Prop): >(obj: T) => boolean; // mix - // // hasIn>: CurriedFunction2; - - // // free generic, helps make a few tests pass. TODO: kill this workaround? - // hasIn(s: Prop, obj: T): boolean; - // // hasIn(s: Prop): (obj: T) => boolean; // mix - // // hasIn: CurriedFunction2; - - // // mixed - // hasIn(s: Prop): { - // >(obj: T): boolean; - // (obj: T): boolean; - // } - - /** - * Returns the first element in a list. - * In some libraries this function is named `first`. - */ - // head>(list: T): T[0]; - // tuple attempts; it doesn't like these. - head(list: [T]): T; - head(list: [T0, T1]): T0; - head(list: [T0, T1, T2]): T0; - - /** - * Returns true if its arguments are identical, false otherwise. Values are identical if they reference the - * same memory. NaN is identical to NaN; 0 and -0 are not identical. - */ - identical(a: T, b: T): boolean; - identical(a: T): (b: T) => boolean; - // identical: CurriedFunction2; - - /** - * A function that does nothing but return the parameter supplied to it. Good as a default - * or placeholder function. - */ - identity(a: T): T; - - /** - * Creates a function that will process either the onTrue or the onFalse function depending upon the result - * of the condition predicate. - */ - ifElse(fn: Pred, onTrue: (v: T) => U, onFalse: (v: T) => V): (v: T) => U|V; - // ifElse: CurriedFunction3, (v: T) => U, (v: T) => V, (v: T) => U|V>; - - - /** - * Increments its argument. - */ - inc(n: number): number; - - /** - * Given a function that generates a key, turns a list of objects into an object indexing the objects - * by the given key. - */ - indexBy(fn: (a: T) => Prop, list: List): Obj; - indexBy(fn: (a: T) => Prop): (list: List) => Obj; - // indexBy: CurriedFunction2<(a: T) => Prop, List, Obj>; - - /** - * Returns the position of the first occurrence of an item in an array - * (by strict equality), - * or -1 if the item is not included in the array. - */ - indexOf(target: T, list: List): number; - indexOf(target: T): (list: List) => number; - // indexOf: CurriedFunction2, number>; - - /** - * Returns all but the last element of a list. - */ - init>(list: T): T; - - /** - * Inserts the supplied element into the list, at index index. Note that - * this is not destructive: it returns a copy of the list with the changes. - */ - - // homogeneous list - // insert(index: number, elt: T, list: List): T[]; - // insert(index: number, elt: T): (list: List) => T[]; - // insert(index: number): CurriedFunction2, T[]>; - // insert(index: number): (elt: T, list: List) => T[]; - // insert(index: number): (elt: T) => (list: List) => T[]; - // insert: CurriedFunction3, T[]>; - - // base - insert(index: number, elt: T, list: List): T[]; - insert(index: number, elt: T):{ - (list: List): T[]; - }; - insert(index: number):{ - (elt: T, list: List): T[]; - (elt: T):{ - (list: List): T[]; - }; - }; - - - // TODO: tuples? - - /** - * Inserts the sub-list into the list, at index `index`. _Note that this - * is not destructive_: it returns a copy of the list with the changes. - */ - - // homogeneous lists (different types) - // insertAll(index: number, elts: List, list: List): Array; - // insertAll(index: number, elts: List): (list: List) => Array; - // insertAll(index: number): CurriedFunction2, List, Array>; - // insertAll(index: number): (elts: List, list: List) => Array; - // insertAll(index: number): (elts: List) => (list: List) => Array; - // insertAll: CurriedFunction3, List, Array>; - - // homogeneous lists (same type) - // insertAll>(index: number): CurriedFunction2; - - // TODO: allowing either or both arrays to be tuples? - - // base - insertAll(index: number, elts: List, list: List): Array; - insertAll(index: number, elts: List):{ - (list: List): Array; - }; - insertAll(index: number):{ - (elts: List, list: List): Array; - (elts: List):{ - (list: List): Array; - }; - }; - - - /** - * Combines two lists into a set (i.e. no duplicates) composed of those elements common to both lists. - */ - intersection(list1: List, list2: List): Array; - intersection(list1: List): (list2: List) => Array; - // intersection: CurriedFunction2, List, Array>; - - - /** - * Combines two lists into a set (i.e. no duplicates) composed of those - * elements common to both lists. Duplication is determined according - * to the value returned by applying the supplied predicate to two list - * elements. - */ - // intersectionWith(pred: (a: T, b: T) => boolean, list1: List, list2: List): T[]; - // intersectionWith(pred: (a: T, b: T) => boolean): CurriedFunction2, List, T[]>; - // intersectionWith: CurriedFunction3<(a: T, b: T) => boolean, List, List, T[]>; - - // base - intersectionWith(pred: (a: T, b: T) => boolean, list1: List, list2: List): T[]; - intersectionWith(pred: (a: T, b: T) => boolean, list1: List):{ - (list2: List): T[]; - }; - intersectionWith(pred: (a: T, b: T) => boolean):{ - (list1: List, list2: List): T[]; - (list1: List):{ - (list2: List): T[]; - }; - }; - - - /** - * Creates a new list with the separator interposed between elements. - */ - intersperse(separator: T, list: List): T[]; - intersperse(separator: T): (list: List) => T[]; - // intersperse: CurriedFunction2, T[]>; - - /** - * Transforms the items of the list with the transducer and appends the transformed items to the accumulator - * using an appropriate iterator function based on the accumulator type. - */ - // into>(acc: V, xf: (list: List) => U, list: List): U; - // into>(acc: V, xf: (list: List) => U): (list: List) => U; - // into>(acc: V): CurriedFunction2<(list: List) => U, List, U>; - // into>(acc: V): (xf: (list: List) => U, list: List) => U; - // into>(acc: V): (xf: (list: List) => U) => (list: List) => U; - // into>: CurriedFunction3) => U, List, U>; - - // base - into, T, U>(acc: V, xf: (list: List) => U, list: List): U; - into, T, U>(acc: V, xf: (list: List) => U):{ - (list: List): U; - }; - into, T, U>(acc: V):{ - (xf: (list: List) => U, list: List): U; - (xf: (list: List) => U):{ - (list: List): U; - }; - }; - - - /** - * Same as R.invertObj, however this accounts for objects with duplicate values by putting the values into an array. - */ - invert(obj: Struct): Obj>; - - /** - * Returns a new object with the keys of the given object as values, and the values of the given object as keys. - */ - invertObj(obj: Struct): Obj; - - /** - * Turns a named method of an object (or object prototype) into a function that can be - * called directly. Passing the optional `len` parameter restricts the returned function to - * the initial `len` parameters of the method. - * - * The returned function is curried and accepts `len + 1` parameters (or `method.length + 1` - * when `len` is not specified), and the final parameter is the target object. - */ - // with keyof -- currently can't seem do to function application like this yet - // invoker (len: number /* = 0 */, name: K, obj: T): obj[K](); - // // invoker: CurriedFunction3; - // invoker(len: number /* = 1 */, name: K, x1: P1, obj: T): obj[K](x1); - // // invoker: CurriedFunction4; - // invoker(len: number /* = 2 */, name: K, x1: P1, x2: P2, obj: T): obj[K](x1, x2); - // // invoker: CurriedFunction5; - // invoker(len: number /* = 3 */, name: K, x1: P1, x2: P2, x3: P3, obj: T): obj[K](x1, x2, x3); - // // invoker: CurriedFunction6; - // invoker(len: number /* = 4 */, name: K, x1: P1, x2: P2, x3: P3, x4: P4, obj: T): obj[K](x1, x2, x3, x4); - // // invoker: CurriedFunction7; - // invoker(len: number /* = 5 */, name: K, x1: P1, x2: P2, x3: P3, x4: P4, x5: P5, obj: T): obj[K](x1, x2, x3, x4, x5); - // // invoker: CurriedFunction8; - - // manually type results - invoker (len: number /* = 0 */, name: Prop, obj: T): R; - invoker (len: number/* = 0 */, name: Prop): (obj: T) => R; - - invoker(len: number /* = 1 */, name: Prop, x1: P1, obj: T): R; - invoker(len: number /* = 1 */, name: Prop): CurriedFunction2; - - invoker(len: number /* = 2 */, name: Prop, x1: P1, x2: P2, obj: T): R; - invoker(len: number /* = 2 */, name: Prop): CurriedFunction3; - - invoker(len: number /* = 3 */, name: Prop, x1: P1, x2: P2, x3: P3, obj: T): R; - invoker(len: number /* = 3 */, name: Prop): CurriedFunction4; - - invoker(len: number /* = 4 */, name: Prop, x1: P1, x2: P2, x3: P3, x4: P4, obj: T): R; - invoker(len: number /* = 4 */, name: Prop): CurriedFunction5; - - invoker(len: number /* = 5 */, name: Prop, x1: P1, x2: P2, x3: P3, x4: P4, x5: P5, obj: T): R; - invoker(len: number /* = 5 */, name: Prop): CurriedFunction6; - - /** - * See if an object (`val`) is an instance of the supplied constructor. - * This function will check up the inheritance chain, if any. - */ - is(ctor: Type, val: any): val is T; - is(ctor: Type): (val: any) => val is T; - // is: CurriedFunction2; // um, val undefined - - /** - * Tests whether or not an object is similar to an array. - * @deprecated: 0.23.0 - */ - isArrayLike(val: any): val is List; - // isArrayLike(val: any): boolean; - - /** - * Reports whether the list has zero elements. - */ - isEmpty(value: any): boolean; - - - /** - * Returns true if the input value is NaN. - */ - isNaN(x: any): boolean; - - /** - * Checks if the input value is null or undefined. - */ - isNil(value: any): boolean; - - /** - * Returns a string made by inserting the `separator` between each - * element and concatenating all the elements into a single string. - */ - join(x: Prop, xs: Array): string; - join(x: Prop): (xs: Array) => string; - // join: CurriedFunction2, string>; - - /** - * Applies a list of functions to a list of values. - */ - juxt(fns: {(...args: T[]): U}[]): (...args: T[]) => U[]; - - - /** - * Returns a list containing the names of all the enumerable own - * properties of the supplied object. - */ - keys(x: Struct): string[]; - - /** - * Returns a list containing the names of all the - * properties of the supplied object, including prototype properties. - */ - keysIn(obj: Struct): string[]; - - /** - * Returns the last element from a list. - */ - last>(list: R): T; - - /** - * Returns the position of the last occurrence of an item (by strict equality) in - * an array, or -1 if the item is not included in the array. - */ - // = indexOf - lastIndexOf(target: T, list: List): number; - lastIndexOf(target: T): (list: List) => number; - // lastIndexOf: CurriedFunction2, number>; - - /** - * Returns the number of elements in the array by returning list.length. - */ - length(list: List): number; - - /** - * Returns a lens for the given getter and setter functions. The getter - * "gets" the value of the focus; the setter "sets" the value of the focus. - * The setter should not mutate the data structure. - */ - // hard to mix cuz different generics - - // assume setter doesn't change the type - lens>(getter: (s: U) => V, setter: (a: V, s: U) => U): ManualLens; - lens>(getter: (s: U) => V): (setter: (a: V, s: U) => U) => ManualLens; - lens(getter: (s: Struct) => V): >(setter: (a: V, s: U) => U) => ManualLens; - // ^ ignore getter param being `U` so I can get away with 1 manual generic rather than having to add the inferred `U`. Useful if the getter doesn't have an explicit return type. - // lens>: CurriedFunction2<(s: U) => V, (a: V, s: U) => U, ManualLens>; - - // allows setter to change value type - lens(getter: (s: T) => U, setter: (a: U, s: T) => V): Lens; - lens(getter: (s: T) => U): (setter: (a: U, s: T) => V) => Lens; - // lens: CurriedFunction2<(s: T) => U, (a: U, s: T) => V, Lens>; - - /** - * Creates a lens that will focus on index n of the source array. - */ - // lensIndex(n: K): KeyLens; - lensIndex(n: number): ManualLens; - lensIndex(n: number): UnknownLens; - - /** - * Returns a lens whose focus is the specified path. - * See also view, set, over. - */ - lensPath(path: Path): ManualLens; - lensPath(path: Path): UnknownLens; - - /** - * lensProp creates a lens that will focus on property k of the source object. - */ - // lensProp(n: K): KeyLens; - lensProp(prop: Prop): ManualLens; - lensProp(prop: Prop): UnknownLens; - - /** - * "lifts" a function of arity > 1 so that it may "map over" a list, Function or other object that satisfies - * the FantasyLand Apply spec. - */ - lift(fn: () => TResult): () => TResult[]; - lift(fn: (v1: T1) => TResult): (v1: List) => TResult[]; - lift(fn: (v1: T1, v2: T2) => TResult): (v1: List, v2: List) => TResult[]; - lift(fn: (v1: T1, v2: T2, v3: T3) => TResult): (v1: List, v2: List, v3: List) => TResult[]; - lift(fn: (v1: T1, v2: T2, v3: T3, v4: T4) => TResult): (v1: List, v2: List, v3: List, v4: List) => TResult[]; - lift(fn: (v1: T1, v2: T2, v3: T3, v4: T4, v5: T5) => TResult): (v1: List, v2: List, v3: List, v4: List, v5: List) => TResult[]; - lift(fn: (v1: T1, v2: T2, v3: T3, v4: T4, v5: T5, v6: T6) => TResult): (v1: List, v2: List, v3: List, v4: List, v5: List, v6: List) => TResult[]; - lift(fn: (v1: T1, v2: T2, v3: T3, v4: T4, v5: T5, v6: T6, v7: T7) => TResult): (v1: List, v2: List, v3: List, v4: List, v5: List, v6: List, v7: List) => TResult[]; - lift(fn: (v1: T1, v2: T2, v3: T3, v4: T4, v5: T5, v6: T6, v7: T7, v8: T8) => TResult): (v1: List, v2: List, v3: List, v4: List, v5: List, v6: List, v7: List, v8: List) => TResult[]; - lift(fn: Variadic): (...argLists: any[][]) => T[]; - - /** - * "lifts" a function to be the specified arity, so that it may "map over" that many lists, Functions or other - * objects that satisfy the FantasyLand Apply spec. - */ - liftN(n: number, fn: () => TResult): () => TResult[]; - liftN(n: number, fn: (v1: T1) => TResult): (v1: List) => TResult[]; - liftN(n: number, fn: (v1: T1, v2: T2) => TResult): (v1: List, v2: List) => TResult[]; - liftN(n: number, fn: (v1: T1, v2: T2, v3: T3) => TResult): (v1: List, v2: List, v3: List) => TResult[]; - liftN(n: number, fn: (v1: T1, v2: T2, v3: T3, v4: T4) => TResult): (v1: List, v2: List, v3: List, v4: List) => TResult[]; - liftN(n: number, fn: (v1: T1, v2: T2, v3: T3, v4: T4, v5: T5) => TResult): (v1: List, v2: List, v3: List, v4: List, v5: List) => TResult[]; - liftN(n: number, fn: (v1: T1, v2: T2, v3: T3, v4: T4, v5: T5, v6: T6) => TResult): (v1: List, v2: List, v3: List, v4: List, v5: List, v6: List) => TResult[]; - liftN(n: number, fn: (v1: T1, v2: T2, v3: T3, v4: T4, v5: T5, v6: T6, v7: T7) => TResult): (v1: List, v2: List, v3: List, v4: List, v5: List, v6: List, v7: List) => TResult[]; - liftN(n: number, fn: (v1: T1, v2: T2, v3: T3, v4: T4, v5: T5, v6: T6, v7: T7, v8: T8) => TResult): (v1: List, v2: List, v3: List, v4: List, v5: List, v6: List, v7: List, v8: List) => TResult[]; - - liftN(n: number): { - (fn: () => TResult): () => TResult[]; - (fn: (v1: T1) => TResult): (v1: List) => TResult[]; - (fn: (v1: T1, v2: T2) => TResult): (v1: List, v2: List) => TResult[]; - (fn: (v1: T1, v2: T2, v3: T3) => TResult): (v1: List, v2: List, v3: List) => TResult[]; - (fn: (v1: T1, v2: T2, v3: T3, v4: T4) => TResult): (v1: List, v2: List, v3: List, v4: List) => TResult[]; - (fn: (v1: T1, v2: T2, v3: T3, v4: T4, v5: T5) => TResult): (v1: List, v2: List, v3: List, v4: List, v5: List) => TResult[]; - (fn: (v1: T1, v2: T2, v3: T3, v4: T4, v5: T5, v6: T6) => TResult): (v1: List, v2: List, v3: List, v4: List, v5: List, v6: List) => TResult[]; - (fn: (v1: T1, v2: T2, v3: T3, v4: T4, v5: T5, v6: T6, v7: T7) => TResult): (v1: List, v2: List, v3: List, v4: List, v5: List, v6: List, v7: List) => TResult[]; - (fn: (v1: T1, v2: T2, v3: T3, v4: T4, v5: T5, v6: T6, v7: T7, v8: T8) => TResult): (v1: List, v2: List, v3: List, v4: List, v5: List, v6: List, v7: List, v8: List) => TResult[]; - - (fn: Variadic): (...argLists: any[][]) => T[]; - }; - - liftN(n: number, fn: Variadic): (...argLists: any[][]) => T[]; - // liftN: CurriedFunction2, (...argLists: any[][]) => T[]>; - - /** - * Returns true if the first parameter is less than the second. - */ - lt(a: number, b: number): boolean; - lt(a: number): (b: number) => boolean; - // lt: CurriedFunction2; - - /** - * Returns true if the first parameter is less than or equal to the second. - */ - lte(a: number, b: number): boolean; - lte(a: number): (b: number) => boolean; - // lte: CurriedFunction2; - - /** - * Returns a new list, constructed by applying the supplied function to every element of the supplied list. - */ - - // homogeneous: - - // array-like - map(fn: (x: T) => U, list: List): U[]; - // map(fn: (x: T) => U): (list: List) => U[]; // disabling for mix breaks a few tests? - // map: CurriedFunction2<(x: T) => U, List, U[]>; - - // object: keyof version - map>(fn: (value: T) => U, obj: M): Obj; - map>(fn: (value: T) => U, obj: M): Obj; - // map(fn: (value: T) => U): >(obj: M) => {[K in keyof M]: U}; // mix - // map>: CurriedFunction2<(value: T) => U, M, {[K in keyof M]: U}>; - - // object: Record version - map(f: (x: T) => U, obj:Obj): Obj; - // map(f: (x: T) => U): (obj: Record) => Record; // mix - // map: CurriedFunction2<(x: T) => U, Record), Record>; - - // functor - map(fn: (x: T) => U, obj: Functor): Functor; - // map(fn: (x: T) => U): (obj: Functor) => Functor; // mix - // map: CurriedFunction2<(x: T) => U, Functor, Functor>; - - // separating values: https://github.com/Microsoft/TypeScript/issues/12342 - // map(fn: (a: A) => B, tpl: [T,U]): [ typeof fn(T), typeof fn(U) ]; - // obj. version? - - // TODO: heterogeneous versions - - // array-like - // map(fn: (x: T) => U, list: [T1, T2]): [fn(T1), fn(T1)]; - // map(fn: F, list: [T1, T2]): [F(T1), F(T1)]; - // map(fn: (x: T) => U, list: [T1, T2]): [typeof fn(T1), typeof fn(T1)]; - // map(fn: F, list: [T1, T2]): [typeof F(T1), typeof F(T1)]; - // (list: [T1, T2]): [fn(T1), fn(T1)]; - - // object - - // mixed: - map(fn: (x: T) => U): { - >(obj: M): Obj; - (obj: Obj): Obj; - (obj: Functor): Functor; - (list: List): U[]; - }; - - /** - * The mapAccum function behaves like a combination of map and reduce. - */ - // mapAccum(fn: (acc: U, value: T) => [U, TResult], acc: U, list: List): [U, TResult[]]; - // mapAccum(fn: (acc: U, value: T) => [U, TResult], acc: U): (list: List) => [U, TResult[]]; - // mapAccum(fn: (acc: U, value: T) => [U, TResult]): CurriedFunction2,[U, TResult[]]>; - // mapAccum: CurriedFunction3<(acc: U, value: T) => [U, TResult], U, List, [U, TResult[]]>; - - // base - mapAccum(fn: (acc: U, value: T) => [U, TResult], acc: U, list: List): [U, TResult[]]; - mapAccum(fn: (acc: U, value: T) => [U, TResult], acc: U):{ - (list: List): [U, TResult[]]; - }; - mapAccum(fn: (acc: U, value: T) => [U, TResult]):{ - (acc: U, list: List): [U, TResult[]]; - (acc: U):{ - (list: List): [U, TResult[]]; - }; - }; - - - /** - * The mapAccumRight function behaves like a combination of map and reduce. - */ - // mapAccumRight(fn: (value: T, acc: U) => [TResult, U], acc: U, list: List): [TResult[], U]; - // mapAccumRight(fn: (value: T, acc: U) => [TResult, U], acc: U): (list: List) => [TResult[], U]; - // mapAccumRight(fn: (value: T, acc: U) => [TResult, U]): CurriedFunction2, [TResult[], U]>; - // mapAccumRight: CurriedFunction3<(value: T, acc: U) => [TResult, U], U, List, [TResult[], U]>; - - // base - mapAccumRight(fn: (value: T, acc: U) => [TResult, U], acc: U, list: List): [TResult[], U]; - mapAccumRight(fn: (value: T, acc: U) => [TResult, U], acc: U):{ - (list: List): [TResult[], U]; - }; - mapAccumRight(fn: (value: T, acc: U) => [TResult, U]):{ - (acc: U, list: List): [TResult[], U]; - (acc: U):{ - (list: List): [TResult[], U]; - }; - }; - - - /** - * Like map, but but passes additional parameters to the mapping function. - */ - mapIndexed>(fn: (val: T, key: number, list: V) => U, list: V): U[]; - mapIndexed>(fn: (val: T, key: number, list: V) => U): (list: V) => U[]; - // mapIndexed>: CurriedFunction2<(val: T, key: number, list: V) => U, V, U[]>; - - - /** - * Like mapObj, but but passes additional arguments to the predicate function. - */ - // hard to mix cuz different generics - - // keyof - mapObjIndexed>(fn: (value: T, key: string, obj?: M) => V, obj: M): Obj; - mapObjIndexed>(fn: (value: T, key: string, obj?: M) => V): (obj: M) => Obj; - // mapObjIndexed>: CurriedFunction2<(value: T, key: string, obj?: M) => V, M, {[K in keyof M]: V}>; - - // Record - mapObjIndexed(f: (value: T, key: string, obj?: Record) => U, obj: Obj): Obj; - mapObjIndexed(f: (value: T, key: string, obj?: Record) => U): (obj: Obj) => Obj; // potentially overwriting K but whatever - // mapObjIndexed: CurriedFunction2<(value: T, key: string, obj?: Record) => U, Record), Record>; - - /** - * Tests a regular expression agains a String - */ - match(regexp: RegExp, str: string): string[]; - match(regexp: RegExp): (str: string) => string[]; - // match: CurriedFunction2; - - - /** - * mathMod behaves like the modulo operator should mathematically, unlike the `%` - * operator (and by extension, R.modulo). So while "-17 % 5" is -2, - * mathMod(-17, 5) is 3. mathMod requires Integer arguments, and returns NaN - * when the modulus is zero or negative. - */ - // |NaN? what's its type? - mathMod(a: number, b: number): number; - mathMod(a: number): (b: number) => number; - // mathMod: CurriedFunction2; - - - /** - * Returns the larger of its two arguments. - */ - max(a: T, b: T): T; - max(a: T): (b: T) => T; - // max: CurriedFunction2; - - /** - * Takes a function and two values, and returns whichever value produces - * the larger result when passed to the provided function. - */ - // maxBy(keyFn: (a: T) => Ord, a: T, b: T): T; - // maxBy(keyFn: (a: T) => Ord): CurriedFunction2; - // maxBy: CurriedFunction3<(a: T) => Ord, T, T, T>; - - // base - maxBy(keyFn: (a: T) => Ord, a: T, b: T): T; - maxBy(keyFn: (a: T) => Ord, a: T):{ - (b: T): T; - }; - maxBy(keyFn: (a: T) => Ord):{ - (a: T, b: T): T; - (a: T):{ - (b: T): T; - }; - }; - - - /** - * Returns the mean of the given list of numbers. - */ - mean(list: List): number; - - /** - * Returns the median of the given list of numbers. - */ - median(list: List): number; - - /** - * Creates a new function that, when invoked, caches the result of calling fn for a given argument set and - * returns the result. Subsequent calls to the memoized fn with the same argument set will not result in an - * additional call to fn; instead, the cached result for that set of arguments will be returned. - */ - memoize(fn: Variadic): Variadic; - - merge: typeof merge - - - /** - * Merges a list of objects together into one object. - */ - mergeAll(list: List): T; - - /** - * Creates a new object with the own properties of the two provided objects. If a key exists in both objects, - * the provided function is applied to the values associated with the key in each object, with the result being used as - * the value associated with the key in the returned object. The key will be excluded from the returned object if the - * resulting value is undefined. - */ - // mergeWith(fn: (x: any, z: any) => any, a: U, b: V): U & V; - // mergeWith(fn: (x: any, z: any) => any, a: U): (b: V) => U & V; - // // mergeWith(fn: (x: any, z: any) => any): (a: U, b: V) => U & V; - // mergeWith(fn: (x: any, z: any) => any): CurriedFunction2; - // // mergeWith: CurriedFunction3<(x: any, z: any) => any, U, V, U & V>; - - // base - mergeWith(fn: (x: any, z: any) => any, a: U, b: V): U & V; - mergeWith(fn: (x: any, z: any) => any, a: U):{ - (b: V): U & V; - }; - mergeWith(fn: (x: any, z: any) => any):{ - (a: U, b: V): U & V; - (a: U):{ - (b: V): U & V; - }; - }; - - - /** - * Creates a new object with the own properties of the two provided objects. If a key exists in both objects, - * the provided function is applied to the key and the values associated with the key in each object, with the - * result being used as the value associated with the key in the returned object. The key will be excluded from - * the returned object if the resulting value is undefined. - */ - // mergeWithKey(fn: (str: string, x: any, z: any) => any, a: U, b: V): U & V; - // mergeWithKey(fn: (str: string, x: any, z: any) => any, a: U): (b: V) => U & V; - // // mergeWithKey(fn: (str: string, x: any, z: any) => any): (a: U, b: V) => U & V; - // mergeWithKey(fn: (str: string, x: any, z: any) => any): CurriedFunction2; - // // mergeWithKey: CurriedFunction3<(str: string, x: any, z: any) => any, U, V, U & V>; - - // mergeWithKey - mergeWithKey(fn: (str: string, x: any, z: any) => any, a: U, b: V): U & V; - mergeWithKey(fn: (str: string, x: any, z: any) => any, a: U):{ - (b: V): U & V; - }; - mergeWithKey(fn: (str: string, x: any, z: any) => any):{ - (a: U, b: V): U & V; - (a: U):{ - (b: V): U & V; - }; - }; - - - /** - * Returns the smaller of its two arguments. - */ - min(a: T, b: T): T; - min(a: T): (b: T) => T; - // min: CurriedFunction2; - - /** - * Takes a function and two values, and returns whichever value produces - * the smaller result when passed to the provided function. - */ - // minBy(keyFn: (a: T) => Ord, a: T, b: T): T; - // minBy(keyFn: (a: T) => Ord): CurriedFunction2; - // // minBy: CurriedFunction3<(a: T) => Ord, T, T, T>; - - // base - minBy(keyFn: (a: T) => Ord, a: T, b: T): T; - minBy(keyFn: (a: T) => Ord, a: T):{ - (b: T): T; - }; - minBy(keyFn: (a: T) => Ord):{ - (a: T, b: T): T; - (a: T):{ - (b: T): T; - }; - }; - - - /** - * Divides the second parameter by the first and returns the remainder. - * The flipped version (`moduloBy`) may be more useful curried. - * Note that this functions preserves the JavaScript-style behavior for - * modulo. For mathematical modulo see `mathMod` - */ - modulo(a: number, b: number): number; - modulo(a: number): (b: number) => number; - // modulo: CurriedFunction2; - - /** - * Multiplies two numbers. Equivalent to a * b but curried. - */ - multiply(a: number, b: number): number; - multiply(a: number): (b: number) => number; - // multiply: CurriedFunction2; - - - /** - * Wraps a function of any arity (including nullary) in a function that accepts exactly n parameters. - * Any extraneous parameters will not be passed to the supplied function. - */ - nAry(n: number, fn: Variadic): Variadic; - nAry(n: number): (fn: Variadic) => Variadic; - // nAry: CurriedFunction2, Variadic>; - - /** - * Negates its argument. - */ - negate(n: number): number; - - - /** - * Returns true if no elements of the list match the predicate, false otherwise. - */ - none(fn: (a: T) => boolean, list: List): boolean; - none(fn: (a: T) => boolean): (list: List) => boolean; - // none: CurriedFunction2<(a: T) => boolean, List, boolean>; - - - /** - * A function wrapping a call to the given function in a `!` operation. It will return `true` when the - * underlying function would return a false-y value, and `false` when it would return a truth-y one. - */ - not(value: any): boolean; - - /** - * Returns the nth element in a list. - */ - nth(n: number, list: List): T; - nth(n: number): (list: List) => T; - // nth: CurriedFunction2, T>; - - /** - * Returns a function which returns its nth argument. - */ - nthArg(n: number): (...a: T[]) => T; - - /** - * Creates an object containing a single key:value pair. - */ - - // Record-based, key intact - objOf>(key: K, value: V): T; - objOf(key: K): >(value: V) => T; - // objOf>: CurriedFunction2; - - // // Obj-based, loses key - // objOf(key: Prop, value: T): Obj; - // objOf(key: Prop): (value: T) => Obj; - // // objOf: CurriedFunction2>; - - /** - * Returns a singleton array containing the value provided. - */ - of(x: T): T[]; - - /** - * Returns a partial copy of an object omitting the keys specified. - */ - omit(names: List, obj: T): T; - omit(names: List): (obj: T) => T; - // omit: CurriedFunction2, T, T>; - - /** - * Accepts a function fn and returns a function that guards invocation of fn such that fn can only ever be - * called once, no matter how many times the returned function is invoked. The first value calculated is - * returned in subsequent invocations. - */ - once(fn: Variadic): Variadic; - - /** - * A function that returns the first truthy of two arguments otherwise the last argument. Note that this is - * NOT short-circuited, meaning that if expressions are passed they are both evaluated. - * Dispatches to the or method of the first argument if applicable. - */ - // hard to mix cuz different generics - - // values - or(a: T, b: U): T|U; - or(a: T): (b: U) => T|U; - // or: CurriedFunction2; - - // dispatch to some `or` method: - or T|U;}, U>(fn1: T, val2: U): T|U; - or T|U;}, U>(fn1: T): (val2: U) => T|U; - // or T|U;}, U>: CurriedFunction2; - - /** - * Returns the result of "setting" the portion of the given data structure - * focused by the given lens to the given value. - */ - // hard to mix cuz different generics - - // key lens: - over(lens: UnknownLens, fn: (v: any) => any, value: T): T; - over(lens: UnknownLens, fn: (v: any) => any): (value: T) => T; - // over(lens: KeyLens): (fn: (v: T[K]) => T[K], value: T) => T; - over(lens: UnknownLens): CurriedFunction2<(v: any) => any, T, T>; - // over: CurriedFunction3, (v: T[K]) => T[K], T, T>; - - // regular lenses: - - // // Functor version: - // over>(lens: Lens|ManualLens|UnknownLens, fn: (v: V) => V, value: T): T; - // over(lens: ManualLens|UnknownLens, fn: (v: V) => V): >(value: T) => T; - // over>(lens: Lens|ManualLens|UnknownLens): CurriedFunction2<(v: V) => V, T, T>; - // // over>(lens: Lens|ManualLens|UnknownLens): (fn: (v: V) => V, value: T) => T; - // // over>: CurriedFunction3, (v: V) => V, T, T>; - - // // Functor version applied to array: - // over>(lens: Lens|ManualLens|UnknownLens, fn: (v: V) => V, value: T): V[]; - // over>(lens: Lens|ManualLens|UnknownLens, fn: (v: V) => V): (value: T) => V[]; - // over>(lens: Lens|ManualLens|UnknownLens): CurriedFunction2<(v: V) => V, T, V[]>; - // // over>(lens: Lens|ManualLens|UnknownLens): (fn: (v: V) => V, value: T) => V[]; - // // over>: CurriedFunction3|ManualLens|UnknownLens, (v: V) => V, T, V[]>; - - // // unbound value: - // over(lens: Lens|ManualLens|UnknownLens, fn: (v: V) => V, value: T): T; - // over(lens: ManualLens|UnknownLens, fn: (v: V) => V): (value: T) => T; - // // over(lens: UnknownLens): (fn: (v: V) => V, value: T) => T; - // over(lens: UnknownLens): CurriedFunction2<(v: V) => V, T, T>; - // // over: CurriedFunction3, (v: V) => V, T, T>; - - // Functor version - over>(lens: Lens|ManualLens|UnknownLens, fn: (v: V) => V, value: T): T; - over>(lens: Lens|ManualLens|UnknownLens, fn: (v: V) => V):{ - (value: T): T; - }; - over>(lens: Lens|ManualLens|UnknownLens):{ - (fn: (v: V) => V, value: T): T; - (fn: (v: V) => V):{ - (value: T): T; - }; - }; - - // Functor version applied to array - over>(lens: Lens|ManualLens|UnknownLens, fn: (v: V) => V, value: T): V[]; - over>(lens: Lens|ManualLens|UnknownLens, fn: (v: V) => V):{ - (value: T): V[]; - }; - over>(lens: Lens|ManualLens|UnknownLens):{ - (fn: (v: V) => V, value: T): V[]; - (fn: (v: V) => V):{ - (value: T): V[]; - }; - }; - - // unbound value - over(lens: Lens|ManualLens|UnknownLens, fn: (v: V) => V, value: T): T; - over(lens: Lens|ManualLens|UnknownLens, fn: (v: V) => V):{ - (value: T): T; - }; - over(lens: Lens|ManualLens|UnknownLens):{ - (fn: (v: V) => V, value: T): T; - (fn: (v: V) => V):{ - (value: T): T; - }; - }; - - - /** - * Takes two arguments, fst and snd, and returns [fst, snd]. - */ - pair(fst: F, snd: S): [F, S]; - pair(fst: F): (snd: S) => [F, S]; - // pair: CurriedFunction2; - - /** - * Accepts as its arguments a function and any number of values and returns a function that, - * when invoked, calls the original function with all of the values prepended to the - * original function's arguments list. In some libraries this function is named `applyLeft`. - */ - partial(fn: Variadic, args: any[]): Variadic; - partial(fn: Variadic): (args: any[]) => Variadic; - // partial: CurriedFunction2, args: any[], Variadic>; - // TODO: fixed-arity versions - - /** - * Accepts as its arguments a function and any number of values and returns a function that, - * when invoked, calls the original function with all of the values appended to the original - * function's arguments list. - */ - partialRight(fn: Variadic, args: any[]): Variadic; - partialRight(fn: Variadic): (args: any[]) => Variadic; - // partialRight: CurriedFunction2, args: any[], Variadic>; - // TODO: fixed-arity versions - - /** - * Takes a predicate and a list and returns the pair of lists of elements - * which do and do not satisfy the predicate, respectively. - */ - // arrays - partition(fn: (a: T) => boolean, list: List): [T[], T[]]; - partition(fn: (a: T) => boolean): (list: List) => [T[], T[]]; - // partition: CurriedFunction2<(a: T) => boolean, List, [T[], T[]]>; - // objects - partition,U extends Obj,V>(fn: (a: V) => boolean, obj: T & U) : [T,U]; - // partition,U extends Obj,V>: CurriedFunction2<(a: T) => boolean, obj: T & U, [T,U]>; - // objects, alternative notation - partition>(fn: (a: T) => boolean, obj: U) : [Obj, Obj]; - // partition>: CurriedFunction2<(a: T) => boolean, U, [Partial,Partial]>; - - /** - * Retrieve the value at a given path. - */ - - // fixed-length versions - - // simpler versions, able to deal only with objects, not arrays: - - // // in-based - // path(path: [T1, T2], obj: {[K1 in T1]: {[K2 in T2]: TResult}}): TResult; - // path(path: [T1, T2, T3], obj: {[K1 in T1]: {[K2 in T2]: {[K3 in T3]: TResult}}}): TResult; - // path(path: [T1, T2, T3, T4], obj: {[K1 in T1]: {[K2 in T2]: {[K3 in T3]: {[K4 in T4]: TResult}}}}): TResult; - // path(path: [T1, T2, T3, T4, T5], obj: {[K1 in T1]: {[K2 in T2]: {[K3 in T3]: {[K4 in T4]: {[K5 in T5]: TResult}}}}}): TResult; - // path(path: [T1, T2, T3, T4, T5, T6], obj: {[K1 in T1]: {[K2 in T2]: {[K3 in T3]: {[K4 in T4]: {[K5 in T5]: {[K6 in T6]: TResult}}}}}}): TResult; - // path(path: [T1, T2, T3, T4, T5, T6, T7], obj: {[K1 in T1]: {[K2 in T2]: {[K3 in T3]: {[K4 in T4]: {[K5 in T5]: {[K6 in T6]: {[K7 in T7]: TResult}}}}}}}): TResult; - // path(path: [T1, T2, T3, T4, T5, T6, T7, T8], obj: {[K1 in T1]: {[K2 in T2]: {[K3 in T3]: {[K4 in T4]: {[K5 in T5]: {[K6 in T6]: {[K7 in T7]: {[K8 in T8]: TResult}}}}}}}}): TResult; - // path(path: [T1, T2, T3, T4, T5, T6, T7, T8, T9], obj: {[K1 in T1]: {[K2 in T2]: {[K3 in T3]: {[K4 in T4]: {[K5 in T5]: {[K6 in T6]: {[K7 in T7]: {[K8 in T8]: {[K9 in T9]: TResult}}}}}}}}}): TResult; - - // // Record-based - // path(path: [K1, K2], obj: Record>): TResult; - // path(path: [K1, K2, K3], obj: Record>>): TResult; - // path(path: [K1, K2, K3, K4], obj: Record>>>): TResult; - // path(path: [K1, K2, K3, K4, K5], obj: Record>>>>): TResult; - // path(path: [K1, K2, K3, K4, K5, K6], obj: Record>>>>>): TResult; - // path(path: [K1, K2, K3, K4, K5, K6, K7], obj: Record>>>>>>): TResult; - // path(path: [K1, K2, K3, K4, K5, K6, K7, K8], obj: Record>>>>>>>): TResult; - // path(path: [K1, K2, K3, K4, K5, K6, K7, K8, K9], obj: Record>>>>>>>>): TResult; - - // // for each path length list all combinations of objects and homogeneous arrays... tuples not supported yet. - - // path(path: [T1], obj: {[K1 in T1]: TResult}): TResult; - // path(path: [T1], obj: TResult[]): TResult; - // path(path: [T1, T2], obj: {[K1 in T1]: {[K2 in T2]: TResult}}): TResult; - // path(path: [T1, T2], obj: {[K1 in T1]: TResult[]}): TResult; - // path(path: [T1, T2], obj: {[K2 in T2]: TResult}[]): TResult; - // path(path: [T1, T2], obj: TResult[][]): TResult; - // path(path: [T1, T2, T3], obj: {[K1 in T1]: {[K2 in T2]: {[K3 in T3]: TResult}}}): TResult; - // path(path: [T1, T2, T3], obj: {[K1 in T1]: {[K2 in T2]: TResult[]}}): TResult; - // path(path: [T1, T2, T3], obj: {[K1 in T1]: {[K3 in T3]: TResult}[]}): TResult; - // path(path: [T1, T2, T3], obj: {[K1 in T1]: TResult[][]}): TResult; - // path(path: [T1, T2, T3], obj: {[K2 in T2]: {[K3 in T3]: TResult}}[]): TResult; - // path(path: [T1, T2, T3], obj: {[K2 in T2]: TResult[]}[]): TResult; - // path(path: [T1, T2, T3], obj: {[K3 in T3]: TResult}[][]): TResult; - // path(path: [T1, T2, T3], obj: TResult[][][]): TResult; - // path(path: [T1, T2, T3, T4], obj: {[K1 in T1]: {[K2 in T2]: {[K3 in T3]: {[K4 in T4]: TResult}}}}): TResult; - // path(path: [T1, T2, T3, T4], obj: {[K1 in T1]: {[K2 in T2]: {[K3 in T3]: TResult[]}}}): TResult; - // path(path: [T1, T2, T3, T4], obj: {[K1 in T1]: {[K2 in T2]: {[K4 in T4]: TResult}[]}}): TResult; - // path(path: [T1, T2, T3, T4], obj: {[K1 in T1]: {[K2 in T2]: TResult[][]}}): TResult; - // path(path: [T1, T2, T3, T4], obj: {[K1 in T1]: {[K3 in T3]: {[K4 in T4]: TResult}}[]}): TResult; - // path(path: [T1, T2, T3, T4], obj: {[K1 in T1]: {[K3 in T3]: TResult[]}[]}): TResult; - // path(path: [T1, T2, T3, T4], obj: {[K1 in T1]: {[K4 in T4]: TResult}[][]}): TResult; - // path(path: [T1, T2, T3, T4], obj: {[K1 in T1]: TResult[][][]}): TResult; - // path(path: [T1, T2, T3, T4], obj: {[K2 in T2]: {[K3 in T3]: {[K4 in T4]: TResult}}}[]): TResult; - // path(path: [T1, T2, T3, T4], obj: {[K2 in T2]: {[K3 in T3]: TResult[]}}[]): TResult; - // path(path: [T1, T2, T3, T4], obj: {[K2 in T2]: {[K4 in T4]: TResult}[]}[]): TResult; - // path(path: [T1, T2, T3, T4], obj: {[K2 in T2]: TResult[][]}[]): TResult; - // path(path: [T1, T2, T3, T4], obj: {[K3 in T3]: {[K4 in T4]: TResult}}[][]): TResult; - // path(path: [T1, T2, T3, T4], obj: {[K3 in T3]: TResult[]}[][]): TResult; - // path(path: [T1, T2, T3, T4], obj: {[K4 in T4]: TResult}[][][]): TResult; - // path(path: [T1, T2, T3, T4], obj: TResult[][][][]): TResult; - // path(path: [T1, T2, T3, T4, T5], obj: {[K1 in T1]: {[K2 in T2]: {[K3 in T3]: {[K4 in T4]: {[K5 in T5]: TResult}}}}}): TResult; - // path(path: [T1, T2, T3, T4, T5], obj: {[K1 in T1]: {[K2 in T2]: {[K3 in T3]: {[K4 in T4]: TResult[]}}}}): TResult; - // path(path: [T1, T2, T3, T4, T5], obj: {[K1 in T1]: {[K2 in T2]: {[K3 in T3]: {[K5 in T5]: TResult}[]}}}): TResult; - // path(path: [T1, T2, T3, T4, T5], obj: {[K1 in T1]: {[K2 in T2]: {[K3 in T3]: TResult[][]}}}): TResult; - // path(path: [T1, T2, T3, T4, T5], obj: {[K1 in T1]: {[K2 in T2]: {[K4 in T4]: {[K5 in T5]: TResult}}[]}}): TResult; - // path(path: [T1, T2, T3, T4, T5], obj: {[K1 in T1]: {[K2 in T2]: {[K4 in T4]: TResult[]}[]}}): TResult; - // path(path: [T1, T2, T3, T4, T5], obj: {[K1 in T1]: {[K2 in T2]: {[K5 in T5]: TResult}[][]}}): TResult; - // path(path: [T1, T2, T3, T4, T5], obj: {[K1 in T1]: {[K2 in T2]: TResult[][][]}}): TResult; - // path(path: [T1, T2, T3, T4, T5], obj: {[K1 in T1]: {[K3 in T3]: {[K4 in T4]: {[K5 in T5]: TResult}}}[]}): TResult; - // path(path: [T1, T2, T3, T4, T5], obj: {[K1 in T1]: {[K3 in T3]: {[K4 in T4]: TResult[]}}[]}): TResult; - // path(path: [T1, T2, T3, T4, T5], obj: {[K1 in T1]: {[K3 in T3]: {[K5 in T5]: TResult}[]}[]}): TResult; - // path(path: [T1, T2, T3, T4, T5], obj: {[K1 in T1]: {[K3 in T3]: TResult[][]}[]}): TResult; - // path(path: [T1, T2, T3, T4, T5], obj: {[K1 in T1]: {[K4 in T4]: {[K5 in T5]: TResult}}[][]}): TResult; - // path(path: [T1, T2, T3, T4, T5], obj: {[K1 in T1]: {[K4 in T4]: TResult[]}[][]}): TResult; - // path(path: [T1, T2, T3, T4, T5], obj: {[K1 in T1]: {[K5 in T5]: TResult}[][][]}): TResult; - // path(path: [T1, T2, T3, T4, T5], obj: {[K1 in T1]: TResult[][][][]}): TResult; - // path(path: [T1, T2, T3, T4, T5], obj: {[K2 in T2]: {[K3 in T3]: {[K4 in T4]: {[K5 in T5]: TResult}}}}[]): TResult; - // path(path: [T1, T2, T3, T4, T5], obj: {[K2 in T2]: {[K3 in T3]: {[K4 in T4]: TResult[]}}}[]): TResult; - // path(path: [T1, T2, T3, T4, T5], obj: {[K2 in T2]: {[K3 in T3]: {[K5 in T5]: TResult}[]}}[]): TResult; - // path(path: [T1, T2, T3, T4, T5], obj: {[K2 in T2]: {[K3 in T3]: TResult[][]}}[]): TResult; - // path(path: [T1, T2, T3, T4, T5], obj: {[K2 in T2]: {[K4 in T4]: {[K5 in T5]: TResult}}[]}[]): TResult; - // path(path: [T1, T2, T3, T4, T5], obj: {[K2 in T2]: {[K4 in T4]: TResult[]}[]}[]): TResult; - // path(path: [T1, T2, T3, T4, T5], obj: {[K2 in T2]: {[K5 in T5]: TResult}[][]}[]): TResult; - // path(path: [T1, T2, T3, T4, T5], obj: {[K2 in T2]: TResult[][][]}[]): TResult; - // path(path: [T1, T2, T3, T4, T5], obj: {[K3 in T3]: {[K4 in T4]: {[K5 in T5]: TResult}}}[][]): TResult; - // path(path: [T1, T2, T3, T4, T5], obj: {[K3 in T3]: {[K4 in T4]: TResult[]}}[][]): TResult; - // path(path: [T1, T2, T3, T4, T5], obj: {[K3 in T3]: {[K5 in T5]: TResult}[]}[][]): TResult; - // path(path: [T1, T2, T3, T4, T5], obj: {[K3 in T3]: TResult[][]}[][]): TResult; - // path(path: [T1, T2, T3, T4, T5], obj: {[K4 in T4]: {[K5 in T5]: TResult}}[][][]): TResult; - // path(path: [T1, T2, T3, T4, T5], obj: {[K4 in T4]: TResult[]}[][][]): TResult; - // path(path: [T1, T2, T3, T4, T5], obj: {[K5 in T5]: TResult}[][][][]): TResult; - // path(path: [T1, T2, T3, T4, T5], obj: TResult[][][][][]): TResult; - // path(path: [T1, T2, T3, T4, T5, T6], obj: {[K1 in T1]: {[K2 in T2]: {[K3 in T3]: {[K4 in T4]: {[K5 in T5]: {[K6 in T6]: TResult}}}}}}): TResult; - // path(path: [T1, T2, T3, T4, T5, T6], obj: {[K1 in T1]: {[K2 in T2]: {[K3 in T3]: {[K4 in T4]: {[K5 in T5]: TResult[]}}}}}): TResult; - // path(path: [T1, T2, T3, T4, T5, T6], obj: {[K1 in T1]: {[K2 in T2]: {[K3 in T3]: {[K4 in T4]: {[K6 in T6]: TResult}[]}}}}): TResult; - // path(path: [T1, T2, T3, T4, T5, T6], obj: {[K1 in T1]: {[K2 in T2]: {[K3 in T3]: {[K4 in T4]: TResult[][]}}}}): TResult; - // path(path: [T1, T2, T3, T4, T5, T6], obj: {[K1 in T1]: {[K2 in T2]: {[K3 in T3]: {[K5 in T5]: {[K6 in T6]: TResult}}[]}}}): TResult; - // path(path: [T1, T2, T3, T4, T5, T6], obj: {[K1 in T1]: {[K2 in T2]: {[K3 in T3]: {[K5 in T5]: TResult[]}[]}}}): TResult; - // path(path: [T1, T2, T3, T4, T5, T6], obj: {[K1 in T1]: {[K2 in T2]: {[K3 in T3]: {[K6 in T6]: TResult}[][]}}}): TResult; - // path(path: [T1, T2, T3, T4, T5, T6], obj: {[K1 in T1]: {[K2 in T2]: {[K3 in T3]: TResult[][][]}}}): TResult; - // path(path: [T1, T2, T3, T4, T5, T6], obj: {[K1 in T1]: {[K2 in T2]: {[K4 in T4]: {[K5 in T5]: {[K6 in T6]: TResult}}}[]}}): TResult; - // path(path: [T1, T2, T3, T4, T5, T6], obj: {[K1 in T1]: {[K2 in T2]: {[K4 in T4]: {[K5 in T5]: TResult[]}}[]}}): TResult; - // path(path: [T1, T2, T3, T4, T5, T6], obj: {[K1 in T1]: {[K2 in T2]: {[K4 in T4]: {[K6 in T6]: TResult}[]}[]}}): TResult; - // path(path: [T1, T2, T3, T4, T5, T6], obj: {[K1 in T1]: {[K2 in T2]: {[K4 in T4]: TResult[][]}[]}}): TResult; - // path(path: [T1, T2, T3, T4, T5, T6], obj: {[K1 in T1]: {[K2 in T2]: {[K5 in T5]: {[K6 in T6]: TResult}}[][]}}): TResult; - // path(path: [T1, T2, T3, T4, T5, T6], obj: {[K1 in T1]: {[K2 in T2]: {[K5 in T5]: TResult[]}[][]}}): TResult; - // path(path: [T1, T2, T3, T4, T5, T6], obj: {[K1 in T1]: {[K2 in T2]: {[K6 in T6]: TResult}[][][]}}): TResult; - // path(path: [T1, T2, T3, T4, T5, T6], obj: {[K1 in T1]: {[K2 in T2]: TResult[][][][]}}): TResult; - // path(path: [T1, T2, T3, T4, T5, T6], obj: {[K1 in T1]: {[K3 in T3]: {[K4 in T4]: {[K5 in T5]: {[K6 in T6]: TResult}}}}[]}): TResult; - // path(path: [T1, T2, T3, T4, T5, T6], obj: {[K1 in T1]: {[K3 in T3]: {[K4 in T4]: {[K5 in T5]: TResult[]}}}[]}): TResult; - // path(path: [T1, T2, T3, T4, T5, T6], obj: {[K1 in T1]: {[K3 in T3]: {[K4 in T4]: {[K6 in T6]: TResult}[]}}[]}): TResult; - // path(path: [T1, T2, T3, T4, T5, T6], obj: {[K1 in T1]: {[K3 in T3]: {[K4 in T4]: TResult[][]}}[]}): TResult; - // path(path: [T1, T2, T3, T4, T5, T6], obj: {[K1 in T1]: {[K3 in T3]: {[K5 in T5]: {[K6 in T6]: TResult}}[]}[]}): TResult; - // path(path: [T1, T2, T3, T4, T5, T6], obj: {[K1 in T1]: {[K3 in T3]: {[K5 in T5]: TResult[]}[]}[]}): TResult; - // path(path: [T1, T2, T3, T4, T5, T6], obj: {[K1 in T1]: {[K3 in T3]: {[K6 in T6]: TResult}[][]}[]}): TResult; - // path(path: [T1, T2, T3, T4, T5, T6], obj: {[K1 in T1]: {[K3 in T3]: TResult[][][]}[]}): TResult; - // path(path: [T1, T2, T3, T4, T5, T6], obj: {[K1 in T1]: {[K4 in T4]: {[K5 in T5]: {[K6 in T6]: TResult}}}[][]}): TResult; - // path(path: [T1, T2, T3, T4, T5, T6], obj: {[K1 in T1]: {[K4 in T4]: {[K5 in T5]: TResult[]}}[][]}): TResult; - // path(path: [T1, T2, T3, T4, T5, T6], obj: {[K1 in T1]: {[K4 in T4]: {[K6 in T6]: TResult}[]}[][]}): TResult; - // path(path: [T1, T2, T3, T4, T5, T6], obj: {[K1 in T1]: {[K4 in T4]: TResult[][]}[][]}): TResult; - // path(path: [T1, T2, T3, T4, T5, T6], obj: {[K1 in T1]: {[K5 in T5]: {[K6 in T6]: TResult}}[][][]}): TResult; - // path(path: [T1, T2, T3, T4, T5, T6], obj: {[K1 in T1]: {[K5 in T5]: TResult[]}[][][]}): TResult; - // path(path: [T1, T2, T3, T4, T5, T6], obj: {[K1 in T1]: {[K6 in T6]: TResult}[][][][]}): TResult; - // path(path: [T1, T2, T3, T4, T5, T6], obj: {[K1 in T1]: TResult[][][][][]}): TResult; - // path(path: [T1, T2, T3, T4, T5, T6], obj: {[K2 in T2]: {[K3 in T3]: {[K4 in T4]: {[K5 in T5]: {[K6 in T6]: TResult}}}}}[]): TResult; - // path(path: [T1, T2, T3, T4, T5, T6], obj: {[K2 in T2]: {[K3 in T3]: {[K4 in T4]: {[K5 in T5]: TResult[]}}}}[]): TResult; - // path(path: [T1, T2, T3, T4, T5, T6], obj: {[K2 in T2]: {[K3 in T3]: {[K4 in T4]: {[K6 in T6]: TResult}[]}}}[]): TResult; - // path(path: [T1, T2, T3, T4, T5, T6], obj: {[K2 in T2]: {[K3 in T3]: {[K4 in T4]: TResult[][]}}}[]): TResult; - // path(path: [T1, T2, T3, T4, T5, T6], obj: {[K2 in T2]: {[K3 in T3]: {[K5 in T5]: {[K6 in T6]: TResult}}[]}}[]): TResult; - // path(path: [T1, T2, T3, T4, T5, T6], obj: {[K2 in T2]: {[K3 in T3]: {[K5 in T5]: TResult[]}[]}}[]): TResult; - // path(path: [T1, T2, T3, T4, T5, T6], obj: {[K2 in T2]: {[K3 in T3]: {[K6 in T6]: TResult}[][]}}[]): TResult; - // path(path: [T1, T2, T3, T4, T5, T6], obj: {[K2 in T2]: {[K3 in T3]: TResult[][][]}}[]): TResult; - // path(path: [T1, T2, T3, T4, T5, T6], obj: {[K2 in T2]: {[K4 in T4]: {[K5 in T5]: {[K6 in T6]: TResult}}}[]}[]): TResult; - // path(path: [T1, T2, T3, T4, T5, T6], obj: {[K2 in T2]: {[K4 in T4]: {[K5 in T5]: TResult[]}}[]}[]): TResult; - // path(path: [T1, T2, T3, T4, T5, T6], obj: {[K2 in T2]: {[K4 in T4]: {[K6 in T6]: TResult}[]}[]}[]): TResult; - // path(path: [T1, T2, T3, T4, T5, T6], obj: {[K2 in T2]: {[K4 in T4]: TResult[][]}[]}[]): TResult; - // path(path: [T1, T2, T3, T4, T5, T6], obj: {[K2 in T2]: {[K5 in T5]: {[K6 in T6]: TResult}}[][]}[]): TResult; - // path(path: [T1, T2, T3, T4, T5, T6], obj: {[K2 in T2]: {[K5 in T5]: TResult[]}[][]}[]): TResult; - // path(path: [T1, T2, T3, T4, T5, T6], obj: {[K2 in T2]: {[K6 in T6]: TResult}[][][]}[]): TResult; - // path(path: [T1, T2, T3, T4, T5, T6], obj: {[K2 in T2]: TResult[][][][]}[]): TResult; - // path(path: [T1, T2, T3, T4, T5, T6], obj: {[K3 in T3]: {[K4 in T4]: {[K5 in T5]: {[K6 in T6]: TResult}}}}[][]): TResult; - // path(path: [T1, T2, T3, T4, T5, T6], obj: {[K3 in T3]: {[K4 in T4]: {[K5 in T5]: TResult[]}}}[][]): TResult; - // path(path: [T1, T2, T3, T4, T5, T6], obj: {[K3 in T3]: {[K4 in T4]: {[K6 in T6]: TResult}[]}}[][]): TResult; - // path(path: [T1, T2, T3, T4, T5, T6], obj: {[K3 in T3]: {[K4 in T4]: TResult[][]}}[][]): TResult; - // path(path: [T1, T2, T3, T4, T5, T6], obj: {[K3 in T3]: {[K5 in T5]: {[K6 in T6]: TResult}}[]}[][]): TResult; - // path(path: [T1, T2, T3, T4, T5, T6], obj: {[K3 in T3]: {[K5 in T5]: TResult[]}[]}[][]): TResult; - // path(path: [T1, T2, T3, T4, T5, T6], obj: {[K3 in T3]: {[K6 in T6]: TResult}[][]}[][]): TResult; - // path(path: [T1, T2, T3, T4, T5, T6], obj: {[K3 in T3]: TResult[][][]}[][]): TResult; - // path(path: [T1, T2, T3, T4, T5, T6], obj: {[K4 in T4]: {[K5 in T5]: {[K6 in T6]: TResult}}}[][][]): TResult; - // path(path: [T1, T2, T3, T4, T5, T6], obj: {[K4 in T4]: {[K5 in T5]: TResult[]}}[][][]): TResult; - // path(path: [T1, T2, T3, T4, T5, T6], obj: {[K4 in T4]: {[K6 in T6]: TResult}[]}[][][]): TResult; - // path(path: [T1, T2, T3, T4, T5, T6], obj: {[K4 in T4]: TResult[][]}[][][]): TResult; - // path(path: [T1, T2, T3, T4, T5, T6], obj: {[K5 in T5]: {[K6 in T6]: TResult}}[][][][]): TResult; - // path(path: [T1, T2, T3, T4, T5, T6], obj: {[K5 in T5]: TResult[]}[][][][]): TResult; - // path(path: [T1, T2, T3, T4, T5, T6], obj: {[K6 in T6]: TResult}[][][][][]): TResult; - // path(path: [T1, T2, T3, T4, T5, T6], obj: TResult[][][][][][]): TResult; - - // fallback, prevents errors but lacks inference; expected result must be supplied manually. - path(path: Path, obj: Struct): T; - path(path: Path): (obj: Struct) => T; - - // path: CurriedFunction2, T>; - // failed attempt at proper typing, see https://github.com/Microsoft/TypeScript/issues/12393 : - // path(keys: [K1, K2], obj: T): U; - // path(keys: [K1, K2], obj: T): T[K1][K2]; - - /** - * Determines whether a nested path on an object has a specific value, - * in `R.equals` terms. Most likely used to filter a list. - */ - // pathEq(path: Path, val: any, obj: Struct): boolean; - // pathEq(path: Path, val: any): (obj: Struct) => boolean; - // pathEq(path: Path): CurriedFunction2, boolean>; - // // pathEq: CurriedFunction3, boolean>; - - // base - pathEq(p: Path, v: any, o: any): boolean; - pathEq(p: Path, v: any): { - (o: any): boolean; - }; - pathEq(p: Path):{ - (v: any, o: any): boolean; - (v: any):{ - (o: any): boolean; - }; - }; - - - /** - * If the given, non-null object has a value at the given path, returns the value at that path. - * Otherwise returns the provided default value. - */ - // pathOr(d: T, p: Path, obj: Struct): T|any; - // pathOr(d: T, p: Path): (obj: Struct) => T|any; - // pathOr(d: T): CurriedFunction2, T|any>; - // // pathOr(d: T, p: Path): (obj: Struct) => T|any; - // // pathOr(d: T): (p: Path, obj: Struct) => T|any; - // // pathOr: CurriedFunction3, T|any>; - - // base - pathOr(d: T, p: Path, obj: Struct): T|any; - pathOr(d: T, p: Path):{ - (obj: Struct): T|any; - }; - pathOr(d: T):{ - (p: Path, obj: Struct): T|any; - (p: Path):{ - (obj: Struct): T|any; - }; - }; - - - /** - * Returns `true` if the specified object property at given path satisfies the given predicate; `false` - * otherwise. - */ - // pathSatisfies(fn: Pred, p: Path, obj: any): boolean; - // pathSatisfies(fn: Pred, p: Path): (obj: any) => boolean; - // pathSatisfies(fn: Pred): CurriedFunction2; - // // pathSatisfies: CurriedFunction3, Path, any, boolean>; - - // base - pathSatisfies(fn: Pred, p: Path, obj: any): boolean; - pathSatisfies(fn: Pred, p: Path):{ - (obj: any): boolean; - }; - pathSatisfies(fn: Pred):{ - (p: Path, obj: any): boolean; - (p: Path):{ - (obj: any): boolean; - }; - }; - - - /** - * Returns a partial copy of an object containing only the keys specified. If the key does not exist, the - * property is ignored. - */ - pick(names: List, obj: T): T; - pick(names: List): (obj: T) => T; - // pick: CurriedFunction2, T, Pick>; - - // pick(names: List, obj: T): Partial; - // pick(names: List): (obj: T) => Partial; - // // pick: CurriedFunction2, T, Partial>; - - // /** - // * Similar to `pick` except that this one includes a `key: undefined` pair for properties that don't exist. - // */ - // pickAll(names: List, obj: T): Partial; - // pickAll(names: List): (obj: T) => Partial; - // // pickAll: CurriedFunction2, T, Partial>; - - - // /** - // * Returns a partial copy of an object containing only the keys that satisfy the supplied predicate. - // */ - // pickBy(pred: ObjPred, obj: T): Partial; - // pickBy(pred: ObjPred): (obj: T) => Partial; - // // pickBy: CurriedFunction2, T, Partial>; - - - /** - * Performs left-to-right function composition. - * The leftmost function may have any arity; the remaining functions must be unary. - * In some libraries this function is named sequence. - * Note: The result of pipe is not automatically curried. - */ - pipe(fn0: (x0: V0) => T1): (x0: V0) => T1; - pipe(fn0: (x0: V0, x1: V1) => T1): (x0: V0, x1: V1) => T1; - pipe(fn0: (x0: V0, x1: V1, x2: V2) => T1): (x0: V0, x1: V1, x2: V2) => T1; - pipe(fn0: (x0: V0, x1: V1, x2: V2, x3: V3) => T1): (x0: V0, x1: V1, x2: V2, x3: V3) => T1; - pipe(fn0: (x0: V0) => T1, fn1: (x: T1) => T2): (x0: V0) => T2; - pipe(fn0: (x0: V0, x1: V1) => T1, fn1: (x: T1) => T2): (x0: V0, x1: V1) => T2; - pipe(fn0: (x0: V0, x1: V1, x2: V2) => T1, fn1: (x: T1) => T2): (x0: V0, x1: V1, x2: V2) => T2; - pipe(fn0: (x0: V0, x1: V1, x2: V2, x3: V3) => T1, fn1: (x: T1) => T2): (x0: V0, x1: V1, x2: V2, x3: V3) => T2; - pipe(fn0: (x0: V0) => T1, fn1: (x: T1) => T2, fn2: (x: T2) => T3): (x0: V0) => T3; - pipe(fn0: (x0: V0, x1: V1) => T1, fn1: (x: T1) => T2, fn2: (x: T2) => T3): (x0: V0, x1: V1) => T3; - pipe(fn0: (x0: V0, x1: V1, x2: V2) => T1, fn1: (x: T1) => T2, fn2: (x: T2) => T3): (x0: V0, x1: V1, x2: V2) => T3; - pipe(fn0: (x0: V0, x1: V1, x2: V2, x3: V3) => T1, fn1: (x: T1) => T2, fn2: (x: T2) => T3): (x0: V0, x1: V1, x2: V2, x3: V3) => T3; - pipe(fn0: (x0: V0) => T1, fn1: (x: T1) => T2, fn2: (x: T2) => T3, fn3: (x: T3) => T4): (x0: V0) => T4; - pipe(fn0: (x0: V0, x1: V1) => T1, fn1: (x: T1) => T2, fn2: (x: T2) => T3, fn3: (x: T3) => T4): (x0: V0, x1: V1) => T4; - pipe(fn0: (x0: V0, x1: V1, x2: V2) => T1, fn1: (x: T1) => T2, fn2: (x: T2) => T3, fn3: (x: T3) => T4): (x0: V0, x1: V1, x2: V2) => T4; - pipe(fn0: (x0: V0, x1: V1, x2: V2, x3: V3) => T1, fn1: (x: T1) => T2, fn2: (x: T2) => T3, fn3: (x: T3) => T4): (x0: V0, x1: V1, x2: V2, x3: V3) => T4; - pipe(fn0: (x0: V0) => T1, fn1: (x: T1) => T2, fn2: (x: T2) => T3, fn3: (x: T3) => T4, fn4: (x: T4) => T5): (x0: V0) => T5; - pipe(fn0: (x0: V0, x1: V1) => T1, fn1: (x: T1) => T2, fn2: (x: T2) => T3, fn3: (x: T3) => T4, fn4: (x: T4) => T5): (x0: V0, x1: V1) => T5; - pipe(fn0: (x0: V0, x1: V1, x2: V2) => T1, fn1: (x: T1) => T2, fn2: (x: T2) => T3, fn3: (x: T3) => T4, fn4: (x: T4) => T5): (x0: V0, x1: V1, x2: V2) => T5; - pipe(fn0: (x0: V0, x1: V1, x2: V2, x3: V3) => T1, fn1: (x: T1) => T2, fn2: (x: T2) => T3, fn3: (x: T3) => T4, fn4: (x: T4) => T5): (x0: V0, x1: V1, x2: V2, x3: V3) => T5; - pipe(fn0: (x0: V0) => T1, fn1: (x: T1) => T2, fn2: (x: T2) => T3, fn3: (x: T3) => T4, fn4: (x: T4) => T5, fn5: (x: T5) => T6): (x0: V0) => T6; - pipe(fn0: (x0: V0, x1: V1) => T1, fn1: (x: T1) => T2, fn2: (x: T2) => T3, fn3: (x: T3) => T4, fn4: (x: T4) => T5, fn5: (x: T5) => T6): (x0: V0, x1: V1) => T6; - pipe(fn0: (x0: V0, x1: V1, x2: V2) => T1, fn1: (x: T1) => T2, fn2: (x: T2) => T3, fn3: (x: T3) => T4, fn4: (x: T4) => T5, fn5: (x: T5) => T6): (x0: V0, x1: V1, x2: V2) => T6; - pipe(fn0: (x0: V0, x1: V1, x2: V2, x3: V3) => T1, fn1: (x: T1) => T2, fn2: (x: T2) => T3, fn3: (x: T3) => T4, fn4: (x: T4) => T5, fn5: (x: T5) => T6): (x0: V0, x1: V1, x2: V2, x3: V3) => T6; - pipe(fn0: (x0: V0) => T1, fn1: (x: T1) => T2, fn2: (x: T2) => T3, fn3: (x: T3) => T4, fn4: (x: T4) => T5, fn5: (x: T5) => T6, fn6: (x: T6) => T7): (x0: V0) => T7; - pipe(fn0: (x0: V0, x1: V1) => T1, fn1: (x: T1) => T2, fn2: (x: T2) => T3, fn3: (x: T3) => T4, fn4: (x: T4) => T5, fn5: (x: T5) => T6, fn6: (x: T6) => T7): (x0: V0, x1: V1) => T7; - pipe(fn0: (x0: V0, x1: V1, x2: V2) => T1, fn1: (x: T1) => T2, fn2: (x: T2) => T3, fn3: (x: T3) => T4, fn4: (x: T4) => T5, fn5: (x: T5) => T6, fn6: (x: T6) => T7): (x0: V0, x1: V1, x2: V2) => T7; - pipe(fn0: (x0: V0, x1: V1, x2: V2, x3: V3) => T1, fn1: (x: T1) => T2, fn2: (x: T2) => T3, fn3: (x: T3) => T4, fn4: (x: T4) => T5, fn5: (x: T5) => T6, fn6: (x: T6) => T7): (x0: V0, x1: V1, x2: V2, x3: V3) => T7; - pipe(fn0: (x0: V0) => T1, fn1: (x: T1) => T2, fn2: (x: T2) => T3, fn3: (x: T3) => T4, fn4: (x: T4) => T5, fn5: (x: T5) => T6, fn6: (x: T6) => T7, fn7: (x: T7) => T8): (x0: V0) => T8; - pipe(fn0: (x0: V0, x1: V1) => T1, fn1: (x: T1) => T2, fn2: (x: T2) => T3, fn3: (x: T3) => T4, fn4: (x: T4) => T5, fn5: (x: T5) => T6, fn6: (x: T6) => T7, fn7: (x: T7) => T8): (x0: V0, x1: V1) => T8; - pipe(fn0: (x0: V0, x1: V1, x2: V2) => T1, fn1: (x: T1) => T2, fn2: (x: T2) => T3, fn3: (x: T3) => T4, fn4: (x: T4) => T5, fn5: (x: T5) => T6, fn6: (x: T6) => T7, fn7: (x: T7) => T8): (x0: V0, x1: V1, x2: V2) => T8; - pipe(fn0: (x0: V0, x1: V1, x2: V2, x3: V3) => T1, fn1: (x: T1) => T2, fn2: (x: T2) => T3, fn3: (x: T3) => T4, fn4: (x: T4) => T5, fn5: (x: T5) => T6, fn6: (x: T6) => T7, fn7: (x: T7) => T8): (x0: V0, x1: V1, x2: V2, x3: V3) => T8; - pipe(fn0: (x0: V0) => T1, fn1: (x: T1) => T2, fn2: (x: T2) => T3, fn3: (x: T3) => T4, fn4: (x: T4) => T5, fn5: (x: T5) => T6, fn6: (x: T6) => T7, fn7: (x: T7) => T8, fn8: (x: T8) => T9): (x0: V0) => T9; - pipe(fn0: (x0: V0, x1: V1) => T1, fn1: (x: T1) => T2, fn2: (x: T2) => T3, fn3: (x: T3) => T4, fn4: (x: T4) => T5, fn5: (x: T5) => T6, fn6: (x: T6) => T7, fn7: (x: T7) => T8, fn8: (x: T8) => T9): (x0: V0, x1: V1) => T9; - pipe(fn0: (x0: V0, x1: V1, x2: V2) => T1, fn1: (x: T1) => T2, fn2: (x: T2) => T3, fn3: (x: T3) => T4, fn4: (x: T4) => T5, fn5: (x: T5) => T6, fn6: (x: T6) => T7, fn7: (x: T7) => T8, fn8: (x: T8) => T9): (x0: V0, x1: V1, x2: V2) => T9; - pipe(fn0: (x0: V0, x1: V1, x2: V2, x3: V3) => T1, fn1: (x: T1) => T2, fn2: (x: T2) => T3, fn3: (x: T3) => T4, fn4: (x: T4) => T5, fn5: (x: T5) => T6, fn6: (x: T6) => T7, fn7: (x: T7) => T8, fn8: (x: T8) => T9): (x0: V0, x1: V1, x2: V2, x3: V3) => T9; - - /** - * Performs left-to-right composition of one or more Promise-returning functions. The leftmost function may have any arity; the remaining functions must be unary. - */ - pipeP(fn0: (x0: V0) => Promise): (x0: V0) => Promise; - pipeP(fn0: (x0: V0, x1: V1) => Promise): (x0: V0, x1: V1) => Promise; - pipeP(fn0: (x0: V0, x1: V1, x2: V2) => Promise): (x0: V0, x1: V1, x2: V2) => Promise; - pipeP(fn0: (x0: V0, x1: V1, x2: V2, x3: V3) => Promise): (x0: V0, x1: V1, x2: V2, x3: V3) => Promise; - pipeP(fn0: (x0: V0) => Promise, fn1: (x: T1) => Promise|T2): (x0: V0) => Promise; - pipeP(fn0: (x0: V0, x1: V1) => Promise, fn1: (x: T1) => Promise|T2): (x0: V0, x1: V1) => Promise; - pipeP(fn0: (x0: V0, x1: V1, x2: V2) => Promise, fn1: (x: T1) => Promise|T2): (x0: V0, x1: V1, x2: V2) => Promise; - pipeP(fn0: (x0: V0, x1: V1, x2: V2, x3: V3) => Promise, fn1: (x: T1) => Promise|T2): (x0: V0, x1: V1, x2: V2, x3: V3) => Promise; - pipeP(fn0: (x0: V0) => Promise, fn1: (x: T1) => Promise|T2, fn2: (x: T2) => Promise|T3): (x0: V0) => Promise; - pipeP(fn0: (x0: V0, x1: V1) => Promise, fn1: (x: T1) => Promise|T2, fn2: (x: T2) => Promise|T3): (x0: V0, x1: V1) => Promise; - pipeP(fn0: (x0: V0, x1: V1, x2: V2) => Promise, fn1: (x: T1) => Promise|T2, fn2: (x: T2) => Promise|T3): (x0: V0, x1: V1, x2: V2) => Promise; - pipeP(fn0: (x0: V0, x1: V1, x2: V2, x3: V3) => Promise, fn1: (x: T1) => Promise|T2, fn2: (x: T2) => Promise|T3): (x0: V0, x1: V1, x2: V2, x3: V3) => Promise; - pipeP(fn0: (x0: V0) => Promise, fn1: (x: T1) => Promise|T2, fn2: (x: T2) => Promise|T3, fn3: (x: T3) => Promise|T4): (x0: V0) => Promise; - pipeP(fn0: (x0: V0, x1: V1) => Promise, fn1: (x: T1) => Promise|T2, fn2: (x: T2) => Promise|T3, fn3: (x: T3) => Promise|T4): (x0: V0, x1: V1) => Promise; - pipeP(fn0: (x0: V0, x1: V1, x2: V2) => Promise, fn1: (x: T1) => Promise|T2, fn2: (x: T2) => Promise|T3, fn3: (x: T3) => Promise|T4): (x0: V0, x1: V1, x2: V2) => Promise; - pipeP(fn0: (x0: V0, x1: V1, x2: V2, x3: V3) => Promise, fn1: (x: T1) => Promise|T2, fn2: (x: T2) => Promise|T3, fn3: (x: T3) => Promise|T4): (x0: V0, x1: V1, x2: V2, x3: V3) => Promise; - pipeP(fn0: (x0: V0) => Promise, fn1: (x: T1) => Promise|T2, fn2: (x: T2) => Promise|T3, fn3: (x: T3) => Promise|T4, fn4: (x: T4) => Promise|T5): (x0: V0) => Promise; - pipeP(fn0: (x0: V0, x1: V1) => Promise, fn1: (x: T1) => Promise|T2, fn2: (x: T2) => Promise|T3, fn3: (x: T3) => Promise|T4, fn4: (x: T4) => Promise|T5): (x0: V0, x1: V1) => Promise; - pipeP(fn0: (x0: V0, x1: V1, x2: V2) => Promise, fn1: (x: T1) => Promise|T2, fn2: (x: T2) => Promise|T3, fn3: (x: T3) => Promise|T4, fn4: (x: T4) => Promise|T5): (x0: V0, x1: V1, x2: V2) => Promise; - pipeP(fn0: (x0: V0, x1: V1, x2: V2, x3: V3) => Promise, fn1: (x: T1) => Promise|T2, fn2: (x: T2) => Promise|T3, fn3: (x: T3) => Promise|T4, fn4: (x: T4) => Promise|T5): (x0: V0, x1: V1, x2: V2, x3: V3) => Promise; - pipeP(fn0: (x0: V0) => Promise, fn1: (x: T1) => Promise|T2, fn2: (x: T2) => Promise|T3, fn3: (x: T3) => Promise|T4, fn4: (x: T4) => Promise|T5, fn5: (x: T5) => Promise|T6): (x0: V0) => Promise; - pipeP(fn0: (x0: V0, x1: V1) => Promise, fn1: (x: T1) => Promise|T2, fn2: (x: T2) => Promise|T3, fn3: (x: T3) => Promise|T4, fn4: (x: T4) => Promise|T5, fn5: (x: T5) => Promise|T6): (x0: V0, x1: V1) => Promise; - pipeP(fn0: (x0: V0, x1: V1, x2: V2) => Promise, fn1: (x: T1) => Promise|T2, fn2: (x: T2) => Promise|T3, fn3: (x: T3) => Promise|T4, fn4: (x: T4) => Promise|T5, fn5: (x: T5) => Promise|T6): (x0: V0, x1: V1, x2: V2) => Promise; - pipeP(fn0: (x0: V0, x1: V1, x2: V2, x3: V3) => Promise, fn1: (x: T1) => Promise|T2, fn2: (x: T2) => Promise|T3, fn3: (x: T3) => Promise|T4, fn4: (x: T4) => Promise|T5, fn5: (x: T5) => Promise|T6): (x0: V0, x1: V1, x2: V2, x3: V3) => Promise; - pipeP(fn0: (x0: V0) => Promise, fn1: (x: T1) => Promise|T2, fn2: (x: T2) => Promise|T3, fn3: (x: T3) => Promise|T4, fn4: (x: T4) => Promise|T5, fn5: (x: T5) => Promise|T6, fn6: (x: T6) => Promise|T7): (x0: V0) => Promise; - pipeP(fn0: (x0: V0, x1: V1) => Promise, fn1: (x: T1) => Promise|T2, fn2: (x: T2) => Promise|T3, fn3: (x: T3) => Promise|T4, fn4: (x: T4) => Promise|T5, fn5: (x: T5) => Promise|T6, fn6: (x: T6) => Promise|T7): (x0: V0, x1: V1) => Promise; - pipeP(fn0: (x0: V0, x1: V1, x2: V2) => Promise, fn1: (x: T1) => Promise|T2, fn2: (x: T2) => Promise|T3, fn3: (x: T3) => Promise|T4, fn4: (x: T4) => Promise|T5, fn5: (x: T5) => Promise|T6, fn6: (x: T6) => Promise|T7): (x0: V0, x1: V1, x2: V2) => Promise; - pipeP(fn0: (x0: V0, x1: V1, x2: V2, x3: V3) => Promise, fn1: (x: T1) => Promise|T2, fn2: (x: T2) => Promise|T3, fn3: (x: T3) => Promise|T4, fn4: (x: T4) => Promise|T5, fn5: (x: T5) => Promise|T6, fn6: (x: T6) => Promise|T7): (x0: V0, x1: V1, x2: V2, x3: V3) => Promise; - pipeP(fn0: (x0: V0) => Promise, fn1: (x: T1) => Promise|T2, fn2: (x: T2) => Promise|T3, fn3: (x: T3) => Promise|T4, fn4: (x: T4) => Promise|T5, fn5: (x: T5) => Promise|T6, fn6: (x: T6) => Promise|T7, fn7: (x: T7) => Promise|T8): (x0: V0) => Promise; - pipeP(fn0: (x0: V0, x1: V1) => Promise, fn1: (x: T1) => Promise|T2, fn2: (x: T2) => Promise|T3, fn3: (x: T3) => Promise|T4, fn4: (x: T4) => Promise|T5, fn5: (x: T5) => Promise|T6, fn6: (x: T6) => Promise|T7, fn7: (x: T7) => Promise|T8): (x0: V0, x1: V1) => Promise; - pipeP(fn0: (x0: V0, x1: V1, x2: V2) => Promise, fn1: (x: T1) => Promise|T2, fn2: (x: T2) => Promise|T3, fn3: (x: T3) => Promise|T4, fn4: (x: T4) => Promise|T5, fn5: (x: T5) => Promise|T6, fn6: (x: T6) => Promise|T7, fn7: (x: T7) => Promise|T8): (x0: V0, x1: V1, x2: V2) => Promise; - pipeP(fn0: (x0: V0, x1: V1, x2: V2, x3: V3) => Promise, fn1: (x: T1) => Promise|T2, fn2: (x: T2) => Promise|T3, fn3: (x: T3) => Promise|T4, fn4: (x: T4) => Promise|T5, fn5: (x: T5) => Promise|T6, fn6: (x: T6) => Promise|T7, fn7: (x: T7) => Promise|T8): (x0: V0, x1: V1, x2: V2, x3: V3) => Promise; - pipeP(fn0: (x0: V0) => Promise, fn1: (x: T1) => Promise|T2, fn2: (x: T2) => Promise|T3, fn3: (x: T3) => Promise|T4, fn4: (x: T4) => Promise|T5, fn5: (x: T5) => Promise|T6, fn6: (x: T6) => Promise|T7, fn7: (x: T7) => Promise|T8, fn8: (x: T8) => Promise|T9): (x0: V0) => Promise; - pipeP(fn0: (x0: V0, x1: V1) => Promise, fn1: (x: T1) => Promise|T2, fn2: (x: T2) => Promise|T3, fn3: (x: T3) => Promise|T4, fn4: (x: T4) => Promise|T5, fn5: (x: T5) => Promise|T6, fn6: (x: T6) => Promise|T7, fn7: (x: T7) => Promise|T8, fn8: (x: T8) => Promise|T9): (x0: V0, x1: V1) => Promise; - pipeP(fn0: (x0: V0, x1: V1, x2: V2) => Promise, fn1: (x: T1) => Promise|T2, fn2: (x: T2) => Promise|T3, fn3: (x: T3) => Promise|T4, fn4: (x: T4) => Promise|T5, fn5: (x: T5) => Promise|T6, fn6: (x: T6) => Promise|T7, fn7: (x: T7) => Promise|T8, fn8: (x: T8) => Promise|T9): (x0: V0, x1: V1, x2: V2) => Promise; - pipeP(fn0: (x0: V0, x1: V1, x2: V2, x3: V3) => Promise, fn1: (x: T1) => Promise|T2, fn2: (x: T2) => Promise|T3, fn3: (x: T3) => Promise|T4, fn4: (x: T4) => Promise|T5, fn5: (x: T5) => Promise|T6, fn6: (x: T6) => Promise|T7, fn7: (x: T7) => Promise|T8, fn8: (x: T8) => Promise|T9): (x0: V0, x1: V1, x2: V2, x3: V3) => Promise; - - /** - * Returns the left-to-right Kleisli composition of the provided functions, each of which must return a value of a type supported by chain. - */ - // skipped extra params on fn0 -- not mentioned in the docs! - pipeK(fn0: (v: Chain) => Chain): (v: V) => Chain; - pipeK(fn0: (v: Chain) => Chain, fn1: (x: T1) => Chain): (v: V) => Chain; - pipeK(fn0: (v: Chain) => Chain, fn1: (x: T1) => Chain, fn2: (x: T2) => Chain): (v: V) => Chain; - pipeK(fn0: (v: Chain) => Chain, fn1: (x: T1) => Chain, fn2: (x: T2) => Chain, fn3: (x: T3) => Chain): (v: V) => Chain; - pipeK(fn0: (v: Chain) => Chain, fn1: (x: T1) => Chain, fn2: (x: T2) => Chain, fn3: (x: T3) => Chain, fn4: (x: T4) => Chain): (v: V) => Chain; - pipeK(fn0: (v: Chain) => Chain, fn1: (x: T1) => Chain, fn2: (x: T2) => Chain, fn3: (x: T3) => Chain, fn4: (x: T4) => Chain, fn5: (x: T5) => Chain): (v: V) => Chain; - pipeK(fn0: (v: Chain) => Chain, fn1: (x: T1) => Chain, fn2: (x: T2) => Chain, fn3: (x: T3) => Chain, fn4: (x: T4) => Chain, fn5: (x: T5) => Chain, fn6: (x: T6) => Chain): (v: V) => Chain; - pipeK(fn0: (v: Chain) => Chain, fn1: (x: T1) => Chain, fn2: (x: T2) => Chain, fn3: (x: T3) => Chain, fn4: (x: T4) => Chain, fn5: (x: T5) => Chain, fn6: (x: T6) => Chain, fn7: (x: T7) => Chain): (v: V) => Chain; - pipeK(fn0: (v: Chain) => Chain, fn1: (x: T1) => Chain, fn2: (x: T2) => Chain, fn3: (x: T3) => Chain, fn4: (x: T4) => Chain, fn5: (x: T5) => Chain, fn6: (x: T6) => Chain, fn7: (x: T7) => Chain, fn8: (x: T8) => Chain): (v: V) => Chain; - - /** - * Returns a new list by plucking the same named property off all objects in the list supplied. - */ - // hard to mix cuz different generics - - // infer - pluck, K extends keyof T>(p: K, list: List): U[]; // fails on number keys - pluck, K extends keyof T>(p: K): (list: List) => U[]; // doesn't work, T info late - // pluck, K extends keyof T>: CurriedFunction2, T[K][]>; - - // supply return object type manually when unable to infer it... - pluck(p: Prop, list: Struct[]): T[]; - pluck(p: Prop): (list: Struct[]) => T[]; - // pluck: CurriedFunction2[], T[]>; - - /** - * Returns a new list with the given element at the front, followed by the contents of the - * list. - */ - prepend(el: T, list: List): T[]; - prepend(el: T): (list: List) => T[]; - // prepend: CurriedFunction2, T[]>; - - /** - * Multiplies together all the elements of a list. - */ - product(list: List): number; - - - /** - * Reasonable analog to SQL `select` statement. - */ - // hard to mix cuz different generics - - // infer - project(props: List, objs: List): T[]; - project(props: List): (objs: List) => T[]; // T info probably too late - // project: CurriedFunction2, List, Pick[]>; - - // supply return object type manually when unable to infer it... - project(props: List, objs: List): U[]; - project(props: List): (objs: List) => U[]; - // project: CurriedFunction2, List, U[]>; - - /** - * Returns a function that when supplied an object returns the indicated property of that object, if it exists. - */ - - // keyof version - prop(p: Prop, obj: T): T; - // prop(p: K): (obj: T) => T[K]; // T info late - // prop: CurriedFunction2; - // prop(p: K): (obj: T) => T[K]; // K redefined, fails - // prop: CurriedFunction2; - - // Record version, more curry-friendly - prop>(p: K, obj: T): V; // uncurried adds value only for {} from e.g. degeneration - prop(p: K): >(obj: T) => V; - // prop>: CurriedFunction2; - - /** - * Determines whether the given property of an object has a specific - * value according to strict equality (`===`). Most likely used to - * filter a list. - */ - // propEq>(name: Prop, val: any, obj: T): boolean; - // propEq>(name: Prop, val: any): (obj: T) => boolean; - // propEq>(name: Prop): CurriedFunction2; - // // propEq>(name: Prop): (val: any, obj: T) => boolean; - // // propEq>(name: Prop): (val: any) => (obj: T) => boolean; - // // propEq>: CurriedFunction3; - - // base - propEq>(name: Prop, val: any, obj: T): boolean; - propEq(name: Prop, val: any):{ - >(obj: T): boolean; - }; - propEq(name: Prop):{ - >(val: any, obj: T): boolean; - (val: any):{ - >(obj: T): boolean; - }; - }; - - - /** - * Returns true if the specified object property is of the given type; false otherwise. - */ - - // Record - propIs>(type: T, name: K, obj: U): obj is (U & Obj); - propIs(type: T, name: K): >(obj: U) => obj is (U & Obj); - // propIs(type: T): { - // >(name: K, obj: U): obj is (U & Record); - // (name: K): >(obj: U) => obj is (U & Record); - // } - // propIs>: CurriedFunction3)>; // obj is? name unavailable... - - // inference, fails if name and object are supplied separately - propIs(type: T, name: Prop, obj: V): obj is (V & Obj); - // propIs(type: T, name: K): (obj: V) => obj is (V & Record); // object info not available in time :( - // propIs(type: T): { - // (name: K, obj: V): obj is (V & Record); - // (name: K): (obj: V) => obj is (V & Record); // object info not available in time :( - // } - // propIs: CurriedFunction3)>; // obj is? name unavailable... - - // curry-friendlier fallback - propIs(type: Function, name: Prop, obj: Struct): boolean; - propIs(type: Function, name: Prop): (obj: Struct) => boolean; - propIs(type: Function): CurriedFunction2, boolean>; - // propIs(type: Function): { - // (name: Prop, obj: Struct): boolean; - // (name: Prop): (obj: Struct) => boolean; - // } - // propIs: CurriedFunction3, boolean>; - - // mixed: - propIs(type: T): { - // record - >(name: K, obj: U): obj is (U & Obj); - (name: K): >(obj: U) => obj is (U & Obj); - // keyof - (name: Prop, obj: V): obj is (V & Obj); - // (name: K): (obj: V) => obj is (V & Record); // object info not available in time :( - }; - - /** - * If the given, non-null object has an own property with the specified name, returns the value of that property. - * Otherwise returns the provided default value. - */ - - // // infer with Record (curry-friendly) -- can't use here: it'd error whenever the default should trigger - // propOr>(val: T, p: K, obj: U): V|T; - // propOr(val: T, p: K): >(obj: U) => V|T; - // propOr>(val: T): CurriedFunction2; - // // propOr>: CurriedFunction3; - - // infer with keyof (not curry-friendly), allowing a default value with a type different from the actual one - propOr(val: T, p: K, obj: Obj): K|T; // obj[K]? - propOr(val: T, p: K): (obj: Obj) => K|T; // generics too early? - propOr(val: T): CurriedFunction2, K|T>; // generics too early? - // propOr(val: T): (p: K, obj: U) => U[K]|T; - // propOr(val: T): (p: K) => (obj: U) => U[K]|T; // U too early? - // propOr: CurriedFunction3; - - // presume the value at the given key matches the type of the default value, bad but less likely to fail with currying - propOr(val: T, p: Prop, obj: Struct): T; // adds value only to protect against {} from e.g. generic degeneration - // propOr(val: T, p: Prop): (obj: Struct) => T; - // // propOr(val: T): (p: Prop, obj: Struct) => T; - // propOr(val: T): CurriedFunction2, T>; - // // propOr: CurriedFunction3, T>; - propOr(val: T, p: Prop): Struct; - propOr(val: T):{ - (p: Prop): Struct; - }; - - - // // useless unbound generics? - // propOr(val: T, p: Prop, obj: U): V; - // propOr(val: T, p: Prop): (obj: U) => V; - // // propOr(val: T): (p: Prop, obj: U) => V; - // propOr(val: T): CurriedFunction2; - // // propOr: CurriedFunction3; - - /** - * Acts as multiple `prop`: array of keys in, array of values out. Preserves order. - */ - - // generic version - props(ps: List, obj: Struct): T[]; - props(ps: List): (obj: Struct) => T[]; - // props: CurriedFunction2, Struct, T[]>; - - // TODO: heterogeneous version - // Record-based? - // props>(ps: List, obj: Struct): ???; - - /** - * Returns true if the specified object property satisfies the given predicate; false otherwise. - */ - - // // Record (curry-friendly) - // propSatisfies>(pred: Pred, name: K, obj: U): boolean; - // propSatisfies(pred: Pred, name: K): >(obj: U) => boolean; - // propSatisfies>(pred: Pred): CurriedFunction2; - // // propSatisfies>: CurriedFunction3, K, U, boolean>; - - // // keyof, info too late on currying - // propSatisfies, K extends keyof U>(pred: Pred, name: Prop, obj: U): boolean; - // propSatisfies(pred: Pred, name: Prop): (obj: U) => boolean; - // propSatisfies(pred: Pred): CurriedFunction2; - // // propSatisfies: CurriedFunction3, Prop, U, boolean>; - - // Record (curry-friendly) - propSatisfies>(pred: Pred, name: K, obj: U): boolean; - propSatisfies(pred: Pred, name: K):{ - >(obj: U): boolean; - }; - propSatisfies(pred: Pred):{ - >(name: K, obj: U): boolean; - (name: K):{ - >(obj: U): boolean; - }; - }; - - // keyof, info too late on currying - propSatisfies(pred: Pred, name: Prop, obj: U): boolean; - propSatisfies(pred: Pred, name: Prop):{ - (obj: U): boolean; - }; - propSatisfies(pred: Pred):{ - (name: Prop, obj: U): boolean; - (name: Prop):{ - (obj: U): boolean; - }; - }; - - - /** - * Returns a list of numbers from `from` (inclusive) to `to` - * (exclusive). In mathematical terms, `range(a, b)` is equivalent to - * the half-open interval `[a, b)`. - */ - range(from: number, to: number): number[]; - range(from: number): (to: number) => number[]; - // range: CurriedFunction2; - - /** - * Returns a single item by iterating through the list, successively calling the iterator - * function and passing it an accumulator value and the current value from the array, and - * then passing the result to the next call. - */ - // reduce>(fn: (acc: TResult, elem: T, idx: Number, list: R) => TResult|Reduced, acc: TResult, list: R): TResult; - // reduce>(fn: (acc: TResult, elem: T, idx: Number, list: R) => TResult|Reduced, acc: TResult): (list: R) => TResult; - // reduce>(fn: (acc: TResult, elem: T, idx: Number, list: R) => TResult|Reduced): CurriedFunction2; - // // reduce>(fn: (acc: TResult, elem: T, idx: Number, list: R) => TResult|Reduced): (acc: TResult, list: R) => TResult; - // // reduce>: CurriedFunction3<(acc: TResult, elem: T, idx: Number, list: R) => TResult|Reduced, TResult, R, TResult>; - // base - reduce>(fn: (acc: TResult, elem: T, idx: number, list: R) => TResult|Reduced, acc: TResult, list: R): TResult; - reduce>(fn: (acc: TResult, elem: T, idx: number, list: R) => TResult|Reduced, acc: TResult):{ - (list: R): TResult; - }; - reduce>(fn: (acc: TResult, elem: T, idx: number, list: R) => TResult|Reduced):{ - (acc: TResult, list: R): TResult; - (acc: TResult):{ - (list: R): TResult; - }; - }; - - - /** - * Groups the elements of the list according to the result of calling the String-returning function keyFn on each - * element and reduces the elements of each group to a single value via the reducer function valueFn. - */ - // // reason for 'any' on acc: somehow empty accumulators like '[]' won't work well when matching - // reduceBy>(valueFn: (acc: TResult, elem: T, idx: number, list: R) => TResult, acc: TResult|any, keyFn: (elem: T) => string, list: R): TResult; - // reduceBy>(valueFn: (acc: TResult, elem: T, idx: number, list: R) => TResult, acc: TResult|any, keyFn: (elem: T) => string): (list: R) => TResult; - // reduceBy>(valueFn: (acc: TResult, elem: T, idx: number, list: R) => TResult, acc: TResult|any): CurriedFunction2<(elem: T) => string, R, TResult>; - // reduceBy>(valueFn: (acc: TResult, elem: T, idx: number, list: R) => TResult): CurriedFunction3 string, R, TResult>; - // // reduceBy>: CurriedFunction4<(acc: TResult, elem: T, idx: number, list: R) => TResult, TResult|any, (elem: T) => string, R, TResult>; - // base - reduceBy>(valueFn: (acc: TResult, elem: T, idx: number, list: R) => TResult, acc: TResult|any, keyFn: (elem: T) => string, list: R): TResult; - reduceBy>(valueFn: (acc: TResult, elem: T, idx: number, list: R) => TResult, acc: TResult|any, keyFn: (elem: T) => string):{ - (list: R): TResult; - }; - reduceBy>(valueFn: (acc: TResult, elem: T, idx: number, list: R) => TResult, acc: TResult|any):{ - (keyFn: (elem: T) => string, list: R): TResult; - (keyFn: (elem: T) => string):{ - (list: R): TResult; - }; - }; - reduceBy>(valueFn: (acc: TResult, elem: T, idx: number, list: R) => TResult):{ - (acc: TResult|any, keyFn: (elem: T) => string, list: R): TResult; - (acc: TResult|any, keyFn: (elem: T) => string):{ - (list: R): TResult; - }; - (acc: TResult|any):{ - (keyFn: (elem: T) => string, list: R): TResult; - (keyFn: (elem: T) => string):{ - (list: R): TResult; - }; - }; - }; - - - /** - * Returns a value wrapped to indicate that it is the final value of the reduce and - * transduce functions. The returned value should be considered a black box: the internal - * structure is not guaranteed to be stable. - */ - reduced(elem: T): Reduced; - - /** - * Returns a single item by iterating through the list, successively calling the iterator - * function and passing it an accumulator value and the current value from the array, and - * then passing the result to the next call. - */ - // // reason for 'any' on acc: somehow empty accumulators like '[]' won't work well when matching - // reduceRight(fn: (elem: T, acc: TResult) => TResult|Reduced, acc: TResult|any, list: List): TResult; - // reduceRight(fn: (elem: T, acc: TResult) => TResult|Reduced, acc: TResult|any): (list: List) => TResult; - // reduceRight(fn: (elem: T, acc: TResult) => TResult|Reduced): CurriedFunction2, TResult>; - // // reduceRight(fn: (elem: T, acc: TResult) => TResult|Reduced): (acc: TResult|any, list: List) => TResult; - // // reduceRight(fn: (elem: T, acc: TResult) => TResult|Reduced): (acc: TResult|any) => (list: List) => TResult; - // // reduceRight: CurriedFunction3<(elem: T, acc: TResult) => TResult|Reduced, TResult|any, List, TResult>; - // base - reduceRight(fn: (elem: T, acc: TResult) => TResult|Reduced, acc: TResult|any, list: List): TResult; - reduceRight(fn: (elem: T, acc: TResult) => TResult|Reduced, acc: TResult|any):{ - (list: List): TResult; - }; - reduceRight(fn: (elem: T, acc: TResult) => TResult|Reduced):{ - (acc: TResult|any, list: List): TResult; - (acc: TResult|any):{ - (list: List): TResult; - }; - }; - - - /** - * Like reduce, reduceWhile returns a single item by iterating through the list, successively calling the iterator function. - * reduceWhile also takes a predicate that is evaluated before each step. If the predicate returns false, it "short-circuits" - * the iteration and returns the current value of the accumulator. - */ - // reduceWhile(pred: (acc: TResult, elem: T) => boolean, fn: (acc: TResult, elem: T) => TResult|Reduced, acc: TResult, list: List): TResult; - // reduceWhile(pred: (acc: TResult, elem: T) => boolean, fn: (acc: TResult, elem: T) => TResult|Reduced, acc: TResult): (list: List) => TResult; - // reduceWhile(pred: (acc: TResult, elem: T) => boolean, fn: (acc: TResult, elem: T) => TResult|Reduced): CurriedFunction2, TResult>; - // reduceWhile(pred: (acc: TResult, elem: T) => boolean): CurriedFunction3<(acc: TResult, elem: T) => TResult|Reduced, TResult, List, TResult>; - // // reduceWhile: CurriedFunction4<(acc: TResult, elem: T) => boolean, (acc: TResult, elem: T) => TResult|Reduced, TResult, List, TResult>; - - // base - reduceWhile(pred: (acc: TResult, elem: T) => boolean, fn: (acc: TResult, elem: T) => TResult|Reduced, acc: TResult, list: List): TResult; - reduceWhile(pred: (acc: TResult, elem: T) => boolean, fn: (acc: TResult, elem: T) => TResult|Reduced, acc: TResult):{ - (list: List): TResult; - }; - reduceWhile(pred: (acc: TResult, elem: T) => boolean, fn: (acc: TResult, elem: T) => TResult|Reduced):{ - (acc: TResult, list: List): TResult; - (acc: TResult):{ - (list: List): TResult; - }; - }; - reduceWhile(pred: (acc: TResult, elem: T) => boolean):{ - (fn: (acc: TResult, elem: T) => TResult|Reduced, acc: TResult, list: List): TResult; - (fn: (acc: TResult, elem: T) => TResult|Reduced, acc: TResult):{ - (list: List): TResult; - }; - (fn: (acc: TResult, elem: T) => TResult|Reduced):{ - (acc: TResult, list: List): TResult; - (acc: TResult):{ - (list: List): TResult; - }; - }; - }; - - - /** - * Similar to `filter`, except that it keeps only values for which the given predicate - * function returns falsy. - */ - // = filter - - // array - reject(pred: Pred, list: List): T[]; - // reject(pred: Pred): (list: List) => T[]; // mix - // reject: CurriedFunction2, List, T[]>; - - // functor to functor - reject(pred: Pred, list: Functor): Functor; - // reject(pred: Pred): (list: Functor) => Functor; // mix - // reject: CurriedFunction2, Functor, Functor>; - - // functor to array - reject(pred: Pred, list: Functor): T[]; - // reject(pred: Pred): (list: Functor) => T[]; // mix - // reject: CurriedFunction2, Functor, T[]>; - - // object - reject>(pred: Pred, obj: U) : U; - // reject(pred: Pred): >(obj: U) => Partial; // mix - // reject>: CurriedFunction2, U, Partial>; - - // mixed - reject(pred: Pred): { - (list: List): T[]; - (list: Functor): Functor; - (list: Functor): T[]; - >(obj: U): U; - }; - - /** - * Removes the sub-list of `list` starting at index `start` and containing `count` elements. - */ - // remove(start: number, count: number, list: List): T[]; - // remove(start: number, count: number): (list: List) => T[]; - // remove(start: number): CurriedFunction2,T[]>; - // // remove: CurriedFunction3, T[]>; - - // base - remove(start: number, count: number, list: List): T[]; - remove(start: number, count: number):{ - (list: List): T[]; - }; - remove(start: number):{ - (count: number, list: List): T[]; - (count: number):{ - (list: List): T[]; - }; - }; - - - /** - * Returns a fixed list of size n containing a specified identical value. - */ - repeat(a: T, n: number): T[]; - repeat(a: T): (n: number) => T[]; - // repeat: CurriedFunction2; - - - /** - * Replace a substring or regex match in a string with a replacement. - */ - // replace(pattern: RegExp|Prop, replacement: Prop, str: string): string; - // replace(pattern: RegExp|Prop, replacement: Prop): (str: string) => string; - // replace(pattern: RegExp|Prop): CurriedFunction2; - // // replace(pattern: RegExp|Prop): (replacement: Prop, str: string) => string; - // // replace(pattern: RegExp|Prop): (replacement: Prop) => (str: string) => string; - // // replace: CurriedFunction3; - - // base - replace(pattern: RegExp|Prop, replacement: Prop, str: string): string; - replace(pattern: RegExp|Prop, replacement: Prop):{ - (str: string): string; - }; - replace(pattern: RegExp|Prop):{ - (replacement: Prop, str: string): string; - (replacement: Prop):{ - (str: string): string; - }; - }; - - - - /** - * Returns a new list with the same elements as the original list, just in the reverse order. - */ - reverse(list: List): T[]; - - /** - * Scan is similar to reduce, but returns a list of successively reduced values from the left. - */ - // scan(fn: (acc: TResult, elem: T) => TResult|Reduced, acc: TResult, list: List): TResult[]; - // scan(fn: (acc: TResult, elem: T) => TResult|Reduced, acc: TResult): (list: List) => TResult[]; - // scan(fn: (acc: TResult, elem: T) => TResult|Reduced): CurriedFunction2, TResult[]>; - // // scan: CurriedFunction3<(acc: TResult, elem: T) => TResult|Reduced, TResult, List, TResult[]>; - - // base - scan(fn: (acc: TResult, elem: T) => TResult|Reduced, acc: TResult, list: List): TResult[]; - scan(fn: (acc: TResult, elem: T) => TResult|Reduced, acc: TResult):{ - (list: List): TResult[]; - }; - scan(fn: (acc: TResult, elem: T) => TResult|Reduced):{ - (acc: TResult, list: List): TResult[]; - (acc: TResult):{ - (list: List): TResult[]; - }; - }; - - - /** - * Transforms a Traversable of Applicative into an Applicative of Traversable. - */ - - // common case of array as traversable: - sequence(f: (v: T) => Applicative, traversable: List>): Applicative>; - // sequence(f: (v: T) => Applicative): (traversable: List>) => Applicative>; // mix - // sequence: CurriedFunction2<(v: T) => Applicative, List>, Applicative>>; - - // general ADT case: - sequence(f: (v: T) => Applicative, traversable: Traversable>): Applicative>; - // sequence(f: (v: T) => Applicative): (traversable: Traversable>) => Applicative>; // mix - // sequence: CurriedFunction2<(v: T) => Applicative, Traversable>, Applicative>>; - - // mixed: - sequence(f: (v: T) => Applicative): { - (traversable: List>): Applicative>; - (traversable: Traversable>): Applicative>; - }; - - - /** - * Returns the result of "setting" the portion of the given data structure focused by the given lens to the - * given value. - */ - // hard to mix cuz different generics - - // // key lens: - // set(lens: KeyLens, a: T[K], obj: T): T; - // set(lens: KeyLens, a: T[K]): (obj: T) => T; - // set(lens: KeyLens): CurriedFunction2; - // // set: CurriedFunction3, T[K], T, T>; - - // regular lenses: - - // // smart approach, unreliable: - // set(lens: Lens, a: U, obj: T): T; - // set(lens: Lens, a: U): (obj: T) => T; - // // set(lens: Lens): (a: U, obj: T) => T; - // set(lens: Lens): CurriedFunction2; - // // set: CurriedFunction3, U, T, T>; - - // // // manually set lens; is this useful? - // // set(lens: ManualLens, a: U, obj: T): T; - // // set(lens: ManualLens, a: U): (obj: T) => T; - // // set(lens: ManualLens): CurriedFunction2; - // // // set: CurriedFunction3, U, T, T>; - - // // assume result type equal to input object: - // set(lens: UnknownLens, a: any, obj: T): T; - // set(lens: UnknownLens, a: any): (obj: T) => T; - // // set(lens: UnknownLens): (a: any, obj: T) => T; - // set(lens: UnknownLens): CurriedFunction2; - // // set: CurriedFunction3; - - // // // old version, with value as an unbound generic; is this useful? - // // set(lens: UnknownLens, a: U, obj: T): T; - // // set(lens: UnknownLens, a: U): (obj: T) => T; - // // set(lens: UnknownLens): CurriedFunction2; - // // // set: CurriedFunction3; - // base - set(lens: Lens, a: U, obj: T): T; - set(lens: Lens, a: U):{ - (obj: T): T; - }; - set(lens: Lens):{ - (a: U, obj: T): T; - (a: U):{ - (obj: T): T; - }; - }; - - // unknow - set(lens: UnknownLens, a: any, obj: T): T; - set(lens: UnknownLens, a: any):{ - (obj: T): T; - }; - set(lens: UnknownLens):{ - (a: any, obj: T): T; - (a: any):{ - (obj: T): T; - }; - }; - - - /** - * Returns the elements from `xs` starting at `a` and ending at `b - 1`. - */ - // slice>(a: number, b: number, list: T): T; - // slice(a: number, b: number): >(list: T) => T; - // slice>(a: number): CurriedFunction2; - // // slice(a: number): >(b: number, list: T) => T; - // // slice(a: number): >(b: number) => (list: T) => T; - // // slice>: CurriedFunction3; - - // base - slice>(a: number, b: number, list: T): T; - slice(a: number, b: number):{ - >(list: T): T; - }; - slice(a: number):{ - >(b: number, list: T): T; - (b: number):{ - >(list: T): T; - }; - }; - - - /** - * Returns a copy of the list, sorted according to the comparator function, which should accept two values at a - * time and return a negative number if the first value is smaller, a positive number if it's larger, and zero - * if they are equal. - */ - sort(fn: (a: T, b: T) => number, list: List): T[]; - sort(fn: (a: T, b: T) => number): (list: List) => T[]; - // sort: CurriedFunction2<(a: T, b: T) => number, List, T[]>; - - - /** - * Sorts the list according to a key generated by the supplied function. - */ - sortBy(fn: (a: T) => K, list: List): T[]; - sortBy(fn: (a: T) => K): (list: List) => T[]; - // sortBy: CurriedFunction2<(a: T) => K, List, T[]>; - - /** - * Sorts a list according to a list of comparators. - */ - sortWith(comparators: List<(a: T, b: T) => number>, list: List): T[]; - sortWith(comparators: List<(a: T, b: T) => number>): (list: List) => T[]; - // sortWith: CurriedFunction2 number>, List, T[]>; - - /** - * Splits a string into an array of strings based on the given - * separator. - */ - split(sep: RegExp|Prop, str: string): string[]; - split(sep: RegExp|Prop): (str: string) => string[]; - // split: CurriedFunction2; - - /** - * Splits a given list or string at a given index. - */ - // string - splitAt(index: number, list: string): [string, string]; - // splitAt(index: number): (list: string) => [string, string]; - // splitAt: CurriedFunction2; - // array - splitAt(index: number, list: List): T[][]; - // splitAt(index: number): (list: List) => T[][]; - // splitAt: CurriedFunction2, T[][]>; - // mixed - splitAt(index: number): { - (list: string): [string, string]; - (list: List): T[][]; - }; - - /** - * Splits a collection into slices of the specified length. - */ - splitEvery>(a: number, list: R): R[]; - splitEvery(a: number): >(list: R) => R[]; - // splitEvery>: CurriedFunction2; - - /** - * Takes a list and a predicate and returns a pair of lists with the following properties: - * - the result of concatenating the two output lists is equivalent to the input list; - * - none of the elements of the first output list satisfies the predicate; and - * - if the second output list is non-empty, its first element satisfies the predicate. - */ - splitWhen>(pred: Pred, list: R): R[]; - splitWhen(pred: Pred): >(list: R) => R[]; - // splitWhen>: CurriedFunction2, R, R[]>; - - /** - * Subtracts two numbers. Equivalent to `a - b` but curried. - */ - subtract(a: number, b: number): number; - subtract(a: number): (b: number) => number; - // subtract: CurriedFunction2; - - /** - * Adds together all the elements of a list. - */ - sum(list: List): number; - - /** - * Finds the set (i.e. no duplicates) of all elements contained in the first or second list, but not both. - */ - symmetricDifference(list1: List, list2: List): T[]; - symmetricDifference(list: List): (list: List) => T[]; - // symmetricDifference: CurriedFunction2, List, T[]>; - - /** - * Finds the set (i.e. no duplicates) of all elements contained in the first or second list, but not both. - * Duplication is determined according to the value returned by applying the supplied predicate to two list elements. - */ - // symmetricDifferenceWith(pred: (a: T, b: T) => boolean, list1: List, list2: List): T[]; - // symmetricDifferenceWith(pred: (a: T, b: T) => boolean): CurriedFunction2, List, T[]>; - // // symmetricDifferenceWith: CurriedFunction3<(a: T, b: T) => boolean, List, List, T[]>; - - // base - symmetricDifferenceWith(pred: (a: T, b: T) => boolean, list1: List, list2: List): T[]; - symmetricDifferenceWith(pred: (a: T, b: T) => boolean, list1: List):{ - (list2: List): T[]; - }; - symmetricDifferenceWith(pred: (a: T, b: T) => boolean):{ - (list1: List, list2: List): T[]; - (list1: List):{ - (list2: List): T[]; - }; - }; - - - /** - * A function that always returns true. Any passed in parameters are ignored. - */ - T(): true; - - /** - * Returns all but the first element of a list. - */ - tail>(list: T): T; - - /** - * Returns a new list containing the first `n` elements of the given list. If - * `n > * list.length`, returns a list of `list.length` elements. - */ - take>(n: number, xs: T): T; - take(n: number): >(xs: T) => T; - // take>: CurriedFunction2; - - - /** - * Returns a new list containing the last n elements of the given list. If n > list.length, - * returns a list of list.length elements. - */ - // = take - takeLast>(n: number, xs: T): T; - takeLast(n: number): >(xs: T) => T; - // takeLast>: CurriedFunction2; - - /** - * Returns a new list containing the last n elements of a given list, passing each value - * to the supplied predicate function, and terminating when the predicate function returns - * false. Excludes the element that caused the predicate function to fail. The predicate - * function is passed one argument: (value). - */ - // = takeWhile - takeLastWhile>(pred: Pred, list: R): R; - takeLastWhile(pred: Pred): >(list: R) => R; - // takeLastWhile>: CurriedFunction2, R, R>; - - /** - * Returns a new list containing the first `n` elements of a given list, passing each value - * to the supplied predicate function, and terminating when the predicate function returns - * `false`. - */ - takeWhile>(pred: Pred, list: R): R; - takeWhile(pred: Pred): >(list: R) => R; - // takeWhile>: CurriedFunction2, R, R>; - - /** - * The function to call with x. The return value of fn will be thrown away. - */ - tap(fn: (a: T) => any, value: T): T; - tap(fn: (a: T) => any): (value: T) => T; - // tap: CurriedFunction2<(a: T) => any, T, T>; - - /** - * Determines whether a given string matches a given regular expression. - */ - test(regexp: RegExp, str: Prop): boolean; - test(regexp: RegExp): (str: Prop) => boolean; - // test: CurriedFunction2; - - /** - * Calls an input function `n` times, returning an array containing the results of those - * function calls. - */ - times(fn: (i: number) => T, n: number): T[]; - times(fn: (i: number) => T): (n: number) => T[]; - // times: CurriedFunction2<(i: number) => T, number, T[]>; - - - /** - * The lower case version of a string. - */ - toLower(str: string): string; - - /** - * Converts an object into an array of key, value arrays. - * Only the object's own properties are used. - * Note that the order of the output array is not guaranteed to be - * consistent across different JS platforms. - */ - toPairs(obj: Obj): [string,T][]; - - /** - * Converts an object into an array of key, value arrays. - * The object's own properties and prototype properties are used. - * Note that the order of the output array is not guaranteed to be - * consistent across different JS platforms. - */ - toPairsIn(obj: Obj): [string,T][]; - toPairsIn(obj: Object): [string,any][]; - - /** - * Returns the string representation of the given value. eval'ing the output should - * result in a value equivalent to the input value. Many of the built-in toString - * methods do not satisfy this requirement. - * - * If the given value is an [object Object] with a toString method other than - * Object.prototype.toString, this method is invoked with no arguments to produce the - * return value. This means user-defined constructor functions can provide a suitable - * toString method. - */ - toString(val: StringRepresentable | any): string; - - /** - * The upper case version of a string. - */ - toUpper(str: string): string; - - /** - * Initializes a transducer using supplied iterator function. Returns a single item by iterating through the - * list, successively calling the transformed iterator function and passing it an accumulator value and the - * current value from the array, and then passing the result to the next call. - */ - // transduce(xf: (arg: List) => List, fn: (acc: List, val: U) => List, acc: List, list: List): U; - // transduce(xf: (arg: List) => List, fn: (acc: List, val: U) => List, acc: List): (list: List) => U; - // transduce(xf: (arg: List) => List, fn: (acc: List, val: U) => List): CurriedFunction2,List,U>; - // transduce(xf: (arg: List) => List): CurriedFunction3<(acc: List, val: U) => List,List,List,U>; - // // transduce: CurriedFunction4<(arg: List) => List, (acc: List, val: U) => List, List, List, U>; - - // base - transduce(xf: (arg: List) => List, fn: (acc: List, val:U) => List, acc: List, list: List): U; - transduce(xf: (arg: List) => List, fn: (acc: List, val:U) => List, acc: List):{ - (list: List): U; - }; - transduce(xf: (arg: List) => List, fn: (acc: List, val:U) => List):{ - (acc: List, list: List): U; - (acc: List):{ - (list: List): U; - }; - }; - transduce(xf: (arg: List) => List):{ - (fn: (acc: List, val:U) => List, acc: List, list: List): U; - (fn: (acc: List, val:U) => List, acc: List):{ - (list: List): U; - }; - (fn: (acc: List, val:U) => List):{ - (acc: List, list: List): U; - (acc: List):{ - (list: List): U; - }; - }; - }; - - - /** - * Transposes the rows and columns of a 2D list. When passed a list of n lists of length x, returns a list of x lists of length n. - */ - transpose(list: List>): T[][]; - transpose(list: List>): any[][]; - - /** - * Maps an Applicative-returning function over a Traversable, then uses - * `sequence` to transform the resulting Traversable of Applicative into - * an Applicative of Traversable. - */ - - // // common case of array as traversable: - // traverse(ap: (v: T) => Applicative, fn: (v: T) => Applicative, traversable: List): Applicative>; - // // traverse(ap: (v: T) => Applicative, fn: (v: T) => Applicative): (traversable: List) => Applicative>; // mix - // traverse(ap: (v: T) => Applicative): CurriedFunction2<(v: T) => Applicative, List, Applicative>>; - // // traverse: CurriedFunction3<(v: T) => Applicative, (v: T) => Applicative, List, Applicative>>; - - // // general ADT case: - // traverse(ap: (v: T) => Applicative, fn: (v: T) => Applicative, traversable: Traversable): Applicative>; - // // traverse(ap: (v: T) => Applicative, fn: (v: T) => Applicative): (traversable: Traversable) => Applicative>; // mix - // traverse(ap: (v: T) => Applicative): CurriedFunction2<(v: T) => Applicative, Traversable, Applicative>>; - // // traverse: CurriedFunction3<(v: T) => Applicative, (v: T) => Applicative, Traversable, Applicative>>; - - // // mixed: - // traverse(ap: (v: T) => Applicative, fn: (v: T) => Applicative): { - // (traversable: List): Applicative>; - // (traversable: Traversable): Applicative>; - // }; - - // base - traverse(ap: (v: T) => Applicative, fn: (v: T) => Applicative, traversable: List): Applicative>; - traverse(ap: (v: T) => Applicative, fn: (v: T) => Applicative):{ - (traversable: List): Applicative>; - }; - traverse(ap: (v: T) => Applicative):{ - (fn: (v: T) => Applicative, traversable: List): Applicative>; - (fn: (v: T) => Applicative):{ - (traversable: List): Applicative>; - }; - }; - - // general ADT case - traverse(ap: (v: T) => Applicative, fn: (v: T) => Applicative, traversable: List): Applicative>; - traverse(ap: (v: T) => Applicative, fn: (v: T) => Applicative):{ - (traversable: List): Applicative>; - }; - traverse(ap: (v: T) => Applicative):{ - (fn: (v: T) => Applicative, traversable: List): Applicative>; - (fn: (v: T) => Applicative):{ - (traversable: List): Applicative>; - }; - }; - - - /** - * Removes (strips) whitespace from both ends of the string. - */ - trim(str: string): string; - - /** - * tryCatch takes two functions, a tryer and a catcher. The returned function evaluates the tryer; if it does - * not throw, it simply returns the result. If the tryer does throw, the returned function evaluates the catcher - * function and returns its result. Note that for effective composition with this function, both the tryer and - * catcher functions must return the same type of results. - */ - tryCatch(tryer: Variadic, catcher: Variadic): Variadic; - // tryCatch: CurriedFunction2, Variadic, Variadic>; - - /** - * Gives a single-word string description of the (native) type of a value, returning such answers as 'Object', - * 'Number', 'Array', or 'Null'. Does not attempt to distinguish user Object types any further, reporting them - * all as 'Object'. - */ - type(val: any): string; - - /** - * Takes a function fn, which takes a single array argument, and returns a function which: - * - takes any number of positional arguments; - * - passes these arguments to fn as an array; and - * - returns the result. - * In other words, R.unapply derives a variadic function from a function which takes an array. - * R.unapply is the inverse of R.apply. - */ - unapply(fn: (args: any[]) => T): Variadic; - - /** - * Wraps a function of any arity (including nullary) in a function that accepts exactly 1 parameter. - * Any extraneous parameters will not be passed to the supplied function. - */ - unary(fn: (a: T, ...args: any[]) => U): (a: T) => U; - - /** - * Returns a function of arity n from a (manually) curried function. - */ - uncurryN(len: number, fn: (a: any) => any): Variadic; - // uncurryN: CurriedFunction2 any, Variadic>; - - /** - * Builds a list from a seed value. Accepts an iterator function, which returns either false - * to stop iteration or an array of length 2 containing the value to add to the resulting - * list and the seed to be used in the next call to the iterator function. - */ - unfold(fn: (seed: T) => [TResult, T]|false, seed: T): TResult[]; - unfold(fn: (seed: T) => [TResult, T]|false): (seed: T) => TResult[]; - // unfold: CurriedFunction2<(seed: T) => TResult[]|boolean, T, TResult[]>; - - /** - * Combines two lists into a set (i.e. no duplicates) composed of the - * elements of each list. - */ - union(as: List, bs: List): T[]; - union(as: List): (bs: List) => T[]; - // union: CurriedFunction2, List, T[]>; - - /** - * Combines two lists into a set (i.e. no duplicates) composed of the elements of each list. Duplication is - * determined according to the value returned by applying the supplied predicate to two list elements. - */ - // unionWith(pred: (a: T, b: T) => boolean, list1: List, list2: List): T[]; - // unionWith(pred: (a: T, b: T) => boolean, list1: List): (list2: List) => T[]; - // unionWith(pred: (a: T, b: T) => boolean): CurriedFunction2, List, T[]>; - // // unionWith: CurriedFunction3<(a: T, b: T) => boolean, List, List, T[]>; - - // base - unionWith(pred: (a: T, b: T) => boolean, list1: List, list2: List): T[]; - unionWith(pred: (a: T, b: T) => boolean, list1: List):{ - (list2: List): T[]; - }; - unionWith(pred: (a: T, b: T) => boolean):{ - (list1: List, list2: List): T[]; - (list1: List):{ - (list2: List): T[]; - }; - }; - - - /** - * Returns a new list containing only one copy of each element in the original list. - */ - uniq(list: List): T[]; - - /** - * Returns a new list containing only one copy of each element in the original list, based upon the value returned by applying the supplied function to each list element. Prefers the first item if the supplied function produces the same value on two items. R.equals is used for comparison. - */ - uniqBy(fn: (a: T) => U, list: List): T[]; - uniqBy(fn: (a: T) => U): (list: List) => T[]; - // uniqBy: CurriedFunction2<(a: T) => U, List, T[]>; - - /** - * Returns a new list containing only one copy of each element in the original list, based upon the value - * returned by applying the supplied predicate to two list elements. - */ - uniqWith(pred: (x: T, y: T) => boolean, list: List): T[]; - uniqWith(pred: (x: T, y: T) => boolean): (list: List) => T[]; - // uniqWith: CurriedFunction2<(x: T, y: T) => boolean, List, T[]>; - - /** - * Tests the final argument by passing it to the given predicate function. If the predicate is not satisfied, - * the function will return the result of calling the whenFalseFn function with the same argument. If the - * predicate is satisfied, the argument is returned as is. - */ - unless(pred: Pred, whenFalseFn: (a: T) => U, obj: T): U; - unless(pred: Pred, whenFalseFn: (a: T) => U): (obj: T) => U; - // unless: CurriedFunction3, (a: T) => U, T, U>; - - /** - * Returns a new list by pulling every item at the first level of nesting out, and putting - * them in a new array. - */ - unnest(x: List>): T[]; - unnest(x: List): T[]; - - /** - * Takes a predicate, a transformation function, and an initial value, and returns a value of the same type as - * the initial value. It does so by applying the transformation until the predicate is satisfied, at which point - * it returns the satisfactory value. - */ - // until(pred: Pred, fn: (val: T) => U, init: U): U; - // until(pred: Pred, fn: (val: T) => U): (init: U) => U; - // until(pred: Pred): CurriedFunction2<(val: T) => U, U, U>; - // // until: CurriedFunction3, (val: T) => U, U, U>; - - // base - until(pred: Pred, fn: (val: T) => U, init: U): U; - until(pred: Pred, fn: (val: T) => U):{ - (init: U): U; - }; - until(pred: Pred):{ - (fn: (val: T) => U, init: U): U; - (fn: (val: T) => U):{ - (init: U): U; - }; - }; - - - /** - * Returns a new copy of the array with the element at the provided index replaced with the given value. - */ - // update(index: number, value: T, list: List): T[]; - // update(index: number, value: T): (list: List) => T[]; - // update(index: number): CurriedFunction2,T[]>; - // // update: CurriedFunction3, T[]>; - - // base - update(index: number, value: T, list: List): T[]; - update(index: number, value: T):{ - (list: List): T[]; - }; - update(index: number):{ - (value: T, list: List): T[]; - (value: T):{ - (list: List): T[]; - }; - }; - - - /** - * Accepts a function fn and a list of transformer functions and returns a new curried function. - * When the new function is invoked, it calls the function fn with parameters consisting of the - * result of calling each supplied handler on successive arguments to the new function. - * - * If more arguments are passed to the returned function than transformer functions, those arguments - * are passed directly to fn as additional parameters. If you expect additional arguments that don't - * need to be transformed, although you can ignore them, it's best to pass an identity function so - * that the new function reports the correct arity. - */ - useWith(fn: Variadic, transformers: List): Variadic; - useWith(fn: Variadic): (transformers: List) => Variadic; - // useWith: CurriedFunction2, List, Variadic>; - - /** - * Returns a list of all the enumerable own properties of the supplied object. - * Note that the order of the output array is not guaranteed across - * different JS platforms. - */ - values(obj: Struct): T[]; - values(obj: Object): any[]; - - /** - * Returns a list of all the properties, including prototype properties, of the supplied - * object. Note that the order of the output array is not guaranteed to be consistent across different JS platforms. - */ - valuesIn(obj: Struct): T[]; - valuesIn(obj: Object): any[]; - - /** - * Returns a "view" of the given data structure, determined by the given lens. The lens's focus determines which - * portion of the data structure is visible. - */ - // hard to mix cuz different generics - - // // key lens: - // view(lens: KeyLens, obj: T): T[K]; - // view(lens: KeyLens): (obj: T) => T[K]; - // // view: CurriedFunction2, T, T[K]>; - - // regular lenses: - - // smart approach, unreliable: - view(lens: Lens, obj: T): U; - view(lens: Lens): (obj: T) => U; - // view: CurriedFunction2, T, U>; - - // lens with type manually set - view(lens: ManualLens, obj: Struct): T; - view(lens: ManualLens): (obj: Struct) => T; - // view: CurriedFunction2, Struct, T>; - - // unknown lens, manually supply return type. does this add to the above case? - view(lens: UnknownLens, obj: Struct): T; - view(lens: UnknownLens): (obj: Struct) => T; - // view: CurriedFunction2, T>; - - /** - * Tests the final argument by passing it to the given predicate function. If the predicate is satisfied, the function - * will return the result of calling the whenTrueFn function with the same argument. If the predicate is not satisfied, - * the argument is returned as is. - */ - // when(pred: Pred, whenTrueFn: (a: T) => U, obj: T): U; - // when(pred: Pred, whenTrueFn: (a: T) => U): (obj: T) => U; - // when(pred: Pred): CurriedFunction2<(a: T) => U, T, U>; - // // when: CurriedFunction3, (a: T) => U, T, U>; - - // base - when(pred: Pred, whenTrueFn: (a: T) => U, obj: T): U; - when(pred: Pred, whenTrueFn: (a: T) => U):{ - (obj: T): U; - }; - when(pred: Pred):{ - (whenTrueFn: (a: T) => U, obj: T): U; - (whenTrueFn: (a: T) => U):{ - (obj: T): U; - }; - }; - - - - /** - * Takes a spec object and a test object and returns true if the test satisfies the spec. - * Any property on the spec that is not a function is interpreted as an equality - * relation. - * - * If the spec has a property mapped to a function, then `where` evaluates the function, passing in - * the test object's value for the property in question, as well as the whole test object. - * - * `where` is well suited to declarativley expressing constraints for other functions, e.g., - * `filter`, `find`, etc. - */ - // hard to mix cuz different generics - - // // heterogeneous version - // where>(spec: { [P in keyof T]?: Pred; }, testObj: T): boolean; - // where>(spec: { [P in keyof T]?: Pred; }): (testObj: T) => boolean; // generics too early? - // // where>: CurriedFunction2<{ [P in keyof T]?: Pred; }, T, boolean>; - - // homogeneous version - where(spec: Obj>, testObj: Obj): boolean; - where(spec: Obj>): (testObj: Obj) => boolean; - // where: CurriedFunction2>, Obj, boolean>; - - // DIY "fill in the type params yourself" version - where(spec: T, testObj: U): boolean; - where(spec: T): (testObj: U) => boolean; - // where: CurriedFunction2; - - /** - * Takes a spec object and a test object; returns true if the test satisfies the spec, - * false otherwise. An object satisfies the spec if, for each of the spec's own properties, - * accessing that property of the object gives the same value (in R.eq terms) as accessing - * that property of the spec. - */ - // hard to mix cuz different generics - - // // heterogeneous version - // whereEq>(spec: Partial, testObj: T): boolean; - // whereEq>(spec: Partial): (testObj: T) => boolean; - // // whereEq>: CurriedFunction2, T, boolean>; - - // homogeneous version - whereEq(spec: Obj, testObj: Obj): boolean; - whereEq(spec: Obj): (testObj: Obj) => boolean; - // whereEq: CurriedFunction2, Obj, boolean>; - - // DIY "fill in the type params yourself" version - whereEq(spec: T, testObj: U): boolean; - whereEq(spec: T): (testObj: U) => boolean; - // whereEq: CurriedFunction2; - - /** - * Returns a new list without values in the first argument. R.equals is used to determine equality. - * Acts as a transducer if a transformer is given in list position. - */ - without(list1: List, list2: List): T[]; - without(list1: List): (list2: List) => T[]; - // without: CurriedFunction2, List, T[]>; - - /** - * Creates a new list out of the two supplied by creating each possible pair from the lists. - */ - xprod(as: List, bs: List): KeyValuePair[]; - xprod(as: List): (bs: List) => KeyValuePair[]; - // xprod: CurriedFunction2, List, KeyValuePair[]>; - - /** - * Creates a new list out of the two supplied by pairing up equally-positioned items from - * both lists. Note: `zip` is equivalent to `zipWith(function(a, b) { return [a, b] })`. - */ - zip(list1: List, list2: List): KeyValuePair[]; - zip(list1: List): (list2: List) => KeyValuePair[]; - // zip: CurriedFunction2, List, KeyValuePair[]>; - - /** - * Creates a new object out of a list of keys and a list of values. - */ - // TODO: Obj as a return value is to specific, any seems to loose - zipObj(keys: List, values: List): Obj; - zipObj(keys: List): (values: List) => Obj; - // zipObj: CurriedFunction2, List, Obj>; - - - /** - * Creates a new list out of the two supplied by applying the function to each - * equally-positioned pair in the lists. - */ - zipWith(fn: (x: T, y: U) => TResult, list1: List, list2: List): TResult[]; - zipWith(fn: (x: T, y: U) => TResult, list1: List): (list2: List) => TResult[]; - zipWith(fn: (x: T, y: U) => TResult): CurriedFunction2, List, TResult[]>; - // zipWith: CurriedFunction3<(x: T, y: U) => TResult, List, List, TResult[]>; - - } + }; + + + + /** + * Takes a spec object and a test object and returns true if the test satisfies the spec. + * Any property on the spec that is not a function is interpreted as an equality + * relation. + * + * If the spec has a property mapped to a function, then `where` evaluates the function, passing in + * the test object's value for the property in question, as well as the whole test object. + * + * `where` is well suited to declarativley expressing constraints for other functions, e.g., + * `filter`, `find`, etc. + */ + // hard to mix cuz different generics + + // // heterogeneous version + // where>(spec: { [P in keyof T]?: Pred; }, testObj: T): boolean; + // where>(spec: { [P in keyof T]?: Pred; }): (testObj: T) => boolean; // generics too early? + // // where>: CurriedFunction2<{ [P in keyof T]?: Pred; }, T, boolean>; + + // homogeneous version + where(spec: Obj>, testObj: Obj): boolean; + where(spec: Obj>): (testObj: Obj) => boolean; + // where: CurriedFunction2>, Obj, boolean>; + + // DIY "fill in the type params yourself" version + where(spec: T, testObj: U): boolean; + where(spec: T): (testObj: U) => boolean; + // where: CurriedFunction2; + + /** + * Takes a spec object and a test object; returns true if the test satisfies the spec, + * false otherwise. An object satisfies the spec if, for each of the spec's own properties, + * accessing that property of the object gives the same value (in R.eq terms) as accessing + * that property of the spec. + */ + // hard to mix cuz different generics + + // // heterogeneous version + // whereEq>(spec: Partial, testObj: T): boolean; + // whereEq>(spec: Partial): (testObj: T) => boolean; + // // whereEq>: CurriedFunction2, T, boolean>; + + // homogeneous version + whereEq(spec: Obj, testObj: Obj): boolean; + whereEq(spec: Obj): (testObj: Obj) => boolean; + // whereEq: CurriedFunction2, Obj, boolean>; + + // DIY "fill in the type params yourself" version + whereEq(spec: T, testObj: U): boolean; + whereEq(spec: T): (testObj: U) => boolean; + // whereEq: CurriedFunction2; + + /** + * Returns a new list without values in the first argument. R.equals is used to determine equality. + * Acts as a transducer if a transformer is given in list position. + */ + without(list1: List, list2: List): T[]; + without(list1: List): (list2: List) => T[]; + // without: CurriedFunction2, List, T[]>; + + /** + * Creates a new list out of the two supplied by creating each possible pair from the lists. + */ + xprod(as: List, bs: List): KeyValuePair[]; + xprod(as: List): (bs: List) => KeyValuePair[]; + // xprod: CurriedFunction2, List, KeyValuePair[]>; + + /** + * Creates a new list out of the two supplied by pairing up equally-positioned items from + * both lists. Note: `zip` is equivalent to `zipWith(function(a, b) { return [a, b] })`. + */ + zip(list1: List, list2: List): KeyValuePair[]; + zip(list1: List): (list2: List) => KeyValuePair[]; + // zip: CurriedFunction2, List, KeyValuePair[]>; + + /** + * Creates a new object out of a list of keys and a list of values. + */ + // TODO: Obj as a return value is to specific, any seems to loose + zipObj(keys: List, values: List): Obj; + zipObj(keys: List): (values: List) => Obj; + // zipObj: CurriedFunction2, List, Obj>; + + + /** + * Creates a new list out of the two supplied by applying the function to each + * equally-positioned pair in the lists. + */ + zipWith(fn: (x: T, y: U) => TResult, list1: List, list2: List): TResult[]; + zipWith(fn: (x: T, y: U) => TResult, list1: List): (list2: List) => TResult[]; + zipWith(fn: (x: T, y: U) => TResult): CurriedFunction2, List, TResult[]>; + // zipWith: CurriedFunction3<(x: T, y: U) => TResult, List, List, TResult[]>; + + } } export = R; diff --git a/interfaces.d.ts b/interfaces.d.ts new file mode 100644 index 0000000..43ba384 --- /dev/null +++ b/interfaces.d.ts @@ -0,0 +1,223 @@ +// Fantasyland export interfaces + +// TODO: incorporate generalized inheritance e.g.: ``; possibly needs [rank 2 +// polymorphism](https://github.com/Microsoft/TypeScript/issues/1213). + +export interface Setoid { + equals(b: Setoid): boolean; +} + +export interface Semigroup { + concat(b: Semigroup): Semigroup; +} + +export interface Monoid extends Semigroup { + /* static */ empty(): Monoid; +} + +export interface Functor { + map(fn: (t: T) => U): Functor; +} + +export interface Apply extends Functor { + apply(fn: Apply<(t: T) => U>): Apply; +} + +export interface Applicative extends Apply { + /* static */ of(a: U): Applicative; +} + +export interface Alt extends Functor { + alt(b: T): Alt; +} + +export interface Plus extends Alt { + /* static */ zero(): Plus; +} + +export interface Alternative extends Plus, Applicative { +} + +export interface Foldable { + reduce(fn: (u: U, t: T) => U, u: U): U; +} + +export interface Traversable extends Functor, Foldable { + traverse(fn: (t: T) => Applicative, of: (v: V) => Applicative): Applicative>; +} + +export interface Chain extends Apply { + chain(fn: (t: T) => Chain): Chain; +} + +export interface ChainRec extends Chain { + /* static */ chainRec(f: (next: (a: A) => C, done: (b: B) => C, value: A) => ChainRec, i: A): ChainRec; +} + +export interface Monad extends Applicative, Chain { +} + +export interface Extend { + extend(f: (v: Extend) => U): Extend; +} + +export interface Comonad extends Functor, Extend { + extract(): U; // 'same U as in extend's f -- how to bind? +} + +export interface Bifunctor extends Functor /*, Functor*/ { + bimap(f: (v: T) => B, g: (v: U) => D): Bifunctor; +} + +export interface Profunctor extends Functor /*, Functor*/ { + promap(f: (v: T) => B, g: (v: U) => D): Profunctor; +} + +// simple types + +type Index = string | number; +type Primitive = string | number | boolean; +type Ord = string | number | boolean | Date; + +export interface Dictionary { + [index: string]: T; +} + +type Obj = Dictionary; +type List = ArrayLike; +type StringLike = string | StringRepresentable; +type Prop = Index | StringRepresentable; +type Path = List; +type Struct = Obj | List; +type AccOpts = List|Obj|Transformer; +type Pred = (v: T) => boolean; +type ObjPred = (value: T, key: string) => boolean; + +// Ramda export interfaces + +export interface Type extends Function { + new (...args: any[]): T; +} + +export interface Variadic { + (...args: any[]): T; +} + +export interface KeyValuePair extends Array { 0 : K; 1 : V; } + +export interface Transformer { + step: (acc: Acc, v: T) => Acc; + init: () => Acc; + result: (acc: Acc) => Res; // = R.identity +} + +export interface NumericDictionary { + [index: number]: T; +} + +export interface StringRepresentable { + toString(): T; +} + +export interface NestedObj { + [index: string]: T|NestedObj; +} + +// export interface RecursiveArray extends Array> {} +// export interface ListOfRecursiveArraysOrValues extends List> {} +export interface NestedArray { + [index: number]: T | NestedArray; + length: number; +} + +// // an unfortunate compromise -- while the actual lens should be generic, for the purpose of TS the structure should be supplied beforehand +// export interface KeyLens, K extends keyof T> { +// // > +// (obj: T): T[K]; // get +// set(v: T[K], obj: T): T; +// // map(fn: (v: T[K]) => T[K], obj: T): T +// } +export interface Lens { + (obj: T): U; // get + set(v: U, obj: T): T; + // map(fn: (v: U) => U, obj: T): T +} +export interface ManualLens { + >(obj: T): U; // get + set>(v: U, obj: T): T; + // >map(fn: (v: U) => U, obj: T): T +} +export interface UnknownLens { + (obj: T): U; // get + set(v: U, obj: T): T; + // map(fn: (v: U) => U, obj: T): T +} + +// @see https://gist.github.com/donnut/fd56232da58d25ceecf1, comment by @albrow + +// export interface CurriedFunction1 { +// (v1: T1): R; +// } +type CurriedFunction1 = (v1: T1) => R; + +export interface CurriedFunction2 { + (v1: T1): (v2: T2) => R; + (v1: T1, v2: T2): R; +} +export interface CurriedFunction3 { + (v1: T1): CurriedFunction2; + (v1: T1, v2: T2): (v3: T3) => R; + (v1: T1, v2: T2, v3: T3): R; +} +export interface CurriedFunction4 { + (v1: T1): CurriedFunction3; + (v1: T1, v2: T2): CurriedFunction2; + (v1: T1, v2: T2, v3: T3): (v4: T4) => R; + (v1: T1, v2: T2, v3: T3, v4: T4): R; +} +export interface CurriedFunction5 { + (v1: T1): CurriedFunction4; + (v1: T1, v2: T2): CurriedFunction3; + (v1: T1, v2: T2, v3: T3): CurriedFunction2; + (v1: T1, v2: T2, v3: T3, v4: T4): (v5: T5) => R; + (v1: T1, v2: T2, v3: T3, v4: T4, v5: T5): R; +} +export interface CurriedFunction6 { + (v1: T1): CurriedFunction5; + (v1: T1, v2: T2): CurriedFunction4; + (v1: T1, v2: T2, v3: T3): CurriedFunction3; + (v1: T1, v2: T2, v3: T3, v4: T4): CurriedFunction2; + (v1: T1, v2: T2, v3: T3, v4: T4, v5: T5): (v6: T6) => R; + (v1: T1, v2: T2, v3: T3, v4: T4, v5: T5, v6: T6): R; +} +export interface CurriedFunction7 { + (v1: T1): CurriedFunction6; + (v1: T1, v2: T2): CurriedFunction5; + (v1: T1, v2: T2, v3: T3): CurriedFunction4; + (v1: T1, v2: T2, v3: T3, v4: T4): CurriedFunction3; + (v1: T1, v2: T2, v3: T3, v4: T4, v5: T5): CurriedFunction2; + (v1: T1, v2: T2, v3: T3, v4: T4, v5: T5, v6: T6): (v7: T7) => R; + (v1: T1, v2: T2, v3: T3, v4: T4, v5: T5, v6: T6, v7: T7): R; +} +export interface CurriedFunction8 { + (v1: T1): CurriedFunction7; + (v1: T1, v2: T2): CurriedFunction6; + (v1: T1, v2: T2, v3: T3): CurriedFunction5; + (v1: T1, v2: T2, v3: T3, v4: T4): CurriedFunction4; + (v1: T1, v2: T2, v3: T3, v4: T4, v5: T5): CurriedFunction3; + (v1: T1, v2: T2, v3: T3, v4: T4, v5: T5, v6: T6): CurriedFunction2; + (v1: T1, v2: T2, v3: T3, v4: T4, v5: T5, v6: T6, v7: T7): (v8: T8) => R; + (v1: T1, v2: T2, v3: T3, v4: T4, v5: T5, v6: T6, v7: T7, v8: T8): R; +} +export interface CurriedFunction9 { + (v1: T1): CurriedFunction8; + (v1: T1, v2: T2): CurriedFunction7; + (v1: T1, v2: T2, v3: T3): CurriedFunction6; + (v1: T1, v2: T2, v3: T3, v4: T4): CurriedFunction5; + (v1: T1, v2: T2, v3: T3, v4: T4, v5: T5): CurriedFunction4; + (v1: T1, v2: T2, v3: T3, v4: T4, v5: T5, v6: T6): CurriedFunction3; + (v1: T1, v2: T2, v3: T3, v4: T4, v5: T5, v6: T6, v7: T7): CurriedFunction2; + (v1: T1, v2: T2, v3: T3, v4: T4, v5: T5, v6: T6, v7: T7, v8: T8): (v9: T9) => R; + (v1: T1, v2: T2, v3: T3, v4: T4, v5: T5, v6: T6, v7: T7, v8: T8, v9: T9): R; +} diff --git a/src/__.d.ts b/src/__.d.ts new file mode 100644 index 0000000..707e839 --- /dev/null +++ b/src/__.d.ts @@ -0,0 +1,14 @@ +/** + * A special placeholder value used to specify "gaps" within curried + * functions, allowing partial application of any combination of + * arguments, regardless of their positions. + * NOTE: can't type this yet, for binary functions consider R.flip! + */ +declare const __: any; // { "@@functional/placeholder": boolean }; +// ^ don't type by value, since it can be inserted anywhere... +// Note this is still not useful, as it doesn't take into account how it changes formulas (leaving holes!). +// This remains TODO, and should be done on the level of curried functions, but that +// pretty much requires being able to express the separate functions as a single curried function... +// until that moment handling this would mean having to handle each possible combination for each function. :( + +export default __ \ No newline at end of file diff --git a/src/add.d.ts b/src/add.d.ts new file mode 100644 index 0000000..007a0bf --- /dev/null +++ b/src/add.d.ts @@ -0,0 +1,7 @@ +/** + * Adds two numbers. Equivalent to a + b but curried. + */ +declare function add(a: number, b: number): number; +declare function add(a: number): (b: number) => number; + +export default add diff --git a/src/addIndex.d.ts b/src/addIndex.d.ts new file mode 100644 index 0000000..e581146 --- /dev/null +++ b/src/addIndex.d.ts @@ -0,0 +1,20 @@ +import { + CurriedFunction2, + CurriedFunction3, + List +} from '../interfaces' + +/** +* Creates a new list iteration function from an existing one by adding two new parameters to its callback +* function: the current index, and the entire list. +*/ +declare function addIndex(fn: (f: (item: T) => U, list: List) => U[]): + CurriedFunction2<(item: T, idx: number, list?: List) => U, List, U[]>; +/* Special case for forEach */ +declare function addIndex(fn: (f: (item: T) => void, list: List) => T[]): + CurriedFunction2<(item: T, idx: number, list?: List) => void, List, T[]>; +/* Special case for reduce */ +declare function addIndex(fn: (f: (acc: U, item: T) => U, aci: U, list: List) => U): + CurriedFunction3<(acc: U, item: T, idx: number, list?: List) => U, U, List, U>; + +export default addIndex diff --git a/src/curry.d.ts b/src/curry.d.ts index fc5c44a..1ec3ff7 100644 --- a/src/curry.d.ts +++ b/src/curry.d.ts @@ -1,73 +1,14 @@ - -type CurriedFunction1 = (v1: T1) => R; - -interface CurriedFunction2 { - (v1: T1): (v2: T2) => R; - (v1: T1, v2: T2): R; -} - -interface CurriedFunction3 { - (v1: T1): CurriedFunction2; - (v1: T1, v2: T2): (v3: T3) => R; - (v1: T1, v2: T2, v3: T3): R; -} - -interface CurriedFunction4 { - (v1: T1): CurriedFunction3; - (v1: T1, v2: T2): CurriedFunction2; - (v1: T1, v2: T2, v3: T3): (v4: T4) => R; - (v1: T1, v2: T2, v3: T3, v4: T4): R; -} - -interface CurriedFunction5 { - (v1: T1): CurriedFunction4; - (v1: T1, v2: T2): CurriedFunction3; - (v1: T1, v2: T2, v3: T3): CurriedFunction2; - (v1: T1, v2: T2, v3: T3, v4: T4): (v5: T5) => R; - (v1: T1, v2: T2, v3: T3, v4: T4, v5: T5): R; -} - -interface CurriedFunction6 { - (v1: T1): CurriedFunction5; - (v1: T1, v2: T2): CurriedFunction4; - (v1: T1, v2: T2, v3: T3): CurriedFunction3; - (v1: T1, v2: T2, v3: T3, v4: T4): CurriedFunction2; - (v1: T1, v2: T2, v3: T3, v4: T4, v5: T5): (v6: T6) => R; - (v1: T1, v2: T2, v3: T3, v4: T4, v5: T5, v6: T6): R; -} - -interface CurriedFunction7 { - (v1: T1): CurriedFunction6; - (v1: T1, v2: T2): CurriedFunction5; - (v1: T1, v2: T2, v3: T3): CurriedFunction4; - (v1: T1, v2: T2, v3: T3, v4: T4): CurriedFunction3; - (v1: T1, v2: T2, v3: T3, v4: T4, v5: T5): CurriedFunction2; - (v1: T1, v2: T2, v3: T3, v4: T4, v5: T5, v6: T6): (v7: T7) => R; - (v1: T1, v2: T2, v3: T3, v4: T4, v5: T5, v6: T6, v7: T7): R; -} - -interface CurriedFunction8 { - (v1: T1): CurriedFunction7; - (v1: T1, v2: T2): CurriedFunction6; - (v1: T1, v2: T2, v3: T3): CurriedFunction5; - (v1: T1, v2: T2, v3: T3, v4: T4): CurriedFunction4; - (v1: T1, v2: T2, v3: T3, v4: T4, v5: T5): CurriedFunction3; - (v1: T1, v2: T2, v3: T3, v4: T4, v5: T5, v6: T6): CurriedFunction2; - (v1: T1, v2: T2, v3: T3, v4: T4, v5: T5, v6: T6, v7: T7): (v8: T8) => R; - (v1: T1, v2: T2, v3: T3, v4: T4, v5: T5, v6: T6, v7: T7, v8: T8): R; -} - -interface CurriedFunction9 { - (v1: T1): CurriedFunction8; - (v1: T1, v2: T2): CurriedFunction7; - (v1: T1, v2: T2, v3: T3): CurriedFunction6; - (v1: T1, v2: T2, v3: T3, v4: T4): CurriedFunction5; - (v1: T1, v2: T2, v3: T3, v4: T4, v5: T5): CurriedFunction4; - (v1: T1, v2: T2, v3: T3, v4: T4, v5: T5, v6: T6): CurriedFunction3; - (v1: T1, v2: T2, v3: T3, v4: T4, v5: T5, v6: T6, v7: T7): CurriedFunction2; - (v1: T1, v2: T2, v3: T3, v4: T4, v5: T5, v6: T6, v7: T7, v8: T8): (v9: T9) => R; - (v1: T1, v2: T2, v3: T3, v4: T4, v5: T5, v6: T6, v7: T7, v8: T8, v9: T9): R; -} +import { + CurriedFunction1, + CurriedFunction2, + CurriedFunction3, + CurriedFunction4, + CurriedFunction5, + CurriedFunction6, + CurriedFunction7, + CurriedFunction8, + CurriedFunction9 +} from '../interfaces' /** * Returns a curried equivalent of the provided function. diff --git a/src/props.d.ts b/src/props.d.ts new file mode 100644 index 0000000..f00c295 --- /dev/null +++ b/src/props.d.ts @@ -0,0 +1,31 @@ +import { Struct, List } from '../interfaces' + +/** + * Acts as multiple `prop`: array of keys in, array of values out. Preserves order. + */ + + + +declare function props< + P1 extends string, + O extends {[K in P1]: any}> + (ps: [P1], obj: O): [O[P1]]; + + +declare function props< + P1 extends string, P2 extends string, + O extends {[K in P1 | P2]: any}> + (ps: [P1, P2], obj: O): [O[P1], O[P2]]; + +declare function props + (ps: [P1, P2]): (obj: {[K in P1]: T1} & {[K2 in P2]: T2}) + => [T1, T2]; + + +// declare function props +// (ps: [A], obj: {[K in A]: PropA}): [PropA]; +// declare function props(ps: List, obj: Struct): T[]; +// declare function props(ps: List, obj: Struct): T[]; +// declare function props(ps: List): (obj: Struct) => T[]; + +export default props From bc4fad4dd2a2b3f22b2be952026f8f46193cbfcd Mon Sep 17 00:00:00 2001 From: whitecolor Date: Wed, 5 Apr 2017 13:40:49 +0500 Subject: [PATCH 03/19] add tape --- package.json | 2 ++ {tests => test}/merge.ts | 0 test/props.ts | 13 +++++++++++++ tsconfig.json | 7 ++++++- 4 files changed, 21 insertions(+), 1 deletion(-) rename {tests => test}/merge.ts (100%) create mode 100644 test/props.ts diff --git a/package.json b/package.json index 032c63f..629daad 100644 --- a/package.json +++ b/package.json @@ -7,7 +7,9 @@ "types": "echo testing types... && bash test.sh" }, "devDependencies": { + "@types/tape": "^4.2.29", "ramda": "0.23.0", + "tape": "^4.6.3", "tslint": "^4.2.0", "tslint-config-typings": "^0.3.1", "typescript": "^2.2.1-insiders.20170209", diff --git a/tests/merge.ts b/test/merge.ts similarity index 100% rename from tests/merge.ts rename to test/merge.ts diff --git a/test/props.ts b/test/props.ts new file mode 100644 index 0000000..94c8c0b --- /dev/null +++ b/test/props.ts @@ -0,0 +1,13 @@ +import props from 'ramda/src/props' +import * as test from 'tape' + +const obj = { + num: 1, + str: 'str', + other: {} +}; + +test('props: one argument', (t) => { + const res = props(['str'], obj) as any + t.is(res[0], 'str' as string) +}) diff --git a/tsconfig.json b/tsconfig.json index 76ea8e8..ba045d2 100644 --- a/tsconfig.json +++ b/tsconfig.json @@ -4,6 +4,11 @@ "module": "commonjs", "noEmit": true, "noImplicitAny": true, - "strictNullChecks": true + "strictNullChecks": true, + "baseUrl": ".", + "paths": { + "ramda": ["."], + "ramda/src/*": ["./src/*"] + } } } From 8bf17074bd4d5385915210e7e9a10ab49bf87c68 Mon Sep 17 00:00:00 2001 From: whitecolor Date: Wed, 5 Apr 2017 13:41:07 +0500 Subject: [PATCH 04/19] add type-check script --- type-check.ts | 46 ++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 46 insertions(+) create mode 100644 type-check.ts diff --git a/type-check.ts b/type-check.ts new file mode 100644 index 0000000..3e74a87 --- /dev/null +++ b/type-check.ts @@ -0,0 +1,46 @@ +import * as ts from 'typescript'; +import * as fs from 'fs'; +import * as path from 'path'; + +const options: ts.CompilerOptions = ts.readConfigFile('tsconfig.json', ts.sys.readFile) + .config.compilerOptions || {}; +const host = ts.createCompilerHost(options, true); + +const testDir = 'test' +const checkCallMatch = /^t\.is/ + +const tsFiles = fs.readdirSync(testDir) + .map(fileName => path.join(testDir, fileName)) + +const program = ts.createProgram(tsFiles, options, host); +const checker = program.getTypeChecker(); +const getType = (node: ts.Node) => + checker.typeToString(checker.getTypeAtLocation(node)); + +tsFiles.forEach(tsFile => { + const source = program.getSourceFile(tsFile); + const traverseNodes = (node: ts.Node) => { + node.getChildren().forEach(child => { + if (child.getText().match(checkCallMatch)) { + if (child.kind === ts.SyntaxKind.CallExpression) { + const argsNode = child.getChildren()[2]; + const firstArg = argsNode.getChildren()[0]; + const secondArg = argsNode.getChildren()[2]; + const firstArgType = getType(firstArg); + const secondArgType = getType(secondArg); + if (firstArgType !== secondArgType) { + var pos = source.getLineAndCharacterOfPosition(child.pos) + throw new Error( + `Types of arguments do not match in \`${child.getText()}\`\n` + + `${tsFile}:${pos.line},${pos.character}\n` + + `\`${firstArg.getText()}\` has type \`${firstArgType}\` ` + + `and \`${secondArg.getText()}\` has type \`${secondArgType}\`` + ); + } + } + } + traverseNodes(child); + }); + }; + traverseNodes(source); +}); From 8820ee06768da7522699d41b4cebded09e94f431 Mon Sep 17 00:00:00 2001 From: whitecolor Date: Wed, 5 Apr 2017 16:11:24 +0500 Subject: [PATCH 05/19] replace tape with mocha --- index.d.ts | 1 + package.json | 9 +++++--- src/props.d.ts | 32 +++++++++++++++------------- test/merge.ts | 2 +- test/props.ts | 41 ++++++++++++++++++++++++++++------- type-check.ts | 58 ++++++++++++++++++++++++++------------------------ 6 files changed, 88 insertions(+), 55 deletions(-) diff --git a/index.d.ts b/index.d.ts index 176d3a7..60b5334 100644 --- a/index.d.ts +++ b/index.d.ts @@ -8,6 +8,7 @@ import add from './src/add' import addIndex from './src/addIndex' import curry from './src/curry' import merge from './src/merge' +import props = require('./src/props') declare var R: R.Static; diff --git a/package.json b/package.json index 629daad..3ba1bdb 100644 --- a/package.json +++ b/package.json @@ -3,13 +3,16 @@ "version": "0.23.0-RC1", "scripts": { "lint": "echo linting... && tslint index.d.ts", - "test": "echo testing errors... && ./node_modules/typescript/bin/tsc --lib \"es2015\" --module commonjs tests/test.ts --noEmit", + "test": "mocha --compilers ts:ts-node/register test/*.ts type-check.ts", + "test-watch": "npm test -- --watch", + "_test": "echo testing errors... && ./node_modules/typescript/bin/tsc --lib \"es2015\" --module commonjs tests/test.ts --noEmit", "types": "echo testing types... && bash test.sh" }, "devDependencies": { - "@types/tape": "^4.2.29", + "@types/mocha": "^2.2.40", + "mocha": "^3.2.0", "ramda": "0.23.0", - "tape": "^4.6.3", + "ts-node": "^3.0.2", "tslint": "^4.2.0", "tslint-config-typings": "^0.3.1", "typescript": "^2.2.1-insiders.20170209", diff --git a/src/props.d.ts b/src/props.d.ts index f00c295..a14db79 100644 --- a/src/props.d.ts +++ b/src/props.d.ts @@ -1,10 +1,12 @@ -import { Struct, List } from '../interfaces' +import { Struct, List, Prop } from '../interfaces' /** * Acts as multiple `prop`: array of keys in, array of values out. Preserves order. */ - - +declare function props< + P1 extends string, P2 extends string, + O extends {[K in P1 | P2]: any}> + (ps: [P1, P2], obj: O): [O[P1], O[P2]]; declare function props< P1 extends string, @@ -13,19 +15,19 @@ declare function props< declare function props< - P1 extends string, P2 extends string, - O extends {[K in P1 | P2]: any}> - (ps: [P1, P2], obj: O): [O[P1], O[P2]]; + P1 extends string, P2 extends string> + (ps: [P1, P2]): (obj: O) => [O[P1], O[P2]]; + + +declare function props + (ps: [P1]): (obj: O) => [O[P1]]; -declare function props - (ps: [P1, P2]): (obj: {[K in P1]: T1} & {[K2 in P2]: T2}) - => [T1, T2]; +// declare function props +// (ps: [P1, P2]): (obj: {[K in P1]: T1} & {[K2 in P2]: T2}) +// => [T1, T2]; -// declare function props -// (ps: [A], obj: {[K in A]: PropA}): [PropA]; -// declare function props(ps: List, obj: Struct): T[]; -// declare function props(ps: List, obj: Struct): T[]; -// declare function props(ps: List): (obj: Struct) => T[]; +//declare function props(ps: List, obj: List): T[]; +//declare function props(ps: List): (obj: List) => T[]; -export default props +export = props; diff --git a/test/merge.ts b/test/merge.ts index f58ffc3..35d91d7 100644 --- a/test/merge.ts +++ b/test/merge.ts @@ -1,4 +1,4 @@ -import * as R from '..'; +import * as R from 'ramda'; () => { // $ExpectType Dictionary diff --git a/test/props.ts b/test/props.ts index 94c8c0b..ff31102 100644 --- a/test/props.ts +++ b/test/props.ts @@ -1,13 +1,38 @@ -import props from 'ramda/src/props' -import * as test from 'tape' +import props = require('ramda/src/props'); +import { equal } from 'assert'; -const obj = { +interface TestObj { + num: number, + str: string, + other: {} +} + +const obj: TestObj = { num: 1, - str: 'str', + str: 'strValue', other: {} }; -test('props: one argument', (t) => { - const res = props(['str'], obj) as any - t.is(res[0], 'str' as string) -}) +describe('props', () => { + it('one prop', () => { + const res = props(['str'], obj); + equal(res[0], 'strValue' as string); + }); + + it('two props', () => { + const res = props(['str', 'num'], obj); + equal(res[0], 'strValue'); + equal(res[1], 1 as number); + }); + + it('curried: one prop', () => { + const res = props(['str'])(obj); + equal(res[0], 'strValue' as string); + }); + + it('curried: two props', () => { + const res = props(['str', 'num'])(obj); + equal(res[0], 'strValue' as string); + equal(res[1], 1 as number); + }); +}); diff --git a/type-check.ts b/type-check.ts index 3e74a87..b201c88 100644 --- a/type-check.ts +++ b/type-check.ts @@ -1,46 +1,48 @@ import * as ts from 'typescript'; import * as fs from 'fs'; import * as path from 'path'; +import { equal } from 'assert'; const options: ts.CompilerOptions = ts.readConfigFile('tsconfig.json', ts.sys.readFile) .config.compilerOptions || {}; const host = ts.createCompilerHost(options, true); -const testDir = 'test' -const checkCallMatch = /^t\.is/ +const testDir = 'test'; +const checkCallMatch = /^equal\W/; const tsFiles = fs.readdirSync(testDir) - .map(fileName => path.join(testDir, fileName)) + .map(fileName => path.join(testDir, fileName)); const program = ts.createProgram(tsFiles, options, host); const checker = program.getTypeChecker(); const getType = (node: ts.Node) => checker.typeToString(checker.getTypeAtLocation(node)); - -tsFiles.forEach(tsFile => { - const source = program.getSourceFile(tsFile); - const traverseNodes = (node: ts.Node) => { - node.getChildren().forEach(child => { - if (child.getText().match(checkCallMatch)) { - if (child.kind === ts.SyntaxKind.CallExpression) { - const argsNode = child.getChildren()[2]; - const firstArg = argsNode.getChildren()[0]; - const secondArg = argsNode.getChildren()[2]; - const firstArgType = getType(firstArg); - const secondArgType = getType(secondArg); - if (firstArgType !== secondArgType) { - var pos = source.getLineAndCharacterOfPosition(child.pos) - throw new Error( - `Types of arguments do not match in \`${child.getText()}\`\n` + - `${tsFile}:${pos.line},${pos.character}\n` + - `\`${firstArg.getText()}\` has type \`${firstArgType}\` ` + - `and \`${secondArg.getText()}\` has type \`${secondArgType}\`` - ); +describe('Check typings', () => { + tsFiles.forEach(tsFile => { + const source = program.getSourceFile(tsFile); + const traverseNodes = (node: ts.Node) => { + node.getChildren().forEach(child => { + const expressionText = child.getText() + if (expressionText.match(checkCallMatch)) { + if (child.kind === ts.SyntaxKind.CallExpression) { + const argsNode = child.getChildren()[2]; + const firstArg = argsNode.getChildren()[0]; + const secondArg = argsNode.getChildren()[2]; + const firstArgType = getType(firstArg); + const secondArgType = getType(secondArg); + const pos = source.getLineAndCharacterOfPosition(child.pos); + it(`${expressionText} at ${tsFile}:${pos.line}:${pos.character}`, () => { + equal(firstArgType, secondArgType, + //`` + + `\`${firstArg.getText()}\` type \`${firstArgType}\`` + + `doesn't match \`${firstArg.getText()}\` type \`${secondArgType}\`` + ); + }); } } - } - traverseNodes(child); - }); - }; - traverseNodes(source); + traverseNodes(child); + }); + }; + traverseNodes(source); + }); }); From 190cc2bbdd6479c6334ed659461bceb544d9fe2d Mon Sep 17 00:00:00 2001 From: whitecolor Date: Wed, 5 Apr 2017 19:55:48 +0500 Subject: [PATCH 06/19] add type-fail to test ts error cases --- .gitignore | 1 + src/props.d.ts | 32 +++++++++++++++------ test/props.ts | 78 +++++++++++++++++++++++++++++++++++++------------- type-check.ts | 9 +++--- type-fail.ts | 26 +++++++++++++++++ 5 files changed, 114 insertions(+), 32 deletions(-) create mode 100644 type-fail.ts diff --git a/.gitignore b/.gitignore index abd4794..e8bc6ec 100644 --- a/.gitignore +++ b/.gitignore @@ -1,4 +1,5 @@ node_modules +/tmp dist *.swp *.swo diff --git a/src/props.d.ts b/src/props.d.ts index a14db79..06d5c27 100644 --- a/src/props.d.ts +++ b/src/props.d.ts @@ -4,30 +4,46 @@ import { Struct, List, Prop } from '../interfaces' * Acts as multiple `prop`: array of keys in, array of values out. Preserves order. */ declare function props< - P1 extends string, P2 extends string, + P1 extends string & keyof O, + P2 extends string & keyof O, + P3 extends string & keyof O, + O extends {[K in P1 | P2 | P3]: any}> + (ps: [P1, P2, P3], obj: O): [O[P1], O[P2], O[P3]]; + +declare function props< + P1 extends string & keyof O, + P2 extends string & keyof O, O extends {[K in P1 | P2]: any}> (ps: [P1, P2], obj: O): [O[P1], O[P2]]; declare function props< - P1 extends string, + P1 extends string & keyof O, O extends {[K in P1]: any}> (ps: [P1], obj: O): [O[P1]]; +// curried: + declare function props< - P1 extends string, P2 extends string> + P1 extends string, + P2 extends string> (ps: [P1, P2]): (obj: O) => [O[P1], O[P2]]; declare function props (ps: [P1]): (obj: O) => [O[P1]]; -// declare function props -// (ps: [P1, P2]): (obj: {[K in P1]: T1} & {[K2 in P2]: T2}) -// => [T1, T2]; +// array: + +declare function props(ps: List, obj: List): T[]; +declare function props(ps: List): (obj: List) => T[]; + +// allow custom typed result +// declare function props +// (ps: Prop[], obj: any): R; -//declare function props(ps: List, obj: List): T[]; -//declare function props(ps: List): (obj: List) => T[]; +// declare function props +// (ps: Prop[]): (obj: any) => R; export = props; diff --git a/test/props.ts b/test/props.ts index ff31102..6a15c2c 100644 --- a/test/props.ts +++ b/test/props.ts @@ -1,38 +1,76 @@ import props = require('ramda/src/props'); -import { equal } from 'assert'; +import { equal, throws } from 'assert'; +import { typeFail } from '../type-fail'; -interface TestObj { - num: number, - str: string, - other: {} +interface Obj { + p1: number; + p2: string; + p3: boolean; + p4: string; } -const obj: TestObj = { - num: 1, - str: 'strValue', - other: {} +const obj: Obj = { + p1: 33, + p2: 'Jake', + p3: true, + p4: 'some' }; describe('props', () => { it('one prop', () => { - const res = props(['str'], obj); - equal(res[0], 'strValue' as string); + const res = props(['p2'], obj); + equal(res[0], obj.p2); }); it('two props', () => { - const res = props(['str', 'num'], obj); - equal(res[0], 'strValue'); - equal(res[1], 1 as number); + const res = props(['p1', 'p3'], obj); + equal(res[0], obj.p1); + equal(res[1], obj.p3); + }); + + it('three props', () => { + const res = props(['p1', 'p2', 'p3'], obj); + equal(res[0], obj.p1); + equal(res[1], obj.p2); + equal(res[2], obj.p3); + }); + + + it('four props - not typed', () => { + const res = props(['p1', 'p2', 'p3', 'p4'], obj); + equal(res[0], obj.p1 as any); + equal(res[1], obj.p2 as any); + equal(res[2], obj.p3 as any); + equal(res[3], obj.p4 as any); }); it('curried: one prop', () => { - const res = props(['str'])(obj); - equal(res[0], 'strValue' as string); + const res = props(['p1'])(obj); + equal(res[0], obj.p1); + }); + + it('curried: two prop', () => { + const res = props(['p1', 'p3'])(obj); + equal(res[0], obj.p1); + equal(res[1], obj.p3); + }); + + it('array support', () => { + const res = props(['0', 2], [10, 20, 30, 40]); + equal(res[0], 10 as number); + equal(res[1], 30 as number); + }); + + it('curried: array support', () => { + const res = props([0, '2'])([10, 20, 'x', 40]); + equal(res[0], 10 as number | string); + equal(res[1], 'x' as number | string); }); - it('curried: two props', () => { - const res = props(['str', 'num'])(obj); - equal(res[0], 'strValue' as string); - equal(res[1], 1 as number); + it('ts error: unkonwn props not allowed', () => { + typeFail(` + import props = require('ramda/src/props'); + props(['p1', 'other'], {p1: 1}) + `, /not assignable/); }); }); diff --git a/type-check.ts b/type-check.ts index b201c88..06962db 100644 --- a/type-check.ts +++ b/type-check.ts @@ -14,6 +14,7 @@ const tsFiles = fs.readdirSync(testDir) .map(fileName => path.join(testDir, fileName)); const program = ts.createProgram(tsFiles, options, host); + const checker = program.getTypeChecker(); const getType = (node: ts.Node) => checker.typeToString(checker.getTypeAtLocation(node)); @@ -32,10 +33,10 @@ describe('Check typings', () => { const secondArgType = getType(secondArg); const pos = source.getLineAndCharacterOfPosition(child.pos); it(`${expressionText} at ${tsFile}:${pos.line}:${pos.character}`, () => { - equal(firstArgType, secondArgType, - //`` + - `\`${firstArg.getText()}\` type \`${firstArgType}\`` + - `doesn't match \`${firstArg.getText()}\` type \`${secondArgType}\`` + equal(firstArgType, secondArgType, + //`` + + `\`${firstArg.getText()}\` type \`${firstArgType}\`` + + `doesn't match \`${secondArg.getText()}\` type \`${secondArgType}\`` ); }); } diff --git a/type-fail.ts b/type-fail.ts new file mode 100644 index 0000000..ad10a0f --- /dev/null +++ b/type-fail.ts @@ -0,0 +1,26 @@ +import * as fs from 'fs'; +import * as path from 'path'; +import * as assert from 'assert'; + +export const typeFail = (source: string, errorMatch?: RegExp) => { + const dir = __dirname + '/tmp'; + if (!fs.existsSync(dir)) { + fs.mkdirSync(dir); + } + const filePath = path.join(dir, Math.random() + '.ts'); + fs.writeFileSync(filePath, source, 'utf-8'); + try { + require(filePath); + assert.ok(false, 'file imported without error'); + } catch (e) { + if (errorMatch) { + const tsErrorMessage = e.diagnostics[0].message; + if (!tsErrorMessage.match(errorMatch)) { + assert.ok(false, + 'file imported with error that does not have expected match:' + + tsErrorMessage); + } + } + } + fs.unlinkSync(filePath); +}; From 11bcb812f749c03a5cb130ee7fed2a30e508f1a8 Mon Sep 17 00:00:00 2001 From: whitecolor Date: Thu, 6 Apr 2017 23:46:49 +0500 Subject: [PATCH 07/19] type-check tests restrucutre --- type-check.ts | 41 +++++++++++++++++++++-------------------- 1 file changed, 21 insertions(+), 20 deletions(-) diff --git a/type-check.ts b/type-check.ts index 06962db..5c4dc1b 100644 --- a/type-check.ts +++ b/type-check.ts @@ -20,30 +20,31 @@ const getType = (node: ts.Node) => checker.typeToString(checker.getTypeAtLocation(node)); describe('Check typings', () => { tsFiles.forEach(tsFile => { - const source = program.getSourceFile(tsFile); - const traverseNodes = (node: ts.Node) => { - node.getChildren().forEach(child => { - const expressionText = child.getText() - if (expressionText.match(checkCallMatch)) { - if (child.kind === ts.SyntaxKind.CallExpression) { - const argsNode = child.getChildren()[2]; - const firstArg = argsNode.getChildren()[0]; - const secondArg = argsNode.getChildren()[2]; - const firstArgType = getType(firstArg); - const secondArgType = getType(secondArg); - const pos = source.getLineAndCharacterOfPosition(child.pos); - it(`${expressionText} at ${tsFile}:${pos.line}:${pos.character}`, () => { + it(`${tsFile}`, () => { + const source = program.getSourceFile(tsFile); + const traverseNodes = (node: ts.Node) => { + node.getChildren().forEach(child => { + const expressionText = child.getText() + if (expressionText.match(checkCallMatch)) { + if (child.kind === ts.SyntaxKind.CallExpression) { + const argsNode = child.getChildren()[2]; + const firstArg = argsNode.getChildren()[0]; + const secondArg = argsNode.getChildren()[2]; + const firstArgType = getType(firstArg); + const secondArgType = getType(secondArg); + const pos = source.getLineAndCharacterOfPosition(child.pos); + equal(firstArgType, secondArgType, - //`` + + `${tsFile}:${pos.line}:${pos.character}\n` + `\`${firstArg.getText()}\` type \`${firstArgType}\`` + `doesn't match \`${secondArg.getText()}\` type \`${secondArgType}\`` ); - }); + } } - } - traverseNodes(child); - }); - }; - traverseNodes(source); + traverseNodes(child); + }); + }; + traverseNodes(source); + }); }); }); From 11dab2ed6159e0399e3501389d522d5b702ebdfe Mon Sep 17 00:00:00 2001 From: whitecolor Date: Thu, 6 Apr 2017 23:47:27 +0500 Subject: [PATCH 08/19] code gen initial --- gen.ts | 47 ++++++++ package.json | 6 +- remove-generated.ts | 8 ++ src/_props.d.ts | 49 ++++++++ src/props.d.ts | 267 +++++++++++++++++++++++++++++++++++++++----- test/props.ts | 16 +-- tpl/props.ts | 50 +++++++++ 7 files changed, 404 insertions(+), 39 deletions(-) create mode 100644 gen.ts create mode 100644 remove-generated.ts create mode 100644 src/_props.d.ts create mode 100644 tpl/props.ts diff --git a/gen.ts b/gen.ts new file mode 100644 index 0000000..1938790 --- /dev/null +++ b/gen.ts @@ -0,0 +1,47 @@ +import * as fs from 'fs'; + +export const importInterfaces = (names: string[]) => + `import { ${names.join(', ')} } from '../interfaces';` + +export type FunParams = { [name: string]: string }[] + +export const parseFunParams = (params: FunParams) => + params.map(p => `${Object.keys(p)[0]}: ${p[Object.keys(p)[0]]}`).join(', ') + +export const arrowFunction = ( + typeParams: string[], + params: FunParams, + result: string) => { + return `<\n${typeParams.join(',\n')}>\n(${parseFunParams(params)}) => \n${result}` +} + +export const declareFunction = (name: string, + typeParams: string[], + params: FunParams, + result: string +) => `declare function ${name}` + + `<\n${typeParams.join(',\n')}>\n(${parseFunParams(params)}): \n${result}` + + +export function getParamsNums(max: number) { + return Array.from(Array(max + 1).keys()).map(i => + Array.from(Array(i + 1).keys()).slice(1) + ).slice(1) +} + + + +const tplFiles = fs.readdirSync(__dirname + '/tpl') + +describe('Generation', () => { + tplFiles.forEach(tplFile => { + const name = tplFile.replace(/\.ts$/, '') + it(name, () => { + const src = require(__dirname + '/tpl/' + tplFile) + .concat(`export = ${name}`) + .join('\n\n') + .concat('\n') + fs.writeFileSync(__dirname + `/src/${name}.d.ts`, src) + }) + }) +}) \ No newline at end of file diff --git a/package.json b/package.json index 3ba1bdb..9d0430e 100644 --- a/package.json +++ b/package.json @@ -3,10 +3,10 @@ "version": "0.23.0-RC1", "scripts": { "lint": "echo linting... && tslint index.d.ts", - "test": "mocha --compilers ts:ts-node/register test/*.ts type-check.ts", - "test-watch": "npm test -- --watch", + "test": "mocha --compilers ts:ts-node/register test/*.ts type-check.ts", "_test": "echo testing errors... && ./node_modules/typescript/bin/tsc --lib \"es2015\" --module commonjs tests/test.ts --noEmit", - "types": "echo testing types... && bash test.sh" + "types": "echo testing types... && bash test.sh", + "gen": "ts-node remove-generated && mocha --compilers ts:ts-node/register gen.ts" }, "devDependencies": { "@types/mocha": "^2.2.40", diff --git a/remove-generated.ts b/remove-generated.ts new file mode 100644 index 0000000..54e45d1 --- /dev/null +++ b/remove-generated.ts @@ -0,0 +1,8 @@ +/* + Need to remove generated files before launching mocha in watch mode +*/ +import * as fs from 'fs'; + +fs.readdirSync(__dirname + '/tpl') + .map(file => 'src/' + file.replace(/\.ts/, '\.d.ts')) + .forEach(fs.unlinkSync) \ No newline at end of file diff --git a/src/_props.d.ts b/src/_props.d.ts new file mode 100644 index 0000000..06d5c27 --- /dev/null +++ b/src/_props.d.ts @@ -0,0 +1,49 @@ +import { Struct, List, Prop } from '../interfaces' + +/** + * Acts as multiple `prop`: array of keys in, array of values out. Preserves order. + */ +declare function props< + P1 extends string & keyof O, + P2 extends string & keyof O, + P3 extends string & keyof O, + O extends {[K in P1 | P2 | P3]: any}> + (ps: [P1, P2, P3], obj: O): [O[P1], O[P2], O[P3]]; + +declare function props< + P1 extends string & keyof O, + P2 extends string & keyof O, + O extends {[K in P1 | P2]: any}> + (ps: [P1, P2], obj: O): [O[P1], O[P2]]; + +declare function props< + P1 extends string & keyof O, + O extends {[K in P1]: any}> + (ps: [P1], obj: O): [O[P1]]; + + +// curried: + +declare function props< + P1 extends string, + P2 extends string> + (ps: [P1, P2]): (obj: O) => [O[P1], O[P2]]; + + +declare function props + (ps: [P1]): (obj: O) => [O[P1]]; + +// array: + +declare function props(ps: List, obj: List): T[]; +declare function props(ps: List): (obj: List) => T[]; + +// allow custom typed result + +// declare function props +// (ps: Prop[], obj: any): R; + +// declare function props +// (ps: Prop[]): (obj: any) => R; + +export = props; diff --git a/src/props.d.ts b/src/props.d.ts index 06d5c27..cd78207 100644 --- a/src/props.d.ts +++ b/src/props.d.ts @@ -1,49 +1,260 @@ -import { Struct, List, Prop } from '../interfaces' +import { Struct, List, Prop } from '../interfaces'; + + +/** + * Acts as multiple `prop`: array of keys in, array of values out. Preserves order. + */ +declare function props< +P1 extends string & keyof O, +P2 extends string & keyof O, +P3 extends string & keyof O, +P4 extends string & keyof O, +P5 extends string & keyof O, +P6 extends string & keyof O, +P7 extends string & keyof O, +P8 extends string & keyof O, +O extends {[K in P1 | P2 | P3 | P4 | P5 | P6 | P7 | P8]: any}> +(ps: [P1, P2, P3, P4, P5, P6, P7, P8], obj: O): +[O[P1], O[P2], O[P3], O[P4], O[P5], O[P6], O[P7], O[P8]] + + +/** + * Acts as multiple `prop`: array of keys in, array of values out. Preserves order. + */ +declare function props< +P1 extends string & keyof O, +P2 extends string & keyof O, +P3 extends string & keyof O, +P4 extends string & keyof O, +P5 extends string & keyof O, +P6 extends string & keyof O, +P7 extends string & keyof O, +O extends {[K in P1 | P2 | P3 | P4 | P5 | P6 | P7]: any}> +(ps: [P1, P2, P3, P4, P5, P6, P7], obj: O): +[O[P1], O[P2], O[P3], O[P4], O[P5], O[P6], O[P7]] + + +/** + * Acts as multiple `prop`: array of keys in, array of values out. Preserves order. + */ +declare function props< +P1 extends string & keyof O, +P2 extends string & keyof O, +P3 extends string & keyof O, +P4 extends string & keyof O, +P5 extends string & keyof O, +P6 extends string & keyof O, +O extends {[K in P1 | P2 | P3 | P4 | P5 | P6]: any}> +(ps: [P1, P2, P3, P4, P5, P6], obj: O): +[O[P1], O[P2], O[P3], O[P4], O[P5], O[P6]] + + +/** + * Acts as multiple `prop`: array of keys in, array of values out. Preserves order. + */ +declare function props< +P1 extends string & keyof O, +P2 extends string & keyof O, +P3 extends string & keyof O, +P4 extends string & keyof O, +P5 extends string & keyof O, +O extends {[K in P1 | P2 | P3 | P4 | P5]: any}> +(ps: [P1, P2, P3, P4, P5], obj: O): +[O[P1], O[P2], O[P3], O[P4], O[P5]] + + +/** + * Acts as multiple `prop`: array of keys in, array of values out. Preserves order. + */ +declare function props< +P1 extends string & keyof O, +P2 extends string & keyof O, +P3 extends string & keyof O, +P4 extends string & keyof O, +O extends {[K in P1 | P2 | P3 | P4]: any}> +(ps: [P1, P2, P3, P4], obj: O): +[O[P1], O[P2], O[P3], O[P4]] + + +/** + * Acts as multiple `prop`: array of keys in, array of values out. Preserves order. + */ +declare function props< +P1 extends string & keyof O, +P2 extends string & keyof O, +P3 extends string & keyof O, +O extends {[K in P1 | P2 | P3]: any}> +(ps: [P1, P2, P3], obj: O): +[O[P1], O[P2], O[P3]] + + +/** + * Acts as multiple `prop`: array of keys in, array of values out. Preserves order. + */ +declare function props< +P1 extends string & keyof O, +P2 extends string & keyof O, +O extends {[K in P1 | P2]: any}> +(ps: [P1, P2], obj: O): +[O[P1], O[P2]] + + +/** + * Acts as multiple `prop`: array of keys in, array of values out. Preserves order. + */ +declare function props< +P1 extends string & keyof O, +O extends {[K in P1]: any}> +(ps: [P1], obj: O): +[O[P1]] + +// curried + /** * Acts as multiple `prop`: array of keys in, array of values out. Preserves order. */ declare function props< - P1 extends string & keyof O, - P2 extends string & keyof O, - P3 extends string & keyof O, - O extends {[K in P1 | P2 | P3]: any}> - (ps: [P1, P2, P3], obj: O): [O[P1], O[P2], O[P3]]; +P1 extends string, +P2 extends string, +P3 extends string, +P4 extends string, +P5 extends string, +P6 extends string, +P7 extends string, +P8 extends string> +(ps: [P1, P2, P3, P4, P5, P6, P7, P8]): +< +O extends {[K in P1 | P2 | P3 | P4 | P5 | P6 | P7 | P8]: any}> +(obj: O) => +[O[P1], O[P2], O[P3], O[P4], O[P5], O[P6], O[P7], O[P8]] + +/** + * Acts as multiple `prop`: array of keys in, array of values out. Preserves order. + */ declare function props< - P1 extends string & keyof O, - P2 extends string & keyof O, - O extends {[K in P1 | P2]: any}> - (ps: [P1, P2], obj: O): [O[P1], O[P2]]; +P1 extends string, +P2 extends string, +P3 extends string, +P4 extends string, +P5 extends string, +P6 extends string, +P7 extends string> +(ps: [P1, P2, P3, P4, P5, P6, P7]): +< +O extends {[K in P1 | P2 | P3 | P4 | P5 | P6 | P7]: any}> +(obj: O) => +[O[P1], O[P2], O[P3], O[P4], O[P5], O[P6], O[P7]] + +/** + * Acts as multiple `prop`: array of keys in, array of values out. Preserves order. + */ declare function props< - P1 extends string & keyof O, - O extends {[K in P1]: any}> - (ps: [P1], obj: O): [O[P1]]; +P1 extends string, +P2 extends string, +P3 extends string, +P4 extends string, +P5 extends string, +P6 extends string> +(ps: [P1, P2, P3, P4, P5, P6]): +< +O extends {[K in P1 | P2 | P3 | P4 | P5 | P6]: any}> +(obj: O) => +[O[P1], O[P2], O[P3], O[P4], O[P5], O[P6]] + +/** + * Acts as multiple `prop`: array of keys in, array of values out. Preserves order. + */ +declare function props< +P1 extends string, +P2 extends string, +P3 extends string, +P4 extends string, +P5 extends string> +(ps: [P1, P2, P3, P4, P5]): +< +O extends {[K in P1 | P2 | P3 | P4 | P5]: any}> +(obj: O) => +[O[P1], O[P2], O[P3], O[P4], O[P5]] -// curried: +/** + * Acts as multiple `prop`: array of keys in, array of values out. Preserves order. + */ declare function props< - P1 extends string, - P2 extends string> - (ps: [P1, P2]): (obj: O) => [O[P1], O[P2]]; +P1 extends string, +P2 extends string, +P3 extends string, +P4 extends string> +(ps: [P1, P2, P3, P4]): +< +O extends {[K in P1 | P2 | P3 | P4]: any}> +(obj: O) => +[O[P1], O[P2], O[P3], O[P4]] -declare function props - (ps: [P1]): (obj: O) => [O[P1]]; +/** + * Acts as multiple `prop`: array of keys in, array of values out. Preserves order. + */ +declare function props< +P1 extends string, +P2 extends string, +P3 extends string> +(ps: [P1, P2, P3]): +< +O extends {[K in P1 | P2 | P3]: any}> +(obj: O) => +[O[P1], O[P2], O[P3]] + + +/** + * Acts as multiple `prop`: array of keys in, array of values out. Preserves order. + */ +declare function props< +P1 extends string, +P2 extends string> +(ps: [P1, P2]): +< +O extends {[K in P1 | P2]: any}> +(obj: O) => +[O[P1], O[P2]] + + +/** + * Acts as multiple `prop`: array of keys in, array of values out. Preserves order. + */ +declare function props< +P1 extends string> +(ps: [P1]): +< +O extends {[K in P1]: any}> +(obj: O) => +[O[P1]] -// array: -declare function props(ps: List, obj: List): T[]; -declare function props(ps: List): (obj: List) => T[]; +/** + * Acts as multiple `prop`: array of keys in, array of values out. Preserves order. + */ +declare function props< +T> +(ps: List, obj: List): +T[] -// allow custom typed result +// curried -// declare function props -// (ps: Prop[], obj: any): R; -// declare function props -// (ps: Prop[]): (obj: any) => R; +/** + * Acts as multiple `prop`: array of keys in, array of values out. Preserves order. + */ +declare function props< +T> +(ps: List): +< +T> +(obj: List) => +T[] -export = props; +export = props diff --git a/test/props.ts b/test/props.ts index 6a15c2c..6b09136 100644 --- a/test/props.ts +++ b/test/props.ts @@ -1,5 +1,5 @@ import props = require('ramda/src/props'); -import { equal, throws } from 'assert'; +import { equal } from 'assert'; import { typeFail } from '../type-fail'; interface Obj { @@ -36,13 +36,13 @@ describe('props', () => { }); - it('four props - not typed', () => { - const res = props(['p1', 'p2', 'p3', 'p4'], obj); - equal(res[0], obj.p1 as any); - equal(res[1], obj.p2 as any); - equal(res[2], obj.p3 as any); - equal(res[3], obj.p4 as any); - }); + // it('four props - not typed', () => { + // const res = props(['p1', 'p2', 'p3', 'p4'], obj); + // equal(res[0], obj.p1 as any); + // equal(res[1], obj.p2 as any); + // equal(res[2], obj.p3 as any); + // equal(res[3], obj.p4 as any); + // }); it('curried: one prop', () => { const res = props(['p1'])(obj); diff --git a/tpl/props.ts b/tpl/props.ts new file mode 100644 index 0000000..c2022a3 --- /dev/null +++ b/tpl/props.ts @@ -0,0 +1,50 @@ +import { + importInterfaces, + declareFunction, + arrowFunction, + getParamsNums +} from '../gen'; + +const numParams = getParamsNums(8).reverse(); + +const docs = ` +/** + * Acts as multiple \`prop\`: array of keys in, array of values out. Preserves order. + */ +`; + +module.exports = [ + importInterfaces(['Struct', 'List', 'Prop']), + ...numParams.map((nums) => + docs + + declareFunction('props', + nums.map(n => `P${n} extends string & keyof O`) + .concat(`O extends {[K in ${nums.map(n => 'P' + n).join(' | ')}]: any}`), + [ + { ps: `[${nums.map(n => 'P' + n).join(', ')}]` }, + { obj: 'O' } + ], + `[${nums.map(n => 'O[P' + n + ']').join(', ')}]` + )), + `// curried`, + ...numParams.map((nums) => + docs + + declareFunction('props', + nums.map(n => `P${n} extends string`), + [ + { ps: `[${nums.map(n => 'P' + n).join(', ')}]` } + ], + arrowFunction( + [`O extends {[K in ${nums.map(n => 'P' + n).join(' | ')}]: any}`], + [{ obj: 'O' }], + `[${nums.map(n => 'O[P' + n + ']').join(', ')}]` + ) + )), + docs + + declareFunction('props', ['T'], [{ ps: 'List' }, { obj: 'List' }], 'T[]'), + `// curried`, + docs + + declareFunction('props', ['T'], [{ ps: 'List' }], + arrowFunction(['T'], [{ obj: 'List' }], 'T[]') + ) +]; From a998c6b21c5cb5b9f1ce9d97950ee263ee131207 Mon Sep 17 00:00:00 2001 From: whitecolor Date: Fri, 7 Apr 2017 16:02:19 +0500 Subject: [PATCH 09/19] get index to working state --- .gitignore | 2 +- index.d.ts | 26 +++++++++++++++++++++----- interfaces.d.ts | 28 ++++++++++++++-------------- src/addIndex.d.ts | 2 +- src/curry.d.ts | 2 +- src/merge.d.ts | 4 ++-- tpl/props.ts | 23 ++++++++++++----------- type-check.ts | 4 ++-- 8 files changed, 54 insertions(+), 37 deletions(-) diff --git a/.gitignore b/.gitignore index e8bc6ec..2892e12 100644 --- a/.gitignore +++ b/.gitignore @@ -6,4 +6,4 @@ dist .session.vim .sizecache.json test.js -*.log +*.log* diff --git a/index.d.ts b/index.d.ts index 60b5334..f203222 100644 --- a/index.d.ts +++ b/index.d.ts @@ -5,19 +5,35 @@ import __ from './src/__' import add from './src/add' -import addIndex from './src/addIndex' -import curry from './src/curry' -import merge from './src/merge' +import addIndex = require('./src/addIndex') +import curry = require('./src/curry') +import merge = require('./src/merge') import props = require('./src/props') +import { + List, Struct, Obj, NestedObj, + Pred, Variadic, Functor, Type, Transformer, Prop, Path, + NestedArray, KeyValuePair, AccOpts, + Ord, Chain, Lens, ManualLens, UnknownLens, + Applicative, Traversable, + StringRepresentable, + CurriedFunction1, + CurriedFunction2, + CurriedFunction3, + CurriedFunction4, + CurriedFunction5, + CurriedFunction6, + CurriedFunction7, + CurriedFunction8 +} from './interfaces' declare var R: R.Static; declare namespace R { - + interface Reduced { } interface Static { - + __: typeof __ add: typeof add addIndex: typeof addIndex diff --git a/interfaces.d.ts b/interfaces.d.ts index 43ba384..c5d0110 100644 --- a/interfaces.d.ts +++ b/interfaces.d.ts @@ -52,7 +52,7 @@ export interface Chain extends Apply { } export interface ChainRec extends Chain { - /* static */ chainRec(f: (next: (a: A) => C, done: (b: B) => C, value: A) => ChainRec, i: A): ChainRec; + /* static */ chainRec(f: (next: (a: A) => C, done: (b: B) => C, value: A) => ChainRec, i: A): ChainRec; } export interface Monad extends Applicative, Chain { @@ -66,12 +66,12 @@ export interface Comonad extends Functor, Extend { extract(): U; // 'same U as in extend's f -- how to bind? } -export interface Bifunctor extends Functor /*, Functor*/ { - bimap(f: (v: T) => B, g: (v: U) => D): Bifunctor; +export interface Bifunctor extends Functor /*, Functor*/ { + bimap(f: (v: T) => B, g: (v: U) => D): Bifunctor; } -export interface Profunctor extends Functor /*, Functor*/ { - promap(f: (v: T) => B, g: (v: U) => D): Profunctor; +export interface Profunctor extends Functor /*, Functor*/ { + promap(f: (v: T) => B, g: (v: U) => D): Profunctor; } // simple types @@ -90,7 +90,7 @@ type StringLike = string | StringRepresentable; type Prop = Index | StringRepresentable; type Path = List; type Struct = Obj | List; -type AccOpts = List|Obj|Transformer; +type AccOpts = List | Obj | Transformer; type Pred = (v: T) => boolean; type ObjPred = (value: T, key: string) => boolean; @@ -104,7 +104,7 @@ export interface Variadic { (...args: any[]): T; } -export interface KeyValuePair extends Array { 0 : K; 1 : V; } +export interface KeyValuePair extends Array { 0: K; 1: V; } export interface Transformer { step: (acc: Acc, v: T) => Acc; @@ -121,14 +121,14 @@ export interface StringRepresentable { } export interface NestedObj { - [index: string]: T|NestedObj; + [index: string]: T | NestedObj; } // export interface RecursiveArray extends Array> {} // export interface ListOfRecursiveArraysOrValues extends List> {} -export interface NestedArray { - [index: number]: T | NestedArray; - length: number; +export interface NestedArray { + [index: number]: T | NestedArray; + length: number; } // // an unfortunate compromise -- while the actual lens should be generic, for the purpose of TS the structure should be supplied beforehand @@ -138,7 +138,7 @@ export interface NestedArray { // set(v: T[K], obj: T): T; // // map(fn: (v: T[K]) => T[K], obj: T): T // } -export interface Lens { +export interface Lens { (obj: T): U; // get set(v: U, obj: T): T; // map(fn: (v: U) => U, obj: T): T @@ -149,8 +149,8 @@ export interface ManualLens { // >map(fn: (v: U) => U, obj: T): T } export interface UnknownLens { - (obj: T): U; // get - set(v: U, obj: T): T; + (obj: T): U; // get + set(v: U, obj: T): T; // map(fn: (v: U) => U, obj: T): T } diff --git a/src/addIndex.d.ts b/src/addIndex.d.ts index e581146..0ea3121 100644 --- a/src/addIndex.d.ts +++ b/src/addIndex.d.ts @@ -17,4 +17,4 @@ declare function addIndex(fn: (f: (item: T) => void, list: List) => T[]): declare function addIndex(fn: (f: (acc: U, item: T) => U, aci: U, list: List) => U): CurriedFunction3<(acc: U, item: T, idx: number, list?: List) => U, U, List, U>; -export default addIndex +export = addIndex diff --git a/src/curry.d.ts b/src/curry.d.ts index 1ec3ff7..3482b12 100644 --- a/src/curry.d.ts +++ b/src/curry.d.ts @@ -22,4 +22,4 @@ declare function curry(fn: (a: T1, b: T2, c declare function curry(fn: (a: T1, b: T2, c: T3, d: T4, e: T5, f: T6, g: T7, h: T8) => TResult): CurriedFunction8; declare function curry(fn: (a: T1, b: T2, c: T3, d: T4, e: T5, f: T6, g: T7, h: T8, i: T9) => TResult): CurriedFunction9; -export default curry; +export = curry; diff --git a/src/merge.d.ts b/src/merge.d.ts index a64c50b..820dd71 100644 --- a/src/merge.d.ts +++ b/src/merge.d.ts @@ -1,4 +1,4 @@ -import { Struct } from '..' +import { Struct } from '../interfaces' /** * Create a new object with the own properties of a @@ -8,4 +8,4 @@ import { Struct } from '..' declare function merge, T2 extends Struct>(a: T1, b: T2): T1 & T2; declare function merge>(a: T1): >(b: T2) => T1 & T2; -export default merge; +export = merge; diff --git a/tpl/props.ts b/tpl/props.ts index c2022a3..be89166 100644 --- a/tpl/props.ts +++ b/tpl/props.ts @@ -5,7 +5,8 @@ import { getParamsNums } from '../gen'; -const numParams = getParamsNums(8).reverse(); +const propsParams = getParamsNums(8).reverse() + .map(nums => nums.map(n => 'P' + n)); const docs = ` /** @@ -15,29 +16,29 @@ const docs = ` module.exports = [ importInterfaces(['Struct', 'List', 'Prop']), - ...numParams.map((nums) => + ...propsParams.map((props) => docs + declareFunction('props', - nums.map(n => `P${n} extends string & keyof O`) - .concat(`O extends {[K in ${nums.map(n => 'P' + n).join(' | ')}]: any}`), + props.map(Pn => `${Pn} extends string & keyof O`) + .concat(`O extends {[K in ${props.join(' | ')}]: any}`), [ - { ps: `[${nums.map(n => 'P' + n).join(', ')}]` }, + { ps: `[${props.join(', ')}]` }, { obj: 'O' } ], - `[${nums.map(n => 'O[P' + n + ']').join(', ')}]` + `[${props.map(Pn => 'O[' + Pn + ']').join(', ')}]` )), `// curried`, - ...numParams.map((nums) => + ...propsParams.map((props) => docs + declareFunction('props', - nums.map(n => `P${n} extends string`), + props.map(Pn => `${Pn} extends string`), [ - { ps: `[${nums.map(n => 'P' + n).join(', ')}]` } + { ps: `[${props.join(', ')}]` } ], arrowFunction( - [`O extends {[K in ${nums.map(n => 'P' + n).join(' | ')}]: any}`], + [`O extends {[K in ${props.join(' | ')}]: any}`], [{ obj: 'O' }], - `[${nums.map(n => 'O[P' + n + ']').join(', ')}]` + `[${props.map(Pn => 'O[' + Pn + ']').join(', ')}]` ) )), docs + diff --git a/type-check.ts b/type-check.ts index 5c4dc1b..c682bac 100644 --- a/type-check.ts +++ b/type-check.ts @@ -24,7 +24,7 @@ describe('Check typings', () => { const source = program.getSourceFile(tsFile); const traverseNodes = (node: ts.Node) => { node.getChildren().forEach(child => { - const expressionText = child.getText() + const expressionText = child.getText(); if (expressionText.match(checkCallMatch)) { if (child.kind === ts.SyntaxKind.CallExpression) { const argsNode = child.getChildren()[2]; @@ -35,7 +35,7 @@ describe('Check typings', () => { const pos = source.getLineAndCharacterOfPosition(child.pos); equal(firstArgType, secondArgType, - `${tsFile}:${pos.line}:${pos.character}\n` + + `${tsFile}:${pos.line}:${pos.character}\n` + `\`${firstArg.getText()}\` type \`${firstArgType}\`` + `doesn't match \`${secondArg.getText()}\` type \`${secondArgType}\`` ); From 52a8e18d3468fcc0afa7ac084c302fec6dd476b0 Mon Sep 17 00:00:00 2001 From: whitecolor Date: Fri, 7 Apr 2017 16:10:04 +0500 Subject: [PATCH 10/19] add props to index --- index.d.ts | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/index.d.ts b/index.d.ts index f203222..5ce743c 100644 --- a/index.d.ts +++ b/index.d.ts @@ -2325,10 +2325,10 @@ declare namespace R { /** * Acts as multiple `prop`: array of keys in, array of values out. Preserves order. */ - - // generic version - props(ps: List, obj: Struct): T[]; - props(ps: List): (obj: Struct) => T[]; + props: typeof props + // generic version + //props(ps: List, obj: Struct): T[]; + //props(ps: List): (obj: Struct) => T[]; // props: CurriedFunction2, Struct, T[]>; // TODO: heterogeneous version From b094c268dad4c9bc8c87d190ee11984367910224 Mon Sep 17 00:00:00 2001 From: whitecolor Date: Sun, 9 Apr 2017 04:19:33 +0500 Subject: [PATCH 11/19] flatten: src, test --- index.d.ts | 180 ++---------------------------------------------- test/flatten.ts | 41 +++++++++++ 2 files changed, 47 insertions(+), 174 deletions(-) create mode 100644 test/flatten.ts diff --git a/index.d.ts b/index.d.ts index 5ce743c..0db980f 100644 --- a/index.d.ts +++ b/index.d.ts @@ -9,6 +9,7 @@ import addIndex = require('./src/addIndex') import curry = require('./src/curry') import merge = require('./src/merge') import props = require('./src/props') +import flatten = require('./src/props') import { List, Struct, Obj, NestedObj, Pred, Variadic, Functor, Type, Transformer, Prop, Path, @@ -320,7 +321,7 @@ declare namespace R { /** * Performs right-to-left function composition. The rightmost function may have any arity; the remaining * functions must be unary. - */ + */ compose(fn0: (x0: V0) => T1): (x0: V0) => T1; compose(fn0: (x0: V0, x1: V1) => T1): (x0: V0, x1: V1) => T1; compose(fn0: (x0: V0, x1: V1, x2: V2) => T1): (x0: V0, x1: V1, x2: V2) => T1; @@ -779,20 +780,7 @@ declare namespace R { findLastIndex(fn: (a: T) => boolean): (list: List) => number; // findLastIndex: CurriedFunction2<(a: T) => boolean, List, number>; - /** - * Returns a new list by pulling every item out of it (and all its sub-arrays) and putting - * them in a new array, depth-first. - */ - // flatten(x: ArrayLike>>>>>>): T[]; - // flatten(x: ArrayLike>>>>>): T[]; - // flatten(x: ArrayLike>>>>): T[]; - // flatten(x: ArrayLike>>>): T[]; - // flatten(x: ArrayLike>>): T[]; - // flatten(x: ArrayLike>): T[]; - // flatten(x: ArrayLike): T[]; - // TODO: figure out how to handle arrays using different levels of nesting - // flatten(x: ListOfRecursiveArraysOrValues): T[]; - flatten(x: NestedArray): T[]; + flatten: typeof flatten; /** * Returns a new function much like the supplied one, except that the first two arguments' @@ -1239,8 +1227,8 @@ declare namespace R { * Returns a lens whose focus is the specified path. * See also view, set, over. */ - lensPath(path: Path): ManualLens; - lensPath(path: Path): UnknownLens; + lensPath(path: Path): ManualLens; + lensPath(path: Path): UnknownLens; /** * lensProp creates a lens that will focus on property k of the source object. @@ -1798,163 +1786,7 @@ declare namespace R { partition>(fn: (a: T) => boolean, obj: U): [Obj, Obj]; // partition>: CurriedFunction2<(a: T) => boolean, U, [Partial,Partial]>; - /** - * Retrieve the value at a given path. - */ - - // fixed-length versions - - // simpler versions, able to deal only with objects, not arrays: - - // // in-based - // path(path: [T1, T2], obj: {[K1 in T1]: {[K2 in T2]: TResult}}): TResult; - // path(path: [T1, T2, T3], obj: {[K1 in T1]: {[K2 in T2]: {[K3 in T3]: TResult}}}): TResult; - // path(path: [T1, T2, T3, T4], obj: {[K1 in T1]: {[K2 in T2]: {[K3 in T3]: {[K4 in T4]: TResult}}}}): TResult; - // path(path: [T1, T2, T3, T4, T5], obj: {[K1 in T1]: {[K2 in T2]: {[K3 in T3]: {[K4 in T4]: {[K5 in T5]: TResult}}}}}): TResult; - // path(path: [T1, T2, T3, T4, T5, T6], obj: {[K1 in T1]: {[K2 in T2]: {[K3 in T3]: {[K4 in T4]: {[K5 in T5]: {[K6 in T6]: TResult}}}}}}): TResult; - // path(path: [T1, T2, T3, T4, T5, T6, T7], obj: {[K1 in T1]: {[K2 in T2]: {[K3 in T3]: {[K4 in T4]: {[K5 in T5]: {[K6 in T6]: {[K7 in T7]: TResult}}}}}}}): TResult; - // path(path: [T1, T2, T3, T4, T5, T6, T7, T8], obj: {[K1 in T1]: {[K2 in T2]: {[K3 in T3]: {[K4 in T4]: {[K5 in T5]: {[K6 in T6]: {[K7 in T7]: {[K8 in T8]: TResult}}}}}}}}): TResult; - // path(path: [T1, T2, T3, T4, T5, T6, T7, T8, T9], obj: {[K1 in T1]: {[K2 in T2]: {[K3 in T3]: {[K4 in T4]: {[K5 in T5]: {[K6 in T6]: {[K7 in T7]: {[K8 in T8]: {[K9 in T9]: TResult}}}}}}}}}): TResult; - - // // Record-based - // path(path: [K1, K2], obj: Record>): TResult; - // path(path: [K1, K2, K3], obj: Record>>): TResult; - // path(path: [K1, K2, K3, K4], obj: Record>>>): TResult; - // path(path: [K1, K2, K3, K4, K5], obj: Record>>>>): TResult; - // path(path: [K1, K2, K3, K4, K5, K6], obj: Record>>>>>): TResult; - // path(path: [K1, K2, K3, K4, K5, K6, K7], obj: Record>>>>>>): TResult; - // path(path: [K1, K2, K3, K4, K5, K6, K7, K8], obj: Record>>>>>>>): TResult; - // path(path: [K1, K2, K3, K4, K5, K6, K7, K8, K9], obj: Record>>>>>>>>): TResult; - - // // for each path length list all combinations of objects and homogeneous arrays... tuples not supported yet. - - // path(path: [T1], obj: {[K1 in T1]: TResult}): TResult; - // path(path: [T1], obj: TResult[]): TResult; - // path(path: [T1, T2], obj: {[K1 in T1]: {[K2 in T2]: TResult}}): TResult; - // path(path: [T1, T2], obj: {[K1 in T1]: TResult[]}): TResult; - // path(path: [T1, T2], obj: {[K2 in T2]: TResult}[]): TResult; - // path(path: [T1, T2], obj: TResult[][]): TResult; - // path(path: [T1, T2, T3], obj: {[K1 in T1]: {[K2 in T2]: {[K3 in T3]: TResult}}}): TResult; - // path(path: [T1, T2, T3], obj: {[K1 in T1]: {[K2 in T2]: TResult[]}}): TResult; - // path(path: [T1, T2, T3], obj: {[K1 in T1]: {[K3 in T3]: TResult}[]}): TResult; - // path(path: [T1, T2, T3], obj: {[K1 in T1]: TResult[][]}): TResult; - // path(path: [T1, T2, T3], obj: {[K2 in T2]: {[K3 in T3]: TResult}}[]): TResult; - // path(path: [T1, T2, T3], obj: {[K2 in T2]: TResult[]}[]): TResult; - // path(path: [T1, T2, T3], obj: {[K3 in T3]: TResult}[][]): TResult; - // path(path: [T1, T2, T3], obj: TResult[][][]): TResult; - // path(path: [T1, T2, T3, T4], obj: {[K1 in T1]: {[K2 in T2]: {[K3 in T3]: {[K4 in T4]: TResult}}}}): TResult; - // path(path: [T1, T2, T3, T4], obj: {[K1 in T1]: {[K2 in T2]: {[K3 in T3]: TResult[]}}}): TResult; - // path(path: [T1, T2, T3, T4], obj: {[K1 in T1]: {[K2 in T2]: {[K4 in T4]: TResult}[]}}): TResult; - // path(path: [T1, T2, T3, T4], obj: {[K1 in T1]: {[K2 in T2]: TResult[][]}}): TResult; - // path(path: [T1, T2, T3, T4], obj: {[K1 in T1]: {[K3 in T3]: {[K4 in T4]: TResult}}[]}): TResult; - // path(path: [T1, T2, T3, T4], obj: {[K1 in T1]: {[K3 in T3]: TResult[]}[]}): TResult; - // path(path: [T1, T2, T3, T4], obj: {[K1 in T1]: {[K4 in T4]: TResult}[][]}): TResult; - // path(path: [T1, T2, T3, T4], obj: {[K1 in T1]: TResult[][][]}): TResult; - // path(path: [T1, T2, T3, T4], obj: {[K2 in T2]: {[K3 in T3]: {[K4 in T4]: TResult}}}[]): TResult; - // path(path: [T1, T2, T3, T4], obj: {[K2 in T2]: {[K3 in T3]: TResult[]}}[]): TResult; - // path(path: [T1, T2, T3, T4], obj: {[K2 in T2]: {[K4 in T4]: TResult}[]}[]): TResult; - // path(path: [T1, T2, T3, T4], obj: {[K2 in T2]: TResult[][]}[]): TResult; - // path(path: [T1, T2, T3, T4], obj: {[K3 in T3]: {[K4 in T4]: TResult}}[][]): TResult; - // path(path: [T1, T2, T3, T4], obj: {[K3 in T3]: TResult[]}[][]): TResult; - // path(path: [T1, T2, T3, T4], obj: {[K4 in T4]: TResult}[][][]): TResult; - // path(path: [T1, T2, T3, T4], obj: TResult[][][][]): TResult; - // path(path: [T1, T2, T3, T4, T5], obj: {[K1 in T1]: {[K2 in T2]: {[K3 in T3]: {[K4 in T4]: {[K5 in T5]: TResult}}}}}): TResult; - // path(path: [T1, T2, T3, T4, T5], obj: {[K1 in T1]: {[K2 in T2]: {[K3 in T3]: {[K4 in T4]: TResult[]}}}}): TResult; - // path(path: [T1, T2, T3, T4, T5], obj: {[K1 in T1]: {[K2 in T2]: {[K3 in T3]: {[K5 in T5]: TResult}[]}}}): TResult; - // path(path: [T1, T2, T3, T4, T5], obj: {[K1 in T1]: {[K2 in T2]: {[K3 in T3]: TResult[][]}}}): TResult; - // path(path: [T1, T2, T3, T4, T5], obj: {[K1 in T1]: {[K2 in T2]: {[K4 in T4]: {[K5 in T5]: TResult}}[]}}): TResult; - // path(path: [T1, T2, T3, T4, T5], obj: {[K1 in T1]: {[K2 in T2]: {[K4 in T4]: TResult[]}[]}}): TResult; - // path(path: [T1, T2, T3, T4, T5], obj: {[K1 in T1]: {[K2 in T2]: {[K5 in T5]: TResult}[][]}}): TResult; - // path(path: [T1, T2, T3, T4, T5], obj: {[K1 in T1]: {[K2 in T2]: TResult[][][]}}): TResult; - // path(path: [T1, T2, T3, T4, T5], obj: {[K1 in T1]: {[K3 in T3]: {[K4 in T4]: {[K5 in T5]: TResult}}}[]}): TResult; - // path(path: [T1, T2, T3, T4, T5], obj: {[K1 in T1]: {[K3 in T3]: {[K4 in T4]: TResult[]}}[]}): TResult; - // path(path: [T1, T2, T3, T4, T5], obj: {[K1 in T1]: {[K3 in T3]: {[K5 in T5]: TResult}[]}[]}): TResult; - // path(path: [T1, T2, T3, T4, T5], obj: {[K1 in T1]: {[K3 in T3]: TResult[][]}[]}): TResult; - // path(path: [T1, T2, T3, T4, T5], obj: {[K1 in T1]: {[K4 in T4]: {[K5 in T5]: TResult}}[][]}): TResult; - // path(path: [T1, T2, T3, T4, T5], obj: {[K1 in T1]: {[K4 in T4]: TResult[]}[][]}): TResult; - // path(path: [T1, T2, T3, T4, T5], obj: {[K1 in T1]: {[K5 in T5]: TResult}[][][]}): TResult; - // path(path: [T1, T2, T3, T4, T5], obj: {[K1 in T1]: TResult[][][][]}): TResult; - // path(path: [T1, T2, T3, T4, T5], obj: {[K2 in T2]: {[K3 in T3]: {[K4 in T4]: {[K5 in T5]: TResult}}}}[]): TResult; - // path(path: [T1, T2, T3, T4, T5], obj: {[K2 in T2]: {[K3 in T3]: {[K4 in T4]: TResult[]}}}[]): TResult; - // path(path: [T1, T2, T3, T4, T5], obj: {[K2 in T2]: {[K3 in T3]: {[K5 in T5]: TResult}[]}}[]): TResult; - // path(path: [T1, T2, T3, T4, T5], obj: {[K2 in T2]: {[K3 in T3]: TResult[][]}}[]): TResult; - // path(path: [T1, T2, T3, T4, T5], obj: {[K2 in T2]: {[K4 in T4]: {[K5 in T5]: TResult}}[]}[]): TResult; - // path(path: [T1, T2, T3, T4, T5], obj: {[K2 in T2]: {[K4 in T4]: TResult[]}[]}[]): TResult; - // path(path: [T1, T2, T3, T4, T5], obj: {[K2 in T2]: {[K5 in T5]: TResult}[][]}[]): TResult; - // path(path: [T1, T2, T3, T4, T5], obj: {[K2 in T2]: TResult[][][]}[]): TResult; - // path(path: [T1, T2, T3, T4, T5], obj: {[K3 in T3]: {[K4 in T4]: {[K5 in T5]: TResult}}}[][]): TResult; - // path(path: [T1, T2, T3, T4, T5], obj: {[K3 in T3]: {[K4 in T4]: TResult[]}}[][]): TResult; - // path(path: [T1, T2, T3, T4, T5], obj: {[K3 in T3]: {[K5 in T5]: TResult}[]}[][]): TResult; - // path(path: [T1, T2, T3, T4, T5], obj: {[K3 in T3]: TResult[][]}[][]): TResult; - // path(path: [T1, T2, T3, T4, T5], obj: {[K4 in T4]: {[K5 in T5]: TResult}}[][][]): TResult; - // path(path: [T1, T2, T3, T4, T5], obj: {[K4 in T4]: TResult[]}[][][]): TResult; - // path(path: [T1, T2, T3, T4, T5], obj: {[K5 in T5]: TResult}[][][][]): TResult; - // path(path: [T1, T2, T3, T4, T5], obj: TResult[][][][][]): TResult; - // path(path: [T1, T2, T3, T4, T5, T6], obj: {[K1 in T1]: {[K2 in T2]: {[K3 in T3]: {[K4 in T4]: {[K5 in T5]: {[K6 in T6]: TResult}}}}}}): TResult; - // path(path: [T1, T2, T3, T4, T5, T6], obj: {[K1 in T1]: {[K2 in T2]: {[K3 in T3]: {[K4 in T4]: {[K5 in T5]: TResult[]}}}}}): TResult; - // path(path: [T1, T2, T3, T4, T5, T6], obj: {[K1 in T1]: {[K2 in T2]: {[K3 in T3]: {[K4 in T4]: {[K6 in T6]: TResult}[]}}}}): TResult; - // path(path: [T1, T2, T3, T4, T5, T6], obj: {[K1 in T1]: {[K2 in T2]: {[K3 in T3]: {[K4 in T4]: TResult[][]}}}}): TResult; - // path(path: [T1, T2, T3, T4, T5, T6], obj: {[K1 in T1]: {[K2 in T2]: {[K3 in T3]: {[K5 in T5]: {[K6 in T6]: TResult}}[]}}}): TResult; - // path(path: [T1, T2, T3, T4, T5, T6], obj: {[K1 in T1]: {[K2 in T2]: {[K3 in T3]: {[K5 in T5]: TResult[]}[]}}}): TResult; - // path(path: [T1, T2, T3, T4, T5, T6], obj: {[K1 in T1]: {[K2 in T2]: {[K3 in T3]: {[K6 in T6]: TResult}[][]}}}): TResult; - // path(path: [T1, T2, T3, T4, T5, T6], obj: {[K1 in T1]: {[K2 in T2]: {[K3 in T3]: TResult[][][]}}}): TResult; - // path(path: [T1, T2, T3, T4, T5, T6], obj: {[K1 in T1]: {[K2 in T2]: {[K4 in T4]: {[K5 in T5]: {[K6 in T6]: TResult}}}[]}}): TResult; - // path(path: [T1, T2, T3, T4, T5, T6], obj: {[K1 in T1]: {[K2 in T2]: {[K4 in T4]: {[K5 in T5]: TResult[]}}[]}}): TResult; - // path(path: [T1, T2, T3, T4, T5, T6], obj: {[K1 in T1]: {[K2 in T2]: {[K4 in T4]: {[K6 in T6]: TResult}[]}[]}}): TResult; - // path(path: [T1, T2, T3, T4, T5, T6], obj: {[K1 in T1]: {[K2 in T2]: {[K4 in T4]: TResult[][]}[]}}): TResult; - // path(path: [T1, T2, T3, T4, T5, T6], obj: {[K1 in T1]: {[K2 in T2]: {[K5 in T5]: {[K6 in T6]: TResult}}[][]}}): TResult; - // path(path: [T1, T2, T3, T4, T5, T6], obj: {[K1 in T1]: {[K2 in T2]: {[K5 in T5]: TResult[]}[][]}}): TResult; - // path(path: [T1, T2, T3, T4, T5, T6], obj: {[K1 in T1]: {[K2 in T2]: {[K6 in T6]: TResult}[][][]}}): TResult; - // path(path: [T1, T2, T3, T4, T5, T6], obj: {[K1 in T1]: {[K2 in T2]: TResult[][][][]}}): TResult; - // path(path: [T1, T2, T3, T4, T5, T6], obj: {[K1 in T1]: {[K3 in T3]: {[K4 in T4]: {[K5 in T5]: {[K6 in T6]: TResult}}}}[]}): TResult; - // path(path: [T1, T2, T3, T4, T5, T6], obj: {[K1 in T1]: {[K3 in T3]: {[K4 in T4]: {[K5 in T5]: TResult[]}}}[]}): TResult; - // path(path: [T1, T2, T3, T4, T5, T6], obj: {[K1 in T1]: {[K3 in T3]: {[K4 in T4]: {[K6 in T6]: TResult}[]}}[]}): TResult; - // path(path: [T1, T2, T3, T4, T5, T6], obj: {[K1 in T1]: {[K3 in T3]: {[K4 in T4]: TResult[][]}}[]}): TResult; - // path(path: [T1, T2, T3, T4, T5, T6], obj: {[K1 in T1]: {[K3 in T3]: {[K5 in T5]: {[K6 in T6]: TResult}}[]}[]}): TResult; - // path(path: [T1, T2, T3, T4, T5, T6], obj: {[K1 in T1]: {[K3 in T3]: {[K5 in T5]: TResult[]}[]}[]}): TResult; - // path(path: [T1, T2, T3, T4, T5, T6], obj: {[K1 in T1]: {[K3 in T3]: {[K6 in T6]: TResult}[][]}[]}): TResult; - // path(path: [T1, T2, T3, T4, T5, T6], obj: {[K1 in T1]: {[K3 in T3]: TResult[][][]}[]}): TResult; - // path(path: [T1, T2, T3, T4, T5, T6], obj: {[K1 in T1]: {[K4 in T4]: {[K5 in T5]: {[K6 in T6]: TResult}}}[][]}): TResult; - // path(path: [T1, T2, T3, T4, T5, T6], obj: {[K1 in T1]: {[K4 in T4]: {[K5 in T5]: TResult[]}}[][]}): TResult; - // path(path: [T1, T2, T3, T4, T5, T6], obj: {[K1 in T1]: {[K4 in T4]: {[K6 in T6]: TResult}[]}[][]}): TResult; - // path(path: [T1, T2, T3, T4, T5, T6], obj: {[K1 in T1]: {[K4 in T4]: TResult[][]}[][]}): TResult; - // path(path: [T1, T2, T3, T4, T5, T6], obj: {[K1 in T1]: {[K5 in T5]: {[K6 in T6]: TResult}}[][][]}): TResult; - // path(path: [T1, T2, T3, T4, T5, T6], obj: {[K1 in T1]: {[K5 in T5]: TResult[]}[][][]}): TResult; - // path(path: [T1, T2, T3, T4, T5, T6], obj: {[K1 in T1]: {[K6 in T6]: TResult}[][][][]}): TResult; - // path(path: [T1, T2, T3, T4, T5, T6], obj: {[K1 in T1]: TResult[][][][][]}): TResult; - // path(path: [T1, T2, T3, T4, T5, T6], obj: {[K2 in T2]: {[K3 in T3]: {[K4 in T4]: {[K5 in T5]: {[K6 in T6]: TResult}}}}}[]): TResult; - // path(path: [T1, T2, T3, T4, T5, T6], obj: {[K2 in T2]: {[K3 in T3]: {[K4 in T4]: {[K5 in T5]: TResult[]}}}}[]): TResult; - // path(path: [T1, T2, T3, T4, T5, T6], obj: {[K2 in T2]: {[K3 in T3]: {[K4 in T4]: {[K6 in T6]: TResult}[]}}}[]): TResult; - // path(path: [T1, T2, T3, T4, T5, T6], obj: {[K2 in T2]: {[K3 in T3]: {[K4 in T4]: TResult[][]}}}[]): TResult; - // path(path: [T1, T2, T3, T4, T5, T6], obj: {[K2 in T2]: {[K3 in T3]: {[K5 in T5]: {[K6 in T6]: TResult}}[]}}[]): TResult; - // path(path: [T1, T2, T3, T4, T5, T6], obj: {[K2 in T2]: {[K3 in T3]: {[K5 in T5]: TResult[]}[]}}[]): TResult; - // path(path: [T1, T2, T3, T4, T5, T6], obj: {[K2 in T2]: {[K3 in T3]: {[K6 in T6]: TResult}[][]}}[]): TResult; - // path(path: [T1, T2, T3, T4, T5, T6], obj: {[K2 in T2]: {[K3 in T3]: TResult[][][]}}[]): TResult; - // path(path: [T1, T2, T3, T4, T5, T6], obj: {[K2 in T2]: {[K4 in T4]: {[K5 in T5]: {[K6 in T6]: TResult}}}[]}[]): TResult; - // path(path: [T1, T2, T3, T4, T5, T6], obj: {[K2 in T2]: {[K4 in T4]: {[K5 in T5]: TResult[]}}[]}[]): TResult; - // path(path: [T1, T2, T3, T4, T5, T6], obj: {[K2 in T2]: {[K4 in T4]: {[K6 in T6]: TResult}[]}[]}[]): TResult; - // path(path: [T1, T2, T3, T4, T5, T6], obj: {[K2 in T2]: {[K4 in T4]: TResult[][]}[]}[]): TResult; - // path(path: [T1, T2, T3, T4, T5, T6], obj: {[K2 in T2]: {[K5 in T5]: {[K6 in T6]: TResult}}[][]}[]): TResult; - // path(path: [T1, T2, T3, T4, T5, T6], obj: {[K2 in T2]: {[K5 in T5]: TResult[]}[][]}[]): TResult; - // path(path: [T1, T2, T3, T4, T5, T6], obj: {[K2 in T2]: {[K6 in T6]: TResult}[][][]}[]): TResult; - // path(path: [T1, T2, T3, T4, T5, T6], obj: {[K2 in T2]: TResult[][][][]}[]): TResult; - // path(path: [T1, T2, T3, T4, T5, T6], obj: {[K3 in T3]: {[K4 in T4]: {[K5 in T5]: {[K6 in T6]: TResult}}}}[][]): TResult; - // path(path: [T1, T2, T3, T4, T5, T6], obj: {[K3 in T3]: {[K4 in T4]: {[K5 in T5]: TResult[]}}}[][]): TResult; - // path(path: [T1, T2, T3, T4, T5, T6], obj: {[K3 in T3]: {[K4 in T4]: {[K6 in T6]: TResult}[]}}[][]): TResult; - // path(path: [T1, T2, T3, T4, T5, T6], obj: {[K3 in T3]: {[K4 in T4]: TResult[][]}}[][]): TResult; - // path(path: [T1, T2, T3, T4, T5, T6], obj: {[K3 in T3]: {[K5 in T5]: {[K6 in T6]: TResult}}[]}[][]): TResult; - // path(path: [T1, T2, T3, T4, T5, T6], obj: {[K3 in T3]: {[K5 in T5]: TResult[]}[]}[][]): TResult; - // path(path: [T1, T2, T3, T4, T5, T6], obj: {[K3 in T3]: {[K6 in T6]: TResult}[][]}[][]): TResult; - // path(path: [T1, T2, T3, T4, T5, T6], obj: {[K3 in T3]: TResult[][][]}[][]): TResult; - // path(path: [T1, T2, T3, T4, T5, T6], obj: {[K4 in T4]: {[K5 in T5]: {[K6 in T6]: TResult}}}[][][]): TResult; - // path(path: [T1, T2, T3, T4, T5, T6], obj: {[K4 in T4]: {[K5 in T5]: TResult[]}}[][][]): TResult; - // path(path: [T1, T2, T3, T4, T5, T6], obj: {[K4 in T4]: {[K6 in T6]: TResult}[]}[][][]): TResult; - // path(path: [T1, T2, T3, T4, T5, T6], obj: {[K4 in T4]: TResult[][]}[][][]): TResult; - // path(path: [T1, T2, T3, T4, T5, T6], obj: {[K5 in T5]: {[K6 in T6]: TResult}}[][][][]): TResult; - // path(path: [T1, T2, T3, T4, T5, T6], obj: {[K5 in T5]: TResult[]}[][][][]): TResult; - // path(path: [T1, T2, T3, T4, T5, T6], obj: {[K6 in T6]: TResult}[][][][][]): TResult; - // path(path: [T1, T2, T3, T4, T5, T6], obj: TResult[][][][][][]): TResult; - + // fallback, prevents errors but lacks inference; expected result must be supplied manually. path(path: Path, obj: Struct): T; path(path: Path): (obj: Struct) => T; diff --git a/test/flatten.ts b/test/flatten.ts new file mode 100644 index 0000000..d7feae8 --- /dev/null +++ b/test/flatten.ts @@ -0,0 +1,41 @@ +import flatten = require('ramda/src/flatten'); +import { equal } from 'assert'; +import { itFailsType, typeFail } from '../type-fail'; + +type nestedX = { x: number }; + + +const obj = { a: { b: { c: 42 } } }; +const objWithList = { a: [{ c: 42 }, { c: 43 }] }; + +const flat = [1, 2, 3, 4, 5]; + +const oneLevel = [[1, 2], [3, 4], [5]]; + +const twoLevel = [[1, [2]], [3, 4], [5]]; + +const twoAndThreeLevel = [[1, [2]], [[3, [4]]], [5]]; + +describe('flatten', () => { + it('one level nested array', () => { + const res = flatten(oneLevel)[0]; + equal(res, flat); + }); + + it('two level nested array', () => { + const res = flatten(twoLevel)[0]; + const flat = [1, 2, 3, 4, 5] + }); + + it('two and tree level nested array', () => { + const res = flatten(twoAndThreeLevel)[0]; + const flat = [1, 2, 3, 4, 5] + }); + + it.skip('ts error: incorrect type for value not allowed', () => { + typeFail(` + import assocPath = require('ramda/src/assocPath'); + assocPath(['a', 'b'], '42', {a: {b: 0}}) + `, /incompatible with index signature/); + }); +}); From 2aec297002920eac2862f855ca240ae1beec0722 Mon Sep 17 00:00:00 2001 From: whitecolor Date: Sun, 9 Apr 2017 05:08:22 +0500 Subject: [PATCH 12/19] flatten: gen, tests --- gen.ts | 49 ++++++++++++++++++++++++++++++++++-------------- src/flatten.d.ts | 37 ++++++++++++++++++++++++++++++++++++ test/flatten.ts | 43 ++++++++++++++++++++---------------------- tpl/flatten.ts | 26 +++++++++++++++++++++++++ 4 files changed, 118 insertions(+), 37 deletions(-) create mode 100644 src/flatten.d.ts create mode 100644 tpl/flatten.ts diff --git a/gen.ts b/gen.ts index 1938790..2243af9 100644 --- a/gen.ts +++ b/gen.ts @@ -1,47 +1,68 @@ import * as fs from 'fs'; +import * as path from 'path'; +import { promisify } from 'typed-promisify'; export const importInterfaces = (names: string[]) => - `import { ${names.join(', ')} } from '../interfaces';` + `import { ${names.join(', ')} } from '../interfaces';`; -export type FunParams = { [name: string]: string }[] +export type FunParams = { [name: string]: string }[]; export const parseFunParams = (params: FunParams) => - params.map(p => `${Object.keys(p)[0]}: ${p[Object.keys(p)[0]]}`).join(', ') + params.map(p => `${Object.keys(p)[0]}: ${p[Object.keys(p)[0]]}`).join(', '); export const arrowFunction = ( typeParams: string[], params: FunParams, result: string) => { - return `<\n${typeParams.join(',\n')}>\n(${parseFunParams(params)}) => \n${result}` -} + return `<\n${typeParams.join(',\n')}>\n(${parseFunParams(params)}) => \n${result}`; +}; + +export const docs = (description: string) => + ('/**\n' + description.trim()).split('\n').join('\n * ') + '\n */\n'; + export const declareFunction = (name: string, typeParams: string[], params: FunParams, result: string ) => `declare function ${name}` + - `<\n${typeParams.join(',\n')}>\n(${parseFunParams(params)}): \n${result}` + //`<\n${typeParams.join(',\n')}>\n(${parseFunParams(params)}): \n${result}`; + `<${typeParams.join(', ')}>(${parseFunParams(params)}): ${result}`; export function getParamsNums(max: number) { return Array.from(Array(max + 1).keys()).map(i => Array.from(Array(i + 1).keys()).slice(1) - ).slice(1) + ).slice(1); } +export const makeNestedObjPath = (props: string[], init: string) => + props.concat([]).reverse().reduce((prev, prop, index) => + `{[K${props.length - index} in ${prop}]: ${prev}}` + , init); +export const defineType = (type: string, def: string) => + `type ${type} = ${def};`; +; -const tplFiles = fs.readdirSync(__dirname + '/tpl') +const tplFiles = fs.readdirSync(__dirname + '/tpl'); + +const g = (global as any); +g.genFileCache = g.genFileCache || {}; describe('Generation', () => { tplFiles.forEach(tplFile => { - const name = tplFile.replace(/\.ts$/, '') + const name = tplFile.replace(/\.ts$/, ''); it(name, () => { const src = require(__dirname + '/tpl/' + tplFile) .concat(`export = ${name}`) .join('\n\n') - .concat('\n') - fs.writeFileSync(__dirname + `/src/${name}.d.ts`, src) - }) - }) -}) \ No newline at end of file + .concat('\n'); + + if (g.genFileCache[name] !== src) { + fs.writeFileSync(__dirname + `/src/${name}.d.ts`, src); + g.genFileCache[name] = src; + } + }); + }); +}); diff --git a/src/flatten.d.ts b/src/flatten.d.ts new file mode 100644 index 0000000..d57b92a --- /dev/null +++ b/src/flatten.d.ts @@ -0,0 +1,37 @@ +type NestedArray5 = (T | (T | (T | (T | (T | T[])[])[])[])[])[]; +type NestedArray4 = (T | (T | (T | (T | T[])[])[])[])[]; +type NestedArray3 = (T | (T | (T | T[])[])[])[]; +type NestedArray2 = (T | (T | T[])[])[]; +type NestedArray1 = (T | T[])[]; + +/** + * Returns a new list by pulling every item out + * of it (and all its sub-arrays) and putting them in a new array, depth-first. + */ +declare function flatten(list: NestedArray5): T[] + +/** + * Returns a new list by pulling every item out + * of it (and all its sub-arrays) and putting them in a new array, depth-first. + */ +declare function flatten(list: NestedArray4): T[] + +/** + * Returns a new list by pulling every item out + * of it (and all its sub-arrays) and putting them in a new array, depth-first. + */ +declare function flatten(list: NestedArray3): T[] + +/** + * Returns a new list by pulling every item out + * of it (and all its sub-arrays) and putting them in a new array, depth-first. + */ +declare function flatten(list: NestedArray2): T[] + +/** + * Returns a new list by pulling every item out + * of it (and all its sub-arrays) and putting them in a new array, depth-first. + */ +declare function flatten(list: NestedArray1): T[] + +export = flatten diff --git a/test/flatten.ts b/test/flatten.ts index d7feae8..6f22f58 100644 --- a/test/flatten.ts +++ b/test/flatten.ts @@ -1,41 +1,38 @@ import flatten = require('ramda/src/flatten'); -import { equal } from 'assert'; -import { itFailsType, typeFail } from '../type-fail'; - -type nestedX = { x: number }; - - -const obj = { a: { b: { c: 42 } } }; -const objWithList = { a: [{ c: 42 }, { c: 43 }] }; +import { equal, deepEqual } from 'assert'; +import { typeFail } from '../type-fail'; const flat = [1, 2, 3, 4, 5]; - const oneLevel = [[1, 2], [3, 4], [5]]; - +const oneLevelNoType = [['1', 2], [3, 4], [5]]; const twoLevel = [[1, [2]], [3, 4], [5]]; - const twoAndThreeLevel = [[1, [2]], [[3, [4]]], [5]]; describe('flatten', () => { - it('one level nested array', () => { - const res = flatten(oneLevel)[0]; - equal(res, flat); + it('one level nested array', () => { + const res = flatten(oneLevel); + deepEqual(res, flat); }); it('two level nested array', () => { - const res = flatten(twoLevel)[0]; - const flat = [1, 2, 3, 4, 5] + const res = flatten(twoLevel); + deepEqual(res, flat); }); it('two and tree level nested array', () => { - const res = flatten(twoAndThreeLevel)[0]; - const flat = [1, 2, 3, 4, 5] + const res = flatten(twoAndThreeLevel); + deepEqual(res, flat); }); - it.skip('ts error: incorrect type for value not allowed', () => { - typeFail(` - import assocPath = require('ramda/src/assocPath'); - assocPath(['a', 'b'], '42', {a: {b: 0}}) - `, /incompatible with index signature/); + it('string | number type array', () => { + const res = flatten(oneLevelNoType); + deepEqual(res, ['1', 2, 3, 4, 5]); }); + + // it.skip('ts error: incorrect type for value not allowed', () => { + // typeFail(` + // import assocPath = require('ramda/src/flatten'); + // assocPath(['a', 'b'], '42', {a: {b: 0}}) + // `, /incompatible with index signature/); + // }); }); diff --git a/tpl/flatten.ts b/tpl/flatten.ts new file mode 100644 index 0000000..48bedf4 --- /dev/null +++ b/tpl/flatten.ts @@ -0,0 +1,26 @@ +import { + declareFunction, + getParamsNums, + defineType, docs +} from '../gen'; + +const nestedListLevels = getParamsNums(5).reverse(); + +const desc = `Returns a new list by pulling every item out +of it (and all its sub-arrays) and putting them in a new array, depth-first.`; + +const typeName = 'NestedArray'; + +module.exports = [ + nestedListLevels + .map((levels, i) => defineType(typeName + levels.length + '', + levels.reduce((prev) => `(T | ${prev})[]`, 'T[]') + )).join('\n'), + ...nestedListLevels.map((levels) => + docs(desc) + + declareFunction('flatten', + ['T'], + [{ list: typeName + levels.length + '' }], + `T[]` + )) +]; From 9105ed43a064041764b0fa2608d3a7747a787e7a Mon Sep 17 00:00:00 2001 From: whitecolor Date: Sun, 9 Apr 2017 05:40:24 +0500 Subject: [PATCH 13/19] updates to scripts --- gen.ts | 36 +++++++++++++++++------------------- package.json | 2 +- remove-generated.ts | 1 + type-check.ts | 8 ++++---- type-fail.ts | 12 +++++++++++- 5 files changed, 34 insertions(+), 25 deletions(-) diff --git a/gen.ts b/gen.ts index 2243af9..86bb86b 100644 --- a/gen.ts +++ b/gen.ts @@ -1,34 +1,34 @@ import * as fs from 'fs'; import * as path from 'path'; -import { promisify } from 'typed-promisify'; export const importInterfaces = (names: string[]) => `import { ${names.join(', ')} } from '../interfaces';`; export type FunParams = { [name: string]: string }[]; -export const parseFunParams = (params: FunParams) => +const parseFunParams = (params: FunParams) => params.map(p => `${Object.keys(p)[0]}: ${p[Object.keys(p)[0]]}`).join(', '); -export const arrowFunction = ( - typeParams: string[], - params: FunParams, - result: string) => { - return `<\n${typeParams.join(',\n')}>\n(${parseFunParams(params)}) => \n${result}`; -}; - export const docs = (description: string) => ('/**\n' + description.trim()).split('\n').join('\n * ') + '\n */\n'; +export const defineType = (type: string, def: string) => + `type ${type} = ${def};`; +; export const declareFunction = (name: string, typeParams: string[], params: FunParams, result: string ) => `declare function ${name}` + - //`<\n${typeParams.join(',\n')}>\n(${parseFunParams(params)}): \n${result}`; - `<${typeParams.join(', ')}>(${parseFunParams(params)}): ${result}`; + `<${typeParams.join(', ')}>(${parseFunParams(params)}): ${result};`; +export const arrowFunction = ( + typeParams: string[], + params: FunParams, + result: string) => { + return `<${typeParams.join(', ')}> (${parseFunParams(params)}) => ${result}`; +}; export function getParamsNums(max: number) { return Array.from(Array(max + 1).keys()).map(i => @@ -41,10 +41,6 @@ export const makeNestedObjPath = (props: string[], init: string) => `{[K${props.length - index} in ${prop}]: ${prev}}` , init); -export const defineType = (type: string, def: string) => - `type ${type} = ${def};`; -; - const tplFiles = fs.readdirSync(__dirname + '/tpl'); const g = (global as any); @@ -54,10 +50,12 @@ describe('Generation', () => { tplFiles.forEach(tplFile => { const name = tplFile.replace(/\.ts$/, ''); it(name, () => { - const src = require(__dirname + '/tpl/' + tplFile) - .concat(`export = ${name}`) - .join('\n\n') - .concat('\n'); + const lines = require(__dirname + '/tpl/' + tplFile) + const src = + docs('This is auto generated source.') + '\n' + + lines.concat(`export = ${name}`) + .join('\n\n') + .concat('\n'); if (g.genFileCache[name] !== src) { fs.writeFileSync(__dirname + `/src/${name}.d.ts`, src); diff --git a/package.json b/package.json index 9d0430e..3d1b9dd 100644 --- a/package.json +++ b/package.json @@ -3,7 +3,7 @@ "version": "0.23.0-RC1", "scripts": { "lint": "echo linting... && tslint index.d.ts", - "test": "mocha --compilers ts:ts-node/register test/*.ts type-check.ts", + "test": "mocha --compilers ts:ts-node/register test/*.ts type-check.ts", "_test": "echo testing errors... && ./node_modules/typescript/bin/tsc --lib \"es2015\" --module commonjs tests/test.ts --noEmit", "types": "echo testing types... && bash test.sh", "gen": "ts-node remove-generated && mocha --compilers ts:ts-node/register gen.ts" diff --git a/remove-generated.ts b/remove-generated.ts index 54e45d1..f7e8126 100644 --- a/remove-generated.ts +++ b/remove-generated.ts @@ -5,4 +5,5 @@ import * as fs from 'fs'; fs.readdirSync(__dirname + '/tpl') .map(file => 'src/' + file.replace(/\.ts/, '\.d.ts')) + .filter(fs.existsSync) .forEach(fs.unlinkSync) \ No newline at end of file diff --git a/type-check.ts b/type-check.ts index c682bac..40e74a5 100644 --- a/type-check.ts +++ b/type-check.ts @@ -8,7 +8,7 @@ const options: ts.CompilerOptions = ts.readConfigFile('tsconfig.json', ts.sys.re const host = ts.createCompilerHost(options, true); const testDir = 'test'; -const checkCallMatch = /^equal\W/; +const checkCallMatch = /^(equal\W|deepEqual\W)/; const tsFiles = fs.readdirSync(testDir) .map(fileName => path.join(testDir, fileName)); @@ -32,12 +32,12 @@ describe('Check typings', () => { const secondArg = argsNode.getChildren()[2]; const firstArgType = getType(firstArg); const secondArgType = getType(secondArg); - const pos = source.getLineAndCharacterOfPosition(child.pos); + const pos = source.getLineAndCharacterOfPosition(firstArg.pos); equal(firstArgType, secondArgType, - `${tsFile}:${pos.line}:${pos.character}\n` + + `${tsFile}:${pos.line + 1}:${pos.character + 1}: ` + `\`${firstArg.getText()}\` type \`${firstArgType}\`` + - `doesn't match \`${secondArg.getText()}\` type \`${secondArgType}\`` + ` doesn't match \`${secondArg.getText()}\` type \`${secondArgType}\`` ); } } diff --git a/type-fail.ts b/type-fail.ts index ad10a0f..1d5bb55 100644 --- a/type-fail.ts +++ b/type-fail.ts @@ -9,9 +9,10 @@ export const typeFail = (source: string, errorMatch?: RegExp) => { } const filePath = path.join(dir, Math.random() + '.ts'); fs.writeFileSync(filePath, source, 'utf-8'); + let noError = false; try { require(filePath); - assert.ok(false, 'file imported without error'); + noError = true; } catch (e) { if (errorMatch) { const tsErrorMessage = e.diagnostics[0].message; @@ -23,4 +24,13 @@ export const typeFail = (source: string, errorMatch?: RegExp) => { } } fs.unlinkSync(filePath); + if (noError) { + assert.ok(false, 'file imported without error'); + } + }; + +export const itFailsType = (name: string, src: string, errorMatch?: RegExp) => + it('ts error: ' + name, () => { + typeFail(src, errorMatch); + }); From 1637b88c61abd68a4aaaafe5941fb56aac03bbd1 Mon Sep 17 00:00:00 2001 From: whitecolor Date: Sun, 9 Apr 2017 05:44:47 +0500 Subject: [PATCH 14/19] fix flatten import --- index.d.ts | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/index.d.ts b/index.d.ts index 0db980f..63e81d3 100644 --- a/index.d.ts +++ b/index.d.ts @@ -9,11 +9,11 @@ import addIndex = require('./src/addIndex') import curry = require('./src/curry') import merge = require('./src/merge') import props = require('./src/props') -import flatten = require('./src/props') +import flatten = require('./src/flatten') import { List, Struct, Obj, NestedObj, Pred, Variadic, Functor, Type, Transformer, Prop, Path, - NestedArray, KeyValuePair, AccOpts, + KeyValuePair, AccOpts, Ord, Chain, Lens, ManualLens, UnknownLens, Applicative, Traversable, StringRepresentable, From 4c2e7f9d324d233657b32d4f796483dcb88cee42 Mon Sep 17 00:00:00 2001 From: whitecolor Date: Sun, 9 Apr 2017 15:40:30 +0500 Subject: [PATCH 15/19] add path typed --- .gitignore | 3 + .vscode/settings.json | 5 +- gen.ts | 70 ++- index.d.ts | 22 +- src/_props.d.ts | 49 -- src/assocPath.d.ts | 246 +++++++++ src/flatten.d.ts | 14 +- src/lensPath.d.ts | 212 ++++++++ src/path.d.ts | 1195 +++++++++++++++++++++++++++++++++++++++++ src/prop.d.ts | 175 ++++++ src/props.d.ts | 259 +++------ test/assocPath.ts | 29 + test/lensPath.ts | 33 ++ test/path.ts | 53 ++ tpl/assocPath.ts | 68 +++ tpl/lensPath.ts | 53 ++ tpl/path.ts | 49 ++ tpl/prop.ts | 51 ++ tpl/props.ts | 17 +- 19 files changed, 2331 insertions(+), 272 deletions(-) delete mode 100644 src/_props.d.ts create mode 100644 src/assocPath.d.ts create mode 100644 src/lensPath.d.ts create mode 100644 src/path.d.ts create mode 100644 src/prop.d.ts create mode 100644 test/assocPath.ts create mode 100644 test/lensPath.ts create mode 100644 test/path.ts create mode 100644 tpl/assocPath.ts create mode 100644 tpl/lensPath.ts create mode 100644 tpl/path.ts create mode 100644 tpl/prop.ts diff --git a/.gitignore b/.gitignore index 2892e12..981460f 100644 --- a/.gitignore +++ b/.gitignore @@ -1,5 +1,7 @@ node_modules /tmp +/ts-node-* + dist *.swp *.swo @@ -7,3 +9,4 @@ dist .sizecache.json test.js *.log* + diff --git a/.vscode/settings.json b/.vscode/settings.json index 9bbf37f..d2e1405 100644 --- a/.vscode/settings.json +++ b/.vscode/settings.json @@ -1,4 +1,7 @@ // Place your settings in this file to overwrite default and user settings. { - "typescript.tsdk": "node_modules/typescript/lib" + "typescript.tsdk": "node_modules/typescript/lib", + "files.exclude": { + "ts-node-*": true + } } diff --git a/gen.ts b/gen.ts index 86bb86b..e556a6d 100644 --- a/gen.ts +++ b/gen.ts @@ -7,7 +7,7 @@ export const importInterfaces = (names: string[]) => export type FunParams = { [name: string]: string }[]; const parseFunParams = (params: FunParams) => - params.map(p => `${Object.keys(p)[0]}: ${p[Object.keys(p)[0]]}`).join(', '); + params.map(p => `${Object.keys(p)[0]}: ${p[Object.keys(p)[0]]}`); export const docs = (description: string) => ('/**\n' + description.trim()).split('\n').join('\n * ') + '\n */\n'; @@ -16,18 +16,40 @@ export const defineType = (type: string, def: string) => `type ${type} = ${def};`; ; +const maxGeneratedLineSize = 75; + +const joinWithMaxLineSize + = (lines: string[], part: string): string[] => { + const lastLine = lines[lines.length - 1]; + const isLineSizeAllowed = + (lastLine + part).length < maxGeneratedLineSize || part.length < 5; + return isLineSizeAllowed + ? lines.slice(0, -1).concat((lastLine + part)) + : lines.slice(0, -1) + .concat(lastLine.trim()) + .concat(part.replace(/^\s*/, '')); + }; + +const addCommaExeptLast = (parts: string[]) => + parts.slice(0, -1).map(p => p + ', ') + .concat(parts[parts.length - 1]); + export const declareFunction = (name: string, typeParams: string[], params: FunParams, result: string -) => `declare function ${name}` + - `<${typeParams.join(', ')}>(${parseFunParams(params)}): ${result};`; +): string => [`declare function ${name}<`, +...addCommaExeptLast(typeParams), + `>`, `(`, ...addCommaExeptLast(parseFunParams(params)), `):`, ` ${result};`] + .reduce(joinWithMaxLineSize, ['']).join('\n '); export const arrowFunction = ( typeParams: string[], params: FunParams, result: string) => { - return `<${typeParams.join(', ')}> (${parseFunParams(params)}) => ${result}`; + return [`<`, ...addCommaExeptLast(typeParams), + `>`, `(`, ...addCommaExeptLast(parseFunParams(params)), `) =>`, ` ${result}`] + .reduce(joinWithMaxLineSize, ['']).join('\n '); }; export function getParamsNums(max: number) { @@ -36,11 +58,45 @@ export function getParamsNums(max: number) { ).slice(1); } -export const makeNestedObjPath = (props: string[], init: string) => +const zeroPad = (count: number) => + (str: string): string => + Array(count + 1).join('0') + .substring(0, count - str.length) + str; + +type Binary = 0 | 1; + +const toBinaryArray = (length: number) => + (num: number) => zeroPad(length)(num.toString(2)) + .split('') + .map(x => parseInt(x) as Binary); + +const makeStringNumberCombination = + (nums: number[]): (string | number)[][] => + Array.from(Array(Math.pow(2, nums.length)).keys()) + .map(toBinaryArray(nums.length)) + .map((binary) => + binary.map((x, index) => x ? (index + 1) : (index + 1).toString()) + ); + +export const makeParamsStringNumberCombination = (max: number) => + getParamsNums(max) + .map(makeStringNumberCombination) + .reduce((flat, props) => flat.concat(props), []); + +export const addLetter = (letter = 'P') => (prop: string) => + parseInt(prop) ? letter + prop : prop; + +export const makeNestedObjPath = (props: (string | number)[], init: string) => props.concat([]).reverse().reduce((prev, prop, index) => - `{[K${props.length - index} in ${prop}]: ${prev}}` + typeof prop === 'string' + ? `{[K${props.length - index} in ${addLetter()(prop)}]: ${prev}}` + : `${prev}[]` , init); +export const makeTuple = (items: (string | number)[], size?: number) => + `[` + items.map(addLetter()).join(', ') + `]` + + (size ? ` & { ${size}?: void }` : ''); + const tplFiles = fs.readdirSync(__dirname + '/tpl'); const g = (global as any); @@ -50,7 +106,7 @@ describe('Generation', () => { tplFiles.forEach(tplFile => { const name = tplFile.replace(/\.ts$/, ''); it(name, () => { - const lines = require(__dirname + '/tpl/' + tplFile) + const lines = require(__dirname + '/tpl/' + tplFile); const src = docs('This is auto generated source.') + '\n' + lines.concat(`export = ${name}`) diff --git a/index.d.ts b/index.d.ts index 63e81d3..33a431f 100644 --- a/index.d.ts +++ b/index.d.ts @@ -9,6 +9,7 @@ import addIndex = require('./src/addIndex') import curry = require('./src/curry') import merge = require('./src/merge') import props = require('./src/props') +import path = require('./src/path') import flatten = require('./src/flatten') import { List, Struct, Obj, NestedObj, @@ -1785,25 +1786,8 @@ declare namespace R { // objects, alternative notation partition>(fn: (a: T) => boolean, obj: U): [Obj, Obj]; // partition>: CurriedFunction2<(a: T) => boolean, U, [Partial,Partial]>; - - - // fallback, prevents errors but lacks inference; expected result must be supplied manually. - path(path: Path, obj: Struct): T; - path(path: Path): (obj: Struct) => T; - - // path: CurriedFunction2, T>; - // failed attempt at proper typing, see https://github.com/Microsoft/TypeScript/issues/12393 : - // path(keys: [K1, K2], obj: T): U; - // path(keys: [K1, K2], obj: T): T[K1][K2]; - - /** - * Determines whether a nested path on an object has a specific value, - * in `R.equals` terms. Most likely used to filter a list. - */ - // pathEq(path: Path, val: any, obj: Struct): boolean; - // pathEq(path: Path, val: any): (obj: Struct) => boolean; - // pathEq(path: Path): CurriedFunction2, boolean>; - // // pathEq: CurriedFunction3, boolean>; + + path: typeof path; // base pathEq(p: Path, v: any, o: any): boolean; diff --git a/src/_props.d.ts b/src/_props.d.ts deleted file mode 100644 index 06d5c27..0000000 --- a/src/_props.d.ts +++ /dev/null @@ -1,49 +0,0 @@ -import { Struct, List, Prop } from '../interfaces' - -/** - * Acts as multiple `prop`: array of keys in, array of values out. Preserves order. - */ -declare function props< - P1 extends string & keyof O, - P2 extends string & keyof O, - P3 extends string & keyof O, - O extends {[K in P1 | P2 | P3]: any}> - (ps: [P1, P2, P3], obj: O): [O[P1], O[P2], O[P3]]; - -declare function props< - P1 extends string & keyof O, - P2 extends string & keyof O, - O extends {[K in P1 | P2]: any}> - (ps: [P1, P2], obj: O): [O[P1], O[P2]]; - -declare function props< - P1 extends string & keyof O, - O extends {[K in P1]: any}> - (ps: [P1], obj: O): [O[P1]]; - - -// curried: - -declare function props< - P1 extends string, - P2 extends string> - (ps: [P1, P2]): (obj: O) => [O[P1], O[P2]]; - - -declare function props - (ps: [P1]): (obj: O) => [O[P1]]; - -// array: - -declare function props(ps: List, obj: List): T[]; -declare function props(ps: List): (obj: List) => T[]; - -// allow custom typed result - -// declare function props -// (ps: Prop[], obj: any): R; - -// declare function props -// (ps: Prop[]): (obj: any) => R; - -export = props; diff --git a/src/assocPath.d.ts b/src/assocPath.d.ts new file mode 100644 index 0000000..f46fe5d --- /dev/null +++ b/src/assocPath.d.ts @@ -0,0 +1,246 @@ +/** + * This is auto generated source. + */ + +import { Path, List, Prop } from '../interfaces'; + + +/** + * Makes a shallow clone of an object, setting or overriding + * the nodes required to create the given path, and placing the specific + * value at the tail end of that path. + * + * Note: Tuples are not supported for typings. + */ +declare function assocPath( + path: [P1, P2, P3, P4, P5, P6, P7, P8], value: T, obj: O): O; + + +/** + * Makes a shallow clone of an object, setting or overriding + * the nodes required to create the given path, and placing the specific + * value at the tail end of that path. + * + * Note: Tuples are not supported for typings. + */ +declare function assocPath( + path: [P1, P2, P3, P4, P5, P6, P7], value: T, obj: O): O; + + +/** + * Makes a shallow clone of an object, setting or overriding + * the nodes required to create the given path, and placing the specific + * value at the tail end of that path. + * + * Note: Tuples are not supported for typings. + */ +declare function assocPath( + path: [P1, P2, P3, P4, P5, P6], value: T, obj: O): O; + + +/** + * Makes a shallow clone of an object, setting or overriding + * the nodes required to create the given path, and placing the specific + * value at the tail end of that path. + * + * Note: Tuples are not supported for typings. + */ +declare function assocPath( + path: [P1, P2, P3, P4, P5], value: T, obj: O): O; + + +/** + * Makes a shallow clone of an object, setting or overriding + * the nodes required to create the given path, and placing the specific + * value at the tail end of that path. + * + * Note: Tuples are not supported for typings. + */ +declare function assocPath( + path: [P1, P2, P3, P4], value: T, obj: O): O; + + +/** + * Makes a shallow clone of an object, setting or overriding + * the nodes required to create the given path, and placing the specific + * value at the tail end of that path. + * + * Note: Tuples are not supported for typings. + */ +declare function assocPath( + path: [P1, P2, P3], value: T, obj: O): O; + + +/** + * Makes a shallow clone of an object, setting or overriding + * the nodes required to create the given path, and placing the specific + * value at the tail end of that path. + * + * Note: Tuples are not supported for typings. + */ +declare function assocPath( + path: [P1, P2], value: T, obj: O): O; + + +/** + * Makes a shallow clone of an object, setting or overriding + * the nodes required to create the given path, and placing the specific + * value at the tail end of that path. + * + * Note: Tuples are not supported for typings. + */ +declare function assocPath(path: [P1], value: T, obj: O): O; + +// curried + + +/** + * Makes a shallow clone of an object, setting or overriding + * the nodes required to create the given path, and placing the specific + * value at the tail end of that path. + * + * Note: Tuples are not supported for typings. + */ +declare function assocPath( + ps: [P1, P2, P3, P4, P5, P6, P7, P8]): + (obj: O) => + [O[P1], O[P2], O[P3], O[P4], O[P5], O[P6], O[P7], O[P8]]; + + +/** + * Makes a shallow clone of an object, setting or overriding + * the nodes required to create the given path, and placing the specific + * value at the tail end of that path. + * + * Note: Tuples are not supported for typings. + */ +declare function assocPath(ps: [P1, P2, P3, P4, P5, P6, P7]): + (obj: O) => + [O[P1], O[P2], O[P3], O[P4], O[P5], O[P6], O[P7]]; + + +/** + * Makes a shallow clone of an object, setting or overriding + * the nodes required to create the given path, and placing the specific + * value at the tail end of that path. + * + * Note: Tuples are not supported for typings. + */ +declare function assocPath( + ps: [P1, P2, P3, P4, P5, P6]): + (obj: O) => + [O[P1], O[P2], O[P3], O[P4], O[P5], O[P6]]; + + +/** + * Makes a shallow clone of an object, setting or overriding + * the nodes required to create the given path, and placing the specific + * value at the tail end of that path. + * + * Note: Tuples are not supported for typings. + */ +declare function assocPath( + ps: [P1, P2, P3, P4, P5]): + (obj: O) => + [O[P1], O[P2], O[P3], O[P4], O[P5]]; + + +/** + * Makes a shallow clone of an object, setting or overriding + * the nodes required to create the given path, and placing the specific + * value at the tail end of that path. + * + * Note: Tuples are not supported for typings. + */ +declare function assocPath(ps: [P1, P2, P3, P4]): + (obj: O) => + [O[P1], O[P2], O[P3], O[P4]]; + + +/** + * Makes a shallow clone of an object, setting or overriding + * the nodes required to create the given path, and placing the specific + * value at the tail end of that path. + * + * Note: Tuples are not supported for typings. + */ +declare function assocPath(ps: [P1, P2, P3]): + (obj: O) => [O[P1], O[P2], O[P3]]; + + +/** + * Makes a shallow clone of an object, setting or overriding + * the nodes required to create the given path, and placing the specific + * value at the tail end of that path. + * + * Note: Tuples are not supported for typings. + */ +declare function assocPath( + ps: [P1, P2]): + (obj: O) => [O[P1], O[P2]]; + + +/** + * Makes a shallow clone of an object, setting or overriding + * the nodes required to create the given path, and placing the specific + * value at the tail end of that path. + * + * Note: Tuples are not supported for typings. + */ +declare function assocPath(ps: [P1]): + (obj: O) => [O[P1]]; + + +/** + * Makes a shallow clone of an object, setting or overriding + * the nodes required to create the given path, and placing the specific + * value at the tail end of that path. + * + * Note: Tuples are not supported for typings. + */ +declare function props(ps: List, obj: List): T[]; + +// curried + + +/** + * Makes a shallow clone of an object, setting or overriding + * the nodes required to create the given path, and placing the specific + * value at the tail end of that path. + * + * Note: Tuples are not supported for typings. + */ +declare function props(ps: List): (obj: List) => T[]; + +export = assocPath diff --git a/src/flatten.d.ts b/src/flatten.d.ts index d57b92a..6ad01e9 100644 --- a/src/flatten.d.ts +++ b/src/flatten.d.ts @@ -1,3 +1,7 @@ +/** + * This is auto generated source. + */ + type NestedArray5 = (T | (T | (T | (T | (T | T[])[])[])[])[])[]; type NestedArray4 = (T | (T | (T | (T | T[])[])[])[])[]; type NestedArray3 = (T | (T | (T | T[])[])[])[]; @@ -8,30 +12,30 @@ type NestedArray1 = (T | T[])[]; * Returns a new list by pulling every item out * of it (and all its sub-arrays) and putting them in a new array, depth-first. */ -declare function flatten(list: NestedArray5): T[] +declare function flatten(list: NestedArray5): T[]; /** * Returns a new list by pulling every item out * of it (and all its sub-arrays) and putting them in a new array, depth-first. */ -declare function flatten(list: NestedArray4): T[] +declare function flatten(list: NestedArray4): T[]; /** * Returns a new list by pulling every item out * of it (and all its sub-arrays) and putting them in a new array, depth-first. */ -declare function flatten(list: NestedArray3): T[] +declare function flatten(list: NestedArray3): T[]; /** * Returns a new list by pulling every item out * of it (and all its sub-arrays) and putting them in a new array, depth-first. */ -declare function flatten(list: NestedArray2): T[] +declare function flatten(list: NestedArray2): T[]; /** * Returns a new list by pulling every item out * of it (and all its sub-arrays) and putting them in a new array, depth-first. */ -declare function flatten(list: NestedArray1): T[] +declare function flatten(list: NestedArray1): T[]; export = flatten diff --git a/src/lensPath.d.ts b/src/lensPath.d.ts new file mode 100644 index 0000000..6d18e82 --- /dev/null +++ b/src/lensPath.d.ts @@ -0,0 +1,212 @@ +/** + * This is auto generated source. + */ + +import { Path, List, Prop } from '../interfaces'; + + +/** + * Returns a lens whose focus is the specified path. + * See also view, set, over. + * Note: Tuples are not supported for typings1. + */ +declare function lensPath( + ps: [P1, P2, P3, P4, P5, P6, P7, P8], obj: O): + [O[P1], O[P2], O[P3], O[P4], O[P5], O[P6], O[P7], O[P8]]; + + +/** + * Returns a lens whose focus is the specified path. + * See also view, set, over. + * Note: Tuples are not supported for typings1. + */ +declare function lensPath( + ps: [P1, P2, P3, P4, P5, P6, P7], obj: O): + [O[P1], O[P2], O[P3], O[P4], O[P5], O[P6], O[P7]]; + + +/** + * Returns a lens whose focus is the specified path. + * See also view, set, over. + * Note: Tuples are not supported for typings1. + */ +declare function lensPath( + ps: [P1, P2, P3, P4, P5, P6], obj: O): + [O[P1], O[P2], O[P3], O[P4], O[P5], O[P6]]; + + +/** + * Returns a lens whose focus is the specified path. + * See also view, set, over. + * Note: Tuples are not supported for typings1. + */ +declare function lensPath(ps: [P1, P2, P3, P4, P5], + obj: O): [O[P1], O[P2], O[P3], O[P4], O[P5]]; + + +/** + * Returns a lens whose focus is the specified path. + * See also view, set, over. + * Note: Tuples are not supported for typings1. + */ +declare function lensPath( + ps: [P1, P2, P3, P4], obj: O): [O[P1], O[P2], O[P3], O[P4]]; + + +/** + * Returns a lens whose focus is the specified path. + * See also view, set, over. + * Note: Tuples are not supported for typings1. + */ +declare function lensPath(ps: [P1, P2, P3], obj: O): + [O[P1], O[P2], O[P3]]; + + +/** + * Returns a lens whose focus is the specified path. + * See also view, set, over. + * Note: Tuples are not supported for typings1. + */ +declare function lensPath( + ps: [P1, P2], obj: O): [O[P1], O[P2]]; + + +/** + * Returns a lens whose focus is the specified path. + * See also view, set, over. + * Note: Tuples are not supported for typings1. + */ +declare function lensPath(ps: [P1], obj: O): [O[P1]]; + +// curried + + +/** + * Returns a lens whose focus is the specified path. + * See also view, set, over. + * Note: Tuples are not supported for typings1. + */ +declare function lensPath( + ps: [P1, P2, P3, P4, P5, P6, P7, P8]): + (obj: O) => + [O[P1], O[P2], O[P3], O[P4], O[P5], O[P6], O[P7], O[P8]]; + + +/** + * Returns a lens whose focus is the specified path. + * See also view, set, over. + * Note: Tuples are not supported for typings1. + */ +declare function lensPath(ps: [P1, P2, P3, P4, P5, P6, P7]): + (obj: O) => + [O[P1], O[P2], O[P3], O[P4], O[P5], O[P6], O[P7]]; + + +/** + * Returns a lens whose focus is the specified path. + * See also view, set, over. + * Note: Tuples are not supported for typings1. + */ +declare function lensPath( + ps: [P1, P2, P3, P4, P5, P6]): + (obj: O) => + [O[P1], O[P2], O[P3], O[P4], O[P5], O[P6]]; + + +/** + * Returns a lens whose focus is the specified path. + * See also view, set, over. + * Note: Tuples are not supported for typings1. + */ +declare function lensPath( + ps: [P1, P2, P3, P4, P5]): + (obj: O) => + [O[P1], O[P2], O[P3], O[P4], O[P5]]; + + +/** + * Returns a lens whose focus is the specified path. + * See also view, set, over. + * Note: Tuples are not supported for typings1. + */ +declare function lensPath(ps: [P1, P2, P3, P4]): + (obj: O) => + [O[P1], O[P2], O[P3], O[P4]]; + + +/** + * Returns a lens whose focus is the specified path. + * See also view, set, over. + * Note: Tuples are not supported for typings1. + */ +declare function lensPath(ps: [P1, P2, P3]): + (obj: O) => [O[P1], O[P2], O[P3]]; + + +/** + * Returns a lens whose focus is the specified path. + * See also view, set, over. + * Note: Tuples are not supported for typings1. + */ +declare function lensPath( + ps: [P1, P2]): + (obj: O) => [O[P1], O[P2]]; + + +/** + * Returns a lens whose focus is the specified path. + * See also view, set, over. + * Note: Tuples are not supported for typings1. + */ +declare function lensPath(ps: [P1]): + (obj: O) => [O[P1]]; + + +/** + * Returns a lens whose focus is the specified path. + * See also view, set, over. + * Note: Tuples are not supported for typings1. + */ +declare function props(ps: List, obj: List): T[]; + +// curried + + +/** + * Returns a lens whose focus is the specified path. + * See also view, set, over. + * Note: Tuples are not supported for typings1. + */ +declare function props(ps: List): (obj: List) => T[]; + +export = lensPath diff --git a/src/path.d.ts b/src/path.d.ts new file mode 100644 index 0000000..540bd3c --- /dev/null +++ b/src/path.d.ts @@ -0,0 +1,1195 @@ +/** + * This is auto generated source. + */ + +/** + * Retrieve the value at a given path. + * Note: Nested tuples are not supported for typings. + * Max path depth typed is 5. + */ +declare function path(path: [P1] & { 1?: void }, + obj: {[K1 in P1]: T}): T; + +/** + * Retrieve the value at a given path. + * Note: Nested tuples are not supported for typings. + * Max path depth typed is 5. + */ +declare function path(path: [P1] & { 1?: void }, + obj: T[]): T; + +/** + * Retrieve the value at a given path. + * Note: Nested tuples are not supported for typings. + * Max path depth typed is 5. + */ +declare function path( + path: [P1, P2] & { 2?: void }, obj: {[K1 in P1]: {[K2 in P2]: T}}): T; + +/** + * Retrieve the value at a given path. + * Note: Nested tuples are not supported for typings. + * Max path depth typed is 5. + */ +declare function path( + path: [P1, P2] & { 2?: void }, obj: {[K1 in P1]: T[]}): T; + +/** + * Retrieve the value at a given path. + * Note: Nested tuples are not supported for typings. + * Max path depth typed is 5. + */ +declare function path( + path: [P1, P2] & { 2?: void }, obj: {[K2 in P2]: T}[]): T; + +/** + * Retrieve the value at a given path. + * Note: Nested tuples are not supported for typings. + * Max path depth typed is 5. + */ +declare function path( + path: [P1, P2] & { 2?: void }, obj: T[][]): T; + +/** + * Retrieve the value at a given path. + * Note: Nested tuples are not supported for typings. + * Max path depth typed is 5. + */ +declare function path(path: [P1, P2, P3] & { 3?: void }, + obj: {[K1 in P1]: {[K2 in P2]: {[K3 in P3]: T}}}): T; + +/** + * Retrieve the value at a given path. + * Note: Nested tuples are not supported for typings. + * Max path depth typed is 5. + */ +declare function path(path: [P1, P2, P3] & { 3?: void }, + obj: {[K1 in P1]: {[K2 in P2]: T[]}}): T; + +/** + * Retrieve the value at a given path. + * Note: Nested tuples are not supported for typings. + * Max path depth typed is 5. + */ +declare function path(path: [P1, P2, P3] & { 3?: void }, + obj: {[K1 in P1]: {[K3 in P3]: T}[]}): T; + +/** + * Retrieve the value at a given path. + * Note: Nested tuples are not supported for typings. + * Max path depth typed is 5. + */ +declare function path(path: [P1, P2, P3] & { 3?: void }, + obj: {[K1 in P1]: T[][]}): T; + +/** + * Retrieve the value at a given path. + * Note: Nested tuples are not supported for typings. + * Max path depth typed is 5. + */ +declare function path(path: [P1, P2, P3] & { 3?: void }, + obj: {[K2 in P2]: {[K3 in P3]: T}}[]): T; + +/** + * Retrieve the value at a given path. + * Note: Nested tuples are not supported for typings. + * Max path depth typed is 5. + */ +declare function path(path: [P1, P2, P3] & { 3?: void }, + obj: {[K2 in P2]: T[]}[]): T; + +/** + * Retrieve the value at a given path. + * Note: Nested tuples are not supported for typings. + * Max path depth typed is 5. + */ +declare function path(path: [P1, P2, P3] & { 3?: void }, + obj: {[K3 in P3]: T}[][]): T; + +/** + * Retrieve the value at a given path. + * Note: Nested tuples are not supported for typings. + * Max path depth typed is 5. + */ +declare function path(path: [P1, P2, P3] & { 3?: void }, obj: T[][][]): T; + +/** + * Retrieve the value at a given path. + * Note: Nested tuples are not supported for typings. + * Max path depth typed is 5. + */ +declare function path( + path: [P1, P2, P3, P4] & { 4?: void }, + obj: {[K1 in P1]: {[K2 in P2]: {[K3 in P3]: {[K4 in P4]: T}}}}): T; + +/** + * Retrieve the value at a given path. + * Note: Nested tuples are not supported for typings. + * Max path depth typed is 5. + */ +declare function path( + path: [P1, P2, P3, P4] & { 4?: void }, + obj: {[K1 in P1]: {[K2 in P2]: {[K3 in P3]: T[]}}}): T; + +/** + * Retrieve the value at a given path. + * Note: Nested tuples are not supported for typings. + * Max path depth typed is 5. + */ +declare function path( + path: [P1, P2, P3, P4] & { 4?: void }, + obj: {[K1 in P1]: {[K2 in P2]: {[K4 in P4]: T}[]}}): T; + +/** + * Retrieve the value at a given path. + * Note: Nested tuples are not supported for typings. + * Max path depth typed is 5. + */ +declare function path( + path: [P1, P2, P3, P4] & { 4?: void }, + obj: {[K1 in P1]: {[K2 in P2]: T[][]}}): T; + +/** + * Retrieve the value at a given path. + * Note: Nested tuples are not supported for typings. + * Max path depth typed is 5. + */ +declare function path( + path: [P1, P2, P3, P4] & { 4?: void }, + obj: {[K1 in P1]: {[K3 in P3]: {[K4 in P4]: T}}[]}): T; + +/** + * Retrieve the value at a given path. + * Note: Nested tuples are not supported for typings. + * Max path depth typed is 5. + */ +declare function path( + path: [P1, P2, P3, P4] & { 4?: void }, + obj: {[K1 in P1]: {[K3 in P3]: T[]}[]}): T; + +/** + * Retrieve the value at a given path. + * Note: Nested tuples are not supported for typings. + * Max path depth typed is 5. + */ +declare function path( + path: [P1, P2, P3, P4] & { 4?: void }, + obj: {[K1 in P1]: {[K4 in P4]: T}[][]}): T; + +/** + * Retrieve the value at a given path. + * Note: Nested tuples are not supported for typings. + * Max path depth typed is 5. + */ +declare function path( + path: [P1, P2, P3, P4] & { 4?: void }, obj: {[K1 in P1]: T[][][]}): T; + +/** + * Retrieve the value at a given path. + * Note: Nested tuples are not supported for typings. + * Max path depth typed is 5. + */ +declare function path( + path: [P1, P2, P3, P4] & { 4?: void }, + obj: {[K2 in P2]: {[K3 in P3]: {[K4 in P4]: T}}}[]): T; + +/** + * Retrieve the value at a given path. + * Note: Nested tuples are not supported for typings. + * Max path depth typed is 5. + */ +declare function path( + path: [P1, P2, P3, P4] & { 4?: void }, + obj: {[K2 in P2]: {[K3 in P3]: T[]}}[]): T; + +/** + * Retrieve the value at a given path. + * Note: Nested tuples are not supported for typings. + * Max path depth typed is 5. + */ +declare function path( + path: [P1, P2, P3, P4] & { 4?: void }, + obj: {[K2 in P2]: {[K4 in P4]: T}[]}[]): T; + +/** + * Retrieve the value at a given path. + * Note: Nested tuples are not supported for typings. + * Max path depth typed is 5. + */ +declare function path( + path: [P1, P2, P3, P4] & { 4?: void }, obj: {[K2 in P2]: T[][]}[]): T; + +/** + * Retrieve the value at a given path. + * Note: Nested tuples are not supported for typings. + * Max path depth typed is 5. + */ +declare function path( + path: [P1, P2, P3, P4] & { 4?: void }, + obj: {[K3 in P3]: {[K4 in P4]: T}}[][]): T; + +/** + * Retrieve the value at a given path. + * Note: Nested tuples are not supported for typings. + * Max path depth typed is 5. + */ +declare function path( + path: [P1, P2, P3, P4] & { 4?: void }, obj: {[K3 in P3]: T[]}[][]): T; + +/** + * Retrieve the value at a given path. + * Note: Nested tuples are not supported for typings. + * Max path depth typed is 5. + */ +declare function path( + path: [P1, P2, P3, P4] & { 4?: void }, obj: {[K4 in P4]: T}[][][]): T; + +/** + * Retrieve the value at a given path. + * Note: Nested tuples are not supported for typings. + * Max path depth typed is 5. + */ +declare function path( + path: [P1, P2, P3, P4] & { 4?: void }, obj: T[][][][]): T; + +/** + * Retrieve the value at a given path. + * Note: Nested tuples are not supported for typings. + * Max path depth typed is 5. + */ +declare function path( + path: [P1, P2, P3, P4, P5] & { 5?: void }, + obj: {[K1 in P1]: {[K2 in P2]: {[K3 in P3]: {[K4 in P4]: {[K5 in P5]: T}}}}}): T; + +/** + * Retrieve the value at a given path. + * Note: Nested tuples are not supported for typings. + * Max path depth typed is 5. + */ +declare function path( + path: [P1, P2, P3, P4, P5] & { 5?: void }, + obj: {[K1 in P1]: {[K2 in P2]: {[K3 in P3]: {[K4 in P4]: T[]}}}}): T; + +/** + * Retrieve the value at a given path. + * Note: Nested tuples are not supported for typings. + * Max path depth typed is 5. + */ +declare function path( + path: [P1, P2, P3, P4, P5] & { 5?: void }, + obj: {[K1 in P1]: {[K2 in P2]: {[K3 in P3]: {[K5 in P5]: T}[]}}}): T; + +/** + * Retrieve the value at a given path. + * Note: Nested tuples are not supported for typings. + * Max path depth typed is 5. + */ +declare function path( + path: [P1, P2, P3, P4, P5] & { 5?: void }, + obj: {[K1 in P1]: {[K2 in P2]: {[K3 in P3]: T[][]}}}): T; + +/** + * Retrieve the value at a given path. + * Note: Nested tuples are not supported for typings. + * Max path depth typed is 5. + */ +declare function path( + path: [P1, P2, P3, P4, P5] & { 5?: void }, + obj: {[K1 in P1]: {[K2 in P2]: {[K4 in P4]: {[K5 in P5]: T}}[]}}): T; + +/** + * Retrieve the value at a given path. + * Note: Nested tuples are not supported for typings. + * Max path depth typed is 5. + */ +declare function path( + path: [P1, P2, P3, P4, P5] & { 5?: void }, + obj: {[K1 in P1]: {[K2 in P2]: {[K4 in P4]: T[]}[]}}): T; + +/** + * Retrieve the value at a given path. + * Note: Nested tuples are not supported for typings. + * Max path depth typed is 5. + */ +declare function path( + path: [P1, P2, P3, P4, P5] & { 5?: void }, + obj: {[K1 in P1]: {[K2 in P2]: {[K5 in P5]: T}[][]}}): T; + +/** + * Retrieve the value at a given path. + * Note: Nested tuples are not supported for typings. + * Max path depth typed is 5. + */ +declare function path( + path: [P1, P2, P3, P4, P5] & { 5?: void }, + obj: {[K1 in P1]: {[K2 in P2]: T[][][]}}): T; + +/** + * Retrieve the value at a given path. + * Note: Nested tuples are not supported for typings. + * Max path depth typed is 5. + */ +declare function path( + path: [P1, P2, P3, P4, P5] & { 5?: void }, + obj: {[K1 in P1]: {[K3 in P3]: {[K4 in P4]: {[K5 in P5]: T}}}[]}): T; + +/** + * Retrieve the value at a given path. + * Note: Nested tuples are not supported for typings. + * Max path depth typed is 5. + */ +declare function path( + path: [P1, P2, P3, P4, P5] & { 5?: void }, + obj: {[K1 in P1]: {[K3 in P3]: {[K4 in P4]: T[]}}[]}): T; + +/** + * Retrieve the value at a given path. + * Note: Nested tuples are not supported for typings. + * Max path depth typed is 5. + */ +declare function path( + path: [P1, P2, P3, P4, P5] & { 5?: void }, + obj: {[K1 in P1]: {[K3 in P3]: {[K5 in P5]: T}[]}[]}): T; + +/** + * Retrieve the value at a given path. + * Note: Nested tuples are not supported for typings. + * Max path depth typed is 5. + */ +declare function path( + path: [P1, P2, P3, P4, P5] & { 5?: void }, + obj: {[K1 in P1]: {[K3 in P3]: T[][]}[]}): T; + +/** + * Retrieve the value at a given path. + * Note: Nested tuples are not supported for typings. + * Max path depth typed is 5. + */ +declare function path( + path: [P1, P2, P3, P4, P5] & { 5?: void }, + obj: {[K1 in P1]: {[K4 in P4]: {[K5 in P5]: T}}[][]}): T; + +/** + * Retrieve the value at a given path. + * Note: Nested tuples are not supported for typings. + * Max path depth typed is 5. + */ +declare function path( + path: [P1, P2, P3, P4, P5] & { 5?: void }, + obj: {[K1 in P1]: {[K4 in P4]: T[]}[][]}): T; + +/** + * Retrieve the value at a given path. + * Note: Nested tuples are not supported for typings. + * Max path depth typed is 5. + */ +declare function path( + path: [P1, P2, P3, P4, P5] & { 5?: void }, + obj: {[K1 in P1]: {[K5 in P5]: T}[][][]}): T; + +/** + * Retrieve the value at a given path. + * Note: Nested tuples are not supported for typings. + * Max path depth typed is 5. + */ +declare function path( + path: [P1, P2, P3, P4, P5] & { 5?: void }, obj: {[K1 in P1]: T[][][][]}): T; + +/** + * Retrieve the value at a given path. + * Note: Nested tuples are not supported for typings. + * Max path depth typed is 5. + */ +declare function path( + path: [P1, P2, P3, P4, P5] & { 5?: void }, + obj: {[K2 in P2]: {[K3 in P3]: {[K4 in P4]: {[K5 in P5]: T}}}}[]): T; + +/** + * Retrieve the value at a given path. + * Note: Nested tuples are not supported for typings. + * Max path depth typed is 5. + */ +declare function path( + path: [P1, P2, P3, P4, P5] & { 5?: void }, + obj: {[K2 in P2]: {[K3 in P3]: {[K4 in P4]: T[]}}}[]): T; + +/** + * Retrieve the value at a given path. + * Note: Nested tuples are not supported for typings. + * Max path depth typed is 5. + */ +declare function path( + path: [P1, P2, P3, P4, P5] & { 5?: void }, + obj: {[K2 in P2]: {[K3 in P3]: {[K5 in P5]: T}[]}}[]): T; + +/** + * Retrieve the value at a given path. + * Note: Nested tuples are not supported for typings. + * Max path depth typed is 5. + */ +declare function path( + path: [P1, P2, P3, P4, P5] & { 5?: void }, + obj: {[K2 in P2]: {[K3 in P3]: T[][]}}[]): T; + +/** + * Retrieve the value at a given path. + * Note: Nested tuples are not supported for typings. + * Max path depth typed is 5. + */ +declare function path( + path: [P1, P2, P3, P4, P5] & { 5?: void }, + obj: {[K2 in P2]: {[K4 in P4]: {[K5 in P5]: T}}[]}[]): T; + +/** + * Retrieve the value at a given path. + * Note: Nested tuples are not supported for typings. + * Max path depth typed is 5. + */ +declare function path( + path: [P1, P2, P3, P4, P5] & { 5?: void }, + obj: {[K2 in P2]: {[K4 in P4]: T[]}[]}[]): T; + +/** + * Retrieve the value at a given path. + * Note: Nested tuples are not supported for typings. + * Max path depth typed is 5. + */ +declare function path( + path: [P1, P2, P3, P4, P5] & { 5?: void }, + obj: {[K2 in P2]: {[K5 in P5]: T}[][]}[]): T; + +/** + * Retrieve the value at a given path. + * Note: Nested tuples are not supported for typings. + * Max path depth typed is 5. + */ +declare function path( + path: [P1, P2, P3, P4, P5] & { 5?: void }, obj: {[K2 in P2]: T[][][]}[]): T; + +/** + * Retrieve the value at a given path. + * Note: Nested tuples are not supported for typings. + * Max path depth typed is 5. + */ +declare function path( + path: [P1, P2, P3, P4, P5] & { 5?: void }, + obj: {[K3 in P3]: {[K4 in P4]: {[K5 in P5]: T}}}[][]): T; + +/** + * Retrieve the value at a given path. + * Note: Nested tuples are not supported for typings. + * Max path depth typed is 5. + */ +declare function path( + path: [P1, P2, P3, P4, P5] & { 5?: void }, + obj: {[K3 in P3]: {[K4 in P4]: T[]}}[][]): T; + +/** + * Retrieve the value at a given path. + * Note: Nested tuples are not supported for typings. + * Max path depth typed is 5. + */ +declare function path( + path: [P1, P2, P3, P4, P5] & { 5?: void }, + obj: {[K3 in P3]: {[K5 in P5]: T}[]}[][]): T; + +/** + * Retrieve the value at a given path. + * Note: Nested tuples are not supported for typings. + * Max path depth typed is 5. + */ +declare function path( + path: [P1, P2, P3, P4, P5] & { 5?: void }, obj: {[K3 in P3]: T[][]}[][]): T; + +/** + * Retrieve the value at a given path. + * Note: Nested tuples are not supported for typings. + * Max path depth typed is 5. + */ +declare function path( + path: [P1, P2, P3, P4, P5] & { 5?: void }, + obj: {[K4 in P4]: {[K5 in P5]: T}}[][][]): T; + +/** + * Retrieve the value at a given path. + * Note: Nested tuples are not supported for typings. + * Max path depth typed is 5. + */ +declare function path( + path: [P1, P2, P3, P4, P5] & { 5?: void }, obj: {[K4 in P4]: T[]}[][][]): T; + +/** + * Retrieve the value at a given path. + * Note: Nested tuples are not supported for typings. + * Max path depth typed is 5. + */ +declare function path( + path: [P1, P2, P3, P4, P5] & { 5?: void }, obj: {[K5 in P5]: T}[][][][]): T; + +/** + * Retrieve the value at a given path. + * Note: Nested tuples are not supported for typings. + * Max path depth typed is 5. + */ +declare function path( + path: [P1, P2, P3, P4, P5] & { 5?: void }, obj: T[][][][][]): T; + +// curried + +/** + * Retrieve the value at a given path. + * Note: Nested tuples are not supported for typings. + * Max path depth typed is 5. + */ +declare function path(path: [P1] & { 1?: void }): + (obj: {[K1 in P1]: T}) => T; + +/** + * Retrieve the value at a given path. + * Note: Nested tuples are not supported for typings. + * Max path depth typed is 5. + */ +declare function path(path: [P1] & { 1?: void }): + (obj: T[]) => T; + +/** + * Retrieve the value at a given path. + * Note: Nested tuples are not supported for typings. + * Max path depth typed is 5. + */ +declare function path( + path: [P1, P2] & { 2?: void }): + (obj: {[K1 in P1]: {[K2 in P2]: T}}) => T; + +/** + * Retrieve the value at a given path. + * Note: Nested tuples are not supported for typings. + * Max path depth typed is 5. + */ +declare function path( + path: [P1, P2] & { 2?: void }): (obj: {[K1 in P1]: T[]}) => T; + +/** + * Retrieve the value at a given path. + * Note: Nested tuples are not supported for typings. + * Max path depth typed is 5. + */ +declare function path( + path: [P1, P2] & { 2?: void }): (obj: {[K2 in P2]: T}[]) => T; + +/** + * Retrieve the value at a given path. + * Note: Nested tuples are not supported for typings. + * Max path depth typed is 5. + */ +declare function path( + path: [P1, P2] & { 2?: void }): (obj: T[][]) => T; + +/** + * Retrieve the value at a given path. + * Note: Nested tuples are not supported for typings. + * Max path depth typed is 5. + */ +declare function path(path: [P1, P2, P3] & { 3?: void }): + (obj: {[K1 in P1]: {[K2 in P2]: {[K3 in P3]: T}}}) => T; + +/** + * Retrieve the value at a given path. + * Note: Nested tuples are not supported for typings. + * Max path depth typed is 5. + */ +declare function path(path: [P1, P2, P3] & { 3?: void }): + (obj: {[K1 in P1]: {[K2 in P2]: T[]}}) => T; + +/** + * Retrieve the value at a given path. + * Note: Nested tuples are not supported for typings. + * Max path depth typed is 5. + */ +declare function path(path: [P1, P2, P3] & { 3?: void }): + (obj: {[K1 in P1]: {[K3 in P3]: T}[]}) => T; + +/** + * Retrieve the value at a given path. + * Note: Nested tuples are not supported for typings. + * Max path depth typed is 5. + */ +declare function path(path: [P1, P2, P3] & { 3?: void }): + (obj: {[K1 in P1]: T[][]}) => T; + +/** + * Retrieve the value at a given path. + * Note: Nested tuples are not supported for typings. + * Max path depth typed is 5. + */ +declare function path(path: [P1, P2, P3] & { 3?: void }): + (obj: {[K2 in P2]: {[K3 in P3]: T}}[]) => T; + +/** + * Retrieve the value at a given path. + * Note: Nested tuples are not supported for typings. + * Max path depth typed is 5. + */ +declare function path(path: [P1, P2, P3] & { 3?: void }): + (obj: {[K2 in P2]: T[]}[]) => T; + +/** + * Retrieve the value at a given path. + * Note: Nested tuples are not supported for typings. + * Max path depth typed is 5. + */ +declare function path(path: [P1, P2, P3] & { 3?: void }): + (obj: {[K3 in P3]: T}[][]) => T; + +/** + * Retrieve the value at a given path. + * Note: Nested tuples are not supported for typings. + * Max path depth typed is 5. + */ +declare function path(path: [P1, P2, P3] & { 3?: void }): + (obj: T[][][]) => T; + +/** + * Retrieve the value at a given path. + * Note: Nested tuples are not supported for typings. + * Max path depth typed is 5. + */ +declare function path( + path: [P1, P2, P3, P4] & { 4?: void }): + (obj: {[K1 in P1]: {[K2 in P2]: {[K3 in P3]: {[K4 in P4]: T}}}}) => T; + +/** + * Retrieve the value at a given path. + * Note: Nested tuples are not supported for typings. + * Max path depth typed is 5. + */ +declare function path( + path: [P1, P2, P3, P4] & { 4?: void }): + (obj: {[K1 in P1]: {[K2 in P2]: {[K3 in P3]: T[]}}}) => T; + +/** + * Retrieve the value at a given path. + * Note: Nested tuples are not supported for typings. + * Max path depth typed is 5. + */ +declare function path( + path: [P1, P2, P3, P4] & { 4?: void }): + (obj: {[K1 in P1]: {[K2 in P2]: {[K4 in P4]: T}[]}}) => T; + +/** + * Retrieve the value at a given path. + * Note: Nested tuples are not supported for typings. + * Max path depth typed is 5. + */ +declare function path( + path: [P1, P2, P3, P4] & { 4?: void }): + (obj: {[K1 in P1]: {[K2 in P2]: T[][]}}) => T; + +/** + * Retrieve the value at a given path. + * Note: Nested tuples are not supported for typings. + * Max path depth typed is 5. + */ +declare function path( + path: [P1, P2, P3, P4] & { 4?: void }): + (obj: {[K1 in P1]: {[K3 in P3]: {[K4 in P4]: T}}[]}) => T; + +/** + * Retrieve the value at a given path. + * Note: Nested tuples are not supported for typings. + * Max path depth typed is 5. + */ +declare function path( + path: [P1, P2, P3, P4] & { 4?: void }): + (obj: {[K1 in P1]: {[K3 in P3]: T[]}[]}) => T; + +/** + * Retrieve the value at a given path. + * Note: Nested tuples are not supported for typings. + * Max path depth typed is 5. + */ +declare function path( + path: [P1, P2, P3, P4] & { 4?: void }): + (obj: {[K1 in P1]: {[K4 in P4]: T}[][]}) => T; + +/** + * Retrieve the value at a given path. + * Note: Nested tuples are not supported for typings. + * Max path depth typed is 5. + */ +declare function path( + path: [P1, P2, P3, P4] & { 4?: void }): + (obj: {[K1 in P1]: T[][][]}) => T; + +/** + * Retrieve the value at a given path. + * Note: Nested tuples are not supported for typings. + * Max path depth typed is 5. + */ +declare function path( + path: [P1, P2, P3, P4] & { 4?: void }): + (obj: {[K2 in P2]: {[K3 in P3]: {[K4 in P4]: T}}}[]) => T; + +/** + * Retrieve the value at a given path. + * Note: Nested tuples are not supported for typings. + * Max path depth typed is 5. + */ +declare function path( + path: [P1, P2, P3, P4] & { 4?: void }): + (obj: {[K2 in P2]: {[K3 in P3]: T[]}}[]) => T; + +/** + * Retrieve the value at a given path. + * Note: Nested tuples are not supported for typings. + * Max path depth typed is 5. + */ +declare function path( + path: [P1, P2, P3, P4] & { 4?: void }): + (obj: {[K2 in P2]: {[K4 in P4]: T}[]}[]) => T; + +/** + * Retrieve the value at a given path. + * Note: Nested tuples are not supported for typings. + * Max path depth typed is 5. + */ +declare function path( + path: [P1, P2, P3, P4] & { 4?: void }): + (obj: {[K2 in P2]: T[][]}[]) => T; + +/** + * Retrieve the value at a given path. + * Note: Nested tuples are not supported for typings. + * Max path depth typed is 5. + */ +declare function path( + path: [P1, P2, P3, P4] & { 4?: void }): + (obj: {[K3 in P3]: {[K4 in P4]: T}}[][]) => T; + +/** + * Retrieve the value at a given path. + * Note: Nested tuples are not supported for typings. + * Max path depth typed is 5. + */ +declare function path( + path: [P1, P2, P3, P4] & { 4?: void }): + (obj: {[K3 in P3]: T[]}[][]) => T; + +/** + * Retrieve the value at a given path. + * Note: Nested tuples are not supported for typings. + * Max path depth typed is 5. + */ +declare function path( + path: [P1, P2, P3, P4] & { 4?: void }): + (obj: {[K4 in P4]: T}[][][]) => T; + +/** + * Retrieve the value at a given path. + * Note: Nested tuples are not supported for typings. + * Max path depth typed is 5. + */ +declare function path( + path: [P1, P2, P3, P4] & { 4?: void }): (obj: T[][][][]) => T; + +/** + * Retrieve the value at a given path. + * Note: Nested tuples are not supported for typings. + * Max path depth typed is 5. + */ +declare function path( + path: [P1, P2, P3, P4, P5] & { 5?: void }): + ( + obj: {[K1 in P1]: {[K2 in P2]: {[K3 in P3]: {[K4 in P4]: {[K5 in P5]: T}}}}}) => T; + +/** + * Retrieve the value at a given path. + * Note: Nested tuples are not supported for typings. + * Max path depth typed is 5. + */ +declare function path( + path: [P1, P2, P3, P4, P5] & { 5?: void }): + (obj: {[K1 in P1]: {[K2 in P2]: {[K3 in P3]: {[K4 in P4]: T[]}}}}) => T; + +/** + * Retrieve the value at a given path. + * Note: Nested tuples are not supported for typings. + * Max path depth typed is 5. + */ +declare function path( + path: [P1, P2, P3, P4, P5] & { 5?: void }): + (obj: {[K1 in P1]: {[K2 in P2]: {[K3 in P3]: {[K5 in P5]: T}[]}}}) => T; + +/** + * Retrieve the value at a given path. + * Note: Nested tuples are not supported for typings. + * Max path depth typed is 5. + */ +declare function path( + path: [P1, P2, P3, P4, P5] & { 5?: void }): + (obj: {[K1 in P1]: {[K2 in P2]: {[K3 in P3]: T[][]}}}) => T; + +/** + * Retrieve the value at a given path. + * Note: Nested tuples are not supported for typings. + * Max path depth typed is 5. + */ +declare function path( + path: [P1, P2, P3, P4, P5] & { 5?: void }): + (obj: {[K1 in P1]: {[K2 in P2]: {[K4 in P4]: {[K5 in P5]: T}}[]}}) => T; + +/** + * Retrieve the value at a given path. + * Note: Nested tuples are not supported for typings. + * Max path depth typed is 5. + */ +declare function path( + path: [P1, P2, P3, P4, P5] & { 5?: void }): + (obj: {[K1 in P1]: {[K2 in P2]: {[K4 in P4]: T[]}[]}}) => T; + +/** + * Retrieve the value at a given path. + * Note: Nested tuples are not supported for typings. + * Max path depth typed is 5. + */ +declare function path( + path: [P1, P2, P3, P4, P5] & { 5?: void }): + (obj: {[K1 in P1]: {[K2 in P2]: {[K5 in P5]: T}[][]}}) => T; + +/** + * Retrieve the value at a given path. + * Note: Nested tuples are not supported for typings. + * Max path depth typed is 5. + */ +declare function path( + path: [P1, P2, P3, P4, P5] & { 5?: void }): + (obj: {[K1 in P1]: {[K2 in P2]: T[][][]}}) => T; + +/** + * Retrieve the value at a given path. + * Note: Nested tuples are not supported for typings. + * Max path depth typed is 5. + */ +declare function path( + path: [P1, P2, P3, P4, P5] & { 5?: void }): + (obj: {[K1 in P1]: {[K3 in P3]: {[K4 in P4]: {[K5 in P5]: T}}}[]}) => T; + +/** + * Retrieve the value at a given path. + * Note: Nested tuples are not supported for typings. + * Max path depth typed is 5. + */ +declare function path( + path: [P1, P2, P3, P4, P5] & { 5?: void }): + (obj: {[K1 in P1]: {[K3 in P3]: {[K4 in P4]: T[]}}[]}) => T; + +/** + * Retrieve the value at a given path. + * Note: Nested tuples are not supported for typings. + * Max path depth typed is 5. + */ +declare function path( + path: [P1, P2, P3, P4, P5] & { 5?: void }): + (obj: {[K1 in P1]: {[K3 in P3]: {[K5 in P5]: T}[]}[]}) => T; + +/** + * Retrieve the value at a given path. + * Note: Nested tuples are not supported for typings. + * Max path depth typed is 5. + */ +declare function path( + path: [P1, P2, P3, P4, P5] & { 5?: void }): + (obj: {[K1 in P1]: {[K3 in P3]: T[][]}[]}) => T; + +/** + * Retrieve the value at a given path. + * Note: Nested tuples are not supported for typings. + * Max path depth typed is 5. + */ +declare function path( + path: [P1, P2, P3, P4, P5] & { 5?: void }): + (obj: {[K1 in P1]: {[K4 in P4]: {[K5 in P5]: T}}[][]}) => T; + +/** + * Retrieve the value at a given path. + * Note: Nested tuples are not supported for typings. + * Max path depth typed is 5. + */ +declare function path( + path: [P1, P2, P3, P4, P5] & { 5?: void }): + (obj: {[K1 in P1]: {[K4 in P4]: T[]}[][]}) => T; + +/** + * Retrieve the value at a given path. + * Note: Nested tuples are not supported for typings. + * Max path depth typed is 5. + */ +declare function path( + path: [P1, P2, P3, P4, P5] & { 5?: void }): + (obj: {[K1 in P1]: {[K5 in P5]: T}[][][]}) => T; + +/** + * Retrieve the value at a given path. + * Note: Nested tuples are not supported for typings. + * Max path depth typed is 5. + */ +declare function path( + path: [P1, P2, P3, P4, P5] & { 5?: void }): + (obj: {[K1 in P1]: T[][][][]}) => T; + +/** + * Retrieve the value at a given path. + * Note: Nested tuples are not supported for typings. + * Max path depth typed is 5. + */ +declare function path( + path: [P1, P2, P3, P4, P5] & { 5?: void }): + (obj: {[K2 in P2]: {[K3 in P3]: {[K4 in P4]: {[K5 in P5]: T}}}}[]) => T; + +/** + * Retrieve the value at a given path. + * Note: Nested tuples are not supported for typings. + * Max path depth typed is 5. + */ +declare function path( + path: [P1, P2, P3, P4, P5] & { 5?: void }): + (obj: {[K2 in P2]: {[K3 in P3]: {[K4 in P4]: T[]}}}[]) => T; + +/** + * Retrieve the value at a given path. + * Note: Nested tuples are not supported for typings. + * Max path depth typed is 5. + */ +declare function path( + path: [P1, P2, P3, P4, P5] & { 5?: void }): + (obj: {[K2 in P2]: {[K3 in P3]: {[K5 in P5]: T}[]}}[]) => T; + +/** + * Retrieve the value at a given path. + * Note: Nested tuples are not supported for typings. + * Max path depth typed is 5. + */ +declare function path( + path: [P1, P2, P3, P4, P5] & { 5?: void }): + (obj: {[K2 in P2]: {[K3 in P3]: T[][]}}[]) => T; + +/** + * Retrieve the value at a given path. + * Note: Nested tuples are not supported for typings. + * Max path depth typed is 5. + */ +declare function path( + path: [P1, P2, P3, P4, P5] & { 5?: void }): + (obj: {[K2 in P2]: {[K4 in P4]: {[K5 in P5]: T}}[]}[]) => T; + +/** + * Retrieve the value at a given path. + * Note: Nested tuples are not supported for typings. + * Max path depth typed is 5. + */ +declare function path( + path: [P1, P2, P3, P4, P5] & { 5?: void }): + (obj: {[K2 in P2]: {[K4 in P4]: T[]}[]}[]) => T; + +/** + * Retrieve the value at a given path. + * Note: Nested tuples are not supported for typings. + * Max path depth typed is 5. + */ +declare function path( + path: [P1, P2, P3, P4, P5] & { 5?: void }): + (obj: {[K2 in P2]: {[K5 in P5]: T}[][]}[]) => T; + +/** + * Retrieve the value at a given path. + * Note: Nested tuples are not supported for typings. + * Max path depth typed is 5. + */ +declare function path( + path: [P1, P2, P3, P4, P5] & { 5?: void }): + (obj: {[K2 in P2]: T[][][]}[]) => T; + +/** + * Retrieve the value at a given path. + * Note: Nested tuples are not supported for typings. + * Max path depth typed is 5. + */ +declare function path( + path: [P1, P2, P3, P4, P5] & { 5?: void }): + (obj: {[K3 in P3]: {[K4 in P4]: {[K5 in P5]: T}}}[][]) => T; + +/** + * Retrieve the value at a given path. + * Note: Nested tuples are not supported for typings. + * Max path depth typed is 5. + */ +declare function path( + path: [P1, P2, P3, P4, P5] & { 5?: void }): + (obj: {[K3 in P3]: {[K4 in P4]: T[]}}[][]) => T; + +/** + * Retrieve the value at a given path. + * Note: Nested tuples are not supported for typings. + * Max path depth typed is 5. + */ +declare function path( + path: [P1, P2, P3, P4, P5] & { 5?: void }): + (obj: {[K3 in P3]: {[K5 in P5]: T}[]}[][]) => T; + +/** + * Retrieve the value at a given path. + * Note: Nested tuples are not supported for typings. + * Max path depth typed is 5. + */ +declare function path( + path: [P1, P2, P3, P4, P5] & { 5?: void }): + (obj: {[K3 in P3]: T[][]}[][]) => T; + +/** + * Retrieve the value at a given path. + * Note: Nested tuples are not supported for typings. + * Max path depth typed is 5. + */ +declare function path( + path: [P1, P2, P3, P4, P5] & { 5?: void }): + (obj: {[K4 in P4]: {[K5 in P5]: T}}[][][]) => T; + +/** + * Retrieve the value at a given path. + * Note: Nested tuples are not supported for typings. + * Max path depth typed is 5. + */ +declare function path( + path: [P1, P2, P3, P4, P5] & { 5?: void }): + (obj: {[K4 in P4]: T[]}[][][]) => T; + +/** + * Retrieve the value at a given path. + * Note: Nested tuples are not supported for typings. + * Max path depth typed is 5. + */ +declare function path( + path: [P1, P2, P3, P4, P5] & { 5?: void }): + (obj: {[K5 in P5]: T}[][][][]) => T; + +/** + * Retrieve the value at a given path. + * Note: Nested tuples are not supported for typings. + * Max path depth typed is 5. + */ +declare function path( + path: [P1, P2, P3, P4, P5] & { 5?: void }): (obj: T[][][][][]) => T; + +export = path diff --git a/src/prop.d.ts b/src/prop.d.ts new file mode 100644 index 0000000..0625d2f --- /dev/null +++ b/src/prop.d.ts @@ -0,0 +1,175 @@ +/** + * This is auto generated source. + */ + +import { Struct, List, Prop } from '../interfaces'; + + +/** + * Acts as multiple `prop`: array of keys in, array of values out. Preserves order. + */ +declare function props( + ps: [P1, P2, P3, P4, P5, P6, P7, P8], obj: O): + [O[P1], O[P2], O[P3], O[P4], O[P5], O[P6], O[P7], O[P8]]; + + +/** + * Acts as multiple `prop`: array of keys in, array of values out. Preserves order. + */ +declare function props( + ps: [P1, P2, P3, P4, P5, P6, P7], obj: O): + [O[P1], O[P2], O[P3], O[P4], O[P5], O[P6], O[P7]]; + + +/** + * Acts as multiple `prop`: array of keys in, array of values out. Preserves order. + */ +declare function props( + ps: [P1, P2, P3, P4, P5, P6], obj: O): + [O[P1], O[P2], O[P3], O[P4], O[P5], O[P6]]; + + +/** + * Acts as multiple `prop`: array of keys in, array of values out. Preserves order. + */ +declare function props(ps: [P1, P2, P3, P4, P5], + obj: O): [O[P1], O[P2], O[P3], O[P4], O[P5]]; + + +/** + * Acts as multiple `prop`: array of keys in, array of values out. Preserves order. + */ +declare function props( + ps: [P1, P2, P3, P4], obj: O): [O[P1], O[P2], O[P3], O[P4]]; + + +/** + * Acts as multiple `prop`: array of keys in, array of values out. Preserves order. + */ +declare function props(ps: [P1, P2, P3], obj: O): + [O[P1], O[P2], O[P3]]; + + +/** + * Acts as multiple `prop`: array of keys in, array of values out. Preserves order. + */ +declare function props( + ps: [P1, P2], obj: O): [O[P1], O[P2]]; + + +/** + * Acts as multiple `prop`: array of keys in, array of values out. Preserves order. + */ +declare function props(ps: [P1], obj: O): [O[P1]]; + +// curried + + +/** + * Acts as multiple `prop`: array of keys in, array of values out. Preserves order. + */ +declare function props( + ps: [P1, P2, P3, P4, P5, P6, P7, P8]): + (obj: O) => + [O[P1], O[P2], O[P3], O[P4], O[P5], O[P6], O[P7], O[P8]]; + + +/** + * Acts as multiple `prop`: array of keys in, array of values out. Preserves order. + */ +declare function props(ps: [P1, P2, P3, P4, P5, P6, P7]): + (obj: O) => + [O[P1], O[P2], O[P3], O[P4], O[P5], O[P6], O[P7]]; + + +/** + * Acts as multiple `prop`: array of keys in, array of values out. Preserves order. + */ +declare function props( + ps: [P1, P2, P3, P4, P5, P6]): + (obj: O) => + [O[P1], O[P2], O[P3], O[P4], O[P5], O[P6]]; + + +/** + * Acts as multiple `prop`: array of keys in, array of values out. Preserves order. + */ +declare function props( + ps: [P1, P2, P3, P4, P5]): + (obj: O) => + [O[P1], O[P2], O[P3], O[P4], O[P5]]; + + +/** + * Acts as multiple `prop`: array of keys in, array of values out. Preserves order. + */ +declare function props(ps: [P1, P2, P3, P4]): + (obj: O) => + [O[P1], O[P2], O[P3], O[P4]]; + + +/** + * Acts as multiple `prop`: array of keys in, array of values out. Preserves order. + */ +declare function props(ps: [P1, P2, P3]): + (obj: O) => [O[P1], O[P2], O[P3]]; + + +/** + * Acts as multiple `prop`: array of keys in, array of values out. Preserves order. + */ +declare function props(ps: [P1, P2]): + (obj: O) => [O[P1], O[P2]]; + + +/** + * Acts as multiple `prop`: array of keys in, array of values out. Preserves order. + */ +declare function props(ps: [P1]): + (obj: O) => [O[P1]]; + + +/** + * Acts as multiple `prop`: array of keys in, array of values out. Preserves order. + */ +declare function props(ps: List, obj: List): T[]; + +// curried + + +/** + * Acts as multiple `prop`: array of keys in, array of values out. Preserves order. + */ +declare function props(ps: List): (obj: List) => T[]; + +export = prop diff --git a/src/props.d.ts b/src/props.d.ts index cd78207..341fdbb 100644 --- a/src/props.d.ts +++ b/src/props.d.ts @@ -1,260 +1,157 @@ -import { Struct, List, Prop } from '../interfaces'; +/** + * This is auto generated source. + */ +import { Struct, List, Prop } from '../interfaces'; /** * Acts as multiple `prop`: array of keys in, array of values out. Preserves order. */ -declare function props< -P1 extends string & keyof O, -P2 extends string & keyof O, -P3 extends string & keyof O, -P4 extends string & keyof O, -P5 extends string & keyof O, -P6 extends string & keyof O, -P7 extends string & keyof O, -P8 extends string & keyof O, -O extends {[K in P1 | P2 | P3 | P4 | P5 | P6 | P7 | P8]: any}> -(ps: [P1, P2, P3, P4, P5, P6, P7, P8], obj: O): -[O[P1], O[P2], O[P3], O[P4], O[P5], O[P6], O[P7], O[P8]] - +declare function props( + ps: [P1, P2, P3, P4, P5, P6, P7, P8], obj: O): + [O[P1], O[P2], O[P3], O[P4], O[P5], O[P6], O[P7], O[P8]]; /** * Acts as multiple `prop`: array of keys in, array of values out. Preserves order. */ -declare function props< -P1 extends string & keyof O, -P2 extends string & keyof O, -P3 extends string & keyof O, -P4 extends string & keyof O, -P5 extends string & keyof O, -P6 extends string & keyof O, -P7 extends string & keyof O, -O extends {[K in P1 | P2 | P3 | P4 | P5 | P6 | P7]: any}> -(ps: [P1, P2, P3, P4, P5, P6, P7], obj: O): -[O[P1], O[P2], O[P3], O[P4], O[P5], O[P6], O[P7]] - +declare function props( + ps: [P1, P2, P3, P4, P5, P6, P7], obj: O): + [O[P1], O[P2], O[P3], O[P4], O[P5], O[P6], O[P7]]; /** * Acts as multiple `prop`: array of keys in, array of values out. Preserves order. */ -declare function props< -P1 extends string & keyof O, -P2 extends string & keyof O, -P3 extends string & keyof O, -P4 extends string & keyof O, -P5 extends string & keyof O, -P6 extends string & keyof O, -O extends {[K in P1 | P2 | P3 | P4 | P5 | P6]: any}> -(ps: [P1, P2, P3, P4, P5, P6], obj: O): -[O[P1], O[P2], O[P3], O[P4], O[P5], O[P6]] - +declare function props( + ps: [P1, P2, P3, P4, P5, P6], obj: O): + [O[P1], O[P2], O[P3], O[P4], O[P5], O[P6]]; /** * Acts as multiple `prop`: array of keys in, array of values out. Preserves order. */ -declare function props< -P1 extends string & keyof O, -P2 extends string & keyof O, -P3 extends string & keyof O, -P4 extends string & keyof O, -P5 extends string & keyof O, -O extends {[K in P1 | P2 | P3 | P4 | P5]: any}> -(ps: [P1, P2, P3, P4, P5], obj: O): -[O[P1], O[P2], O[P3], O[P4], O[P5]] - +declare function props(ps: [P1, P2, P3, P4, P5], + obj: O): [O[P1], O[P2], O[P3], O[P4], O[P5]]; /** * Acts as multiple `prop`: array of keys in, array of values out. Preserves order. */ -declare function props< -P1 extends string & keyof O, -P2 extends string & keyof O, -P3 extends string & keyof O, -P4 extends string & keyof O, -O extends {[K in P1 | P2 | P3 | P4]: any}> -(ps: [P1, P2, P3, P4], obj: O): -[O[P1], O[P2], O[P3], O[P4]] - +declare function props( + ps: [P1, P2, P3, P4], obj: O): [O[P1], O[P2], O[P3], O[P4]]; /** * Acts as multiple `prop`: array of keys in, array of values out. Preserves order. */ -declare function props< -P1 extends string & keyof O, -P2 extends string & keyof O, -P3 extends string & keyof O, -O extends {[K in P1 | P2 | P3]: any}> -(ps: [P1, P2, P3], obj: O): -[O[P1], O[P2], O[P3]] - +declare function props(ps: [P1, P2, P3], obj: O): + [O[P1], O[P2], O[P3]]; /** * Acts as multiple `prop`: array of keys in, array of values out. Preserves order. */ -declare function props< -P1 extends string & keyof O, -P2 extends string & keyof O, -O extends {[K in P1 | P2]: any}> -(ps: [P1, P2], obj: O): -[O[P1], O[P2]] - +declare function props( + ps: [P1, P2], obj: O): [O[P1], O[P2]]; /** * Acts as multiple `prop`: array of keys in, array of values out. Preserves order. */ -declare function props< -P1 extends string & keyof O, -O extends {[K in P1]: any}> -(ps: [P1], obj: O): -[O[P1]] +declare function props(ps: [P1], obj: O): [O[P1]]; // curried - /** * Acts as multiple `prop`: array of keys in, array of values out. Preserves order. */ -declare function props< -P1 extends string, -P2 extends string, -P3 extends string, -P4 extends string, -P5 extends string, -P6 extends string, -P7 extends string, -P8 extends string> -(ps: [P1, P2, P3, P4, P5, P6, P7, P8]): -< -O extends {[K in P1 | P2 | P3 | P4 | P5 | P6 | P7 | P8]: any}> -(obj: O) => -[O[P1], O[P2], O[P3], O[P4], O[P5], O[P6], O[P7], O[P8]] - +declare function props( + ps: [P1, P2, P3, P4, P5, P6, P7, P8]): + (obj: O) => + [O[P1], O[P2], O[P3], O[P4], O[P5], O[P6], O[P7], O[P8]]; /** * Acts as multiple `prop`: array of keys in, array of values out. Preserves order. */ -declare function props< -P1 extends string, -P2 extends string, -P3 extends string, -P4 extends string, -P5 extends string, -P6 extends string, -P7 extends string> -(ps: [P1, P2, P3, P4, P5, P6, P7]): -< -O extends {[K in P1 | P2 | P3 | P4 | P5 | P6 | P7]: any}> -(obj: O) => -[O[P1], O[P2], O[P3], O[P4], O[P5], O[P6], O[P7]] - +declare function props(ps: [P1, P2, P3, P4, P5, P6, P7]): + (obj: O) => + [O[P1], O[P2], O[P3], O[P4], O[P5], O[P6], O[P7]]; /** * Acts as multiple `prop`: array of keys in, array of values out. Preserves order. */ -declare function props< -P1 extends string, -P2 extends string, -P3 extends string, -P4 extends string, -P5 extends string, -P6 extends string> -(ps: [P1, P2, P3, P4, P5, P6]): -< -O extends {[K in P1 | P2 | P3 | P4 | P5 | P6]: any}> -(obj: O) => -[O[P1], O[P2], O[P3], O[P4], O[P5], O[P6]] - +declare function props( + ps: [P1, P2, P3, P4, P5, P6]): + (obj: O) => + [O[P1], O[P2], O[P3], O[P4], O[P5], O[P6]]; /** * Acts as multiple `prop`: array of keys in, array of values out. Preserves order. */ -declare function props< -P1 extends string, -P2 extends string, -P3 extends string, -P4 extends string, -P5 extends string> -(ps: [P1, P2, P3, P4, P5]): -< -O extends {[K in P1 | P2 | P3 | P4 | P5]: any}> -(obj: O) => -[O[P1], O[P2], O[P3], O[P4], O[P5]] - +declare function props( + ps: [P1, P2, P3, P4, P5]): + (obj: O) => + [O[P1], O[P2], O[P3], O[P4], O[P5]]; /** * Acts as multiple `prop`: array of keys in, array of values out. Preserves order. */ -declare function props< -P1 extends string, -P2 extends string, -P3 extends string, -P4 extends string> -(ps: [P1, P2, P3, P4]): -< -O extends {[K in P1 | P2 | P3 | P4]: any}> -(obj: O) => -[O[P1], O[P2], O[P3], O[P4]] - +declare function props(ps: [P1, P2, P3, P4]): + (obj: O) => + [O[P1], O[P2], O[P3], O[P4]]; /** * Acts as multiple `prop`: array of keys in, array of values out. Preserves order. */ -declare function props< -P1 extends string, -P2 extends string, -P3 extends string> -(ps: [P1, P2, P3]): -< -O extends {[K in P1 | P2 | P3]: any}> -(obj: O) => -[O[P1], O[P2], O[P3]] - +declare function props(ps: [P1, P2, P3]): + (obj: O) => [O[P1], O[P2], O[P3]]; /** * Acts as multiple `prop`: array of keys in, array of values out. Preserves order. */ -declare function props< -P1 extends string, -P2 extends string> -(ps: [P1, P2]): -< -O extends {[K in P1 | P2]: any}> -(obj: O) => -[O[P1], O[P2]] - +declare function props(ps: [P1, P2]): + (obj: O) => [O[P1], O[P2]]; /** * Acts as multiple `prop`: array of keys in, array of values out. Preserves order. */ -declare function props< -P1 extends string> -(ps: [P1]): -< -O extends {[K in P1]: any}> -(obj: O) => -[O[P1]] - +declare function props(ps: [P1]): + (obj: O) => [O[P1]]; /** * Acts as multiple `prop`: array of keys in, array of values out. Preserves order. */ -declare function props< -T> -(ps: List, obj: List): -T[] +declare function props(ps: List, obj: List): T[]; // curried - /** * Acts as multiple `prop`: array of keys in, array of values out. Preserves order. */ -declare function props< -T> -(ps: List): -< -T> -(obj: List) => -T[] +declare function props(ps: List): (obj: List) => T[]; export = props diff --git a/test/assocPath.ts b/test/assocPath.ts new file mode 100644 index 0000000..74994ce --- /dev/null +++ b/test/assocPath.ts @@ -0,0 +1,29 @@ +import assocPath = require('ramda/src/assocPath'); +import { equal } from 'assert'; +import { itFailsType, typeFail } from '../type-fail'; + +type nestedX = { x: number }; + +const obj = { a: { b: { c: 0 } } }; +const objWithList = { a: [ { c: 0 }, { c: 1 } ] }; + +describe('assocPath', () => { + it('path with two props', () => { + const value: number = 42; + const res = assocPath(['a', 'b'], { c: value }, obj).a.b.c; + equal(res, value); + }); + + it('object with list inside', () => { + const value: number = 42; + const res = assocPath(['a', 1], { c: value }, objWithList).a[1].c; + equal(res, value); + }); + + it('ts error: incorrect type for value not allowed', () => { + typeFail(` + import assocPath = require('ramda/src/assocPath'); + assocPath(['a', 'b'], '42', {a: {b: 0}}) + `, /incompatible with index signature/); + }); +}); diff --git a/test/lensPath.ts b/test/lensPath.ts new file mode 100644 index 0000000..564fabd --- /dev/null +++ b/test/lensPath.ts @@ -0,0 +1,33 @@ +// import lensPath = require('ramda/src/lensPath'); +// import { equal } from 'assert'; +// import { typeFail } from '../type-fail'; + +// interface Obj { +// p1: number; +// p2: string; +// p3: boolean; +// p4: string; +// } + +// const obj: Obj = { +// p1: 33, +// p2: 'Jake', +// p3: true, +// p4: 'some' +// }; + +// describe('lensPath', () => { +// it('one prop', () => { +// const res = lensPath(['p2'], obj); +// equal(res[0], obj.p2); +// }); + +// //var xHeadYLens = lensPath(['x', 0, 'y']); + +// // it('ts error: unkonwn props not allowed', () => { +// // typeFail(` +// // import props = require('ramda/src/props'); +// // props(['p1', 'other'], {p1: 1}) +// // `, /not assignable/); +// // }); +// }); diff --git a/test/path.ts b/test/path.ts new file mode 100644 index 0000000..aa0b079 --- /dev/null +++ b/test/path.ts @@ -0,0 +1,53 @@ +import path = require('ramda/src/path'); +import { nth, prop } from 'ramda'; +import { equal } from 'assert'; +import { itFailsType, typeFail } from '../type-fail'; + +type nestedX = { x: number }; + + +const obj = { a: { b: { c: 42 } } }; +const objWithList = { a: [{ c: 42 }, { c: 43 }] }; +const objWithNestedList = { a: [{ c: [{ d: 42 }] }, { c: [{ d: 43 }] }] }; +const list = [{ c: 42 }, { c: 43 }]; +const tuple = [{ c: 42 }, { d: 43 }]; + +describe('path', () => { + it('path tree deep', () => { + const value: number = 42; + const c = 'c' as string; + const res = path(['a', 'b', c], obj); + equal(res, value); + }); + + it('curried: path tree deep', () => { + const value: number = 42; + const res = path(['a', 'b', 'c'])(obj); + equal(res, value); + }); + + it('object with list inside', () => { + const value: number = 43; + const res = path(['a', 1, 'c'], objWithList); + equal(res, value); + }); + + it('list with object inside', () => { + const value: number = 43; + const res = path([ 1, 'c'], list); + equal(res, value); + }); + + it('object with list inside', () => { + const value: number = 43; + const res = path(['a', 1, 'c', 0, 'd'], objWithNestedList); + equal(res, value); + }); + + // it.skip('ts error: incorrect type for value not allowed', () => { + // typeFail(` + // import assocPath = require('ramda/src/assocPath'); + // assocPath(['a', 'b'], '42', {a: {b: 0}}) + // `, /incompatible with index signature/); + // }); +}); diff --git a/tpl/assocPath.ts b/tpl/assocPath.ts new file mode 100644 index 0000000..9f05651 --- /dev/null +++ b/tpl/assocPath.ts @@ -0,0 +1,68 @@ +import { + importInterfaces, + declareFunction, + arrowFunction, + getParamsNums +} from '../gen'; + +const propsParams = getParamsNums(8).reverse() + .map(nums => nums.map(n => 'P' + n)); + +const docs = ` +/** + * Makes a shallow clone of an object, setting or overriding + * the nodes required to create the given path, and placing the specific + * value at the tail end of that path. + * + * Note: Tuples are not supported for typings. + */ +`; + +const makeNestedObjPath = (props: string[], init: string) => + props.concat([]).reverse().reduce((prev, prop, index) => + `{[K${props.length - index} in ${prop}]: ${prev}}` + , init) + +module.exports = [ + importInterfaces(['Path', 'List', 'Prop']), + ...propsParams.map((props) => + docs + + declareFunction('assocPath', + props.map(Pn => `${Pn} extends string | number`) + //.concat(props.map(Pn => `${Pn.replace(/P/, 'N')} extends number`)) + .concat([ + `T`, + //'O extends ' + makeNestedObjPath(props.map(Pn => `${Pn} & ${Pn.replace(/P/, 'N')}`) , 'T') + 'O extends ' + makeNestedObjPath(props, 'T') + ]), + [ + { path: `[${props.join(', ')}]` }, + { value: 'T' }, + { + obj: 'O' + } + ], + `O` + )), + `// curried`, + ...propsParams.map((props) => + docs + + declareFunction('assocPath', + props.map(Pn => `${Pn} extends string`), + [ + { ps: `[${props.join(', ')}]` } + ], + arrowFunction( + [`O extends {[K in ${props.join(' | ')}]: any}`], + [{ obj: 'O' }], + `[${props.map(Pn => 'O[' + Pn + ']').join(', ')}]` + ) + )), + docs + + declareFunction('props', ['T'], [{ ps: 'List' }, { obj: 'List' }], 'T[]'), + `// curried`, + docs + + declareFunction('props', ['T'], [{ ps: 'List' }], + arrowFunction(['T'], [{ obj: 'List' }], 'T[]') + ) +]; diff --git a/tpl/lensPath.ts b/tpl/lensPath.ts new file mode 100644 index 0000000..58de024 --- /dev/null +++ b/tpl/lensPath.ts @@ -0,0 +1,53 @@ +import { + importInterfaces, + declareFunction, + arrowFunction, + getParamsNums +} from '../gen'; + +const propsParams = getParamsNums(8).reverse() + .map(nums => nums.map(n => 'P' + n)); + +const docs = ` +/** + * Returns a lens whose focus is the specified path. + * See also view, set, over. + * Note: Tuples are not supported for typings1. + */ +`; + +module.exports = [ + importInterfaces(['Path', 'List', 'Prop']), + ...propsParams.map((props) => + docs + + declareFunction('lensPath', + props.map(Pn => `${Pn} extends string & keyof O`) + .concat(`O extends {[K in ${props.join(' | ')}]: any}`), + [ + { ps: `[${props.join(', ')}]` }, + { obj: 'O' } + ], + `[${props.map(Pn => 'O[' + Pn + ']').join(', ')}]` + )), + `// curried`, + ...propsParams.map((props) => + docs + + declareFunction('lensPath', + props.map(Pn => `${Pn} extends string`), + [ + { ps: `[${props.join(', ')}]` } + ], + arrowFunction( + [`O extends {[K in ${props.join(' | ')}]: any}`], + [{ obj: 'O' }], + `[${props.map(Pn => 'O[' + Pn + ']').join(', ')}]` + ) + )), + docs + + declareFunction('props', ['T'], [{ ps: 'List' }, { obj: 'List' }], 'T[]'), + `// curried`, + docs + + declareFunction('props', ['T'], [{ ps: 'List' }], + arrowFunction(['T'], [{ obj: 'List' }], 'T[]') + ) +]; diff --git a/tpl/path.ts b/tpl/path.ts new file mode 100644 index 0000000..115e97d --- /dev/null +++ b/tpl/path.ts @@ -0,0 +1,49 @@ +import { + importInterfaces, + declareFunction, + arrowFunction, + makeParamsStringNumberCombination, + makeNestedObjPath, + makeTuple, docs +} from '../gen'; + +const maxPathDepth = 5; + +const propsParams = + makeParamsStringNumberCombination(maxPathDepth); + +const desc = `Retrieve the value at a given path. +Note: Nested tuples are not supported for typings. +Max path depth typed is ${maxPathDepth}.`; + +module.exports = [ + ...propsParams.map((props) => + docs(desc) + + declareFunction('path', + props.map(n => `P${n} extends ${typeof n}`) + .concat(`T`), + [ + { path: makeTuple(props, props.length) }, + { + obj: makeNestedObjPath(props, 'T') + } + ], + `T` + )), + `// curried`, + ...propsParams.map((props) => + docs(desc) + + declareFunction('path', + props.map(n => `P${n} extends ${typeof n}`) + .concat(`T`), + [ + { path: makeTuple(props, props.length) } + ], + arrowFunction([`T`], [ + { + obj: makeNestedObjPath(props, 'T') + } + ], 'T' + ) + )) +]; diff --git a/tpl/prop.ts b/tpl/prop.ts new file mode 100644 index 0000000..be89166 --- /dev/null +++ b/tpl/prop.ts @@ -0,0 +1,51 @@ +import { + importInterfaces, + declareFunction, + arrowFunction, + getParamsNums +} from '../gen'; + +const propsParams = getParamsNums(8).reverse() + .map(nums => nums.map(n => 'P' + n)); + +const docs = ` +/** + * Acts as multiple \`prop\`: array of keys in, array of values out. Preserves order. + */ +`; + +module.exports = [ + importInterfaces(['Struct', 'List', 'Prop']), + ...propsParams.map((props) => + docs + + declareFunction('props', + props.map(Pn => `${Pn} extends string & keyof O`) + .concat(`O extends {[K in ${props.join(' | ')}]: any}`), + [ + { ps: `[${props.join(', ')}]` }, + { obj: 'O' } + ], + `[${props.map(Pn => 'O[' + Pn + ']').join(', ')}]` + )), + `// curried`, + ...propsParams.map((props) => + docs + + declareFunction('props', + props.map(Pn => `${Pn} extends string`), + [ + { ps: `[${props.join(', ')}]` } + ], + arrowFunction( + [`O extends {[K in ${props.join(' | ')}]: any}`], + [{ obj: 'O' }], + `[${props.map(Pn => 'O[' + Pn + ']').join(', ')}]` + ) + )), + docs + + declareFunction('props', ['T'], [{ ps: 'List' }, { obj: 'List' }], 'T[]'), + `// curried`, + docs + + declareFunction('props', ['T'], [{ ps: 'List' }], + arrowFunction(['T'], [{ obj: 'List' }], 'T[]') + ) +]; diff --git a/tpl/props.ts b/tpl/props.ts index be89166..9295766 100644 --- a/tpl/props.ts +++ b/tpl/props.ts @@ -2,22 +2,19 @@ import { importInterfaces, declareFunction, arrowFunction, - getParamsNums + getParamsNums, + docs } from '../gen'; const propsParams = getParamsNums(8).reverse() .map(nums => nums.map(n => 'P' + n)); -const docs = ` -/** - * Acts as multiple \`prop\`: array of keys in, array of values out. Preserves order. - */ -`; +const desc = 'Acts as multiple \`prop\`: array of keys in, array of values out. Preserves order.'; module.exports = [ importInterfaces(['Struct', 'List', 'Prop']), ...propsParams.map((props) => - docs + + docs(desc) + declareFunction('props', props.map(Pn => `${Pn} extends string & keyof O`) .concat(`O extends {[K in ${props.join(' | ')}]: any}`), @@ -29,7 +26,7 @@ module.exports = [ )), `// curried`, ...propsParams.map((props) => - docs + + docs(desc) + declareFunction('props', props.map(Pn => `${Pn} extends string`), [ @@ -41,10 +38,10 @@ module.exports = [ `[${props.map(Pn => 'O[' + Pn + ']').join(', ')}]` ) )), - docs + + docs(desc) + declareFunction('props', ['T'], [{ ps: 'List' }, { obj: 'List' }], 'T[]'), `// curried`, - docs + + docs(desc) + declareFunction('props', ['T'], [{ ps: 'List' }], arrowFunction(['T'], [{ obj: 'List' }], 'T[]') ) From 16e12f9d32f96341032b56bd92124789f906ad52 Mon Sep 17 00:00:00 2001 From: whitecolor Date: Wed, 26 Apr 2017 15:24:53 +0500 Subject: [PATCH 16/19] move head --- src/head.d.ts | 18 ++++++++++++++++++ test/head.ts | 19 +++++++++++++++++++ 2 files changed, 37 insertions(+) create mode 100644 src/head.d.ts create mode 100644 test/head.ts diff --git a/src/head.d.ts b/src/head.d.ts new file mode 100644 index 0000000..3b547fa --- /dev/null +++ b/src/head.d.ts @@ -0,0 +1,18 @@ + +interface Head { + /** + * Returns the first element in a list. + * In some libraries this function is named `first`. + * Takes list. + */ + (list: T[]): T; + /** + * Returns the first element in a list. + * In some libraries this function is named `first`. + * Takes tuple. + */ + (list: [T0, T1]): T0; +} + +declare const head: Head +export = head diff --git a/test/head.ts b/test/head.ts new file mode 100644 index 0000000..d002655 --- /dev/null +++ b/test/head.ts @@ -0,0 +1,19 @@ +import head = require('ramda/src/head'); +import { equal } from 'assert'; +import { typeFail } from '../type-fail'; + +const list = [1, 2, 3, 4, 5]; + +const tuple = ['1', 2, 3]; + +describe('flatten', () => { + it('takes list', () => { + const res = head(list); + equal(res, list[0]); + }); + + it('takes list', () => { + const res = head(tuple); + equal(res, list[0]); + }); +}); From 2d2d481ab3ae627291e7dc9f1e78376247aa31ee Mon Sep 17 00:00:00 2001 From: whitecolor Date: Wed, 26 Apr 2017 16:21:29 +0500 Subject: [PATCH 17/19] assocPath flatten --- index.d.ts | 44 ++---- src/assocPath.d.ts | 365 ++++++++++++++++----------------------------- src/flatten.d.ts | 2 +- 3 files changed, 137 insertions(+), 274 deletions(-) diff --git a/index.d.ts b/index.d.ts index 33a431f..8ff0cd3 100644 --- a/index.d.ts +++ b/index.d.ts @@ -7,10 +7,14 @@ import __ from './src/__' import add from './src/add' import addIndex = require('./src/addIndex') import curry = require('./src/curry') +import flatten = require('./src/flatten') +import head = require('./src/head') import merge = require('./src/merge') import props = require('./src/props') import path = require('./src/path') -import flatten = require('./src/flatten') + +import assocPath = require('./src/assocPath') +//import mapObjIndexed = require('./src/mapObjIndexed') import { List, Struct, Obj, NestedObj, Pred, Variadic, Functor, Type, Transformer, Prop, Path, @@ -201,29 +205,8 @@ declare namespace R { }; }; - - /** - * Makes a shallow clone of an object, setting or overriding the nodes required to create the given path, and - * placing the specific value at the tail end of that path. - */ - // assocPath(path: Path, val: T, obj: U): U; - // assocPath(path: Path, val: T): (obj: U) => U; - // assocPath(path: Path): CurriedFunction2; - // assocPath: CurriedFunction3; - - // base - assocPath(path: Path, val: T, obj: U): U; - assocPath(path: Path, val: T): { - (obj: U): U; - }; - assocPath(path: Path): { - (val: T, obj: U): U; - (val: T): { - (obj: U): U; - }; - }; - - + assocPath: typeof assocPath; + /** * Wraps a function of any arity (including nullary) in a function that accepts exactly 2 * parameters. Any extraneous parameters will not be passed to the supplied function. @@ -891,15 +874,7 @@ declare namespace R { // (obj: T): boolean; // } - /** - * Returns the first element in a list. - * In some libraries this function is named `first`. - */ - // head>(list: T): T[0]; - // tuple attempts; it doesn't like these. - head(list: [T]): T; - head(list: [T0, T1]): T0; - head(list: [T0, T1, T2]): T0; + head: typeof head; /** * Returns true if its arguments are identical, false otherwise. Values are identical if they reference the @@ -1402,7 +1377,8 @@ declare namespace R { * Like mapObj, but but passes additional arguments to the predicate function. */ // hard to mix cuz different generics - + + // keyof mapObjIndexed>(fn: (value: T, key: string, obj?: M) => V, obj: M): Obj; mapObjIndexed>(fn: (value: T, key: string, obj?: M) => V): (obj: M) => Obj; diff --git a/src/assocPath.d.ts b/src/assocPath.d.ts index f46fe5d..720a64d 100644 --- a/src/assocPath.d.ts +++ b/src/assocPath.d.ts @@ -2,245 +2,132 @@ * This is auto generated source. */ -import { Path, List, Prop } from '../interfaces'; - - -/** - * Makes a shallow clone of an object, setting or overriding - * the nodes required to create the given path, and placing the specific - * value at the tail end of that path. - * - * Note: Tuples are not supported for typings. - */ -declare function assocPath( - path: [P1, P2, P3, P4, P5, P6, P7, P8], value: T, obj: O): O; - - -/** - * Makes a shallow clone of an object, setting or overriding - * the nodes required to create the given path, and placing the specific - * value at the tail end of that path. - * - * Note: Tuples are not supported for typings. - */ -declare function assocPath( - path: [P1, P2, P3, P4, P5, P6, P7], value: T, obj: O): O; - - -/** - * Makes a shallow clone of an object, setting or overriding - * the nodes required to create the given path, and placing the specific - * value at the tail end of that path. - * - * Note: Tuples are not supported for typings. - */ -declare function assocPath( - path: [P1, P2, P3, P4, P5, P6], value: T, obj: O): O; - - -/** - * Makes a shallow clone of an object, setting or overriding - * the nodes required to create the given path, and placing the specific - * value at the tail end of that path. - * - * Note: Tuples are not supported for typings. - */ -declare function assocPath( - path: [P1, P2, P3, P4, P5], value: T, obj: O): O; - - -/** - * Makes a shallow clone of an object, setting or overriding - * the nodes required to create the given path, and placing the specific - * value at the tail end of that path. - * - * Note: Tuples are not supported for typings. - */ -declare function assocPath( - path: [P1, P2, P3, P4], value: T, obj: O): O; - - -/** - * Makes a shallow clone of an object, setting or overriding - * the nodes required to create the given path, and placing the specific - * value at the tail end of that path. - * - * Note: Tuples are not supported for typings. - */ -declare function assocPath( + path: [P1] & { 1?: void }, value: T, obj: O): O; + /** + * Makes a shallow clone of an object, setting or overriding + * the nodes required to create the given path, and placing the specific + * value at the tail end of that path. + * Note: Tuples are not supported by typings. + * Max path depth typed is 5. + */ + (path: [P1, P2] & { 2?: void }, + value: T, obj: O): O; + /** + * Makes a shallow clone of an object, setting or overriding + * the nodes required to create the given path, and placing the specific + * value at the tail end of that path. + * Note: Tuples are not supported by typings. + * Max path depth typed is 5. + */ + ( - path: [P1, P2, P3], value: T, obj: O): O; - - -/** - * Makes a shallow clone of an object, setting or overriding - * the nodes required to create the given path, and placing the specific - * value at the tail end of that path. - * - * Note: Tuples are not supported for typings. - */ -declare function assocPath( - path: [P1, P2], value: T, obj: O): O; - - -/** - * Makes a shallow clone of an object, setting or overriding - * the nodes required to create the given path, and placing the specific - * value at the tail end of that path. - * - * Note: Tuples are not supported for typings. - */ -declare function assocPath(path: [P1], value: T, obj: O): O; - -// curried - - -/** - * Makes a shallow clone of an object, setting or overriding - * the nodes required to create the given path, and placing the specific - * value at the tail end of that path. - * - * Note: Tuples are not supported for typings. - */ -declare function assocPath( - ps: [P1, P2, P3, P4, P5, P6, P7, P8]): - (obj: O) => - [O[P1], O[P2], O[P3], O[P4], O[P5], O[P6], O[P7], O[P8]]; - - -/** - * Makes a shallow clone of an object, setting or overriding - * the nodes required to create the given path, and placing the specific - * value at the tail end of that path. - * - * Note: Tuples are not supported for typings. - */ -declare function assocPath(ps: [P1, P2, P3, P4, P5, P6, P7]): - (obj: O) => - [O[P1], O[P2], O[P3], O[P4], O[P5], O[P6], O[P7]]; - - -/** - * Makes a shallow clone of an object, setting or overriding - * the nodes required to create the given path, and placing the specific - * value at the tail end of that path. - * - * Note: Tuples are not supported for typings. - */ -declare function assocPath( - ps: [P1, P2, P3, P4, P5, P6]): - (obj: O) => - [O[P1], O[P2], O[P3], O[P4], O[P5], O[P6]]; - - -/** - * Makes a shallow clone of an object, setting or overriding - * the nodes required to create the given path, and placing the specific - * value at the tail end of that path. - * - * Note: Tuples are not supported for typings. - */ -declare function assocPath( - ps: [P1, P2, P3, P4, P5]): - (obj: O) => - [O[P1], O[P2], O[P3], O[P4], O[P5]]; - - -/** - * Makes a shallow clone of an object, setting or overriding - * the nodes required to create the given path, and placing the specific - * value at the tail end of that path. - * - * Note: Tuples are not supported for typings. - */ -declare function assocPath(ps: [P1, P2, P3, P4]): - (obj: O) => - [O[P1], O[P2], O[P3], O[P4]]; - - -/** - * Makes a shallow clone of an object, setting or overriding - * the nodes required to create the given path, and placing the specific - * value at the tail end of that path. - * - * Note: Tuples are not supported for typings. - */ -declare function assocPath(ps: [P1, P2, P3]): - (obj: O) => [O[P1], O[P2], O[P3]]; - - -/** - * Makes a shallow clone of an object, setting or overriding - * the nodes required to create the given path, and placing the specific - * value at the tail end of that path. - * - * Note: Tuples are not supported for typings. - */ -declare function assocPath( - ps: [P1, P2]): - (obj: O) => [O[P1], O[P2]]; - - -/** - * Makes a shallow clone of an object, setting or overriding - * the nodes required to create the given path, and placing the specific - * value at the tail end of that path. - * - * Note: Tuples are not supported for typings. - */ -declare function assocPath(ps: [P1]): - (obj: O) => [O[P1]]; - - -/** - * Makes a shallow clone of an object, setting or overriding - * the nodes required to create the given path, and placing the specific - * value at the tail end of that path. - * - * Note: Tuples are not supported for typings. - */ -declare function props(ps: List, obj: List): T[]; - -// curried - - -/** - * Makes a shallow clone of an object, setting or overriding - * the nodes required to create the given path, and placing the specific - * value at the tail end of that path. - * - * Note: Tuples are not supported for typings. - */ -declare function props(ps: List): (obj: List) => T[]; + path: [P1, P2, P3] & { 3?: void }, value: T, obj: O): O; + /** + * Makes a shallow clone of an object, setting or overriding + * the nodes required to create the given path, and placing the specific + * value at the tail end of that path. + * Note: Tuples are not supported by typings. + * Max path depth typed is 5. + */ + ( + path: [P1, P2, P3, P4] & { 4?: void }, value: T, obj: O): O; + /** + * Makes a shallow clone of an object, setting or overriding + * the nodes required to create the given path, and placing the specific + * value at the tail end of that path. + * Note: Tuples are not supported by typings. + * Max path depth typed is 5. + */ + ( + path: [P1, P2, P3, P4, P5] & { 5?: void }, value: T, obj: O): O; + (path: [P1] & { 1?: void }, value: T): { + (obj: O): O; + } + ( + path: [P1, P2] & { 2?: void }, value: T): { + (obj: O): O; + } + (path: [P1, P2, P3] & { 3?: void }, value: T): { + (obj: O): O; + } + ( + path: [P1, P2, P3, P4] & { 4?: void }, value: T): { + ( + obj: O): O; + } + (path: [P1, P2, P3, P4, P5] & { 5?: void }, + value: T): { + < + O extends {[K1 in P1]: {[K2 in P2]: {[K3 in P3]: {[K4 in P4]: {[K5 in P5]: T}}}}}>( + obj: O): O; + } + (path: [P1] & { 1?: void }): { + (value: T): { + (obj: O): O; + } + (value: T, obj: O): O; + } + ( + path: [P1, P2] & { 2?: void }): { + (value: T): { + (obj: O): O; + } + (value: T, obj: O): O; + } + (path: [P1, P2, P3] & { 3?: void }): { + (value: T): { + (obj: O): O; + } + (value: T, + obj: O): O; + } + ( + path: [P1, P2, P3, P4] & { 4?: void }): { + (value: T): { + ( + obj: O): O; + } + ( + value: T, obj: O): O; + } + (path: [P1, P2, P3, P4, P5] & { 5?: void }): { + (value: T): { + < + O extends {[K1 in P1]: {[K2 in P2]: {[K3 in P3]: {[K4 in P4]: {[K5 in P5]: T}}}}}>( + obj: O): O; + } + ( + value: T, obj: O): O; + } +} + +declare const assocPath: AssocPath export = assocPath diff --git a/src/flatten.d.ts b/src/flatten.d.ts index 6ad01e9..b8c447f 100644 --- a/src/flatten.d.ts +++ b/src/flatten.d.ts @@ -38,4 +38,4 @@ declare function flatten(list: NestedArray2): T[]; */ declare function flatten(list: NestedArray1): T[]; -export = flatten +export = flatten From 1ad86a206a259b9dab385e823bc2e64752e2027b Mon Sep 17 00:00:00 2001 From: whitecolor Date: Wed, 26 Apr 2017 16:21:36 +0500 Subject: [PATCH 18/19] new gen --- gen.ts | 94 ++++++++++++-- package.json | 6 +- src/_assocPath.d.ts | 38 ++++++ src/lensPath.d.ts | 2 +- src/mapObjIndexed.d.ts | 25 ++++ src/path.d.ts | 252 ++++++++++++++++++------------------- src/prop.d.ts | 2 +- src/props.d.ts | 12 +- test/assocPath.ts | 26 +++- test/head.ts | 4 +- test/mapObjIndexed.ts | 17 +++ tpl/assocPath.ts | 273 ++++++++++++++++++++++++++++++++--------- tpl/flatten.ts | 4 +- tpl/lensPath.ts | 4 +- tpl/path.ts | 6 +- tpl/prop.ts | 4 +- tpl/props.ts | 4 +- 17 files changed, 553 insertions(+), 220 deletions(-) create mode 100644 src/_assocPath.d.ts create mode 100644 src/mapObjIndexed.d.ts create mode 100644 test/mapObjIndexed.ts diff --git a/gen.ts b/gen.ts index e556a6d..cc973ba 100644 --- a/gen.ts +++ b/gen.ts @@ -4,11 +4,17 @@ import * as path from 'path'; export const importInterfaces = (names: string[]) => `import { ${names.join(', ')} } from '../interfaces';`; -export type FunParams = { [name: string]: string }[]; +export type MethodParams = { [name: string]: string }[]; -const parseFunParams = (params: FunParams) => +const parseFunParams = (params: MethodParams) => params.map(p => `${Object.keys(p)[0]}: ${p[Object.keys(p)[0]]}`); +export const docsLines = (description: string) => + (['/**']).concat( + description.trim().split('\n').map(d => ' * ' + d ) + ).concat('*/'); + + export const docs = (description: string) => ('/**\n' + description.trim()).split('\n').join('\n * ') + '\n */\n'; @@ -36,7 +42,7 @@ const addCommaExeptLast = (parts: string[]) => export const declareFunction = (name: string, typeParams: string[], - params: FunParams, + params: MethodParams, result: string ): string => [`declare function ${name}<`, ...addCommaExeptLast(typeParams), @@ -45,24 +51,31 @@ export const declareFunction = (name: string, export const arrowFunction = ( typeParams: string[], - params: FunParams, + params: MethodParams, result: string) => { return [`<`, ...addCommaExeptLast(typeParams), `>`, `(`, ...addCommaExeptLast(parseFunParams(params)), `) =>`, ` ${result}`] .reduce(joinWithMaxLineSize, ['']).join('\n '); }; -export function getParamsNums(max: number) { +export function makeParamStringNumbers(max: number) { return Array.from(Array(max + 1).keys()).map(i => Array.from(Array(i + 1).keys()).slice(1) + .map(x => x.toString()) ).slice(1); } + + const zeroPad = (count: number) => (str: string): string => Array(count + 1).join('0') .substring(0, count - str.length) + str; +const spacePadding = (count: number) => + Array((count + 1)).join(' ') + + type Binary = 0 | 1; const toBinaryArray = (length: number) => @@ -71,15 +84,15 @@ const toBinaryArray = (length: number) => .map(x => parseInt(x) as Binary); const makeStringNumberCombination = - (nums: number[]): (string | number)[][] => + (nums: string[]): (string | number)[][] => Array.from(Array(Math.pow(2, nums.length)).keys()) .map(toBinaryArray(nums.length)) .map((binary) => binary.map((x, index) => x ? (index + 1) : (index + 1).toString()) ); -export const makeParamsStringNumberCombination = (max: number) => - getParamsNums(max) +export const makeParamStringNumberCombinations = (max: number) => + makeParamStringNumbers(max) .map(makeStringNumberCombination) .reduce((flat, props) => flat.concat(props), []); @@ -99,20 +112,79 @@ export const makeTuple = (items: (string | number)[], size?: number) => const tplFiles = fs.readdirSync(__dirname + '/tpl'); +export type MethodSignature = { + d?: string, + t?: string[], + p?: MethodParams, + r: string | MethodSignature[] +}; + +export type MethodInterface = MethodSignature[]; + +export type Template = { + imports?: string[], + signatures: MethodSignature[] | MethodSignature[][] +}; + +const capitalizeFirstLetter = (name: string) => + name.charAt(0).toUpperCase() + name.slice(1); + + const g = (global as any); g.genFileCache = g.genFileCache || {}; +export const genarateSignature = (sig: MethodSignature, padding: number): string => { + return (sig.d ? docsLines(sig.d) : []).concat(( + (sig.t && sig.t.length) + ? [`<`, ...addCommaExeptLast(sig.t), `>`] : [] + ).concat( + [`(`, ...addCommaExeptLast(parseFunParams(sig.p || [])), `):`] + ).concat( + typeof (sig.r) === 'string' ? [` ${sig.r};`] + : [ + ` {\n`, + ` ${generateSignatures(sig.r, padding + 1)}`, + `\n${spacePadding(padding)}}` + ] + ) + .reduce(joinWithMaxLineSize, [''])) + .join('\n' + spacePadding(padding)); +}; +const reduceFlatten = (flat: T[], props: T | T[]) => + flat.concat(props) + +const generateSignatures = + (signatures: MethodSignature[], padding = 1) => + spacePadding(padding) + signatures.map(sig => genarateSignature(sig, padding)) + .join('\n' + spacePadding(padding)); + + describe('Generation', () => { tplFiles.forEach(tplFile => { const name = tplFile.replace(/\.ts$/, ''); it(name, () => { - const lines = require(__dirname + '/tpl/' + tplFile); + const tpl = require(__dirname + '/tpl/' + tplFile); + let lines: string[] = []; + // TODO handle empty tlp + if (tpl.signatures) { + const signatures: MethodSignature[] = tpl.signatures.reduce(reduceFlatten); + const interfaceName = capitalizeFirstLetter(name); + lines.push(`interface ${interfaceName} {`); + lines.push(generateSignatures(signatures)); + lines.push(`}`); + lines = [lines.join('\n')]; + if (tpl.imports) { + lines.unshift(importInterfaces(tpl.imports)); + } + lines.push(`declare const ${name}: ${interfaceName}`); + } else { + lines = tpl as string[]; + } const src = docs('This is auto generated source.') + '\n' + - lines.concat(`export = ${name}`) + lines.concat(`export = ${name} `) .join('\n\n') .concat('\n'); - if (g.genFileCache[name] !== src) { fs.writeFileSync(__dirname + `/src/${name}.d.ts`, src); g.genFileCache[name] = src; diff --git a/package.json b/package.json index 3d1b9dd..c46bd7b 100644 --- a/package.json +++ b/package.json @@ -1,10 +1,14 @@ { "name": "@types/ramda", "version": "0.23.0-RC1", + "files": [ + "index.d.ts", + "interfaces.d.ts", + "src" + ], "scripts": { "lint": "echo linting... && tslint index.d.ts", "test": "mocha --compilers ts:ts-node/register test/*.ts type-check.ts", - "_test": "echo testing errors... && ./node_modules/typescript/bin/tsc --lib \"es2015\" --module commonjs tests/test.ts --noEmit", "types": "echo testing types... && bash test.sh", "gen": "ts-node remove-generated && mocha --compilers ts:ts-node/register gen.ts" }, diff --git a/src/_assocPath.d.ts b/src/_assocPath.d.ts new file mode 100644 index 0000000..9c86e64 --- /dev/null +++ b/src/_assocPath.d.ts @@ -0,0 +1,38 @@ +/** + * This is auto generated source. + */ + +import { Path } from '../interfaces' + +interface assocPath { + /** + * 1Returns a new function much like the supplied one, except that the first two arguments' + * order is reversed. + */ + (path: Path, val: T, obj: U): U; + /** + * 2Returns a new function much like the supplied one, except that the first two arguments' + * order is reversed. + */ + (path: Path, val: T): { + (obj: U): U; + }; + /** + * 3Returns a new function much like the supplied one, except that the first two arguments' + * order is reversed. + */ + + (path: Path): { + /** + * 4Returns a new function much like the supplied one, except that the first two arguments' + * order is reversed. + */ + (val: T, obj: U): U; + (val: T): { + (obj: U): U; + }; + }; +} +declare const x: assocPath + +export = x diff --git a/src/lensPath.d.ts b/src/lensPath.d.ts index 6d18e82..219aa7e 100644 --- a/src/lensPath.d.ts +++ b/src/lensPath.d.ts @@ -209,4 +209,4 @@ declare function props(ps: List, obj: List): T[]; */ declare function props(ps: List): (obj: List) => T[]; -export = lensPath +export = lensPath diff --git a/src/mapObjIndexed.d.ts b/src/mapObjIndexed.d.ts new file mode 100644 index 0000000..155d0a1 --- /dev/null +++ b/src/mapObjIndexed.d.ts @@ -0,0 +1,25 @@ +import { Obj } from '../interfaces' + +interface MapObjIndexed { + // > + // (fn: (value?: T, key?: string, obj?: M) => V, obj: M): Obj; + + // + // (fn: (value?: O[K], key?: K, obj?: O) => R[K], obj: O): R; + + + (fn: (value?: O[K], key?: K, obj?: O) => R[K], obj: O): R; + + //>(fn: (value?: T, key?: string, obj?: M) => V, obj: M): Obj; + // >(fn: (value: T, key: string, obj?: M) => V): (obj: M) => Obj; + + // // Record + // (f: (value: T, key: string, obj?: Record) => U, obj: Obj): Obj; + // (f: (value: T, key: string, obj?: Record) => U): (obj: Obj) => Obj; + +} + +declare const mapObjIndexed: MapObjIndexed + +export = mapObjIndexed diff --git a/src/path.d.ts b/src/path.d.ts index 540bd3c..e94b423 100644 --- a/src/path.d.ts +++ b/src/path.d.ts @@ -4,7 +4,7 @@ /** * Retrieve the value at a given path. - * Note: Nested tuples are not supported for typings. + * Note: Tuples are not supported by typings. * Max path depth typed is 5. */ declare function path(path: [P1] & { 1?: void }, @@ -12,7 +12,7 @@ declare function path(path: [P1] & { 1?: void }, /** * Retrieve the value at a given path. - * Note: Nested tuples are not supported for typings. + * Note: Tuples are not supported by typings. * Max path depth typed is 5. */ declare function path(path: [P1] & { 1?: void }, @@ -20,7 +20,7 @@ declare function path(path: [P1] & { 1?: void }, /** * Retrieve the value at a given path. - * Note: Nested tuples are not supported for typings. + * Note: Tuples are not supported by typings. * Max path depth typed is 5. */ declare function path( @@ -28,7 +28,7 @@ declare function path( /** * Retrieve the value at a given path. - * Note: Nested tuples are not supported for typings. + * Note: Tuples are not supported by typings. * Max path depth typed is 5. */ declare function path( @@ -36,7 +36,7 @@ declare function path( /** * Retrieve the value at a given path. - * Note: Nested tuples are not supported for typings. + * Note: Tuples are not supported by typings. * Max path depth typed is 5. */ declare function path( @@ -44,7 +44,7 @@ declare function path( /** * Retrieve the value at a given path. - * Note: Nested tuples are not supported for typings. + * Note: Tuples are not supported by typings. * Max path depth typed is 5. */ declare function path( @@ -52,7 +52,7 @@ declare function path( /** * Retrieve the value at a given path. - * Note: Nested tuples are not supported for typings. + * Note: Tuples are not supported by typings. * Max path depth typed is 5. */ declare function path(path: [P1] & { 1?: void }): @@ -602,7 +602,7 @@ declare function path(path: [P1] & { 1?: void }): /** * Retrieve the value at a given path. - * Note: Nested tuples are not supported for typings. + * Note: Tuples are not supported by typings. * Max path depth typed is 5. */ declare function path(path: [P1] & { 1?: void }): @@ -610,7 +610,7 @@ declare function path(path: [P1] & { 1?: void }): /** * Retrieve the value at a given path. - * Note: Nested tuples are not supported for typings. + * Note: Tuples are not supported by typings. * Max path depth typed is 5. */ declare function path( @@ -619,7 +619,7 @@ declare function path( /** * Retrieve the value at a given path. - * Note: Nested tuples are not supported for typings. + * Note: Tuples are not supported by typings. * Max path depth typed is 5. */ declare function path( @@ -627,7 +627,7 @@ declare function path( /** * Retrieve the value at a given path. - * Note: Nested tuples are not supported for typings. + * Note: Tuples are not supported by typings. * Max path depth typed is 5. */ declare function path( @@ -635,7 +635,7 @@ declare function path( /** * Retrieve the value at a given path. - * Note: Nested tuples are not supported for typings. + * Note: Tuples are not supported by typings. * Max path depth typed is 5. */ declare function path( @@ -643,7 +643,7 @@ declare function path( /** * Retrieve the value at a given path. - * Note: Nested tuples are not supported for typings. + * Note: Tuples are not supported by typings. * Max path depth typed is 5. */ declare function path( path: [P1, P2, P3, P4, P5] & { 5?: void }): (obj: {[K2 in P2]: T[][][]}[]) => T; /** * Retrieve the value at a given path. - * Note: Nested tuples are not supported for typings. + * Note: Tuples are not supported by typings. * Max path depth typed is 5. */ declare function path( path: [P1, P2, P3, P4, P5] & { 5?: void }): (obj: T[][][][][]) => T; -export = path +export = path diff --git a/src/prop.d.ts b/src/prop.d.ts index 0625d2f..a2e7b0f 100644 --- a/src/prop.d.ts +++ b/src/prop.d.ts @@ -172,4 +172,4 @@ declare function props(ps: List, obj: List): T[]; */ declare function props(ps: List): (obj: List) => T[]; -export = prop +export = prop diff --git a/src/props.d.ts b/src/props.d.ts index 341fdbb..3ae641f 100644 --- a/src/props.d.ts +++ b/src/props.d.ts @@ -86,7 +86,7 @@ declare function props( ps: [P1, P2, P3, P4, P5, P6, P7, P8]): (obj: O) => - [O[P1], O[P2], O[P3], O[P4], O[P5], O[P6], O[P7], O[P8]]; + [O[P1], O[P2], O[P3], O[P4], O[P5], O[P6], O[P7], O[P8]]; /** * Acts as multiple `prop`: array of keys in, array of values out. Preserves order. @@ -95,7 +95,7 @@ declare function props(ps: [P1, P2, P3, P4, P5, P6, P7]): (obj: O) => - [O[P1], O[P2], O[P3], O[P4], O[P5], O[P6], O[P7]]; + [O[P1], O[P2], O[P3], O[P4], O[P5], O[P6], O[P7]]; /** * Acts as multiple `prop`: array of keys in, array of values out. Preserves order. @@ -104,7 +104,7 @@ declare function props( ps: [P1, P2, P3, P4, P5, P6]): (obj: O) => - [O[P1], O[P2], O[P3], O[P4], O[P5], O[P6]]; + [O[P1], O[P2], O[P3], O[P4], O[P5], O[P6]]; /** * Acts as multiple `prop`: array of keys in, array of values out. Preserves order. @@ -113,7 +113,7 @@ declare function props( ps: [P1, P2, P3, P4, P5]): (obj: O) => - [O[P1], O[P2], O[P3], O[P4], O[P5]]; + [O[P1], O[P2], O[P3], O[P4], O[P5]]; /** * Acts as multiple `prop`: array of keys in, array of values out. Preserves order. @@ -121,7 +121,7 @@ declare function props(ps: [P1, P2, P3, P4]): (obj: O) => - [O[P1], O[P2], O[P3], O[P4]]; + [O[P1], O[P2], O[P3], O[P4]]; /** * Acts as multiple `prop`: array of keys in, array of values out. Preserves order. @@ -154,4 +154,4 @@ declare function props(ps: List, obj: List): T[]; */ declare function props(ps: List): (obj: List) => T[]; -export = props +export = props diff --git a/test/assocPath.ts b/test/assocPath.ts index 74994ce..f805d75 100644 --- a/test/assocPath.ts +++ b/test/assocPath.ts @@ -5,8 +5,7 @@ import { itFailsType, typeFail } from '../type-fail'; type nestedX = { x: number }; const obj = { a: { b: { c: 0 } } }; -const objWithList = { a: [ { c: 0 }, { c: 1 } ] }; - +const objWithList = { a: [{ c: 0 }, { c: 1 }] }; describe('assocPath', () => { it('path with two props', () => { const value: number = 42; @@ -20,10 +19,31 @@ describe('assocPath', () => { equal(res, value); }); + it('curried 2-1: object with list inside', () => { + const value: number = 42; + const res = assocPath(['a', 1], { c: value }) + (objWithList).a[1].c; + equal(res, value); + }); + + it('curried 1-2: object with list inside', () => { + const value: number = 42; + const res = assocPath(['a', 1])({ c: value }, + objWithList).a[1].c; + equal(res, value); + }); + + it('curried 1-1-1: object with list inside', () => { + const value: number = 42; + const res = assocPath(['a', 1])({ c: value }) + (objWithList).a[1].c; + equal(res, value); + }); + it('ts error: incorrect type for value not allowed', () => { typeFail(` import assocPath = require('ramda/src/assocPath'); assocPath(['a', 'b'], '42', {a: {b: 0}}) - `, /incompatible with index signature/); + `, /is not assignable/); }); }); diff --git a/test/head.ts b/test/head.ts index d002655..f59f648 100644 --- a/test/head.ts +++ b/test/head.ts @@ -12,8 +12,8 @@ describe('flatten', () => { equal(res, list[0]); }); - it('takes list', () => { + it('takes tuple', () => { const res = head(tuple); - equal(res, list[0]); + equal(res, tuple[0]); }); }); diff --git a/test/mapObjIndexed.ts b/test/mapObjIndexed.ts new file mode 100644 index 0000000..faaa6e7 --- /dev/null +++ b/test/mapObjIndexed.ts @@ -0,0 +1,17 @@ +import mapObjIndexed = require('ramda/src/mapObjIndexed'); +import { equal } from 'assert'; +import { typeFail } from '../type-fail'; + +type nestedX = { x: number }; + +const obj = { a: 1, b: 2, c: 3}; +//const objWithList = { a: [{ c: 0 }, { c: 1 }] }; + +describe('mapObjIndexed', () => { + // it('path with two props', () => { + // const value: number = 42; + // const mapFn = (x: number) => x.toString() + // const res = mapObjIndexed(mapFn, obj) + // equal(res, value); + // }); +}); diff --git a/tpl/assocPath.ts b/tpl/assocPath.ts index 9f05651..1786a68 100644 --- a/tpl/assocPath.ts +++ b/tpl/assocPath.ts @@ -2,67 +2,224 @@ import { importInterfaces, declareFunction, arrowFunction, - getParamsNums + makeParamStringNumberCombinations, + makeParamStringNumbers, + makeNestedObjPath, + makeTuple, + Template, + docs } from '../gen'; -const propsParams = getParamsNums(8).reverse() - .map(nums => nums.map(n => 'P' + n)); +// const propsParams = getParamsNums(8).reverse() +// .map(nums => nums.map(n => 'P' + n)); -const docs = ` -/** - * Makes a shallow clone of an object, setting or overriding - * the nodes required to create the given path, and placing the specific - * value at the tail end of that path. - * - * Note: Tuples are not supported for typings. - */ +const maxPathDepth = 5; + +const desc = ` +Makes a shallow clone of an object, setting or overriding +the nodes required to create the given path, and placing the specific +value at the tail end of that path. +Note: Tuples are not supported by typings. +Max path depth typed is ${maxPathDepth}. `; -const makeNestedObjPath = (props: string[], init: string) => - props.concat([]).reverse().reduce((prev, prop, index) => - `{[K${props.length - index} in ${prop}]: ${prev}}` - , init) +// const propsParams = +// makeParamStringNumberCombinations(maxPathDepth); + +const propsParams = + makeParamStringNumbers(maxPathDepth); + +const orBrackets = (...items: string[]) => + `(${items.join(') | (')})`; + + +const generic = [ + { + d: desc, + t: ['T', 'O'], + p: [{ path: 'Path' }, { val: 'T' }, { obj: 'O' }], + r: 'O' + }, + { + d: desc, + t: ['T'], + p: [{ path: 'Path' }, { val: 'T' }], + r: [ + { + t: ['O'], + p: [{ obj: 'O' }], + r: 'O' + } + ] + }, + { + p: [{ path: 'Path' }], r: [ + { + d: desc, + t: ['T', 'O'], + p: [{ val: 'T' }, { obj: 'O' }], + r: 'O' + }, + { + t: ['T'], p: [{ val: 'T' }], r: [ + { t: ['O'], p: [{ obj: 'O' }], r: 'O' } + ] + } + ] + } +] + + +const template: Template = { + imports: ['Path'], + signatures: [ + ...propsParams.map(props => [ + { + d: desc, + t: props.map(n => `P${n} extends ${typeof n} | number`) + .concat([ + `T`, + 'O extends ' + makeNestedObjPath(props, 'T') + ]), + p: [ + { path: makeTuple(props, props.length) }, + { value: 'T' }, + { + obj: 'O' + } + ], + r: 'O' + } + ]), + // curry 2-1 + ...propsParams.map(props => [ + { + // d: desc, + t: props.map(n => `P${n} extends ${typeof n} | number`) + .concat([ + `T` + ]), + p: [ + { path: makeTuple(props, props.length) }, + { value: 'T' } + ], + r: [{ + t: ['O extends ' + makeNestedObjPath(props, 'T')], + p: [{ obj: 'O' }], + r: `O` + }] + } + ]), + // curry 1-(1,2) + ...propsParams.map(props => [ + { + //d: desc, + t: props.map(n => `P${n} extends ${typeof n} | number`) + .concat([ + `T` + ]), + p: [ + { path: makeTuple(props, props.length) } + ], + r: [{ + t: ['T'], + p: [{ value: 'T' }], + r: [{ + t: ['O extends ' + makeNestedObjPath(props, 'T')], + p: [{ obj: 'O' }], + r: `O` + }] + }, { + t: [`T`, 'O extends ' + makeNestedObjPath(props, 'T')], + p: [{ value: 'T' }, { obj: 'O' }], + r: `O` + }] + } + ]), + //generic + ] +}; + +module.exports = template; -module.exports = [ - importInterfaces(['Path', 'List', 'Prop']), - ...propsParams.map((props) => - docs + - declareFunction('assocPath', - props.map(Pn => `${Pn} extends string | number`) - //.concat(props.map(Pn => `${Pn.replace(/P/, 'N')} extends number`)) - .concat([ - `T`, - //'O extends ' + makeNestedObjPath(props.map(Pn => `${Pn} & ${Pn.replace(/P/, 'N')}`) , 'T') - 'O extends ' + makeNestedObjPath(props, 'T') - ]), - [ - { path: `[${props.join(', ')}]` }, - { value: 'T' }, - { - obj: 'O' - } - ], - `O` - )), - `// curried`, - ...propsParams.map((props) => - docs + - declareFunction('assocPath', - props.map(Pn => `${Pn} extends string`), - [ - { ps: `[${props.join(', ')}]` } - ], - arrowFunction( - [`O extends {[K in ${props.join(' | ')}]: any}`], - [{ obj: 'O' }], - `[${props.map(Pn => 'O[' + Pn + ']').join(', ')}]` - ) - )), - docs + - declareFunction('props', ['T'], [{ ps: 'List' }, { obj: 'List' }], 'T[]'), - `// curried`, - docs + - declareFunction('props', ['T'], [{ ps: 'List' }], - arrowFunction(['T'], [{ obj: 'List' }], 'T[]') - ) -]; +// const fun = [ +// // importInterfaces(['Path', 'List', 'Prop']), +// ...propsParams.map((props) => +// docs(desc) + +// declareFunction('assocPath', +// props.map(n => `P${n} extends ${typeof n}`) +// .concat([ +// `T`, +// 'O extends ' + makeNestedObjPath(props, 'T') +// ]), +// [ +// { path: makeTuple(props, props.length) }, +// { value: 'T' }, +// { +// obj: 'O' +// } +// ], +// `O` +// )), +// `// curried 1-1-1`, +// ...propsParams.map((props) => +// docs(desc) + +// declareFunction('assocPath', +// props.map(n => `P${n} extends ${typeof n}`) +// .concat(`T`), +// [ +// { paths: makeTuple(props, props.length) }, +// { value: 'T' } +// ], +// arrowFunction( +// ['T'], +// [{ value: 'T' }], +// arrowFunction( +// [ +// 'O extends ' + makeNestedObjPath(props, 'T') +// ], +// [{ obj: 'O' }], +// `O` +// ) +// ) +// )), +// `// curried 2-1`, +// ...propsParams.map((props) => +// docs(desc) + +// declareFunction('assocPath', +// props.map(n => `P${n} extends ${typeof n}`) +// .concat(`T`), +// [ +// { paths: makeTuple(props, props.length) }, +// { value: 'T' } +// ], +// arrowFunction( +// ['O extends ' + makeNestedObjPath(props, 'T')], +// [{ obj: 'O' }], +// `O` +// ) +// )), +// `// curried 1-2`, +// ...propsParams.map((props) => +// docs(desc) + +// declareFunction('assocPath', +// props.map(n => `P${n} extends ${typeof n}`), +// [ +// { paths: makeTuple(props, props.length) } +// ], +// arrowFunction( +// ['T', +// 'O extends ' + makeNestedObjPath(props, 'T') +// ], +// [{ value: 'T' }, { obj: 'O' }], +// `O` +// ), +// )), +// // docs + +// // declareFunction('props', ['T'], [{ ps: 'List' }, { obj: 'List' }], 'T[]'), +// // `// curried`, +// // docs + +// // declareFunction('props', ['T'], [{ ps: 'List' }], +// // arrowFunction(['T'], [{ obj: 'List' }], 'T[]') +// // ) +// ]; diff --git a/tpl/flatten.ts b/tpl/flatten.ts index 48bedf4..4c9c432 100644 --- a/tpl/flatten.ts +++ b/tpl/flatten.ts @@ -1,10 +1,10 @@ import { declareFunction, - getParamsNums, + makeParamStringNumbers, defineType, docs } from '../gen'; -const nestedListLevels = getParamsNums(5).reverse(); +const nestedListLevels = makeParamStringNumbers(5).reverse(); const desc = `Returns a new list by pulling every item out of it (and all its sub-arrays) and putting them in a new array, depth-first.`; diff --git a/tpl/lensPath.ts b/tpl/lensPath.ts index 58de024..23882d8 100644 --- a/tpl/lensPath.ts +++ b/tpl/lensPath.ts @@ -2,10 +2,10 @@ import { importInterfaces, declareFunction, arrowFunction, - getParamsNums + makeParamStringNumbers } from '../gen'; -const propsParams = getParamsNums(8).reverse() +const propsParams = makeParamStringNumbers(8).reverse() .map(nums => nums.map(n => 'P' + n)); const docs = ` diff --git a/tpl/path.ts b/tpl/path.ts index 115e97d..9835b85 100644 --- a/tpl/path.ts +++ b/tpl/path.ts @@ -2,7 +2,7 @@ import { importInterfaces, declareFunction, arrowFunction, - makeParamsStringNumberCombination, + makeParamStringNumberCombinations, makeNestedObjPath, makeTuple, docs } from '../gen'; @@ -10,10 +10,10 @@ import { const maxPathDepth = 5; const propsParams = - makeParamsStringNumberCombination(maxPathDepth); + makeParamStringNumberCombinations(maxPathDepth); const desc = `Retrieve the value at a given path. -Note: Nested tuples are not supported for typings. +Note: Tuples are not supported by typings. Max path depth typed is ${maxPathDepth}.`; module.exports = [ diff --git a/tpl/prop.ts b/tpl/prop.ts index be89166..4f77245 100644 --- a/tpl/prop.ts +++ b/tpl/prop.ts @@ -2,10 +2,10 @@ import { importInterfaces, declareFunction, arrowFunction, - getParamsNums + makeParamStringNumbers } from '../gen'; -const propsParams = getParamsNums(8).reverse() +const propsParams = makeParamStringNumbers(8).reverse() .map(nums => nums.map(n => 'P' + n)); const docs = ` diff --git a/tpl/props.ts b/tpl/props.ts index 9295766..ee8b223 100644 --- a/tpl/props.ts +++ b/tpl/props.ts @@ -2,11 +2,11 @@ import { importInterfaces, declareFunction, arrowFunction, - getParamsNums, + makeParamStringNumbers, docs } from '../gen'; -const propsParams = getParamsNums(8).reverse() +const propsParams = makeParamStringNumbers(8).reverse() .map(nums => nums.map(n => 'P' + n)); const desc = 'Acts as multiple \`prop\`: array of keys in, array of values out. Preserves order.'; From 5b504df31a348ba3ac4ef8098227ffea8116e7f1 Mon Sep 17 00:00:00 2001 From: whitecolor Date: Wed, 26 Apr 2017 20:49:54 +0500 Subject: [PATCH 19/19] refactor, remove old stuff --- .editorconfig | 11 - .gitignore | 16 +- .travis.yml | 14 +- .vscode/settings.json | 13 +- LICENSE | 21 - gen.ts | 53 +- issues.md | 54 - package.json | 16 +- scripts.js | 2869 ----------------------------------- src/_assocPath.d.ts | 38 - src/assocPath.d.ts | 113 +- src/path.d.ts | 2234 +++++++++++++-------------- src/prop.d.ts | 175 --- test.sh | 10 - test/assocPath.ts | 68 +- test/path.ts | 11 +- tests/test.ts | 3326 ----------------------------------------- tests/test.ts.out | 1916 ------------------------ tpl/assocPath.ts | 258 +--- tpl/path.ts | 105 +- tsconfig.json | 16 +- typings.json | 8 - yarn.lock | 1241 +++++++++++++++ 23 files changed, 2559 insertions(+), 10027 deletions(-) delete mode 100644 .editorconfig delete mode 100644 LICENSE delete mode 100644 issues.md delete mode 100644 scripts.js delete mode 100644 src/_assocPath.d.ts delete mode 100644 src/prop.d.ts delete mode 100644 test.sh delete mode 100644 tests/test.ts delete mode 100644 tests/test.ts.out delete mode 100644 typings.json create mode 100644 yarn.lock diff --git a/.editorconfig b/.editorconfig deleted file mode 100644 index 8e84acc..0000000 --- a/.editorconfig +++ /dev/null @@ -1,11 +0,0 @@ -# EditorConfig is awesome: http://EditorConfig.org - -root = true - -[*] -indent_size = 2 -indent_style = space -end_of_line = lf -charset = utf-8 -trim_trailing_whitespace = true -insert_final_newline = true diff --git a/.gitignore b/.gitignore index 981460f..a0cbc8a 100644 --- a/.gitignore +++ b/.gitignore @@ -2,11 +2,15 @@ node_modules /tmp /ts-node-* -dist -*.swp -*.swo -.session.vim -.sizecache.json -test.js *.log* +# generated + +src/assocPath.d.ts +src/flatten.d.ts +src/head.d.ts +src/lensPath.d.ts +src/mapObjIndexed.d.ts +src/merge.d.ts +src/path.d.ts +src/props.d.ts diff --git a/.travis.yml b/.travis.yml index 963767e..b8edf89 100644 --- a/.travis.yml +++ b/.travis.yml @@ -4,20 +4,12 @@ language: node_js notifications: email: on_success: never - on_failure: never # change + on_failure: never script: - - npm run lint - # - npm run bundle - - npm rm tslint - - npm install $TYPESCRIPT --force - # - npm run exec - - npm run test + # - yarn tslint + - yarn run test -env: - # - TYPESCRIPT=typescript@2.2 - - TYPESCRIPT=typescript@latest - - TYPESCRIPT=typescript@next node_js: - "stable" diff --git a/.vscode/settings.json b/.vscode/settings.json index d2e1405..ebbcd57 100644 --- a/.vscode/settings.json +++ b/.vscode/settings.json @@ -1,7 +1,10 @@ // Place your settings in this file to overwrite default and user settings. { - "typescript.tsdk": "node_modules/typescript/lib", - "files.exclude": { - "ts-node-*": true - } -} + "typescript.tsdk": "./node_modules/typescript/lib", + "search.exclude": {}, + "files.exclude": { + "ts-node-*": true + // "**/*.js": true, + }, + "tslint.run": "onSave" +} \ No newline at end of file diff --git a/LICENSE b/LICENSE deleted file mode 100644 index fc755d4..0000000 --- a/LICENSE +++ /dev/null @@ -1,21 +0,0 @@ -The MIT License (MIT) - -Copyright (c) 2014, 2015, 2016 Erwin Poeze - -Permission is hereby granted, free of charge, to any person obtaining a copy -of this software and associated documentation files (the "Software"), to deal -in the Software without restriction, including without limitation the rights -to use, copy, modify, merge, publish, distribute, sublicense, and/or sell -copies of the Software, and to permit persons to whom the Software is -furnished to do so, subject to the following conditions: - -The above copyright notice and this permission notice shall be included in all -copies or substantial portions of the Software. - -THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, -OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE -SOFTWARE. diff --git a/gen.ts b/gen.ts index cc973ba..042dbb3 100644 --- a/gen.ts +++ b/gen.ts @@ -11,8 +11,8 @@ const parseFunParams = (params: MethodParams) => export const docsLines = (description: string) => (['/**']).concat( - description.trim().split('\n').map(d => ' * ' + d ) - ).concat('*/'); + description.trim().split('\n').map(d => ' * ' + d) + ).concat('*/'); export const docs = (description: string) => @@ -20,7 +20,9 @@ export const docs = (description: string) => export const defineType = (type: string, def: string) => `type ${type} = ${def};`; -; + +const isArray = Array.isArray +const isString = (obj: any) => typeof obj === 'string' const maxGeneratedLineSize = 75; @@ -61,19 +63,17 @@ export const arrowFunction = ( export function makeParamStringNumbers(max: number) { return Array.from(Array(max + 1).keys()).map(i => Array.from(Array(i + 1).keys()).slice(1) - .map(x => x.toString()) + .map(x => x.toString()) ).slice(1); } - - const zeroPad = (count: number) => (str: string): string => Array(count + 1).join('0') .substring(0, count - str.length) + str; const spacePadding = (count: number) => - Array((count + 1)).join(' ') + Array((count + 1)).join(' ') type Binary = 0 | 1; @@ -99,12 +99,16 @@ export const makeParamStringNumberCombinations = (max: number) => export const addLetter = (letter = 'P') => (prop: string) => parseInt(prop) ? letter + prop : prop; -export const makeNestedObjPath = (props: (string | number)[], init: string) => +/** + * Makes nestes path like {[K1 in P1]: {[K2 in P2]: T[]}}): T + * for "1"(string), "2" (string), 3 (number) + */ +export const makeNestedObjPath = (props: (string | number)[], T: string) => props.concat([]).reverse().reduce((prev, prop, index) => typeof prop === 'string' ? `{[K${props.length - index} in ${addLetter()(prop)}]: ${prev}}` : `${prev}[]` - , init); + , T); export const makeTuple = (items: (string | number)[], size?: number) => `[` + items.map(addLetter()).join(', ') + `]` @@ -116,7 +120,7 @@ export type MethodSignature = { d?: string, t?: string[], p?: MethodParams, - r: string | MethodSignature[] + r: string | MethodSignature | MethodSignature[] }; export type MethodInterface = MethodSignature[]; @@ -130,10 +134,20 @@ const capitalizeFirstLetter = (name: string) => name.charAt(0).toUpperCase() + name.slice(1); +export function methodSignature( + docs: string, + types: string[], + params: MethodParams, + result: string | MethodSignature | MethodSignature[]): MethodSignature { + return { + d: docs, t: types, p: params, r: result + } +} + const g = (global as any); g.genFileCache = g.genFileCache || {}; -export const genarateSignature = (sig: MethodSignature, padding: number): string => { +const genarateSignature = (sig: MethodSignature, padding: number): string => { return (sig.d ? docsLines(sig.d) : []).concat(( (sig.t && sig.t.length) ? [`<`, ...addCommaExeptLast(sig.t), `>`] : [] @@ -142,21 +156,22 @@ export const genarateSignature = (sig: MethodSignature, padding: number): string ).concat( typeof (sig.r) === 'string' ? [` ${sig.r};`] : [ - ` {\n`, - ` ${generateSignatures(sig.r, padding + 1)}`, - `\n${spacePadding(padding)}}` - ] + ` {\n`, + ` ${generateSignatures(isArray(sig.r) ? sig.r : [sig.r], padding + 1)}`, + `\n${spacePadding(padding)}}` + ] ) .reduce(joinWithMaxLineSize, [''])) .join('\n' + spacePadding(padding)); }; + const reduceFlatten = (flat: T[], props: T | T[]) => flat.concat(props) const generateSignatures = (signatures: MethodSignature[], padding = 1) => spacePadding(padding) + signatures.map(sig => genarateSignature(sig, padding)) - .join('\n' + spacePadding(padding)); + .join('\n' + spacePadding(padding)); describe('Generation', () => { @@ -167,7 +182,11 @@ describe('Generation', () => { let lines: string[] = []; // TODO handle empty tlp if (tpl.signatures) { - const signatures: MethodSignature[] = tpl.signatures.reduce(reduceFlatten); + // TODO: remove this nesting and flattening + const signatures: MethodSignature[] = + isArray(tpl.signatures[0]) ? + tpl.signatures.reduce(reduceFlatten) + : tpl.signatures; const interfaceName = capitalizeFirstLetter(name); lines.push(`interface ${interfaceName} {`); lines.push(generateSignatures(signatures)); diff --git a/issues.md b/issues.md deleted file mode 100644 index 5702243..0000000 --- a/issues.md +++ /dev/null @@ -1,54 +0,0 @@ --> 1420 - 1429 - --> 1811 - --> 2005: can not find name 'Partial'; - --> 2014: can not find name 'Partial'; - --> 2177: 好像不能用 [0]; - --> 2592-2593: return type {} & U; - --> 2624: as previous - --> 2598: can not find name 'Record' - --> 2625: can not find name 'Recrod' - --> 2685-2693: `{} & U` and can not find name 'Record' - --> 2916, 2917: can not find name 'Record' - --> 2967-2972: keyof - --> 3073: can not find name 'Partial' - -3084-3231: compile slowly - --> 3310-3315: can not find name ['Pick', 'Partial'] - --> 3440-3443: [k]; - --> 3469-3472: can not find name 'Pick' - --> 3483-3493: keyword 'keyof', can not find name 'Record'; - --> 3524-3531: can not find name 'Record'; - --> 3533-3540: keyof, Record - --> 3552-3560: keyof, Record - --> 3573-3579: [k]; - --> 3629-3639: Record - --> 3810-3813: Partial; - --> 3820: Partial; - --> 4573-4576: keyof - --> 4596-4599: Partial; - diff --git a/package.json b/package.json index c46bd7b..a716e5c 100644 --- a/package.json +++ b/package.json @@ -7,20 +7,18 @@ "src" ], "scripts": { - "lint": "echo linting... && tslint index.d.ts", - "test": "mocha --compilers ts:ts-node/register test/*.ts type-check.ts", - "types": "echo testing types... && bash test.sh", - "gen": "ts-node remove-generated && mocha --compilers ts:ts-node/register gen.ts" + "gen": "ts-node remove-generated && mocha --compilers ts:ts-node/register gen.ts", + "test": "mocha --compilers ts:ts-node/register test/*.ts type-check.ts" }, "devDependencies": { "@types/mocha": "^2.2.40", + "@types/node": "^7.0.13", + "del-cli": "^0.2.1", "mocha": "^3.2.0", "ramda": "0.23.0", "ts-node": "^3.0.2", - "tslint": "^4.2.0", + "tslint": "^5.1.0", "tslint-config-typings": "^0.3.1", - "typescript": "^2.2.1-insiders.20170209", - "typings-checker": "github:tycho01/typings-checker" - }, - "typings": "index.d.ts" + "typescript": "^2.2.2" + } } diff --git a/scripts.js b/scripts.js deleted file mode 100644 index b240281..0000000 --- a/scripts.js +++ /dev/null @@ -1,2869 +0,0 @@ -// usage: paste this whole file into a console with Ramda available to get generated typings -// import * as R from 'ramda'; - -let letters = (idx) => (n) => R.range(idx, idx + R.clamp(0, 26, n)).map(i => String.fromCharCode(i)); -let upper = letters(65); -let lower = letters(97); -let nm = (cnt, fn) => R.range(0,cnt).map(fn).join(', '); -let bits = (k, i) => { - let rem = 0; - return R.range(1, k+1).map(n => { - let res = i % Math.pow(2, n) - rem; - rem += res; - return res ? 1 : 0; - }) -}; - -function composeDef(i, j) { - let vals = nm(j, n => `V${n}`); - let pars = nm(j, n => `x${n}: V${n}`); - let fns = nm(i-1, n => `fn${i-1-n}: (x: T${i-1-n}) => T${i-n}`); - let types = nm(i, n => `T${n+1}`); - return `compose<${vals}, ${types}>(${fns}${i>1?', ':''}fn0: (${pars}) => T1): (${pars}) => T${i};` -} - -function composePDef(i, j) { - let vals = nm(j, n => `V${n}`); - let pars = nm(j, n => `x${n}: V${n}`); - let fns = nm(i-1, n => `fn${i-1-n}: (x: T${i-1-n}) => Promise|T${i-n}`); - let types = nm(i, n => `T${n+1}`); - return `composeP<${vals}, ${types}>(${fns}${i>1?', ':''}fn0: (${pars}) => Promise): (${pars}) => Promise;` -} - -function pipeDef(i, j) { - let vals = nm(j, n => `V${n}`); - let pars = nm(j, n => `x${n}: V${n}`); - let fns = nm(i-1, n => `fn${n+1}: (x: T${n+1}) => T${n+2}`); - let types = nm(i, n => `T${n+1}`); - return `pipe<${vals}, ${types}>(fn0: (${pars}) => T1${i>1?', ':''}${fns}): (${pars}) => T${i};` -} - -function pipePDef(i, j) { - let vals = nm(j, n => `V${n}`); - let pars = nm(j, n => `x${n}: V${n}`); - let fns = nm(i-1, n => `fn${n+1}: (x: T${n+1}) => Promise|T${n+2}`); - let types = nm(i, n => `T${n+1}`); - return `pipeP<${vals}, ${types}>(fn0: (${pars}) => Promise${i>1?', ':''}${fns}): (${pars}) => Promise;` -} - -function pipeKDef(i) { - let fns = nm(i-1, n => `fn${n+1}: (x: T${n+1}) => Chain`); - let types = nm(i, n => `T${n+1}`); - return `pipeK(fn0: (v: Chain) => Chain${i>1?', ':''}${fns}): (v: V) => Chain;` -} - -function composeKDef(i) { - let fns = nm(i-1, n => `fn${i-1-n}: (x: T${i-1-n}) => Chain`); - let types = nm(i, n => `T${n+1}`); - return `composeK(${fns}${i>1?', ':''}fn0: (v: Chain) => Chain): (v: V) => Chain;` -} - -function curryDef(i) { - let lows = lower(i); - let pars = nm(i, n => `${lows[n]}: T${n+1}`); - let types = nm(i, n => `T${n+1}`); - return `curry<${types}, TResult>(fn: (${pars}) => TResult): CurriedFunction${i}<${types}, TResult>;` -} -R.flatten(R.range(2,10).map(i => curryDef(i))).join('\n') - -function curryDefGen(i) { - // let lows = lower(i); - let pars = nm(i, n => `v${n}: T${n+1}`); // lows[n] - let types = nm(i, n => `T${n+1}`); - let parObj = R.pipe(R.range(0), R.map(n => [`v${n}`, `T${n+1}`]), R.fromPairs)(i); // lows[n] - let curried = genOption([[], parObj, 'TResult'], 2); - return `curry<${types}, TResult>(fn: (${pars}) => TResult): {\n${curried}};` -} -R.flatten(R.range(1,10).map(i => curryDefGen(i))).join('\n') - -function CurriedFunctionDef(i) { - let types = nm(i, n => `T${n+1}`); - let curriedDef = (j) => { // , extraGenerics = false - let pars = nm(j, n => `v${n+1}: T${n+1}`); - let tps = nm(i-j, n => `T${j+n+1}`); - let gens = nm(i, n => `T${n+1}`); - let curried = (i-j > 1) ? `CurriedFunction${i-j}<${tps}, R>` : (i-j == 0) ? 'R' : `(v${i}: T${i}) => R`; - // return (extraGenerics ? `<${gens}, R>` : '') + `(${pars}): ${curried};` - return `(${pars}): ${curried};` - } - let nums = R.range(0,i); - // let defs = [...nums.map(n => curriedDef(n+1)), ...nums.map(n => curriedDef(n+1, true))].join('\n '); - let defs = nums.map(n => curriedDef(n+1)).join('\n '); - return `interface CurriedFunction${i}<${types}, R> { - ${defs} -}`; -} -R.flatten(R.range(2,10).map(i => CurriedFunctionDef(i))).join('\n') - -function CurriedFnDef(i) { - let types = nm(i, n => `T${n+1}`); - let curriedDef = (j) => { - let pars = nm(j, n => `v${n+1}: T${n+1}`); - let tps = nm(i-j, n => `T${j+n+1}`); - let gens = nm(i, n => `T${n+1}`); - let parObj = R.pipe(R.range(j), R.map(n => [`v${n+1}`, `T${n+1}`]), R.fromPairs)(i); - let curried = (i-j > 1) ? `{\n${ - genOption([[], parObj, 'R'], 4) - } }` : - (i-j == 0) ? 'R' : - `(v${i}: T${i}) => R`; - return `(${pars}): ${curried};` - } - let nums = R.range(0,i); - let defs = nums.map(n => curriedDef(i-n)).join('\n '); - return `interface CurriedFn${i}<${types}, R> {\n ${defs}\n}`; -} -R.flatten(R.range(1,10).map(i => CurriedFnDef(i))).join('\n') - -function liftDef(i) { - let pars = nm(i, n => `v${n+1}: T${n+1}`); - let listPars = nm(i, n => `v${n+1}: List`); - let types = nm(i, n => `T${n+1}`); - return `lift<${types}, TResult>(fn: (${pars}) => TResult): (${listPars}) => TResult[];` -} - -function liftNDef(i, together = true) { - let pars = nm(i, n => `v${n+1}: T${n+1}`); - let listPars = nm(i, n => `v${n+1}: List`); - let types = nm(i, n => `T${n+1}`); - return together ? `liftN<${types}, TResult>(n: number, fn: (${pars}) => TResult): (${listPars}) => TResult[];` : - `liftN(n: number): <${types}, TResult>(fn: (${pars}) => TResult) => (${listPars}) => TResult[];`; -} - -function liftNDefSeparate(i) { - let pars = nm(i, n => `v${n+1}: T${n+1}`); - let listPars = nm(i, n => `v${n+1}: List`); - let types = nm(i, n => `T${n+1}`); - return `<${types}, TResult>(fn: (${pars}) => TResult): (${listPars}) => TResult[];`; -} -R.flatten(R.range(2,10).map(i => liftNDefSeparate(i))).join('\n'); - -function pathDef(i) { - let obj = R.range(1,i+1).reduce((str, n) => `{[K${i-n+1} in T${i-n+1}]: ${str}}`, 'TResult'); - let types = nm(i, n => `T${n+1}`); - let typesStr = nm(i, n => `T${n+1} extends string`); - return `path<${typesStr}, TResult>(path: [${types}], obj: ${obj}): TResult;` -} - -function pathDefRecord(i) { - let obj = R.range(1,i+1).reduce((str, n) => `Record`, 'TResult'); - let types = nm(i, n => `K${n+1}`); - let typesStr = nm(i, n => `K${n+1} extends string`); - return `path<${typesStr}, TResult>(path: [${types}], obj: ${obj}): TResult;` -} -R.flatten(R.range(2,10).map(i => pathDefRecord(i))).join('\n') - -function pathDefPoly(i, j) { - let isArrs = bits(i, j); - let obj = R.range(1,i+1).reduce((str, n) => isArrs[n-1] ? `${str}[]` : `{[K${i-n+1} in T${i-n+1}]: ${str}}`, 'TResult'); - let types = nm(i, n => `T${n+1}`); - let typesExt = nm(i, n => `T${n+1} extends ${isArrs[i-n-1] ? 'number' : 'string'}`); - // let typesExt = R.reverse(R.range(0,i).map(n => `T${n+1} extends ${isArrs[n] ? 'number' : 'string'}`)).join(', '); - return `path<${typesExt}, TResult>(path: [${types}], obj: ${obj}): TResult;` -} -R.flatten(R.range(1,7).map(i => R.range(0, Math.pow(2, i)).map(j => pathDefPoly(i, j)))).join('\n') - -// type Option = [/*generics*/ string[], ParamObj, /*retval*/ string | Option[]]; -// type ParamObj = { [name: string]: string }; - -var whitespace = (indentation = 0) => R.repeat(' ', indentation).join(''); -var comment = (s, indent = 0) => `${whitespace(indent)}// ${s}`; - -function genCurried(options /*: { [name: string]: Option }*/, indent = 0, name = false, isTop = false) /*: string */ { - let ws = indent + isTop ? 0 : 2; - let strs = R.pipe( - R.toPairs, - R.chain(([k,o]) => [ - comment(k, ws), - genOption(o, ws, name), - ]), - R.join('\n'), - )(options); - return isTop ? strs : `{\n${strs}\n${whitespace(indent)}}`; -} - -function genOption(option /*: Option*/, indent = 0, name = false, skipLeft = 0) /*: string */ { - let ws = R.repeat(' ', indent).join(''); - let [generics, paramObj, returnOrOptions] = option; - let genericNames = generics.map(R.pipe(R.match(/\w+/), R.head)); - let genericObj = R.fromPairs(R.zip(genericNames, generics)); - let params = R.toPairs(paramObj); - let rest = R.is(Object)(returnOrOptions) ? genCurried(returnOrOptions, indent) : returnOrOptions; - let uncurried = R.is(Object)(returnOrOptions) ? R.pipe( - R.toPairs, - R.chain(([k, [gens, parObj, ret]]) => [ - comment(k, indent), - genOption([R.concat(generics, gens), R.merge(paramObj, parObj), ret], indent, name, R.pipe(R.values, R.length)(paramObj)), - ]), // mergeOptions(v) - R.values, - R.when(R.length, R.append(comment('mixed', indent))), - )(returnOrOptions) : []; - let [paramInfos, retGenerics] = params.reduce(([paramTypes, generics], pair) => { - let [k,v] = pair; - let usedGenerics = R.keys(generics) - .filter(s => R.test(new RegExp(`\\b${s}\\b`), v)); - // TODO: for `keyOf` also check if the generic has been used in other used generics. - // potentially need to recheck for more as long as I've added new ones! - let remainingGenerics = R.omit(usedGenerics, generics); - return [ - R.concat(paramTypes, [[ - [k,v], - usedGenerics.map(k => generics[k]), - ]]), - remainingGenerics, - ]; - }, [[], genericObj]); - let nums = R.range(skipLeft, params.length); // number of params delegated to the right side. for 4: 0, 1, 2, 3. - let current = nums.map((num) => { - let numLeft = params.length - num; - let [left, right] = [R.take(numLeft, paramInfos), R.drop(numLeft, paramInfos)]; - let [leftParams, rightParams] = R.map(R.map(R.prop(0)))([left, right]); - let [leftGenerics, rightGenerics] = R.map(R.chain(R.prop(1)))([left, right]); - let unusedGenerics = R.values(retGenerics); - if (num) { - rightGenerics = rightGenerics.concat(unusedGenerics); - } else { - leftGenerics = leftGenerics.concat(unusedGenerics); - } - const genStr = (gens) => gens.length ? `<${gens.join(', ')}>` : ''; - const parStr = R.pipe(R.map(/*([k,v]) => `${k}: ${v}`*/ R.join(': ')), R.join(', ')); - const fnStr = (gens, pars, retVal, useArrow = false, useName = false) => - `${useName && name || ''}${genStr(gens)}(${parStr(pars)})${useArrow ? ' =>' : ':'} ${retVal}`; - let returnVal = !num ? rest : - num == 1 ? fnStr(rightGenerics, rightParams, rest, true, false) : - (`{\n${ - genOption([rightGenerics, R.fromPairs(rightParams), rest], indent + 2) //, name - }${ws}}`); - return `${ws}${fnStr(leftGenerics, leftParams, returnVal, false, true)};\n`; - }).join(''); - return uncurried.concat(current).join('\n'); -} - -const defs = { - -pathEq: [ - [], - { - p: 'Path', - v: 'any', - o: 'any', - }, - 'boolean' -], - -add: [ - [], - { - a: 'number', - b: 'number', - }, - 'number' -], - -adjust: [ - ['T'], - { - fn: '(a: T) => T', - index: 'number', - list: 'List' - }, - 'T[]' -], - -all: [ - ['T'], - { - pred: 'Pred', - list: 'List', - }, - 'boolean' -], - -allPass: [ - ['T'], - { - pred: 'Pred[]', - }, - 'Pred' -], - -always: [ - ['T'], - { - val: 'T', - }, - '() => T' -], - -add: { - base: [ - ['T extends {and?: Function}'], - { - fn1: 'T', - val2: 'boolean+any' - }, - 'boolean' - ], - no_generics: [ - [], - { - v1: 'any', - v2: 'any', - }, - 'boolean', - ] -}, - -any: [ - ['T'], - { - pred: 'Pred', - list: 'List', - }, - 'boolean', -], - -anyPass: [ - ['T'], - { - preds: 'Pred[]', - }, - 'Pred', -], - -ap: [ - ['T', 'U'], - { - fns: '((a: T) => U)[]', - xs: 'List', - }, - 'U[]', -], - -aperture: [ - ['T'], - { - n: 'number', - list: 'List', - }, - 'T[][]' -], - -append: [ - ['T', 'U'], - { - el: 'U', - list: 'List', - }, - '(T & U)[]' -], - -apply: { - // // fails, can't use ... on Args because it only indirectly represents an array... - // capture: [ - // ['Args extends any[]', 'TResult'], - // { - // fn: '(...args: Args) => TResult', - // args: 'Args', - // }, - // 'TResult', - // ], - any: [ - ['TResult'], - { - fn: '(...args: any[]) => TResult', - args: 'any[]', - }, - 'TResult', - ], -}, - -applySpec: [ - ['T'], - { - obj: 'any', - }, - 'Variadic', -], - -ascend: { - base: [ - ['T', 'U extends Struct', 'K extends keyof U'], - { - prop: 'K', - val: 'T', - obj: 'U' - }, - '{[P in K]: T} & U' - ], - 'any object as long as the type remains unchanged': [ - ['T'], - { - prop: 'Prop', - val: 'any', - obj: 'T', - }, - 'T', - ] -}, - -assoc: { - 'extend object with new property': [ - ['T', 'U extends Struct' ,'K extends string'], - { - prop: 'K', - val: 'T', - obj: 'U', - }, - '{[P in K]: T} & U' - ], - 'any object as long as the type remains unchanged': [ - ['T'], - { - prop: 'Prop', - val: 'any', - obj: 'T', - }, - 'T' - ] -}, - -assocPath: [ - ['T', 'U'], - { - path: 'Path', - val: 'T', - obj: 'U', - }, - 'U' -], - -binary: { - base: [ - ['T', 'A', 'B'], - { - fn: '(a: A, b: T, ...args: any[]) => T' - }, - '(a: A, b: B) => T' - ], - 'non generics for return func': [ - ['T'], - { - fn: 'Variadic', - }, - '(a:any, b:any) => T' - ] -}, - -bind: [ - ['T'], - { - fn: 'Variadic', - thisObj: '{}', - }, - 'Variadic' -], - -both: [ - ['T'], - { - pred1: 'Pred', - pred2: 'Pred', - }, - 'Pred', -], - -call: [ - ['T'], - { - fn: 'Variadic', - '...args': 'any[]', - }, - 'T', -], - -chain: { -'list version': [ - ['T', 'U'], - { - fn: '(n: T) => U[]', - list: 'List', - }, - 'U[]', -], -'generic chain version': [ - ['T', 'U'], - { - fn: '(n: T) => Chain', - list: 'Chain', - }, - 'Chain', -], -'function argument': [ - ['T', 'U', 'V'], - { - fn: '(v: V) => (list: List) => U[]', - monad: '(list: List) => V' - }, - '(list: List) => U[]', -] -}, - -clamp: [ - ['T'], - { - min: 'T', - max: 'T', - value: 'T', - }, - 'T', -], - -clone: { -'Objects': [ - ['T'], - { - value: 'T' - }, - 'T' -], -'Arrays': [ - ['T'], - { - value: 'List', - }, - 'T[]', -] -}, - -comparator: [ - ['T'], - { - pred: '(a: T, b: T) => boolean' - }, - '(x: T, y: T) => number' -], - -complement: [ - ['T'], - { - pred: 'Variadic', - }, - 'Variadic', -], - -compose: R.flatten(R.range(1,10).map(i => R.range(1,5).map(j => composeDef(i,j)))).join('\n'), - -composeK: R.flatten(R.range(1,10).map(i => composeKDef(i))).join('\n'), - -composeP: R.flatten(R.range(1,10).map(i => R.range(1,5).map(j => composePDef(i,j)))).join('\n'), - -concat: [ - ['T extends List'], - { - list1: 'T', - list2: 'T', - }, - 'T', -], - -cond: [ - ['T', 'U'], - { - fns: '[Pred, (v: T) => U][]', - }, - '(v: T) => U' -], - -construct: [ - [], - { - fn: 'Function', - }, - 'Function' -], - -constructN: [ - [], - { - n: 'number', - fn: 'Function', - }, - 'Function', -], - -contains: { - base: [ - [], - { - a: 'string', - list: 'string', - }, - 'boolean', - ], - generics: [ - ['T', 'R extends List'], - { - a: 'T', - list: 'R', - }, - 'boolean', - ] -}, - -converge: [ - ['T'], - { - after: 'Variadic', - fns: 'List>', - }, - 'Variadic', -], - -countBy: [ - ['T'], - { - fn: '(a: T) => Prop', - list: 'List', - }, - 'Obj', -], - -// curry - -// curryN - -dec: [ - [], - { - n: 'number', - }, - 'number' -], - -defaultTo: [ - ['T', 'U'], - { - a: 'T', - b: 'U', - }, - 'T|U', -], - -descend: [ - ['T', 'V extends Ord'], - { - comparator: '(val: T) => V', - a: 'T', - b: 'T', - }, - 'number' -], - -differenceWith: [ - ['T'], - { - pred: '(a: T, b: T) => boolean', - list1: 'List', - list2: 'List', - }, - 'T[]' -], - -dissoc: { -accurate: [['T'], { prop: 'keyof T', obj: 'T' }, 'T'], -easier: [['T'], { prop: 'Prop', obj: 'Struct' }, 'T'], -}, - -dissocPath: [ - ['T'], - { - path: 'Path', - obj: 'Struct', - }, - 'T' -], - -divide: [ - [], - { - a: 'number', - b: 'number', - }, - 'number' -], - -drop: [ - ['T extends List'], - { - n: 'number', - xs: 'T' - }, - 'T' -], - -dropLast: [ - ['T extends List'], - { - n: 'number', - xs: 'T', - }, - 'T' -], - -dropLastWhile: [ - ['T', 'R extends List'], - { - pred: 'Pred', - list: 'R' - }, - 'T[]' -], - -dropWhile: [ - ['T', 'R extends List'], - { - pred: 'Pred', - list: 'R' - }, - 'T[]' -], - -either: [ - ['T'], - { - pred1: 'Pred', - pred2: 'Pred', - }, - 'Pred' -], - -empty: [ - ['T'], - { - x: 'T', - }, - 'T' -], - -eqBy: [ - ['T'], - { - fn: '(a: T) => T', - a: 'T', - b: 'T', - }, - 'boolean' -], - -eqProps: { - base: [ - ['T', 'U'], - { - prop: 'Prop', - obj1: 'T', - obj2: 'U' - }, - 'boolean' - ], - 'less generics': [ - [], - { - prop: 'Prop', - obj1: 'any', - obj2: 'any', - }, - 'boolean' - ] -}, - -equals: [ - ['T'], - { - a: 'T', - b: 'T', - }, - 'boolean' -], - -evolve: { - base: [ - ['V'], - { - transformations: 'NestedObj<(v: any) => any>', - obj: 'V', - }, - 'V' - ], - 'no inference': [ - [], - { - transformations: 'Obj', - obj: 'any', - }, - 'T' - ] -}, - -// F - -filter: { - base: [ - ['T'], - { - pred: 'Pred', - list: 'List', - }, - 'T[]' - ], - 'functor to functor': [ - ['T'], - { - pred: 'Pred', - list: 'Functor', - }, - 'Functor[]' - ], - 'functor to array': [ - ['T'], - { - pred: 'Pred', - list: 'Functor', - }, - 'T[]' - ], - 'object': [ - ['T', 'U extends Obj'], - { - pred: 'Pred', - obj: 'U', - }, - 'Partial' - ] -}, - -find: [ - ['T'], - { - fn: '(a: T) => boolean', - list: 'List' - }, - 'T' -], - -findIndex: [ - ['T'], - { - fn: '(a: T) => boolean', - list: 'List', - }, - 'number' -], - -findLast: [ - ['T'], - { - fn: '(a: T) => boolean', - list: 'List', - }, - 'T' -], - -findLastIndex: [ - ['T'], - { - fn: '(a: T) => boolean', - list: 'List', - }, - 'number' -], - -flatten: [ - ['T'], - { - x: 'NestedArray' - }, - 'T[]' -], - -flip: { - base: [ - ['T', 'U', 'TResult'], - { - fn: '(arg0: T, arg1: U) => TResult' - }, - '(arg1:U, arg0?:T) => TResult' - ], - 'rest arguments': [ - ['T', 'U', 'Rest', 'TResult'], - { - fn: '(arg0: T, arg1: U, ...args: Rest[]) => TResult' - }, - '(arg1: U, arg0?: T, ...args: Rest[]) => TResult' - ] -}, - -forEach: [ - ['T'], - { - fn: '(x: T) => void', - list: 'List' - }, - 'T[]' -], - -forEachObjIndexed: [ - ['T', 'Inp extends Struct'], - { - fn: '(val: T, key: string, obj?: Inp) => void', - o: 'Inp', - }, - 'Inp' -], - -fromPairs: [ - ['V'], - { - pairs: 'List>', - }, - 'Obj' -], - -groupBy: [ - ['T'], - { - fn: '(a: T) => prop', - list: 'List', - }, - 'Obj' -], - -groupWith: [ - ['T'], - { - fn: '(a: T) => Prop', - list: 'List', - }, - 'Obj' -], - -gt: [ - [], - { - a: 'number', - b: 'number', - }, - 'boolean' -], - -gte: [ - [], - { - a: 'number', - b: 'number', - }, - 'boolean' -], - -has: [ - [], - { - s: 'Prop', - obj: 'Struct', - }, - 'boolean' -], - -hasIn: [ - [], - { - s: 'Prop', - obj: 'Struct', - }, - 'boolean' -], - -// head - -identical: [ - ['T'], - { - a: 'T', - b: 'T', - }, - 'boolean' -], - -// identity - -ifElse: [ - ['T', 'U', 'V'], - { - fn: 'Pred', - onTrue: '(v: T) => U', - onFalse: '(v: T) => V' - }, - '(v: T) => U|V' -], - -// inc - -indexBy: [ - ['T'], - { - fn: '(a: T) => Prop', - list: 'List', - }, - 'Obj' -], - -indexOf: [ - ['T'], - { - target: 'T', - list: 'List', - }, - 'number' -], - -// init - -insert: [ - ['T'], - { - index: 'number', - elt: 'T', - list: 'List', - }, - 'T[]' -], - -insertAll: [ - ['T', 'U'], - { - index: 'number', - elts: 'List', - list: 'List', - }, - 'Array' -], - -intersection: [ - ['T', 'U'], - { - list1: 'List', - list2: 'List', - }, - 'Array' -], - -intersectionWith: [ - ['T'], - { - pred: '(a: T, b: T) => boolean', - list1: 'List', - list2: 'List', - }, - 'T[]' -], - -intersperse: [ - ['T'], - { - separator: 'T', - list: 'List', - }, - 'T[]' -], - -into: [ - ['T', 'U', 'V extends AccOpts'], - { - acc: 'V', - xf: '(list: List) => U', - list: 'List', - }, - 'U' -], - -// invert - -invoker: [ - ['T', 'R'], - { - len: 'number', - name: 'Prop', - obj: 'T', - }, - 'R' -], - -is: [ - ['T'], - { - ctor: 'Type', - val: 'any', - }, - 'val is T' -], - -// isArrayLike - -// isEmpty - -// isNaN - -// isNil - -join: [ - [], - { - x: 'Prop', - xs: 'Array', - }, - 'string' -], - -juxt: [ - ['T', 'U'], - { - fns: '{(...args: T[]): U}[]' - }, - '(...args: T[]) => U[]' -], - -// keys - -// keysIn - -// last - -lastIndexOf: [ - ['T'], - { - target: 'T', - list: 'List', - }, - 'number' -], - -// length - -lens: { - base: [ - ['V', 'U extends Struct'], - { - getter: '(s: U) => V', - setter: '(a: V, s: U) => U', - }, - 'ManualLens' - ], - 'allows setter to change value type': [ - ['T', 'U', 'V'], - { - getter: '(s: T) => U', - setter: '(a: U, s: T) => V' - }, - 'Lens' - ] -}, - -// lensIndex - -// lensPath - -lift: R.flatten(R.range(0,10).map(i => liftDef(i))).join('\n'), - -liftN: R.flatten(R.range(0,10).map(i => liftNDef(i, true))).join('\n'), // false - -lt: [ - [], - { - a: 'number', - b: 'number', - }, - 'boolean' -], - -lte: [ - [], - { - a: 'number', - b: 'number', - }, - 'boolean' -], - -map: { - base: [['T','U'], { fn: '(value: T) => U' }, { - array: [[], { list: 'List' }, 'U[]'], - obj_keyof: [['M extends Obj'], { obj: 'M' }, '{[K in keyof M]: U}'], - obj_record: [['K extends string'], { obj: 'Record' }, 'Record'], - functor: [[], { obj: 'Functor' }, 'Functor'], - // compose: [['Args extends any[]'], { f1: '(...args: Args) => T' }, '(...args: Args) => U'], - compose: [[], { f1: '(...args: any[]) => T' }, '(...args: any[]) => U'], - }], -}, - -// map: { -// base: [ -// ['T', 'U'], -// { -// fn: '(val: T) => U', -// list: 'List', -// }, -// 'U[]' -// ], -// 'object: keyof version': [ -// ['T', 'U', 'M extends Obj'], -// { -// fn: '(val: T) => U', -// obj: 'M', -// }, -// '{[K in keyof M]: U}' -// ], -// 'object: Record version': [ -// ['T', 'U', 'K extends string'], -// { -// fn: '(val: T) => U', -// obj: 'Record', -// }, -// 'Record' -// ], -// 'functor': [ -// ['T', 'U'], -// { -// fn: '(val: T) => U', -// obj: 'Functor', -// }, -// 'Functor' -// ] -// }, - -mapAccum: [ - ['T', 'U', 'TResult'], - { - fn: '(acc: U, value: T) => [U, TResult]', - acc: 'U', - list: 'List', - }, - '[U, TResult[]]' -], - -mapAccumRight: [ - ['T', 'U', 'TResult'], - { - fn: '(value: T, acc: U) => [TResult, U]', - acc: 'U', - list: 'List', - }, - '[TResult[], U]' -], - -mapIndexed: [ - ['T', 'U', 'V'], - { - fn: '(value: T, acc: U) => [TResult, U]', - acc: 'U', - list: 'List', - }, - '[TResult[], U]', -], - -mapObjIndexed: [ - ['T', 'V', 'M extends Obj'], - { - fn: '(value: T, key: string, obj?:M) => V', - obj: 'M' - }, - '{[K in keyof M]: V}' -], - -match: [ - [], - { - regexp: 'RegExp', - str: 'string' - }, - 'string[]' -], - -mathMod: [ - [], - { - a: 'number', - b: 'number', - }, - 'number' -], - -max: [ - ['T extends Ord'], - { - a: 'T', - b: 'T', - }, - 'T' -], - -maxBy: [ - ['T'], - { - keyFn: '(a: T) => Ord', - a: 'T', - b: 'T', - }, - 'T' -], - -// mean - -// median - -// memoize - -merge: [ - ['V1', 'V2', 'T1 extends Struct', 'T2 extends Struct'], - { - a: 'T1', - b: 'T2', - }, - 'T1 & T2' -], - -mergeAll: [ - ['T'], - { - list: 'List', - }, - 'T' -], - -mergeWith: [ - ['U', 'V'], - { - fn: '(x: any, z: any) => any', - a: 'U', - b: 'V', - }, - 'U & V' -], - -mergeWithKey: { - 'mergeWithKey': [ - ['U', 'V'], - { - fn: '(str: string, x: any, z: any) => any', - a: 'U', - b: 'V', - }, - 'U & V' - ] -}, - -minBy: [ - ['T'], - { - keyFn: '(a: T) => Ord', - a: 'T', - b: 'T' - }, - 'T' -], - -over: { -'Functor version': [ - ['V', 'T extends Functor'], - { - lens: 'Lens|ManualLens|UnknownLens', - fn: '(v: V) => V', - value: 'T', - }, - 'T' -], -'Functor version applied to array': [ - ['V', 'T extends List'], - { - lens: 'Lens|ManualLens|UnknownLens', - fn: '(v: V) => V', - value: 'T', - }, - 'V[]' -], -'unbound value': [ - ['T', 'V'], - { - lens: 'Lens|ManualLens|UnknownLens', - fn: '(v: V) => V', - value: 'T', - }, - 'T' -] -}, - -path: R.flatten(R.range(2,10).map(i => pathDef(i))).join('\n'), - -pathOr: [ - ['T'], - { - d: 'T', - p: 'Path', - obj: 'Struct', - }, - 'T|any' -], - -pathSatisfies: [ - ['T'], - { - fn: 'Pred', - p: 'Path', - obj: 'any', - }, - 'boolean' -], - -pipe: R.flatten(R.range(1,10).map(i => R.range(1,5).map(j => pipeDef(i,j)))).join('\n'), - -pipeK: R.flatten(R.range(1,10).map(i => pipeKDef(i))).join('\n'), - -pipeP: R.flatten(R.range(1,10).map(i => R.range(1,5).map(j => pipePDef(i,j)))).join('\n'), - -propEq: [ - ['T extends Struct'], - { - name: 'Prop', - val: 'any', - obj: 'T', - }, - 'boolean' -], - -propOr: [['T'], { val: 'T' }, { - record: [['K extends string', 'V', 'U extends Record'], { p: 'K', obj: 'U' }, 'V|T'], - keyof: [['U', 'K extends keyof U'], { p: 'K', obj: 'U' }, 'U[K]|T'], - same: [[], { p: 'Prop', obj: 'Struct' }, 'T'], - unbound: [['U', 'V'], { p: 'Prop', obj: 'U' }, 'V'], -}], - -propStatisfies: { -'Record (curry-friendly)': [ - ['V', 'K extends string', 'U extends Record'], - { - pred: 'Pred', - name: 'K', - obj: 'U', - }, - 'boolean' -], -'keyof, info too late on currying': [ - ['T', 'U'], - { - pred: 'Pred', - name: 'Prop', - obj: 'U' - }, - 'boolean' -] -}, - -reduce: [ - ['T', 'TResult', 'R extends List'], - { - fn: '(acc: TResult, elem: T, idx: number, list: R) => TResult|Reduced', - acc: 'TResult', - list: 'R', - }, - 'TResult' -], - -reduceBy: [ - ['T', 'TResult', 'R extends List'], - { - valueFn: '(acc: TResult, elem: T, idx: number, list: R) => TResult', - acc: 'TResult|any', - keyFn: '(elem: T) => string', - list: 'R', - }, - 'TResult' -], - -reduceRight: [ - ['T', 'TResult'], - { - fn: '(elem: T, acc: TResult) => TResult|Reduced', - acc: 'TResult|any', - list: 'List', - }, - 'TResult' -], - -reduceWhile: [ - ['T', 'TResult'], - { - pred: '(acc: TResult, elem: T) => boolean', - fn: '(acc: TResult, elem: T) => TResult|Reduced', - acc: 'TResult', - list: 'List', - }, - 'TResult' -], - -remove: [ - ['T'], - { - start: 'number', - count: 'number', - list: 'List', - }, - 'T[]' -], - -replace: [ - [], - { - pattern: 'RegExp|Prop', - replacement: 'Prop', - str: 'string', - }, - 'string' -], - -scan: [ - ['T', 'TResult'], - { - fn: '(acc: TResult, elem: T) => TResult|Reduced', - acc: 'TResult', - list: 'List' - }, - 'TResult[]' -], - -set: { - base: [ - ['T', 'U'], - { - lens: 'Lens', - a: 'U', - obj: 'T' - }, - 'T' - ], - unknown: [ - ['T'], - { - lens: 'UnknownLens', - a: 'any', - obj: 'T', - }, - 'T' - ] -}, - -slice: [ - ['T extends List'], - { - a: 'number', - b: 'number', - list: 'T', - }, - 'T' -], - -symmetricDifferenceWith: [ - ['T'], - { - pred: '(a: T, b: T) => boolean', - list1: 'List', - list2: 'List', - }, - 'T[]' -], - -transduce: [ - ['T', 'U'], - { - xf: '(arg: List) => List', - fn: '(acc: List, val:U) => List', - acc: 'List', - list: 'List' - }, - 'U' -], - -traverse: { - base: [ - ['T', 'U'], - { - ap: '(v: T) => Applicative', - fn: '(v: T) => Applicative', - traversable: 'List', - }, - 'Applicative>' - ], - 'general ADT case': [ - ['T', 'U'], - { - ap: '(v: T) => Applicative', - fn: '(v: T) => Applicative', - traversable: 'List', - }, - 'Applicative>' - ] -}, - -unionWith: [ - ['T'], - { - pred: '(a: T, b: T) => boolean', - list1: 'List', - list2: 'List', - }, - 'T[]' -], - -until: [ - ['T', 'U'], - { - pred: 'Pred', - fn: '(val: T) => U', - init: 'U', - }, - 'U' -], - -update: [ - ['T'], - { - index: 'number', - value: 'T', - list: 'List' - }, - 'T[]' -], - -when: [ - ['T', 'U'], - { - pred: 'Pred', - whenTrueFn: '(a: T) => U', - obj: 'T', - }, - 'U' -], - -and: { - 'dispatch to some `and` method:': [ - ['T extends {and?: Function}'], - { - fn1: 'T', - val2: 'boolean|any' - }, - 'boolean' - ], - 'no generics': [ - [], - { - v1: 'any', - v2: 'any', - }, - 'boolean' - ] -}, - -difference: [ - ['T'], - { - list1: 'List', - list2: 'List', - }, - 'T[]', -], - -// dropRepeats - -// dropRepeatsWith - -identity: [ - ['T'], - { - a: 'T' - }, - 'T' -], - -inc: [ - [], - { - n: 'number', - }, - 'number', -], - -init: [ - ['T extends List'], - { - list: 'T', - }, - 'T' -], - -invert: [ - [], - { - obj: 'Struct' - }, - 'Obj>' -], - -invertObj: [ - [], - { - obj: 'Struct' - }, - 'Obj' -], - -isArrayLike: [ - [], - { - val: 'any', - }, - 'val in List' -], - -isEmpty: [ - [], - { - val: 'any', - }, - 'boolean' -], - -isNil: [ - [], - { - val: 'any', - }, - 'boolean', -], - -keys: [ - [], - { - x: 'Struct', - }, - 'string[]' -], - -keysIn: [ - [], - { - obj: 'Struct', - }, - 'string[]' -], - -last: [ - ['T', 'R extends List'], - { - list: 'R', - }, - 'T' -], - -length: [ - [], - { - list: 'List', - }, - 'number' -], - -lensIndex: { - 'generics': [ - ['T'], - { - n: 'number' - }, - 'ManualLens' - ], - 'non-generic': [ - [], - { - n: 'number', - }, - 'UnknownLens' - ], -}, - -lensPath: { - 'generics': [ - ['T'], - { - path: 'Path' - }, - 'ManualLens' - ], - 'non-generic': [ - [], - { - path: 'Path', - }, - 'UnknownLens' - ], -}, - -lensProp: { - 'generics': [ - ['T'], - { - prop: 'Prop' - }, - 'ManualLens' - ], - 'non-generic': [ - [], - { - prop: 'Prop', - }, - 'UnknownLens' - ], -}, - -mean: [ - [], - { - list: 'List', - }, - 'number' -], - -median: [ - [], - { - list: 'List', - }, - 'number' -], - -memoize: [ - ['T'], - { - fn: 'Variadic' - }, - 'Variadic' -], - -min: [ - ['T extends Ord'], - { - a: 'T', - b: 'T', - }, - 'T' -], - -modulo: [ - [], - { - a: 'number', - b: 'number', - }, - 'number' -], - -multiply: [ - [], - { - a: 'number', - b: 'number', - }, - 'number' -], - -nAry: [ - ['T'], - { - n: 'number', - fn: 'Variadic', - }, - 'Variadic' -], - -negate: [ - [], - { - n: 'number', - }, - 'number', -], - -none: [ - ['T'], - { - fn: '(a: T) => boolean', - list: 'List', - }, - 'boolean' -], - -not: [ - [], - { - value: 'any', - }, - 'boolean', -], - -nth: [ - ['T'], - { - n: 'number', - list: 'list' - }, -], - -nthArg: [ - [], - { - n: 'number', - }, - '(...a : T[]) => T' -], - -objOf: [ - ['K extends string', 'V', 'T extends Record'], - { - key: 'K', - value: 'V', - }, - 'T' -], - -of: [ - ['T'], - { - x: 'T' - }, - 'T[]' -], - -omit: [ - ['T'], - { - names: 'List', - obj: 'T', - }, - 'T' -], - -once: [ - ['T'], - { - fn: 'Variadic', - }, - 'Variadic' -], - -or: { - 'dispatch to some `or` method': [ - ['T extends {or?: (alt: U) => T|U}', 'U'], - { - fn1: 'T', - val2: 'U' - }, - 'T|U' - ], - 'values': [ - ['T', 'U'], - { - a: 'T', - b: 'U', - }, - 'T|U' - ], -}, - -pair: [ - ['F', 'S'], - { - fst: 'F', - snd: 'S', - }, - '[F, S]' -], - -partial: [ - ['T'], - { - fn: 'Variadic', - args: 'any[]', - }, - 'Variadic', -], - -partialRight: [ - ['T'], - { - fn: 'Variadic', - args: 'any[]', - }, - 'Variadic', -], - -partition: { - 'arrays': [ - ['T'], - { - fn: '(a: T) => boolean', - list: 'List', - }, - '[T[], T[]]' - ], - 'objects': [ - ['T extends Obj', 'U extends Obj', 'V'], - { - fn: '(a: V) => boolean', - obj: 'T & U' - }, - '[T, U]' - ], - 'objects, alternative notation': [ - ['T', 'U extends Obj'], - { - fn: '(a: T) => boolean', - obj: 'U', - }, - '[Partial, Partial]' - ], -}, - -pick: { - 'generic 1': [ - ['T', 'K extends keyof T'], - { - names: 'List', - obj: 'T' - }, - 'Pick' - ], - 'generic 2': [ - ['T'], - { - names: 'List', - obj: 'T', - }, - 'Partial' - ], -}, - -pickAll: [ - ['T', 'K'], - { - names: 'List', - obj: 'T', - }, - 'Partial' -], - -pickBy: [ - ['T'], - { - pred: 'ObjPred', - obj: 'T', - }, - 'Partial' -], - -pluck: { - 'infer': [ - ['T extends Struct', 'K extends keyof T'], - { - p: 'K', - list: 'List' - }, - 'T[K][]' - ], - 'supply return object type manually when unable to infer it...': [ - ['T'], - { - p: 'Prop', - list: 'Struct[]', - }, - 'T[]', - ], -}, - -prepend: [ - ['T'], - { - el: 'T', - list: 'List', - }, - 'T[]' -], - -product: [ - [], - { - list: 'List', - }, - 'number' -], - -project: { - 'infer': [ - ['T', 'K extends keyof T'], - { - props: 'List', - objs: 'List', - }, - 'Pick[]' - ], - 'supply return object type manually when unable to infer it...': [ - ['T', 'U'], - { - props: 'List', - objs: 'List', - }, - 'U[]' - ], -}, - -prop: { - 'keyof version': [ - ['T', 'K extends keyof T'], - { - p: 'K', - obj: 'T', - }, - 'T[K]', - ], - 'Record version, more curry-friendly': [ - ['K extends string', 'V', 'T extends Record'], - { - p: 'K', - obj: 'T', - }, - 'V', - ], -}, - -propIs: { - 'Record': [ - ['T extends Function', 'K extends string', 'V', 'U extends Record'], - { - type: 'T', - name: 'K', - obj: 'U', - }, - 'obj is (U & Record)' - ], - 'curry-friendlier fallback': [ - [], - { - type: 'Function', - name: 'Prop', - obj: 'Struct' - }, - 'boolean' - ], - // unsure - // 'mixed': -}, - -propSatisfies: { - 'Record': [ - ['V', 'K extends string', 'U extends Record'], - { - pred: 'Pred', - name: 'K', - obj: 'U', - }, - 'boolean', - ], - 'keyof, info too late on currying': [ - ['T', 'U'], - { - pred: 'Pred', - name: 'Pred', - obj: 'U', - }, - 'boolean' - ], -}, - -props: [ - ['T'], - { - ps: 'List', - obj: 'Struct', - }, - 'T[]' -], - -range: [ - [], - { - from: 'number', - to: 'number', - }, - 'number[]', -], - -reduced: [ - ['T'], - { - el: 'T' - }, - 'Reduced' -], - -reject: { - 'array': [ - ['T'], - { - pred: 'Pred', - list: 'List', - }, - 'T[]', - ], - 'functor to functor': [ - ['T'], - { - pred: 'Pred', - list: 'Functor', - }, - 'Functor', - ], - 'functor to array': [ - ['T'], - { - pred: 'Pred', - list: 'Functor', - }, - 'T[]' - ], - 'object': [ - ['T', 'U extends Obj'], - { - pred: 'Pred', - obj: 'U', - }, - 'Partial' - ], - // mixed -}, - -repeat: [ - ['T'], - { - a: 'T', - n: 'number', - }, - 'T[]', -], - -reverse: [ - ['T'], - { - list: 'List', - }, - 'T[]' -], - -sequence: { - 'common case of array as traversable': [ - ['T'], - { - fn: '(v: T) => Applicative', - traversable: 'List>', - }, - 'Applicative>' - ], - 'general ADT case:': [ - ['T'], - { - fn: '(v: T) => Applicative', - traversable: 'Traversable >', - }, - 'Applicative>' - ], - // mixed -}, - -sort: [ - ['T'], - { - fn: '(a: T, b: T) => number', - list: 'List' - }, - 'T[]' -], - -sortBy: [ - ['T'], - { - fn: '(a: T) => string', - list: 'List' - }, - 'T[]' -], - -sortWith: [ - ['T'], - { - comparators: 'List<(a: T, b: T) => number>', - list: 'List' - }, - 'T[]', -], - -split: [ - [], - { - sep: 'RegExp|Prop', - str: 'string', - }, - 'string[]', -], - -splitAt: { - 'string': [ - [], - { - index: 'number', - list: 'string', - }, - 'string[]' - ], - 'array': [ - ['T'], - { - index: 'number', - list: 'List', - }, - 'T[][]' - ], - // mixed -}, - -splitEvery: [ - ['T', 'R extends List'], - { - a: 'number', - list: 'R', - }, - 'R[]', -], - -splitWhen: [ - ['T', 'R extends List'], - { - pred: 'Pred', - list: 'R', - }, - 'R[]', -], - -subtract: [ - [], - { - a: 'number', - b: 'number', - }, - 'number', -], - -sum: [ - [], - { - list: 'List', - }, - 'number' -], - -symmetricDifference: [ - ['T'], - { - list1: 'List', - list2: 'List', - }, - 'T[]' -], - -tail: [ - ['T exetnds List'], - { - list: 'T' - }, - 'T' -], - -take: [ - ['T extends List'], - { - n: 'number', - xs: 'T', - }, - 'T' -], - -takeLast: [ - ['T extends List'], - { - n: 'number', - xs: 'T', - }, - 'T' -], - -takeLastWhile: [ - ['T', 'R extends List'], - { - pred: 'Pred', - list: 'R', - }, - 'R' -], - -takeWhile: [ - ['T', 'R extends List'], - { - pred: 'Pred', - list: 'R', - }, - 'R' -], - -tap: [ - ['T'], - { - fn: '(a: T) => any', - value: 'T' - }, - 'T' -], - -test: [ - [], - { - regexp: 'RegExp', - str: 'Prop', - }, - 'boolean' -], - -times: [ - ['T'], - { - fn: '(i: number) => T', - n: 'number', - }, - 'T[]' -], - -toLower: [ - [], - { - str: 'string', - }, - 'string' -], - -toPairs: [ - ['T'], - { - obj: 'Obj', - }, - '[string, T][]' -], - -toPairsIn: { - 'generics': [ - ['T'], - { - obj: 'Obj', - }, - '[string, T][]' - ], - 'non-generic': [ - [], - { - obj: 'Object', - }, - '[string, any][]' - ], -}, - -toString: [ - [], - { - val: 'StringRepresentable | any' - }, - 'string' -], - -toUpper: [ - [], - { - str: 'string', - }, - 'string' -], - -transpose: { - 'generics 1': [ - ['T'], - { - list: 'List>' - }, - 'T[][]' - ], - 'generics 2': [ - [], - { - list: 'List>', - }, - 'any[][]' - ], -}, - -trim: [ - [], - { - str: 'string', - }, - 'string' -], - -tryCatch: [ - ['T'], - { - tryer: 'Variadic', - catcher: 'Variadic', - }, - 'Variadic' -], - -type: [ - [], - { - val: 'any', - }, - 'string' -], - -unapply: [ - ['T'], - { - fn: '(args: any[]) => T', - }, - 'Variadic' -], - -unary: [ - ['T', 'U'], - { - fn: '(a: T, ...args: any[]) => U', - }, - '(a: T) => U' -], - -uncurryN: [ - ['T'], - { - len: 'number', - fn: '(a: any) => any', - }, - 'Variadic' -], - -unfold: [ - ['T', 'TResult'], - { - fn: '(seed: T) => [TResult, T] | false', - seed: 'T', - }, - 'TResult[]' -], - -union: [ - ['T'], - { - as: 'List', - bs: 'List', - }, - 'T[]' -], - -uniq: [ - ['T'], - { - list: 'List', - }, - 'T[]' -], - -uniqBy: [ - ['T', 'U'], - { - fn: '(a: T) => U', - list: 'List', - }, - 'T[]' -], - -uniqWith: [ - ['T', 'U'], - { - pred: '(x: T, y: T) => boolean', - list: 'List', - }, - 'T[]' -], - -unless: [ - ['T', 'U'], - { - pred: 'Pred', - whenFalseFn: '(a: T) => U', - obj: 'T', - }, - 'U' -], - -unnest: [ - ['T'], - { - x: 'List>', - }, - 'T[]' -], - -useWith: [ - ['T'], - { - fn: 'Variadic', - transformers: 'List', - }, - 'Variadic' -], - -values: { - 'Struct': [ - ['T'], - { - obj: 'Struct', - }, - 'T[]' - ], - 'Object': [ - ['T'], - { - obj: 'Object', - }, - 'any[]' - ] -}, - -valuesIn: { - 'Struct': [ - ['T'], - { - obj: 'Struct', - }, - 'T[]' - ], - 'Object': [ - ['T'], - { - obj: 'Object', - }, - 'any[]' - ] -}, - -view: { - 'smart approach, unreliable': [ - ['T', 'U'], - { - lens: 'Lens', - obj: 'T', - }, - 'U' - ], - 'lens with type manually set': [ - ['T'], - { - lens: 'ManualLens', - obj: 'Struct', - }, - 'T' - ], - 'unknown lens, manually supply return type. does this add to the above case?': [ - ['T'], - { - lens: 'UnknownLens', - obj: 'Struct', - }, - 'any' - ], -}, - -where: { - 'heterogeneous version': [ - ['T extends Obj'], - { - spec: '{[P in keyof K]?: Pred}', - testObj: 'T', - }, - 'boolean' - ], - 'homogeneous version': [ - ['T'], - { - spec: 'Obj>', - testObj: 'Obj' - }, - 'boolean' - ], - 'DIY "fill in the type params yourself" version': [ - ['T', 'U'], - { - spec: 'T', - testObj: 'U' - }, - 'boolean' - ], -}, - -whereEq: { - 'heterogeneous version': [ - ['T extends Obj'], - { - spec: 'Partial', - testObj: 'T', - }, - 'boolean' - ], - 'homogeneous version': [ - ['T'], - { - spec: 'Obj', - testObj: 'Obj' - }, - 'boolean' - ], - 'DIY "fill in the type params yourself" version': [ - ['T', 'U'], - { - spec: 'T', - testObj: 'U', - }, - 'boolean' - ], -}, - -without: [ - ['T'], - { - list1: 'List', - list2: 'List', - }, - 'T[]' -], - -xprod: [ - ['K', 'V'], - { - as: 'List', - bs: 'List', - }, - 'KeyValuePair[]' -], - -zip: [ - ['K', 'V'], - { - list1: 'List', - list2: 'List', - }, - 'KeyValuePair[]' -], - -zipObj: [ - ['T'], - { - keys: 'List', - values: 'List', - }, - 'Obj' -], - -zipWith: [ - ['T', 'U', 'TResult'], - { - fn: '(x: T, y: U) => TResult', - list1: 'List', - list2: 'List', - }, - 'TResult[]' -], - -F: 'F(): false;', - -T: 'T(): true;', - -head: { - 'triple': [ - ['T0', 'T1', 'T2'], - { - list: '[T0, T1, T2]', - }, - 'T0', - ], - 'tuple': [ - ['T0', 'T1'], - { - list: '[T0, T1]', - }, - 'T0', - ], - 'single': [ - ['T'], - { - list: '[T]', - }, - 'T' - ], - 'any': [ - ['T extends List'], - { - list: 'T' - }, - 'any' - ] -}, - -curryN: [ - ['T'], - { - length: 'number', - fn: 'Variadic' - }, - 'Variadic', -], - -}; - -let defStrs = R.mapObjIndexed((v, k) => - !R.is(Object, v) ? v : // string - Array.isArray(v) ? - genOption(v, 0, k) : // array - genCurried(v, 0, k, true) // object -)(defs); - -R.pipe(R.values, R.join('\n\n'))(defStrs); - diff --git a/src/_assocPath.d.ts b/src/_assocPath.d.ts deleted file mode 100644 index 9c86e64..0000000 --- a/src/_assocPath.d.ts +++ /dev/null @@ -1,38 +0,0 @@ -/** - * This is auto generated source. - */ - -import { Path } from '../interfaces' - -interface assocPath { - /** - * 1Returns a new function much like the supplied one, except that the first two arguments' - * order is reversed. - */ - (path: Path, val: T, obj: U): U; - /** - * 2Returns a new function much like the supplied one, except that the first two arguments' - * order is reversed. - */ - (path: Path, val: T): { - (obj: U): U; - }; - /** - * 3Returns a new function much like the supplied one, except that the first two arguments' - * order is reversed. - */ - - (path: Path): { - /** - * 4Returns a new function much like the supplied one, except that the first two arguments' - * order is reversed. - */ - (val: T, obj: U): U; - (val: T): { - (obj: U): U; - }; - }; -} -declare const x: assocPath - -export = x diff --git a/src/assocPath.d.ts b/src/assocPath.d.ts index 720a64d..10aeed7 100644 --- a/src/assocPath.d.ts +++ b/src/assocPath.d.ts @@ -12,8 +12,7 @@ interface AssocPath { * Note: Tuples are not supported by typings. * Max path depth typed is 5. */ - ( - path: [P1] & { 1?: void }, value: T, obj: O): O; + (path: Path, val: T, obj: O): O; /** * Makes a shallow clone of an object, setting or overriding * the nodes required to create the given path, and placing the specific @@ -21,113 +20,17 @@ interface AssocPath { * Note: Tuples are not supported by typings. * Max path depth typed is 5. */ - (path: [P1, P2] & { 2?: void }, - value: T, obj: O): O; - /** - * Makes a shallow clone of an object, setting or overriding - * the nodes required to create the given path, and placing the specific - * value at the tail end of that path. - * Note: Tuples are not supported by typings. - * Max path depth typed is 5. - */ - ( - path: [P1, P2, P3] & { 3?: void }, value: T, obj: O): O; - /** - * Makes a shallow clone of an object, setting or overriding - * the nodes required to create the given path, and placing the specific - * value at the tail end of that path. - * Note: Tuples are not supported by typings. - * Max path depth typed is 5. - */ - ( - path: [P1, P2, P3, P4] & { 4?: void }, value: T, obj: O): O; - /** - * Makes a shallow clone of an object, setting or overriding - * the nodes required to create the given path, and placing the specific - * value at the tail end of that path. - * Note: Tuples are not supported by typings. - * Max path depth typed is 5. - */ - ( - path: [P1, P2, P3, P4, P5] & { 5?: void }, value: T, obj: O): O; - (path: [P1] & { 1?: void }, value: T): { - (obj: O): O; - } - ( - path: [P1, P2] & { 2?: void }, value: T): { - (obj: O): O; - } - (path: [P1, P2, P3] & { 3?: void }, value: T): { - (obj: O): O; - } - ( - path: [P1, P2, P3, P4] & { 4?: void }, value: T): { - ( - obj: O): O; - } - (path: [P1, P2, P3, P4, P5] & { 5?: void }, - value: T): { - < - O extends {[K1 in P1]: {[K2 in P2]: {[K3 in P3]: {[K4 in P4]: {[K5 in P5]: T}}}}}>( - obj: O): O; - } - (path: [P1] & { 1?: void }): { - (value: T): { - (obj: O): O; - } - (value: T, obj: O): O; - } - ( - path: [P1, P2] & { 2?: void }): { - (value: T): { - (obj: O): O; - } - (value: T, obj: O): O; - } - (path: [P1, P2, P3] & { 3?: void }): { - (value: T): { - (obj: O): O; - } - (value: T, - obj: O): O; - } - ( - path: [P1, P2, P3, P4] & { 4?: void }): { - (value: T): { - ( - obj: O): O; - } - ( - value: T, obj: O): O; + (path: Path, val: T): { + (obj: O): O; } - (path: [P1, P2, P3, P4, P5] & { 5?: void }): { - (value: T): { - < - O extends {[K1 in P1]: {[K2 in P2]: {[K3 in P3]: {[K4 in P4]: {[K5 in P5]: T}}}}}>( - obj: O): O; + (path: Path): { + (val: T, obj: O): O; + (val: T): { + (obj: O): O; } - ( - value: T, obj: O): O; } } declare const assocPath: AssocPath -export = assocPath +export = assocPath diff --git a/src/path.d.ts b/src/path.d.ts index e94b423..57fb5d8 100644 --- a/src/path.d.ts +++ b/src/path.d.ts @@ -2,1194 +2,1052 @@ * This is auto generated source. */ -/** - * Retrieve the value at a given path. - * Note: Tuples are not supported by typings. - * Max path depth typed is 5. - */ -declare function path(path: [P1] & { 1?: void }, - obj: {[K1 in P1]: T}): T; - -/** - * Retrieve the value at a given path. - * Note: Tuples are not supported by typings. - * Max path depth typed is 5. - */ -declare function path(path: [P1] & { 1?: void }, - obj: T[]): T; - -/** - * Retrieve the value at a given path. - * Note: Tuples are not supported by typings. - * Max path depth typed is 5. - */ -declare function path( - path: [P1, P2] & { 2?: void }, obj: {[K1 in P1]: {[K2 in P2]: T}}): T; - -/** - * Retrieve the value at a given path. - * Note: Tuples are not supported by typings. - * Max path depth typed is 5. - */ -declare function path( - path: [P1, P2] & { 2?: void }, obj: {[K1 in P1]: T[]}): T; - -/** - * Retrieve the value at a given path. - * Note: Tuples are not supported by typings. - * Max path depth typed is 5. - */ -declare function path( - path: [P1, P2] & { 2?: void }, obj: {[K2 in P2]: T}[]): T; - -/** - * Retrieve the value at a given path. - * Note: Tuples are not supported by typings. - * Max path depth typed is 5. - */ -declare function path( - path: [P1, P2] & { 2?: void }, obj: T[][]): T; - -/** - * Retrieve the value at a given path. - * Note: Tuples are not supported by typings. - * Max path depth typed is 5. - */ -declare function path(path: [P1, P2, P3] & { 3?: void }, - obj: {[K1 in P1]: {[K2 in P2]: {[K3 in P3]: T}}}): T; - -/** - * Retrieve the value at a given path. - * Note: Tuples are not supported by typings. - * Max path depth typed is 5. - */ -declare function path(path: [P1, P2, P3] & { 3?: void }, - obj: {[K1 in P1]: {[K2 in P2]: T[]}}): T; - -/** - * Retrieve the value at a given path. - * Note: Tuples are not supported by typings. - * Max path depth typed is 5. - */ -declare function path(path: [P1, P2, P3] & { 3?: void }, - obj: {[K1 in P1]: {[K3 in P3]: T}[]}): T; - -/** - * Retrieve the value at a given path. - * Note: Tuples are not supported by typings. - * Max path depth typed is 5. - */ -declare function path(path: [P1, P2, P3] & { 3?: void }, - obj: {[K1 in P1]: T[][]}): T; - -/** - * Retrieve the value at a given path. - * Note: Tuples are not supported by typings. - * Max path depth typed is 5. - */ -declare function path(path: [P1, P2, P3] & { 3?: void }, - obj: {[K2 in P2]: {[K3 in P3]: T}}[]): T; - -/** - * Retrieve the value at a given path. - * Note: Tuples are not supported by typings. - * Max path depth typed is 5. - */ -declare function path(path: [P1, P2, P3] & { 3?: void }, - obj: {[K2 in P2]: T[]}[]): T; - -/** - * Retrieve the value at a given path. - * Note: Tuples are not supported by typings. - * Max path depth typed is 5. - */ -declare function path(path: [P1, P2, P3] & { 3?: void }, - obj: {[K3 in P3]: T}[][]): T; - -/** - * Retrieve the value at a given path. - * Note: Tuples are not supported by typings. - * Max path depth typed is 5. - */ -declare function path(path: [P1, P2, P3] & { 3?: void }, obj: T[][][]): T; - -/** - * Retrieve the value at a given path. - * Note: Tuples are not supported by typings. - * Max path depth typed is 5. - */ -declare function path( - path: [P1, P2, P3, P4] & { 4?: void }, - obj: {[K1 in P1]: {[K2 in P2]: {[K3 in P3]: {[K4 in P4]: T}}}}): T; - -/** - * Retrieve the value at a given path. - * Note: Tuples are not supported by typings. - * Max path depth typed is 5. - */ -declare function path( - path: [P1, P2, P3, P4] & { 4?: void }, - obj: {[K1 in P1]: {[K2 in P2]: {[K3 in P3]: T[]}}}): T; - -/** - * Retrieve the value at a given path. - * Note: Tuples are not supported by typings. - * Max path depth typed is 5. - */ -declare function path( - path: [P1, P2, P3, P4] & { 4?: void }, - obj: {[K1 in P1]: {[K2 in P2]: {[K4 in P4]: T}[]}}): T; - -/** - * Retrieve the value at a given path. - * Note: Tuples are not supported by typings. - * Max path depth typed is 5. - */ -declare function path( - path: [P1, P2, P3, P4] & { 4?: void }, - obj: {[K1 in P1]: {[K2 in P2]: T[][]}}): T; - -/** - * Retrieve the value at a given path. - * Note: Tuples are not supported by typings. - * Max path depth typed is 5. - */ -declare function path( - path: [P1, P2, P3, P4] & { 4?: void }, - obj: {[K1 in P1]: {[K3 in P3]: {[K4 in P4]: T}}[]}): T; - -/** - * Retrieve the value at a given path. - * Note: Tuples are not supported by typings. - * Max path depth typed is 5. - */ -declare function path( - path: [P1, P2, P3, P4] & { 4?: void }, - obj: {[K1 in P1]: {[K3 in P3]: T[]}[]}): T; - -/** - * Retrieve the value at a given path. - * Note: Tuples are not supported by typings. - * Max path depth typed is 5. - */ -declare function path( - path: [P1, P2, P3, P4] & { 4?: void }, - obj: {[K1 in P1]: {[K4 in P4]: T}[][]}): T; - -/** - * Retrieve the value at a given path. - * Note: Tuples are not supported by typings. - * Max path depth typed is 5. - */ -declare function path( - path: [P1, P2, P3, P4] & { 4?: void }, obj: {[K1 in P1]: T[][][]}): T; - -/** - * Retrieve the value at a given path. - * Note: Tuples are not supported by typings. - * Max path depth typed is 5. - */ -declare function path( - path: [P1, P2, P3, P4] & { 4?: void }, - obj: {[K2 in P2]: {[K3 in P3]: {[K4 in P4]: T}}}[]): T; - -/** - * Retrieve the value at a given path. - * Note: Tuples are not supported by typings. - * Max path depth typed is 5. - */ -declare function path( - path: [P1, P2, P3, P4] & { 4?: void }, - obj: {[K2 in P2]: {[K3 in P3]: T[]}}[]): T; - -/** - * Retrieve the value at a given path. - * Note: Tuples are not supported by typings. - * Max path depth typed is 5. - */ -declare function path( - path: [P1, P2, P3, P4] & { 4?: void }, - obj: {[K2 in P2]: {[K4 in P4]: T}[]}[]): T; - -/** - * Retrieve the value at a given path. - * Note: Tuples are not supported by typings. - * Max path depth typed is 5. - */ -declare function path( - path: [P1, P2, P3, P4] & { 4?: void }, obj: {[K2 in P2]: T[][]}[]): T; - -/** - * Retrieve the value at a given path. - * Note: Tuples are not supported by typings. - * Max path depth typed is 5. - */ -declare function path( - path: [P1, P2, P3, P4] & { 4?: void }, - obj: {[K3 in P3]: {[K4 in P4]: T}}[][]): T; - -/** - * Retrieve the value at a given path. - * Note: Tuples are not supported by typings. - * Max path depth typed is 5. - */ -declare function path( - path: [P1, P2, P3, P4] & { 4?: void }, obj: {[K3 in P3]: T[]}[][]): T; - -/** - * Retrieve the value at a given path. - * Note: Tuples are not supported by typings. - * Max path depth typed is 5. - */ -declare function path( - path: [P1, P2, P3, P4] & { 4?: void }, obj: {[K4 in P4]: T}[][][]): T; - -/** - * Retrieve the value at a given path. - * Note: Tuples are not supported by typings. - * Max path depth typed is 5. - */ -declare function path( - path: [P1, P2, P3, P4] & { 4?: void }, obj: T[][][][]): T; - -/** - * Retrieve the value at a given path. - * Note: Tuples are not supported by typings. - * Max path depth typed is 5. - */ -declare function path( - path: [P1, P2, P3, P4, P5] & { 5?: void }, - obj: {[K1 in P1]: {[K2 in P2]: {[K3 in P3]: {[K4 in P4]: {[K5 in P5]: T}}}}}): T; - -/** - * Retrieve the value at a given path. - * Note: Tuples are not supported by typings. - * Max path depth typed is 5. - */ -declare function path( - path: [P1, P2, P3, P4, P5] & { 5?: void }, - obj: {[K1 in P1]: {[K2 in P2]: {[K3 in P3]: {[K4 in P4]: T[]}}}}): T; - -/** - * Retrieve the value at a given path. - * Note: Tuples are not supported by typings. - * Max path depth typed is 5. - */ -declare function path( - path: [P1, P2, P3, P4, P5] & { 5?: void }, - obj: {[K1 in P1]: {[K2 in P2]: {[K3 in P3]: {[K5 in P5]: T}[]}}}): T; - -/** - * Retrieve the value at a given path. - * Note: Tuples are not supported by typings. - * Max path depth typed is 5. - */ -declare function path( - path: [P1, P2, P3, P4, P5] & { 5?: void }, - obj: {[K1 in P1]: {[K2 in P2]: {[K3 in P3]: T[][]}}}): T; - -/** - * Retrieve the value at a given path. - * Note: Tuples are not supported by typings. - * Max path depth typed is 5. - */ -declare function path( - path: [P1, P2, P3, P4, P5] & { 5?: void }, - obj: {[K1 in P1]: {[K2 in P2]: {[K4 in P4]: {[K5 in P5]: T}}[]}}): T; - -/** - * Retrieve the value at a given path. - * Note: Tuples are not supported by typings. - * Max path depth typed is 5. - */ -declare function path( - path: [P1, P2, P3, P4, P5] & { 5?: void }, - obj: {[K1 in P1]: {[K2 in P2]: {[K4 in P4]: T[]}[]}}): T; - -/** - * Retrieve the value at a given path. - * Note: Tuples are not supported by typings. - * Max path depth typed is 5. - */ -declare function path( - path: [P1, P2, P3, P4, P5] & { 5?: void }, - obj: {[K1 in P1]: {[K2 in P2]: {[K5 in P5]: T}[][]}}): T; - -/** - * Retrieve the value at a given path. - * Note: Tuples are not supported by typings. - * Max path depth typed is 5. - */ -declare function path( - path: [P1, P2, P3, P4, P5] & { 5?: void }, - obj: {[K1 in P1]: {[K2 in P2]: T[][][]}}): T; - -/** - * Retrieve the value at a given path. - * Note: Tuples are not supported by typings. - * Max path depth typed is 5. - */ -declare function path( - path: [P1, P2, P3, P4, P5] & { 5?: void }, - obj: {[K1 in P1]: {[K3 in P3]: {[K4 in P4]: {[K5 in P5]: T}}}[]}): T; - -/** - * Retrieve the value at a given path. - * Note: Tuples are not supported by typings. - * Max path depth typed is 5. - */ -declare function path( - path: [P1, P2, P3, P4, P5] & { 5?: void }, - obj: {[K1 in P1]: {[K3 in P3]: {[K4 in P4]: T[]}}[]}): T; - -/** - * Retrieve the value at a given path. - * Note: Tuples are not supported by typings. - * Max path depth typed is 5. - */ -declare function path( - path: [P1, P2, P3, P4, P5] & { 5?: void }, - obj: {[K1 in P1]: {[K3 in P3]: {[K5 in P5]: T}[]}[]}): T; - -/** - * Retrieve the value at a given path. - * Note: Tuples are not supported by typings. - * Max path depth typed is 5. - */ -declare function path( - path: [P1, P2, P3, P4, P5] & { 5?: void }, - obj: {[K1 in P1]: {[K3 in P3]: T[][]}[]}): T; - -/** - * Retrieve the value at a given path. - * Note: Tuples are not supported by typings. - * Max path depth typed is 5. - */ -declare function path( - path: [P1, P2, P3, P4, P5] & { 5?: void }, - obj: {[K1 in P1]: {[K4 in P4]: {[K5 in P5]: T}}[][]}): T; - -/** - * Retrieve the value at a given path. - * Note: Tuples are not supported by typings. - * Max path depth typed is 5. - */ -declare function path( - path: [P1, P2, P3, P4, P5] & { 5?: void }, - obj: {[K1 in P1]: {[K4 in P4]: T[]}[][]}): T; - -/** - * Retrieve the value at a given path. - * Note: Tuples are not supported by typings. - * Max path depth typed is 5. - */ -declare function path( - path: [P1, P2, P3, P4, P5] & { 5?: void }, - obj: {[K1 in P1]: {[K5 in P5]: T}[][][]}): T; - -/** - * Retrieve the value at a given path. - * Note: Tuples are not supported by typings. - * Max path depth typed is 5. - */ -declare function path( - path: [P1, P2, P3, P4, P5] & { 5?: void }, obj: {[K1 in P1]: T[][][][]}): T; - -/** - * Retrieve the value at a given path. - * Note: Tuples are not supported by typings. - * Max path depth typed is 5. - */ -declare function path( - path: [P1, P2, P3, P4, P5] & { 5?: void }, - obj: {[K2 in P2]: {[K3 in P3]: {[K4 in P4]: {[K5 in P5]: T}}}}[]): T; - -/** - * Retrieve the value at a given path. - * Note: Tuples are not supported by typings. - * Max path depth typed is 5. - */ -declare function path( - path: [P1, P2, P3, P4, P5] & { 5?: void }, - obj: {[K2 in P2]: {[K3 in P3]: {[K4 in P4]: T[]}}}[]): T; - -/** - * Retrieve the value at a given path. - * Note: Tuples are not supported by typings. - * Max path depth typed is 5. - */ -declare function path( - path: [P1, P2, P3, P4, P5] & { 5?: void }, - obj: {[K2 in P2]: {[K3 in P3]: {[K5 in P5]: T}[]}}[]): T; - -/** - * Retrieve the value at a given path. - * Note: Tuples are not supported by typings. - * Max path depth typed is 5. - */ -declare function path( - path: [P1, P2, P3, P4, P5] & { 5?: void }, - obj: {[K2 in P2]: {[K3 in P3]: T[][]}}[]): T; - -/** - * Retrieve the value at a given path. - * Note: Tuples are not supported by typings. - * Max path depth typed is 5. - */ -declare function path( - path: [P1, P2, P3, P4, P5] & { 5?: void }, - obj: {[K2 in P2]: {[K4 in P4]: {[K5 in P5]: T}}[]}[]): T; - -/** - * Retrieve the value at a given path. - * Note: Tuples are not supported by typings. - * Max path depth typed is 5. - */ -declare function path( - path: [P1, P2, P3, P4, P5] & { 5?: void }, - obj: {[K2 in P2]: {[K4 in P4]: T[]}[]}[]): T; - -/** - * Retrieve the value at a given path. - * Note: Tuples are not supported by typings. - * Max path depth typed is 5. - */ -declare function path( - path: [P1, P2, P3, P4, P5] & { 5?: void }, - obj: {[K2 in P2]: {[K5 in P5]: T}[][]}[]): T; - -/** - * Retrieve the value at a given path. - * Note: Tuples are not supported by typings. - * Max path depth typed is 5. - */ -declare function path( - path: [P1, P2, P3, P4, P5] & { 5?: void }, obj: {[K2 in P2]: T[][][]}[]): T; - -/** - * Retrieve the value at a given path. - * Note: Tuples are not supported by typings. - * Max path depth typed is 5. - */ -declare function path( - path: [P1, P2, P3, P4, P5] & { 5?: void }, - obj: {[K3 in P3]: {[K4 in P4]: {[K5 in P5]: T}}}[][]): T; - -/** - * Retrieve the value at a given path. - * Note: Tuples are not supported by typings. - * Max path depth typed is 5. - */ -declare function path( - path: [P1, P2, P3, P4, P5] & { 5?: void }, - obj: {[K3 in P3]: {[K4 in P4]: T[]}}[][]): T; - -/** - * Retrieve the value at a given path. - * Note: Tuples are not supported by typings. - * Max path depth typed is 5. - */ -declare function path( - path: [P1, P2, P3, P4, P5] & { 5?: void }, - obj: {[K3 in P3]: {[K5 in P5]: T}[]}[][]): T; - -/** - * Retrieve the value at a given path. - * Note: Tuples are not supported by typings. - * Max path depth typed is 5. - */ -declare function path( - path: [P1, P2, P3, P4, P5] & { 5?: void }, obj: {[K3 in P3]: T[][]}[][]): T; - -/** - * Retrieve the value at a given path. - * Note: Tuples are not supported by typings. - * Max path depth typed is 5. - */ -declare function path( - path: [P1, P2, P3, P4, P5] & { 5?: void }, - obj: {[K4 in P4]: {[K5 in P5]: T}}[][][]): T; - -/** - * Retrieve the value at a given path. - * Note: Tuples are not supported by typings. - * Max path depth typed is 5. - */ -declare function path( - path: [P1, P2, P3, P4, P5] & { 5?: void }, obj: {[K4 in P4]: T[]}[][][]): T; - -/** - * Retrieve the value at a given path. - * Note: Tuples are not supported by typings. - * Max path depth typed is 5. - */ -declare function path( - path: [P1, P2, P3, P4, P5] & { 5?: void }, obj: {[K5 in P5]: T}[][][][]): T; - -/** - * Retrieve the value at a given path. - * Note: Tuples are not supported by typings. - * Max path depth typed is 5. - */ -declare function path( - path: [P1, P2, P3, P4, P5] & { 5?: void }, obj: T[][][][][]): T; - -// curried - -/** - * Retrieve the value at a given path. - * Note: Tuples are not supported by typings. - * Max path depth typed is 5. - */ -declare function path(path: [P1] & { 1?: void }): - (obj: {[K1 in P1]: T}) => T; - -/** - * Retrieve the value at a given path. - * Note: Tuples are not supported by typings. - * Max path depth typed is 5. - */ -declare function path(path: [P1] & { 1?: void }): - (obj: T[]) => T; - -/** - * Retrieve the value at a given path. - * Note: Tuples are not supported by typings. - * Max path depth typed is 5. - */ -declare function path( - path: [P1, P2] & { 2?: void }): - (obj: {[K1 in P1]: {[K2 in P2]: T}}) => T; - -/** - * Retrieve the value at a given path. - * Note: Tuples are not supported by typings. - * Max path depth typed is 5. - */ -declare function path( - path: [P1, P2] & { 2?: void }): (obj: {[K1 in P1]: T[]}) => T; - -/** - * Retrieve the value at a given path. - * Note: Tuples are not supported by typings. - * Max path depth typed is 5. - */ -declare function path( - path: [P1, P2] & { 2?: void }): (obj: {[K2 in P2]: T}[]) => T; - -/** - * Retrieve the value at a given path. - * Note: Tuples are not supported by typings. - * Max path depth typed is 5. - */ -declare function path( - path: [P1, P2] & { 2?: void }): (obj: T[][]) => T; - -/** - * Retrieve the value at a given path. - * Note: Tuples are not supported by typings. - * Max path depth typed is 5. - */ -declare function path(path: [P1, P2, P3] & { 3?: void }): - (obj: {[K1 in P1]: {[K2 in P2]: {[K3 in P3]: T}}}) => T; - -/** - * Retrieve the value at a given path. - * Note: Tuples are not supported by typings. - * Max path depth typed is 5. - */ -declare function path(path: [P1, P2, P3] & { 3?: void }): - (obj: {[K1 in P1]: {[K2 in P2]: T[]}}) => T; - -/** - * Retrieve the value at a given path. - * Note: Tuples are not supported by typings. - * Max path depth typed is 5. - */ -declare function path(path: [P1, P2, P3] & { 3?: void }): - (obj: {[K1 in P1]: {[K3 in P3]: T}[]}) => T; - -/** - * Retrieve the value at a given path. - * Note: Tuples are not supported by typings. - * Max path depth typed is 5. - */ -declare function path(path: [P1, P2, P3] & { 3?: void }): - (obj: {[K1 in P1]: T[][]}) => T; - -/** - * Retrieve the value at a given path. - * Note: Tuples are not supported by typings. - * Max path depth typed is 5. - */ -declare function path(path: [P1, P2, P3] & { 3?: void }): - (obj: {[K2 in P2]: {[K3 in P3]: T}}[]) => T; - -/** - * Retrieve the value at a given path. - * Note: Tuples are not supported by typings. - * Max path depth typed is 5. - */ -declare function path(path: [P1, P2, P3] & { 3?: void }): - (obj: {[K2 in P2]: T[]}[]) => T; - -/** - * Retrieve the value at a given path. - * Note: Tuples are not supported by typings. - * Max path depth typed is 5. - */ -declare function path(path: [P1, P2, P3] & { 3?: void }): - (obj: {[K3 in P3]: T}[][]) => T; - -/** - * Retrieve the value at a given path. - * Note: Tuples are not supported by typings. - * Max path depth typed is 5. - */ -declare function path(path: [P1, P2, P3] & { 3?: void }): - (obj: T[][][]) => T; - -/** - * Retrieve the value at a given path. - * Note: Tuples are not supported by typings. - * Max path depth typed is 5. - */ -declare function path( - path: [P1, P2, P3, P4] & { 4?: void }): - (obj: {[K1 in P1]: {[K2 in P2]: {[K3 in P3]: {[K4 in P4]: T}}}}) => T; - -/** - * Retrieve the value at a given path. - * Note: Tuples are not supported by typings. - * Max path depth typed is 5. - */ -declare function path( - path: [P1, P2, P3, P4] & { 4?: void }): - (obj: {[K1 in P1]: {[K2 in P2]: {[K3 in P3]: T[]}}}) => T; - -/** - * Retrieve the value at a given path. - * Note: Tuples are not supported by typings. - * Max path depth typed is 5. - */ -declare function path( - path: [P1, P2, P3, P4] & { 4?: void }): - (obj: {[K1 in P1]: {[K2 in P2]: {[K4 in P4]: T}[]}}) => T; - -/** - * Retrieve the value at a given path. - * Note: Tuples are not supported by typings. - * Max path depth typed is 5. - */ -declare function path( - path: [P1, P2, P3, P4] & { 4?: void }): - (obj: {[K1 in P1]: {[K2 in P2]: T[][]}}) => T; - -/** - * Retrieve the value at a given path. - * Note: Tuples are not supported by typings. - * Max path depth typed is 5. - */ -declare function path( - path: [P1, P2, P3, P4] & { 4?: void }): - (obj: {[K1 in P1]: {[K3 in P3]: {[K4 in P4]: T}}[]}) => T; - -/** - * Retrieve the value at a given path. - * Note: Tuples are not supported by typings. - * Max path depth typed is 5. - */ -declare function path( - path: [P1, P2, P3, P4] & { 4?: void }): - (obj: {[K1 in P1]: {[K3 in P3]: T[]}[]}) => T; - -/** - * Retrieve the value at a given path. - * Note: Tuples are not supported by typings. - * Max path depth typed is 5. - */ -declare function path( - path: [P1, P2, P3, P4] & { 4?: void }): - (obj: {[K1 in P1]: {[K4 in P4]: T}[][]}) => T; - -/** - * Retrieve the value at a given path. - * Note: Tuples are not supported by typings. - * Max path depth typed is 5. - */ -declare function path( - path: [P1, P2, P3, P4] & { 4?: void }): - (obj: {[K1 in P1]: T[][][]}) => T; - -/** - * Retrieve the value at a given path. - * Note: Tuples are not supported by typings. - * Max path depth typed is 5. - */ -declare function path( - path: [P1, P2, P3, P4] & { 4?: void }): - (obj: {[K2 in P2]: {[K3 in P3]: {[K4 in P4]: T}}}[]) => T; - -/** - * Retrieve the value at a given path. - * Note: Tuples are not supported by typings. - * Max path depth typed is 5. - */ -declare function path( - path: [P1, P2, P3, P4] & { 4?: void }): - (obj: {[K2 in P2]: {[K3 in P3]: T[]}}[]) => T; - -/** - * Retrieve the value at a given path. - * Note: Tuples are not supported by typings. - * Max path depth typed is 5. - */ -declare function path( - path: [P1, P2, P3, P4] & { 4?: void }): - (obj: {[K2 in P2]: {[K4 in P4]: T}[]}[]) => T; - -/** - * Retrieve the value at a given path. - * Note: Tuples are not supported by typings. - * Max path depth typed is 5. - */ -declare function path( - path: [P1, P2, P3, P4] & { 4?: void }): - (obj: {[K2 in P2]: T[][]}[]) => T; - -/** - * Retrieve the value at a given path. - * Note: Tuples are not supported by typings. - * Max path depth typed is 5. - */ -declare function path( - path: [P1, P2, P3, P4] & { 4?: void }): - (obj: {[K3 in P3]: {[K4 in P4]: T}}[][]) => T; - -/** - * Retrieve the value at a given path. - * Note: Tuples are not supported by typings. - * Max path depth typed is 5. - */ -declare function path( - path: [P1, P2, P3, P4] & { 4?: void }): - (obj: {[K3 in P3]: T[]}[][]) => T; - -/** - * Retrieve the value at a given path. - * Note: Tuples are not supported by typings. - * Max path depth typed is 5. - */ -declare function path( - path: [P1, P2, P3, P4] & { 4?: void }): - (obj: {[K4 in P4]: T}[][][]) => T; - -/** - * Retrieve the value at a given path. - * Note: Tuples are not supported by typings. - * Max path depth typed is 5. - */ -declare function path( - path: [P1, P2, P3, P4] & { 4?: void }): (obj: T[][][][]) => T; - -/** - * Retrieve the value at a given path. - * Note: Tuples are not supported by typings. - * Max path depth typed is 5. - */ -declare function path( - path: [P1, P2, P3, P4, P5] & { 5?: void }): +interface Path { + /** + * Retrieve the value at a given path. + * Note: Tuples are not supported by typings. + * Max path depth typed is 5. + */ + (path: [P1, P2, P3, P4, P5]): { + (obj: T[][][][][]): T; + } + /** + * Retrieve the value at a given path. + * Note: Tuples are not supported by typings. + * Max path depth typed is 5. + */ + (path: [P1, P2, P3, P4, P5]): { + (obj: {[K5 in P5]: T}[][][][]): T; + } + /** + * Retrieve the value at a given path. + * Note: Tuples are not supported by typings. + * Max path depth typed is 5. + */ + (path: [P1, P2, P3, P4, P5]): { + (obj: {[K4 in P4]: T[]}[][][]): T; + } + /** + * Retrieve the value at a given path. + * Note: Tuples are not supported by typings. + * Max path depth typed is 5. + */ + (path: [P1, P2, P3, P4, P5]): { + (obj: {[K4 in P4]: {[K5 in P5]: T}}[][][]): T; + } + /** + * Retrieve the value at a given path. + * Note: Tuples are not supported by typings. + * Max path depth typed is 5. + */ + (path: [P1, P2, P3, P4, P5]): { + (obj: {[K3 in P3]: T[][]}[][]): T; + } + /** + * Retrieve the value at a given path. + * Note: Tuples are not supported by typings. + * Max path depth typed is 5. + */ + (path: [P1, P2, P3, P4, P5]): { + (obj: {[K3 in P3]: {[K5 in P5]: T}[]}[][]): T; + } + /** + * Retrieve the value at a given path. + * Note: Tuples are not supported by typings. + * Max path depth typed is 5. + */ + (path: [P1, P2, P3, P4, P5]): { + (obj: {[K3 in P3]: {[K4 in P4]: T[]}}[][]): T; + } + /** + * Retrieve the value at a given path. + * Note: Tuples are not supported by typings. + * Max path depth typed is 5. + */ + (path: [P1, P2, P3, P4, P5]): { + (obj: {[K3 in P3]: {[K4 in P4]: {[K5 in P5]: T}}}[][]): T; + } + /** + * Retrieve the value at a given path. + * Note: Tuples are not supported by typings. + * Max path depth typed is 5. + */ + (path: [P1, P2, P3, P4, P5]): { + (obj: {[K2 in P2]: T[][][]}[]): T; + } + /** + * Retrieve the value at a given path. + * Note: Tuples are not supported by typings. + * Max path depth typed is 5. + */ + (path: [P1, P2, P3, P4, P5]): { + (obj: {[K2 in P2]: {[K5 in P5]: T}[][]}[]): T; + } + /** + * Retrieve the value at a given path. + * Note: Tuples are not supported by typings. + * Max path depth typed is 5. + */ + (path: [P1, P2, P3, P4, P5]): { + (obj: {[K2 in P2]: {[K4 in P4]: T[]}[]}[]): T; + } + /** + * Retrieve the value at a given path. + * Note: Tuples are not supported by typings. + * Max path depth typed is 5. + */ + (path: [P1, P2, P3, P4, P5]): { + (obj: {[K2 in P2]: {[K4 in P4]: {[K5 in P5]: T}}[]}[]): T; + } + /** + * Retrieve the value at a given path. + * Note: Tuples are not supported by typings. + * Max path depth typed is 5. + */ + (path: [P1, P2, P3, P4, P5]): { + (obj: {[K2 in P2]: {[K3 in P3]: T[][]}}[]): T; + } + /** + * Retrieve the value at a given path. + * Note: Tuples are not supported by typings. + * Max path depth typed is 5. + */ + (path: [P1, P2, P3, P4, P5]): { + (obj: {[K2 in P2]: {[K3 in P3]: {[K5 in P5]: T}[]}}[]): T; + } + /** + * Retrieve the value at a given path. + * Note: Tuples are not supported by typings. + * Max path depth typed is 5. + */ + (path: [P1, P2, P3, P4, P5]): { + (obj: {[K2 in P2]: {[K3 in P3]: {[K4 in P4]: T[]}}}[]): T; + } + /** + * Retrieve the value at a given path. + * Note: Tuples are not supported by typings. + * Max path depth typed is 5. + */ + (path: [P1, P2, P3, P4, P5]): { + (obj: {[K2 in P2]: {[K3 in P3]: {[K4 in P4]: {[K5 in P5]: T}}}}[]): T; + } + /** + * Retrieve the value at a given path. + * Note: Tuples are not supported by typings. + * Max path depth typed is 5. + */ + (path: [P1, P2, P3, P4, P5]): { + (obj: {[K1 in P1]: T[][][][]}): T; + } + /** + * Retrieve the value at a given path. + * Note: Tuples are not supported by typings. + * Max path depth typed is 5. + */ + (path: [P1, P2, P3, P4, P5]): { + (obj: {[K1 in P1]: {[K5 in P5]: T}[][][]}): T; + } + /** + * Retrieve the value at a given path. + * Note: Tuples are not supported by typings. + * Max path depth typed is 5. + */ + (path: [P1, P2, P3, P4, P5]): { + (obj: {[K1 in P1]: {[K4 in P4]: T[]}[][]}): T; + } + /** + * Retrieve the value at a given path. + * Note: Tuples are not supported by typings. + * Max path depth typed is 5. + */ + (path: [P1, P2, P3, P4, P5]): { + (obj: {[K1 in P1]: {[K4 in P4]: {[K5 in P5]: T}}[][]}): T; + } + /** + * Retrieve the value at a given path. + * Note: Tuples are not supported by typings. + * Max path depth typed is 5. + */ + (path: [P1, P2, P3, P4, P5]): { + (obj: {[K1 in P1]: {[K3 in P3]: T[][]}[]}): T; + } + /** + * Retrieve the value at a given path. + * Note: Tuples are not supported by typings. + * Max path depth typed is 5. + */ + (path: [P1, P2, P3, P4, P5]): { + (obj: {[K1 in P1]: {[K3 in P3]: {[K5 in P5]: T}[]}[]}): T; + } + /** + * Retrieve the value at a given path. + * Note: Tuples are not supported by typings. + * Max path depth typed is 5. + */ + (path: [P1, P2, P3, P4, P5]): { + (obj: {[K1 in P1]: {[K3 in P3]: {[K4 in P4]: T[]}}[]}): T; + } + /** + * Retrieve the value at a given path. + * Note: Tuples are not supported by typings. + * Max path depth typed is 5. + */ + (path: [P1, P2, P3, P4, P5]): { + (obj: {[K1 in P1]: {[K3 in P3]: {[K4 in P4]: {[K5 in P5]: T}}}[]}): T; + } + /** + * Retrieve the value at a given path. + * Note: Tuples are not supported by typings. + * Max path depth typed is 5. + */ + (path: [P1, P2, P3, P4, P5]): { + (obj: {[K1 in P1]: {[K2 in P2]: T[][][]}}): T; + } + /** + * Retrieve the value at a given path. + * Note: Tuples are not supported by typings. + * Max path depth typed is 5. + */ + (path: [P1, P2, P3, P4, P5]): { + (obj: {[K1 in P1]: {[K2 in P2]: {[K5 in P5]: T}[][]}}): T; + } + /** + * Retrieve the value at a given path. + * Note: Tuples are not supported by typings. + * Max path depth typed is 5. + */ + (path: [P1, P2, P3, P4, P5]): { + (obj: {[K1 in P1]: {[K2 in P2]: {[K4 in P4]: T[]}[]}}): T; + } + /** + * Retrieve the value at a given path. + * Note: Tuples are not supported by typings. + * Max path depth typed is 5. + */ + (path: [P1, P2, P3, P4, P5]): { + (obj: {[K1 in P1]: {[K2 in P2]: {[K4 in P4]: {[K5 in P5]: T}}[]}}): T; + } + /** + * Retrieve the value at a given path. + * Note: Tuples are not supported by typings. + * Max path depth typed is 5. + */ + (path: [P1, P2, P3, P4, P5]): { + (obj: {[K1 in P1]: {[K2 in P2]: {[K3 in P3]: T[][]}}}): T; + } + /** + * Retrieve the value at a given path. + * Note: Tuples are not supported by typings. + * Max path depth typed is 5. + */ + (path: [P1, P2, P3, P4, P5]): { + (obj: {[K1 in P1]: {[K2 in P2]: {[K3 in P3]: {[K5 in P5]: T}[]}}}): T; + } + /** + * Retrieve the value at a given path. + * Note: Tuples are not supported by typings. + * Max path depth typed is 5. + */ + (path: [P1, P2, P3, P4, P5]): { + (obj: {[K1 in P1]: {[K2 in P2]: {[K3 in P3]: {[K4 in P4]: T[]}}}}): T; + } + /** + * Retrieve the value at a given path. + * Note: Tuples are not supported by typings. + * Max path depth typed is 5. + */ + (path: [P1, P2, P3, P4, P5]): { ( - obj: {[K1 in P1]: {[K2 in P2]: {[K3 in P3]: {[K4 in P4]: {[K5 in P5]: T}}}}}) => T; - -/** - * Retrieve the value at a given path. - * Note: Tuples are not supported by typings. - * Max path depth typed is 5. - */ -declare function path( - path: [P1, P2, P3, P4, P5] & { 5?: void }): - (obj: {[K1 in P1]: {[K2 in P2]: {[K3 in P3]: {[K4 in P4]: T[]}}}}) => T; - -/** - * Retrieve the value at a given path. - * Note: Tuples are not supported by typings. - * Max path depth typed is 5. - */ -declare function path( - path: [P1, P2, P3, P4, P5] & { 5?: void }): - (obj: {[K1 in P1]: {[K2 in P2]: {[K3 in P3]: {[K5 in P5]: T}[]}}}) => T; - -/** - * Retrieve the value at a given path. - * Note: Tuples are not supported by typings. - * Max path depth typed is 5. - */ -declare function path( - path: [P1, P2, P3, P4, P5] & { 5?: void }): - (obj: {[K1 in P1]: {[K2 in P2]: {[K3 in P3]: T[][]}}}) => T; - -/** - * Retrieve the value at a given path. - * Note: Tuples are not supported by typings. - * Max path depth typed is 5. - */ -declare function path( - path: [P1, P2, P3, P4, P5] & { 5?: void }): - (obj: {[K1 in P1]: {[K2 in P2]: {[K4 in P4]: {[K5 in P5]: T}}[]}}) => T; - -/** - * Retrieve the value at a given path. - * Note: Tuples are not supported by typings. - * Max path depth typed is 5. - */ -declare function path( - path: [P1, P2, P3, P4, P5] & { 5?: void }): - (obj: {[K1 in P1]: {[K2 in P2]: {[K4 in P4]: T[]}[]}}) => T; - -/** - * Retrieve the value at a given path. - * Note: Tuples are not supported by typings. - * Max path depth typed is 5. - */ -declare function path( - path: [P1, P2, P3, P4, P5] & { 5?: void }): - (obj: {[K1 in P1]: {[K2 in P2]: {[K5 in P5]: T}[][]}}) => T; - -/** - * Retrieve the value at a given path. - * Note: Tuples are not supported by typings. - * Max path depth typed is 5. - */ -declare function path( - path: [P1, P2, P3, P4, P5] & { 5?: void }): - (obj: {[K1 in P1]: {[K2 in P2]: T[][][]}}) => T; - -/** - * Retrieve the value at a given path. - * Note: Tuples are not supported by typings. - * Max path depth typed is 5. - */ -declare function path( - path: [P1, P2, P3, P4, P5] & { 5?: void }): - (obj: {[K1 in P1]: {[K3 in P3]: {[K4 in P4]: {[K5 in P5]: T}}}[]}) => T; - -/** - * Retrieve the value at a given path. - * Note: Tuples are not supported by typings. - * Max path depth typed is 5. - */ -declare function path( - path: [P1, P2, P3, P4, P5] & { 5?: void }): - (obj: {[K1 in P1]: {[K3 in P3]: {[K4 in P4]: T[]}}[]}) => T; - -/** - * Retrieve the value at a given path. - * Note: Tuples are not supported by typings. - * Max path depth typed is 5. - */ -declare function path( - path: [P1, P2, P3, P4, P5] & { 5?: void }): - (obj: {[K1 in P1]: {[K3 in P3]: {[K5 in P5]: T}[]}[]}) => T; - -/** - * Retrieve the value at a given path. - * Note: Tuples are not supported by typings. - * Max path depth typed is 5. - */ -declare function path( - path: [P1, P2, P3, P4, P5] & { 5?: void }): - (obj: {[K1 in P1]: {[K3 in P3]: T[][]}[]}) => T; - -/** - * Retrieve the value at a given path. - * Note: Tuples are not supported by typings. - * Max path depth typed is 5. - */ -declare function path( - path: [P1, P2, P3, P4, P5] & { 5?: void }): - (obj: {[K1 in P1]: {[K4 in P4]: {[K5 in P5]: T}}[][]}) => T; - -/** - * Retrieve the value at a given path. - * Note: Tuples are not supported by typings. - * Max path depth typed is 5. - */ -declare function path( - path: [P1, P2, P3, P4, P5] & { 5?: void }): - (obj: {[K1 in P1]: {[K4 in P4]: T[]}[][]}) => T; - -/** - * Retrieve the value at a given path. - * Note: Tuples are not supported by typings. - * Max path depth typed is 5. - */ -declare function path( - path: [P1, P2, P3, P4, P5] & { 5?: void }): - (obj: {[K1 in P1]: {[K5 in P5]: T}[][][]}) => T; - -/** - * Retrieve the value at a given path. - * Note: Tuples are not supported by typings. - * Max path depth typed is 5. - */ -declare function path( - path: [P1, P2, P3, P4, P5] & { 5?: void }): - (obj: {[K1 in P1]: T[][][][]}) => T; - -/** - * Retrieve the value at a given path. - * Note: Tuples are not supported by typings. - * Max path depth typed is 5. - */ -declare function path( - path: [P1, P2, P3, P4, P5] & { 5?: void }): - (obj: {[K2 in P2]: {[K3 in P3]: {[K4 in P4]: {[K5 in P5]: T}}}}[]) => T; - -/** - * Retrieve the value at a given path. - * Note: Tuples are not supported by typings. - * Max path depth typed is 5. - */ -declare function path( - path: [P1, P2, P3, P4, P5] & { 5?: void }): - (obj: {[K2 in P2]: {[K3 in P3]: {[K4 in P4]: T[]}}}[]) => T; - -/** - * Retrieve the value at a given path. - * Note: Tuples are not supported by typings. - * Max path depth typed is 5. - */ -declare function path( - path: [P1, P2, P3, P4, P5] & { 5?: void }): - (obj: {[K2 in P2]: {[K3 in P3]: {[K5 in P5]: T}[]}}[]) => T; - -/** - * Retrieve the value at a given path. - * Note: Tuples are not supported by typings. - * Max path depth typed is 5. - */ -declare function path( - path: [P1, P2, P3, P4, P5] & { 5?: void }): - (obj: {[K2 in P2]: {[K3 in P3]: T[][]}}[]) => T; - -/** - * Retrieve the value at a given path. - * Note: Tuples are not supported by typings. - * Max path depth typed is 5. - */ -declare function path( - path: [P1, P2, P3, P4, P5] & { 5?: void }): - (obj: {[K2 in P2]: {[K4 in P4]: {[K5 in P5]: T}}[]}[]) => T; - -/** - * Retrieve the value at a given path. - * Note: Tuples are not supported by typings. - * Max path depth typed is 5. - */ -declare function path( - path: [P1, P2, P3, P4, P5] & { 5?: void }): - (obj: {[K2 in P2]: {[K4 in P4]: T[]}[]}[]) => T; - -/** - * Retrieve the value at a given path. - * Note: Tuples are not supported by typings. - * Max path depth typed is 5. - */ -declare function path( - path: [P1, P2, P3, P4, P5] & { 5?: void }): - (obj: {[K2 in P2]: {[K5 in P5]: T}[][]}[]) => T; - -/** - * Retrieve the value at a given path. - * Note: Tuples are not supported by typings. - * Max path depth typed is 5. - */ -declare function path( - path: [P1, P2, P3, P4, P5] & { 5?: void }): - (obj: {[K2 in P2]: T[][][]}[]) => T; - -/** - * Retrieve the value at a given path. - * Note: Tuples are not supported by typings. - * Max path depth typed is 5. - */ -declare function path( - path: [P1, P2, P3, P4, P5] & { 5?: void }): - (obj: {[K3 in P3]: {[K4 in P4]: {[K5 in P5]: T}}}[][]) => T; - -/** - * Retrieve the value at a given path. - * Note: Tuples are not supported by typings. - * Max path depth typed is 5. - */ -declare function path( - path: [P1, P2, P3, P4, P5] & { 5?: void }): - (obj: {[K3 in P3]: {[K4 in P4]: T[]}}[][]) => T; - -/** - * Retrieve the value at a given path. - * Note: Tuples are not supported by typings. - * Max path depth typed is 5. - */ -declare function path( - path: [P1, P2, P3, P4, P5] & { 5?: void }): - (obj: {[K3 in P3]: {[K5 in P5]: T}[]}[][]) => T; - -/** - * Retrieve the value at a given path. - * Note: Tuples are not supported by typings. - * Max path depth typed is 5. - */ -declare function path( - path: [P1, P2, P3, P4, P5] & { 5?: void }): - (obj: {[K3 in P3]: T[][]}[][]) => T; - -/** - * Retrieve the value at a given path. - * Note: Tuples are not supported by typings. - * Max path depth typed is 5. - */ -declare function path( - path: [P1, P2, P3, P4, P5] & { 5?: void }): - (obj: {[K4 in P4]: {[K5 in P5]: T}}[][][]) => T; - -/** - * Retrieve the value at a given path. - * Note: Tuples are not supported by typings. - * Max path depth typed is 5. - */ -declare function path( - path: [P1, P2, P3, P4, P5] & { 5?: void }): - (obj: {[K4 in P4]: T[]}[][][]) => T; - -/** - * Retrieve the value at a given path. - * Note: Tuples are not supported by typings. - * Max path depth typed is 5. - */ -declare function path( - path: [P1, P2, P3, P4, P5] & { 5?: void }): - (obj: {[K5 in P5]: T}[][][][]) => T; - -/** - * Retrieve the value at a given path. - * Note: Tuples are not supported by typings. - * Max path depth typed is 5. - */ -declare function path( - path: [P1, P2, P3, P4, P5] & { 5?: void }): (obj: T[][][][][]) => T; + obj: {[K1 in P1]: {[K2 in P2]: {[K3 in P3]: {[K4 in P4]: {[K5 in P5]: T}}}}}): T; + } + /** + * Retrieve the value at a given path. + * Note: Tuples are not supported by typings. + * Max path depth typed is 5. + */ + (path: [P1, P2, P3, P4]): { + (obj: T[][][][]): T; + } + /** + * Retrieve the value at a given path. + * Note: Tuples are not supported by typings. + * Max path depth typed is 5. + */ + (path: [P1, P2, P3, P4]): { + (obj: {[K4 in P4]: T}[][][]): T; + } + /** + * Retrieve the value at a given path. + * Note: Tuples are not supported by typings. + * Max path depth typed is 5. + */ + (path: [P1, P2, P3, P4]): { + (obj: {[K3 in P3]: T[]}[][]): T; + } + /** + * Retrieve the value at a given path. + * Note: Tuples are not supported by typings. + * Max path depth typed is 5. + */ + (path: [P1, P2, P3, P4]): { + (obj: {[K3 in P3]: {[K4 in P4]: T}}[][]): T; + } + /** + * Retrieve the value at a given path. + * Note: Tuples are not supported by typings. + * Max path depth typed is 5. + */ + (path: [P1, P2, P3, P4]): { + (obj: {[K2 in P2]: T[][]}[]): T; + } + /** + * Retrieve the value at a given path. + * Note: Tuples are not supported by typings. + * Max path depth typed is 5. + */ + (path: [P1, P2, P3, P4]): { + (obj: {[K2 in P2]: {[K4 in P4]: T}[]}[]): T; + } + /** + * Retrieve the value at a given path. + * Note: Tuples are not supported by typings. + * Max path depth typed is 5. + */ + (path: [P1, P2, P3, P4]): { + (obj: {[K2 in P2]: {[K3 in P3]: T[]}}[]): T; + } + /** + * Retrieve the value at a given path. + * Note: Tuples are not supported by typings. + * Max path depth typed is 5. + */ + (path: [P1, P2, P3, P4]): { + (obj: {[K2 in P2]: {[K3 in P3]: {[K4 in P4]: T}}}[]): T; + } + /** + * Retrieve the value at a given path. + * Note: Tuples are not supported by typings. + * Max path depth typed is 5. + */ + (path: [P1, P2, P3, P4]): { + (obj: {[K1 in P1]: T[][][]}): T; + } + /** + * Retrieve the value at a given path. + * Note: Tuples are not supported by typings. + * Max path depth typed is 5. + */ + (path: [P1, P2, P3, P4]): { + (obj: {[K1 in P1]: {[K4 in P4]: T}[][]}): T; + } + /** + * Retrieve the value at a given path. + * Note: Tuples are not supported by typings. + * Max path depth typed is 5. + */ + (path: [P1, P2, P3, P4]): { + (obj: {[K1 in P1]: {[K3 in P3]: T[]}[]}): T; + } + /** + * Retrieve the value at a given path. + * Note: Tuples are not supported by typings. + * Max path depth typed is 5. + */ + (path: [P1, P2, P3, P4]): { + (obj: {[K1 in P1]: {[K3 in P3]: {[K4 in P4]: T}}[]}): T; + } + /** + * Retrieve the value at a given path. + * Note: Tuples are not supported by typings. + * Max path depth typed is 5. + */ + (path: [P1, P2, P3, P4]): { + (obj: {[K1 in P1]: {[K2 in P2]: T[][]}}): T; + } + /** + * Retrieve the value at a given path. + * Note: Tuples are not supported by typings. + * Max path depth typed is 5. + */ + (path: [P1, P2, P3, P4]): { + (obj: {[K1 in P1]: {[K2 in P2]: {[K4 in P4]: T}[]}}): T; + } + /** + * Retrieve the value at a given path. + * Note: Tuples are not supported by typings. + * Max path depth typed is 5. + */ + (path: [P1, P2, P3, P4]): { + (obj: {[K1 in P1]: {[K2 in P2]: {[K3 in P3]: T[]}}}): T; + } + /** + * Retrieve the value at a given path. + * Note: Tuples are not supported by typings. + * Max path depth typed is 5. + */ + (path: [P1, P2, P3, P4]): { + (obj: {[K1 in P1]: {[K2 in P2]: {[K3 in P3]: {[K4 in P4]: T}}}}): T; + } + /** + * Retrieve the value at a given path. + * Note: Tuples are not supported by typings. + * Max path depth typed is 5. + */ + ( + path: [P1, P2, P3]): { + (obj: T[][][]): T; + } + /** + * Retrieve the value at a given path. + * Note: Tuples are not supported by typings. + * Max path depth typed is 5. + */ + ( + path: [P1, P2, P3]): { + (obj: {[K3 in P3]: T}[][]): T; + } + /** + * Retrieve the value at a given path. + * Note: Tuples are not supported by typings. + * Max path depth typed is 5. + */ + ( + path: [P1, P2, P3]): { + (obj: {[K2 in P2]: T[]}[]): T; + } + /** + * Retrieve the value at a given path. + * Note: Tuples are not supported by typings. + * Max path depth typed is 5. + */ + ( + path: [P1, P2, P3]): { + (obj: {[K2 in P2]: {[K3 in P3]: T}}[]): T; + } + /** + * Retrieve the value at a given path. + * Note: Tuples are not supported by typings. + * Max path depth typed is 5. + */ + ( + path: [P1, P2, P3]): { + (obj: {[K1 in P1]: T[][]}): T; + } + /** + * Retrieve the value at a given path. + * Note: Tuples are not supported by typings. + * Max path depth typed is 5. + */ + ( + path: [P1, P2, P3]): { + (obj: {[K1 in P1]: {[K3 in P3]: T}[]}): T; + } + /** + * Retrieve the value at a given path. + * Note: Tuples are not supported by typings. + * Max path depth typed is 5. + */ + ( + path: [P1, P2, P3]): { + (obj: {[K1 in P1]: {[K2 in P2]: T[]}}): T; + } + /** + * Retrieve the value at a given path. + * Note: Tuples are not supported by typings. + * Max path depth typed is 5. + */ + ( + path: [P1, P2, P3]): { + (obj: {[K1 in P1]: {[K2 in P2]: {[K3 in P3]: T}}}): T; + } + /** + * Retrieve the value at a given path. + * Note: Tuples are not supported by typings. + * Max path depth typed is 5. + */ + (path: [P1, P2]): { + (obj: T[][]): T; + } + /** + * Retrieve the value at a given path. + * Note: Tuples are not supported by typings. + * Max path depth typed is 5. + */ + (path: [P1, P2]): { + (obj: {[K2 in P2]: T}[]): T; + } + /** + * Retrieve the value at a given path. + * Note: Tuples are not supported by typings. + * Max path depth typed is 5. + */ + (path: [P1, P2]): { + (obj: {[K1 in P1]: T[]}): T; + } + /** + * Retrieve the value at a given path. + * Note: Tuples are not supported by typings. + * Max path depth typed is 5. + */ + (path: [P1, P2]): { + (obj: {[K1 in P1]: {[K2 in P2]: T}}): T; + } + /** + * Retrieve the value at a given path. + * Note: Tuples are not supported by typings. + * Max path depth typed is 5. + */ + (path: [P1]): { + (obj: T[]): T; + } + /** + * Retrieve the value at a given path. + * Note: Tuples are not supported by typings. + * Max path depth typed is 5. + */ + (path: [P1]): { + (obj: {[K1 in P1]: T}): T; + } + /** + * Retrieve the value at a given path. + * Note: Tuples are not supported by typings. + * Max path depth typed is 5. + */ + (path: [P1, P2, P3, P4, P5], + obj: T[][][][][]): T; + /** + * Retrieve the value at a given path. + * Note: Tuples are not supported by typings. + * Max path depth typed is 5. + */ + (path: [P1, P2, P3, P4, P5], + obj: {[K5 in P5]: T}[][][][]): T; + /** + * Retrieve the value at a given path. + * Note: Tuples are not supported by typings. + * Max path depth typed is 5. + */ + (path: [P1, P2, P3, P4, P5], + obj: {[K4 in P4]: T[]}[][][]): T; + /** + * Retrieve the value at a given path. + * Note: Tuples are not supported by typings. + * Max path depth typed is 5. + */ + (path: [P1, P2, P3, P4, P5], + obj: {[K4 in P4]: {[K5 in P5]: T}}[][][]): T; + /** + * Retrieve the value at a given path. + * Note: Tuples are not supported by typings. + * Max path depth typed is 5. + */ + (path: [P1, P2, P3, P4, P5], + obj: {[K3 in P3]: T[][]}[][]): T; + /** + * Retrieve the value at a given path. + * Note: Tuples are not supported by typings. + * Max path depth typed is 5. + */ + (path: [P1, P2, P3, P4, P5], + obj: {[K3 in P3]: {[K5 in P5]: T}[]}[][]): T; + /** + * Retrieve the value at a given path. + * Note: Tuples are not supported by typings. + * Max path depth typed is 5. + */ + (path: [P1, P2, P3, P4, P5], + obj: {[K3 in P3]: {[K4 in P4]: T[]}}[][]): T; + /** + * Retrieve the value at a given path. + * Note: Tuples are not supported by typings. + * Max path depth typed is 5. + */ + (path: [P1, P2, P3, P4, P5], + obj: {[K3 in P3]: {[K4 in P4]: {[K5 in P5]: T}}}[][]): T; + /** + * Retrieve the value at a given path. + * Note: Tuples are not supported by typings. + * Max path depth typed is 5. + */ + (path: [P1, P2, P3, P4, P5], + obj: {[K2 in P2]: T[][][]}[]): T; + /** + * Retrieve the value at a given path. + * Note: Tuples are not supported by typings. + * Max path depth typed is 5. + */ + (path: [P1, P2, P3, P4, P5], + obj: {[K2 in P2]: {[K5 in P5]: T}[][]}[]): T; + /** + * Retrieve the value at a given path. + * Note: Tuples are not supported by typings. + * Max path depth typed is 5. + */ + (path: [P1, P2, P3, P4, P5], + obj: {[K2 in P2]: {[K4 in P4]: T[]}[]}[]): T; + /** + * Retrieve the value at a given path. + * Note: Tuples are not supported by typings. + * Max path depth typed is 5. + */ + (path: [P1, P2, P3, P4, P5], + obj: {[K2 in P2]: {[K4 in P4]: {[K5 in P5]: T}}[]}[]): T; + /** + * Retrieve the value at a given path. + * Note: Tuples are not supported by typings. + * Max path depth typed is 5. + */ + (path: [P1, P2, P3, P4, P5], + obj: {[K2 in P2]: {[K3 in P3]: T[][]}}[]): T; + /** + * Retrieve the value at a given path. + * Note: Tuples are not supported by typings. + * Max path depth typed is 5. + */ + (path: [P1, P2, P3, P4, P5], + obj: {[K2 in P2]: {[K3 in P3]: {[K5 in P5]: T}[]}}[]): T; + /** + * Retrieve the value at a given path. + * Note: Tuples are not supported by typings. + * Max path depth typed is 5. + */ + (path: [P1, P2, P3, P4, P5], + obj: {[K2 in P2]: {[K3 in P3]: {[K4 in P4]: T[]}}}[]): T; + /** + * Retrieve the value at a given path. + * Note: Tuples are not supported by typings. + * Max path depth typed is 5. + */ + (path: [P1, P2, P3, P4, P5], + obj: {[K2 in P2]: {[K3 in P3]: {[K4 in P4]: {[K5 in P5]: T}}}}[]): T; + /** + * Retrieve the value at a given path. + * Note: Tuples are not supported by typings. + * Max path depth typed is 5. + */ + (path: [P1, P2, P3, P4, P5], + obj: {[K1 in P1]: T[][][][]}): T; + /** + * Retrieve the value at a given path. + * Note: Tuples are not supported by typings. + * Max path depth typed is 5. + */ + (path: [P1, P2, P3, P4, P5], + obj: {[K1 in P1]: {[K5 in P5]: T}[][][]}): T; + /** + * Retrieve the value at a given path. + * Note: Tuples are not supported by typings. + * Max path depth typed is 5. + */ + (path: [P1, P2, P3, P4, P5], + obj: {[K1 in P1]: {[K4 in P4]: T[]}[][]}): T; + /** + * Retrieve the value at a given path. + * Note: Tuples are not supported by typings. + * Max path depth typed is 5. + */ + (path: [P1, P2, P3, P4, P5], + obj: {[K1 in P1]: {[K4 in P4]: {[K5 in P5]: T}}[][]}): T; + /** + * Retrieve the value at a given path. + * Note: Tuples are not supported by typings. + * Max path depth typed is 5. + */ + (path: [P1, P2, P3, P4, P5], + obj: {[K1 in P1]: {[K3 in P3]: T[][]}[]}): T; + /** + * Retrieve the value at a given path. + * Note: Tuples are not supported by typings. + * Max path depth typed is 5. + */ + (path: [P1, P2, P3, P4, P5], + obj: {[K1 in P1]: {[K3 in P3]: {[K5 in P5]: T}[]}[]}): T; + /** + * Retrieve the value at a given path. + * Note: Tuples are not supported by typings. + * Max path depth typed is 5. + */ + (path: [P1, P2, P3, P4, P5], + obj: {[K1 in P1]: {[K3 in P3]: {[K4 in P4]: T[]}}[]}): T; + /** + * Retrieve the value at a given path. + * Note: Tuples are not supported by typings. + * Max path depth typed is 5. + */ + (path: [P1, P2, P3, P4, P5], + obj: {[K1 in P1]: {[K3 in P3]: {[K4 in P4]: {[K5 in P5]: T}}}[]}): T; + /** + * Retrieve the value at a given path. + * Note: Tuples are not supported by typings. + * Max path depth typed is 5. + */ + (path: [P1, P2, P3, P4, P5], + obj: {[K1 in P1]: {[K2 in P2]: T[][][]}}): T; + /** + * Retrieve the value at a given path. + * Note: Tuples are not supported by typings. + * Max path depth typed is 5. + */ + (path: [P1, P2, P3, P4, P5], + obj: {[K1 in P1]: {[K2 in P2]: {[K5 in P5]: T}[][]}}): T; + /** + * Retrieve the value at a given path. + * Note: Tuples are not supported by typings. + * Max path depth typed is 5. + */ + (path: [P1, P2, P3, P4, P5], + obj: {[K1 in P1]: {[K2 in P2]: {[K4 in P4]: T[]}[]}}): T; + /** + * Retrieve the value at a given path. + * Note: Tuples are not supported by typings. + * Max path depth typed is 5. + */ + (path: [P1, P2, P3, P4, P5], + obj: {[K1 in P1]: {[K2 in P2]: {[K4 in P4]: {[K5 in P5]: T}}[]}}): T; + /** + * Retrieve the value at a given path. + * Note: Tuples are not supported by typings. + * Max path depth typed is 5. + */ + (path: [P1, P2, P3, P4, P5], + obj: {[K1 in P1]: {[K2 in P2]: {[K3 in P3]: T[][]}}}): T; + /** + * Retrieve the value at a given path. + * Note: Tuples are not supported by typings. + * Max path depth typed is 5. + */ + (path: [P1, P2, P3, P4, P5], + obj: {[K1 in P1]: {[K2 in P2]: {[K3 in P3]: {[K5 in P5]: T}[]}}}): T; + /** + * Retrieve the value at a given path. + * Note: Tuples are not supported by typings. + * Max path depth typed is 5. + */ + (path: [P1, P2, P3, P4, P5], + obj: {[K1 in P1]: {[K2 in P2]: {[K3 in P3]: {[K4 in P4]: T[]}}}}): T; + /** + * Retrieve the value at a given path. + * Note: Tuples are not supported by typings. + * Max path depth typed is 5. + */ + (path: [P1, P2, P3, P4, P5], + obj: {[K1 in P1]: {[K2 in P2]: {[K3 in P3]: {[K4 in P4]: {[K5 in P5]: T}}}}}): T; + /** + * Retrieve the value at a given path. + * Note: Tuples are not supported by typings. + * Max path depth typed is 5. + */ + (path: [P1, P2, P3, P4], obj: T[][][][]): T; + /** + * Retrieve the value at a given path. + * Note: Tuples are not supported by typings. + * Max path depth typed is 5. + */ + (path: [P1, P2, P3, P4], obj: {[K4 in P4]: T}[][][]): T; + /** + * Retrieve the value at a given path. + * Note: Tuples are not supported by typings. + * Max path depth typed is 5. + */ + (path: [P1, P2, P3, P4], obj: {[K3 in P3]: T[]}[][]): T; + /** + * Retrieve the value at a given path. + * Note: Tuples are not supported by typings. + * Max path depth typed is 5. + */ + (path: [P1, P2, P3, P4], + obj: {[K3 in P3]: {[K4 in P4]: T}}[][]): T; + /** + * Retrieve the value at a given path. + * Note: Tuples are not supported by typings. + * Max path depth typed is 5. + */ + (path: [P1, P2, P3, P4], obj: {[K2 in P2]: T[][]}[]): T; + /** + * Retrieve the value at a given path. + * Note: Tuples are not supported by typings. + * Max path depth typed is 5. + */ + (path: [P1, P2, P3, P4], + obj: {[K2 in P2]: {[K4 in P4]: T}[]}[]): T; + /** + * Retrieve the value at a given path. + * Note: Tuples are not supported by typings. + * Max path depth typed is 5. + */ + (path: [P1, P2, P3, P4], + obj: {[K2 in P2]: {[K3 in P3]: T[]}}[]): T; + /** + * Retrieve the value at a given path. + * Note: Tuples are not supported by typings. + * Max path depth typed is 5. + */ + (path: [P1, P2, P3, P4], + obj: {[K2 in P2]: {[K3 in P3]: {[K4 in P4]: T}}}[]): T; + /** + * Retrieve the value at a given path. + * Note: Tuples are not supported by typings. + * Max path depth typed is 5. + */ + (path: [P1, P2, P3, P4], obj: {[K1 in P1]: T[][][]}): T; + /** + * Retrieve the value at a given path. + * Note: Tuples are not supported by typings. + * Max path depth typed is 5. + */ + (path: [P1, P2, P3, P4], + obj: {[K1 in P1]: {[K4 in P4]: T}[][]}): T; + /** + * Retrieve the value at a given path. + * Note: Tuples are not supported by typings. + * Max path depth typed is 5. + */ + (path: [P1, P2, P3, P4], + obj: {[K1 in P1]: {[K3 in P3]: T[]}[]}): T; + /** + * Retrieve the value at a given path. + * Note: Tuples are not supported by typings. + * Max path depth typed is 5. + */ + (path: [P1, P2, P3, P4], + obj: {[K1 in P1]: {[K3 in P3]: {[K4 in P4]: T}}[]}): T; + /** + * Retrieve the value at a given path. + * Note: Tuples are not supported by typings. + * Max path depth typed is 5. + */ + (path: [P1, P2, P3, P4], + obj: {[K1 in P1]: {[K2 in P2]: T[][]}}): T; + /** + * Retrieve the value at a given path. + * Note: Tuples are not supported by typings. + * Max path depth typed is 5. + */ + (path: [P1, P2, P3, P4], + obj: {[K1 in P1]: {[K2 in P2]: {[K4 in P4]: T}[]}}): T; + /** + * Retrieve the value at a given path. + * Note: Tuples are not supported by typings. + * Max path depth typed is 5. + */ + (path: [P1, P2, P3, P4], + obj: {[K1 in P1]: {[K2 in P2]: {[K3 in P3]: T[]}}}): T; + /** + * Retrieve the value at a given path. + * Note: Tuples are not supported by typings. + * Max path depth typed is 5. + */ + (path: [P1, P2, P3, P4], + obj: {[K1 in P1]: {[K2 in P2]: {[K3 in P3]: {[K4 in P4]: T}}}}): T; + /** + * Retrieve the value at a given path. + * Note: Tuples are not supported by typings. + * Max path depth typed is 5. + */ + ( + path: [P1, P2, P3], obj: T[][][]): T; + /** + * Retrieve the value at a given path. + * Note: Tuples are not supported by typings. + * Max path depth typed is 5. + */ + ( + path: [P1, P2, P3], obj: {[K3 in P3]: T}[][]): T; + /** + * Retrieve the value at a given path. + * Note: Tuples are not supported by typings. + * Max path depth typed is 5. + */ + ( + path: [P1, P2, P3], obj: {[K2 in P2]: T[]}[]): T; + /** + * Retrieve the value at a given path. + * Note: Tuples are not supported by typings. + * Max path depth typed is 5. + */ + ( + path: [P1, P2, P3], obj: {[K2 in P2]: {[K3 in P3]: T}}[]): T; + /** + * Retrieve the value at a given path. + * Note: Tuples are not supported by typings. + * Max path depth typed is 5. + */ + ( + path: [P1, P2, P3], obj: {[K1 in P1]: T[][]}): T; + /** + * Retrieve the value at a given path. + * Note: Tuples are not supported by typings. + * Max path depth typed is 5. + */ + ( + path: [P1, P2, P3], obj: {[K1 in P1]: {[K3 in P3]: T}[]}): T; + /** + * Retrieve the value at a given path. + * Note: Tuples are not supported by typings. + * Max path depth typed is 5. + */ + ( + path: [P1, P2, P3], obj: {[K1 in P1]: {[K2 in P2]: T[]}}): T; + /** + * Retrieve the value at a given path. + * Note: Tuples are not supported by typings. + * Max path depth typed is 5. + */ + ( + path: [P1, P2, P3], obj: {[K1 in P1]: {[K2 in P2]: {[K3 in P3]: T}}}): T; + /** + * Retrieve the value at a given path. + * Note: Tuples are not supported by typings. + * Max path depth typed is 5. + */ + (path: [P1, P2], obj: T[][]): T; + /** + * Retrieve the value at a given path. + * Note: Tuples are not supported by typings. + * Max path depth typed is 5. + */ + (path: [P1, P2], + obj: {[K2 in P2]: T}[]): T; + /** + * Retrieve the value at a given path. + * Note: Tuples are not supported by typings. + * Max path depth typed is 5. + */ + (path: [P1, P2], + obj: {[K1 in P1]: T[]}): T; + /** + * Retrieve the value at a given path. + * Note: Tuples are not supported by typings. + * Max path depth typed is 5. + */ + (path: [P1, P2], + obj: {[K1 in P1]: {[K2 in P2]: T}}): T; + /** + * Retrieve the value at a given path. + * Note: Tuples are not supported by typings. + * Max path depth typed is 5. + */ + (path: [P1], obj: T[]): T; + /** + * Retrieve the value at a given path. + * Note: Tuples are not supported by typings. + * Max path depth typed is 5. + */ + (path: [P1], obj: {[K1 in P1]: T}): T; + /** + * Retrieve the value at a given path. + * Note: Tuples are not supported by typings. + * Max path depth typed is 5. + * Fallback signature. + */ + (path: (string | number)[]): { + (obj: any): T; + } + /** + * Retrieve the value at a given path. + * Note: Tuples are not supported by typings. + * Max path depth typed is 5. + * Fallback signature. + */ + (path: (string | number)[], obj: any): T; +} + +declare const path: Path export = path diff --git a/src/prop.d.ts b/src/prop.d.ts deleted file mode 100644 index a2e7b0f..0000000 --- a/src/prop.d.ts +++ /dev/null @@ -1,175 +0,0 @@ -/** - * This is auto generated source. - */ - -import { Struct, List, Prop } from '../interfaces'; - - -/** - * Acts as multiple `prop`: array of keys in, array of values out. Preserves order. - */ -declare function props( - ps: [P1, P2, P3, P4, P5, P6, P7, P8], obj: O): - [O[P1], O[P2], O[P3], O[P4], O[P5], O[P6], O[P7], O[P8]]; - - -/** - * Acts as multiple `prop`: array of keys in, array of values out. Preserves order. - */ -declare function props( - ps: [P1, P2, P3, P4, P5, P6, P7], obj: O): - [O[P1], O[P2], O[P3], O[P4], O[P5], O[P6], O[P7]]; - - -/** - * Acts as multiple `prop`: array of keys in, array of values out. Preserves order. - */ -declare function props( - ps: [P1, P2, P3, P4, P5, P6], obj: O): - [O[P1], O[P2], O[P3], O[P4], O[P5], O[P6]]; - - -/** - * Acts as multiple `prop`: array of keys in, array of values out. Preserves order. - */ -declare function props(ps: [P1, P2, P3, P4, P5], - obj: O): [O[P1], O[P2], O[P3], O[P4], O[P5]]; - - -/** - * Acts as multiple `prop`: array of keys in, array of values out. Preserves order. - */ -declare function props( - ps: [P1, P2, P3, P4], obj: O): [O[P1], O[P2], O[P3], O[P4]]; - - -/** - * Acts as multiple `prop`: array of keys in, array of values out. Preserves order. - */ -declare function props(ps: [P1, P2, P3], obj: O): - [O[P1], O[P2], O[P3]]; - - -/** - * Acts as multiple `prop`: array of keys in, array of values out. Preserves order. - */ -declare function props( - ps: [P1, P2], obj: O): [O[P1], O[P2]]; - - -/** - * Acts as multiple `prop`: array of keys in, array of values out. Preserves order. - */ -declare function props(ps: [P1], obj: O): [O[P1]]; - -// curried - - -/** - * Acts as multiple `prop`: array of keys in, array of values out. Preserves order. - */ -declare function props( - ps: [P1, P2, P3, P4, P5, P6, P7, P8]): - (obj: O) => - [O[P1], O[P2], O[P3], O[P4], O[P5], O[P6], O[P7], O[P8]]; - - -/** - * Acts as multiple `prop`: array of keys in, array of values out. Preserves order. - */ -declare function props(ps: [P1, P2, P3, P4, P5, P6, P7]): - (obj: O) => - [O[P1], O[P2], O[P3], O[P4], O[P5], O[P6], O[P7]]; - - -/** - * Acts as multiple `prop`: array of keys in, array of values out. Preserves order. - */ -declare function props( - ps: [P1, P2, P3, P4, P5, P6]): - (obj: O) => - [O[P1], O[P2], O[P3], O[P4], O[P5], O[P6]]; - - -/** - * Acts as multiple `prop`: array of keys in, array of values out. Preserves order. - */ -declare function props( - ps: [P1, P2, P3, P4, P5]): - (obj: O) => - [O[P1], O[P2], O[P3], O[P4], O[P5]]; - - -/** - * Acts as multiple `prop`: array of keys in, array of values out. Preserves order. - */ -declare function props(ps: [P1, P2, P3, P4]): - (obj: O) => - [O[P1], O[P2], O[P3], O[P4]]; - - -/** - * Acts as multiple `prop`: array of keys in, array of values out. Preserves order. - */ -declare function props(ps: [P1, P2, P3]): - (obj: O) => [O[P1], O[P2], O[P3]]; - - -/** - * Acts as multiple `prop`: array of keys in, array of values out. Preserves order. - */ -declare function props(ps: [P1, P2]): - (obj: O) => [O[P1], O[P2]]; - - -/** - * Acts as multiple `prop`: array of keys in, array of values out. Preserves order. - */ -declare function props(ps: [P1]): - (obj: O) => [O[P1]]; - - -/** - * Acts as multiple `prop`: array of keys in, array of values out. Preserves order. - */ -declare function props(ps: List, obj: List): T[]; - -// curried - - -/** - * Acts as multiple `prop`: array of keys in, array of values out. Preserves order. - */ -declare function props(ps: List): (obj: List) => T[]; - -export = prop diff --git a/test.sh b/test.sh deleted file mode 100644 index 1f61d0d..0000000 --- a/test.sh +++ /dev/null @@ -1,10 +0,0 @@ -#!/bin/bash -for test in $(find tests -name '*.ts'); do - node ./node_modules/typings-checker/dist/index.js $test --verbose --noLines 2>&1 | perl -pe 's/\.ts:(\d+)/.ts/' | tee $test.out - rc=${PIPESTATUS[0]}; if [[ $rc != 0 ]]; then exit $rc; fi -done - -# This shows changes and sets the exit code. -set -o errexit -git status -git --no-pager diff -- tests diff --git a/test/assocPath.ts b/test/assocPath.ts index f805d75..c119956 100644 --- a/test/assocPath.ts +++ b/test/assocPath.ts @@ -7,43 +7,43 @@ type nestedX = { x: number }; const obj = { a: { b: { c: 0 } } }; const objWithList = { a: [{ c: 0 }, { c: 1 }] }; describe('assocPath', () => { - it('path with two props', () => { - const value: number = 42; - const res = assocPath(['a', 'b'], { c: value }, obj).a.b.c; - equal(res, value); - }); + // it('path with two props', () => { + // const value: number = 42; + // const res = assocPath(['a', 'b'], { c: value }, obj).a.b.c; + // equal(res, value); + // }); - it('object with list inside', () => { - const value: number = 42; - const res = assocPath(['a', 1], { c: value }, objWithList).a[1].c; - equal(res, value); - }); + // it('object with list inside', () => { + // const value: number = 42; + // const res = assocPath(['a', 1], { c: value }, objWithList).a[1].c; + // equal(res, value); + // }); - it('curried 2-1: object with list inside', () => { - const value: number = 42; - const res = assocPath(['a', 1], { c: value }) - (objWithList).a[1].c; - equal(res, value); - }); + // it('curried 2-1: object with list inside', () => { + // const value: number = 42; + // const res = assocPath(['a', 1], { c: value }) + // (objWithList).a[1].c; + // equal(res, value); + // }); - it('curried 1-2: object with list inside', () => { - const value: number = 42; - const res = assocPath(['a', 1])({ c: value }, - objWithList).a[1].c; - equal(res, value); - }); + // it('curried 1-2: object with list inside', () => { + // const value: number = 42; + // const res = assocPath(['a', 1])({ c: value }, + // objWithList).a[1].c; + // equal(res, value); + // }); - it('curried 1-1-1: object with list inside', () => { - const value: number = 42; - const res = assocPath(['a', 1])({ c: value }) - (objWithList).a[1].c; - equal(res, value); - }); + // it('curried 1-1-1: object with list inside', () => { + // const value: number = 42; + // const res = assocPath(['a', 1])({ c: value }) + // (objWithList).a[1].c; + // equal(res, value); + // }); - it('ts error: incorrect type for value not allowed', () => { - typeFail(` - import assocPath = require('ramda/src/assocPath'); - assocPath(['a', 'b'], '42', {a: {b: 0}}) - `, /is not assignable/); - }); + // it('ts error: incorrect type for value not allowed', () => { + // typeFail(` + // import assocPath = require('ramda/src/assocPath'); + // assocPath(['a', 'b'], '42', {a: {b: 0}}) + // `, /is not assignable/); + // }); }); diff --git a/test/path.ts b/test/path.ts index aa0b079..fec1ce0 100644 --- a/test/path.ts +++ b/test/path.ts @@ -34,7 +34,7 @@ describe('path', () => { it('list with object inside', () => { const value: number = 43; - const res = path([ 1, 'c'], list); + const res = path([1, 'c'], list); equal(res, value); }); @@ -44,6 +44,15 @@ describe('path', () => { equal(res, value); }); + it('generic path sting[]', () => { + const value: number = 42; + const f = (p: string[]) => { + return path(p, obj); + }; + const res = f(['a', 'b', 'c']); + equal(res, value); + }); + // it.skip('ts error: incorrect type for value not allowed', () => { // typeFail(` // import assocPath = require('ramda/src/assocPath'); diff --git a/tests/test.ts b/tests/test.ts deleted file mode 100644 index 9f71aee..0000000 --- a/tests/test.ts +++ /dev/null @@ -1,3326 +0,0 @@ -import * as R from '../index'; - -declare let console: any; - -let double = (x: number): number => x + x; - -let shout = function(x: number): string { - return x >= 10 - ? 'big' - : 'small'; -}; - -// check type information is not lost for lists -let onlyNumberList = function(xs: number[]): number[] { - return xs; -}; - -// check type information is not lost for simple objects -let onlyNumberObj = function(xs: {[key: string]: number}): {[key: string]: number} { - return xs; -}; - - -class F { - x = 'X'; - y = 'Y'; -} -class F2 { - a = 100; - y = 1; - x() {}; - z() {}; -} - -// isArrayLike -() => { - // $ExpectType boolean - R.isArrayLike('a'); - // $ExpectType boolean - R.isArrayLike([1,2,3]); - // $ExpectType boolean - R.isArrayLike([]); -}; - -// propIs -(() => { - // $ExpectType boolean - R.propIs(Number, 'x', {x: 1, y: 2}); // => true - // $ExpectType boolean - R.propIs(Number, 'x')({x: 1, y: 2}); // => true - // $ExpectType boolean - R.propIs(Number)('x', {x: 1, y: 2}); // => true - // $ExpectType boolean - R.propIs(Number)('x')({x: 1, y: 2}); // => true - // $ExpectType boolean - R.propIs(Number, 'x', {x: 'foo'}); // => false - // $ExpectError Argument of type 'x' is not assignable to parameter of type 'never'.`, because 'x' is not in `{}`. - R.propIs(Number, 'x', {}); // => false -}); - -// type -(() => { - // $ExpectType string - R.type({}); // => 'Object' - // $ExpectType string - R.type(1); // => 'Number' - // $ExpectType string - R.type(false); // => 'Boolean' - // $ExpectType string - R.type('s'); // => 'String' - // $ExpectType string - R.type(null); // => 'Null' - // $ExpectType string - R.type([]); // => 'Array' - // $ExpectType string - R.type(/[A-z]/); // => 'RegExp' -}); - -// curry -() => { - const addTwo = R.curry((x: number, y: number) => x + y); - // $ExpectType (v2: number) => number - addTwo(3); - // $ExpectType number - addTwo(3)(1); - const addThree = R.curry((x: number, y: number, z: number) => x + y + z); - // $ExpectType number - addThree(3, 2, 1); - // $ExpectType number - addThree(3)(2)(1); - // $ExpectType (v3: number) => number - addThree(3, 2); - // $ExpectType (v2: number) => number - addThree(3)(2); - // $ExpectType CurriedFunction2 - addThree(3); - - const xy = R.curry((x: X, y: Y) => ({ x, y })); - // $ExpectType (v2: Y) => { x: number; y: Y; } - xy(3); - // $ExpectType { x: number; y: number; } - xy(3)(1); - const xyz = R.curry((x: X, y: Y, z: Z) => ({ x, y, z })); - // $ExpectType { x: number; y: number; z: number; } - xyz(3, 2, 1); - // $ExpectType { x: number; y: number; z: number; } - xyz(3)(2)(1); - // $ExpectType (v3: Z) => ({ x: number; y: number; z: Z; }) - xyz(3, 2); - // $ExpectType (v3: Z) => ({ x: number; y: number; z: Z; }) - xyz(3)(2); - // $ExpectType (v2: Y, v3: Z) => ({ x: number; y: Y; z: Z; }) - xyz(3); -}; - -// unary, binary, nAry -() => { - let takesNoArg = function() { return true; }; - let takesOneArg = function(a: number) { return [a]; }; - let takesTwoArgs = function(a: number, b: number) { return [a, b]; }; - let takesThreeArgs = function(a: number, b: number, c: number) { return [a, b, c]; }; - - let addFourNumbers = function(a: number, b: number, c: number, d: number): number { - return a + b + c + d; - }; - - const curriedFourNumbers = R.curry(addFourNumbers); - // $ExpectType CurriedFunction4 - curriedFourNumbers; - // $ExpectType CurriedFunction3 - curriedFourNumbers(1); - // $ExpectType CurriedFunction2 - curriedFourNumbers(1)(2); - // $ExpectType (v1: T1) => R - curriedFourNumbers(1)(2)(3); - // $ExpectType (v1: T1) => R - curriedFourNumbers(1,2,4); - // $ExpectType number - curriedFourNumbers(1)(2)(3)(4); - // $ExpectType number - curriedFourNumbers(1,2)(3,4); - // $ExpectType number - curriedFourNumbers(1,2,3)(4); - - // $ExpectType () => boolean - R.nAry(0, takesNoArg); - // $ExpectType () => number[] - R.nAry(0, takesOneArg); - // $ExpectType (a: number) => number[] - R.nAry(1, takesTwoArgs); - // $ExpectType (a: number) => number[] - R.nAry(1, takesThreeArgs); - - // $ExpectType (a: number) => number[] - R.unary(takesOneArg); - // $ExpectType (a: number) => number[] - R.unary(takesTwoArgs); - // $ExpectType (a: number) => number[] - R.unary(takesThreeArgs); - - // $ExpectType (a: number, b: number) => number[] - R.binary(takesTwoArgs); - // $ExpectType (a: number, b: number) => number[] - R.binary(takesThreeArgs); - - let addTwoNumbers = function(a: number, b: number) { return a + b; }; - // $ExpectType CurriedFunction2 - let addTwoNumbersCurried = R.curry(addTwoNumbers); - - let inc = addTwoNumbersCurried(1); - // $ExpectType number - inc(2); - // $ExpectType number - addTwoNumbersCurried(2,3); -}; - -// uncurry -() => { - const addFour = (a: number) => (b: number) => (c: number) => (d: number) => a + b + c + d; - const uncurriedAddFour = R.uncurryN(4, addFour); - // $ExpectType number - uncurriedAddFour(1, 2, 3, 4); // => 10 -}; - -// unless -() => { - // $ExpectType (v: a|[a]) => [a] - const coerceArray = R.unless(R.isArrayLike, R.of); - // $ExpectType number[] - coerceArray([1, 2, 3]); // => [1, 2, 3] - // $ExpectType number[] - coerceArray(1); // => [1] -}; - -// nthArg -(() => { - // $ExpectType string - R.nthArg(1)('a', 'b', 'c'); // => 'b' - // $ExpectType string - R.nthArg(-1)('a', 'b', 'c'); // => 'c' -}); - -// unapply -() => { - // $ExpectType (...args: string[])=>string - R.unapply(JSON.stringify); - // $ExpectType string - R.unapply(JSON.stringify)(1, 2, 3); // => '[1,2,3]' -}; - -// until -() => { - // $ExpectType number - R.until(R.flip(R.gt)(100), R.multiply(2))(1); // => 128 -}; - -// propSatisfies -() => { - const truncate = R.when( - R.propSatisfies(R.flip(R.gt)(10), 'length'), - R.pipe(R.take(10), R.append('…'), R.join('')) - ); - // $ExpectType string - truncate('12345'); // => '12345' - // $ExpectType string - truncate('0123456789ABC'); // => '0123456789…' -}; - -/* compose */ -() => { - let limit10 = function(x: number): boolean { - return x >= 10; - }; - // $ExpectType (x0: number) => boolean - R.compose(limit10, double); - // $ExpectType boolean - R.compose(limit10, double)(10); - - const f0 = (s: string) => +s; // string -> number - const f1 = (n: number) => n === 1; // number -> boolean - const f2 = R.compose(f1, f0); // string -> boolean - - // akward example that bounces types between number and string - const g0 = (list: number[]) => R.map(R.inc, list); - const g1 = R.dropWhile(R.gt(10)); - const g2 = R.map((i: number) => i > 5 ? 'bigger' : 'smaller'); - const g3 = R.all((i: string) => i === 'smaller'); - // $ExpectType (list: number[]) => boolean - const g = R.compose(g3, g2, g1, g0); - // $ExpectType boolean - g([1, 2, 10, 13]); -}; - -/* pipe */ -() => { - // $ExpectType (x0: number) => string - R.pipe(double, double, shout); - // $ExpectType string - R.pipe(double, double, shout)(10); - - // $ExpectType string - const capitalize = (str: string) => R.pipe( - R.split(''), - R.adjust(R.toUpper, 0), - R.join('') - )(str); - - let f = R.pipe(Math.pow, R.negate, R.inc); - // $ExpectType number - f(3, 4); // -(3^4) + 1 - - // test for type degeneration if the first function has generics - // $ExpectType (x0: number) => number - R.pipe(R.identity, double); -}; - -/* pipeP */ -() => { - // $ExpectType Promise - R.pipeP( - (m: number) => Promise.resolve(R.multiply(2, m)), - (m: number) => Promise.resolve(m / 2), - R.multiply(2) - )(10); -}; - -// TODO: pipeK - -// invoker -() => { - // $ExpectType string - R.invoker(0, 'toUpperCase', 'foo'); - // $ExpectType string - R.invoker(1, 'charAt', 'foo', 1); -}; - -// juxt -(() => { - const range = R.juxt([Math.min, Math.max]); - // $ExpectType number[] - range(3, 4, 9, -3); // => [-3, 9] - - const chopped = R.juxt([R.head, R.last]); - // $ExpectType string[] - chopped('longstring'); // => ['l', 'g'] -}); - -// useWith -(() => { - let square = function(x: number) { return x * x; }; - let add = function(a: number, b: number) { return a + b; }; - // Adds any number of arguments together - let addAll = function() { - return 0; - }; - - // Basic example - R.useWith(addAll, [ double, square ]); -}); - -// clone -(() => { - let printXPlusFive = function(x: number) { console.log(x + 5); }; - R.forEach(printXPlusFive, [1, 2, 3]); - // $ExpectType Object[] - R.clone([{},{},{}]); - // $ExpectType number[] - R.clone([1,2,3]); -})(); - -// forEach -// (() => { -// let printXPlusFive = function(x, i) { console.log(i + 5); }; -// R.forEach.idx(printXPlusFive, [{name: 1}, {name: 2}, {name: 3}]); -// })(); - -// times -(() => { - let i = function(x: number) {return x;}; - // $ExpectType number[] - R.times(i, 5); -})(); - -// pipe -(() => { - let triple = function(x: number): number { return x * 3; }; - let square = function(x: number): number { return x * x; }; - let squareThenDoubleThenTriple = R.pipe(square, double, triple); - // $ExpectType number - squareThenDoubleThenTriple(5); // => 150 -})(); - -// partial -(() => { - let multiply = function(a: number, b: number) { return a * b; }; - let double = R.partial(multiply, [2]); - // $ExpectType number - double(2); // => 4 - - let greet = function(salutation: string, title: string, firstName: string, lastName: string) { - return salutation + ', ' + title + ' ' + firstName + ' ' + lastName + '!'; - }; - let sayHello = R.partial(greet, ['Hello']); - let sayHelloToMs = R.partial(sayHello, ['Ms.']); - // $ExpectType string - sayHelloToMs('Jane', 'Jones'); // => 'Hello, Ms. Jane Jones!' - - let greetMsJaneJones = R.partialRight(greet, ['Ms.', 'Jane', 'Jones']); - // $ExpectType string - greetMsJaneJones('Hello'); // => 'Hello, Ms. Jane Jones!' -})(); - -// memoize -(() => { - let numberOfCalls = 0; - let trackedAdd = function(a: number, b: number) { - numberOfCalls += 1; - return a + b; - }; - let memoTrackedAdd = R.memoize(trackedAdd); - - // $ExpectType number - memoTrackedAdd(1, 2); // => 3 - // $ExpectType number - numberOfCalls; // => 1 - // $ExpectType number - memoTrackedAdd(1, 2); // => 3 - // $ExpectType number - numberOfCalls; // => 1 - // $ExpectType number - memoTrackedAdd(2, 3); // => 5 - // $ExpectType number - numberOfCalls; // => 2 - - // Note that argument order matters - // $ExpectType number - memoTrackedAdd(2, 1); // => 3 - // $ExpectType number - numberOfCalls; // => 3 -})(); - -// once -(() => { - let x: number; - let addOneOnce = R.once(function(x: number){ return x + 1; }); - // $ExpectType number - addOneOnce(10); // => 11 - // $ExpectType number - addOneOnce(addOneOnce(50)); // => 11 -})(); - -// match -() => { - // $ExpectType string[] - R.match(/([a-z]a)/g, 'bananas'); // => ['ba', 'na', 'na'] - // $ExpectType string[] - R.match(/a/, 'b'); // => [] - // $ExpectError Argument of type 'null' is not assignable to parameter of type 'string'. - let sr = R.match(/a/, null); // error with strict null checks -}; - -// reduce -(() => { - let numbers = [1, 2, 3]; - let add = function(a: number, b: number) { - return a + b; - }; - // $ExpectType number - R.reduce(add, 10, numbers); // => 16; -})(); - -// add -(() => { - let plus3 = R.add(3); - // $ExpectType number - plus3(5); -})(); - -// reduceRight -(() => { - let pairs = [ ['a', 1], ['b', 2], ['c', 3] ]; - let flattenPairs = function(acc: [string, number], pair: [string, number]) { - return acc.concat(pair); - }; - // $ExpectType Array - R.reduceRight(flattenPairs, [], pairs); // => [ 'c', 3, 'b', 2, 'a', 1 ] -})(); - -// reduceWhile -() => { - let isOdd = (x: number, acc: number) => x % 2 === 1; - let xs = [1, 3, 5, 60, 777, 800]; - // $ExpectType number - R.reduceWhile(isOdd, R.add, 0, xs); // => 9 - - let ys = [2, 4, 6]; - // $ExpectType number - R.reduceWhile(isOdd, R.add, 111, ys); // => 111 -}; - -// mapObjIndexed -(() => { - let values = { x: 1, y: 2, z: 3 }; - let prependKeyAndDouble = function(num: number, key: string, obj: any) { - return key + (num * 2); - }; - // $ExpectType Dictionary - R.mapObjIndexed(prependKeyAndDouble, values); // => { x: 'x2', y: 'y4', z: 'z6' } -}); - -// ap, of -(() => { - // $ExpectType number[] - R.ap([R.multiply(2), R.add(3)], [1,2,3]); // => [2, 4, 6, 4, 5, 6] - // $ExpectType number[][] - R.of([1]); // => [[1]] - // $ExpectType number[] - R.of(1); -}); - -// empty -() => { - // $ExpectType number[] - R.empty([1,2,3,4,5]); // => [] - // $ExpectType number[] - R.empty([1, 2, 3]); // => [] - // $ExpectType string - R.empty('unicorns'); // => '' - // $ExpectType {} - R.empty({x: 1, y: 2}); // => {} -}; - -// length -(() => { - // $ExpectType number - R.length([1, 2, 3]); // => 3 -}); - -// addIndex, filter, reject -(() => { - const isEven = function(n: number) { - return n % 2 === 0; - }; - const filterIndexed = R.addIndex(R.filter); - - // $ExpectType number[] - R.filter(isEven, [1, 2, 3, 4]); // => [2, 4] - - let lastTwo = function(val: number, idx: number, list: number[]) { - return list.length - idx <= 2; - }; - // $ExpectType number[] - filterIndexed(lastTwo, [8, 6, 7, 5, 3, 0, 9]); // => [0, 9] - - let isOdd = function(n: number) { - return n % 2 === 1; - }; - // $ExpectType number[] - R.reject(isOdd, [1, 2, 3, 4]); // => [2, 4] -}); - -// take, takeWhile -(() => { - let isNotFour = function(x: number) { - return !(x === 4); - }; - // $ExpectType number[] - R.takeWhile(isNotFour, [1, 2, 3, 4]); // => [1, 2, 3] - // $ExpectType number[] - R.take(2, [1, 2, 3, 4]); // => [1, 2] -}); - -// unfold -(() => { - let f = function(n: number) { return n > 50 ? false : [-n, n + 10]; }; - // $ExpectType number[] - R.unfold(f, 10); // => [-10, -20, -30, -40, -50] - let b = R.unfold(f); // => [-10, -20, -30, -40, -50] - // $ExpectType number[] - b(10); -}); - -/***************************************************************** - * Function category - */ - -// flip -() => { - let mergeThree = function(a: number, b: number, c: number): number[] { - return ([] as number[]).concat(a, b, c); // strictNullChecks: must cast array to right type - }; - // $ExpectType number[] - mergeThree(1, 2, 3); // => [1, 2, 3] - let flipped = R.flip(mergeThree); - // $ExpectType number[] - flipped(1, 2, 3); // => [2, 1, 3] - }; - -/********************* - * List category - ********************/ - -// all -() => { - let lessThan2 = R.flip(R.lt)(2); - let lessThan3 = R.flip(R.lt)(3); - // $ExpectType boolean - R.all(lessThan2)([1, 2]); // => false - // $ExpectType boolean - R.all(lessThan3)([1, 2]); // => true -}; - -// any -() => { - let lessThan0 = R.flip(R.lt)(0); - let lessThan2 = R.flip(R.lt)(2); - // $ExpectType boolean - R.any(lessThan0)([1, 2]); // => false - // $ExpectType boolean - R.any(lessThan2)([1, 2]); // => true -}; - -// ascend -() => { - let byAge = R.ascend(R.prop('age')); - let alice = { - name: 'ALICE', - age: 101 - }; - let bob = { - name: 'Bob', - age: -10 - }; - let clara = { - name: 'clara', - age: 314.159 - }; - let people = [clara, bob, alice]; - // $ExpectType typeof people - let peopleByYoungestFirst = R.sort(byAge, people); -}; - -// aperture -() => { - // $ExpectType number[][] - R.aperture(2, [1, 2, 3, 4, 5]); // => [[1, 2], [2, 3], [3, 4], [4, 5]] - // $ExpectType number[][] - R.aperture(3, [1, 2, 3, 4, 5]); // => [[1, 2, 3], [2, 3, 4], [3, 4, 5]] - // $ExpectType number[][] - R.aperture(7, [1, 2, 3, 4, 5]); // => [] - // $ExpectType number[][] - R.aperture(7)([1, 2, 3, 4, 5]); // => [] -}; - -// append -() => { - // $ExpectType string[] - R.append('tests', ['write', 'more']); // => ['write', 'more', 'tests'] - // $ExpectType string[] - R.append('tests')(['write', 'more']); // => ['write', 'more', 'tests'] - // $ExpectType string[] - R.append('tests', []); // => ['tests'] - // $ExpectType Array - R.append(['tests'], ['write', 'more']); // => ['write', 'more', ['tests']] - // $ExpectType Array - R.append(['tests'], ['write', 'more']); // => ['write', 'more', ['tests']] - // $ExpectType Array - R.append(['tests'])(['write', 'more']); // => ['write', 'more', ['tests']] - // $ExpectType Array - R.append(['tests'])(['write', 'more']); // => ['write', 'more', ['tests']] -}; - -// chain -() => { - let duplicate = function(n: number) { - return [n, n]; - }; - // $ExpectType number[] - R.chain(duplicate, [1, 2, 3]); // => [1, 1, 2, 2, 3, 3] - // $ExpectType number[] - R.chain(duplicate)([1, 2, 3]); // => [1, 1, 2, 2, 3, 3] - // $ExpectType number[] - R.chain(R.append, R.head)([1, 2, 3]); // => [1, 2, 3, 1] - // $ExpectType number[] - R.chain(R.append)(R.head)([1, 2, 3]); // => [1, 2, 3, 1] -}; - -// clamp -() => { - // $ExpectType number - R.clamp(1, 10, -1); // => 1 - // $ExpectType number - R.clamp(1, 10)(11); // => 10 - // $ExpectType number - R.clamp(1)(10, 4); // => 4 - // $ExpectType string - R.clamp('a', 'd', 'e'); // => 'd' -}; - -// concat -() => { - R.concat([], []); // => [] // let r: [] = - // $ExpectType number[] - R.concat([4, 5, 6], [1, 2, 3]); // => [4, 5, 6, 1, 2, 3] - // $ExpectType number[] - R.concat([4, 5, 6])([1, 2, 3]); // => [4, 5, 6, 1, 2, 3] - // $ExpectType string - R.concat('ABC')('DEF'); // 'ABCDEF' -}; - -// contains -() => { - // $ExpectType boolean - R.contains(3)([1, 2, 3]); // => true - // $ExpectType boolean - R.contains(3, [1, 2, 3]); // => true - // $ExpectType boolean - R.contains(4)([1, 2, 3]); // => false - // $ExpectType boolean - R.contains({})([{}, {}]); // => false - let obj = {}; - // $ExpectType boolean - R.contains(obj)([{}, obj, {}]); // => true -}; - -// descend -() => { - let byAge = R.descend(R.prop('age')); - let alice = { - name: 'ALICE', - age: 101 - }; - let bob = { - name: 'Bob', - age: -10 - }; - let clara = { - name: 'clara', - age: 314.159 - }; - let people = [clara, bob, alice]; - // $ExpectType typeof people - let peopleByOldestFirst = R.sort(byAge, people); -}; - -// drop -() => { - // $ExpectType number[] - R.drop(3, [1,2,3,4,5,6,7]); // => [4,5,6,7] - // $ExpectType number[] - R.drop(3)([1,2,3,4,5,6,7]); // => [4,5,6,7] - // $ExpectType string - R.drop(3, 'ramda'); // => 'ram' - // $ExpectType string - R.drop(3)('ramda'); // => 'ram' -}; - -// dropLast -(() => { - // $ExpectType string[] - R.dropLast(1, ['foo', 'bar', 'baz']); // => ['foo', 'bar'] - // $ExpectType string[] - R.dropLast(2)(['foo', 'bar', 'baz']); // => ['foo'] - // $ExpectType string - R.dropLast(3, 'ramda'); // => 'ra' - // $ExpectType string - R.dropLast(3)('ramda'); // => 'ra' -}); - -// dropLastWhile -(() => { - let lteThree = (x: number) => x <= 3; - // $ExpectType number[] - R.dropLastWhile(lteThree, [1, 2, 3, 4, 3, 2, 1]); // => [1, 2, 3, 4] -}); - -// dropWhile -() => { - let lteTwo = function(x: number) { - return x <= 2; - }; - // $ExpectType number[] - R.dropWhile(lteTwo, [1, 2, 3, 4]); // => [3, 4] - // $ExpectType number[] - R.dropWhile(lteTwo)([1, 2, 3, 4]); // => [3, 4] -}; - -// filter -() => { - let isEven = function(n: number) { - return n % 2 === 0; - }; - // filter works with lists... - // $ExpectType number[] - R.filter(isEven, [1, 2, 3, 4]); // => [2, 4] - let isEvenFn = R.filter(isEven); - isEvenFn([1, 2, 3, 4]); - // ... but also objects - // $ExpectType Dictionary - R.filter(isEven, {a: 1, b: 2, c: 3, d: 4}); // => {b: 2, d: 4} - let isEvenFnObj = R.filter(isEven); - // see that we did not break anything - // and we kept type information - // $ExpectType number[] - onlyNumberList(R.filter(isEven,[1,2,3,4])); - // $ExpectType Dictionary - onlyNumberObj(R.filter(isEven, {a: 1, b: 2, c: 3, d: 4})); // strictNullChecks: Partial fails, consider Pick -}; - -// addIndex -() => { - let lastTwo = function(val: number, idx: number, list: number[]) { - return list.length - idx <= 2; - }; - let filterIndexed = R.addIndex(R.filter); - - // $ExpectType number[] - filterIndexed(lastTwo, [8, 6, 7, 5, 3, 0, 9]); // => [0, 9] - let lastTwoFn = filterIndexed(lastTwo); - // $ExpectType number[] - lastTwoFn([8, 6, 7, 5, 3, 0, 9]); -}; - -// find, propEq -() => { - let xs = [{a: 1}, {a: 2}, {a: 3}]; - // $ExpectType Dictionary - R.find(R.propEq('a', 2))(xs); // => {a: 2} - // $ExpectType undefined - R.find(R.propEq('a', 4))(xs); // => undefined -}; - -// find -() => { - type Task = {id: number}; - let tasks: Task[] = []; - const a = R.find((task: Task) => task.id === 1, tasks); // this works - const f: (list: Task[]) => Task = R.find((task: Task) => task.id === 1); - // $ExpectType Task - f(tasks); // works -}; - -// findIndex -() => { - type Task = {a: number}; - let xs = [{a: 1}, {a: 2}, {a: 3}]; - const a: (list: Task[]) => number = R.findIndex(R.propEq('a', 2)); - // $ExpectType number - a(xs); // => 1 - // $ExpectType number - R.findIndex(R.propEq('a', 4))(xs); // => -1 - - // $ExpectType number - R.findIndex((x: number) => x === 1, [1, 2, 3]); -}; - -// findLast -() => { - let xs = [{a: 1, b: 0}, {a: 1, b: 1}]; - // $ExpectType Dictionary - R.findLast(R.propEq('a', 1))(xs); // => {a: 1, b: 1} - // $ExpectType undefined - R.findLast(R.propEq('a', 4))(xs); // => undefined -}; - -// findLastIndex -() => { - let xs = [{a: 1, b: 0}, {a: 1, b: 1}]; - // $ExpectType number - R.findLastIndex(R.propEq('a', 1))(xs); // => 1 - // $ExpectType number - R.findLastIndex(R.propEq('a', 4))(xs); // => -1 - // $ExpectType number[] - R.findLastIndex((x: number) => x === 1, [1, 2, 3]); -}; - -// pathEq -() => { - let user1 = { address: { zipCode: 90210 } }; - let user2 = { address: { zipCode: 55555 } }; - let user3 = { name: 'Bob' }; - let users = [ user1, user2, user3 ]; - let isFamous = R.pathEq(['address', 'zipCode'], 90210); - // $ExpectType Object[] - R.filter(isFamous, users); // => [ user1 ] -}; - -// propEq -() => { - let xs: {[key: string]: string} = {a: '1', b: '0'}; - // $ExpectType boolean - R.propEq('a', '1', xs);// => true - // $ExpectType boolean - R.propEq('a', '4', xs); // => false -}; -() => { - let xs: {[key: string]: number} = {a: 1, b: 0}; - // $ExpectType boolean - R.propEq('a', 1, xs);// => true - // $ExpectType boolean - R.propEq('a', 4, xs); // => false -}; -() => { - let xs = {a: '1', b: '0'}; - // $ExpectType boolean - R.propEq('a', '1', xs);// => true - // $ExpectType boolean - R.propEq('a', '4', xs); // => false -}; -() => { - let xs = {a: 1, b: 0}; - // $ExpectType boolean - R.propEq('a', 1, xs);// => true - // $ExpectType boolean - R.propEq('a', 4, xs); // => false -}; -interface Obj { a: number; b: number; }; -() => { - let xs: Obj = {a: 1, b: 0}; - // $ExpectType boolean - R.propEq('a', 1, xs);// => true - // $ExpectType boolean - R.propEq('a', 4, xs); // => false -}; - -// forEach -() => { - let printXPlusFive = function(x: number) { console.log(x + 5); }; - // $ExpectType number[] - R.forEach(printXPlusFive, [1, 2, 3]); // => [1, 2, 3] - // $ExpectType number[] - R.forEach(printXPlusFive)([1, 2, 3]); // => [1, 2, 3] - // => 6 - // => 7 - // => 8 -}; - -// forEach -() => { - let printKeyConcatValue = (value: any, key: string, obj: any) => console.log(key + ':' + value); - // $ExpectType {x: 1, y: 2} - R.forEachObjIndexed(printKeyConcatValue, {x: 1, y: 2}); - // $ExpectType {x: 1, y: 2} - R.forEachObjIndexed(printKeyConcatValue)({x: 1, y: 2}); - // $ExpectType [1, 2] - R.forEachObjIndexed(printKeyConcatValue, [1, 2]); - // $ExpectType [1, 2] - R.forEachObjIndexed(printKeyConcatValue)([1, 2]); -}; - -// addIndex? -() => { - let plusFive = function(num: number, idx: number, list: number[]) { list[idx] = num + 5; }; - // $ExpectType number[] - R.addIndex(R.forEach)(plusFive)([1, 2, 3]); // => [6, 7, 8] -}; - -// groupBy -() => { - let byGrade = R.groupBy(function(student: {score: number; name: string}) { - let score = student.score; - return score < 65 ? 'F' : - score < 70 ? 'D' : - score < 80 ? 'C' : - score < 90 ? 'B' : 'A'; - }); - let students = [{name: 'Abby', score: 84}, - {name: 'Eddy', score: 58}, - {name: 'Jack', score: 69}]; - // $ExpectType Dictionary - byGrade(students); -}; - -// groupWith -() => { - // $ExpectType number[][] - R.groupWith(R.equals, [0, 1, 1, 2, 3, 5, 8, 13, 21]); - // [[0], [1, 1], [2, 3, 5, 8, 13, 21]] - - // $ExpectType number[][] - R.groupWith((a: number, b: number) => a % 2 === b % 2, [0, 1, 1, 2, 3, 5, 8, 13, 21]); - // [[0], [1, 1], [2], [3, 5], [8], [13, 21]] - - const isVowel = (a: string) => R.contains(a, 'aeiou') ? a : ''; - // $ExpectType string[] - R.groupWith(R.eqBy(isVowel), 'aestiou'); - // ['ae', 'st', 'iou'] -}; - -// head -() => { - // $ExpectType string - R.head(['fi', 'fo', 'fum']); // => 'fi' - // $ExpectType number - R.head([10, 'ten']); // => 10 - // $ExpectType string - R.head(['10', 10]); // => '10' -}; - -// indexBy -(() => { - let list = [{id: 'xyz', title: 'A'}, {id: 'abc', title: 'B'}]; - // $ExpectType Dictionary - R.indexBy(R.prop('id'), list); - // $ExpectType Dictionary - R.indexBy(R.prop('id'))(list); - // $ExpectType Dictionary - R.indexBy<{id: string}>(R.prop('id'))(list); -}); - -// indexOf -() => { - // $ExpectType number - R.indexOf(3, [1,2,3,4]); // => 2 - // $ExpectType number - R.indexOf(10)([1,2,3,4]); // => -1 -}; - -// init -() => { - // $ExpectType string[] - R.init(['fi', 'fo', 'fum']); // => ['fi', 'fo'] -}; - -// insert -() => { - // $ExpectType number[] - R.insert(2, 5, [1,2,3,4]); // => [1,2,5,3,4] - // $ExpectType number[] - R.insert(2)(5, [1,2,3,4]); // => [1,2,5,3,4] - // $ExpectType number[] - R.insert(2, 5)([1,2,3,4]); // => [1,2,5,3,4] - // $ExpectType number[] - R.insert(2)(5)([1,2,3,4]); // => [1,2,5,3,4] -}; - -// insertAll -() => { - // $ExpectType number[] - R.insertAll(2, [10,11,12], [1,2,3,4]); - // $ExpectType number[] - R.insertAll(2)([10,11,12], [1,2,3,4]); - // $ExpectType number[] - R.insertAll(2, [10,11,12])([1,2,3,4]); - // $ExpectType number[] - R.insertAll(2)([10,11,12])([1,2,3,4]); -}; - -// intersection -() => { - // $ExpectType number[] - R.intersection([1,2,3,4], [7,6,5,4,3]); // => [4, 3] - // $ExpectType number[] - R.intersection([1,2,3,4])([7,6,5,4,3]); // => [4, 3] - // $ExpectType number[] - R.intersection([1,2,4], [1,2,3]); // => [1,2] - // $ExpectType number[] - R.intersection([1,2,4])([1,2,3]); // => [1,2] -}; - -// intersectionWith -() => { - let buffaloSpringfield = [ - {id: 824, name: 'Richie Furay'}, - {id: 956, name: 'Dewey Martin'}, - {id: 313, name: 'Bruce Palmer'}, - {id: 456, name: 'Stephen Stills'}, - {id: 177, name: 'Neil Young'} - ]; - let csny = [ - {id: 204, name: 'David Crosby'}, - {id: 456, name: 'Stephen Stills'}, - {id: 539, name: 'Graham Nash'}, - {id: 177, name: 'Neil Young'} - ]; - - // $ExpectType { id: number, name: string }[] - R.intersectionWith(R.eqBy(R.prop('id')), buffaloSpringfield, csny); - // => [{id: 456, name: 'Stephen Stills'}, {id: 177, name: 'Neil Young'}] - // $ExpectType { id: number, name: string }[] - R.intersectionWith(R.eqBy(R.prop('id')), buffaloSpringfield, csny); - // => [{id: 456, name: 'Stephen Stills'}, {id: 177, name: 'Neil Young'}] - // $ExpectType { id: number, name: string }[] - R.intersectionWith(R.eqBy(R.prop('id')))(buffaloSpringfield, csny); - // $ExpectType { id: number, name: string }[] - R.intersectionWith(R.eqBy(R.prop('id')))(buffaloSpringfield)(csny); -}; - -// into -() => { - let numbers = [1, 2, 3, 4]; - let a = R.map(R.add(1), R.take(2, numbers)); - let b = R.take(2); - let transducer = R.compose(R.map(R.add(1)), R.take(2)); - - - // $ExpectType number[] - R.into([], transducer, numbers); // => [2, 3] - // $ExpectType number[] - R.into([])(transducer, numbers); // => [2, 3] - // $ExpectType number[] - R.into([], transducer)(numbers); // => [2, 3] - - let intoArray = R.into([]); - // $ExpectType number[] - intoArray(transducer, numbers); // => [2, 3] - // $ExpectType number[] - intoArray(transducer)(numbers); // => [2, 3] -}; - -// join -() => { - let spacer = R.join(' '); - // $ExpectType string - spacer(['a', 2, 3.4]); // => 'a 2 3.4' - // $ExpectType string - R.join('|', [1, 2, 3]); // => '1|2|3' -}; - -// last -() => { - // $ExpectType string - R.last(['fi', 'fo', 'fum']); // => 'fum' -}; - -// lastIndexOf -() => { - R.lastIndexOf(3, [-1,3,3,0,1,2,3,4]); // => 6 - R.lastIndexOf(10, [1,2,3,4]); // => -1 - R.lastIndexOf(10)([1,2,3,4]); // => -1 -}; - -// length -() => { - // $ExpectType number - R.length([]); // => 0 - // $ExpectType number - R.length([1, 2, 3]); // => 3 -}; - -// lensIndex, set, view, over -() => { - let headLens = R.lensIndex(0); - // $ExpectType number - headLens([10, 20, 30, 40]); // => 10 - // $ExpectType Array - headLens.set('mu', [10, 20, 30, 40]); // => ['mu', 20, 30, 40] - // $ExpectType string - R.view(headLens, ['a', 'b', 'c']); // => 'a' - // $ExpectType string[] - R.set(headLens, 'x', ['a', 'b', 'c']); // => ['x', 'b', 'c'] - // $ExpectType string[] - R.over(headLens, R.toUpper, ['a', 'b', 'c']); // => ['A', 'b', 'c'] -}; - -// map -() => { - let arrayify = (v: T): T[] => [v]; - // homogeneous array - // $ExpectType number[] - R.map(double, [1, 2, 3]); // => [2, 4, 6] - // $ExpectType number[] - R.map(double)([1, 2, 3]); // => [2, 4, 6] - // homogeneous object - // $ExpectType Dictionary - R.map(double, { a: 1, b: 2, c: 3 }); // => { a: 2, b: 4, c: 6 } - // $ExpectType Dictionary - R.map(double)({ a: 1, b: 2, c: 3 }); // => { a: 2, b: 4, c: 6 } - // heterogeneous array - // $ExpectType [number[], string[]] - R.map(arrayify, [1, 'a']); // => [[1], ['a']] - // $ExpectType [number[], string[]] - R.map(arrayify)([1, 'a']); // => [[1], ['a']] - // heterogeneous object - // $ExpectType { a: number[], b: string[] } - R.map(arrayify, { a: 1, b: 'c' }); // => { a: [1], b: ['c'] } - // $ExpectType { a: number[], b: string[] } - R.map(arrayify)({ a: 1, b: 'c' }); // => { a: [1], b: ['c'] } - - // functor - // I'm sorry, I have no clue how to make this example work with proper functor typing - // const stringFunctor = { - // map: (fn: (c: number) => number) => { - // let chars = 'Ifmmp!Xpsme'.split(''); - // return chars.map((char) => String.fromCharCode(fn(char.charCodeAt(0)))).join(''); - // } - // }; - // let s = R.map((x: number) => x-1, stringFunctor); // => 'Hello World' -}; - -// mapAccum -() => { - let digits = ['1', '2', '3', '4']; - let append = function(a: string, b: string): [string, string]{ - return [a + b, a + b]; - }; - // $ExpectType Array - R.mapAccum(append, '0', digits); // => ['01234', ['01', '012', '0123', '01234']] - // $ExpectType Array - R.mapAccum(append)('0', digits); // => ['01234', ['01', '012', '0123', '01234']] - // $ExpectType Array - R.mapAccum(append, '0')(digits); // => ['01234', ['01', '012', '0123', '01234']] - // $ExpectType Array - R.mapAccum(append)('0')(digits); // => ['01234', ['01', '012', '0123', '01234']] -}; - -// mapAccumRight -() => { - let digits = ['1', '2', '3', '4']; - let append = function(a: string, b: string): [string, string] { - return [a + b, a + b]; - }; - // $ExpectType Array - R.mapAccumRight(append, '0', digits); // => ['04321', ['04321', '0432', '043', '04']] - // $ExpectType Array - R.mapAccumRight(append)('0', digits); // => ['04321', ['04321', '0432', '043', '04']] - // $ExpectType Array - R.mapAccumRight(append, '0')(digits); // => ['04321', ['04321', '0432', '043', '04']] - // $ExpectType Array - R.mapAccumRight(append)('0')(digits); // => ['04321', ['04321', '0432', '043', '04']] -}; - -// addIndex -() => { - let squareEnds = function(elt: number, idx: number, list: number[]) { - if (idx === 0 || idx === list.length - 1) { - return elt * elt; - } - return elt; - }; - // $ExpectType number[] - R.addIndex(R.map)(squareEnds, [8, 5, 3, 0, 9]); // => [64, 5, 3, 0, 81] - // $ExpectType number[] - R.addIndex(R.map)(squareEnds)([8, 5, 3, 0, 9]); // => [64, 5, 3, 0, 81] -}; - -// none -() => { - // $ExpectType boolean - R.none(R.isNaN, [1, 2, 3]); // => true - // $ExpectType boolean - R.none(R.isNaN, [1, 2, 3, NaN]); // => false - // $ExpectType boolean - R.none(R.isNaN)([1, 2, 3, NaN]); // => false -}; - -// nth -() => { - let list = ['foo', 'bar', 'baz', 'quux']; - // $ExpectType string - R.nth(1, list); // => 'bar' - // $ExpectType string - R.nth(-1, list); // => 'quux' - // $ExpectType undefined - R.nth(-99, list); // => undefined - // $ExpectType undefined - R.nth(-99)(list); // => undefined -}; - -// partition, contains -() => { - // $ExpectType [string[], string[]] - R.partition(R.contains('s'), ['sss', 'ttt', 'foo', 'bars']); - // $ExpectType [string[], string[]] - R.partition(R.contains('s'))(['sss', 'ttt', 'foo', 'bars']); - // $ExpectType [number[], number[]] - R.partition((x: number) => x > 2, [1, 2, 3, 4]); - // $ExpectType [number[], number[]] - R.partition((x: number) => x > 2)([1, 2, 3, 4]); - // $ExpectType Object[] - R.partition(R.contains('s'),{ a: 'sss', b: 'ttt', foo: 'bars' }); // => [ { a: 'sss', foo: 'bars' }, { b: 'ttt' } ] -}; - -// pluck -() => { - // $ExpectType number[] - R.pluck('a', [{a: 1}, {a: 2}]); // => [1, 2] - // $ExpectType number[] - R.pluck(0, [[1, 2], [3, 4]]); // => [1, 3] - // $ExpectType number[] - R.pluck('a')([{a: 1}, {a: 2}]); // => [1, 2] - // $ExpectType number[] - R.pluck(0)([[1, 2], [3, 4]]); // => [1, 3] -}; - -// prepend -() => { - // $ExpectType string[] - R.prepend('fee', ['fi', 'fo', 'fum']); // => ['fee', 'fi', 'fo', 'fum'] - // $ExpectType string[] - R.prepend('fee')(['fi', 'fo', 'fum']); // => ['fee', 'fi', 'fo', 'fum'] -}; - -// range -() => { - // $ExpectType number[] - R.range(1, 5); // => [1, 2, 3, 4] - // $ExpectType number[] - R.range(50)(53); // => [50, 51, 52] -}; - -// reduce -() => { - let numbers = [1, 2, 3]; - let add = function(a: number, b: number) { - return a + b; - }; - // $ExpectType number - R.reduce(add, 10, numbers); // => 16 - // $ExpectType number - R.reduce(add)(10, numbers); // => 16 - // $ExpectType number - R.reduce(add, 10)(numbers); // => 16 -}; - -// reduceBy - -interface Student { - name: string; - score: number; -} -() => { - const reduceToNamesBy = R.reduceBy((acc: string[], student: Student) => acc.concat(student.name), []); - const namesByGrade = reduceToNamesBy(function(student: Student) { - let score = student.score; - return score < 65 ? 'F' : - score < 70 ? 'D' : - score < 80 ? 'C' : - score < 90 ? 'B' : 'A'; - }); - let students = [{name: 'Lucy', score: 92}, - {name: 'Drew', score: 85}, - {name: 'Bart', score: 62}]; - // $ExpectType Dictionary - namesByGrade(students); - // { - // 'A': ['Lucy'], - // 'B': ['Drew'] - // 'F': ['Bart'] - // } -}; - -// addIndex -() => { - let reduceIndexed = R.addIndex(R.reduce); - let letters = ['a', 'b', 'c']; - let objectify = function(accObject: {[elem: string]: number}, elem: string, idx: number, list: string[]) { - accObject[elem] = idx; - return accObject; - }; - // $ExpectType Dictionary - reduceIndexed(objectify, {}, letters); // => { 'a': 0, 'b': 1, 'c': 2 } - // $ExpectType Dictionary - reduceIndexed(objectify)({}, letters); // => { 'a': 0, 'b': 1, 'c': 2 } - // $ExpectType Dictionary - reduceIndexed(objectify, {})(letters); // => { 'a': 0, 'b': 1, 'c': 2 } -}; - -// reduceRight -interface KeyValuePair extends Array { 0 : K; 1 : V; } -type Pair = KeyValuePair; -() => { - let pairs: Pair[] = [ ['a', 1], ['b', 2], ['c', 3] ]; - let flattenPairs = function(pair: Pair, acc: Pair[]): Pair[] { - return acc.concat(pair); - }; - // $ExpectType Array - R.reduceRight(flattenPairs, [], pairs); // => [ 'c', 3, 'b', 2, 'a', 1 ] - // $ExpectType Array - R.reduceRight(flattenPairs, [])(pairs); // => [ 'c', 3, 'b', 2, 'a', 1 ] - // $ExpectType Array - R.reduceRight(flattenPairs)([], pairs); // => [ 'c', 3, 'b', 2, 'a', 1 ] -}; - -// reject -() => { - let isOdd = function(n: number) { - return n % 2 === 1; - }; - // $ExpectType number[] - R.reject(isOdd, [1, 2, 3, 4]); // => [2, 4] - const a2 = R.reject(isOdd); - // $ExpectType number[] - R.reject(isOdd)([1, 2, 3, 4]); // => [2, 4] -}; - -// rejectIndexed -() => { - const lastTwo = function(val: number, idx: number, list: number[]) { - return list.length - idx <= 2; - }; - const rejectIndexed = R.addIndex(R.reject); - // $ExpectType number[] - rejectIndexed(lastTwo, [8, 6, 7, 5, 3, 0, 9]); // => [8, 6, 7, 5, 3] - // $ExpectType number[] - rejectIndexed(lastTwo)([8, 6, 7, 5, 3, 0, 9]); // => [8, 6, 7, 5, 3] -}; - -// remove -() => { - // $ExpectType number[] - R.remove(2, 3, [1,2,3,4,5,6,7,8]); // => [1,2,6,7,8] - // $ExpectType number[] - R.remove(2, 3)([1,2,3,4,5,6,7,8]); // => [1,2,6,7,8] - // $ExpectType number[] - R.remove(2)(3, [1,2,3,4,5,6,7,8]); // => [1,2,6,7,8] -}; - -// repeat -() => { - // $ExpectType string[] - R.repeat('hi', 5); // => ['hi', 'hi', 'hi', 'hi', 'hi'] - let obj = {}; - let repeatedObjs = R.repeat(obj, 5); // => [{}, {}, {}, {}, {}] - // $ExpectType boolean - repeatedObjs[0] === repeatedObjs[1]; // => true -}; - -// reverse -() => { - // $ExpectType number[] - R.reverse([1, 2, 3]); // => [3, 2, 1] - // $ExpectType number[] - R.reverse([1, 2]); // => [2, 1] - // $ExpectType number[] - R.reverse([1]); // => [1] - // $ExpectType number[] - R.reverse([]); // => [] -}; - -// scan -() => { - let numbers = [1, 2, 3, 4]; - // $ExpectType number[] - R.scan(R.multiply, 1, numbers); // => [1, 1, 2, 6, 24] - // $ExpectType number[] - R.scan(R.multiply, 1)(numbers); // => [1, 1, 2, 6, 24] - // $ExpectType number[] - R.scan(R.multiply)(1, numbers); // => [1, 1, 2, 6, 24] -}; - -// slice -() => { - let xs = R.range(0, 10); - // $ExpectType number[] - R.slice(2, 5, xs); // => [2, 3, 4] - // $ExpectType number[] - R.slice(2, 5)(xs); // => [2, 3, 4] - // $ExpectType number[] - R.slice(2)(5, xs); // => [2, 3, 4] - - let str = 'Hello World'; - // $ExpectType string - R.slice(2, 5, str); // => 'llo' - // $ExpectType string - R.slice(2, 5)(str); // => 'llo' - // $ExpectType string - R.slice(2)(5, str); // => 'llo' -}; - -// sort -() => { - let diff = function(a: number, b: number) { return a - b; }; - // $ExpectType number[] - R.sort(diff, [4,2,7,5]); // => [2, 4, 5, 7] - // $ExpectType number[] - R.sort(diff)([4,2,7,5]); // => [2, 4, 5, 7] -}; - -// cond, equals, always -() => { - const fn = R.cond([ - [R.equals(0), R.always('water freezes at 0°C')], - [R.equals(100), R.always('water boils at 100°C')], - [R.T, (temp: number) => 'nothing special happens at ' + temp + '°C'] - ]); - // $ExpectType string - fn(0); // => 'water freezes at 0°C' - // $ExpectType string - fn(50); // => 'nothing special happens at 50°C' - // $ExpectType string - fn(100); // => 'water boils at 100°C' -}; - -// tail -() => { - // $ExpectType string[] - R.tail(['fi', 'fo', 'fum']); // => ['fo', 'fum'] - // $ExpectType number[] - R.tail([1, 2, 3]); // => [2, 3] -}; - -// take -() => { - // $ExpectType number[] - R.take(3,[1,2,3,4,5]); // => [1,2,3] - - let members= [ 'Paul Desmond','Bob Bates','Joe Dodge','Ron Crotty','Lloyd Davis','Joe Morello','Norman Bates', - 'Eugene Wright','Gerry Mulligan','Jack Six','Alan Dawson','Darius Brubeck','Chris Brubeck', - 'Dan Brubeck','Bobby Militello','Michael Moore','Randy Jones']; - let takeFive = R.take(5); - // $ExpectType string[] - takeFive(members); // => ['Paul Desmond','Bob Bates','Joe Dodge','Ron Crotty','Lloyd Davis'] -}; -() => { - // $ExpectType string - R.take(3,'Example'); // => 'Exa' - - let takeThree = R.take(3); - // $ExpectType string - takeThree('Example'); // => 'Exa' -}; - -// takeLast -() => { - // $ExpectType string[] - R.takeLast(1, ['foo', 'bar', 'baz']); // => ['baz'] - // $ExpectType string[] - R.takeLast(2)(['foo', 'bar', 'baz']); // => ['bar', 'baz'] - // $ExpectType string - R.takeLast(3, 'ramda'); // => 'mda' - // $ExpectType string - R.takeLast(3)('ramda'); // => 'mda' -}; - -// takeLastWhile -() => { - const isNotOne = (x: number) => x !== 1; - // $ExpectType number[] - R.takeLastWhile(isNotOne, [1, 2, 3, 4]); // => [2, 3, 4] - // $ExpectType number[] - R.takeLastWhile(isNotOne)([1, 2, 3, 4]); // => [2, 3, 4] -}; - -// takeWhile -() => { - let isNotFour = function(x: number) { - return !(x === 4); - }; - // $ExpectType number[] - R.takeWhile(isNotFour, [1, 2, 3, 4]); // => [1, 2, 3] - // $ExpectType number[] - R.takeWhile(isNotFour)([1, 2, 3, 4]); // => [1, 2, 3] -}; - -// tap -() => { - const sayX = (x: number) => console.log('x is ' + x); - // $ExpectType number - R.tap(sayX, 100); // => 100 -}; - -// test -() => { - // $ExpectType boolean - R.test(/^x/, 'xyz'); // => true - // $ExpectType boolean - R.test(/^y/)('xyz'); // => false -}; - -// times -() => { - // $ExpectType number[] - R.times(R.identity, 5); // => [0, 1, 2, 3, 4] - // $ExpectType number[] - R.times(R.identity)(5); // => [0, 1, 2, 3, 4] -}; - -// toString -() => { - class Point { - constructor(public x: number, public y: number) { - this.x = x; - this.y = y; - } - toStringn() { - return 'new Point(' + this.x + ', ' + this.y + ')'; - } - }; - // $ExpectType string - R.toString(new Point(1, 2)); // => 'new Point(1, 2)' - // $ExpectType string - R.toString(42); // => '42' - // $ExpectType string - R.toString('abc'); // => ''abc'' - // $ExpectType string - R.toString([1, 2, 3]); // => '[1, 2, 3]' - // $ExpectType string - R.toString({foo: 1, bar: 2, baz: 3}); // => '{'bar': 2, 'baz': 3, 'foo': 1}' - // $ExpectType string - R.toString(new Date('2001-02-03T04: 05: 06Z')); // => 'new Date('2001-02-03T04: 05: 06.000Z')' -}; - -// transduce -() => { - let numbers = [1, 2, 3, 4]; - let transducer = R.compose(R.map(R.add(1)), R.take(2)); - let fn = R.flip(R.append); - // $ExpectType number[] - R.transduce(transducer, fn, [] as number[], numbers); // => [2, 3] // strictNullChecks: must annotate empty array type - // $ExpectType number[] - R.transduce(transducer, fn, [] as number[])(numbers); // => [2, 3] - // $ExpectType number[] - R.transduce(transducer, fn)([] as number[], numbers); // => [2, 3] - // $ExpectType number[] - R.transduce(transducer)(fn, [] as number[], numbers); // => [2, 3] -}; - -// // traverse -// () => { -// // Returns `Nothing` if the given divisor is `0` -// safeDiv = n => d => d === 0 ? Nothing() : Just(n / d) -// -// R.traverse(Maybe.of, safeDiv(10), [2, 4, 5]); // => Just([5, 2.5, 2]) -// R.traverse(Maybe.of, safeDiv(10), [2, 0, 5]); // => Nothing -// } - -// transpose -() => { - // $ExpectType any[][] - R.transpose([[1, 'a'], [2, 'b'], [3, 'c']]); // => [[1, 2, 3], ['a', 'b', 'c']] - // $ExpectType any[][] - R.transpose([[1, 2, 3], ['a', 'b', 'c']]); // => [[1, 'a'], [2, 'b'], [3, 'c']] - // $ExpectType number[][] - R.transpose([[10, 11], [20], [], [30, 31, 32]]); // => [[10, 20, 30], [11, 31], [32]] -}; - -// tryCatch -() => { - const x = R.prop('x'); - // $ExpectType boolean - R.tryCatch(R.prop('x'), R.F)({x: true}); // => true - // $ExpectType boolean - R.tryCatch(R.prop('x'), R.F)(null); // => false -}; - -// uniq -() => { - // $ExpectType number[] - R.uniq([1, 1, 2, 1]); // => [1, 2] - // $ExpectType Object[] - R.uniq([{}, {}]); // => [{}, {}] - // $ExpectType any[] - R.uniq([1, '1']); // => [1, '1'] -}; - -// uniqWith -() => { - let strEq = function(a: any, b: any) { return String(a) === String(b); }; - // $ExpectType number[] - R.uniqWith(strEq, [1, '1', 2, 1]); // => [1, 2] - // $ExpectType number[] - R.uniqWith(strEq)([1, '1', 2, 1]); // => [1, 2] - // $ExpectType Object[] - R.uniqWith(strEq)([{}, {}]); // => [{}] - // $ExpectType number[] - R.uniqWith(strEq)([1, '1', 1]); // => [1] - // $ExpectType string[] - R.uniqWith(strEq)(['1', 1, 1]); // => ['1'] -}; - -// unnest, equals -() => { - // $ExpectType boolean - R.equals(R.unnest([1, [2], [[3]]]), [1,2,[3]]); // => true - // $ExpectType boolean - R.equals(R.unnest([[1, 2], [3, 4], [5, 6]]),[1,2,3,4,5,6]); // => true -}; - -// xprod -() => { - // $ExpectType [number, string][] - R.xprod([1, 2], ['a', 'b']); // => [[1, 'a'], [1, 'b'], [2, 'a'], [2, 'b']] - // $ExpectType [number, string][] - R.xprod([1, 2])(['a', 'b']); // => [[1, 'a'], [1, 'b'], [2, 'a'], [2, 'b']] -}; - -// zip -() => { - // $ExpectType [number, string][] - R.zip([1, 2, 3], ['a', 'b', 'c']); // => [[1, 'a'], [2, 'b'], [3, 'c']] - // $ExpectType [number, string][] - R.zip([1, 2, 3])(['a', 'b', 'c']); // => [[1, 'a'], [2, 'b'], [3, 'c']] -}; - -// zipObj -() => { - // $ExpectType Dictionary - R.zipObj(['a', 'b', 'c'], [1, 2, 3]); // => {a: 1, b: 2, c: 3} - // $ExpectType Dictionary - R.zipObj(['a', 'b', 'c'])([1, 2, 3]); // => {a: 1, b: 2, c: 3} -}; - -// zipWith -() => { - let f = function(x: number, y: string) { - // ... - }; - // $ExpectType any[] - R.zipWith(f, [1, 2, 3], ['a', 'b', 'c']); // => [f(1, 'a'), f(2, 'b'), f(3, 'c')] - // $ExpectType any[] - R.zipWith(f)([1, 2, 3], ['a', 'b', 'c']); // => [f(1, 'a'), f(2, 'b'), f(3, 'c')] - // $ExpectType any[] - R.zipWith(f, [1, 2, 3])(['a', 'b', 'c']); // => [f(1, 'a'), f(2, 'b'), f(3, 'c')] -}; - -/***************************************************************** - * Object category - */ - -// assoc -() => { - // $ExpectType Dictionary - R.assoc('c', 3, {a: 1, b: 2}); // => {a: 1, b: 2, c: 3} - // $ExpectType Dictionary - R.assoc('c')(3, {a: 1, b: 2}); // => {a: 1, b: 2, c: 3} - // $ExpectType Dictionary - R.assoc('c', 3)({a: 1, b: 2}); // => {a: 1, b: 2, c: 3} -}; - -// dissoc -() => { - // $ExpectType Dictionary - R.dissoc<{a: number, c: number}>('b', {a: 1, b: 2, c: 3}); // => {a: 1, c: 3} - // $ExpectType Dictionary - R.dissoc('b', {a: 1, b: 2, c: 3}); // => {a: 1, c: 3} - // $ExpectType Dictionary - R.dissoc('b')<{a: number, c: number}>({a: 1, b: 2, c: 3}); // => {a: 1, c: 3} -}; - -// assocPath -() => { - // $ExpectType {a: {b: {c: number}}} - R.assocPath(['a', 'b', 'c'], 42, {a: {b: {c: 0}}}); // => {a: {b: {c: 42}}} - // $ExpectType {a: {b: {c: number}}} - R.assocPath(['a', 'b', 'c'])(42, {a: {b: {c: 0}}}); // => {a: {b: {c: 42}}} - // $ExpectType {a: {b: {c: number}}} - R.assocPath(['a', 'b', 'c'], 42)({a: {b: {c: 0}}}); // => {a: {b: {c: 42}}} -}; - -// dissocPath -() => { - // $ExpectType {a: {b: {}}} - R.dissocPath(['a', 'b', 'c'], {a: {b: {c: 42}}}); // => {a: {b: {}}} - // optionally specify return type - // $ExpectType {a: {b: {}}} - R.dissocPath<{a : { b: number}}>(['a', 'b', 'c'], {a: {b: {c: 42}}}); // => {a: {b: {}}} - // $ExpectType {a: {b: {}}} - R.dissocPath(['a', 'b', 'c'])({a: {b: {c: 42}}}); // => {a: {b: {}}} -}; - -// clone -() => { - let obj1 = [{}, {}, {}]; - let obj2 = [{a: 1}, {a: 2}, {a: 3}]; - // $ExpectType any[] - R.clone(obj1); - // $ExpectType {a: number}[] - R.clone(obj2); - // $ExpectType Object - R.clone({}); - // $ExpectType 10 - R.clone(10); - // $ExpectType "foo" - R.clone('foo'); - // $ExpectType number - R.clone(Date.now()); -}; - -// eqProps -() => { - let o1 = { a: 1, b: 2, c: 3, d: 4 }; - let o2 = { a: 10, b: 20, c: 3, d: 40 }; - // $ExpectType boolean - R.eqProps('a', o1, o2); // => false - // $ExpectType boolean - R.eqProps('c', o1, o2); // => true - // $ExpectType {(obj1: T, obj2: U): boolean} - R.eqProps('c'); - // $ExpectType {(obj2: U): boolean} - R.eqProps('c', o1); -}; - -// evolve -() => { - let tomato = {firstName: 'Tomato ', data: {elapsed: 100, remaining: 1400}, id: 123}; - let transformations = { - firstName: R.trim, - lastName: R.trim, // Will not get invoked. - data: {elapsed: R.add(1), remaining: R.add(-1)} - }; - // $ExpectType typeof tomato - const a: typeof tomato = R.evolve(transformations, tomato); // => {firstName: 'Tomato', data: {elapsed: 101, remaining: 1399}, id: 123} - // $ExpectType typeof tomato - const b: typeof tomato = R.evolve(transformations)(tomato); // => {firstName: 'Tomato', data: {elapsed: 101, remaining: 1399}, id: 123} -}; - -// has -() => { - const hasName = R.has('name'); - // $ExpectType boolean - hasName({name: 'alice'}); // => true - // $ExpectType boolean - hasName({name: 'bob'}); // => true - // $ExpectType boolean - hasName({}); // => false - - const point = {x: 0, y: 0}; - const pointHas = R.flip(R.has)(point); - // $ExpectType boolean - pointHas('x'); // => true - // $ExpectType boolean - pointHas('y'); // => true - // $ExpectType boolean - pointHas('z'); // => false -}; - -// hasIn -class Rectangle { - constructor(public width: number, public height: number) { - this.width = width; - this.height = height; - } - area(): number { - return this.width * this.height; - } -}; -() => { - let square = new Rectangle(2, 2); - // $ExpectType boolean - R.hasIn('width', square); // => true - // $ExpectType boolean - R.hasIn('area', square); // => true - // $ExpectType boolean - R.flip(R.hasIn)(square)('area'); // => true -}; - -// invert -() => { - let raceResultsByFirstName = { - first: 'alice', - second: 'jake', - third: 'alice' - }; - // $ExpectType Dictionary - R.invert(raceResultsByFirstName); - // => { 'alice': ['first', 'third'], 'jake': ['second'] } -}; - -// invertObj -() => { - let raceResults0 = { - first: 'alice', - second: 'jake' - }; - // $ExpectType Dictionary - R.invertObj(raceResults0); - // => { 'alice': 'first', 'jake': 'second' } - - // Alternatively: - let raceResults1 = ['alice', 'jake']; - // $ExpectType Dictionary - R.invertObj(raceResults1); - // => { 'alice': '0', 'jake': '1' } -}; - -// keys -() => { - // $ExpectType string[] - R.keys({a: 1, b: 2, c: 3}); // => ['a', 'b', 'c'] -}; - -// keysIn -() => { - let f = new F(); - // $ExpectType string[] - R.keysIn(f); // => ['x', 'y'] -}; - -// lens -() => { - interface xy { - x: number; - y: number; - } - // let xLens = R.lens(R.prop('x'), R.assoc('x')); - // let xLens = R.lens(R.prop('x'), R.assoc('x')); - let xLens = R.lens(R.prop('x'))(R.assoc('x')); - // ^ works with only 1 generic, for curried version managed to split the inferred generic from the manual generic - // $ExpectType number - R.view(xLens, {x: 1, y: 2}); // => 1 - // $ExpectType { x: number, y: number } - R.set(xLens, 4, {x: 1, y: 2}); // => {x: 4, y: 2} - // $ExpectType { x: number, y: number } - R.set(xLens)(4, {x: 1, y: 2}); // => {x: 4, y: 2} - // $ExpectType { x: number, y: number } - R.set(xLens, 4)({x: 1, y: 2}); // => {x: 4, y: 2} - // $ExpectType { x: number, y: number } - R.over(xLens, R.negate, {x: 1, y: 2}); // => {x: -1, y: 2} - // $ExpectType { x: number, y: number } - R.over(xLens, R.negate)({x: 1, y: 2}); // => {x: -1, y: 2} - // $ExpectType { x: number, y: number } - R.over(xLens)(R.negate, {x: 1, y: 2}); // => {x: -1, y: 2} -}; - -// lensIndex -() => { - let headLens = R.lensIndex(0); - // $ExpectType string - R.view(headLens, ['a', 'b', 'c']); // => 'a' - // $ExpectType string[] - R.set(headLens, 'x', ['a', 'b', 'c']); // => ['x', 'b', 'c'] - // $ExpectType string[] - R.over(headLens, R.toUpper, ['a', 'b', 'c']); // => ['A', 'b', 'c'] -}; - -// lensProp -() => { - let xLens = R.lensProp('x'); - // $ExpectType number - R.view(xLens, {x: 1, y: 2}); // => 1 - // $ExpectType Dictionary - R.set(xLens, 4, {x: 1, y: 2}); // => {x: 4, y: 2} - // $ExpectType Dictionary - R.over(xLens, R.negate, {x: 1, y: 2}); // => {x: -1, y: 2} -}; - -// lensPath -() => { - const xyLens = R.lensPath(['x', 'y']); - // $ExpectType number - R.view(xyLens, {x: {y: 2, z: 3}}); // => 2 - // $ExpectType { [s: string]: { [s: string]: number } } - R.set(xyLens, 4, {x: {y: 2, z: 3}}); // => {x: {y: 4, z: 3}} - // $ExpectType { [s: string]: { [s: string]: number } } - R.over(xyLens, R.negate, {x: {y: 2, z: 3}}); // => {x: {y: -2, z: 3}} -}; - -// keys -() => { - // $ExpectType string[] - R.keys({a: 1, b: 2, c: 3}); // => ['a', 'b', 'c'] -}; - -// keysIn -() => { - let f = new F(); - // $ExpectType string[] - R.keysIn(f); // => ['x', 'y'] -}; - -// lens -() => { - let headLens = R.lens( - function get(arr: number[]) { return arr[0]; }, - function set(val: number, arr: number[]) { return [val].concat(arr.slice(1)); } - ); - headLens([10, 20, 30, 40]); // => 10 - // // $ExpectError Argument of type 'mu' is not assignable to parameter of type 'number'. - // headLens.set('mu', [10, 20, 30, 40]); // => ['mu', 20, 30, 40] - - let phraseLens = R.lens( - function get(obj: any) { return obj.phrase; }, - function set(val: string, obj: any) { - let out = R.clone(obj); - out.phrase = val; - return out; - } - ); - let obj1 = { phrase: 'Absolute filth . . . and I LOVED it!'}; - let obj2 = { phrase: "What's all this, then?"}; - // $ExpectType string - phraseLens(obj1); // => 'Absolute filth . . . and I LOVED it!' - // $ExpectType string - phraseLens(obj2); // => "What's all this, then?" - // $ExpectType Dictionary - phraseLens.set('Ooh Betty', obj1); // => { phrase: 'Ooh Betty'} -}; - -// lensProp -() => { - let phraseLens = R.lensProp('phrase'); - let obj1 = { phrase: 'Absolute filth . . . and I LOVED it!'}; - let obj2 = { phrase: "What's all this, then?"}; - // $ExpectType string - phraseLens(obj1); // => 'Absolute filth . . . and I LOVED it!' - // $ExpectType string - phraseLens(obj2); // => 'What's all this, then?' - // $ExpectType Dictionary - phraseLens.set('Ooh Betty', obj1); // => { phrase: 'Ooh Betty'} -}; - -// merge -() => { - // $ExpectType Dictionary - R.merge({ 'name': 'fred', 'age': 10 }, { 'age': 40 }); - // => { 'name': 'fred', 'age': 40 } - let resetToDefault = R.flip(R.merge)({x: 0}); - // $ExpectType Dictionary - resetToDefault({x: 5, y: 2}); // => {x: 0, y: 2} -}; - -// megeAll -() => { - // $ExpectType Dictionary - R.mergeAll([{foo: 1},{bar: 2},{baz: 3}]); // => {foo: 1,bar: 2,baz: 3} - // $ExpectType Dictionary - R.mergeAll([{foo: 1},{foo: 2},{bar: 2}]); // => {foo: 2,bar: 2} -}; - -// mergeWith -() => { - // $ExpectType { a: boolean, b: boolean, values: number[] } - R.mergeWith(R.concat, - { a: true, values: [10, 20] }, - { b: true, values: [15, 35] }); - // => { a: true, b: true, values: [10, 20, 15, 35] } -}; - -// mergeWithKey -() => { - let concatValues = (k: string, l: string, r: string) => k === 'values' ? R.concat(l, r) : r; - R.mergeWithKey(concatValues, - { a: true, thing: 'foo', values: [10, 20] }, - { b: true, thing: 'bar', values: [15, 35] }); - const merge = R.mergeWithKey(concatValues); - // $ExpectType { a: boolean, b: boolean, values: number[], thing: string } - merge({ a: true, thing: 'foo', values: [10, 20] }, { b: true, thing: 'bar', values: [15, 35] }); -}; - -// pathOr -() => { - // $ExpectType number - R.pathOr('N/A', ['a', 'b'], {a: {b: 2}}); // => 2 - // $ExpectType number - R.pathOr('N/A', ['a', 'b'])({a: {b: 2}}); // => 2 - // $ExpectType number - R.pathOr('N/A', ['a', 'b'], {c: {b: 2}}); // => 'N/A' - // $ExpectType number - R.pathOr({c: 2})(['a', 'b'], {c: {b: 2}}); // => 'N/A' -}; - -// pathSatisfies -() => { - // $ExpectType boolean - R.pathSatisfies((a: any) => a === 'foo', ['a', 'b', 'c'], {a: {b: {c: 'foo'}}}); // => true - // $ExpectType boolean - R.pathSatisfies((a: any) => a === 'bar', ['a', 'b', 'c'], {a: {b: {c: 'foo'}}}); // => false - // $ExpectType boolean - R.pathSatisfies((a: any) => a === 1, ['a', 'b', 'c'], {a: {b: {c: 1}}}); // => true - // $ExpectType boolean - R.pathSatisfies((a: any) => a !== 1, ['a', 'b', 'c'], {a: {b: {c: 2}}}); // => true - // $ExpectType boolean - R.pathSatisfies((a: any) => a === 1)(['a', 'b', 'c'], {a: {b: {c: 1}}}); // => true - // $ExpectType boolean - R.pathSatisfies((a: any) => a === 1, ['a', 'b', 'c'])({a: {b: {c: 1}}}); // => true - // $ExpectType boolean - R.pathSatisfies((a: any) => a === 1)(['a', 'b', 'c'])({a: {b: {c: 1}}}); // => true -}; - -// pickBy -() => { - let isPositive = function(n: number) { - return n > 0; - }; - // $ExpectType Dictionary - R.pickBy(isPositive, {a: 1, b: 2, c: -1, d: 0, e: 5}); // => {a: 1, b: 2, e: 5} - let containsBackground = function(val: any) { - return val.bgcolor; - }; - let colors = {1: {color: 'read'}, 2: {color: 'black', bgcolor: 'yellow'}}; - // $ExpectType { 2: R.Dictionary } - R.pickBy(containsBackground, colors); // => {2: {color: 'black', bgcolor: 'yellow'}} - - let isUpperCase = function(val: number, key: string) { return key.toUpperCase() === key; }; - // $ExpectType Dictionary - R.pickBy(isUpperCase, {a: 1, b: 2, A: 3, B: 4}); // => {A: 3, B: 4} -}; - - -// pick -() => { - // $ExpectType Dictionary - R.pick(['a', 'd'], {a: 1, b: 2, c: 3, d: 4}); // => {a: 1, d: 4} - // the following should errror: e/f are not keys in these objects - // $ExpectError not keys - let no1 = R.pick(['a', 'e', 'f'], {a: 1, b: 2, c: 3, d: 4}); // => {a: 1} - // $ExpectError not keys - let no2 = R.pick(['a', 'e', 'f'])({a: 1, b: 2, c: 3, d: 4}); // => {a: 1} - // $ExpectError not keys - let no3 = R.pick(['a', 'e', 'f'], [1, 2, 3, 4]); // => {a: 1} -}; - -// objOf -() => { - let matchPhrases = R.compose( - R.objOf('must'), - R.map(R.objOf('match_phrase')) - ); - // $ExpectType { must: { match_phrase: string }[] } - matchPhrases(['foo', 'bar', 'baz']); -}; - -// omit -() => { - // $ExpectType Dictionary - R.omit(['a', 'd'], {a: 1, b: 2, c: 3, d: 4}); // => {b: 2, c: 3} - // $ExpectType Dictionary - R.omit(['a', 'd'])({a: 1, b: 2, c: 3, d: 4}); // => {b: 2, c: 3} -}; - -// fromPairs -() => { - // $ExpectType Dictionary - R.fromPairs([['a', 1], ['b', 2], ['c', 3]]); // => {a: 1, b: 2, c: 3} -}; - -// pair -() => { - R.pair('foo', 'bar'); // => ['foo', 'bar'] - let p = R.pair('foo', 1); // => ['foo', 'bar'] - // $ExpectType string - p[0]; - // $ExpectType number - p[1]; -}; - -// over, lensIndex -() => { - let headLens = R.lensIndex(0); - // $ExpectType string[] - R.over(headLens, R.toUpper, ['foo', 'bar', 'baz']); // => ['FOO', 'bar', 'baz'] -}; - -// pickAll -() => { - // $ExpectType Dictionary - R.pickAll(['a', 'd'], {a: 1, b: 2, c: 3, d: 4}); // => {a: 1, d: 4} - // $ExpectType Dictionary - R.pickAll(['a', 'd'])({a: 1, b: 2, c: 3, d: 4}); // => {a: 1, d: 4} - // $ExpectType Dictionary - R.pickAll(['a', 'e', 'f'], {a: 1, b: 2, c: 3, d: 4}); // => {a: 1, e: undefined, f: undefined} - // $ExpectType Dictionary - R.pickAll(['a', 'e', 'f'])({a: 1, b: 2, c: 3, d: 4}); // => {a: 1, e: undefined, f: undefined} // why does this pass while the above fails? -}; - -// pickBy -() => { - let isUpperCase = function(val: number, key: string) { return key.toUpperCase() === key; }; - // $ExpectType Dictionary - R.pickBy(isUpperCase, {a: 1, b: 2, A: 3, B: 4}); // => {A: 3, B: 4} -}; - -// project -() => { - let abby = {name: 'Abby', age: 7, hair: 'blond', grade: 2}; - let fred = {name: 'Fred', age: 12, hair: 'brown', grade: 7}; - let kids = [abby, fred]; - // $ExpectType { name: string, grade: number }[] - R.project(['name', 'grade'], kids); // => [{name: 'Abby', grade: 2}, {name: 'Fred', grade: 7}] -}; - -// prop -() => { - // $ExpectType number - R.prop('x', {x: 100}); // => 100 - // $ExpectError Argument of type 'x' is not assignable to parameter of type 'never'. - R.prop('x', {}); // => undefined -}; - -// propOr -() => { - let alice = { - name: 'ALICE', - age: 101 - }; - let favorite = R.prop('favoriteLibrary'); - let favoriteWithDefault = R.propOr('Ramda', 'favoriteLibrary'); - - // $ExpectType undefined - favorite(alice); // => undefined - // $ExpectType string - favoriteWithDefault(alice); // => 'Ramda' -}; - -// propSatisfies -() => { - // $ExpectType boolean - R.propSatisfies((x: number) => x > 0, 'x', {x: 1, y: 2}); // => true - // $ExpectType boolean - R.propSatisfies((x: number) => x > 0, 'x')({x: 1, y: 2}); // => true - // $ExpectType boolean - R.propSatisfies((x: number) => x > 0)('x')({x: 1, y: 2}); // => true -}; - -// props -() => { - // $ExpectType number[] - R.props(['x', 'y'], {x: 1, y: 2}); // => [1, 2] - // $ExpectType Array - R.props(['c', 'a', 'b'], {b: 2, a: 1}); // => [undefined, 1, 2] - - let fullName = R.compose(R.join(' '), R.props(['first', 'last'])); - // $ExpectType string - fullName({last: 'Bullet-Tooth', age: 33, first: 'Tony'}); // => 'Tony Bullet-Tooth' -}; - -// toPairs -() => { - // $ExpectType [string, number][] - R.toPairs({a: 1, b: 2, c: 3}); // => [['a', 1], ['b', 2], ['c', 3]] -}; - -// toPairsIn -() => { - let f = new F(); - // $ExpectType [string, string][] - R.toPairsIn(f); // => [['x','X'], ['y','Y']] - // $ExpectType [string, string][] - R.toPairsIn(f); // => [['x','X'], ['y','Y']] -}; - -// values -() => { - // $ExpectType number[] - R.values({a: 1, b: 2, c: 3}); // => [1, 2, 3] -}; - -// valuesIn -() => { - let f = new F(); - // $ExpectType string[] - R.valuesIn(f); // => ['X', 'Y'] -}; - -// where -() => { - let spec = {x: 2}; - // $ExpectType boolean - R.where(spec, {w: 10, x: 2, y: 300}); // => true - // $ExpectType boolean - R.where(spec, {x: 1, y: 'moo', z: true}); // => false - // $ExpectType boolean - R.where(spec)({w: 10, x: 2, y: 300}); // => true - // $ExpectType boolean - R.where(spec)({x: 1, y: 'moo', z: true}); // => false - - // There's no way to represent the below functionality in typescript - // per http: //stackoverflow.com/a/29803848/632495 - // will need a work around. - - let spec2 = {x: function(val: number, obj: any) { return val + obj.y > 10; }}; - // $ExpectType boolean - R.where(spec2, {x: 2, y: 7}); // => false - // $ExpectType boolean - R.where(spec2, {x: 3, y: 8}); // => true - - let xs = [{x: 2, y: 1}, {x: 10, y: 2}, {x: 8, y: 3}, {x: 10, y: 4}]; - // $ExpectType { x: number, y: number }[] - R.filter(R.where({x: 10}), xs); // ==> [{x: 10, y: 2}, {x: 10, y: 4}] - // $ExpectType { x: number, y: number }[] - R.filter(R.where({x: 10}))(xs); // ==> [{x: 10, y: 2}, {x: 10, y: 4}] -}; - -// whereEq -() => { - // $ExpectType (v: Object) => Boolean - let pred = R.whereEq({a: 1, b: 2}); - // $ExpectType boolean - pred({a: 1}); // => false - // $ExpectType boolean - pred({a: 1, b: 2}); // => true - // $ExpectType boolean - pred({a: 1, b: 2, c: 3}); // => true - // $ExpectType boolean - pred({a: 1, b: 1}); // => false - // $ExpectType boolean - R.whereEq({a: 'one'}, {a: 'one'}); // => true -}; - -// without -() => { - // $ExpectType number[] - R.without([1, 2], [1, 2, 1, 3, 4]); // => [3, 4] -}; - -// mapIndexed, addIndex -() => { - let mapIndexed = R.addIndex(R.map); - // $ExpectType string[] - mapIndexed(function(val: string, idx: number) {return idx + '-' + val;})(['f', 'o', 'o', 'b', 'a', 'r']); - // $ExpectType string[] - R.mapIndexed(function(val: string, idx: number) {return idx + '-' + val;})(['f', 'o', 'o', 'b', 'a', 'r']); - // => ['0-f', '1-o', '2-o', '3-b', '4-a', '5-r'] - // $ExpectType number[] - R.mapIndexed((rectangle: Rectangle, idx: number): number => rectangle.area()*idx, [new Rectangle(1,2), new Rectangle(4,7)]); - // => [2, 56] -}; - -// addIndex -() => { - let reduceIndexed = R.addIndex(R.reduce); - // $ExpectType string[] - reduceIndexed( - (acc: string, val: string, idx: number) => acc + ',' + idx + '-' + val - ,'' - ,['f', 'o', 'o', 'b', 'a', 'r'] - ); - // => ['0-f,1-o,2-o,3-b,4-a,5-r'] -}; - -// always -() => { - let t = R.always('Tee'); - // $ExpectType string - t(); // => 'Tee' -}; - -// ap -() => { - // $ExpectType number[] - R.ap([R.multiply(2), R.add(3)], [1,2,3]); // => [2, 4, 6, 4, 5, 6] - // $ExpectType number[] - R.ap([R.multiply(2), R.add(3)])([1,2,3]); // => [2, 4, 6, 4, 5, 6] -}; - -// apply -() => { - let nums = [1, 2, 3, -99, 42, 6, 7]; - // $ExpectType number - R.apply(Math.max, nums); // => 42 - // $ExpectType number - R.apply(Math.max)(nums); // => 42 -}; - -// applySpec -() => { - type T = {sum: number, nested: {mul: number}}; - const getMetrics = R.applySpec({ - sum: R.add, nested: { mul: R.multiply } - }); - // $ExpectType T - getMetrics(2, 4); // => { sum: 6, nested: { mul: 8 } } -}; - -// binary -() => { - let takesThreeArgs = function(a: number, b: number, c: number) { - return [a, b, c]; - }; - // $ExpectType number - takesThreeArgs.length; // => 3 - // $ExpectType number[] - takesThreeArgs(1, 2, 3); // => [1, 2, 3] - - let takesTwoArgs = R.binary(takesThreeArgs); - // $ExpectType number - takesTwoArgs.length; // => 2 - // Only 2 arguments are passed to the wrapped function - // $ExpectError Supplied parameters do not match any signature of call target. - takesTwoArgs(1, 2, 3); // => [1, 2, undefined] -}; - -// pipe, inc, negate -() => { - const f = R.pipe(Math.pow, R.negate, R.inc); - // $ExpectType number - f(3, 4); // -(3^4) + 1 -}; - -// comparator -() => { - type T = {age: number}; - let cmp = R.comparator(function(a: T, b: T) { - return a.age < b.age; - }); - let people = [ - {name: 'Agy', age: 33}, {name: 'Bib', age: 15}, {name: 'Cari', age: 16} - ]; - // $ExpectType { age: number, name: string }[] - R.sort(cmp, people); -}; - -// converge -() => { - let add = function(a: number, b: number) { return a + b; }; - let multiply = function(a: number, b: number) { return a * b; }; - let subtract = function(a: number, b: number) { return a - b; }; - - // ≅ multiply( add(1, 2), subtract(1, 2) ); - // $ExpectType number - R.converge(multiply, [ add, subtract ])(1, 2); // => -3 - - let add3 = function(a: number, b: number, c: number) { return a + b + c; }; - // $ExpectType number - R.converge(add3, [ multiply, add, subtract ])(1, 2); // => 4 -}; - -// compose -() => { - const f0 = R.compose(Math.pow); - const f1 = R.compose(R.negate, Math.pow); - const f2 = R.compose(R.inc, R.negate, Math.pow); - const f3 = R.compose(R.inc, R.inc, R.negate, Math.pow); - const f4 = R.compose(R.inc, R.inc, R.inc, R.negate, Math.pow); - const f5 = R.compose(R.inc, R.inc, R.inc, R.inc, R.negate, Math.pow); - // $ExpectType number - f0(3, 4); // -(3^4) + 1 - // $ExpectType number - f1(3, 4); // -(3^4) + 1 - // $ExpectType number - f2(3, 4); // -(3^4) + 1 - // $ExpectType number - f3(3, 4); // -(3^4) + 1 - // $ExpectType number - f4(3, 4); // -(3^4) + 1 - // $ExpectType number - f5(3, 4); // -(3^4) + 1 - - // test for type degeneration if the first function has generics - // $ExpectType (x0: number) => number - R.compose(double, R.identity); -}; - -// compose -() => { - const fn = function(a: string, b: number, c: string) { - return [a,b,c]; - }; - const gn = R.compose(R.length, fn); - // $ExpectType number - gn('Hello', 4, 'world'); -}; - -// TODO: composeP - -// TODO: composeK - -// construct, constructN -(() => { - type circle = { r: number, colors: string[] }; - let Circle = function(r: number) { - this.r = r; - this.colors = Array.prototype.slice.call(arguments, 1); - }; - Circle.prototype.area = function() {return Math.PI * Math.pow(this.r, 2);}; - let circleN = R.constructN(2, Circle); - // $ExpectType circle - circleN(1, 'red'); - let circle = R.construct(Circle); - // $ExpectType circle - circle(1, 'red'); -})(); - -/***************************************************************** - * Relation category - */ - -// countBy -() => { - let numbers = [1.0, 1.1, 1.2, 2.0, 3.0, 2.2]; - let letters = R.split('', 'abcABCaaaBBc'); - // $ExpectType Dictionary - R.countBy(Math.floor)(numbers); // => {'1': 3, '2': 2, '3': 1} - // $ExpectType Dictionary - R.countBy(R.toLower)(letters); // => {'a': 5, 'b': 4, 'c': 3} -}; - -// difference -() => { - // $ExpectType number[] - R.difference([1,2,3,4], [7,6,5,4,3]); // => [1,2] - // $ExpectType number[] - R.difference([7,6,5,4,3], [1,2,3,4]); // => [7,6,5] -}; - -// differenceWith -() => { - function cmp(x: any, y: any) { return x.a === y.a; } - let l1 = [{a: 1}, {a: 2}, {a: 3}]; - let l2 = [{a: 3}, {a: 4}]; - // $ExpectType {a: number}[] - R.differenceWith(cmp, l1, l2); // => [{a: 1}, {a: 2}] - // $ExpectType {a: number}[] - R.differenceWith(cmp)(l1, l2); // => [{a: 1}, {a: 2}] - // $ExpectType {a: number}[] - R.differenceWith(cmp)(l1)(l2); // => [{a: 1}, {a: 2}] -}; - -// equals -() => { - // $ExpectType boolean - R.equals(1, 1); // => true - // $ExpectType boolean - R.equals('2', '1'); // => false - // $ExpectType boolean - R.equals([1, 2, 3], [1, 2, 3]); // => true - - let a: any = {}; a.v = a; - let b: any = {}; b.v = b; - // $ExpectType boolean - R.equals(a, b); // => true -}; - -// identity -() => { - const a1 = R.identity(1); // => 1 - let obj = {}; - // $ExpectType number[] - R.identity([1,2,3]); - // $ExpectType string[] - R.identity(['a','b','c']); - // $ExpectType boolean - R.identity(obj) === obj; // => true -}; - -// identical -() => { - let o = {}; - // $ExpectType boolean - R.identical(o, o); // => true - // $ExpectType boolean - R.identical(1, 1); // => true - // $ExpectType boolean - R.identical('2', '1'); // => false - // $ExpectType boolean - R.identical([], []); // => false - // $ExpectType boolean - R.identical(0, -0); // => false - // $ExpectType boolean - R.identical(NaN, NaN); // => true -}; - -// path -() => { - // $ExpectType number - R.path(['a', 'b'], {a: {b: 2}}); // => 2 - // $ExpectType number - R.path(['a', 'b'])({a: {b: 2}}); // => 2 -}; - -// sortBy -() => { - let sortByNameCaseInsensitive = R.sortBy(R.compose(R.toLower, R.prop('name'))); - let sortByAgeAscending = R.sortBy(R.prop('age')); - let alice = { - name: 'ALICE', - age: 101 - }; - let bob = { - name: 'Bob', - age: -10 - }; - let clara = { - name: 'clara', - age: 314.159 - }; - let people = [clara, bob, alice]; - // $ExpectType { name: string, age: number }[] - sortByNameCaseInsensitive(people); // => [alice, bob, clara] - sortByAgeAscending(people); // => [bob, alice, clara] -}; - -// sortWith -() => { - let alice = { - name: 'alice', - age: 40 - }; - let bob = { - name: 'bob', - age: 30 - }; - let clara = { - name: 'clara', - age: 40 - }; - let people = [clara, bob, alice]; - // $ExpectType typeof people - R.sortWith([ - R.descend(R.prop('age')), - R.ascend(R.prop('name')) - ], people); - let ageNameSort = R.sortWith([ - R.descend(R.prop('age')), - R.ascend(R.prop('name')) - ]); - // $ExpectType typeof people - ageNameSort(people); - // => [alice, clara, bob] -}; - -// splitAt -() => { - // $ExpectType number[][] - R.splitAt(1, [1, 2, 3]); // => [[1], [2, 3]] - // $ExpectType number[][] - R.splitAt(1)([1, 2, 3]); // => [[1], [2, 3]] - // $ExpectType string[] - R.splitAt(5, 'hello world'); // => ['hello', ' world'] - // $ExpectType string[] - R.splitAt(-1, 'foobar'); // => ['fooba', 'r'] -}; - -// splitWhen -() => { - // $ExpectType number[][] - R.splitWhen(R.equals(2), [1, 2, 3, 1, 2, 3]); // => [[1], [2, 3, 1, 2, 3]] - // $ExpectType number[][] - R.splitWhen(R.equals(2))([1, 2, 3, 1, 2, 3]); // => [[1], [2, 3, 1, 2, 3]] -}; - -// add -() => { - // $ExpectType number - R.add(2, 3); // => 5 - // $ExpectType number - R.add(7)(10); // => 17 -}; - -// dec -() => { - // $ExpectType number - R.dec(42); // => 41 -}; - -// divide -() => { - // $ExpectType number - R.divide(71, 100); // => 0.71 - - let half = R.flip(R.divide)(2); - // $ExpectType number - half(42); // => 21 - - let reciprocal = R.divide(1); - // $ExpectType number - reciprocal(4); // => 0.25 -}; - -// gt -() => { - // $ExpectType boolean - R.gt(2, 6); // => false - // $ExpectType boolean - R.gt(2, 0); // => true - // $ExpectType boolean - R.gt(2, 2); // => false - // $ExpectType boolean - R.flip(R.gt)(2)(10); // => true - // $ExpectType boolean - R.gt(2)(10); // => false -}; - -// gte -() => { - // $ExpectType boolean - R.gte(2, 6); // => false - // $ExpectType boolean - R.gte(2, 0); // => true - // $ExpectType boolean - R.gte(2, 2); // => false - // $ExpectType boolean - R.flip(R.gte)(2)(10); // => true - // $ExpectType boolean - R.gte(2)(10); // => false -}; - -// isNaN -() => { - // $ExpectType boolean - R.isNaN(NaN); // => true - // $ExpectType boolean - R.isNaN(undefined); // => false - // $ExpectType boolean - R.isNaN({}); // => false -}; - -// lt -() => { - // $ExpectType boolean - R.lt(2, 6); // => true - // $ExpectType boolean - R.lt(2, 0); // => false - // $ExpectType boolean - R.lt(2, 2); // => false - // $ExpectType boolean - R.lt(5)(10); // => true - // $ExpectType boolean - R.flip(R.lt)(5)(10); // => false // right-sectioned currying -}; - -// lte -() => { - // $ExpectType boolean - R.lte(2, 6); // => true - // $ExpectType boolean - R.lte(2, 0); // => false - // $ExpectType boolean - R.lte(2, 2); // => true - // $ExpectType boolean - R.flip(R.lte)(2)(1); // => true - // $ExpectType boolean - R.lte(2)(10); // => true -}; - -// mathMod -() => { - // $ExpectType number - R.mathMod(-17, 5); // => 3 - // $ExpectType number - R.mathMod(17, 5); // => 2 - // $ExpectType number - R.mathMod(17, -5); // => NaN - // $ExpectType number - R.mathMod(17, 0); // => NaN - // $ExpectType number - R.mathMod(17.2, 5); // => NaN - // $ExpectType number - R.mathMod(17, 5.3); // => NaN - - let clock = R.flip(R.mathMod)(12); - // $ExpectType number - clock(15); // => 3 - // $ExpectType number - clock(24); // => 0 - - let seventeenMod = R.mathMod(17); - // $ExpectType number - seventeenMod(3); // => 2 -}; - -// max -() => { - // $ExpectType number - R.max(7, 3); // => 7 - // $ExpectType string - R.max('a', 'z'); // => 'z' -}; - -// maxBy -() => { - function cmp(obj: { x: number }) { return obj.x; } - let a = {x: 1}; - let b = {x: 2}; - let c = {x: 3}; - let d = {x: 'a'}; - let e = {x: 'z'}; - // $ExpectType { x: number; } - R.maxBy(cmp, a, c); // => {x: 3} - // $ExpectType { x: number; } - R.maxBy(cmp)(a, c); // => {x: 3} - // $ExpectType { x: number; } - R.maxBy(cmp)(a)(b); - // $ExpectError Argument of type '{ x: string; }' is not assignable to parameter of type '{ x: number; }' - R.maxBy(cmp)(d)(e); -}; - -// mean -() => { - // $ExpectType number - R.mean([2, 7, 9]); // => 6 - // $ExpectType number - R.mean([]); // => NaN -}; - -// median -() => { - // $ExpectType number - R.median([7, 2, 10, 9]); // => 8 - // $ExpectType number - R.median([]); // => NaN -}; - -// min -() => { - // $ExpectType number - R.min(9, 3); // => 3 - // $ExpectType string - R.min('a', 'z'); // => 'a' -}; - -// minBy -() => { - function cmp(obj: { x: number }) { return obj.x; } - let a = {x: 1}; - let b = {x: 2}; - let c = {x: 3}; - let d = {x: 'a'}; - let e = {x: 'z'}; - // $ExpectType { x: number } - R.minBy(cmp, a, b); // => {x: 1} - // $ExpectType { x: number } - R.minBy(cmp)(a, b); // => {x: 1} - // $ExpectType { x: number } - R.minBy(cmp)(a)(c); - // $ExpectError Argument of type '{ x: string; }' is not assignable to parameter of type '{ x: number; }' - R.minBy(cmp, d, e); -}; - -// modulo -() => { - // $ExpectType number - R.modulo(17, 3); // => 2 - // JS behavior: - // $ExpectType number - R.modulo(-17, 3); // => -2 - // $ExpectType number - R.modulo(17, -3); // => 2 - - let isOdd = R.flip(R.modulo)(2); - // $ExpectType number - isOdd(42); // => 0 - // $ExpectType number - isOdd(21); // => 1 -}; - -// multiply -() => { - let double = R.multiply(2); - let triple = R.multiply(3); - // $ExpectType number - double(3); // => 6 - // $ExpectType number - triple(4); // => 12 - // $ExpectType number - R.multiply(2, 5); // => 10 -}; - -// negate -() => { - // $ExpectType number - R.negate(42); // => -42 -}; - -// product -() => { - // $ExpectType number - R.product([2,4,6,8,100,1]); // => 38400 -}; - -// subtract -() => { - // $ExpectType number - R.subtract(10, 8); // => 2 - - let minus5 = R.flip(R.subtract)(5); - // $ExpectType number - minus5(17); // => 12 - - let complementaryAngle = R.subtract(90); - // $ExpectType number - complementaryAngle(30); // => 60 - // $ExpectType number - complementaryAngle(72); // => 18 -}; - -// sum -() => { - // $ExpectType number - R.sum([2,4,6,8,100,1]); // => 121 -}; - -// symmetricDifference -() => { - // $ExpectType number[] - R.symmetricDifference([1,2,3,4], [7,6,5,4,3]); // => [1,2,7,6,5] - // $ExpectType number[] - R.symmetricDifference([7,6,5,4,3])([1,2,3,4]); // => [7,6,5,1,2] -}; - -// symmetricDifferenceWith -() => { - const eqA = R.eqBy(R.prop('a')); - const l1 = [{a: 1}, {a: 2}, {a: 3}, {a: 4}]; - const l2 = [{a: 3}, {a: 4}, {a: 5}, {a: 6}]; - // $ExpectType { a: number }[] - R.symmetricDifferenceWith(eqA, l1, l2); // => [{a: 1}, {a: 2}, {a: 5}, {a: 6}] - // $ExpectType { a: number }[] - R.symmetricDifferenceWith(eqA)(l1, l2); // => [{a: 1}, {a: 2}, {a: 5}, {a: 6}] - // $ExpectType (a: any[]) => any[] - R.symmetricDifferenceWith(eqA)(l1); // => [{a: 1}, {a: 2}, {a: 5}, {a: 6}] -}; - -/***************************************************************** - * String category - */ - -// replace -() => { - // $ExpectType string - R.replace('foo', 'bar', 'foo foo foo'); // => 'bar foo foo' - // $ExpectType string - R.replace('foo', 'bar')('foo foo foo'); // => 'bar foo foo' - // $ExpectType string - R.replace('foo')('bar')('foo foo foo'); // => 'bar foo foo' - // $ExpectType string - R.replace(/foo/, 'bar', 'foo foo foo'); // => 'bar foo foo' - - // Use the 'g' (global) flag to replace all occurrences: - // $ExpectType string - R.replace(/foo/g, 'bar', 'foo foo foo'); // => 'bar bar bar' - // $ExpectType string - R.replace(/foo/g, 'bar')('foo foo foo'); // => 'bar bar bar' - // $ExpectType string - R.replace(/foo/g)('bar')('foo foo foo'); // => 'bar bar bar' -}; - -/***************************************************************** - * Is category - */ - -() => { - // $ExpectType boolean - R.is(Object, {}); // => true - // $ExpectType boolean - R.is(Object)({}); // => true - // $ExpectType boolean - R.is(Number, 1); // => true - // $ExpectType boolean - R.is(Number)(1); // => true - // $ExpectType boolean - R.is(Object, 1); // => false - // $ExpectType boolean - R.is(Object)(1); // => false - // $ExpectType boolean - R.is(String, 's'); // => true - // $ExpectType boolean - R.is(String)('s'); // => true - // $ExpectType boolean - R.is(String, ''); // => true - // $ExpectType boolean - R.is(String)(''); // => true - // $ExpectType boolean - R.is(Object, new Object()); // => true - // $ExpectType boolean - R.is(Object)(new Object()); // => true - // $ExpectType boolean - R.is(Object, 's'); // => false - // $ExpectType boolean - R.is(Object)('s'); // => false - // $ExpectType boolean - R.is(Number, {}); // => false - // $ExpectType boolean - R.is(Number)({}); // => false -}; - -/***************************************************************** - * Logic category - */ - -// allPass -() => { - let gt10 = function(x: number) { return x > 10; }; - let even = function(x: number) { return x % 2 === 0;}; - let f = R.allPass([gt10, even]); - // $ExpectType boolean - f(11); // => false - // $ExpectType boolean - f(12); // => true -}; - -// and -() => { - // $ExpectType boolean - R.and(false, true); // => false - // $ExpectType number - R.and(0, []); // => 0 - // $ExpectType number - R.and(0)([]); // => 0 - // $ExpectType null - R.and(null, ''); // => null - let Why: any = (function(val: boolean) { - let why: any; - why.val = val; - why.and = function(x: boolean) { - return this.val && x; - }; - return Why; - })(true); - let why = new Why(true); - // $ExpectType boolean - R.and(why, false); // false -}; - -// anyPass -() => { - let gt10 = function(x: number) { return x > 10; }; - let even = function(x: number) { return x % 2 === 0;}; - let f = R.anyPass([gt10, even]); - // $ExpectType boolean - f(11); // => true - // $ExpectType boolean - f(8); // => true - // $ExpectType boolean - f(9); // => false -}; - -// both -() => { - let gt10 = function(x: number) { return x > 10; }; - let even = function(x: number) { return x % 2 === 0; }; - let f = R.both(gt10, even); - let g = R.both(gt10)(even); - // $ExpectType boolean - f(100); // => true - // $ExpectType boolean - f(101); // => false -}; - -// complement -() => { - let isEven = function(n: number) { return n % 2 === 0; }; - let isOdd = R.complement(isEven); - // $ExpectType boolean - isOdd(21); // => true - // $ExpectType boolean - isOdd(42); // => false -}; - -// eqBy -(() => { - // $ExpectType boolean - R.eqBy(Math.abs, 5, -5); // => true - // $ExpectType boolean - R.eqBy(Math.abs)(5, -5); // => true - // $ExpectType boolean - R.eqBy(Math.abs, 5)(-5); // => true -}); - -// defaultTo -() => { - let defaultTo42 = R.defaultTo(42); - // $ExpectType number - defaultTo42(null); // => 42 - // $ExpectType number - defaultTo42(undefined); // => 42 - // $ExpectType string - defaultTo42('Ramda'); // => 'Ramda' -}; - -// either -() => { - let gt10 = function(x: number) { return x > 10; }; - let even = function(x: number) { return x % 2 === 0; }; - let f = R.either(gt10, even); - let g = R.either(gt10)(even); - // $ExpectType boolean - f(101); // => true - // $ExpectType boolean - f(8); // => true -}; - -// ifElse -() => { - // Flatten all arrays in the list but leave other values alone. - let flattenArrays = R.map(R.ifElse(Array.isArray, R.flatten, R.identity)); - - // $ExpectType any[] - flattenArrays([[0], [[10], [8]], 1234, {}]); // => [[0], [10, 8], 1234, {}] - // $ExpectType any[] - flattenArrays([[[10], 123], [8, [10]], 'hello']); // => [[10, 123], [8, 10], 'hello'] -}; - -// isEmpty -() => { - // $ExpectType boolean - R.isEmpty([1, 2, 3]); // => false - // $ExpectType boolean - R.isEmpty([]); // => true - // $ExpectType boolean - R.isEmpty(''); // => true - // $ExpectType boolean - R.isEmpty(null); // => false - // $ExpectType boolean - R.isEmpty({}); // =>true - // $ExpectType boolean - R.isEmpty({a: 1}); // => false -}; - -// not -() => { - // $ExpectType boolean - R.not(true); // => false - // $ExpectType boolean - R.not(false); // => true - // $ExpectType boolean - R.not(0); // => true - // $ExpectType boolean - R.not(1); // => false -}; - -class Why { - val: boolean; - constructor(val: boolean) { - this.val = val; - } - or(x: boolean) { - return this.val && x; - } -} - -// or -() => { - // $ExpectType boolean - R.or(false, true); // => false - // $ExpectType number|any[] - R.or(0, []); // => [] - // $ExpectType number|any[] - R.or(0)([]); // => [] - // $ExpectType string - R.or(null, ''); // => '' - - let why = new Why(true); - why.or(true); - // $ExpectType Why|boolean - R.or(why, false); // false -}; - -// intersperse -() => { - // $ExpectType string[] - R.intersperse(',', ['foo', 'bar']); // => ['foo', ',', 'bar'] - // $ExpectType number[] - R.intersperse(0, [1, 2]); // => [1, 0, 2] - // $ExpectType number[] - R.intersperse(0, [1]); // => [1] -}; - -// ISSUES: - -// RESOLVED ISSUES: - -() => { - // #65, evolve issue - const a1 = R.evolve({ elapsed: R.add(1), remaining: R.add(-1) }, { name: 'Tomato', elapsed: 100, remaining: 1400 }); - const a2 = R.evolve({ elapsed: R.add(1), remaining: R.add(-1) })({ name: 'Tomato', elapsed: 100, remaining: 1400 }); - let test = { a: 1, b: 2}; - // $ExpectType { a: number, b: number } - R.evolve({ a: R.add(1)}, test ); -}; - -() => { - // #73 - let filterMatrix = function (v: number, m: Array>): Array { - return R.chain(R.filter((c: number) => c === v), m); - // return R.chain(R.filter(R.equals(v)), m) - }; - let b = [ - [0, 1], - [1, 0] - ]; - // $ExpectType number[] - filterMatrix(1, b); // --> [1, 1] - - // compiles - let filterMatrix2 = function (v: number, m: Array>): Array { - return R.chain((r: number[]) => R.filter((c: number) => c === v, r), m); - }; - - // also compiles - let mapMatrix3 = function(fn: (v: number) => number, m: Array>): Array { - return R.chain(R.map((c: number) => fn(c)), m); - }; -}; - -() => { - // #109 - function grepSomethingRecursively(grepPatterns: string | string[]) { - if (R.is(Array, grepPatterns)) { - R.forEach(() => {}, grepPatterns); - } - } -}; - -// UNRESOLVED ISSUES: - -// /* - -() => { - // #29 - // $ExpectType string[] - R.pipe(R.append('a'), R.uniq)(['a', 'b', 'c']); - // $ExpectType string[][] - R.pipe( - R.split(''), - R.map((letter: string) => ([ letter ])) - )('dave'); - - // $ExpectType number - R.pipe( - R.prop('name'), - R.length - )({ name: 'dave' }); - - let build: string; - let mapPackages = R.partial(R.map, [(test: any) => test.package]); - let filterBuild = R.partial(R.filter, [(test: any) => test.build === build]); - let getPackages = R.compose(R.uniq, mapPackages, filterBuild); - this.packages = getPackages(this._tests); - // ^ expected: ?? - - interface Foo { - build: string; - package: string; - } - const build2 = 'dev'; - let mapPackages2 = R.map((test: Foo) => test.package); - let filterBuild2 = R.filter((test: Foo) => test.build === build2); - let getPackages2 = R.compose(R.uniq, mapPackages2, filterBuild2); - let foos = [{ - build: 'dev', - package: 'devPackage' - }, { - build: 'prod', - package: 'prodPackage' - }, { - build: 'dev', - package: 'devPackage' - }]; - let foosFiltered = getPackages2(foos); - // ^ expected: ?? -}; - -() => { - // #69: lens composition - const sectioneditems = { sections: [ - {items: []}, - {items: []} - ]}; - const elem = 'Hello'; - R.over(R.compose(R.lensProp('sections'), R.lensIndex(sectioneditems.sections.length - 1), R.lensProp('items')), R.append(elem), sectioneditems); -}; - -() => { - // #78: curry loses generics - // : R.CurriedFunction3, T, T[], T[]> - // : R.CurriedFunction3, any, any[], any[]> - let updateBy = R.curry((pred: (v: T) => boolean, val: T, array: T[]): T[] => { - let i = R.findIndex(pred, array); - if (i >= 0) { - return R.update(i, val, array); - } else { - return array; - } - }); - // $ExpectType number[] - updateBy((n: number) => n > 1, 0, [1,2,3]); -}; - -() => { - // #86: lose generics in compose - let pairs = [['1','A'], ['2','B'], ['3','C']]; - // $ExpectType { [index: string]: string } - R.fromPairs ([['1','A'], ['2','B'], ['3','C']]); - // $ExpectType { [index: string]: string } - R.fromPairs (pairs); // fails -- variable reduced to string[][], killing tuples - // $ExpectType { [index: string]: string } - R.pipe (R.fromPairs)([['1','A'], ['2','B'], ['3','C']]); - // $ExpectType { [index: string]: string } - R.compose(R.fromPairs)([['1','A'], ['2','B'], ['3','C']]); - - // generics in pipe loses generics - R.pipe(R.identity); -}; - -() => { - // #90: curried function loses generics - const map = (func: (some: string) => (x: number) => 1) => { - return func('xx')(1); - }; - const map2 = (func: (some: string, other: string) => '1') => { - return func('xx', 'x'); - }; - // will work only with proposed changes - map(R.assoc('xxx')); - map2(R.assoc('xxx')); -}; - -() => { - // #92: lose generics in compose - - // can't infer cond paths, must annotate: - // $ExpectType (v: T) => T - const x = R.cond([ - [R.F, R.F], - [R.T, R.identity] - ]); - // argument order matters for some reason... - // $ExpectType (v: number) => number - R.pipe (R.inc, x); // ok - // $ExpectType (v: number) => number - R.compose(x, R.inc); // boom - - // don't use generics in pipe/compose/curry if it can't resolve them right away: - let pipeF0 = R.pipe (R.identity); // : (v: {}) => {} - let compF0 = R.compose(R.identity); // : (v: {}) => {} - - // argument order matters too: - let pipeF1 = R.pipe (R.inc, R.identity); // : (v: number) => number - let compF1 = R.compose(R.identity, R.inc); // : (v: number) => {} - // $ExpectType number - compF1(1); // uh-oh, fails - - // also can't reason backward: - let compF2 = R.compose(R.inc, R.identity); // : (v: {}) => number - // $ExpectType number - compF2('foo'); // uh-oh, passes - let pipeF2 = R.pipe (R.identity, R.inc); // : (v: {}) => number - // $ExpectType number - pipeF2('foo'); // uh-oh, passes -}; - -() => { - // #101: compose can't guess types for generic functions - interface SomeStruct { - a: number[]; - b: string[]; - c: { [index: string]: string }; - } - const x: SomeStruct = { - 'a': [], - 'b': [], - 'c': {} - }; - // const fun = <(y: SomeStruct) => SomeStruct>R.compose( // annotated: works - const fun = R.compose( - R.assoc('a', [1, 2, 3]), - R.assoc('b', ['a', 'b', 'c']), - R.assoc('c', { 'k': 'v'}) - ); - let struct: SomeStruct = fun(x); - - let a = R.assoc('a', 2, {z:3}); - let b = R.assoc('b', 2); -}; - -() => { - // #118: flatten - // $ExpectType number[] - R.flatten([1, 2, [3, 4], 5, [6, [7, 8, [9, [10, 11], 12]]]]); - // => [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12] -}; - -() => { - // #119: path - // $ExpectType number - R.path(['a', 'b', 'c'], {a: {b: {c: 2}}}); - // $ExpectType null - R.path(['a', 'b', 'c'], {a: {b: 2}}); // still fails - // let n = R.path(['a', '0', 'c'], {a: [{c: 2}] }) - // $ExpectType number - R.path(['a', 0, 'c'], {a: [{c: 2}] }); -}; - -() => { - // #129: nested evolve - type FormState = { index: number }; - function ramdaIssue(state: FormState): FormState { - return R.evolve({ - index: R.inc - }, state); - } -}; - -// */ diff --git a/tests/test.ts.out b/tests/test.ts.out deleted file mode 100644 index f8b1e20..0000000 --- a/tests/test.ts.out +++ /dev/null @@ -1,1916 +0,0 @@ -tests/test.ts:R.propIs(Number, 'x', {}); - -Expected error Argument of type 'x' is not assignable to parameter of type 'never'.`, because 'x' is not in `{}`. - -tests/test.ts:xy(3); - -Expected type - (v2: Y) => { x: number; y: Y; } -but got: - (v2: {}) => { x: {}; y: {}; } - -tests/test.ts:xy(3)(1); - -Expected type - { x: number; y: number; } -but got: - { x: {}; y: {}; } - -tests/test.ts:xyz(3, 2, 1); - -Expected type - { x: number; y: number; z: number; } -but got: - { x: {}; y: {}; z: {}; } - -tests/test.ts:xyz(3)(2)(1); - -Expected type - { x: number; y: number; z: number; } -but got: - { x: {}; y: {}; z: {}; } - -tests/test.ts:xyz(3, 2); - -Expected type - (v3: Z) => ({ x: number; y: number; z: Z; }) -but got: - (v3: {}) => { x: {}; y: {}; z: {}; } - -tests/test.ts:xyz(3)(2); - -Expected type - (v3: Z) => ({ x: number; y: number; z: Z; }) -but got: - (v2: {}) => { x: {}; y: {}; z: {}; } - -tests/test.ts:xyz(3); - -Expected type - (v2: Y, v3: Z) => ({ x: number; y: Y; z: Z; }) -but got: - CurriedFunction2<{}, {}, { x: {}; y: {}; z: {}; }> - -tests/test.ts:curriedFourNumbers(1)(2)(3); - -Expected type - (v1: T1) => R -but got: - (v2: number) => number - -tests/test.ts:curriedFourNumbers(1,2,4); - -Expected type - (v1: T1) => R -but got: - (v4: number) => number - -tests/test.ts:R.nAry(0, takesNoArg); - -Expected type - () => boolean -but got: - Variadic - -tests/test.ts:R.nAry(0, takesOneArg); - -Expected type - () => number[] -but got: - Variadic - -tests/test.ts:R.nAry(1, takesTwoArgs); - -Expected type - (a: number) => number[] -but got: - Variadic - -tests/test.ts:R.nAry(1, takesThreeArgs); - -Expected type - (a: number) => number[] -but got: - Variadic - -tests/test.ts:R.binary(takesTwoArgs); - -Expected type - (a: number, b: number) => number[] -but got: - (a: any, b: any) => number[] - -tests/test.ts:R.binary(takesThreeArgs); - -Expected type - (a: number, b: number) => number[] -but got: - (a: any, b: any) => number[] - -tests/test.ts:let addTwoNumbersCurried = R.curry(addTwoNumbers); - -Expected type - CurriedFunction2 -but got: - any - -tests/test.ts:const coerceArray = R.unless(R.isArrayLike, R.of); - -Expected type - (v: a|[a]) => [a] -but got: - any - -tests/test.ts:coerceArray([1, 2, 3]); - -Expected type - number[] -but got: - any[] - -tests/test.ts:coerceArray(1); - -Expected type - number[] -but got: - any[] - -tests/test.ts:R.nthArg(1)('a', 'b', 'c'); - -Expected type - string -but got: - "a" | "b" | "c" - -tests/test.ts:R.nthArg(-1)('a', 'b', 'c'); - -Expected type - string -but got: - "a" | "b" | "c" - -tests/test.ts:R.unapply(JSON.stringify); - -Expected type - (...args: string[])=>string -but got: - Variadic - -tests/test.ts:const g = R.compose(g3, g2, g1, g0); - -Expected type - (list: number[]) => boolean -but got: - any - -tests/test.ts:const capitalize = (str: string) => R.pipe( - R.split(''), - R.adjust(R.toUpper, 0), - R.join('') - )(str); - -Expected type - string -but got: - any - -tests/test.ts:R.pipe(R.identity, double); - -Expected type - (x0: number) => number -but got: - (x0: {}) => number - -tests/test.ts: Unexpected error - 'Promise' only refers to a type, but is being used as a value here. - -tests/test.ts: Unexpected error - 'Promise' only refers to a type, but is being used as a value here. - -tests/test.ts:R.invoker(0, 'toUpperCase', 'foo'); - -Expected type - string -but got: - any - -tests/test.ts:R.invoker(1, 'charAt', 'foo', 1); - -Expected type - string -but got: - any - -tests/test.ts:chopped('longstring'); - -Expected type - string[] -but got: - any[] - -tests/test.ts:R.clone([{},{},{}]); - -Expected type - Object[] -but got: - {}[] - -tests/test.ts:R.reduceRight(flattenPairs, [], pairs); - -Expected type - Array -but got: - [string, number] - -tests/test.ts:R.mapObjIndexed(prependKeyAndDouble, values); - -Expected type - Dictionary -but got: - { x: string; y: string; z: string; } - -tests/test.ts:R.empty('unicorns'); - -Expected type - string -but got: - "unicorns" - -tests/test.ts:R.empty({x: 1, y: 2}); - -Expected type - {} -but got: - { x: number; y: number; } - -tests/test.ts:filterIndexed(lastTwo, [8, 6, 7, 5, 3, 0, 9]); - -Expected type - number[] -but got: - any[] - -tests/test.ts:R.unfold(f, 10); - -Expected type - number[] -but got: - TResult[] - -tests/test.ts: Unexpected error - Argument of type '(n: number) => false | number[]' is not assignable to parameter of type '(seed: number) => false | [{}, number]'. - Type 'false | number[]' is not assignable to type 'false | [{}, number]'. - Type 'number[]' is not assignable to type 'false | [{}, number]'. - Type 'number[]' is not assignable to type '[{}, number]'. - -tests/test.ts:b(10); - -Expected type - number[] -but got: - TResult[] - -tests/test.ts:let peopleByYoungestFirst = R.sort(byAge, people); - -Expected type - typeof people -but got: - any - -tests/test.ts:R.append(['tests'], ['write', 'more']); - -Expected type - Array -but got: - (string & string[])[] - -tests/test.ts:R.append(['tests'], ['write', 'more']); - -Expected type - Array -but got: - (string & string[])[] - -tests/test.ts:R.append(['tests'])(['write', 'more']); - -Expected type - Array -but got: - (string & string[])[] - -tests/test.ts:R.append(['tests'])(['write', 'more']); - -Expected type - Array -but got: - (string & string[])[] - -tests/test.ts:R.chain(R.append, R.head)([1, 2, 3]); - -Expected type - number[] -but got: - any - -tests/test.ts:R.chain(R.append)(R.head)([1, 2, 3]); - -Expected type - number[] -but got: - any - -tests/test.ts:R.clamp(1, 10, -1); - -Expected type - number -but got: - 1 | -1 | 10 - -tests/test.ts:R.clamp('a', 'd', 'e'); - -Expected type - string -but got: - "a" | "d" | "e" - -tests/test.ts:let peopleByOldestFirst = R.sort(byAge, people); - -Expected type - typeof people -but got: - any - -tests/test.ts:R.drop(3)([1,2,3,4,5,6,7]); - -Expected type - number[] -but got: - ArrayLike - -tests/test.ts:R.drop(3, 'ramda'); - -Expected type - string -but got: - "ramda" - -tests/test.ts:R.drop(3)('ramda'); - -Expected type - string -but got: - ArrayLike - -tests/test.ts:R.dropLast(2)(['foo', 'bar', 'baz']); - -Expected type - string[] -but got: - ArrayLike - -tests/test.ts:R.dropLast(3, 'ramda'); - -Expected type - string -but got: - "ramda" - -tests/test.ts:R.dropLast(3)('ramda'); - -Expected type - string -but got: - ArrayLike - -tests/test.ts:R.filter(isEven, {a: 1, b: 2, c: 3, d: 4}); - -Expected type - Dictionary -but got: - Partial<{ a: number; b: number; c: number; d: number; }> - -tests/test.ts:onlyNumberObj(R.filter(isEven, {a: 1, b: 2, c: 3, d: 4})); - -Expected type - Dictionary -but got: - { [key: string]: number; } - -tests/test.ts:filterIndexed(lastTwo, [8, 6, 7, 5, 3, 0, 9]); - -Expected type - number[] -but got: - any[] - -tests/test.ts:lastTwoFn([8, 6, 7, 5, 3, 0, 9]); - -Expected type - number[] -but got: - any[] - -tests/test.ts:R.find(R.propEq('a', 2))(xs); - -Expected type - Dictionary -but got: - {} - -tests/test.ts:R.find(R.propEq('a', 4))(xs); - -Expected type - undefined -but got: - {} - -tests/test.ts:R.findLast(R.propEq('a', 1))(xs); - -Expected type - Dictionary -but got: - {} - -tests/test.ts:R.findLast(R.propEq('a', 4))(xs); - -Expected type - undefined -but got: - {} - -tests/test.ts:R.findLastIndex((x: number) => x === 1, [1, 2, 3]); - -Expected type - number[] -but got: - number - -tests/test.ts:R.filter(isFamous, users); - -Expected type - Object[] -but got: - any[] - -tests/test.ts:R.forEachObjIndexed(printKeyConcatValue, {x: 1, y: 2}); - -Expected type - {x: 1, y: 2} -but got: - { x: number; y: number; } - -tests/test.ts:R.forEachObjIndexed(printKeyConcatValue)({x: 1, y: 2}); - -Expected type - {x: 1, y: 2} -but got: - any - -tests/test.ts:R.forEachObjIndexed(printKeyConcatValue, [1, 2]); - -Expected type - [1, 2] -but got: - number[] - -tests/test.ts:R.forEachObjIndexed(printKeyConcatValue)([1, 2]); - -Expected type - [1, 2] -but got: - any - -tests/test.ts:R.addIndex(R.forEach)(plusFive)([1, 2, 3]); - -Expected type - number[] -but got: - any[] - -tests/test.ts:byGrade(students); - -Expected type - Dictionary -but got: - Dictionary<{ score: number; name: string; }[]> - -tests/test.ts:R.head([10, 'ten']); - -Expected type - number -but got: - Index - -tests/test.ts:R.head(['10', 10]); - -Expected type - string -but got: - Index - -tests/test.ts:R.indexBy(R.prop('id'), list); - -Expected type - Dictionary -but got: - Dictionary<{}> - -tests/test.ts:R.indexBy(R.prop('id'))(list); - -Expected type - Dictionary -but got: - Dictionary<{}> - -tests/test.ts:R.indexBy<{id: string}>(R.prop('id'))(list); - -Expected type - Dictionary -but got: - Dictionary<{ id: string; }> - -tests/test.ts:R.intersectionWith(R.eqBy(R.prop('id')), buffaloSpringfield, csny); - -Expected type - { id: number, name: string }[] -but got: - {}[] - -tests/test.ts:R.intersectionWith(R.eqBy(R.prop('id')), buffaloSpringfield, csny); - -Expected type - { id: number, name: string }[] -but got: - {}[] - -tests/test.ts:R.intersectionWith(R.eqBy(R.prop('id')))(buffaloSpringfield, csny); - -Expected type - { id: number, name: string }[] -but got: - {}[] - -tests/test.ts:R.intersectionWith(R.eqBy(R.prop('id')))(buffaloSpringfield)(csny); - -Expected type - { id: number, name: string }[] -but got: - {}[] - -tests/test.ts: Unexpected error - Supplied parameters do not match any signature of call target. - -tests/test.ts: Unexpected error - Supplied parameters do not match any signature of call target. - -tests/test.ts:R.last(['fi', 'fo', 'fum']); - -Expected type - string -but got: - {} - -tests/test.ts:headLens([10, 20, 30, 40]); - -Expected type - number -but got: - {} - -tests/test.ts:headLens.set('mu', [10, 20, 30, 40]); - -Expected type - Array -but got: - number[] - -tests/test.ts:R.view(headLens, ['a', 'b', 'c']); - -Expected type - string -but got: - {} - -tests/test.ts:R.set(headLens, 'x', ['a', 'b', 'c']); - -Expected type - string[] -but got: - any - -tests/test.ts:R.over(headLens, R.toUpper, ['a', 'b', 'c']); - -Expected type - string[] -but got: - any - -tests/test.ts:R.map(double)([1, 2, 3]); - -Expected type - number[] -but got: - Functor - -tests/test.ts:R.map(double, { a: 1, b: 2, c: 3 }); - -Expected type - Dictionary -but got: - { a: number; b: number; c: number; } - -tests/test.ts:R.map(double)({ a: 1, b: 2, c: 3 }); - -Expected type - Dictionary -but got: - { a: number; b: number; c: number; } - -tests/test.ts:R.map(arrayify, [1, 'a']); - -Expected type - [number[], string[]] -but got: - {}[][] - -tests/test.ts:R.map(arrayify)([1, 'a']); - -Expected type - [number[], string[]] -but got: - Record<"length" | "toString" | "toLocaleString" | "push" | "pop" | "concat" | "join" | "reverse" ... - -tests/test.ts:R.map(arrayify, { a: 1, b: 'c' }); - -Expected type - { a: number[], b: string[] } -but got: - { a: {}[]; b: {}[]; } - -tests/test.ts:R.map(arrayify)({ a: 1, b: 'c' }); - -Expected type - { a: number[], b: string[] } -but got: - { a: {}[]; b: {}[]; } - -tests/test.ts:R.mapAccum(append, '0', digits); - -Expected type - Array -but got: - [string, string[]] - -tests/test.ts:R.mapAccum(append)('0', digits); - -Expected type - Array -but got: - [string, string[]] - -tests/test.ts:R.mapAccum(append, '0')(digits); - -Expected type - Array -but got: - [string, string[]] - -tests/test.ts:R.mapAccum(append)('0')(digits); - -Expected type - Array -but got: - [string, string[]] - -tests/test.ts:R.mapAccumRight(append, '0', digits); - -Expected type - Array -but got: - [string[], string] - -tests/test.ts:R.mapAccumRight(append)('0', digits); - -Expected type - Array -but got: - [string[], string] - -tests/test.ts:R.mapAccumRight(append, '0')(digits); - -Expected type - Array -but got: - [string[], string] - -tests/test.ts:R.mapAccumRight(append)('0')(digits); - -Expected type - Array -but got: - [string[], string] - -tests/test.ts:R.addIndex(R.map)(squareEnds, [8, 5, 3, 0, 9]); - -Expected type - number[] -but got: - any[] - -tests/test.ts:R.addIndex(R.map)(squareEnds)([8, 5, 3, 0, 9]); - -Expected type - number[] -but got: - any[] - -tests/test.ts:R.nth(-99, list); - -Expected type - undefined -but got: - string - -tests/test.ts:R.nth(-99)(list); - -Expected type - undefined -but got: - string - -tests/test.ts:R.partition(R.contains('s'),{ a: 'sss', b: 'ttt', foo: 'bars' }); - -Expected type - Object[] -but got: - [Dictionary, Dictionary] - -tests/test.ts:R.pluck(0, [[1, 2], [3, 4]]); - -Expected type - number[] -but got: - {}[] - -tests/test.ts:R.pluck('a')([{a: 1}, {a: 2}]); - -Expected type - number[] -but got: - {}[] - -tests/test.ts:R.pluck(0)([[1, 2], [3, 4]]); - -Expected type - number[] -but got: - {}[] - -tests/test.ts:namesByGrade(students); - -Expected type - Dictionary -but got: - string[] - -tests/test.ts:reduceIndexed(objectify, {}, letters); - -Expected type - Dictionary -but got: - any - -tests/test.ts:reduceIndexed(objectify)({}, letters); - -Expected type - Dictionary -but got: - any - -tests/test.ts:reduceIndexed(objectify, {})(letters); - -Expected type - Dictionary -but got: - any - -tests/test.ts:R.reduceRight(flattenPairs, [], pairs); - -Expected type - Array -but got: - KeyValuePair[] - -tests/test.ts:R.reduceRight(flattenPairs, [])(pairs); - -Expected type - Array -but got: - KeyValuePair[] - -tests/test.ts:R.reduceRight(flattenPairs)([], pairs); - -Expected type - Array -but got: - KeyValuePair[] - -tests/test.ts:rejectIndexed(lastTwo, [8, 6, 7, 5, 3, 0, 9]); - -Expected type - number[] -but got: - any[] - -tests/test.ts:rejectIndexed(lastTwo)([8, 6, 7, 5, 3, 0, 9]); - -Expected type - number[] -but got: - any[] - -tests/test.ts:R.reverse([]); - -Expected type - number[] -but got: - never[] - -tests/test.ts:R.take(3,'Example'); - -Expected type - string -but got: - "Example" - -tests/test.ts:takeThree('Example'); - -Expected type - string -but got: - "Example" - -tests/test.ts:R.takeLast(3, 'ramda'); - -Expected type - string -but got: - "ramda" - -tests/test.ts:R.takeLast(3)('ramda'); - -Expected type - string -but got: - "ramda" - -tests/test.ts:R.transduce(transducer, fn, [] as number[], numbers); - -Expected type - number[] -but got: - number | undefined - -tests/test.ts:R.transduce(transducer, fn, [] as number[])(numbers); - -Expected type - number[] -but got: - number | undefined - -tests/test.ts:R.transduce(transducer, fn)([] as number[], numbers); - -Expected type - number[] -but got: - number | undefined - -tests/test.ts:R.transduce(transducer)(fn, [] as number[], numbers); - -Expected type - number[] -but got: - number | undefined - -tests/test.ts:R.transpose([[1, 'a'], [2, 'b'], [3, 'c']]); - -Expected type - any[][] -but got: - Index[][] - -tests/test.ts:R.uniq([{}, {}]); - -Expected type - Object[] -but got: - {}[] - -tests/test.ts:R.uniq([1, '1']); - -Expected type - any[] -but got: - Index[] - -tests/test.ts:R.uniqWith(strEq, [1, '1', 2, 1]); - -Expected type - number[] -but got: - any[] - -tests/test.ts:R.uniqWith(strEq)([1, '1', 2, 1]); - -Expected type - number[] -but got: - any[] - -tests/test.ts:R.uniqWith(strEq)([{}, {}]); - -Expected type - Object[] -but got: - any[] - -tests/test.ts:R.uniqWith(strEq)([1, '1', 1]); - -Expected type - number[] -but got: - any[] - -tests/test.ts:R.uniqWith(strEq)(['1', 1, 1]); - -Expected type - string[] -but got: - any[] - -tests/test.ts:R.xprod([1, 2], ['a', 'b']); - -Expected type - [number, string][] -but got: - KeyValuePair[] - -tests/test.ts:R.xprod([1, 2])(['a', 'b']); - -Expected type - [number, string][] -but got: - KeyValuePair[] - -tests/test.ts:R.zip([1, 2, 3], ['a', 'b', 'c']); - -Expected type - [number, string][] -but got: - KeyValuePair[] - -tests/test.ts:R.zip([1, 2, 3])(['a', 'b', 'c']); - -Expected type - [number, string][] -but got: - KeyValuePair[] - -tests/test.ts:R.zipWith(f, [1, 2, 3], ['a', 'b', 'c']); - -Expected type - any[] -but got: - void[] - -tests/test.ts:R.zipWith(f)([1, 2, 3], ['a', 'b', 'c']); - -Expected type - any[] -but got: - void[] - -tests/test.ts:R.zipWith(f, [1, 2, 3])(['a', 'b', 'c']); - -Expected type - any[] -but got: - void[] - -tests/test.ts:R.assoc('c', 3, {a: 1, b: 2}); - -Expected type - Dictionary -but got: - { c: number; } & { a: number; b: number; } - -tests/test.ts:R.assoc('c')(3, {a: 1, b: 2}); - -Expected type - Dictionary -but got: - { c: number; } & { a: number; b: number; } - -tests/test.ts:R.assoc('c', 3)({a: 1, b: 2}); - -Expected type - Dictionary -but got: - { c: number; } & { a: number; b: number; } - -tests/test.ts:R.dissoc<{a: number, c: number}>('b', {a: 1, b: 2, c: 3}); - -Expected type - Dictionary -but got: - { a: number; c: number; } - -tests/test.ts:R.dissoc('b', {a: 1, b: 2, c: 3}); - -Expected type - Dictionary -but got: - { a: number; b: number; c: number; } - -tests/test.ts:R.dissoc('b')<{a: number, c: number}>({a: 1, b: 2, c: 3}); - -Expected type - Dictionary -but got: - { a: number; c: number; } - -tests/test.ts:R.assocPath(['a', 'b', 'c'], 42, {a: {b: {c: 0}}}); - -Expected type - {a: {b: {c: number}}} -but got: - { a: { b: { c: number; }; }; } - -tests/test.ts:R.assocPath(['a', 'b', 'c'])(42, {a: {b: {c: 0}}}); - -Expected type - {a: {b: {c: number}}} -but got: - { a: { b: { c: number; }; }; } - -tests/test.ts:R.assocPath(['a', 'b', 'c'], 42)({a: {b: {c: 0}}}); - -Expected type - {a: {b: {c: number}}} -but got: - { a: { b: { c: number; }; }; } - -tests/test.ts:R.dissocPath(['a', 'b', 'c'], {a: {b: {c: 42}}}); - -Expected type - {a: {b: {}}} -but got: - {} - -tests/test.ts:R.dissocPath<{a : { b: number}}>(['a', 'b', 'c'], {a: {b: {c: 42}}}); - -Expected type - {a: {b: {}}} -but got: - { a: { b: number; }; } - -tests/test.ts:R.dissocPath(['a', 'b', 'c'])({a: {b: {c: 42}}}); - -Expected type - {a: {b: {}}} -but got: - {} - -tests/test.ts:R.clone(obj1); - -Expected type - any[] -but got: - {}[] - -tests/test.ts:R.clone(obj2); - -Expected type - {a: number}[] -but got: - { a: number; }[] - -tests/test.ts:R.clone({}); - -Expected type - Object -but got: - {} - -tests/test.ts:R.eqProps('c'); - -Expected type - {(obj1: T, obj2: U): boolean} -but got: - { (obj1: T, obj2: U): boolean; (obj1: T): (obj2: U) => boolean; } - -tests/test.ts:R.eqProps('c', o1); - -Expected type - {(obj2: U): boolean} -but got: - (obj2: U) => boolean - -tests/test.ts:const a: typeof tomato = R.evolve(transformations, tomato); - -Expected type - typeof tomato -but got: - any - -tests/test.ts:const b: typeof tomato = R.evolve(transformations)(tomato); - -Expected type - typeof tomato -but got: - any - -tests/test.ts:R.invert(raceResultsByFirstName); - -Expected type - Dictionary -but got: - Dictionary> - -tests/test.ts:R.set(xLens, 4, {x: 1, y: 2}); - -Expected type - { x: number, y: number } -but got: - any - -tests/test.ts:R.set(xLens)(4, {x: 1, y: 2}); - -Expected type - { x: number, y: number } -but got: - any - -tests/test.ts:R.set(xLens, 4)({x: 1, y: 2}); - -Expected type - { x: number, y: number } -but got: - any - -tests/test.ts:R.over(xLens, R.negate, {x: 1, y: 2}); - -Expected type - { x: number, y: number } -but got: - any - -tests/test.ts:R.over(xLens, R.negate)({x: 1, y: 2}); - -Expected type - { x: number, y: number } -but got: - any - -tests/test.ts:R.over(xLens)(R.negate, {x: 1, y: 2}); - -Expected type - { x: number, y: number } -but got: - any - -tests/test.ts:R.view(headLens, ['a', 'b', 'c']); - -Expected type - string -but got: - {} - -tests/test.ts:R.set(headLens, 'x', ['a', 'b', 'c']); - -Expected type - string[] -but got: - any - -tests/test.ts:R.over(headLens, R.toUpper, ['a', 'b', 'c']); - -Expected type - string[] -but got: - any - -tests/test.ts:R.view(xLens, {x: 1, y: 2}); - -Expected type - number -but got: - {} - -tests/test.ts:R.set(xLens, 4, {x: 1, y: 2}); - -Expected type - Dictionary -but got: - any - -tests/test.ts:R.over(xLens, R.negate, {x: 1, y: 2}); - -Expected type - Dictionary -but got: - any - -tests/test.ts:R.view(xyLens, {x: {y: 2, z: 3}}); - -Expected type - number -but got: - {} - -tests/test.ts:R.set(xyLens, 4, {x: {y: 2, z: 3}}); - -Expected type - { [s: string]: { [s: string]: number } } -but got: - any - -tests/test.ts:R.over(xyLens, R.negate, {x: {y: 2, z: 3}}); - -Expected type - { [s: string]: { [s: string]: number } } -but got: - any - -tests/test.ts:phraseLens(obj1); - -Expected type - string -but got: - any - -tests/test.ts:phraseLens(obj2); - -Expected type - string -but got: - any - -tests/test.ts:phraseLens.set('Ooh Betty', obj1); - -Expected type - Dictionary -but got: - { phrase: string; } - -tests/test.ts:phraseLens(obj1); - -Expected type - string -but got: - {} - -tests/test.ts:phraseLens(obj2); - -Expected type - string -but got: - {} - -tests/test.ts:phraseLens.set('Ooh Betty', obj1); - -Expected type - Dictionary -but got: - { phrase: string; } - -tests/test.ts:R.merge({ 'name': 'fred', 'age': 10 }, { 'age': 40 }); - -Expected type - Dictionary -but got: - { 'name': string; 'age': number; } & { 'age': number; } - -tests/test.ts:resetToDefault({x: 5, y: 2}); - -Expected type - Dictionary -but got: - any - -tests/test.ts:R.mergeAll([{foo: 1},{bar: 2},{baz: 3}]); - -Expected type - Dictionary -but got: - {} - -tests/test.ts:R.mergeAll([{foo: 1},{foo: 2},{bar: 2}]); - -Expected type - Dictionary -but got: - {} - -tests/test.ts:R.mergeWith(R.concat, - { a: true, values: [10, 20] }, - { b: true, values: [15, 35] }); - -Expected type - { a: boolean, b: boolean, values: number[] } -but got: - { a: boolean; values: number[]; } & { b: boolean; values: number[]; } - -tests/test.ts:merge({ a: true, thing: 'foo', values: [10, 20] }, { b: true, thing: 'bar', values: [15, 35] }); - -Expected type - { a: boolean, b: boolean, values: number[], thing: string } -but got: - { a: boolean; thing: string; values: number[]; } & { b: boolean; thing: string; values: number[]; } - -tests/test.ts:R.pathOr('N/A', ['a', 'b'], {a: {b: 2}}); - -Expected type - number -but got: - any - -tests/test.ts:R.pathOr('N/A', ['a', 'b'])({a: {b: 2}}); - -Expected type - number -but got: - any - -tests/test.ts:R.pathOr('N/A', ['a', 'b'], {c: {b: 2}}); - -Expected type - number -but got: - any - -tests/test.ts:R.pathOr({c: 2})(['a', 'b'], {c: {b: 2}}); - -Expected type - number -but got: - any - -tests/test.ts:R.pickBy(isPositive, {a: 1, b: 2, c: -1, d: 0, e: 5}); - -Expected type - Dictionary -but got: - Partial<{ a: number; b: number; c: number; d: number; e: number; }> - -tests/test.ts:R.pickBy(containsBackground, colors); - -Expected type - { 2: R.Dictionary } -but got: - Partial<{ 1: { color: string; }; 2: { color: string; bgcolor: string; }; }> - -tests/test.ts:R.pickBy(isUpperCase, {a: 1, b: 2, A: 3, B: 4}); - -Expected type - Dictionary -but got: - Partial<{ a: number; b: number; A: number; B: number; }> - -tests/test.ts:R.pick(['a', 'd'], {a: 1, b: 2, c: 3, d: 4}); - -Expected type - Dictionary -but got: - Pick<{ a: number; b: number; c: number; d: number; }, "a" | "d"> - -tests/test.ts:let no1 = R.pick(['a', 'e', 'f'], {a: 1, b: 2, c: 3, d: 4}); - -Expected error not keys - -tests/test.ts:let no2 = R.pick(['a', 'e', 'f'])({a: 1, b: 2, c: 3, d: 4}); - -Expected error not keys - -tests/test.ts:let no3 = R.pick(['a', 'e', 'f'], [1, 2, 3, 4]); - -Expected error not keys - -tests/test.ts:matchPhrases(['foo', 'bar', 'baz']); - -Expected type - { must: { match_phrase: string }[] } -but got: - Record<"must", {}> - -tests/test.ts:R.omit(['a', 'd'], {a: 1, b: 2, c: 3, d: 4}); - -Expected type - Dictionary -but got: - { a: number; b: number; c: number; d: number; } - -tests/test.ts:R.omit(['a', 'd'])({a: 1, b: 2, c: 3, d: 4}); - -Expected type - Dictionary -but got: - { a: number; b: number; c: number; d: number; } - -tests/test.ts:R.over(headLens, R.toUpper, ['foo', 'bar', 'baz']); - -Expected type - string[] -but got: - any - -tests/test.ts:R.pickAll(['a', 'd'], {a: 1, b: 2, c: 3, d: 4}); - -Expected type - Dictionary -but got: - Partial<{ a: number; b: number; c: number; d: number; }> - -tests/test.ts:R.pickAll(['a', 'd'])({a: 1, b: 2, c: 3, d: 4}); - -Expected type - Dictionary -but got: - Partial<{}> - -tests/test.ts:R.pickAll(['a', 'e', 'f'], {a: 1, b: 2, c: 3, d: 4}); - -Expected type - Dictionary -but got: - Partial<{ a: number; b: number; c: number; d: number; }> - -tests/test.ts:R.pickAll(['a', 'e', 'f'])({a: 1, b: 2, c: 3, d: 4}); - -Expected type - Dictionary -but got: - Partial<{}> - -tests/test.ts:R.pickBy(isUpperCase, {a: 1, b: 2, A: 3, B: 4}); - -Expected type - Dictionary -but got: - Partial<{ a: number; b: number; A: number; B: number; }> - -tests/test.ts:R.project(['name', 'grade'], kids); - -Expected type - { name: string, grade: number }[] -but got: - Pick<{ name: string; age: number; hair: string; grade: number; }, "name" | "grade">[] - -tests/test.ts:R.prop('x', {}); - -Expected error - Argument of type 'x' is not assignable to parameter of type 'never'. -but got: - Argument of type '{}' is not assignable to parameter of type 'Record<"x", {}>'. - Property 'x' is missing in type '{}'. - -tests/test.ts:favorite(alice); - -Expected type - undefined -but got: - V - -tests/test.ts:favoriteWithDefault(alice); - -Expected type - string -but got: - any - -tests/test.ts:R.props(['c', 'a', 'b'], {b: 2, a: 1}); - -Expected type - Array -but got: - number[] - -tests/test.ts:R.toPairsIn(f); - -Expected type - [string, string][] -but got: - [string, any][] - -tests/test.ts:R.toPairsIn(f); - -Expected type - [string, string][] -but got: - [string, any][] - -tests/test.ts:R.valuesIn(f); - -Expected type - string[] -but got: - any[] - -tests/test.ts:R.filter(R.where({x: 10}), xs); - -Expected type - { x: number, y: number }[] -but got: - {}[] - -tests/test.ts:R.filter(R.where({x: 10}))(xs); - -Expected type - { x: number, y: number }[] -but got: - {}[] - -tests/test.ts:let pred = R.whereEq({a: 1, b: 2}); - -Expected type - (v: Object) => Boolean -but got: - any - -tests/test.ts:reduceIndexed( - (acc: string, val: string, idx: number) => acc + ',' + idx + '-' + val - ,'' - ,['f', 'o', 'o', 'b', 'a', 'r'] - ); - -Expected type - string[] -but got: - any - -tests/test.ts:R.sort(cmp, people); - -Expected type - { age: number, name: string }[] -but got: - T[] - -tests/test.ts:R.compose(double, R.identity); - -Expected type - (x0: number) => number -but got: - (x0: {}) => number - -tests/test.ts:circleN(1, 'red'); - -Expected type - circle -but got: - any - -tests/test.ts:circle(1, 'red'); - -Expected type - circle -but got: - any - -tests/test.ts:R.differenceWith(cmp, l1, l2); - -Expected type - {a: number}[] -but got: - any[] - -tests/test.ts:R.differenceWith(cmp)(l1, l2); - -Expected type - {a: number}[] -but got: - any[] - -tests/test.ts:R.differenceWith(cmp)(l1)(l2); - -Expected type - {a: number}[] -but got: - any[] - -tests/test.ts:R.path(['a', 'b'])({a: {b: 2}}); - -Expected type - number -but got: - {} - -tests/test.ts:sortByNameCaseInsensitive(people); - -Expected type - { name: string, age: number }[] -but got: - {}[] - -tests/test.ts:R.sortWith([ - R.descend(R.prop('age')), - R.ascend(R.prop('name')) - ], people); - -Expected type - typeof people -but got: - {}[] - -tests/test.ts:ageNameSort(people); - -Expected type - typeof people -but got: - {}[] - -tests/test.ts:R.splitAt(5, 'hello world'); - -Expected type - string[] -but got: - [string, string] - -tests/test.ts:R.splitAt(-1, 'foobar'); - -Expected type - string[] -but got: - [string, string] - -tests/test.ts:R.max(7, 3); - -Expected type - number -but got: - 3 | 7 - -tests/test.ts:R.max('a', 'z'); - -Expected type - string -but got: - "a" | "z" - -tests/test.ts:R.min(9, 3); - -Expected type - number -but got: - 3 | 9 - -tests/test.ts:R.min('a', 'z'); - -Expected type - string -but got: - "a" | "z" - -tests/test.ts:R.minBy(cmp, a, b); - -Expected type - { x: number } -but got: - { x: number; } - -tests/test.ts:R.minBy(cmp)(a, b); - -Expected type - { x: number } -but got: - { x: number; } - -tests/test.ts:R.minBy(cmp)(a)(c); - -Expected type - { x: number } -but got: - { x: number; } - -tests/test.ts:R.minBy(cmp, d, e); - -Expected error - Argument of type '{ x: string; }' is not assignable to parameter of type '{ x: number; }' -but got: - The type argument for type parameter 'T' cannot be inferred from the usage. Consider specifying the type arguments explicitly. - Type argument candidate '{ x: string; }' is not a valid type argument because it is not a supertype of candidate '{ x: number; }'. - Types of property 'x' are incompatible. - Type 'number' is not assignable to type 'string'. - -tests/test.ts:R.symmetricDifferenceWith(eqA, l1, l2); - -Expected type - { a: number }[] -but got: - {}[] - -tests/test.ts:R.symmetricDifferenceWith(eqA)(l1, l2); - -Expected type - { a: number }[] -but got: - {}[] - -tests/test.ts:R.symmetricDifferenceWith(eqA)(l1); - -Expected type - (a: any[]) => any[] -but got: - (list2: ArrayLike<{}>) => {}[] - -tests/test.ts:R.and(0, []); - -Expected type - number -but got: - boolean - -tests/test.ts:R.and(0)([]); - -Expected type - number -but got: - boolean - -tests/test.ts:R.and(null, ''); - -Expected type - null -but got: - boolean - -tests/test.ts:defaultTo42(null); - -Expected type - number -but got: - number | null - -tests/test.ts:defaultTo42(undefined); - -Expected type - number -but got: - number | undefined - -tests/test.ts:defaultTo42('Ramda'); - -Expected type - string -but got: - number | "Ramda" - -tests/test.ts:flattenArrays([[0], [[10], [8]], 1234, {}]); - -Expected type - any[] -but got: - { length: any; toString: any; toLocaleString: any; push: any; pop: any; concat: any; join: any; r... - -tests/test.ts:flattenArrays([[[10], 123], [8, [10]], 'hello']); - -Expected type - any[] -but got: - { length: any; toString: any; toLocaleString: any; push: any; pop: any; concat: any; join: any; r... - -tests/test.ts:R.or(0, []); - -Expected type - number|any[] -but got: - 0 | never[] - -tests/test.ts:R.or(0)([]); - -Expected type - number|any[] -but got: - number | never[] - -tests/test.ts:R.or(null, ''); - -Expected type - string -but got: - "" | null - -tests/test.ts:R.or(why, false); - -Expected type - Why|boolean -but got: - false | Why - -tests/test.ts:R.evolve({ a: R.add(1)}, test ); - -Expected type - { a: number, b: number } -but got: - { a: number; b: number; } - -tests/test.ts: Unexpected error - Type '{}[]' is not assignable to type 'number[]'. - Type '{}' is not assignable to type 'number'. - -tests/test.ts:R.pipe(R.append('a'), R.uniq)(['a', 'b', 'c']); - -Expected type - string[] -but got: - ({} & string)[] - -tests/test.ts: Unexpected error - Argument of type '(x0: any) => {}' is not assignable to parameter of type 'UnknownLens | ManualLens<{}> | Lens'. - Type '(x0: any) => {}' is not assignable to type 'Lens'. - Property 'set' is missing in type '(x0: any) => {}'. - -tests/test.ts:updateBy((n: number) => n > 1, 0, [1,2,3]); - -Expected type - number[] -but got: - {}[] - -tests/test.ts:R.fromPairs ([['1','A'], ['2','B'], ['3','C']]); - -Expected type - { [index: string]: string } -but got: - Dictionary - -tests/test.ts:R.fromPairs (pairs); - -Expected type - { [index: string]: string } -but got: - Dictionary - -tests/test.ts:R.pipe (R.fromPairs)([['1','A'], ['2','B'], ['3','C']]); - -Expected type - { [index: string]: string } -but got: - Dictionary<{}> - -tests/test.ts:R.compose(R.fromPairs)([['1','A'], ['2','B'], ['3','C']]); - -Expected type - { [index: string]: string } -but got: - Dictionary<{}> - -tests/test.ts:const x = R.cond([ - [R.F, R.F], - [R.T, R.identity] - ]); - -Expected type - (v: T) => T -but got: - any - -tests/test.ts:R.pipe (R.inc, x); - -Expected type - (v: number) => number -but got: - (x0: number) => {} - -tests/test.ts:R.compose(x, R.inc); - -Expected type - (v: number) => number -but got: - (x0: number) => {} - -tests/test.ts:compF1(1); - -Expected type - number -but got: - {} - -tests/test.ts: Unexpected error - Type '{ a: number[]; } & {}' is not assignable to type 'SomeStruct'. - Property 'b' is missing in type '{ a: number[]; } & {}'. - -tests/test.ts:R.flatten([1, 2, [3, 4], 5, [6, [7, 8, [9, [10, 11], 12]]]]); - -Expected type - number[] -but got: - (number | (number | (number | (number | number[])[])[])[])[] - -tests/test.ts:R.path(['a', 'b', 'c'], {a: {b: 2}}); - -Expected type - null -but got: - { b: number; } - -tests/test.ts: 448 / 724 checks passed. diff --git a/tpl/assocPath.ts b/tpl/assocPath.ts index 1786a68..7c7cff2 100644 --- a/tpl/assocPath.ts +++ b/tpl/assocPath.ts @@ -5,14 +5,12 @@ import { makeParamStringNumberCombinations, makeParamStringNumbers, makeNestedObjPath, + methodSignature, makeTuple, Template, docs } from '../gen'; -// const propsParams = getParamsNums(8).reverse() -// .map(nums => nums.map(n => 'P' + n)); - const maxPathDepth = 5; const desc = ` @@ -23,10 +21,7 @@ Note: Tuples are not supported by typings. Max path depth typed is ${maxPathDepth}. `; -// const propsParams = -// makeParamStringNumberCombinations(maxPathDepth); - -const propsParams = +const propsLists = makeParamStringNumbers(maxPathDepth); const orBrackets = (...items: string[]) => @@ -34,192 +29,83 @@ const orBrackets = (...items: string[]) => const generic = [ - { - d: desc, - t: ['T', 'O'], - p: [{ path: 'Path' }, { val: 'T' }, { obj: 'O' }], - r: 'O' - }, - { - d: desc, - t: ['T'], - p: [{ path: 'Path' }, { val: 'T' }], - r: [ - { - t: ['O'], - p: [{ obj: 'O' }], - r: 'O' - } - ] - }, - { - p: [{ path: 'Path' }], r: [ - { - d: desc, - t: ['T', 'O'], - p: [{ val: 'T' }, { obj: 'O' }], - r: 'O' - }, - { - t: ['T'], p: [{ val: 'T' }], r: [ - { t: ['O'], p: [{ obj: 'O' }], r: 'O' } - ] - } + methodSignature(desc, + ['T', 'O'], + [{ path: 'Path' }, { val: 'T' }, { obj: 'O' }], + 'O' + ), + methodSignature(desc, ['T'], + [{ path: 'Path' }, { val: 'T' }], + methodSignature('', ['O'], [{ obj: 'O' }], 'O') + ), + methodSignature('', [], + [{ path: 'Path' }], [ + methodSignature('', + ['T', 'O'], + [{ val: 'T' }, { obj: 'O' }], + 'O' + ), + methodSignature('', + ['T'], [{ val: 'T' }], + methodSignature('', ['O'], [{ obj: 'O' }], 'O') + ) ] - } -] - + ) +]; const template: Template = { imports: ['Path'], signatures: [ - ...propsParams.map(props => [ - { - d: desc, - t: props.map(n => `P${n} extends ${typeof n} | number`) - .concat([ - `T`, - 'O extends ' + makeNestedObjPath(props, 'T') - ]), - p: [ - { path: makeTuple(props, props.length) }, - { value: 'T' }, - { - obj: 'O' - } - ], - r: 'O' - } - ]), - // curry 2-1 - ...propsParams.map(props => [ - { - // d: desc, - t: props.map(n => `P${n} extends ${typeof n} | number`) - .concat([ - `T` - ]), - p: [ - { path: makeTuple(props, props.length) }, - { value: 'T' } - ], - r: [{ - t: ['O extends ' + makeNestedObjPath(props, 'T')], - p: [{ obj: 'O' }], - r: `O` - }] - } - ]), - // curry 1-(1,2) - ...propsParams.map(props => [ - { - //d: desc, - t: props.map(n => `P${n} extends ${typeof n} | number`) - .concat([ - `T` - ]), - p: [ - { path: makeTuple(props, props.length) } - ], - r: [{ - t: ['T'], - p: [{ value: 'T' }], - r: [{ - t: ['O extends ' + makeNestedObjPath(props, 'T')], - p: [{ obj: 'O' }], - r: `O` - }] - }, { - t: [`T`, 'O extends ' + makeNestedObjPath(props, 'T')], - p: [{ value: 'T' }, { obj: 'O' }], - r: `O` - }] - } - ]), + ...generic + // ...propsLists.map(props => [ + // methodSignature(desc, + // props.map(n => `P${n} extends ${typeof n}`) + // .concat([ + // `T`, 'O extends ' + makeNestedObjPath(props, 'T') + // ]), [ + // { path: makeTuple(props, props.length) }, + // { value: 'T' }, + // { obj: 'O' } + // ], 'O' + // ) + // ]), + // // curry 2-1 + // ...propsLists.map(props => [ + // methodSignature(desc, + // props.map(n => `P${n} extends ${typeof n}`).concat(`T`), [ + // { path: makeTuple(props, props.length) }, + // { value: 'T' } + // ], [ + // methodSignature('', + // ['O extends ' + makeNestedObjPath(props, 'T')], + // [{ obj: 'O' }], + // `O` + // )] + // ) + // ]), + // // curry 1-(1,2) + // ...propsLists.map(props => [ + // methodSignature(desc, + // props.map(n => `P${n} extends ${typeof n}`) + // .concat(`T`), [ + // { path: makeTuple(props, props.length) } + // ], [ + // methodSignature('', ['T'], + // [{ value: 'T' }], [ + // methodSignature('', + // ['O extends ' + makeNestedObjPath(props, 'T')], + // [{ obj: 'O' }], + // `O` + // )] + // ), methodSignature('', + // [`T`, 'O extends ' + makeNestedObjPath(props, 'T')], + // [{ value: 'T' }, { obj: 'O' }], + // `O` + // )] + // ) + // ]), //generic ] }; module.exports = template; - -// const fun = [ -// // importInterfaces(['Path', 'List', 'Prop']), -// ...propsParams.map((props) => -// docs(desc) + -// declareFunction('assocPath', -// props.map(n => `P${n} extends ${typeof n}`) -// .concat([ -// `T`, -// 'O extends ' + makeNestedObjPath(props, 'T') -// ]), -// [ -// { path: makeTuple(props, props.length) }, -// { value: 'T' }, -// { -// obj: 'O' -// } -// ], -// `O` -// )), -// `// curried 1-1-1`, -// ...propsParams.map((props) => -// docs(desc) + -// declareFunction('assocPath', -// props.map(n => `P${n} extends ${typeof n}`) -// .concat(`T`), -// [ -// { paths: makeTuple(props, props.length) }, -// { value: 'T' } -// ], -// arrowFunction( -// ['T'], -// [{ value: 'T' }], -// arrowFunction( -// [ -// 'O extends ' + makeNestedObjPath(props, 'T') -// ], -// [{ obj: 'O' }], -// `O` -// ) -// ) -// )), -// `// curried 2-1`, -// ...propsParams.map((props) => -// docs(desc) + -// declareFunction('assocPath', -// props.map(n => `P${n} extends ${typeof n}`) -// .concat(`T`), -// [ -// { paths: makeTuple(props, props.length) }, -// { value: 'T' } -// ], -// arrowFunction( -// ['O extends ' + makeNestedObjPath(props, 'T')], -// [{ obj: 'O' }], -// `O` -// ) -// )), -// `// curried 1-2`, -// ...propsParams.map((props) => -// docs(desc) + -// declareFunction('assocPath', -// props.map(n => `P${n} extends ${typeof n}`), -// [ -// { paths: makeTuple(props, props.length) } -// ], -// arrowFunction( -// ['T', -// 'O extends ' + makeNestedObjPath(props, 'T') -// ], -// [{ value: 'T' }, { obj: 'O' }], -// `O` -// ), -// )), -// // docs + -// // declareFunction('props', ['T'], [{ ps: 'List' }, { obj: 'List' }], 'T[]'), -// // `// curried`, -// // docs + -// // declareFunction('props', ['T'], [{ ps: 'List' }], -// // arrowFunction(['T'], [{ obj: 'List' }], 'T[]') -// // ) -// ]; diff --git a/tpl/path.ts b/tpl/path.ts index 9835b85..db5b388 100644 --- a/tpl/path.ts +++ b/tpl/path.ts @@ -1,7 +1,9 @@ import { - importInterfaces, - declareFunction, - arrowFunction, + //importInterfaces, + //declareFunction, + //arrowFunction, + makeParamStringNumbers, + methodSignature, makeParamStringNumberCombinations, makeNestedObjPath, makeTuple, docs @@ -11,39 +13,74 @@ const maxPathDepth = 5; const propsParams = makeParamStringNumberCombinations(maxPathDepth); +//const propsParams = makeParamStringNumbers(maxPathDepth) const desc = `Retrieve the value at a given path. Note: Tuples are not supported by typings. Max path depth typed is ${maxPathDepth}.`; -module.exports = [ - ...propsParams.map((props) => - docs(desc) + - declareFunction('path', - props.map(n => `P${n} extends ${typeof n}`) - .concat(`T`), - [ - { path: makeTuple(props, props.length) }, - { - obj: makeNestedObjPath(props, 'T') - } - ], - `T` - )), - `// curried`, - ...propsParams.map((props) => - docs(desc) + - declareFunction('path', - props.map(n => `P${n} extends ${typeof n}`) - .concat(`T`), - [ - { path: makeTuple(props, props.length) } - ], - arrowFunction([`T`], [ - { - obj: makeNestedObjPath(props, 'T') - } - ], 'T' - ) - )) -]; +module.exports = { + signatures: [ + methodSignature(desc + '\nFallback signature.', + ['T'], [{ path: '(string | number)[]' }, { obj: 'any' }], + 'T'), + methodSignature(desc + '\nFallback signature.', + ['T'], [{ path: '(string | number)[]' }], + methodSignature('', [], [{ obj: 'any' }], + 'T') + ), + ...propsParams.map((props) => + methodSignature(desc, + props.map(n => `P${n} extends ${typeof n}`) + .concat(`T`), [ + { path: makeTuple(props) }, + { obj: makeNestedObjPath(props, 'T') } + ], + `T` + )), + ...propsParams.map((props) => + methodSignature(desc, + props.map(n => `P${n} extends ${typeof n}`) + .concat(`T`), [ + { path: makeTuple(props) } + ], + [methodSignature('', [`T`], [ + { obj: makeNestedObjPath(props, 'T') } + ], 'T')] + )), + + + ].reverse() +} + +// module.exports = [ +// ...propsParams.map((props) => +// docs(desc) + +// declareFunction('path', +// props.map(n => `P${n} extends ${typeof n}`) +// .concat(`T`), +// [ +// { path: makeTuple(props, props.length) }, +// { +// obj: makeNestedObjPath(props, 'T') +// } +// ], +// `T` +// )), +// `// curried`, +// ...propsParams.map((props) => +// docs(desc) + +// declareFunction('path', +// props.map(n => `P${n} extends ${typeof n}`) +// .concat(`T`), +// [ +// { path: makeTuple(props, props.length) } +// ], +// arrowFunction([`T`], [ +// { +// obj: makeNestedObjPath(props, 'T') +// } +// ], 'T' +// ) +// )) +// ]; diff --git a/tsconfig.json b/tsconfig.json index ba045d2..ce79588 100644 --- a/tsconfig.json +++ b/tsconfig.json @@ -2,13 +2,23 @@ "compilerOptions": { "target": "es6", "module": "commonjs", - "noEmit": true, - "noImplicitAny": true, "strictNullChecks": true, + "noImplicitAny": true, + "noEmit": true, + "noImplicitThis": true, + "noImplicitReturns": true, + "noFallthroughCasesInSwitch": true, + "experimentalDecorators": true, + "emitDecoratorMetadata": true, "baseUrl": ".", "paths": { "ramda": ["."], "ramda/src/*": ["./src/*"] } - } + }, + "formatCodeOptions": { + "indentSize": 2, + "tabSize": 2 + }, + "exclude": ["**/node_modules/*"] } diff --git a/typings.json b/typings.json deleted file mode 100644 index 9865df7..0000000 --- a/typings.json +++ /dev/null @@ -1,8 +0,0 @@ -{ - "name": "ramda", - "main": "index.d.ts", - "version": "0.22.1", - "homepage": "https://github.com/types/npm-ramda", - "author": "Erwin Poeze ", - "description": "Type definitions for Ramda" -} diff --git a/yarn.lock b/yarn.lock new file mode 100644 index 0000000..4c1be22 --- /dev/null +++ b/yarn.lock @@ -0,0 +1,1241 @@ +# THIS IS AN AUTOGENERATED FILE. DO NOT EDIT THIS FILE DIRECTLY. +# yarn lockfile v1 + + +"@types/mocha@^2.2.40": + version "2.2.41" + resolved "https://registry.yarnpkg.com/@types/mocha/-/mocha-2.2.41.tgz#e27cf0817153eb9f2713b2d3f6c68f1e1c3ca608" + +"@types/node@^7.0.13": + version "7.0.13" + resolved "https://registry.yarnpkg.com/@types/node/-/node-7.0.13.tgz#1b0a53fe9ef9c3a5d061b126cc9b915bca43a3f5" + +ansi-align@^1.1.0: + version "1.1.0" + resolved "https://registry.yarnpkg.com/ansi-align/-/ansi-align-1.1.0.tgz#2f0c1658829739add5ebb15e6b0c6e3423f016ba" + dependencies: + string-width "^1.0.1" + +ansi-regex@^2.0.0: + version "2.1.1" + resolved "https://registry.yarnpkg.com/ansi-regex/-/ansi-regex-2.1.1.tgz#c3b33ab5ee360d86e0e628f0468ae7ef27d654df" + +ansi-styles@^2.2.1: + version "2.2.1" + resolved "https://registry.yarnpkg.com/ansi-styles/-/ansi-styles-2.2.1.tgz#b432dd3358b634cf75e1e4664368240533c1ddbe" + +array-find-index@^1.0.1: + version "1.0.2" + resolved "https://registry.yarnpkg.com/array-find-index/-/array-find-index-1.0.2.tgz#df010aa1287e164bbda6f9723b0a96a1ec4187a1" + +array-union@^1.0.1: + version "1.0.2" + resolved "https://registry.yarnpkg.com/array-union/-/array-union-1.0.2.tgz#9a34410e4f4e3da23dea375be5be70f24778ec39" + dependencies: + array-uniq "^1.0.1" + +array-uniq@^1.0.1: + version "1.0.3" + resolved "https://registry.yarnpkg.com/array-uniq/-/array-uniq-1.0.3.tgz#af6ac877a25cc7f74e058894753858dfdb24fdb6" + +arrify@^1.0.0: + version "1.0.1" + resolved "https://registry.yarnpkg.com/arrify/-/arrify-1.0.1.tgz#898508da2226f380df904728456849c1501a4b0d" + +babel-code-frame@^6.20.0, babel-code-frame@^6.22.0: + version "6.22.0" + resolved "https://registry.yarnpkg.com/babel-code-frame/-/babel-code-frame-6.22.0.tgz#027620bee567a88c32561574e7fd0801d33118e4" + dependencies: + chalk "^1.1.0" + esutils "^2.0.2" + js-tokens "^3.0.0" + +balanced-match@^0.4.1: + version "0.4.2" + resolved "https://registry.yarnpkg.com/balanced-match/-/balanced-match-0.4.2.tgz#cb3f3e3c732dc0f01ee70b403f302e61d7709838" + +boxen@^0.6.0: + version "0.6.0" + resolved "https://registry.yarnpkg.com/boxen/-/boxen-0.6.0.tgz#8364d4248ac34ff0ef1b2f2bf49a6c60ce0d81b6" + dependencies: + ansi-align "^1.1.0" + camelcase "^2.1.0" + chalk "^1.1.1" + cli-boxes "^1.0.0" + filled-array "^1.0.0" + object-assign "^4.0.1" + repeating "^2.0.0" + string-width "^1.0.1" + widest-line "^1.0.0" + +boxen@^1.0.0: + version "1.0.0" + resolved "https://registry.yarnpkg.com/boxen/-/boxen-1.0.0.tgz#b2694baf1f605f708ff0177c12193b22f29aaaab" + dependencies: + ansi-align "^1.1.0" + camelcase "^4.0.0" + chalk "^1.1.1" + cli-boxes "^1.0.0" + string-width "^2.0.0" + term-size "^0.1.0" + widest-line "^1.0.0" + +brace-expansion@^1.0.0: + version "1.1.7" + resolved "https://registry.yarnpkg.com/brace-expansion/-/brace-expansion-1.1.7.tgz#3effc3c50e000531fb720eaff80f0ae8ef23cf59" + dependencies: + balanced-match "^0.4.1" + concat-map "0.0.1" + +browser-stdout@1.3.0: + version "1.3.0" + resolved "https://registry.yarnpkg.com/browser-stdout/-/browser-stdout-1.3.0.tgz#f351d32969d32fa5d7a5567154263d928ae3bd1f" + +buffer-shims@~1.0.0: + version "1.0.0" + resolved "https://registry.yarnpkg.com/buffer-shims/-/buffer-shims-1.0.0.tgz#9978ce317388c649ad8793028c3477ef044a8b51" + +builtin-modules@^1.0.0: + version "1.1.1" + resolved "https://registry.yarnpkg.com/builtin-modules/-/builtin-modules-1.1.1.tgz#270f076c5a72c02f5b65a47df94c5fe3a278892f" + +camelcase-keys@^2.0.0: + version "2.1.0" + resolved "https://registry.yarnpkg.com/camelcase-keys/-/camelcase-keys-2.1.0.tgz#308beeaffdf28119051efa1d932213c91b8f92e7" + dependencies: + camelcase "^2.0.0" + map-obj "^1.0.0" + +camelcase@^2.0.0, camelcase@^2.1.0: + version "2.1.1" + resolved "https://registry.yarnpkg.com/camelcase/-/camelcase-2.1.1.tgz#7c1d16d679a1bbe59ca02cacecfb011e201f5a1f" + +camelcase@^4.0.0: + version "4.1.0" + resolved "https://registry.yarnpkg.com/camelcase/-/camelcase-4.1.0.tgz#d545635be1e33c542649c69173e5de6acfae34dd" + +capture-stack-trace@^1.0.0: + version "1.0.0" + resolved "https://registry.yarnpkg.com/capture-stack-trace/-/capture-stack-trace-1.0.0.tgz#4a6fa07399c26bba47f0b2496b4d0fb408c5550d" + +chalk@^1.0.0, chalk@^1.1.0, chalk@^1.1.1: + version "1.1.3" + resolved "https://registry.yarnpkg.com/chalk/-/chalk-1.1.3.tgz#a8115c55e4a702fe4d150abd3872822a7e09fc98" + dependencies: + ansi-styles "^2.2.1" + escape-string-regexp "^1.0.2" + has-ansi "^2.0.0" + strip-ansi "^3.0.0" + supports-color "^2.0.0" + +cli-boxes@^1.0.0: + version "1.0.0" + resolved "https://registry.yarnpkg.com/cli-boxes/-/cli-boxes-1.0.0.tgz#4fa917c3e59c94a004cd61f8ee509da651687143" + +code-point-at@^1.0.0: + version "1.1.0" + resolved "https://registry.yarnpkg.com/code-point-at/-/code-point-at-1.1.0.tgz#0d070b4d043a5bea33a2f1a40e2edb3d9a4ccf77" + +colors@^1.1.2: + version "1.1.2" + resolved "https://registry.yarnpkg.com/colors/-/colors-1.1.2.tgz#168a4701756b6a7f51a12ce0c97bfa28c084ed63" + +commander@2.9.0: + version "2.9.0" + resolved "https://registry.yarnpkg.com/commander/-/commander-2.9.0.tgz#9c99094176e12240cb22d6c5146098400fe0f7d4" + dependencies: + graceful-readlink ">= 1.0.0" + +concat-map@0.0.1: + version "0.0.1" + resolved "https://registry.yarnpkg.com/concat-map/-/concat-map-0.0.1.tgz#d8a96bd77fd68df7793a73036a3ba0d5405d477b" + +configstore@^2.0.0: + version "2.1.0" + resolved "https://registry.yarnpkg.com/configstore/-/configstore-2.1.0.tgz#737a3a7036e9886102aa6099e47bb33ab1aba1a1" + dependencies: + dot-prop "^3.0.0" + graceful-fs "^4.1.2" + mkdirp "^0.5.0" + object-assign "^4.0.1" + os-tmpdir "^1.0.0" + osenv "^0.1.0" + uuid "^2.0.1" + write-file-atomic "^1.1.2" + xdg-basedir "^2.0.0" + +configstore@^3.0.0: + version "3.0.0" + resolved "https://registry.yarnpkg.com/configstore/-/configstore-3.0.0.tgz#e1b8669c1803ccc50b545e92f8e6e79aa80e0196" + dependencies: + dot-prop "^4.1.0" + graceful-fs "^4.1.2" + mkdirp "^0.5.0" + unique-string "^1.0.0" + write-file-atomic "^1.1.2" + xdg-basedir "^3.0.0" + +core-util-is@~1.0.0: + version "1.0.2" + resolved "https://registry.yarnpkg.com/core-util-is/-/core-util-is-1.0.2.tgz#b5fd54220aa2bc5ab57aab7140c940754503c1a7" + +create-error-class@^3.0.0, create-error-class@^3.0.1: + version "3.0.2" + resolved "https://registry.yarnpkg.com/create-error-class/-/create-error-class-3.0.2.tgz#06be7abef947a3f14a30fd610671d401bca8b7b6" + dependencies: + capture-stack-trace "^1.0.0" + +cross-spawn-async@^2.1.1: + version "2.2.5" + resolved "https://registry.yarnpkg.com/cross-spawn-async/-/cross-spawn-async-2.2.5.tgz#845ff0c0834a3ded9d160daca6d390906bb288cc" + dependencies: + lru-cache "^4.0.0" + which "^1.2.8" + +crypto-random-string@^1.0.0: + version "1.0.0" + resolved "https://registry.yarnpkg.com/crypto-random-string/-/crypto-random-string-1.0.0.tgz#a230f64f568310e1498009940790ec99545bca7e" + +currently-unhandled@^0.4.1: + version "0.4.1" + resolved "https://registry.yarnpkg.com/currently-unhandled/-/currently-unhandled-0.4.1.tgz#988df33feab191ef799a61369dd76c17adf957ea" + dependencies: + array-find-index "^1.0.1" + +debug@2.6.0: + version "2.6.0" + resolved "https://registry.yarnpkg.com/debug/-/debug-2.6.0.tgz#bc596bcabe7617f11d9fa15361eded5608b8499b" + dependencies: + ms "0.7.2" + +decamelize@^1.1.2: + version "1.2.0" + resolved "https://registry.yarnpkg.com/decamelize/-/decamelize-1.2.0.tgz#f6534d15148269b20352e7bee26f501f9a191290" + +deep-extend@~0.4.0: + version "0.4.1" + resolved "https://registry.yarnpkg.com/deep-extend/-/deep-extend-0.4.1.tgz#efe4113d08085f4e6f9687759810f807469e2253" + +del-cli@^0.2.1: + version "0.2.1" + resolved "https://registry.yarnpkg.com/del-cli/-/del-cli-0.2.1.tgz#d5f8ca540e8ab89b2d903075ae47113c72a6d937" + dependencies: + del "^2.2.0" + meow "^3.6.0" + update-notifier "^1.0.3" + +del@^2.2.0: + version "2.2.2" + resolved "https://registry.yarnpkg.com/del/-/del-2.2.2.tgz#c12c981d067846c84bcaf862cff930d907ffd1a8" + dependencies: + globby "^5.0.0" + is-path-cwd "^1.0.0" + is-path-in-cwd "^1.0.0" + object-assign "^4.0.1" + pify "^2.0.0" + pinkie-promise "^2.0.0" + rimraf "^2.2.8" + +diff@3.2.0, diff@^3.0.1, diff@^3.1.0, diff@^3.2.0: + version "3.2.0" + resolved "https://registry.yarnpkg.com/diff/-/diff-3.2.0.tgz#c9ce393a4b7cbd0b058a725c93df299027868ff9" + +doctrine@^0.7.2: + version "0.7.2" + resolved "https://registry.yarnpkg.com/doctrine/-/doctrine-0.7.2.tgz#7cb860359ba3be90e040b26b729ce4bfa654c523" + dependencies: + esutils "^1.1.6" + isarray "0.0.1" + +dot-prop@^3.0.0: + version "3.0.0" + resolved "https://registry.yarnpkg.com/dot-prop/-/dot-prop-3.0.0.tgz#1b708af094a49c9a0e7dbcad790aba539dac1177" + dependencies: + is-obj "^1.0.0" + +dot-prop@^4.1.0: + version "4.1.1" + resolved "https://registry.yarnpkg.com/dot-prop/-/dot-prop-4.1.1.tgz#a8493f0b7b5eeec82525b5c7587fa7de7ca859c1" + dependencies: + is-obj "^1.0.0" + +duplexer2@^0.1.4: + version "0.1.4" + resolved "https://registry.yarnpkg.com/duplexer2/-/duplexer2-0.1.4.tgz#8b12dab878c0d69e3e7891051662a32fc6bddcc1" + dependencies: + readable-stream "^2.0.2" + +duplexer3@^0.1.4: + version "0.1.4" + resolved "https://registry.yarnpkg.com/duplexer3/-/duplexer3-0.1.4.tgz#ee01dd1cac0ed3cbc7fdbea37dc0a8f1ce002ce2" + +error-ex@^1.2.0: + version "1.3.1" + resolved "https://registry.yarnpkg.com/error-ex/-/error-ex-1.3.1.tgz#f855a86ce61adc4e8621c3cda21e7a7612c3a8dc" + dependencies: + is-arrayish "^0.2.1" + +escape-string-regexp@1.0.5, escape-string-regexp@^1.0.2: + version "1.0.5" + resolved "https://registry.yarnpkg.com/escape-string-regexp/-/escape-string-regexp-1.0.5.tgz#1b61c0562190a8dff6ae3bb2cf0200ca130b86d4" + +esutils@^1.1.6: + version "1.1.6" + resolved "https://registry.yarnpkg.com/esutils/-/esutils-1.1.6.tgz#c01ccaa9ae4b897c6d0c3e210ae52f3c7a844375" + +esutils@^2.0.2: + version "2.0.2" + resolved "https://registry.yarnpkg.com/esutils/-/esutils-2.0.2.tgz#0abf4f1caa5bcb1f7a9d8acc6dea4faaa04bac9b" + +execa@^0.4.0: + version "0.4.0" + resolved "https://registry.yarnpkg.com/execa/-/execa-0.4.0.tgz#4eb6467a36a095fabb2970ff9d5e3fb7bce6ebc3" + dependencies: + cross-spawn-async "^2.1.1" + is-stream "^1.1.0" + npm-run-path "^1.0.0" + object-assign "^4.0.1" + path-key "^1.0.0" + strip-eof "^1.0.0" + +filled-array@^1.0.0: + version "1.1.0" + resolved "https://registry.yarnpkg.com/filled-array/-/filled-array-1.1.0.tgz#c3c4f6c663b923459a9aa29912d2d031f1507f84" + +find-up@^1.0.0: + version "1.1.2" + resolved "https://registry.yarnpkg.com/find-up/-/find-up-1.1.2.tgz#6b2e9822b1a2ce0a60ab64d610eccad53cb24d0f" + dependencies: + path-exists "^2.0.0" + pinkie-promise "^2.0.0" + +findup-sync@~0.3.0: + version "0.3.0" + resolved "https://registry.yarnpkg.com/findup-sync/-/findup-sync-0.3.0.tgz#37930aa5d816b777c03445e1966cc6790a4c0b16" + dependencies: + glob "~5.0.0" + +fs.realpath@^1.0.0: + version "1.0.0" + resolved "https://registry.yarnpkg.com/fs.realpath/-/fs.realpath-1.0.0.tgz#1504ad2523158caa40db4a2787cb01411994ea4f" + +get-stdin@^4.0.1: + version "4.0.1" + resolved "https://registry.yarnpkg.com/get-stdin/-/get-stdin-4.0.1.tgz#b968c6b0a04384324902e8bf1a5df32579a450fe" + +get-stream@^3.0.0: + version "3.0.0" + resolved "https://registry.yarnpkg.com/get-stream/-/get-stream-3.0.0.tgz#8e943d1358dc37555054ecbe2edb05aa174ede14" + +glob@7.1.1, glob@^7.0.3, glob@^7.0.5, glob@^7.1.1: + version "7.1.1" + resolved "https://registry.yarnpkg.com/glob/-/glob-7.1.1.tgz#805211df04faaf1c63a3600306cdf5ade50b2ec8" + dependencies: + fs.realpath "^1.0.0" + inflight "^1.0.4" + inherits "2" + minimatch "^3.0.2" + once "^1.3.0" + path-is-absolute "^1.0.0" + +glob@~5.0.0: + version "5.0.15" + resolved "https://registry.yarnpkg.com/glob/-/glob-5.0.15.tgz#1bc936b9e02f4a603fcc222ecf7633d30b8b93b1" + dependencies: + inflight "^1.0.4" + inherits "2" + minimatch "2 || 3" + once "^1.3.0" + path-is-absolute "^1.0.0" + +globby@^5.0.0: + version "5.0.0" + resolved "https://registry.yarnpkg.com/globby/-/globby-5.0.0.tgz#ebd84667ca0dbb330b99bcfc68eac2bc54370e0d" + dependencies: + array-union "^1.0.1" + arrify "^1.0.0" + glob "^7.0.3" + object-assign "^4.0.1" + pify "^2.0.0" + pinkie-promise "^2.0.0" + +got@^5.0.0: + version "5.7.1" + resolved "https://registry.yarnpkg.com/got/-/got-5.7.1.tgz#5f81635a61e4a6589f180569ea4e381680a51f35" + dependencies: + create-error-class "^3.0.1" + duplexer2 "^0.1.4" + is-redirect "^1.0.0" + is-retry-allowed "^1.0.0" + is-stream "^1.0.0" + lowercase-keys "^1.0.0" + node-status-codes "^1.0.0" + object-assign "^4.0.1" + parse-json "^2.1.0" + pinkie-promise "^2.0.0" + read-all-stream "^3.0.0" + readable-stream "^2.0.5" + timed-out "^3.0.0" + unzip-response "^1.0.2" + url-parse-lax "^1.0.0" + +got@^6.7.1: + version "6.7.1" + resolved "https://registry.yarnpkg.com/got/-/got-6.7.1.tgz#240cd05785a9a18e561dc1b44b41c763ef1e8db0" + dependencies: + create-error-class "^3.0.0" + duplexer3 "^0.1.4" + get-stream "^3.0.0" + is-redirect "^1.0.0" + is-retry-allowed "^1.0.0" + is-stream "^1.0.0" + lowercase-keys "^1.0.0" + safe-buffer "^5.0.1" + timed-out "^4.0.0" + unzip-response "^2.0.1" + url-parse-lax "^1.0.0" + +graceful-fs@^4.1.11, graceful-fs@^4.1.2: + version "4.1.11" + resolved "https://registry.yarnpkg.com/graceful-fs/-/graceful-fs-4.1.11.tgz#0e8bdfe4d1ddb8854d64e04ea7c00e2a026e5658" + +"graceful-readlink@>= 1.0.0": + version "1.0.1" + resolved "https://registry.yarnpkg.com/graceful-readlink/-/graceful-readlink-1.0.1.tgz#4cafad76bc62f02fa039b2f94e9a3dd3a391a725" + +growl@1.9.2: + version "1.9.2" + resolved "https://registry.yarnpkg.com/growl/-/growl-1.9.2.tgz#0ea7743715db8d8de2c5ede1775e1b45ac85c02f" + +has-ansi@^2.0.0: + version "2.0.0" + resolved "https://registry.yarnpkg.com/has-ansi/-/has-ansi-2.0.0.tgz#34f5049ce1ecdf2b0649af3ef24e45ed35416d91" + dependencies: + ansi-regex "^2.0.0" + +has-flag@^1.0.0: + version "1.0.0" + resolved "https://registry.yarnpkg.com/has-flag/-/has-flag-1.0.0.tgz#9d9e793165ce017a00f00418c43f942a7b1d11fa" + +hosted-git-info@^2.1.4: + version "2.4.2" + resolved "https://registry.yarnpkg.com/hosted-git-info/-/hosted-git-info-2.4.2.tgz#0076b9f46a270506ddbaaea56496897460612a67" + +imurmurhash@^0.1.4: + version "0.1.4" + resolved "https://registry.yarnpkg.com/imurmurhash/-/imurmurhash-0.1.4.tgz#9218b9b2b928a238b13dc4fb6b6d576f231453ea" + +indent-string@^2.1.0: + version "2.1.0" + resolved "https://registry.yarnpkg.com/indent-string/-/indent-string-2.1.0.tgz#8e2d48348742121b4a8218b7a137e9a52049dc80" + dependencies: + repeating "^2.0.0" + +inflight@^1.0.4: + version "1.0.6" + resolved "https://registry.yarnpkg.com/inflight/-/inflight-1.0.6.tgz#49bd6331d7d02d0c09bc910a1075ba8165b56df9" + dependencies: + once "^1.3.0" + wrappy "1" + +inherits@2, inherits@~2.0.1: + version "2.0.3" + resolved "https://registry.yarnpkg.com/inherits/-/inherits-2.0.3.tgz#633c2c83e3da42a502f52466022480f4208261de" + +ini@~1.3.0: + version "1.3.4" + resolved "https://registry.yarnpkg.com/ini/-/ini-1.3.4.tgz#0537cb79daf59b59a1a517dff706c86ec039162e" + +is-arrayish@^0.2.1: + version "0.2.1" + resolved "https://registry.yarnpkg.com/is-arrayish/-/is-arrayish-0.2.1.tgz#77c99840527aa8ecb1a8ba697b80645a7a926a9d" + +is-builtin-module@^1.0.0: + version "1.0.0" + resolved "https://registry.yarnpkg.com/is-builtin-module/-/is-builtin-module-1.0.0.tgz#540572d34f7ac3119f8f76c30cbc1b1e037affbe" + dependencies: + builtin-modules "^1.0.0" + +is-finite@^1.0.0: + version "1.0.2" + resolved "https://registry.yarnpkg.com/is-finite/-/is-finite-1.0.2.tgz#cc6677695602be550ef11e8b4aa6305342b6d0aa" + dependencies: + number-is-nan "^1.0.0" + +is-fullwidth-code-point@^1.0.0: + version "1.0.0" + resolved "https://registry.yarnpkg.com/is-fullwidth-code-point/-/is-fullwidth-code-point-1.0.0.tgz#ef9e31386f031a7f0d643af82fde50c457ef00cb" + dependencies: + number-is-nan "^1.0.0" + +is-fullwidth-code-point@^2.0.0: + version "2.0.0" + resolved "https://registry.yarnpkg.com/is-fullwidth-code-point/-/is-fullwidth-code-point-2.0.0.tgz#a3b30a5c4f199183167aaab93beefae3ddfb654f" + +is-npm@^1.0.0: + version "1.0.0" + resolved "https://registry.yarnpkg.com/is-npm/-/is-npm-1.0.0.tgz#f2fb63a65e4905b406c86072765a1a4dc793b9f4" + +is-obj@^1.0.0: + version "1.0.1" + resolved "https://registry.yarnpkg.com/is-obj/-/is-obj-1.0.1.tgz#3e4729ac1f5fde025cd7d83a896dab9f4f67db0f" + +is-path-cwd@^1.0.0: + version "1.0.0" + resolved "https://registry.yarnpkg.com/is-path-cwd/-/is-path-cwd-1.0.0.tgz#d225ec23132e89edd38fda767472e62e65f1106d" + +is-path-in-cwd@^1.0.0: + version "1.0.0" + resolved "https://registry.yarnpkg.com/is-path-in-cwd/-/is-path-in-cwd-1.0.0.tgz#6477582b8214d602346094567003be8a9eac04dc" + dependencies: + is-path-inside "^1.0.0" + +is-path-inside@^1.0.0: + version "1.0.0" + resolved "https://registry.yarnpkg.com/is-path-inside/-/is-path-inside-1.0.0.tgz#fc06e5a1683fbda13de667aff717bbc10a48f37f" + dependencies: + path-is-inside "^1.0.1" + +is-redirect@^1.0.0: + version "1.0.0" + resolved "https://registry.yarnpkg.com/is-redirect/-/is-redirect-1.0.0.tgz#1d03dded53bd8db0f30c26e4f95d36fc7c87dc24" + +is-retry-allowed@^1.0.0: + version "1.1.0" + resolved "https://registry.yarnpkg.com/is-retry-allowed/-/is-retry-allowed-1.1.0.tgz#11a060568b67339444033d0125a61a20d564fb34" + +is-stream@^1.0.0, is-stream@^1.1.0: + version "1.1.0" + resolved "https://registry.yarnpkg.com/is-stream/-/is-stream-1.1.0.tgz#12d4a3dd4e68e0b79ceb8dbc84173ae80d91ca44" + +is-utf8@^0.2.0: + version "0.2.1" + resolved "https://registry.yarnpkg.com/is-utf8/-/is-utf8-0.2.1.tgz#4b0da1442104d1b336340e80797e865cf39f7d72" + +isarray@0.0.1: + version "0.0.1" + resolved "https://registry.yarnpkg.com/isarray/-/isarray-0.0.1.tgz#8a18acfca9a8f4177e09abfc6038939b05d1eedf" + +isarray@~1.0.0: + version "1.0.0" + resolved "https://registry.yarnpkg.com/isarray/-/isarray-1.0.0.tgz#bb935d48582cba168c06834957a54a3e07124f11" + +isexe@^2.0.0: + version "2.0.0" + resolved "https://registry.yarnpkg.com/isexe/-/isexe-2.0.0.tgz#e8fbf374dc556ff8947a10dcb0572d633f2cfa10" + +js-tokens@^3.0.0: + version "3.0.1" + resolved "https://registry.yarnpkg.com/js-tokens/-/js-tokens-3.0.1.tgz#08e9f132484a2c45a30907e9dc4d5567b7f114d7" + +json3@3.3.2: + version "3.3.2" + resolved "https://registry.yarnpkg.com/json3/-/json3-3.3.2.tgz#3c0434743df93e2f5c42aee7b19bcb483575f4e1" + +latest-version@^2.0.0: + version "2.0.0" + resolved "https://registry.yarnpkg.com/latest-version/-/latest-version-2.0.0.tgz#56f8d6139620847b8017f8f1f4d78e211324168b" + dependencies: + package-json "^2.0.0" + +latest-version@^3.0.0: + version "3.1.0" + resolved "https://registry.yarnpkg.com/latest-version/-/latest-version-3.1.0.tgz#a205383fea322b33b5ae3b18abee0dc2f356ee15" + dependencies: + package-json "^4.0.0" + +lazy-req@^1.1.0: + version "1.1.0" + resolved "https://registry.yarnpkg.com/lazy-req/-/lazy-req-1.1.0.tgz#bdaebead30f8d824039ce0ce149d4daa07ba1fac" + +lazy-req@^2.0.0: + version "2.0.0" + resolved "https://registry.yarnpkg.com/lazy-req/-/lazy-req-2.0.0.tgz#c9450a363ecdda2e6f0c70132ad4f37f8f06f2b4" + +load-json-file@^1.0.0: + version "1.1.0" + resolved "https://registry.yarnpkg.com/load-json-file/-/load-json-file-1.1.0.tgz#956905708d58b4bab4c2261b04f59f31c99374c0" + dependencies: + graceful-fs "^4.1.2" + parse-json "^2.2.0" + pify "^2.0.0" + pinkie-promise "^2.0.0" + strip-bom "^2.0.0" + +lodash._baseassign@^3.0.0: + version "3.2.0" + resolved "https://registry.yarnpkg.com/lodash._baseassign/-/lodash._baseassign-3.2.0.tgz#8c38a099500f215ad09e59f1722fd0c52bfe0a4e" + dependencies: + lodash._basecopy "^3.0.0" + lodash.keys "^3.0.0" + +lodash._basecopy@^3.0.0: + version "3.0.1" + resolved "https://registry.yarnpkg.com/lodash._basecopy/-/lodash._basecopy-3.0.1.tgz#8da0e6a876cf344c0ad8a54882111dd3c5c7ca36" + +lodash._basecreate@^3.0.0: + version "3.0.3" + resolved "https://registry.yarnpkg.com/lodash._basecreate/-/lodash._basecreate-3.0.3.tgz#1bc661614daa7fc311b7d03bf16806a0213cf821" + +lodash._getnative@^3.0.0: + version "3.9.1" + resolved "https://registry.yarnpkg.com/lodash._getnative/-/lodash._getnative-3.9.1.tgz#570bc7dede46d61cdcde687d65d3eecbaa3aaff5" + +lodash._isiterateecall@^3.0.0: + version "3.0.9" + resolved "https://registry.yarnpkg.com/lodash._isiterateecall/-/lodash._isiterateecall-3.0.9.tgz#5203ad7ba425fae842460e696db9cf3e6aac057c" + +lodash.create@3.1.1: + version "3.1.1" + resolved "https://registry.yarnpkg.com/lodash.create/-/lodash.create-3.1.1.tgz#d7f2849f0dbda7e04682bb8cd72ab022461debe7" + dependencies: + lodash._baseassign "^3.0.0" + lodash._basecreate "^3.0.0" + lodash._isiterateecall "^3.0.0" + +lodash.isarguments@^3.0.0: + version "3.1.0" + resolved "https://registry.yarnpkg.com/lodash.isarguments/-/lodash.isarguments-3.1.0.tgz#2f573d85c6a24289ff00663b491c1d338ff3458a" + +lodash.isarray@^3.0.0: + version "3.0.4" + resolved "https://registry.yarnpkg.com/lodash.isarray/-/lodash.isarray-3.0.4.tgz#79e4eb88c36a8122af86f844aa9bcd851b5fbb55" + +lodash.keys@^3.0.0: + version "3.1.2" + resolved "https://registry.yarnpkg.com/lodash.keys/-/lodash.keys-3.1.2.tgz#4dbc0472b156be50a0b286855d1bd0b0c656098a" + dependencies: + lodash._getnative "^3.0.0" + lodash.isarguments "^3.0.0" + lodash.isarray "^3.0.0" + +loud-rejection@^1.0.0: + version "1.6.0" + resolved "https://registry.yarnpkg.com/loud-rejection/-/loud-rejection-1.6.0.tgz#5b46f80147edee578870f086d04821cf998e551f" + dependencies: + currently-unhandled "^0.4.1" + signal-exit "^3.0.0" + +lowercase-keys@^1.0.0: + version "1.0.0" + resolved "https://registry.yarnpkg.com/lowercase-keys/-/lowercase-keys-1.0.0.tgz#4e3366b39e7f5457e35f1324bdf6f88d0bfc7306" + +lru-cache@^4.0.0: + version "4.0.2" + resolved "https://registry.yarnpkg.com/lru-cache/-/lru-cache-4.0.2.tgz#1d17679c069cda5d040991a09dbc2c0db377e55e" + dependencies: + pseudomap "^1.0.1" + yallist "^2.0.0" + +make-error@^1.1.1: + version "1.2.3" + resolved "https://registry.yarnpkg.com/make-error/-/make-error-1.2.3.tgz#6c4402df732e0977ac6faf754a5074b3d2b1d19d" + +map-obj@^1.0.0, map-obj@^1.0.1: + version "1.0.1" + resolved "https://registry.yarnpkg.com/map-obj/-/map-obj-1.0.1.tgz#d933ceb9205d82bdcf4886f6742bdc2b4dea146d" + +meow@^3.6.0: + version "3.7.0" + resolved "https://registry.yarnpkg.com/meow/-/meow-3.7.0.tgz#72cb668b425228290abbfa856892587308a801fb" + dependencies: + camelcase-keys "^2.0.0" + decamelize "^1.1.2" + loud-rejection "^1.0.0" + map-obj "^1.0.1" + minimist "^1.1.3" + normalize-package-data "^2.3.4" + object-assign "^4.0.1" + read-pkg-up "^1.0.1" + redent "^1.0.0" + trim-newlines "^1.0.0" + +"minimatch@2 || 3", minimatch@^3.0.2: + version "3.0.3" + resolved "https://registry.yarnpkg.com/minimatch/-/minimatch-3.0.3.tgz#2a4e4090b96b2db06a9d7df01055a62a77c9b774" + dependencies: + brace-expansion "^1.0.0" + +minimist@0.0.8, minimist@~0.0.1: + version "0.0.8" + resolved "https://registry.yarnpkg.com/minimist/-/minimist-0.0.8.tgz#857fcabfc3397d2625b8228262e86aa7a011b05d" + +minimist@^1.1.3, minimist@^1.2.0: + version "1.2.0" + resolved "https://registry.yarnpkg.com/minimist/-/minimist-1.2.0.tgz#a35008b20f41383eec1fb914f4cd5df79a264284" + +mkdirp@0.5.1, mkdirp@^0.5.0, mkdirp@^0.5.1: + version "0.5.1" + resolved "https://registry.yarnpkg.com/mkdirp/-/mkdirp-0.5.1.tgz#30057438eac6cf7f8c4767f38648d6697d75c903" + dependencies: + minimist "0.0.8" + +mocha-clean@^1.0.0: + version "1.0.0" + resolved "https://registry.yarnpkg.com/mocha-clean/-/mocha-clean-1.0.0.tgz#7e769b16cb38745df62a28917077953b05fec064" + +mocha@^3.2.0: + version "3.3.0" + resolved "https://registry.yarnpkg.com/mocha/-/mocha-3.3.0.tgz#d29b7428d3f52c82e2e65df1ecb7064e1aabbfb5" + dependencies: + browser-stdout "1.3.0" + commander "2.9.0" + debug "2.6.0" + diff "3.2.0" + escape-string-regexp "1.0.5" + glob "7.1.1" + growl "1.9.2" + json3 "3.3.2" + lodash.create "3.1.1" + mkdirp "0.5.1" + supports-color "3.1.2" + +ms@0.7.2: + version "0.7.2" + resolved "https://registry.yarnpkg.com/ms/-/ms-0.7.2.tgz#ae25cf2512b3885a1d95d7f037868d8431124765" + +node-status-codes@^1.0.0: + version "1.0.0" + resolved "https://registry.yarnpkg.com/node-status-codes/-/node-status-codes-1.0.0.tgz#5ae5541d024645d32a58fcddc9ceecea7ae3ac2f" + +normalize-package-data@^2.3.2, normalize-package-data@^2.3.4: + version "2.3.8" + resolved "https://registry.yarnpkg.com/normalize-package-data/-/normalize-package-data-2.3.8.tgz#d819eda2a9dedbd1ffa563ea4071d936782295bb" + dependencies: + hosted-git-info "^2.1.4" + is-builtin-module "^1.0.0" + semver "2 || 3 || 4 || 5" + validate-npm-package-license "^3.0.1" + +npm-run-path@^1.0.0: + version "1.0.0" + resolved "https://registry.yarnpkg.com/npm-run-path/-/npm-run-path-1.0.0.tgz#f5c32bf595fe81ae927daec52e82f8b000ac3c8f" + dependencies: + path-key "^1.0.0" + +number-is-nan@^1.0.0: + version "1.0.1" + resolved "https://registry.yarnpkg.com/number-is-nan/-/number-is-nan-1.0.1.tgz#097b602b53422a522c1afb8790318336941a011d" + +object-assign@^4.0.1: + version "4.1.1" + resolved "https://registry.yarnpkg.com/object-assign/-/object-assign-4.1.1.tgz#2109adc7965887cfc05cbbd442cac8bfbb360863" + +once@^1.3.0: + version "1.4.0" + resolved "https://registry.yarnpkg.com/once/-/once-1.4.0.tgz#583b1aa775961d4b113ac17d9c50baef9dd76bd1" + dependencies: + wrappy "1" + +optimist@~0.6.0: + version "0.6.1" + resolved "https://registry.yarnpkg.com/optimist/-/optimist-0.6.1.tgz#da3ea74686fa21a19a111c326e90eb15a0196686" + dependencies: + minimist "~0.0.1" + wordwrap "~0.0.2" + +os-homedir@^1.0.0: + version "1.0.2" + resolved "https://registry.yarnpkg.com/os-homedir/-/os-homedir-1.0.2.tgz#ffbc4988336e0e833de0c168c7ef152121aa7fb3" + +os-tmpdir@^1.0.0: + version "1.0.2" + resolved "https://registry.yarnpkg.com/os-tmpdir/-/os-tmpdir-1.0.2.tgz#bbe67406c79aa85c5cfec766fe5734555dfa1274" + +osenv@^0.1.0: + version "0.1.4" + resolved "https://registry.yarnpkg.com/osenv/-/osenv-0.1.4.tgz#42fe6d5953df06c8064be6f176c3d05aaaa34644" + dependencies: + os-homedir "^1.0.0" + os-tmpdir "^1.0.0" + +package-json@^2.0.0: + version "2.4.0" + resolved "https://registry.yarnpkg.com/package-json/-/package-json-2.4.0.tgz#0d15bd67d1cbbddbb2ca222ff2edb86bcb31a8bb" + dependencies: + got "^5.0.0" + registry-auth-token "^3.0.1" + registry-url "^3.0.3" + semver "^5.1.0" + +package-json@^4.0.0: + version "4.0.1" + resolved "https://registry.yarnpkg.com/package-json/-/package-json-4.0.1.tgz#8869a0401253661c4c4ca3da6c2121ed555f5eed" + dependencies: + got "^6.7.1" + registry-auth-token "^3.0.1" + registry-url "^3.0.3" + semver "^5.1.0" + +parse-json@^2.1.0, parse-json@^2.2.0: + version "2.2.0" + resolved "https://registry.yarnpkg.com/parse-json/-/parse-json-2.2.0.tgz#f480f40434ef80741f8469099f8dea18f55a4dc9" + dependencies: + error-ex "^1.2.0" + +path-exists@^2.0.0: + version "2.1.0" + resolved "https://registry.yarnpkg.com/path-exists/-/path-exists-2.1.0.tgz#0feb6c64f0fc518d9a754dd5efb62c7022761f4b" + dependencies: + pinkie-promise "^2.0.0" + +path-is-absolute@^1.0.0: + version "1.0.1" + resolved "https://registry.yarnpkg.com/path-is-absolute/-/path-is-absolute-1.0.1.tgz#174b9268735534ffbc7ace6bf53a5a9e1b5c5f5f" + +path-is-inside@^1.0.1: + version "1.0.2" + resolved "https://registry.yarnpkg.com/path-is-inside/-/path-is-inside-1.0.2.tgz#365417dede44430d1c11af61027facf074bdfc53" + +path-key@^1.0.0: + version "1.0.0" + resolved "https://registry.yarnpkg.com/path-key/-/path-key-1.0.0.tgz#5d53d578019646c0d68800db4e146e6bdc2ac7af" + +path-parse@^1.0.5: + version "1.0.5" + resolved "https://registry.yarnpkg.com/path-parse/-/path-parse-1.0.5.tgz#3c1adf871ea9cd6c9431b6ea2bd74a0ff055c4c1" + +path-type@^1.0.0: + version "1.1.0" + resolved "https://registry.yarnpkg.com/path-type/-/path-type-1.1.0.tgz#59c44f7ee491da704da415da5a4070ba4f8fe441" + dependencies: + graceful-fs "^4.1.2" + pify "^2.0.0" + pinkie-promise "^2.0.0" + +pify@^2.0.0: + version "2.3.0" + resolved "https://registry.yarnpkg.com/pify/-/pify-2.3.0.tgz#ed141a6ac043a849ea588498e7dca8b15330e90c" + +pinkie-promise@^2.0.0: + version "2.0.1" + resolved "https://registry.yarnpkg.com/pinkie-promise/-/pinkie-promise-2.0.1.tgz#2135d6dfa7a358c069ac9b178776288228450ffa" + dependencies: + pinkie "^2.0.0" + +pinkie@^2.0.0: + version "2.0.4" + resolved "https://registry.yarnpkg.com/pinkie/-/pinkie-2.0.4.tgz#72556b80cfa0d48a974e80e77248e80ed4f7f870" + +prepend-http@^1.0.1: + version "1.0.4" + resolved "https://registry.yarnpkg.com/prepend-http/-/prepend-http-1.0.4.tgz#d4f4562b0ce3696e41ac52d0e002e57a635dc6dc" + +process-nextick-args@~1.0.6: + version "1.0.7" + resolved "https://registry.yarnpkg.com/process-nextick-args/-/process-nextick-args-1.0.7.tgz#150e20b756590ad3f91093f25a4f2ad8bff30ba3" + +pseudomap@^1.0.1: + version "1.0.2" + resolved "https://registry.yarnpkg.com/pseudomap/-/pseudomap-1.0.2.tgz#f052a28da70e618917ef0a8ac34c1ae5a68286b3" + +ramda@0.23.0: + version "0.23.0" + resolved "https://registry.yarnpkg.com/ramda/-/ramda-0.23.0.tgz#ccd13fff73497a93974e3e86327bfd87bd6e8e2b" + +rc@^1.0.1, rc@^1.1.6: + version "1.2.1" + resolved "https://registry.yarnpkg.com/rc/-/rc-1.2.1.tgz#2e03e8e42ee450b8cb3dce65be1bf8974e1dfd95" + dependencies: + deep-extend "~0.4.0" + ini "~1.3.0" + minimist "^1.2.0" + strip-json-comments "~2.0.1" + +read-all-stream@^3.0.0: + version "3.1.0" + resolved "https://registry.yarnpkg.com/read-all-stream/-/read-all-stream-3.1.0.tgz#35c3e177f2078ef789ee4bfafa4373074eaef4fa" + dependencies: + pinkie-promise "^2.0.0" + readable-stream "^2.0.0" + +read-pkg-up@^1.0.1: + version "1.0.1" + resolved "https://registry.yarnpkg.com/read-pkg-up/-/read-pkg-up-1.0.1.tgz#9d63c13276c065918d57f002a57f40a1b643fb02" + dependencies: + find-up "^1.0.0" + read-pkg "^1.0.0" + +read-pkg@^1.0.0: + version "1.1.0" + resolved "https://registry.yarnpkg.com/read-pkg/-/read-pkg-1.1.0.tgz#f5ffaa5ecd29cb31c0474bca7d756b6bb29e3f28" + dependencies: + load-json-file "^1.0.0" + normalize-package-data "^2.3.2" + path-type "^1.0.0" + +readable-stream@^2.0.0, readable-stream@^2.0.2, readable-stream@^2.0.5: + version "2.2.9" + resolved "https://registry.yarnpkg.com/readable-stream/-/readable-stream-2.2.9.tgz#cf78ec6f4a6d1eb43d26488cac97f042e74b7fc8" + dependencies: + buffer-shims "~1.0.0" + core-util-is "~1.0.0" + inherits "~2.0.1" + isarray "~1.0.0" + process-nextick-args "~1.0.6" + string_decoder "~1.0.0" + util-deprecate "~1.0.1" + +redent@^1.0.0: + version "1.0.0" + resolved "https://registry.yarnpkg.com/redent/-/redent-1.0.0.tgz#cf916ab1fd5f1f16dfb20822dd6ec7f730c2afde" + dependencies: + indent-string "^2.1.0" + strip-indent "^1.0.1" + +registry-auth-token@^3.0.1: + version "3.3.0" + resolved "https://registry.yarnpkg.com/registry-auth-token/-/registry-auth-token-3.3.0.tgz#57ae67347e73d96345ed1bc01294c7237c02aa63" + dependencies: + rc "^1.1.6" + safe-buffer "^5.0.1" + +registry-url@^3.0.3: + version "3.1.0" + resolved "https://registry.yarnpkg.com/registry-url/-/registry-url-3.1.0.tgz#3d4ef870f73dde1d77f0cf9a381432444e174942" + dependencies: + rc "^1.0.1" + +repeating@^2.0.0: + version "2.0.1" + resolved "https://registry.yarnpkg.com/repeating/-/repeating-2.0.1.tgz#5214c53a926d3552707527fbab415dbc08d06dda" + dependencies: + is-finite "^1.0.0" + +resolve@^1.1.7, resolve@^1.3.2: + version "1.3.3" + resolved "https://registry.yarnpkg.com/resolve/-/resolve-1.3.3.tgz#655907c3469a8680dc2de3a275a8fdd69691f0e5" + dependencies: + path-parse "^1.0.5" + +rimraf@^2.2.8: + version "2.6.1" + resolved "https://registry.yarnpkg.com/rimraf/-/rimraf-2.6.1.tgz#c2338ec643df7a1b7fe5c54fa86f57428a55f33d" + dependencies: + glob "^7.0.5" + +safe-buffer@^5.0.1: + version "5.0.1" + resolved "https://registry.yarnpkg.com/safe-buffer/-/safe-buffer-5.0.1.tgz#d263ca54696cd8a306b5ca6551e92de57918fbe7" + +semver-diff@^2.0.0: + version "2.1.0" + resolved "https://registry.yarnpkg.com/semver-diff/-/semver-diff-2.1.0.tgz#4bbb8437c8d37e4b0cf1a68fd726ec6d645d6d36" + dependencies: + semver "^5.0.3" + +"semver@2 || 3 || 4 || 5", semver@^5.0.3, semver@^5.1.0, semver@^5.3.0: + version "5.3.0" + resolved "https://registry.yarnpkg.com/semver/-/semver-5.3.0.tgz#9b2ce5d3de02d17c6012ad326aa6b4d0cf54f94f" + +signal-exit@^3.0.0: + version "3.0.2" + resolved "https://registry.yarnpkg.com/signal-exit/-/signal-exit-3.0.2.tgz#b5fdc08f1287ea1178628e415e25132b73646c6d" + +slide@^1.1.5: + version "1.1.6" + resolved "https://registry.yarnpkg.com/slide/-/slide-1.1.6.tgz#56eb027d65b4d2dce6cb2e2d32c4d4afc9e1d707" + +source-map-support@^0.4.0: + version "0.4.14" + resolved "https://registry.yarnpkg.com/source-map-support/-/source-map-support-0.4.14.tgz#9d4463772598b86271b4f523f6c1f4e02a7d6aef" + dependencies: + source-map "^0.5.6" + +source-map@^0.5.6: + version "0.5.6" + resolved "https://registry.yarnpkg.com/source-map/-/source-map-0.5.6.tgz#75ce38f52bf0733c5a7f0c118d81334a2bb5f412" + +spdx-correct@~1.0.0: + version "1.0.2" + resolved "https://registry.yarnpkg.com/spdx-correct/-/spdx-correct-1.0.2.tgz#4b3073d933ff51f3912f03ac5519498a4150db40" + dependencies: + spdx-license-ids "^1.0.2" + +spdx-expression-parse@~1.0.0: + version "1.0.4" + resolved "https://registry.yarnpkg.com/spdx-expression-parse/-/spdx-expression-parse-1.0.4.tgz#9bdf2f20e1f40ed447fbe273266191fced51626c" + +spdx-license-ids@^1.0.2: + version "1.2.2" + resolved "https://registry.yarnpkg.com/spdx-license-ids/-/spdx-license-ids-1.2.2.tgz#c9df7a3424594ade6bd11900d596696dc06bac57" + +string-width@^1.0.1: + version "1.0.2" + resolved "https://registry.yarnpkg.com/string-width/-/string-width-1.0.2.tgz#118bdf5b8cdc51a2a7e70d211e07e2b0b9b107d3" + dependencies: + code-point-at "^1.0.0" + is-fullwidth-code-point "^1.0.0" + strip-ansi "^3.0.0" + +string-width@^2.0.0: + version "2.0.0" + resolved "https://registry.yarnpkg.com/string-width/-/string-width-2.0.0.tgz#635c5436cc72a6e0c387ceca278d4e2eec52687e" + dependencies: + is-fullwidth-code-point "^2.0.0" + strip-ansi "^3.0.0" + +string_decoder@~1.0.0: + version "1.0.0" + resolved "https://registry.yarnpkg.com/string_decoder/-/string_decoder-1.0.0.tgz#f06f41157b664d86069f84bdbdc9b0d8ab281667" + dependencies: + buffer-shims "~1.0.0" + +strip-ansi@^3.0.0: + version "3.0.1" + resolved "https://registry.yarnpkg.com/strip-ansi/-/strip-ansi-3.0.1.tgz#6a385fb8853d952d5ff05d0e8aaf94278dc63dcf" + dependencies: + ansi-regex "^2.0.0" + +strip-bom@^2.0.0: + version "2.0.0" + resolved "https://registry.yarnpkg.com/strip-bom/-/strip-bom-2.0.0.tgz#6219a85616520491f35788bdbf1447a99c7e6b0e" + dependencies: + is-utf8 "^0.2.0" + +strip-bom@^3.0.0: + version "3.0.0" + resolved "https://registry.yarnpkg.com/strip-bom/-/strip-bom-3.0.0.tgz#2334c18e9c759f7bdd56fdef7e9ae3d588e68ed3" + +strip-eof@^1.0.0: + version "1.0.0" + resolved "https://registry.yarnpkg.com/strip-eof/-/strip-eof-1.0.0.tgz#bb43ff5598a6eb05d89b59fcd129c983313606bf" + +strip-indent@^1.0.1: + version "1.0.1" + resolved "https://registry.yarnpkg.com/strip-indent/-/strip-indent-1.0.1.tgz#0c7962a6adefa7bbd4ac366460a638552ae1a0a2" + dependencies: + get-stdin "^4.0.1" + +strip-json-comments@^2.0.0, strip-json-comments@~2.0.1: + version "2.0.1" + resolved "https://registry.yarnpkg.com/strip-json-comments/-/strip-json-comments-2.0.1.tgz#3c531942e908c2697c0ec344858c286c7ca0a60a" + +supports-color@3.1.2: + version "3.1.2" + resolved "https://registry.yarnpkg.com/supports-color/-/supports-color-3.1.2.tgz#72a262894d9d408b956ca05ff37b2ed8a6e2a2d5" + dependencies: + has-flag "^1.0.0" + +supports-color@^2.0.0: + version "2.0.0" + resolved "https://registry.yarnpkg.com/supports-color/-/supports-color-2.0.0.tgz#535d045ce6b6363fa40117084629995e9df324c7" + +term-size@^0.1.0: + version "0.1.1" + resolved "https://registry.yarnpkg.com/term-size/-/term-size-0.1.1.tgz#87360b96396cab5760963714cda0d0cbeecad9ca" + dependencies: + execa "^0.4.0" + +timed-out@^3.0.0: + version "3.1.3" + resolved "https://registry.yarnpkg.com/timed-out/-/timed-out-3.1.3.tgz#95860bfcc5c76c277f8f8326fd0f5b2e20eba217" + +timed-out@^4.0.0: + version "4.0.1" + resolved "https://registry.yarnpkg.com/timed-out/-/timed-out-4.0.1.tgz#f32eacac5a175bea25d7fab565ab3ed8741ef56f" + +trim-newlines@^1.0.0: + version "1.0.0" + resolved "https://registry.yarnpkg.com/trim-newlines/-/trim-newlines-1.0.0.tgz#5887966bb582a4503a41eb524f7d35011815a613" + +ts-node@^3.0.2: + version "3.0.2" + resolved "https://registry.yarnpkg.com/ts-node/-/ts-node-3.0.2.tgz#cfc9516c831b920d7efbe16005915062b1294f8c" + dependencies: + arrify "^1.0.0" + chalk "^1.1.1" + diff "^3.1.0" + make-error "^1.1.1" + minimist "^1.2.0" + mkdirp "^0.5.1" + source-map-support "^0.4.0" + tsconfig "^6.0.0" + v8flags "^2.0.11" + yn "^1.2.0" + +tsconfig@^6.0.0: + version "6.0.0" + resolved "https://registry.yarnpkg.com/tsconfig/-/tsconfig-6.0.0.tgz#6b0e8376003d7af1864f8df8f89dd0059ffcd032" + dependencies: + strip-bom "^3.0.0" + strip-json-comments "^2.0.0" + +tslint-config-standard@2.0.0: + version "2.0.0" + resolved "https://registry.yarnpkg.com/tslint-config-standard/-/tslint-config-standard-2.0.0.tgz#8d3255cd2e61b474811773f3c11e040796e46416" + dependencies: + tslint-eslint-rules "^3.0.0" + +tslint-config-typings@^0.3.1: + version "0.3.1" + resolved "https://registry.yarnpkg.com/tslint-config-typings/-/tslint-config-typings-0.3.1.tgz#e095b5b1cab1daca380358276b866129145fbea4" + dependencies: + tslint-config-unional "^0.6.0" + +tslint-config-unional@^0.6.0: + version "0.6.0" + resolved "https://registry.yarnpkg.com/tslint-config-unional/-/tslint-config-unional-0.6.0.tgz#1c1871587fb0024d790f78cf5390b073cd2559db" + dependencies: + tslint-config-standard "2.0.0" + tslint-eslint-rules "3.0.0" + +tslint-eslint-rules@3.0.0, tslint-eslint-rules@^3.0.0: + version "3.0.0" + resolved "https://registry.yarnpkg.com/tslint-eslint-rules/-/tslint-eslint-rules-3.0.0.tgz#42c17e06b4d467cee4268606c6fd455db5822d67" + dependencies: + doctrine "^0.7.2" + tslint "^4.0.0" + +tslint@^4.0.0: + version "4.5.1" + resolved "https://registry.yarnpkg.com/tslint/-/tslint-4.5.1.tgz#05356871bef23a434906734006fc188336ba824b" + dependencies: + babel-code-frame "^6.20.0" + colors "^1.1.2" + diff "^3.0.1" + findup-sync "~0.3.0" + glob "^7.1.1" + optimist "~0.6.0" + resolve "^1.1.7" + tsutils "^1.1.0" + update-notifier "^2.0.0" + +tslint@^5.1.0: + version "5.1.0" + resolved "https://registry.yarnpkg.com/tslint/-/tslint-5.1.0.tgz#51a47baeeb58956fcd617bd2cf00e2ef0eea2ed9" + dependencies: + babel-code-frame "^6.22.0" + colors "^1.1.2" + diff "^3.2.0" + findup-sync "~0.3.0" + glob "^7.1.1" + optimist "~0.6.0" + resolve "^1.3.2" + semver "^5.3.0" + tsutils "^1.4.0" + +tsutils@^1.1.0, tsutils@^1.4.0: + version "1.7.0" + resolved "https://registry.yarnpkg.com/tsutils/-/tsutils-1.7.0.tgz#2e63ccc2d6912bb095f7e363ff4100721dc86f50" + +typescript@^2.2.2: + version "2.2.2" + resolved "https://registry.yarnpkg.com/typescript/-/typescript-2.2.2.tgz#606022508479b55ffa368b58fee963a03dfd7b0c" + +unique-string@^1.0.0: + version "1.0.0" + resolved "https://registry.yarnpkg.com/unique-string/-/unique-string-1.0.0.tgz#9e1057cca851abb93398f8b33ae187b99caec11a" + dependencies: + crypto-random-string "^1.0.0" + +unzip-response@^1.0.2: + version "1.0.2" + resolved "https://registry.yarnpkg.com/unzip-response/-/unzip-response-1.0.2.tgz#b984f0877fc0a89c2c773cc1ef7b5b232b5b06fe" + +unzip-response@^2.0.1: + version "2.0.1" + resolved "https://registry.yarnpkg.com/unzip-response/-/unzip-response-2.0.1.tgz#d2f0f737d16b0615e72a6935ed04214572d56f97" + +update-notifier@^1.0.3: + version "1.0.3" + resolved "https://registry.yarnpkg.com/update-notifier/-/update-notifier-1.0.3.tgz#8f92c515482bd6831b7c93013e70f87552c7cf5a" + dependencies: + boxen "^0.6.0" + chalk "^1.0.0" + configstore "^2.0.0" + is-npm "^1.0.0" + latest-version "^2.0.0" + lazy-req "^1.1.0" + semver-diff "^2.0.0" + xdg-basedir "^2.0.0" + +update-notifier@^2.0.0: + version "2.1.0" + resolved "https://registry.yarnpkg.com/update-notifier/-/update-notifier-2.1.0.tgz#ec0c1e53536b76647a24b77cb83966d9315123d9" + dependencies: + boxen "^1.0.0" + chalk "^1.0.0" + configstore "^3.0.0" + is-npm "^1.0.0" + latest-version "^3.0.0" + lazy-req "^2.0.0" + semver-diff "^2.0.0" + xdg-basedir "^3.0.0" + +url-parse-lax@^1.0.0: + version "1.0.0" + resolved "https://registry.yarnpkg.com/url-parse-lax/-/url-parse-lax-1.0.0.tgz#7af8f303645e9bd79a272e7a14ac68bc0609da73" + dependencies: + prepend-http "^1.0.1" + +user-home@^1.1.1: + version "1.1.1" + resolved "https://registry.yarnpkg.com/user-home/-/user-home-1.1.1.tgz#2b5be23a32b63a7c9deb8d0f28d485724a3df190" + +util-deprecate@~1.0.1: + version "1.0.2" + resolved "https://registry.yarnpkg.com/util-deprecate/-/util-deprecate-1.0.2.tgz#450d4dc9fa70de732762fbd2d4a28981419a0ccf" + +uuid@^2.0.1: + version "2.0.3" + resolved "https://registry.yarnpkg.com/uuid/-/uuid-2.0.3.tgz#67e2e863797215530dff318e5bf9dcebfd47b21a" + +v8flags@^2.0.11: + version "2.1.1" + resolved "https://registry.yarnpkg.com/v8flags/-/v8flags-2.1.1.tgz#aab1a1fa30d45f88dd321148875ac02c0b55e5b4" + dependencies: + user-home "^1.1.1" + +validate-npm-package-license@^3.0.1: + version "3.0.1" + resolved "https://registry.yarnpkg.com/validate-npm-package-license/-/validate-npm-package-license-3.0.1.tgz#2804babe712ad3379459acfbe24746ab2c303fbc" + dependencies: + spdx-correct "~1.0.0" + spdx-expression-parse "~1.0.0" + +which@^1.2.8: + version "1.2.14" + resolved "https://registry.yarnpkg.com/which/-/which-1.2.14.tgz#9a87c4378f03e827cecaf1acdf56c736c01c14e5" + dependencies: + isexe "^2.0.0" + +widest-line@^1.0.0: + version "1.0.0" + resolved "https://registry.yarnpkg.com/widest-line/-/widest-line-1.0.0.tgz#0c09c85c2a94683d0d7eaf8ee097d564bf0e105c" + dependencies: + string-width "^1.0.1" + +wordwrap@~0.0.2: + version "0.0.3" + resolved "https://registry.yarnpkg.com/wordwrap/-/wordwrap-0.0.3.tgz#a3d5da6cd5c0bc0008d37234bbaf1bed63059107" + +wrappy@1: + version "1.0.2" + resolved "https://registry.yarnpkg.com/wrappy/-/wrappy-1.0.2.tgz#b5243d8f3ec1aa35f1364605bc0d1036e30ab69f" + +write-file-atomic@^1.1.2: + version "1.3.3" + resolved "https://registry.yarnpkg.com/write-file-atomic/-/write-file-atomic-1.3.3.tgz#831dd22d491bdc135180bb996a0eb3f8bf587791" + dependencies: + graceful-fs "^4.1.11" + imurmurhash "^0.1.4" + slide "^1.1.5" + +xdg-basedir@^2.0.0: + version "2.0.0" + resolved "https://registry.yarnpkg.com/xdg-basedir/-/xdg-basedir-2.0.0.tgz#edbc903cc385fc04523d966a335504b5504d1bd2" + dependencies: + os-homedir "^1.0.0" + +xdg-basedir@^3.0.0: + version "3.0.0" + resolved "https://registry.yarnpkg.com/xdg-basedir/-/xdg-basedir-3.0.0.tgz#496b2cc109eca8dbacfe2dc72b603c17c5870ad4" + +yallist@^2.0.0: + version "2.1.2" + resolved "https://registry.yarnpkg.com/yallist/-/yallist-2.1.2.tgz#1c11f9218f076089a47dd512f93c6699a6a81d52" + +yn@^1.2.0: + version "1.2.0" + resolved "https://registry.yarnpkg.com/yn/-/yn-1.2.0.tgz#d237a4c533f279b2b89d3acac2db4b8c795e4a63"