reassemble-string

2.0.0 • Public • Published

Coverage Status Build Status Dependency Status npm version Stability: stable

Splits a string (Splitchars: _, -, \s, ., or camelcase) and combines it using a combound function. This is usefull to create functions like camelize, dasherize...

Install

$ npm install --save reassemble-string

Usage

var reassembleString = require('reassemble-string');
 
const camelize = reassembleString((a, b) => a + b.toUpperCase());
const dasherize = reassembleString((a, b) => `${a}-${b}`);
 
camelize('hello-world');   // => "helloWorld"
camelize('hello_world');   // => "helloWorld"
camelize('hello.world');   // => "helloWorld"
camelize('hello - world'); // => "helloWorld"
camelize('hello + world'); // => "hello + world"
dasherize('hello world'); // => "hello-world"
dasherize('helloWorld'); // => "hello-world"

API

reassembleString(combine) -> (string)

reassembleString(combine, string)

combine

Required
Type: function(a, b)

a is the last character of the previous word. b is the first character of the next word lowercased.

You should return a string.

string

Type: string

The string which gets splitted and reassembled.

License

MIT © Christoph Hermann

Versions

Current Tags

  • Version
    Downloads (Last 7 Days)
    • Tag
  • 2.0.0
    0
    • latest

Version History

Package Sidebar

Install

npm i reassemble-string

Weekly Downloads

0

Version

2.0.0

License

MIT

Last publish

Collaborators

  • schtoeffel