aboutsummaryrefslogtreecommitdiff
path: root/node_modules/pretty-format/build/collections.js
diff options
context:
space:
mode:
authorJoel Kronqvist <joel.h.kronqvist@gmail.com>2022-03-05 19:02:27 +0200
committerJoel Kronqvist <joel.h.kronqvist@gmail.com>2022-03-05 19:02:27 +0200
commit5d309ff52cd399a6b71968a6b9a70c8ac0b98981 (patch)
tree360f7eb50f956e2367ef38fa1fc6ac7ac5258042 /node_modules/pretty-format/build/collections.js
parentb500a50f1b97d93c98b36ed9a980f8188d648147 (diff)
downloadLYLLRuoka-5d309ff52cd399a6b71968a6b9a70c8ac0b98981.tar.gz
LYLLRuoka-5d309ff52cd399a6b71968a6b9a70c8ac0b98981.zip
Added node_modules for the updating to work properly.
Diffstat (limited to 'node_modules/pretty-format/build/collections.js')
-rw-r--r--node_modules/pretty-format/build/collections.js187
1 files changed, 187 insertions, 0 deletions
diff --git a/node_modules/pretty-format/build/collections.js b/node_modules/pretty-format/build/collections.js
new file mode 100644
index 0000000..004e349
--- /dev/null
+++ b/node_modules/pretty-format/build/collections.js
@@ -0,0 +1,187 @@
+'use strict';
+
+Object.defineProperty(exports, '__esModule', {
+ value: true
+});
+exports.printIteratorEntries = printIteratorEntries;
+exports.printIteratorValues = printIteratorValues;
+exports.printListItems = printListItems;
+exports.printObjectProperties = printObjectProperties;
+
+/**
+ * Copyright (c) Facebook, Inc. and its affiliates. All Rights Reserved.
+ *
+ * This source code is licensed under the MIT license found in the
+ * LICENSE file in the root directory of this source tree.
+ *
+ */
+const getKeysOfEnumerableProperties = (object, compareKeys) => {
+ const keys = Object.keys(object).sort(compareKeys);
+
+ if (Object.getOwnPropertySymbols) {
+ Object.getOwnPropertySymbols(object).forEach(symbol => {
+ if (Object.getOwnPropertyDescriptor(object, symbol).enumerable) {
+ keys.push(symbol);
+ }
+ });
+ }
+
+ return keys;
+};
+/**
+ * Return entries (for example, of a map)
+ * with spacing, indentation, and comma
+ * without surrounding punctuation (for example, braces)
+ */
+
+function printIteratorEntries(
+ iterator,
+ config,
+ indentation,
+ depth,
+ refs,
+ printer, // Too bad, so sad that separator for ECMAScript Map has been ' => '
+ // What a distracting diff if you change a data structure to/from
+ // ECMAScript Object or Immutable.Map/OrderedMap which use the default.
+ separator = ': '
+) {
+ let result = '';
+ let current = iterator.next();
+
+ if (!current.done) {
+ result += config.spacingOuter;
+ const indentationNext = indentation + config.indent;
+
+ while (!current.done) {
+ const name = printer(
+ current.value[0],
+ config,
+ indentationNext,
+ depth,
+ refs
+ );
+ const value = printer(
+ current.value[1],
+ config,
+ indentationNext,
+ depth,
+ refs
+ );
+ result += indentationNext + name + separator + value;
+ current = iterator.next();
+
+ if (!current.done) {
+ result += ',' + config.spacingInner;
+ } else if (!config.min) {
+ result += ',';
+ }
+ }
+
+ result += config.spacingOuter + indentation;
+ }
+
+ return result;
+}
+/**
+ * Return values (for example, of a set)
+ * with spacing, indentation, and comma
+ * without surrounding punctuation (braces or brackets)
+ */
+
+function printIteratorValues(
+ iterator,
+ config,
+ indentation,
+ depth,
+ refs,
+ printer
+) {
+ let result = '';
+ let current = iterator.next();
+
+ if (!current.done) {
+ result += config.spacingOuter;
+ const indentationNext = indentation + config.indent;
+
+ while (!current.done) {
+ result +=
+ indentationNext +
+ printer(current.value, config, indentationNext, depth, refs);
+ current = iterator.next();
+
+ if (!current.done) {
+ result += ',' + config.spacingInner;
+ } else if (!config.min) {
+ result += ',';
+ }
+ }
+
+ result += config.spacingOuter + indentation;
+ }
+
+ return result;
+}
+/**
+ * Return items (for example, of an array)
+ * with spacing, indentation, and comma
+ * without surrounding punctuation (for example, brackets)
+ **/
+
+function printListItems(list, config, indentation, depth, refs, printer) {
+ let result = '';
+
+ if (list.length) {
+ result += config.spacingOuter;
+ const indentationNext = indentation + config.indent;
+
+ for (let i = 0; i < list.length; i++) {
+ result += indentationNext;
+
+ if (i in list) {
+ result += printer(list[i], config, indentationNext, depth, refs);
+ }
+
+ if (i < list.length - 1) {
+ result += ',' + config.spacingInner;
+ } else if (!config.min) {
+ result += ',';
+ }
+ }
+
+ result += config.spacingOuter + indentation;
+ }
+
+ return result;
+}
+/**
+ * Return properties of an object
+ * with spacing, indentation, and comma
+ * without surrounding punctuation (for example, braces)
+ */
+
+function printObjectProperties(val, config, indentation, depth, refs, printer) {
+ let result = '';
+ const keys = getKeysOfEnumerableProperties(val, config.compareKeys);
+
+ if (keys.length) {
+ result += config.spacingOuter;
+ const indentationNext = indentation + config.indent;
+
+ for (let i = 0; i < keys.length; i++) {
+ const key = keys[i];
+ const name = printer(key, config, indentationNext, depth, refs);
+ const value = printer(val[key], config, indentationNext, depth, refs);
+ result += indentationNext + name + ': ' + value;
+
+ if (i < keys.length - 1) {
+ result += ',' + config.spacingInner;
+ } else if (!config.min) {
+ result += ',';
+ }
+ }
+
+ result += config.spacingOuter + indentation;
+ }
+
+ return result;
+}