How to use isToStringedArrayType method in Jest

Best JavaScript code snippet using jest

pretty_format.js

Source:pretty_format.js Github

copy

Full Screen

...63 const SYMBOL_REGEXP = /^Symbol\((.*)\)(.*)$/;64 const NEWLINE_REGEXP = /\n/gi;65 const getSymbols =66 Object.getOwnPropertySymbols || ((obj) => []);67 function isToStringedArrayType(toStringed) {68 return (69 toStringed === '[object Array]' ||70 toStringed === '[object ArrayBuffer]' ||71 toStringed === '[object DataView]' ||72 toStringed === '[object Float32Array]' ||73 toStringed === '[object Float64Array]' ||74 toStringed === '[object Int8Array]' ||75 toStringed === '[object Int16Array]' ||76 toStringed === '[object Int32Array]' ||77 toStringed === '[object Uint8Array]' ||78 toStringed === '[object Uint8ClampedArray]' ||79 toStringed === '[object Uint16Array]' ||80 toStringed === '[object Uint32Array]'81 );82 }83 function printNumber(val) {84 if (val != +val) return 'NaN';85 const isNegativeZero = val === 0 && 1 / val < 0;86 return isNegativeZero ? '-0' : '' + val;87 }88 function printFunction(val, printFunctionName) {89 if (!printFunctionName) {90 return '[Function]';91 } else if (val.name === '') {92 return '[Function anonymous]';93 } else {94 return '[Function ' + val.name + ']';95 }96 }97 function printSymbol(val) {98 return symbolToString99 .call(val)100 .replace(SYMBOL_REGEXP, 'Symbol($1)');101 }102 function printError(val) {103 return '[' + errorToString.call(val) + ']';104 }105 function printBasicValue(106 val,107 printFunctionName,108 escapeRegex109 ) {110 if (val === true || val === false) return '' + val;111 if (val === undefined) return 'undefined';112 if (val === null) return 'null';113 const typeOf = typeof val;114 if (typeOf === 'number') return printNumber(val);115 if (typeOf === 'string')116 return '"' + printString(val) + '"';117 if (typeOf === 'function')118 return printFunction(val, printFunctionName);119 if (typeOf === 'symbol') return printSymbol(val);120 const toStringed = toString.call(val);121 if (toStringed === '[object WeakMap]')122 return 'WeakMap {}';123 if (toStringed === '[object WeakSet]')124 return 'WeakSet {}';125 if (126 toStringed === '[object Function]' ||127 toStringed === '[object GeneratorFunction]'128 )129 return printFunction(val, printFunctionName);130 if (toStringed === '[object Symbol]')131 return printSymbol(val);132 if (toStringed === '[object Date]')133 return toISOString.call(val);134 if (toStringed === '[object Error]')135 return printError(val);136 if (toStringed === '[object RegExp]') {137 if (escapeRegex) {138 return printString(regExpToString.call(val));139 }140 return regExpToString.call(val);141 }142 if (143 toStringed === '[object Arguments]' &&144 val.length === 0145 )146 return 'Arguments []';147 if (148 isToStringedArrayType(toStringed) &&149 val.length === 0150 )151 return val.constructor.name + ' []';152 if (val instanceof Error) return printError(val);153 return false;154 }155 function printList(156 list,157 indent,158 prevIndent,159 spacing,160 edgeSpacing,161 refs,162 maxDepth,163 currentDepth,164 plugins,165 min,166 callToJSON,167 printFunctionName,168 escapeRegex169 ) {170 let body = '';171 if (list.length) {172 body += edgeSpacing;173 const innerIndent = prevIndent + indent;174 for (let i = 0; i < list.length; i++) {175 body +=176 innerIndent +177 print(178 list[i],179 indent,180 innerIndent,181 spacing,182 edgeSpacing,183 refs,184 maxDepth,185 currentDepth,186 plugins,187 min,188 callToJSON,189 printFunctionName,190 escapeRegex191 );192 if (i < list.length - 1) {193 body += ',' + spacing;194 }195 }196 body += (min ? '' : ',') + edgeSpacing + prevIndent;197 }198 return '[' + body + ']';199 }200 function printArguments(201 val,202 indent,203 prevIndent,204 spacing,205 edgeSpacing,206 refs,207 maxDepth,208 currentDepth,209 plugins,210 min,211 callToJSON,212 printFunctionName,213 escapeRegex214 ) {215 return (216 (min ? '' : 'Arguments ') +217 printList(218 val,219 indent,220 prevIndent,221 spacing,222 edgeSpacing,223 refs,224 maxDepth,225 currentDepth,226 plugins,227 min,228 callToJSON,229 printFunctionName,230 escapeRegex231 )232 );233 }234 function printArray(235 val,236 indent,237 prevIndent,238 spacing,239 edgeSpacing,240 refs,241 maxDepth,242 currentDepth,243 plugins,244 min,245 callToJSON,246 printFunctionName,247 escapeRegex248 ) {249 return (250 (min ? '' : val.constructor.name + ' ') +251 printList(252 val,253 indent,254 prevIndent,255 spacing,256 edgeSpacing,257 refs,258 maxDepth,259 currentDepth,260 plugins,261 min,262 callToJSON,263 printFunctionName,264 escapeRegex265 )266 );267 }268 function printMap(269 val,270 indent,271 prevIndent,272 spacing,273 edgeSpacing,274 refs,275 maxDepth,276 currentDepth,277 plugins,278 min,279 callToJSON,280 printFunctionName,281 escapeRegex282 ) {283 let result = 'Map {';284 const iterator = val.entries();285 let current = iterator.next();286 if (!current.done) {287 result += edgeSpacing;288 const innerIndent = prevIndent + indent;289 while (!current.done) {290 const key = print(291 current.value[0],292 indent,293 innerIndent,294 spacing,295 edgeSpacing,296 refs,297 maxDepth,298 currentDepth,299 plugins,300 min,301 callToJSON,302 printFunctionName,303 escapeRegex304 );305 const value = print(306 current.value[1],307 indent,308 innerIndent,309 spacing,310 edgeSpacing,311 refs,312 maxDepth,313 currentDepth,314 plugins,315 min,316 callToJSON,317 printFunctionName,318 escapeRegex319 );320 result += innerIndent + key + ' => ' + value;321 current = iterator.next();322 if (!current.done) {323 result += ',' + spacing;324 }325 }326 result +=327 (min ? '' : ',') + edgeSpacing + prevIndent;328 }329 return result + '}';330 }331 function printObject(332 val,333 indent,334 prevIndent,335 spacing,336 edgeSpacing,337 refs,338 maxDepth,339 currentDepth,340 plugins,341 min,342 callToJSON,343 printFunctionName,344 escapeRegex345 ) {346 const constructor = min347 ? ''348 : val.constructor349 ? val.constructor.name + ' '350 : 'Object ';351 let result = constructor + '{';352 let keys = Object.keys(val).sort();353 const symbols = getSymbols(val);354 if (symbols.length) {355 keys = keys356 .filter(357 (key) =>358 !(359 typeof key === 'symbol' ||360 toString.call(key) ===361 '[object Symbol]'362 )363 )364 .concat(symbols);365 }366 if (keys.length) {367 result += edgeSpacing;368 const innerIndent = prevIndent + indent;369 for (let i = 0; i < keys.length; i++) {370 const key = keys[i];371 const name = print(372 key,373 indent,374 innerIndent,375 spacing,376 edgeSpacing,377 refs,378 maxDepth,379 currentDepth,380 plugins,381 min,382 callToJSON,383 printFunctionName,384 escapeRegex385 );386 const value = print(387 val[key],388 indent,389 innerIndent,390 spacing,391 edgeSpacing,392 refs,393 maxDepth,394 currentDepth,395 plugins,396 min,397 callToJSON,398 printFunctionName,399 escapeRegex400 );401 result += innerIndent + name + ': ' + value;402 if (i < keys.length - 1) {403 result += ',' + spacing;404 }405 }406 result +=407 (min ? '' : ',') + edgeSpacing + prevIndent;408 }409 return result + '}';410 }411 function printSet(412 val,413 indent,414 prevIndent,415 spacing,416 edgeSpacing,417 refs,418 maxDepth,419 currentDepth,420 plugins,421 min,422 callToJSON,423 printFunctionName,424 escapeRegex425 ) {426 let result = 'Set {';427 const iterator = val.entries();428 let current = iterator.next();429 if (!current.done) {430 result += edgeSpacing;431 const innerIndent = prevIndent + indent;432 while (!current.done) {433 result +=434 innerIndent +435 print(436 current.value[1],437 indent,438 innerIndent,439 spacing,440 edgeSpacing,441 refs,442 maxDepth,443 currentDepth,444 plugins,445 min,446 callToJSON,447 printFunctionName,448 escapeRegex449 );450 current = iterator.next();451 if (!current.done) {452 result += ',' + spacing;453 }454 }455 result +=456 (min ? '' : ',') + edgeSpacing + prevIndent;457 }458 return result + '}';459 }460 function printComplexValue(461 val,462 indent,463 prevIndent,464 spacing,465 edgeSpacing,466 refs,467 maxDepth,468 currentDepth,469 plugins,470 min,471 callToJSON,472 printFunctionName,473 escapeRegex474 ) {475 refs = refs.slice();476 if (refs.indexOf(val) > -1) {477 return '[Circular]';478 } else {479 refs.push(val);480 }481 currentDepth++;482 const hitMaxDepth = currentDepth > maxDepth;483 if (484 callToJSON &&485 !hitMaxDepth &&486 val.toJSON &&487 typeof val.toJSON === 'function'488 ) {489 return print(490 val.toJSON(),491 indent,492 prevIndent,493 spacing,494 edgeSpacing,495 refs,496 maxDepth,497 currentDepth,498 plugins,499 min,500 callToJSON,501 printFunctionName,502 escapeRegex503 );504 }505 const toStringed = toString.call(val);506 if (toStringed === '[object Arguments]') {507 return hitMaxDepth508 ? '[Arguments]'509 : printArguments(510 val,511 indent,512 prevIndent,513 spacing,514 edgeSpacing,515 refs,516 maxDepth,517 currentDepth,518 plugins,519 min,520 callToJSON,521 printFunctionName,522 escapeRegex523 );524 } else if (isToStringedArrayType(toStringed)) {525 return hitMaxDepth526 ? '[Array]'527 : printArray(528 val,529 indent,530 prevIndent,531 spacing,532 edgeSpacing,533 refs,534 maxDepth,535 currentDepth,536 plugins,537 min,538 callToJSON,...

Full Screen

Full Screen

1a8f236363471ef216d1660ddbab4aa940fe96index.js

Source:1a8f236363471ef216d1660ddbab4aa940fe96index.js Github

copy

Full Screen

...9var NEWLINE_REGEXP = /\n/ig;10var getSymbols = Object.getOwnPropertySymbols || function (obj) {11 return [];12};13function isToStringedArrayType(toStringed) {14 return toStringed === '[object Array]' || toStringed === '[object ArrayBuffer]' || toStringed === '[object DataView]' || toStringed === '[object Float32Array]' || toStringed === '[object Float64Array]' || toStringed === '[object Int8Array]' || toStringed === '[object Int16Array]' || toStringed === '[object Int32Array]' || toStringed === '[object Uint8Array]' || toStringed === '[object Uint8ClampedArray]' || toStringed === '[object Uint16Array]' || toStringed === '[object Uint32Array]';15}16function printNumber(val) {17 if (val != +val) return 'NaN';18 var isNegativeZero = val === 0 && 1 / val < 0;19 return isNegativeZero ? '-0' : '' + val;20}21function printFunction(val, printFunctionName) {22 if (!printFunctionName) {23 return '[Function]';24 } else if (val.name === '') {25 return '[Function anonymous]';26 } else {27 return '[Function ' + val.name + ']';28 }29}30function printSymbol(val) {31 return symbolToString.call(val).replace(SYMBOL_REGEXP, 'Symbol($1)');32}33function printError(val) {34 return '[' + errorToString.call(val) + ']';35}36function printBasicValue(val, printFunctionName, escapeRegex) {37 if (val === true || val === false) return '' + val;38 if (val === undefined) return 'undefined';39 if (val === null) return 'null';40 var typeOf = typeof val;41 if (typeOf === 'number') return printNumber(val);42 if (typeOf === 'string') return '"' + printString(val) + '"';43 if (typeOf === 'function') return printFunction(val, printFunctionName);44 if (typeOf === 'symbol') return printSymbol(val);45 var toStringed = toString.call(val);46 if (toStringed === '[object WeakMap]') return 'WeakMap {}';47 if (toStringed === '[object WeakSet]') return 'WeakSet {}';48 if (toStringed === '[object Function]' || toStringed === '[object GeneratorFunction]') return printFunction(val, printFunctionName);49 if (toStringed === '[object Symbol]') return printSymbol(val);50 if (toStringed === '[object Date]') return toISOString.call(val);51 if (toStringed === '[object Error]') return printError(val);52 if (toStringed === '[object RegExp]') {53 if (escapeRegex) {54 return printString(regExpToString.call(val));55 }56 return regExpToString.call(val);57 };58 if (toStringed === '[object Arguments]' && val.length === 0) return 'Arguments []';59 if (isToStringedArrayType(toStringed) && val.length === 0) return val.constructor.name + ' []';60 if (val instanceof Error) return printError(val);61 return false;62}63function printList(list, indent, prevIndent, spacing, edgeSpacing, refs, maxDepth, currentDepth, plugins, min, callToJSON, printFunctionName, escapeRegex) {64 var body = '';65 if (list.length) {66 body += edgeSpacing;67 var innerIndent = prevIndent + indent;68 for (var i = 0; i < list.length; i++) {69 body += innerIndent + print(list[i], indent, innerIndent, spacing, edgeSpacing, refs, maxDepth, currentDepth, plugins, min, callToJSON, printFunctionName, escapeRegex);70 if (i < list.length - 1) {71 body += ',' + spacing;72 }73 }74 body += (min ? '' : ',') + edgeSpacing + prevIndent;75 }76 return '[' + body + ']';77}78function printArguments(val, indent, prevIndent, spacing, edgeSpacing, refs, maxDepth, currentDepth, plugins, min, callToJSON, printFunctionName, escapeRegex) {79 return (min ? '' : 'Arguments ') + printList(val, indent, prevIndent, spacing, edgeSpacing, refs, maxDepth, currentDepth, plugins, min, callToJSON, printFunctionName, escapeRegex);80}81function printArray(val, indent, prevIndent, spacing, edgeSpacing, refs, maxDepth, currentDepth, plugins, min, callToJSON, printFunctionName, escapeRegex) {82 return (min ? '' : val.constructor.name + ' ') + printList(val, indent, prevIndent, spacing, edgeSpacing, refs, maxDepth, currentDepth, plugins, min, callToJSON, printFunctionName, escapeRegex);83}84function printMap(val, indent, prevIndent, spacing, edgeSpacing, refs, maxDepth, currentDepth, plugins, min, callToJSON, printFunctionName, escapeRegex) {85 var result = 'Map {';86 var iterator = val.entries();87 var current = iterator.next();88 if (!current.done) {89 result += edgeSpacing;90 var innerIndent = prevIndent + indent;91 while (!current.done) {92 var key = print(current.value[0], indent, innerIndent, spacing, edgeSpacing, refs, maxDepth, currentDepth, plugins, min, callToJSON, printFunctionName, escapeRegex);93 var value = print(current.value[1], indent, innerIndent, spacing, edgeSpacing, refs, maxDepth, currentDepth, plugins, min, callToJSON, printFunctionName, escapeRegex);94 result += innerIndent + key + ' => ' + value;95 current = iterator.next();96 if (!current.done) {97 result += ',' + spacing;98 }99 }100 result += (min ? '' : ',') + edgeSpacing + prevIndent;101 }102 return result + '}';103}104function printObject(val, indent, prevIndent, spacing, edgeSpacing, refs, maxDepth, currentDepth, plugins, min, callToJSON, printFunctionName, escapeRegex) {105 var constructor = min ? '' : val.constructor ? val.constructor.name + ' ' : 'Object ';106 var result = constructor + '{';107 var keys = Object.keys(val).sort();108 var symbols = getSymbols(val);109 if (symbols.length) {110 keys = keys.filter(function (key) {111 return !(typeof key === 'symbol' || toString.call(key) === '[object Symbol]');112 }).concat(symbols);113 }114 if (keys.length) {115 result += edgeSpacing;116 var innerIndent = prevIndent + indent;117 for (var i = 0; i < keys.length; i++) {118 var key = keys[i];119 var name = print(key, indent, innerIndent, spacing, edgeSpacing, refs, maxDepth, currentDepth, plugins, min, callToJSON, printFunctionName, escapeRegex);120 var value = print(val[key], indent, innerIndent, spacing, edgeSpacing, refs, maxDepth, currentDepth, plugins, min, callToJSON, printFunctionName, escapeRegex);121 result += innerIndent + name + ': ' + value;122 if (i < keys.length - 1) {123 result += ',' + spacing;124 }125 }126 result += (min ? '' : ',') + edgeSpacing + prevIndent;127 }128 return result + '}';129}130function printSet(val, indent, prevIndent, spacing, edgeSpacing, refs, maxDepth, currentDepth, plugins, min, callToJSON, printFunctionName, escapeRegex) {131 var result = 'Set {';132 var iterator = val.entries();133 var current = iterator.next();134 if (!current.done) {135 result += edgeSpacing;136 var innerIndent = prevIndent + indent;137 while (!current.done) {138 result += innerIndent + print(current.value[1], indent, innerIndent, spacing, edgeSpacing, refs, maxDepth, currentDepth, plugins, min, callToJSON, printFunctionName, escapeRegex);139 current = iterator.next();140 if (!current.done) {141 result += ',' + spacing;142 }143 }144 result += (min ? '' : ',') + edgeSpacing + prevIndent;145 }146 return result + '}';147}148function printComplexValue(val, indent, prevIndent, spacing, edgeSpacing, refs, maxDepth, currentDepth, plugins, min, callToJSON, printFunctionName, escapeRegex) {149 refs = refs.slice();150 if (refs.indexOf(val) > -1) {151 return '[Circular]';152 } else {153 refs.push(val);154 }155 currentDepth++;156 var hitMaxDepth = currentDepth > maxDepth;157 if (callToJSON && !hitMaxDepth && val.toJSON && typeof val.toJSON === 'function') {158 return print(val.toJSON(), indent, prevIndent, spacing, edgeSpacing, refs, maxDepth, currentDepth, plugins, min, callToJSON, printFunctionName, escapeRegex);159 }160 var toStringed = toString.call(val);161 if (toStringed === '[object Arguments]') {162 return hitMaxDepth ? '[Arguments]' : printArguments(val, indent, prevIndent, spacing, edgeSpacing, refs, maxDepth, currentDepth, plugins, min, callToJSON, printFunctionName, escapeRegex);163 } else if (isToStringedArrayType(toStringed)) {164 return hitMaxDepth ? '[Array]' : printArray(val, indent, prevIndent, spacing, edgeSpacing, refs, maxDepth, currentDepth, plugins, min, callToJSON, printFunctionName, escapeRegex);165 } else if (toStringed === '[object Map]') {166 return hitMaxDepth ? '[Map]' : printMap(val, indent, prevIndent, spacing, edgeSpacing, refs, maxDepth, currentDepth, plugins, min, callToJSON, printFunctionName, escapeRegex);167 } else if (toStringed === '[object Set]') {168 return hitMaxDepth ? '[Set]' : printSet(val, indent, prevIndent, spacing, edgeSpacing, refs, maxDepth, currentDepth, plugins, min, callToJSON, printFunctionName, escapeRegex);169 } else if (typeof val === 'object') {170 return hitMaxDepth ? '[Object]' : printObject(val, indent, prevIndent, spacing, edgeSpacing, refs, maxDepth, currentDepth, plugins, min, callToJSON, printFunctionName, escapeRegex);171 }172}173function printPlugin(val, indent, prevIndent, spacing, edgeSpacing, refs, maxDepth, currentDepth, plugins, min, callToJSON, printFunctionName, escapeRegex) {174 var match = false;175 var plugin = void 0;176 for (var p = 0; p < plugins.length; p++) {177 plugin = plugins[p];...

Full Screen

Full Screen

88302e4ddf3c3b05c547de817e2b2544ca45f5index.js

Source:88302e4ddf3c3b05c547de817e2b2544ca45f5index.js Github

copy

Full Screen

...9var NEWLINE_REGEXP = /\n/ig;10var getSymbols = Object.getOwnPropertySymbols || function (obj) {11 return [];12};13function isToStringedArrayType(toStringed) {14 return toStringed === '[object Array]' || toStringed === '[object ArrayBuffer]' || toStringed === '[object DataView]' || toStringed === '[object Float32Array]' || toStringed === '[object Float64Array]' || toStringed === '[object Int8Array]' || toStringed === '[object Int16Array]' || toStringed === '[object Int32Array]' || toStringed === '[object Uint8Array]' || toStringed === '[object Uint8ClampedArray]' || toStringed === '[object Uint16Array]' || toStringed === '[object Uint32Array]';15}16function printNumber(val) {17 if (val != +val) return 'NaN';18 var isNegativeZero = val === 0 && 1 / val < 0;19 return isNegativeZero ? '-0' : '' + val;20}21function printFunction(val, printFunctionName) {22 if (!printFunctionName) {23 return '[Function]';24 } else if (val.name === '') {25 return '[Function anonymous]';26 } else {27 return '[Function ' + val.name + ']';28 }29}30function printSymbol(val) {31 return symbolToString.call(val).replace(SYMBOL_REGEXP, 'Symbol($1)');32}33function printError(val) {34 return '[' + errorToString.call(val) + ']';35}36function printBasicValue(val, printFunctionName, escapeRegex) {37 if (val === true || val === false) return '' + val;38 if (val === undefined) return 'undefined';39 if (val === null) return 'null';40 var typeOf = typeof val;41 if (typeOf === 'number') return printNumber(val);42 if (typeOf === 'string') return '"' + printString(val) + '"';43 if (typeOf === 'function') return printFunction(val, printFunctionName);44 if (typeOf === 'symbol') return printSymbol(val);45 var toStringed = toString.call(val);46 if (toStringed === '[object WeakMap]') return 'WeakMap {}';47 if (toStringed === '[object WeakSet]') return 'WeakSet {}';48 if (toStringed === '[object Function]' || toStringed === '[object GeneratorFunction]') return printFunction(val, printFunctionName);49 if (toStringed === '[object Symbol]') return printSymbol(val);50 if (toStringed === '[object Date]') return toISOString.call(val);51 if (toStringed === '[object Error]') return printError(val);52 if (toStringed === '[object RegExp]') {53 if (escapeRegex) {54 return printString(regExpToString.call(val));55 }56 return regExpToString.call(val);57 };58 if (toStringed === '[object Arguments]' && val.length === 0) return 'Arguments []';59 if (isToStringedArrayType(toStringed) && val.length === 0) return val.constructor.name + ' []';60 if (val instanceof Error) return printError(val);61 return false;62}63function printList(list, indent, prevIndent, spacing, edgeSpacing, refs, maxDepth, currentDepth, plugins, min, callToJSON, printFunctionName, escapeRegex) {64 var body = '';65 if (list.length) {66 body += edgeSpacing;67 var innerIndent = prevIndent + indent;68 for (var i = 0; i < list.length; i++) {69 body += innerIndent + print(list[i], indent, innerIndent, spacing, edgeSpacing, refs, maxDepth, currentDepth, plugins, min, callToJSON, printFunctionName, escapeRegex);70 if (i < list.length - 1) {71 body += ',' + spacing;72 }73 }74 body += (min ? '' : ',') + edgeSpacing + prevIndent;75 }76 return '[' + body + ']';77}78function printArguments(val, indent, prevIndent, spacing, edgeSpacing, refs, maxDepth, currentDepth, plugins, min, callToJSON, printFunctionName, escapeRegex) {79 return (min ? '' : 'Arguments ') + printList(val, indent, prevIndent, spacing, edgeSpacing, refs, maxDepth, currentDepth, plugins, min, callToJSON, printFunctionName, escapeRegex);80}81function printArray(val, indent, prevIndent, spacing, edgeSpacing, refs, maxDepth, currentDepth, plugins, min, callToJSON, printFunctionName, escapeRegex) {82 return (min ? '' : val.constructor.name + ' ') + printList(val, indent, prevIndent, spacing, edgeSpacing, refs, maxDepth, currentDepth, plugins, min, callToJSON, printFunctionName, escapeRegex);83}84function printMap(val, indent, prevIndent, spacing, edgeSpacing, refs, maxDepth, currentDepth, plugins, min, callToJSON, printFunctionName, escapeRegex) {85 var result = 'Map {';86 var iterator = val.entries();87 var current = iterator.next();88 if (!current.done) {89 result += edgeSpacing;90 var innerIndent = prevIndent + indent;91 while (!current.done) {92 var key = print(current.value[0], indent, innerIndent, spacing, edgeSpacing, refs, maxDepth, currentDepth, plugins, min, callToJSON, printFunctionName, escapeRegex);93 var value = print(current.value[1], indent, innerIndent, spacing, edgeSpacing, refs, maxDepth, currentDepth, plugins, min, callToJSON, printFunctionName, escapeRegex);94 result += innerIndent + key + ' => ' + value;95 current = iterator.next();96 if (!current.done) {97 result += ',' + spacing;98 }99 }100 result += (min ? '' : ',') + edgeSpacing + prevIndent;101 }102 return result + '}';103}104function printObject(val, indent, prevIndent, spacing, edgeSpacing, refs, maxDepth, currentDepth, plugins, min, callToJSON, printFunctionName, escapeRegex) {105 var constructor = min ? '' : val.constructor ? val.constructor.name + ' ' : 'Object ';106 var result = constructor + '{';107 var keys = Object.keys(val).sort();108 var symbols = getSymbols(val);109 if (symbols.length) {110 keys = keys.filter(function (key) {111 return !(typeof key === 'symbol' || toString.call(key) === '[object Symbol]');112 }).concat(symbols);113 }114 if (keys.length) {115 result += edgeSpacing;116 var innerIndent = prevIndent + indent;117 for (var i = 0; i < keys.length; i++) {118 var key = keys[i];119 var name = print(key, indent, innerIndent, spacing, edgeSpacing, refs, maxDepth, currentDepth, plugins, min, callToJSON, printFunctionName, escapeRegex);120 var value = print(val[key], indent, innerIndent, spacing, edgeSpacing, refs, maxDepth, currentDepth, plugins, min, callToJSON, printFunctionName, escapeRegex);121 result += innerIndent + name + ': ' + value;122 if (i < keys.length - 1) {123 result += ',' + spacing;124 }125 }126 result += (min ? '' : ',') + edgeSpacing + prevIndent;127 }128 return result + '}';129}130function printSet(val, indent, prevIndent, spacing, edgeSpacing, refs, maxDepth, currentDepth, plugins, min, callToJSON, printFunctionName, escapeRegex) {131 var result = 'Set {';132 var iterator = val.entries();133 var current = iterator.next();134 if (!current.done) {135 result += edgeSpacing;136 var innerIndent = prevIndent + indent;137 while (!current.done) {138 result += innerIndent + print(current.value[1], indent, innerIndent, spacing, edgeSpacing, refs, maxDepth, currentDepth, plugins, min, callToJSON, printFunctionName, escapeRegex);139 current = iterator.next();140 if (!current.done) {141 result += ',' + spacing;142 }143 }144 result += (min ? '' : ',') + edgeSpacing + prevIndent;145 }146 return result + '}';147}148function printComplexValue(val, indent, prevIndent, spacing, edgeSpacing, refs, maxDepth, currentDepth, plugins, min, callToJSON, printFunctionName, escapeRegex) {149 refs = refs.slice();150 if (refs.indexOf(val) > -1) {151 return '[Circular]';152 } else {153 refs.push(val);154 }155 currentDepth++;156 var hitMaxDepth = currentDepth > maxDepth;157 if (callToJSON && !hitMaxDepth && val.toJSON && typeof val.toJSON === 'function') {158 return print(val.toJSON(), indent, prevIndent, spacing, edgeSpacing, refs, maxDepth, currentDepth, plugins, min, callToJSON, printFunctionName, escapeRegex);159 }160 var toStringed = toString.call(val);161 if (toStringed === '[object Arguments]') {162 return hitMaxDepth ? '[Arguments]' : printArguments(val, indent, prevIndent, spacing, edgeSpacing, refs, maxDepth, currentDepth, plugins, min, callToJSON, printFunctionName, escapeRegex);163 } else if (isToStringedArrayType(toStringed)) {164 return hitMaxDepth ? '[Array]' : printArray(val, indent, prevIndent, spacing, edgeSpacing, refs, maxDepth, currentDepth, plugins, min, callToJSON, printFunctionName, escapeRegex);165 } else if (toStringed === '[object Map]') {166 return hitMaxDepth ? '[Map]' : printMap(val, indent, prevIndent, spacing, edgeSpacing, refs, maxDepth, currentDepth, plugins, min, callToJSON, printFunctionName, escapeRegex);167 } else if (toStringed === '[object Set]') {168 return hitMaxDepth ? '[Set]' : printSet(val, indent, prevIndent, spacing, edgeSpacing, refs, maxDepth, currentDepth, plugins, min, callToJSON, printFunctionName, escapeRegex);169 } else if (typeof val === 'object') {170 return hitMaxDepth ? '[Object]' : printObject(val, indent, prevIndent, spacing, edgeSpacing, refs, maxDepth, currentDepth, plugins, min, callToJSON, printFunctionName, escapeRegex);171 }172}173function printPlugin(val, indent, prevIndent, spacing, edgeSpacing, refs, maxDepth, currentDepth, plugins, min, callToJSON, printFunctionName, escapeRegex) {174 var match = false;175 var plugin = void 0;176 for (var p = 0; p < plugins.length; p++) {177 plugin = plugins[p];...

Full Screen

Full Screen

6626ef2ab970bba4d185684bbead682c6acea5index.js

Source:6626ef2ab970bba4d185684bbead682c6acea5index.js Github

copy

Full Screen

...9var NEWLINE_REGEXP = /\n/ig;10var getSymbols = Object.getOwnPropertySymbols || function (obj) {11 return [];12};13function isToStringedArrayType(toStringed) {14 return toStringed === '[object Array]' || toStringed === '[object ArrayBuffer]' || toStringed === '[object DataView]' || toStringed === '[object Float32Array]' || toStringed === '[object Float64Array]' || toStringed === '[object Int8Array]' || toStringed === '[object Int16Array]' || toStringed === '[object Int32Array]' || toStringed === '[object Uint8Array]' || toStringed === '[object Uint8ClampedArray]' || toStringed === '[object Uint16Array]' || toStringed === '[object Uint32Array]';15}16function printNumber(val) {17 if (val != +val) return 'NaN';18 var isNegativeZero = val === 0 && 1 / val < 0;19 return isNegativeZero ? '-0' : '' + val;20}21function printFunction(val, printFunctionName) {22 if (!printFunctionName) {23 return '[Function]';24 } else if (val.name === '') {25 return '[Function anonymous]';26 } else {27 return '[Function ' + val.name + ']';28 }29}30function printSymbol(val) {31 return symbolToString.call(val).replace(SYMBOL_REGEXP, 'Symbol($1)');32}33function printError(val) {34 return '[' + errorToString.call(val) + ']';35}36function printBasicValue(val, printFunctionName, escapeRegex) {37 if (val === true || val === false) return '' + val;38 if (val === undefined) return 'undefined';39 if (val === null) return 'null';40 var typeOf = typeof val;41 if (typeOf === 'number') return printNumber(val);42 if (typeOf === 'string') return '"' + printString(val) + '"';43 if (typeOf === 'function') return printFunction(val, printFunctionName);44 if (typeOf === 'symbol') return printSymbol(val);45 var toStringed = toString.call(val);46 if (toStringed === '[object WeakMap]') return 'WeakMap {}';47 if (toStringed === '[object WeakSet]') return 'WeakSet {}';48 if (toStringed === '[object Function]' || toStringed === '[object GeneratorFunction]') return printFunction(val, printFunctionName);49 if (toStringed === '[object Symbol]') return printSymbol(val);50 if (toStringed === '[object Date]') return toISOString.call(val);51 if (toStringed === '[object Error]') return printError(val);52 if (toStringed === '[object RegExp]') {53 if (escapeRegex) {54 return printString(regExpToString.call(val));55 }56 return regExpToString.call(val);57 };58 if (toStringed === '[object Arguments]' && val.length === 0) return 'Arguments []';59 if (isToStringedArrayType(toStringed) && val.length === 0) return val.constructor.name + ' []';60 if (val instanceof Error) return printError(val);61 return false;62}63function printList(list, indent, prevIndent, spacing, edgeSpacing, refs, maxDepth, currentDepth, plugins, min, callToJSON, printFunctionName, escapeRegex) {64 var body = '';65 if (list.length) {66 body += edgeSpacing;67 var innerIndent = prevIndent + indent;68 for (var i = 0; i < list.length; i++) {69 body += innerIndent + print(list[i], indent, innerIndent, spacing, edgeSpacing, refs, maxDepth, currentDepth, plugins, min, callToJSON, printFunctionName, escapeRegex);70 if (i < list.length - 1) {71 body += ',' + spacing;72 }73 }74 body += (min ? '' : ',') + edgeSpacing + prevIndent;75 }76 return '[' + body + ']';77}78function printArguments(val, indent, prevIndent, spacing, edgeSpacing, refs, maxDepth, currentDepth, plugins, min, callToJSON, printFunctionName, escapeRegex) {79 return (min ? '' : 'Arguments ') + printList(val, indent, prevIndent, spacing, edgeSpacing, refs, maxDepth, currentDepth, plugins, min, callToJSON, printFunctionName, escapeRegex);80}81function printArray(val, indent, prevIndent, spacing, edgeSpacing, refs, maxDepth, currentDepth, plugins, min, callToJSON, printFunctionName, escapeRegex) {82 return (min ? '' : val.constructor.name + ' ') + printList(val, indent, prevIndent, spacing, edgeSpacing, refs, maxDepth, currentDepth, plugins, min, callToJSON, printFunctionName, escapeRegex);83}84function printMap(val, indent, prevIndent, spacing, edgeSpacing, refs, maxDepth, currentDepth, plugins, min, callToJSON, printFunctionName, escapeRegex) {85 var result = 'Map {';86 var iterator = val.entries();87 var current = iterator.next();88 if (!current.done) {89 result += edgeSpacing;90 var innerIndent = prevIndent + indent;91 while (!current.done) {92 var key = print(current.value[0], indent, innerIndent, spacing, edgeSpacing, refs, maxDepth, currentDepth, plugins, min, callToJSON, printFunctionName, escapeRegex);93 var value = print(current.value[1], indent, innerIndent, spacing, edgeSpacing, refs, maxDepth, currentDepth, plugins, min, callToJSON, printFunctionName, escapeRegex);94 result += innerIndent + key + ' => ' + value;95 current = iterator.next();96 if (!current.done) {97 result += ',' + spacing;98 }99 }100 result += (min ? '' : ',') + edgeSpacing + prevIndent;101 }102 return result + '}';103}104function printObject(val, indent, prevIndent, spacing, edgeSpacing, refs, maxDepth, currentDepth, plugins, min, callToJSON, printFunctionName, escapeRegex) {105 var constructor = min ? '' : val.constructor ? val.constructor.name + ' ' : 'Object ';106 var result = constructor + '{';107 var keys = Object.keys(val).sort();108 var symbols = getSymbols(val);109 if (symbols.length) {110 keys = keys.filter(function (key) {111 return !(typeof key === 'symbol' || toString.call(key) === '[object Symbol]');112 }).concat(symbols);113 }114 if (keys.length) {115 result += edgeSpacing;116 var innerIndent = prevIndent + indent;117 for (var i = 0; i < keys.length; i++) {118 var key = keys[i];119 var name = print(key, indent, innerIndent, spacing, edgeSpacing, refs, maxDepth, currentDepth, plugins, min, callToJSON, printFunctionName, escapeRegex);120 var value = print(val[key], indent, innerIndent, spacing, edgeSpacing, refs, maxDepth, currentDepth, plugins, min, callToJSON, printFunctionName, escapeRegex);121 result += innerIndent + name + ': ' + value;122 if (i < keys.length - 1) {123 result += ',' + spacing;124 }125 }126 result += (min ? '' : ',') + edgeSpacing + prevIndent;127 }128 return result + '}';129}130function printSet(val, indent, prevIndent, spacing, edgeSpacing, refs, maxDepth, currentDepth, plugins, min, callToJSON, printFunctionName, escapeRegex) {131 var result = 'Set {';132 var iterator = val.entries();133 var current = iterator.next();134 if (!current.done) {135 result += edgeSpacing;136 var innerIndent = prevIndent + indent;137 while (!current.done) {138 result += innerIndent + print(current.value[1], indent, innerIndent, spacing, edgeSpacing, refs, maxDepth, currentDepth, plugins, min, callToJSON, printFunctionName, escapeRegex);139 current = iterator.next();140 if (!current.done) {141 result += ',' + spacing;142 }143 }144 result += (min ? '' : ',') + edgeSpacing + prevIndent;145 }146 return result + '}';147}148function printComplexValue(val, indent, prevIndent, spacing, edgeSpacing, refs, maxDepth, currentDepth, plugins, min, callToJSON, printFunctionName, escapeRegex) {149 refs = refs.slice();150 if (refs.indexOf(val) > -1) {151 return '[Circular]';152 } else {153 refs.push(val);154 }155 currentDepth++;156 var hitMaxDepth = currentDepth > maxDepth;157 if (callToJSON && !hitMaxDepth && val.toJSON && typeof val.toJSON === 'function') {158 return print(val.toJSON(), indent, prevIndent, spacing, edgeSpacing, refs, maxDepth, currentDepth, plugins, min, callToJSON, printFunctionName, escapeRegex);159 }160 var toStringed = toString.call(val);161 if (toStringed === '[object Arguments]') {162 return hitMaxDepth ? '[Arguments]' : printArguments(val, indent, prevIndent, spacing, edgeSpacing, refs, maxDepth, currentDepth, plugins, min, callToJSON, printFunctionName, escapeRegex);163 } else if (isToStringedArrayType(toStringed)) {164 return hitMaxDepth ? '[Array]' : printArray(val, indent, prevIndent, spacing, edgeSpacing, refs, maxDepth, currentDepth, plugins, min, callToJSON, printFunctionName, escapeRegex);165 } else if (toStringed === '[object Map]') {166 return hitMaxDepth ? '[Map]' : printMap(val, indent, prevIndent, spacing, edgeSpacing, refs, maxDepth, currentDepth, plugins, min, callToJSON, printFunctionName, escapeRegex);167 } else if (toStringed === '[object Set]') {168 return hitMaxDepth ? '[Set]' : printSet(val, indent, prevIndent, spacing, edgeSpacing, refs, maxDepth, currentDepth, plugins, min, callToJSON, printFunctionName, escapeRegex);169 } else if (typeof val === 'object') {170 return hitMaxDepth ? '[Object]' : printObject(val, indent, prevIndent, spacing, edgeSpacing, refs, maxDepth, currentDepth, plugins, min, callToJSON, printFunctionName, escapeRegex);171 }172}173function printPlugin(val, indent, prevIndent, spacing, edgeSpacing, refs, maxDepth, currentDepth, plugins, min, callToJSON, printFunctionName, escapeRegex) {174 var match = false;175 var plugin = void 0;176 for (var p = 0; p < plugins.length; p++) {177 plugin = plugins[p];...

Full Screen

Full Screen

338ba61bb79518db5357363966a263aa87c41cindex.js

Source:338ba61bb79518db5357363966a263aa87c41cindex.js Github

copy

Full Screen

...9var NEWLINE_REGEXP = /\n/ig;10var getSymbols = Object.getOwnPropertySymbols || function (obj) {11 return [];12};13function isToStringedArrayType(toStringed) {14 return toStringed === '[object Array]' || toStringed === '[object ArrayBuffer]' || toStringed === '[object DataView]' || toStringed === '[object Float32Array]' || toStringed === '[object Float64Array]' || toStringed === '[object Int8Array]' || toStringed === '[object Int16Array]' || toStringed === '[object Int32Array]' || toStringed === '[object Uint8Array]' || toStringed === '[object Uint8ClampedArray]' || toStringed === '[object Uint16Array]' || toStringed === '[object Uint32Array]';15}16function printNumber(val) {17 if (val != +val) return 'NaN';18 var isNegativeZero = val === 0 && 1 / val < 0;19 return isNegativeZero ? '-0' : '' + val;20}21function printFunction(val, printFunctionName) {22 if (!printFunctionName) {23 return '[Function]';24 } else if (val.name === '') {25 return '[Function anonymous]';26 } else {27 return '[Function ' + val.name + ']';28 }29}30function printSymbol(val) {31 return symbolToString.call(val).replace(SYMBOL_REGEXP, 'Symbol($1)');32}33function printError(val) {34 return '[' + errorToString.call(val) + ']';35}36function printBasicValue(val, printFunctionName, escapeRegex) {37 if (val === true || val === false) return '' + val;38 if (val === undefined) return 'undefined';39 if (val === null) return 'null';40 var typeOf = typeof val;41 if (typeOf === 'number') return printNumber(val);42 if (typeOf === 'string') return '"' + printString(val) + '"';43 if (typeOf === 'function') return printFunction(val, printFunctionName);44 if (typeOf === 'symbol') return printSymbol(val);45 var toStringed = toString.call(val);46 if (toStringed === '[object WeakMap]') return 'WeakMap {}';47 if (toStringed === '[object WeakSet]') return 'WeakSet {}';48 if (toStringed === '[object Function]' || toStringed === '[object GeneratorFunction]') return printFunction(val, printFunctionName);49 if (toStringed === '[object Symbol]') return printSymbol(val);50 if (toStringed === '[object Date]') return toISOString.call(val);51 if (toStringed === '[object Error]') return printError(val);52 if (toStringed === '[object RegExp]') {53 if (escapeRegex) {54 return printString(regExpToString.call(val));55 }56 return regExpToString.call(val);57 };58 if (toStringed === '[object Arguments]' && val.length === 0) return 'Arguments []';59 if (isToStringedArrayType(toStringed) && val.length === 0) return val.constructor.name + ' []';60 if (val instanceof Error) return printError(val);61 return false;62}63function printList(list, indent, prevIndent, spacing, edgeSpacing, refs, maxDepth, currentDepth, plugins, min, callToJSON, printFunctionName, escapeRegex) {64 var body = '';65 if (list.length) {66 body += edgeSpacing;67 var innerIndent = prevIndent + indent;68 for (var i = 0; i < list.length; i++) {69 body += innerIndent + print(list[i], indent, innerIndent, spacing, edgeSpacing, refs, maxDepth, currentDepth, plugins, min, callToJSON, printFunctionName, escapeRegex);70 if (i < list.length - 1) {71 body += ',' + spacing;72 }73 }74 body += (min ? '' : ',') + edgeSpacing + prevIndent;75 }76 return '[' + body + ']';77}78function printArguments(val, indent, prevIndent, spacing, edgeSpacing, refs, maxDepth, currentDepth, plugins, min, callToJSON, printFunctionName, escapeRegex) {79 return (min ? '' : 'Arguments ') + printList(val, indent, prevIndent, spacing, edgeSpacing, refs, maxDepth, currentDepth, plugins, min, callToJSON, printFunctionName, escapeRegex);80}81function printArray(val, indent, prevIndent, spacing, edgeSpacing, refs, maxDepth, currentDepth, plugins, min, callToJSON, printFunctionName, escapeRegex) {82 return (min ? '' : val.constructor.name + ' ') + printList(val, indent, prevIndent, spacing, edgeSpacing, refs, maxDepth, currentDepth, plugins, min, callToJSON, printFunctionName, escapeRegex);83}84function printMap(val, indent, prevIndent, spacing, edgeSpacing, refs, maxDepth, currentDepth, plugins, min, callToJSON, printFunctionName, escapeRegex) {85 var result = 'Map {';86 var iterator = val.entries();87 var current = iterator.next();88 if (!current.done) {89 result += edgeSpacing;90 var innerIndent = prevIndent + indent;91 while (!current.done) {92 var key = print(current.value[0], indent, innerIndent, spacing, edgeSpacing, refs, maxDepth, currentDepth, plugins, min, callToJSON, printFunctionName, escapeRegex);93 var value = print(current.value[1], indent, innerIndent, spacing, edgeSpacing, refs, maxDepth, currentDepth, plugins, min, callToJSON, printFunctionName, escapeRegex);94 result += innerIndent + key + ' => ' + value;95 current = iterator.next();96 if (!current.done) {97 result += ',' + spacing;98 }99 }100 result += (min ? '' : ',') + edgeSpacing + prevIndent;101 }102 return result + '}';103}104function printObject(val, indent, prevIndent, spacing, edgeSpacing, refs, maxDepth, currentDepth, plugins, min, callToJSON, printFunctionName, escapeRegex) {105 var constructor = min ? '' : val.constructor ? val.constructor.name + ' ' : 'Object ';106 var result = constructor + '{';107 var keys = Object.keys(val).sort();108 var symbols = getSymbols(val);109 if (symbols.length) {110 keys = keys.filter(function (key) {111 return !(typeof key === 'symbol' || toString.call(key) === '[object Symbol]');112 }).concat(symbols);113 }114 if (keys.length) {115 result += edgeSpacing;116 var innerIndent = prevIndent + indent;117 for (var i = 0; i < keys.length; i++) {118 var key = keys[i];119 var name = print(key, indent, innerIndent, spacing, edgeSpacing, refs, maxDepth, currentDepth, plugins, min, callToJSON, printFunctionName, escapeRegex);120 var value = print(val[key], indent, innerIndent, spacing, edgeSpacing, refs, maxDepth, currentDepth, plugins, min, callToJSON, printFunctionName, escapeRegex);121 result += innerIndent + name + ': ' + value;122 if (i < keys.length - 1) {123 result += ',' + spacing;124 }125 }126 result += (min ? '' : ',') + edgeSpacing + prevIndent;127 }128 return result + '}';129}130function printSet(val, indent, prevIndent, spacing, edgeSpacing, refs, maxDepth, currentDepth, plugins, min, callToJSON, printFunctionName, escapeRegex) {131 var result = 'Set {';132 var iterator = val.entries();133 var current = iterator.next();134 if (!current.done) {135 result += edgeSpacing;136 var innerIndent = prevIndent + indent;137 while (!current.done) {138 result += innerIndent + print(current.value[1], indent, innerIndent, spacing, edgeSpacing, refs, maxDepth, currentDepth, plugins, min, callToJSON, printFunctionName, escapeRegex);139 current = iterator.next();140 if (!current.done) {141 result += ',' + spacing;142 }143 }144 result += (min ? '' : ',') + edgeSpacing + prevIndent;145 }146 return result + '}';147}148function printComplexValue(val, indent, prevIndent, spacing, edgeSpacing, refs, maxDepth, currentDepth, plugins, min, callToJSON, printFunctionName, escapeRegex) {149 refs = refs.slice();150 if (refs.indexOf(val) > -1) {151 return '[Circular]';152 } else {153 refs.push(val);154 }155 currentDepth++;156 var hitMaxDepth = currentDepth > maxDepth;157 if (callToJSON && !hitMaxDepth && val.toJSON && typeof val.toJSON === 'function') {158 return print(val.toJSON(), indent, prevIndent, spacing, edgeSpacing, refs, maxDepth, currentDepth, plugins, min, callToJSON, printFunctionName, escapeRegex);159 }160 var toStringed = toString.call(val);161 if (toStringed === '[object Arguments]') {162 return hitMaxDepth ? '[Arguments]' : printArguments(val, indent, prevIndent, spacing, edgeSpacing, refs, maxDepth, currentDepth, plugins, min, callToJSON, printFunctionName, escapeRegex);163 } else if (isToStringedArrayType(toStringed)) {164 return hitMaxDepth ? '[Array]' : printArray(val, indent, prevIndent, spacing, edgeSpacing, refs, maxDepth, currentDepth, plugins, min, callToJSON, printFunctionName, escapeRegex);165 } else if (toStringed === '[object Map]') {166 return hitMaxDepth ? '[Map]' : printMap(val, indent, prevIndent, spacing, edgeSpacing, refs, maxDepth, currentDepth, plugins, min, callToJSON, printFunctionName, escapeRegex);167 } else if (toStringed === '[object Set]') {168 return hitMaxDepth ? '[Set]' : printSet(val, indent, prevIndent, spacing, edgeSpacing, refs, maxDepth, currentDepth, plugins, min, callToJSON, printFunctionName, escapeRegex);169 } else if (typeof val === 'object') {170 return hitMaxDepth ? '[Object]' : printObject(val, indent, prevIndent, spacing, edgeSpacing, refs, maxDepth, currentDepth, plugins, min, callToJSON, printFunctionName, escapeRegex);171 }172}173function printPlugin(val, indent, prevIndent, spacing, edgeSpacing, refs, maxDepth, currentDepth, plugins, min, callToJSON, printFunctionName, escapeRegex) {174 var match = false;175 var plugin = void 0;176 for (var p = 0; p < plugins.length; p++) {177 plugin = plugins[p];...

Full Screen

Full Screen

e2b7755bdbe65edde5b0c0d4041283e8c29507index.js

Source:e2b7755bdbe65edde5b0c0d4041283e8c29507index.js Github

copy

Full Screen

...9var NEWLINE_REGEXP = /\n/ig;10var getSymbols = Object.getOwnPropertySymbols || function (obj) {11 return [];12};13function isToStringedArrayType(toStringed) {14 return toStringed === '[object Array]' || toStringed === '[object ArrayBuffer]' || toStringed === '[object DataView]' || toStringed === '[object Float32Array]' || toStringed === '[object Float64Array]' || toStringed === '[object Int8Array]' || toStringed === '[object Int16Array]' || toStringed === '[object Int32Array]' || toStringed === '[object Uint8Array]' || toStringed === '[object Uint8ClampedArray]' || toStringed === '[object Uint16Array]' || toStringed === '[object Uint32Array]';15}16function printNumber(val) {17 if (val != +val) return 'NaN';18 var isNegativeZero = val === 0 && 1 / val < 0;19 return isNegativeZero ? '-0' : '' + val;20}21function printFunction(val, printFunctionName) {22 if (!printFunctionName) {23 return '[Function]';24 } else if (val.name === '') {25 return '[Function anonymous]';26 } else {27 return '[Function ' + val.name + ']';28 }29}30function printSymbol(val) {31 return symbolToString.call(val).replace(SYMBOL_REGEXP, 'Symbol($1)');32}33function printError(val) {34 return '[' + errorToString.call(val) + ']';35}36function printBasicValue(val, printFunctionName, escapeRegex) {37 if (val === true || val === false) return '' + val;38 if (val === undefined) return 'undefined';39 if (val === null) return 'null';40 var typeOf = typeof val;41 if (typeOf === 'number') return printNumber(val);42 if (typeOf === 'string') return '"' + printString(val) + '"';43 if (typeOf === 'function') return printFunction(val, printFunctionName);44 if (typeOf === 'symbol') return printSymbol(val);45 var toStringed = toString.call(val);46 if (toStringed === '[object WeakMap]') return 'WeakMap {}';47 if (toStringed === '[object WeakSet]') return 'WeakSet {}';48 if (toStringed === '[object Function]' || toStringed === '[object GeneratorFunction]') return printFunction(val, printFunctionName);49 if (toStringed === '[object Symbol]') return printSymbol(val);50 if (toStringed === '[object Date]') return toISOString.call(val);51 if (toStringed === '[object Error]') return printError(val);52 if (toStringed === '[object RegExp]') {53 if (escapeRegex) {54 return printString(regExpToString.call(val));55 }56 return regExpToString.call(val);57 };58 if (toStringed === '[object Arguments]' && val.length === 0) return 'Arguments []';59 if (isToStringedArrayType(toStringed) && val.length === 0) return val.constructor.name + ' []';60 if (val instanceof Error) return printError(val);61 return false;62}63function printList(list, indent, prevIndent, spacing, edgeSpacing, refs, maxDepth, currentDepth, plugins, min, callToJSON, printFunctionName, escapeRegex) {64 var body = '';65 if (list.length) {66 body += edgeSpacing;67 var innerIndent = prevIndent + indent;68 for (var i = 0; i < list.length; i++) {69 body += innerIndent + print(list[i], indent, innerIndent, spacing, edgeSpacing, refs, maxDepth, currentDepth, plugins, min, callToJSON, printFunctionName, escapeRegex);70 if (i < list.length - 1) {71 body += ',' + spacing;72 }73 }74 body += (min ? '' : ',') + edgeSpacing + prevIndent;75 }76 return '[' + body + ']';77}78function printArguments(val, indent, prevIndent, spacing, edgeSpacing, refs, maxDepth, currentDepth, plugins, min, callToJSON, printFunctionName, escapeRegex) {79 return (min ? '' : 'Arguments ') + printList(val, indent, prevIndent, spacing, edgeSpacing, refs, maxDepth, currentDepth, plugins, min, callToJSON, printFunctionName, escapeRegex);80}81function printArray(val, indent, prevIndent, spacing, edgeSpacing, refs, maxDepth, currentDepth, plugins, min, callToJSON, printFunctionName, escapeRegex) {82 return (min ? '' : val.constructor.name + ' ') + printList(val, indent, prevIndent, spacing, edgeSpacing, refs, maxDepth, currentDepth, plugins, min, callToJSON, printFunctionName, escapeRegex);83}84function printMap(val, indent, prevIndent, spacing, edgeSpacing, refs, maxDepth, currentDepth, plugins, min, callToJSON, printFunctionName, escapeRegex) {85 var result = 'Map {';86 var iterator = val.entries();87 var current = iterator.next();88 if (!current.done) {89 result += edgeSpacing;90 var innerIndent = prevIndent + indent;91 while (!current.done) {92 var key = print(current.value[0], indent, innerIndent, spacing, edgeSpacing, refs, maxDepth, currentDepth, plugins, min, callToJSON, printFunctionName, escapeRegex);93 var value = print(current.value[1], indent, innerIndent, spacing, edgeSpacing, refs, maxDepth, currentDepth, plugins, min, callToJSON, printFunctionName, escapeRegex);94 result += innerIndent + key + ' => ' + value;95 current = iterator.next();96 if (!current.done) {97 result += ',' + spacing;98 }99 }100 result += (min ? '' : ',') + edgeSpacing + prevIndent;101 }102 return result + '}';103}104function printObject(val, indent, prevIndent, spacing, edgeSpacing, refs, maxDepth, currentDepth, plugins, min, callToJSON, printFunctionName, escapeRegex) {105 var constructor = min ? '' : val.constructor ? val.constructor.name + ' ' : 'Object ';106 var result = constructor + '{';107 var keys = Object.keys(val).sort();108 var symbols = getSymbols(val);109 if (symbols.length) {110 keys = keys.filter(function (key) {111 return !(typeof key === 'symbol' || toString.call(key) === '[object Symbol]');112 }).concat(symbols);113 }114 if (keys.length) {115 result += edgeSpacing;116 var innerIndent = prevIndent + indent;117 for (var i = 0; i < keys.length; i++) {118 var key = keys[i];119 var name = print(key, indent, innerIndent, spacing, edgeSpacing, refs, maxDepth, currentDepth, plugins, min, callToJSON, printFunctionName, escapeRegex);120 var value = print(val[key], indent, innerIndent, spacing, edgeSpacing, refs, maxDepth, currentDepth, plugins, min, callToJSON, printFunctionName, escapeRegex);121 result += innerIndent + name + ': ' + value;122 if (i < keys.length - 1) {123 result += ',' + spacing;124 }125 }126 result += (min ? '' : ',') + edgeSpacing + prevIndent;127 }128 return result + '}';129}130function printSet(val, indent, prevIndent, spacing, edgeSpacing, refs, maxDepth, currentDepth, plugins, min, callToJSON, printFunctionName, escapeRegex) {131 var result = 'Set {';132 var iterator = val.entries();133 var current = iterator.next();134 if (!current.done) {135 result += edgeSpacing;136 var innerIndent = prevIndent + indent;137 while (!current.done) {138 result += innerIndent + print(current.value[1], indent, innerIndent, spacing, edgeSpacing, refs, maxDepth, currentDepth, plugins, min, callToJSON, printFunctionName, escapeRegex);139 current = iterator.next();140 if (!current.done) {141 result += ',' + spacing;142 }143 }144 result += (min ? '' : ',') + edgeSpacing + prevIndent;145 }146 return result + '}';147}148function printComplexValue(val, indent, prevIndent, spacing, edgeSpacing, refs, maxDepth, currentDepth, plugins, min, callToJSON, printFunctionName, escapeRegex) {149 refs = refs.slice();150 if (refs.indexOf(val) > -1) {151 return '[Circular]';152 } else {153 refs.push(val);154 }155 currentDepth++;156 var hitMaxDepth = currentDepth > maxDepth;157 if (callToJSON && !hitMaxDepth && val.toJSON && typeof val.toJSON === 'function') {158 return print(val.toJSON(), indent, prevIndent, spacing, edgeSpacing, refs, maxDepth, currentDepth, plugins, min, callToJSON, printFunctionName, escapeRegex);159 }160 var toStringed = toString.call(val);161 if (toStringed === '[object Arguments]') {162 return hitMaxDepth ? '[Arguments]' : printArguments(val, indent, prevIndent, spacing, edgeSpacing, refs, maxDepth, currentDepth, plugins, min, callToJSON, printFunctionName, escapeRegex);163 } else if (isToStringedArrayType(toStringed)) {164 return hitMaxDepth ? '[Array]' : printArray(val, indent, prevIndent, spacing, edgeSpacing, refs, maxDepth, currentDepth, plugins, min, callToJSON, printFunctionName, escapeRegex);165 } else if (toStringed === '[object Map]') {166 return hitMaxDepth ? '[Map]' : printMap(val, indent, prevIndent, spacing, edgeSpacing, refs, maxDepth, currentDepth, plugins, min, callToJSON, printFunctionName, escapeRegex);167 } else if (toStringed === '[object Set]') {168 return hitMaxDepth ? '[Set]' : printSet(val, indent, prevIndent, spacing, edgeSpacing, refs, maxDepth, currentDepth, plugins, min, callToJSON, printFunctionName, escapeRegex);169 } else if (typeof val === 'object') {170 return hitMaxDepth ? '[Object]' : printObject(val, indent, prevIndent, spacing, edgeSpacing, refs, maxDepth, currentDepth, plugins, min, callToJSON, printFunctionName, escapeRegex);171 }172}173function printPlugin(val, indent, prevIndent, spacing, edgeSpacing, refs, maxDepth, currentDepth, plugins, min, callToJSON, printFunctionName, escapeRegex) {174 var match = false;175 var plugin = void 0;176 for (var p = 0; p < plugins.length; p++) {177 plugin = plugins[p];...

Full Screen

Full Screen

index.js

Source:index.js Github

copy

Full Screen

...7const symbolToString = Symbol.prototype.toString;8const SYMBOL_REGEXP = /^Symbol\((.*)\)(.*)$/;9const NEWLINE_REGEXP = /\n/ig;10const getSymbols = Object.getOwnPropertySymbols || (obj => []);11function isToStringedArrayType(toStringed) {12 return (13 toStringed === '[object Array]' ||14 toStringed === '[object ArrayBuffer]' ||15 toStringed === '[object DataView]' ||16 toStringed === '[object Float32Array]' ||17 toStringed === '[object Float64Array]' ||18 toStringed === '[object Int8Array]' ||19 toStringed === '[object Int16Array]' ||20 toStringed === '[object Int32Array]' ||21 toStringed === '[object Uint8Array]' ||22 toStringed === '[object Uint8ClampedArray]' ||23 toStringed === '[object Uint16Array]' ||24 toStringed === '[object Uint32Array]'25 );26}27function printNumber(val) {28 if (val != +val) return 'NaN';29 const isNegativeZero = val === 0 && (1 / val) < 0;30 return isNegativeZero ? '-0' : '' + val;31}32function printFunction(val, printFunctionName) {33 if (!printFunctionName) {34 return '[Function]';35 } else if (val.name === '') {36 return '[Function anonymous]'37 } else {38 return '[Function ' + val.name + ']';39 }40}41function printSymbol(val) {42 return symbolToString.call(val).replace(SYMBOL_REGEXP, 'Symbol($1)');43}44function printError(val) {45 return '[' + errorToString.call(val) + ']';46}47function printBasicValue(val, printFunctionName, escapeRegex) {48 if (val === true || val === false) return '' + val;49 if (val === undefined) return 'undefined';50 if (val === null) return 'null';51 const typeOf = typeof val;52 if (typeOf === 'number') return printNumber(val);53 if (typeOf === 'string') return '"' + printString(val) + '"';54 if (typeOf === 'function') return printFunction(val, printFunctionName);55 if (typeOf === 'symbol') return printSymbol(val);56 const toStringed = toString.call(val);57 if (toStringed === '[object WeakMap]') return 'WeakMap {}';58 if (toStringed === '[object WeakSet]') return 'WeakSet {}';59 if (toStringed === '[object Function]' || toStringed === '[object GeneratorFunction]') return printFunction(val, printFunctionName);60 if (toStringed === '[object Symbol]') return printSymbol(val);61 if (toStringed === '[object Date]') return toISOString.call(val);62 if (toStringed === '[object Error]') return printError(val);63 if (toStringed === '[object RegExp]') {64 if (escapeRegex) {65 return printString(regExpToString.call(val));66 }67 return regExpToString.call(val);68 };69 if (toStringed === '[object Arguments]' && val.length === 0) return 'Arguments []';70 if (isToStringedArrayType(toStringed) && val.length === 0) return val.constructor.name + ' []';71 if (val instanceof Error) return printError(val);72 return false;73}74function printList(list, indent, prevIndent, spacing, edgeSpacing, refs, maxDepth, currentDepth, plugins, min, callToJSON, printFunctionName, escapeRegex) {75 let body = '';76 if (list.length) {77 body += edgeSpacing;78 const innerIndent = prevIndent + indent;79 for (let i = 0; i < list.length; i++) {80 body += innerIndent + print(list[i], indent, innerIndent, spacing, edgeSpacing, refs, maxDepth, currentDepth, plugins, min, callToJSON, printFunctionName, escapeRegex);81 if (i < list.length - 1) {82 body += ',' + spacing;83 }84 }85 body += (min ? '' : ',') + edgeSpacing + prevIndent;86 }87 return '[' + body + ']';88}89function printArguments(val, indent, prevIndent, spacing, edgeSpacing, refs, maxDepth, currentDepth, plugins, min, callToJSON, printFunctionName, escapeRegex) {90 return (min ? '' : 'Arguments ') + printList(val, indent, prevIndent, spacing, edgeSpacing, refs, maxDepth, currentDepth, plugins, min, callToJSON, printFunctionName, escapeRegex);91}92function printArray(val, indent, prevIndent, spacing, edgeSpacing, refs, maxDepth, currentDepth, plugins, min, callToJSON, printFunctionName, escapeRegex) {93 return (min ? '' : val.constructor.name + ' ') + printList(val, indent, prevIndent, spacing, edgeSpacing, refs, maxDepth, currentDepth, plugins, min, callToJSON, printFunctionName, escapeRegex);94}95function printMap(val, indent, prevIndent, spacing, edgeSpacing, refs, maxDepth, currentDepth, plugins, min, callToJSON, printFunctionName, escapeRegex) {96 let result = 'Map {';97 const iterator = val.entries();98 let current = iterator.next();99 if (!current.done) {100 result += edgeSpacing;101 const innerIndent = prevIndent + indent;102 while (!current.done) {103 const key = print(current.value[0], indent, innerIndent, spacing, edgeSpacing, refs, maxDepth, currentDepth, plugins, min, callToJSON, printFunctionName, escapeRegex);104 const value = print(current.value[1], indent, innerIndent, spacing, edgeSpacing, refs, maxDepth, currentDepth, plugins, min, callToJSON, printFunctionName, escapeRegex);105 result += innerIndent + key + ' => ' + value;106 current = iterator.next();107 if (!current.done) {108 result += ',' + spacing;109 }110 }111 result += (min ? '' : ',') + edgeSpacing + prevIndent;112 }113 return result + '}';114}115function printObject(val, indent, prevIndent, spacing, edgeSpacing, refs, maxDepth, currentDepth, plugins, min, callToJSON, printFunctionName, escapeRegex) {116 const constructor = min ? '' : (val.constructor ? val.constructor.name + ' ' : 'Object ');117 let result = constructor + '{';118 let keys = Object.keys(val).sort();119 const symbols = getSymbols(val);120 if (symbols.length) {121 keys = keys122 .filter(key => !(typeof key === 'symbol' || toString.call(key) === '[object Symbol]'))123 .concat(symbols);124 }125 if (keys.length) {126 result += edgeSpacing;127 const innerIndent = prevIndent + indent;128 for (let i = 0; i < keys.length; i++) {129 const key = keys[i];130 const name = print(key, indent, innerIndent, spacing, edgeSpacing, refs, maxDepth, currentDepth, plugins, min, callToJSON, printFunctionName, escapeRegex);131 const value = print(val[key], indent, innerIndent, spacing, edgeSpacing, refs, maxDepth, currentDepth, plugins, min, callToJSON, printFunctionName, escapeRegex);132 result += innerIndent + name + ': ' + value;133 if (i < keys.length - 1) {134 result += ',' + spacing;135 }136 }137 result += (min ? '' : ',') + edgeSpacing + prevIndent;138 }139 return result + '}';140}141function printSet(val, indent, prevIndent, spacing, edgeSpacing, refs, maxDepth, currentDepth, plugins, min, callToJSON, printFunctionName, escapeRegex) {142 let result = 'Set {';143 const iterator = val.entries();144 let current = iterator.next();145 if (!current.done) {146 result += edgeSpacing;147 const innerIndent = prevIndent + indent;148 while (!current.done) {149 result += innerIndent + print(current.value[1], indent, innerIndent, spacing, edgeSpacing, refs, maxDepth, currentDepth, plugins, min, callToJSON, printFunctionName, escapeRegex);150 current = iterator.next();151 if (!current.done) {152 result += ',' + spacing;153 }154 }155 result += (min ? '' : ',') + edgeSpacing + prevIndent;156 }157 return result + '}';158}159function printComplexValue(val, indent, prevIndent, spacing, edgeSpacing, refs, maxDepth, currentDepth, plugins, min, callToJSON, printFunctionName, escapeRegex) {160 refs = refs.slice();161 if (refs.indexOf(val) > -1) {162 return '[Circular]';163 } else {164 refs.push(val);165 }166 currentDepth++;167 const hitMaxDepth = currentDepth > maxDepth;168 if (callToJSON && !hitMaxDepth && val.toJSON && typeof val.toJSON === 'function') {169 return print(val.toJSON(), indent, prevIndent, spacing, edgeSpacing, refs, maxDepth, currentDepth, plugins, min, callToJSON, printFunctionName, escapeRegex);170 }171 const toStringed = toString.call(val);172 if (toStringed === '[object Arguments]') {173 return hitMaxDepth ? '[Arguments]' : printArguments(val, indent, prevIndent, spacing, edgeSpacing, refs, maxDepth, currentDepth, plugins, min, callToJSON, printFunctionName, escapeRegex);174 } else if (isToStringedArrayType(toStringed)) {175 return hitMaxDepth ? '[Array]' : printArray(val, indent, prevIndent, spacing, edgeSpacing, refs, maxDepth, currentDepth, plugins, min, callToJSON, printFunctionName, escapeRegex);176 } else if (toStringed === '[object Map]') {177 return hitMaxDepth ? '[Map]' : printMap(val, indent, prevIndent, spacing, edgeSpacing, refs, maxDepth, currentDepth, plugins, min, callToJSON, printFunctionName, escapeRegex);178 } else if (toStringed === '[object Set]') {179 return hitMaxDepth ? '[Set]' : printSet(val, indent, prevIndent, spacing, edgeSpacing, refs, maxDepth, currentDepth, plugins, min, callToJSON, printFunctionName, escapeRegex);180 } else if (typeof val === 'object') {181 return hitMaxDepth ? '[Object]' : printObject(val, indent, prevIndent, spacing, edgeSpacing, refs, maxDepth, currentDepth, plugins, min, callToJSON, printFunctionName, escapeRegex);182 }183}184function printPlugin(val, indent, prevIndent, spacing, edgeSpacing, refs, maxDepth, currentDepth, plugins, min, callToJSON, printFunctionName, escapeRegex) {185 let match = false;186 let plugin;187 for (let p = 0; p < plugins.length; p++) {188 plugin = plugins[p];...

Full Screen

Full Screen

pretty-format.js

Source:pretty-format.js Github

copy

Full Screen

...13 var NEWLINE_REGEXP = /\n/ig;14 var getSymbols = Object.getOwnPropertySymbols || function (obj) {15 return [];16 };17 function isToStringedArrayType(toStringed) {18 return toStringed === '[object Array]' || toStringed === '[object ArrayBuffer]' || toStringed === '[object DataView]' || toStringed === '[object Float32Array]' || toStringed === '[object Float64Array]' || toStringed === '[object Int8Array]' || toStringed === '[object Int16Array]' || toStringed === '[object Int32Array]' || toStringed === '[object Uint8Array]' || toStringed === '[object Uint8ClampedArray]' || toStringed === '[object Uint16Array]' || toStringed === '[object Uint32Array]';19 }20 function printNumber(val) {21 if (val != +val) return 'NaN';22 var isNegativeZero = val === 0 && 1 / val < 0;23 return isNegativeZero ? '-0' : '' + val;24 }25 function printFunction(val) {26 if (val.name === '') {27 return '[Function anonymous]';28 } else {29 return '[Function ' + val.name + ']';30 }31 }32 function printSymbol(val) {33 return symbolToString.call(val).replace(SYMBOL_REGEXP, 'Symbol($1)');34 }35 function printError(val) {36 return '[' + errorToString.call(val) + ']';37 }38 function printBasicValue(val) {39 if (val === true || val === false) return '' + val;40 if (val === undefined) return 'undefined';41 if (val === null) return 'null';42 var typeOf = typeof val;43 if (typeOf === 'number') return printNumber(val);44 if (typeOf === 'string') return '"' + printString(val) + '"';45 if (typeOf === 'function') return printFunction(val);46 if (typeOf === 'symbol') return printSymbol(val);47 var toStringed = toString.call(val);48 if (toStringed === '[object WeakMap]') return 'WeakMap {}';49 if (toStringed === '[object WeakSet]') return 'WeakSet {}';50 if (toStringed === '[object Function]' || toStringed === '[object GeneratorFunction]') return printFunction(val);51 if (toStringed === '[object Symbol]') return printSymbol(val);52 if (toStringed === '[object Date]') return toISOString.call(val);53 if (toStringed === '[object Error]') return printError(val);54 if (toStringed === '[object RegExp]') return regExpToString.call(val);55 if (toStringed === '[object Arguments]' && val.length === 0) return 'Arguments []';56 if (isToStringedArrayType(toStringed) && val.length === 0) return val.constructor.name + ' []';57 if (val instanceof Error) return printError(val);58 return false;59 }60 function printList(list, indent, prevIndent, refs, maxDepth, currentDepth, plugins) {61 var body = '';62 if (list.length) {63 body += '\n';64 var innerIndent = prevIndent + indent;65 for (var i = 0; i < list.length; i++) {66 body += innerIndent + print(list[i], indent, innerIndent, refs, maxDepth, currentDepth, plugins);67 if (i < list.length - 1) {68 body += ',\n';69 }70 }71 body += '\n' + prevIndent;72 }73 return '[' + body + ']';74 }75 function printArguments(val, indent, prevIndent, refs, maxDepth, currentDepth, plugins) {76 return 'Arguments ' + printList(val, indent, prevIndent, refs, maxDepth, currentDepth, plugins);77 }78 function printArray(val, indent, prevIndent, refs, maxDepth, currentDepth, plugins) {79 return val.constructor.name + ' ' + printList(val, indent, prevIndent, refs, maxDepth, currentDepth, plugins);80 }81 function printMap(val, indent, prevIndent, refs, maxDepth, currentDepth, plugins) {82 var result = 'Map {';83 var iterator = val.entries();84 var current = iterator.next();85 if (!current.done) {86 result += '\n';87 var innerIndent = prevIndent + indent;88 while (!current.done) {89 var key = print(current.value[0], indent, innerIndent, refs, maxDepth, currentDepth, plugins);90 var value = print(current.value[1], indent, innerIndent, refs, maxDepth, currentDepth, plugins);91 result += innerIndent + key + ' => ' + value;92 current = iterator.next();93 if (!current.done) {94 result += ',\n';95 }96 }97 result += '\n' + prevIndent;98 }99 return result + '}';100 }101 function printObject(val, indent, prevIndent, refs, maxDepth, currentDepth, plugins) {102 var constructor = val.constructor ? val.constructor.name + ' ' : 'Object ';103 var result = constructor + '{';104 var keys = Object.keys(val).sort();105 var symbols = getSymbols(val);106 if (symbols.length) {107 keys = keys.filter(function (key) {108 return !(typeof key === 'symbol' || toString.call(key) === '[object Symbol]');109 }).concat(symbols);110 }111 if (keys.length) {112 result += '\n';113 var innerIndent = prevIndent + indent;114 for (var i = 0; i < keys.length; i++) {115 var key = keys[i];116 var name = print(key, indent, innerIndent, refs, maxDepth, currentDepth, plugins);117 var value = print(val[key], indent, innerIndent, refs, maxDepth, currentDepth, plugins);118 result += innerIndent + name + ': ' + value;119 if (i < keys.length - 1) {120 result += ',\n';121 }122 }123 result += '\n' + prevIndent;124 }125 return result + '}';126 }127 function printSet(val, indent, prevIndent, refs, maxDepth, currentDepth, plugins) {128 var result = 'Set {';129 var iterator = val.entries();130 var current = iterator.next();131 if (!current.done) {132 result += '\n';133 var innerIndent = prevIndent + indent;134 while (!current.done) {135 result += innerIndent + print(current.value[1], indent, innerIndent, refs, maxDepth, currentDepth, plugins);136 current = iterator.next();137 if (!current.done) {138 result += ',\n';139 }140 }141 result += '\n' + prevIndent;142 }143 return result + '}';144 }145 function printComplexValue(val, indent, prevIndent, refs, maxDepth, currentDepth, plugins) {146 refs = refs.slice();147 if (refs.indexOf(val) > -1) {148 return '[Circular]';149 } else {150 refs.push(val);151 }152 currentDepth++;153 var hitMaxDepth = currentDepth > maxDepth;154 if (!hitMaxDepth && val.toJSON && typeof val.toJSON === 'function') {155 return print(val.toJSON(), indent, prevIndent, refs, maxDepth, currentDepth, plugins);156 }157 var toStringed = toString.call(val);158 if (toStringed === '[object Arguments]') {159 return hitMaxDepth ? '[Arguments]' : printArguments(val, indent, prevIndent, refs, maxDepth, currentDepth, plugins);160 } else if (isToStringedArrayType(toStringed)) {161 return hitMaxDepth ? '[Array]' : printArray(val, indent, prevIndent, refs, maxDepth, currentDepth, plugins);162 } else if (toStringed === '[object Map]') {163 return hitMaxDepth ? '[Map]' : printMap(val, indent, prevIndent, refs, maxDepth, currentDepth, plugins);164 } else if (toStringed === '[object Set]') {165 return hitMaxDepth ? '[Set]' : printSet(val, indent, prevIndent, refs, maxDepth, currentDepth, plugins);166 } else if (typeof val === 'object') {167 return hitMaxDepth ? '[Object]' : printObject(val, indent, prevIndent, refs, maxDepth, currentDepth, plugins);168 }169 }170 function printPlugin(val, indent, prevIndent, refs, maxDepth, currentDepth, plugins) {171 var match = false;172 var plugin = void 0;173 for (var p = 0; p < plugins.length; p++) {174 plugin = plugins[p];...

Full Screen

Full Screen

Jest Testing Tutorial

LambdaTest’s Jest Testing Tutorial covers step-by-step guides around Jest with code examples to help you be proficient with the Jest framework. The Jest tutorial has chapters to help you learn right from the basics of Jest framework to code-based tutorials around testing react apps with Jest, perform snapshot testing, import ES modules and more.

Chapters

  1. What is Jest Framework
  2. Advantages of Jest - Jest has 3,898,000 GitHub repositories, as mentioned on its official website. Learn what makes Jest special and why Jest has gained popularity among the testing and developer community.
  3. Jest Installation - All the prerequisites and set up steps needed to help you start Jest automation testing.
  4. Using Jest with NodeJS Project - Learn how to leverage Jest framework to automate testing using a NodeJS Project.
  5. Writing First Test for Jest Framework - Get started with code-based tutorial to help you write and execute your first Jest framework testing script.
  6. Jest Vocabulary - Learn the industry renowned and official jargons of the Jest framework by digging deep into the Jest vocabulary.
  7. Unit Testing with Jest - Step-by-step tutorial to help you execute unit testing with Jest framework.
  8. Jest Basics - Learn about the most pivotal and basic features which makes Jest special.
  9. Jest Parameterized Tests - Avoid code duplication and fasten automation testing with Jest using parameterized tests. Parameterization allows you to trigger the same test scenario over different test configurations by incorporating parameters.
  10. Jest Matchers - Enforce assertions better with the help of matchers. Matchers help you compare the actual output with the expected one. Here is an example to see if the object is acquired from the correct class or not. -

|<p>it('check_object_of_Car', () => {</p><p> expect(newCar()).toBeInstanceOf(Car);</p><p> });</p>| | :- |

  1. Jest Hooks: Setup and Teardown - Learn how to set up conditions which needs to be followed by the test execution and incorporate a tear down function to free resources after the execution is complete.
  2. Jest Code Coverage - Unsure there is no code left unchecked in your application. Jest gives a specific flag called --coverage to help you generate code coverage.
  3. HTML Report Generation - Learn how to create a comprehensive HTML report based on your Jest test execution.
  4. Testing React app using Jest Framework - Learn how to test your react web-application with Jest framework in this detailed Jest tutorial.
  5. Test using LambdaTest cloud Selenium Grid - Run your Jest testing script over LambdaTest cloud-based platform and leverage parallel testing to help trim down your test execution time.
  6. Snapshot Testing for React Front Ends - Capture screenshots of your react based web-application and compare them automatically for visual anomalies with the help of Jest tutorial.
  7. Bonus: Import ES modules with Jest - ES modules are also known as ECMAScript modules. Learn how to best use them by importing in your Jest testing scripts.
  8. Jest vs Mocha vs Jasmine - Learn the key differences between the most popular JavaScript-based testing frameworks i.e. Jest, Mocha, and Jasmine.
  9. Jest FAQs(Frequently Asked Questions) - Explore the most commonly asked questions around Jest framework, with their answers.

Run Jest automation tests on LambdaTest cloud grid

Perform automation testing on 3000+ real desktop and mobile devices online.

Try LambdaTest Now !!

Get 100 minutes of automation test minutes FREE!!

Next-Gen App & Browser Testing Cloud

Was this article helpful?

Helpful

NotHelpful