From f56e21f15b383f17fa1464a229542da37e772faf Mon Sep 17 00:00:00 2001 From: Charlike Mike Reagent Date: Thu, 24 Oct 2019 05:59:54 +0300 Subject: [PATCH 1/9] feat(parse-function): v6, resolves #65 BREAKING CHANGE: exports named `parseFunction`, For more see https://github.com/tunnckoCore/opensource/issues/65#issuecomment-545721424 Signed-off-by: Charlike Mike Reagent --- @types/.gitkeep | 0 packages/parse-function/example.js | 41 ++ packages/parse-function/index.d.ts | 34 ++ packages/parse-function/package.json | 5 +- packages/parse-function/src/index.js | 244 ++--------- packages/parse-function/src/plugins/body.js | 20 +- .../parse-function/src/plugins/initial.js | 25 +- packages/parse-function/src/plugins/params.js | 10 +- packages/parse-function/src/plugins/props.js | 35 +- packages/parse-function/src/utils.js | 49 +-- .../test/__snapshots__/index.js.snap | 396 +++++++++--------- packages/parse-function/test/index.js | 125 ++---- 12 files changed, 406 insertions(+), 578 deletions(-) create mode 100644 @types/.gitkeep create mode 100644 packages/parse-function/example.js create mode 100644 packages/parse-function/index.d.ts diff --git a/@types/.gitkeep b/@types/.gitkeep new file mode 100644 index 00000000..e69de29b diff --git a/packages/parse-function/example.js b/packages/parse-function/example.js new file mode 100644 index 00000000..10ea14eb --- /dev/null +++ b/packages/parse-function/example.js @@ -0,0 +1,41 @@ +import { parse as acornParse } from 'acorn'; +import { parseFunction } from '.'; + +// `node` is an AST Node +function bobbyPlugin(node, result) { + const bobby = 'bobby'; + + return { ...result, bobby }; +} + +function barryPlugin(node, result) { + return { ...result, barry: 'barry barry' }; +} + +const result = parseFunction(bobbyPlugin.toString(), { + parse: acornParse, + plugins: [bobbyPlugin, barryPlugin], // supports array of plugins + parserOptions: {}, +}); + +console.log(result); + +/* { + name: 'bobbyPlugin', + body: "\n const bobby = 'bobby';\n\n return { ...result, bobby };\n", + args: [ 'node', 'result' ], + params: 'node, result', + defaults: { node: undefined, result: undefined }, + value: '(function bobbyPlugin(node, result) {\n const ' + + "bobby = 'bobby';\n\n return { ...result, bobby };\n" + + '})', + isValid: true, + isArrow: false, + isAsync: false, + isNamed: true, + isAnonymous: false, + isGenerator: false, + isExpression: false, + bobby: 'bobby', + barry: 'barry barry' +} */ diff --git a/packages/parse-function/index.d.ts b/packages/parse-function/index.d.ts new file mode 100644 index 00000000..fd9e960c --- /dev/null +++ b/packages/parse-function/index.d.ts @@ -0,0 +1,34 @@ +import { ParserOptions } from '@babel/parser'; + +// eslint-disable-next-line @typescript-eslint/no-explicit-any +type FnType = (...args: any) => any; + +export type Input = FnType | string; +// eslint-disable-next-line @typescript-eslint/no-explicit-any +export type Plugin = (node: any, result: Result) => Result | undefined; +export type Plugins = Plugin | Array; + +export interface Options { + parse?(input: string, options?: ParserOptions): import('@babel/types').File; + parserOptions?: ParserOptions; + plugins?: Plugins; +} + +export interface Result { + name: string | null; + body: string; + args: Array; + params: string; + defaults: { [key: string]: string | undefined }; + value: string; + isValid: boolean; + isArrow: boolean; + isAsync: boolean; + isNamed: boolean; + isAnonymous: boolean; + isGenerator: boolean; + isExpression: boolean; +} + + +export function parseFunction(code: Input, options?: Options): Result diff --git a/packages/parse-function/package.json b/packages/parse-function/package.json index 1b7cde2a..85890feb 100644 --- a/packages/parse-function/package.json +++ b/packages/parse-function/package.json @@ -15,9 +15,10 @@ }, "main": "dist/cjs/index.js", "module": "dist/esm/index.js", - "types": "dist/types/index.d.ts", + "typings": "index.d.ts", "files": [ - "dist" + "dist", + "index.d.ts" ], "keywords": [ "args", diff --git a/packages/parse-function/src/index.js b/packages/parse-function/src/index.js index ae3637c3..fbc46a3b 100644 --- a/packages/parse-function/src/index.js +++ b/packages/parse-function/src/index.js @@ -1,228 +1,38 @@ -/** - * Utilities - */ +/* eslint-disable node/file-extension-in-import, import/extensions */ -import utils from './utils'; +import arrayify from 'arrify'; +import { parse as babelParse } from '@babel/parser'; -/** - * Core plugins - */ +import { setDefaults, getNode } from './utils.js'; +import basePlugin from './plugins/initial.js'; -import initial from './plugins/initial'; +// eslint-disable-next-line import/prefer-default-export +export function parseFunction(code, options) { + const opts = { parse: babelParse, ...options }; + const result = setDefaults(code); -/** - * > Initializes with optional `opts` object which is passed directly - * to the desired parser and returns an object - * with `.use` and `.parse` methods. The default parse which - * is used is [babylon][]'s `.parseExpression` method from `v7`. - * - * ```js - * const parseFunction = require('parse-function') - * - * const app = parseFunction({ - * ecmaVersion: 2017 - * }) - * - * const fixtureFn = (a, b, c) => { - * a = b + c - * return a + 2 - * } - * - * const result = app.parse(fixtureFn) - * console.log(result) - * - * // see more - * console.log(result.name) // => null - * console.log(result.isNamed) // => false - * console.log(result.isArrow) // => true - * console.log(result.isAnonymous) // => true - * - * // array of names of the arguments - * console.log(result.args) // => ['a', 'b', 'c'] - * - * // comma-separated names of the arguments - * console.log(result.params) // => 'a, b, c' - * ``` - * - * @param {Object} `opts` optional, merged with options passed to `.parse` method - * @return {Object} `app` object with `.use` and `.parse` methods - * @name parseFunction - * @api public - */ -export default function parseFunction(opts = {}) { - const plugins = []; - const app = { - /** - * > Parse a given `code` and returns a `result` object - * with useful properties - such as `name`, `body` and `args`. - * By default it uses Babylon parser, but you can switch it by - * passing `options.parse` - for example `options.parse: acorn.parse`. - * In the below example will show how to use `acorn` parser, instead - * of the default one. - * - * ```js - * const acorn = require('acorn') - * const parseFn = require('parse-function') - * const app = parseFn() - * - * const fn = function foo (bar, baz) { return bar * baz } - * const result = app.parse(fn, { - * parse: acorn.parse, - * ecmaVersion: 2017 - * }) - * - * console.log(result.name) // => 'foo' - * console.log(result.args) // => ['bar', 'baz'] - * console.log(result.body) // => ' return bar * baz ' - * console.log(result.isNamed) // => true - * console.log(result.isArrow) // => false - * console.log(result.isAnonymous) // => false - * console.log(result.isGenerator) // => false - * ``` - * - * @param {Function|String} `code` any kind of function or string to be parsed - * @param {Object} `options` directly passed to the parser - babylon, acorn, espree - * @param {Function} `options.parse` by default `babylon.parseExpression`, - * all `options` are passed as second argument - * to that provided function - * @return {Object} `result` see [result section](#result) for more info - * @name .parse - * @api public - */ - parse(code, options) { - const result = utils.setDefaults(code); + if (!result.isValid) { + return result; + } - if (!result.isValid) { - return result; - } + const isFunction = result.value.startsWith('function'); + const isAsyncFn = result.value.startsWith('async function'); + const isAsync = result.value.startsWith('async'); + const isArrow = result.value.includes('=>'); + const isAsyncArrow = isAsync && isArrow; - const mergedOptions = { ...opts, ...options }; + const isMethod = /^\*?.+\([\s\S\w\W]*\)\s*\{/i.test(result.value); - const isFunction = result.value.startsWith('function'); - const isAsyncFn = result.value.startsWith('async function'); - const isAsync = result.value.startsWith('async'); - const isArrow = result.value.includes('=>'); - const isAsyncArrow = isAsync && isArrow; + if (!(isFunction || isAsyncFn || isAsyncArrow) && isMethod) { + result.value = `{ ${result.value} }`; + } - const isMethod = /^\*?.+\([\s\S\w\W]*\)\s*\{/i.test(result.value); + const node = getNode(result, opts); + const plugins = arrayify(opts.plugins); - if (!(isFunction || isAsyncFn || isAsyncArrow) && isMethod) { - result.value = `{ ${result.value} }`; - } + return [basePlugin, ...plugins].filter(Boolean).reduce((res, fn) => { + const pluginResult = fn(node, { ...res }) || res; - const node = utils.getNode(result, mergedOptions); - return plugins.reduce((res, fn) => fn(node, res) || res, result); - }, - - /** - * > Add a plugin `fn` function for extending the API or working on the - * AST nodes. The `fn` is immediately invoked and passed - * with `app` argument which is instance of `parseFunction()` call. - * That `fn` may return another function that - * accepts `(node, result)` signature, where `node` is an AST node - * and `result` is an object which will be returned [result](#result) - * from the `.parse` method. This retuned function is called on each - * node only when `.parse` method is called. - * - * _See [Plugins Architecture](#plugins-architecture) section._ - * - * ```js - * // plugin extending the `app` - * app.use((app) => { - * app.define(app, 'hello', (place) => `Hello ${place}!`) - * }) - * - * const hi = app.hello('World') - * console.log(hi) // => 'Hello World!' - * - * // or plugin that works on AST nodes - * app.use((app) => (node, result) => { - * if (node.type === 'ArrowFunctionExpression') { - * result.thatIsArrow = true - * } - * return result - * }) - * - * const result = app.parse((a, b) => (a + b + 123)) - * console.log(result.name) // => null - * console.log(result.isArrow) // => true - * console.log(result.thatIsArrow) // => true - * - * const result = app.parse(function foo () { return 123 }) - * console.log(result.name) // => 'foo' - * console.log(result.isArrow) // => false - * console.log(result.thatIsArrow) // => undefined - * ``` - * - * @param {Function} `fn` plugin to be called - * @return {Object} `app` instance for chaining - * @name .use - * @api public - */ - use(fn) { - const ret = fn(app); - if (typeof ret === 'function') { - plugins.push(ret); - } - return app; - }, - - /** - * > Define a non-enumerable property on an object. Just - * a convenience mirror of the [define-property][] library, - * so check out its docs. Useful to be used in plugins. - * - * ```js - * const parseFunction = require('parse-function') - * const app = parseFunction() - * - * // use it like `define-property` lib - * const obj = {} - * app.define(obj, 'hi', 'world') - * console.log(obj) // => { hi: 'world' } - * - * // or define a custom plugin that adds `.foo` property - * // to the end result, returned from `app.parse` - * app.use((app) => { - * return (node, result) => { - * // this function is called - * // only when `.parse` is called - * - * app.define(result, 'foo', 123) - * - * return result - * } - * }) - * - * // fixture function to be parsed - * const asyncFn = async (qux) => { - * const bar = await Promise.resolve(qux) - * return bar - * } - * - * const result = app.parse(asyncFn) - * - * console.log(result.name) // => null - * console.log(result.foo) // => 123 - * console.log(result.args) // => ['qux'] - * - * console.log(result.isAsync) // => true - * console.log(result.isArrow) // => true - * console.log(result.isNamed) // => false - * console.log(result.isAnonymous) // => true - * ``` - * - * @param {Object} `obj` the object on which to define the property - * @param {String} `prop` the name of the property to be defined or modified - * @param {Any} `val` the descriptor for the property being defined or modified - * @return {Object} `obj` the passed object, but modified - * @name .define - * @api public - */ - define: utils.define, - }; - - app.use(initial); - - return app; + return pluginResult; + }, result); } diff --git a/packages/parse-function/src/plugins/body.js b/packages/parse-function/src/plugins/body.js index 547b2378..02849299 100644 --- a/packages/parse-function/src/plugins/body.js +++ b/packages/parse-function/src/plugins/body.js @@ -1,24 +1,22 @@ -/* eslint-disable no-param-reassign, unicorn/consistent-function-scoping */ - /** * > Micro plugin to get the raw body, without the * surrounding curly braces. It also preserves * the whitespaces and newlines - they are original. * - * @param {Object} node - * @param {Object} result - * @return {Object} result + * @param node + * @param result + * @return result * @private */ -export default () => (node, result) => { - result.body = result.value.slice(node.body.start, node.body.end); +export default (node, result) => { + let body = result.value.slice(node.body.start, node.body.end); - const openCurly = result.body.charCodeAt(0) === 123; - const closeCurly = result.body.charCodeAt(result.body.length - 1) === 125; + const openCurly = body.charCodeAt(0) === 123; + const closeCurly = body.charCodeAt(body.length - 1) === 125; if (openCurly && closeCurly) { - result.body = result.body.slice(1, -1); + body = body.slice(1, -1); } - return result; + return { ...result, body }; }; diff --git a/packages/parse-function/src/plugins/initial.js b/packages/parse-function/src/plugins/initial.js index 4537fd17..b7637c0b 100644 --- a/packages/parse-function/src/plugins/initial.js +++ b/packages/parse-function/src/plugins/initial.js @@ -1,26 +1,26 @@ -/* eslint-disable no-param-reassign */ +/* eslint-disable no-param-reassign, node/file-extension-in-import, import/extensions */ -import body from './body'; -import props from './props'; -import params from './params'; +import bodyPlugin from './body.js'; +import propsPlugin from './props.js'; +import paramsPlugin from './params.js'; /** * > Default plugin that handles regular functions, * arrow functions, generator functions * and ES6 object method notation. * - * @param {Object} node - * @param {Object} result - * @return {Object} resul + * @param node + * @param result + * @return resul * @private */ -export default (app) => (node, result) => { +export default (node, result) => { const isFn = node.type.endsWith('FunctionExpression'); const isMethod = node.type === 'ObjectExpression'; /* istanbul ignore next */ if (!isFn && !isMethod) { - return; + return result; } node = isMethod ? node.properties[0] : node; @@ -34,10 +34,9 @@ export default (app) => (node, result) => { node.id = id; } - result = props(app)(node, result); - result = params(app)(node, result); - result = body(app)(node, result); + result = bodyPlugin(node, result); + result = propsPlugin(node, result); + result = paramsPlugin(node, result); - // eslint-disable-next-line consistent-return return result; }; diff --git a/packages/parse-function/src/plugins/params.js b/packages/parse-function/src/plugins/params.js index 408fc337..49496382 100644 --- a/packages/parse-function/src/plugins/params.js +++ b/packages/parse-function/src/plugins/params.js @@ -1,16 +1,16 @@ -/* eslint-disable no-param-reassign, unicorn/consistent-function-scoping */ +/* eslint-disable no-param-reassign */ /** * > Micro plugin to visit each of the params * in the given function and collect them into * an `result.args` array and `result.params` string. * - * @param {Object} node - * @param {Object} result - * @return {Object} result + * @param node + * @param result + * @return result * @private */ -export default () => (node, result) => { +export default (node, result) => { node.params.forEach((param) => { const defaultArgsName = param.type === 'AssignmentPattern' && param.left && param.left.name; diff --git a/packages/parse-function/src/plugins/props.js b/packages/parse-function/src/plugins/props.js index 6f0cea7e..8e9afd2c 100644 --- a/packages/parse-function/src/plugins/props.js +++ b/packages/parse-function/src/plugins/props.js @@ -1,4 +1,3 @@ -/* eslint-disable no-param-reassign */ /** * > Set couple of hidden properties and * the name of the given function to @@ -9,25 +8,27 @@ * only when function is really anonymous and don't have * any name. * - * @param {Object} node - * @param {Object} result - * @return {Object} result + * @param node + * @param result + * @return result * @private */ -// eslint-disable-next-line unicorn/consistent-function-scoping -export default () => (node, result) => { - result.isArrow = node.type.startsWith('Arrow'); - result.isAsync = node.async || false; - result.isGenerator = node.generator || false; - result.isExpression = node.expression || false; - result.isAnonymous = node.id === null; - result.isNamed = !result.isAnonymous; +export default (node, result) => { + const res = { + ...result, + isArrow: node.type.startsWith('Arrow'), + isAsync: node.async || false, + isGenerator: node.generator || false, + isExpression: node.expression || false, + isAnonymous: node.id === null, + isNamed: node.id !== null, - // if real anonymous -> set to null, - // notice that you can name you function `anonymous`, haha - // and it won't be "real" anonymous, so `isAnonymous` will be `false` + // if real anonymous -> set to null, + // notice that you can name you function `anonymous`, haha + // and it won't be "real" anonymous, so `isAnonymous` will be `false` - result.name = result.isAnonymous ? null : node.id.name; + name: node.id === null ? null : node.id.name, + }; - return result; + return res; }; diff --git a/packages/parse-function/src/utils.js b/packages/parse-function/src/utils.js index ad6d61ef..f02eb47b 100644 --- a/packages/parse-function/src/utils.js +++ b/packages/parse-function/src/utils.js @@ -1,20 +1,15 @@ /* eslint-disable no-param-reassign */ -import arrayify from 'arrify'; import { parseExpression } from '@babel/parser'; -const utils = {}; - -utils.arrayify = arrayify; - /** * > Create default result object, * and normalize incoming arguments. * - * @param {Function|String} code - * @return {Object} result + * @param code + * @return result * @private */ -utils.setDefaults = function setDefaults(code) { +export function setDefaults(code) { const result = { name: null, body: '', @@ -23,7 +18,7 @@ utils.setDefaults = function setDefaults(code) { }; if (typeof code === 'function') { - code = code.toString('utf8'); + code = code.toString(); } // makes result.isValid === false @@ -31,19 +26,20 @@ utils.setDefaults = function setDefaults(code) { code = ''; } - return utils.setHiddenDefaults(result, code || ''); -}; + return setHiddenDefaults(result, code || ''); +} /** * > Create hidden properties into * the result object. * - * @param {Object} result - * @param {Function|String} code - * @return {Object} result + * @param result + * @param code + * @return result * @private */ -utils.setHiddenDefaults = function setHiddenDefaults(result, code) { + +export function setHiddenDefaults(result, code) { result.defaults = {}; result.value = code; result.isValid = code.length > 0; @@ -55,28 +51,29 @@ utils.setHiddenDefaults = function setHiddenDefaults(result, code) { result.isExpression = false; return result; -}; +} /** * > Get needed AST tree, depending on what * parse method is used. * - * @param {Object} result - * @param {Object} opts - * @return {Object} node + * @param result + * @param opts + * @return node * @private */ -utils.getNode = function getNode(result, opts) { +export function getNode(result, options) { + const opts = { ...options }; if (typeof opts.parse === 'function') { result.value = `(${result.value})`; - const ast = opts.parse(result.value, opts); - const body = (ast.program && ast.program.body) || ast.body; + const ast = opts.parse(result.value, opts.parserOptions); + const astBody = ast.body; + + const body = (ast.program && ast.program.body) || astBody; return body[0].expression; } - return parseExpression(result.value, opts); -}; - -export default utils; + return parseExpression(result.value, opts.parserOptions); +} diff --git a/packages/parse-function/test/__snapshots__/index.js.snap b/packages/parse-function/test/__snapshots__/index.js.snap index 953eca5d..1220d83e 100644 --- a/packages/parse-function/test/__snapshots__/index.js.snap +++ b/packages/parse-function/test/__snapshots__/index.js.snap @@ -22,7 +22,7 @@ Object { "isValid": true, "name": null, "params": "a, cb, restArgs", - "value": "function (a = {foo: \\"ba)r\\", baz: 123}, cb, ...restArgs) {return a * 3}", + "value": "(function (a = {foo: \\"ba)r\\", baz: 123}, cb, ...restArgs) {return a * 3})", } `; @@ -48,7 +48,7 @@ Object { "isValid": true, "name": null, "params": "b, callback, restArgs", - "value": "function (b, callback, ...restArgs) {callback(null, b + 3)}", + "value": "(function (b, callback, ...restArgs) {callback(null, b + 3)})", } `; @@ -70,7 +70,7 @@ Object { "isValid": true, "name": null, "params": "c", - "value": "function (c) {return c * 3}", + "value": "(function (c) {return c * 3})", } `; @@ -92,7 +92,7 @@ Object { "isValid": true, "name": null, "params": "restArgs", - "value": "function (...restArgs) {return 321}", + "value": "(function (...restArgs) {return 321})", } `; @@ -110,7 +110,7 @@ Object { "isValid": true, "name": null, "params": "", - "value": "function () {}", + "value": "(function () {})", } `; @@ -132,7 +132,7 @@ Object { "isValid": true, "name": null, "params": "a", - "value": "function (a = (true, false)) {}", + "value": "(function (a = (true, false)) {})", } `; @@ -154,7 +154,7 @@ Object { "isValid": true, "name": null, "params": "a", - "value": "function (a = (true, null)) {}", + "value": "(function (a = (true, null)) {})", } `; @@ -176,7 +176,7 @@ Object { "isValid": true, "name": null, "params": "a", - "value": "function (a = (true, \\"bar\\")) {}", + "value": "(function (a = (true, \\"bar\\")) {})", } `; @@ -200,7 +200,7 @@ Object { "isValid": true, "name": null, "params": "a, b", - "value": "function (a, b = (i++, true)) {}", + "value": "(function (a, b = (i++, true)) {})", } `; @@ -222,7 +222,7 @@ Object { "isValid": true, "name": null, "params": "a", - "value": "function (a = 1) {}", + "value": "(function (a = 1) {})", } `; @@ -248,7 +248,7 @@ Object { "isValid": true, "name": "namedFn", "params": "a, cb, restArgs", - "value": "function namedFn (a = {foo: \\"ba)r\\", baz: 123}, cb, ...restArgs) {return a * 3}", + "value": "(function namedFn (a = {foo: \\"ba)r\\", baz: 123}, cb, ...restArgs) {return a * 3})", } `; @@ -274,7 +274,7 @@ Object { "isValid": true, "name": "namedFn", "params": "b, callback, restArgs", - "value": "function namedFn (b, callback, ...restArgs) {callback(null, b + 3)}", + "value": "(function namedFn (b, callback, ...restArgs) {callback(null, b + 3)})", } `; @@ -296,7 +296,7 @@ Object { "isValid": true, "name": "namedFn", "params": "c", - "value": "function namedFn (c) {return c * 3}", + "value": "(function namedFn (c) {return c * 3})", } `; @@ -318,7 +318,7 @@ Object { "isValid": true, "name": "namedFn", "params": "restArgs", - "value": "function namedFn (...restArgs) {return 321}", + "value": "(function namedFn (...restArgs) {return 321})", } `; @@ -336,7 +336,7 @@ Object { "isValid": true, "name": "namedFn", "params": "", - "value": "function namedFn () {}", + "value": "(function namedFn () {})", } `; @@ -358,7 +358,7 @@ Object { "isValid": true, "name": "namedFn", "params": "a", - "value": "function namedFn(a = (true, false)) {}", + "value": "(function namedFn(a = (true, false)) {})", } `; @@ -380,7 +380,7 @@ Object { "isValid": true, "name": "namedFn", "params": "a", - "value": "function namedFn(a = (true, null)) {}", + "value": "(function namedFn(a = (true, null)) {})", } `; @@ -402,7 +402,7 @@ Object { "isValid": true, "name": "namedFn", "params": "a", - "value": "function namedFn(a = (true, \\"bar\\")) {}", + "value": "(function namedFn(a = (true, \\"bar\\")) {})", } `; @@ -426,7 +426,7 @@ Object { "isValid": true, "name": "namedFn", "params": "a, b", - "value": "function namedFn(a, b = (i++, true)) {}", + "value": "(function namedFn(a, b = (i++, true)) {})", } `; @@ -448,7 +448,7 @@ Object { "isValid": true, "name": "namedFn", "params": "a", - "value": "function namedFn(a = 1) {}", + "value": "(function namedFn(a = 1) {})", } `; @@ -474,7 +474,7 @@ Object { "isValid": true, "name": "namedFn", "params": "a, cb, restArgs", - "value": "function * namedFn (a = {foo: \\"ba)r\\", baz: 123}, cb, ...restArgs) {return a * 3}", + "value": "(function * namedFn (a = {foo: \\"ba)r\\", baz: 123}, cb, ...restArgs) {return a * 3})", } `; @@ -500,7 +500,7 @@ Object { "isValid": true, "name": "namedFn", "params": "b, callback, restArgs", - "value": "function * namedFn (b, callback, ...restArgs) {callback(null, b + 3)}", + "value": "(function * namedFn (b, callback, ...restArgs) {callback(null, b + 3)})", } `; @@ -522,7 +522,7 @@ Object { "isValid": true, "name": "namedFn", "params": "c", - "value": "function * namedFn (c) {return c * 3}", + "value": "(function * namedFn (c) {return c * 3})", } `; @@ -544,7 +544,7 @@ Object { "isValid": true, "name": "namedFn", "params": "restArgs", - "value": "function * namedFn (...restArgs) {return 321}", + "value": "(function * namedFn (...restArgs) {return 321})", } `; @@ -562,7 +562,7 @@ Object { "isValid": true, "name": "namedFn", "params": "", - "value": "function * namedFn () {}", + "value": "(function * namedFn () {})", } `; @@ -584,7 +584,7 @@ Object { "isValid": true, "name": "namedFn", "params": "a", - "value": "function * namedFn(a = (true, false)) {}", + "value": "(function * namedFn(a = (true, false)) {})", } `; @@ -606,7 +606,7 @@ Object { "isValid": true, "name": "namedFn", "params": "a", - "value": "function * namedFn(a = (true, null)) {}", + "value": "(function * namedFn(a = (true, null)) {})", } `; @@ -628,7 +628,7 @@ Object { "isValid": true, "name": "namedFn", "params": "a", - "value": "function * namedFn(a = (true, \\"bar\\")) {}", + "value": "(function * namedFn(a = (true, \\"bar\\")) {})", } `; @@ -652,7 +652,7 @@ Object { "isValid": true, "name": "namedFn", "params": "a, b", - "value": "function * namedFn(a, b = (i++, true)) {}", + "value": "(function * namedFn(a, b = (i++, true)) {})", } `; @@ -674,11 +674,11 @@ Object { "isValid": true, "name": "namedFn", "params": "a", - "value": "function * namedFn(a = 1) {}", + "value": "(function * namedFn(a = 1) {})", } `; -exports[`#31 - babel (default) - a = {foo: "ba)r", baz: 123}, cb, ...restArgs) => {return a * 3} 1`] = ` +exports[`#31 - babel (default) - (a = {foo: "ba)r", baz: 123}, cb, ...restArgs) => {return a * 3} 1`] = ` Object { "args": Array [ "a", @@ -700,11 +700,11 @@ Object { "isValid": true, "name": null, "params": "a, cb, restArgs", - "value": "(a = {foo: \\"ba)r\\", baz: 123}, cb, ...restArgs) => {return a * 3}", + "value": "((a = {foo: \\"ba)r\\", baz: 123}, cb, ...restArgs) => {return a * 3})", } `; -exports[`#32 - babel (default) - b, callback, ...restArgs) => {callback(null, b + 3)} 1`] = ` +exports[`#32 - babel (default) - (b, callback, ...restArgs) => {callback(null, b + 3)} 1`] = ` Object { "args": Array [ "b", @@ -726,11 +726,11 @@ Object { "isValid": true, "name": null, "params": "b, callback, restArgs", - "value": "(b, callback, ...restArgs) => {callback(null, b + 3)}", + "value": "((b, callback, ...restArgs) => {callback(null, b + 3)})", } `; -exports[`#33 - babel (default) - c) => {return c * 3} 1`] = ` +exports[`#33 - babel (default) - (c) => {return c * 3} 1`] = ` Object { "args": Array [ "c", @@ -748,11 +748,11 @@ Object { "isValid": true, "name": null, "params": "c", - "value": "(c) => {return c * 3}", + "value": "((c) => {return c * 3})", } `; -exports[`#34 - babel (default) - ...restArgs) => {return 321} 1`] = ` +exports[`#34 - babel (default) - (...restArgs) => {return 321} 1`] = ` Object { "args": Array [ "restArgs", @@ -770,11 +770,11 @@ Object { "isValid": true, "name": null, "params": "restArgs", - "value": "(...restArgs) => {return 321}", + "value": "((...restArgs) => {return 321})", } `; -exports[`#35 - babel (default) - ) => {} 1`] = ` +exports[`#35 - babel (default) - () => {} 1`] = ` Object { "args": Array [], "body": "", @@ -788,11 +788,11 @@ Object { "isValid": true, "name": null, "params": "", - "value": "() => {}", + "value": "(() => {})", } `; -exports[`#36 - babel (default) - a = (true, false)) => {} 1`] = ` +exports[`#36 - babel (default) - (a = (true, false)) => {} 1`] = ` Object { "args": Array [ "a", @@ -810,11 +810,11 @@ Object { "isValid": true, "name": null, "params": "a", - "value": "(a = (true, false)) => {}", + "value": "((a = (true, false)) => {})", } `; -exports[`#37 - babel (default) - a = (true, null)) => {} 1`] = ` +exports[`#37 - babel (default) - (a = (true, null)) => {} 1`] = ` Object { "args": Array [ "a", @@ -832,11 +832,11 @@ Object { "isValid": true, "name": null, "params": "a", - "value": "(a = (true, null)) => {}", + "value": "((a = (true, null)) => {})", } `; -exports[`#38 - babel (default) - a = (true, "bar")) => {} 1`] = ` +exports[`#38 - babel (default) - (a = (true, "bar")) => {} 1`] = ` Object { "args": Array [ "a", @@ -854,11 +854,11 @@ Object { "isValid": true, "name": null, "params": "a", - "value": "(a = (true, \\"bar\\")) => {}", + "value": "((a = (true, \\"bar\\")) => {})", } `; -exports[`#39 - babel (default) - a, b = (i++, true)) => {} 1`] = ` +exports[`#39 - babel (default) - (a, b = (i++, true)) => {} 1`] = ` Object { "args": Array [ "a", @@ -878,11 +878,11 @@ Object { "isValid": true, "name": null, "params": "a, b", - "value": "(a, b = (i++, true)) => {}", + "value": "((a, b = (i++, true)) => {})", } `; -exports[`#40 - babel (default) - a = 1) => {} 1`] = ` +exports[`#40 - babel (default) - (a = 1) => {} 1`] = ` Object { "args": Array [ "a", @@ -900,11 +900,11 @@ Object { "isValid": true, "name": null, "params": "a", - "value": "(a = 1) => {}", + "value": "((a = 1) => {})", } `; -exports[`#41 - babel (default) - a) => a * 3 * a 1`] = ` +exports[`#41 - babel (default) - (a) => a * 3 * a 1`] = ` Object { "args": Array [ "a", @@ -922,7 +922,7 @@ Object { "isValid": true, "name": null, "params": "a", - "value": "(a) => a * 3 * a", + "value": "((a) => a * 3 * a)", } `; @@ -944,7 +944,7 @@ Object { "isValid": true, "name": null, "params": "d", - "value": "d => d * 355 * d", + "value": "(d => d * 355 * d)", } `; @@ -966,11 +966,11 @@ Object { "isValid": true, "name": null, "params": "e", - "value": "e => {return e + 5235 / e}", + "value": "(e => {return e + 5235 / e})", } `; -exports[`#44 - babel (default) - a, b) => a + 3 + b 1`] = ` +exports[`#44 - babel (default) - (a, b) => a + 3 + b 1`] = ` Object { "args": Array [ "a", @@ -990,11 +990,11 @@ Object { "isValid": true, "name": null, "params": "a, b", - "value": "(a, b) => a + 3 + b", + "value": "((a, b) => a + 3 + b)", } `; -exports[`#45 - babel (default) - x, y, ...restArgs) => console.log({ value: x * y } 1`] = ` +exports[`#45 - babel (default) - (x, y, ...restArgs) => console.log({ value: x * y }) 1`] = ` Object { "args": Array [ "x", @@ -1016,7 +1016,7 @@ Object { "isValid": true, "name": null, "params": "x, y, restArgs", - "value": "(x, y, ...restArgs) => console.log({ value: x * y })", + "value": "((x, y, ...restArgs) => console.log({ value: x * y }))", } `; @@ -1042,7 +1042,7 @@ Object { "isValid": true, "name": null, "params": "a, cb, restArgs", - "value": "async function (a = {foo: \\"ba)r\\", baz: 123}, cb, ...restArgs) {return a * 3}", + "value": "(async function (a = {foo: \\"ba)r\\", baz: 123}, cb, ...restArgs) {return a * 3})", } `; @@ -1068,7 +1068,7 @@ Object { "isValid": true, "name": null, "params": "b, callback, restArgs", - "value": "async function (b, callback, ...restArgs) {callback(null, b + 3)}", + "value": "(async function (b, callback, ...restArgs) {callback(null, b + 3)})", } `; @@ -1090,7 +1090,7 @@ Object { "isValid": true, "name": null, "params": "c", - "value": "async function (c) {return c * 3}", + "value": "(async function (c) {return c * 3})", } `; @@ -1112,7 +1112,7 @@ Object { "isValid": true, "name": null, "params": "restArgs", - "value": "async function (...restArgs) {return 321}", + "value": "(async function (...restArgs) {return 321})", } `; @@ -1130,7 +1130,7 @@ Object { "isValid": true, "name": null, "params": "", - "value": "async function () {}", + "value": "(async function () {})", } `; @@ -1152,7 +1152,7 @@ Object { "isValid": true, "name": null, "params": "a", - "value": "async function (a = (true, false)) {}", + "value": "(async function (a = (true, false)) {})", } `; @@ -1174,7 +1174,7 @@ Object { "isValid": true, "name": null, "params": "a", - "value": "async function (a = (true, null)) {}", + "value": "(async function (a = (true, null)) {})", } `; @@ -1196,7 +1196,7 @@ Object { "isValid": true, "name": null, "params": "a", - "value": "async function (a = (true, \\"bar\\")) {}", + "value": "(async function (a = (true, \\"bar\\")) {})", } `; @@ -1220,7 +1220,7 @@ Object { "isValid": true, "name": null, "params": "a, b", - "value": "async function (a, b = (i++, true)) {}", + "value": "(async function (a, b = (i++, true)) {})", } `; @@ -1242,7 +1242,7 @@ Object { "isValid": true, "name": null, "params": "a", - "value": "async function (a = 1) {}", + "value": "(async function (a = 1) {})", } `; @@ -1268,7 +1268,7 @@ Object { "isValid": true, "name": "namedFn", "params": "a, cb, restArgs", - "value": "async function namedFn (a = {foo: \\"ba)r\\", baz: 123}, cb, ...restArgs) {return a * 3}", + "value": "(async function namedFn (a = {foo: \\"ba)r\\", baz: 123}, cb, ...restArgs) {return a * 3})", } `; @@ -1294,7 +1294,7 @@ Object { "isValid": true, "name": "namedFn", "params": "b, callback, restArgs", - "value": "async function namedFn (b, callback, ...restArgs) {callback(null, b + 3)}", + "value": "(async function namedFn (b, callback, ...restArgs) {callback(null, b + 3)})", } `; @@ -1316,7 +1316,7 @@ Object { "isValid": true, "name": "namedFn", "params": "c", - "value": "async function namedFn (c) {return c * 3}", + "value": "(async function namedFn (c) {return c * 3})", } `; @@ -1338,7 +1338,7 @@ Object { "isValid": true, "name": "namedFn", "params": "restArgs", - "value": "async function namedFn (...restArgs) {return 321}", + "value": "(async function namedFn (...restArgs) {return 321})", } `; @@ -1356,7 +1356,7 @@ Object { "isValid": true, "name": "namedFn", "params": "", - "value": "async function namedFn () {}", + "value": "(async function namedFn () {})", } `; @@ -1378,7 +1378,7 @@ Object { "isValid": true, "name": "namedFn", "params": "a", - "value": "async function namedFn(a = (true, false)) {}", + "value": "(async function namedFn(a = (true, false)) {})", } `; @@ -1400,7 +1400,7 @@ Object { "isValid": true, "name": "namedFn", "params": "a", - "value": "async function namedFn(a = (true, null)) {}", + "value": "(async function namedFn(a = (true, null)) {})", } `; @@ -1422,7 +1422,7 @@ Object { "isValid": true, "name": "namedFn", "params": "a", - "value": "async function namedFn(a = (true, \\"bar\\")) {}", + "value": "(async function namedFn(a = (true, \\"bar\\")) {})", } `; @@ -1446,7 +1446,7 @@ Object { "isValid": true, "name": "namedFn", "params": "a, b", - "value": "async function namedFn(a, b = (i++, true)) {}", + "value": "(async function namedFn(a, b = (i++, true)) {})", } `; @@ -1468,7 +1468,7 @@ Object { "isValid": true, "name": "namedFn", "params": "a", - "value": "async function namedFn(a = 1) {}", + "value": "(async function namedFn(a = 1) {})", } `; @@ -1494,7 +1494,7 @@ Object { "isValid": true, "name": null, "params": "a, cb, restArgs", - "value": "async (a = {foo: \\"ba)r\\", baz: 123}, cb, ...restArgs) => {return a * 3}", + "value": "(async (a = {foo: \\"ba)r\\", baz: 123}, cb, ...restArgs) => {return a * 3})", } `; @@ -1520,7 +1520,7 @@ Object { "isValid": true, "name": null, "params": "b, callback, restArgs", - "value": "async (b, callback, ...restArgs) => {callback(null, b + 3)}", + "value": "(async (b, callback, ...restArgs) => {callback(null, b + 3)})", } `; @@ -1542,7 +1542,7 @@ Object { "isValid": true, "name": null, "params": "c", - "value": "async (c) => {return c * 3}", + "value": "(async (c) => {return c * 3})", } `; @@ -1564,7 +1564,7 @@ Object { "isValid": true, "name": null, "params": "restArgs", - "value": "async (...restArgs) => {return 321}", + "value": "(async (...restArgs) => {return 321})", } `; @@ -1582,7 +1582,7 @@ Object { "isValid": true, "name": null, "params": "", - "value": "async () => {}", + "value": "(async () => {})", } `; @@ -1604,7 +1604,7 @@ Object { "isValid": true, "name": null, "params": "a", - "value": "async (a = (true, false)) => {}", + "value": "(async (a = (true, false)) => {})", } `; @@ -1626,7 +1626,7 @@ Object { "isValid": true, "name": null, "params": "a", - "value": "async (a = (true, null)) => {}", + "value": "(async (a = (true, null)) => {})", } `; @@ -1648,7 +1648,7 @@ Object { "isValid": true, "name": null, "params": "a", - "value": "async (a = (true, \\"bar\\")) => {}", + "value": "(async (a = (true, \\"bar\\")) => {})", } `; @@ -1672,7 +1672,7 @@ Object { "isValid": true, "name": null, "params": "a, b", - "value": "async (a, b = (i++, true)) => {}", + "value": "(async (a, b = (i++, true)) => {})", } `; @@ -1694,7 +1694,7 @@ Object { "isValid": true, "name": null, "params": "a", - "value": "async (a = 1) => {}", + "value": "(async (a = 1) => {})", } `; @@ -1716,7 +1716,7 @@ Object { "isValid": true, "name": null, "params": "a", - "value": "async (a) => a * 3 * a", + "value": "(async (a) => a * 3 * a)", } `; @@ -1738,7 +1738,7 @@ Object { "isValid": true, "name": null, "params": "d", - "value": "async d => d * 355 * d", + "value": "(async d => d * 355 * d)", } `; @@ -1760,7 +1760,7 @@ Object { "isValid": true, "name": null, "params": "e", - "value": "async e => {return e + 5235 / e}", + "value": "(async e => {return e + 5235 / e})", } `; @@ -1784,11 +1784,11 @@ Object { "isValid": true, "name": null, "params": "a, b", - "value": "async (a, b) => a + 3 + b", + "value": "(async (a, b) => a + 3 + b)", } `; -exports[`#80 - babel (default) - async (x, y, ...restArgs) => console.log({ value: x * y } 1`] = ` +exports[`#80 - babel (default) - async (x, y, ...restArgs) => console.log({ value: x * y }) 1`] = ` Object { "args": Array [ "x", @@ -1810,7 +1810,7 @@ Object { "isValid": true, "name": null, "params": "x, y, restArgs", - "value": "async (x, y, ...restArgs) => console.log({ value: x * y })", + "value": "(async (x, y, ...restArgs) => console.log({ value: x * y }))", } `; @@ -1858,7 +1858,7 @@ Object { "c", ], "body": " - return 123; + return a + b + c; ", "defaults": Object { "a": undefined, @@ -1874,9 +1874,9 @@ Object { "isValid": true, "name": "foo", "params": "a, b, c", - "value": "{ foo(a, b, c) { - return 123; - } }", + "value": "({ foo(a, b, c) { + return a + b + c; + } })", } `; @@ -1900,9 +1900,9 @@ Object { "isValid": true, "name": "bar", "params": "a", - "value": "{ bar(a) { + "value": "({ bar(a) { return () => a; - } }", + } })", } `; @@ -1926,9 +1926,9 @@ Object { "isValid": true, "name": "gen", "params": "a", - "value": "{ *gen(a) { + "value": "({ *gen(a) { return yield a * 321; - } }", + } })", } `; @@ -1954,11 +1954,11 @@ Object { "isValid": true, "name": "namedFn", "params": "a, cb, restArgs", - "value": "{ namedFn (a = {foo: 'ba)r', baz: 123}, cb, ...restArgs) { return a * 3 } }", + "value": "({ namedFn (a = {foo: 'ba)r', baz: 123}, cb, ...restArgs) { return a * 3 } })", } `; -exports[`#91 - options.parse + ecmaVersion: 2019 - function (a = {foo: "ba)r", baz: 123}, cb, ...restArgs) {return a * 3} 1`] = ` +exports[`#91 - options.parse - function (a = {foo: "ba)r", baz: 123}, cb, ...restArgs) {return a * 3} 1`] = ` Object { "args": Array [ "a", @@ -1984,7 +1984,7 @@ Object { } `; -exports[`#92 - options.parse + ecmaVersion: 2019 - function (b, callback, ...restArgs) {callback(null, b + 3)} 1`] = ` +exports[`#92 - options.parse - function (b, callback, ...restArgs) {callback(null, b + 3)} 1`] = ` Object { "args": Array [ "b", @@ -2010,7 +2010,7 @@ Object { } `; -exports[`#93 - options.parse + ecmaVersion: 2019 - function (c) {return c * 3} 1`] = ` +exports[`#93 - options.parse - function (c) {return c * 3} 1`] = ` Object { "args": Array [ "c", @@ -2032,7 +2032,7 @@ Object { } `; -exports[`#94 - options.parse + ecmaVersion: 2019 - function (...restArgs) {return 321} 1`] = ` +exports[`#94 - options.parse - function (...restArgs) {return 321} 1`] = ` Object { "args": Array [ "restArgs", @@ -2054,7 +2054,7 @@ Object { } `; -exports[`#95 - options.parse + ecmaVersion: 2019 - function () {} 1`] = ` +exports[`#95 - options.parse - function () {} 1`] = ` Object { "args": Array [], "body": "", @@ -2072,7 +2072,7 @@ Object { } `; -exports[`#96 - options.parse + ecmaVersion: 2019 - function (a = (true, false)) {} 1`] = ` +exports[`#96 - options.parse - function (a = (true, false)) {} 1`] = ` Object { "args": Array [ "a", @@ -2094,7 +2094,7 @@ Object { } `; -exports[`#97 - options.parse + ecmaVersion: 2019 - function (a = (true, null)) {} 1`] = ` +exports[`#97 - options.parse - function (a = (true, null)) {} 1`] = ` Object { "args": Array [ "a", @@ -2116,7 +2116,7 @@ Object { } `; -exports[`#98 - options.parse + ecmaVersion: 2019 - function (a = (true, "bar")) {} 1`] = ` +exports[`#98 - options.parse - function (a = (true, "bar")) {} 1`] = ` Object { "args": Array [ "a", @@ -2138,7 +2138,7 @@ Object { } `; -exports[`#99 - options.parse + ecmaVersion: 2019 - function (a, b = (i++, true)) {} 1`] = ` +exports[`#99 - options.parse - function (a, b = (i++, true)) {} 1`] = ` Object { "args": Array [ "a", @@ -2162,7 +2162,7 @@ Object { } `; -exports[`#100 - options.parse + ecmaVersion: 2019 - function (a = 1) {} 1`] = ` +exports[`#100 - options.parse - function (a = 1) {} 1`] = ` Object { "args": Array [ "a", @@ -2184,7 +2184,7 @@ Object { } `; -exports[`#101 - options.parse + ecmaVersion: 2019 - function namedFn (a = {foo: "ba)r", baz: 123}, cb, ...restArgs) {return a * 3} 1`] = ` +exports[`#101 - options.parse - function namedFn (a = {foo: "ba)r", baz: 123}, cb, ...restArgs) {return a * 3} 1`] = ` Object { "args": Array [ "a", @@ -2210,7 +2210,7 @@ Object { } `; -exports[`#102 - options.parse + ecmaVersion: 2019 - function namedFn (b, callback, ...restArgs) {callback(null, b + 3)} 1`] = ` +exports[`#102 - options.parse - function namedFn (b, callback, ...restArgs) {callback(null, b + 3)} 1`] = ` Object { "args": Array [ "b", @@ -2236,7 +2236,7 @@ Object { } `; -exports[`#103 - options.parse + ecmaVersion: 2019 - function namedFn (c) {return c * 3} 1`] = ` +exports[`#103 - options.parse - function namedFn (c) {return c * 3} 1`] = ` Object { "args": Array [ "c", @@ -2258,7 +2258,7 @@ Object { } `; -exports[`#104 - options.parse + ecmaVersion: 2019 - function namedFn (...restArgs) {return 321} 1`] = ` +exports[`#104 - options.parse - function namedFn (...restArgs) {return 321} 1`] = ` Object { "args": Array [ "restArgs", @@ -2280,7 +2280,7 @@ Object { } `; -exports[`#105 - options.parse + ecmaVersion: 2019 - function namedFn () {} 1`] = ` +exports[`#105 - options.parse - function namedFn () {} 1`] = ` Object { "args": Array [], "body": "", @@ -2298,7 +2298,7 @@ Object { } `; -exports[`#106 - options.parse + ecmaVersion: 2019 - function namedFn(a = (true, false)) {} 1`] = ` +exports[`#106 - options.parse - function namedFn(a = (true, false)) {} 1`] = ` Object { "args": Array [ "a", @@ -2320,7 +2320,7 @@ Object { } `; -exports[`#107 - options.parse + ecmaVersion: 2019 - function namedFn(a = (true, null)) {} 1`] = ` +exports[`#107 - options.parse - function namedFn(a = (true, null)) {} 1`] = ` Object { "args": Array [ "a", @@ -2342,7 +2342,7 @@ Object { } `; -exports[`#108 - options.parse + ecmaVersion: 2019 - function namedFn(a = (true, "bar")) {} 1`] = ` +exports[`#108 - options.parse - function namedFn(a = (true, "bar")) {} 1`] = ` Object { "args": Array [ "a", @@ -2364,7 +2364,7 @@ Object { } `; -exports[`#109 - options.parse + ecmaVersion: 2019 - function namedFn(a, b = (i++, true)) {} 1`] = ` +exports[`#109 - options.parse - function namedFn(a, b = (i++, true)) {} 1`] = ` Object { "args": Array [ "a", @@ -2388,7 +2388,7 @@ Object { } `; -exports[`#110 - options.parse + ecmaVersion: 2019 - function namedFn(a = 1) {} 1`] = ` +exports[`#110 - options.parse - function namedFn(a = 1) {} 1`] = ` Object { "args": Array [ "a", @@ -2410,7 +2410,7 @@ Object { } `; -exports[`#111 - options.parse + ecmaVersion: 2019 - function * namedFn (a = {foo: "ba)r", baz: 123}, cb, ...restArgs) {return a * 3} 1`] = ` +exports[`#111 - options.parse - function * namedFn (a = {foo: "ba)r", baz: 123}, cb, ...restArgs) {return a * 3} 1`] = ` Object { "args": Array [ "a", @@ -2436,7 +2436,7 @@ Object { } `; -exports[`#112 - options.parse + ecmaVersion: 2019 - function * namedFn (b, callback, ...restArgs) {callback(null, b + 3)} 1`] = ` +exports[`#112 - options.parse - function * namedFn (b, callback, ...restArgs) {callback(null, b + 3)} 1`] = ` Object { "args": Array [ "b", @@ -2462,7 +2462,7 @@ Object { } `; -exports[`#113 - options.parse + ecmaVersion: 2019 - function * namedFn (c) {return c * 3} 1`] = ` +exports[`#113 - options.parse - function * namedFn (c) {return c * 3} 1`] = ` Object { "args": Array [ "c", @@ -2484,7 +2484,7 @@ Object { } `; -exports[`#114 - options.parse + ecmaVersion: 2019 - function * namedFn (...restArgs) {return 321} 1`] = ` +exports[`#114 - options.parse - function * namedFn (...restArgs) {return 321} 1`] = ` Object { "args": Array [ "restArgs", @@ -2506,7 +2506,7 @@ Object { } `; -exports[`#115 - options.parse + ecmaVersion: 2019 - function * namedFn () {} 1`] = ` +exports[`#115 - options.parse - function * namedFn () {} 1`] = ` Object { "args": Array [], "body": "", @@ -2524,7 +2524,7 @@ Object { } `; -exports[`#116 - options.parse + ecmaVersion: 2019 - function * namedFn(a = (true, false)) {} 1`] = ` +exports[`#116 - options.parse - function * namedFn(a = (true, false)) {} 1`] = ` Object { "args": Array [ "a", @@ -2546,7 +2546,7 @@ Object { } `; -exports[`#117 - options.parse + ecmaVersion: 2019 - function * namedFn(a = (true, null)) {} 1`] = ` +exports[`#117 - options.parse - function * namedFn(a = (true, null)) {} 1`] = ` Object { "args": Array [ "a", @@ -2568,7 +2568,7 @@ Object { } `; -exports[`#118 - options.parse + ecmaVersion: 2019 - function * namedFn(a = (true, "bar")) {} 1`] = ` +exports[`#118 - options.parse - function * namedFn(a = (true, "bar")) {} 1`] = ` Object { "args": Array [ "a", @@ -2590,7 +2590,7 @@ Object { } `; -exports[`#119 - options.parse + ecmaVersion: 2019 - function * namedFn(a, b = (i++, true)) {} 1`] = ` +exports[`#119 - options.parse - function * namedFn(a, b = (i++, true)) {} 1`] = ` Object { "args": Array [ "a", @@ -2614,7 +2614,7 @@ Object { } `; -exports[`#120 - options.parse + ecmaVersion: 2019 - function * namedFn(a = 1) {} 1`] = ` +exports[`#120 - options.parse - function * namedFn(a = 1) {} 1`] = ` Object { "args": Array [ "a", @@ -2636,7 +2636,7 @@ Object { } `; -exports[`#121 - options.parse + ecmaVersion: 2019 - (a = {foo: "ba)r", baz: 123}, cb, ...restArgs) => {return a * 3} 1`] = ` +exports[`#121 - options.parse - (a = {foo: "ba)r", baz: 123}, cb, ...restArgs) => {return a * 3} 1`] = ` Object { "args": Array [ "a", @@ -2662,7 +2662,7 @@ Object { } `; -exports[`#122 - options.parse + ecmaVersion: 2019 - (b, callback, ...restArgs) => {callback(null, b + 3)} 1`] = ` +exports[`#122 - options.parse - (b, callback, ...restArgs) => {callback(null, b + 3)} 1`] = ` Object { "args": Array [ "b", @@ -2688,7 +2688,7 @@ Object { } `; -exports[`#123 - options.parse + ecmaVersion: 2019 - (c) => {return c * 3} 1`] = ` +exports[`#123 - options.parse - (c) => {return c * 3} 1`] = ` Object { "args": Array [ "c", @@ -2710,7 +2710,7 @@ Object { } `; -exports[`#124 - options.parse + ecmaVersion: 2019 - (...restArgs) => {return 321} 1`] = ` +exports[`#124 - options.parse - (...restArgs) => {return 321} 1`] = ` Object { "args": Array [ "restArgs", @@ -2732,7 +2732,7 @@ Object { } `; -exports[`#125 - options.parse + ecmaVersion: 2019 - () => {} 1`] = ` +exports[`#125 - options.parse - () => {} 1`] = ` Object { "args": Array [], "body": "", @@ -2750,7 +2750,7 @@ Object { } `; -exports[`#126 - options.parse + ecmaVersion: 2019 - (a = (true, false)) => {} 1`] = ` +exports[`#126 - options.parse - (a = (true, false)) => {} 1`] = ` Object { "args": Array [ "a", @@ -2772,7 +2772,7 @@ Object { } `; -exports[`#127 - options.parse + ecmaVersion: 2019 - (a = (true, null)) => {} 1`] = ` +exports[`#127 - options.parse - (a = (true, null)) => {} 1`] = ` Object { "args": Array [ "a", @@ -2794,7 +2794,7 @@ Object { } `; -exports[`#128 - options.parse + ecmaVersion: 2019 - (a = (true, "bar")) => {} 1`] = ` +exports[`#128 - options.parse - (a = (true, "bar")) => {} 1`] = ` Object { "args": Array [ "a", @@ -2816,7 +2816,7 @@ Object { } `; -exports[`#129 - options.parse + ecmaVersion: 2019 - (a, b = (i++, true)) => {} 1`] = ` +exports[`#129 - options.parse - (a, b = (i++, true)) => {} 1`] = ` Object { "args": Array [ "a", @@ -2840,7 +2840,7 @@ Object { } `; -exports[`#130 - options.parse + ecmaVersion: 2019 - (a = 1) => {} 1`] = ` +exports[`#130 - options.parse - (a = 1) => {} 1`] = ` Object { "args": Array [ "a", @@ -2862,7 +2862,7 @@ Object { } `; -exports[`#131 - options.parse + ecmaVersion: 2019 - (a) => a * 3 * a 1`] = ` +exports[`#131 - options.parse - (a) => a * 3 * a 1`] = ` Object { "args": Array [ "a", @@ -2884,7 +2884,7 @@ Object { } `; -exports[`#132 - options.parse + ecmaVersion: 2019 - d => d * 355 * d 1`] = ` +exports[`#132 - options.parse - d => d * 355 * d 1`] = ` Object { "args": Array [ "d", @@ -2906,7 +2906,7 @@ Object { } `; -exports[`#133 - options.parse + ecmaVersion: 2019 - e => {return e + 5235 / e} 1`] = ` +exports[`#133 - options.parse - e => {return e + 5235 / e} 1`] = ` Object { "args": Array [ "e", @@ -2928,7 +2928,7 @@ Object { } `; -exports[`#134 - options.parse + ecmaVersion: 2019 - (a, b) => a + 3 + b 1`] = ` +exports[`#134 - options.parse - (a, b) => a + 3 + b 1`] = ` Object { "args": Array [ "a", @@ -2952,7 +2952,7 @@ Object { } `; -exports[`#135 - options.parse + ecmaVersion: 2019 - (x, y, ...restArgs) => console.log({ value: x * y }) 1`] = ` +exports[`#135 - options.parse - (x, y, ...restArgs) => console.log({ value: x * y }) 1`] = ` Object { "args": Array [ "x", @@ -2978,7 +2978,7 @@ Object { } `; -exports[`#136 - options.parse + ecmaVersion: 2019 - async function (a = {foo: "ba)r", baz: 123}, cb, ...restArgs) {return a * 3} 1`] = ` +exports[`#136 - options.parse - async function (a = {foo: "ba)r", baz: 123}, cb, ...restArgs) {return a * 3} 1`] = ` Object { "args": Array [ "a", @@ -3004,7 +3004,7 @@ Object { } `; -exports[`#137 - options.parse + ecmaVersion: 2019 - async function (b, callback, ...restArgs) {callback(null, b + 3)} 1`] = ` +exports[`#137 - options.parse - async function (b, callback, ...restArgs) {callback(null, b + 3)} 1`] = ` Object { "args": Array [ "b", @@ -3030,7 +3030,7 @@ Object { } `; -exports[`#138 - options.parse + ecmaVersion: 2019 - async function (c) {return c * 3} 1`] = ` +exports[`#138 - options.parse - async function (c) {return c * 3} 1`] = ` Object { "args": Array [ "c", @@ -3052,7 +3052,7 @@ Object { } `; -exports[`#139 - options.parse + ecmaVersion: 2019 - async function (...restArgs) {return 321} 1`] = ` +exports[`#139 - options.parse - async function (...restArgs) {return 321} 1`] = ` Object { "args": Array [ "restArgs", @@ -3074,7 +3074,7 @@ Object { } `; -exports[`#140 - options.parse + ecmaVersion: 2019 - async function () {} 1`] = ` +exports[`#140 - options.parse - async function () {} 1`] = ` Object { "args": Array [], "body": "", @@ -3092,7 +3092,7 @@ Object { } `; -exports[`#141 - options.parse + ecmaVersion: 2019 - async function (a = (true, false)) {} 1`] = ` +exports[`#141 - options.parse - async function (a = (true, false)) {} 1`] = ` Object { "args": Array [ "a", @@ -3114,7 +3114,7 @@ Object { } `; -exports[`#142 - options.parse + ecmaVersion: 2019 - async function (a = (true, null)) {} 1`] = ` +exports[`#142 - options.parse - async function (a = (true, null)) {} 1`] = ` Object { "args": Array [ "a", @@ -3136,7 +3136,7 @@ Object { } `; -exports[`#143 - options.parse + ecmaVersion: 2019 - async function (a = (true, "bar")) {} 1`] = ` +exports[`#143 - options.parse - async function (a = (true, "bar")) {} 1`] = ` Object { "args": Array [ "a", @@ -3158,7 +3158,7 @@ Object { } `; -exports[`#144 - options.parse + ecmaVersion: 2019 - async function (a, b = (i++, true)) {} 1`] = ` +exports[`#144 - options.parse - async function (a, b = (i++, true)) {} 1`] = ` Object { "args": Array [ "a", @@ -3182,7 +3182,7 @@ Object { } `; -exports[`#145 - options.parse + ecmaVersion: 2019 - async function (a = 1) {} 1`] = ` +exports[`#145 - options.parse - async function (a = 1) {} 1`] = ` Object { "args": Array [ "a", @@ -3204,7 +3204,7 @@ Object { } `; -exports[`#146 - options.parse + ecmaVersion: 2019 - async function namedFn (a = {foo: "ba)r", baz: 123}, cb, ...restArgs) {return a * 3} 1`] = ` +exports[`#146 - options.parse - async function namedFn (a = {foo: "ba)r", baz: 123}, cb, ...restArgs) {return a * 3} 1`] = ` Object { "args": Array [ "a", @@ -3230,7 +3230,7 @@ Object { } `; -exports[`#147 - options.parse + ecmaVersion: 2019 - async function namedFn (b, callback, ...restArgs) {callback(null, b + 3)} 1`] = ` +exports[`#147 - options.parse - async function namedFn (b, callback, ...restArgs) {callback(null, b + 3)} 1`] = ` Object { "args": Array [ "b", @@ -3256,7 +3256,7 @@ Object { } `; -exports[`#148 - options.parse + ecmaVersion: 2019 - async function namedFn (c) {return c * 3} 1`] = ` +exports[`#148 - options.parse - async function namedFn (c) {return c * 3} 1`] = ` Object { "args": Array [ "c", @@ -3278,7 +3278,7 @@ Object { } `; -exports[`#149 - options.parse + ecmaVersion: 2019 - async function namedFn (...restArgs) {return 321} 1`] = ` +exports[`#149 - options.parse - async function namedFn (...restArgs) {return 321} 1`] = ` Object { "args": Array [ "restArgs", @@ -3300,7 +3300,7 @@ Object { } `; -exports[`#150 - options.parse + ecmaVersion: 2019 - async function namedFn () {} 1`] = ` +exports[`#150 - options.parse - async function namedFn () {} 1`] = ` Object { "args": Array [], "body": "", @@ -3318,7 +3318,7 @@ Object { } `; -exports[`#151 - options.parse + ecmaVersion: 2019 - async function namedFn(a = (true, false)) {} 1`] = ` +exports[`#151 - options.parse - async function namedFn(a = (true, false)) {} 1`] = ` Object { "args": Array [ "a", @@ -3340,7 +3340,7 @@ Object { } `; -exports[`#152 - options.parse + ecmaVersion: 2019 - async function namedFn(a = (true, null)) {} 1`] = ` +exports[`#152 - options.parse - async function namedFn(a = (true, null)) {} 1`] = ` Object { "args": Array [ "a", @@ -3362,7 +3362,7 @@ Object { } `; -exports[`#153 - options.parse + ecmaVersion: 2019 - async function namedFn(a = (true, "bar")) {} 1`] = ` +exports[`#153 - options.parse - async function namedFn(a = (true, "bar")) {} 1`] = ` Object { "args": Array [ "a", @@ -3384,7 +3384,7 @@ Object { } `; -exports[`#154 - options.parse + ecmaVersion: 2019 - async function namedFn(a, b = (i++, true)) {} 1`] = ` +exports[`#154 - options.parse - async function namedFn(a, b = (i++, true)) {} 1`] = ` Object { "args": Array [ "a", @@ -3408,7 +3408,7 @@ Object { } `; -exports[`#155 - options.parse + ecmaVersion: 2019 - async function namedFn(a = 1) {} 1`] = ` +exports[`#155 - options.parse - async function namedFn(a = 1) {} 1`] = ` Object { "args": Array [ "a", @@ -3430,7 +3430,7 @@ Object { } `; -exports[`#156 - options.parse + ecmaVersion: 2019 - async (a = {foo: "ba)r", baz: 123}, cb, ...restArgs) => {return a * 3} 1`] = ` +exports[`#156 - options.parse - async (a = {foo: "ba)r", baz: 123}, cb, ...restArgs) => {return a * 3} 1`] = ` Object { "args": Array [ "a", @@ -3456,7 +3456,7 @@ Object { } `; -exports[`#157 - options.parse + ecmaVersion: 2019 - async (b, callback, ...restArgs) => {callback(null, b + 3)} 1`] = ` +exports[`#157 - options.parse - async (b, callback, ...restArgs) => {callback(null, b + 3)} 1`] = ` Object { "args": Array [ "b", @@ -3482,7 +3482,7 @@ Object { } `; -exports[`#158 - options.parse + ecmaVersion: 2019 - async (c) => {return c * 3} 1`] = ` +exports[`#158 - options.parse - async (c) => {return c * 3} 1`] = ` Object { "args": Array [ "c", @@ -3504,7 +3504,7 @@ Object { } `; -exports[`#159 - options.parse + ecmaVersion: 2019 - async (...restArgs) => {return 321} 1`] = ` +exports[`#159 - options.parse - async (...restArgs) => {return 321} 1`] = ` Object { "args": Array [ "restArgs", @@ -3526,7 +3526,7 @@ Object { } `; -exports[`#160 - options.parse + ecmaVersion: 2019 - async () => {} 1`] = ` +exports[`#160 - options.parse - async () => {} 1`] = ` Object { "args": Array [], "body": "", @@ -3544,7 +3544,7 @@ Object { } `; -exports[`#161 - options.parse + ecmaVersion: 2019 - async (a = (true, false)) => {} 1`] = ` +exports[`#161 - options.parse - async (a = (true, false)) => {} 1`] = ` Object { "args": Array [ "a", @@ -3566,7 +3566,7 @@ Object { } `; -exports[`#162 - options.parse + ecmaVersion: 2019 - async (a = (true, null)) => {} 1`] = ` +exports[`#162 - options.parse - async (a = (true, null)) => {} 1`] = ` Object { "args": Array [ "a", @@ -3588,7 +3588,7 @@ Object { } `; -exports[`#163 - options.parse + ecmaVersion: 2019 - async (a = (true, "bar")) => {} 1`] = ` +exports[`#163 - options.parse - async (a = (true, "bar")) => {} 1`] = ` Object { "args": Array [ "a", @@ -3610,7 +3610,7 @@ Object { } `; -exports[`#164 - options.parse + ecmaVersion: 2019 - async (a, b = (i++, true)) => {} 1`] = ` +exports[`#164 - options.parse - async (a, b = (i++, true)) => {} 1`] = ` Object { "args": Array [ "a", @@ -3634,7 +3634,7 @@ Object { } `; -exports[`#165 - options.parse + ecmaVersion: 2019 - async (a = 1) => {} 1`] = ` +exports[`#165 - options.parse - async (a = 1) => {} 1`] = ` Object { "args": Array [ "a", @@ -3656,7 +3656,7 @@ Object { } `; -exports[`#166 - options.parse + ecmaVersion: 2019 - async (a) => a * 3 * a 1`] = ` +exports[`#166 - options.parse - async (a) => a * 3 * a 1`] = ` Object { "args": Array [ "a", @@ -3678,7 +3678,7 @@ Object { } `; -exports[`#167 - options.parse + ecmaVersion: 2019 - async d => d * 355 * d 1`] = ` +exports[`#167 - options.parse - async d => d * 355 * d 1`] = ` Object { "args": Array [ "d", @@ -3700,7 +3700,7 @@ Object { } `; -exports[`#168 - options.parse + ecmaVersion: 2019 - async e => {return e + 5235 / e} 1`] = ` +exports[`#168 - options.parse - async e => {return e + 5235 / e} 1`] = ` Object { "args": Array [ "e", @@ -3722,7 +3722,7 @@ Object { } `; -exports[`#169 - options.parse + ecmaVersion: 2019 - async (a, b) => a + 3 + b 1`] = ` +exports[`#169 - options.parse - async (a, b) => a + 3 + b 1`] = ` Object { "args": Array [ "a", @@ -3746,7 +3746,7 @@ Object { } `; -exports[`#170 - options.parse + ecmaVersion: 2019 - async (x, y, ...restArgs) => console.log({ value: x * y }) 1`] = ` +exports[`#170 - options.parse - async (x, y, ...restArgs) => console.log({ value: x * y }) 1`] = ` Object { "args": Array [ "x", @@ -3772,7 +3772,7 @@ Object { } `; -exports[`#171 - options.parse + ecmaVersion: 2019 - should return object with default values when invalid 1`] = ` +exports[`#171 - options.parse - should return object with default values when invalid 1`] = ` Object { "args": Array [], "body": "", @@ -3790,7 +3790,7 @@ Object { } `; -exports[`#172 - options.parse + ecmaVersion: 2019 - should have '.isValid' and few '.is*'' hidden properties 1`] = ` +exports[`#172 - options.parse - should have '.isValid' and few '.is*'' hidden properties 1`] = ` Object { "args": Array [], "body": "", @@ -3808,7 +3808,7 @@ Object { } `; -exports[`#177 - options.parse + ecmaVersion: 2019 - should work for object methods 1`] = ` +exports[`#177 - options.parse - should work for object methods 1`] = ` Object { "args": Array [ "a", @@ -3816,7 +3816,7 @@ Object { "c", ], "body": " - return 123; + return a + b + c; ", "defaults": Object { "a": undefined, @@ -3833,12 +3833,12 @@ Object { "name": "foo", "params": "a, b, c", "value": "({ foo(a, b, c) { - return 123; + return a + b + c; } })", } `; -exports[`#177 - options.parse + ecmaVersion: 2019 - should work for object methods 2`] = ` +exports[`#177 - options.parse - should work for object methods 2`] = ` Object { "args": Array [ "a", @@ -3864,7 +3864,7 @@ Object { } `; -exports[`#177 - options.parse + ecmaVersion: 2019 - should work for object methods 3`] = ` +exports[`#177 - options.parse - should work for object methods 3`] = ` Object { "args": Array [ "a", @@ -3890,7 +3890,7 @@ Object { } `; -exports[`#177 - options.parse + ecmaVersion: 2019 - should work for object methods 4`] = ` +exports[`#177 - options.parse - should work for object methods 4`] = ` Object { "args": Array [ "a", @@ -5774,7 +5774,7 @@ Object { "c", ], "body": " - return 123; + return a + b + c; ", "defaults": Object { "a": undefined, @@ -5791,7 +5791,7 @@ Object { "name": "foo", "params": "a, b, c", "value": "({ foo(a, b, c) { - return 123; + return a + b + c; } })", } `; @@ -7732,7 +7732,7 @@ Object { "c", ], "body": " - return 123; + return a + b + c; ", "defaults": Object { "a": undefined, @@ -7749,7 +7749,7 @@ Object { "name": "foo", "params": "a, b, c", "value": "({ foo(a, b, c) { - return 123; + return a + b + c; } })", } `; @@ -9690,7 +9690,7 @@ Object { "c", ], "body": " - return 123; + return a + b + c; ", "defaults": Object { "a": undefined, @@ -9707,7 +9707,7 @@ Object { "name": "foo", "params": "a, b, c", "value": "({ foo(a, b, c) { - return 123; + return a + b + c; } })", } `; @@ -9808,6 +9808,6 @@ Object { "isValid": true, "name": null, "params": "v", - "value": "async (v) => { if (v) {} }", + "value": "(async (v) => { if (v) {} })", } `; diff --git a/packages/parse-function/test/index.js b/packages/parse-function/test/index.js index 058896a6..f197ec18 100644 --- a/packages/parse-function/test/index.js +++ b/packages/parse-function/test/index.js @@ -1,14 +1,13 @@ /* eslint-disable unicorn/consistent-function-scoping, no-plusplus */ -import espree from 'espree'; +import { parse as espreeParse } from 'espree'; import { parse as babylonParse } from '@babel/parser'; import { parse as acornParse } from 'acorn'; import { parse as acornLooseParse } from 'acorn-loose'; import forIn from 'for-in'; -import parseFunction from '../src'; -const espreeParse = espree.parse; +import { parseFunction } from '../src'; const fixtures = { regulars: [ @@ -154,9 +153,8 @@ function factory(parserName, parseFn) { test(`#${testsCount++} - ${parserName} - should work for object methods`, () => { const obj = { - // eslint-disable-next-line no-unused-vars foo(a, b, c) { - return 123; + return a + b + c; }, bar(a) { return () => a; @@ -182,17 +180,13 @@ function factory(parserName, parseFn) { test(`#${testsCount++} - ${parserName} - plugins api`, () => { const fnStr = `() => 123 + a + 44`; - // eslint-disable-next-line no-unused-vars - const plugin = (app) => (node, result) => { - // eslint-disable-next-line no-param-reassign - result.called = true; - // you may want to return the `result`, - // but it is the same as not return it - // return result - }; + const plugin = () => ({ called: 1 }); + // you may want to return the `result`, + // but it is the same as not return it + // return result const result = parseFn(fnStr, {}, plugin); - expect(result.called).toStrictEqual(true); + expect(result.called).toStrictEqual(1); }); test(`#${testsCount++} - ${parserName} - fn named "anonymous" has .name: 'anonymous'`, () => { @@ -212,100 +206,53 @@ function factory(parserName, parseFn) { * Actually run all the tests */ -factory('babel (default)', (code, opts, plugin) => { - const app = parseFunction(); - if (plugin) app.use(plugin); - return app.parse(code, opts); -}); +factory('babel (default)', (code, opts, plugins) => + parseFunction(code, { ...opts, plugins }), +); -factory('options.parse + ecmaVersion: 2019', (code, opts, plugin) => { - const app = parseFunction({ - parse: babylonParse, - ecmaVersion: 2019, - }); - if (plugin) app.use(plugin); - return app.parse(code, opts); -}); +factory('options.parse', (code, opts, plugins) => + parseFunction(code, { ...opts, parse: babylonParse, plugins }), +); -factory('acorn.parse', (code, opts, plugin) => { - const app = parseFunction({ - parse: acornParse, - ecmaVersion: 2017, - }); - if (plugin) app.use(plugin); - return app.parse(code, opts); -}); +factory('acorn.parse', (code, opts, plugins) => + parseFunction(code, { ...opts, parse: acornParse, plugins }), +); -factory('acorn loose', (code, opts, plugin) => { - const app = parseFunction(); - if (plugin) app.use(plugin); - return app.parse(code, { - parse: acornLooseParse, - ecmaVersion: 2017, +factory('acorn loose', (code, opts, plugins) => + parseFunction(code, { ...opts, - }); -}); + parse: acornLooseParse, + plugins, + }), +); -factory('espree.parse', (code, opts, plugin) => { - const app = parseFunction({ +factory('espree.parse', (code, opts, plugins) => + parseFunction(code, { + ...opts, parse: espreeParse, - ecmaVersion: 8, - }); - if (plugin) app.use(plugin); - return app.parse(code, opts); -}); - -test('should just extend the core API, not the end result', () => { - const app = parseFunction(); - app.use((inst) => { - // eslint-disable-next-line no-param-reassign - inst.hello = (place) => `Hello ${place}!!`; - }); - const ret = app.hello('pinky World'); - expect(ret).toStrictEqual('Hello pinky World!!'); -}); - -test('should call fn returned from plugin only when `parse` is called', () => { - const app = parseFunction({ - ecmaVersion: 2017, - }); - - let called = 0; - - app.use(() => { - called = 1; - return () => { - called = 2; - }; - }); - - expect(called).toStrictEqual(1); - - const res = app.parse('(a, b) => {}'); - expect(called).toStrictEqual(2); - expect(res.params).toStrictEqual('a, b'); -}); + plugins, + parserOptions: { + ecmaVersion: 8, + }, + }), +); // https://github.com/tunnckoCore/parse-function/issues/61 test('should work with an async arrow function with an `if` statement', () => { - const app = parseFunction(); - const parsed = app.parse('async (v) => { if (v) {} }'); + const parsed = parseFunction('async (v) => { if (v) {} }'); expect(parsed).toMatchSnapshot(); }); test(`fn named "anonymous" has .name: 'anonymous'`, () => { - const app = parseFunction({ ecmaVersion: 2017 }); - const result = app.parse(function anonymous() {}); + const result = parseFunction(function anonymous() {}); expect(result.name).toStrictEqual('anonymous'); expect(result.isAnonymous).toStrictEqual(false); }); test(`real anonymous fn has .name: null`, () => { - const app = parseFunction({ ecmaVersion: 2017 }); - - /* eslint-disable-next-line prefer-arrow-callback, func-names */ - const actual = app.parse(function() {}); + /* eslint-disable-next-line func-names, prefer-arrow-callback */ + const actual = parseFunction(function() {}); expect(actual.name).toBeNull(); expect(actual.isAnonymous).toStrictEqual(true); }); From 73eebf2b6810f758e93f20a1367bafc062d21805 Mon Sep 17 00:00:00 2001 From: Charlike Mike Reagent Date: Thu, 24 Oct 2019 07:37:57 +0300 Subject: [PATCH 2/9] chore: tweaks Signed-off-by: Charlike Mike Reagent --- package.json | 8 +- packages/parse-function/.verb.md | 240 +-- packages/parse-function/README.md | 243 +-- packages/parse-function/example.js | 30 +- packages/parse-function/index.d.ts | 7 +- packages/parse-function/package.json | 3 + packages/parse-function/src/index.js | 84 +- packages/parse-function/src/utils.js | 10 +- .../test/__snapshots__/index.js.snap | 1434 +++++++++++++---- packages/parse-function/test/index.js | 338 ++-- rollup.config.js | 2 +- 11 files changed, 1546 insertions(+), 853 deletions(-) diff --git a/package.json b/package.json index a75752a9..19b40d7e 100644 --- a/package.json +++ b/package.json @@ -20,13 +20,13 @@ "patch:verb": "cp patches/verb-repo-helpers/index.js node_modules/verb-repo-helpers/index.js", "postsetup": "yarn patch:verb && yarn patch:hela && yarn patch:sade", "postsetup:ci": "yarn patch:verb && yarn patch:hela && yarn patch:sade", - "pre-commit": "yarn docs && yarn fmt", + "pre-commit": "LOCAL_TESTING=0 CI=1 yarn start test -u && yarn testy && git status --porcelain", "refresh": "yarn cleanup && yarn setup", "release": "lerna version && lerna publish from-package", "setup": "yarn && yarn bootstrap", "setup:ci": "yarn --frozen-lockfile && yarn bootstrap", "start": "node node_modules/@hela/cli/dist/build/cjs/cli.js", - "test": "CI=1 yarn start test", + "test": "FORCE_COLOR=1 CI=1 LOCAL_TESTING=1 yarn start test", "testy": "node generate-coverage-info.js && yarn start docs && yarn start format" }, "dependencies": { @@ -69,8 +69,8 @@ }, "husky": { "hooks": { - "pre-commit": "echo 'yarn run pre-commit'", - "commit-msg": "echo 'commitlint -E HUSKY_GIT_PARAMS'" + "pre-commit": "yarn run pre-commit", + "commit-msg": "commitlint -E HUSKY_GIT_PARAMS" } }, "jest": { diff --git a/packages/parse-function/.verb.md b/packages/parse-function/.verb.md index bde4b12d..221131a5 100644 --- a/packages/parse-function/.verb.md +++ b/packages/parse-function/.verb.md @@ -67,11 +67,7 @@ Only if you pass really an anonymous function you will get `result.name` equal t > _see: the [.use](#use) method, [test/index.js#L305-L317](https://github.com/tunnckoCore/parse-function/blob/master/test/index.js#L305-L317) and [test/index.js#L396-L414](https://github.com/tunnckoCore/parse-function/blob/master/test/index.js#L396-L414)_ A more human description of the plugin mechanism. Plugins are **synchronous** - no support -and no need for **async** plugins here, but notice that you can do that manually, because -that exact architecture. - -The first function that is passed to the [.use](#use) method is used for extending the core API, -for example adding a new method to the `app` instance. That function is immediately invoked. +and no need for **async** plugins here. ```js const parseFunction = require('parse-function'); @@ -121,198 +117,86 @@ you can add more properties if you want. _Generated using [jest-runner-docs](https://npmjs.com/package/jest-runner-docs)._ -### [parseFunction](./src/index.js#L52) +### [.parse](./src/index.js#L78) -> Initializes with optional `opts` object which is passed directly -> to the desired parser and returns an object -> with `.use` and `.parse` methods. The default parse which -> is used is [babylon][]'s `.parseExpression` method from `v7`. +Parse a given `input` and returns a `Result` object +with useful properties - such as `name`, `body` and `args`. +By default it uses `@babel/parser` parser, but you can switch it by +passing `options.parse` or `options.parseExpression`, for example `options.parse: acorn.parse`. +In the below example will show how to use `acorn` parser, instead +of the default one. **Signature** ```ts -function(opts = {}) -``` - -**Params** - -- `opts` - optional, merged with options passed to `.parse` method -- `returns` - app object with `.use` and `.parse` methods - -**Example** - -```js -const parseFunction = require('parse-function'); - -const app = parseFunction({ - ecmaVersion: 2017, -}); - -const fixtureFn = (a, b, c) => { - a = b + c; - return a + 2; -}; - -const result = app.parse(fixtureFn); -console.log(result); - -// see more -console.log(result.name); // => null -console.log(result.isNamed); // => false -console.log(result.isArrow); // => true -console.log(result.isAnonymous); // => true - -// array of names of the arguments -console.log(result.args); // => ['a', 'b', 'c'] - -// comma-separated names of the arguments -console.log(result.params); // => 'a, b, c' +function(input, options) ``` -### [.parse](./src/index.js#L117) - -> Parse a given `code` and returns a `result` object -> with useful properties - such as `name`, `body` and `args`. -> By default it uses Babylon parser, but you can switch it by -> passing `options.parse` - for example `options.parse: acorn.parse`. -> In the below example will show how to use `acorn` parser, instead -> of the default one. - **Params** -- `code` - any kind of function or string to be parsed +- `input` - any kind of function or string to be parsed - `options` - directly passed to the parser babylon, acorn, espree -- `options.parse` - by default `babylon.parseExpression`, - all `options` are passed as second argument +- `options.parse` - by default `@babel/parser`'s `.parse` or `.parseExpression`, +- `options.parserOptions` - passed to the parser +- `options.plugins` - a plugin function like `function plugin(node: Node, result: Result): Result {}` - `returns` - result see [result section](#result) for more info **Example** ```js -const acorn = require('acorn'); -const parseFn = require('parse-function'); -const app = parseFn(); +import { parse as acornParse } from 'acorn'; +import { parse as espreeParse } from 'espree'; +import { parseFunction } from 'parse-function'; -const fn = function foo(bar, baz) { +function fooFn(bar, baz = 123) { return bar * baz; -}; -const result = app.parse(fn, { - parse: acorn.parse, - ecmaVersion: 2017, -}); - -console.log(result.name); // => 'foo' -console.log(result.args); // => ['bar', 'baz'] -console.log(result.body); // => ' return bar * baz ' -console.log(result.isNamed); // => true -console.log(result.isArrow); // => false -console.log(result.isAnonymous); // => false -console.log(result.isGenerator); // => false -``` - -### [.use](./src/index.js#L170) - -> Add a plugin `fn` function for extending the API or working on the -> AST nodes. The `fn` is immediately invoked and passed -> with `app` argument which is instance of `parseFunction()` call. -> That `fn` may return another function that -> accepts `(node, result)` signature, where `node` is an AST node -> and `result` is an object which will be returned [result](#result) -> from the `.parse` method. This retuned function is called on each -> node only when `.parse` method is called. - -**Params** - -- `fn` - plugin to be called -- `returns` - app instance for chaining - -_See [Plugins Architecture](#plugins-architecture) section._ - -**Example** - -```js -// plugin extending the `app` -app.use((app) => { - app.define(app, 'hello', (place) => `Hello ${place}!`); -}); - -const hi = app.hello('World'); -console.log(hi); // => 'Hello World!' - -// or plugin that works on AST nodes -app.use((app) => (node, result) => { - if (node.type === 'ArrowFunctionExpression') { - result.thatIsArrow = true; - } - return result; -}); - -const result = app.parse((a, b) => a + b + 123); -console.log(result.name); // => null -console.log(result.isArrow); // => true -console.log(result.thatIsArrow); // => true - -const result = app.parse(function foo() { - return 123; -}); -console.log(result.name); // => 'foo' -console.log(result.isArrow); // => false -console.log(result.thatIsArrow); // => undefined -``` - -### [.define](./src/index.js#L228) - -> Define a non-enumerable property on an object. Just -> a convenience mirror of the [define-property][] library, -> so check out its docs. Useful to be used in plugins. - -**Params** - -- `obj` - the object on which to define the property -- `prop` - the name of the property to be defined or modified -- `val` - the descriptor for the property being defined or modified -- `returns` - obj the passed object, but modified - -**Example** - -```js -const parseFunction = require('parse-function'); -const app = parseFunction(); - -// use it like `define-property` lib -const obj = {}; -app.define(obj, 'hi', 'world'); -console.log(obj); // => { hi: 'world' } - -// or define a custom plugin that adds `.foo` property -// to the end result, returned from `app.parse` -app.use((app) => { - return (node, result) => { - // this function is called - // only when `.parse` is called - - app.define(result, 'foo', 123); - - return result; - }; +} + +const result1 = parseFunction(fooFn, { parse: acornParse }); +console.log(result1); + +const result2 = parseFunction(fooFn, { + parse: espreeParse, + parserOptions: { + ecmaVersion: 9, + sourceType: 'module', + ecmaFeatures: { jsx: true, globalReturn: true }, + }, }); -// fixture function to be parsed -const asyncFn = async (qux) => { - const bar = await Promise.resolve(qux); - return bar; -}; - -const result = app.parse(asyncFn); - -console.log(result.name); // => null -console.log(result.foo); // => 123 -console.log(result.args); // => ['qux'] - -console.log(result.isAsync); // => true -console.log(result.isArrow); // => true -console.log(result.isNamed); // => false -console.log(result.isAnonymous); // => true +console.log('parsed with espree', result2); +// => { +// name: 'fooFn', +// body: '\n return bar * baz;\n', +// args: [ 'bar', 'baz' ], +// params: 'bar, baz', +// defaults: { bar: undefined, baz: '123' }, +// value: '(function fooFn(bar, baz = 123) {\n return bar * baz;\n})', +// isValid: true, +// isArrow: false, +// isAsync: false, +// isNamed: true, +// isAnonymous: false, +// isGenerator: false, +// isExpression: false, +// bobby: 'bobby', +// barry: 'barry barry', +// hasDefaultParams: true +// } + +function basicPlugin(node, result) { + const bar = 'barry'; + const hasDefaultParams = + Object.values(result.defaults).filter(Boolean).length > 0; + + return { ...result, foo: 123, bar, hasDefaultParams }; +} + +const resultWithPlugins = parseFunction(fooFn, { plugins: basicPlugin }); +console.log(resultWithPlugins.name); // => 'fooFn' +console.log(resultWithPlugins.foo); // => 123 +console.log(resultWithPlugins.bar); // => 'barry' +console.log(resultWithPlugins.hasDefaultParams); // => true ``` diff --git a/packages/parse-function/README.md b/packages/parse-function/README.md index 68a60032..d5dd4c7e 100644 --- a/packages/parse-function/README.md +++ b/packages/parse-function/README.md @@ -74,10 +74,7 @@ Project is [semantically](https://semver.org) versioned & automatically released - [Real anonymous function](#real-anonymous-function) - [Plugins Architecture](#plugins-architecture) - [API](#api) - - [parseFunction](#parsefunction) - [.parse](#parse) - - [.use](#use) - - [.define](#define) - [Result](#result) - [Contributing](#contributing) - [Guides and Community](#guides-and-community) @@ -167,11 +164,7 @@ Only if you pass really an anonymous function you will get `result.name` equal t > _see: the [.use](#use) method, [test/index.js#L305-L317](https://github.com/tunnckoCore/parse-function/blob/master/test/index.js#L305-L317) and [test/index.js#L396-L414](https://github.com/tunnckoCore/parse-function/blob/master/test/index.js#L396-L414)_ A more human description of the plugin mechanism. Plugins are **synchronous** - no support -and no need for **async** plugins here, but notice that you can do that manually, because -that exact architecture. - -The first function that is passed to the [.use](#use) method is used for extending the core API, -for example adding a new method to the `app` instance. That function is immediately invoked. +and no need for **async** plugins here. ```js const parseFunction = require('parse-function'); @@ -221,198 +214,86 @@ you can add more properties if you want. _Generated using [jest-runner-docs](https://npmjs.com/package/jest-runner-docs)._ -### [parseFunction](./src/index.js#L52) +### [.parse](./src/index.js#L78) -> Initializes with optional `opts` object which is passed directly -> to the desired parser and returns an object -> with `.use` and `.parse` methods. The default parse which -> is used is [babylon][]'s `.parseExpression` method from `v7`. +Parse a given `input` and returns a `Result` object +with useful properties - such as `name`, `body` and `args`. +By default it uses `@babel/parser` parser, but you can switch it by +passing `options.parse` or `options.parseExpression`, for example `options.parse: acorn.parse`. +In the below example will show how to use `acorn` parser, instead +of the default one. **Signature** ```ts -function(opts = {}) -``` - -**Params** - -- `opts` - optional, merged with options passed to `.parse` method -- `returns` - app object with `.use` and `.parse` methods - -**Example** - -```js -const parseFunction = require('parse-function'); - -const app = parseFunction({ - ecmaVersion: 2017, -}); - -const fixtureFn = (a, b, c) => { - a = b + c; - return a + 2; -}; - -const result = app.parse(fixtureFn); -console.log(result); - -// see more -console.log(result.name); // => null -console.log(result.isNamed); // => false -console.log(result.isArrow); // => true -console.log(result.isAnonymous); // => true - -// array of names of the arguments -console.log(result.args); // => ['a', 'b', 'c'] - -// comma-separated names of the arguments -console.log(result.params); // => 'a, b, c' +function(input, options) ``` -### [.parse](./src/index.js#L117) - -> Parse a given `code` and returns a `result` object -> with useful properties - such as `name`, `body` and `args`. -> By default it uses Babylon parser, but you can switch it by -> passing `options.parse` - for example `options.parse: acorn.parse`. -> In the below example will show how to use `acorn` parser, instead -> of the default one. - **Params** -- `code` - any kind of function or string to be parsed +- `input` - any kind of function or string to be parsed - `options` - directly passed to the parser babylon, acorn, espree -- `options.parse` - by default `babylon.parseExpression`, - all `options` are passed as second argument +- `options.parse` - by default `@babel/parser`'s `.parse` or `.parseExpression`, +- `options.parserOptions` - passed to the parser +- `options.plugins` - a plugin function like `function plugin(node: Node, result: Result): Result {}` - `returns` - result see [result section](#result) for more info **Example** ```js -const acorn = require('acorn'); -const parseFn = require('parse-function'); -const app = parseFn(); +import { parse as acornParse } from 'acorn'; +import { parse as espreeParse } from 'espree'; +import { parseFunction } from 'parse-function'; -const fn = function foo(bar, baz) { +function fooFn(bar, baz = 123) { return bar * baz; -}; -const result = app.parse(fn, { - parse: acorn.parse, - ecmaVersion: 2017, -}); - -console.log(result.name); // => 'foo' -console.log(result.args); // => ['bar', 'baz'] -console.log(result.body); // => ' return bar * baz ' -console.log(result.isNamed); // => true -console.log(result.isArrow); // => false -console.log(result.isAnonymous); // => false -console.log(result.isGenerator); // => false -``` - -### [.use](./src/index.js#L170) - -> Add a plugin `fn` function for extending the API or working on the -> AST nodes. The `fn` is immediately invoked and passed -> with `app` argument which is instance of `parseFunction()` call. -> That `fn` may return another function that -> accepts `(node, result)` signature, where `node` is an AST node -> and `result` is an object which will be returned [result](#result) -> from the `.parse` method. This retuned function is called on each -> node only when `.parse` method is called. - -**Params** - -- `fn` - plugin to be called -- `returns` - app instance for chaining - -_See [Plugins Architecture](#plugins-architecture) section._ - -**Example** - -```js -// plugin extending the `app` -app.use((app) => { - app.define(app, 'hello', (place) => `Hello ${place}!`); -}); - -const hi = app.hello('World'); -console.log(hi); // => 'Hello World!' - -// or plugin that works on AST nodes -app.use((app) => (node, result) => { - if (node.type === 'ArrowFunctionExpression') { - result.thatIsArrow = true; - } - return result; -}); - -const result = app.parse((a, b) => a + b + 123); -console.log(result.name); // => null -console.log(result.isArrow); // => true -console.log(result.thatIsArrow); // => true - -const result = app.parse(function foo() { - return 123; -}); -console.log(result.name); // => 'foo' -console.log(result.isArrow); // => false -console.log(result.thatIsArrow); // => undefined -``` - -### [.define](./src/index.js#L228) - -> Define a non-enumerable property on an object. Just -> a convenience mirror of the [define-property][] library, -> so check out its docs. Useful to be used in plugins. - -**Params** - -- `obj` - the object on which to define the property -- `prop` - the name of the property to be defined or modified -- `val` - the descriptor for the property being defined or modified -- `returns` - obj the passed object, but modified - -**Example** - -```js -const parseFunction = require('parse-function'); -const app = parseFunction(); - -// use it like `define-property` lib -const obj = {}; -app.define(obj, 'hi', 'world'); -console.log(obj); // => { hi: 'world' } - -// or define a custom plugin that adds `.foo` property -// to the end result, returned from `app.parse` -app.use((app) => { - return (node, result) => { - // this function is called - // only when `.parse` is called - - app.define(result, 'foo', 123); - - return result; - }; +} + +const result1 = parseFunction(fooFn, { parse: acornParse }); +console.log(result1); + +const result2 = parseFunction(fooFn, { + parse: espreeParse, + parserOptions: { + ecmaVersion: 9, + sourceType: 'module', + ecmaFeatures: { jsx: true, globalReturn: true }, + }, }); -// fixture function to be parsed -const asyncFn = async (qux) => { - const bar = await Promise.resolve(qux); - return bar; -}; - -const result = app.parse(asyncFn); - -console.log(result.name); // => null -console.log(result.foo); // => 123 -console.log(result.args); // => ['qux'] - -console.log(result.isAsync); // => true -console.log(result.isArrow); // => true -console.log(result.isNamed); // => false -console.log(result.isAnonymous); // => true +console.log('parsed with espree', result2); +// => { +// name: 'fooFn', +// body: '\n return bar * baz;\n', +// args: [ 'bar', 'baz' ], +// params: 'bar, baz', +// defaults: { bar: undefined, baz: '123' }, +// value: '(function fooFn(bar, baz = 123) {\n return bar * baz;\n})', +// isValid: true, +// isArrow: false, +// isAsync: false, +// isNamed: true, +// isAnonymous: false, +// isGenerator: false, +// isExpression: false, +// bobby: 'bobby', +// barry: 'barry barry', +// hasDefaultParams: true +// } + +function basicPlugin(node, result) { + const bar = 'barry'; + const hasDefaultParams = + Object.values(result.defaults).filter(Boolean).length > 0; + + return { ...result, foo: 123, bar, hasDefaultParams }; +} + +const resultWithPlugins = parseFunction(fooFn, { plugins: basicPlugin }); +console.log(resultWithPlugins.name); // => 'fooFn' +console.log(resultWithPlugins.foo); // => 123 +console.log(resultWithPlugins.bar); // => 'barry' +console.log(resultWithPlugins.hasDefaultParams); // => true ``` diff --git a/packages/parse-function/example.js b/packages/parse-function/example.js index 10ea14eb..2bcffdf2 100644 --- a/packages/parse-function/example.js +++ b/packages/parse-function/example.js @@ -1,6 +1,10 @@ import { parse as acornParse } from 'acorn'; import { parseFunction } from '.'; +function fooFn(bar, baz = 123) { + return bar * baz; +} + // `node` is an AST Node function bobbyPlugin(node, result) { const bobby = 'bobby'; @@ -9,26 +13,27 @@ function bobbyPlugin(node, result) { } function barryPlugin(node, result) { - return { ...result, barry: 'barry barry' }; + const hasDefaultParams = + Object.values(result.defaults).filter(Boolean).length > 0; + + return { ...result, barry: 'barry barry', hasDefaultParams }; } -const result = parseFunction(bobbyPlugin.toString(), { +const result = parseFunction(fooFn, { parse: acornParse, - plugins: [bobbyPlugin, barryPlugin], // supports array of plugins + plugins: [bobbyPlugin, barryPlugin], parserOptions: {}, }); console.log(result); /* { - name: 'bobbyPlugin', - body: "\n const bobby = 'bobby';\n\n return { ...result, bobby };\n", - args: [ 'node', 'result' ], - params: 'node, result', - defaults: { node: undefined, result: undefined }, - value: '(function bobbyPlugin(node, result) {\n const ' + - "bobby = 'bobby';\n\n return { ...result, bobby };\n" + - '})', + name: 'fooFn', + body: '\n return bar * baz;\n', + args: [ 'bar', 'baz' ], + params: 'bar, baz', + defaults: { bar: undefined, baz: '123' }, + value: '(function fooFn(bar, baz = 123) {\n return bar * baz;\n})', isValid: true, isArrow: false, isAsync: false, @@ -37,5 +42,6 @@ console.log(result); isGenerator: false, isExpression: false, bobby: 'bobby', - barry: 'barry barry' + barry: 'barry barry', + bhasDefaultParams: true } */ diff --git a/packages/parse-function/index.d.ts b/packages/parse-function/index.d.ts index fd9e960c..765bd8e6 100644 --- a/packages/parse-function/index.d.ts +++ b/packages/parse-function/index.d.ts @@ -1,4 +1,5 @@ import { ParserOptions } from '@babel/parser'; +import { File } from '@babel/types'; // eslint-disable-next-line @typescript-eslint/no-explicit-any type FnType = (...args: any) => any; @@ -9,7 +10,8 @@ export type Plugin = (node: any, result: Result) => Result | undefined; export type Plugins = Plugin | Array; export interface Options { - parse?(input: string, options?: ParserOptions): import('@babel/types').File; + parse?(input: string, options?: ParserOptions): File; + parseExpression?(input: string, options?: ParserOptions): File; parserOptions?: ParserOptions; plugins?: Plugins; } @@ -30,5 +32,4 @@ export interface Result { isExpression: boolean; } - -export function parseFunction(code: Input, options?: Options): Result +export function parseFunction(code: Input, options?: Options): Result; diff --git a/packages/parse-function/package.json b/packages/parse-function/package.json index 85890feb..f0d5dbd9 100644 --- a/packages/parse-function/package.json +++ b/packages/parse-function/package.json @@ -48,6 +48,9 @@ "utilities" ], "scripts": {}, + "peerDependencies": { + "@babel/types": "^7.6.3" + }, "dependencies": { "@babel/parser": "^7.6.4" }, diff --git a/packages/parse-function/src/index.js b/packages/parse-function/src/index.js index fbc46a3b..16ce82cb 100644 --- a/packages/parse-function/src/index.js +++ b/packages/parse-function/src/index.js @@ -1,15 +1,83 @@ -/* eslint-disable node/file-extension-in-import, import/extensions */ +/* eslint-disable node/file-extension-in-import, import/extensions, import/prefer-default-export */ import arrayify from 'arrify'; -import { parse as babelParse } from '@babel/parser'; import { setDefaults, getNode } from './utils.js'; import basePlugin from './plugins/initial.js'; -// eslint-disable-next-line import/prefer-default-export -export function parseFunction(code, options) { - const opts = { parse: babelParse, ...options }; - const result = setDefaults(code); +/** + * Parse a given `input` and returns a `Result` object + * with useful properties - such as `name`, `body` and `args`. + * By default it uses `@babel/parser` parser, but you can switch it by + * passing `options.parse` or `options.parseExpression`, for example `options.parse: acorn.parse`. + * In the below example will show how to use `acorn` parser, instead + * of the default one. + * + * @example + * import { parse as acornParse } from 'acorn'; + * import { parse as espreeParse } from 'espree'; + * import { parseFunction } from 'parse-function'; + * + * function fooFn(bar, baz = 123) { return bar * baz; }; + * + * const result1 = parseFunction(fooFn, { parse: acornParse }); + * console.log(result1); + * + * const result2 = parseFunction(fooFn, { + * parse: espreeParse, + * parserOptions: { + * ecmaVersion: 9, + * sourceType: 'module', + * ecmaFeatures: { jsx: true, globalReturn: true }, + * }, + * }); + * + * console.log('parsed with espree', result2); + * // => { + * // name: 'fooFn', + * // body: '\n return bar * baz;\n', + * // args: [ 'bar', 'baz' ], + * // params: 'bar, baz', + * // defaults: { bar: undefined, baz: '123' }, + * // value: '(function fooFn(bar, baz = 123) {\n return bar * baz;\n})', + * // isValid: true, + * // isArrow: false, + * // isAsync: false, + * // isNamed: true, + * // isAnonymous: false, + * // isGenerator: false, + * // isExpression: false, + * // bobby: 'bobby', + * // barry: 'barry barry', + * // hasDefaultParams: true + * // } + * + * function basicPlugin(node, result) { + * const bar = 'barry'; + * const hasDefaultParams = + * Object.values(result.defaults).filter(Boolean).length > 0; + * + * return { ...result, foo: 123, bar, hasDefaultParams }; + * } + * + * const resultWithPlugins = parseFunction(fooFn, { plugins: basicPlugin }); + * console.log(resultWithPlugins.name); // => 'fooFn' + * console.log(resultWithPlugins.foo); // => 123 + * console.log(resultWithPlugins.bar); // => 'barry' + * console.log(resultWithPlugins.hasDefaultParams); // => true + * + * @param {Function|String} `input` any kind of function or string to be parsed + * @param {Object} `options` directly passed to the parser - babylon, acorn, espree + * @param {Function} `options.parse` by default `@babel/parser`'s `.parse` or `.parseExpression`, + * @param {ParserOptions} `options.parserOptions` passed to the parser + * @param {Plugins} `options.plugins` a plugin function like `function plugin(node: Node, result: Result): Result {}` + * @return {Object} `result` see [result section](#result) for more info + * @name .parse + * @api public + */ +export function parseFunction(input, options) { + const opts = { ...options }; + const result = setDefaults(input); if (!result.isValid) { return result; @@ -27,12 +95,12 @@ export function parseFunction(code, options) { result.value = `{ ${result.value} }`; } - const node = getNode(result, opts); + const node = getNode(result, opts, opts.parse); const plugins = arrayify(opts.plugins); return [basePlugin, ...plugins].filter(Boolean).reduce((res, fn) => { const pluginResult = fn(node, { ...res }) || res; - return pluginResult; + return { ...res, ...pluginResult }; }, result); } diff --git a/packages/parse-function/src/utils.js b/packages/parse-function/src/utils.js index f02eb47b..7f12096a 100644 --- a/packages/parse-function/src/utils.js +++ b/packages/parse-function/src/utils.js @@ -62,12 +62,12 @@ export function setHiddenDefaults(result, code) { * @return node * @private */ -export function getNode(result, options) { +export function getNode(result, options, parse) { const opts = { ...options }; - if (typeof opts.parse === 'function') { + if (typeof parse === 'function') { result.value = `(${result.value})`; - const ast = opts.parse(result.value, opts.parserOptions); + const ast = parse(result.value, opts.parserOptions); const astBody = ast.body; const body = (ast.program && ast.program.body) || astBody; @@ -75,5 +75,7 @@ export function getNode(result, options) { return body[0].expression; } - return parseExpression(result.value, opts.parserOptions); + return typeof options.parseExpression === 'function' + ? options.parseExpression(result.value, opts.parserOptions) + : parseExpression(result.value, opts.parserOptions); } diff --git a/packages/parse-function/test/__snapshots__/index.js.snap b/packages/parse-function/test/__snapshots__/index.js.snap index 1220d83e..d4d36da3 100644 --- a/packages/parse-function/test/__snapshots__/index.js.snap +++ b/packages/parse-function/test/__snapshots__/index.js.snap @@ -1,12 +1,13 @@ // Jest Snapshot v1, https://goo.gl/fbAQLP -exports[`#1 - babel (default) - function (a = {foo: "ba)r", baz: 123}, cb, ...restArgs) {return a * 3} 1`] = ` +exports[`#1 - babel (.parseExpression) - function (a = {foo: "ba)r", baz: 123}, cb, ...restArgs) {return a * 3} 1`] = ` Object { "args": Array [ "a", "cb", "restArgs", ], + "barry": 223, "body": "return a * 3", "defaults": Object { "a": "{foo: \\"ba)r\\", baz: 123}", @@ -22,17 +23,19 @@ Object { "isValid": true, "name": null, "params": "a, cb, restArgs", - "value": "(function (a = {foo: \\"ba)r\\", baz: 123}, cb, ...restArgs) {return a * 3})", + "qux": 123, + "value": "function (a = {foo: \\"ba)r\\", baz: 123}, cb, ...restArgs) {return a * 3}", } `; -exports[`#2 - babel (default) - function (b, callback, ...restArgs) {callback(null, b + 3)} 1`] = ` +exports[`#2 - babel (.parseExpression) - function (b, callback, ...restArgs) {callback(null, b + 3)} 1`] = ` Object { "args": Array [ "b", "callback", "restArgs", ], + "barry": 223, "body": "callback(null, b + 3)", "defaults": Object { "b": undefined, @@ -48,15 +51,17 @@ Object { "isValid": true, "name": null, "params": "b, callback, restArgs", - "value": "(function (b, callback, ...restArgs) {callback(null, b + 3)})", + "qux": 123, + "value": "function (b, callback, ...restArgs) {callback(null, b + 3)}", } `; -exports[`#3 - babel (default) - function (c) {return c * 3} 1`] = ` +exports[`#3 - babel (.parseExpression) - function (c) {return c * 3} 1`] = ` Object { "args": Array [ "c", ], + "barry": 223, "body": "return c * 3", "defaults": Object { "c": undefined, @@ -70,15 +75,17 @@ Object { "isValid": true, "name": null, "params": "c", - "value": "(function (c) {return c * 3})", + "qux": 123, + "value": "function (c) {return c * 3}", } `; -exports[`#4 - babel (default) - function (...restArgs) {return 321} 1`] = ` +exports[`#4 - babel (.parseExpression) - function (...restArgs) {return 321} 1`] = ` Object { "args": Array [ "restArgs", ], + "barry": 223, "body": "return 321", "defaults": Object { "restArgs": undefined, @@ -92,13 +99,15 @@ Object { "isValid": true, "name": null, "params": "restArgs", - "value": "(function (...restArgs) {return 321})", + "qux": 123, + "value": "function (...restArgs) {return 321}", } `; -exports[`#5 - babel (default) - function () {} 1`] = ` +exports[`#5 - babel (.parseExpression) - function () {} 1`] = ` Object { "args": Array [], + "barry": 223, "body": "", "defaults": Object {}, "isAnonymous": true, @@ -110,15 +119,17 @@ Object { "isValid": true, "name": null, "params": "", - "value": "(function () {})", + "qux": 123, + "value": "function () {}", } `; -exports[`#6 - babel (default) - function (a = (true, false)) {} 1`] = ` +exports[`#6 - babel (.parseExpression) - function (a = (true, false)) {} 1`] = ` Object { "args": Array [ "a", ], + "barry": 223, "body": "", "defaults": Object { "a": "false", @@ -132,15 +143,17 @@ Object { "isValid": true, "name": null, "params": "a", - "value": "(function (a = (true, false)) {})", + "qux": 123, + "value": "function (a = (true, false)) {}", } `; -exports[`#7 - babel (default) - function (a = (true, null)) {} 1`] = ` +exports[`#7 - babel (.parseExpression) - function (a = (true, null)) {} 1`] = ` Object { "args": Array [ "a", ], + "barry": 223, "body": "", "defaults": Object { "a": "null", @@ -154,15 +167,17 @@ Object { "isValid": true, "name": null, "params": "a", - "value": "(function (a = (true, null)) {})", + "qux": 123, + "value": "function (a = (true, null)) {}", } `; -exports[`#8 - babel (default) - function (a = (true, "bar")) {} 1`] = ` +exports[`#8 - babel (.parseExpression) - function (a = (true, "bar")) {} 1`] = ` Object { "args": Array [ "a", ], + "barry": 223, "body": "", "defaults": Object { "a": "\\"bar\\"", @@ -176,16 +191,18 @@ Object { "isValid": true, "name": null, "params": "a", - "value": "(function (a = (true, \\"bar\\")) {})", + "qux": 123, + "value": "function (a = (true, \\"bar\\")) {}", } `; -exports[`#9 - babel (default) - function (a, b = (i++, true)) {} 1`] = ` +exports[`#9 - babel (.parseExpression) - function (a, b = (i++, true)) {} 1`] = ` Object { "args": Array [ "a", "b", ], + "barry": 223, "body": "", "defaults": Object { "a": undefined, @@ -200,15 +217,17 @@ Object { "isValid": true, "name": null, "params": "a, b", - "value": "(function (a, b = (i++, true)) {})", + "qux": 123, + "value": "function (a, b = (i++, true)) {}", } `; -exports[`#10 - babel (default) - function (a = 1) {} 1`] = ` +exports[`#10 - babel (.parseExpression) - function (a = 1) {} 1`] = ` Object { "args": Array [ "a", ], + "barry": 223, "body": "", "defaults": Object { "a": "1", @@ -222,17 +241,19 @@ Object { "isValid": true, "name": null, "params": "a", - "value": "(function (a = 1) {})", + "qux": 123, + "value": "function (a = 1) {}", } `; -exports[`#11 - babel (default) - function namedFn (a = {foo: "ba)r", baz: 123}, cb, ...restArgs) {return a * 3} 1`] = ` +exports[`#11 - babel (.parseExpression) - function namedFn (a = {foo: "ba)r", baz: 123}, cb, ...restArgs) {return a * 3} 1`] = ` Object { "args": Array [ "a", "cb", "restArgs", ], + "barry": 223, "body": "return a * 3", "defaults": Object { "a": "{foo: \\"ba)r\\", baz: 123}", @@ -248,17 +269,19 @@ Object { "isValid": true, "name": "namedFn", "params": "a, cb, restArgs", - "value": "(function namedFn (a = {foo: \\"ba)r\\", baz: 123}, cb, ...restArgs) {return a * 3})", + "qux": 123, + "value": "function namedFn (a = {foo: \\"ba)r\\", baz: 123}, cb, ...restArgs) {return a * 3}", } `; -exports[`#12 - babel (default) - function namedFn (b, callback, ...restArgs) {callback(null, b + 3)} 1`] = ` +exports[`#12 - babel (.parseExpression) - function namedFn (b, callback, ...restArgs) {callback(null, b + 3)} 1`] = ` Object { "args": Array [ "b", "callback", "restArgs", ], + "barry": 223, "body": "callback(null, b + 3)", "defaults": Object { "b": undefined, @@ -274,15 +297,17 @@ Object { "isValid": true, "name": "namedFn", "params": "b, callback, restArgs", - "value": "(function namedFn (b, callback, ...restArgs) {callback(null, b + 3)})", + "qux": 123, + "value": "function namedFn (b, callback, ...restArgs) {callback(null, b + 3)}", } `; -exports[`#13 - babel (default) - function namedFn (c) {return c * 3} 1`] = ` +exports[`#13 - babel (.parseExpression) - function namedFn (c) {return c * 3} 1`] = ` Object { "args": Array [ "c", ], + "barry": 223, "body": "return c * 3", "defaults": Object { "c": undefined, @@ -296,15 +321,17 @@ Object { "isValid": true, "name": "namedFn", "params": "c", - "value": "(function namedFn (c) {return c * 3})", + "qux": 123, + "value": "function namedFn (c) {return c * 3}", } `; -exports[`#14 - babel (default) - function namedFn (...restArgs) {return 321} 1`] = ` +exports[`#14 - babel (.parseExpression) - function namedFn (...restArgs) {return 321} 1`] = ` Object { "args": Array [ "restArgs", ], + "barry": 223, "body": "return 321", "defaults": Object { "restArgs": undefined, @@ -318,13 +345,15 @@ Object { "isValid": true, "name": "namedFn", "params": "restArgs", - "value": "(function namedFn (...restArgs) {return 321})", + "qux": 123, + "value": "function namedFn (...restArgs) {return 321}", } `; -exports[`#15 - babel (default) - function namedFn () {} 1`] = ` +exports[`#15 - babel (.parseExpression) - function namedFn () {} 1`] = ` Object { "args": Array [], + "barry": 223, "body": "", "defaults": Object {}, "isAnonymous": false, @@ -336,15 +365,17 @@ Object { "isValid": true, "name": "namedFn", "params": "", - "value": "(function namedFn () {})", + "qux": 123, + "value": "function namedFn () {}", } `; -exports[`#16 - babel (default) - function namedFn(a = (true, false)) {} 1`] = ` +exports[`#16 - babel (.parseExpression) - function namedFn(a = (true, false)) {} 1`] = ` Object { "args": Array [ "a", ], + "barry": 223, "body": "", "defaults": Object { "a": "false", @@ -358,15 +389,17 @@ Object { "isValid": true, "name": "namedFn", "params": "a", - "value": "(function namedFn(a = (true, false)) {})", + "qux": 123, + "value": "function namedFn(a = (true, false)) {}", } `; -exports[`#17 - babel (default) - function namedFn(a = (true, null)) {} 1`] = ` +exports[`#17 - babel (.parseExpression) - function namedFn(a = (true, null)) {} 1`] = ` Object { "args": Array [ "a", ], + "barry": 223, "body": "", "defaults": Object { "a": "null", @@ -380,15 +413,17 @@ Object { "isValid": true, "name": "namedFn", "params": "a", - "value": "(function namedFn(a = (true, null)) {})", + "qux": 123, + "value": "function namedFn(a = (true, null)) {}", } `; -exports[`#18 - babel (default) - function namedFn(a = (true, "bar")) {} 1`] = ` +exports[`#18 - babel (.parseExpression) - function namedFn(a = (true, "bar")) {} 1`] = ` Object { "args": Array [ "a", ], + "barry": 223, "body": "", "defaults": Object { "a": "\\"bar\\"", @@ -402,16 +437,18 @@ Object { "isValid": true, "name": "namedFn", "params": "a", - "value": "(function namedFn(a = (true, \\"bar\\")) {})", + "qux": 123, + "value": "function namedFn(a = (true, \\"bar\\")) {}", } `; -exports[`#19 - babel (default) - function namedFn(a, b = (i++, true)) {} 1`] = ` +exports[`#19 - babel (.parseExpression) - function namedFn(a, b = (i++, true)) {} 1`] = ` Object { "args": Array [ "a", "b", ], + "barry": 223, "body": "", "defaults": Object { "a": undefined, @@ -426,15 +463,17 @@ Object { "isValid": true, "name": "namedFn", "params": "a, b", - "value": "(function namedFn(a, b = (i++, true)) {})", + "qux": 123, + "value": "function namedFn(a, b = (i++, true)) {}", } `; -exports[`#20 - babel (default) - function namedFn(a = 1) {} 1`] = ` +exports[`#20 - babel (.parseExpression) - function namedFn(a = 1) {} 1`] = ` Object { "args": Array [ "a", ], + "barry": 223, "body": "", "defaults": Object { "a": "1", @@ -448,17 +487,19 @@ Object { "isValid": true, "name": "namedFn", "params": "a", - "value": "(function namedFn(a = 1) {})", + "qux": 123, + "value": "function namedFn(a = 1) {}", } `; -exports[`#21 - babel (default) - function * namedFn (a = {foo: "ba)r", baz: 123}, cb, ...restArgs) {return a * 3} 1`] = ` +exports[`#21 - babel (.parseExpression) - function * namedFn (a = {foo: "ba)r", baz: 123}, cb, ...restArgs) {return a * 3} 1`] = ` Object { "args": Array [ "a", "cb", "restArgs", ], + "barry": 223, "body": "return a * 3", "defaults": Object { "a": "{foo: \\"ba)r\\", baz: 123}", @@ -474,17 +515,19 @@ Object { "isValid": true, "name": "namedFn", "params": "a, cb, restArgs", - "value": "(function * namedFn (a = {foo: \\"ba)r\\", baz: 123}, cb, ...restArgs) {return a * 3})", + "qux": 123, + "value": "function * namedFn (a = {foo: \\"ba)r\\", baz: 123}, cb, ...restArgs) {return a * 3}", } `; -exports[`#22 - babel (default) - function * namedFn (b, callback, ...restArgs) {callback(null, b + 3)} 1`] = ` +exports[`#22 - babel (.parseExpression) - function * namedFn (b, callback, ...restArgs) {callback(null, b + 3)} 1`] = ` Object { "args": Array [ "b", "callback", "restArgs", ], + "barry": 223, "body": "callback(null, b + 3)", "defaults": Object { "b": undefined, @@ -500,15 +543,17 @@ Object { "isValid": true, "name": "namedFn", "params": "b, callback, restArgs", - "value": "(function * namedFn (b, callback, ...restArgs) {callback(null, b + 3)})", + "qux": 123, + "value": "function * namedFn (b, callback, ...restArgs) {callback(null, b + 3)}", } `; -exports[`#23 - babel (default) - function * namedFn (c) {return c * 3} 1`] = ` +exports[`#23 - babel (.parseExpression) - function * namedFn (c) {return c * 3} 1`] = ` Object { "args": Array [ "c", ], + "barry": 223, "body": "return c * 3", "defaults": Object { "c": undefined, @@ -522,15 +567,17 @@ Object { "isValid": true, "name": "namedFn", "params": "c", - "value": "(function * namedFn (c) {return c * 3})", + "qux": 123, + "value": "function * namedFn (c) {return c * 3}", } `; -exports[`#24 - babel (default) - function * namedFn (...restArgs) {return 321} 1`] = ` +exports[`#24 - babel (.parseExpression) - function * namedFn (...restArgs) {return 321} 1`] = ` Object { "args": Array [ "restArgs", ], + "barry": 223, "body": "return 321", "defaults": Object { "restArgs": undefined, @@ -544,13 +591,15 @@ Object { "isValid": true, "name": "namedFn", "params": "restArgs", - "value": "(function * namedFn (...restArgs) {return 321})", + "qux": 123, + "value": "function * namedFn (...restArgs) {return 321}", } `; -exports[`#25 - babel (default) - function * namedFn () {} 1`] = ` +exports[`#25 - babel (.parseExpression) - function * namedFn () {} 1`] = ` Object { "args": Array [], + "barry": 223, "body": "", "defaults": Object {}, "isAnonymous": false, @@ -562,15 +611,17 @@ Object { "isValid": true, "name": "namedFn", "params": "", - "value": "(function * namedFn () {})", + "qux": 123, + "value": "function * namedFn () {}", } `; -exports[`#26 - babel (default) - function * namedFn(a = (true, false)) {} 1`] = ` +exports[`#26 - babel (.parseExpression) - function * namedFn(a = (true, false)) {} 1`] = ` Object { "args": Array [ "a", ], + "barry": 223, "body": "", "defaults": Object { "a": "false", @@ -584,15 +635,17 @@ Object { "isValid": true, "name": "namedFn", "params": "a", - "value": "(function * namedFn(a = (true, false)) {})", + "qux": 123, + "value": "function * namedFn(a = (true, false)) {}", } `; -exports[`#27 - babel (default) - function * namedFn(a = (true, null)) {} 1`] = ` +exports[`#27 - babel (.parseExpression) - function * namedFn(a = (true, null)) {} 1`] = ` Object { "args": Array [ "a", ], + "barry": 223, "body": "", "defaults": Object { "a": "null", @@ -606,15 +659,17 @@ Object { "isValid": true, "name": "namedFn", "params": "a", - "value": "(function * namedFn(a = (true, null)) {})", + "qux": 123, + "value": "function * namedFn(a = (true, null)) {}", } `; -exports[`#28 - babel (default) - function * namedFn(a = (true, "bar")) {} 1`] = ` +exports[`#28 - babel (.parseExpression) - function * namedFn(a = (true, "bar")) {} 1`] = ` Object { "args": Array [ "a", ], + "barry": 223, "body": "", "defaults": Object { "a": "\\"bar\\"", @@ -628,16 +683,18 @@ Object { "isValid": true, "name": "namedFn", "params": "a", - "value": "(function * namedFn(a = (true, \\"bar\\")) {})", + "qux": 123, + "value": "function * namedFn(a = (true, \\"bar\\")) {}", } `; -exports[`#29 - babel (default) - function * namedFn(a, b = (i++, true)) {} 1`] = ` +exports[`#29 - babel (.parseExpression) - function * namedFn(a, b = (i++, true)) {} 1`] = ` Object { "args": Array [ "a", "b", ], + "barry": 223, "body": "", "defaults": Object { "a": undefined, @@ -652,15 +709,17 @@ Object { "isValid": true, "name": "namedFn", "params": "a, b", - "value": "(function * namedFn(a, b = (i++, true)) {})", + "qux": 123, + "value": "function * namedFn(a, b = (i++, true)) {}", } `; -exports[`#30 - babel (default) - function * namedFn(a = 1) {} 1`] = ` +exports[`#30 - babel (.parseExpression) - function * namedFn(a = 1) {} 1`] = ` Object { "args": Array [ "a", ], + "barry": 223, "body": "", "defaults": Object { "a": "1", @@ -674,17 +733,19 @@ Object { "isValid": true, "name": "namedFn", "params": "a", - "value": "(function * namedFn(a = 1) {})", + "qux": 123, + "value": "function * namedFn(a = 1) {}", } `; -exports[`#31 - babel (default) - (a = {foo: "ba)r", baz: 123}, cb, ...restArgs) => {return a * 3} 1`] = ` +exports[`#31 - babel (.parseExpression) - a = {foo: "ba)r", baz: 123}, cb, ...restArgs) => {return a * 3} 1`] = ` Object { "args": Array [ "a", "cb", "restArgs", ], + "barry": 223, "body": "return a * 3", "defaults": Object { "a": "{foo: \\"ba)r\\", baz: 123}", @@ -700,17 +761,19 @@ Object { "isValid": true, "name": null, "params": "a, cb, restArgs", - "value": "((a = {foo: \\"ba)r\\", baz: 123}, cb, ...restArgs) => {return a * 3})", + "qux": 123, + "value": "(a = {foo: \\"ba)r\\", baz: 123}, cb, ...restArgs) => {return a * 3}", } `; -exports[`#32 - babel (default) - (b, callback, ...restArgs) => {callback(null, b + 3)} 1`] = ` +exports[`#32 - babel (.parseExpression) - b, callback, ...restArgs) => {callback(null, b + 3)} 1`] = ` Object { "args": Array [ "b", "callback", "restArgs", ], + "barry": 223, "body": "callback(null, b + 3)", "defaults": Object { "b": undefined, @@ -726,15 +789,17 @@ Object { "isValid": true, "name": null, "params": "b, callback, restArgs", - "value": "((b, callback, ...restArgs) => {callback(null, b + 3)})", + "qux": 123, + "value": "(b, callback, ...restArgs) => {callback(null, b + 3)}", } `; -exports[`#33 - babel (default) - (c) => {return c * 3} 1`] = ` +exports[`#33 - babel (.parseExpression) - c) => {return c * 3} 1`] = ` Object { "args": Array [ "c", ], + "barry": 223, "body": "return c * 3", "defaults": Object { "c": undefined, @@ -748,15 +813,17 @@ Object { "isValid": true, "name": null, "params": "c", - "value": "((c) => {return c * 3})", + "qux": 123, + "value": "(c) => {return c * 3}", } `; -exports[`#34 - babel (default) - (...restArgs) => {return 321} 1`] = ` +exports[`#34 - babel (.parseExpression) - ...restArgs) => {return 321} 1`] = ` Object { "args": Array [ "restArgs", ], + "barry": 223, "body": "return 321", "defaults": Object { "restArgs": undefined, @@ -770,13 +837,15 @@ Object { "isValid": true, "name": null, "params": "restArgs", - "value": "((...restArgs) => {return 321})", + "qux": 123, + "value": "(...restArgs) => {return 321}", } `; -exports[`#35 - babel (default) - () => {} 1`] = ` +exports[`#35 - babel (.parseExpression) - ) => {} 1`] = ` Object { "args": Array [], + "barry": 223, "body": "", "defaults": Object {}, "isAnonymous": true, @@ -788,15 +857,17 @@ Object { "isValid": true, "name": null, "params": "", - "value": "(() => {})", + "qux": 123, + "value": "() => {}", } `; -exports[`#36 - babel (default) - (a = (true, false)) => {} 1`] = ` +exports[`#36 - babel (.parseExpression) - a = (true, false)) => {} 1`] = ` Object { "args": Array [ "a", ], + "barry": 223, "body": "", "defaults": Object { "a": "false", @@ -810,15 +881,17 @@ Object { "isValid": true, "name": null, "params": "a", - "value": "((a = (true, false)) => {})", + "qux": 123, + "value": "(a = (true, false)) => {}", } `; -exports[`#37 - babel (default) - (a = (true, null)) => {} 1`] = ` +exports[`#37 - babel (.parseExpression) - a = (true, null)) => {} 1`] = ` Object { "args": Array [ "a", ], + "barry": 223, "body": "", "defaults": Object { "a": "null", @@ -832,15 +905,17 @@ Object { "isValid": true, "name": null, "params": "a", - "value": "((a = (true, null)) => {})", + "qux": 123, + "value": "(a = (true, null)) => {}", } `; -exports[`#38 - babel (default) - (a = (true, "bar")) => {} 1`] = ` +exports[`#38 - babel (.parseExpression) - a = (true, "bar")) => {} 1`] = ` Object { "args": Array [ "a", ], + "barry": 223, "body": "", "defaults": Object { "a": "\\"bar\\"", @@ -854,16 +929,18 @@ Object { "isValid": true, "name": null, "params": "a", - "value": "((a = (true, \\"bar\\")) => {})", + "qux": 123, + "value": "(a = (true, \\"bar\\")) => {}", } `; -exports[`#39 - babel (default) - (a, b = (i++, true)) => {} 1`] = ` +exports[`#39 - babel (.parseExpression) - a, b = (i++, true)) => {} 1`] = ` Object { "args": Array [ "a", "b", ], + "barry": 223, "body": "", "defaults": Object { "a": undefined, @@ -878,15 +955,17 @@ Object { "isValid": true, "name": null, "params": "a, b", - "value": "((a, b = (i++, true)) => {})", + "qux": 123, + "value": "(a, b = (i++, true)) => {}", } `; -exports[`#40 - babel (default) - (a = 1) => {} 1`] = ` +exports[`#40 - babel (.parseExpression) - a = 1) => {} 1`] = ` Object { "args": Array [ "a", ], + "barry": 223, "body": "", "defaults": Object { "a": "1", @@ -900,15 +979,17 @@ Object { "isValid": true, "name": null, "params": "a", - "value": "((a = 1) => {})", + "qux": 123, + "value": "(a = 1) => {}", } `; -exports[`#41 - babel (default) - (a) => a * 3 * a 1`] = ` +exports[`#41 - babel (.parseExpression) - a) => a * 3 * a 1`] = ` Object { "args": Array [ "a", ], + "barry": 223, "body": "a * 3 * a", "defaults": Object { "a": undefined, @@ -922,15 +1003,17 @@ Object { "isValid": true, "name": null, "params": "a", - "value": "((a) => a * 3 * a)", + "qux": 123, + "value": "(a) => a * 3 * a", } `; -exports[`#42 - babel (default) - d => d * 355 * d 1`] = ` +exports[`#42 - babel (.parseExpression) - d => d * 355 * d 1`] = ` Object { "args": Array [ "d", ], + "barry": 223, "body": "d * 355 * d", "defaults": Object { "d": undefined, @@ -944,15 +1027,17 @@ Object { "isValid": true, "name": null, "params": "d", - "value": "(d => d * 355 * d)", + "qux": 123, + "value": "d => d * 355 * d", } `; -exports[`#43 - babel (default) - e => {return e + 5235 / e} 1`] = ` +exports[`#43 - babel (.parseExpression) - e => {return e + 5235 / e} 1`] = ` Object { "args": Array [ "e", ], + "barry": 223, "body": "return e + 5235 / e", "defaults": Object { "e": undefined, @@ -966,16 +1051,18 @@ Object { "isValid": true, "name": null, "params": "e", - "value": "(e => {return e + 5235 / e})", + "qux": 123, + "value": "e => {return e + 5235 / e}", } `; -exports[`#44 - babel (default) - (a, b) => a + 3 + b 1`] = ` +exports[`#44 - babel (.parseExpression) - a, b) => a + 3 + b 1`] = ` Object { "args": Array [ "a", "b", ], + "barry": 223, "body": "a + 3 + b", "defaults": Object { "a": undefined, @@ -990,17 +1077,19 @@ Object { "isValid": true, "name": null, "params": "a, b", - "value": "((a, b) => a + 3 + b)", + "qux": 123, + "value": "(a, b) => a + 3 + b", } `; -exports[`#45 - babel (default) - (x, y, ...restArgs) => console.log({ value: x * y }) 1`] = ` +exports[`#45 - babel (.parseExpression) - x, y, ...restArgs) => console.log({ value: x * y } 1`] = ` Object { "args": Array [ "x", "y", "restArgs", ], + "barry": 223, "body": "console.log({ value: x * y })", "defaults": Object { "restArgs": undefined, @@ -1016,17 +1105,19 @@ Object { "isValid": true, "name": null, "params": "x, y, restArgs", - "value": "((x, y, ...restArgs) => console.log({ value: x * y }))", + "qux": 123, + "value": "(x, y, ...restArgs) => console.log({ value: x * y })", } `; -exports[`#46 - babel (default) - async function (a = {foo: "ba)r", baz: 123}, cb, ...restArgs) {return a * 3} 1`] = ` +exports[`#46 - babel (.parseExpression) - async function (a = {foo: "ba)r", baz: 123}, cb, ...restArgs) {return a * 3} 1`] = ` Object { "args": Array [ "a", "cb", "restArgs", ], + "barry": 223, "body": "return a * 3", "defaults": Object { "a": "{foo: \\"ba)r\\", baz: 123}", @@ -1042,17 +1133,19 @@ Object { "isValid": true, "name": null, "params": "a, cb, restArgs", - "value": "(async function (a = {foo: \\"ba)r\\", baz: 123}, cb, ...restArgs) {return a * 3})", + "qux": 123, + "value": "async function (a = {foo: \\"ba)r\\", baz: 123}, cb, ...restArgs) {return a * 3}", } `; -exports[`#47 - babel (default) - async function (b, callback, ...restArgs) {callback(null, b + 3)} 1`] = ` +exports[`#47 - babel (.parseExpression) - async function (b, callback, ...restArgs) {callback(null, b + 3)} 1`] = ` Object { "args": Array [ "b", "callback", "restArgs", ], + "barry": 223, "body": "callback(null, b + 3)", "defaults": Object { "b": undefined, @@ -1068,15 +1161,17 @@ Object { "isValid": true, "name": null, "params": "b, callback, restArgs", - "value": "(async function (b, callback, ...restArgs) {callback(null, b + 3)})", + "qux": 123, + "value": "async function (b, callback, ...restArgs) {callback(null, b + 3)}", } `; -exports[`#48 - babel (default) - async function (c) {return c * 3} 1`] = ` +exports[`#48 - babel (.parseExpression) - async function (c) {return c * 3} 1`] = ` Object { "args": Array [ "c", ], + "barry": 223, "body": "return c * 3", "defaults": Object { "c": undefined, @@ -1090,15 +1185,17 @@ Object { "isValid": true, "name": null, "params": "c", - "value": "(async function (c) {return c * 3})", + "qux": 123, + "value": "async function (c) {return c * 3}", } `; -exports[`#49 - babel (default) - async function (...restArgs) {return 321} 1`] = ` +exports[`#49 - babel (.parseExpression) - async function (...restArgs) {return 321} 1`] = ` Object { "args": Array [ "restArgs", ], + "barry": 223, "body": "return 321", "defaults": Object { "restArgs": undefined, @@ -1112,13 +1209,15 @@ Object { "isValid": true, "name": null, "params": "restArgs", - "value": "(async function (...restArgs) {return 321})", + "qux": 123, + "value": "async function (...restArgs) {return 321}", } `; -exports[`#50 - babel (default) - async function () {} 1`] = ` +exports[`#50 - babel (.parseExpression) - async function () {} 1`] = ` Object { "args": Array [], + "barry": 223, "body": "", "defaults": Object {}, "isAnonymous": true, @@ -1130,15 +1229,17 @@ Object { "isValid": true, "name": null, "params": "", - "value": "(async function () {})", + "qux": 123, + "value": "async function () {}", } `; -exports[`#51 - babel (default) - async function (a = (true, false)) {} 1`] = ` +exports[`#51 - babel (.parseExpression) - async function (a = (true, false)) {} 1`] = ` Object { "args": Array [ "a", ], + "barry": 223, "body": "", "defaults": Object { "a": "false", @@ -1152,15 +1253,17 @@ Object { "isValid": true, "name": null, "params": "a", - "value": "(async function (a = (true, false)) {})", + "qux": 123, + "value": "async function (a = (true, false)) {}", } `; -exports[`#52 - babel (default) - async function (a = (true, null)) {} 1`] = ` +exports[`#52 - babel (.parseExpression) - async function (a = (true, null)) {} 1`] = ` Object { "args": Array [ "a", ], + "barry": 223, "body": "", "defaults": Object { "a": "null", @@ -1174,15 +1277,17 @@ Object { "isValid": true, "name": null, "params": "a", - "value": "(async function (a = (true, null)) {})", + "qux": 123, + "value": "async function (a = (true, null)) {}", } `; -exports[`#53 - babel (default) - async function (a = (true, "bar")) {} 1`] = ` +exports[`#53 - babel (.parseExpression) - async function (a = (true, "bar")) {} 1`] = ` Object { "args": Array [ "a", ], + "barry": 223, "body": "", "defaults": Object { "a": "\\"bar\\"", @@ -1196,16 +1301,18 @@ Object { "isValid": true, "name": null, "params": "a", - "value": "(async function (a = (true, \\"bar\\")) {})", + "qux": 123, + "value": "async function (a = (true, \\"bar\\")) {}", } `; -exports[`#54 - babel (default) - async function (a, b = (i++, true)) {} 1`] = ` +exports[`#54 - babel (.parseExpression) - async function (a, b = (i++, true)) {} 1`] = ` Object { "args": Array [ "a", "b", ], + "barry": 223, "body": "", "defaults": Object { "a": undefined, @@ -1220,15 +1327,17 @@ Object { "isValid": true, "name": null, "params": "a, b", - "value": "(async function (a, b = (i++, true)) {})", + "qux": 123, + "value": "async function (a, b = (i++, true)) {}", } `; -exports[`#55 - babel (default) - async function (a = 1) {} 1`] = ` +exports[`#55 - babel (.parseExpression) - async function (a = 1) {} 1`] = ` Object { "args": Array [ "a", ], + "barry": 223, "body": "", "defaults": Object { "a": "1", @@ -1242,17 +1351,19 @@ Object { "isValid": true, "name": null, "params": "a", - "value": "(async function (a = 1) {})", + "qux": 123, + "value": "async function (a = 1) {}", } `; -exports[`#56 - babel (default) - async function namedFn (a = {foo: "ba)r", baz: 123}, cb, ...restArgs) {return a * 3} 1`] = ` +exports[`#56 - babel (.parseExpression) - async function namedFn (a = {foo: "ba)r", baz: 123}, cb, ...restArgs) {return a * 3} 1`] = ` Object { "args": Array [ "a", "cb", "restArgs", ], + "barry": 223, "body": "return a * 3", "defaults": Object { "a": "{foo: \\"ba)r\\", baz: 123}", @@ -1268,17 +1379,19 @@ Object { "isValid": true, "name": "namedFn", "params": "a, cb, restArgs", - "value": "(async function namedFn (a = {foo: \\"ba)r\\", baz: 123}, cb, ...restArgs) {return a * 3})", + "qux": 123, + "value": "async function namedFn (a = {foo: \\"ba)r\\", baz: 123}, cb, ...restArgs) {return a * 3}", } `; -exports[`#57 - babel (default) - async function namedFn (b, callback, ...restArgs) {callback(null, b + 3)} 1`] = ` +exports[`#57 - babel (.parseExpression) - async function namedFn (b, callback, ...restArgs) {callback(null, b + 3)} 1`] = ` Object { "args": Array [ "b", "callback", "restArgs", ], + "barry": 223, "body": "callback(null, b + 3)", "defaults": Object { "b": undefined, @@ -1294,15 +1407,17 @@ Object { "isValid": true, "name": "namedFn", "params": "b, callback, restArgs", - "value": "(async function namedFn (b, callback, ...restArgs) {callback(null, b + 3)})", + "qux": 123, + "value": "async function namedFn (b, callback, ...restArgs) {callback(null, b + 3)}", } `; -exports[`#58 - babel (default) - async function namedFn (c) {return c * 3} 1`] = ` +exports[`#58 - babel (.parseExpression) - async function namedFn (c) {return c * 3} 1`] = ` Object { "args": Array [ "c", ], + "barry": 223, "body": "return c * 3", "defaults": Object { "c": undefined, @@ -1316,15 +1431,17 @@ Object { "isValid": true, "name": "namedFn", "params": "c", - "value": "(async function namedFn (c) {return c * 3})", + "qux": 123, + "value": "async function namedFn (c) {return c * 3}", } `; -exports[`#59 - babel (default) - async function namedFn (...restArgs) {return 321} 1`] = ` +exports[`#59 - babel (.parseExpression) - async function namedFn (...restArgs) {return 321} 1`] = ` Object { "args": Array [ "restArgs", ], + "barry": 223, "body": "return 321", "defaults": Object { "restArgs": undefined, @@ -1338,13 +1455,15 @@ Object { "isValid": true, "name": "namedFn", "params": "restArgs", - "value": "(async function namedFn (...restArgs) {return 321})", + "qux": 123, + "value": "async function namedFn (...restArgs) {return 321}", } `; -exports[`#60 - babel (default) - async function namedFn () {} 1`] = ` +exports[`#60 - babel (.parseExpression) - async function namedFn () {} 1`] = ` Object { "args": Array [], + "barry": 223, "body": "", "defaults": Object {}, "isAnonymous": false, @@ -1356,15 +1475,17 @@ Object { "isValid": true, "name": "namedFn", "params": "", - "value": "(async function namedFn () {})", + "qux": 123, + "value": "async function namedFn () {}", } `; -exports[`#61 - babel (default) - async function namedFn(a = (true, false)) {} 1`] = ` +exports[`#61 - babel (.parseExpression) - async function namedFn(a = (true, false)) {} 1`] = ` Object { "args": Array [ "a", ], + "barry": 223, "body": "", "defaults": Object { "a": "false", @@ -1378,15 +1499,17 @@ Object { "isValid": true, "name": "namedFn", "params": "a", - "value": "(async function namedFn(a = (true, false)) {})", + "qux": 123, + "value": "async function namedFn(a = (true, false)) {}", } `; -exports[`#62 - babel (default) - async function namedFn(a = (true, null)) {} 1`] = ` +exports[`#62 - babel (.parseExpression) - async function namedFn(a = (true, null)) {} 1`] = ` Object { "args": Array [ "a", ], + "barry": 223, "body": "", "defaults": Object { "a": "null", @@ -1400,15 +1523,17 @@ Object { "isValid": true, "name": "namedFn", "params": "a", - "value": "(async function namedFn(a = (true, null)) {})", + "qux": 123, + "value": "async function namedFn(a = (true, null)) {}", } `; -exports[`#63 - babel (default) - async function namedFn(a = (true, "bar")) {} 1`] = ` +exports[`#63 - babel (.parseExpression) - async function namedFn(a = (true, "bar")) {} 1`] = ` Object { "args": Array [ "a", ], + "barry": 223, "body": "", "defaults": Object { "a": "\\"bar\\"", @@ -1422,16 +1547,18 @@ Object { "isValid": true, "name": "namedFn", "params": "a", - "value": "(async function namedFn(a = (true, \\"bar\\")) {})", + "qux": 123, + "value": "async function namedFn(a = (true, \\"bar\\")) {}", } `; -exports[`#64 - babel (default) - async function namedFn(a, b = (i++, true)) {} 1`] = ` +exports[`#64 - babel (.parseExpression) - async function namedFn(a, b = (i++, true)) {} 1`] = ` Object { "args": Array [ "a", "b", ], + "barry": 223, "body": "", "defaults": Object { "a": undefined, @@ -1446,15 +1573,17 @@ Object { "isValid": true, "name": "namedFn", "params": "a, b", - "value": "(async function namedFn(a, b = (i++, true)) {})", + "qux": 123, + "value": "async function namedFn(a, b = (i++, true)) {}", } `; -exports[`#65 - babel (default) - async function namedFn(a = 1) {} 1`] = ` +exports[`#65 - babel (.parseExpression) - async function namedFn(a = 1) {} 1`] = ` Object { "args": Array [ "a", ], + "barry": 223, "body": "", "defaults": Object { "a": "1", @@ -1468,17 +1597,19 @@ Object { "isValid": true, "name": "namedFn", "params": "a", - "value": "(async function namedFn(a = 1) {})", + "qux": 123, + "value": "async function namedFn(a = 1) {}", } `; -exports[`#66 - babel (default) - async (a = {foo: "ba)r", baz: 123}, cb, ...restArgs) => {return a * 3} 1`] = ` +exports[`#66 - babel (.parseExpression) - async (a = {foo: "ba)r", baz: 123}, cb, ...restArgs) => {return a * 3} 1`] = ` Object { "args": Array [ "a", "cb", "restArgs", ], + "barry": 223, "body": "return a * 3", "defaults": Object { "a": "{foo: \\"ba)r\\", baz: 123}", @@ -1494,17 +1625,19 @@ Object { "isValid": true, "name": null, "params": "a, cb, restArgs", - "value": "(async (a = {foo: \\"ba)r\\", baz: 123}, cb, ...restArgs) => {return a * 3})", + "qux": 123, + "value": "async (a = {foo: \\"ba)r\\", baz: 123}, cb, ...restArgs) => {return a * 3}", } `; -exports[`#67 - babel (default) - async (b, callback, ...restArgs) => {callback(null, b + 3)} 1`] = ` +exports[`#67 - babel (.parseExpression) - async (b, callback, ...restArgs) => {callback(null, b + 3)} 1`] = ` Object { "args": Array [ "b", "callback", "restArgs", ], + "barry": 223, "body": "callback(null, b + 3)", "defaults": Object { "b": undefined, @@ -1520,15 +1653,17 @@ Object { "isValid": true, "name": null, "params": "b, callback, restArgs", - "value": "(async (b, callback, ...restArgs) => {callback(null, b + 3)})", + "qux": 123, + "value": "async (b, callback, ...restArgs) => {callback(null, b + 3)}", } `; -exports[`#68 - babel (default) - async (c) => {return c * 3} 1`] = ` +exports[`#68 - babel (.parseExpression) - async (c) => {return c * 3} 1`] = ` Object { "args": Array [ "c", ], + "barry": 223, "body": "return c * 3", "defaults": Object { "c": undefined, @@ -1542,15 +1677,17 @@ Object { "isValid": true, "name": null, "params": "c", - "value": "(async (c) => {return c * 3})", + "qux": 123, + "value": "async (c) => {return c * 3}", } `; -exports[`#69 - babel (default) - async (...restArgs) => {return 321} 1`] = ` +exports[`#69 - babel (.parseExpression) - async (...restArgs) => {return 321} 1`] = ` Object { "args": Array [ "restArgs", ], + "barry": 223, "body": "return 321", "defaults": Object { "restArgs": undefined, @@ -1564,13 +1701,15 @@ Object { "isValid": true, "name": null, "params": "restArgs", - "value": "(async (...restArgs) => {return 321})", + "qux": 123, + "value": "async (...restArgs) => {return 321}", } `; -exports[`#70 - babel (default) - async () => {} 1`] = ` +exports[`#70 - babel (.parseExpression) - async () => {} 1`] = ` Object { "args": Array [], + "barry": 223, "body": "", "defaults": Object {}, "isAnonymous": true, @@ -1582,15 +1721,17 @@ Object { "isValid": true, "name": null, "params": "", - "value": "(async () => {})", + "qux": 123, + "value": "async () => {}", } `; -exports[`#71 - babel (default) - async (a = (true, false)) => {} 1`] = ` +exports[`#71 - babel (.parseExpression) - async (a = (true, false)) => {} 1`] = ` Object { "args": Array [ "a", ], + "barry": 223, "body": "", "defaults": Object { "a": "false", @@ -1604,15 +1745,17 @@ Object { "isValid": true, "name": null, "params": "a", - "value": "(async (a = (true, false)) => {})", + "qux": 123, + "value": "async (a = (true, false)) => {}", } `; -exports[`#72 - babel (default) - async (a = (true, null)) => {} 1`] = ` +exports[`#72 - babel (.parseExpression) - async (a = (true, null)) => {} 1`] = ` Object { "args": Array [ "a", ], + "barry": 223, "body": "", "defaults": Object { "a": "null", @@ -1626,15 +1769,17 @@ Object { "isValid": true, "name": null, "params": "a", - "value": "(async (a = (true, null)) => {})", + "qux": 123, + "value": "async (a = (true, null)) => {}", } `; -exports[`#73 - babel (default) - async (a = (true, "bar")) => {} 1`] = ` +exports[`#73 - babel (.parseExpression) - async (a = (true, "bar")) => {} 1`] = ` Object { "args": Array [ "a", ], + "barry": 223, "body": "", "defaults": Object { "a": "\\"bar\\"", @@ -1648,16 +1793,18 @@ Object { "isValid": true, "name": null, "params": "a", - "value": "(async (a = (true, \\"bar\\")) => {})", + "qux": 123, + "value": "async (a = (true, \\"bar\\")) => {}", } `; -exports[`#74 - babel (default) - async (a, b = (i++, true)) => {} 1`] = ` +exports[`#74 - babel (.parseExpression) - async (a, b = (i++, true)) => {} 1`] = ` Object { "args": Array [ "a", "b", ], + "barry": 223, "body": "", "defaults": Object { "a": undefined, @@ -1672,15 +1819,17 @@ Object { "isValid": true, "name": null, "params": "a, b", - "value": "(async (a, b = (i++, true)) => {})", + "qux": 123, + "value": "async (a, b = (i++, true)) => {}", } `; -exports[`#75 - babel (default) - async (a = 1) => {} 1`] = ` +exports[`#75 - babel (.parseExpression) - async (a = 1) => {} 1`] = ` Object { "args": Array [ "a", ], + "barry": 223, "body": "", "defaults": Object { "a": "1", @@ -1694,15 +1843,17 @@ Object { "isValid": true, "name": null, "params": "a", - "value": "(async (a = 1) => {})", + "qux": 123, + "value": "async (a = 1) => {}", } `; -exports[`#76 - babel (default) - async (a) => a * 3 * a 1`] = ` +exports[`#76 - babel (.parseExpression) - async (a) => a * 3 * a 1`] = ` Object { "args": Array [ "a", ], + "barry": 223, "body": "a * 3 * a", "defaults": Object { "a": undefined, @@ -1716,15 +1867,17 @@ Object { "isValid": true, "name": null, "params": "a", - "value": "(async (a) => a * 3 * a)", + "qux": 123, + "value": "async (a) => a * 3 * a", } `; -exports[`#77 - babel (default) - async d => d * 355 * d 1`] = ` +exports[`#77 - babel (.parseExpression) - async d => d * 355 * d 1`] = ` Object { "args": Array [ "d", ], + "barry": 223, "body": "d * 355 * d", "defaults": Object { "d": undefined, @@ -1738,15 +1891,17 @@ Object { "isValid": true, "name": null, "params": "d", - "value": "(async d => d * 355 * d)", + "qux": 123, + "value": "async d => d * 355 * d", } `; -exports[`#78 - babel (default) - async e => {return e + 5235 / e} 1`] = ` +exports[`#78 - babel (.parseExpression) - async e => {return e + 5235 / e} 1`] = ` Object { "args": Array [ "e", ], + "barry": 223, "body": "return e + 5235 / e", "defaults": Object { "e": undefined, @@ -1760,16 +1915,18 @@ Object { "isValid": true, "name": null, "params": "e", - "value": "(async e => {return e + 5235 / e})", + "qux": 123, + "value": "async e => {return e + 5235 / e}", } `; -exports[`#79 - babel (default) - async (a, b) => a + 3 + b 1`] = ` +exports[`#79 - babel (.parseExpression) - async (a, b) => a + 3 + b 1`] = ` Object { "args": Array [ "a", "b", ], + "barry": 223, "body": "a + 3 + b", "defaults": Object { "a": undefined, @@ -1784,17 +1941,19 @@ Object { "isValid": true, "name": null, "params": "a, b", - "value": "(async (a, b) => a + 3 + b)", + "qux": 123, + "value": "async (a, b) => a + 3 + b", } `; -exports[`#80 - babel (default) - async (x, y, ...restArgs) => console.log({ value: x * y }) 1`] = ` +exports[`#80 - babel (.parseExpression) - async (x, y, ...restArgs) => console.log({ value: x * y } 1`] = ` Object { "args": Array [ "x", "y", "restArgs", ], + "barry": 223, "body": "console.log({ value: x * y })", "defaults": Object { "restArgs": undefined, @@ -1810,11 +1969,12 @@ Object { "isValid": true, "name": null, "params": "x, y, restArgs", - "value": "(async (x, y, ...restArgs) => console.log({ value: x * y }))", + "qux": 123, + "value": "async (x, y, ...restArgs) => console.log({ value: x * y })", } `; -exports[`#81 - babel (default) - should return object with default values when invalid 1`] = ` +exports[`#81 - babel (.parseExpression) - should return object with default values when invalid 1`] = ` Object { "args": Array [], "body": "", @@ -1832,7 +1992,7 @@ Object { } `; -exports[`#82 - babel (default) - should have '.isValid' and few '.is*'' hidden properties 1`] = ` +exports[`#82 - babel (.parseExpression) - should have '.isValid' and few '.is*'' hidden properties 1`] = ` Object { "args": Array [], "body": "", @@ -1850,7 +2010,7 @@ Object { } `; -exports[`#87 - babel (default) - should work for object methods 1`] = ` +exports[`#87 - babel (.parseExpression) - should work for object methods 1`] = ` Object { "args": Array [ "a", @@ -1858,8 +2018,8 @@ Object { "c", ], "body": " - return a + b + c; - ", + return a + b + c; + ", "defaults": Object { "a": undefined, "b": undefined, @@ -1874,20 +2034,20 @@ Object { "isValid": true, "name": "foo", "params": "a, b, c", - "value": "({ foo(a, b, c) { - return a + b + c; - } })", + "value": "{ foo(a, b, c) { + return a + b + c; + } }", } `; -exports[`#87 - babel (default) - should work for object methods 2`] = ` +exports[`#87 - babel (.parseExpression) - should work for object methods 2`] = ` Object { "args": Array [ "a", ], "body": " - return () => a; - ", + return () => a; + ", "defaults": Object { "a": undefined, }, @@ -1900,20 +2060,20 @@ Object { "isValid": true, "name": "bar", "params": "a", - "value": "({ bar(a) { - return () => a; - } })", + "value": "{ bar(a) { + return () => a; + } }", } `; -exports[`#87 - babel (default) - should work for object methods 3`] = ` +exports[`#87 - babel (.parseExpression) - should work for object methods 3`] = ` Object { "args": Array [ "a", ], "body": " - return yield a * 321; - ", + return yield a * 321; + ", "defaults": Object { "a": undefined, }, @@ -1926,13 +2086,13 @@ Object { "isValid": true, "name": "gen", "params": "a", - "value": "({ *gen(a) { - return yield a * 321; - } })", + "value": "{ *gen(a) { + return yield a * 321; + } }", } `; -exports[`#87 - babel (default) - should work for object methods 4`] = ` +exports[`#87 - babel (.parseExpression) - should work for object methods 4`] = ` Object { "args": Array [ "a", @@ -1954,17 +2114,18 @@ Object { "isValid": true, "name": "namedFn", "params": "a, cb, restArgs", - "value": "({ namedFn (a = {foo: 'ba)r', baz: 123}, cb, ...restArgs) { return a * 3 } })", + "value": "{ namedFn (a = {foo: 'ba)r', baz: 123}, cb, ...restArgs) { return a * 3 } }", } `; -exports[`#91 - options.parse - function (a = {foo: "ba)r", baz: 123}, cb, ...restArgs) {return a * 3} 1`] = ` +exports[`#91 - options.parse: babel.parse - function (a = {foo: "ba)r", baz: 123}, cb, ...restArgs) {return a * 3} 1`] = ` Object { "args": Array [ "a", "cb", "restArgs", ], + "barry": 223, "body": "return a * 3", "defaults": Object { "a": "{foo: \\"ba)r\\", baz: 123}", @@ -1980,17 +2141,19 @@ Object { "isValid": true, "name": null, "params": "a, cb, restArgs", + "qux": 123, "value": "(function (a = {foo: \\"ba)r\\", baz: 123}, cb, ...restArgs) {return a * 3})", } `; -exports[`#92 - options.parse - function (b, callback, ...restArgs) {callback(null, b + 3)} 1`] = ` +exports[`#92 - options.parse: babel.parse - function (b, callback, ...restArgs) {callback(null, b + 3)} 1`] = ` Object { "args": Array [ "b", "callback", "restArgs", ], + "barry": 223, "body": "callback(null, b + 3)", "defaults": Object { "b": undefined, @@ -2006,15 +2169,17 @@ Object { "isValid": true, "name": null, "params": "b, callback, restArgs", + "qux": 123, "value": "(function (b, callback, ...restArgs) {callback(null, b + 3)})", } `; -exports[`#93 - options.parse - function (c) {return c * 3} 1`] = ` +exports[`#93 - options.parse: babel.parse - function (c) {return c * 3} 1`] = ` Object { "args": Array [ "c", ], + "barry": 223, "body": "return c * 3", "defaults": Object { "c": undefined, @@ -2028,15 +2193,17 @@ Object { "isValid": true, "name": null, "params": "c", + "qux": 123, "value": "(function (c) {return c * 3})", } `; -exports[`#94 - options.parse - function (...restArgs) {return 321} 1`] = ` +exports[`#94 - options.parse: babel.parse - function (...restArgs) {return 321} 1`] = ` Object { "args": Array [ "restArgs", ], + "barry": 223, "body": "return 321", "defaults": Object { "restArgs": undefined, @@ -2050,13 +2217,15 @@ Object { "isValid": true, "name": null, "params": "restArgs", + "qux": 123, "value": "(function (...restArgs) {return 321})", } `; -exports[`#95 - options.parse - function () {} 1`] = ` +exports[`#95 - options.parse: babel.parse - function () {} 1`] = ` Object { "args": Array [], + "barry": 223, "body": "", "defaults": Object {}, "isAnonymous": true, @@ -2068,15 +2237,17 @@ Object { "isValid": true, "name": null, "params": "", + "qux": 123, "value": "(function () {})", } `; -exports[`#96 - options.parse - function (a = (true, false)) {} 1`] = ` +exports[`#96 - options.parse: babel.parse - function (a = (true, false)) {} 1`] = ` Object { "args": Array [ "a", ], + "barry": 223, "body": "", "defaults": Object { "a": "false", @@ -2090,15 +2261,17 @@ Object { "isValid": true, "name": null, "params": "a", + "qux": 123, "value": "(function (a = (true, false)) {})", } `; -exports[`#97 - options.parse - function (a = (true, null)) {} 1`] = ` +exports[`#97 - options.parse: babel.parse - function (a = (true, null)) {} 1`] = ` Object { "args": Array [ "a", ], + "barry": 223, "body": "", "defaults": Object { "a": "null", @@ -2112,15 +2285,17 @@ Object { "isValid": true, "name": null, "params": "a", + "qux": 123, "value": "(function (a = (true, null)) {})", } `; -exports[`#98 - options.parse - function (a = (true, "bar")) {} 1`] = ` +exports[`#98 - options.parse: babel.parse - function (a = (true, "bar")) {} 1`] = ` Object { "args": Array [ "a", ], + "barry": 223, "body": "", "defaults": Object { "a": "\\"bar\\"", @@ -2134,16 +2309,18 @@ Object { "isValid": true, "name": null, "params": "a", + "qux": 123, "value": "(function (a = (true, \\"bar\\")) {})", } `; -exports[`#99 - options.parse - function (a, b = (i++, true)) {} 1`] = ` +exports[`#99 - options.parse: babel.parse - function (a, b = (i++, true)) {} 1`] = ` Object { "args": Array [ "a", "b", ], + "barry": 223, "body": "", "defaults": Object { "a": undefined, @@ -2158,15 +2335,17 @@ Object { "isValid": true, "name": null, "params": "a, b", + "qux": 123, "value": "(function (a, b = (i++, true)) {})", } `; -exports[`#100 - options.parse - function (a = 1) {} 1`] = ` +exports[`#100 - options.parse: babel.parse - function (a = 1) {} 1`] = ` Object { "args": Array [ "a", ], + "barry": 223, "body": "", "defaults": Object { "a": "1", @@ -2180,17 +2359,19 @@ Object { "isValid": true, "name": null, "params": "a", + "qux": 123, "value": "(function (a = 1) {})", } `; -exports[`#101 - options.parse - function namedFn (a = {foo: "ba)r", baz: 123}, cb, ...restArgs) {return a * 3} 1`] = ` +exports[`#101 - options.parse: babel.parse - function namedFn (a = {foo: "ba)r", baz: 123}, cb, ...restArgs) {return a * 3} 1`] = ` Object { "args": Array [ "a", "cb", "restArgs", ], + "barry": 223, "body": "return a * 3", "defaults": Object { "a": "{foo: \\"ba)r\\", baz: 123}", @@ -2206,17 +2387,19 @@ Object { "isValid": true, "name": "namedFn", "params": "a, cb, restArgs", + "qux": 123, "value": "(function namedFn (a = {foo: \\"ba)r\\", baz: 123}, cb, ...restArgs) {return a * 3})", } `; -exports[`#102 - options.parse - function namedFn (b, callback, ...restArgs) {callback(null, b + 3)} 1`] = ` +exports[`#102 - options.parse: babel.parse - function namedFn (b, callback, ...restArgs) {callback(null, b + 3)} 1`] = ` Object { "args": Array [ "b", "callback", "restArgs", ], + "barry": 223, "body": "callback(null, b + 3)", "defaults": Object { "b": undefined, @@ -2232,15 +2415,17 @@ Object { "isValid": true, "name": "namedFn", "params": "b, callback, restArgs", + "qux": 123, "value": "(function namedFn (b, callback, ...restArgs) {callback(null, b + 3)})", } `; -exports[`#103 - options.parse - function namedFn (c) {return c * 3} 1`] = ` +exports[`#103 - options.parse: babel.parse - function namedFn (c) {return c * 3} 1`] = ` Object { "args": Array [ "c", ], + "barry": 223, "body": "return c * 3", "defaults": Object { "c": undefined, @@ -2254,15 +2439,17 @@ Object { "isValid": true, "name": "namedFn", "params": "c", + "qux": 123, "value": "(function namedFn (c) {return c * 3})", } `; -exports[`#104 - options.parse - function namedFn (...restArgs) {return 321} 1`] = ` +exports[`#104 - options.parse: babel.parse - function namedFn (...restArgs) {return 321} 1`] = ` Object { "args": Array [ "restArgs", ], + "barry": 223, "body": "return 321", "defaults": Object { "restArgs": undefined, @@ -2276,13 +2463,15 @@ Object { "isValid": true, "name": "namedFn", "params": "restArgs", + "qux": 123, "value": "(function namedFn (...restArgs) {return 321})", } `; -exports[`#105 - options.parse - function namedFn () {} 1`] = ` +exports[`#105 - options.parse: babel.parse - function namedFn () {} 1`] = ` Object { "args": Array [], + "barry": 223, "body": "", "defaults": Object {}, "isAnonymous": false, @@ -2294,15 +2483,17 @@ Object { "isValid": true, "name": "namedFn", "params": "", + "qux": 123, "value": "(function namedFn () {})", } `; -exports[`#106 - options.parse - function namedFn(a = (true, false)) {} 1`] = ` +exports[`#106 - options.parse: babel.parse - function namedFn(a = (true, false)) {} 1`] = ` Object { "args": Array [ "a", ], + "barry": 223, "body": "", "defaults": Object { "a": "false", @@ -2316,15 +2507,17 @@ Object { "isValid": true, "name": "namedFn", "params": "a", + "qux": 123, "value": "(function namedFn(a = (true, false)) {})", } `; -exports[`#107 - options.parse - function namedFn(a = (true, null)) {} 1`] = ` +exports[`#107 - options.parse: babel.parse - function namedFn(a = (true, null)) {} 1`] = ` Object { "args": Array [ "a", ], + "barry": 223, "body": "", "defaults": Object { "a": "null", @@ -2338,15 +2531,17 @@ Object { "isValid": true, "name": "namedFn", "params": "a", + "qux": 123, "value": "(function namedFn(a = (true, null)) {})", } `; -exports[`#108 - options.parse - function namedFn(a = (true, "bar")) {} 1`] = ` +exports[`#108 - options.parse: babel.parse - function namedFn(a = (true, "bar")) {} 1`] = ` Object { "args": Array [ "a", ], + "barry": 223, "body": "", "defaults": Object { "a": "\\"bar\\"", @@ -2360,16 +2555,18 @@ Object { "isValid": true, "name": "namedFn", "params": "a", + "qux": 123, "value": "(function namedFn(a = (true, \\"bar\\")) {})", } `; -exports[`#109 - options.parse - function namedFn(a, b = (i++, true)) {} 1`] = ` +exports[`#109 - options.parse: babel.parse - function namedFn(a, b = (i++, true)) {} 1`] = ` Object { "args": Array [ "a", "b", ], + "barry": 223, "body": "", "defaults": Object { "a": undefined, @@ -2384,15 +2581,17 @@ Object { "isValid": true, "name": "namedFn", "params": "a, b", + "qux": 123, "value": "(function namedFn(a, b = (i++, true)) {})", } `; -exports[`#110 - options.parse - function namedFn(a = 1) {} 1`] = ` +exports[`#110 - options.parse: babel.parse - function namedFn(a = 1) {} 1`] = ` Object { "args": Array [ "a", ], + "barry": 223, "body": "", "defaults": Object { "a": "1", @@ -2406,17 +2605,19 @@ Object { "isValid": true, "name": "namedFn", "params": "a", + "qux": 123, "value": "(function namedFn(a = 1) {})", } `; -exports[`#111 - options.parse - function * namedFn (a = {foo: "ba)r", baz: 123}, cb, ...restArgs) {return a * 3} 1`] = ` +exports[`#111 - options.parse: babel.parse - function * namedFn (a = {foo: "ba)r", baz: 123}, cb, ...restArgs) {return a * 3} 1`] = ` Object { "args": Array [ "a", "cb", "restArgs", ], + "barry": 223, "body": "return a * 3", "defaults": Object { "a": "{foo: \\"ba)r\\", baz: 123}", @@ -2432,17 +2633,19 @@ Object { "isValid": true, "name": "namedFn", "params": "a, cb, restArgs", + "qux": 123, "value": "(function * namedFn (a = {foo: \\"ba)r\\", baz: 123}, cb, ...restArgs) {return a * 3})", } `; -exports[`#112 - options.parse - function * namedFn (b, callback, ...restArgs) {callback(null, b + 3)} 1`] = ` +exports[`#112 - options.parse: babel.parse - function * namedFn (b, callback, ...restArgs) {callback(null, b + 3)} 1`] = ` Object { "args": Array [ "b", "callback", "restArgs", ], + "barry": 223, "body": "callback(null, b + 3)", "defaults": Object { "b": undefined, @@ -2458,15 +2661,17 @@ Object { "isValid": true, "name": "namedFn", "params": "b, callback, restArgs", + "qux": 123, "value": "(function * namedFn (b, callback, ...restArgs) {callback(null, b + 3)})", } `; -exports[`#113 - options.parse - function * namedFn (c) {return c * 3} 1`] = ` +exports[`#113 - options.parse: babel.parse - function * namedFn (c) {return c * 3} 1`] = ` Object { "args": Array [ "c", ], + "barry": 223, "body": "return c * 3", "defaults": Object { "c": undefined, @@ -2480,15 +2685,17 @@ Object { "isValid": true, "name": "namedFn", "params": "c", + "qux": 123, "value": "(function * namedFn (c) {return c * 3})", } `; -exports[`#114 - options.parse - function * namedFn (...restArgs) {return 321} 1`] = ` +exports[`#114 - options.parse: babel.parse - function * namedFn (...restArgs) {return 321} 1`] = ` Object { "args": Array [ "restArgs", ], + "barry": 223, "body": "return 321", "defaults": Object { "restArgs": undefined, @@ -2502,13 +2709,15 @@ Object { "isValid": true, "name": "namedFn", "params": "restArgs", + "qux": 123, "value": "(function * namedFn (...restArgs) {return 321})", } `; -exports[`#115 - options.parse - function * namedFn () {} 1`] = ` +exports[`#115 - options.parse: babel.parse - function * namedFn () {} 1`] = ` Object { "args": Array [], + "barry": 223, "body": "", "defaults": Object {}, "isAnonymous": false, @@ -2520,15 +2729,17 @@ Object { "isValid": true, "name": "namedFn", "params": "", + "qux": 123, "value": "(function * namedFn () {})", } `; -exports[`#116 - options.parse - function * namedFn(a = (true, false)) {} 1`] = ` +exports[`#116 - options.parse: babel.parse - function * namedFn(a = (true, false)) {} 1`] = ` Object { "args": Array [ "a", ], + "barry": 223, "body": "", "defaults": Object { "a": "false", @@ -2542,15 +2753,17 @@ Object { "isValid": true, "name": "namedFn", "params": "a", + "qux": 123, "value": "(function * namedFn(a = (true, false)) {})", } `; -exports[`#117 - options.parse - function * namedFn(a = (true, null)) {} 1`] = ` +exports[`#117 - options.parse: babel.parse - function * namedFn(a = (true, null)) {} 1`] = ` Object { "args": Array [ "a", ], + "barry": 223, "body": "", "defaults": Object { "a": "null", @@ -2564,15 +2777,17 @@ Object { "isValid": true, "name": "namedFn", "params": "a", + "qux": 123, "value": "(function * namedFn(a = (true, null)) {})", } `; -exports[`#118 - options.parse - function * namedFn(a = (true, "bar")) {} 1`] = ` +exports[`#118 - options.parse: babel.parse - function * namedFn(a = (true, "bar")) {} 1`] = ` Object { "args": Array [ "a", ], + "barry": 223, "body": "", "defaults": Object { "a": "\\"bar\\"", @@ -2586,16 +2801,18 @@ Object { "isValid": true, "name": "namedFn", "params": "a", + "qux": 123, "value": "(function * namedFn(a = (true, \\"bar\\")) {})", } `; -exports[`#119 - options.parse - function * namedFn(a, b = (i++, true)) {} 1`] = ` +exports[`#119 - options.parse: babel.parse - function * namedFn(a, b = (i++, true)) {} 1`] = ` Object { "args": Array [ "a", "b", ], + "barry": 223, "body": "", "defaults": Object { "a": undefined, @@ -2610,15 +2827,17 @@ Object { "isValid": true, "name": "namedFn", "params": "a, b", + "qux": 123, "value": "(function * namedFn(a, b = (i++, true)) {})", } `; -exports[`#120 - options.parse - function * namedFn(a = 1) {} 1`] = ` +exports[`#120 - options.parse: babel.parse - function * namedFn(a = 1) {} 1`] = ` Object { "args": Array [ "a", ], + "barry": 223, "body": "", "defaults": Object { "a": "1", @@ -2632,17 +2851,19 @@ Object { "isValid": true, "name": "namedFn", "params": "a", + "qux": 123, "value": "(function * namedFn(a = 1) {})", } `; -exports[`#121 - options.parse - (a = {foo: "ba)r", baz: 123}, cb, ...restArgs) => {return a * 3} 1`] = ` +exports[`#121 - options.parse: babel.parse - (a = {foo: "ba)r", baz: 123}, cb, ...restArgs) => {return a * 3} 1`] = ` Object { "args": Array [ "a", "cb", "restArgs", ], + "barry": 223, "body": "return a * 3", "defaults": Object { "a": "{foo: \\"ba)r\\", baz: 123}", @@ -2658,17 +2879,19 @@ Object { "isValid": true, "name": null, "params": "a, cb, restArgs", + "qux": 123, "value": "((a = {foo: \\"ba)r\\", baz: 123}, cb, ...restArgs) => {return a * 3})", } `; -exports[`#122 - options.parse - (b, callback, ...restArgs) => {callback(null, b + 3)} 1`] = ` +exports[`#122 - options.parse: babel.parse - (b, callback, ...restArgs) => {callback(null, b + 3)} 1`] = ` Object { "args": Array [ "b", "callback", "restArgs", ], + "barry": 223, "body": "callback(null, b + 3)", "defaults": Object { "b": undefined, @@ -2684,15 +2907,17 @@ Object { "isValid": true, "name": null, "params": "b, callback, restArgs", + "qux": 123, "value": "((b, callback, ...restArgs) => {callback(null, b + 3)})", } `; -exports[`#123 - options.parse - (c) => {return c * 3} 1`] = ` +exports[`#123 - options.parse: babel.parse - (c) => {return c * 3} 1`] = ` Object { "args": Array [ "c", ], + "barry": 223, "body": "return c * 3", "defaults": Object { "c": undefined, @@ -2706,15 +2931,17 @@ Object { "isValid": true, "name": null, "params": "c", + "qux": 123, "value": "((c) => {return c * 3})", } `; -exports[`#124 - options.parse - (...restArgs) => {return 321} 1`] = ` +exports[`#124 - options.parse: babel.parse - (...restArgs) => {return 321} 1`] = ` Object { "args": Array [ "restArgs", ], + "barry": 223, "body": "return 321", "defaults": Object { "restArgs": undefined, @@ -2728,13 +2955,15 @@ Object { "isValid": true, "name": null, "params": "restArgs", + "qux": 123, "value": "((...restArgs) => {return 321})", } `; -exports[`#125 - options.parse - () => {} 1`] = ` +exports[`#125 - options.parse: babel.parse - () => {} 1`] = ` Object { "args": Array [], + "barry": 223, "body": "", "defaults": Object {}, "isAnonymous": true, @@ -2746,15 +2975,17 @@ Object { "isValid": true, "name": null, "params": "", + "qux": 123, "value": "(() => {})", } `; -exports[`#126 - options.parse - (a = (true, false)) => {} 1`] = ` +exports[`#126 - options.parse: babel.parse - (a = (true, false)) => {} 1`] = ` Object { "args": Array [ "a", ], + "barry": 223, "body": "", "defaults": Object { "a": "false", @@ -2768,15 +2999,17 @@ Object { "isValid": true, "name": null, "params": "a", + "qux": 123, "value": "((a = (true, false)) => {})", } `; -exports[`#127 - options.parse - (a = (true, null)) => {} 1`] = ` +exports[`#127 - options.parse: babel.parse - (a = (true, null)) => {} 1`] = ` Object { "args": Array [ "a", ], + "barry": 223, "body": "", "defaults": Object { "a": "null", @@ -2790,15 +3023,17 @@ Object { "isValid": true, "name": null, "params": "a", + "qux": 123, "value": "((a = (true, null)) => {})", } `; -exports[`#128 - options.parse - (a = (true, "bar")) => {} 1`] = ` +exports[`#128 - options.parse: babel.parse - (a = (true, "bar")) => {} 1`] = ` Object { "args": Array [ "a", ], + "barry": 223, "body": "", "defaults": Object { "a": "\\"bar\\"", @@ -2812,16 +3047,18 @@ Object { "isValid": true, "name": null, "params": "a", + "qux": 123, "value": "((a = (true, \\"bar\\")) => {})", } `; -exports[`#129 - options.parse - (a, b = (i++, true)) => {} 1`] = ` +exports[`#129 - options.parse: babel.parse - (a, b = (i++, true)) => {} 1`] = ` Object { "args": Array [ "a", "b", ], + "barry": 223, "body": "", "defaults": Object { "a": undefined, @@ -2836,15 +3073,17 @@ Object { "isValid": true, "name": null, "params": "a, b", + "qux": 123, "value": "((a, b = (i++, true)) => {})", } `; -exports[`#130 - options.parse - (a = 1) => {} 1`] = ` +exports[`#130 - options.parse: babel.parse - (a = 1) => {} 1`] = ` Object { "args": Array [ "a", ], + "barry": 223, "body": "", "defaults": Object { "a": "1", @@ -2858,15 +3097,17 @@ Object { "isValid": true, "name": null, "params": "a", + "qux": 123, "value": "((a = 1) => {})", } `; -exports[`#131 - options.parse - (a) => a * 3 * a 1`] = ` +exports[`#131 - options.parse: babel.parse - (a) => a * 3 * a 1`] = ` Object { "args": Array [ "a", ], + "barry": 223, "body": "a * 3 * a", "defaults": Object { "a": undefined, @@ -2880,15 +3121,17 @@ Object { "isValid": true, "name": null, "params": "a", + "qux": 123, "value": "((a) => a * 3 * a)", } `; -exports[`#132 - options.parse - d => d * 355 * d 1`] = ` +exports[`#132 - options.parse: babel.parse - d => d * 355 * d 1`] = ` Object { "args": Array [ "d", ], + "barry": 223, "body": "d * 355 * d", "defaults": Object { "d": undefined, @@ -2902,15 +3145,17 @@ Object { "isValid": true, "name": null, "params": "d", + "qux": 123, "value": "(d => d * 355 * d)", } `; -exports[`#133 - options.parse - e => {return e + 5235 / e} 1`] = ` +exports[`#133 - options.parse: babel.parse - e => {return e + 5235 / e} 1`] = ` Object { "args": Array [ "e", ], + "barry": 223, "body": "return e + 5235 / e", "defaults": Object { "e": undefined, @@ -2924,16 +3169,18 @@ Object { "isValid": true, "name": null, "params": "e", + "qux": 123, "value": "(e => {return e + 5235 / e})", } `; -exports[`#134 - options.parse - (a, b) => a + 3 + b 1`] = ` +exports[`#134 - options.parse: babel.parse - (a, b) => a + 3 + b 1`] = ` Object { "args": Array [ "a", "b", ], + "barry": 223, "body": "a + 3 + b", "defaults": Object { "a": undefined, @@ -2948,17 +3195,19 @@ Object { "isValid": true, "name": null, "params": "a, b", + "qux": 123, "value": "((a, b) => a + 3 + b)", } `; -exports[`#135 - options.parse - (x, y, ...restArgs) => console.log({ value: x * y }) 1`] = ` +exports[`#135 - options.parse: babel.parse - (x, y, ...restArgs) => console.log({ value: x * y }) 1`] = ` Object { "args": Array [ "x", "y", "restArgs", ], + "barry": 223, "body": "console.log({ value: x * y })", "defaults": Object { "restArgs": undefined, @@ -2974,17 +3223,19 @@ Object { "isValid": true, "name": null, "params": "x, y, restArgs", + "qux": 123, "value": "((x, y, ...restArgs) => console.log({ value: x * y }))", } `; -exports[`#136 - options.parse - async function (a = {foo: "ba)r", baz: 123}, cb, ...restArgs) {return a * 3} 1`] = ` +exports[`#136 - options.parse: babel.parse - async function (a = {foo: "ba)r", baz: 123}, cb, ...restArgs) {return a * 3} 1`] = ` Object { "args": Array [ "a", "cb", "restArgs", ], + "barry": 223, "body": "return a * 3", "defaults": Object { "a": "{foo: \\"ba)r\\", baz: 123}", @@ -3000,17 +3251,19 @@ Object { "isValid": true, "name": null, "params": "a, cb, restArgs", + "qux": 123, "value": "(async function (a = {foo: \\"ba)r\\", baz: 123}, cb, ...restArgs) {return a * 3})", } `; -exports[`#137 - options.parse - async function (b, callback, ...restArgs) {callback(null, b + 3)} 1`] = ` +exports[`#137 - options.parse: babel.parse - async function (b, callback, ...restArgs) {callback(null, b + 3)} 1`] = ` Object { "args": Array [ "b", "callback", "restArgs", ], + "barry": 223, "body": "callback(null, b + 3)", "defaults": Object { "b": undefined, @@ -3026,15 +3279,17 @@ Object { "isValid": true, "name": null, "params": "b, callback, restArgs", + "qux": 123, "value": "(async function (b, callback, ...restArgs) {callback(null, b + 3)})", } `; -exports[`#138 - options.parse - async function (c) {return c * 3} 1`] = ` +exports[`#138 - options.parse: babel.parse - async function (c) {return c * 3} 1`] = ` Object { "args": Array [ "c", ], + "barry": 223, "body": "return c * 3", "defaults": Object { "c": undefined, @@ -3048,15 +3303,17 @@ Object { "isValid": true, "name": null, "params": "c", + "qux": 123, "value": "(async function (c) {return c * 3})", } `; -exports[`#139 - options.parse - async function (...restArgs) {return 321} 1`] = ` +exports[`#139 - options.parse: babel.parse - async function (...restArgs) {return 321} 1`] = ` Object { "args": Array [ "restArgs", ], + "barry": 223, "body": "return 321", "defaults": Object { "restArgs": undefined, @@ -3070,13 +3327,15 @@ Object { "isValid": true, "name": null, "params": "restArgs", + "qux": 123, "value": "(async function (...restArgs) {return 321})", } `; -exports[`#140 - options.parse - async function () {} 1`] = ` +exports[`#140 - options.parse: babel.parse - async function () {} 1`] = ` Object { "args": Array [], + "barry": 223, "body": "", "defaults": Object {}, "isAnonymous": true, @@ -3088,15 +3347,17 @@ Object { "isValid": true, "name": null, "params": "", + "qux": 123, "value": "(async function () {})", } `; -exports[`#141 - options.parse - async function (a = (true, false)) {} 1`] = ` +exports[`#141 - options.parse: babel.parse - async function (a = (true, false)) {} 1`] = ` Object { "args": Array [ "a", ], + "barry": 223, "body": "", "defaults": Object { "a": "false", @@ -3110,15 +3371,17 @@ Object { "isValid": true, "name": null, "params": "a", + "qux": 123, "value": "(async function (a = (true, false)) {})", } `; -exports[`#142 - options.parse - async function (a = (true, null)) {} 1`] = ` +exports[`#142 - options.parse: babel.parse - async function (a = (true, null)) {} 1`] = ` Object { "args": Array [ "a", ], + "barry": 223, "body": "", "defaults": Object { "a": "null", @@ -3132,15 +3395,17 @@ Object { "isValid": true, "name": null, "params": "a", + "qux": 123, "value": "(async function (a = (true, null)) {})", } `; -exports[`#143 - options.parse - async function (a = (true, "bar")) {} 1`] = ` +exports[`#143 - options.parse: babel.parse - async function (a = (true, "bar")) {} 1`] = ` Object { "args": Array [ "a", ], + "barry": 223, "body": "", "defaults": Object { "a": "\\"bar\\"", @@ -3154,16 +3419,18 @@ Object { "isValid": true, "name": null, "params": "a", + "qux": 123, "value": "(async function (a = (true, \\"bar\\")) {})", } `; -exports[`#144 - options.parse - async function (a, b = (i++, true)) {} 1`] = ` +exports[`#144 - options.parse: babel.parse - async function (a, b = (i++, true)) {} 1`] = ` Object { "args": Array [ "a", "b", ], + "barry": 223, "body": "", "defaults": Object { "a": undefined, @@ -3178,15 +3445,17 @@ Object { "isValid": true, "name": null, "params": "a, b", + "qux": 123, "value": "(async function (a, b = (i++, true)) {})", } `; -exports[`#145 - options.parse - async function (a = 1) {} 1`] = ` +exports[`#145 - options.parse: babel.parse - async function (a = 1) {} 1`] = ` Object { "args": Array [ "a", ], + "barry": 223, "body": "", "defaults": Object { "a": "1", @@ -3200,17 +3469,19 @@ Object { "isValid": true, "name": null, "params": "a", + "qux": 123, "value": "(async function (a = 1) {})", } `; -exports[`#146 - options.parse - async function namedFn (a = {foo: "ba)r", baz: 123}, cb, ...restArgs) {return a * 3} 1`] = ` +exports[`#146 - options.parse: babel.parse - async function namedFn (a = {foo: "ba)r", baz: 123}, cb, ...restArgs) {return a * 3} 1`] = ` Object { "args": Array [ "a", "cb", "restArgs", ], + "barry": 223, "body": "return a * 3", "defaults": Object { "a": "{foo: \\"ba)r\\", baz: 123}", @@ -3226,17 +3497,19 @@ Object { "isValid": true, "name": "namedFn", "params": "a, cb, restArgs", + "qux": 123, "value": "(async function namedFn (a = {foo: \\"ba)r\\", baz: 123}, cb, ...restArgs) {return a * 3})", } `; -exports[`#147 - options.parse - async function namedFn (b, callback, ...restArgs) {callback(null, b + 3)} 1`] = ` +exports[`#147 - options.parse: babel.parse - async function namedFn (b, callback, ...restArgs) {callback(null, b + 3)} 1`] = ` Object { "args": Array [ "b", "callback", "restArgs", ], + "barry": 223, "body": "callback(null, b + 3)", "defaults": Object { "b": undefined, @@ -3252,15 +3525,17 @@ Object { "isValid": true, "name": "namedFn", "params": "b, callback, restArgs", + "qux": 123, "value": "(async function namedFn (b, callback, ...restArgs) {callback(null, b + 3)})", } `; -exports[`#148 - options.parse - async function namedFn (c) {return c * 3} 1`] = ` +exports[`#148 - options.parse: babel.parse - async function namedFn (c) {return c * 3} 1`] = ` Object { "args": Array [ "c", ], + "barry": 223, "body": "return c * 3", "defaults": Object { "c": undefined, @@ -3274,15 +3549,17 @@ Object { "isValid": true, "name": "namedFn", "params": "c", + "qux": 123, "value": "(async function namedFn (c) {return c * 3})", } `; -exports[`#149 - options.parse - async function namedFn (...restArgs) {return 321} 1`] = ` +exports[`#149 - options.parse: babel.parse - async function namedFn (...restArgs) {return 321} 1`] = ` Object { "args": Array [ "restArgs", ], + "barry": 223, "body": "return 321", "defaults": Object { "restArgs": undefined, @@ -3296,13 +3573,15 @@ Object { "isValid": true, "name": "namedFn", "params": "restArgs", + "qux": 123, "value": "(async function namedFn (...restArgs) {return 321})", } `; -exports[`#150 - options.parse - async function namedFn () {} 1`] = ` +exports[`#150 - options.parse: babel.parse - async function namedFn () {} 1`] = ` Object { "args": Array [], + "barry": 223, "body": "", "defaults": Object {}, "isAnonymous": false, @@ -3314,15 +3593,17 @@ Object { "isValid": true, "name": "namedFn", "params": "", + "qux": 123, "value": "(async function namedFn () {})", } `; -exports[`#151 - options.parse - async function namedFn(a = (true, false)) {} 1`] = ` +exports[`#151 - options.parse: babel.parse - async function namedFn(a = (true, false)) {} 1`] = ` Object { "args": Array [ "a", ], + "barry": 223, "body": "", "defaults": Object { "a": "false", @@ -3336,15 +3617,17 @@ Object { "isValid": true, "name": "namedFn", "params": "a", + "qux": 123, "value": "(async function namedFn(a = (true, false)) {})", } `; -exports[`#152 - options.parse - async function namedFn(a = (true, null)) {} 1`] = ` +exports[`#152 - options.parse: babel.parse - async function namedFn(a = (true, null)) {} 1`] = ` Object { "args": Array [ "a", ], + "barry": 223, "body": "", "defaults": Object { "a": "null", @@ -3358,15 +3641,17 @@ Object { "isValid": true, "name": "namedFn", "params": "a", + "qux": 123, "value": "(async function namedFn(a = (true, null)) {})", } `; -exports[`#153 - options.parse - async function namedFn(a = (true, "bar")) {} 1`] = ` +exports[`#153 - options.parse: babel.parse - async function namedFn(a = (true, "bar")) {} 1`] = ` Object { "args": Array [ "a", ], + "barry": 223, "body": "", "defaults": Object { "a": "\\"bar\\"", @@ -3380,16 +3665,18 @@ Object { "isValid": true, "name": "namedFn", "params": "a", + "qux": 123, "value": "(async function namedFn(a = (true, \\"bar\\")) {})", } `; -exports[`#154 - options.parse - async function namedFn(a, b = (i++, true)) {} 1`] = ` +exports[`#154 - options.parse: babel.parse - async function namedFn(a, b = (i++, true)) {} 1`] = ` Object { "args": Array [ "a", "b", ], + "barry": 223, "body": "", "defaults": Object { "a": undefined, @@ -3404,15 +3691,17 @@ Object { "isValid": true, "name": "namedFn", "params": "a, b", + "qux": 123, "value": "(async function namedFn(a, b = (i++, true)) {})", } `; -exports[`#155 - options.parse - async function namedFn(a = 1) {} 1`] = ` +exports[`#155 - options.parse: babel.parse - async function namedFn(a = 1) {} 1`] = ` Object { "args": Array [ "a", ], + "barry": 223, "body": "", "defaults": Object { "a": "1", @@ -3426,17 +3715,19 @@ Object { "isValid": true, "name": "namedFn", "params": "a", + "qux": 123, "value": "(async function namedFn(a = 1) {})", } `; -exports[`#156 - options.parse - async (a = {foo: "ba)r", baz: 123}, cb, ...restArgs) => {return a * 3} 1`] = ` +exports[`#156 - options.parse: babel.parse - async (a = {foo: "ba)r", baz: 123}, cb, ...restArgs) => {return a * 3} 1`] = ` Object { "args": Array [ "a", "cb", "restArgs", ], + "barry": 223, "body": "return a * 3", "defaults": Object { "a": "{foo: \\"ba)r\\", baz: 123}", @@ -3452,17 +3743,19 @@ Object { "isValid": true, "name": null, "params": "a, cb, restArgs", + "qux": 123, "value": "(async (a = {foo: \\"ba)r\\", baz: 123}, cb, ...restArgs) => {return a * 3})", } `; -exports[`#157 - options.parse - async (b, callback, ...restArgs) => {callback(null, b + 3)} 1`] = ` +exports[`#157 - options.parse: babel.parse - async (b, callback, ...restArgs) => {callback(null, b + 3)} 1`] = ` Object { "args": Array [ "b", "callback", "restArgs", ], + "barry": 223, "body": "callback(null, b + 3)", "defaults": Object { "b": undefined, @@ -3478,15 +3771,17 @@ Object { "isValid": true, "name": null, "params": "b, callback, restArgs", + "qux": 123, "value": "(async (b, callback, ...restArgs) => {callback(null, b + 3)})", } `; -exports[`#158 - options.parse - async (c) => {return c * 3} 1`] = ` +exports[`#158 - options.parse: babel.parse - async (c) => {return c * 3} 1`] = ` Object { "args": Array [ "c", ], + "barry": 223, "body": "return c * 3", "defaults": Object { "c": undefined, @@ -3500,15 +3795,17 @@ Object { "isValid": true, "name": null, "params": "c", + "qux": 123, "value": "(async (c) => {return c * 3})", } `; -exports[`#159 - options.parse - async (...restArgs) => {return 321} 1`] = ` +exports[`#159 - options.parse: babel.parse - async (...restArgs) => {return 321} 1`] = ` Object { "args": Array [ "restArgs", ], + "barry": 223, "body": "return 321", "defaults": Object { "restArgs": undefined, @@ -3522,13 +3819,15 @@ Object { "isValid": true, "name": null, "params": "restArgs", + "qux": 123, "value": "(async (...restArgs) => {return 321})", } `; -exports[`#160 - options.parse - async () => {} 1`] = ` +exports[`#160 - options.parse: babel.parse - async () => {} 1`] = ` Object { "args": Array [], + "barry": 223, "body": "", "defaults": Object {}, "isAnonymous": true, @@ -3540,15 +3839,17 @@ Object { "isValid": true, "name": null, "params": "", + "qux": 123, "value": "(async () => {})", } `; -exports[`#161 - options.parse - async (a = (true, false)) => {} 1`] = ` +exports[`#161 - options.parse: babel.parse - async (a = (true, false)) => {} 1`] = ` Object { "args": Array [ "a", ], + "barry": 223, "body": "", "defaults": Object { "a": "false", @@ -3562,15 +3863,17 @@ Object { "isValid": true, "name": null, "params": "a", + "qux": 123, "value": "(async (a = (true, false)) => {})", } `; -exports[`#162 - options.parse - async (a = (true, null)) => {} 1`] = ` +exports[`#162 - options.parse: babel.parse - async (a = (true, null)) => {} 1`] = ` Object { "args": Array [ "a", ], + "barry": 223, "body": "", "defaults": Object { "a": "null", @@ -3584,15 +3887,17 @@ Object { "isValid": true, "name": null, "params": "a", + "qux": 123, "value": "(async (a = (true, null)) => {})", } `; -exports[`#163 - options.parse - async (a = (true, "bar")) => {} 1`] = ` +exports[`#163 - options.parse: babel.parse - async (a = (true, "bar")) => {} 1`] = ` Object { "args": Array [ "a", ], + "barry": 223, "body": "", "defaults": Object { "a": "\\"bar\\"", @@ -3606,16 +3911,18 @@ Object { "isValid": true, "name": null, "params": "a", + "qux": 123, "value": "(async (a = (true, \\"bar\\")) => {})", } `; -exports[`#164 - options.parse - async (a, b = (i++, true)) => {} 1`] = ` +exports[`#164 - options.parse: babel.parse - async (a, b = (i++, true)) => {} 1`] = ` Object { "args": Array [ "a", "b", ], + "barry": 223, "body": "", "defaults": Object { "a": undefined, @@ -3630,15 +3937,17 @@ Object { "isValid": true, "name": null, "params": "a, b", + "qux": 123, "value": "(async (a, b = (i++, true)) => {})", } `; -exports[`#165 - options.parse - async (a = 1) => {} 1`] = ` +exports[`#165 - options.parse: babel.parse - async (a = 1) => {} 1`] = ` Object { "args": Array [ "a", ], + "barry": 223, "body": "", "defaults": Object { "a": "1", @@ -3652,15 +3961,17 @@ Object { "isValid": true, "name": null, "params": "a", + "qux": 123, "value": "(async (a = 1) => {})", } `; -exports[`#166 - options.parse - async (a) => a * 3 * a 1`] = ` +exports[`#166 - options.parse: babel.parse - async (a) => a * 3 * a 1`] = ` Object { "args": Array [ "a", ], + "barry": 223, "body": "a * 3 * a", "defaults": Object { "a": undefined, @@ -3674,15 +3985,17 @@ Object { "isValid": true, "name": null, "params": "a", + "qux": 123, "value": "(async (a) => a * 3 * a)", } `; -exports[`#167 - options.parse - async d => d * 355 * d 1`] = ` +exports[`#167 - options.parse: babel.parse - async d => d * 355 * d 1`] = ` Object { "args": Array [ "d", ], + "barry": 223, "body": "d * 355 * d", "defaults": Object { "d": undefined, @@ -3696,15 +4009,17 @@ Object { "isValid": true, "name": null, "params": "d", + "qux": 123, "value": "(async d => d * 355 * d)", } `; -exports[`#168 - options.parse - async e => {return e + 5235 / e} 1`] = ` +exports[`#168 - options.parse: babel.parse - async e => {return e + 5235 / e} 1`] = ` Object { "args": Array [ "e", ], + "barry": 223, "body": "return e + 5235 / e", "defaults": Object { "e": undefined, @@ -3718,16 +4033,18 @@ Object { "isValid": true, "name": null, "params": "e", + "qux": 123, "value": "(async e => {return e + 5235 / e})", } `; -exports[`#169 - options.parse - async (a, b) => a + 3 + b 1`] = ` +exports[`#169 - options.parse: babel.parse - async (a, b) => a + 3 + b 1`] = ` Object { "args": Array [ "a", "b", ], + "barry": 223, "body": "a + 3 + b", "defaults": Object { "a": undefined, @@ -3742,17 +4059,19 @@ Object { "isValid": true, "name": null, "params": "a, b", + "qux": 123, "value": "(async (a, b) => a + 3 + b)", } `; -exports[`#170 - options.parse - async (x, y, ...restArgs) => console.log({ value: x * y }) 1`] = ` +exports[`#170 - options.parse: babel.parse - async (x, y, ...restArgs) => console.log({ value: x * y }) 1`] = ` Object { "args": Array [ "x", "y", "restArgs", ], + "barry": 223, "body": "console.log({ value: x * y })", "defaults": Object { "restArgs": undefined, @@ -3768,11 +4087,12 @@ Object { "isValid": true, "name": null, "params": "x, y, restArgs", + "qux": 123, "value": "(async (x, y, ...restArgs) => console.log({ value: x * y }))", } `; -exports[`#171 - options.parse - should return object with default values when invalid 1`] = ` +exports[`#171 - options.parse: babel.parse - should return object with default values when invalid 1`] = ` Object { "args": Array [], "body": "", @@ -3790,7 +4110,7 @@ Object { } `; -exports[`#172 - options.parse - should have '.isValid' and few '.is*'' hidden properties 1`] = ` +exports[`#172 - options.parse: babel.parse - should have '.isValid' and few '.is*'' hidden properties 1`] = ` Object { "args": Array [], "body": "", @@ -3808,7 +4128,7 @@ Object { } `; -exports[`#177 - options.parse - should work for object methods 1`] = ` +exports[`#177 - options.parse: babel.parse - should work for object methods 1`] = ` Object { "args": Array [ "a", @@ -3816,8 +4136,8 @@ Object { "c", ], "body": " - return a + b + c; - ", + return a + b + c; + ", "defaults": Object { "a": undefined, "b": undefined, @@ -3833,19 +4153,19 @@ Object { "name": "foo", "params": "a, b, c", "value": "({ foo(a, b, c) { - return a + b + c; - } })", + return a + b + c; + } })", } `; -exports[`#177 - options.parse - should work for object methods 2`] = ` +exports[`#177 - options.parse: babel.parse - should work for object methods 2`] = ` Object { "args": Array [ "a", ], "body": " - return () => a; - ", + return () => a; + ", "defaults": Object { "a": undefined, }, @@ -3859,19 +4179,19 @@ Object { "name": "bar", "params": "a", "value": "({ bar(a) { - return () => a; - } })", + return () => a; + } })", } `; -exports[`#177 - options.parse - should work for object methods 3`] = ` +exports[`#177 - options.parse: babel.parse - should work for object methods 3`] = ` Object { "args": Array [ "a", ], "body": " - return yield a * 321; - ", + return yield a * 321; + ", "defaults": Object { "a": undefined, }, @@ -3885,12 +4205,12 @@ Object { "name": "gen", "params": "a", "value": "({ *gen(a) { - return yield a * 321; - } })", + return yield a * 321; + } })", } `; -exports[`#177 - options.parse - should work for object methods 4`] = ` +exports[`#177 - options.parse: babel.parse - should work for object methods 4`] = ` Object { "args": Array [ "a", @@ -3923,6 +4243,7 @@ Object { "cb", "restArgs", ], + "barry": 223, "body": "return a * 3", "defaults": Object { "a": "{foo: \\"ba)r\\", baz: 123}", @@ -3938,6 +4259,7 @@ Object { "isValid": true, "name": null, "params": "a, cb, restArgs", + "qux": 123, "value": "(function (a = {foo: \\"ba)r\\", baz: 123}, cb, ...restArgs) {return a * 3})", } `; @@ -3949,6 +4271,7 @@ Object { "callback", "restArgs", ], + "barry": 223, "body": "callback(null, b + 3)", "defaults": Object { "b": undefined, @@ -3964,6 +4287,7 @@ Object { "isValid": true, "name": null, "params": "b, callback, restArgs", + "qux": 123, "value": "(function (b, callback, ...restArgs) {callback(null, b + 3)})", } `; @@ -3973,6 +4297,7 @@ Object { "args": Array [ "c", ], + "barry": 223, "body": "return c * 3", "defaults": Object { "c": undefined, @@ -3986,6 +4311,7 @@ Object { "isValid": true, "name": null, "params": "c", + "qux": 123, "value": "(function (c) {return c * 3})", } `; @@ -3995,6 +4321,7 @@ Object { "args": Array [ "restArgs", ], + "barry": 223, "body": "return 321", "defaults": Object { "restArgs": undefined, @@ -4008,6 +4335,7 @@ Object { "isValid": true, "name": null, "params": "restArgs", + "qux": 123, "value": "(function (...restArgs) {return 321})", } `; @@ -4015,6 +4343,7 @@ Object { exports[`#185 - acorn.parse - function () {} 1`] = ` Object { "args": Array [], + "barry": 223, "body": "", "defaults": Object {}, "isAnonymous": true, @@ -4026,6 +4355,7 @@ Object { "isValid": true, "name": null, "params": "", + "qux": 123, "value": "(function () {})", } `; @@ -4035,6 +4365,7 @@ Object { "args": Array [ "a", ], + "barry": 223, "body": "", "defaults": Object { "a": "false", @@ -4048,6 +4379,7 @@ Object { "isValid": true, "name": null, "params": "a", + "qux": 123, "value": "(function (a = (true, false)) {})", } `; @@ -4057,6 +4389,7 @@ Object { "args": Array [ "a", ], + "barry": 223, "body": "", "defaults": Object { "a": "null", @@ -4070,6 +4403,7 @@ Object { "isValid": true, "name": null, "params": "a", + "qux": 123, "value": "(function (a = (true, null)) {})", } `; @@ -4079,6 +4413,7 @@ Object { "args": Array [ "a", ], + "barry": 223, "body": "", "defaults": Object { "a": "\\"bar\\"", @@ -4092,6 +4427,7 @@ Object { "isValid": true, "name": null, "params": "a", + "qux": 123, "value": "(function (a = (true, \\"bar\\")) {})", } `; @@ -4102,6 +4438,7 @@ Object { "a", "b", ], + "barry": 223, "body": "", "defaults": Object { "a": undefined, @@ -4116,6 +4453,7 @@ Object { "isValid": true, "name": null, "params": "a, b", + "qux": 123, "value": "(function (a, b = (i++, true)) {})", } `; @@ -4125,6 +4463,7 @@ Object { "args": Array [ "a", ], + "barry": 223, "body": "", "defaults": Object { "a": "1", @@ -4138,6 +4477,7 @@ Object { "isValid": true, "name": null, "params": "a", + "qux": 123, "value": "(function (a = 1) {})", } `; @@ -4149,6 +4489,7 @@ Object { "cb", "restArgs", ], + "barry": 223, "body": "return a * 3", "defaults": Object { "a": "{foo: \\"ba)r\\", baz: 123}", @@ -4164,6 +4505,7 @@ Object { "isValid": true, "name": "namedFn", "params": "a, cb, restArgs", + "qux": 123, "value": "(function namedFn (a = {foo: \\"ba)r\\", baz: 123}, cb, ...restArgs) {return a * 3})", } `; @@ -4175,6 +4517,7 @@ Object { "callback", "restArgs", ], + "barry": 223, "body": "callback(null, b + 3)", "defaults": Object { "b": undefined, @@ -4190,6 +4533,7 @@ Object { "isValid": true, "name": "namedFn", "params": "b, callback, restArgs", + "qux": 123, "value": "(function namedFn (b, callback, ...restArgs) {callback(null, b + 3)})", } `; @@ -4199,6 +4543,7 @@ Object { "args": Array [ "c", ], + "barry": 223, "body": "return c * 3", "defaults": Object { "c": undefined, @@ -4212,6 +4557,7 @@ Object { "isValid": true, "name": "namedFn", "params": "c", + "qux": 123, "value": "(function namedFn (c) {return c * 3})", } `; @@ -4221,6 +4567,7 @@ Object { "args": Array [ "restArgs", ], + "barry": 223, "body": "return 321", "defaults": Object { "restArgs": undefined, @@ -4234,6 +4581,7 @@ Object { "isValid": true, "name": "namedFn", "params": "restArgs", + "qux": 123, "value": "(function namedFn (...restArgs) {return 321})", } `; @@ -4241,6 +4589,7 @@ Object { exports[`#195 - acorn.parse - function namedFn () {} 1`] = ` Object { "args": Array [], + "barry": 223, "body": "", "defaults": Object {}, "isAnonymous": false, @@ -4252,6 +4601,7 @@ Object { "isValid": true, "name": "namedFn", "params": "", + "qux": 123, "value": "(function namedFn () {})", } `; @@ -4261,6 +4611,7 @@ Object { "args": Array [ "a", ], + "barry": 223, "body": "", "defaults": Object { "a": "false", @@ -4274,6 +4625,7 @@ Object { "isValid": true, "name": "namedFn", "params": "a", + "qux": 123, "value": "(function namedFn(a = (true, false)) {})", } `; @@ -4283,6 +4635,7 @@ Object { "args": Array [ "a", ], + "barry": 223, "body": "", "defaults": Object { "a": "null", @@ -4296,6 +4649,7 @@ Object { "isValid": true, "name": "namedFn", "params": "a", + "qux": 123, "value": "(function namedFn(a = (true, null)) {})", } `; @@ -4305,6 +4659,7 @@ Object { "args": Array [ "a", ], + "barry": 223, "body": "", "defaults": Object { "a": "\\"bar\\"", @@ -4318,6 +4673,7 @@ Object { "isValid": true, "name": "namedFn", "params": "a", + "qux": 123, "value": "(function namedFn(a = (true, \\"bar\\")) {})", } `; @@ -4328,6 +4684,7 @@ Object { "a", "b", ], + "barry": 223, "body": "", "defaults": Object { "a": undefined, @@ -4342,6 +4699,7 @@ Object { "isValid": true, "name": "namedFn", "params": "a, b", + "qux": 123, "value": "(function namedFn(a, b = (i++, true)) {})", } `; @@ -4351,6 +4709,7 @@ Object { "args": Array [ "a", ], + "barry": 223, "body": "", "defaults": Object { "a": "1", @@ -4364,6 +4723,7 @@ Object { "isValid": true, "name": "namedFn", "params": "a", + "qux": 123, "value": "(function namedFn(a = 1) {})", } `; @@ -4375,6 +4735,7 @@ Object { "cb", "restArgs", ], + "barry": 223, "body": "return a * 3", "defaults": Object { "a": "{foo: \\"ba)r\\", baz: 123}", @@ -4390,6 +4751,7 @@ Object { "isValid": true, "name": "namedFn", "params": "a, cb, restArgs", + "qux": 123, "value": "(function * namedFn (a = {foo: \\"ba)r\\", baz: 123}, cb, ...restArgs) {return a * 3})", } `; @@ -4401,6 +4763,7 @@ Object { "callback", "restArgs", ], + "barry": 223, "body": "callback(null, b + 3)", "defaults": Object { "b": undefined, @@ -4416,6 +4779,7 @@ Object { "isValid": true, "name": "namedFn", "params": "b, callback, restArgs", + "qux": 123, "value": "(function * namedFn (b, callback, ...restArgs) {callback(null, b + 3)})", } `; @@ -4425,6 +4789,7 @@ Object { "args": Array [ "c", ], + "barry": 223, "body": "return c * 3", "defaults": Object { "c": undefined, @@ -4438,6 +4803,7 @@ Object { "isValid": true, "name": "namedFn", "params": "c", + "qux": 123, "value": "(function * namedFn (c) {return c * 3})", } `; @@ -4447,6 +4813,7 @@ Object { "args": Array [ "restArgs", ], + "barry": 223, "body": "return 321", "defaults": Object { "restArgs": undefined, @@ -4460,6 +4827,7 @@ Object { "isValid": true, "name": "namedFn", "params": "restArgs", + "qux": 123, "value": "(function * namedFn (...restArgs) {return 321})", } `; @@ -4467,6 +4835,7 @@ Object { exports[`#205 - acorn.parse - function * namedFn () {} 1`] = ` Object { "args": Array [], + "barry": 223, "body": "", "defaults": Object {}, "isAnonymous": false, @@ -4478,6 +4847,7 @@ Object { "isValid": true, "name": "namedFn", "params": "", + "qux": 123, "value": "(function * namedFn () {})", } `; @@ -4487,6 +4857,7 @@ Object { "args": Array [ "a", ], + "barry": 223, "body": "", "defaults": Object { "a": "false", @@ -4500,6 +4871,7 @@ Object { "isValid": true, "name": "namedFn", "params": "a", + "qux": 123, "value": "(function * namedFn(a = (true, false)) {})", } `; @@ -4509,6 +4881,7 @@ Object { "args": Array [ "a", ], + "barry": 223, "body": "", "defaults": Object { "a": "null", @@ -4522,6 +4895,7 @@ Object { "isValid": true, "name": "namedFn", "params": "a", + "qux": 123, "value": "(function * namedFn(a = (true, null)) {})", } `; @@ -4531,6 +4905,7 @@ Object { "args": Array [ "a", ], + "barry": 223, "body": "", "defaults": Object { "a": "\\"bar\\"", @@ -4544,6 +4919,7 @@ Object { "isValid": true, "name": "namedFn", "params": "a", + "qux": 123, "value": "(function * namedFn(a = (true, \\"bar\\")) {})", } `; @@ -4554,6 +4930,7 @@ Object { "a", "b", ], + "barry": 223, "body": "", "defaults": Object { "a": undefined, @@ -4568,6 +4945,7 @@ Object { "isValid": true, "name": "namedFn", "params": "a, b", + "qux": 123, "value": "(function * namedFn(a, b = (i++, true)) {})", } `; @@ -4577,6 +4955,7 @@ Object { "args": Array [ "a", ], + "barry": 223, "body": "", "defaults": Object { "a": "1", @@ -4590,6 +4969,7 @@ Object { "isValid": true, "name": "namedFn", "params": "a", + "qux": 123, "value": "(function * namedFn(a = 1) {})", } `; @@ -4601,6 +4981,7 @@ Object { "cb", "restArgs", ], + "barry": 223, "body": "return a * 3", "defaults": Object { "a": "{foo: \\"ba)r\\", baz: 123}", @@ -4616,6 +4997,7 @@ Object { "isValid": true, "name": null, "params": "a, cb, restArgs", + "qux": 123, "value": "((a = {foo: \\"ba)r\\", baz: 123}, cb, ...restArgs) => {return a * 3})", } `; @@ -4627,6 +5009,7 @@ Object { "callback", "restArgs", ], + "barry": 223, "body": "callback(null, b + 3)", "defaults": Object { "b": undefined, @@ -4642,6 +5025,7 @@ Object { "isValid": true, "name": null, "params": "b, callback, restArgs", + "qux": 123, "value": "((b, callback, ...restArgs) => {callback(null, b + 3)})", } `; @@ -4651,6 +5035,7 @@ Object { "args": Array [ "c", ], + "barry": 223, "body": "return c * 3", "defaults": Object { "c": undefined, @@ -4664,6 +5049,7 @@ Object { "isValid": true, "name": null, "params": "c", + "qux": 123, "value": "((c) => {return c * 3})", } `; @@ -4673,6 +5059,7 @@ Object { "args": Array [ "restArgs", ], + "barry": 223, "body": "return 321", "defaults": Object { "restArgs": undefined, @@ -4686,6 +5073,7 @@ Object { "isValid": true, "name": null, "params": "restArgs", + "qux": 123, "value": "((...restArgs) => {return 321})", } `; @@ -4693,6 +5081,7 @@ Object { exports[`#215 - acorn.parse - () => {} 1`] = ` Object { "args": Array [], + "barry": 223, "body": "", "defaults": Object {}, "isAnonymous": true, @@ -4704,6 +5093,7 @@ Object { "isValid": true, "name": null, "params": "", + "qux": 123, "value": "(() => {})", } `; @@ -4713,6 +5103,7 @@ Object { "args": Array [ "a", ], + "barry": 223, "body": "", "defaults": Object { "a": "false", @@ -4726,6 +5117,7 @@ Object { "isValid": true, "name": null, "params": "a", + "qux": 123, "value": "((a = (true, false)) => {})", } `; @@ -4735,6 +5127,7 @@ Object { "args": Array [ "a", ], + "barry": 223, "body": "", "defaults": Object { "a": "null", @@ -4748,6 +5141,7 @@ Object { "isValid": true, "name": null, "params": "a", + "qux": 123, "value": "((a = (true, null)) => {})", } `; @@ -4757,6 +5151,7 @@ Object { "args": Array [ "a", ], + "barry": 223, "body": "", "defaults": Object { "a": "\\"bar\\"", @@ -4770,6 +5165,7 @@ Object { "isValid": true, "name": null, "params": "a", + "qux": 123, "value": "((a = (true, \\"bar\\")) => {})", } `; @@ -4780,6 +5176,7 @@ Object { "a", "b", ], + "barry": 223, "body": "", "defaults": Object { "a": undefined, @@ -4794,6 +5191,7 @@ Object { "isValid": true, "name": null, "params": "a, b", + "qux": 123, "value": "((a, b = (i++, true)) => {})", } `; @@ -4803,6 +5201,7 @@ Object { "args": Array [ "a", ], + "barry": 223, "body": "", "defaults": Object { "a": "1", @@ -4816,6 +5215,7 @@ Object { "isValid": true, "name": null, "params": "a", + "qux": 123, "value": "((a = 1) => {})", } `; @@ -4825,6 +5225,7 @@ Object { "args": Array [ "a", ], + "barry": 223, "body": "a * 3 * a", "defaults": Object { "a": undefined, @@ -4838,6 +5239,7 @@ Object { "isValid": true, "name": null, "params": "a", + "qux": 123, "value": "((a) => a * 3 * a)", } `; @@ -4847,6 +5249,7 @@ Object { "args": Array [ "d", ], + "barry": 223, "body": "d * 355 * d", "defaults": Object { "d": undefined, @@ -4860,6 +5263,7 @@ Object { "isValid": true, "name": null, "params": "d", + "qux": 123, "value": "(d => d * 355 * d)", } `; @@ -4869,6 +5273,7 @@ Object { "args": Array [ "e", ], + "barry": 223, "body": "return e + 5235 / e", "defaults": Object { "e": undefined, @@ -4882,6 +5287,7 @@ Object { "isValid": true, "name": null, "params": "e", + "qux": 123, "value": "(e => {return e + 5235 / e})", } `; @@ -4892,6 +5298,7 @@ Object { "a", "b", ], + "barry": 223, "body": "a + 3 + b", "defaults": Object { "a": undefined, @@ -4906,6 +5313,7 @@ Object { "isValid": true, "name": null, "params": "a, b", + "qux": 123, "value": "((a, b) => a + 3 + b)", } `; @@ -4917,6 +5325,7 @@ Object { "y", "restArgs", ], + "barry": 223, "body": "console.log({ value: x * y })", "defaults": Object { "restArgs": undefined, @@ -4932,6 +5341,7 @@ Object { "isValid": true, "name": null, "params": "x, y, restArgs", + "qux": 123, "value": "((x, y, ...restArgs) => console.log({ value: x * y }))", } `; @@ -4943,6 +5353,7 @@ Object { "cb", "restArgs", ], + "barry": 223, "body": "return a * 3", "defaults": Object { "a": "{foo: \\"ba)r\\", baz: 123}", @@ -4958,6 +5369,7 @@ Object { "isValid": true, "name": null, "params": "a, cb, restArgs", + "qux": 123, "value": "(async function (a = {foo: \\"ba)r\\", baz: 123}, cb, ...restArgs) {return a * 3})", } `; @@ -4969,6 +5381,7 @@ Object { "callback", "restArgs", ], + "barry": 223, "body": "callback(null, b + 3)", "defaults": Object { "b": undefined, @@ -4984,6 +5397,7 @@ Object { "isValid": true, "name": null, "params": "b, callback, restArgs", + "qux": 123, "value": "(async function (b, callback, ...restArgs) {callback(null, b + 3)})", } `; @@ -4993,6 +5407,7 @@ Object { "args": Array [ "c", ], + "barry": 223, "body": "return c * 3", "defaults": Object { "c": undefined, @@ -5006,6 +5421,7 @@ Object { "isValid": true, "name": null, "params": "c", + "qux": 123, "value": "(async function (c) {return c * 3})", } `; @@ -5015,6 +5431,7 @@ Object { "args": Array [ "restArgs", ], + "barry": 223, "body": "return 321", "defaults": Object { "restArgs": undefined, @@ -5028,6 +5445,7 @@ Object { "isValid": true, "name": null, "params": "restArgs", + "qux": 123, "value": "(async function (...restArgs) {return 321})", } `; @@ -5035,6 +5453,7 @@ Object { exports[`#230 - acorn.parse - async function () {} 1`] = ` Object { "args": Array [], + "barry": 223, "body": "", "defaults": Object {}, "isAnonymous": true, @@ -5046,6 +5465,7 @@ Object { "isValid": true, "name": null, "params": "", + "qux": 123, "value": "(async function () {})", } `; @@ -5055,6 +5475,7 @@ Object { "args": Array [ "a", ], + "barry": 223, "body": "", "defaults": Object { "a": "false", @@ -5068,6 +5489,7 @@ Object { "isValid": true, "name": null, "params": "a", + "qux": 123, "value": "(async function (a = (true, false)) {})", } `; @@ -5077,6 +5499,7 @@ Object { "args": Array [ "a", ], + "barry": 223, "body": "", "defaults": Object { "a": "null", @@ -5090,6 +5513,7 @@ Object { "isValid": true, "name": null, "params": "a", + "qux": 123, "value": "(async function (a = (true, null)) {})", } `; @@ -5099,6 +5523,7 @@ Object { "args": Array [ "a", ], + "barry": 223, "body": "", "defaults": Object { "a": "\\"bar\\"", @@ -5112,6 +5537,7 @@ Object { "isValid": true, "name": null, "params": "a", + "qux": 123, "value": "(async function (a = (true, \\"bar\\")) {})", } `; @@ -5122,6 +5548,7 @@ Object { "a", "b", ], + "barry": 223, "body": "", "defaults": Object { "a": undefined, @@ -5136,6 +5563,7 @@ Object { "isValid": true, "name": null, "params": "a, b", + "qux": 123, "value": "(async function (a, b = (i++, true)) {})", } `; @@ -5145,6 +5573,7 @@ Object { "args": Array [ "a", ], + "barry": 223, "body": "", "defaults": Object { "a": "1", @@ -5158,6 +5587,7 @@ Object { "isValid": true, "name": null, "params": "a", + "qux": 123, "value": "(async function (a = 1) {})", } `; @@ -5169,6 +5599,7 @@ Object { "cb", "restArgs", ], + "barry": 223, "body": "return a * 3", "defaults": Object { "a": "{foo: \\"ba)r\\", baz: 123}", @@ -5184,6 +5615,7 @@ Object { "isValid": true, "name": "namedFn", "params": "a, cb, restArgs", + "qux": 123, "value": "(async function namedFn (a = {foo: \\"ba)r\\", baz: 123}, cb, ...restArgs) {return a * 3})", } `; @@ -5195,6 +5627,7 @@ Object { "callback", "restArgs", ], + "barry": 223, "body": "callback(null, b + 3)", "defaults": Object { "b": undefined, @@ -5210,6 +5643,7 @@ Object { "isValid": true, "name": "namedFn", "params": "b, callback, restArgs", + "qux": 123, "value": "(async function namedFn (b, callback, ...restArgs) {callback(null, b + 3)})", } `; @@ -5219,6 +5653,7 @@ Object { "args": Array [ "c", ], + "barry": 223, "body": "return c * 3", "defaults": Object { "c": undefined, @@ -5232,6 +5667,7 @@ Object { "isValid": true, "name": "namedFn", "params": "c", + "qux": 123, "value": "(async function namedFn (c) {return c * 3})", } `; @@ -5241,6 +5677,7 @@ Object { "args": Array [ "restArgs", ], + "barry": 223, "body": "return 321", "defaults": Object { "restArgs": undefined, @@ -5254,6 +5691,7 @@ Object { "isValid": true, "name": "namedFn", "params": "restArgs", + "qux": 123, "value": "(async function namedFn (...restArgs) {return 321})", } `; @@ -5261,6 +5699,7 @@ Object { exports[`#240 - acorn.parse - async function namedFn () {} 1`] = ` Object { "args": Array [], + "barry": 223, "body": "", "defaults": Object {}, "isAnonymous": false, @@ -5272,6 +5711,7 @@ Object { "isValid": true, "name": "namedFn", "params": "", + "qux": 123, "value": "(async function namedFn () {})", } `; @@ -5281,6 +5721,7 @@ Object { "args": Array [ "a", ], + "barry": 223, "body": "", "defaults": Object { "a": "false", @@ -5294,6 +5735,7 @@ Object { "isValid": true, "name": "namedFn", "params": "a", + "qux": 123, "value": "(async function namedFn(a = (true, false)) {})", } `; @@ -5303,6 +5745,7 @@ Object { "args": Array [ "a", ], + "barry": 223, "body": "", "defaults": Object { "a": "null", @@ -5316,6 +5759,7 @@ Object { "isValid": true, "name": "namedFn", "params": "a", + "qux": 123, "value": "(async function namedFn(a = (true, null)) {})", } `; @@ -5325,6 +5769,7 @@ Object { "args": Array [ "a", ], + "barry": 223, "body": "", "defaults": Object { "a": "\\"bar\\"", @@ -5338,6 +5783,7 @@ Object { "isValid": true, "name": "namedFn", "params": "a", + "qux": 123, "value": "(async function namedFn(a = (true, \\"bar\\")) {})", } `; @@ -5348,6 +5794,7 @@ Object { "a", "b", ], + "barry": 223, "body": "", "defaults": Object { "a": undefined, @@ -5362,6 +5809,7 @@ Object { "isValid": true, "name": "namedFn", "params": "a, b", + "qux": 123, "value": "(async function namedFn(a, b = (i++, true)) {})", } `; @@ -5371,6 +5819,7 @@ Object { "args": Array [ "a", ], + "barry": 223, "body": "", "defaults": Object { "a": "1", @@ -5384,6 +5833,7 @@ Object { "isValid": true, "name": "namedFn", "params": "a", + "qux": 123, "value": "(async function namedFn(a = 1) {})", } `; @@ -5395,6 +5845,7 @@ Object { "cb", "restArgs", ], + "barry": 223, "body": "return a * 3", "defaults": Object { "a": "{foo: \\"ba)r\\", baz: 123}", @@ -5410,6 +5861,7 @@ Object { "isValid": true, "name": null, "params": "a, cb, restArgs", + "qux": 123, "value": "(async (a = {foo: \\"ba)r\\", baz: 123}, cb, ...restArgs) => {return a * 3})", } `; @@ -5421,6 +5873,7 @@ Object { "callback", "restArgs", ], + "barry": 223, "body": "callback(null, b + 3)", "defaults": Object { "b": undefined, @@ -5436,6 +5889,7 @@ Object { "isValid": true, "name": null, "params": "b, callback, restArgs", + "qux": 123, "value": "(async (b, callback, ...restArgs) => {callback(null, b + 3)})", } `; @@ -5445,6 +5899,7 @@ Object { "args": Array [ "c", ], + "barry": 223, "body": "return c * 3", "defaults": Object { "c": undefined, @@ -5458,6 +5913,7 @@ Object { "isValid": true, "name": null, "params": "c", + "qux": 123, "value": "(async (c) => {return c * 3})", } `; @@ -5467,6 +5923,7 @@ Object { "args": Array [ "restArgs", ], + "barry": 223, "body": "return 321", "defaults": Object { "restArgs": undefined, @@ -5480,6 +5937,7 @@ Object { "isValid": true, "name": null, "params": "restArgs", + "qux": 123, "value": "(async (...restArgs) => {return 321})", } `; @@ -5487,6 +5945,7 @@ Object { exports[`#250 - acorn.parse - async () => {} 1`] = ` Object { "args": Array [], + "barry": 223, "body": "", "defaults": Object {}, "isAnonymous": true, @@ -5498,6 +5957,7 @@ Object { "isValid": true, "name": null, "params": "", + "qux": 123, "value": "(async () => {})", } `; @@ -5507,6 +5967,7 @@ Object { "args": Array [ "a", ], + "barry": 223, "body": "", "defaults": Object { "a": "false", @@ -5520,6 +5981,7 @@ Object { "isValid": true, "name": null, "params": "a", + "qux": 123, "value": "(async (a = (true, false)) => {})", } `; @@ -5529,6 +5991,7 @@ Object { "args": Array [ "a", ], + "barry": 223, "body": "", "defaults": Object { "a": "null", @@ -5542,6 +6005,7 @@ Object { "isValid": true, "name": null, "params": "a", + "qux": 123, "value": "(async (a = (true, null)) => {})", } `; @@ -5551,6 +6015,7 @@ Object { "args": Array [ "a", ], + "barry": 223, "body": "", "defaults": Object { "a": "\\"bar\\"", @@ -5564,6 +6029,7 @@ Object { "isValid": true, "name": null, "params": "a", + "qux": 123, "value": "(async (a = (true, \\"bar\\")) => {})", } `; @@ -5574,6 +6040,7 @@ Object { "a", "b", ], + "barry": 223, "body": "", "defaults": Object { "a": undefined, @@ -5588,6 +6055,7 @@ Object { "isValid": true, "name": null, "params": "a, b", + "qux": 123, "value": "(async (a, b = (i++, true)) => {})", } `; @@ -5597,6 +6065,7 @@ Object { "args": Array [ "a", ], + "barry": 223, "body": "", "defaults": Object { "a": "1", @@ -5610,6 +6079,7 @@ Object { "isValid": true, "name": null, "params": "a", + "qux": 123, "value": "(async (a = 1) => {})", } `; @@ -5619,6 +6089,7 @@ Object { "args": Array [ "a", ], + "barry": 223, "body": "a * 3 * a", "defaults": Object { "a": undefined, @@ -5632,6 +6103,7 @@ Object { "isValid": true, "name": null, "params": "a", + "qux": 123, "value": "(async (a) => a * 3 * a)", } `; @@ -5641,6 +6113,7 @@ Object { "args": Array [ "d", ], + "barry": 223, "body": "d * 355 * d", "defaults": Object { "d": undefined, @@ -5654,6 +6127,7 @@ Object { "isValid": true, "name": null, "params": "d", + "qux": 123, "value": "(async d => d * 355 * d)", } `; @@ -5663,6 +6137,7 @@ Object { "args": Array [ "e", ], + "barry": 223, "body": "return e + 5235 / e", "defaults": Object { "e": undefined, @@ -5676,6 +6151,7 @@ Object { "isValid": true, "name": null, "params": "e", + "qux": 123, "value": "(async e => {return e + 5235 / e})", } `; @@ -5686,6 +6162,7 @@ Object { "a", "b", ], + "barry": 223, "body": "a + 3 + b", "defaults": Object { "a": undefined, @@ -5700,6 +6177,7 @@ Object { "isValid": true, "name": null, "params": "a, b", + "qux": 123, "value": "(async (a, b) => a + 3 + b)", } `; @@ -5711,6 +6189,7 @@ Object { "y", "restArgs", ], + "barry": 223, "body": "console.log({ value: x * y })", "defaults": Object { "restArgs": undefined, @@ -5726,6 +6205,7 @@ Object { "isValid": true, "name": null, "params": "x, y, restArgs", + "qux": 123, "value": "(async (x, y, ...restArgs) => console.log({ value: x * y }))", } `; @@ -5774,8 +6254,8 @@ Object { "c", ], "body": " - return a + b + c; - ", + return a + b + c; + ", "defaults": Object { "a": undefined, "b": undefined, @@ -5791,8 +6271,8 @@ Object { "name": "foo", "params": "a, b, c", "value": "({ foo(a, b, c) { - return a + b + c; - } })", + return a + b + c; + } })", } `; @@ -5802,8 +6282,8 @@ Object { "a", ], "body": " - return () => a; - ", + return () => a; + ", "defaults": Object { "a": undefined, }, @@ -5817,8 +6297,8 @@ Object { "name": "bar", "params": "a", "value": "({ bar(a) { - return () => a; - } })", + return () => a; + } })", } `; @@ -5828,8 +6308,8 @@ Object { "a", ], "body": " - return yield a * 321; - ", + return yield a * 321; + ", "defaults": Object { "a": undefined, }, @@ -5843,8 +6323,8 @@ Object { "name": "gen", "params": "a", "value": "({ *gen(a) { - return yield a * 321; - } })", + return yield a * 321; + } })", } `; @@ -5881,6 +6361,7 @@ Object { "cb", "restArgs", ], + "barry": 223, "body": "return a * 3", "defaults": Object { "a": "{foo: \\"ba)r\\", baz: 123}", @@ -5896,6 +6377,7 @@ Object { "isValid": true, "name": null, "params": "a, cb, restArgs", + "qux": 123, "value": "(function (a = {foo: \\"ba)r\\", baz: 123}, cb, ...restArgs) {return a * 3})", } `; @@ -5907,6 +6389,7 @@ Object { "callback", "restArgs", ], + "barry": 223, "body": "callback(null, b + 3)", "defaults": Object { "b": undefined, @@ -5922,6 +6405,7 @@ Object { "isValid": true, "name": null, "params": "b, callback, restArgs", + "qux": 123, "value": "(function (b, callback, ...restArgs) {callback(null, b + 3)})", } `; @@ -5931,6 +6415,7 @@ Object { "args": Array [ "c", ], + "barry": 223, "body": "return c * 3", "defaults": Object { "c": undefined, @@ -5944,6 +6429,7 @@ Object { "isValid": true, "name": null, "params": "c", + "qux": 123, "value": "(function (c) {return c * 3})", } `; @@ -5953,6 +6439,7 @@ Object { "args": Array [ "restArgs", ], + "barry": 223, "body": "return 321", "defaults": Object { "restArgs": undefined, @@ -5966,6 +6453,7 @@ Object { "isValid": true, "name": null, "params": "restArgs", + "qux": 123, "value": "(function (...restArgs) {return 321})", } `; @@ -5973,6 +6461,7 @@ Object { exports[`#275 - acorn loose - function () {} 1`] = ` Object { "args": Array [], + "barry": 223, "body": "", "defaults": Object {}, "isAnonymous": true, @@ -5984,6 +6473,7 @@ Object { "isValid": true, "name": null, "params": "", + "qux": 123, "value": "(function () {})", } `; @@ -5993,6 +6483,7 @@ Object { "args": Array [ "a", ], + "barry": 223, "body": "", "defaults": Object { "a": "false", @@ -6006,6 +6497,7 @@ Object { "isValid": true, "name": null, "params": "a", + "qux": 123, "value": "(function (a = (true, false)) {})", } `; @@ -6015,6 +6507,7 @@ Object { "args": Array [ "a", ], + "barry": 223, "body": "", "defaults": Object { "a": "null", @@ -6028,6 +6521,7 @@ Object { "isValid": true, "name": null, "params": "a", + "qux": 123, "value": "(function (a = (true, null)) {})", } `; @@ -6037,6 +6531,7 @@ Object { "args": Array [ "a", ], + "barry": 223, "body": "", "defaults": Object { "a": "\\"bar\\"", @@ -6050,6 +6545,7 @@ Object { "isValid": true, "name": null, "params": "a", + "qux": 123, "value": "(function (a = (true, \\"bar\\")) {})", } `; @@ -6060,6 +6556,7 @@ Object { "a", "b", ], + "barry": 223, "body": "", "defaults": Object { "a": undefined, @@ -6074,6 +6571,7 @@ Object { "isValid": true, "name": null, "params": "a, b", + "qux": 123, "value": "(function (a, b = (i++, true)) {})", } `; @@ -6083,6 +6581,7 @@ Object { "args": Array [ "a", ], + "barry": 223, "body": "", "defaults": Object { "a": "1", @@ -6096,6 +6595,7 @@ Object { "isValid": true, "name": null, "params": "a", + "qux": 123, "value": "(function (a = 1) {})", } `; @@ -6107,6 +6607,7 @@ Object { "cb", "restArgs", ], + "barry": 223, "body": "return a * 3", "defaults": Object { "a": "{foo: \\"ba)r\\", baz: 123}", @@ -6122,6 +6623,7 @@ Object { "isValid": true, "name": "namedFn", "params": "a, cb, restArgs", + "qux": 123, "value": "(function namedFn (a = {foo: \\"ba)r\\", baz: 123}, cb, ...restArgs) {return a * 3})", } `; @@ -6133,6 +6635,7 @@ Object { "callback", "restArgs", ], + "barry": 223, "body": "callback(null, b + 3)", "defaults": Object { "b": undefined, @@ -6148,6 +6651,7 @@ Object { "isValid": true, "name": "namedFn", "params": "b, callback, restArgs", + "qux": 123, "value": "(function namedFn (b, callback, ...restArgs) {callback(null, b + 3)})", } `; @@ -6157,6 +6661,7 @@ Object { "args": Array [ "c", ], + "barry": 223, "body": "return c * 3", "defaults": Object { "c": undefined, @@ -6170,6 +6675,7 @@ Object { "isValid": true, "name": "namedFn", "params": "c", + "qux": 123, "value": "(function namedFn (c) {return c * 3})", } `; @@ -6179,6 +6685,7 @@ Object { "args": Array [ "restArgs", ], + "barry": 223, "body": "return 321", "defaults": Object { "restArgs": undefined, @@ -6192,6 +6699,7 @@ Object { "isValid": true, "name": "namedFn", "params": "restArgs", + "qux": 123, "value": "(function namedFn (...restArgs) {return 321})", } `; @@ -6199,6 +6707,7 @@ Object { exports[`#285 - acorn loose - function namedFn () {} 1`] = ` Object { "args": Array [], + "barry": 223, "body": "", "defaults": Object {}, "isAnonymous": false, @@ -6210,6 +6719,7 @@ Object { "isValid": true, "name": "namedFn", "params": "", + "qux": 123, "value": "(function namedFn () {})", } `; @@ -6219,6 +6729,7 @@ Object { "args": Array [ "a", ], + "barry": 223, "body": "", "defaults": Object { "a": "false", @@ -6232,6 +6743,7 @@ Object { "isValid": true, "name": "namedFn", "params": "a", + "qux": 123, "value": "(function namedFn(a = (true, false)) {})", } `; @@ -6241,6 +6753,7 @@ Object { "args": Array [ "a", ], + "barry": 223, "body": "", "defaults": Object { "a": "null", @@ -6254,6 +6767,7 @@ Object { "isValid": true, "name": "namedFn", "params": "a", + "qux": 123, "value": "(function namedFn(a = (true, null)) {})", } `; @@ -6263,6 +6777,7 @@ Object { "args": Array [ "a", ], + "barry": 223, "body": "", "defaults": Object { "a": "\\"bar\\"", @@ -6276,6 +6791,7 @@ Object { "isValid": true, "name": "namedFn", "params": "a", + "qux": 123, "value": "(function namedFn(a = (true, \\"bar\\")) {})", } `; @@ -6286,6 +6802,7 @@ Object { "a", "b", ], + "barry": 223, "body": "", "defaults": Object { "a": undefined, @@ -6300,6 +6817,7 @@ Object { "isValid": true, "name": "namedFn", "params": "a, b", + "qux": 123, "value": "(function namedFn(a, b = (i++, true)) {})", } `; @@ -6309,6 +6827,7 @@ Object { "args": Array [ "a", ], + "barry": 223, "body": "", "defaults": Object { "a": "1", @@ -6322,6 +6841,7 @@ Object { "isValid": true, "name": "namedFn", "params": "a", + "qux": 123, "value": "(function namedFn(a = 1) {})", } `; @@ -6333,6 +6853,7 @@ Object { "cb", "restArgs", ], + "barry": 223, "body": "return a * 3", "defaults": Object { "a": "{foo: \\"ba)r\\", baz: 123}", @@ -6348,6 +6869,7 @@ Object { "isValid": true, "name": "namedFn", "params": "a, cb, restArgs", + "qux": 123, "value": "(function * namedFn (a = {foo: \\"ba)r\\", baz: 123}, cb, ...restArgs) {return a * 3})", } `; @@ -6359,6 +6881,7 @@ Object { "callback", "restArgs", ], + "barry": 223, "body": "callback(null, b + 3)", "defaults": Object { "b": undefined, @@ -6374,6 +6897,7 @@ Object { "isValid": true, "name": "namedFn", "params": "b, callback, restArgs", + "qux": 123, "value": "(function * namedFn (b, callback, ...restArgs) {callback(null, b + 3)})", } `; @@ -6383,6 +6907,7 @@ Object { "args": Array [ "c", ], + "barry": 223, "body": "return c * 3", "defaults": Object { "c": undefined, @@ -6396,6 +6921,7 @@ Object { "isValid": true, "name": "namedFn", "params": "c", + "qux": 123, "value": "(function * namedFn (c) {return c * 3})", } `; @@ -6405,6 +6931,7 @@ Object { "args": Array [ "restArgs", ], + "barry": 223, "body": "return 321", "defaults": Object { "restArgs": undefined, @@ -6418,6 +6945,7 @@ Object { "isValid": true, "name": "namedFn", "params": "restArgs", + "qux": 123, "value": "(function * namedFn (...restArgs) {return 321})", } `; @@ -6425,6 +6953,7 @@ Object { exports[`#295 - acorn loose - function * namedFn () {} 1`] = ` Object { "args": Array [], + "barry": 223, "body": "", "defaults": Object {}, "isAnonymous": false, @@ -6436,6 +6965,7 @@ Object { "isValid": true, "name": "namedFn", "params": "", + "qux": 123, "value": "(function * namedFn () {})", } `; @@ -6445,6 +6975,7 @@ Object { "args": Array [ "a", ], + "barry": 223, "body": "", "defaults": Object { "a": "false", @@ -6458,6 +6989,7 @@ Object { "isValid": true, "name": "namedFn", "params": "a", + "qux": 123, "value": "(function * namedFn(a = (true, false)) {})", } `; @@ -6467,6 +6999,7 @@ Object { "args": Array [ "a", ], + "barry": 223, "body": "", "defaults": Object { "a": "null", @@ -6480,6 +7013,7 @@ Object { "isValid": true, "name": "namedFn", "params": "a", + "qux": 123, "value": "(function * namedFn(a = (true, null)) {})", } `; @@ -6489,6 +7023,7 @@ Object { "args": Array [ "a", ], + "barry": 223, "body": "", "defaults": Object { "a": "\\"bar\\"", @@ -6502,6 +7037,7 @@ Object { "isValid": true, "name": "namedFn", "params": "a", + "qux": 123, "value": "(function * namedFn(a = (true, \\"bar\\")) {})", } `; @@ -6512,6 +7048,7 @@ Object { "a", "b", ], + "barry": 223, "body": "", "defaults": Object { "a": undefined, @@ -6526,6 +7063,7 @@ Object { "isValid": true, "name": "namedFn", "params": "a, b", + "qux": 123, "value": "(function * namedFn(a, b = (i++, true)) {})", } `; @@ -6535,6 +7073,7 @@ Object { "args": Array [ "a", ], + "barry": 223, "body": "", "defaults": Object { "a": "1", @@ -6548,6 +7087,7 @@ Object { "isValid": true, "name": "namedFn", "params": "a", + "qux": 123, "value": "(function * namedFn(a = 1) {})", } `; @@ -6559,6 +7099,7 @@ Object { "cb", "restArgs", ], + "barry": 223, "body": "return a * 3", "defaults": Object { "a": "{foo: \\"ba)r\\", baz: 123}", @@ -6574,6 +7115,7 @@ Object { "isValid": true, "name": null, "params": "a, cb, restArgs", + "qux": 123, "value": "((a = {foo: \\"ba)r\\", baz: 123}, cb, ...restArgs) => {return a * 3})", } `; @@ -6585,6 +7127,7 @@ Object { "callback", "restArgs", ], + "barry": 223, "body": "callback(null, b + 3)", "defaults": Object { "b": undefined, @@ -6600,6 +7143,7 @@ Object { "isValid": true, "name": null, "params": "b, callback, restArgs", + "qux": 123, "value": "((b, callback, ...restArgs) => {callback(null, b + 3)})", } `; @@ -6609,6 +7153,7 @@ Object { "args": Array [ "c", ], + "barry": 223, "body": "return c * 3", "defaults": Object { "c": undefined, @@ -6622,6 +7167,7 @@ Object { "isValid": true, "name": null, "params": "c", + "qux": 123, "value": "((c) => {return c * 3})", } `; @@ -6631,6 +7177,7 @@ Object { "args": Array [ "restArgs", ], + "barry": 223, "body": "return 321", "defaults": Object { "restArgs": undefined, @@ -6644,6 +7191,7 @@ Object { "isValid": true, "name": null, "params": "restArgs", + "qux": 123, "value": "((...restArgs) => {return 321})", } `; @@ -6651,6 +7199,7 @@ Object { exports[`#305 - acorn loose - () => {} 1`] = ` Object { "args": Array [], + "barry": 223, "body": "", "defaults": Object {}, "isAnonymous": true, @@ -6662,6 +7211,7 @@ Object { "isValid": true, "name": null, "params": "", + "qux": 123, "value": "(() => {})", } `; @@ -6671,6 +7221,7 @@ Object { "args": Array [ "a", ], + "barry": 223, "body": "", "defaults": Object { "a": "false", @@ -6684,6 +7235,7 @@ Object { "isValid": true, "name": null, "params": "a", + "qux": 123, "value": "((a = (true, false)) => {})", } `; @@ -6693,6 +7245,7 @@ Object { "args": Array [ "a", ], + "barry": 223, "body": "", "defaults": Object { "a": "null", @@ -6706,6 +7259,7 @@ Object { "isValid": true, "name": null, "params": "a", + "qux": 123, "value": "((a = (true, null)) => {})", } `; @@ -6715,6 +7269,7 @@ Object { "args": Array [ "a", ], + "barry": 223, "body": "", "defaults": Object { "a": "\\"bar\\"", @@ -6728,6 +7283,7 @@ Object { "isValid": true, "name": null, "params": "a", + "qux": 123, "value": "((a = (true, \\"bar\\")) => {})", } `; @@ -6738,6 +7294,7 @@ Object { "a", "b", ], + "barry": 223, "body": "", "defaults": Object { "a": undefined, @@ -6752,6 +7309,7 @@ Object { "isValid": true, "name": null, "params": "a, b", + "qux": 123, "value": "((a, b = (i++, true)) => {})", } `; @@ -6761,6 +7319,7 @@ Object { "args": Array [ "a", ], + "barry": 223, "body": "", "defaults": Object { "a": "1", @@ -6774,6 +7333,7 @@ Object { "isValid": true, "name": null, "params": "a", + "qux": 123, "value": "((a = 1) => {})", } `; @@ -6783,6 +7343,7 @@ Object { "args": Array [ "a", ], + "barry": 223, "body": "a * 3 * a", "defaults": Object { "a": undefined, @@ -6796,6 +7357,7 @@ Object { "isValid": true, "name": null, "params": "a", + "qux": 123, "value": "((a) => a * 3 * a)", } `; @@ -6805,6 +7367,7 @@ Object { "args": Array [ "d", ], + "barry": 223, "body": "d * 355 * d", "defaults": Object { "d": undefined, @@ -6818,6 +7381,7 @@ Object { "isValid": true, "name": null, "params": "d", + "qux": 123, "value": "(d => d * 355 * d)", } `; @@ -6827,6 +7391,7 @@ Object { "args": Array [ "e", ], + "barry": 223, "body": "return e + 5235 / e", "defaults": Object { "e": undefined, @@ -6840,6 +7405,7 @@ Object { "isValid": true, "name": null, "params": "e", + "qux": 123, "value": "(e => {return e + 5235 / e})", } `; @@ -6850,6 +7416,7 @@ Object { "a", "b", ], + "barry": 223, "body": "a + 3 + b", "defaults": Object { "a": undefined, @@ -6864,6 +7431,7 @@ Object { "isValid": true, "name": null, "params": "a, b", + "qux": 123, "value": "((a, b) => a + 3 + b)", } `; @@ -6875,6 +7443,7 @@ Object { "y", "restArgs", ], + "barry": 223, "body": "console.log({ value: x * y })", "defaults": Object { "restArgs": undefined, @@ -6890,6 +7459,7 @@ Object { "isValid": true, "name": null, "params": "x, y, restArgs", + "qux": 123, "value": "((x, y, ...restArgs) => console.log({ value: x * y }))", } `; @@ -6901,6 +7471,7 @@ Object { "cb", "restArgs", ], + "barry": 223, "body": "return a * 3", "defaults": Object { "a": "{foo: \\"ba)r\\", baz: 123}", @@ -6916,6 +7487,7 @@ Object { "isValid": true, "name": null, "params": "a, cb, restArgs", + "qux": 123, "value": "(async function (a = {foo: \\"ba)r\\", baz: 123}, cb, ...restArgs) {return a * 3})", } `; @@ -6927,6 +7499,7 @@ Object { "callback", "restArgs", ], + "barry": 223, "body": "callback(null, b + 3)", "defaults": Object { "b": undefined, @@ -6942,6 +7515,7 @@ Object { "isValid": true, "name": null, "params": "b, callback, restArgs", + "qux": 123, "value": "(async function (b, callback, ...restArgs) {callback(null, b + 3)})", } `; @@ -6951,6 +7525,7 @@ Object { "args": Array [ "c", ], + "barry": 223, "body": "return c * 3", "defaults": Object { "c": undefined, @@ -6964,6 +7539,7 @@ Object { "isValid": true, "name": null, "params": "c", + "qux": 123, "value": "(async function (c) {return c * 3})", } `; @@ -6973,6 +7549,7 @@ Object { "args": Array [ "restArgs", ], + "barry": 223, "body": "return 321", "defaults": Object { "restArgs": undefined, @@ -6986,6 +7563,7 @@ Object { "isValid": true, "name": null, "params": "restArgs", + "qux": 123, "value": "(async function (...restArgs) {return 321})", } `; @@ -6993,6 +7571,7 @@ Object { exports[`#320 - acorn loose - async function () {} 1`] = ` Object { "args": Array [], + "barry": 223, "body": "", "defaults": Object {}, "isAnonymous": true, @@ -7004,6 +7583,7 @@ Object { "isValid": true, "name": null, "params": "", + "qux": 123, "value": "(async function () {})", } `; @@ -7013,6 +7593,7 @@ Object { "args": Array [ "a", ], + "barry": 223, "body": "", "defaults": Object { "a": "false", @@ -7026,6 +7607,7 @@ Object { "isValid": true, "name": null, "params": "a", + "qux": 123, "value": "(async function (a = (true, false)) {})", } `; @@ -7035,6 +7617,7 @@ Object { "args": Array [ "a", ], + "barry": 223, "body": "", "defaults": Object { "a": "null", @@ -7048,6 +7631,7 @@ Object { "isValid": true, "name": null, "params": "a", + "qux": 123, "value": "(async function (a = (true, null)) {})", } `; @@ -7057,6 +7641,7 @@ Object { "args": Array [ "a", ], + "barry": 223, "body": "", "defaults": Object { "a": "\\"bar\\"", @@ -7070,6 +7655,7 @@ Object { "isValid": true, "name": null, "params": "a", + "qux": 123, "value": "(async function (a = (true, \\"bar\\")) {})", } `; @@ -7080,6 +7666,7 @@ Object { "a", "b", ], + "barry": 223, "body": "", "defaults": Object { "a": undefined, @@ -7094,6 +7681,7 @@ Object { "isValid": true, "name": null, "params": "a, b", + "qux": 123, "value": "(async function (a, b = (i++, true)) {})", } `; @@ -7103,6 +7691,7 @@ Object { "args": Array [ "a", ], + "barry": 223, "body": "", "defaults": Object { "a": "1", @@ -7116,6 +7705,7 @@ Object { "isValid": true, "name": null, "params": "a", + "qux": 123, "value": "(async function (a = 1) {})", } `; @@ -7127,6 +7717,7 @@ Object { "cb", "restArgs", ], + "barry": 223, "body": "return a * 3", "defaults": Object { "a": "{foo: \\"ba)r\\", baz: 123}", @@ -7142,6 +7733,7 @@ Object { "isValid": true, "name": "namedFn", "params": "a, cb, restArgs", + "qux": 123, "value": "(async function namedFn (a = {foo: \\"ba)r\\", baz: 123}, cb, ...restArgs) {return a * 3})", } `; @@ -7153,6 +7745,7 @@ Object { "callback", "restArgs", ], + "barry": 223, "body": "callback(null, b + 3)", "defaults": Object { "b": undefined, @@ -7168,6 +7761,7 @@ Object { "isValid": true, "name": "namedFn", "params": "b, callback, restArgs", + "qux": 123, "value": "(async function namedFn (b, callback, ...restArgs) {callback(null, b + 3)})", } `; @@ -7177,6 +7771,7 @@ Object { "args": Array [ "c", ], + "barry": 223, "body": "return c * 3", "defaults": Object { "c": undefined, @@ -7190,6 +7785,7 @@ Object { "isValid": true, "name": "namedFn", "params": "c", + "qux": 123, "value": "(async function namedFn (c) {return c * 3})", } `; @@ -7199,6 +7795,7 @@ Object { "args": Array [ "restArgs", ], + "barry": 223, "body": "return 321", "defaults": Object { "restArgs": undefined, @@ -7212,6 +7809,7 @@ Object { "isValid": true, "name": "namedFn", "params": "restArgs", + "qux": 123, "value": "(async function namedFn (...restArgs) {return 321})", } `; @@ -7219,6 +7817,7 @@ Object { exports[`#330 - acorn loose - async function namedFn () {} 1`] = ` Object { "args": Array [], + "barry": 223, "body": "", "defaults": Object {}, "isAnonymous": false, @@ -7230,6 +7829,7 @@ Object { "isValid": true, "name": "namedFn", "params": "", + "qux": 123, "value": "(async function namedFn () {})", } `; @@ -7239,6 +7839,7 @@ Object { "args": Array [ "a", ], + "barry": 223, "body": "", "defaults": Object { "a": "false", @@ -7252,6 +7853,7 @@ Object { "isValid": true, "name": "namedFn", "params": "a", + "qux": 123, "value": "(async function namedFn(a = (true, false)) {})", } `; @@ -7261,6 +7863,7 @@ Object { "args": Array [ "a", ], + "barry": 223, "body": "", "defaults": Object { "a": "null", @@ -7274,6 +7877,7 @@ Object { "isValid": true, "name": "namedFn", "params": "a", + "qux": 123, "value": "(async function namedFn(a = (true, null)) {})", } `; @@ -7283,6 +7887,7 @@ Object { "args": Array [ "a", ], + "barry": 223, "body": "", "defaults": Object { "a": "\\"bar\\"", @@ -7296,6 +7901,7 @@ Object { "isValid": true, "name": "namedFn", "params": "a", + "qux": 123, "value": "(async function namedFn(a = (true, \\"bar\\")) {})", } `; @@ -7306,6 +7912,7 @@ Object { "a", "b", ], + "barry": 223, "body": "", "defaults": Object { "a": undefined, @@ -7320,6 +7927,7 @@ Object { "isValid": true, "name": "namedFn", "params": "a, b", + "qux": 123, "value": "(async function namedFn(a, b = (i++, true)) {})", } `; @@ -7329,6 +7937,7 @@ Object { "args": Array [ "a", ], + "barry": 223, "body": "", "defaults": Object { "a": "1", @@ -7342,6 +7951,7 @@ Object { "isValid": true, "name": "namedFn", "params": "a", + "qux": 123, "value": "(async function namedFn(a = 1) {})", } `; @@ -7353,6 +7963,7 @@ Object { "cb", "restArgs", ], + "barry": 223, "body": "return a * 3", "defaults": Object { "a": "{foo: \\"ba)r\\", baz: 123}", @@ -7368,6 +7979,7 @@ Object { "isValid": true, "name": null, "params": "a, cb, restArgs", + "qux": 123, "value": "(async (a = {foo: \\"ba)r\\", baz: 123}, cb, ...restArgs) => {return a * 3})", } `; @@ -7379,6 +7991,7 @@ Object { "callback", "restArgs", ], + "barry": 223, "body": "callback(null, b + 3)", "defaults": Object { "b": undefined, @@ -7394,6 +8007,7 @@ Object { "isValid": true, "name": null, "params": "b, callback, restArgs", + "qux": 123, "value": "(async (b, callback, ...restArgs) => {callback(null, b + 3)})", } `; @@ -7403,6 +8017,7 @@ Object { "args": Array [ "c", ], + "barry": 223, "body": "return c * 3", "defaults": Object { "c": undefined, @@ -7416,6 +8031,7 @@ Object { "isValid": true, "name": null, "params": "c", + "qux": 123, "value": "(async (c) => {return c * 3})", } `; @@ -7425,6 +8041,7 @@ Object { "args": Array [ "restArgs", ], + "barry": 223, "body": "return 321", "defaults": Object { "restArgs": undefined, @@ -7438,6 +8055,7 @@ Object { "isValid": true, "name": null, "params": "restArgs", + "qux": 123, "value": "(async (...restArgs) => {return 321})", } `; @@ -7445,6 +8063,7 @@ Object { exports[`#340 - acorn loose - async () => {} 1`] = ` Object { "args": Array [], + "barry": 223, "body": "", "defaults": Object {}, "isAnonymous": true, @@ -7456,6 +8075,7 @@ Object { "isValid": true, "name": null, "params": "", + "qux": 123, "value": "(async () => {})", } `; @@ -7465,6 +8085,7 @@ Object { "args": Array [ "a", ], + "barry": 223, "body": "", "defaults": Object { "a": "false", @@ -7478,6 +8099,7 @@ Object { "isValid": true, "name": null, "params": "a", + "qux": 123, "value": "(async (a = (true, false)) => {})", } `; @@ -7487,6 +8109,7 @@ Object { "args": Array [ "a", ], + "barry": 223, "body": "", "defaults": Object { "a": "null", @@ -7500,6 +8123,7 @@ Object { "isValid": true, "name": null, "params": "a", + "qux": 123, "value": "(async (a = (true, null)) => {})", } `; @@ -7509,6 +8133,7 @@ Object { "args": Array [ "a", ], + "barry": 223, "body": "", "defaults": Object { "a": "\\"bar\\"", @@ -7522,6 +8147,7 @@ Object { "isValid": true, "name": null, "params": "a", + "qux": 123, "value": "(async (a = (true, \\"bar\\")) => {})", } `; @@ -7532,6 +8158,7 @@ Object { "a", "b", ], + "barry": 223, "body": "", "defaults": Object { "a": undefined, @@ -7546,6 +8173,7 @@ Object { "isValid": true, "name": null, "params": "a, b", + "qux": 123, "value": "(async (a, b = (i++, true)) => {})", } `; @@ -7555,6 +8183,7 @@ Object { "args": Array [ "a", ], + "barry": 223, "body": "", "defaults": Object { "a": "1", @@ -7568,6 +8197,7 @@ Object { "isValid": true, "name": null, "params": "a", + "qux": 123, "value": "(async (a = 1) => {})", } `; @@ -7577,6 +8207,7 @@ Object { "args": Array [ "a", ], + "barry": 223, "body": "a * 3 * a", "defaults": Object { "a": undefined, @@ -7590,6 +8221,7 @@ Object { "isValid": true, "name": null, "params": "a", + "qux": 123, "value": "(async (a) => a * 3 * a)", } `; @@ -7599,6 +8231,7 @@ Object { "args": Array [ "d", ], + "barry": 223, "body": "d * 355 * d", "defaults": Object { "d": undefined, @@ -7612,6 +8245,7 @@ Object { "isValid": true, "name": null, "params": "d", + "qux": 123, "value": "(async d => d * 355 * d)", } `; @@ -7621,6 +8255,7 @@ Object { "args": Array [ "e", ], + "barry": 223, "body": "return e + 5235 / e", "defaults": Object { "e": undefined, @@ -7634,6 +8269,7 @@ Object { "isValid": true, "name": null, "params": "e", + "qux": 123, "value": "(async e => {return e + 5235 / e})", } `; @@ -7644,6 +8280,7 @@ Object { "a", "b", ], + "barry": 223, "body": "a + 3 + b", "defaults": Object { "a": undefined, @@ -7658,6 +8295,7 @@ Object { "isValid": true, "name": null, "params": "a, b", + "qux": 123, "value": "(async (a, b) => a + 3 + b)", } `; @@ -7669,6 +8307,7 @@ Object { "y", "restArgs", ], + "barry": 223, "body": "console.log({ value: x * y })", "defaults": Object { "restArgs": undefined, @@ -7684,6 +8323,7 @@ Object { "isValid": true, "name": null, "params": "x, y, restArgs", + "qux": 123, "value": "(async (x, y, ...restArgs) => console.log({ value: x * y }))", } `; @@ -7732,8 +8372,8 @@ Object { "c", ], "body": " - return a + b + c; - ", + return a + b + c; + ", "defaults": Object { "a": undefined, "b": undefined, @@ -7749,8 +8389,8 @@ Object { "name": "foo", "params": "a, b, c", "value": "({ foo(a, b, c) { - return a + b + c; - } })", + return a + b + c; + } })", } `; @@ -7760,8 +8400,8 @@ Object { "a", ], "body": " - return () => a; - ", + return () => a; + ", "defaults": Object { "a": undefined, }, @@ -7775,8 +8415,8 @@ Object { "name": "bar", "params": "a", "value": "({ bar(a) { - return () => a; - } })", + return () => a; + } })", } `; @@ -7786,8 +8426,8 @@ Object { "a", ], "body": " - return yield a * 321; - ", + return yield a * 321; + ", "defaults": Object { "a": undefined, }, @@ -7801,8 +8441,8 @@ Object { "name": "gen", "params": "a", "value": "({ *gen(a) { - return yield a * 321; - } })", + return yield a * 321; + } })", } `; @@ -7839,6 +8479,7 @@ Object { "cb", "restArgs", ], + "barry": 223, "body": "return a * 3", "defaults": Object { "a": "{foo: \\"ba)r\\", baz: 123}", @@ -7854,6 +8495,7 @@ Object { "isValid": true, "name": null, "params": "a, cb, restArgs", + "qux": 123, "value": "(function (a = {foo: \\"ba)r\\", baz: 123}, cb, ...restArgs) {return a * 3})", } `; @@ -7865,6 +8507,7 @@ Object { "callback", "restArgs", ], + "barry": 223, "body": "callback(null, b + 3)", "defaults": Object { "b": undefined, @@ -7880,6 +8523,7 @@ Object { "isValid": true, "name": null, "params": "b, callback, restArgs", + "qux": 123, "value": "(function (b, callback, ...restArgs) {callback(null, b + 3)})", } `; @@ -7889,6 +8533,7 @@ Object { "args": Array [ "c", ], + "barry": 223, "body": "return c * 3", "defaults": Object { "c": undefined, @@ -7902,6 +8547,7 @@ Object { "isValid": true, "name": null, "params": "c", + "qux": 123, "value": "(function (c) {return c * 3})", } `; @@ -7911,6 +8557,7 @@ Object { "args": Array [ "restArgs", ], + "barry": 223, "body": "return 321", "defaults": Object { "restArgs": undefined, @@ -7924,6 +8571,7 @@ Object { "isValid": true, "name": null, "params": "restArgs", + "qux": 123, "value": "(function (...restArgs) {return 321})", } `; @@ -7931,6 +8579,7 @@ Object { exports[`#365 - espree.parse - function () {} 1`] = ` Object { "args": Array [], + "barry": 223, "body": "", "defaults": Object {}, "isAnonymous": true, @@ -7942,6 +8591,7 @@ Object { "isValid": true, "name": null, "params": "", + "qux": 123, "value": "(function () {})", } `; @@ -7951,6 +8601,7 @@ Object { "args": Array [ "a", ], + "barry": 223, "body": "", "defaults": Object { "a": "false", @@ -7964,6 +8615,7 @@ Object { "isValid": true, "name": null, "params": "a", + "qux": 123, "value": "(function (a = (true, false)) {})", } `; @@ -7973,6 +8625,7 @@ Object { "args": Array [ "a", ], + "barry": 223, "body": "", "defaults": Object { "a": "null", @@ -7986,6 +8639,7 @@ Object { "isValid": true, "name": null, "params": "a", + "qux": 123, "value": "(function (a = (true, null)) {})", } `; @@ -7995,6 +8649,7 @@ Object { "args": Array [ "a", ], + "barry": 223, "body": "", "defaults": Object { "a": "\\"bar\\"", @@ -8008,6 +8663,7 @@ Object { "isValid": true, "name": null, "params": "a", + "qux": 123, "value": "(function (a = (true, \\"bar\\")) {})", } `; @@ -8018,6 +8674,7 @@ Object { "a", "b", ], + "barry": 223, "body": "", "defaults": Object { "a": undefined, @@ -8032,6 +8689,7 @@ Object { "isValid": true, "name": null, "params": "a, b", + "qux": 123, "value": "(function (a, b = (i++, true)) {})", } `; @@ -8041,6 +8699,7 @@ Object { "args": Array [ "a", ], + "barry": 223, "body": "", "defaults": Object { "a": "1", @@ -8054,6 +8713,7 @@ Object { "isValid": true, "name": null, "params": "a", + "qux": 123, "value": "(function (a = 1) {})", } `; @@ -8065,6 +8725,7 @@ Object { "cb", "restArgs", ], + "barry": 223, "body": "return a * 3", "defaults": Object { "a": "{foo: \\"ba)r\\", baz: 123}", @@ -8080,6 +8741,7 @@ Object { "isValid": true, "name": "namedFn", "params": "a, cb, restArgs", + "qux": 123, "value": "(function namedFn (a = {foo: \\"ba)r\\", baz: 123}, cb, ...restArgs) {return a * 3})", } `; @@ -8091,6 +8753,7 @@ Object { "callback", "restArgs", ], + "barry": 223, "body": "callback(null, b + 3)", "defaults": Object { "b": undefined, @@ -8106,6 +8769,7 @@ Object { "isValid": true, "name": "namedFn", "params": "b, callback, restArgs", + "qux": 123, "value": "(function namedFn (b, callback, ...restArgs) {callback(null, b + 3)})", } `; @@ -8115,6 +8779,7 @@ Object { "args": Array [ "c", ], + "barry": 223, "body": "return c * 3", "defaults": Object { "c": undefined, @@ -8128,6 +8793,7 @@ Object { "isValid": true, "name": "namedFn", "params": "c", + "qux": 123, "value": "(function namedFn (c) {return c * 3})", } `; @@ -8137,6 +8803,7 @@ Object { "args": Array [ "restArgs", ], + "barry": 223, "body": "return 321", "defaults": Object { "restArgs": undefined, @@ -8150,6 +8817,7 @@ Object { "isValid": true, "name": "namedFn", "params": "restArgs", + "qux": 123, "value": "(function namedFn (...restArgs) {return 321})", } `; @@ -8157,6 +8825,7 @@ Object { exports[`#375 - espree.parse - function namedFn () {} 1`] = ` Object { "args": Array [], + "barry": 223, "body": "", "defaults": Object {}, "isAnonymous": false, @@ -8168,6 +8837,7 @@ Object { "isValid": true, "name": "namedFn", "params": "", + "qux": 123, "value": "(function namedFn () {})", } `; @@ -8177,6 +8847,7 @@ Object { "args": Array [ "a", ], + "barry": 223, "body": "", "defaults": Object { "a": "false", @@ -8190,6 +8861,7 @@ Object { "isValid": true, "name": "namedFn", "params": "a", + "qux": 123, "value": "(function namedFn(a = (true, false)) {})", } `; @@ -8199,6 +8871,7 @@ Object { "args": Array [ "a", ], + "barry": 223, "body": "", "defaults": Object { "a": "null", @@ -8212,6 +8885,7 @@ Object { "isValid": true, "name": "namedFn", "params": "a", + "qux": 123, "value": "(function namedFn(a = (true, null)) {})", } `; @@ -8221,6 +8895,7 @@ Object { "args": Array [ "a", ], + "barry": 223, "body": "", "defaults": Object { "a": "\\"bar\\"", @@ -8234,6 +8909,7 @@ Object { "isValid": true, "name": "namedFn", "params": "a", + "qux": 123, "value": "(function namedFn(a = (true, \\"bar\\")) {})", } `; @@ -8244,6 +8920,7 @@ Object { "a", "b", ], + "barry": 223, "body": "", "defaults": Object { "a": undefined, @@ -8258,6 +8935,7 @@ Object { "isValid": true, "name": "namedFn", "params": "a, b", + "qux": 123, "value": "(function namedFn(a, b = (i++, true)) {})", } `; @@ -8267,6 +8945,7 @@ Object { "args": Array [ "a", ], + "barry": 223, "body": "", "defaults": Object { "a": "1", @@ -8280,6 +8959,7 @@ Object { "isValid": true, "name": "namedFn", "params": "a", + "qux": 123, "value": "(function namedFn(a = 1) {})", } `; @@ -8291,6 +8971,7 @@ Object { "cb", "restArgs", ], + "barry": 223, "body": "return a * 3", "defaults": Object { "a": "{foo: \\"ba)r\\", baz: 123}", @@ -8306,6 +8987,7 @@ Object { "isValid": true, "name": "namedFn", "params": "a, cb, restArgs", + "qux": 123, "value": "(function * namedFn (a = {foo: \\"ba)r\\", baz: 123}, cb, ...restArgs) {return a * 3})", } `; @@ -8317,6 +8999,7 @@ Object { "callback", "restArgs", ], + "barry": 223, "body": "callback(null, b + 3)", "defaults": Object { "b": undefined, @@ -8332,6 +9015,7 @@ Object { "isValid": true, "name": "namedFn", "params": "b, callback, restArgs", + "qux": 123, "value": "(function * namedFn (b, callback, ...restArgs) {callback(null, b + 3)})", } `; @@ -8341,6 +9025,7 @@ Object { "args": Array [ "c", ], + "barry": 223, "body": "return c * 3", "defaults": Object { "c": undefined, @@ -8354,6 +9039,7 @@ Object { "isValid": true, "name": "namedFn", "params": "c", + "qux": 123, "value": "(function * namedFn (c) {return c * 3})", } `; @@ -8363,6 +9049,7 @@ Object { "args": Array [ "restArgs", ], + "barry": 223, "body": "return 321", "defaults": Object { "restArgs": undefined, @@ -8376,6 +9063,7 @@ Object { "isValid": true, "name": "namedFn", "params": "restArgs", + "qux": 123, "value": "(function * namedFn (...restArgs) {return 321})", } `; @@ -8383,6 +9071,7 @@ Object { exports[`#385 - espree.parse - function * namedFn () {} 1`] = ` Object { "args": Array [], + "barry": 223, "body": "", "defaults": Object {}, "isAnonymous": false, @@ -8394,6 +9083,7 @@ Object { "isValid": true, "name": "namedFn", "params": "", + "qux": 123, "value": "(function * namedFn () {})", } `; @@ -8403,6 +9093,7 @@ Object { "args": Array [ "a", ], + "barry": 223, "body": "", "defaults": Object { "a": "false", @@ -8416,6 +9107,7 @@ Object { "isValid": true, "name": "namedFn", "params": "a", + "qux": 123, "value": "(function * namedFn(a = (true, false)) {})", } `; @@ -8425,6 +9117,7 @@ Object { "args": Array [ "a", ], + "barry": 223, "body": "", "defaults": Object { "a": "null", @@ -8438,6 +9131,7 @@ Object { "isValid": true, "name": "namedFn", "params": "a", + "qux": 123, "value": "(function * namedFn(a = (true, null)) {})", } `; @@ -8447,6 +9141,7 @@ Object { "args": Array [ "a", ], + "barry": 223, "body": "", "defaults": Object { "a": "\\"bar\\"", @@ -8460,6 +9155,7 @@ Object { "isValid": true, "name": "namedFn", "params": "a", + "qux": 123, "value": "(function * namedFn(a = (true, \\"bar\\")) {})", } `; @@ -8470,6 +9166,7 @@ Object { "a", "b", ], + "barry": 223, "body": "", "defaults": Object { "a": undefined, @@ -8484,6 +9181,7 @@ Object { "isValid": true, "name": "namedFn", "params": "a, b", + "qux": 123, "value": "(function * namedFn(a, b = (i++, true)) {})", } `; @@ -8493,6 +9191,7 @@ Object { "args": Array [ "a", ], + "barry": 223, "body": "", "defaults": Object { "a": "1", @@ -8506,6 +9205,7 @@ Object { "isValid": true, "name": "namedFn", "params": "a", + "qux": 123, "value": "(function * namedFn(a = 1) {})", } `; @@ -8517,6 +9217,7 @@ Object { "cb", "restArgs", ], + "barry": 223, "body": "return a * 3", "defaults": Object { "a": "{foo: \\"ba)r\\", baz: 123}", @@ -8532,6 +9233,7 @@ Object { "isValid": true, "name": null, "params": "a, cb, restArgs", + "qux": 123, "value": "((a = {foo: \\"ba)r\\", baz: 123}, cb, ...restArgs) => {return a * 3})", } `; @@ -8543,6 +9245,7 @@ Object { "callback", "restArgs", ], + "barry": 223, "body": "callback(null, b + 3)", "defaults": Object { "b": undefined, @@ -8558,6 +9261,7 @@ Object { "isValid": true, "name": null, "params": "b, callback, restArgs", + "qux": 123, "value": "((b, callback, ...restArgs) => {callback(null, b + 3)})", } `; @@ -8567,6 +9271,7 @@ Object { "args": Array [ "c", ], + "barry": 223, "body": "return c * 3", "defaults": Object { "c": undefined, @@ -8580,6 +9285,7 @@ Object { "isValid": true, "name": null, "params": "c", + "qux": 123, "value": "((c) => {return c * 3})", } `; @@ -8589,6 +9295,7 @@ Object { "args": Array [ "restArgs", ], + "barry": 223, "body": "return 321", "defaults": Object { "restArgs": undefined, @@ -8602,6 +9309,7 @@ Object { "isValid": true, "name": null, "params": "restArgs", + "qux": 123, "value": "((...restArgs) => {return 321})", } `; @@ -8609,6 +9317,7 @@ Object { exports[`#395 - espree.parse - () => {} 1`] = ` Object { "args": Array [], + "barry": 223, "body": "", "defaults": Object {}, "isAnonymous": true, @@ -8620,6 +9329,7 @@ Object { "isValid": true, "name": null, "params": "", + "qux": 123, "value": "(() => {})", } `; @@ -8629,6 +9339,7 @@ Object { "args": Array [ "a", ], + "barry": 223, "body": "", "defaults": Object { "a": "false", @@ -8642,6 +9353,7 @@ Object { "isValid": true, "name": null, "params": "a", + "qux": 123, "value": "((a = (true, false)) => {})", } `; @@ -8651,6 +9363,7 @@ Object { "args": Array [ "a", ], + "barry": 223, "body": "", "defaults": Object { "a": "null", @@ -8664,6 +9377,7 @@ Object { "isValid": true, "name": null, "params": "a", + "qux": 123, "value": "((a = (true, null)) => {})", } `; @@ -8673,6 +9387,7 @@ Object { "args": Array [ "a", ], + "barry": 223, "body": "", "defaults": Object { "a": "\\"bar\\"", @@ -8686,6 +9401,7 @@ Object { "isValid": true, "name": null, "params": "a", + "qux": 123, "value": "((a = (true, \\"bar\\")) => {})", } `; @@ -8696,6 +9412,7 @@ Object { "a", "b", ], + "barry": 223, "body": "", "defaults": Object { "a": undefined, @@ -8710,6 +9427,7 @@ Object { "isValid": true, "name": null, "params": "a, b", + "qux": 123, "value": "((a, b = (i++, true)) => {})", } `; @@ -8719,6 +9437,7 @@ Object { "args": Array [ "a", ], + "barry": 223, "body": "", "defaults": Object { "a": "1", @@ -8732,6 +9451,7 @@ Object { "isValid": true, "name": null, "params": "a", + "qux": 123, "value": "((a = 1) => {})", } `; @@ -8741,6 +9461,7 @@ Object { "args": Array [ "a", ], + "barry": 223, "body": "a * 3 * a", "defaults": Object { "a": undefined, @@ -8754,6 +9475,7 @@ Object { "isValid": true, "name": null, "params": "a", + "qux": 123, "value": "((a) => a * 3 * a)", } `; @@ -8763,6 +9485,7 @@ Object { "args": Array [ "d", ], + "barry": 223, "body": "d * 355 * d", "defaults": Object { "d": undefined, @@ -8776,6 +9499,7 @@ Object { "isValid": true, "name": null, "params": "d", + "qux": 123, "value": "(d => d * 355 * d)", } `; @@ -8785,6 +9509,7 @@ Object { "args": Array [ "e", ], + "barry": 223, "body": "return e + 5235 / e", "defaults": Object { "e": undefined, @@ -8798,6 +9523,7 @@ Object { "isValid": true, "name": null, "params": "e", + "qux": 123, "value": "(e => {return e + 5235 / e})", } `; @@ -8808,6 +9534,7 @@ Object { "a", "b", ], + "barry": 223, "body": "a + 3 + b", "defaults": Object { "a": undefined, @@ -8822,6 +9549,7 @@ Object { "isValid": true, "name": null, "params": "a, b", + "qux": 123, "value": "((a, b) => a + 3 + b)", } `; @@ -8833,6 +9561,7 @@ Object { "y", "restArgs", ], + "barry": 223, "body": "console.log({ value: x * y })", "defaults": Object { "restArgs": undefined, @@ -8848,6 +9577,7 @@ Object { "isValid": true, "name": null, "params": "x, y, restArgs", + "qux": 123, "value": "((x, y, ...restArgs) => console.log({ value: x * y }))", } `; @@ -8859,6 +9589,7 @@ Object { "cb", "restArgs", ], + "barry": 223, "body": "return a * 3", "defaults": Object { "a": "{foo: \\"ba)r\\", baz: 123}", @@ -8874,6 +9605,7 @@ Object { "isValid": true, "name": null, "params": "a, cb, restArgs", + "qux": 123, "value": "(async function (a = {foo: \\"ba)r\\", baz: 123}, cb, ...restArgs) {return a * 3})", } `; @@ -8885,6 +9617,7 @@ Object { "callback", "restArgs", ], + "barry": 223, "body": "callback(null, b + 3)", "defaults": Object { "b": undefined, @@ -8900,6 +9633,7 @@ Object { "isValid": true, "name": null, "params": "b, callback, restArgs", + "qux": 123, "value": "(async function (b, callback, ...restArgs) {callback(null, b + 3)})", } `; @@ -8909,6 +9643,7 @@ Object { "args": Array [ "c", ], + "barry": 223, "body": "return c * 3", "defaults": Object { "c": undefined, @@ -8922,6 +9657,7 @@ Object { "isValid": true, "name": null, "params": "c", + "qux": 123, "value": "(async function (c) {return c * 3})", } `; @@ -8931,6 +9667,7 @@ Object { "args": Array [ "restArgs", ], + "barry": 223, "body": "return 321", "defaults": Object { "restArgs": undefined, @@ -8944,6 +9681,7 @@ Object { "isValid": true, "name": null, "params": "restArgs", + "qux": 123, "value": "(async function (...restArgs) {return 321})", } `; @@ -8951,6 +9689,7 @@ Object { exports[`#410 - espree.parse - async function () {} 1`] = ` Object { "args": Array [], + "barry": 223, "body": "", "defaults": Object {}, "isAnonymous": true, @@ -8962,6 +9701,7 @@ Object { "isValid": true, "name": null, "params": "", + "qux": 123, "value": "(async function () {})", } `; @@ -8971,6 +9711,7 @@ Object { "args": Array [ "a", ], + "barry": 223, "body": "", "defaults": Object { "a": "false", @@ -8984,6 +9725,7 @@ Object { "isValid": true, "name": null, "params": "a", + "qux": 123, "value": "(async function (a = (true, false)) {})", } `; @@ -8993,6 +9735,7 @@ Object { "args": Array [ "a", ], + "barry": 223, "body": "", "defaults": Object { "a": "null", @@ -9006,6 +9749,7 @@ Object { "isValid": true, "name": null, "params": "a", + "qux": 123, "value": "(async function (a = (true, null)) {})", } `; @@ -9015,6 +9759,7 @@ Object { "args": Array [ "a", ], + "barry": 223, "body": "", "defaults": Object { "a": "\\"bar\\"", @@ -9028,6 +9773,7 @@ Object { "isValid": true, "name": null, "params": "a", + "qux": 123, "value": "(async function (a = (true, \\"bar\\")) {})", } `; @@ -9038,6 +9784,7 @@ Object { "a", "b", ], + "barry": 223, "body": "", "defaults": Object { "a": undefined, @@ -9052,6 +9799,7 @@ Object { "isValid": true, "name": null, "params": "a, b", + "qux": 123, "value": "(async function (a, b = (i++, true)) {})", } `; @@ -9061,6 +9809,7 @@ Object { "args": Array [ "a", ], + "barry": 223, "body": "", "defaults": Object { "a": "1", @@ -9074,6 +9823,7 @@ Object { "isValid": true, "name": null, "params": "a", + "qux": 123, "value": "(async function (a = 1) {})", } `; @@ -9085,6 +9835,7 @@ Object { "cb", "restArgs", ], + "barry": 223, "body": "return a * 3", "defaults": Object { "a": "{foo: \\"ba)r\\", baz: 123}", @@ -9100,6 +9851,7 @@ Object { "isValid": true, "name": "namedFn", "params": "a, cb, restArgs", + "qux": 123, "value": "(async function namedFn (a = {foo: \\"ba)r\\", baz: 123}, cb, ...restArgs) {return a * 3})", } `; @@ -9111,6 +9863,7 @@ Object { "callback", "restArgs", ], + "barry": 223, "body": "callback(null, b + 3)", "defaults": Object { "b": undefined, @@ -9126,6 +9879,7 @@ Object { "isValid": true, "name": "namedFn", "params": "b, callback, restArgs", + "qux": 123, "value": "(async function namedFn (b, callback, ...restArgs) {callback(null, b + 3)})", } `; @@ -9135,6 +9889,7 @@ Object { "args": Array [ "c", ], + "barry": 223, "body": "return c * 3", "defaults": Object { "c": undefined, @@ -9148,6 +9903,7 @@ Object { "isValid": true, "name": "namedFn", "params": "c", + "qux": 123, "value": "(async function namedFn (c) {return c * 3})", } `; @@ -9157,6 +9913,7 @@ Object { "args": Array [ "restArgs", ], + "barry": 223, "body": "return 321", "defaults": Object { "restArgs": undefined, @@ -9170,6 +9927,7 @@ Object { "isValid": true, "name": "namedFn", "params": "restArgs", + "qux": 123, "value": "(async function namedFn (...restArgs) {return 321})", } `; @@ -9177,6 +9935,7 @@ Object { exports[`#420 - espree.parse - async function namedFn () {} 1`] = ` Object { "args": Array [], + "barry": 223, "body": "", "defaults": Object {}, "isAnonymous": false, @@ -9188,6 +9947,7 @@ Object { "isValid": true, "name": "namedFn", "params": "", + "qux": 123, "value": "(async function namedFn () {})", } `; @@ -9197,6 +9957,7 @@ Object { "args": Array [ "a", ], + "barry": 223, "body": "", "defaults": Object { "a": "false", @@ -9210,6 +9971,7 @@ Object { "isValid": true, "name": "namedFn", "params": "a", + "qux": 123, "value": "(async function namedFn(a = (true, false)) {})", } `; @@ -9219,6 +9981,7 @@ Object { "args": Array [ "a", ], + "barry": 223, "body": "", "defaults": Object { "a": "null", @@ -9232,6 +9995,7 @@ Object { "isValid": true, "name": "namedFn", "params": "a", + "qux": 123, "value": "(async function namedFn(a = (true, null)) {})", } `; @@ -9241,6 +10005,7 @@ Object { "args": Array [ "a", ], + "barry": 223, "body": "", "defaults": Object { "a": "\\"bar\\"", @@ -9254,6 +10019,7 @@ Object { "isValid": true, "name": "namedFn", "params": "a", + "qux": 123, "value": "(async function namedFn(a = (true, \\"bar\\")) {})", } `; @@ -9264,6 +10030,7 @@ Object { "a", "b", ], + "barry": 223, "body": "", "defaults": Object { "a": undefined, @@ -9278,6 +10045,7 @@ Object { "isValid": true, "name": "namedFn", "params": "a, b", + "qux": 123, "value": "(async function namedFn(a, b = (i++, true)) {})", } `; @@ -9287,6 +10055,7 @@ Object { "args": Array [ "a", ], + "barry": 223, "body": "", "defaults": Object { "a": "1", @@ -9300,6 +10069,7 @@ Object { "isValid": true, "name": "namedFn", "params": "a", + "qux": 123, "value": "(async function namedFn(a = 1) {})", } `; @@ -9311,6 +10081,7 @@ Object { "cb", "restArgs", ], + "barry": 223, "body": "return a * 3", "defaults": Object { "a": "{foo: \\"ba)r\\", baz: 123}", @@ -9326,6 +10097,7 @@ Object { "isValid": true, "name": null, "params": "a, cb, restArgs", + "qux": 123, "value": "(async (a = {foo: \\"ba)r\\", baz: 123}, cb, ...restArgs) => {return a * 3})", } `; @@ -9337,6 +10109,7 @@ Object { "callback", "restArgs", ], + "barry": 223, "body": "callback(null, b + 3)", "defaults": Object { "b": undefined, @@ -9352,6 +10125,7 @@ Object { "isValid": true, "name": null, "params": "b, callback, restArgs", + "qux": 123, "value": "(async (b, callback, ...restArgs) => {callback(null, b + 3)})", } `; @@ -9361,6 +10135,7 @@ Object { "args": Array [ "c", ], + "barry": 223, "body": "return c * 3", "defaults": Object { "c": undefined, @@ -9374,6 +10149,7 @@ Object { "isValid": true, "name": null, "params": "c", + "qux": 123, "value": "(async (c) => {return c * 3})", } `; @@ -9383,6 +10159,7 @@ Object { "args": Array [ "restArgs", ], + "barry": 223, "body": "return 321", "defaults": Object { "restArgs": undefined, @@ -9396,6 +10173,7 @@ Object { "isValid": true, "name": null, "params": "restArgs", + "qux": 123, "value": "(async (...restArgs) => {return 321})", } `; @@ -9403,6 +10181,7 @@ Object { exports[`#430 - espree.parse - async () => {} 1`] = ` Object { "args": Array [], + "barry": 223, "body": "", "defaults": Object {}, "isAnonymous": true, @@ -9414,6 +10193,7 @@ Object { "isValid": true, "name": null, "params": "", + "qux": 123, "value": "(async () => {})", } `; @@ -9423,6 +10203,7 @@ Object { "args": Array [ "a", ], + "barry": 223, "body": "", "defaults": Object { "a": "false", @@ -9436,6 +10217,7 @@ Object { "isValid": true, "name": null, "params": "a", + "qux": 123, "value": "(async (a = (true, false)) => {})", } `; @@ -9445,6 +10227,7 @@ Object { "args": Array [ "a", ], + "barry": 223, "body": "", "defaults": Object { "a": "null", @@ -9458,6 +10241,7 @@ Object { "isValid": true, "name": null, "params": "a", + "qux": 123, "value": "(async (a = (true, null)) => {})", } `; @@ -9467,6 +10251,7 @@ Object { "args": Array [ "a", ], + "barry": 223, "body": "", "defaults": Object { "a": "\\"bar\\"", @@ -9480,6 +10265,7 @@ Object { "isValid": true, "name": null, "params": "a", + "qux": 123, "value": "(async (a = (true, \\"bar\\")) => {})", } `; @@ -9490,6 +10276,7 @@ Object { "a", "b", ], + "barry": 223, "body": "", "defaults": Object { "a": undefined, @@ -9504,6 +10291,7 @@ Object { "isValid": true, "name": null, "params": "a, b", + "qux": 123, "value": "(async (a, b = (i++, true)) => {})", } `; @@ -9513,6 +10301,7 @@ Object { "args": Array [ "a", ], + "barry": 223, "body": "", "defaults": Object { "a": "1", @@ -9526,6 +10315,7 @@ Object { "isValid": true, "name": null, "params": "a", + "qux": 123, "value": "(async (a = 1) => {})", } `; @@ -9535,6 +10325,7 @@ Object { "args": Array [ "a", ], + "barry": 223, "body": "a * 3 * a", "defaults": Object { "a": undefined, @@ -9548,6 +10339,7 @@ Object { "isValid": true, "name": null, "params": "a", + "qux": 123, "value": "(async (a) => a * 3 * a)", } `; @@ -9557,6 +10349,7 @@ Object { "args": Array [ "d", ], + "barry": 223, "body": "d * 355 * d", "defaults": Object { "d": undefined, @@ -9570,6 +10363,7 @@ Object { "isValid": true, "name": null, "params": "d", + "qux": 123, "value": "(async d => d * 355 * d)", } `; @@ -9579,6 +10373,7 @@ Object { "args": Array [ "e", ], + "barry": 223, "body": "return e + 5235 / e", "defaults": Object { "e": undefined, @@ -9592,6 +10387,7 @@ Object { "isValid": true, "name": null, "params": "e", + "qux": 123, "value": "(async e => {return e + 5235 / e})", } `; @@ -9602,6 +10398,7 @@ Object { "a", "b", ], + "barry": 223, "body": "a + 3 + b", "defaults": Object { "a": undefined, @@ -9616,6 +10413,7 @@ Object { "isValid": true, "name": null, "params": "a, b", + "qux": 123, "value": "(async (a, b) => a + 3 + b)", } `; @@ -9627,6 +10425,7 @@ Object { "y", "restArgs", ], + "barry": 223, "body": "console.log({ value: x * y })", "defaults": Object { "restArgs": undefined, @@ -9642,6 +10441,7 @@ Object { "isValid": true, "name": null, "params": "x, y, restArgs", + "qux": 123, "value": "(async (x, y, ...restArgs) => console.log({ value: x * y }))", } `; @@ -9690,8 +10490,8 @@ Object { "c", ], "body": " - return a + b + c; - ", + return a + b + c; + ", "defaults": Object { "a": undefined, "b": undefined, @@ -9707,8 +10507,8 @@ Object { "name": "foo", "params": "a, b, c", "value": "({ foo(a, b, c) { - return a + b + c; - } })", + return a + b + c; + } })", } `; @@ -9718,8 +10518,8 @@ Object { "a", ], "body": " - return () => a; - ", + return () => a; + ", "defaults": Object { "a": undefined, }, @@ -9733,8 +10533,8 @@ Object { "name": "bar", "params": "a", "value": "({ bar(a) { - return () => a; - } })", + return () => a; + } })", } `; @@ -9744,8 +10544,8 @@ Object { "a", ], "body": " - return yield a * 321; - ", + return yield a * 321; + ", "defaults": Object { "a": undefined, }, @@ -9759,8 +10559,8 @@ Object { "name": "gen", "params": "a", "value": "({ *gen(a) { - return yield a * 321; - } })", + return yield a * 321; + } })", } `; @@ -9808,6 +10608,6 @@ Object { "isValid": true, "name": null, "params": "v", - "value": "(async (v) => { if (v) {} })", + "value": "async (v) => { if (v) {} }", } `; diff --git a/packages/parse-function/test/index.js b/packages/parse-function/test/index.js index f197ec18..5ce57b5e 100644 --- a/packages/parse-function/test/index.js +++ b/packages/parse-function/test/index.js @@ -1,13 +1,13 @@ /* eslint-disable unicorn/consistent-function-scoping, no-plusplus */ import { parse as espreeParse } from 'espree'; -import { parse as babylonParse } from '@babel/parser'; +import { parse as babylonParse, parseExpression } from '@babel/parser'; import { parse as acornParse } from 'acorn'; import { parse as acornLooseParse } from 'acorn-loose'; import forIn from 'for-in'; -import { parseFunction } from '../src'; +// import { parseFunction } from '../src'; const fixtures = { regulars: [ @@ -85,174 +85,222 @@ let testsCount = 1; * the `acorn.parse` method. */ -function factory(parserName, parseFn) { - forIn(fixtures, (values) => { - values.forEach((code) => { - const actual = parseFn(code); - // const expected = expectedResults[key][i]; - const value = actual.value.replace(/^\(\{? ?/, '').replace(/\)$/, ''); - - test(`#${testsCount++} - ${parserName} - ${value}`, () => { - expect(actual).toMatchSnapshot(); +// locally, test both source and the dist files, for ensurances +const sources = [ + '../src/index.js', + process.env.LOCAL_TESTING === '1' && '../dist/cjs/index.js', + process.env.LOCAL_TESTING === '1' && '../dist/esm/index.js', +].filter(Boolean); + +/* eslint-disable no-loop-func */ + +// eslint-disable-next-line unicorn/no-for-loop +for (let i = 0; sources.length > i; i++) { + // eslint-disable-next-line global-require, import/no-dynamic-require + const { parseFunction } = require(sources[i]); + + // eslint-disable-next-line no-inner-declarations + function factory(parserName, parseFn) { + forIn(fixtures, (values) => { + values.forEach((code) => { + function quxPlugin(node, result) { + const qux = 123; + return { ...result, qux }; + } + function barryPlugin(node, result) { + return { barry: result.qux + 100 }; + } + + const plugins = [quxPlugin, barryPlugin]; + const actual = parseFn(code, null, plugins); + // const expected = expectedResults[key][i]; + const value = actual.value.replace(/^\(\{? ?/, '').replace(/\)$/, ''); + + test(`#${testsCount++} - ${parserName} - ${value}`, () => { + expect(actual).toMatchSnapshot(); + expect(actual.qux).toStrictEqual(123); + expect(actual.barry).toStrictEqual(223); + }); }); }); - }); - test(`#${testsCount++} - ${parserName} - should return object with default values when invalid`, () => { - const actual = parseFn(123456); + test(`#${testsCount++} - ${parserName} - should return object with default values when invalid`, () => { + const actual = parseFn(123456); - expect(actual).toMatchSnapshot(); - }); + expect(actual).toMatchSnapshot(); + }); - test(`#${testsCount++} - ${parserName} - should have '.isValid' and few '.is*'' hidden properties`, () => { - const actual = parseFn([1, 2, 3]); + test(`#${testsCount++} - ${parserName} - should have '.isValid' and few '.is*'' hidden properties`, () => { + const actual = parseFn([1, 2, 3]); - expect(actual).toMatchSnapshot(); - }); - - // bug in v4 and v5 - // https://github.com/tunnckoCore/parse-function/issues/3 - // test(`#${testsCount++} - ${parserName} - should not fails to get .body when something after close curly`, () => { - // const actual = parseFn('function (a) {return a * 2}; var b = 1') - // expect(actual.body, 'return a * 2') - // done() - // }) - - test(`#${testsCount++} - ${parserName} - should work when comment in arguments (see #11)`, () => { - const actual = parseFn('function (/* done */) { return 123 }'); - expect(actual.params).toStrictEqual(''); - expect(actual.body).toStrictEqual(' return 123 '); - - const res = parseFn('function (foo/* done */, bar) { return 123 }'); - expect(res.params).toStrictEqual('foo, bar'); - expect(res.body).toStrictEqual(' return 123 '); - }); + expect(actual).toMatchSnapshot(); + }); - test(`#${testsCount++} - ${parserName} - should support to parse generator functions`, () => { - const actual = parseFn('function * named (abc) { return abc + 123 }'); - expect(actual.name).toStrictEqual('named'); - expect(actual.params).toStrictEqual('abc'); - expect(actual.body).toStrictEqual(' return abc + 123 '); - }); + // bug in v4 and v5 + // https://github.com/tunnckoCore/parse-function/issues/3 + // test(`#${testsCount++} - ${parserName} - should not fails to get .body when something after close curly`, () => { + // const actual = parseFn('function (a) {return a * 2}; var b = 1') + // expect(actual.body, 'return a * 2') + // done() + // }) + + test(`#${testsCount++} - ${parserName} - should work when comment in arguments (see #11)`, () => { + const actual = parseFn('function (/* done */) { return 123 }'); + expect(actual.params).toStrictEqual(''); + expect(actual.body).toStrictEqual(' return 123 '); + + const res = parseFn('function (foo/* done */, bar) { return 123 }'); + expect(res.params).toStrictEqual('foo, bar'); + expect(res.body).toStrictEqual(' return 123 '); + }); - test(`#${testsCount++} - ${parserName} - should support to parse async functions (ES2016)`, () => { - const actual = parseFn('async function foo (bar) { return bar }'); - expect(actual.name).toStrictEqual('foo'); - expect(actual.params).toStrictEqual('bar'); - expect(actual.body).toStrictEqual(' return bar '); - }); + test(`#${testsCount++} - ${parserName} - should support to parse generator functions`, () => { + const actual = parseFn('function * named (abc) { return abc + 123 }'); + expect(actual.name).toStrictEqual('named'); + expect(actual.params).toStrictEqual('abc'); + expect(actual.body).toStrictEqual(' return abc + 123 '); + }); - test(`#${testsCount++} - ${parserName} - should parse a real function which is passed`, () => { - const actual = parseFn(function fooBar(a, bc) { - return a + bc; + test(`#${testsCount++} - ${parserName} - should support to parse async functions (ES2016)`, () => { + const actual = parseFn('async function foo (bar) { return bar }'); + expect(actual.name).toStrictEqual('foo'); + expect(actual.params).toStrictEqual('bar'); + expect(actual.body).toStrictEqual(' return bar '); }); - expect(actual.name).toStrictEqual('fooBar'); - expect(actual.params).toStrictEqual('a, bc'); - expect(actual.body).toStrictEqual('\n return a + bc;\n '); - }); - test(`#${testsCount++} - ${parserName} - should work for object methods`, () => { - const obj = { - foo(a, b, c) { - return a + b + c; - }, - bar(a) { - return () => a; - }, - *gen(a) { - return yield a * 321; - }, - }; + test(`#${testsCount++} - ${parserName} - should parse a real function which is passed`, () => { + const actual = parseFn(function fooBar(a, bc) { + return a + bc; + }); + expect(actual.name).toStrictEqual('fooBar'); + expect(actual.params).toStrictEqual('a, bc'); + expect(actual.body).toStrictEqual('\n return a + bc;\n '); + }); - const foo = parseFn(obj.foo); - expect(foo).toMatchSnapshot(); + test(`#${testsCount++} - ${parserName} - should work for object methods`, () => { + const obj = { + foo(a, b, c) { + return a + b + c; + }, + bar(a) { + return () => a; + }, + *gen(a) { + return yield a * 321; + }, + }; + + const foo = parseFn(obj.foo); + expect(foo).toMatchSnapshot(); + + const bar = parseFn(obj.bar); + expect(bar).toMatchSnapshot(); + + const gen = parseFn(obj.gen); + expect(gen).toMatchSnapshot(); + + const namedFn = `namedFn (a = {foo: 'ba)r', baz: 123}, cb, ...restArgs) { return a * 3 }`; + const namedFnc = parseFn(namedFn); + expect(namedFnc).toMatchSnapshot(); + }); - const bar = parseFn(obj.bar); - expect(bar).toMatchSnapshot(); + test(`#${testsCount++} - ${parserName} - plugins api`, () => { + const fnStr = `() => 123 + a + 44`; + const plugin = () => ({ called: 1 }); + // you may want to return the `result`, + // but it is the same as not return it + // return result + const result = parseFn(fnStr, {}, plugin); - const gen = parseFn(obj.gen); - expect(gen).toMatchSnapshot(); + expect(result.called).toStrictEqual(1); + }); - const namedFn = `namedFn (a = {foo: 'ba)r', baz: 123}, cb, ...restArgs) { return a * 3 }`; - const namedFnc = parseFn(namedFn); - expect(namedFnc).toMatchSnapshot(); - }); + test(`#${testsCount++} - ${parserName} - fn named "anonymous" has .name: 'anonymous'`, () => { + const result = parseFn('function anonymous () {}'); + expect(result.name).toStrictEqual('anonymous'); + expect(result.isAnonymous).toStrictEqual(false); + }); - test(`#${testsCount++} - ${parserName} - plugins api`, () => { - const fnStr = `() => 123 + a + 44`; - const plugin = () => ({ called: 1 }); - // you may want to return the `result`, - // but it is the same as not return it - // return result - const result = parseFn(fnStr, {}, plugin); + test(`#${testsCount++} - ${parserName} - real anonymous fn has .name: null`, () => { + const actual = parseFn('function () {}'); + expect(actual.name).toBeNull(); + expect(actual.isAnonymous).toStrictEqual(true); + }); + } + + /** + * Actually run all the tests + */ + + factory('babel (.parseExpression)', (code, opts, plugins) => + parseFunction(code, { ...opts, plugins }), + ); + + factory('options.parse: babel.parse', (code, opts, plugins) => + parseFunction(code, { ...opts, parse: babylonParse, plugins }), + ); + + factory('acorn.parse', (code, opts, plugins) => + parseFunction(code, { ...opts, parse: acornParse, plugins }), + ); + + factory('acorn loose', (code, opts, plugins) => + parseFunction(code, { + ...opts, + parse: acornLooseParse, + plugins, + }), + ); + + factory('espree.parse', (code, opts, plugins) => + parseFunction(code, { + ...opts, + parse: espreeParse, + plugins, + parserOptions: { + ecmaVersion: 8, + }, + }), + ); - expect(result.called).toStrictEqual(1); + // https://github.com/tunnckoCore/parse-function/issues/61 + test('should work with an async arrow function with an `if` statement', () => { + const parsed = parseFunction('async (v) => { if (v) {} }'); + expect(parsed).toMatchSnapshot(); }); - test(`#${testsCount++} - ${parserName} - fn named "anonymous" has .name: 'anonymous'`, () => { - const result = parseFn('function anonymous () {}'); + test(`fn named "anonymous" has .name: 'anonymous'`, () => { + const result = parseFunction(function anonymous() {}); + expect(result.name).toStrictEqual('anonymous'); expect(result.isAnonymous).toStrictEqual(false); }); - test(`#${testsCount++} - ${parserName} - real anonymous fn has .name: null`, () => { - const actual = parseFn('function () {}'); + test(`real anonymous fn has .name: null`, () => { + /* eslint-disable-next-line func-names, prefer-arrow-callback */ + const actual = parseFunction(function() {}, { parseExpression }); expect(actual.name).toBeNull(); expect(actual.isAnonymous).toStrictEqual(true); }); -} -/** - * Actually run all the tests - */ + test('work even if plugin does NOT return anything (result object)', () => { + const plugins = [ + (node, res) => { + expect(res.name).toStrictEqual('bie'); + }, + ]; -factory('babel (default)', (code, opts, plugins) => - parseFunction(code, { ...opts, plugins }), -); - -factory('options.parse', (code, opts, plugins) => - parseFunction(code, { ...opts, parse: babylonParse, plugins }), -); - -factory('acorn.parse', (code, opts, plugins) => - parseFunction(code, { ...opts, parse: acornParse, plugins }), -); - -factory('acorn loose', (code, opts, plugins) => - parseFunction(code, { - ...opts, - parse: acornLooseParse, - plugins, - }), -); - -factory('espree.parse', (code, opts, plugins) => - parseFunction(code, { - ...opts, - parse: espreeParse, - plugins, - parserOptions: { - ecmaVersion: 8, - }, - }), -); - -// https://github.com/tunnckoCore/parse-function/issues/61 -test('should work with an async arrow function with an `if` statement', () => { - const parsed = parseFunction('async (v) => { if (v) {} }'); - expect(parsed).toMatchSnapshot(); -}); - -test(`fn named "anonymous" has .name: 'anonymous'`, () => { - const result = parseFunction(function anonymous() {}); - - expect(result.name).toStrictEqual('anonymous'); - expect(result.isAnonymous).toStrictEqual(false); -}); - -test(`real anonymous fn has .name: null`, () => { - /* eslint-disable-next-line func-names, prefer-arrow-callback */ - const actual = parseFunction(function() {}); - expect(actual.name).toBeNull(); - expect(actual.isAnonymous).toStrictEqual(true); -}); + const parsed = parseFunction( + 'function bie(cc, xx) { return cc * 3 + xx; }', + { + plugins, + }, + ); + + expect(parsed.name).toStrictEqual('bie'); + expect(parsed.body).toStrictEqual(' return cc * 3 + xx; '); + expect(parsed.params).toStrictEqual('cc, xx'); + expect(parsed.isNamed).toStrictEqual(true); + expect(parsed.isAnonymous).toStrictEqual(false); + }); +} diff --git a/rollup.config.js b/rollup.config.js index 3adc1664..5ba5d2eb 100644 --- a/rollup.config.js +++ b/rollup.config.js @@ -11,7 +11,7 @@ const { extensions } = getWorkspacesAndExtensions(__dirname); process.env.ROLLUP_MIN = process.env.ROLLUP_MIN || '1'; -const externals = [].concat('@babel/core', '@babel/parser'); +const externals = [].concat('@babel/core', '@babel/parser', '@babel/types'); const tunnckocoreInterop = `const ___exportsWithoutDefault = Object.keys(exports) .filter((x) => x !== 'default') From 4cd4a833f7e802e76bdd283efc1c5c00b34d80da Mon Sep 17 00:00:00 2001 From: Charlike Mike Reagent Date: Thu, 24 Oct 2019 07:56:00 +0300 Subject: [PATCH 3/9] fix: require node >= 10.13 Signed-off-by: Charlike Mike Reagent --- packages/parse-function/README.md | 6 +++--- packages/parse-function/package.json | 2 +- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/packages/parse-function/README.md b/packages/parse-function/README.md index d5dd4c7e..d43aa617 100644 --- a/packages/parse-function/README.md +++ b/packages/parse-function/README.md @@ -87,7 +87,7 @@ _(TOC generated by [verb](https://github.com/verbose/verb) using [markdown-toc]( ## Install -This project requires [**Node.js**](https://nodejs.org) **>=8.11** _(see [Support & Release Policy](https://github.com/tunnckoCoreLabs/support-release-policy))_. Install it using +This project requires [**Node.js**](https://nodejs.org) **>=10.13** _(see [Support & Release Policy](https://github.com/tunnckoCoreLabs/support-release-policy))_. Install it using [**yarn**](https://yarnpkg.com) or [**npm**](https://npmjs.com).
_We highly recommend to use Yarn when you think to contribute to this project._ @@ -369,7 +369,7 @@ Consider showing your [support](#support-the-project) to them. :sparkling_heart: ## License Copyright (c) 2016-present, [Charlike Mike Reagent](https://tunnckocore.com) `` & [contributors](#wonderful-contributors).
-Released under the [MPL-2.0 License][license-url]. +Released under the [MIT License][license-url]. [contributing-url]: https://github.com/tunnckoCore/opensource/blob/master/CONTRIBUTING.md [code_of_conduct-url]: https://github.com/tunnckoCore/opensource/blob/master/CODE_OF_CONDUCT.md @@ -378,7 +378,7 @@ Released under the [MPL-2.0 License][license-url]. [npmv-url]: https://www.npmjs.com/package/parse-function [npmv-img]: https://badgen.net/npm/v/parse-function?icon=npm -[nodejs-img]: https://badgen.net/badge/node/>=8.11/green +[nodejs-img]: https://badgen.net/badge/node/>=10.13/green