Node-Red configuration
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.

es.function.name.js 914B

1234567891011121314151617181920212223242526
  1. 'use strict';
  2. var DESCRIPTORS = require('../internals/descriptors');
  3. var FUNCTION_NAME_EXISTS = require('../internals/function-name').EXISTS;
  4. var uncurryThis = require('../internals/function-uncurry-this');
  5. var defineBuiltInAccessor = require('../internals/define-built-in-accessor');
  6. var FunctionPrototype = Function.prototype;
  7. var functionToString = uncurryThis(FunctionPrototype.toString);
  8. var nameRE = /function\b(?:\s|\/\*[\S\s]*?\*\/|\/\/[^\n\r]*[\n\r]+)*([^\s(/]*)/;
  9. var regExpExec = uncurryThis(nameRE.exec);
  10. var NAME = 'name';
  11. // Function instances `.name` property
  12. // https://tc39.es/ecma262/#sec-function-instances-name
  13. if (DESCRIPTORS && !FUNCTION_NAME_EXISTS) {
  14. defineBuiltInAccessor(FunctionPrototype, NAME, {
  15. configurable: true,
  16. get: function () {
  17. try {
  18. return regExpExec(nameRE, functionToString(this))[1];
  19. } catch (error) {
  20. return '';
  21. }
  22. }
  23. });
  24. }