0.0.1 • Published 7 years ago

string-split-join v0.0.1

Weekly downloads
970
License
MIT
Repository
github
Last release
7 years ago

string-split-join

Build Status codecov npm version devDependency Status GitHub issues GitHub stars GitHub license

Table of contents

About

StringUtils for splitting and joining strings with support for separatorCharacter and escapeCharacter.

Installation

Install through npm:

npm install --save string-split-join

Use it like:

import { StringUtils } from 'string-split-join';

export class Test {
  public test(): void {
    let result: string;

    // Joining
    result = StringUtils.join([ 'a', 'b', ':c', 'd']); // 'a:b:\\:c:d'
    result = StringUtils.join([ 'a', 'b', ':c', 'd'], { escapeChar: '$' });  // 'a:b:$:c:d'
    result = StringUtils.join([ 'a', 'b', '|c', 'd'], { separatorChar: '|', escapeChar: '$' }); // 'a|b|$|c|d'

    // Splitting
    let results: [];
    results = StringUtils.split('a:b:\\:c:d'); // ['a', 'b', ':c', 'd' ]
    results = StringUtils.split('a|b|c|d', { separatorChar: '|' }); // ['a', 'b', 'c', 'd' ]
    results = StringUtils.split('a|b|$|c|d', { separatorChar: '|', escapeChar: '$' }); // ['a', 'b', '|c', 'd' ]
  }
}

Usage without a module bundler

<script src="node_modules/string-split-join/bundles/string-split-join.umd.js"></script>
<script>
    // everything is exported StringUtils namespace
</script>

Documentation

All documentation is auto-generated from the source via compodoc and can be viewed here: https://StefH.github.io/string-split-join/docs/

Development

Prepare your environment

  • Install Node.js and yarn
  • Install local dev dependencies: yarn while current directory is this repo

Development server

Run yarn start to start a development server on port 8000 with auto reload + tests.

Testing

Run yarn test to run tests once or yarn run test:watch to continually run tests.

Release

  • Bump the version in package.json (once the module hits 1.0 this will become automatic)
yarn run release

License

MIT