diff --git a/lodash/lodash-3.10.d.ts b/lodash/lodash-3.10.d.ts index c570cc11c..fd2018e0c 100644 --- a/lodash/lodash-3.10.d.ts +++ b/lodash/lodash-3.10.d.ts @@ -230,7 +230,6 @@ declare module _ { interface LoDashExplicitObjectWrapper extends LoDashExplicitWrapperBase> { } interface LoDashImplicitArrayWrapper extends LoDashImplicitWrapperBase> { - join(seperator?: string): string; pop(): T; push(...items: T[]): LoDashImplicitArrayWrapper; shift(): T; @@ -246,6 +245,49 @@ declare module _ { interface LoDashExplicitNumberArrayWrapper extends LoDashExplicitArrayWrapper { } + // join (exists only in wrappers) + interface LoDashImplicitWrapper { + /** + * @see _.join + */ + join(separator?: string): string; + } + + interface LoDashImplicitArrayWrapper { + /** + * @see _.join + */ + join(separator?: string): string; + } + + interface LoDashImplicitObjectWrapper { + /** + * @see _.join + */ + join(separator?: string): string; + } + + interface LoDashExplicitWrapper { + /** + * @see _.join + */ + join(separator?: string): LoDashExplicitWrapper; + } + + interface LoDashExplicitArrayWrapper { + /** + * @see _.join + */ + join(separator?: string): LoDashExplicitWrapper; + } + + interface LoDashExplicitObjectWrapper { + /** + * @see _.join + */ + join(separator?: string): LoDashExplicitWrapper; + } + /********* * Array * *********/ diff --git a/lodash/lodash-tests-3.10.ts b/lodash/lodash-tests-3.10.ts index efe2e1b3e..3f39fbfaf 100644 --- a/lodash/lodash-tests-3.10.ts +++ b/lodash/lodash-tests-3.10.ts @@ -133,7 +133,6 @@ module TestWrapper { } //Wrapped array shortcut methods -result = _([1, 2, 3, 4]).join(','); result = _([1, 2, 3, 4]).pop(); result = <_.LoDashImplicitArrayWrapper>_([1, 2, 3, 4]).push(5, 6, 7); result = _([1, 2, 3, 4]).shift(); @@ -142,6 +141,34 @@ result = <_.LoDashImplicitArrayWrapper>_([1, 2, 3, 4]).splice(1); result = <_.LoDashImplicitArrayWrapper>_([1, 2, 3, 4]).splice(1, 2, 5, 6); result = <_.LoDashImplicitArrayWrapper>_([1, 2, 3, 4]).unshift(5, 6); +// join (exists only in wrappers) +namespace TestJoin { + let array = [1, 2]; + let list = {0: 1, 1: 2, length: 2}; + + { + let result: string; + + result = _('abc').join(); + result = _('abc').join('_'); + result = _(array).join(); + result = _(array).join('_'); + result = _(list).join(); + result = _(list).join('_'); + } + + { + let result: _.LoDashExplicitWrapper; + + result = _('abc').chain().join(); + result = _('abc').chain().join('_'); + result = _(array).chain().join(); + result = _(array).chain().join('_'); + result = _(list).chain().join(); + result = _(list).chain().join('_'); + } +} + /********* * Array * *********/ diff --git a/lodash/lodash-tests.ts b/lodash/lodash-tests.ts index af33b66ac..b003c40d4 100644 --- a/lodash/lodash-tests.ts +++ b/lodash/lodash-tests.ts @@ -133,7 +133,6 @@ module TestWrapper { } //Wrapped array shortcut methods -result = _([1, 2, 3, 4]).join(','); result = _([1, 2, 3, 4]).pop(); result = <_.LoDashImplicitArrayWrapper>_([1, 2, 3, 4]).push(5, 6, 7); result = _([1, 2, 3, 4]).shift(); @@ -941,6 +940,41 @@ module TestIntersection { } } +// _.join +namespace TestJoin { + let array = [1, 2]; + let list = {0: 1, 1: 2, length: 2}; + + { + let result: string; + + result = _.join('abc'); + result = _.join('abc', '_'); + result = _.join(array); + result = _.join(array, '_'); + result = _.join(list); + result = _.join(list, '_'); + + result = _('abc').join(); + result = _('abc').join('_'); + result = _(array).join(); + result = _(array).join('_'); + result = _(list).join(); + result = _(list).join('_'); + } + + { + let result: _.LoDashExplicitWrapper; + + result = _('abc').chain().join(); + result = _('abc').chain().join('_'); + result = _(array).chain().join(); + result = _(array).chain().join('_'); + result = _(list).chain().join(); + result = _(list).chain().join('_'); + } +} + // _.last module TestLast { let array: TResult[]; diff --git a/lodash/lodash.d.ts b/lodash/lodash.d.ts index f9249d16b..2d8ab3655 100644 --- a/lodash/lodash.d.ts +++ b/lodash/lodash.d.ts @@ -375,7 +375,6 @@ declare module _ { interface LoDashExplicitObjectWrapper extends LoDashExplicitWrapperBase> { } interface LoDashImplicitArrayWrapper extends LoDashImplicitWrapperBase> { - join(seperator?: string): string; pop(): T; push(...items: T[]): LoDashImplicitArrayWrapper; shift(): T; @@ -1676,26 +1675,61 @@ declare module _ { ): any[]; } - //_.join DUMMY + //_.join interface LoDashStatic { /** * Converts all elements in `array` into a string separated by `separator`. * - * @static - * @memberOf _ - * @category Array - * @param {Array} array The array to convert. - * @param {string} [separator=','] The element separator. - * @returns {string} Returns the joined string. - * @example - * - * _.join(['a', 'b', 'c'], '~'); - * // => 'a~b~c' + * @param array The array to convert. + * @param separator The element separator. + * @returns Returns the joined string. */ join( - array: any[]|List, - ...values: any[] - ): any[]; + array: List, + separator?: string + ): string; + } + + interface LoDashImplicitWrapper { + /** + * @see _.join + */ + join(separator?: string): string; + } + + interface LoDashImplicitArrayWrapper { + /** + * @see _.join + */ + join(separator?: string): string; + } + + interface LoDashImplicitObjectWrapper { + /** + * @see _.join + */ + join(separator?: string): string; + } + + interface LoDashExplicitWrapper { + /** + * @see _.join + */ + join(separator?: string): LoDashExplicitWrapper; + } + + interface LoDashExplicitArrayWrapper { + /** + * @see _.join + */ + join(separator?: string): LoDashExplicitWrapper; + } + + interface LoDashExplicitObjectWrapper { + /** + * @see _.join + */ + join(separator?: string): LoDashExplicitWrapper; } //_.pullAll DUMMY