用工小程序前端代码
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.

544 lines
19 KiB

10 months ago
10 months ago
10 months ago
10 months ago
10 months ago
10 months ago
10 months ago
  1. var hasMap = typeof Map === 'function' && Map.prototype;
  2. var mapSizeDescriptor = Object.getOwnPropertyDescriptor && hasMap ? Object.getOwnPropertyDescriptor(Map.prototype, 'size') : null;
  3. var mapSize = hasMap && mapSizeDescriptor && typeof mapSizeDescriptor.get === 'function' ? mapSizeDescriptor.get : null;
  4. var mapForEach = hasMap && Map.prototype.forEach;
  5. var hasSet = typeof Set === 'function' && Set.prototype;
  6. var setSizeDescriptor = Object.getOwnPropertyDescriptor && hasSet ? Object.getOwnPropertyDescriptor(Set.prototype, 'size') : null;
  7. var setSize = hasSet && setSizeDescriptor && typeof setSizeDescriptor.get === 'function' ? setSizeDescriptor.get : null;
  8. var setForEach = hasSet && Set.prototype.forEach;
  9. var hasWeakMap = typeof WeakMap === 'function' && WeakMap.prototype;
  10. var weakMapHas = hasWeakMap ? WeakMap.prototype.has : null;
  11. var hasWeakSet = typeof WeakSet === 'function' && WeakSet.prototype;
  12. var weakSetHas = hasWeakSet ? WeakSet.prototype.has : null;
  13. var hasWeakRef = typeof WeakRef === 'function' && WeakRef.prototype;
  14. var weakRefDeref = hasWeakRef ? WeakRef.prototype.deref : null;
  15. var booleanValueOf = Boolean.prototype.valueOf;
  16. var objectToString = Object.prototype.toString;
  17. var functionToString = Function.prototype.toString;
  18. var $match = String.prototype.match;
  19. var $slice = String.prototype.slice;
  20. var $replace = String.prototype.replace;
  21. var $toUpperCase = String.prototype.toUpperCase;
  22. var $toLowerCase = String.prototype.toLowerCase;
  23. var $test = RegExp.prototype.test;
  24. var $concat = Array.prototype.concat;
  25. var $join = Array.prototype.join;
  26. var $arrSlice = Array.prototype.slice;
  27. var $floor = Math.floor;
  28. var bigIntValueOf = typeof BigInt === 'function' ? BigInt.prototype.valueOf : null;
  29. var gOPS = Object.getOwnPropertySymbols;
  30. var symToString = typeof Symbol === 'function' && typeof Symbol.iterator === 'symbol' ? Symbol.prototype.toString : null;
  31. var hasShammedSymbols = typeof Symbol === 'function' && typeof Symbol.iterator === 'object';
  32. // ie, `has-tostringtag/shams
  33. var toStringTag = typeof Symbol === 'function' && Symbol.toStringTag && (typeof Symbol.toStringTag === hasShammedSymbols ? 'object' : 'symbol')
  34. ? Symbol.toStringTag
  35. : null;
  36. var isEnumerable = Object.prototype.propertyIsEnumerable;
  37. var gPO = (typeof Reflect === 'function' ? Reflect.getPrototypeOf : Object.getPrototypeOf) || (
  38. [].__proto__ === Array.prototype // eslint-disable-line no-proto
  39. ? function (O) {
  40. return O.__proto__; // eslint-disable-line no-proto
  41. }
  42. : null
  43. );
  44. function addNumericSeparator(num, str) {
  45. if (
  46. num === Infinity
  47. || num === -Infinity
  48. || num !== num
  49. || (num && num > -1000 && num < 1000)
  50. || $test.call(/e/, str)
  51. ) {
  52. return str;
  53. }
  54. var sepRegex = /[0-9](?=(?:[0-9]{3})+(?![0-9]))/g;
  55. if (typeof num === 'number') {
  56. var int = num < 0 ? -$floor(-num) : $floor(num); // trunc(num)
  57. if (int !== num) {
  58. var intStr = String(int);
  59. var dec = $slice.call(str, intStr.length + 1);
  60. return $replace.call(intStr, sepRegex, '$&_') + '.' + $replace.call($replace.call(dec, /([0-9]{3})/g, '$&_'), /_$/, '');
  61. }
  62. }
  63. return $replace.call(str, sepRegex, '$&_');
  64. }
  65. var utilInspect = require('./util.inspect');
  66. var inspectCustom = utilInspect.custom;
  67. var inspectSymbol = isSymbol(inspectCustom) ? inspectCustom : null;
  68. var quotes = {
  69. __proto__: null,
  70. 'double': '"',
  71. single: "'"
  72. };
  73. var quoteREs = {
  74. __proto__: null,
  75. 'double': /(["\\])/g,
  76. single: /(['\\])/g
  77. };
  78. module.exports = function inspect_(obj, options, depth, seen) {
  79. var opts = options || {};
  80. if (has(opts, 'quoteStyle') && !has(quotes, opts.quoteStyle)) {
  81. throw new TypeError('option "quoteStyle" must be "single" or "double"');
  82. }
  83. if (
  84. has(opts, 'maxStringLength') && (typeof opts.maxStringLength === 'number'
  85. ? opts.maxStringLength < 0 && opts.maxStringLength !== Infinity
  86. : opts.maxStringLength !== null
  87. )
  88. ) {
  89. throw new TypeError('option "maxStringLength", if provided, must be a positive integer, Infinity, or `null`');
  90. }
  91. var customInspect = has(opts, 'customInspect') ? opts.customInspect : true;
  92. if (typeof customInspect !== 'boolean' && customInspect !== 'symbol') {
  93. throw new TypeError('option "customInspect", if provided, must be `true`, `false`, or `\'symbol\'`');
  94. }
  95. if (
  96. has(opts, 'indent')
  97. && opts.indent !== null
  98. && opts.indent !== '\t'
  99. && !(parseInt(opts.indent, 10) === opts.indent && opts.indent > 0)
  100. ) {
  101. throw new TypeError('option "indent" must be "\\t", an integer > 0, or `null`');
  102. }
  103. if (has(opts, 'numericSeparator') && typeof opts.numericSeparator !== 'boolean') {
  104. throw new TypeError('option "numericSeparator", if provided, must be `true` or `false`');
  105. }
  106. var numericSeparator = opts.numericSeparator;
  107. if (typeof obj === 'undefined') {
  108. return 'undefined';
  109. }
  110. if (obj === null) {
  111. return 'null';
  112. }
  113. if (typeof obj === 'boolean') {
  114. return obj ? 'true' : 'false';
  115. }
  116. if (typeof obj === 'string') {
  117. return inspectString(obj, opts);
  118. }
  119. if (typeof obj === 'number') {
  120. if (obj === 0) {
  121. return Infinity / obj > 0 ? '0' : '-0';
  122. }
  123. var str = String(obj);
  124. return numericSeparator ? addNumericSeparator(obj, str) : str;
  125. }
  126. if (typeof obj === 'bigint') {
  127. var bigIntStr = String(obj) + 'n';
  128. return numericSeparator ? addNumericSeparator(obj, bigIntStr) : bigIntStr;
  129. }
  130. var maxDepth = typeof opts.depth === 'undefined' ? 5 : opts.depth;
  131. if (typeof depth === 'undefined') { depth = 0; }
  132. if (depth >= maxDepth && maxDepth > 0 && typeof obj === 'object') {
  133. return isArray(obj) ? '[Array]' : '[Object]';
  134. }
  135. var indent = getIndent(opts, depth);
  136. if (typeof seen === 'undefined') {
  137. seen = [];
  138. } else if (indexOf(seen, obj) >= 0) {
  139. return '[Circular]';
  140. }
  141. function inspect(value, from, noIndent) {
  142. if (from) {
  143. seen = $arrSlice.call(seen);
  144. seen.push(from);
  145. }
  146. if (noIndent) {
  147. var newOpts = {
  148. depth: opts.depth
  149. };
  150. if (has(opts, 'quoteStyle')) {
  151. newOpts.quoteStyle = opts.quoteStyle;
  152. }
  153. return inspect_(value, newOpts, depth + 1, seen);
  154. }
  155. return inspect_(value, opts, depth + 1, seen);
  156. }
  157. if (typeof obj === 'function' && !isRegExp(obj)) { // in older engines, regexes are callable
  158. var name = nameOf(obj);
  159. var keys = arrObjKeys(obj, inspect);
  160. return '[Function' + (name ? ': ' + name : ' (anonymous)') + ']' + (keys.length > 0 ? ' { ' + $join.call(keys, ', ') + ' }' : '');
  161. }
  162. if (isSymbol(obj)) {
  163. var symString = hasShammedSymbols ? $replace.call(String(obj), /^(Symbol\(.*\))_[^)]*$/, '$1') : symToString.call(obj);
  164. return typeof obj === 'object' && !hasShammedSymbols ? markBoxed(symString) : symString;
  165. }
  166. if (isElement(obj)) {
  167. var s = '<' + $toLowerCase.call(String(obj.nodeName));
  168. var attrs = obj.attributes || [];
  169. for (var i = 0; i < attrs.length; i++) {
  170. s += ' ' + attrs[i].name + '=' + wrapQuotes(quote(attrs[i].value), 'double', opts);
  171. }
  172. s += '>';
  173. if (obj.childNodes && obj.childNodes.length) { s += '...'; }
  174. s += '</' + $toLowerCase.call(String(obj.nodeName)) + '>';
  175. return s;
  176. }
  177. if (isArray(obj)) {
  178. if (obj.length === 0) { return '[]'; }
  179. var xs = arrObjKeys(obj, inspect);
  180. if (indent && !singleLineValues(xs)) {
  181. return '[' + indentedJoin(xs, indent) + ']';
  182. }
  183. return '[ ' + $join.call(xs, ', ') + ' ]';
  184. }
  185. if (isError(obj)) {
  186. var parts = arrObjKeys(obj, inspect);
  187. if (!('cause' in Error.prototype) && 'cause' in obj && !isEnumerable.call(obj, 'cause')) {
  188. return '{ [' + String(obj) + '] ' + $join.call($concat.call('[cause]: ' + inspect(obj.cause), parts), ', ') + ' }';
  189. }
  190. if (parts.length === 0) { return '[' + String(obj) + ']'; }
  191. return '{ [' + String(obj) + '] ' + $join.call(parts, ', ') + ' }';
  192. }
  193. if (typeof obj === 'object' && customInspect) {
  194. if (inspectSymbol && typeof obj[inspectSymbol] === 'function' && utilInspect) {
  195. return utilInspect(obj, { depth: maxDepth - depth });
  196. } else if (customInspect !== 'symbol' && typeof obj.inspect === 'function') {
  197. return obj.inspect();
  198. }
  199. }
  200. if (isMap(obj)) {
  201. var mapParts = [];
  202. if (mapForEach) {
  203. mapForEach.call(obj, function (value, key) {
  204. mapParts.push(inspect(key, obj, true) + ' => ' + inspect(value, obj));
  205. });
  206. }
  207. return collectionOf('Map', mapSize.call(obj), mapParts, indent);
  208. }
  209. if (isSet(obj)) {
  210. var setParts = [];
  211. if (setForEach) {
  212. setForEach.call(obj, function (value) {
  213. setParts.push(inspect(value, obj));
  214. });
  215. }
  216. return collectionOf('Set', setSize.call(obj), setParts, indent);
  217. }
  218. if (isWeakMap(obj)) {
  219. return weakCollectionOf('WeakMap');
  220. }
  221. if (isWeakSet(obj)) {
  222. return weakCollectionOf('WeakSet');
  223. }
  224. if (isWeakRef(obj)) {
  225. return weakCollectionOf('WeakRef');
  226. }
  227. if (isNumber(obj)) {
  228. return markBoxed(inspect(Number(obj)));
  229. }
  230. if (isBigInt(obj)) {
  231. return markBoxed(inspect(bigIntValueOf.call(obj)));
  232. }
  233. if (isBoolean(obj)) {
  234. return markBoxed(booleanValueOf.call(obj));
  235. }
  236. if (isString(obj)) {
  237. return markBoxed(inspect(String(obj)));
  238. }
  239. // note: in IE 8, sometimes `global !== window` but both are the prototypes of each other
  240. /* eslint-env browser */
  241. if (typeof window !== 'undefined' && obj === window) {
  242. return '{ [object Window] }';
  243. }
  244. if (
  245. (typeof globalThis !== 'undefined' && obj === globalThis)
  246. || (typeof global !== 'undefined' && obj === global)
  247. ) {
  248. return '{ [object globalThis] }';
  249. }
  250. if (!isDate(obj) && !isRegExp(obj)) {
  251. var ys = arrObjKeys(obj, inspect);
  252. var isPlainObject = gPO ? gPO(obj) === Object.prototype : obj instanceof Object || obj.constructor === Object;
  253. var protoTag = obj instanceof Object ? '' : 'null prototype';
  254. var stringTag = !isPlainObject && toStringTag && Object(obj) === obj && toStringTag in obj ? $slice.call(toStr(obj), 8, -1) : protoTag ? 'Object' : '';
  255. var constructorTag = isPlainObject || typeof obj.constructor !== 'function' ? '' : obj.constructor.name ? obj.constructor.name + ' ' : '';
  256. var tag = constructorTag + (stringTag || protoTag ? '[' + $join.call($concat.call([], stringTag || [], protoTag || []), ': ') + '] ' : '');
  257. if (ys.length === 0) { return tag + '{}'; }
  258. if (indent) {
  259. return tag + '{' + indentedJoin(ys, indent) + '}';
  260. }
  261. return tag + '{ ' + $join.call(ys, ', ') + ' }';
  262. }
  263. return String(obj);
  264. };
  265. function wrapQuotes(s, defaultStyle, opts) {
  266. var style = opts.quoteStyle || defaultStyle;
  267. var quoteChar = quotes[style];
  268. return quoteChar + s + quoteChar;
  269. }
  270. function quote(s) {
  271. return $replace.call(String(s), /"/g, '&quot;');
  272. }
  273. function canTrustToString(obj) {
  274. return !toStringTag || !(typeof obj === 'object' && (toStringTag in obj || typeof obj[toStringTag] !== 'undefined'));
  275. }
  276. function isArray(obj) { return toStr(obj) === '[object Array]' && canTrustToString(obj); }
  277. function isDate(obj) { return toStr(obj) === '[object Date]' && canTrustToString(obj); }
  278. function isRegExp(obj) { return toStr(obj) === '[object RegExp]' && canTrustToString(obj); }
  279. function isError(obj) { return toStr(obj) === '[object Error]' && canTrustToString(obj); }
  280. function isString(obj) { return toStr(obj) === '[object String]' && canTrustToString(obj); }
  281. function isNumber(obj) { return toStr(obj) === '[object Number]' && canTrustToString(obj); }
  282. function isBoolean(obj) { return toStr(obj) === '[object Boolean]' && canTrustToString(obj); }
  283. // Symbol and BigInt do have Symbol.toStringTag by spec, so that can't be used to eliminate false positives
  284. function isSymbol(obj) {
  285. if (hasShammedSymbols) {
  286. return obj && typeof obj === 'object' && obj instanceof Symbol;
  287. }
  288. if (typeof obj === 'symbol') {
  289. return true;
  290. }
  291. if (!obj || typeof obj !== 'object' || !symToString) {
  292. return false;
  293. }
  294. try {
  295. symToString.call(obj);
  296. return true;
  297. } catch (e) {}
  298. return false;
  299. }
  300. function isBigInt(obj) {
  301. if (!obj || typeof obj !== 'object' || !bigIntValueOf) {
  302. return false;
  303. }
  304. try {
  305. bigIntValueOf.call(obj);
  306. return true;
  307. } catch (e) {}
  308. return false;
  309. }
  310. var hasOwn = Object.prototype.hasOwnProperty || function (key) { return key in this; };
  311. function has(obj, key) {
  312. return hasOwn.call(obj, key);
  313. }
  314. function toStr(obj) {
  315. return objectToString.call(obj);
  316. }
  317. function nameOf(f) {
  318. if (f.name) { return f.name; }
  319. var m = $match.call(functionToString.call(f), /^function\s*([\w$]+)/);
  320. if (m) { return m[1]; }
  321. return null;
  322. }
  323. function indexOf(xs, x) {
  324. if (xs.indexOf) { return xs.indexOf(x); }
  325. for (var i = 0, l = xs.length; i < l; i++) {
  326. if (xs[i] === x) { return i; }
  327. }
  328. return -1;
  329. }
  330. function isMap(x) {
  331. if (!mapSize || !x || typeof x !== 'object') {
  332. return false;
  333. }
  334. try {
  335. mapSize.call(x);
  336. try {
  337. setSize.call(x);
  338. } catch (s) {
  339. return true;
  340. }
  341. return x instanceof Map; // core-js workaround, pre-v2.5.0
  342. } catch (e) {}
  343. return false;
  344. }
  345. function isWeakMap(x) {
  346. if (!weakMapHas || !x || typeof x !== 'object') {
  347. return false;
  348. }
  349. try {
  350. weakMapHas.call(x, weakMapHas);
  351. try {
  352. weakSetHas.call(x, weakSetHas);
  353. } catch (s) {
  354. return true;
  355. }
  356. return x instanceof WeakMap; // core-js workaround, pre-v2.5.0
  357. } catch (e) {}
  358. return false;
  359. }
  360. function isWeakRef(x) {
  361. if (!weakRefDeref || !x || typeof x !== 'object') {
  362. return false;
  363. }
  364. try {
  365. weakRefDeref.call(x);
  366. return true;
  367. } catch (e) {}
  368. return false;
  369. }
  370. function isSet(x) {
  371. if (!setSize || !x || typeof x !== 'object') {
  372. return false;
  373. }
  374. try {
  375. setSize.call(x);
  376. try {
  377. mapSize.call(x);
  378. } catch (m) {
  379. return true;
  380. }
  381. return x instanceof Set; // core-js workaround, pre-v2.5.0
  382. } catch (e) {}
  383. return false;
  384. }
  385. function isWeakSet(x) {
  386. if (!weakSetHas || !x || typeof x !== 'object') {
  387. return false;
  388. }
  389. try {
  390. weakSetHas.call(x, weakSetHas);
  391. try {
  392. weakMapHas.call(x, weakMapHas);
  393. } catch (s) {
  394. return true;
  395. }
  396. return x instanceof WeakSet; // core-js workaround, pre-v2.5.0
  397. } catch (e) {}
  398. return false;
  399. }
  400. function isElement(x) {
  401. if (!x || typeof x !== 'object') { return false; }
  402. if (typeof HTMLElement !== 'undefined' && x instanceof HTMLElement) {
  403. return true;
  404. }
  405. return typeof x.nodeName === 'string' && typeof x.getAttribute === 'function';
  406. }
  407. function inspectString(str, opts) {
  408. if (str.length > opts.maxStringLength) {
  409. var remaining = str.length - opts.maxStringLength;
  410. var trailer = '... ' + remaining + ' more character' + (remaining > 1 ? 's' : '');
  411. return inspectString($slice.call(str, 0, opts.maxStringLength), opts) + trailer;
  412. }
  413. var quoteRE = quoteREs[opts.quoteStyle || 'single'];
  414. quoteRE.lastIndex = 0;
  415. // eslint-disable-next-line no-control-regex
  416. var s = $replace.call($replace.call(str, quoteRE, '\\$1'), /[\x00-\x1f]/g, lowbyte);
  417. return wrapQuotes(s, 'single', opts);
  418. }
  419. function lowbyte(c) {
  420. var n = c.charCodeAt(0);
  421. var x = {
  422. 8: 'b',
  423. 9: 't',
  424. 10: 'n',
  425. 12: 'f',
  426. 13: 'r'
  427. }[n];
  428. if (x) { return '\\' + x; }
  429. return '\\x' + (n < 0x10 ? '0' : '') + $toUpperCase.call(n.toString(16));
  430. }
  431. function markBoxed(str) {
  432. return 'Object(' + str + ')';
  433. }
  434. function weakCollectionOf(type) {
  435. return type + ' { ? }';
  436. }
  437. function collectionOf(type, size, entries, indent) {
  438. var joinedEntries = indent ? indentedJoin(entries, indent) : $join.call(entries, ', ');
  439. return type + ' (' + size + ') {' + joinedEntries + '}';
  440. }
  441. function singleLineValues(xs) {
  442. for (var i = 0; i < xs.length; i++) {
  443. if (indexOf(xs[i], '\n') >= 0) {
  444. return false;
  445. }
  446. }
  447. return true;
  448. }
  449. function getIndent(opts, depth) {
  450. var baseIndent;
  451. if (opts.indent === '\t') {
  452. baseIndent = '\t';
  453. } else if (typeof opts.indent === 'number' && opts.indent > 0) {
  454. baseIndent = $join.call(Array(opts.indent + 1), ' ');
  455. } else {
  456. return null;
  457. }
  458. return {
  459. base: baseIndent,
  460. prev: $join.call(Array(depth + 1), baseIndent)
  461. };
  462. }
  463. function indentedJoin(xs, indent) {
  464. if (xs.length === 0) { return ''; }
  465. var lineJoiner = '\n' + indent.prev + indent.base;
  466. return lineJoiner + $join.call(xs, ',' + lineJoiner) + '\n' + indent.prev;
  467. }
  468. function arrObjKeys(obj, inspect) {
  469. var isArr = isArray(obj);
  470. var xs = [];
  471. if (isArr) {
  472. xs.length = obj.length;
  473. for (var i = 0; i < obj.length; i++) {
  474. xs[i] = has(obj, i) ? inspect(obj[i], obj) : '';
  475. }
  476. }
  477. var syms = typeof gOPS === 'function' ? gOPS(obj) : [];
  478. var symMap;
  479. if (hasShammedSymbols) {
  480. symMap = {};
  481. for (var k = 0; k < syms.length; k++) {
  482. symMap['$' + syms[k]] = syms[k];
  483. }
  484. }
  485. for (var key in obj) { // eslint-disable-line no-restricted-syntax
  486. if (!has(obj, key)) { continue; } // eslint-disable-line no-restricted-syntax, no-continue
  487. if (isArr && String(Number(key)) === key && key < obj.length) { continue; } // eslint-disable-line no-restricted-syntax, no-continue
  488. if (hasShammedSymbols && symMap['$' + key] instanceof Symbol) {
  489. // this is to prevent shammed Symbols, which are stored as strings, from being included in the string key section
  490. continue; // eslint-disable-line no-restricted-syntax, no-continue
  491. } else if ($test.call(/[^\w$]/, key)) {
  492. xs.push(inspect(key, obj) + ': ' + inspect(obj[key], obj));
  493. } else {
  494. xs.push(key + ': ' + inspect(obj[key], obj));
  495. }
  496. }
  497. if (typeof gOPS === 'function') {
  498. for (var j = 0; j < syms.length; j++) {
  499. if (isEnumerable.call(obj, syms[j])) {
  500. xs.push('[' + inspect(syms[j]) + ']: ' + inspect(obj[syms[j]], obj));
  501. }
  502. }
  503. }
  504. return xs;
  505. }