UNPKG

808 BJavaScriptView Raw
1'use strict';
2
3const internals = {};
4
5
6exports.mergeOptions = function (parent, child, ignore) {
7
8 ignore = ignore || [];
9 const options = {};
10
11 Object.keys(parent || {}).forEach((key) => {
12
13 if (ignore.indexOf(key) === -1) {
14 options[key] = parent[key];
15 }
16 });
17
18 Object.keys(child || {}).forEach((key) => {
19
20 options[key] = child[key];
21 });
22
23 return options;
24};
25
26
27exports.applyOptions = function (parent, child) {
28
29 Object.keys(child).forEach((key) => {
30
31 parent[key] = child[key];
32 });
33};
34
35
36exports.position = function (err) {
37
38 const match = /\:(\d+)\:(\d+)/.exec(err.stack.split('\n')[1]);
39 if (!match) {
40 return {};
41 }
42
43 return {
44 line: parseInt(match[1], 10),
45 column: parseInt(match[2], 10)
46 };
47};