Package Exports
- @ultraq/string-utils
- @ultraq/string-utils/string-utils.cjs.js
- @ultraq/string-utils/string-utils.es.js
This package does not declare an exports field, so the exports above have been automatically detected and optimized by JSPM instead. If any package subpath is missing, it is recommended to post an issue to the original package (@ultraq/string-utils) to support the "exports" field. If that is not possible, create a JSPM override to customize the exports field for this package.
Readme
string-utils
A collection of utilities for JavaScript strings.
Installation
Via npm:
npm install @ultraq/string-utils
API
escapeHtml(string)
Escapes special HTML characters in a string with their entity code equivalents. Returns a string safe to use as text within an HTML document.
- string: string to escape.
format(template, ...values)
Returns the replacement of each placeholder in a template string with a corresponding replacement value.
- template: String containing indexed (
{0}
,{1}
, ...) or named ({value}
,{greeting}
, ...) placeholders, but not both. wheren
is the corresponding index value to have filled-in. - ...values: Either an argument list / array of values to replace values in an indexed template string, or an object where the keys are the names in a named template string to replace with their values.