lodash-rails 2.3.0 → 2.4.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +1 -1
- data/lib/lodash/rails/version.rb +1 -1
- data/vendor/assets/javascripts/lodash.compat.js +373 -187
- data/vendor/assets/javascripts/lodash.compat.min.js +54 -52
- data/vendor/assets/javascripts/lodash.js +374 -199
- data/vendor/assets/javascripts/lodash.min.js +49 -49
- data/vendor/assets/javascripts/lodash.underscore.js +203 -134
- data/vendor/assets/javascripts/lodash.underscore.min.js +34 -34
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 0d865feba128fce2fa4242fef5509c1151d1f7c2
|
4
|
+
data.tar.gz: d75387730262868c079d3d736d06dc50866378a1
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: bdbf9635e91438de1a4a380c1e9ea1be90560d37b69759fd567c7b0042be8cc4fad3b5b5650e41f44646d859781be160734028893ed9beeeb3d790709c71b35e
|
7
|
+
data.tar.gz: a7ead375e03ba6bbd1e2e19c03ce295cb86ed5619eacb905dc7537c644ffac56e4c1af891611599098ad9c827733c77f46132f9ec91d7f9d8b1f753bdc748e10
|
data/README.md
CHANGED
data/lib/lodash/rails/version.rb
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
/**
|
2
2
|
* @license
|
3
|
-
* Lo-Dash 2.
|
3
|
+
* Lo-Dash 2.4.0 (Custom Build) <http://lodash.com/>
|
4
4
|
* Build: `lodash -o ./dist/lodash.compat.js`
|
5
5
|
* Copyright 2012-2013 The Dojo Foundation <http://dojofoundation.org/>
|
6
6
|
* Based on Underscore.js 1.5.2 <http://underscorejs.org/LICENSE>
|
@@ -50,7 +50,7 @@
|
|
50
50
|
|
51
51
|
/**
|
52
52
|
* Used to match ES6 template delimiters
|
53
|
-
* http://people.mozilla.org/~jorendorff/es6-draft.html#sec-
|
53
|
+
* http://people.mozilla.org/~jorendorff/es6-draft.html#sec-literals-string-literals
|
54
54
|
*/
|
55
55
|
var reEsTemplate = /\$\{([^\\}]*(?:\\.[^\\}]*)*)\}/g;
|
56
56
|
|
@@ -79,7 +79,7 @@
|
|
79
79
|
var contextProps = [
|
80
80
|
'Array', 'Boolean', 'Date', 'Error', 'Function', 'Math', 'Number', 'Object',
|
81
81
|
'RegExp', 'String', '_', 'attachEvent', 'clearTimeout', 'isFinite', 'isNaN',
|
82
|
-
'parseInt', '
|
82
|
+
'parseInt', 'setTimeout'
|
83
83
|
];
|
84
84
|
|
85
85
|
/** Used to fix the JScript [[DontEnum]] bug */
|
@@ -281,22 +281,29 @@
|
|
281
281
|
*/
|
282
282
|
function compareAscending(a, b) {
|
283
283
|
var ac = a.criteria,
|
284
|
-
bc = b.criteria
|
284
|
+
bc = b.criteria,
|
285
|
+
index = -1,
|
286
|
+
length = ac.length;
|
285
287
|
|
286
|
-
|
287
|
-
|
288
|
-
|
289
|
-
|
290
|
-
|
291
|
-
|
292
|
-
|
293
|
-
|
288
|
+
while (++index < length) {
|
289
|
+
var value = ac[index],
|
290
|
+
other = bc[index];
|
291
|
+
|
292
|
+
if (value !== other) {
|
293
|
+
if (value > other || typeof value == 'undefined') {
|
294
|
+
return 1;
|
295
|
+
}
|
296
|
+
if (value < other || typeof other == 'undefined') {
|
297
|
+
return -1;
|
298
|
+
}
|
294
299
|
}
|
295
300
|
}
|
296
|
-
//
|
297
|
-
//
|
298
|
-
//
|
299
|
-
//
|
301
|
+
// Fixes an `Array#sort` bug in the JS engine embedded in Adobe applications
|
302
|
+
// that causes it, under certain circumstances, to return the same value for
|
303
|
+
// `a` and `b`. See https://github.com/jashkenas/underscore/pull/1247
|
304
|
+
//
|
305
|
+
// This also ensures a stable sort in V8 and other engines.
|
306
|
+
// See http://code.google.com/p/v8/issues/detail?id=90
|
300
307
|
return a.index - b.index;
|
301
308
|
}
|
302
309
|
|
@@ -513,16 +520,11 @@
|
|
513
520
|
fnToString = Function.prototype.toString,
|
514
521
|
getPrototypeOf = reNative.test(getPrototypeOf = Object.getPrototypeOf) && getPrototypeOf,
|
515
522
|
hasOwnProperty = objectProto.hasOwnProperty,
|
516
|
-
now = reNative.test(now = Date.now) && now || function() { return +new Date; },
|
517
523
|
push = arrayRef.push,
|
518
524
|
propertyIsEnumerable = objectProto.propertyIsEnumerable,
|
519
525
|
setTimeout = context.setTimeout,
|
520
526
|
splice = arrayRef.splice;
|
521
527
|
|
522
|
-
/** Used to detect `setImmediate` in Node.js */
|
523
|
-
var setImmediate = typeof (setImmediate = freeGlobal && moduleExports && freeGlobal.setImmediate) == 'function' &&
|
524
|
-
!reNative.test(setImmediate) && setImmediate;
|
525
|
-
|
526
528
|
/** Used to set meta data on functions */
|
527
529
|
var defineProperty = (function() {
|
528
530
|
// IE 8 only accepts DOM elements
|
@@ -2477,22 +2479,22 @@
|
|
2477
2479
|
}
|
2478
2480
|
|
2479
2481
|
/**
|
2480
|
-
* Checks if the specified
|
2482
|
+
* Checks if the specified property name exists as a direct property of `object`,
|
2481
2483
|
* instead of an inherited property.
|
2482
2484
|
*
|
2483
2485
|
* @static
|
2484
2486
|
* @memberOf _
|
2485
2487
|
* @category Objects
|
2486
|
-
* @param {Object} object The object to
|
2487
|
-
* @param {string}
|
2488
|
+
* @param {Object} object The object to inspect.
|
2489
|
+
* @param {string} key The name of the property to check.
|
2488
2490
|
* @returns {boolean} Returns `true` if key is a direct property, else `false`.
|
2489
2491
|
* @example
|
2490
2492
|
*
|
2491
2493
|
* _.has({ 'a': 1, 'b': 2, 'c': 3 }, 'b');
|
2492
2494
|
* // => true
|
2493
2495
|
*/
|
2494
|
-
function has(object,
|
2495
|
-
return object ? hasOwnProperty.call(object,
|
2496
|
+
function has(object, key) {
|
2497
|
+
return object ? hasOwnProperty.call(object, key) : false;
|
2496
2498
|
}
|
2497
2499
|
|
2498
2500
|
/**
|
@@ -2505,7 +2507,7 @@
|
|
2505
2507
|
* @returns {Object} Returns the created inverted object.
|
2506
2508
|
* @example
|
2507
2509
|
*
|
2508
|
-
*
|
2510
|
+
* _.invert({ 'first': 'fred', 'second': 'barney' });
|
2509
2511
|
* // => { 'fred': 'first', 'barney': 'second' }
|
2510
2512
|
*/
|
2511
2513
|
function invert(object) {
|
@@ -2897,6 +2899,52 @@
|
|
2897
2899
|
return typeof value == 'undefined';
|
2898
2900
|
}
|
2899
2901
|
|
2902
|
+
/**
|
2903
|
+
* Creates an object with the same keys as `object` and values generated by
|
2904
|
+
* running each own enumerable property of `object` through the callback.
|
2905
|
+
* The callback is bound to `thisArg` and invoked with three arguments;
|
2906
|
+
* (value, key, object).
|
2907
|
+
*
|
2908
|
+
* If a property name is provided for `callback` the created "_.pluck" style
|
2909
|
+
* callback will return the property value of the given element.
|
2910
|
+
*
|
2911
|
+
* If an object is provided for `callback` the created "_.where" style callback
|
2912
|
+
* will return `true` for elements that have the properties of the given object,
|
2913
|
+
* else `false`.
|
2914
|
+
*
|
2915
|
+
* @static
|
2916
|
+
* @memberOf _
|
2917
|
+
* @category Objects
|
2918
|
+
* @param {Object} object The object to iterate over.
|
2919
|
+
* @param {Function|Object|string} [callback=identity] The function called
|
2920
|
+
* per iteration. If a property name or object is provided it will be used
|
2921
|
+
* to create a "_.pluck" or "_.where" style callback, respectively.
|
2922
|
+
* @param {*} [thisArg] The `this` binding of `callback`.
|
2923
|
+
* @returns {Array} Returns a new object with values of the results of each `callback` execution.
|
2924
|
+
* @example
|
2925
|
+
*
|
2926
|
+
* _.mapValues({ 'a': 1, 'b': 2, 'c': 3} , function(num) { return num * 3; });
|
2927
|
+
* // => { 'a': 3, 'b': 6, 'c': 9 }
|
2928
|
+
*
|
2929
|
+
* var characters = {
|
2930
|
+
* 'fred': { 'name': 'fred', 'age': 40 },
|
2931
|
+
* 'pebbles': { 'name': 'pebbles', 'age': 1 }
|
2932
|
+
* };
|
2933
|
+
*
|
2934
|
+
* // using "_.pluck" callback shorthand
|
2935
|
+
* _.mapValues(characters, 'age');
|
2936
|
+
* // => { 'fred': 40, 'pebbles': 1 }
|
2937
|
+
*/
|
2938
|
+
function mapValues(object, callback, thisArg) {
|
2939
|
+
var result = {};
|
2940
|
+
callback = lodash.createCallback(callback, thisArg, 3);
|
2941
|
+
|
2942
|
+
forOwn(object, function(value, key, object) {
|
2943
|
+
result[key] = callback(value, key, object);
|
2944
|
+
});
|
2945
|
+
return result;
|
2946
|
+
}
|
2947
|
+
|
2900
2948
|
/**
|
2901
2949
|
* Recursively merges own enumerable properties of the source object(s), that
|
2902
2950
|
* don't resolve to `undefined` into the destination object. Subsequent sources
|
@@ -2955,7 +3003,6 @@
|
|
2955
3003
|
if (!isObject(object)) {
|
2956
3004
|
return object;
|
2957
3005
|
}
|
2958
|
-
|
2959
3006
|
// allows working with `_.reduce` and `_.reduceRight` without using
|
2960
3007
|
// their `index` and `collection` arguments
|
2961
3008
|
if (typeof args[2] != 'number') {
|
@@ -3112,11 +3159,11 @@
|
|
3112
3159
|
|
3113
3160
|
/**
|
3114
3161
|
* An alternative to `_.reduce` this method transforms `object` to a new
|
3115
|
-
* `accumulator` object which is the result of running each of its
|
3116
|
-
* through a callback, with each callback execution
|
3117
|
-
* the `accumulator` object. The callback is bound to
|
3118
|
-
* with four arguments; (accumulator, value, key, object).
|
3119
|
-
* iteration early by explicitly returning `false`.
|
3162
|
+
* `accumulator` object which is the result of running each of its own
|
3163
|
+
* enumerable properties through a callback, with each callback execution
|
3164
|
+
* potentially mutating the `accumulator` object. The callback is bound to
|
3165
|
+
* `thisArg` and invoked with four arguments; (accumulator, value, key, object).
|
3166
|
+
* Callbacks may exit iteration early by explicitly returning `false`.
|
3120
3167
|
*
|
3121
3168
|
* @static
|
3122
3169
|
* @memberOf _
|
@@ -3955,7 +4002,7 @@
|
|
3955
4002
|
* @type Function
|
3956
4003
|
* @category Collections
|
3957
4004
|
* @param {Array|Object|string} collection The collection to iterate over.
|
3958
|
-
* @param {string} property The property to pluck.
|
4005
|
+
* @param {string} property The name of the property to pluck.
|
3959
4006
|
* @returns {Array} Returns a new array of property values.
|
3960
4007
|
* @example
|
3961
4008
|
*
|
@@ -4176,7 +4223,7 @@
|
|
4176
4223
|
* // => 3
|
4177
4224
|
*
|
4178
4225
|
* _.size('pebbles');
|
4179
|
-
* // =>
|
4226
|
+
* // => 7
|
4180
4227
|
*/
|
4181
4228
|
function size(collection) {
|
4182
4229
|
var length = collection ? collection.length : 0;
|
@@ -4256,6 +4303,9 @@
|
|
4256
4303
|
* If a property name is provided for `callback` the created "_.pluck" style
|
4257
4304
|
* callback will return the property value of the given element.
|
4258
4305
|
*
|
4306
|
+
* If an array of property names is provided for `callback` the collection
|
4307
|
+
* will be sorted by each property value.
|
4308
|
+
*
|
4259
4309
|
* If an object is provided for `callback` the created "_.where" style callback
|
4260
4310
|
* will return `true` for elements that have the properties of the given object,
|
4261
4311
|
* else `false`.
|
@@ -4264,7 +4314,7 @@
|
|
4264
4314
|
* @memberOf _
|
4265
4315
|
* @category Collections
|
4266
4316
|
* @param {Array|Object|string} collection The collection to iterate over.
|
4267
|
-
* @param {Function|Object|string} [callback=identity] The function called
|
4317
|
+
* @param {Array|Function|Object|string} [callback=identity] The function called
|
4268
4318
|
* per iteration. If a property name or object is provided it will be used
|
4269
4319
|
* to create a "_.pluck" or "_.where" style callback, respectively.
|
4270
4320
|
* @param {*} [thisArg] The `this` binding of `callback`.
|
@@ -4277,19 +4327,37 @@
|
|
4277
4327
|
* _.sortBy([1, 2, 3], function(num) { return this.sin(num); }, Math);
|
4278
4328
|
* // => [3, 1, 2]
|
4279
4329
|
*
|
4330
|
+
* var characters = [
|
4331
|
+
* { 'name': 'barney', 'age': 36 },
|
4332
|
+
* { 'name': 'fred', 'age': 40 },
|
4333
|
+
* { 'name': 'barney', 'age': 26 },
|
4334
|
+
* { 'name': 'fred', 'age': 30 }
|
4335
|
+
* ];
|
4336
|
+
*
|
4280
4337
|
* // using "_.pluck" callback shorthand
|
4281
|
-
* _.sortBy(
|
4282
|
-
* // => ['
|
4338
|
+
* _.map(_.sortBy(characters, 'age'), _.values);
|
4339
|
+
* // => [['barney', 26], ['fred', 30], ['barney', 36], ['fred', 40]]
|
4340
|
+
*
|
4341
|
+
* // sorting by multiple properties
|
4342
|
+
* _.map(_.sortBy(characters, ['name', 'age']), _.values);
|
4343
|
+
* // = > [['barney', 26], ['barney', 36], ['fred', 30], ['fred', 40]]
|
4283
4344
|
*/
|
4284
4345
|
function sortBy(collection, callback, thisArg) {
|
4285
4346
|
var index = -1,
|
4347
|
+
isArr = isArray(callback),
|
4286
4348
|
length = collection ? collection.length : 0,
|
4287
4349
|
result = Array(typeof length == 'number' ? length : 0);
|
4288
4350
|
|
4289
|
-
|
4351
|
+
if (!isArr) {
|
4352
|
+
callback = lodash.createCallback(callback, thisArg, 3);
|
4353
|
+
}
|
4290
4354
|
forEach(collection, function(value, key, collection) {
|
4291
4355
|
var object = result[++index] = getObject();
|
4292
|
-
|
4356
|
+
if (isArr) {
|
4357
|
+
object.criteria = map(callback, function(key) { return value[key]; });
|
4358
|
+
} else {
|
4359
|
+
(object.criteria = getArray())[0] = callback(value, key, collection);
|
4360
|
+
}
|
4293
4361
|
object.index = index;
|
4294
4362
|
object.value = value;
|
4295
4363
|
});
|
@@ -4299,6 +4367,9 @@
|
|
4299
4367
|
while (length--) {
|
4300
4368
|
var object = result[length];
|
4301
4369
|
result[length] = object.value;
|
4370
|
+
if (!isArr) {
|
4371
|
+
releaseArray(object.criteria);
|
4372
|
+
}
|
4302
4373
|
releaseObject(object);
|
4303
4374
|
}
|
4304
4375
|
return result;
|
@@ -4336,7 +4407,7 @@
|
|
4336
4407
|
* @type Function
|
4337
4408
|
* @category Collections
|
4338
4409
|
* @param {Array|Object|string} collection The collection to iterate over.
|
4339
|
-
* @param {Object}
|
4410
|
+
* @param {Object} props The object of property values to filter by.
|
4340
4411
|
* @returns {Array} Returns a new array of elements that have the given properties.
|
4341
4412
|
* @example
|
4342
4413
|
*
|
@@ -4741,29 +4812,34 @@
|
|
4741
4812
|
* @memberOf _
|
4742
4813
|
* @category Arrays
|
4743
4814
|
* @param {...Array} [array] The arrays to inspect.
|
4744
|
-
* @returns {Array} Returns an array of
|
4815
|
+
* @returns {Array} Returns an array of shared values.
|
4745
4816
|
* @example
|
4746
4817
|
*
|
4747
|
-
* _.intersection([1, 2, 3], [
|
4818
|
+
* _.intersection([1, 2, 3], [5, 2, 1, 4], [2, 1]);
|
4748
4819
|
* // => [1, 2]
|
4749
4820
|
*/
|
4750
|
-
function intersection(
|
4751
|
-
var args =
|
4752
|
-
argsLength = args.length,
|
4821
|
+
function intersection() {
|
4822
|
+
var args = [],
|
4753
4823
|
argsIndex = -1,
|
4824
|
+
argsLength = arguments.length,
|
4754
4825
|
caches = getArray(),
|
4755
|
-
index = -1,
|
4756
4826
|
indexOf = getIndexOf(),
|
4757
|
-
|
4758
|
-
result = [],
|
4827
|
+
trustIndexOf = indexOf === baseIndexOf,
|
4759
4828
|
seen = getArray();
|
4760
4829
|
|
4761
4830
|
while (++argsIndex < argsLength) {
|
4762
|
-
var value =
|
4763
|
-
|
4764
|
-
(value
|
4765
|
-
|
4831
|
+
var value = arguments[argsIndex];
|
4832
|
+
if (isArray(value) || isArguments(value)) {
|
4833
|
+
args.push(value);
|
4834
|
+
caches.push(trustIndexOf && value.length >= largeArraySize &&
|
4835
|
+
createCache(argsIndex ? args[argsIndex] : seen));
|
4836
|
+
}
|
4766
4837
|
}
|
4838
|
+
var array = args[0],
|
4839
|
+
index = -1,
|
4840
|
+
length = array ? array.length : 0,
|
4841
|
+
result = [];
|
4842
|
+
|
4767
4843
|
outer:
|
4768
4844
|
while (++index < length) {
|
4769
4845
|
var cache = caches[0];
|
@@ -5180,13 +5256,13 @@
|
|
5180
5256
|
* @memberOf _
|
5181
5257
|
* @category Arrays
|
5182
5258
|
* @param {...Array} [array] The arrays to inspect.
|
5183
|
-
* @returns {Array} Returns an array of
|
5259
|
+
* @returns {Array} Returns an array of combined values.
|
5184
5260
|
* @example
|
5185
5261
|
*
|
5186
|
-
* _.union([1, 2, 3], [
|
5187
|
-
* // => [1, 2, 3,
|
5262
|
+
* _.union([1, 2, 3], [5, 2, 1, 4], [2, 1]);
|
5263
|
+
* // => [1, 2, 3, 5, 4]
|
5188
5264
|
*/
|
5189
|
-
function union(
|
5265
|
+
function union() {
|
5190
5266
|
return baseUniq(baseFlatten(arguments, true, true));
|
5191
5267
|
}
|
5192
5268
|
|
@@ -5266,6 +5342,38 @@
|
|
5266
5342
|
return baseDifference(array, slice(arguments, 1));
|
5267
5343
|
}
|
5268
5344
|
|
5345
|
+
/**
|
5346
|
+
* Creates an array that is the smymetric difference of the provided arrays.
|
5347
|
+
* See http://en.wikipedia.org/wiki/Symmetric_difference.
|
5348
|
+
*
|
5349
|
+
* @static
|
5350
|
+
* @memberOf _
|
5351
|
+
* @category Arrays
|
5352
|
+
* @param {...Array} [array] The arrays to inspect.
|
5353
|
+
* @returns {Array} Returns an array of values.
|
5354
|
+
* @example
|
5355
|
+
*
|
5356
|
+
* _.xor([1, 2, 3], [5, 2, 1, 4]);
|
5357
|
+
* // => [3, 5, 4]
|
5358
|
+
*
|
5359
|
+
* _.xor([1, 2, 5], [2, 3, 5], [3, 4, 5]);
|
5360
|
+
* // => [1, 4, 5]
|
5361
|
+
*/
|
5362
|
+
function xor() {
|
5363
|
+
var index = -1,
|
5364
|
+
length = arguments.length;
|
5365
|
+
|
5366
|
+
while (++index < length) {
|
5367
|
+
var array = arguments[index];
|
5368
|
+
if (isArray(array) || isArguments(array)) {
|
5369
|
+
var result = result
|
5370
|
+
? baseUniq(baseDifference(result, array).concat(baseDifference(array, result)))
|
5371
|
+
: array;
|
5372
|
+
}
|
5373
|
+
}
|
5374
|
+
return result || [];
|
5375
|
+
}
|
5376
|
+
|
5269
5377
|
/**
|
5270
5378
|
* Creates an array of grouped elements, the first of which contains the first
|
5271
5379
|
* elements of the given arrays, the second of which contains the second
|
@@ -5317,6 +5425,9 @@
|
|
5317
5425
|
length = keys ? keys.length : 0,
|
5318
5426
|
result = {};
|
5319
5427
|
|
5428
|
+
if (!values && length && !isArray(keys[0])) {
|
5429
|
+
values = [];
|
5430
|
+
}
|
5320
5431
|
while (++index < length) {
|
5321
5432
|
var key = keys[index];
|
5322
5433
|
if (values) {
|
@@ -5409,8 +5520,8 @@
|
|
5409
5520
|
* @example
|
5410
5521
|
*
|
5411
5522
|
* var view = {
|
5412
|
-
*
|
5413
|
-
*
|
5523
|
+
* 'label': 'docs',
|
5524
|
+
* 'onClick': function() { console.log('clicked ' + this.label); }
|
5414
5525
|
* };
|
5415
5526
|
*
|
5416
5527
|
* _.bindAll(view);
|
@@ -5519,74 +5630,6 @@
|
|
5519
5630
|
};
|
5520
5631
|
}
|
5521
5632
|
|
5522
|
-
/**
|
5523
|
-
* Produces a callback bound to an optional `thisArg`. If `func` is a property
|
5524
|
-
* name the created callback will return the property value for a given element.
|
5525
|
-
* If `func` is an object the created callback will return `true` for elements
|
5526
|
-
* that contain the equivalent object properties, otherwise it will return `false`.
|
5527
|
-
*
|
5528
|
-
* @static
|
5529
|
-
* @memberOf _
|
5530
|
-
* @category Functions
|
5531
|
-
* @param {*} [func=identity] The value to convert to a callback.
|
5532
|
-
* @param {*} [thisArg] The `this` binding of the created callback.
|
5533
|
-
* @param {number} [argCount] The number of arguments the callback accepts.
|
5534
|
-
* @returns {Function} Returns a callback function.
|
5535
|
-
* @example
|
5536
|
-
*
|
5537
|
-
* var characters = [
|
5538
|
-
* { 'name': 'barney', 'age': 36 },
|
5539
|
-
* { 'name': 'fred', 'age': 40 }
|
5540
|
-
* ];
|
5541
|
-
*
|
5542
|
-
* // wrap to create custom callback shorthands
|
5543
|
-
* _.createCallback = _.wrap(_.createCallback, function(func, callback, thisArg) {
|
5544
|
-
* var match = /^(.+?)__([gl]t)(.+)$/.exec(callback);
|
5545
|
-
* return !match ? func(callback, thisArg) : function(object) {
|
5546
|
-
* return match[2] == 'gt' ? object[match[1]] > match[3] : object[match[1]] < match[3];
|
5547
|
-
* };
|
5548
|
-
* });
|
5549
|
-
*
|
5550
|
-
* _.filter(characters, 'age__gt38');
|
5551
|
-
* // => [{ 'name': 'fred', 'age': 40 }]
|
5552
|
-
*/
|
5553
|
-
function createCallback(func, thisArg, argCount) {
|
5554
|
-
var type = typeof func;
|
5555
|
-
if (func == null || type == 'function') {
|
5556
|
-
return baseCreateCallback(func, thisArg, argCount);
|
5557
|
-
}
|
5558
|
-
// handle "_.pluck" style callback shorthands
|
5559
|
-
if (type != 'object') {
|
5560
|
-
return function(object) {
|
5561
|
-
return object[func];
|
5562
|
-
};
|
5563
|
-
}
|
5564
|
-
var props = keys(func),
|
5565
|
-
key = props[0],
|
5566
|
-
a = func[key];
|
5567
|
-
|
5568
|
-
// handle "_.where" style callback shorthands
|
5569
|
-
if (props.length == 1 && a === a && !isObject(a)) {
|
5570
|
-
// fast path the common case of providing an object with a single
|
5571
|
-
// property containing a primitive value
|
5572
|
-
return function(object) {
|
5573
|
-
var b = object[key];
|
5574
|
-
return a === b && (a !== 0 || (1 / a == 1 / b));
|
5575
|
-
};
|
5576
|
-
}
|
5577
|
-
return function(object) {
|
5578
|
-
var length = props.length,
|
5579
|
-
result = false;
|
5580
|
-
|
5581
|
-
while (length--) {
|
5582
|
-
if (!(result = baseIsEqual(object[props[length]], func[props[length]], null, true))) {
|
5583
|
-
break;
|
5584
|
-
}
|
5585
|
-
}
|
5586
|
-
return result;
|
5587
|
-
};
|
5588
|
-
}
|
5589
|
-
|
5590
5633
|
/**
|
5591
5634
|
* Creates a function which accepts one or more arguments of `func` that when
|
5592
5635
|
* invoked either executes `func` returning its result, if all `func` arguments
|
@@ -5772,8 +5815,8 @@
|
|
5772
5815
|
* @returns {number} Returns the timer id.
|
5773
5816
|
* @example
|
5774
5817
|
*
|
5775
|
-
* _.defer(function() { console.log(
|
5776
|
-
* //
|
5818
|
+
* _.defer(function(text) { console.log(text); }, 'deferred');
|
5819
|
+
* // logs 'deferred' after one or more milliseconds
|
5777
5820
|
*/
|
5778
5821
|
function defer(func) {
|
5779
5822
|
if (!isFunction(func)) {
|
@@ -5782,15 +5825,6 @@
|
|
5782
5825
|
var args = slice(arguments, 1);
|
5783
5826
|
return setTimeout(function() { func.apply(undefined, args); }, 1);
|
5784
5827
|
}
|
5785
|
-
// use `setImmediate` if available in Node.js
|
5786
|
-
if (setImmediate) {
|
5787
|
-
defer = function(func) {
|
5788
|
-
if (!isFunction(func)) {
|
5789
|
-
throw new TypeError;
|
5790
|
-
}
|
5791
|
-
return setImmediate.apply(context, arguments);
|
5792
|
-
};
|
5793
|
-
}
|
5794
5828
|
|
5795
5829
|
/**
|
5796
5830
|
* Executes the `func` function after `wait` milliseconds. Additional arguments
|
@@ -5805,9 +5839,8 @@
|
|
5805
5839
|
* @returns {number} Returns the timer id.
|
5806
5840
|
* @example
|
5807
5841
|
*
|
5808
|
-
*
|
5809
|
-
*
|
5810
|
-
* // => 'logged later' (Appears after one second.)
|
5842
|
+
* _.delay(function(text) { console.log(text); }, 1000, 'later');
|
5843
|
+
* // => logs 'later' after one second
|
5811
5844
|
*/
|
5812
5845
|
function delay(func, wait) {
|
5813
5846
|
if (!isFunction(func)) {
|
@@ -6038,6 +6071,93 @@
|
|
6038
6071
|
|
6039
6072
|
/*--------------------------------------------------------------------------*/
|
6040
6073
|
|
6074
|
+
/**
|
6075
|
+
* Creates a function that returns `value`.
|
6076
|
+
*
|
6077
|
+
* @static
|
6078
|
+
* @memberOf _
|
6079
|
+
* @category Utilities
|
6080
|
+
* @param {*} value The value to return from the new function.
|
6081
|
+
* @returns {Function} Returns the new function.
|
6082
|
+
* @example
|
6083
|
+
*
|
6084
|
+
* var object = { 'name': 'fred' };
|
6085
|
+
* var getter = _.constant(object);
|
6086
|
+
* getter() === object;
|
6087
|
+
* // => true
|
6088
|
+
*/
|
6089
|
+
function constant(value) {
|
6090
|
+
return function() {
|
6091
|
+
return value;
|
6092
|
+
};
|
6093
|
+
}
|
6094
|
+
|
6095
|
+
/**
|
6096
|
+
* Produces a callback bound to an optional `thisArg`. If `func` is a property
|
6097
|
+
* name the created callback will return the property value for a given element.
|
6098
|
+
* If `func` is an object the created callback will return `true` for elements
|
6099
|
+
* that contain the equivalent object properties, otherwise it will return `false`.
|
6100
|
+
*
|
6101
|
+
* @static
|
6102
|
+
* @memberOf _
|
6103
|
+
* @category Utilities
|
6104
|
+
* @param {*} [func=identity] The value to convert to a callback.
|
6105
|
+
* @param {*} [thisArg] The `this` binding of the created callback.
|
6106
|
+
* @param {number} [argCount] The number of arguments the callback accepts.
|
6107
|
+
* @returns {Function} Returns a callback function.
|
6108
|
+
* @example
|
6109
|
+
*
|
6110
|
+
* var characters = [
|
6111
|
+
* { 'name': 'barney', 'age': 36 },
|
6112
|
+
* { 'name': 'fred', 'age': 40 }
|
6113
|
+
* ];
|
6114
|
+
*
|
6115
|
+
* // wrap to create custom callback shorthands
|
6116
|
+
* _.createCallback = _.wrap(_.createCallback, function(func, callback, thisArg) {
|
6117
|
+
* var match = /^(.+?)__([gl]t)(.+)$/.exec(callback);
|
6118
|
+
* return !match ? func(callback, thisArg) : function(object) {
|
6119
|
+
* return match[2] == 'gt' ? object[match[1]] > match[3] : object[match[1]] < match[3];
|
6120
|
+
* };
|
6121
|
+
* });
|
6122
|
+
*
|
6123
|
+
* _.filter(characters, 'age__gt38');
|
6124
|
+
* // => [{ 'name': 'fred', 'age': 40 }]
|
6125
|
+
*/
|
6126
|
+
function createCallback(func, thisArg, argCount) {
|
6127
|
+
var type = typeof func;
|
6128
|
+
if (func == null || type == 'function') {
|
6129
|
+
return baseCreateCallback(func, thisArg, argCount);
|
6130
|
+
}
|
6131
|
+
// handle "_.pluck" style callback shorthands
|
6132
|
+
if (type != 'object') {
|
6133
|
+
return property(func);
|
6134
|
+
}
|
6135
|
+
var props = keys(func),
|
6136
|
+
key = props[0],
|
6137
|
+
a = func[key];
|
6138
|
+
|
6139
|
+
// handle "_.where" style callback shorthands
|
6140
|
+
if (props.length == 1 && a === a && !isObject(a)) {
|
6141
|
+
// fast path the common case of providing an object with a single
|
6142
|
+
// property containing a primitive value
|
6143
|
+
return function(object) {
|
6144
|
+
var b = object[key];
|
6145
|
+
return a === b && (a !== 0 || (1 / a == 1 / b));
|
6146
|
+
};
|
6147
|
+
}
|
6148
|
+
return function(object) {
|
6149
|
+
var length = props.length,
|
6150
|
+
result = false;
|
6151
|
+
|
6152
|
+
while (length--) {
|
6153
|
+
if (!(result = baseIsEqual(object[props[length]], func[props[length]], null, true))) {
|
6154
|
+
break;
|
6155
|
+
}
|
6156
|
+
}
|
6157
|
+
return result;
|
6158
|
+
};
|
6159
|
+
}
|
6160
|
+
|
6041
6161
|
/**
|
6042
6162
|
* Converts the characters `&`, `<`, `>`, `"`, and `'` in `string` to their
|
6043
6163
|
* corresponding HTML entities.
|
@@ -6075,51 +6195,71 @@
|
|
6075
6195
|
}
|
6076
6196
|
|
6077
6197
|
/**
|
6078
|
-
* Adds function properties of a source object to the
|
6079
|
-
*
|
6198
|
+
* Adds function properties of a source object to the destination object.
|
6199
|
+
* If `object` is a function methods will be added to its prototype as well.
|
6080
6200
|
*
|
6081
6201
|
* @static
|
6082
6202
|
* @memberOf _
|
6083
6203
|
* @category Utilities
|
6084
|
-
* @param {Object} object
|
6085
|
-
* @param {Object}
|
6204
|
+
* @param {Function|Object} [object=lodash] object The destination object.
|
6205
|
+
* @param {Object} source The object of functions to add.
|
6206
|
+
* @param {Object} [options] The options object.
|
6207
|
+
* @param {boolean} [options.chain=true] Specify whether the functions added are chainable.
|
6086
6208
|
* @example
|
6087
6209
|
*
|
6088
|
-
*
|
6089
|
-
*
|
6090
|
-
*
|
6091
|
-
* }
|
6092
|
-
* });
|
6210
|
+
* function capitalize(string) {
|
6211
|
+
* return string.charAt(0).toUpperCase() + string.slice(1).toLowerCase();
|
6212
|
+
* }
|
6093
6213
|
*
|
6214
|
+
* _.mixin({ 'capitalize': capitalize });
|
6094
6215
|
* _.capitalize('fred');
|
6095
6216
|
* // => 'Fred'
|
6096
6217
|
*
|
6218
|
+
* _('fred').capitalize().value();
|
6219
|
+
* // => 'Fred'
|
6220
|
+
*
|
6221
|
+
* _.mixin({ 'capitalize': capitalize }, { 'chain': false });
|
6097
6222
|
* _('fred').capitalize();
|
6098
6223
|
* // => 'Fred'
|
6099
6224
|
*/
|
6100
|
-
function mixin(object, source) {
|
6101
|
-
var
|
6102
|
-
|
6225
|
+
function mixin(object, source, options) {
|
6226
|
+
var chain = true,
|
6227
|
+
methodNames = source && functions(source);
|
6103
6228
|
|
6104
|
-
if (!source) {
|
6229
|
+
if (!source || (!options && !methodNames.length)) {
|
6230
|
+
if (options == null) {
|
6231
|
+
options = source;
|
6232
|
+
}
|
6105
6233
|
ctor = lodashWrapper;
|
6106
6234
|
source = object;
|
6107
6235
|
object = lodash;
|
6236
|
+
methodNames = functions(source);
|
6108
6237
|
}
|
6109
|
-
|
6238
|
+
if (options === false) {
|
6239
|
+
chain = false;
|
6240
|
+
} else if (isObject(options) && 'chain' in options) {
|
6241
|
+
chain = options.chain;
|
6242
|
+
}
|
6243
|
+
var ctor = object,
|
6244
|
+
isFunc = isFunction(ctor);
|
6245
|
+
|
6246
|
+
forEach(methodNames, function(methodName) {
|
6110
6247
|
var func = object[methodName] = source[methodName];
|
6111
6248
|
if (isFunc) {
|
6112
6249
|
ctor.prototype[methodName] = function() {
|
6113
|
-
var
|
6250
|
+
var chainAll = this.__chain__,
|
6251
|
+
value = this.__wrapped__,
|
6114
6252
|
args = [value];
|
6115
6253
|
|
6116
6254
|
push.apply(args, arguments);
|
6117
6255
|
var result = func.apply(object, args);
|
6118
|
-
if (
|
6119
|
-
|
6256
|
+
if (chain || chainAll) {
|
6257
|
+
if (value === result && isObject(result)) {
|
6258
|
+
return this;
|
6259
|
+
}
|
6260
|
+
result = new ctor(result);
|
6261
|
+
result.__chain__ = chainAll;
|
6120
6262
|
}
|
6121
|
-
result = new ctor(result);
|
6122
|
-
result.__chain__ = this.__chain__;
|
6123
6263
|
return result;
|
6124
6264
|
};
|
6125
6265
|
}
|
@@ -6159,6 +6299,23 @@
|
|
6159
6299
|
// no operation performed
|
6160
6300
|
}
|
6161
6301
|
|
6302
|
+
/**
|
6303
|
+
* Gets the number of milliseconds that have elapsed since the Unix epoch
|
6304
|
+
* (1 January 1970 00:00:00 UTC).
|
6305
|
+
*
|
6306
|
+
* @static
|
6307
|
+
* @memberOf _
|
6308
|
+
* @category Utilities
|
6309
|
+
* @example
|
6310
|
+
*
|
6311
|
+
* var stamp = _.now();
|
6312
|
+
* _.defer(function() { console.log(_.now() - stamp); });
|
6313
|
+
* // => logs the number of milliseconds it took for the deferred function to be called
|
6314
|
+
*/
|
6315
|
+
var now = reNative.test(now = Date.now) && now || function() {
|
6316
|
+
return new Date().getTime();
|
6317
|
+
};
|
6318
|
+
|
6162
6319
|
/**
|
6163
6320
|
* Converts the given value into an integer of the specified radix.
|
6164
6321
|
* If `radix` is `undefined` or `0` a `radix` of `10` is used unless the
|
@@ -6183,6 +6340,36 @@
|
|
6183
6340
|
return nativeParseInt(isString(value) ? value.replace(reLeadingSpacesAndZeros, '') : value, radix || 0);
|
6184
6341
|
};
|
6185
6342
|
|
6343
|
+
/**
|
6344
|
+
* Creates a "_.pluck" style function, which returns the `key` value of a
|
6345
|
+
* given object.
|
6346
|
+
*
|
6347
|
+
* @static
|
6348
|
+
* @memberOf _
|
6349
|
+
* @category Utilities
|
6350
|
+
* @param {string} key The name of the property to retrieve.
|
6351
|
+
* @returns {Function} Returns the new function.
|
6352
|
+
* @example
|
6353
|
+
*
|
6354
|
+
* var characters = [
|
6355
|
+
* { 'name': 'fred', 'age': 40 },
|
6356
|
+
* { 'name': 'barney', 'age': 36 }
|
6357
|
+
* ];
|
6358
|
+
*
|
6359
|
+
* var getName = _.property('name');
|
6360
|
+
*
|
6361
|
+
* _.map(characters, getName);
|
6362
|
+
* // => ['barney', 'fred']
|
6363
|
+
*
|
6364
|
+
* _.sortBy(characters, getName);
|
6365
|
+
* // => [{ 'name': 'barney', 'age': 36 }, { 'name': 'fred', 'age': 40 }]
|
6366
|
+
*/
|
6367
|
+
function property(key) {
|
6368
|
+
return function(object) {
|
6369
|
+
return object[key];
|
6370
|
+
};
|
6371
|
+
}
|
6372
|
+
|
6186
6373
|
/**
|
6187
6374
|
* Produces a random number between `min` and `max` (inclusive). If only one
|
6188
6375
|
* argument is provided a number between `0` and the given number will be
|
@@ -6242,7 +6429,7 @@
|
|
6242
6429
|
}
|
6243
6430
|
|
6244
6431
|
/**
|
6245
|
-
* Resolves the value of
|
6432
|
+
* Resolves the value of property `key` on `object`. If `key` is a function
|
6246
6433
|
* it will be invoked with the `this` binding of `object` and its result returned,
|
6247
6434
|
* else the property value is returned. If `object` is falsey then `undefined`
|
6248
6435
|
* is returned.
|
@@ -6251,7 +6438,7 @@
|
|
6251
6438
|
* @memberOf _
|
6252
6439
|
* @category Utilities
|
6253
6440
|
* @param {Object} object The object to inspect.
|
6254
|
-
* @param {string}
|
6441
|
+
* @param {string} key The name of the property to resolve.
|
6255
6442
|
* @returns {*} Returns the resolved value.
|
6256
6443
|
* @example
|
6257
6444
|
*
|
@@ -6268,10 +6455,10 @@
|
|
6268
6455
|
* _.result(object, 'stuff');
|
6269
6456
|
* // => 'nonsense'
|
6270
6457
|
*/
|
6271
|
-
function result(object,
|
6458
|
+
function result(object, key) {
|
6272
6459
|
if (object) {
|
6273
|
-
var value = object[
|
6274
|
-
return isFunction(value) ? object[
|
6460
|
+
var value = object[key];
|
6461
|
+
return isFunction(value) ? object[key]() : value;
|
6275
6462
|
}
|
6276
6463
|
}
|
6277
6464
|
|
@@ -6335,8 +6522,8 @@
|
|
6335
6522
|
* // => 'hello mustache!'
|
6336
6523
|
*
|
6337
6524
|
* // using the `imports` option to import jQuery
|
6338
|
-
* var list = '<%
|
6339
|
-
* _.template(list, { 'people': ['fred', 'barney'] }, { 'imports': { '
|
6525
|
+
* var list = '<% jq.each(people, function(name) { %><li><%- name %></li><% }); %>';
|
6526
|
+
* _.template(list, { 'people': ['fred', 'barney'] }, { 'imports': { 'jq': jQuery } });
|
6340
6527
|
* // => '<li>fred</li><li>barney</li>'
|
6341
6528
|
*
|
6342
6529
|
* // using the `sourceURL` option to specify a custom sourceURL for the template
|
@@ -6615,7 +6802,7 @@
|
|
6615
6802
|
* _(characters).chain()
|
6616
6803
|
* .first()
|
6617
6804
|
* .pick('age')
|
6618
|
-
* .value()
|
6805
|
+
* .value();
|
6619
6806
|
* // => { 'age': 36 }
|
6620
6807
|
*/
|
6621
6808
|
function wrapperChain() {
|
@@ -6668,6 +6855,7 @@
|
|
6668
6855
|
lodash.chain = chain;
|
6669
6856
|
lodash.compact = compact;
|
6670
6857
|
lodash.compose = compose;
|
6858
|
+
lodash.constant = constant;
|
6671
6859
|
lodash.countBy = countBy;
|
6672
6860
|
lodash.create = create;
|
6673
6861
|
lodash.createCallback = createCallback;
|
@@ -6694,6 +6882,7 @@
|
|
6694
6882
|
lodash.invoke = invoke;
|
6695
6883
|
lodash.keys = keys;
|
6696
6884
|
lodash.map = map;
|
6885
|
+
lodash.mapValues = mapValues;
|
6697
6886
|
lodash.max = max;
|
6698
6887
|
lodash.memoize = memoize;
|
6699
6888
|
lodash.merge = merge;
|
@@ -6705,6 +6894,7 @@
|
|
6705
6894
|
lodash.partialRight = partialRight;
|
6706
6895
|
lodash.pick = pick;
|
6707
6896
|
lodash.pluck = pluck;
|
6897
|
+
lodash.property = property;
|
6708
6898
|
lodash.pull = pull;
|
6709
6899
|
lodash.range = range;
|
6710
6900
|
lodash.reject = reject;
|
@@ -6723,6 +6913,7 @@
|
|
6723
6913
|
lodash.where = where;
|
6724
6914
|
lodash.without = without;
|
6725
6915
|
lodash.wrap = wrap;
|
6916
|
+
lodash.xor = xor;
|
6726
6917
|
lodash.zip = zip;
|
6727
6918
|
lodash.zipObject = zipObject;
|
6728
6919
|
|
@@ -6780,6 +6971,7 @@
|
|
6780
6971
|
lodash.mixin = mixin;
|
6781
6972
|
lodash.noConflict = noConflict;
|
6782
6973
|
lodash.noop = noop;
|
6974
|
+
lodash.now = now;
|
6783
6975
|
lodash.parseInt = parseInt;
|
6784
6976
|
lodash.random = random;
|
6785
6977
|
lodash.reduce = reduce;
|
@@ -6803,20 +6995,15 @@
|
|
6803
6995
|
lodash.include = contains;
|
6804
6996
|
lodash.inject = reduce;
|
6805
6997
|
|
6806
|
-
|
6807
|
-
|
6808
|
-
|
6809
|
-
|
6810
|
-
|
6811
|
-
|
6812
|
-
|
6813
|
-
|
6814
|
-
|
6815
|
-
? new lodashWrapper(result, chainAll)
|
6816
|
-
: result;
|
6817
|
-
};
|
6818
|
-
}
|
6819
|
-
});
|
6998
|
+
mixin(function() {
|
6999
|
+
var source = {}
|
7000
|
+
forOwn(lodash, function(func, methodName) {
|
7001
|
+
if (!lodash.prototype[methodName]) {
|
7002
|
+
source[methodName] = func;
|
7003
|
+
}
|
7004
|
+
});
|
7005
|
+
return source;
|
7006
|
+
}(), false);
|
6820
7007
|
|
6821
7008
|
/*--------------------------------------------------------------------------*/
|
6822
7009
|
|
@@ -6852,7 +7039,7 @@
|
|
6852
7039
|
* @memberOf _
|
6853
7040
|
* @type string
|
6854
7041
|
*/
|
6855
|
-
lodash.VERSION = '2.
|
7042
|
+
lodash.VERSION = '2.4.0';
|
6856
7043
|
|
6857
7044
|
// add "Chaining" functions to the wrapper
|
6858
7045
|
lodash.prototype.chain = wrapperChain;
|
@@ -6873,7 +7060,7 @@
|
|
6873
7060
|
};
|
6874
7061
|
});
|
6875
7062
|
|
6876
|
-
// add `Array` functions that return the wrapped value
|
7063
|
+
// add `Array` functions that return the existing wrapped value
|
6877
7064
|
baseEach(['push', 'reverse', 'sort', 'unshift'], function(methodName) {
|
6878
7065
|
var func = arrayRef[methodName];
|
6879
7066
|
lodash.prototype[methodName] = function() {
|
@@ -6923,9 +7110,8 @@
|
|
6923
7110
|
// some AMD build optimizers like r.js check for condition patterns like the following:
|
6924
7111
|
if (typeof define == 'function' && typeof define.amd == 'object' && define.amd) {
|
6925
7112
|
// Expose Lo-Dash to the global object even when an AMD loader is present in
|
6926
|
-
// case Lo-Dash
|
6927
|
-
//
|
6928
|
-
// module by its `noConflict()` method.
|
7113
|
+
// case Lo-Dash is loaded with a RequireJS shim config.
|
7114
|
+
// See http://requirejs.org/docs/api.html#config-shim
|
6929
7115
|
root._ = _;
|
6930
7116
|
|
6931
7117
|
// define as an anonymous module so, through path mapping, it can be
|