mirror of
https://github.com/zhigang1992/DefinitelyTyped.git
synced 2026-04-08 09:17:06 +08:00
String object has additional ES2017 and ESNEXT methods
This commit is contained in:
12
types/node/index.d.ts
vendored
12
types/node/index.d.ts
vendored
@@ -68,6 +68,18 @@ interface SymbolConstructor {
|
||||
}
|
||||
declare var Symbol: SymbolConstructor;
|
||||
|
||||
// Node.js ES2017 and ESNEXT support
|
||||
interface String {
|
||||
/** Pads the current string with another string (repeated, if needed) so that the resulting string reaches the given length. The padding is applied from the start (left) of the current string. */
|
||||
padStart(targetLength?: number, padString?: string): string;
|
||||
/** Pads the current string with a given string (repeated, if needed) so that the resulting string reaches a given length. The padding is applied from the end (right) of the current string. */
|
||||
padEnd(targetLength?: number, padString?: string): string;
|
||||
/** Removes whitespace from the left end of a string. */
|
||||
trimLeft(): string;
|
||||
/** Removes whitespace from the right end of a string. */
|
||||
trimRight(): string;
|
||||
}
|
||||
|
||||
/************************************************
|
||||
* *
|
||||
* GLOBAL *
|
||||
|
||||
@@ -3751,3 +3751,27 @@ namespace module_tests {
|
||||
const m1: Module = new Module("moduleId");
|
||||
const m2: Module = new Module.Module("moduleId");
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////
|
||||
/// Node.js ES2017 Support
|
||||
////////////////////////////////////////////////////
|
||||
|
||||
namespace es2017_tests {
|
||||
const s: string = 'foo';
|
||||
const s1: string = s.padStart();
|
||||
const s11: string = s.padStart(10);
|
||||
const s12: string = s.padStart(10, 'x');
|
||||
const s2: string = s.padEnd();
|
||||
const s21: string = s.padEnd(10);
|
||||
const s22: string = s.padEnd(10, 'x');
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////
|
||||
/// Node.js ESNEXT Support
|
||||
////////////////////////////////////////////////////
|
||||
|
||||
namespace esnext_tests {
|
||||
const s: string = 'foo';
|
||||
const s1: string = s.trimLeft();
|
||||
const s2: string = s.trimRight();
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user