Global

Members

(constant) debounce

Source:

(constant) debounceLeading

Description:
  • Creates a debounced function which is called on the leading edge of the wait timeout.
Source:
Creates a debounced function which is called on the leading edge of the wait timeout.
Example
debounceLeading(200, () => {});

(constant) debounceTrailing

Description:
  • Creates a debounced function which is called on the trailing edge of the wait timeout.
Source:
Creates a debounced function which is called on the trailing edge of the wait timeout.
Example
debounceTrailing(200, () => {});

(constant) defaultToStrict

Description:
  • TODO: TESTS TODO: DOCS
Source:
TODO: TESTS TODO: DOCS

(constant) dotPath

Description:
  • Gets a prop value using a dot-separated path composed of any combination of prop names and/or array indices.
Source:
Gets a prop value using a dot-separated path composed of any combination of prop names and/or array indices.
Example
dotPath('a.b', { a: { b: 1 } }); // => 1
  dotPath('foo', { foo: 'bar' }); // => 'bar'
  dotPath('a.0', { a: [1, 2, 3] }); // => 1
  dotPath('0', ['foo', 'bar']); // => 'foo'
  dotPath('0.0', [[1, 2, 3]]); // => 1

(constant) dotPathOr

Description:
  • If the given, non-null object has a value at the given dot-separated path, returns the value at that path. Otherwise returns the provided default value. Path can be composed of any combination of prop names and/or array indices.
Source:
See:
If the given, non-null object has a value at the given dot-separated path, returns the value at that path. Otherwise returns the provided default value. Path can be composed of any combination of prop names and/or array indices.
Example
dotPathOr('N/A', 'a.b', { a: { b: 1 } }); // => 1
  dotPathOr('N/A', 'invalid.key', { a: 1 }); // => 'N/A'
  dotPathOr('N/A', 'a.b.0', { a: { b: [1, 2, 3] } }); // => 1
  dotPathOr('N/A', 'a.b.0', { a: { b: 'not an arrray' } }); // => 'N/A'

(constant) ensureStartsWith

Description:
  • Ensures a string / array value starts with the specified prefix. If not, the prefix is prepended to the value.
Source:
Ensures a string / array value starts with the specified prefix. If not, the prefix is prepended to the value.

(constant) eqDotPaths

Description:
  • Useful for doing comparing two objects (e.g. component props or state) to see if a particular property value has changed. Accepts either a standard key name or a dot-separated path for the property to check and does a deep equality check on the property values.
Source:
Useful for doing comparing two objects (e.g. component props or state) to see if a particular property value has changed. Accepts either a standard key name or a dot-separated path for the property to check and does a deep equality check on the property values.

(constant) eqDotPathsShallow

Description:
  • Useful for doing comparing two objects (e.g. component props or state) to see if a particular property value has changed. Accepts either a standard key name or a dot-separated path for the property to check and does a shallow equality check on the property values.
Source:
Useful for doing comparing two objects (e.g. component props or state) to see if a particular property value has changed. Accepts either a standard key name or a dot-separated path for the property to check and does a shallow equality check on the property values.
Example
eqDotPathsShallow('foo', { foo: 1 }, { foo: 1 }); // => true
  eqDotPathsShallow('foo', { foo: 1 }, { foo: 2 }); // => false
  eqDotPathsShallow('a', { a: [1, 2, 3] }, { a: [1, 2, 3] }); // => true
  eqDotPathsShallow('a', { a: { b: [1, 2, 3] } }, { a: { b: [1, 2, 3] } }); // false

(constant) eqPaths

Description:
  • Takes a path to check and two objects and checks if the value at that path is equal for both objects.
Source:
Takes a path to check and two objects and checks if the value at that path is equal for both objects.

(constant) equalsAny

Description:
  • Predicate that checks to see if a value exists in an array.
