@uxland/ramda-extensions
TypeScript icon, indicating that this package has built-in type declarations

1.0.3 • Public • Published

UXL Ramda Extensions npm version

Build Status Statements Branches Functions Lines
BuildStatus Statements Branches Functions Lines

Installation

npm i @uxland/ramda-extensions

Usage

Id equality

Checks if input value is equal to object's id

idEq("id")({ id: "id" }); //=> true
idEq("foo")({ id: "id" }); //=> false
idEq(undefined)({ foo: "bar" }); //=> true

Id

Returns property 'id' of object

id({ id: 1 }); //=> 1
id({ foo: "bar" }); //=> undefined

Is not empty

Checks whether input is empty

isNotEmpty(undefined); //=> true
isNotEmpty(1); //=> true
isNotEmpty("1"); //=> true
isNotEmpty(""); //=> false
isNotEmpty([]); //=> false
isNotEmpty(["foo"]); //=> true
isNotEmpty({}); //=> false
isNotEmpty({ foo: "bar" }); //=> true

Is not null neither empty

Checks whether input is not null nor empty

isNotNullNeitherEmpty(undefined); //=> false
isNotNullNeitherEmpty(1); //=> true
isNotNullNeitherEmpty("1"); //=> true
isNotNullNeitherEmpty(""); //=> false
isNotNullNeitherEmpty([]); //=> false
isNotNullNeitherEmpty(["foo"]); //=> true
isNotNullNeitherEmpty({}); //=> false
isNotNullNeitherEmpty({ foo: "bar" }); //=> true

Is not nil

Checks whether input is undefined or null

isNotNil(undefined); //=> false
isNotNil(1); //=> true
isNotNil("1"); //=> true
isNotNil(""); //=> true
isNotNil([]); //=> true
isNotNil(["foo"]); //=> true
isNotNil({}); //=> true
isNotNil({ foo: "bar" }); //=> true

Is null or empty

Checks whether input is null or empty

isNullOrEmpty(undefined); //=> true
isNullOrEmpty(1); //=> true
isNullOrEmpty("1"); //=> true
isNullOrEmpty(""); //=> true
isNullOrEmpty([]); //=> true
isNullOrEmpty(["foo"]); //=> true
isNullOrEmpty({}); //=> true
isNullOrEmpty({ foo: "bar" }); //=> true

Promise.all

Resolves Promise.all

Reject empty

Filters out input of empty values/items

rejectEmpty([]); //=> []
rejectEmpty(["foo", "", {}, { foo: "bar" }, undefined]); //=> [foo,{"foo":"bar"}, undefined]
rejectEmpty({}); //=> {}
rejectEmpty({ foo: "bar", qux: "", quux: undefined }); //=> {foo: 'bar'}

Reject nil or empty

Filters out input of empty or null values/items

rejectEmpty([]); //=> []
rejectEmpty(["foo", "", {}, { foo: "bar" }, undefined]); //=> foo,{"foo":"bar"}
rejectEmpty({}); //=> {}
rejectEmpty({ foo: "bar", qux: "", quux: undefined }); //=> {foo: 'bar'}

Reject nil

Filters out input null or undefined values/items

rejectEmpty([]); //=> []
rejectEmpty(["foo", "", {}, { foo: "bar" }, undefined]); //=> [foo,'',{"foo":"bar"}]
rejectEmpty({}); //=> {}
rejectEmpty({ foo: "bar", qux: "", quux: undefined }); //=> {foo: 'bar', qux: ''}

Array to dictionary by key

Converts an array to dictionary using provided key as reference

toDictionaryBy("id")([
  { id: 1, description: "foo" },
  { id: 2, description: "bar" },
]); //=> {1: {id: 1, description: 'foo'}, 2: {id: 2, description: 'bar'}}

Array to dictionary

Converts an array to dictionary using ID as key

toDictionary([
  { id: 1, description: "foo" },
  { id: 2, description: "bar" },
]); //=> {1: {id: 1, description: 'foo'}, 2: {id: 2, description: 'bar'}}

Path to array

Splits path by '.' into a string array

toPath('foo.bar') => ['foo', 'bar']
toPath('3') => ['3']

Readme

Keywords

none

Package Sidebar

Install

npm i @uxland/ramda-extensions

Weekly Downloads

77

Version

1.0.3

License

BSD-4-Clause

Unpacked Size

47.6 kB

Total Files

32

Last publish

Collaborators

  • avizcaino
  • uxland-admin