Skip to content

Commit

Permalink
fix: forgotten comment in typings source
Browse files Browse the repository at this point in the history
  • Loading branch information
selfrefactor committed Jul 25, 2020
1 parent eb034f8 commit 9e4597e
Show file tree
Hide file tree
Showing 8 changed files with 1,060 additions and 279 deletions.
1,233 changes: 1,006 additions & 227 deletions README.md

Large diffs are not rendered by default.

12 changes: 5 additions & 7 deletions dist/rambda.esm.js
Original file line number Diff line number Diff line change
Expand Up @@ -240,6 +240,10 @@ function chain(fn, list) {
}

function clampFn(min, max, input) {
if (min > max) {
throw new Error('min must not be greater than max in clamp(min, max, value)');
}

if (input >= min && input <= max) return input;
if (input > max) return max;
if (input < min) return min;
Expand Down Expand Up @@ -858,12 +862,6 @@ function forEach(fn, list) {
return list;
}

function fromPairs(listOfPairs) {
const toReturn = {};
listOfPairs.forEach(([prop, value]) => toReturn[prop] = value);
return toReturn;
}

function groupBy(groupFn, list) {
if (arguments.length === 1) return _list => groupBy(groupFn, _list);
const result = {};
Expand Down Expand Up @@ -1839,4 +1837,4 @@ function zipObj(keys, values) {
}, {});
}

export { F, T, add, adjust, all, allPass, always, and, any, anyPass, append, applySpec, assoc, assocPath, both, chain, clamp, clone, complement, compose, concat, cond, converge, curry, curryN, dec, defaultTo, difference, dissoc, divide, drop, dropLast, either, endsWith, equals, filter, find, findIndex, findLast, findLastIndex, flatten, flip, forEach, fromPairs, groupBy, groupWith, has, hasPath, head, identical, identity, ifElse, inc, includes, indexBy, indexOf, init, intersection, intersperse, is, isEmpty, isNil, join, keys, last, lastIndexOf, length, lens, lensIndex, lensPath, lensProp, map, match, mathMod, max, maxBy, maxByFn, mean, median, merge, mergeAll, mergeDeepRight, mergeLeft, min, minBy, minByFn, modulo, multiply, negate, none, not, nth, omit, over, partial, partition, path, pathEq, pathOr, paths, pick, pickAll, pipe, pluck, prepend, product, prop, propEq, propIs, propOr, range, reduce, reject, repeat, replace, reverse, set, slice, sort, sortBy, split, splitEvery, startsWith, subtract, sum, symmetricDifference, tail, take, takeLast, tap, test, times, toLower, toPairs, toString, toUpper, transpose, trim, tryCatch, type, uniq, uniqWith, unless, update, values, view, when, where, whereEq, without, xor, zip, zipObj };
export { F, T, add, adjust, all, allPass, always, and, any, anyPass, append, applySpec, assoc, assocPath, both, chain, clamp, clone, complement, compose, concat, cond, converge, curry, curryN, dec, defaultTo, difference, dissoc, divide, drop, dropLast, either, endsWith, equals, filter, find, findIndex, findLast, findLastIndex, flatten, flip, forEach, groupBy, groupWith, has, hasPath, head, identical, identity, ifElse, inc, includes, indexBy, indexOf, init, intersection, intersperse, is, isEmpty, isNil, join, keys, last, lastIndexOf, length, lens, lensIndex, lensPath, lensProp, map, match, mathMod, max, maxBy, maxByFn, mean, median, merge, mergeAll, mergeDeepRight, mergeLeft, min, minBy, minByFn, modulo, multiply, negate, none, not, nth, omit, over, partial, partition, path, pathEq, pathOr, paths, pick, pickAll, pipe, pluck, prepend, product, prop, propEq, propIs, propOr, range, reduce, reject, repeat, replace, reverse, set, slice, sort, sortBy, split, splitEvery, startsWith, subtract, sum, symmetricDifference, tail, take, takeLast, tap, test, times, toLower, toPairs, toString, toUpper, transpose, trim, tryCatch, type, uniq, uniqWith, unless, update, values, view, when, where, whereEq, without, xor, zip, zipObj };
11 changes: 4 additions & 7 deletions dist/rambda.js
Original file line number Diff line number Diff line change
Expand Up @@ -244,6 +244,10 @@ function chain(fn, list) {
}

