| Index: node_modules/vulcanize/node_modules/update-notifier/node_modules/configstore/node_modules/js-yaml/lib/js-yaml/type/js/function.js
|
| diff --git a/node_modules/vulcanize/node_modules/update-notifier/node_modules/configstore/node_modules/js-yaml/lib/js-yaml/type/js/function.js b/node_modules/vulcanize/node_modules/update-notifier/node_modules/configstore/node_modules/js-yaml/lib/js-yaml/type/js/function.js
|
| index 65dcf7f8a9f9603ab26a55bb4bd22d7f8c6a802c..05efaceab6a0861ebbbea234cdf54af8ffb42eb1 100644
|
| --- a/node_modules/vulcanize/node_modules/update-notifier/node_modules/configstore/node_modules/js-yaml/lib/js-yaml/type/js/function.js
|
| +++ b/node_modules/vulcanize/node_modules/update-notifier/node_modules/configstore/node_modules/js-yaml/lib/js-yaml/type/js/function.js
|
| @@ -1,6 +1,5 @@
|
| 'use strict';
|
|
|
| -
|
| var esprima;
|
|
|
| // Browserified version does not have esprima
|
| @@ -14,18 +13,18 @@ try {
|
| esprima = require('esprima');
|
| } catch (_) {
|
| /*global window */
|
| - if (window) { esprima = window.esprima; }
|
| + if (typeof window !== 'undefined') { esprima = window.esprima; }
|
| }
|
|
|
| -
|
| var Type = require('../../type');
|
|
|
| -
|
| -function resolveJavascriptFunction(state) {
|
| - /*jslint evil:true*/
|
| +function resolveJavascriptFunction(data) {
|
| + if (null === data) {
|
| + return false;
|
| + }
|
|
|
| try {
|
| - var source = '(' + state.result + ')',
|
| + var source = '(' + data + ')',
|
| ast = esprima.parse(source, { range: true }),
|
| params = [],
|
| body;
|
| @@ -37,35 +36,50 @@ function resolveJavascriptFunction(state) {
|
| return false;
|
| }
|
|
|
| - ast.body[0].expression.params.forEach(function (param) {
|
| - params.push(param.name);
|
| - });
|
| -
|
| - body = ast.body[0].expression.body.range;
|
| -
|
| - // Esprima's ranges include the first '{' and the last '}' characters on
|
| - // function expressions. So cut them out.
|
| - state.result = new Function(params, source.slice(body[0]+1, body[1]-1));
|
| return true;
|
| } catch (err) {
|
| return false;
|
| }
|
| }
|
|
|
| +function constructJavascriptFunction(data) {
|
| + /*jslint evil:true*/
|
| +
|
| + var source = '(' + data + ')',
|
| + ast = esprima.parse(source, { range: true }),
|
| + params = [],
|
| + body;
|
| +
|
| + if ('Program' !== ast.type ||
|
| + 1 !== ast.body.length ||
|
| + 'ExpressionStatement' !== ast.body[0].type ||
|
| + 'FunctionExpression' !== ast.body[0].expression.type) {
|
| + throw new Error('Failed to resolve function');
|
| + }
|
| +
|
| + ast.body[0].expression.params.forEach(function (param) {
|
| + params.push(param.name);
|
| + });
|
| +
|
| + body = ast.body[0].expression.body.range;
|
| +
|
| + // Esprima's ranges include the first '{' and the last '}' characters on
|
| + // function expressions. So cut them out.
|
| + return new Function(params, source.slice(body[0]+1, body[1]-1));
|
| +}
|
|
|
| function representJavascriptFunction(object /*, style*/) {
|
| return object.toString();
|
| }
|
|
|
| -
|
| function isFunction(object) {
|
| return '[object Function]' === Object.prototype.toString.call(object);
|
| }
|
|
|
| -
|
| module.exports = new Type('tag:yaml.org,2002:js/function', {
|
| - loadKind: 'scalar',
|
| - loadResolver: resolveJavascriptFunction,
|
| - dumpPredicate: isFunction,
|
| - dumpRepresenter: representJavascriptFunction
|
| + kind: 'scalar',
|
| + resolve: resolveJavascriptFunction,
|
| + construct: constructJavascriptFunction,
|
| + predicate: isFunction,
|
| + represent: representJavascriptFunction
|
| });
|
|
|