This a library that expose some ramda helpers
With yarn
yarn add ramda-helpers
Whit npm
npm install --save ramda-helpers
You have to import helpers like any other ES6 module
import ramdahelper from 'ramda-helpers'
ramdaHelper.isNilOrEmpty(null) //=> true
returns a list without falsy values
Parameters
Array
Examples
compact(['', 'test', 0, undefined, null]) //=> ['test']
Returns Array
Sort desc a list of nested object by a prop
Parameters
Examples
descOrderBy('a', [{ a:1, b:2 }, { a:2, b:1 }]) //=> [{ a:2, b:1 }, { a:1, b:2 }]
Returns Array
Retrieve the value at the given path
Parameters
Examples
getPath('a.b.c', { a: { b : { c : 'value' } } }) //=> 'value'
getPath(['a', 'b', 'c'], { a: { b : { c : 'value' } } }) //=> 'value'
getPath(['a', 'c', 'd'], { a: { b : { c : 'value' } } }) //=> undefined
Returns any The data at path
Returns true if prop is a Array
Parameters
value
any
Examples
isArray(() => {}) //=> false
isArray({}) //=> false
isArray([]) //=> true
Returns Boolean
Returns true if prop is a function
Parameters
value
any
Examples
isFunction({}) //=> false
isFunction(() => {}) //=> true
Returns Boolean
- See: isPathSatisfied if you want to test nested object
Test if value is NilOrEmpty
Parameters
val
any
Examples
isNilOrEmpty([]) //=> true
isNilOrEmpty({}) //=> true
isNilOrEmpty('') //=> true
isNilOrEmpty(null) //=> true
isNilOrEmpty(false) //=> false
isNilOrEmpty('test') //=> false
isNilOrEmpty(['test']) //=> false
isNilOrEmpty({ a: 1 }) //=> false
Returns bool
- See: isArray
Returns true if prop is not an array
Parameters
value
any
Examples
isNotArray(() => {}) //=> true
isNotArray({}) //=> true
isNotArray([]) //=> false
Returns Boolean
- See: isFunction
Returns true if prop is not a function
Parameters
value
any
Examples
isNotFunction(() => {}) //=> false
isNotFunction({}) //=> true
Returns Boolean
- See: isPlainObject
Returns true if prop is not a plainObject
Parameters
value
any
Examples
isNotPlainObject({}) //=> false
isNotPlainObject(() => {}) //=> true
isNotPlainObject([]) //=> true
Returns Boolean
Returns true
if the specified object property at given path isSet @see isSet
returns false
otherwise
Parameters
Examples
isPathSatisfied('a.b.c', { a: { b: { c: 'c'} } }) //=> true
isPathSatisfied(['a', 'b', 'c'], { a: { b: { c: 'c'} } }) //=> true
isPathSatisfied('a.c.d', { a: { b: { c: 'c'} } }) //=> false
Returns Boolean
Returns true if prop is a plainObject
Parameters
value
any
Examples
isPlainObject({}) //=> true
isPlainObject(() => {}) //=> false
isPlainObject([]) //=> false
Returns Boolean
- See: isNilOrEmpty
Returns true
for value that are defined and not empty, false
otherwise
Parameters
value
any
Examples
isSet([]) //=> false
isSet({}) //=> false
isSet('') //=> false
isSet(null) //=> false
isSet(false) //=> true
isSet('test') //=> true
isSet(['test']) //=> true
isSet({ a: 1 }) //=> true
Returns Boolean
Returns the object which have the greater value by the key, * otherwise returns default object
Parameters
defaultObject
anyArray
Examples
maxByKey('a', { a: 0 }, [{ a: 6 }, { a: 5 }]) //=> { a: 6 }
Returns any
Returns objects with all keys renamed by the predicate (recursivly)
Parameters
Examples
renameByKey(str => `prefix_${str}`, { test: 'test' })
//=> { prefix_test: 'test' }
Returns Object
Returns string in camelCase style
Parameters
str
string
Examples
strToCamelCase('') //=> ''
strToCamelCase('camelCaseString') //=> 'camelCaseString'
strToCamelCase('StrWithUpper') //=> 'strWithUpper'
strToCamelCase('str-with-dashes') //=> 'strWithDashes'
strToCamelCase('Iam@-random/string') //=> 'iamRandomString'
Returns string