| /** |
| * Lo-Dash 2.4.1 (Custom Build) <http://lodash.com/> |
| * Build: `lodash modularize underscore exports="node" -o ./underscore/` |
| * Copyright 2012-2013 The Dojo Foundation <http://dojofoundation.org/> |
| * Based on Underscore.js 1.5.2 <http://underscorejs.org/LICENSE> |
| * Copyright 2009-2013 Jeremy Ashkenas, DocumentCloud and Investigative Reporters & Editors |
| * Available under MIT license <http://lodash.com/license> |
| */ |
| var keys = require('./keys'), |
| objectTypes = require('../internals/objectTypes'); |
| |
| /** |
| * Assigns own enumerable properties of source object(s) to the destination |
| * object for all destination properties that resolve to `undefined`. Once a |
| * property is set, additional defaults of the same property will be ignored. |
| * |
| * @static |
| * @memberOf _ |
| * @type Function |
| * @category Objects |
| * @param {Object} object The destination object. |
| * @param {...Object} [source] The source objects. |
| * @param- {Object} [guard] Allows working with `_.reduce` without using its |
| * `key` and `object` arguments as sources. |
| * @returns {Object} Returns the destination object. |
| * @example |
| * |
| * var object = { 'name': 'barney' }; |
| * _.defaults(object, { 'name': 'fred', 'employer': 'slate' }); |
| * // => { 'name': 'barney', 'employer': 'slate' } |
| */ |
| function defaults(object) { |
| if (!object) { |
| return object; |
| } |
| for (var argsIndex = 1, argsLength = arguments.length; argsIndex < argsLength; argsIndex++) { |
| var iterable = arguments[argsIndex]; |
| if (iterable) { |
| for (var key in iterable) { |
| if (typeof object[key] == 'undefined') { |
| object[key] = iterable[key]; |
| } |
| } |
| } |
| } |
| return object; |
| } |
| |
| module.exports = defaults; |