mirror of
https://github.com/wassname/DefinitelyTyped.git
synced 2026-09-09 11:13:57 +08:00
lodash: changed _.mixin() method
This commit is contained in:
+15
-6
@@ -1652,12 +1652,6 @@ var testAttempFn: TestAttemptFn;
|
||||
result = <TResult|Error>_.attempt<TResult>(testAttempFn);
|
||||
result = <TResult|Error>_(testAttempFn).attempt<TResult>();
|
||||
|
||||
_.mixin({
|
||||
'capitalize': function (string) {
|
||||
return string.charAt(0).toUpperCase() + string.slice(1).toLowerCase();
|
||||
}
|
||||
});
|
||||
|
||||
var lodash = <typeof _>_.noConflict();
|
||||
|
||||
result = <number>_.random(0, 5);
|
||||
@@ -1939,6 +1933,21 @@ result = <number>(_.methodOf<number>(TestMethodOfObject, 1, 2))(['a', '0']);
|
||||
result = <number>(_(TestMethodOfObject).methodOf<number>(1, 2).value())('a[0]');
|
||||
result = <number>(_(TestMethodOfObject).methodOf<number>(1, 2).value())(['a', '0']);
|
||||
|
||||
// _.mixin
|
||||
{
|
||||
let testMixinSource: _.Dictionary<Function>;
|
||||
let testMixinOptions: {chain?: boolean;}
|
||||
let result: TResult;
|
||||
result = _.mixin<TResult, Object>({}, testMixinSource);
|
||||
result = _.mixin<TResult, Object>({}, testMixinSource, testMixinOptions);
|
||||
result = _.mixin<TResult>(testMixinSource);
|
||||
result = _.mixin<TResult>(testMixinSource, testMixinOptions);
|
||||
result = _({}).mixin<TResult>(testMixinSource).value();
|
||||
result = _({}).mixin<TResult>(testMixinSource, testMixinOptions).value();
|
||||
result = _(testMixinSource).mixin<TResult>().value();
|
||||
result = _(testMixinSource).mixin<TResult>(testMixinOptions).value();
|
||||
}
|
||||
|
||||
// _.uniqueId
|
||||
result = <string>_.uniqueId();
|
||||
result = <string>_.uniqueId('');
|
||||
|
||||
Vendored
+46
-4
@@ -8151,12 +8151,54 @@ declare module _ {
|
||||
}
|
||||
|
||||
//_.mixin
|
||||
interface MixinOptions {
|
||||
chain?: boolean;
|
||||
}
|
||||
|
||||
interface LoDashStatic {
|
||||
/**
|
||||
* Adds function properties of a source object to the lodash function and chainable wrapper.
|
||||
* @param object The object of function properties to add to lodash.
|
||||
**/
|
||||
mixin(object?: Dictionary<(value: any) => any>): void;
|
||||
* Adds all own enumerable function properties of a source object to the destination object. If object is a
|
||||
* function then methods are added to its prototype as well.
|
||||
*
|
||||
* Note: Use _.runInContext to create a pristine lodash function to avoid conflicts caused by modifying
|
||||
* the original.
|
||||
*
|
||||
* @param object The destination object.
|
||||
* @param source The object of functions to add.
|
||||
* @param options The options object.
|
||||
* @param options.chain Specify whether the functions added are chainable.
|
||||
* @return Returns object.
|
||||
*/
|
||||
mixin<TResult, TObject>(
|
||||
object: TObject,
|
||||
source: Dictionary<Function>,
|
||||
options?: MixinOptions
|
||||
): TResult;
|
||||
|
||||
/**
|
||||
* @see _.mixin
|
||||
*/
|
||||
mixin<TResult>(
|
||||
source: Dictionary<Function>,
|
||||
options?: MixinOptions
|
||||
): TResult;
|
||||
}
|
||||
|
||||
interface LoDashObjectWrapper<T> {
|
||||
/**
|
||||
* @see _.mixin
|
||||
*/
|
||||
mixin<TResult>(
|
||||
source: Dictionary<Function>,
|
||||
options?: MixinOptions
|
||||
): LoDashObjectWrapper<TResult>;
|
||||
|
||||
/**
|
||||
* @see _.mixin
|
||||
*/
|
||||
mixin<TResult>(
|
||||
options?: MixinOptions
|
||||
): LoDashObjectWrapper<TResult>;
|
||||
}
|
||||
|
||||
//_.noConflict
|
||||
|
||||
Reference in New Issue
Block a user