lamed_string
AS A "JavaScript developer" I WANT TO HAVE "I want to manage string function in one place" SO THAT I CAN "reap the benefit in all projects"
Part of See it Done
Install
npm
npm i lamed_string -s
yarn
yarn add lamed_string
Usage
Node
const _lstring = require('lamed_string');
Array Functions
Functions | Description |
---|---|
Array.replaceAll(find, replace) | Replace all occurrences of a string in an array. |
Array.toLowerCase() | Change array elements to lower case. |
Array.toUpperCase() | Change array elements to upper case. |
Array.includesAny('???') | Removes all occurrences of a set of strings in an array |
Array.removeAny(Array) | Removes all occurrences of a set of strings in an array |
## Other functions
Functions | Description |
---|---|
'???'.includeAll(???) | Test if all argument items are included in String. If argument is array, the array items will be used. |
'???'.includeAny(???) | Test if any argument items are included in String. If argument is array, the array items will be used. |
'???'.replaceAll(find, replace) | Replace all occurrences of a string |
Date.toStr('/') | Outputs the date as yyyy/mm/dd |
substring_BetweenChars(str, strStart, strEnd) | Returns from str the string between srtStat and strEnd. |
object2Str(object, format = false) | Convert object to string; @param format - if true then format the object string |
Description
'???'.replaceAll(find, replace)
- Replace all occurrences of a string in an array.
Parameter | Description |
---|---|
find | The string to search for |
replace | The string to replace all occurances with |
'hello, there, my, pet.'.replaceAll(',', ''); // hello there my pet.
'???'.toLowerCase()
- Change array elements to lower case.
'HELLO, THERE, MY, PET.'.toLowerCase(',', ''); // hello, there, my, pet.
'???'.toUpperCase()
- Change array elements to upper case.
'hello, there, my, pet.'.toUpperCase(',', ''); // HELLO, THERE, MY, PET.
'???'.includeAll()
- Test if all argument items are included in String. If argument is array, the array items will be used.
/* string parameter */ "absdefg_aa_bb"; //false "absdefg_aa_bb"; //true - This is useful when search items are not provided "absdefg_aa_bb"; //false "absdefg_aa_bb"; //false "absdefg_aa_bb"; //true "absdefg_aa_bb"; //false "absdefg_aa_bb"; //true "absdefg_aa_bb"; //true /* array parameter */ "absdefg_aa_bb"; //true "absdefg_aa_bb"; //true "absdefg_aa_bb"; //false
'???'.includeAny()
- Test if any argument items are included in String. If argument is array, the array items will be used.
/* string parameter */ "absdefg_aa_bb"; //false "absdefg_aa_bb"; //false "absdefg_aa_bb"; //false "absdefg_aa_bb"; //false "absdefg_aa_bb"; //true "absdefg_aa_bb"; //true "absdefg_aa_bb"; //true "absdefg_aa_bb"; //true "absdefg_aa_bb"; //false "absdefg_aa_bb"; //false 'ROUTE'; //false /* array parameter */ "absdefg_aa_bb"; //true "absdefg_aa_bb"; //true "absdefg_aa_bb"; //false