mirror of
https://github.com/whoisclebs/lodash.git
synced 2026-02-07 10:07:48 +00:00
Bump to v3.0.0.
This commit is contained in:
22
lodash.mixin/LICENSE.txt
Normal file
22
lodash.mixin/LICENSE.txt
Normal file
@@ -0,0 +1,22 @@
|
||||
Copyright 2012-2015 The Dojo Foundation <http://dojofoundation.org/>
|
||||
Based on Underscore.js 1.7.0, copyright 2009-2015 Jeremy Ashkenas,
|
||||
DocumentCloud and Investigative Reporters & Editors <http://underscorejs.org/>
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining
|
||||
a copy of this software and associated documentation files (the
|
||||
"Software"), to deal in the Software without restriction, including
|
||||
without limitation the rights to use, copy, modify, merge, publish,
|
||||
distribute, sublicense, and/or sell copies of the Software, and to
|
||||
permit persons to whom the Software is furnished to do so, subject to
|
||||
the following conditions:
|
||||
|
||||
The above copyright notice and this permission notice shall be
|
||||
included in all copies or substantial portions of the Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
||||
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
||||
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
||||
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
||||
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
||||
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
||||
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
20
lodash.mixin/README.md
Normal file
20
lodash.mixin/README.md
Normal file
@@ -0,0 +1,20 @@
|
||||
# lodash.mixin v3.0.0
|
||||
|
||||
The [modern build](https://github.com/lodash/lodash/wiki/Build-Differences) of [lodash’s](https://lodash.com/) `_.mixin` exported as a [Node.js](http://nodejs.org/)/[io.js](https://iojs.org/) module.
|
||||
|
||||
## Installation
|
||||
|
||||
Using npm:
|
||||
|
||||
```bash
|
||||
$ {sudo -H} npm i -g npm
|
||||
$ npm i --save lodash.mixin
|
||||
```
|
||||
|
||||
In Node.js/io.js:
|
||||
|
||||
```js
|
||||
var mixin = require('lodash.mixin');
|
||||
```
|
||||
|
||||
See the [documentation](https://lodash.com/docs#mixin) or [package source](https://github.com/lodash/lodash/blob/3.0.0-npm-packages/lodash.mixin) for more details.
|
||||
123
lodash.mixin/index.js
Normal file
123
lodash.mixin/index.js
Normal file
@@ -0,0 +1,123 @@
|
||||
/**
|
||||
* lodash 3.0.0 (Custom Build) <https://lodash.com/>
|
||||
* Build: `lodash modern modularize exports="npm" -o ./`
|
||||
* Copyright 2012-2015 The Dojo Foundation <http://dojofoundation.org/>
|
||||
* Based on Underscore.js 1.7.0 <http://underscorejs.org/LICENSE>
|
||||
* Copyright 2009-2015 Jeremy Ashkenas, DocumentCloud and Investigative Reporters & Editors
|
||||
* Available under MIT license <https://lodash.com/license>
|
||||
*/
|
||||
var arrayCopy = require('lodash._arraycopy'),
|
||||
baseFunctions = require('lodash._basefunctions'),
|
||||
isFunction = require('lodash.isfunction'),
|
||||
keys = require('lodash.keys');
|
||||
|
||||
/** Used for native method references. */
|
||||
var arrayProto = Array.prototype;
|
||||
|
||||
/** Native method references. */
|
||||
var push = arrayProto.push;
|
||||
|
||||
/**
|
||||
* Checks if `value` is the language type of `Object`.
|
||||
* (e.g. arrays, functions, objects, regexes, `new Number(0)`, and `new String('')`)
|
||||
*
|
||||
* **Note:** See the [ES5 spec](https://es5.github.io/#x8) for more details.
|
||||
*
|
||||
* @static
|
||||
* @memberOf _
|
||||
* @category Lang
|
||||
* @param {*} value The value to check.
|
||||
* @returns {boolean} Returns `true` if `value` is an object, else `false`.
|
||||
* @example
|
||||
*
|
||||
* _.isObject({});
|
||||
* // => true
|
||||
*
|
||||
* _.isObject([1, 2, 3]);
|
||||
* // => true
|
||||
*
|
||||
* _.isObject(1);
|
||||
* // => false
|
||||
*/
|
||||
function isObject(value) {
|
||||
// Avoid a V8 JIT bug in Chrome 19-20.
|
||||
// See https://code.google.com/p/v8/issues/detail?id=2291 for more details.
|
||||
var type = typeof value;
|
||||
return type == 'function' || (value && type == 'object') || false;
|
||||
}
|
||||
|
||||
/**
|
||||
* 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.
|
||||
*
|
||||
* @static
|
||||
* @memberOf _
|
||||
* @category Utility
|
||||
* @param {Function|Object} [object=this] object The destination object.
|
||||
* @param {Object} source The object of functions to add.
|
||||
* @param {Object} [options] The options object.
|
||||
* @param {boolean} [options.chain=true] Specify whether the functions added
|
||||
* are chainable.
|
||||
* @returns {Function|Object} Returns `object`.
|
||||
* @example
|
||||
*
|
||||
* function vowels(string) {
|
||||
* return _.filter(string, function(v) {
|
||||
* return /[aeiou]/i.test(v);
|
||||
* });
|
||||
* }
|
||||
*
|
||||
* // use `_.runInContext` to avoid potential conflicts (esp. in Node.js)
|
||||
* var _ = require('lodash').runInContext();
|
||||
*
|
||||
* _.mixin({ 'vowels': vowels });
|
||||
* _.vowels('fred');
|
||||
* // => ['e']
|
||||
*
|
||||
* _('fred').vowels().value();
|
||||
* // => ['e']
|
||||
*
|
||||
* _.mixin({ 'vowels': vowels }, { 'chain': false });
|
||||
* _('fred').vowels();
|
||||
* // => ['e']
|
||||
*/
|
||||
function mixin(object, source, options) {
|
||||
var methodNames = baseFunctions(source, keys(source));
|
||||
|
||||
var chain = true,
|
||||
index = -1,
|
||||
isFunc = isFunction(object),
|
||||
length = methodNames.length;
|
||||
|
||||
if (options === false) {
|
||||
chain = false;
|
||||
} else if (isObject(options) && 'chain' in options) {
|
||||
chain = options.chain;
|
||||
}
|
||||
while (++index < length) {
|
||||
var methodName = methodNames[index],
|
||||
func = source[methodName];
|
||||
|
||||
object[methodName] = func;
|
||||
if (isFunc) {
|
||||
object.prototype[methodName] = (function(func) {
|
||||
return function() {
|
||||
var chainAll = this.__chain__;
|
||||
if (chain || chainAll) {
|
||||
var result = object(this.__wrapped__);
|
||||
(result.__actions__ = arrayCopy(this.__actions__)).push({ 'func': func, 'args': arguments, 'thisArg': object });
|
||||
result.__chain__ = chainAll;
|
||||
return result;
|
||||
}
|
||||
var args = [this.value()];
|
||||
push.apply(args, arguments);
|
||||
return func.apply(object, args);
|
||||
};
|
||||
}(func));
|
||||
}
|
||||
}
|
||||
return object;
|
||||
}
|
||||
|
||||
module.exports = mixin;
|
||||
25
lodash.mixin/package.json
Normal file
25
lodash.mixin/package.json
Normal file
@@ -0,0 +1,25 @@
|
||||
{
|
||||
"name": "lodash.mixin",
|
||||
"version": "3.0.0",
|
||||
"description": "The modern build of lodash’s `_.mixin` as a module.",
|
||||
"homepage": "https://lodash.com/",
|
||||
"icon": "https://lodash.com/icon.svg",
|
||||
"license": "MIT",
|
||||
"keywords": "lodash, lodash-modularized, stdlib, util",
|
||||
"author": "John-David Dalton <john.david.dalton@gmail.com> (http://allyoucanleet.com/)",
|
||||
"contributors": [
|
||||
"John-David Dalton <john.david.dalton@gmail.com> (http://allyoucanleet.com/)",
|
||||
"Benjamin Tan <demoneaux@gmail.com> (https://d10.github.io/)",
|
||||
"Blaine Bublitz <blaine@iceddev.com> (http://www.iceddev.com/)",
|
||||
"Kit Cambridge <github@kitcambridge.be> (http://kitcambridge.be/)",
|
||||
"Mathias Bynens <mathias@qiwi.be> (https://mathiasbynens.be/)"
|
||||
],
|
||||
"repository": "lodash/lodash",
|
||||
"scripts": { "test": "echo \"See https://travis-ci.org/lodash/lodash-cli for testing details.\"" },
|
||||
"dependencies": {
|
||||
"lodash._arraycopy": "^3.0.0",
|
||||
"lodash._basefunctions": "^3.0.0",
|
||||
"lodash.isfunction": "^3.0.0",
|
||||
"lodash.keys": "^3.0.0"
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user