@shelf/fast-uslug
TypeScript icon, indicating that this package has built-in type declarations

1.0.0 • Public • Published

fast-uslug CircleCI

It was forked from uslug.

30x faster than uslug.

Permissive slug generator that works with unicode. We keep only characters from the categories Letter, Number and Separator (see Unicode Categories) and the common CJK Unified Ideographs as defined in the version 6.0.0 of the Unicode specification.

Inspired by unicode-slugify. Note that this slug generator is different from node-slug which focus on translating unicode characters to english or latin equivalent.

Install

$ yarn add @shelf/fast-uslug

Usage

import {fastUslug} from '@shelf/fast-uslug';

fastUslug('some string'); // some-string

Quick Examples

import {fastUslug} from '@shelf/fast-uslug';

fastUslug('Ґатунок Їхніх обценьок неперевершений!'); // 'ґатунок-їхніх-обценьок-неперевершений'
fastUslug('汉语/漢語'); // '汉语漢語'

fastUslug('Y U NO', {lower: false}); // 'Y-U-NO'
fastUslug('Y U NO', {spaces: true}); // 'y u no'
fastUslug('Y-U|NO', {allowedChars: '|'}); // 'yu|no'

Benchmark

uslug @shelf/fast-uslug Improvement
10 words: 7 375 ops/s, ±0.19% 10 words: 243 646 ops/s, ±0.19% 33x
100 words: 702 ops/s, ±0.10% 100 words: 22 683 ops/s, ±0.17% 32x
1000 words: 69 ops/s, ±0.17% 1000 words: 2 241 ops/s, ±0.17% 34x

You can run yarn benhmark to test on your own.

Options

fastUslug(string, options)

Generate a slug for the string passed.

Arguments

  • string - The string you want to slugify.
  • options - An optional object that can contain:
    • allowedChars: a Set of chars that you want to be whitelisted. Default: '-_~'.
    • lower: a Boolean to force to lower case the slug. Default: true.
    • spaces: a Boolean to allow spaces. Default: false.

See Also

Publish

$ git checkout master
$ yarn version
$ yarn publish
$ git push origin master --tags

License

MIT © Shelf

Readme

Keywords

none

Package Sidebar

Install

npm i @shelf/fast-uslug

Weekly Downloads

401

Version

1.0.0

License

MIT

Unpacked Size

165 kB

Total Files

27

Last publish

Collaborators

  • vladmarchuk
  • vadymaslovskyi
  • marianna-milovanova
  • petro.bodnarchuk
  • kateryna-kochina
  • maksym.tarnavskyi
  • andrii-nastenko
  • mykhailo.yatsko
  • ahavrysh
  • nikita_shelf
  • maciej.orlowski
  • monopotan
  • andrew214
  • bogdan.kolesnyk
  • kristina.zhak
  • anton-russo
  • mmazurowski
  • mateuszgajdashelf
  • kchlon
  • dmytro.harazdovskiy
  • duch0416
  • i5adovyi
  • olesiamuller
  • mykola.khytra
  • yuliiakovalchuk
  • el_scrambone
  • bodyaflesh
  • andriisermiahin
  • mpushkin
  • batovpavlo
  • domovoj
  • vozemer
  • oleksii.dymnich
  • dima-bond
  • maksym.hayovets
  • oles.zadorozhnyy
  • ss1l
  • gemshelf
  • hartzler
  • vladgolubev
  • hmelenok
  • knupman
  • maaraanas
  • terret
  • chapelskyi.slavik
  • pihorb
  • irynah
  • diana.kryskuv
  • andy.raven
  • rafler
  • sskalp88
  • demiansua
  • yuriil
  • ktv18
  • drews_abuse
  • rostyslav-horytskyi
  • whodeen