jsmp-infra-modash
v1.0.2
Published
Handy functions for arrays and strings manipulation
Downloads
1
Maintainers
Readme
jsmp-infra-modash
This package allows you to use handy functions for arrays and strings manipulation.
Getting Started
npm install jsmp-infra-modash
After the package has been installed you can start using all the handy functions. Usage is simple: import and use. Here is an example:
const { removeFromStr } = require('jsmp-infra-modash');
removeFromStr('hello123', 'numbers'); // hello
Documentation
flattenArrays
flattenArrays(...arrays)
Arguments:
- arrays: any number of arrays that have nested arrays inside them.
Returns:
- array: all passed arrays are merged into one and flattened. All arguments should be typeof arrays, if not - the error will be thrown.
Example:
flattenArrays([1, [2]], [[2, 3]]); // [1, 2, 2, 3]
removeFromStr
removeFromStr(str, target = 'whitespace')
Arguments:
- str: string that will be formatted. Should be typeof string or error will be thrown.
- target: optional string (default value: 'whitespace') accepts a keyword which defines how string will be formatted. Allowed keyword values:
'whitespace'
,'numbers'
. If keyword is unknown, error will be thrown.
Returns:
- string: formatting chosen by a keyword is applied. If target is
'whitespace'
: all whitespace will be removed from string. If target'numbers'
: all numbers will be removed from string.
Example:
removeFromStr('h e l l o'); // 'hello'
removeFromStr(1hel23l4o); // 'hello'