New Research: Supply Chain Attack on Axios Pulls Malicious Dependency from npm.Details →
Socket
Book a DemoSign in
Socket

stringmerge

Package Overview
Dependencies
Maintainers
1
Versions
1
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

stringmerge

String Alternating Merge

latest
Source
npmnpm
Version
1.0.0
Version published
Maintainers
1
Created
Source

stringmerge → String Alternating Merge

npm npm wercker status David

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 like
  • dist/stringmerge-browser.js - The browser build includes all the various library dependancies
  • dist/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)

Keywords

string

FAQs

Package last updated on 06 Oct 2017

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts