web 3d图形渲染器
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.

22 lines
815 B

  1. 'use strict';
  2. var $ = require('../internals/export');
  3. var IS_PURE = require('../internals/is-pure');
  4. var anObject = require('../internals/an-object');
  5. var aFunction = require('../internals/a-function');
  6. // `Set.prototype.update` method
  7. // https://github.com/tc39/proposal-collection-methods
  8. $({ target: 'Map', proto: true, real: true, forced: IS_PURE }, {
  9. update: function update(key, callback /* , thunk */) {
  10. var map = anObject(this);
  11. var length = arguments.length;
  12. aFunction(callback);
  13. var isPresentInMap = map.has(key);
  14. if (!isPresentInMap && length < 3) {
  15. throw TypeError('Updating absent value');
  16. }
  17. var value = isPresentInMap ? map.get(key) : aFunction(length > 2 ? arguments[2] : undefined)(key, map);
  18. map.set(key, callback(value, key, map));
  19. return map;
  20. }
  21. });