mirror of
https://github.com/gosticks/DefinitelyTyped.git
synced 2026-10-04 06:47:03 +00:00
Merge pull request #31197 from cprecioso/sindresorhus__slugify
Add sindresorhus__slugify
This commit is contained in:
+42
@@ -0,0 +1,42 @@
|
||||
// Type definitions for @sindresorhus/slugify 0.6
|
||||
// Project: https://github.com/sindesorhus/slugify
|
||||
// Definitions by: Carlos Precioso <https://github.com/cprecioso>
|
||||
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
|
||||
|
||||
declare namespace slugify {
|
||||
interface Options {
|
||||
/**
|
||||
* @default "-"
|
||||
*/
|
||||
separator?: string;
|
||||
|
||||
/**
|
||||
* Make the slug lowercase.
|
||||
* @default true
|
||||
*/
|
||||
lowercase?: boolean;
|
||||
|
||||
/**
|
||||
* Convert camelcase to separate words. Internally it does `fooBar` → `foo bar`.
|
||||
* @default true
|
||||
*/
|
||||
decamelize?: boolean;
|
||||
|
||||
/**
|
||||
* Specifying this only replaces the default if you set an item with the same key, like &.
|
||||
* The replacements are run on the original string before any other transformations.
|
||||
*
|
||||
* Add a leading and trailing space to the replacement to have it separated by dashes.
|
||||
*
|
||||
* @default [ ['&', ' and '], ['🦄', ' unicorn '], ['♥', ' love '] ]
|
||||
*/
|
||||
customReplacements?: ReadonlyArray<[string, string]>;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Slugify a string
|
||||
*/
|
||||
declare function slugify(input: string, options?: slugify.Options): string;
|
||||
|
||||
export = slugify;
|
||||
@@ -0,0 +1,29 @@
|
||||
import slugify = require("@sindresorhus/slugify");
|
||||
|
||||
slugify("I ♥ Dogs");
|
||||
|
||||
slugify(" Déjà Vu! ");
|
||||
|
||||
slugify("fooBar 123 $#%");
|
||||
|
||||
slugify("I ♥ 🦄 & 🐶", { customReplacements: [["🐶", "dog"]] });
|
||||
|
||||
slugify("BAR and baz");
|
||||
|
||||
slugify("BAR and baz", { separator: "_" });
|
||||
|
||||
slugify("Déjà Vu!");
|
||||
|
||||
slugify("Déjà Vu!", { lowercase: false });
|
||||
|
||||
slugify("fooBar");
|
||||
|
||||
slugify("fooBar", { decamelize: false });
|
||||
|
||||
slugify("Foo@unicorn", {
|
||||
customReplacements: [["@", "at"]]
|
||||
});
|
||||
|
||||
slugify("foo@unicorn", {
|
||||
customReplacements: [["@", " at "]]
|
||||
});
|
||||
@@ -0,0 +1,19 @@
|
||||
{
|
||||
"compilerOptions": {
|
||||
"module": "commonjs",
|
||||
"lib": ["es6"],
|
||||
"noImplicitAny": true,
|
||||
"noImplicitThis": true,
|
||||
"strictNullChecks": true,
|
||||
"strictFunctionTypes": true,
|
||||
"baseUrl": "../",
|
||||
"typeRoots": ["../"],
|
||||
"types": [],
|
||||
"noEmit": true,
|
||||
"forceConsistentCasingInFileNames": true,
|
||||
"paths": {
|
||||
"@sindresorhus/slugify": ["sindresorhus__slugify"]
|
||||
}
|
||||
},
|
||||
"files": ["index.d.ts", "sindresorhus__slugify-tests.ts"]
|
||||
}
|
||||
@@ -0,0 +1 @@
|
||||
{ "extends": "dtslint/dt.json" }
|
||||
Reference in New Issue
Block a user