Skip to content

Commit

Permalink
Meta tweaks
Browse files Browse the repository at this point in the history
  • Loading branch information
sindresorhus committed May 7, 2020
1 parent 1be97b4 commit 3e3f7ed
Show file tree
Hide file tree
Showing 4 changed files with 38 additions and 38 deletions.
68 changes: 34 additions & 34 deletions index.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -114,33 +114,6 @@ declare namespace slugify {
}

declare const slugify: {
/**
Slugify a string.
@param string - String to slugify.
@example
```
import slugify = require('@sindresorhus/slugify');
slugify('I ♥ Dogs');
//=> 'i-love-dogs'
slugify(' Déjà Vu! ');
//=> 'deja-vu'
slugify('fooBar 123 $#%');
//=> 'foo-bar-123'
slugify('я люблю единорогов');
//=> 'ya-lyublyu-edinorogov'
```
*/
(
string: string,
options?: slugify.Options
): string;

/**
Returns a new instance of `slugify(string, options?)` with a counter to handle multiple occurences of the same string.
Expand Down Expand Up @@ -180,11 +153,6 @@ declare const slugify: {
You can then use `slugify.counter()` to generate unique HTML `id`'s to ensure anchors will link to the right headline.
*/
counter: () => {
(
string: string,
options?: slugify.Options
): string;

/**
Reset the counter.
Expand All @@ -205,8 +173,40 @@ declare const slugify: {
//=> 'foo-bar'
```
*/
reset(): void;
reset: () => void;

(
string: string,
options?: slugify.Options
): string;
};
}

/**
Slugify a string.
@param string - String to slugify.
@example
```
import slugify = require('@sindresorhus/slugify');
slugify('I ♥ Dogs');
//=> 'i-love-dogs'
slugify(' Déjà Vu! ');
//=> 'deja-vu'
slugify('fooBar 123 $#%');
//=> 'foo-bar-123'
slugify('я люблю единорогов');
//=> 'ya-lyublyu-edinorogov'
```
*/
(
string: string,
options?: slugify.Options
): string;
};

export = slugify;
2 changes: 1 addition & 1 deletion index.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ const builtinOverridableReplacements = require('./overridable-replacements');
const decamelize = string => {
return string
// Separate capitalized words.
.replace(/([A-Z]{2,})([\d]+)/g, '$1 $2')
.replace(/([A-Z]{2,})(\d+)/g, '$1 $2')
.replace(/([a-z\d]+)([A-Z]{2,})/g, '$1 $2')

.replace(/([a-z\d])([A-Z])/g, '$1 $2')
Expand Down
2 changes: 1 addition & 1 deletion index.test-d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,6 @@ expectType<string>(slugify('fooBar', {decamelize: false}));
expectType<string>(slugify('I ♥ 🦄 & 🐶', {customReplacements: [['🐶', 'dog']]}));
expectType<string>(slugify('_foo_bar', {preserveLeadingUnderscore: true}));

// counter
// Counter
expectType<string>(slugify.counter()('I ♥ Dogs'));
expectType<void>(slugify.counter().reset());
4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -42,11 +42,11 @@
],
"dependencies": {
"@sindresorhus/transliterate": "^0.1.0",
"escape-string-regexp": "^2.0.0"
"escape-string-regexp": "^4.0.0"
},
"devDependencies": {
"ava": "^2.4.0",
"tsd": "^0.11.0",
"xo": "^0.26.1"
"xo": "^0.30.0"
}
}

0 comments on commit 3e3f7ed

Please sign in to comment.