@bigbinary/neeto-cist v1.0.9
neeto-cist
A collection of common utility functions used across all our neeto products. Try out the utility functions live at neetoCommons REPL.
Contents
Installation
Install from npm:
yarn add @bigbinary/neeto-cist@latest
Install the peer dependencies:
yarn add ramda
Usage
You can import all functions from @bigbinary/neeto-cist
.
import { slugify } from "@bigbinary/neeto-cist";
Exports several general utility functions that are used throughout neeto products. The functions are designed in a similar fashion as ramda so that they can easily interoperate with each other.
Pure functions were designed to be fail fast. If you call findById(10, null)
,
it will throw error saying that it can't iterate through null
.
But for most such pure functions, there is a failsafe alternative available. The
failsafe alternative function will be prefixed with _
. Example:
_findById(10, null)
returns null
, _findById(10, undefined)
returns
undefined
and _findById(10, [{ id: 10 }])
returns { id: 10 }
.
List of Pure Functions
Name
- findById
- findIndexById
- removeById
- replaceById
- modifyById
- existsById
- findBy
- findIndexBy
- removeBy
- replaceBy
- modifyBy
- existsBy
- findLastBy
- findLastIndexBy
- filterBy
- countBy
- renameKeys
- copyKeys
- copyKeysDeep
- transformObjectDeep
- preprocessForSerialization
- keysToCamelCase
- keysToSnakeCase
- deepFreezeObject
- matches
- filterNonNull
- slugify
- humanize
- snakeToCamelCase
- camelToSnakeCase
- capitalize
- hyphenate
- truncate
- noop
- toLabelAndValue
- getRandomInt
- randomPick
- dynamicArray
- isNotEmpty
- isNot (alias notEquals)
- isNotEqualDeep (alias notEqualsDeep)
- isNotPresent
- isPresent
- modifyWithImmer