jsmp-infra-array-string-modifier v1.0.5
##jsmp-infra-array-string-modifier
A small library without deep sense for JavaScript.
##Info package npm link
Features
- Arrays of objects and strings
- Replicates the unique method of JavaScript arrays of objects
- Transform strings with separator
- Prevent saving same names in array of objects
- Faster, smaller, and perhaps easier to use
Load
Run npm install to install all package
$ npm install --save jsmp-infra-array-string-modifier
var ASModifier = require('jsmp-infra-array-string-modifier');
ES6 module:
import { modifyArray } from 'jsmp-infra-array-string-modifier';
import { modifyString } from 'jsmp-infra-array-string-modifier';
Use
In all examples below, const let
, semicolons and toString
calls are not shown.
#####modifyArray modifyArray method takes 2 argument: initial array, and name, that should be added to array, if is not exist in it
#####modifyString modifyString method takes 2 argument: initial string with spaces, and separator, on which will be replaced all spaces in string
//array
initialArray = [{id: 0, name: 'Leek'}]
uniqValArray = modifyArray(initialArray, 'Tom') // [{id: 0, name: 'Leek'}, {id: 0, name: 'Tom'}]
uniqValArray2 = modifyArray(uniqValArray, 'Leek') // [{id: 0, name: 'Leek'}, {id: 1, name: 'Tom'}]
uniqValArray3 = modifyArray(uniqValArray) // [{id: 0, name: 'Leek'}, {id: 1, name: 'Tom'}, {id: 2, name: 'Jane'}]
//string
initialString = 'test awesome and not informative string'
transformedString = modifyString(initialString, '%') //'test%awesome%and%not%informative%string'
transformedString = modifyString(initialString) //'test!awesome!and!not!informative!string'
Test
The library can be tested using Node.js or a browser. To run all the tests, from a command-line at the root directory using npm
$ npm test
or at the test directory using Node
$ node test
Build
Run npm run compile to compile code from ES6 to ES5
npm run compile
Watch
Run npm run watch to compile code from ES6 to ES5 when code changed
npm run watch