aboutsummaryrefslogtreecommitdiff
path: root/node_modules/js-yaml/lib
diff options
context:
space:
mode:
authorFlorian Dold <florian.dold@gmail.com>2018-09-20 02:56:13 +0200
committerFlorian Dold <florian.dold@gmail.com>2018-09-20 02:56:13 +0200
commitbbff7403fbf46f9ad92240ac213df8d30ef31b64 (patch)
treec58400ec5124da1c7d56b01aea83309f80a56c3b /node_modules/js-yaml/lib
parent003fb34971cf63466184351b4db5f7c67df4f444 (diff)
downloadwallet-core-bbff7403fbf46f9ad92240ac213df8d30ef31b64.tar.xz
update packages
Diffstat (limited to 'node_modules/js-yaml/lib')
-rw-r--r--node_modules/js-yaml/lib/js-yaml/dumper.js10
-rw-r--r--node_modules/js-yaml/lib/js-yaml/type/int.js9
-rw-r--r--node_modules/js-yaml/lib/js-yaml/type/js/function.js14
3 files changed, 24 insertions, 9 deletions
diff --git a/node_modules/js-yaml/lib/js-yaml/dumper.js b/node_modules/js-yaml/lib/js-yaml/dumper.js
index 025b18552..67cf6ca0c 100644
--- a/node_modules/js-yaml/lib/js-yaml/dumper.js
+++ b/node_modules/js-yaml/lib/js-yaml/dumper.js
@@ -234,6 +234,12 @@ function isPlainSafeFirst(c) {
&& c !== CHAR_GRAVE_ACCENT;
}
+// Determines whether block indentation indicator is required.
+function needIndentIndicator(string) {
+ var leadingSpaceRe = /^\n* /;
+ return leadingSpaceRe.test(string);
+}
+
var STYLE_PLAIN = 1,
STYLE_SINGLE = 2,
STYLE_LITERAL = 3,
@@ -301,7 +307,7 @@ function chooseScalarStyle(string, singleLineOnly, indentPerLevel, lineWidth, te
? STYLE_PLAIN : STYLE_SINGLE;
}
// Edge case: block indentation indicator can only have one digit.
- if (string[0] === ' ' && indentPerLevel > 9) {
+ if (indentPerLevel > 9 && needIndentIndicator(string)) {
return STYLE_DOUBLE;
}
// At this point we know block styles are valid.
@@ -365,7 +371,7 @@ function writeScalar(state, string, level, iskey) {
// Pre-conditions: string is valid for a block scalar, 1 <= indentPerLevel <= 9.
function blockHeader(string, indentPerLevel) {
- var indentIndicator = (string[0] === ' ') ? String(indentPerLevel) : '';
+ var indentIndicator = needIndentIndicator(string) ? String(indentPerLevel) : '';
// note the special case: the string '\n' counts as a "trailing" empty line.
var clip = string[string.length - 1] === '\n';
diff --git a/node_modules/js-yaml/lib/js-yaml/type/int.js b/node_modules/js-yaml/lib/js-yaml/type/int.js
index 4ae522a5a..ba61c5f95 100644
--- a/node_modules/js-yaml/lib/js-yaml/type/int.js
+++ b/node_modules/js-yaml/lib/js-yaml/type/int.js
@@ -157,10 +157,11 @@ module.exports = new Type('tag:yaml.org,2002:int', {
construct: constructYamlInteger,
predicate: isInteger,
represent: {
- binary: function (object) { return '0b' + object.toString(2); },
- octal: function (object) { return '0' + object.toString(8); },
- decimal: function (object) { return object.toString(10); },
- hexadecimal: function (object) { return '0x' + object.toString(16).toUpperCase(); }
+ binary: function (obj) { return obj >= 0 ? '0b' + obj.toString(2) : '-0b' + obj.toString(2).slice(1); },
+ octal: function (obj) { return obj >= 0 ? '0' + obj.toString(8) : '-0' + obj.toString(8).slice(1); },
+ decimal: function (obj) { return obj.toString(10); },
+ /* eslint-disable max-len */
+ hexadecimal: function (obj) { return obj >= 0 ? '0x' + obj.toString(16).toUpperCase() : '-0x' + obj.toString(16).toUpperCase().slice(1); }
},
defaultStyle: 'decimal',
styleAliases: {
diff --git a/node_modules/js-yaml/lib/js-yaml/type/js/function.js b/node_modules/js-yaml/lib/js-yaml/type/js/function.js
index c6a42d002..3604e2333 100644
--- a/node_modules/js-yaml/lib/js-yaml/type/js/function.js
+++ b/node_modules/js-yaml/lib/js-yaml/type/js/function.js
@@ -30,7 +30,8 @@ function resolveJavascriptFunction(data) {
if (ast.type !== 'Program' ||
ast.body.length !== 1 ||
ast.body[0].type !== 'ExpressionStatement' ||
- ast.body[0].expression.type !== 'FunctionExpression') {
+ (ast.body[0].expression.type !== 'ArrowFunctionExpression' &&
+ ast.body[0].expression.type !== 'FunctionExpression')) {
return false;
}
@@ -51,7 +52,8 @@ function constructJavascriptFunction(data) {
if (ast.type !== 'Program' ||
ast.body.length !== 1 ||
ast.body[0].type !== 'ExpressionStatement' ||
- ast.body[0].expression.type !== 'FunctionExpression') {
+ (ast.body[0].expression.type !== 'ArrowFunctionExpression' &&
+ ast.body[0].expression.type !== 'FunctionExpression')) {
throw new Error('Failed to resolve function');
}
@@ -63,8 +65,14 @@ function constructJavascriptFunction(data) {
// Esprima's ranges include the first '{' and the last '}' characters on
// function expressions. So cut them out.
+ if (ast.body[0].expression.body.type === 'BlockStatement') {
+ /*eslint-disable no-new-func*/
+ return new Function(params, source.slice(body[0] + 1, body[1] - 1));
+ }
+ // ES6 arrow functions can omit the BlockStatement. In that case, just return
+ // the body.
/*eslint-disable no-new-func*/
- return new Function(params, source.slice(body[0] + 1, body[1] - 1));
+ return new Function(params, 'return ' + source.slice(body[0], body[1]));
}
function representJavascriptFunction(object /*, style*/) {