jsmp-infra-transformer

1.0.17 • Public • Published

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:
    1. string || null || undefined;
    2. object || null || undefined:
      • repeat (number)
      • capitalize (boolean)
  • transformArray
    1. array || null || undefined;
    2. 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 }); //['@', '@', '@']

Package Sidebar

Install

npm i jsmp-infra-transformer

Weekly Downloads

17

Version

1.0.17

License

ISC

Unpacked Size

544 kB

Total Files

12

Last publish

Collaborators

  • nirrvaa