es.reflect.apply.js 893 B

12345678910111213141516171819202122232425
  1. var $ = require('../internals/export');
  2. var getBuiltIn = require('../internals/get-built-in');
  3. var aFunction = require('../internals/a-function');
  4. var anObject = require('../internals/an-object');
  5. var fails = require('../internals/fails');
  6. var nativeApply = getBuiltIn('Reflect', 'apply');
  7. var functionApply = Function.apply;
  8. // MS Edge argumentsList argument is optional
  9. var OPTIONAL_ARGUMENTS_LIST = !fails(function () {
  10. nativeApply(function () { /* empty */ });
  11. });
  12. // `Reflect.apply` method
  13. // https://tc39.github.io/ecma262/#sec-reflect.apply
  14. $({ target: 'Reflect', stat: true, forced: OPTIONAL_ARGUMENTS_LIST }, {
  15. apply: function apply(target, thisArgument, argumentsList) {
  16. aFunction(target);
  17. anObject(argumentsList);
  18. return nativeApply
  19. ? nativeApply(target, thisArgument, argumentsList)
  20. : functionApply.call(target, thisArgument, argumentsList);
  21. }
  22. });