stringmerge
v1.0.0
Published
String Alternating Merge
Downloads
3
Readme
stringmerge → String Alternating Merge
Description
Merges multiple strings together alternating through their arguments.
merge :: (...String) → String
merge :: ('abc', '123456') -> 'a1b2c3456'
Install
You can either install stringmerge via npm:
yarn add stringmerge
Alternatively, you can download/copy one of files in the /dist
folder depending on your use-case:
dist/stringmerge.js
- The node build for use with webpack and the likedist/stringmerge-browser.js
- The browser build includes all the various library dependanciesdist/stringmerge-browser.min.js
- The minified version of browser version
Mode of Operation
The default export merge
merges string arguments together via a simple while
loop. Any non-string arguments will be disregarded.
import merge from 'stringmerge'
const mergedString = merge('abc', '123', 123, 'z');
// should(mergeResults).be.eql('a1zb2c3');
Alternatively, you can use the mergeGenerator
export which utilizes a generator to iterate through the arguments. This only makes sense if you have a ridiculous amount of arguments around the ballpark of +25000.
import { mergeGenerator } from 'stringmerge'
const mergedString = mergeGenerator('abc', '123', 123, 'z');
// should(mergeResults).be.eql('a1zb2c3');
Npm Sripts
scripts:
build: 'Builds stringmerge → output dist/'
clean: 'deletes all dist/ files'
commit: 'commitizen commit'
dev: 'webpack watch development'
benchmark: 'runs benchmarks located in __tests__/benchmark.run.js'
test: 'runs test located in __tests__/tests.run.js'
Benchmarks
merge - two arguments x 325,472 ops/sec ±1.10% (91 runs sampled)
mergeGenerator - two arguments x 247,051 ops/sec ±0.50% (90 runs sampled)
merge - ten arguments x 37,848 ops/sec ±0.55% (91 runs sampled)
mergeGenerator - ten arguments x 25,903 ops/sec ±1.96% (89 runs sampled)
merge 50000 - arguments x 0.13 ops/sec ±65.16% (5 runs sampled)
mergeGenerator - 50000 arguments x 0.56 ops/sec ±50.97% (6 runs sampled)