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
Use npm install stringweaver
to install the module locally.
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>
// 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!"
Use npm test
to run all tests (with coverage report)