mirror of
https://github.com/whoisclebs/lodash.git
synced 2026-02-04 00:57:48 +00:00
Bump to v3.3.0.
This commit is contained in:
@@ -23,7 +23,9 @@ define(['../internal/baseCopy', '../internal/baseCreate', '../internal/isIterate
|
||||
* Shape.call(this);
|
||||
* }
|
||||
*
|
||||
* Circle.prototype = _.create(Shape.prototype, { 'constructor': Circle });
|
||||
* Circle.prototype = _.create(Shape.prototype, {
|
||||
* 'constructor': Circle
|
||||
* });
|
||||
*
|
||||
* var circle = new Circle;
|
||||
* circle instanceof Circle;
|
||||
|
||||
@@ -31,7 +31,9 @@ define(['../internal/baseCallback', '../internal/baseFind', '../internal/baseFor
|
||||
* 'pebbles': { 'age': 1, 'active': true }
|
||||
* };
|
||||
*
|
||||
* _.findKey(users, function(chr) { return chr.age < 40; });
|
||||
* _.findKey(users, function(chr) {
|
||||
* return chr.age < 40;
|
||||
* });
|
||||
* // => 'barney' (iteration order is not guaranteed)
|
||||
*
|
||||
* // using the `_.matches` callback shorthand
|
||||
|
||||
@@ -31,7 +31,9 @@ define(['../internal/baseCallback', '../internal/baseFind', '../internal/baseFor
|
||||
* 'pebbles': { 'age': 1, 'active': true }
|
||||
* };
|
||||
*
|
||||
* _.findLastKey(users, function(chr) { return chr.age < 40; });
|
||||
* _.findLastKey(users, function(chr) {
|
||||
* return chr.age < 40;
|
||||
* });
|
||||
* // => returns `pebbles` assuming `_.findKey` returns `barney`
|
||||
*
|
||||
* // using the `_.matches` callback shorthand
|
||||
|
||||
@@ -15,10 +15,17 @@ define(['../internal/baseForOwn', '../internal/bindCallback'], function(baseForO
|
||||
* @returns {Object} Returns `object`.
|
||||
* @example
|
||||
*
|
||||
* _.forOwn({ '0': 'zero', '1': 'one', 'length': 2 }, function(n, key) {
|
||||
* function Foo() {
|
||||
* this.a = 1;
|
||||
* this.b = 2;
|
||||
* }
|
||||
*
|
||||
* Foo.prototype.c = 3;
|
||||
*
|
||||
* _.forOwn(new Foo, function(value, key) {
|
||||
* console.log(key);
|
||||
* });
|
||||
* // => logs '0', '1', and 'length' (iteration order is not guaranteed)
|
||||
* // => logs 'a' and 'b' (iteration order is not guaranteed)
|
||||
*/
|
||||
function forOwn(object, iteratee, thisArg) {
|
||||
if (typeof iteratee != 'function' || typeof thisArg != 'undefined') {
|
||||
|
||||
@@ -13,10 +13,17 @@ define(['../internal/baseForRight', '../internal/bindCallback', './keys'], funct
|
||||
* @returns {Object} Returns `object`.
|
||||
* @example
|
||||
*
|
||||
* _.forOwnRight({ '0': 'zero', '1': 'one', 'length': 2 }, function(n, key) {
|
||||
* function Foo() {
|
||||
* this.a = 1;
|
||||
* this.b = 2;
|
||||
* }
|
||||
*
|
||||
* Foo.prototype.c = 3;
|
||||
*
|
||||
* _.forOwnRight(new Foo, function(value, key) {
|
||||
* console.log(key);
|
||||
* });
|
||||
* // => logs 'length', '1', and '0' assuming `_.forOwn` logs '0', '1', and 'length'
|
||||
* // => logs 'b' and 'a' assuming `_.forOwn` logs 'a' and 'b'
|
||||
*/
|
||||
function forOwnRight(object, iteratee, thisArg) {
|
||||
iteratee = bindCallback(iteratee, thisArg, 3);
|
||||
|
||||
@@ -13,7 +13,7 @@ define(['../internal/baseFunctions', './keysIn'], function(baseFunctions, keysIn
|
||||
* @example
|
||||
*
|
||||
* _.functions(_);
|
||||
* // => ['all', 'any', 'bind', ...]
|
||||
* // => ['after', 'ary', 'assign', ...]
|
||||
*/
|
||||
function functions(object) {
|
||||
return baseFunctions(object, keysIn(object));
|
||||
|
||||
@@ -18,7 +18,9 @@ define([], function() {
|
||||
* @returns {boolean} Returns `true` if `key` is a direct property, else `false`.
|
||||
* @example
|
||||
*
|
||||
* _.has({ 'a': 1, 'b': 2, 'c': 3 }, 'b');
|
||||
* var object = { 'a': 1, 'b': 2, 'c': 3 };
|
||||
*
|
||||
* _.has(object, 'b');
|
||||
* // => true
|
||||
*/
|
||||
function has(object, key) {
|
||||
|
||||
@@ -20,16 +20,14 @@ define(['../internal/isIterateeCall', './keys'], function(isIterateeCall, keys)
|
||||
* @returns {Object} Returns the new inverted object.
|
||||
* @example
|
||||
*
|
||||
* _.invert({ 'first': 'fred', 'second': 'barney' });
|
||||
* // => { 'fred': 'first', 'barney': 'second' }
|
||||
* var object = { 'a': 1, 'b': 2, 'c': 1 };
|
||||
*
|
||||
* // without `multiValue`
|
||||
* _.invert({ 'first': 'fred', 'second': 'barney', 'third': 'fred' });
|
||||
* // => { 'fred': 'third', 'barney': 'second' }
|
||||
* _.invert(object);
|
||||
* // => { '1': 'c', '2': 'b' }
|
||||
*
|
||||
* // with `multiValue`
|
||||
* _.invert({ 'first': 'fred', 'second': 'barney', 'third': 'fred' }, true);
|
||||
* // => { 'fred': ['first', 'third'], 'barney': ['second'] }
|
||||
* _.invert(object, true);
|
||||
* // => { '1': ['a', 'c'], '2': ['b'] }
|
||||
*/
|
||||
function invert(object, multiValue, guard) {
|
||||
if (guard && isIterateeCall(object, multiValue, guard)) {
|
||||
|
||||
@@ -27,8 +27,10 @@ define(['../internal/baseCallback', '../internal/baseForOwn'], function(baseCall
|
||||
* @returns {Object} Returns the new mapped object.
|
||||
* @example
|
||||
*
|
||||
* _.mapValues({ 'a': 1, 'b': 2, 'c': 3} , function(n) { return n * 3; });
|
||||
* // => { 'a': 3, 'b': 6, 'c': 9 }
|
||||
* _.mapValues({ 'a': 1, 'b': 2 }, function(n) {
|
||||
* return n * 3;
|
||||
* });
|
||||
* // => { 'a': 3, 'b': 6 }
|
||||
*
|
||||
* var users = {
|
||||
* 'fred': { 'user': 'fred', 'age': 40 },
|
||||
|
||||
@@ -42,7 +42,9 @@ define(['../internal/baseMerge', '../internal/createAssigner'], function(baseMer
|
||||
* };
|
||||
*
|
||||
* _.merge(object, other, function(a, b) {
|
||||
* return _.isArray(a) ? a.concat(b) : undefined;
|
||||
* if (_.isArray(a)) {
|
||||
* return a.concat(b);
|
||||
* }
|
||||
* });
|
||||
* // => { 'fruits': ['apple', 'banana'], 'vegetables': ['beet', 'carrot'] }
|
||||
*/
|
||||
|
||||
@@ -18,18 +18,16 @@ define(['../internal/arrayEach', '../internal/baseCallback', '../internal/baseCr
|
||||
* @returns {*} Returns the accumulated value.
|
||||
* @example
|
||||
*
|
||||
* var squares = _.transform([1, 2, 3, 4, 5, 6], function(result, n) {
|
||||
* n *= n;
|
||||
* if (n % 2) {
|
||||
* return result.push(n) < 3;
|
||||
* }
|
||||
* _.transform([2, 3, 4], function(result, n) {
|
||||
* result.push(n *= n);
|
||||
* return n % 2 == 0;
|
||||
* });
|
||||
* // => [1, 9, 25]
|
||||
* // => [4, 9]
|
||||
*
|
||||
* var mapped = _.transform({ 'a': 1, 'b': 2, 'c': 3 }, function(result, n, key) {
|
||||
* _.transform({ 'a': 1, 'b': 2 }, function(result, n, key) {
|
||||
* result[key] = n * 3;
|
||||
* });
|
||||
* // => { 'a': 3, 'b': 6, 'c': 9 }
|
||||
* // => { 'a': 3, 'b': 6 }
|
||||
*/
|
||||
function transform(object, iteratee, accumulator, thisArg) {
|
||||
var isArr = isArray(object) || isTypedArray(object);
|
||||
|
||||
Reference in New Issue
Block a user