transliteration: Provides its own types (#39556)

This commit is contained in:
Alexander T
2019-10-28 21:13:05 -07:00
committed by Jesse Trinity
parent 39f2f2eaa5
commit f9be2e89f0
5 changed files with 6 additions and 132 deletions
+6
View File
@@ -4158,6 +4158,12 @@
"sourceRepoURL": "https://github.com/sindresorhus/to-semver",
"asOfVersion": "2.0.0"
},
{
"libraryName": "transliteration",
"typingsPackageName": "transliteration",
"sourceRepoURL": "https://github.com/dzcpy/transliteration",
"asOfVersion": "1.6.6"
},
{
"libraryName": "trash",
"typingsPackageName": "trash",
-68
View File
@@ -1,68 +0,0 @@
// Type definitions for transliteration 1.6
// Project: https://github.com/dzcpy/transliteration
// Definitions by: Anthony Trinh <https://github.com/tony19>
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
export function transliterate(str: string, options?: transliterate.Options): string;
export namespace transliterate {
/**
* Bind options globally so any following calls will be using
* optionsObj by default. If optionsObj argument is omitted,
* it will return current default option object.
*/
function config(optionsObj?: Options): Options;
interface Options {
/**
* Unicode characters that are not in the database will be replaced with `unknown`
* default: "[?]"
*/
unknown?: string;
/**
* Custom replacement of the strings before transliteration
*/
replace?: string[][] | {[source: string]: string};
/**
* Strings in the ignore list will be bypassed from transliteration
*/
ignore?: string[];
}
}
export function slugify(str: string, options?: slugify.Options): string;
export namespace slugify {
/**
* Bind options globally so any following calls will be using
* optionsObj by default. If optionsObj argument is omitted,
* it will return current default option object.
*/
function config(optionsObj?: Options): Options;
interface Options {
/**
* Whether to force slugs to be lowercased
* default: true
*/
lowercase?: boolean;
/**
* Separator of the slug
* default: "-"
*/
separator?: string;
/**
* Custom replacement of the strings before transliteration
*/
replace?: string[][] | {[source: string]: string};
/**
* Strings in the ignore list will be bypassed from transliteration
*/
ignore?: string[];
}
}
@@ -1,40 +0,0 @@
import { transliterate as tr, slugify } from 'transliteration';
tr('你好,世界'); // Ni Hao , Shi Jie
tr('Γεια σας, τον κόσμο'); // Geia sas, ton kosmo
tr('안녕하세요, 세계'); // annyeonghaseyo, segye
tr('你好,世界', { replace: {你: 'You'}, ignore: ['好'] }); // You 好, Shi Jie
tr('你好,世界', { replace: [['你', 'You']], ignore: ['好'] }); // You 好, Shi Jie (option in array form)
// or use configurations
tr.config({ replace: [['你', 'You']], ignore: ['好'] });
tr('你好,世界'); // You 好, Shi Jie
// get configurations
const opt1 = tr.config();
opt1.ignore = ['foo', 'bar', 'baz'];
opt1.ignore = undefined;
opt1.replace = [['a', 'foo'], ['b', 'bar']];
opt1.replace = {a: 'foo', b: 'bar', c: 'baz'};
opt1.replace = undefined;
opt1.unknown = '***?***';
opt1.unknown = undefined;
slugify('你好,世界'); // ni-hao-shi-jie
slugify('你好,世界', { lowercase: false, separator: '_' }); // Ni_Hao_Shi_Jie
slugify('你好,世界', { replace: {你好: 'Hello', 世界: 'world'}, separator: '_' }); // hello_world
slugify('你好,世界', { replace: [['你好', 'Hello'], ['世界', 'world']], separator: '_' }); // hello_world (option in array form)
slugify('你好,世界', { ignore: ['你好'] }); // 你好shi-jie
// or use configurations
slugify.config({ lowercase: false, separator: '_' });
slugify('你好,世界'); // Ni_Hao_Shi_Jie
// get configurations
const opt2 = slugify.config();
opt2.ignore = ['foo', 'bar', 'baz'];
opt2.ignore = undefined;
opt2.replace = [['a', 'foo'], ['b', 'bar']];
opt2.replace = {a: 'foo', b: 'bar', c: 'baz'};
opt2.replace = undefined;
opt2.lowercase = false;
opt2.lowercase = true;
opt2.lowercase = undefined;
opt2.separator = ';';
opt2.separator = undefined;
-23
View File
@@ -1,23 +0,0 @@
{
"compilerOptions": {
"module": "commonjs",
"lib": [
"es5"
],
"noImplicitAny": true,
"noImplicitThis": true,
"strictNullChecks": true,
"strictFunctionTypes": true,
"baseUrl": "../",
"typeRoots": [
"../"
],
"types": [],
"noEmit": true,
"forceConsistentCasingInFileNames": true
},
"files": [
"index.d.ts",
"transliteration-tests.ts"
]
}
-1
View File
@@ -1 +0,0 @@
{ "extends": "dtslint/dt.json" }