str-reduce
v1.0.0
Published
Reduce concurrent characters in string
Downloads
1
Maintainers
Readme
str-reduce
A dependency free way of reducing adjacent characters in a string limited by an amount.
Install
$ npm install --save str-reduce
Usage
const strReduce = require('str-reduce');
strReduce('aaabb', 2);
//=> 'aabb'
strReduce('AAaaaBBbb', 2);
//=> AAaaBBbb
strReduce('this will reduce duplicate characters', 1)
//=> 'this wil reduce duplicate characters'
strReduce('****************************', 6)
//=> '******'
API
strReduce(str, amount)
Takes in a str
of type string
and an amount
of type number
.
Returns a string
of the reduced str
where any same adacent characters are limited to the amount
specificed.
Tests
Clone the project and run npm test
in project root.
License
MIT © Lukasz Brodowski