8000 GitHub - KooiInc/js-stringweaver: A nifty JS Stringbuilder
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content

KooiInc/js-stringweaver

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

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)

0