Sha256: 75339cc783b30eb4b67c71450189fa602f35e622592c6dc9c16a23621f602afe

Contents?: true

Size: 1.3 KB

Versions: 25

Compression:

Stored size: 1.3 KB

Contents

var assignValue = require('./_assignValue'),
    castPath = require('./_castPath'),
    isIndex = require('./_isIndex'),
    isKey = require('./_isKey'),
    isObject = require('./isObject'),
    toKey = require('./_toKey');

/**
 * The base implementation of `_.set`.
 *
 * @private
 * @param {Object} object The object to query.
 * @param {Array|string} path The path of the property to set.
 * @param {*} value The value to set.
 * @param {Function} [customizer] The function to customize path creation.
 * @returns {Object} Returns `object`.
 */
function baseSet(object, path, value, customizer) {
  path = isKey(path, object) ? [path] : castPath(path);

  var index = -1,
      length = path.length,
      lastIndex = length - 1,
      nested = object;

  while (nested != null && ++index < length) {
    var key = toKey(path[index]);
    if (isObject(nested)) {
      var newValue = value;
      if (index != lastIndex) {
        var objValue = nested[key];
        newValue = customizer ? customizer(objValue, key, nested) : undefined;
        if (newValue === undefined) {
          newValue = objValue == null
            ? (isIndex(path[index + 1]) ? [] : {})
            : objValue;
        }
      }
      assignValue(nested, key, newValue);
    }
    nested = nested[key];
  }
  return object;
}

module.exports = baseSet;

Version data entries

25 entries across 4 versions & 2 rubygems

Version Path
babel-schmooze-sprockets-0.1.3 node_modules/lodash/_baseSet.js
blackboard-3.1.9 lib/site_template/node_modules/sass-graph/node_modules/lodash/_baseSet.js
babel-schmooze-sprockets-0.1.2 node_modules/lodash/_baseSet.js
babel-schmooze-sprockets-0.1.1 node_modules/babel-helper-define-map/node_modules/lodash/_baseSet.js
babel-schmooze-sprockets-0.1.1 node_modules/babel-helper-function-name/node_modules/lodash/_baseSet.js
babel-schmooze-sprockets-0.1.1 node_modules/babel-helper-get-function-arity/node_modules/lodash/_baseSet.js
babel-schmooze-sprockets-0.1.1 node_modules/babel-helper-hoist-variables/node_modules/lodash/_baseSet.js
babel-schmooze-sprockets-0.1.1 node_modules/babel-helper-optimise-call-expression/node_modules/lodash/_baseSet.js
babel-schmooze-sprockets-0.1.1 node_modules/babel-helper-regex/node_modules/lodash/_baseSet.js
babel-schmooze-sprockets-0.1.1 node_modules/babel-helper-replace-supers/node_modules/lodash/_baseSet.js
babel-schmooze-sprockets-0.1.1 node_modules/babel-plugin-transform-es2015-block-scoping/node_modules/lodash/_baseSet.js
babel-schmooze-sprockets-0.1.1 node_modules/babel-plugin-transform-es2015-classes/node_modules/lodash/_baseSet.js
babel-schmooze-sprockets-0.1.1 node_modules/babel-core/node_modules/lodash/_baseSet.js
babel-schmooze-sprockets-0.1.1 node_modules/babel-plugin-transform-es2015-function-name/node_modules/lodash/_baseSet.js
babel-schmooze-sprockets-0.1.1 node_modules/babel-plugin-transform-es2015-modules-commonjs/node_modules/lodash/_baseSet.js
babel-schmooze-sprockets-0.1.1 node_modules/babel-plugin-transform-es2015-parameters/node_modules/lodash/_baseSet.js
babel-schmooze-sprockets-0.1.1 node_modules/babel-plugin-transform-es2015-shorthand-properties/node_modules/lodash/_baseSet.js
babel-schmooze-sprockets-0.1.1 node_modules/babel-plugin-transform-es2015-sticky-regex/node_modules/lodash/_baseSet.js
babel-schmooze-sprockets-0.1.1 node_modules/babel-plugin-transform-regenerator/node_modules/lodash/_baseSet.js
babel-schmooze-sprockets-0.1.1 node_modules/babel-plugin-transform-strict-mode/node_modules/lodash/_baseSet.js