* Add uslug type definitions

* Fix header of uslug
This commit is contained in:
Junyoung Choi
2019-03-29 20:27:46 -07:00
committed by Ron Buckton
parent 62b83bada6
commit 5afa9902c6
4 changed files with 58 additions and 0 deletions
+24
View File
@@ -0,0 +1,24 @@
// Type definitions for uslug 1.0
// Project: https://github.com/jeremys/uslug
// Definitions by: Junyoung Choi <https://github.com/rokt33r>
// 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;
+23
View File
@@ -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"
]
}
+3
View File
@@ -0,0 +1,3 @@
{
"extends": "dtslint/dt.json"
}
+8
View File
@@ -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'