function clampFn(min, max, input) {
if (min > max) {
throw new Error('min must not be greater than max in clamp(min, max, value)');
}

if (input >= min && input <= max) return input;
if (input > max) return max;
if (input < min) return min;
Expand Down Expand Up @@ -862,12 +866,6 @@ function forEach(fn, list) {
return list;
}

function fromPairs(listOfPairs) {
const toReturn = {};
listOfPairs.forEach(([prop, value]) => toReturn[prop] = value);
return toReturn;
}

function groupBy(groupFn, list) {
if (arguments.length === 1) return _list => groupBy(groupFn, _list);
const result = {};
Expand Down Expand Up @@ -1886,7 +1884,6 @@ exports.findLastIndex = findLastIndex;
exports.flatten = flatten;
exports.flip = flip;
exports.forEach = forEach;
exports.fromPairs = fromPairs;
exports.groupBy = groupBy;
exports.groupWith = groupWith;
exports.has = has;
Expand Down
11 changes: 4 additions & 7 deletions dist/rambda.umd.js
Original file line number Diff line number Diff line change
Expand Up @@ -246,6 +246,10 @@
}

function clampFn(min, max, input) {
if (min > max) {
throw new Error('min must not be greater than max in clamp(min, max, value)');
}

if (input >= min && input <= max) return input;
if (input > max) return max;
if (input < min) return min;
Expand Down Expand Up @@ -864,12 +868,6 @@
return list;
}

function fromPairs(listOfPairs) {
const toReturn = {};
listOfPairs.forEach(([prop, value]) => toReturn[prop] = value);
return toReturn;
}

function groupBy(groupFn, list) {
if (arguments.length === 1) return _list => groupBy(groupFn, _list);
const result = {};
Expand Down Expand Up @@ -1888,7 +1886,6 @@
exports.flatten = flatten;
exports.flip = flip;
exports.forEach = forEach;
exports.fromPairs = fromPairs;
exports.groupBy = groupBy;
exports.groupWith = groupWith;
exports.has = has;
Expand Down
1 change: 0 additions & 1 deletion files/index.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1274,7 +1274,6 @@ Notes:
*/
// @SINGLE_MARKER
// export function fromPairs<V>(listOfPairs: Array<[string, V]>): { [index: string]: V };
export function fromPairs<V>(listOfPairs: KeyValuePair<string, V>[]): { [index: string]: V };
export function fromPairs<V>(listOfPairs: KeyValuePair<number, V>[]): { [index: number]: V };

Expand Down
64 changes: 36 additions & 28 deletions index.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@ type Merge<O1 extends object, O2 extends object, Depth extends 'flat' | 'deep'>
// RAMBDAX INTERFACES
// ============================================
type Func<T> = (input: any) => T;
type VoidInputFunc<T> = () => T;
type Predicatex<T> = (input: T, index: number) => boolean;
type Fn<In, Out> = (x: In) => Out;
type FnTwo<In, Out> = (x: In, y: In) => Out;
Expand Down Expand Up @@ -111,7 +112,10 @@ type ProduceRules<Input> = {
type ProduceFunctionRule<Input> = (input: Input) => any
type ProduceAsyncRule<Input> = (input: Input) => Promise<any>
type Async<T> = (x: any) => Promise<T>;
type AsyncWithMap<T> = (x: any, i?: number) => Promise<T>;
type AsyncIterable<T, K> = (x: T) => Promise<K>;
type AsyncIterableIndexed<T, K> = (x: T, i: number) => Promise<K>;
type AsyncPredicate<T> = (x: T) => Promise<boolean>;
type AsyncPredicateIndexed<T> = (x: T, i: number) => Promise<boolean>;
type AsyncWithProp<T> = (x: any, prop?: string) => Promise<T>;

export const DELAY: 'RAMBDAX_DELAY'
Expand Down Expand Up @@ -307,7 +311,7 @@ export function converge(after: ((...a: readonly any[]) => any), fns: Array<((..
/**
* It expects a function as input and returns its curried version.
*/
export function curry<F extends (...args: any) => any>(f: F): FunctionToolbelt.Curry<F>;
export function curry(fn: (...args: readonly any[]) => any): (...a: readonly any[]) => any;

/**
* It returns a curried equivalent of the provided function, with the specified arity.
Expand Down Expand Up @@ -338,7 +342,7 @@ export function difference<T>(a: ReadonlyArray<T>): (b: ReadonlyArray<T>) => T[]
* It returns a new object that does not contain property `prop`.
*/
export function dissoc<T>(prop: string, obj: any): T;
export function dissoc(prop: string): <U>(obj: any) => U;
export function dissoc<T>(prop: string): (obj: any) => T;

export function divide(x: number, y: number): number;
export function divide(x: number): (y: number) => number;
Expand Down Expand Up @@ -368,7 +372,9 @@ export function dropLast<T>(howMany: number): {
*
* This `predicate` function will return `true`, if any of the two input predicates return `true`.
*/
export function either(firstPredicate: Pred, secondPredicate: Pred): Pred;
export function either(firstPredicate: Pred, firstPredicate: Pred): Pred;
export function either<T>(firstPredicate: Predicate<T>, secondPredicate: Predicate<T>): Predicate<T>;
export function either<T>(firstPredicate: Predicate<T>): (secondPredicate: Predicate<T>) => Predicate<T>;
export function either(firstPredicate: Pred): (secondPredicate: Pred) => Pred;

/**
Expand Down Expand Up @@ -436,7 +442,7 @@ export function findLastIndex<T>(predicate: (x: T, index: number) => boolean): (
/**
* It deeply flattens an array.
*/
export function flatten<T>(x: ReadonlyArray<T> | ReadonlyArray<T[]> | ReadonlyArray<ReadonlyArray<T>>): T[];
export function flatten<T>(list: ReadonlyArray<any>): T[];

/**
* It returns function which calls `fn` with exchanged first and second argument.
Expand All @@ -447,12 +453,12 @@ export function flip<F extends (...args: any) => any, P extends FunctionToolbelt
/**
* It applies `iterable` function over all members of `list` and returns `list`.
*/
export function forEach<T>(fn: (x: T) => void, list: T[]): T[];
export function forEach<T>(fn: (x: T) => void): (list: T[]) => T[];
export function forEach<T>(fn: (x: T) => void, list: ReadonlyArray<T>): ReadonlyArray<T>;
export function forEach<T>(fn: (x: T) => void): (list: ReadonlyArray<T>) => ReadonlyArray<T>;
export function forEach<T>(fn: (value: T, key: string, obj: { [key: string]: T }) => void, obj: { [key: string]: T }): void;
export function forEach<T>(fn: (value: T, key: string, obj: { [key: string]: T }) => void): (obj: { [key: string]: T }) => void;
export function forEach<T, U>(fn: MapFunctionObject<T, U>, list: Dictionary<T>): Dictionary<T>;
export function forEach<T, U>(fn: MapFunctionArray<T, U>, list: T[]): T[];
export function forEach<T, U>(fn: MapFunctionArray<T, U>): (list: T[]) => T[];
export function forEach<T, U, S>(fn: MapFunctionObject<T, U>): (list: Dictionary<T>) => Dictionary<T>;
export function forEach<T>(fn: MapFunctionArray<T, T>): (list: T[]) => T[];
export function forEach<T>(fn: MapFunctionArray<T, T>, list: ReadonlyArray<T>): T[];

/**
* It transforms a `listOfPairs` to an object.
Expand Down Expand Up @@ -514,8 +520,16 @@ export function identity<T>(input: T): T;
*
* When `fn`` is called with `input` argument, it will return either `onTrue(input)` or `onFalse(input)` depending on `condition(input)` evaluation.
*/
export function ifElse(condition: Pred, onTrue: Arity2Fn, onFalse: Arity2Fn): Arity2Fn;
export function ifElse(condition: Pred, onTrue: Arity1Fn, onFalse: Arity1Fn): Arity1Fn;
export function ifElse<T, U>(
condition: (x: T) => boolean,
onTrue: (x: T) => U,
onFalse: (x: T) => U,
): (x: T) => U;
export function ifElse<T, K, U>(
condition: (x: T, y: K) => boolean,
onTrue: (x: T, y: K) => U,
onFalse: (x: T, y: K) => U,
): (x: T, y: K) => U;

/**
* It increments a number.
Expand Down Expand Up @@ -801,19 +815,13 @@ export function omit<T, U>(propsToOmit: string): (obj: T) => U;
export function omit<T>(propsToOmit: string, obj: object): T;
export function omit<T>(propsToOmit: string): (obj: object) => T;

/**
* It is very similar to `R.curry`, but you can pass initial arguments when you create the curried function.
*
* `R.partial` will keep returning a function until all the arguments that the function `fn` expects are passed.
* The name comes from the fact that you partially inject the inputs.
*/
export function partial<V0, V1, T>(fn: (x0: V0, x1: V1) => T, x0: V0): (x1: V1) => T;
export function partial<V0, V1, V2, T>(fn: (x0: V0, x1: V1, x2: V2) => T, x0: V0, x1: V1): (x2: V2) => T;
export function partial<V0, V1, V2, T>(fn: (x0: V0, x1: V1, x2: V2) => T, x0: V0): (x1: V1, x2: V2) => T;
export function partial<V0, V1, V2, V3, T>(fn: (x0: V0, x1: V1, x2: V2, x3: V3) => T, x0: V0, x1: V1, x2: V2): (x2: V3) => T;
export function partial<V0, V1, V2, V3, T>(fn: (x0: V0, x1: V1, x2: V2, x3: V3) => T, x0: V0, x1: V1): (x2: V2, x3: V3) => T;
export function partial<V0, V1, V2, V3, T>(fn: (x0: V0, x1: V1, x2: V2, x3: V3) => T, x0: V0): (x1: V1, x2: V2, x3: V3) => T;
export function partial<T>(fn: (...a: any[]) => T, ...args: any[]): (...a: any[]) => T;
export function partial<V0, V1, T>(fn: (x0: V0, x1: V1) => T, args: [V0]): (x1: V1) => T;
export function partial<V0, V1, V2, T>(fn: (x0: V0, x1: V1, x2: V2) => T, args: [V0, V1]): (x2: V2) => T;
export function partial<V0, V1, V2, T>(fn: (x0: V0, x1: V1, x2: V2) => T, args: [V0]): (x1: V1, x2: V2) => T;
export function partial<V0, V1, V2, V3, T>(fn: (x0: V0, x1: V1, x2: V2, x3: V3) => T, args: [V0, V1, V2]): (x2: V3) => T;
export function partial<V0, V1, V2, V3, T>(fn: (x0: V0, x1: V1, x2: V2, x3: V3) => T, args: [V0, V1]): (x2: V2, x3: V3) => T;
export function partial<V0, V1, V2, V3, T>(fn: (x0: V0, x1: V1, x2: V2, x3: V3) => T, args: [V0]): (x1: V1, x2: V2, x3: V3) => T;
export function partial<T>(fn: (...a: readonly any[]) => T, args: readonly any[]): (...a: readonly any[]) => T;

/**
* It will return array of two objects/arrays according to `predicate` function. The first member holds all instanses of `input` that pass the `predicate` function, while the second member - those who doesn't.
Expand Down Expand Up @@ -890,8 +898,8 @@ export function pick<T>(propsToPick: string): (input: object) => T;
*/
export function pickAll<T, U>(propsToPick: readonly string[], input: T): U;
export function pickAll<T, U>(propsToPick: readonly string[]): (input: T) => U;
export function pickAll<T, U>(propsToPick: readonly string, input: T): U;
export function pickAll<T, U>(propsToPick: readonly string): (input: T) => U;
export function pickAll<T, U>(propsToPick: string, input: T): U;
export function pickAll<T, U>(propsToPick: string): (input: T) => U;

/**
* It performs left-to-right function composition.
Expand Down
4 changes: 2 additions & 2 deletions source/_typings.spec.js
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
import { spawnSync } from 'child_process'
import isCI from 'is-ci'
import { resolve } from 'path'

jest.setTimeout(3 * 60 * 1000)

const DIR = resolve(__dirname, '../')

test('typings are correct', async () => {
if (isCI) return

Expand Down
3 changes: 3 additions & 0 deletions src/clamp.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,9 @@ import { curry } from './curry'
function clampFn(
min, max, input
){
if (min > max){
throw new Error('min must not be greater than max in clamp(min, max, value)')
}
if (input >= min && input <= max) return input

if (input > max) return max
Expand Down

0 comments on commit 9e4597e

Please sign in to comment.