pax_global_header00006660000000000000000000000064132351560470014520gustar00rootroot0000000000000052 comment=55b72c358ea6da83d21cf441dc6f61d0de59de42 acorn5-object-spread-5.1.2/000077500000000000000000000000001323515604700154345ustar00rootroot00000000000000acorn5-object-spread-5.1.2/.editorconfig000066400000000000000000000001431323515604700201070ustar00rootroot00000000000000root = true [*] indent_style = space indent_size = 2 end_of_line = lf insert_final_newline = true acorn5-object-spread-5.1.2/.gitattributes000066400000000000000000000000161323515604700203240ustar00rootroot00000000000000* text eol=lf acorn5-object-spread-5.1.2/.gitignore000066400000000000000000000000161323515604700174210ustar00rootroot00000000000000/node_modules acorn5-object-spread-5.1.2/.npmignore000066400000000000000000000000101323515604700174220ustar00rootroot00000000000000test .* acorn5-object-spread-5.1.2/.travis.yml000066400000000000000000000000421323515604700175410ustar00rootroot00000000000000language: node_js node_js: '0.10' acorn5-object-spread-5.1.2/CHANGELOG.md000066400000000000000000000012431323515604700172450ustar00rootroot00000000000000# acorn5-object-spread changelog ## 5.1.1 * Backport check for default values from acorn 5.3.0 ## 5.1.0 * Make plugin compatible with acorn 5.3.x ## 5.0.0 * Require acorn 5.2.x ## 4.0.0 * Remove support for complex rest properties since they are forbidded by the spec ## 3.1.0 * Support complex rest properties like `{...{a = 5, ...as}}` * Support rest properties in arrow function arguments * Fail if rest property is not last property or has a trailing comma * Detect duplicate exports with rest properties * Don't complain about duplicate property names in patterns ## 3.0.0 * Support rest properties * Emit `SpreadElement` instead of `SpreadProperty` nodes acorn5-object-spread-5.1.2/LICENSE000066400000000000000000000020371323515604700164430ustar00rootroot00000000000000Copyright (C) 2016 by UXtemple Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. acorn5-object-spread-5.1.2/README.md000066400000000000000000000005661323515604700167220ustar00rootroot00000000000000# Spread and rest properties support in acorn 5 [![NPM version](https://img.shields.io/npm/v/acorn5-object-spread.svg)](https://www.npmjs.org/package/acorn5-object-spread) Since spread and rest properties are part of ECMAScript 2018, acorn now supports them out of the box. Just make sure that you use acorn >= 5.4.1 and set `ecmaVersion` >= 9. This plugin is deprecated. acorn5-object-spread-5.1.2/index.js000066400000000000000000000001071323515604700170770ustar00rootroot00000000000000'use strict'; module.exports = require('./inject')(require('acorn')); acorn5-object-spread-5.1.2/inject.js000066400000000000000000000101471323515604700172510ustar00rootroot00000000000000'use strict'; module.exports = function(acorn) { let acornVersion = acorn.version.match(/^5\.(\d+)\./) if (!acornVersion || Number(acornVersion[1]) < 2) { throw new Error("Unsupported acorn version " + acorn.version + ", please use acorn 5 >= 5.2"); } var tt = acorn.tokTypes; const getCheckLVal = origCheckLVal => function (expr, bindingType, checkClashes) { if (expr.type == "ObjectPattern") { for (let prop of expr.properties) this.checkLVal(prop, bindingType, checkClashes) return } else if (expr.type === "Property") { // AssignmentProperty has type == "Property" return this.checkLVal(expr.value, bindingType, checkClashes) } return origCheckLVal.apply(this, arguments) } acorn.plugins.objectSpread = function objectSpreadPlugin(instance) { instance.extend("parseProperty", nextMethod => function (isPattern, refDestructuringErrors) { if (this.options.ecmaVersion >= 6 && this.type === tt.ellipsis) { let prop if (isPattern) { prop = this.startNode() this.next() prop.argument = this.parseIdent() this.finishNode(prop, "RestElement") } else { prop = this.parseSpread(refDestructuringErrors) } if (this.type === tt.comma) { if (isPattern) { this.raise(this.start, "Comma is not permitted after the rest element") } else if (refDestructuringErrors && refDestructuringErrors.trailingComma < 0) { refDestructuringErrors.trailingComma = this.start } } return prop } return nextMethod.apply(this, arguments) }) instance.extend("checkPropClash", nextMethod => function(prop, propHash) { if (prop.type == "SpreadElement" || prop.type == "RestElement") return return nextMethod.apply(this, arguments) }) instance.extend("checkLVal", getCheckLVal) // This backports toAssignable from 5.3.0 to 5.2.x instance.extend("toAssignable", nextMethod => function(node, isBinding, refDestructuringErrors) { if (this.options.ecmaVersion >= 6 && node) { if (node.type == "ObjectExpression") { node.type = "ObjectPattern" if (refDestructuringErrors) this.checkPatternErrors(refDestructuringErrors, true) for (let prop of node.properties) this.toAssignable(prop, isBinding, refDestructuringErrors) return node } else if (node.type === "Property") { // AssignmentProperty has type == "Property" if (node.kind !== "init") this.raise(node.key.start, "Object pattern can't contain getter or setter") return this.toAssignable(node.value, isBinding, refDestructuringErrors) } else if (node.type === "SpreadElement") { node.type = "RestElement" this.toAssignable(node.argument, isBinding, refDestructuringErrors) if (node.argument.type === "AssignmentPattern") this.raise(node.argument.start, "Rest elements cannot have a default value") return } } return nextMethod.apply(this, arguments) }) instance.extend("toAssignableList", nextMethod => function (exprList, isBinding) { const result = nextMethod.call(this, exprList, isBinding) if (exprList.length && exprList[exprList.length - 1] && exprList[exprList.length - 1].type === "RestElement") { // Backport check from 5.3.0 if (exprList[exprList.length - 1].argument.type === "AssignmentPattern") this.raise(exprList[exprList.length - 1].argument.start, "Rest elements cannot have a default value") } return result }) instance.extend("checkPatternExport", nextMethod => function(exports, pat) { if (pat.type == "ObjectPattern") { for (let prop of pat.properties) this.checkPatternExport(exports, prop) return } else if (pat.type === "Property") { return this.checkPatternExport(exports, pat.value) } else if (pat.type === "RestElement") { return this.checkPatternExport(exports, pat.argument) } nextMethod.apply(this, arguments) }) }; return acorn; }; acorn5-object-spread-5.1.2/package.json000066400000000000000000000010331323515604700177170ustar00rootroot00000000000000{ "name": "acorn5-object-spread", "description": "Support for rest and spread properties in acorn 5", "homepage": "https://github.com/adrianheine/acorn5-object-spread", "contributors": [ "DarĂ­o Javier Cravero ", "Adrian Heine " ], "repository": { "type": "git", "url": "https://github.com/adrianheine/acorn5-object-spread" }, "license": "MIT", "scripts": { "test": "node test/run.js" }, "dependencies": { "acorn": "^5.2.1" }, "version": "5.1.2" } acorn5-object-spread-5.1.2/test/000077500000000000000000000000001323515604700164135ustar00rootroot00000000000000acorn5-object-spread-5.1.2/test/driver.js000066400000000000000000000065651323515604700202600ustar00rootroot00000000000000var tests = []; exports.test = function(code, ast, options) { tests.push({code: code, ast: ast, options: options}); }; exports.testFail = function(code, message, options) { tests.push({code: code, error: message, options: options}); }; exports.testAssert = function(code, assert, options) { tests.push({code: code, assert: assert, options: options}); }; exports.runTests = function(config, callback) { var parse = config.parse; for (var i = 0; i < tests.length; ++i) { var test = tests[i]; if (config.filter && !config.filter(test)) continue; try { var testOpts = test.options || {locations: true}; var expected = {}; if (expected.onComment = testOpts.onComment) { testOpts.onComment = [] } if (expected.onToken = testOpts.onToken) { testOpts.onToken = []; } testOpts.plugins = testOpts.plugins || { objectSpread: true }; var ast = parse(test.code, testOpts); if (test.error) { if (config.loose) { callback("ok", test.code); } else { callback("fail", test.code, "Expected error message: " + test.error + "\nBut parsing succeeded."); } } else if (test.assert) { var error = test.assert(ast); if (error) callback("fail", test.code, "\n Assertion failed:\n " + error); else callback("ok", test.code); } else { var mis = misMatch(test.ast, ast); for (var name in expected) { if (mis) break; if (expected[name]) { mis = misMatch(expected[name], testOpts[name]); testOpts[name] = expected[name]; } } if (mis) callback("fail", test.code, mis); else callback("ok", test.code); } } catch(e) { if (!(e instanceof SyntaxError)) { throw e; } if (test.error) { if (e.message == test.error) callback("ok", test.code); else callback("fail", test.code, "Expected error message: " + test.error + "\nGot error message: " + e.message); } else { callback("error", test.code, e.stack || e.toString()); } } } }; function ppJSON(v) { return v instanceof RegExp ? v.toString() : JSON.stringify(v, null, 2); } function addPath(str, pt) { if (str.charAt(str.length-1) == ")") return str.slice(0, str.length-1) + "/" + pt + ")"; return str + " (" + pt + ")"; } var misMatch = exports.misMatch = function(exp, act) { if (!exp || !act || (typeof exp != "object") || (typeof act != "object")) { if (exp !== act) return ppJSON(exp) + " !== " + ppJSON(act); } else if (exp instanceof RegExp || act instanceof RegExp) { var left = ppJSON(exp), right = ppJSON(act); if (left !== right) return left + " !== " + right; } else if (exp.splice) { if (!act.slice) return ppJSON(exp) + " != " + ppJSON(act); if (act.length != exp.length) return "array length mismatch " + exp.length + " != " + act.length; for (var i = 0; i < act.length; ++i) { var mis = misMatch(exp[i], act[i]); if (mis) return addPath(mis, i); } } else { for (var prop in exp) { var mis = misMatch(exp[prop], act[prop]); if (mis) return addPath(mis, prop); } for (var prop in act) { if (!(prop in exp)) { var mis = misMatch(exp[prop], act[prop]); if (mis) return addPath(mis, prop); } } } }; acorn5-object-spread-5.1.2/test/run.js000066400000000000000000000026511323515604700175610ustar00rootroot00000000000000var driver = require("./driver.js"); require("./tests-object-spread.js"); function group(name) { if (typeof console === "object" && console.group) { console.group(name); } } function groupEnd() { if (typeof console === "object" && console.groupEnd) { console.groupEnd(name); } } function log(title, message) { if (typeof console === "object") console.log(title, message); } var stats, modes = { Normal: { config: { parse: require("..").parse } } }; function report(state, code, message) { if (state != "ok") {++stats.failed; log(code, message);} ++stats.testsRun; } group("Errors"); for (var name in modes) { group(name); var mode = modes[name]; stats = mode.stats = {testsRun: 0, failed: 0}; var t0 = +new Date; driver.runTests(mode.config, report); mode.stats.duration = +new Date - t0; groupEnd(); } groupEnd(); function outputStats(name, stats) { log(name + ":", stats.testsRun + " tests run in " + stats.duration + "ms; " + (stats.failed ? stats.failed + " failures." : "all passed.")); } var total = {testsRun: 0, failed: 0, duration: 0}; group("Stats"); for (var name in modes) { var stats = modes[name].stats; outputStats(name + " parser", stats); for (var key in stats) total[key] += stats[key]; } outputStats("Total", total); groupEnd(); if (total.failed && typeof process === "object") { process.stdout.write("", function() { process.exit(1); }); } acorn5-object-spread-5.1.2/test/tests-object-spread.js000066400000000000000000000352671323515604700226500ustar00rootroot00000000000000// ObjectSpread tests var fbTestFixture = { // Taken and adapted from babylon's tests. 'ObjectSpread': { 'let z = {...x}': { "type": "VariableDeclaration", "start": 0, "end": 14, "declarations": [ { "type": "VariableDeclarator", "start": 4, "end": 14, "id": { "type": "Identifier", "start": 4, "end": 5, "name": "z" }, "init": { "type": "ObjectExpression", "start": 8, "end": 14, "properties": [ { "type": "SpreadElement", "start": 9, "end": 13, "argument": { "type": "Identifier", "start": 12, "end": 13, "name": "x" } } ] } } ], "kind": "let" }, 'z = {x, ...y}': { "type": "ExpressionStatement", "start": 0, "end": 13, "expression": { "type": "AssignmentExpression", "start": 0, "end": 13, "operator": "=", "left": { "type": "Identifier", "start": 0, "end": 1, "name": "z" }, "right": { "type": "ObjectExpression", "start": 4, "end": 13, "properties": [ { "type": "Property", "start": 5, "end": 6, "method": false, "shorthand": true, "computed": false, "key": { "type": "Identifier", "start": 5, "end": 6, "name": "x" }, "value": { "type": "Identifier", "start": 5, "end": 6, "name": "x" }, "kind": "init" }, { "type": "SpreadElement", "start": 8, "end": 12, "argument": { "type": "Identifier", "start": 11, "end": 12, "name": "y" } } ] } } }, '({x, ...y, a, ...b, c})': { "type": "ExpressionStatement", "start": 0, "end": 23, "expression": { "type": "ObjectExpression", "start": 1, "end": 22, "properties": [ { "type": "Property", "start": 2, "end": 3, "method": false, "shorthand": true, "computed": false, "key": { "type": "Identifier", "start": 2, "end": 3, "name": "x" }, "value": { "type": "Identifier", "start": 2, "end": 3, "name": "x" }, "kind": "init" }, { "type": "SpreadElement", "start": 5, "end": 9, "argument": { "type": "Identifier", "start": 8, "end": 9, "name": "y" } }, { "type": "Property", "start": 11, "end": 12, "method": false, "shorthand": true, "computed": false, "key": { "type": "Identifier", "start": 11, "end": 12, "name": "a" }, "value": { "type": "Identifier", "start": 11, "end": 12, "name": "a" }, "kind": "init" }, { "type": "SpreadElement", "start": 14, "end": 18, "argument": { "type": "Identifier", "start": 17, "end": 18, "name": "b" } }, { "type": "Property", "start": 20, "end": 21, "method": false, "shorthand": true, "computed": false, "key": { "type": "Identifier", "start": 20, "end": 21, "name": "c" }, "value": { "type": "Identifier", "start": 20, "end": 21, "name": "c" }, "kind": "init" } ] } }, "var someObject = { someKey: { ...mapGetters([ 'some_val_1', 'some_val_2' ]) } }": { "type": "VariableDeclaration", "start": 0, "end": 79, "declarations": [ { "type": "VariableDeclarator", "start": 4, "end": 79, "id": { "type": "Identifier", "start": 4, "end": 14, "name": "someObject" }, "init": { "type": "ObjectExpression", "start": 17, "end": 79, "properties": [ { "type": "Property", "start": 19, "end": 77, "method": false, "shorthand": false, "computed": false, "key": { "type": "Identifier", "start": 19, "end": 26, "name": "someKey" }, "value": { "type": "ObjectExpression", "start": 28, "end": 77, "properties": [ { "type": "SpreadElement", "start": 30, "end": 75, "argument": { "type": "CallExpression", "start": 33, "end": 75, "callee": { "type": "Identifier", "start": 33, "end": 43, "name": "mapGetters" }, "arguments": [ { "type": "ArrayExpression", "start": 44, "end": 74, "elements": [ { "type": "Literal", "start": 46, "end": 58, "value": "some_val_1", "raw": "'some_val_1'" }, { "type": "Literal", "start": 60, "end": 72, "value": "some_val_2", "raw": "'some_val_2'" } ] } ] } } ] }, "kind": "init" } ] } } ], "kind": "var" } }, 'ObjectRest': { 'let {x, ...y} = v': { "type": "VariableDeclaration", "start": 0, "end": 17, "declarations": [ { "type": "VariableDeclarator", "start": 4, "end": 17, "id": { "type": "ObjectPattern", "start": 4, "end": 13, "properties": [ { "type": "Property", "start": 5, "end": 6, "method": false, "shorthand": true, "computed": false, "key": { "type": "Identifier", "start": 5, "end": 6, "name": "x" }, "kind": "init", "value": { "type": "Identifier", "start": 5, "end": 6, "name": "x" } }, { "type": "RestElement", "start": 8, "end": 12, "argument": { "type": "Identifier", "start": 11, "end": 12, "name": "y" } } ] }, "init": { "type": "Identifier", "start": 16, "end": 17, "name": "v" } } ], "kind": "let" }, '(function({x, ...y}) {})': { "type": "ExpressionStatement", "start": 0, "end": 24, "expression": { "type": "FunctionExpression", "start": 1, "end": 23, "id": null, "generator": false, "expression": false, "params": [ { "type": "ObjectPattern", "start": 10, "end": 19, "properties": [ { "type": "Property", "start": 11, "end": 12, "method": false, "shorthand": true, "computed": false, "key": { "type": "Identifier", "start": 11, "end": 12, "name": "x" }, "kind": "init", "value": { "type": "Identifier", "start": 11, "end": 12, "name": "x" } }, { "type": "RestElement", "start": 14, "end": 18, "argument": { "type": "Identifier", "start": 17, "end": 18, "name": "y" } } ] } ], "body": { "type": "BlockStatement", "start": 21, "end": 23, "body": [] } } }, 'const fn = ({text = "default", ...props}) => text + props.children': { "type": "VariableDeclaration", "start": 0, "end": 66, "declarations": [ { "type": "VariableDeclarator", "start": 6, "end": 66, "id": { "type": "Identifier", "start": 6, "end": 8, "name": "fn" }, "init": { "type": "ArrowFunctionExpression", "start": 11, "end": 66, "id": null, "generator": false, "expression": true, "params": [ { "type": "ObjectPattern", "start": 12, "end": 40, "properties": [ { "type": "Property", "start": 13, "end": 29, "method": false, "shorthand": true, "computed": false, "key": { "type": "Identifier", "start": 13, "end": 17, "name": "text" }, "kind": "init", "value": { "type": "AssignmentPattern", "start": 13, "end": 29, "left": { "type": "Identifier", "start": 13, "end": 17, "name": "text" }, "right": { "type": "Literal", "start": 20, "end": 29, "value": "default", "raw": "\"default\"" } } }, { "type": "RestElement", "start": 31, "end": 39, "argument": { "type": "Identifier", "start": 34, "end": 39, "name": "props" } } ] } ], "body": { "type": "BinaryExpression", "start": 45, "end": 66, "left": { "type": "Identifier", "start": 45, "end": 49, "name": "text" }, "operator": "+", "right": { "type": "MemberExpression", "start": 52, "end": 66, "object": { "type": "Identifier", "start": 52, "end": 57, "name": "props" }, "property": { "type": "Identifier", "start": 58, "end": 66, "name": "children" }, "computed": false } } } } ], "kind": "const" } } }; if (typeof exports !== "undefined") { var test = require("./driver.js").test; var testFail = require("./driver.js").testFail; var tokTypes = require("../").tokTypes; } testFail("({get x() {}}) => {}", "Object pattern can't contain getter or setter (1:6)") testFail("let {...x, ...y} = {}", "Comma is not permitted after the rest element (1:9)") testFail("({...x,}) => z", "Comma is not permitted after the rest element (1:6)") testFail("export const { foo, ...bar } = baz;\nexport const bar = 1;\n", "Identifier 'bar' has already been declared (2:13)", { sourceType: "module" }) testFail("function ({...x,}) { z }", "Unexpected token (1:9)") testFail("let {...{x, y}} = {}", "Unexpected token (1:8)") testFail("let {...{...{x, y}}} = {}", "Unexpected token (1:8)") testFail("0, {...rest, b} = {}", "Comma is not permitted after the rest element (1:11)") testFail("(([a, ...b = 0]) => {})", "Rest elements cannot have a default value (1:9)") testFail("(({a, ...b = 0}) => {})", "Rest elements cannot have a default value (1:9)") for (var ns in fbTestFixture) { ns = fbTestFixture[ns]; for (var code in ns) { test(code, { type: 'Program', body: [ns[code]], start: 0, end: code.length, sourceType: "script" }, { ecmaVersion: 7 }); } }