diff --git a/types/uslug/index.d.ts b/types/uslug/index.d.ts new file mode 100644 index 0000000000..c248562dc1 --- /dev/null +++ b/types/uslug/index.d.ts @@ -0,0 +1,24 @@ +// Type definitions for uslug 1.0 +// Project: https://github.com/jeremys/uslug +// Definitions by: Junyoung Choi +// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped + +/** + * Generate a slug for the string passed. + * @param value The string you want to slugify + * @param options An optional object that can contain: + * - allowedChars: a String 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. + */ +declare function uslug(value: string, options?: uslug.UslugOptions): string; + +declare namespace uslug { + interface UslugOptions { + allowedChars?: string; + lower?: boolean; + spaces?: boolean; + } +} + +export = uslug; diff --git a/types/uslug/tsconfig.json b/types/uslug/tsconfig.json new file mode 100644 index 0000000000..b7ed02eddf --- /dev/null +++ b/types/uslug/tsconfig.json @@ -0,0 +1,23 @@ +{ + "compilerOptions": { + "module": "commonjs", + "lib": [ + "es6" + ], + "noImplicitAny": true, + "noImplicitThis": true, + "strictNullChecks": false, + "strictFunctionTypes": true, + "baseUrl": "../", + "typeRoots": [ + "../" + ], + "types": [], + "noEmit": true, + "forceConsistentCasingInFileNames": true + }, + "files": [ + "index.d.ts", + "uslug-tests.ts" + ] +} \ No newline at end of file diff --git a/types/uslug/tslint.json b/types/uslug/tslint.json new file mode 100644 index 0000000000..30a1bdde2e --- /dev/null +++ b/types/uslug/tslint.json @@ -0,0 +1,3 @@ +{ + "extends": "dtslint/dt.json" +} \ No newline at end of file diff --git a/types/uslug/uslug-tests.ts b/types/uslug/uslug-tests.ts new file mode 100644 index 0000000000..48a108ca44 --- /dev/null +++ b/types/uslug/uslug-tests.ts @@ -0,0 +1,8 @@ +import uslug = require("uslug"); + +uslug('Быстрее и лучше!'); // 'быстрее-и-лучше' +uslug('汉语/漢語'); // '汉语漢語' + +uslug('Y U NO', { lower: false }); // 'Y-U-NO' +uslug('Y U NO', { spaces: true }); // 'y u no' +uslug('Y-U|NO', { allowedChars: '|' }); // 'yu|no'