Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update version #10

Merged
merged 5 commits into from
Dec 9, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@

[![build status](https://img.shields.io/travis/tommmyy/ramda-extension/master.svg?style=flat-square)](https://travis-ci.org/tommmyy/ramda-extension)

[See the docs page](https://ramda-extension.firebaseapp.com)

Library that adds utilities functions composed mainly on the top of the marvelous [Ramda](http://ramdajs.com) library.

Most of the functions have its own tests and examples in the JS Doc.
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "ramda-extension",
"version": "0.1.0",
"version": "0.1.1",
"repository": {
"type": "git",
"url": "https://github.com/tommmyy/ramda-extension.git"
Expand Down
7 changes: 4 additions & 3 deletions src/alwaysEmptyArray.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,14 @@ import { emptyArray } from './internal';

/**
* Always returns empty array.
*
* @func
* @category Function
*
* @example
*
* alwaysEmptyArray() // []
* R_.alwaysEmptyArray() // []
*
* @sig a -> [a]
*/
export default always(emptyArray);
const alwaysEmptyArray = always(emptyArray);
export default alwaysEmptyArray;
7 changes: 4 additions & 3 deletions src/alwaysEmptyObject.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,14 @@ import { emptyObject } from './internal';

/**
* Always returns empty object.
*
* @func
* @category Function
*
* @example
*
* alwaysEmptyObject() // {}
* R_.alwaysEmptyObject() // {}
*
* @sig a -> [a]
*/
export default always(emptyObject);
const alwaysEmptyObject = always(emptyObject);
export default alwaysEmptyObject;
7 changes: 4 additions & 3 deletions src/alwaysEmptyString.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,14 @@ import { emptyString } from './internal';

/**
* Always returns empty string.
*
* @func
* @category Function
*
* @example
*
* alwaysEmptyString() // ''
* R_.alwaysEmptyString() // ''
*
* @sig a -> String
*/
export default always(emptyString);
const alwaysEmptyString = always(emptyString);
export default alwaysEmptyString;
7 changes: 4 additions & 3 deletions src/alwaysNull.js
Original file line number Diff line number Diff line change
@@ -1,13 +1,14 @@
import { always } from 'ramda';
/**
* Always returns null.
*
* @func
* @category Function
*
* @example
*
* alwaysNull() // null
* R_.alwaysNull() // null
*
* @sig a -> Object
*/
export default always(null);
const alwaysNull = always(null);
export default alwaysNull;
5 changes: 3 additions & 2 deletions src/argumentsToList.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import { unapply, identity } from 'ramda';

/**
* Converts arguments to list.
*
* @func
* @category Function
*
* @example
Expand All @@ -11,4 +11,5 @@ import { unapply, identity } from 'ramda';
*
* @sig (a, b, c, ...) → ([a, b, c, ...])
*/
export default unapply(identity);
const argumentsToList = unapply(identity);
export default argumentsToList;
5 changes: 3 additions & 2 deletions src/assocDotPath.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import overHead from './overHead';
* 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.
*
* @func
* @category Object
* @param {String} path the dot path to set
* @param {*} val The new value
Expand All @@ -20,4 +20,5 @@ import overHead from './overHead';
* // Any missing or non-object keys in path will be overridden
* R_.assocDotPath(['a', 'b', 'c'], 42, {a: 5}); //=> {a: {b: {c: 42}}}
*/
export default curryN(2, compose(apply(assocPath), overHead(splitByDoth), argumentsToList));
const assocDotPath = curryN(2, compose(apply(assocPath), overHead(splitByDoth), argumentsToList));
export default assocDotPath;
7 changes: 4 additions & 3 deletions src/constructRegExp.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,13 @@ import { constructN } from 'ramda';

/**
* Constructs RegExp.
*
* @func
* @category Function
*
* @example
*
* test(constructRegExp('end$', 'gi'), 'in the end') // true
* test(R_.constructRegExp('end$', 'gi'), 'in the end') // true
*
*/
export default constructN(2, RegExp);
const constructRegExp = constructN(2, RegExp);
export default constructRegExp;
9 changes: 5 additions & 4 deletions src/containsAll.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { curry, compose, isEmpty, difference } from 'ramda';
/**
* Resolves to true if all elements in first list are found within the second list
*
* @func
* @category List
*
*
Expand All @@ -11,10 +11,11 @@ import { curry, compose, isEmpty, difference } from 'ramda';
*
* @example
*
* containsAll(['a', 'b'], ['a', 'b', 'c']) // true
* containsAll(['a', 'b', 'd'], ['a', 'b', 'c']) // false
* R_.containsAll(['a', 'b'], ['a', 'b', 'c']) // true
* R_.containsAll(['a', 'b', 'd'], ['a', 'b', 'c']) // false
*
* @sig [a] -> [a] -> Boolean
*
*/
export default curry(compose(isEmpty, difference));
const containsAll = curry(compose(isEmpty, difference));
export default containsAll;
9 changes: 5 additions & 4 deletions src/containsAny.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import {curry, compose, not, isEmpty, intersection } from 'ramda';
/**
* Returns `true` if any of the items from first array are in the second array.
*
* @func
* @category List
*
* @param {Array} List
Expand All @@ -10,10 +10,11 @@ import {curry, compose, not, isEmpty, intersection } from 'ramda';
*
* @example
*
* containsAny(['a', 'e'], ['a', 'b', 'c']) // true
* containsAny(['e', 'f'], ['a', 'b', 'c']) // false
* R_.containsAny(['a', 'e'], ['a', 'b', 'c']) // true
* R_.containsAny(['e', 'f'], ['a', 'b', 'c']) // false
*
* @sig [a] -> [a] -> Boolean
*
*/
export default curry(compose(not, isEmpty, intersection));
const containsAny = curry(compose(not, isEmpty, intersection));
export default containsAny;
9 changes: 5 additions & 4 deletions src/containsNone.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import { curry, compose, isEmpty, intersection } from 'ramda';

/**
* Returns `true` if any of the items from first array is not the second array.
*
* @func
* @category List
*
* @param {Array} List
Expand All @@ -11,9 +11,10 @@ import { curry, compose, isEmpty, intersection } from 'ramda';
*
* @example
*
* containsNone(['e', 'f'], ['a', 'b', 'c']) // true
* containsNone(['a', 'f'], ['a', 'b', 'c']) // false
* R_.containsNone(['e', 'f'], ['a', 'b', 'c']) // true
* R_.containsNone(['a', 'f'], ['a', 'b', 'c']) // false
*
* @sig [a] -> [a] -> Boolean
*/
export default curry(compose(isEmpty, intersection));
const containsNone = curry(compose(isEmpty, intersection));
export default containsNone;
9 changes: 5 additions & 4 deletions src/dispatch.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,14 +4,15 @@ import findNotNil from './findNotNil';
/**
* Returns result of first not nil evaluated functions in the list.
* Undefined otherwise.
*
* @func
* @category Function
*
* @example
*
* dispatch([R.always(null), R.identity, R.always(null)], 3) // 3
* dispatch([R.always(null), R.identity, R.always(null)], null) // undefined
* R_.dispatch([R.always(null), R.identity, R.always(null)], 3) // 3
* R_.dispatch([R.always(null), R.identity, R.always(null)], null) // undefined
*
* @sig [a] -> b|undefined
*/
export default useWith(compose(findNotNil, call), [juxt, identity]);
const dispatch = useWith(compose(findNotNil, call), [juxt, identity]);
export default dispatch;
5 changes: 3 additions & 2 deletions src/dissocDotPath.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import overHead from './overHead';
/**
* Makes a shallow clone of an object, omitting the property at the given dot path. Note that this copies and flattens
* prototype properties onto the new object as well. All non-primitive properties are copied by reference.
*
* @func
* @category Object
*
* @param {String} path The dot path to the value to omit
Expand All @@ -16,4 +16,5 @@ import overHead from './overHead';
*
* R_.dissocDotPath('a.b.c', {a: {b: {c: 42}}}); //=> {a: {b: {}}}
*/
export default curryN(2, compose(apply(dissocPath), overHead(splitByDot), argumentsToList));
const dissocDotPath = curryN(2, compose(apply(dissocPath), overHead(splitByDot), argumentsToList));
export default dissocDotPath;
5 changes: 3 additions & 2 deletions src/dotPath.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import overHead from './overHead';

/**
* Retrieve the value at a given dot path.
*
* @func
* @category Object
* @param {String} path The dot path to use.
* @param {Object} obj The object to retrieve the nested property from.
Expand All @@ -15,4 +15,5 @@ import overHead from './overHead';
* R_.dotPath('a.b', {a: {b: 2}}); //=> 2
* R_.dotPath('a.b', {c: {b: 2}}); //=> undefined
*/
export default curryN(2, compose(apply(path), overHead(splitByDoth), argumentsToList));
const dotPath = curryN(2, compose(apply(path), overHead(splitByDoth), argumentsToList));
export default dotPath;
11 changes: 6 additions & 5 deletions src/endsWithSuffix.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ const getRegExp_ = useWith(flip(constructRegExp)('gi'), [flip(concat)('$')]);

/**
* Testing string if ends with some suffix.
*
* @func
* @category String
*
* @param {string} suffix
Expand All @@ -15,10 +15,11 @@ const getRegExp_ = useWith(flip(constructRegExp)('gi'), [flip(concat)('$')]);
*
* @example
*
* endsWithPrefix('o', 'hello') // true
* endsWithPrefix('ello', 'hello') // true
* endsWithPrefix('y', 'good bye') // false
* R_.endsWithSuffix('o', 'hello') // true
* R_.endsWithSuffix('ello', 'hello') // true
* R_.endsWithSuffix('y', 'good bye') // false
*
* @sig a -> b -> Boolean
*/
export default useWith(test, [getRegExp_, identity]);
const endsWithSuffix = useWith(test, [getRegExp_, identity]);
export default endsWithSuffix;
15 changes: 14 additions & 1 deletion src/equalsEmptyString.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,19 @@ import { equals } from 'ramda';
import { emptyString } from './internal';

/**
* Testing if function is equals to ''
* @func
* @category String
*
* @param {string} string
* @return {boolean} True if string is empty
*
* @example
*
* R_.equalsEmptyString('') // true
* R_.equalsEmptyString('hi') // false
*
* @sig a -> Boolean
*/
export default equals(emptyString);
const equalsEmptyString = equals(emptyString);
export default equalsEmptyString;
11 changes: 6 additions & 5 deletions src/equalsZero.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,15 +3,16 @@ import { equals } from 'ramda';

/**
* Returns true if argument equals 0.
*
* @func
* @category Math
*
* @example
*
* equalsZero(3) // false
* equalsZero(0) // true
* equalsZero(-3) // false
* R_.equalsZero(3) // false
* R_.equalsZero(0) // true
* R_.equalsZero(-3) // false
*
* @sig Number -> Boolean
*/
export default equals(0);
const equalsZero = equals(0);
export default equalsZero;
7 changes: 4 additions & 3 deletions src/findNotNil.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,14 +3,15 @@ import notNil from './notNil';

/**
* Returns first not nil value
*
* @func
* @category List
*
* @example
*
* findNotNil([null, undefined, 0, true]) // 0
* R_.findNotNil([null, undefined, 0, true]) // 0
*
* @sig [a] -> a
*
*/
export default find(notNil);
const findNotNil = find(notNil);
export default findNotNil;
9 changes: 5 additions & 4 deletions src/isArray.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,15 @@ import { is } from 'ramda';

/**
* Returns true if argument is type of Array.
*
* @func
* @category Type
*
* @example
*
* isArray([]) // true
* isArray('') // false
* R_.isArray([]) // true
* R_.isArray('') // false

* @sig a -> Boolean
*/
export default is(Array);
const isArray = is(Array);
export default isArray;
13 changes: 7 additions & 6 deletions src/isFunction.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,17 +2,18 @@ import { is } from 'ramda';

/**
* Returns true if argument is type of Function.
*
* @func
* @category Type
*
* @example
*
* isFunction(() => {}) // true
* isFunction({}) // false
* isFunction([]) // false
* isFunction('') // false
* R_.isFunction(() => {}) // true
* R_.isFunction({}) // false
* R_.isFunction([]) // false
* R_.isFunction('') // false
*
* @sig a -> Boolean
*
*/
export default is(Function);
const isFunction = is(Function);
export default isFunction;
Loading