Current File : /home/tradevaly/www/node_modules/collect.js/src/methods/pull.js
'use strict';

const { isFunction } = require('../helpers/is');

module.exports = function pull(key, defaultValue) {
  let returnValue = this.items[key] || null;

  if (!returnValue && defaultValue !== undefined) {
    if (isFunction(defaultValue)) {
      returnValue = defaultValue();
    } else {
      returnValue = defaultValue;
    }
  }

  delete this.items[key];

  return returnValue;
};