Ramda Extensions
npm install @uxland/ramda-extensions| Build Status | Statements | Branches | Functions | Lines |
| ----------------------------------------------- | --------------------------------------------- | ----------------------------------------- | ------------------------------------------- | ----------------------------------- |
| !BuildStatus | !Statements | !Branches | !Functions | !Lines |
npm i @uxland/ramda-extensions
Checks if input value is equal to object's id
``typescript`
idEq("id")({ id: "id" }); //=> true
idEq("foo")({ id: "id" }); //=> false
idEq(undefined)({ foo: "bar" }); //=> true
Returns property 'id' of object
`typescript`
id({ id: 1 }); //=> 1
id({ foo: "bar" }); //=> undefined
Checks whether input is empty
`typescript`
isNotEmpty(undefined); //=> true
isNotEmpty(1); //=> true
isNotEmpty("1"); //=> true
isNotEmpty(""); //=> false
isNotEmpty([]); //=> false
isNotEmpty(["foo"]); //=> true
isNotEmpty({}); //=> false
isNotEmpty({ foo: "bar" }); //=> true
Checks whether input is not null nor empty
`typescript`
isNotNullNeitherEmpty(undefined); //=> false
isNotNullNeitherEmpty(1); //=> true
isNotNullNeitherEmpty("1"); //=> true
isNotNullNeitherEmpty(""); //=> false
isNotNullNeitherEmpty([]); //=> false
isNotNullNeitherEmpty(["foo"]); //=> true
isNotNullNeitherEmpty({}); //=> false
isNotNullNeitherEmpty({ foo: "bar" }); //=> true
Checks whether input is undefined or null
`typescript`
isNotNil(undefined); //=> false
isNotNil(1); //=> true
isNotNil("1"); //=> true
isNotNil(""); //=> true
isNotNil([]); //=> true
isNotNil(["foo"]); //=> true
isNotNil({}); //=> true
isNotNil({ foo: "bar" }); //=> true
Checks whether input is null or empty
`typescript`
isNullOrEmpty(undefined); //=> true
isNullOrEmpty(1); //=> true
isNullOrEmpty("1"); //=> true
isNullOrEmpty(""); //=> true
isNullOrEmpty([]); //=> true
isNullOrEmpty(["foo"]); //=> true
isNullOrEmpty({}); //=> true
isNullOrEmpty({ foo: "bar" }); //=> true
Resolves Promise.all
Filters out input of empty values/items
`typescript`
rejectEmpty([]); //=> []
rejectEmpty(["foo", "", {}, { foo: "bar" }, undefined]); //=> [foo,{"foo":"bar"}, undefined]
rejectEmpty({}); //=> {}
rejectEmpty({ foo: "bar", qux: "", quux: undefined }); //=> {foo: 'bar'}
Filters out input of empty or null values/items
`typescript`
rejectEmpty([]); //=> []
rejectEmpty(["foo", "", {}, { foo: "bar" }, undefined]); //=> foo,{"foo":"bar"}
rejectEmpty({}); //=> {}
rejectEmpty({ foo: "bar", qux: "", quux: undefined }); //=> {foo: 'bar'}
Filters out input null or undefined values/items
`typescript`
rejectEmpty([]); //=> []
rejectEmpty(["foo", "", {}, { foo: "bar" }, undefined]); //=> [foo,'',{"foo":"bar"}]
rejectEmpty({}); //=> {}
rejectEmpty({ foo: "bar", qux: "", quux: undefined }); //=> {foo: 'bar', qux: ''}
Converts an array to dictionary using provided key as reference
`typescript`
toDictionaryBy("id")([
{ id: 1, description: "foo" },
{ id: 2, description: "bar" },
]); //=> {1: {id: 1, description: 'foo'}, 2: {id: 2, description: 'bar'}}
Converts an array to dictionary using ID as key
`typescript`
toDictionary([
{ id: 1, description: "foo" },
{ id: 2, description: "bar" },
]); //=> {1: {id: 1, description: 'foo'}, 2: {id: 2, description: 'bar'}}
Splits path by '.' into a string array
`typescript``
toPath('foo.bar') => ['foo', 'bar']
toPath('3') => ['3']