mirror of
https://github.com/wassname/DefinitelyTyped.git
synced 2026-09-09 11:13:57 +08:00
Allow standalone usage and fix tests.
This commit is contained in:
@@ -1,7 +1,8 @@
|
||||
/// <reference path='../underscore/underscore.d.ts' />
|
||||
/// <reference path='underscore.string.d.ts' />
|
||||
|
||||
_.mixin(_['string'].exports());
|
||||
_.mixin(_.string.exports());
|
||||
interface UnderscoreStatic extends UnderscoreStringStaticExports { }
|
||||
|
||||
_.numberFormat(1000, 2);
|
||||
_.numberFormat(123456789.123, 5, '.', ',');
|
||||
|
||||
+62
-26
@@ -4,6 +4,45 @@
|
||||
// Definitions: https://github.com/borisyankov/DefinitelyTyped
|
||||
|
||||
interface UnderscoreStatic {
|
||||
str: UnderscoreStringStatic;
|
||||
string: UnderscoreStringStatic;
|
||||
}
|
||||
|
||||
interface UnderscoreStringStatic extends UnderscoreStringStaticExports {
|
||||
/**
|
||||
* Tests if string contains a substring.
|
||||
* ('foobar', 'ob') => true
|
||||
* @param str
|
||||
* @param needle
|
||||
*/
|
||||
include(str: string, needle: string): boolean;
|
||||
|
||||
/**
|
||||
* Tests if string contains a substring.
|
||||
* ('foobar', 'ob') => true
|
||||
* @param str
|
||||
* @param needle
|
||||
*/
|
||||
contains(str: string, needle: string): boolean;
|
||||
|
||||
/**
|
||||
* Return reversed string.
|
||||
* ('foobar') => 'raboof'
|
||||
* @param str
|
||||
*/
|
||||
reverse(str: string): string;
|
||||
}
|
||||
|
||||
/**
|
||||
* Functions exported for mixing with underscore object.
|
||||
*
|
||||
* Usage:
|
||||
* _.mixin(_.string.exports());
|
||||
* interface UnderscoreStatic extends UnderscoreStringStaticExports { }
|
||||
*/
|
||||
interface UnderscoreStringStaticExports {
|
||||
|
||||
exports(): UnderscoreStringStaticExports;
|
||||
|
||||
/**
|
||||
* Determine if a string is 'blank.'
|
||||
@@ -98,22 +137,6 @@ interface UnderscoreStatic {
|
||||
*/
|
||||
insert(str: string, i: number, substr: string): string;
|
||||
|
||||
/**
|
||||
* Tests if string contains a substring.
|
||||
* ('foobar', 'ob') => true
|
||||
* @param str
|
||||
* @param needle
|
||||
*/
|
||||
include(str: string, needle: string): boolean;
|
||||
|
||||
/**
|
||||
* Tests if string contains a substring.
|
||||
* ('foobar', 'ob') => true
|
||||
* @param str
|
||||
* @param needle
|
||||
*/
|
||||
contains(str: string, needle: string): boolean;
|
||||
|
||||
/**
|
||||
* Joins strings together with given separator.
|
||||
* (' ', 'foo', 'bar') => 'foo bar'
|
||||
@@ -129,13 +152,6 @@ interface UnderscoreStatic {
|
||||
*/
|
||||
lines(str: string): any[];
|
||||
|
||||
/**
|
||||
* Return reversed string.
|
||||
* ('foobar') => 'raboof'
|
||||
* @param str
|
||||
*/
|
||||
reverse(str: string): string;
|
||||
|
||||
/**
|
||||
* Checks if string starts with another string.
|
||||
* ('image.gif', 'image') => true
|
||||
@@ -279,7 +295,27 @@ interface UnderscoreStatic {
|
||||
* @param str
|
||||
* @param delimiter
|
||||
*/
|
||||
words(str: string, delimiter?: string): any[];
|
||||
words(str: string): string[];
|
||||
|
||||
/**
|
||||
* Split string by delimiter (String or RegExp).
|
||||
* /\s+/ by default.
|
||||
* (' I love you ') => ['I','love','you']
|
||||
* ('I_love_you', '_') => ['I','love','you']
|
||||
* @param str
|
||||
* @param delimiter
|
||||
*/
|
||||
words(str: string, delimiter: string): string[];
|
||||
|
||||
/**
|
||||
* Split string by delimiter (String or RegExp).
|
||||
* /\s+/ by default.
|
||||
* (' I love you ') => ['I','love','you']
|
||||
* ('I_love_you', '_') => ['I','love','you']
|
||||
* @param str
|
||||
* @param delimiter
|
||||
*/
|
||||
words(str: string, delimiter: RegExp): string[];
|
||||
|
||||
/**
|
||||
* Pads a string with characters until the total string length is equal to the passed length parameter.
|
||||
@@ -295,7 +331,7 @@ interface UnderscoreStatic {
|
||||
* @param padStr
|
||||
* @param type
|
||||
*/
|
||||
pad(str: string, length: number, padStr:string, type?: string): string;
|
||||
pad(str: string, length: number, padStr?:string, type?: string): string;
|
||||
|
||||
/**
|
||||
* Left-pad a string.
|
||||
@@ -527,4 +563,4 @@ interface UnderscoreStatic {
|
||||
|
||||
}
|
||||
|
||||
// TODO interface Underscore<T>
|
||||
// TODO interface UnderscoreString extends Underscore<string>
|
||||
|
||||
Reference in New Issue
Block a user