mirror of
https://github.com/gosticks/DefinitelyTyped.git
synced 2026-10-04 14:57:10 +00:00
Add types for strman (#40979)
* Initialize module * Add types for all exported methods * Add tests for all exported methods
This commit is contained in:
committed by
Daniel Rosenwasser
parent
487ed3b63e
commit
08c1f18272
Vendored
+74
@@ -0,0 +1,74 @@
|
||||
// Type definitions for strman 2.0
|
||||
// Project: https://github.com/dleitee/strman#readme
|
||||
// Definitions by: Adam Bergman <https://github.com/adambrgmn>
|
||||
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
|
||||
|
||||
export function append(value: string, ...appends: string[]): string;
|
||||
export function appendArray(value: string, appends: string[]): string;
|
||||
export function at(value: string, index: number): string;
|
||||
export function base64decode(value: string): string;
|
||||
export function base64encode(value: string): string;
|
||||
export function between(value: string, start: string, end: string): string[];
|
||||
export function binDecode(value: string): string;
|
||||
export function binEncode(value: string): string;
|
||||
export function chars(value: string): string[];
|
||||
export function collapseWhitespace(value: string): string;
|
||||
export function compare(stringA: string, stringB: string): number;
|
||||
export function contains(value: string, needle: string, caseSensitive?: boolean): boolean;
|
||||
export function containsAll(value: string, needle: string[], caseSensitive?: boolean): boolean;
|
||||
export function containsAny(value: string, needle: string[], caseSensitive?: boolean): boolean;
|
||||
export function countSubstr(value: string, substr: string, caseSensitive?: boolean, allowOverlapping?: boolean): number;
|
||||
export function decDecode(value: string): string;
|
||||
export function decEncode(value: string): string;
|
||||
export function endsWith(value: string, search: string, position?: number, caseSensitive?: boolean): boolean;
|
||||
export function ensureLeft(value: string, substr: string, caseSensitive?: boolean): string;
|
||||
export function ensureRight(value: string, substr: string, caseSensitive?: boolean): string;
|
||||
export function equal(stringA: string, stringB: string): boolean;
|
||||
export function first(value: string, n: number): string;
|
||||
export function format(value: string, ...params: string[]): string;
|
||||
export function hexDecode(value: string): string;
|
||||
export function hexEncode(value: string): string;
|
||||
export function htmlDecode(value: string): string;
|
||||
export function htmlEncode(value: string): string;
|
||||
export function inequal(stringA: string, stringB: string): boolean;
|
||||
export function insert(value: string, substr: string, position: number): string;
|
||||
export function isLowerCase(value: string): boolean;
|
||||
export function isString(value: any): boolean;
|
||||
export function isString(value: any): value is string;
|
||||
export function isUpperCase(value: string): boolean;
|
||||
export function last(value: string, n: number): string;
|
||||
export function lastIndexOf(value: string, needle: string, offset?: number, caseSensitive?: boolean): string;
|
||||
export function leftPad(value: string, length: number, char?: string): string;
|
||||
export function leftTrim(value: string, char?: string): string;
|
||||
export function prepend(value: string, ...prepends: string[]): string;
|
||||
export function prependArray(value: string, prepends: string[]): string;
|
||||
export function removeEmptyStrings(strings: Array<string | undefined | null>): string[];
|
||||
export function removeLeft(value: string, prefix: string, caseSensitive?: boolean): string;
|
||||
export function removeNonWords(value: string, replaced?: string): string;
|
||||
export function removeRight(value: string, suffix: string, caseSensitive?: boolean): string;
|
||||
export function removeSpaces(value: string, replaced?: string): string;
|
||||
export function repeat(string: string, multiplier: number): string;
|
||||
export function replace(value: string, search: string, newValue: string, caseSensitive?: boolean, multiline?: boolean): string;
|
||||
export function reverse(value: string): string;
|
||||
export function rightPad(value: string, length: number, char?: string): string;
|
||||
export function rightTrim(value: string, char?: string): string;
|
||||
export function safeTruncate(value: string, length: number, append?: string): string;
|
||||
export function shuffle(value: string): string;
|
||||
export function slice(value: string, beginSlice: number, endSlice: number): string;
|
||||
export function slugify(value: string): string;
|
||||
export function split(value: string, separator: string, limit?: number): string[];
|
||||
export function startsWith(value: string, search: string, position?: number, caseSensitive?: boolean): boolean;
|
||||
export function substr(value: string, start: number, length: number): string;
|
||||
export function surround(value: string, substr: string, substrRight?: string): string;
|
||||
export function toCamelCase(value: string): string;
|
||||
export function toDecamelize(value: string): string;
|
||||
export function toKebabCase(value: string): string;
|
||||
export function toLowerCase(value: string): string;
|
||||
export function toSnakeCase(value: string): string;
|
||||
export function toStudlyCaps(value: string): string;
|
||||
export function toUpperCase(value: string): string;
|
||||
export function transliterate(value: string): string;
|
||||
export function trim(value: string, char?: string): string;
|
||||
export function truncate(value: string, length: number, append?: string): string;
|
||||
export function urlDecode(value: string): string;
|
||||
export function urlEncode(value: string): string;
|
||||
@@ -0,0 +1,71 @@
|
||||
import * as strman from 'strman';
|
||||
|
||||
strman.append('hello', 'world', '!'); // $ExpectType string
|
||||
strman.appendArray('hello', ['world', '!']); // $ExpectType string
|
||||
strman.at('hello', 1); // $ExpectType string
|
||||
strman.base64decode('c3RybWFu'); // $ExpectType string
|
||||
strman.base64encode('value'); // $ExpectType string
|
||||
strman.between('[abc] [def]', '[', ']'); // $ExpectType string[]
|
||||
strman.binDecode('value'); // $ExpectType string
|
||||
strman.binEncode('value'); // $ExpectType string
|
||||
strman.chars('value'); // $ExpectType string[]
|
||||
strman.collapseWhitespace('value'); // $ExpectType string
|
||||
strman.compare('stringA', 'stringB'); // $ExpectType number
|
||||
strman.contains('hello', 'll', false); // $ExpectType boolean
|
||||
strman.containsAll('hello', ['he', 'lo'], true); // $ExpectType boolean
|
||||
strman.containsAny('hello', ['he', 'lo'], true); // $ExpectType boolean
|
||||
strman.countSubstr('hello fella', 'll', false, true); // $ExpectType number
|
||||
strman.decDecode('001150011600114001090009700110'); // $ExpectType string
|
||||
strman.decEncode('value'); // $ExpectType string
|
||||
strman.endsWith('hello', 'lo'); // $ExpectType boolean
|
||||
strman.ensureLeft('lo world', 'hello'); // $ExpectType string
|
||||
strman.ensureRight('hello wo', 'world'); // $ExpectType string
|
||||
strman.equal('hello', 'hello'); // $ExpectType boolean
|
||||
strman.first('hello world', 2); // $ExpectType string
|
||||
strman.format('%{0}% %{1}%!', 'hello', 'world'); // $ExpectType string
|
||||
strman.hexDecode('007300740072006d0061006e'); // $ExpectType string
|
||||
strman.hexEncode('value'); // $ExpectType string
|
||||
strman.htmlDecode('<div>'); // $ExpectType string
|
||||
strman.htmlEncode('<div>'); // $ExpectType string
|
||||
strman.inequal('stringA', 'stringB'); // $ExpectType boolean
|
||||
strman.insert('helo', 'l', 2); // $ExpectType string
|
||||
strman.isLowerCase('value'); // $ExpectType boolean
|
||||
strman.isString('value'); // $ExpectType boolean
|
||||
strman.isString(123); // $ExpectType boolean
|
||||
strman.isUpperCase('VALUE'); // $ExpectType boolean
|
||||
strman.last('hello', 2); // $ExpectType string
|
||||
strman.lastIndexOf('hello', 'l'); // $ExpectType string
|
||||
strman.leftPad('hello', 10, '-'); // $ExpectType string
|
||||
strman.leftTrim(' hello'); // $ExpectType string
|
||||
strman.prepend('world', 'hel', 'lo', ' '); // $ExpectType string
|
||||
strman.prependArray('world', ['hel', 'lo', ' ']); // $ExpectType string
|
||||
strman.removeEmptyStrings(['hello', null, 'world', undefined, '']); // $ExpectType string[]
|
||||
strman.removeLeft('hhello', 'h'); // $ExpectType string
|
||||
strman.removeNonWords('__hello../'); // $ExpectType string
|
||||
strman.removeRight('hello worldd', 'd'); // $ExpectType string
|
||||
strman.removeSpaces('hello world'); // $ExpectType string
|
||||
strman.repeat('hello', 2); // $ExpectType string
|
||||
strman.replace('hello world', 'world', 'ts'); // $ExpectType string
|
||||
strman.reverse('hello'); // $ExpectType string
|
||||
strman.rightPad('hello', 15, '-'); // $ExpectType string
|
||||
strman.rightTrim('hhello', 'h'); // $ExpectType string
|
||||
strman.safeTruncate('hello world friend!', 8, '...'); // $ExpectType string
|
||||
strman.shuffle('hello'); // $ExpectType string
|
||||
strman.slice('hello', 2, 2); // $ExpectType string
|
||||
strman.slugify('héllö'); // $ExpectType string
|
||||
strman.split('hello world', ' '); // $ExpectType string[]
|
||||
strman.startsWith('hello', 'he'); // $ExpectType boolean
|
||||
strman.substr('hello', 2, 2); // $ExpectType string
|
||||
strman.surround('hello', '¡', '!'); // $ExpectType string
|
||||
strman.toCamelCase('hello world'); // $ExpectType string
|
||||
strman.toDecamelize('hello world'); // $ExpectType string
|
||||
strman.toKebabCase('hello world'); // $ExpectType string
|
||||
strman.toLowerCase('hello world'); // $ExpectType string
|
||||
strman.toSnakeCase('hello world'); // $ExpectType string
|
||||
strman.toStudlyCaps('hello world'); // $ExpectType string
|
||||
strman.toUpperCase('hello world'); // $ExpectType string
|
||||
strman.transliterate('value'); // $ExpectType string
|
||||
strman.trim(' hello '); // $ExpectType string
|
||||
strman.truncate('hello world', 8, '...'); // $ExpectType string
|
||||
strman.urlDecode('https://github.com/dleitee/strman/&name=%C3%A1%C3%A9%C3%AD%C3%B3%C3%BA'); // $ExpectType string
|
||||
strman.urlEncode('https://github.com/dleitee/strman/&name=áéíóú'); // $ExpectType string
|
||||
@@ -0,0 +1,23 @@
|
||||
{
|
||||
"compilerOptions": {
|
||||
"module": "commonjs",
|
||||
"lib": [
|
||||
"es6"
|
||||
],
|
||||
"noImplicitAny": true,
|
||||
"noImplicitThis": true,
|
||||
"strictFunctionTypes": true,
|
||||
"strictNullChecks": true,
|
||||
"baseUrl": "../",
|
||||
"typeRoots": [
|
||||
"../"
|
||||
],
|
||||
"types": [],
|
||||
"noEmit": true,
|
||||
"forceConsistentCasingInFileNames": true
|
||||
},
|
||||
"files": [
|
||||
"index.d.ts",
|
||||
"strman-tests.ts"
|
||||
]
|
||||
}
|
||||
@@ -0,0 +1 @@
|
||||
{ "extends": "dtslint/dt.json" }
|
||||
Reference in New Issue
Block a user