Package Exports
- web-id
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 (web-id) to support the "exports" field. If that is not possible, create a JSPM override to customize the exports field for this package.
Readme
web-id
Convert strings into web-usable ids.
Usage
$ npm install web-idconst WebId = require('web-id');
const webid = new WebId({
prefix: 'wid'
});
const myId = webid.generate('1. László Čapek had déjà vu in the Åland Islands');
// wid-laszlo-capek-had-deja-vu-in-the-aland-islandsProperties
.original - The original, unaltered string.
.id - The web safe id.
webid.id; // laszlo-capek-had-deja-vu-in-the-aland-islands.delimiter or .delim - Get or set the current delimiter. Default is -.
Note that only unreserved characters are allowed: ALPHA / DIGIT / '-' / '.' / '_' / '~'.
webid.delimiter // -
webid.delimiter = '_'; // set the delimiter to _
webid.id; // laszlo_capek_had_deja_vu_in_the_aland_islands
webid.delimiter = '&'; // assertion error.prefix - Set a prefix for the id. Prefixes are run through WebId.cleanString();
webid.prefix = 'myId';
webid.id; // my-id-laszlo-capek-had-deja-vu-in-the-aland-islands
`.iterated` or `.iter` - Get the iterated id (see the `.iterate()` method).
```javascript
webid.iterated // laszlo-capek-had-deja-vu-in-the-aland-islands-1.unique - Get the web safe id with a shortid appended to the end.
webid.unique // laszlo-capek-had-deja-vu-in-the-aland-islands-r1yb6dtneMethods
.iterate() - iterate the id. Retrieve the iterated id with the .iterated or .iter getters. Chainable.
webid.iterate().iterated // laszlo-capek-had-deja-vu-in-the-aland-islands-1
webid.iter // laszlo-capek-had-deja-vu-in-the-aland-islands-1.generate(str) - Generate a web id.
webid.generate('1. László Čapek had déjà vu in the Åland Islands');
// laszlo-capek-had-deja-vu-in-the-aland-islands.generateUnique(str) - (re)generate a unique id by appending a shortid to the .id.
webid.generateUnique('1. László Čapek had déjà vu in the Åland Islands');
// laszlo-capek-had-deja-vu-in-the-aland-islands-ryoBZht3lWebId.cleanString(str) (static) - An intermediary cleanup step that runs lodash functions: trim, lowerCase, deburr, and kebabCase.
WebId.cleanString('1. László Čapek had déjà vu in the Åland Islands');
// 1-laszlo-capek-had-deja-vu-in-the-aland-islands