Study project
npm install jsmp-infra-array-string-modifier!jsmp-infra-array-string-modifier
##jsmp-infra-array-string-modifier
A small library without deep sense for JavaScript.
##Info
package npm link
bash
$ npm install --save jsmp-infra-array-string-modifier
`
`js
var ASModifier = require('jsmp-infra-array-string-modifier');
`
ES6 module:
`js
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
`js
//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
`bash
$ npm test
`
or at the test directory using Node
`bash
$ node test
`
Build
Run npm run compile to compile code from ES6 to ES5
`bash
npm run compile
`
Watch
Run npm run watch to compile code from ES6 to ES5 when code changed
`bash
npm run watch
``