jsmp-infra-transformer
v1.0.17
Published
helps to transform strings and arrays
Downloads
4
Maintainers
Readme
#SJMP-INFRA-TRANSFORMER
This package is my hometask. Don't download it! But if you want, yo could, why not?
#DESCRIPTION
Has a set of two pure functions, which take string (transformString) orarray (transformArray).
- transformString arguments:
- string || null || undefined;
- object || null || undefined:
- repeat (number)
- capitalize (boolean)
- transformArray
- array || null || undefined;
- object || null || undefined:
- newLength (number)
- placeholder (string)
#INSTALLATION
try npm i jsmp-infra-transformer -S
or yarn add jsmp-infra-transformer
#EXAMPLES
You need to import this package into your project
import transformer from 'jsmp-infra-transformer'; //ES6 modules
const transformer = require('jsmp-infra-transformer'); //Old-fashioned syntax
Next you could just use it like this:
const string = 'Hello!';
const transformedString = transformer.transform(string, { repeat: 2 }); // Hello!Hello!
const string = 'heLLO!';
const transformedString = transformer.transform(string, { capitlize: true }); // Hello!
const string = 'hello!';
const transformedString = transformer.transform(string, { repeat: 2, capitlize: true }); // Hello!hello!
const array = [];
const transformedArray = transformer.transform(array, { newLength: 2 }); //[empty × 2]
const array = ['somedata', 'someAnotherData'];
const transformedArray = transformer.transform(array, { placeholder: '@' }); //['@', '@']
const array = ['somedata', 'someAnotherData'];
const transformedArray = transformer.transform(array, { placeholder: '@', newLength: 3 }); //['@', '@', '@']