diff options
author | 2020-11-18 23:26:45 +0100 | |
---|---|---|
committer | 2020-11-18 23:26:45 +0100 | |
commit | 81ddf9b700bc48a1f8e472209f080f9c1d9a9b09 (patch) | |
tree | 8b959d50c5a614cbf9fcb346ed556140374d4b6d /node_modules/@webassemblyjs/helper-code-frame/esm | |
parent | 1870f3fdf43707a15fda0f609a021f516f45eb63 (diff) | |
download | website_creator-81ddf9b700bc48a1f8e472209f080f9c1d9a9b09.tar.gz website_creator-81ddf9b700bc48a1f8e472209f080f9c1d9a9b09.tar.bz2 website_creator-81ddf9b700bc48a1f8e472209f080f9c1d9a9b09.zip |
rm node_modules
Diffstat (limited to 'node_modules/@webassemblyjs/helper-code-frame/esm')
-rw-r--r-- | node_modules/@webassemblyjs/helper-code-frame/esm/index.js | 37 |
1 files changed, 0 insertions, 37 deletions
diff --git a/node_modules/@webassemblyjs/helper-code-frame/esm/index.js b/node_modules/@webassemblyjs/helper-code-frame/esm/index.js deleted file mode 100644 index 791c65e..0000000 --- a/node_modules/@webassemblyjs/helper-code-frame/esm/index.js +++ /dev/null @@ -1,37 +0,0 @@ -function _typeof(obj) { if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") { _typeof = function _typeof(obj) { return typeof obj; }; } else { _typeof = function _typeof(obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; } return _typeof(obj); } - -import { print } from "@webassemblyjs/wast-printer"; -var SHOW_LINES_AROUND_POINTER = 5; - -function repeat(char, nb) { - return Array(nb).fill(char).join(""); -} // TODO(sven): allow arbitrary ast nodes - - -export function codeFrameFromAst(ast, loc) { - return codeFrameFromSource(print(ast), loc); -} -export function codeFrameFromSource(source, loc) { - var start = loc.start, - end = loc.end; - var length = 1; - - if (_typeof(end) === "object") { - length = end.column - start.column + 1; - } - - return source.split("\n").reduce(function (acc, line, lineNbr) { - if (Math.abs(start.line - lineNbr) < SHOW_LINES_AROUND_POINTER) { - acc += line + "\n"; - } // Add a new line with the pointer padded left - - - if (lineNbr === start.line - 1) { - acc += repeat(" ", start.column - 1); - acc += repeat("^", length); - acc += "\n"; - } - - return acc; - }, ""); -}
\ No newline at end of file |