An ES/JS Stringbuilder utility
| Bundle | ||
| Examples | ||
| src | ||
| tests | ||
| index.js | ||
| LICENSE | ||
| package.json | ||
| README.md | ||
Important
This repository is moved to Codeberg.org.
For now it is kept in sync with the original repository @Github.
Depending on future USA/Microsoft/Github policies the Github version maybe discontinued later.
In other words, starting july 10 2025 the Codeberg repository is authorative.
js-stringweaver
An ES/JS "stringbuilder" utility module. The module delivers a constructor to create mutable strings.
Highlights
- small footprint
- extendable with custom getters/methods
- retains history of changes
- no external dependencies
- instances can use and/or chain native String getters/methods (e.g.
replace,split,length) - 100% test coverage
Documentation
Demonstration / Documentation. Idem @Github
Install module
Use npm install stringweaver to install the module locally.
Import/use (NodeJS or browser client file)
/* notes:
- make sure the script/node project is of type "module"
- the bundled module can be found @ https://unpkg.com/stringweaver/Bundle/index.min.js
- the module is imported as $S here */
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)