@jsep-plugin/assignment
Advanced tools
Comparing version 1.1.0 to 1.2.0-beta.1
@@ -29,3 +29,3 @@ 'use strict'; | ||
const updateNodeTypes = [jsep.IDENTIFIER, jsep.MEMBER_EXP]; | ||
plugin.assignmentOperators.forEach(op => jsep.addBinaryOp(op, plugin.assignmentPrecedence)); | ||
plugin.assignmentOperators.forEach(op => jsep.addBinaryOp(op, plugin.assignmentPrecedence, true)); | ||
@@ -71,12 +71,19 @@ jsep.hooks.add('gobble-token', function gobbleUpdatePrefix(env) { | ||
// Update all binary assignment nodes in the tree | ||
updateBinariessToAssignments(env.node); | ||
updateBinariesToAssignments(env.node); | ||
} | ||
}); | ||
function updateBinariessToAssignments(node) { | ||
function updateBinariesToAssignments(node) { | ||
if (plugin.assignmentOperators.has(node.operator)) { | ||
node.type = 'AssignmentExpression'; | ||
updateBinariessToAssignments(node.left); | ||
updateBinariessToAssignments(node.right); | ||
updateBinariesToAssignments(node.left); | ||
updateBinariesToAssignments(node.right); | ||
} | ||
else if (!node.operator) { | ||
Object.values(node).forEach((val) => { | ||
if (val && typeof val === 'object') { | ||
updateBinariesToAssignments(val); | ||
} | ||
}); | ||
} | ||
} | ||
@@ -83,0 +90,0 @@ }, |
@@ -1,2 +0,2 @@ | ||
"use strict";const e={name:"assignment",assignmentOperators:new Set(["=","*=","**=","/=","%=","+=","-=","<<=",">>=",">>>=","&=","^=","|="]),updateOperators:[43,45],assignmentPrecedence:.9,init(t){const o=[t.IDENTIFIER,t.MEMBER_EXP];function n(t){e.assignmentOperators.has(t.operator)&&(t.type="AssignmentExpression",n(t.left),n(t.right))}e.assignmentOperators.forEach((o=>t.addBinaryOp(o,e.assignmentPrecedence))),t.hooks.add("gobble-token",(function(t){const n=this.code;e.updateOperators.some((e=>e===n&&e===this.expr.charCodeAt(this.index+1)))&&(this.index+=2,t.node={type:"UpdateExpression",operator:43===n?"++":"--",argument:this.gobbleTokenProperty(this.gobbleIdentifier()),prefix:!0},t.node.argument&&o.includes(t.node.argument.type)||this.throwError(`Unexpected ${t.node.operator}`))})),t.hooks.add("after-token",(function(t){if(t.node){const n=this.code;e.updateOperators.some((e=>e===n&&e===this.expr.charCodeAt(this.index+1)))&&(o.includes(t.node.type)||this.throwError(`Unexpected ${t.node.operator}`),this.index+=2,t.node={type:"UpdateExpression",operator:43===n?"++":"--",argument:t.node,prefix:!1})}})),t.hooks.add("after-expression",(function(e){e.node&&n(e.node)}))}};module.exports=e; | ||
"use strict";const e={name:"assignment",assignmentOperators:new Set(["=","*=","**=","/=","%=","+=","-=","<<=",">>=",">>>=","&=","^=","|="]),updateOperators:[43,45],assignmentPrecedence:.9,init(t){const o=[t.IDENTIFIER,t.MEMBER_EXP];function n(t){e.assignmentOperators.has(t.operator)?(t.type="AssignmentExpression",n(t.left),n(t.right)):t.operator||Object.values(t).forEach((e=>{e&&"object"==typeof e&&n(e)}))}e.assignmentOperators.forEach((o=>t.addBinaryOp(o,e.assignmentPrecedence,!0))),t.hooks.add("gobble-token",(function(t){const n=this.code;e.updateOperators.some((e=>e===n&&e===this.expr.charCodeAt(this.index+1)))&&(this.index+=2,t.node={type:"UpdateExpression",operator:43===n?"++":"--",argument:this.gobbleTokenProperty(this.gobbleIdentifier()),prefix:!0},t.node.argument&&o.includes(t.node.argument.type)||this.throwError(`Unexpected ${t.node.operator}`))})),t.hooks.add("after-token",(function(t){if(t.node){const n=this.code;e.updateOperators.some((e=>e===n&&e===this.expr.charCodeAt(this.index+1)))&&(o.includes(t.node.type)||this.throwError(`Unexpected ${t.node.operator}`),this.index+=2,t.node={type:"UpdateExpression",operator:43===n?"++":"--",argument:t.node,prefix:!1})}})),t.hooks.add("after-expression",(function(e){e.node&&n(e.node)}))}};module.exports=e; | ||
//# sourceMappingURL=index.cjs.min.js.map |
@@ -30,3 +30,3 @@ var index = (function () { | ||
const updateNodeTypes = [jsep.IDENTIFIER, jsep.MEMBER_EXP]; | ||
plugin.assignmentOperators.forEach(op => jsep.addBinaryOp(op, plugin.assignmentPrecedence)); | ||
plugin.assignmentOperators.forEach(op => jsep.addBinaryOp(op, plugin.assignmentPrecedence, true)); | ||
@@ -72,12 +72,19 @@ jsep.hooks.add('gobble-token', function gobbleUpdatePrefix(env) { | ||
// Update all binary assignment nodes in the tree | ||
updateBinariessToAssignments(env.node); | ||
updateBinariesToAssignments(env.node); | ||
} | ||
}); | ||
function updateBinariessToAssignments(node) { | ||
function updateBinariesToAssignments(node) { | ||
if (plugin.assignmentOperators.has(node.operator)) { | ||
node.type = 'AssignmentExpression'; | ||
updateBinariessToAssignments(node.left); | ||
updateBinariessToAssignments(node.right); | ||
updateBinariesToAssignments(node.left); | ||
updateBinariesToAssignments(node.right); | ||
} | ||
else if (!node.operator) { | ||
Object.values(node).forEach((val) => { | ||
if (val && typeof val === 'object') { | ||
updateBinariesToAssignments(val); | ||
} | ||
}); | ||
} | ||
} | ||
@@ -84,0 +91,0 @@ }, |
@@ -1,2 +0,2 @@ | ||
var index=function(){"use strict";const e={name:"assignment",assignmentOperators:new Set(["=","*=","**=","/=","%=","+=","-=","<<=",">>=",">>>=","&=","^=","|="]),updateOperators:[43,45],assignmentPrecedence:.9,init(t){const n=[t.IDENTIFIER,t.MEMBER_EXP];function o(t){e.assignmentOperators.has(t.operator)&&(t.type="AssignmentExpression",o(t.left),o(t.right))}e.assignmentOperators.forEach((n=>t.addBinaryOp(n,e.assignmentPrecedence))),t.hooks.add("gobble-token",(function(t){const o=this.code;e.updateOperators.some((e=>e===o&&e===this.expr.charCodeAt(this.index+1)))&&(this.index+=2,t.node={type:"UpdateExpression",operator:43===o?"++":"--",argument:this.gobbleTokenProperty(this.gobbleIdentifier()),prefix:!0},t.node.argument&&n.includes(t.node.argument.type)||this.throwError(`Unexpected ${t.node.operator}`))})),t.hooks.add("after-token",(function(t){if(t.node){const o=this.code;e.updateOperators.some((e=>e===o&&e===this.expr.charCodeAt(this.index+1)))&&(n.includes(t.node.type)||this.throwError(`Unexpected ${t.node.operator}`),this.index+=2,t.node={type:"UpdateExpression",operator:43===o?"++":"--",argument:t.node,prefix:!1})}})),t.hooks.add("after-expression",(function(e){e.node&&o(e.node)}))}};return e}(); | ||
var index=function(){"use strict";const e={name:"assignment",assignmentOperators:new Set(["=","*=","**=","/=","%=","+=","-=","<<=",">>=",">>>=","&=","^=","|="]),updateOperators:[43,45],assignmentPrecedence:.9,init(t){const o=[t.IDENTIFIER,t.MEMBER_EXP];function n(t){e.assignmentOperators.has(t.operator)?(t.type="AssignmentExpression",n(t.left),n(t.right)):t.operator||Object.values(t).forEach((e=>{e&&"object"==typeof e&&n(e)}))}e.assignmentOperators.forEach((o=>t.addBinaryOp(o,e.assignmentPrecedence,!0))),t.hooks.add("gobble-token",(function(t){const n=this.code;e.updateOperators.some((e=>e===n&&e===this.expr.charCodeAt(this.index+1)))&&(this.index+=2,t.node={type:"UpdateExpression",operator:43===n?"++":"--",argument:this.gobbleTokenProperty(this.gobbleIdentifier()),prefix:!0},t.node.argument&&o.includes(t.node.argument.type)||this.throwError(`Unexpected ${t.node.operator}`))})),t.hooks.add("after-token",(function(t){if(t.node){const n=this.code;e.updateOperators.some((e=>e===n&&e===this.expr.charCodeAt(this.index+1)))&&(o.includes(t.node.type)||this.throwError(`Unexpected ${t.node.operator}`),this.index+=2,t.node={type:"UpdateExpression",operator:43===n?"++":"--",argument:t.node,prefix:!1})}})),t.hooks.add("after-expression",(function(e){e.node&&n(e.node)}))}};return e}(); | ||
//# sourceMappingURL=index.iife.min.js.map |
@@ -27,3 +27,3 @@ const PLUS_CODE = 43; // + | ||
const updateNodeTypes = [jsep.IDENTIFIER, jsep.MEMBER_EXP]; | ||
plugin.assignmentOperators.forEach(op => jsep.addBinaryOp(op, plugin.assignmentPrecedence)); | ||
plugin.assignmentOperators.forEach(op => jsep.addBinaryOp(op, plugin.assignmentPrecedence, true)); | ||
@@ -69,12 +69,19 @@ jsep.hooks.add('gobble-token', function gobbleUpdatePrefix(env) { | ||
// Update all binary assignment nodes in the tree | ||
updateBinariessToAssignments(env.node); | ||
updateBinariesToAssignments(env.node); | ||
} | ||
}); | ||
function updateBinariessToAssignments(node) { | ||
function updateBinariesToAssignments(node) { | ||
if (plugin.assignmentOperators.has(node.operator)) { | ||
node.type = 'AssignmentExpression'; | ||
updateBinariessToAssignments(node.left); | ||
updateBinariessToAssignments(node.right); | ||
updateBinariesToAssignments(node.left); | ||
updateBinariesToAssignments(node.right); | ||
} | ||
else if (!node.operator) { | ||
Object.values(node).forEach((val) => { | ||
if (val && typeof val === 'object') { | ||
updateBinariesToAssignments(val); | ||
} | ||
}); | ||
} | ||
} | ||
@@ -81,0 +88,0 @@ }, |
@@ -1,2 +0,2 @@ | ||
const e={name:"assignment",assignmentOperators:new Set(["=","*=","**=","/=","%=","+=","-=","<<=",">>=",">>>=","&=","^=","|="]),updateOperators:[43,45],assignmentPrecedence:.9,init(t){const o=[t.IDENTIFIER,t.MEMBER_EXP];function n(t){e.assignmentOperators.has(t.operator)&&(t.type="AssignmentExpression",n(t.left),n(t.right))}e.assignmentOperators.forEach((o=>t.addBinaryOp(o,e.assignmentPrecedence))),t.hooks.add("gobble-token",(function(t){const n=this.code;e.updateOperators.some((e=>e===n&&e===this.expr.charCodeAt(this.index+1)))&&(this.index+=2,t.node={type:"UpdateExpression",operator:43===n?"++":"--",argument:this.gobbleTokenProperty(this.gobbleIdentifier()),prefix:!0},t.node.argument&&o.includes(t.node.argument.type)||this.throwError(`Unexpected ${t.node.operator}`))})),t.hooks.add("after-token",(function(t){if(t.node){const n=this.code;e.updateOperators.some((e=>e===n&&e===this.expr.charCodeAt(this.index+1)))&&(o.includes(t.node.type)||this.throwError(`Unexpected ${t.node.operator}`),this.index+=2,t.node={type:"UpdateExpression",operator:43===n?"++":"--",argument:t.node,prefix:!1})}})),t.hooks.add("after-expression",(function(e){e.node&&n(e.node)}))}};export{e as default}; | ||
const e={name:"assignment",assignmentOperators:new Set(["=","*=","**=","/=","%=","+=","-=","<<=",">>=",">>>=","&=","^=","|="]),updateOperators:[43,45],assignmentPrecedence:.9,init(t){const o=[t.IDENTIFIER,t.MEMBER_EXP];function n(t){e.assignmentOperators.has(t.operator)?(t.type="AssignmentExpression",n(t.left),n(t.right)):t.operator||Object.values(t).forEach((e=>{e&&"object"==typeof e&&n(e)}))}e.assignmentOperators.forEach((o=>t.addBinaryOp(o,e.assignmentPrecedence,!0))),t.hooks.add("gobble-token",(function(t){const n=this.code;e.updateOperators.some((e=>e===n&&e===this.expr.charCodeAt(this.index+1)))&&(this.index+=2,t.node={type:"UpdateExpression",operator:43===n?"++":"--",argument:this.gobbleTokenProperty(this.gobbleIdentifier()),prefix:!0},t.node.argument&&o.includes(t.node.argument.type)||this.throwError(`Unexpected ${t.node.operator}`))})),t.hooks.add("after-token",(function(t){if(t.node){const n=this.code;e.updateOperators.some((e=>e===n&&e===this.expr.charCodeAt(this.index+1)))&&(o.includes(t.node.type)||this.throwError(`Unexpected ${t.node.operator}`),this.index+=2,t.node={type:"UpdateExpression",operator:43===n?"++":"--",argument:t.node,prefix:!1})}})),t.hooks.add("after-expression",(function(e){e.node&&n(e.node)}))}};export{e as default}; | ||
//# sourceMappingURL=index.min.js.map |
{ | ||
"name": "@jsep-plugin/assignment", | ||
"version": "1.1.0", | ||
"version": "1.2.0-beta.1", | ||
"description": "Adds assignment expression support", | ||
@@ -5,0 +5,0 @@ "author": "Shelly (https://github.com/6utt3rfly)", |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
No v1
QualityPackage is not semver >=1. This means it is not stable and does not support ^ ranges.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
38977
299
2