text
Source: contracts.js:101
A grab-bag of pure string utilities.
String helpers used across Forge.
Static Methods
slugify(input) -> string
static
contracts.js:110Convert a string to a URL-friendly slug.
Parameters
input(string) — The string to slugify.
Returns
string— A lowercase, hyphenated slug.
Example
CODE
text.slugify('Hello World'); // => 'hello-world'truncate(input, max) -> string
static
contracts.js:121Truncate a string to max characters, appending an ellipsis.
Parameters
input(string) — The string to shorten.max(number, optional, default: 80) — Maximum length before truncation.
Returns
string— The truncated string.
seedCache(entries, options) -> Cache
static
cache.js:204Create a Cache pre-populated from an object of key/value pairs.
This is a global function (no @memberof), so it appears on the aggregated Globals page rather than owning its own page.
Parameters
entries(Object.<string, *>) — Initial entries to seed the cache with.options(CacheOptions, optional) — Options forwarded to the Cache constructor.
Returns
Cache— A new, seeded cache.
Example
CODE
const cache = createCache({ a: 1, b: 2 }, { maxSize: 10 });
cache.get('b'); // => 2- Since: 1.0.0