summaryrefslogtreecommitdiffstats
path: root/node_modules/@webassemblyjs/helper-buffer/esm
diff options
context:
space:
mode:
authorGravatar Piotr Russ <mail@pruss.it> 2020-11-16 00:10:28 +0100
committerGravatar Piotr Russ <mail@pruss.it> 2020-11-16 00:10:28 +0100
commite06ec920f7a5d784e674c4c4b4e6d1da3dc7391d (patch)
tree55713f725f77b44ebfec86e4eec3ce33e71458ca /node_modules/@webassemblyjs/helper-buffer/esm
downloadwebsite_creator-e06ec920f7a5d784e674c4c4b4e6d1da3dc7391d.tar.gz
website_creator-e06ec920f7a5d784e674c4c4b4e6d1da3dc7391d.tar.bz2
website_creator-e06ec920f7a5d784e674c4c4b4e6d1da3dc7391d.zip
api, login, auth
Diffstat (limited to 'node_modules/@webassemblyjs/helper-buffer/esm')
-rw-r--r--node_modules/@webassemblyjs/helper-buffer/esm/compare.js65
-rw-r--r--node_modules/@webassemblyjs/helper-buffer/esm/index.js67
2 files changed, 132 insertions, 0 deletions
diff --git a/node_modules/@webassemblyjs/helper-buffer/esm/compare.js b/node_modules/@webassemblyjs/helper-buffer/esm/compare.js
new file mode 100644
index 0000000..8cea6b3
--- /dev/null
+++ b/node_modules/@webassemblyjs/helper-buffer/esm/compare.js
@@ -0,0 +1,65 @@
+// this are dev dependencies
+var diff = require("jest-diff");
+
+var _require = require("jest-diff/build/constants"),
+ NO_DIFF_MESSAGE = _require.NO_DIFF_MESSAGE;
+
+var _require2 = require("@webassemblyjs/wasm-parser"),
+ decode = _require2.decode;
+
+var oldConsoleLog = console.log;
+export function compareArrayBuffers(l, r) {
+ /**
+ * Decode left
+ */
+ var bufferL = "";
+
+ console.log = function () {
+ for (var _len = arguments.length, texts = new Array(_len), _key = 0; _key < _len; _key++) {
+ texts[_key] = arguments[_key];
+ }
+
+ return bufferL += texts.join("") + "\n";
+ };
+
+ try {
+ decode(l, {
+ dump: true
+ });
+ } catch (e) {
+ console.error(bufferL);
+ console.error(e);
+ throw e;
+ }
+ /**
+ * Decode right
+ */
+
+
+ var bufferR = "";
+
+ console.log = function () {
+ for (var _len2 = arguments.length, texts = new Array(_len2), _key2 = 0; _key2 < _len2; _key2++) {
+ texts[_key2] = arguments[_key2];
+ }
+
+ return bufferR += texts.join("") + "\n";
+ };
+
+ try {
+ decode(r, {
+ dump: true
+ });
+ } catch (e) {
+ console.error(bufferR);
+ console.error(e);
+ throw e;
+ }
+
+ console.log = oldConsoleLog;
+ var out = diff(bufferL, bufferR);
+
+ if (out !== null && out !== NO_DIFF_MESSAGE) {
+ throw new Error("\n" + out);
+ }
+} \ No newline at end of file
diff --git a/node_modules/@webassemblyjs/helper-buffer/esm/index.js b/node_modules/@webassemblyjs/helper-buffer/esm/index.js
new file mode 100644
index 0000000..2c35b9e
--- /dev/null
+++ b/node_modules/@webassemblyjs/helper-buffer/esm/index.js
@@ -0,0 +1,67 @@
+function _toConsumableArray(arr) { if (Array.isArray(arr)) { for (var i = 0, arr2 = new Array(arr.length); i < arr.length; i++) { arr2[i] = arr[i]; } return arr2; } else { return Array.from(arr); } }
+
+function concatUint8Arrays() {
+ for (var _len = arguments.length, arrays = new Array(_len), _key = 0; _key < _len; _key++) {
+ arrays[_key] = arguments[_key];
+ }
+
+ var totalLength = arrays.reduce(function (a, b) {
+ return a + b.length;
+ }, 0);
+ var result = new Uint8Array(totalLength);
+ var offset = 0;
+
+ for (var _i = 0; _i < arrays.length; _i++) {
+ var arr = arrays[_i];
+
+ if (arr instanceof Uint8Array === false) {
+ throw new Error("arr must be of type Uint8Array");
+ }
+
+ result.set(arr, offset);
+ offset += arr.length;
+ }
+
+ return result;
+}
+
+export function overrideBytesInBuffer(buffer, startLoc, endLoc, newBytes) {
+ var beforeBytes = buffer.slice(0, startLoc);
+ var afterBytes = buffer.slice(endLoc, buffer.length); // replacement is empty, we can omit it
+
+ if (newBytes.length === 0) {
+ return concatUint8Arrays(beforeBytes, afterBytes);
+ }
+
+ var replacement = Uint8Array.from(newBytes);
+ return concatUint8Arrays(beforeBytes, replacement, afterBytes);
+}
+export function makeBuffer() {
+ for (var _len2 = arguments.length, splitedBytes = new Array(_len2), _key2 = 0; _key2 < _len2; _key2++) {
+ splitedBytes[_key2] = arguments[_key2];
+ }
+
+ var bytes = [].concat.apply([], splitedBytes);
+ return new Uint8Array(bytes).buffer;
+}
+export function fromHexdump(str) {
+ var lines = str.split("\n"); // remove any leading left whitespace
+
+ lines = lines.map(function (line) {
+ return line.trim();
+ });
+ var bytes = lines.reduce(function (acc, line) {
+ var cols = line.split(" "); // remove the offset, left column
+
+ cols.shift();
+ cols = cols.filter(function (x) {
+ return x !== "";
+ });
+ var bytes = cols.map(function (x) {
+ return parseInt(x, 16);
+ });
+ acc.push.apply(acc, _toConsumableArray(bytes));
+ return acc;
+ }, []);
+ return Buffer.from(bytes);
+} \ No newline at end of file