Source:
Predicate that checks to see if a value exists in an array.
Example
equalsAny([1, 2, 3], 2); // => true
equalsAny(['a', 'b', 'c'], 2); // => false

(constant) equalsShallow

Source:
Example
equalsShallow({ a: 1 }, { a: 1 }); // true
  equalsShallow({ a: 1 }, { a: 2 }); // false
  equalsShallow({ a: { b: 1 } }, { a: { b: 1 } }); // false

(constant) filterMap

Description:
  • Maps an array by the given transform, but only values that pass the given given predicate are transformed and included in the resulting array.
Source:
Maps an array by the given transform, but only values that pass the given given predicate are transformed and included in the resulting array.

(constant) format

Description:
  • Formats a string. Curried version of [`string-format`](https://github.com/davidchambers/string-format). It handles more than I'm indicating in the type signature here. Once you play around with it, feel free to put some more examples and update these docs.
Source:
Formats a string. Curried version of [`string-format`](https://github.com/davidchambers/string-format). It handles more than I'm indicating in the type signature here. Once you play around with it, feel free to put some more examples and update these docs.
Example
format('Hello, {}!', 'Alice');                    // => 'Hello, Alice!'
  compose(format('Hello, {}!'), identity)('Alice'); // => 'Hello, Alice!'

(constant) intersectAny

Description:
  • Finds *any* intersections between any number of lists. TODO: Handle strings that look like numbers. See tests.
Source:
Finds *any* intersections between any number of lists. TODO: Handle strings that look like numbers. See tests.
Example
intersectAny([[1, 2, 3], [5, 6, 9], [3, 9]])            // => [3, 9]
  intersectAny([['foo', 'bar'], ['baz'], ['bar', 'qux']]) // => ['bar']

(constant) isNilOrEmpty

Description:
  • Checks if a value is null, undefined, an empty string, an empty object, an empty array.
Source:
See:
  • R.isNil
  • R.isEmpty
Checks if a value is null, undefined, an empty string, an empty object, an empty array.

(constant) isNot

Description:
  • Checks if a value is not of a certain type (i.e. the opposite of `is`).
Source:
Checks if a value is not of a certain type (i.e. the opposite of `is`).

(constant) isNotEmpty

Description:
  • Returns true if value is non-empty.
Source:
Returns true if value is non-empty.

(constant) isNotNil

Description:
  • Takes a value and returns true if the value is neither null nor undefined; returns false if not.
Source:
Takes a value and returns true if the value is neither null nor undefined; returns false if not.

(constant) isPopulatedString

Description:
  • Checks if a value is both a string and non-empty.
Source:
Checks if a value is both a string and non-empty.
Example
isPopulatedString('foo');   // true
  isPopulatedString('   ');   // true
  isPopulatedString('');      // false
  isPopulatedString(5);       // false
  isPopulatedString(true);    // false

(constant) jsonParseSafe

Description:
  • A safe version of `JSON.parse` that returns an [error, result] tuple instead of throwing an error.
Source:
A safe version of `JSON.parse` that returns an [error, result] tuple instead of throwing an error.
Example
const [error, result] = jsonParseSafe('{ "foo": "bar" }'); // => [null, { foo: 'bar' }]
  const [error, result] = jsonParseSafe('{'); // => [SyntaxError, null]

(constant) keyByWith

Description:
  • A variant of `keyBy` / `indexBy` that accepts getter functions for both the key and the value.
Source:
A variant of `keyBy` / `indexBy` that accepts getter functions for both the key and the value.
Example
const list = [{ key: 'foo', value: 'bar' }, { key: 'a', value: 1 }];
    const result = keyByWith(prop('key'), prop('value'), list); // => { foo: 'bar', a: 1 }

(constant) list

Description:
  • TODO: TESTS TODO: DOCS
Source:
TODO: TESTS TODO: DOCS

(constant) mapFilter

Description:
  • Maps an array by the given transform, but only the transformed values that pass the given predicate are included in the resulting array.
Source:
Maps an array by the given transform, but only the transformed values that pass the given predicate are included in the resulting array.

(constant) mapRejectNil

Description:
  • Maps an array by the given transform, but only the transformed values that are not nil are included in the resulting array.
Source:
Maps an array by the given transform, but only the transformed values that are not nil are included in the resulting array.

(constant) mergeSpec

Description:
  • TODO: TESTS TODO: DOCS
Source:
TODO: TESTS TODO: DOCS

(constant) mergeWithArrays

Description:
  • A merge that also handles arrays.
Source:
A merge that also handles arrays.
Example
mergeWithArrays({
    foo: [1, 2, 3],
    bar: 'first',
    baz: true,
  }, {
    foo: [4, 5],
    bar: 'second',
  });
  // {
  //   foo: [1, 2, 3, 4, 5],
  //   bar: 'second',
  //   baz: true,
  // }

(constant) propOrStrict

Description:
  • TODO: TESTS TODO: DOCS
Source:
TODO: TESTS TODO: DOCS

(constant) rejectNilMap

Description:
  • Maps an array by the given transform, but only values that are not nil are transformed and included in the resulting array.
Source:
Maps an array by the given transform, but only values that are not nil are transformed and included in the resulting array.

(constant) replaceAll

Description:
  • Really, using `R.replace` with regex is fine, but this makes a nice interface.
Source:
Really, using `R.replace` with regex is fine, but this makes a nice interface.
Example
replaceAll(
    '\\n',
    '\n',
    'foo\\nbar\\nbaz\\n',
  );
  // foo\nbar\nbaz\n

(constant) round

Description:
  • Curried FP version of `lodash.round` NOTE: `lodash/fp.round` has a fixed arity of one, therefore a precision cannot be specified.
Source:
See:
  • lodash.round
Curried FP version of `lodash.round` NOTE: `lodash/fp.round` has a fixed arity of one, therefore a precision cannot be specified.

(constant) stringToBoolean

Description:
  • Cast a configuration string to a boolean value by looking for common "truth" directives. All else is false. This is especially useful for deciphering environment variables. See tests for full behavior.
Source:
Cast a configuration string to a boolean value by looking for common "truth" directives. All else is false. This is especially useful for deciphering environment variables. See tests for full behavior.
Example
stringToBoolean('True');    // true
  stringToBoolean(' yes ');   // true
  stringToBoolean('false');   // false
  stringToBoolean('treu');    // false
  stringToBoolean('asdf');    // false

(constant) tap

Description:
  • Runs the given function with the supplied object, then returns the object.
Source:
Runs the given function with the supplied object, then returns the object.
Example
tap((x) => return 'bar')('foo');   // 'foo'
  tap(console.log)('foo');           // 'foo' (and it will have been logged)
  compose(
    split,
    tap((x) => dbRemoveUserByName(x)), // unrelated, but you won't have a handle on this promise
    toLower,
  )('USER NAME');
  // ['u', 's', 'e', 'r', 'n', 'a', 'm', 'e']
  // And the promise will have been kicked off to remove that user by name

(constant) throttle

Source:

(constant) throttleLeading

Source:

(constant) throttleTrailing

Source:

(constant) trace

Description:
  • Effectively a curried `console.log` that also returns it's input.
Source:
Effectively a curried `console.log` that also returns it's input.
Example
trace('The meaning of life: ', 42);   // 42

  pipe(
    identity
    trace('The meaning of life: ')      // 42
    // ...
  )(42)

(constant) tryCatchSafe

Description:
  • A safe version of `try/catch` that returns an [error, result] tuple instead of throwing an error.
Source:
A safe version of `try/catch` that returns an [error, result] tuple instead of throwing an error.
Example
const [error, result] = tryCatchSafe(someFnThatMightThrow, [arg1, arg2]);

(constant) updateKeyPaths

Description:
  • Updates the key paths for a given object according to the provided map of { oldKey: newKey } where `newKey` is an array. Any keys that aren't included in the map will be passed through unchanged.
Source:
Updates the key paths for a given object according to the provided map of { oldKey: newKey } where `newKey` is an array. Any keys that aren't included in the map will be passed through unchanged.
Example
updateKeyPaths({ foo: ['params', 'bar'] }, { foo: 1 }); // => { params: { bar: 1 } }

(constant) updateKeys

Description:
  • Updates the key names for a given object according to the provided map of { oldKey: newKey } where `newKey` is a string. Any keys that aren't included in the map will be passed through unchanged.
Source:
Updates the key names for a given object according to the provided map of { oldKey: newKey } where `newKey` is a string. Any keys that aren't included in the map will be passed through unchanged.
Example
updateKeys({ foo: 'bar' }, { foo: 1 }); // => { bar: 1 }

(constant) updateKeysWith

Description:
  • Updates the keys for an object using the provided function and a map of { oldKey: newKey }. The type of newKey will depend on which function is passed as the first argument (i.e. if you use `assoc` it will expect a string, if you use `assocPath` it will expect an array, etc.)
Source:
Updates the keys for an object using the provided function and a map of { oldKey: newKey }. The type of newKey will depend on which function is passed as the first argument (i.e. if you use `assoc` it will expect a string, if you use `assocPath` it will expect an array, etc.)

(constant) upperCamelCase

Description:
  • Upper-first-camelcase-ify
Source:
Upper-first-camelcase-ify
Example
upperCamelCase('foo-bar-baz') // => 'FooBarBaz'
  upperCamelCase('foo_bar_baz') // => 'FooBarBaz'

(constant) within

Source:

Methods

defer()

Description:
  • Returns a deferred. No longer in the Promise spec (or Bluebird) - but extremely useful. http://bluebirdjs.com/docs/api/deferred-migration.html https://github.com/kriskowal/q/wiki/API-Reference#qdefer
Source:

fpThrow()

Description:
  • Takes an error and immediately throws it. Useful for throwing an error when using pipe, compose, cond, etc. without having to create an anonymous function to throw it. If the given error is not a Error instance then it will be used as the error message and a new Error instance will be created and then thrown. TODO: TESTS
Source:
Throws:
The given error.
Type
Error

nonePass()

Description:
  • Takes a list of predicates and returns a predicate that returns true for a given list of arguments if at none of the provided predicates is satisfied by those arguments. The function returned is a curried function whose arity matches that of the highest-arity predicate.
Source:
Example
const isClub = propEq('♣', 'suit');
  const isSpade = propEq('♠', 'suit');
  const isRedCard = nonePass([isClub, isSpade]);

  isRedCard({ rank: '10', suit: '♣' }); //=> false
  isRedCard({ rank: 'Q', suit: '♠' }); //=> false
  isRedCard({ rank: 'Q', suit: '♦' }); //=> true

noopAsync()

Description:
  • This is async version of noop.
Source:

(async) resolveProps()

Description:
  • Takes an object where the values may be promises and returns an object where all those promises are resolved. If any individual promise is rejected, resolveProps rejects. Similar to http://bluebirdjs.com/docs/api/promise.props.html REASONING: we are trying to no longer use libraries that create their own "Promise" classes with special methods (q/bluebird) - i.e., we want to treat everything like a native promise
Source:

sleep()

Description:
  • An async function that just waits to resolve
Source:

stringify()

Source:
Example
stringify(''); // => "''"
  stringify(true); // => "true"
  stringify(null); // => "null"
  stringify([1, 2, 3]); // => "[1, 2, 3]"
  stringify({ foo: 'bar' }); // => "{ foo: 'bar' }"
  stringify(Symbol('foo')); // => "Symbol(foo)"
  stringify(() => ''); // => "<fn>"