4.17.11
3.10.1
2.4.2
1.3.1
_.mixin([object=lodash], source, [options={}])
Adds all own enumerable string keyed 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.
Since
0.1.0
Arguments
argument
[object=lodash]
source
[options={}]
[options.chain=true]
type
(Function|Object)
Object
Object
boolean
description
The destination object.
The object of functions to add.
The options object.
Specify whether mixins are chainable.
Returns
(array)
Example
function vowels(string) {
return _.filter(string, function (v) {
return /[aeiou]/i.test(v);
});
}
_.mixin({ vowels: vowels });
_.vowels("fred");
// => ['e']
_("fred").vowels().value();
// => ['e']
_.mixin(
{ vowels: vowels },
{ chain: false }
);
_("fred").vowels();
// => ['e']
function vowels(string) {
return _.filter(string, function (v) {
return /[aeiou]/i.test(v);
});
}
_.mixin({ vowels: vowels });
_.vowels("fred");
// => ['e']
_("fred").vowels().value();
// => ['e']
_.mixin({ vowels: vowels }, { chain: false });
_("fred").vowels();
// => ['e']