From 2127b2f1e438efa61f3d087079a5f17385a38e4c Mon Sep 17 00:00:00 2001 From: Kasumi Hanazuki Date: Fri, 13 Feb 2015 16:08:54 +0900 Subject: [PATCH] lodash: Add definitions for string functions --- lodash/lodash-tests.ts | 35 ++++++++++++++++++++++++ lodash/lodash.d.ts | 60 +++++++++++++++++++++++++++++++----------- 2 files changed, 79 insertions(+), 16 deletions(-) diff --git a/lodash/lodash-tests.ts b/lodash/lodash-tests.ts index 2017252ff..6f24b75dc 100644 --- a/lodash/lodash-tests.ts +++ b/lodash/lodash-tests.ts @@ -1096,6 +1096,41 @@ result = _.unescape('Moe, Larry & Curly'); result = _.uniqueId('contact_'); result = _.uniqueId(); +/********* +* String +*********/ + +result = _.camelCase('Foo Bar'); +result = _.capitalize('fred'); +result = _.deburr('déjà vu'); +result = _.endsWith('abc', 'c'); +result = _.escape('fred, barney, & pebbles'); +result = _.escapeRegExp('[lodash](https://lodash.com/)'); +result = _.kebabCase('Foo Bar'); +result = _.pad('abc', 8); +result = _.pad('abc', 8, '_-'); +result = _.padLeft('abc', 6); +result = _.padLeft('abc', 6, '_-'); +result = _.padRight('abc', 6); +result = _.padRight('abc', 6, '_-'); +result = _.repeat('*', 3); +result = _.snakeCase('Foo Bar'); +result = _.startCase('--foo-bar'); +result = _.startsWith('abc', 'a'); +result = _.trim(' abc '); +result = _.trim('-_-abc-_-', '_-'); +result = _.trimLeft(' abc '); +result = _.trimLeft('-_-abc-_-', '_-'); +result = _.trimRight(' abc '); +result = _.trimRight('-_-abc-_-', '_-'); +result = _.trunc('hi-diddly-ho there, neighborino'); +result = _.trunc('hi-diddly-ho there, neighborino', 24); +result = _.trunc('hi-diddly-ho there, neighborino', { 'length': 24, 'separator': ' ' }); +result = _.trunc('hi-diddly-ho there, neighborino', { 'length': 24, 'separator': /,? +/ }); +result = _.trunc('hi-diddly-ho there, neighborino', { 'omission': ' […]' }); +result = _.words('fred, barney, & pebbles'); +result = _.words('fred, barney, & pebbles', /[^, ]+/g); + /********** * Utilities * ***********/ diff --git a/lodash/lodash.d.ts b/lodash/lodash.d.ts index c8f7ad42d..c43f27c5c 100644 --- a/lodash/lodash.d.ts +++ b/lodash/lodash.d.ts @@ -6133,6 +6133,50 @@ declare module _ { values(object: any): any[]; } + /********** + * String * + **********/ + + interface LoDashStatic { + camelCase(str?: string): string; + capitalize(str?: string): string; + deburr(str?: string): string; + endsWith(str?: string, target?: string, position?: number): boolean; + escape(str?: string): string; + escapeRegExp(str?: string): string; + kebabCase(str?: string): string; + pad(str?: string, length?: number, chars?: string): string; + padLeft(str?: string, length?: number, chars?: string): string; + padRight(str?: string, length?: number, chars?: string): string; + repeat(str?: string, n?: number): string; + snakeCase(str?: string): string; + startCase(str?: string): string; + startsWith(str?: string, target?: string, position?: number): boolean; + trim(str?: string, chars?: string): string; + trimLeft(str?: string, chars?: string): string; + trimRight(str?: string, chars?: string): string; + trunc(str?: string, len?: number): string; + trunc(str?: string, options?: { length?: number; omission?: string; separator?: string }): string; + trunc(str?: string, options?: { length?: number; omission?: string; separator?: RegExp }): string; + words(str?: string, pattern?: string): string[]; + words(str?: string, pattern?: RegExp): string[]; + } + + //_.parseInt + interface LoDashStatic { + /** + * Converts the given value into an integer of the specified radix. If radix is undefined or 0 a + * radix of 10 is used unless the value is a hexadecimal, in which case a radix of 16 is used. + * + * Note: This method avoids differences in native ES3 and ES5 parseInt implementations. See + * http://es5.github.io/#E. + * @param value The value to parse. + * @param radix The radix used to interpret the value to parse. + * @return The new integer value. + **/ + parseInt(value: string, radix?: number): number; + } + /************* * Utilities * *************/ @@ -6174,22 +6218,6 @@ declare module _ { noConflict(): typeof _; } - //_.parseInt - interface LoDashStatic { - /** - * Converts the given value into an integer of the specified radix. If radix is undefined or 0 a - * radix of 10 is used unless the value is a hexadecimal, in which case a radix of 16 is used. - * - * Note: This method avoids differences in native ES3 and ES5 parseInt implementations. See - * http://es5.github.io/#E. - * @param value The value to parse. - * @param radix The radix used to interpret the value to parse. - * @return The new integer value. - **/ - parseInt(value: string): number; - } - - //_.property interface LoDashStatic { /**