my-idlers/node_modules/collect.js/dist/methods/pull.js

20 lines
426 B
JavaScript
Raw Normal View History

'use strict';
var _require = require('../helpers/is'),
isFunction = _require.isFunction;
module.exports = function pull(key, defaultValue) {
var returnValue = this.items[key] || null;
if (!returnValue && defaultValue !== undefined) {
if (isFunction(defaultValue)) {
returnValue = defaultValue();
} else {
returnValue = defaultValue;
}
}
delete this.items[key];
return returnValue;
};