You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

19 lines
426 B

4 years ago
  1. 'use strict';
  2. var _require = require('../helpers/is'),
  3. isFunction = _require.isFunction;
  4. module.exports = function pull(key, defaultValue) {
  5. var returnValue = this.items[key] || null;
  6. if (!returnValue && defaultValue !== undefined) {
  7. if (isFunction(defaultValue)) {
  8. returnValue = defaultValue();
  9. } else {
  10. returnValue = defaultValue;
  11. }
  12. }
  13. delete this.items[key];
  14. return returnValue;
  15. };