stringweaver

1.3.1 • Public • Published

js-stringweaver - a js-stringbuilder

A JS "stringbuilder" module

A constructor to create mutable strings.

  • small footprint
  • extendable with custom getters/methods
  • retains history of changes
  • no external dependencies
  • instances can use/chain native String getters/methods (e.g. length, split)
  • 100% test coverage

Demonstration / Documentation

Install module

Use npm install stringweaver to install the module locally.

In browser

In html

  <script type="module" src="[location of index.js or index.min.js]"></script>
  <!-- OR load minified directly from unpkg -->
  <script
      type="module"
      src="https://app.unpkg.com/stringweaver@latest/files/Bundle/index.min.js">
  </script>

Import/use (NodeJS or browser client file)

// note: for NodeJS, make sure the project is of type "module"
// import as $S
import $S from "[location of index.js or Bundle/index.min.js]";
// assign the symbolic string extension
const SB = Symbol.toSB;
const myBrandNewString = $S`Hello`.append(" world");
const myNextString = "** "[SB].append(myBrandNewString).toUpperCase().append(`!`);
// myBrandNewString => "Hello world"
// myNextString => "** HELLO WORLD!"

Unit testing

Use npm test to run all tests (with coverage report)

Package Sidebar

Install

npm i stringweaver

Weekly Downloads

342

Version

1.3.1

License

MIT

Unpacked Size

163 kB

Total Files

13

Last publish

Collaborators

  • kooiinc