mirror of
https://github.com/FlipsideCrypto/DefinitelyTyped.git
synced 2026-02-06 10:56:53 +00:00
Definition for speakingurl (#13105)
This commit is contained in:
parent
34124e057f
commit
9b58b09101
29
speakingurl/index.d.ts
vendored
Normal file
29
speakingurl/index.d.ts
vendored
Normal file
@ -0,0 +1,29 @@
|
||||
// Type definitions for speakingurl 10.0
|
||||
// Project: http://pid.github.io/speakingurl/
|
||||
// Definitions by: Zlatko Andonovski <https://github.com/Goldsmith42/>
|
||||
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
|
||||
|
||||
interface Dictionary<T> {
|
||||
[x: string]: T;
|
||||
}
|
||||
|
||||
interface Options {
|
||||
separator?: string;
|
||||
lang?: string|boolean;
|
||||
symbols?: boolean;
|
||||
maintainCase?: boolean;
|
||||
titleCase?: string[]|boolean;
|
||||
truncate?: number;
|
||||
uric?: boolean;
|
||||
uricNoSlash?: boolean;
|
||||
mark?: boolean;
|
||||
custom?: string[]|Dictionary<string>;
|
||||
}
|
||||
|
||||
declare function getSlug(input: string, options?: Options|string): string;
|
||||
|
||||
declare namespace getSlug {
|
||||
export function createSlug(options: Options): (input: string) => string;
|
||||
}
|
||||
|
||||
export = getSlug;
|
||||
94
speakingurl/speakingurl-tests.ts
Normal file
94
speakingurl/speakingurl-tests.ts
Normal file
@ -0,0 +1,94 @@
|
||||
import getSlug = require("speakingurl");
|
||||
|
||||
let slug: string;
|
||||
|
||||
// Examples from https://github.com/pid/speakingurl#usage
|
||||
|
||||
slug = getSlug("Schöner Titel läßt grüßen!? Bel été !");
|
||||
slug = getSlug("Schöner Titel läßt grüßen!? Bel été !", '*');
|
||||
slug = getSlug("Schöner Titel läßt grüßen!? Bel été !", {
|
||||
separator: '_'
|
||||
});
|
||||
slug = getSlug("Schöner Titel läßt grüßen!? Bel été !", {
|
||||
uric: true
|
||||
});
|
||||
slug = getSlug("Schöner Titel läßt grüßen!? Bel été !", {
|
||||
uricNoSlash: true
|
||||
});
|
||||
slug = getSlug("Schöner Titel läßt grüßen!? Bel été !", {
|
||||
mark: true
|
||||
});
|
||||
slug = getSlug("Schöner Titel läßt grüßen!? Bel été !", {
|
||||
truncate: 20
|
||||
});
|
||||
slug = getSlug("Schöner Titel läßt grüßen!? Bel été !", {
|
||||
maintainCase: true
|
||||
});
|
||||
slug = getSlug("Äpfel & Birnen!", {
|
||||
lang: 'de'
|
||||
});
|
||||
slug = getSlug("မြန်မာ သာဓက", {
|
||||
lang: 'my'
|
||||
});
|
||||
slug = getSlug('މިއަދަކީ ހދ ރީތި ދވހކވ', {
|
||||
lang: 'dv'
|
||||
});
|
||||
slug = getSlug("Apple & Pear!", {
|
||||
lang: 'en' // lang: "en" is default, just to clarify
|
||||
});
|
||||
slug = getSlug('Foo & Bar * Baz', {
|
||||
custom: {
|
||||
'&': ' doo '
|
||||
},
|
||||
uric: true
|
||||
});
|
||||
slug = getSlug('Foo ♥ Bar');
|
||||
slug = getSlug('Foo & Bar | (Baz) * Doo', {
|
||||
custom: {
|
||||
'*': 'Boo'
|
||||
},
|
||||
mark: true
|
||||
});
|
||||
slug = getSlug('Foo and Bar or Baz', {
|
||||
custom: {
|
||||
and: 'und',
|
||||
or: ''
|
||||
}
|
||||
});
|
||||
slug = getSlug('[Knöpfe]', {
|
||||
custom: [
|
||||
'[',
|
||||
']'
|
||||
]
|
||||
});
|
||||
slug = getSlug('NEXUS4 only $299');
|
||||
slug = getSlug('NEXUS4 only €299', {
|
||||
maintainCase: true
|
||||
});
|
||||
slug = getSlug('Don\'t drink and drive', {
|
||||
titleCase: true
|
||||
});
|
||||
slug = getSlug('Don\'t drink and drive', {
|
||||
titleCase: ['and']
|
||||
});
|
||||
slug = getSlug('Foo & Bar ♥ Foo < Bar', {
|
||||
lang: false
|
||||
});
|
||||
slug = getSlug('Foo & Bar ♥ Foo < Bar', {
|
||||
symbols: false
|
||||
});
|
||||
slug = getSlug('ä♥ä', {
|
||||
lang: 'tr',
|
||||
symbols: false
|
||||
});
|
||||
|
||||
const options = {
|
||||
titleCase: [
|
||||
"a", "an", "and", "as", "at", "but",
|
||||
"by", "en", "for", "if", "in", "nor",
|
||||
"of", "on", "or", "per", "the", "to", "vs"
|
||||
]
|
||||
};
|
||||
|
||||
const mySlug = getSlug.createSlug(options);
|
||||
slug = mySlug('welcome to the jungle');
|
||||
19
speakingurl/tsconfig.json
Normal file
19
speakingurl/tsconfig.json
Normal file
@ -0,0 +1,19 @@
|
||||
{
|
||||
"compilerOptions": {
|
||||
"module": "commonjs",
|
||||
"target": "es6",
|
||||
"noImplicitAny": true,
|
||||
"strictNullChecks": true,
|
||||
"baseUrl": "../",
|
||||
"typeRoots": [
|
||||
"../"
|
||||
],
|
||||
"types": [],
|
||||
"noEmit": true,
|
||||
"forceConsistentCasingInFileNames": true
|
||||
},
|
||||
"files": [
|
||||
"index.d.ts",
|
||||
"speakingurl-tests.ts"
|
||||
]
|
||||
}
|
||||
1
speakingurl/tslint.json
Normal file
1
speakingurl/tslint.json
Normal file
@ -0,0 +1 @@
|
||||
{ "extends": "../tslint.json" }
|
||||
Loading…
Reference in New Issue
Block a user