Merge pull request #31197 from cprecioso/sindresorhus__slugify

Add sindresorhus__slugify
This commit is contained in:
Nathan Shively-Sanders
2018-12-17 15:46:42 -08:00
committed by GitHub
4 changed files with 91 additions and 0 deletions
+42
View File
@@ -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 "]]
});
+19
View File
@@ -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"]
}
+1
View File
@@ -0,0 +1 @@
{ "extends": "dtslint/dt.json" }