mirror of
https://github.com/zhigang1992/DefinitelyTyped.git
synced 2026-04-23 04:49:15 +08:00
* Add xstream * Add bigi * Add uuid-js * Add user-home * Add strip-bom * Add strip-ansi * Add slug * Add safe-regex * Add react-recaptcha * Add is-absolute-url * Add is-archive * Add is-compressed * Add is-relative-url * add is-root-path * Add is-root * Add is-text-path * add os-homedir * Add os-tmpdir * Add path-is-absolute * Add pad * Add number-is-nan * Add node-hid * Add is-finite * is-path-incwd * Add indent-string * Add cpy * Add camelcase-keys * Add blacklist * add http-codes * clamp-js * Add checkstyle-formatter * Add currency-formatter * Add multi-typeof * Add intl-messageformat * Add coinstring * Add ecurve * Add bitcoinjs-lib * Add deep-freeze * Add fuxxaldrin * Add react-body-classname * Add react-highlight-words * Update headers * Fix lint errors * remove xstream * Code review comments * Remove clamp-js in favour of https://github.com/DefinitelyTyped/DefinitelyTyped/pull/13527
41 lines
1.3 KiB
TypeScript
41 lines
1.3 KiB
TypeScript
import slug = require('slug')
|
|
var print = console.log.bind(console, '>')
|
|
|
|
print(slug('i ♥ unicode'))
|
|
// > i-love-unicode
|
|
|
|
print(slug('unicode ♥ is ☢')) // yes!
|
|
// > unicode-love-is-radioactive
|
|
|
|
print(slug('i ♥ unicode', '_')) // If you prefer something else then `-` as seperator
|
|
// > i_love_unicode
|
|
|
|
slug.charmap['♥'] = 'freaking love' // change default charmap or use option {charmap:{…}} as 2. argument
|
|
print(slug('I ♥ UNICODE'))
|
|
// > I-freaking-love-UNICODE
|
|
|
|
print(slug('☏-Number', {lower: true})) // If you prefer lower case
|
|
// > telephone-number
|
|
|
|
print(slug('i <3 unicode'))
|
|
// > i-love-unicode
|
|
|
|
// options is either object or replacement (sets options.replacement)
|
|
slug('string', { } || 'replacement');
|
|
slug.defaults.mode ='pretty';
|
|
slug.defaults.modes['rfc3986'] = {
|
|
replacement: '-', // replace spaces with replacement
|
|
symbols: true, // replace unicode symbols or not
|
|
remove: null, // (optional) regex to remove characters
|
|
lower: true, // result in lower case
|
|
charmap: slug.charmap, // replace special characters
|
|
multicharmap: slug.multicharmap // replace multi-characters
|
|
};
|
|
slug.defaults.modes['pretty'] = {
|
|
replacement: '-',
|
|
symbols: true,
|
|
remove: /[.]/g,
|
|
lower: false,
|
|
charmap: slug.charmap,
|
|
multicharmap: slug.multicharmap
|
|
}; |