Repositorio del curso CCOM4030 el semestre B91 del proyecto Artesanías con el Instituto de Cultura

GetIntrinsic.js 9.2KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189
  1. 'use strict';
  2. /* globals
  3. Atomics,
  4. SharedArrayBuffer,
  5. */
  6. var undefined; // eslint-disable-line no-shadow-restricted-names
  7. var $TypeError = TypeError;
  8. var ThrowTypeError = Object.getOwnPropertyDescriptor
  9. ? (function () { return Object.getOwnPropertyDescriptor(arguments, 'callee').get; }())
  10. : function () { throw new $TypeError(); };
  11. var hasSymbols = require('has-symbols')();
  12. var getProto = Object.getPrototypeOf || function (x) { return x.__proto__; }; // eslint-disable-line no-proto
  13. var generator; // = function * () {};
  14. var generatorFunction = generator ? getProto(generator) : undefined;
  15. var asyncFn; // async function() {};
  16. var asyncFunction = asyncFn ? asyncFn.constructor : undefined;
  17. var asyncGen; // async function * () {};
  18. var asyncGenFunction = asyncGen ? getProto(asyncGen) : undefined;
  19. var asyncGenIterator = asyncGen ? asyncGen() : undefined;
  20. var TypedArray = typeof Uint8Array === 'undefined' ? undefined : getProto(Uint8Array);
  21. var INTRINSICS = {
  22. '$ %Array%': Array,
  23. '$ %ArrayBuffer%': typeof ArrayBuffer === 'undefined' ? undefined : ArrayBuffer,
  24. '$ %ArrayBufferPrototype%': typeof ArrayBuffer === 'undefined' ? undefined : ArrayBuffer.prototype,
  25. '$ %ArrayIteratorPrototype%': hasSymbols ? getProto([][Symbol.iterator]()) : undefined,
  26. '$ %ArrayPrototype%': Array.prototype,
  27. '$ %ArrayProto_entries%': Array.prototype.entries,
  28. '$ %ArrayProto_forEach%': Array.prototype.forEach,
  29. '$ %ArrayProto_keys%': Array.prototype.keys,
  30. '$ %ArrayProto_values%': Array.prototype.values,
  31. '$ %AsyncFromSyncIteratorPrototype%': undefined,
  32. '$ %AsyncFunction%': asyncFunction,
  33. '$ %AsyncFunctionPrototype%': asyncFunction ? asyncFunction.prototype : undefined,
  34. '$ %AsyncGenerator%': asyncGen ? getProto(asyncGenIterator) : undefined,
  35. '$ %AsyncGeneratorFunction%': asyncGenFunction,
  36. '$ %AsyncGeneratorPrototype%': asyncGenFunction ? asyncGenFunction.prototype : undefined,
  37. '$ %AsyncIteratorPrototype%': asyncGenIterator && hasSymbols && Symbol.asyncIterator ? asyncGenIterator[Symbol.asyncIterator]() : undefined,
  38. '$ %Atomics%': typeof Atomics === 'undefined' ? undefined : Atomics,
  39. '$ %Boolean%': Boolean,
  40. '$ %BooleanPrototype%': Boolean.prototype,
  41. '$ %DataView%': typeof DataView === 'undefined' ? undefined : DataView,
  42. '$ %DataViewPrototype%': typeof DataView === 'undefined' ? undefined : DataView.prototype,
  43. '$ %Date%': Date,
  44. '$ %DatePrototype%': Date.prototype,
  45. '$ %decodeURI%': decodeURI,
  46. '$ %decodeURIComponent%': decodeURIComponent,
  47. '$ %encodeURI%': encodeURI,
  48. '$ %encodeURIComponent%': encodeURIComponent,
  49. '$ %Error%': Error,
  50. '$ %ErrorPrototype%': Error.prototype,
  51. '$ %eval%': eval, // eslint-disable-line no-eval
  52. '$ %EvalError%': EvalError,
  53. '$ %EvalErrorPrototype%': EvalError.prototype,
  54. '$ %Float32Array%': typeof Float32Array === 'undefined' ? undefined : Float32Array,
  55. '$ %Float32ArrayPrototype%': typeof Float32Array === 'undefined' ? undefined : Float32Array.prototype,
  56. '$ %Float64Array%': typeof Float64Array === 'undefined' ? undefined : Float64Array,
  57. '$ %Float64ArrayPrototype%': typeof Float64Array === 'undefined' ? undefined : Float64Array.prototype,
  58. '$ %Function%': Function,
  59. '$ %FunctionPrototype%': Function.prototype,
  60. '$ %Generator%': generator ? getProto(generator()) : undefined,
  61. '$ %GeneratorFunction%': generatorFunction,
  62. '$ %GeneratorPrototype%': generatorFunction ? generatorFunction.prototype : undefined,
  63. '$ %Int8Array%': typeof Int8Array === 'undefined' ? undefined : Int8Array,
  64. '$ %Int8ArrayPrototype%': typeof Int8Array === 'undefined' ? undefined : Int8Array.prototype,
  65. '$ %Int16Array%': typeof Int16Array === 'undefined' ? undefined : Int16Array,
  66. '$ %Int16ArrayPrototype%': typeof Int16Array === 'undefined' ? undefined : Int8Array.prototype,
  67. '$ %Int32Array%': typeof Int32Array === 'undefined' ? undefined : Int32Array,
  68. '$ %Int32ArrayPrototype%': typeof Int32Array === 'undefined' ? undefined : Int32Array.prototype,
  69. '$ %isFinite%': isFinite,
  70. '$ %isNaN%': isNaN,
  71. '$ %IteratorPrototype%': hasSymbols ? getProto(getProto([][Symbol.iterator]())) : undefined,
  72. '$ %JSON%': JSON,
  73. '$ %JSONParse%': JSON.parse,
  74. '$ %Map%': typeof Map === 'undefined' ? undefined : Map,
  75. '$ %MapIteratorPrototype%': typeof Map === 'undefined' || !hasSymbols ? undefined : getProto(new Map()[Symbol.iterator]()),
  76. '$ %MapPrototype%': typeof Map === 'undefined' ? undefined : Map.prototype,
  77. '$ %Math%': Math,
  78. '$ %Number%': Number,
  79. '$ %NumberPrototype%': Number.prototype,
  80. '$ %Object%': Object,
  81. '$ %ObjectPrototype%': Object.prototype,
  82. '$ %ObjProto_toString%': Object.prototype.toString,
  83. '$ %ObjProto_valueOf%': Object.prototype.valueOf,
  84. '$ %parseFloat%': parseFloat,
  85. '$ %parseInt%': parseInt,
  86. '$ %Promise%': typeof Promise === 'undefined' ? undefined : Promise,
  87. '$ %PromisePrototype%': typeof Promise === 'undefined' ? undefined : Promise.prototype,
  88. '$ %PromiseProto_then%': typeof Promise === 'undefined' ? undefined : Promise.prototype.then,
  89. '$ %Promise_all%': typeof Promise === 'undefined' ? undefined : Promise.all,
  90. '$ %Promise_reject%': typeof Promise === 'undefined' ? undefined : Promise.reject,
  91. '$ %Promise_resolve%': typeof Promise === 'undefined' ? undefined : Promise.resolve,
  92. '$ %Proxy%': typeof Proxy === 'undefined' ? undefined : Proxy,
  93. '$ %RangeError%': RangeError,
  94. '$ %RangeErrorPrototype%': RangeError.prototype,
  95. '$ %ReferenceError%': ReferenceError,
  96. '$ %ReferenceErrorPrototype%': ReferenceError.prototype,
  97. '$ %Reflect%': typeof Reflect === 'undefined' ? undefined : Reflect,
  98. '$ %RegExp%': RegExp,
  99. '$ %RegExpPrototype%': RegExp.prototype,
  100. '$ %Set%': typeof Set === 'undefined' ? undefined : Set,
  101. '$ %SetIteratorPrototype%': typeof Set === 'undefined' || !hasSymbols ? undefined : getProto(new Set()[Symbol.iterator]()),
  102. '$ %SetPrototype%': typeof Set === 'undefined' ? undefined : Set.prototype,
  103. '$ %SharedArrayBuffer%': typeof SharedArrayBuffer === 'undefined' ? undefined : SharedArrayBuffer,
  104. '$ %SharedArrayBufferPrototype%': typeof SharedArrayBuffer === 'undefined' ? undefined : SharedArrayBuffer.prototype,
  105. '$ %String%': String,
  106. '$ %StringIteratorPrototype%': hasSymbols ? getProto(''[Symbol.iterator]()) : undefined,
  107. '$ %StringPrototype%': String.prototype,
  108. '$ %Symbol%': hasSymbols ? Symbol : undefined,
  109. '$ %SymbolPrototype%': hasSymbols ? Symbol.prototype : undefined,
  110. '$ %SyntaxError%': SyntaxError,
  111. '$ %SyntaxErrorPrototype%': SyntaxError.prototype,
  112. '$ %ThrowTypeError%': ThrowTypeError,
  113. '$ %TypedArray%': TypedArray,
  114. '$ %TypedArrayPrototype%': TypedArray ? TypedArray.prototype : undefined,
  115. '$ %TypeError%': $TypeError,
  116. '$ %TypeErrorPrototype%': $TypeError.prototype,
  117. '$ %Uint8Array%': typeof Uint8Array === 'undefined' ? undefined : Uint8Array,
  118. '$ %Uint8ArrayPrototype%': typeof Uint8Array === 'undefined' ? undefined : Uint8Array.prototype,
  119. '$ %Uint8ClampedArray%': typeof Uint8ClampedArray === 'undefined' ? undefined : Uint8ClampedArray,
  120. '$ %Uint8ClampedArrayPrototype%': typeof Uint8ClampedArray === 'undefined' ? undefined : Uint8ClampedArray.prototype,
  121. '$ %Uint16Array%': typeof Uint16Array === 'undefined' ? undefined : Uint16Array,
  122. '$ %Uint16ArrayPrototype%': typeof Uint16Array === 'undefined' ? undefined : Uint16Array.prototype,
  123. '$ %Uint32Array%': typeof Uint32Array === 'undefined' ? undefined : Uint32Array,
  124. '$ %Uint32ArrayPrototype%': typeof Uint32Array === 'undefined' ? undefined : Uint32Array.prototype,
  125. '$ %URIError%': URIError,
  126. '$ %URIErrorPrototype%': URIError.prototype,
  127. '$ %WeakMap%': typeof WeakMap === 'undefined' ? undefined : WeakMap,
  128. '$ %WeakMapPrototype%': typeof WeakMap === 'undefined' ? undefined : WeakMap.prototype,
  129. '$ %WeakSet%': typeof WeakSet === 'undefined' ? undefined : WeakSet,
  130. '$ %WeakSetPrototype%': typeof WeakSet === 'undefined' ? undefined : WeakSet.prototype
  131. };
  132. var bind = require('function-bind');
  133. var $replace = bind.call(Function.call, String.prototype.replace);
  134. /* adapted from https://github.com/lodash/lodash/blob/4.17.15/dist/lodash.js#L6735-L6744 */
  135. var rePropName = /[^%.[\]]+|\[(?:(-?\d+(?:\.\d+)?)|(["'])((?:(?!\2)[^\\]|\\.)*?)\2)\]|(?=(?:\.|\[\])(?:\.|\[\]|%$))/g;
  136. var reEscapeChar = /\\(\\)?/g; /** Used to match backslashes in property paths. */
  137. var stringToPath = function stringToPath(string) {
  138. var result = [];
  139. $replace(string, rePropName, function (match, number, quote, subString) {
  140. result[result.length] = quote ? $replace(subString, reEscapeChar, '$1') : (number || match);
  141. });
  142. return result;
  143. };
  144. /* end adaptation */
  145. var getBaseIntrinsic = function getBaseIntrinsic(name, allowMissing) {
  146. var key = '$ ' + name;
  147. if (!(key in INTRINSICS)) {
  148. throw new SyntaxError('intrinsic ' + name + ' does not exist!');
  149. }
  150. // istanbul ignore if // hopefully this is impossible to test :-)
  151. if (typeof INTRINSICS[key] === 'undefined' && !allowMissing) {
  152. throw new $TypeError('intrinsic ' + name + ' exists, but is not available. Please file an issue!');
  153. }
  154. return INTRINSICS[key];
  155. };
  156. module.exports = function GetIntrinsic(name, allowMissing) {
  157. if (arguments.length > 1 && typeof allowMissing !== 'boolean') {
  158. throw new TypeError('"allowMissing" argument must be a boolean');
  159. }
  160. var parts = stringToPath(name);
  161. if (parts.length === 0) {
  162. return getBaseIntrinsic(name, allowMissing);
  163. }
  164. var value = getBaseIntrinsic('%' + parts[0] + '%', allowMissing);
  165. for (var i = 1; i < parts.length; i += 1) {
  166. if (value != null) {
  167. value = value[parts[i]];
  168. }
  169. }
  170. return value;
  171. };