@jsep-plugin/assignment
Advanced tools
| import * as jsep from 'jsep'; | ||
| import { Expression } from 'jsep'; | ||
| export const name: string; | ||
| export function init(this: typeof jsep): void; | ||
| export interface UpdateExpression extends Expression { | ||
| type: 'UpdateExpression'; | ||
| operator: '++' | '--'; | ||
| argument: Expression; | ||
| prefix: boolean; | ||
| } | ||
| export interface AssignmentExpression extends Expression { | ||
| type: 'AssignmentExpression'; | ||
| operator: '=' | ||
| | '*=' | ||
| | '**=' | ||
| | '/=' | ||
| | '%=' | ||
| | '+=' | ||
| | '-=' | ||
| | '<<=' | ||
| | '>>=' | ||
| | '>>>=' | ||
| | '&=' | ||
| | '^=' | ||
| | '|='; | ||
| left: Expression; | ||
| right: Expression; | ||
| } |
@@ -30,5 +30,6 @@ 'use strict'; | ||
| // See operator precedence https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Operators/Operator_Precedence | ||
| assignmentOperators.forEach(op => jsep.addBinaryOp(op, 11)); | ||
| // We need lower priority than || and && which start at 1 | ||
| assignmentOperators.forEach(op => jsep.addBinaryOp(op, 0.9)); | ||
| jsep.hooks.add('gobble-expression', function gobbleUpdatePrefix(env) { | ||
| jsep.hooks.add('gobble-token', function gobbleUpdatePrefix(env) { | ||
| const code = this.code; | ||
@@ -40,3 +41,3 @@ if (updateOperators.some(c => c === code && c === this.expr.charCodeAt(this.index + 1))) { | ||
| operator: code === PLUS_CODE ? '++' : '--', | ||
| argument: this.gobbleExpression(), | ||
| argument: this.gobbleTokenProperty(this.gobbleIdentifier()), | ||
| prefix: true, | ||
@@ -43,0 +44,0 @@ }; |
@@ -1,1 +0,1 @@ | ||
| {"version":3,"file":"index.cjs.js","sources":["../../src/index.js"],"sourcesContent":["const PLUS_CODE = 43; // +\r\nconst MINUS_CODE = 45; // -\r\n\r\nexport default {\r\n\tname: 'assignment',\r\n\r\n\tinit(jsep) {\r\n\t\t// Assignment and Update support\r\n\t\tconst assignmentOperators = new Set([\r\n\t\t\t'=',\r\n\t\t\t'*=',\r\n\t\t\t'**=',\r\n\t\t\t'/=',\r\n\t\t\t'%=',\r\n\t\t\t'+=',\r\n\t\t\t'-=',\r\n\t\t\t'<<=',\r\n\t\t\t'>>=',\r\n\t\t\t'>>>=',\r\n\t\t\t'&=',\r\n\t\t\t'^=',\r\n\t\t\t'|=',\r\n\t\t]);\r\n\t\tconst updateOperators = [PLUS_CODE, MINUS_CODE];\r\n\t\tconst updateNodeTypes = [jsep.IDENTIFIER, jsep.MEMBER_EXP];\r\n\r\n\t\t// See operator precedence https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Operators/Operator_Precedence\r\n\t\tassignmentOperators.forEach(op => jsep.addBinaryOp(op, 11));\r\n\r\n\t\tjsep.hooks.add('gobble-expression', function gobbleUpdatePrefix(env) {\r\n\t\t\tconst code = this.code;\r\n\t\t\tif (updateOperators.some(c => c === code && c === this.expr.charCodeAt(this.index + 1))) {\r\n\t\t\t\tthis.index += 2;\r\n\t\t\t\tenv.node = {\r\n\t\t\t\t\ttype: 'UpdateExpression',\r\n\t\t\t\t\toperator: code === PLUS_CODE ? '++' : '--',\r\n\t\t\t\t\targument: this.gobbleExpression(),\r\n\t\t\t\t\tprefix: true,\r\n\t\t\t\t};\r\n\t\t\t\tif (!env.node.argument || !updateNodeTypes.includes(env.node.argument.type)) {\r\n\t\t\t\t\tthis.throwError(`Unexpected ${env.node.operator}`);\r\n\t\t\t\t}\r\n\t\t\t}\r\n\t\t});\r\n\r\n\t\tjsep.hooks.add('after-token', function gobbleUpdatePostfix(env) {\r\n\t\t\tif (env.node) {\r\n\t\t\t\tconst code = this.code;\r\n\t\t\t\tif (updateOperators.some(c => c === code && c === this.expr.charCodeAt(this.index + 1))) {\r\n\t\t\t\t\tif (!updateNodeTypes.includes(env.node.type)) {\r\n\t\t\t\t\t\tthis.throwError(`Unexpected ${env.node.operator}`);\r\n\t\t\t\t\t}\r\n\t\t\t\t\tthis.index += 2;\r\n\t\t\t\t\tenv.node = {\r\n\t\t\t\t\t\ttype: 'UpdateExpression',\r\n\t\t\t\t\t\toperator: code === PLUS_CODE ? '++' : '--',\r\n\t\t\t\t\t\targument: env.node,\r\n\t\t\t\t\t\tprefix: false,\r\n\t\t\t\t\t};\r\n\t\t\t\t}\r\n\t\t\t}\r\n\t\t});\r\n\r\n\t\tjsep.hooks.add('after-expression', function gobbleAssignment(env) {\r\n\t\t\tif (env.node && assignmentOperators.has(env.node.operator)) {\r\n\t\t\t\tenv.node.type = 'AssignmentExpression';\r\n\t\t\t}\r\n\t\t});\r\n\t},\r\n};\r\n"],"names":[],"mappings":";;AAAA,MAAM,SAAS,GAAG,EAAE,CAAC;AACrB,MAAM,UAAU,GAAG,EAAE,CAAC;AACtB;AACA,YAAe;AACf,CAAC,IAAI,EAAE,YAAY;AACnB;AACA,CAAC,IAAI,CAAC,IAAI,EAAE;AACZ;AACA,EAAE,MAAM,mBAAmB,GAAG,IAAI,GAAG,CAAC;AACtC,GAAG,GAAG;AACN,GAAG,IAAI;AACP,GAAG,KAAK;AACR,GAAG,IAAI;AACP,GAAG,IAAI;AACP,GAAG,IAAI;AACP,GAAG,IAAI;AACP,GAAG,KAAK;AACR,GAAG,KAAK;AACR,GAAG,MAAM;AACT,GAAG,IAAI;AACP,GAAG,IAAI;AACP,GAAG,IAAI;AACP,GAAG,CAAC,CAAC;AACL,EAAE,MAAM,eAAe,GAAG,CAAC,SAAS,EAAE,UAAU,CAAC,CAAC;AAClD,EAAE,MAAM,eAAe,GAAG,CAAC,IAAI,CAAC,UAAU,EAAE,IAAI,CAAC,UAAU,CAAC,CAAC;AAC7D;AACA;AACA,EAAE,mBAAmB,CAAC,OAAO,CAAC,EAAE,IAAI,IAAI,CAAC,WAAW,CAAC,EAAE,EAAE,EAAE,CAAC,CAAC,CAAC;AAC9D;AACA,EAAE,IAAI,CAAC,KAAK,CAAC,GAAG,CAAC,mBAAmB,EAAE,SAAS,kBAAkB,CAAC,GAAG,EAAE;AACvE,GAAG,MAAM,IAAI,GAAG,IAAI,CAA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C,EAAE;AACnD,MAAM,IAAI,CAAC,UAAU,CAAC,CAAC,WAAW,EAAE,GAAG,CAAC,IAAI,CAAC,QAAQ,CAAC,CAAC,CAAC,CAAC;AACzD,MAAM;AACN,KAAK,IAAI,CAAC,KAAK,IAAI,CAAC,CAAC;AACrB,KAAK,GAAG,CAAC,IAAI,GAAG;AAChB,MAAM,IAAI,EAAE,kBAAkB;AAC9B,MAAM,QAAQ,EAAE,IAAI,KAAK,SAAS,GAAG,IAAI,GAAG,IAAI;AAChD,MAAM,QAAQ,EAAE,GAAG,CAAC,IAAI;AACxB,MAAM,MAAM,EAAE,KAAK;AACnB,MAAM,CAAC;AACP,KAAK;AACL,IAAI;AACJ,GAAG,CAAC,CAAC;AACL;AACA,EAAE,IAAI,CAAC,KAAK,CAAC,GAAG,CAAC,kBAAkB,EAAE,SAAS,gBAAgB,CAAC,GAAG,EAAE;AACpE,GAAG,IAAI,GAAG,CAAC,IAAI,IAAI,mBAAmB,CAAC,GAAG,CAAC,GAAG,CAAC,IAAI,CAAC,QAAQ,CAAC,EAAE;AAC/D,IAAI,GAAG,CAAC,IAAI,CAAC,IAAI,GAAG,sBAAsB,CAAC;AAC3C,IAAI;AACJ,GAAG,CAAC,CAAC;AACL,EAAE;AACF,CAAC;;;;"} | ||
| {"version":3,"file":"index.cjs.js","sources":["../../src/index.js"],"sourcesContent":["const PLUS_CODE = 43; // +\r\nconst MINUS_CODE = 45; // -\r\n\r\nexport default {\r\n\tname: 'assignment',\r\n\r\n\tinit(jsep) {\r\n\t\t// Assignment and Update support\r\n\t\tconst assignmentOperators = new Set([\r\n\t\t\t'=',\r\n\t\t\t'*=',\r\n\t\t\t'**=',\r\n\t\t\t'/=',\r\n\t\t\t'%=',\r\n\t\t\t'+=',\r\n\t\t\t'-=',\r\n\t\t\t'<<=',\r\n\t\t\t'>>=',\r\n\t\t\t'>>>=',\r\n\t\t\t'&=',\r\n\t\t\t'^=',\r\n\t\t\t'|=',\r\n\t\t]);\r\n\t\tconst updateOperators = [PLUS_CODE, MINUS_CODE];\r\n\t\tconst updateNodeTypes = [jsep.IDENTIFIER, jsep.MEMBER_EXP];\r\n\r\n\t\t// See operator precedence https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Operators/Operator_Precedence\r\n\t\t// We need lower priority than || and && which start at 1\r\n\t\tassignmentOperators.forEach(op => jsep.addBinaryOp(op, 0.9));\r\n\r\n\t\tjsep.hooks.add('gobble-token', function gobbleUpdatePrefix(env) {\r\n\t\t\tconst code = this.code;\r\n\t\t\tif (updateOperators.some(c => c === code && c === this.expr.charCodeAt(this.index + 1))) {\r\n\t\t\t\tthis.index += 2;\r\n\t\t\t\tenv.node = {\r\n\t\t\t\t\ttype: 'UpdateExpression',\r\n\t\t\t\t\toperator: code === PLUS_CODE ? '++' : '--',\r\n\t\t\t\t\targument: this.gobbleTokenProperty(this.gobbleIdentifier()),\r\n\t\t\t\t\tprefix: true,\r\n\t\t\t\t};\r\n\t\t\t\tif (!env.node.argument || !updateNodeTypes.includes(env.node.argument.type)) {\r\n\t\t\t\t\tthis.throwError(`Unexpected ${env.node.operator}`);\r\n\t\t\t\t}\r\n\t\t\t}\r\n\t\t});\r\n\r\n\t\tjsep.hooks.add('after-token', function gobbleUpdatePostfix(env) {\r\n\t\t\tif (env.node) {\r\n\t\t\t\tconst code = this.code;\r\n\t\t\t\tif (updateOperators.some(c => c === code && c === this.expr.charCodeAt(this.index + 1))) {\r\n\t\t\t\t\tif (!updateNodeTypes.includes(env.node.type)) {\r\n\t\t\t\t\t\tthis.throwError(`Unexpected ${env.node.operator}`);\r\n\t\t\t\t\t}\r\n\t\t\t\t\tthis.index += 2;\r\n\t\t\t\t\tenv.node = {\r\n\t\t\t\t\t\ttype: 'UpdateExpression',\r\n\t\t\t\t\t\toperator: code === PLUS_CODE ? '++' : '--',\r\n\t\t\t\t\t\targument: env.node,\r\n\t\t\t\t\t\tprefix: false,\r\n\t\t\t\t\t};\r\n\t\t\t\t}\r\n\t\t\t}\r\n\t\t});\r\n\r\n\t\tjsep.hooks.add('after-expression', function gobbleAssignment(env) {\r\n\t\t\tif (env.node && assignmentOperators.has(env.node.operator)) {\r\n\t\t\t\tenv.node.type = 'AssignmentExpression';\r\n\t\t\t}\r\n\t\t});\r\n\t},\r\n};\r\n"],"names":[],"mappings":";;AAAA,MAAM,SAAS,GAAG,EAAE,CAAC;AACrB,MAAM,UAAU,GAAG,EAAE,CAAC;AACtB;AACA,YAAe;AACf,CAAC,IAAI,EAAE,YAAY;AACnB;AACA,CAAC,IAAI,CAAC,IAAI,EAAE;AACZ;AACA,EAAE,MAAM,mBAAmB,GAAG,IAAI,GAAG,CAAC;AACtC,GAAG,GAAG;AACN,GAAG,IAAI;AACP,GAAG,KAAK;AACR,GAAG,IAAI;AACP,GAAG,IAAI;AACP,GAAG,IAAI;AACP,GAAG,IAAI;AACP,GAAG,KAAK;AACR,GAAG,KAAK;AACR,GAAG,MAAM;AACT,GAAG,IAAI;AACP,GAAG,IAAI;AACP,GAAG,IAAI;AACP,GAAG,CAAC,CAAC;AACL,EAAE,MAAM,eAAe,GAAG,CAAC,SAAS,EAAE,UAAU,CAAC,CAAC;AAClD,EAAE,MAAM,eAAe,GAAG,CAAC,IAAI,CAAC,UAAU,EAAE,IAAI,CAAC,UAAU,CAAC,CAAC;AAC7D;AACA;AACA;AACA,EAAE,mBAAmB,CAAC,OAAO,CAAC,EAAE,IAAI,IAAI,CAAC,WAAW,CAAC,EAAE,EAAE,GAAG,CAAC,CAAC,CAAC;AAC/D;AACA,EAAE,IAAI,CAAC,KAAK,CAAC,GAAG,CAAC,cAAc,EAAE,SAAS,kBAAkB,CAAC,GAAG,EAAE;AAClE,GAAG,MAAM,IAAI,GAAG,IAAI,CAAC,IAAI,CAAC;AAC1B,GAAG,IAAI,eAAe,CAAC,IAAI,CAAC,CAAC,IAAI,CAAC,KAAK,IAAI,IAAI,CAAC,KAAK,IAAI,CAAC,IAAI,CAAC,UAAU,CAAC,IAAI,CAAC,KAAK,G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;AACN,KAAK,IAAI,CAAC,KAAK,IAAI,CAAC,CAAC;AACrB,KAAK,GAAG,CAAC,IAAI,GAAG;AAChB,MAAM,IAAI,EAAE,kBAAkB;AAC9B,MAAM,QAAQ,EAAE,IAAI,KAAK,SAAS,GAAG,IAAI,GAAG,IAAI;AAChD,MAAM,QAAQ,EAAE,GAAG,CAAC,IAAI;AACxB,MAAM,MAAM,EAAE,KAAK;AACnB,MAAM,CAAC;AACP,KAAK;AACL,IAAI;AACJ,GAAG,CAAC,CAAC;AACL;AACA,EAAE,IAAI,CAAC,KAAK,CAAC,GAAG,CAAC,kBAAkB,EAAE,SAAS,gBAAgB,CAAC,GAAG,EAAE;AACpE,GAAG,IAAI,GAAG,CAAC,IAAI,IAAI,mBAAmB,CAAC,GAAG,CAAC,GAAG,CAAC,IAAI,CAAC,QAAQ,CAAC,EAAE;AAC/D,IAAI,GAAG,CAAC,IAAI,CAAC,IAAI,GAAG,sBAAsB,CAAC;AAC3C,IAAI;AACJ,GAAG,CAAC,CAAC;AACL,EAAE;AACF,CAAC;;;;"} |
@@ -1,2 +0,2 @@ | ||
| "use strict";var e={name:"assignment",init(e){const o=new Set(["=","*=","**=","/=","%=","+=","-=","<<=",">>=",">>>=","&=","^=","|="]),t=[43,45],n=[e.IDENTIFIER,e.MEMBER_EXP];o.forEach((o=>e.addBinaryOp(o,11))),e.hooks.add("gobble-expression",(function(e){const o=this.code;t.some((e=>e===o&&e===this.expr.charCodeAt(this.index+1)))&&(this.index+=2,e.node={type:"UpdateExpression",operator:43===o?"++":"--",argument:this.gobbleExpression(),prefix:!0},e.node.argument&&n.includes(e.node.argument.type)||this.throwError(`Unexpected ${e.node.operator}`))})),e.hooks.add("after-token",(function(e){if(e.node){const o=this.code;t.some((e=>e===o&&e===this.expr.charCodeAt(this.index+1)))&&(n.includes(e.node.type)||this.throwError(`Unexpected ${e.node.operator}`),this.index+=2,e.node={type:"UpdateExpression",operator:43===o?"++":"--",argument:e.node,prefix:!1})}})),e.hooks.add("after-expression",(function(e){e.node&&o.has(e.node.operator)&&(e.node.type="AssignmentExpression")}))}};module.exports=e; | ||
| "use strict";var e={name:"assignment",init(e){const o=new Set(["=","*=","**=","/=","%=","+=","-=","<<=",">>=",">>>=","&=","^=","|="]),t=[43,45],n=[e.IDENTIFIER,e.MEMBER_EXP];o.forEach((o=>e.addBinaryOp(o,.9))),e.hooks.add("gobble-token",(function(e){const o=this.code;t.some((e=>e===o&&e===this.expr.charCodeAt(this.index+1)))&&(this.index+=2,e.node={type:"UpdateExpression",operator:43===o?"++":"--",argument:this.gobbleTokenProperty(this.gobbleIdentifier()),prefix:!0},e.node.argument&&n.includes(e.node.argument.type)||this.throwError(`Unexpected ${e.node.operator}`))})),e.hooks.add("after-token",(function(e){if(e.node){const o=this.code;t.some((e=>e===o&&e===this.expr.charCodeAt(this.index+1)))&&(n.includes(e.node.type)||this.throwError(`Unexpected ${e.node.operator}`),this.index+=2,e.node={type:"UpdateExpression",operator:43===o?"++":"--",argument:e.node,prefix:!1})}})),e.hooks.add("after-expression",(function(e){e.node&&o.has(e.node.operator)&&(e.node.type="AssignmentExpression")}))}};module.exports=e; | ||
| //# sourceMappingURL=index.cjs.min.js.map |
@@ -1,1 +0,1 @@ | ||
| {"version":3,"file":"index.cjs.min.js","sources":["../../src/index.js"],"sourcesContent":["const PLUS_CODE = 43; // +\r\nconst MINUS_CODE = 45; // -\r\n\r\nexport default {\r\n\tname: 'assignment',\r\n\r\n\tinit(jsep) {\r\n\t\t// Assignment and Update support\r\n\t\tconst assignmentOperators = new Set([\r\n\t\t\t'=',\r\n\t\t\t'*=',\r\n\t\t\t'**=',\r\n\t\t\t'/=',\r\n\t\t\t'%=',\r\n\t\t\t'+=',\r\n\t\t\t'-=',\r\n\t\t\t'<<=',\r\n\t\t\t'>>=',\r\n\t\t\t'>>>=',\r\n\t\t\t'&=',\r\n\t\t\t'^=',\r\n\t\t\t'|=',\r\n\t\t]);\r\n\t\tconst updateOperators = [PLUS_CODE, MINUS_CODE];\r\n\t\tconst updateNodeTypes = [jsep.IDENTIFIER, jsep.MEMBER_EXP];\r\n\r\n\t\t// See operator precedence https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Operators/Operator_Precedence\r\n\t\tassignmentOperators.forEach(op => jsep.addBinaryOp(op, 11));\r\n\r\n\t\tjsep.hooks.add('gobble-expression', function gobbleUpdatePrefix(env) {\r\n\t\t\tconst code = this.code;\r\n\t\t\tif (updateOperators.some(c => c === code && c === this.expr.charCodeAt(this.index + 1))) {\r\n\t\t\t\tthis.index += 2;\r\n\t\t\t\tenv.node = {\r\n\t\t\t\t\ttype: 'UpdateExpression',\r\n\t\t\t\t\toperator: code === PLUS_CODE ? '++' : '--',\r\n\t\t\t\t\targument: this.gobbleExpression(),\r\n\t\t\t\t\tprefix: true,\r\n\t\t\t\t};\r\n\t\t\t\tif (!env.node.argument || !updateNodeTypes.includes(env.node.argument.type)) {\r\n\t\t\t\t\tthis.throwError(`Unexpected ${env.node.operator}`);\r\n\t\t\t\t}\r\n\t\t\t}\r\n\t\t});\r\n\r\n\t\tjsep.hooks.add('after-token', function gobbleUpdatePostfix(env) {\r\n\t\t\tif (env.node) {\r\n\t\t\t\tconst code = this.code;\r\n\t\t\t\tif (updateOperators.some(c => c === code && c === this.expr.charCodeAt(this.index + 1))) {\r\n\t\t\t\t\tif (!updateNodeTypes.includes(env.node.type)) {\r\n\t\t\t\t\t\tthis.throwError(`Unexpected ${env.node.operator}`);\r\n\t\t\t\t\t}\r\n\t\t\t\t\tthis.index += 2;\r\n\t\t\t\t\tenv.node = {\r\n\t\t\t\t\t\ttype: 'UpdateExpression',\r\n\t\t\t\t\t\toperator: code === PLUS_CODE ? '++' : '--',\r\n\t\t\t\t\t\targument: env.node,\r\n\t\t\t\t\t\tprefix: false,\r\n\t\t\t\t\t};\r\n\t\t\t\t}\r\n\t\t\t}\r\n\t\t});\r\n\r\n\t\tjsep.hooks.add('after-expression', function gobbleAssignment(env) {\r\n\t\t\tif (env.node && assignmentOperators.has(env.node.operator)) {\r\n\t\t\t\tenv.node.type = 'AssignmentExpression';\r\n\t\t\t}\r\n\t\t});\r\n\t},\r\n};\r\n"],"names":["name","[object Object]","jsep","assignmentOperators","Set","updateOperators","updateNodeTypes","IDENTIFIER","MEMBER_EXP","forEach","op","addBinaryOp","hooks","add","env","code","this","some","c","expr","charCodeAt","index","node","type","operator","argument","gobbleExpression","prefix","includes","throwError","has"],"mappings":"aAGA,MAAe,CACdA,KAAM,aAENC,KAAKC,GAEJ,MAAMC,EAAsB,IAAIC,IAAI,CACnC,IACA,KACA,MACA,KACA,KACA,KACA,KACA,MACA,MACA,OACA,KACA,KACA,OAEKC,EAAkB,CAvBR,GACC,IAuBXC,EAAkB,CAACJ,EAAKK,WAAYL,EAAKM,YAG/CL,EAAoBM,SAAQC,GAAMR,EAAKS,YAAYD,EAAI,MAEvDR,EAAKU,MAAMC,IAAI,qBAAqB,SAA4BC,GAC/D,MAAMC,EAAOC,KAAKD,KACdV,EAAgBY,MAAKC,GAAKA,IAAMH,GAAQG,IAAMF,KAAKG,KAAKC,WAAWJ,KAAKK,MAAQ,OACnFL,KAAKK,OAAS,EACdP,EAAIQ,KAAO,CACVC,KAAM,mBACNC,SAnCa,KAmCHT,EAAqB,KAAO,KACtCU,SAAUT,KAAKU,mBACfC,QAAQ,GAEJb,EAAIQ,KAAKG,UAAanB,EAAgBsB,SAASd,EAAIQ,KAAKG,SAASF,OACrEP,KAAKa,WAAW,cAAcf,EAAIQ,KAAKE,gBAK1CtB,EAAKU,MAAMC,IAAI,eAAe,SAA6BC,GAC1D,GAAIA,EAAIQ,KAAM,CACb,MAAMP,EAAOC,KAAKD,KACdV,EAAgBY,MAAKC,GAAKA,IAAMH,GAAQG,IAAMF,KAAKG,KAAKC,WAAWJ,KAAKK,MAAQ,OAC9Ef,EAAgBsB,SAASd,EAAIQ,KAAKC,OACtCP,KAAKa,WAAW,cAAcf,EAAIQ,KAAKE,YAExCR,KAAKK,OAAS,EACdP,EAAIQ,KAAO,CACVC,KAAM,mBACNC,SAvDY,KAuDFT,EAAqB,KAAO,KACtCU,SAAUX,EAAIQ,KACdK,QAAQ,QAMZzB,EAAKU,MAAMC,IAAI,oBAAoB,SAA0BC,GACxDA,EAAIQ,MAAQnB,EAAoB2B,IAAIhB,EAAIQ,KAAKE,YAChDV,EAAIQ,KAAKC,KAAO"} | ||
| {"version":3,"file":"index.cjs.min.js","sources":["../../src/index.js"],"sourcesContent":["const PLUS_CODE = 43; // +\r\nconst MINUS_CODE = 45; // -\r\n\r\nexport default {\r\n\tname: 'assignment',\r\n\r\n\tinit(jsep) {\r\n\t\t// Assignment and Update support\r\n\t\tconst assignmentOperators = new Set([\r\n\t\t\t'=',\r\n\t\t\t'*=',\r\n\t\t\t'**=',\r\n\t\t\t'/=',\r\n\t\t\t'%=',\r\n\t\t\t'+=',\r\n\t\t\t'-=',\r\n\t\t\t'<<=',\r\n\t\t\t'>>=',\r\n\t\t\t'>>>=',\r\n\t\t\t'&=',\r\n\t\t\t'^=',\r\n\t\t\t'|=',\r\n\t\t]);\r\n\t\tconst updateOperators = [PLUS_CODE, MINUS_CODE];\r\n\t\tconst updateNodeTypes = [jsep.IDENTIFIER, jsep.MEMBER_EXP];\r\n\r\n\t\t// See operator precedence https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Operators/Operator_Precedence\r\n\t\t// We need lower priority than || and && which start at 1\r\n\t\tassignmentOperators.forEach(op => jsep.addBinaryOp(op, 0.9));\r\n\r\n\t\tjsep.hooks.add('gobble-token', function gobbleUpdatePrefix(env) {\r\n\t\t\tconst code = this.code;\r\n\t\t\tif (updateOperators.some(c => c === code && c === this.expr.charCodeAt(this.index + 1))) {\r\n\t\t\t\tthis.index += 2;\r\n\t\t\t\tenv.node = {\r\n\t\t\t\t\ttype: 'UpdateExpression',\r\n\t\t\t\t\toperator: code === PLUS_CODE ? '++' : '--',\r\n\t\t\t\t\targument: this.gobbleTokenProperty(this.gobbleIdentifier()),\r\n\t\t\t\t\tprefix: true,\r\n\t\t\t\t};\r\n\t\t\t\tif (!env.node.argument || !updateNodeTypes.includes(env.node.argument.type)) {\r\n\t\t\t\t\tthis.throwError(`Unexpected ${env.node.operator}`);\r\n\t\t\t\t}\r\n\t\t\t}\r\n\t\t});\r\n\r\n\t\tjsep.hooks.add('after-token', function gobbleUpdatePostfix(env) {\r\n\t\t\tif (env.node) {\r\n\t\t\t\tconst code = this.code;\r\n\t\t\t\tif (updateOperators.some(c => c === code && c === this.expr.charCodeAt(this.index + 1))) {\r\n\t\t\t\t\tif (!updateNodeTypes.includes(env.node.type)) {\r\n\t\t\t\t\t\tthis.throwError(`Unexpected ${env.node.operator}`);\r\n\t\t\t\t\t}\r\n\t\t\t\t\tthis.index += 2;\r\n\t\t\t\t\tenv.node = {\r\n\t\t\t\t\t\ttype: 'UpdateExpression',\r\n\t\t\t\t\t\toperator: code === PLUS_CODE ? '++' : '--',\r\n\t\t\t\t\t\targument: env.node,\r\n\t\t\t\t\t\tprefix: false,\r\n\t\t\t\t\t};\r\n\t\t\t\t}\r\n\t\t\t}\r\n\t\t});\r\n\r\n\t\tjsep.hooks.add('after-expression', function gobbleAssignment(env) {\r\n\t\t\tif (env.node && assignmentOperators.has(env.node.operator)) {\r\n\t\t\t\tenv.node.type = 'AssignmentExpression';\r\n\t\t\t}\r\n\t\t});\r\n\t},\r\n};\r\n"],"names":["name","[object Object]","jsep","assignmentOperators","Set","updateOperators","updateNodeTypes","IDENTIFIER","MEMBER_EXP","forEach","op","addBinaryOp","hooks","add","env","code","this","some","c","expr","charCodeAt","index","node","type","operator","argument","gobbleTokenProperty","gobbleIdentifier","prefix","includes","throwError","has"],"mappings":"aAGA,MAAe,CACdA,KAAM,aAENC,KAAKC,GAEJ,MAAMC,EAAsB,IAAIC,IAAI,CACnC,IACA,KACA,MACA,KACA,KACA,KACA,KACA,MACA,MACA,OACA,KACA,KACA,OAEKC,EAAkB,CAvBR,GACC,IAuBXC,EAAkB,CAACJ,EAAKK,WAAYL,EAAKM,YAI/CL,EAAoBM,SAAQC,GAAMR,EAAKS,YAAYD,EAAI,MAEvDR,EAAKU,MAAMC,IAAI,gBAAgB,SAA4BC,GAC1D,MAAMC,EAAOC,KAAKD,KACdV,EAAgBY,MAAKC,GAAKA,IAAMH,GAAQG,IAAMF,KAAKG,KAAKC,WAAWJ,KAAKK,MAAQ,OACnFL,KAAKK,OAAS,EACdP,EAAIQ,KAAO,CACVC,KAAM,mBACNC,SApCa,KAoCHT,EAAqB,KAAO,KACtCU,SAAUT,KAAKU,oBAAoBV,KAAKW,oBACxCC,QAAQ,GAEJd,EAAIQ,KAAKG,UAAanB,EAAgBuB,SAASf,EAAIQ,KAAKG,SAASF,OACrEP,KAAKc,WAAW,cAAchB,EAAIQ,KAAKE,gBAK1CtB,EAAKU,MAAMC,IAAI,eAAe,SAA6BC,GAC1D,GAAIA,EAAIQ,KAAM,CACb,MAAMP,EAAOC,KAAKD,KACdV,EAAgBY,MAAKC,GAAKA,IAAMH,GAAQG,IAAMF,KAAKG,KAAKC,WAAWJ,KAAKK,MAAQ,OAC9Ef,EAAgBuB,SAASf,EAAIQ,KAAKC,OACtCP,KAAKc,WAAW,cAAchB,EAAIQ,KAAKE,YAExCR,KAAKK,OAAS,EACdP,EAAIQ,KAAO,CACVC,KAAM,mBACNC,SAxDY,KAwDFT,EAAqB,KAAO,KACtCU,SAAUX,EAAIQ,KACdM,QAAQ,QAMZ1B,EAAKU,MAAMC,IAAI,oBAAoB,SAA0BC,GACxDA,EAAIQ,MAAQnB,EAAoB4B,IAAIjB,EAAIQ,KAAKE,YAChDV,EAAIQ,KAAKC,KAAO"} |
@@ -31,5 +31,6 @@ var index = (function () { | ||
| // See operator precedence https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Operators/Operator_Precedence | ||
| assignmentOperators.forEach(op => jsep.addBinaryOp(op, 11)); | ||
| // We need lower priority than || and && which start at 1 | ||
| assignmentOperators.forEach(op => jsep.addBinaryOp(op, 0.9)); | ||
| jsep.hooks.add('gobble-expression', function gobbleUpdatePrefix(env) { | ||
| jsep.hooks.add('gobble-token', function gobbleUpdatePrefix(env) { | ||
| const code = this.code; | ||
@@ -41,3 +42,3 @@ if (updateOperators.some(c => c === code && c === this.expr.charCodeAt(this.index + 1))) { | ||
| operator: code === PLUS_CODE ? '++' : '--', | ||
| argument: this.gobbleExpression(), | ||
| argument: this.gobbleTokenProperty(this.gobbleIdentifier()), | ||
| prefix: true, | ||
@@ -44,0 +45,0 @@ }; |
@@ -1,1 +0,1 @@ | ||
| {"version":3,"file":"index.iife.js","sources":["../../src/index.js"],"sourcesContent":["const PLUS_CODE = 43; // +\r\nconst MINUS_CODE = 45; // -\r\n\r\nexport default {\r\n\tname: 'assignment',\r\n\r\n\tinit(jsep) {\r\n\t\t// Assignment and Update support\r\n\t\tconst assignmentOperators = new Set([\r\n\t\t\t'=',\r\n\t\t\t'*=',\r\n\t\t\t'**=',\r\n\t\t\t'/=',\r\n\t\t\t'%=',\r\n\t\t\t'+=',\r\n\t\t\t'-=',\r\n\t\t\t'<<=',\r\n\t\t\t'>>=',\r\n\t\t\t'>>>=',\r\n\t\t\t'&=',\r\n\t\t\t'^=',\r\n\t\t\t'|=',\r\n\t\t]);\r\n\t\tconst updateOperators = [PLUS_CODE, MINUS_CODE];\r\n\t\tconst updateNodeTypes = [jsep.IDENTIFIER, jsep.MEMBER_EXP];\r\n\r\n\t\t// See operator precedence https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Operators/Operator_Precedence\r\n\t\tassignmentOperators.forEach(op => jsep.addBinaryOp(op, 11));\r\n\r\n\t\tjsep.hooks.add('gobble-expression', function gobbleUpdatePrefix(env) {\r\n\t\t\tconst code = this.code;\r\n\t\t\tif (updateOperators.some(c => c === code && c === this.expr.charCodeAt(this.index + 1))) {\r\n\t\t\t\tthis.index += 2;\r\n\t\t\t\tenv.node = {\r\n\t\t\t\t\ttype: 'UpdateExpression',\r\n\t\t\t\t\toperator: code === PLUS_CODE ? '++' : '--',\r\n\t\t\t\t\targument: this.gobbleExpression(),\r\n\t\t\t\t\tprefix: true,\r\n\t\t\t\t};\r\n\t\t\t\tif (!env.node.argument || !updateNodeTypes.includes(env.node.argument.type)) {\r\n\t\t\t\t\tthis.throwError(`Unexpected ${env.node.operator}`);\r\n\t\t\t\t}\r\n\t\t\t}\r\n\t\t});\r\n\r\n\t\tjsep.hooks.add('after-token', function gobbleUpdatePostfix(env) {\r\n\t\t\tif (env.node) {\r\n\t\t\t\tconst code = this.code;\r\n\t\t\t\tif (updateOperators.some(c => c === code && c === this.expr.charCodeAt(this.index + 1))) {\r\n\t\t\t\t\tif (!updateNodeTypes.includes(env.node.type)) {\r\n\t\t\t\t\t\tthis.throwError(`Unexpected ${env.node.operator}`);\r\n\t\t\t\t\t}\r\n\t\t\t\t\tthis.index += 2;\r\n\t\t\t\t\tenv.node = {\r\n\t\t\t\t\t\ttype: 'UpdateExpression',\r\n\t\t\t\t\t\toperator: code === PLUS_CODE ? '++' : '--',\r\n\t\t\t\t\t\targument: env.node,\r\n\t\t\t\t\t\tprefix: false,\r\n\t\t\t\t\t};\r\n\t\t\t\t}\r\n\t\t\t}\r\n\t\t});\r\n\r\n\t\tjsep.hooks.add('after-expression', function gobbleAssignment(env) {\r\n\t\t\tif (env.node && assignmentOperators.has(env.node.operator)) {\r\n\t\t\t\tenv.node.type = 'AssignmentExpression';\r\n\t\t\t}\r\n\t\t});\r\n\t},\r\n};\r\n"],"names":[],"mappings":";;;CAAA,MAAM,SAAS,GAAG,EAAE,CAAC;CACrB,MAAM,UAAU,GAAG,EAAE,CAAC;AACtB;AACA,aAAe;CACf,CAAC,IAAI,EAAE,YAAY;AACnB;CACA,CAAC,IAAI,CAAC,IAAI,EAAE;CACZ;CACA,EAAE,MAAM,mBAAmB,GAAG,IAAI,GAAG,CAAC;CACtC,GAAG,GAAG;CACN,GAAG,IAAI;CACP,GAAG,KAAK;CACR,GAAG,IAAI;CACP,GAAG,IAAI;CACP,GAAG,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,IAAI,GAAG,CAAC,IAAI,CAAC,IAAI,GAAG,sBAAsB,CAAC;CAC3C,IAAI;CACJ,GAAG,CAAC,CAAC;CACL,EAAE;CACF,CAAC;;;;;;;;"} | ||
| {"version":3,"file":"index.iife.js","sources":["../../src/index.js"],"sourcesContent":["const PLUS_CODE = 43; // +\r\nconst MINUS_CODE = 45; // -\r\n\r\nexport default {\r\n\tname: 'assignment',\r\n\r\n\tinit(jsep) {\r\n\t\t// Assignment and Update support\r\n\t\tconst assignmentOperators = new Set([\r\n\t\t\t'=',\r\n\t\t\t'*=',\r\n\t\t\t'**=',\r\n\t\t\t'/=',\r\n\t\t\t'%=',\r\n\t\t\t'+=',\r\n\t\t\t'-=',\r\n\t\t\t'<<=',\r\n\t\t\t'>>=',\r\n\t\t\t'>>>=',\r\n\t\t\t'&=',\r\n\t\t\t'^=',\r\n\t\t\t'|=',\r\n\t\t]);\r\n\t\tconst updateOperators = [PLUS_CODE, MINUS_CODE];\r\n\t\tconst updateNodeTypes = [jsep.IDENTIFIER, jsep.MEMBER_EXP];\r\n\r\n\t\t// See operator precedence https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Operators/Operator_Precedence\r\n\t\t// We need lower priority than || and && which start at 1\r\n\t\tassignmentOperators.forEach(op => jsep.addBinaryOp(op, 0.9));\r\n\r\n\t\tjsep.hooks.add('gobble-token', function gobbleUpdatePrefix(env) {\r\n\t\t\tconst code = this.code;\r\n\t\t\tif (updateOperators.some(c => c === code && c === this.expr.charCodeAt(this.index + 1))) {\r\n\t\t\t\tthis.index += 2;\r\n\t\t\t\tenv.node = {\r\n\t\t\t\t\ttype: 'UpdateExpression',\r\n\t\t\t\t\toperator: code === PLUS_CODE ? '++' : '--',\r\n\t\t\t\t\targument: this.gobbleTokenProperty(this.gobbleIdentifier()),\r\n\t\t\t\t\tprefix: true,\r\n\t\t\t\t};\r\n\t\t\t\tif (!env.node.argument || !updateNodeTypes.includes(env.node.argument.type)) {\r\n\t\t\t\t\tthis.throwError(`Unexpected ${env.node.operator}`);\r\n\t\t\t\t}\r\n\t\t\t}\r\n\t\t});\r\n\r\n\t\tjsep.hooks.add('after-token', function gobbleUpdatePostfix(env) {\r\n\t\t\tif (env.node) {\r\n\t\t\t\tconst code = this.code;\r\n\t\t\t\tif (updateOperators.some(c => c === code && c === this.expr.charCodeAt(this.index + 1))) {\r\n\t\t\t\t\tif (!updateNodeTypes.includes(env.node.type)) {\r\n\t\t\t\t\t\tthis.throwError(`Unexpected ${env.node.operator}`);\r\n\t\t\t\t\t}\r\n\t\t\t\t\tthis.index += 2;\r\n\t\t\t\t\tenv.node = {\r\n\t\t\t\t\t\ttype: 'UpdateExpression',\r\n\t\t\t\t\t\toperator: code === PLUS_CODE ? '++' : '--',\r\n\t\t\t\t\t\targument: env.node,\r\n\t\t\t\t\t\tprefix: false,\r\n\t\t\t\t\t};\r\n\t\t\t\t}\r\n\t\t\t}\r\n\t\t});\r\n\r\n\t\tjsep.hooks.add('after-expression', function gobbleAssignment(env) {\r\n\t\t\tif (env.node && assignmentOperators.has(env.node.operator)) {\r\n\t\t\t\tenv.node.type = 'AssignmentExpression';\r\n\t\t\t}\r\n\t\t});\r\n\t},\r\n};\r\n"],"names":[],"mappings":";;;CAAA,MAAM,SAAS,GAAG,EAAE,CAAC;CACrB,MAAM,UAAU,GAAG,EAAE,CAAC;AACtB;AACA,aAAe;CACf,CAAC,IAAI,EAAE,YAAY;AACnB;CACA,CAAC,IAAI,CAAC,IAAI,EAAE;CACZ;CACA,EAAE,MAAM,mBAAmB,GAAG,IAAI,GAAG,CAAC;CACtC,GAAG,GAAG;CACN,GAAG,IAAI;CACP,GAAG,KAAK;CACR,GAAG,IAAI;CACP,GAAG,IAAI;CACP,GAAG,IAAI;CACP,GAAG,IAAI;CACP,GAAG,KAAK;CACR,GAAG,KAAK;CACR,GAAG,MAAM;CACT,GAAG,IAAI;CACP,GAAG,IAAI;CACP,GAAG,IAAI;CACP,GAAG,CAAC,CAAC;CACL,EAAE,M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;"} |
@@ -1,2 +0,2 @@ | ||
| var index=function(){"use strict";return{name:"assignment",init(e){const o=new Set(["=","*=","**=","/=","%=","+=","-=","<<=",">>=",">>>=","&=","^=","|="]),n=[43,45],t=[e.IDENTIFIER,e.MEMBER_EXP];o.forEach((o=>e.addBinaryOp(o,11))),e.hooks.add("gobble-expression",(function(e){const o=this.code;n.some((e=>e===o&&e===this.expr.charCodeAt(this.index+1)))&&(this.index+=2,e.node={type:"UpdateExpression",operator:43===o?"++":"--",argument:this.gobbleExpression(),prefix:!0},e.node.argument&&t.includes(e.node.argument.type)||this.throwError(`Unexpected ${e.node.operator}`))})),e.hooks.add("after-token",(function(e){if(e.node){const o=this.code;n.some((e=>e===o&&e===this.expr.charCodeAt(this.index+1)))&&(t.includes(e.node.type)||this.throwError(`Unexpected ${e.node.operator}`),this.index+=2,e.node={type:"UpdateExpression",operator:43===o?"++":"--",argument:e.node,prefix:!1})}})),e.hooks.add("after-expression",(function(e){e.node&&o.has(e.node.operator)&&(e.node.type="AssignmentExpression")}))}}}(); | ||
| var index=function(){"use strict";return{name:"assignment",init(e){const o=new Set(["=","*=","**=","/=","%=","+=","-=","<<=",">>=",">>>=","&=","^=","|="]),t=[43,45],n=[e.IDENTIFIER,e.MEMBER_EXP];o.forEach((o=>e.addBinaryOp(o,.9))),e.hooks.add("gobble-token",(function(e){const o=this.code;t.some((e=>e===o&&e===this.expr.charCodeAt(this.index+1)))&&(this.index+=2,e.node={type:"UpdateExpression",operator:43===o?"++":"--",argument:this.gobbleTokenProperty(this.gobbleIdentifier()),prefix:!0},e.node.argument&&n.includes(e.node.argument.type)||this.throwError(`Unexpected ${e.node.operator}`))})),e.hooks.add("after-token",(function(e){if(e.node){const o=this.code;t.some((e=>e===o&&e===this.expr.charCodeAt(this.index+1)))&&(n.includes(e.node.type)||this.throwError(`Unexpected ${e.node.operator}`),this.index+=2,e.node={type:"UpdateExpression",operator:43===o?"++":"--",argument:e.node,prefix:!1})}})),e.hooks.add("after-expression",(function(e){e.node&&o.has(e.node.operator)&&(e.node.type="AssignmentExpression")}))}}}(); | ||
| //# sourceMappingURL=index.iife.min.js.map |
@@ -1,1 +0,1 @@ | ||
| {"version":3,"file":"index.iife.min.js","sources":["../../src/index.js"],"sourcesContent":["const PLUS_CODE = 43; // +\r\nconst MINUS_CODE = 45; // -\r\n\r\nexport default {\r\n\tname: 'assignment',\r\n\r\n\tinit(jsep) {\r\n\t\t// Assignment and Update support\r\n\t\tconst assignmentOperators = new Set([\r\n\t\t\t'=',\r\n\t\t\t'*=',\r\n\t\t\t'**=',\r\n\t\t\t'/=',\r\n\t\t\t'%=',\r\n\t\t\t'+=',\r\n\t\t\t'-=',\r\n\t\t\t'<<=',\r\n\t\t\t'>>=',\r\n\t\t\t'>>>=',\r\n\t\t\t'&=',\r\n\t\t\t'^=',\r\n\t\t\t'|=',\r\n\t\t]);\r\n\t\tconst updateOperators = [PLUS_CODE, MINUS_CODE];\r\n\t\tconst updateNodeTypes = [jsep.IDENTIFIER, jsep.MEMBER_EXP];\r\n\r\n\t\t// See operator precedence https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Operators/Operator_Precedence\r\n\t\tassignmentOperators.forEach(op => jsep.addBinaryOp(op, 11));\r\n\r\n\t\tjsep.hooks.add('gobble-expression', function gobbleUpdatePrefix(env) {\r\n\t\t\tconst code = this.code;\r\n\t\t\tif (updateOperators.some(c => c === code && c === this.expr.charCodeAt(this.index + 1))) {\r\n\t\t\t\tthis.index += 2;\r\n\t\t\t\tenv.node = {\r\n\t\t\t\t\ttype: 'UpdateExpression',\r\n\t\t\t\t\toperator: code === PLUS_CODE ? '++' : '--',\r\n\t\t\t\t\targument: this.gobbleExpression(),\r\n\t\t\t\t\tprefix: true,\r\n\t\t\t\t};\r\n\t\t\t\tif (!env.node.argument || !updateNodeTypes.includes(env.node.argument.type)) {\r\n\t\t\t\t\tthis.throwError(`Unexpected ${env.node.operator}`);\r\n\t\t\t\t}\r\n\t\t\t}\r\n\t\t});\r\n\r\n\t\tjsep.hooks.add('after-token', function gobbleUpdatePostfix(env) {\r\n\t\t\tif (env.node) {\r\n\t\t\t\tconst code = this.code;\r\n\t\t\t\tif (updateOperators.some(c => c === code && c === this.expr.charCodeAt(this.index + 1))) {\r\n\t\t\t\t\tif (!updateNodeTypes.includes(env.node.type)) {\r\n\t\t\t\t\t\tthis.throwError(`Unexpected ${env.node.operator}`);\r\n\t\t\t\t\t}\r\n\t\t\t\t\tthis.index += 2;\r\n\t\t\t\t\tenv.node = {\r\n\t\t\t\t\t\ttype: 'UpdateExpression',\r\n\t\t\t\t\t\toperator: code === PLUS_CODE ? '++' : '--',\r\n\t\t\t\t\t\targument: env.node,\r\n\t\t\t\t\t\tprefix: false,\r\n\t\t\t\t\t};\r\n\t\t\t\t}\r\n\t\t\t}\r\n\t\t});\r\n\r\n\t\tjsep.hooks.add('after-expression', function gobbleAssignment(env) {\r\n\t\t\tif (env.node && assignmentOperators.has(env.node.operator)) {\r\n\t\t\t\tenv.node.type = 'AssignmentExpression';\r\n\t\t\t}\r\n\t\t});\r\n\t},\r\n};\r\n"],"names":["name","[object Object]","jsep","assignmentOperators","Set","updateOperators","updateNodeTypes","IDENTIFIER","MEMBER_EXP","forEach","op","addBinaryOp","hooks","add","env","code","this","some","c","expr","charCodeAt","index","node","type","operator","argument","gobbleExpression","prefix","includes","throwError","has"],"mappings":"wCAGe,CACdA,KAAM,aAENC,KAAKC,GAEJ,MAAMC,EAAsB,IAAIC,IAAI,CACnC,IACA,KACA,MACA,KACA,KACA,KACA,KACA,MACA,MACA,OACA,KACA,KACA,OAEKC,EAAkB,CAvBR,GACC,IAuBXC,EAAkB,CAACJ,EAAKK,WAAYL,EAAKM,YAG/CL,EAAoBM,SAAQC,GAAMR,EAAKS,YAAYD,EAAI,MAEvDR,EAAKU,MAAMC,IAAI,qBAAqB,SAA4BC,GAC/D,MAAMC,EAAOC,KAAKD,KACdV,EAAgBY,MAAKC,GAAKA,IAAMH,GAAQG,IAAMF,KAAKG,KAAKC,WAAWJ,KAAKK,MAAQ,OACnFL,KAAKK,OAAS,EACdP,EAAIQ,KAAO,CACVC,KAAM,mBACNC,SAnCa,KAmCHT,EAAqB,KAAO,KACtCU,SAAUT,KAAKU,mBACfC,QAAQ,GAEJb,EAAIQ,KAAKG,UAAanB,EAAgBsB,SAASd,EAAIQ,KAAKG,SAASF,OACrEP,KAAKa,WAAW,cAAcf,EAAIQ,KAAKE,gBAK1CtB,EAAKU,MAAMC,IAAI,eAAe,SAA6BC,GAC1D,GAAIA,EAAIQ,KAAM,CACb,MAAMP,EAAOC,KAAKD,KACdV,EAAgBY,MAAKC,GAAKA,IAAMH,GAAQG,IAAMF,KAAKG,KAAKC,WAAWJ,KAAKK,MAAQ,OAC9Ef,EAAgBsB,SAASd,EAAIQ,KAAKC,OACtCP,KAAKa,WAAW,cAAcf,EAAIQ,KAAKE,YAExCR,KAAKK,OAAS,EACdP,EAAIQ,KAAO,CACVC,KAAM,mBACNC,SAvDY,KAuDFT,EAAqB,KAAO,KACtCU,SAAUX,EAAIQ,KACdK,QAAQ,QAMZzB,EAAKU,MAAMC,IAAI,oBAAoB,SAA0BC,GACxDA,EAAIQ,MAAQnB,EAAoB2B,IAAIhB,EAAIQ,KAAKE,YAChDV,EAAIQ,KAAKC,KAAO"} | ||
| {"version":3,"file":"index.iife.min.js","sources":["../../src/index.js"],"sourcesContent":["const PLUS_CODE = 43; // +\r\nconst MINUS_CODE = 45; // -\r\n\r\nexport default {\r\n\tname: 'assignment',\r\n\r\n\tinit(jsep) {\r\n\t\t// Assignment and Update support\r\n\t\tconst assignmentOperators = new Set([\r\n\t\t\t'=',\r\n\t\t\t'*=',\r\n\t\t\t'**=',\r\n\t\t\t'/=',\r\n\t\t\t'%=',\r\n\t\t\t'+=',\r\n\t\t\t'-=',\r\n\t\t\t'<<=',\r\n\t\t\t'>>=',\r\n\t\t\t'>>>=',\r\n\t\t\t'&=',\r\n\t\t\t'^=',\r\n\t\t\t'|=',\r\n\t\t]);\r\n\t\tconst updateOperators = [PLUS_CODE, MINUS_CODE];\r\n\t\tconst updateNodeTypes = [jsep.IDENTIFIER, jsep.MEMBER_EXP];\r\n\r\n\t\t// See operator precedence https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Operators/Operator_Precedence\r\n\t\t// We need lower priority than || and && which start at 1\r\n\t\tassignmentOperators.forEach(op => jsep.addBinaryOp(op, 0.9));\r\n\r\n\t\tjsep.hooks.add('gobble-token', function gobbleUpdatePrefix(env) {\r\n\t\t\tconst code = this.code;\r\n\t\t\tif (updateOperators.some(c => c === code && c === this.expr.charCodeAt(this.index + 1))) {\r\n\t\t\t\tthis.index += 2;\r\n\t\t\t\tenv.node = {\r\n\t\t\t\t\ttype: 'UpdateExpression',\r\n\t\t\t\t\toperator: code === PLUS_CODE ? '++' : '--',\r\n\t\t\t\t\targument: this.gobbleTokenProperty(this.gobbleIdentifier()),\r\n\t\t\t\t\tprefix: true,\r\n\t\t\t\t};\r\n\t\t\t\tif (!env.node.argument || !updateNodeTypes.includes(env.node.argument.type)) {\r\n\t\t\t\t\tthis.throwError(`Unexpected ${env.node.operator}`);\r\n\t\t\t\t}\r\n\t\t\t}\r\n\t\t});\r\n\r\n\t\tjsep.hooks.add('after-token', function gobbleUpdatePostfix(env) {\r\n\t\t\tif (env.node) {\r\n\t\t\t\tconst code = this.code;\r\n\t\t\t\tif (updateOperators.some(c => c === code && c === this.expr.charCodeAt(this.index + 1))) {\r\n\t\t\t\t\tif (!updateNodeTypes.includes(env.node.type)) {\r\n\t\t\t\t\t\tthis.throwError(`Unexpected ${env.node.operator}`);\r\n\t\t\t\t\t}\r\n\t\t\t\t\tthis.index += 2;\r\n\t\t\t\t\tenv.node = {\r\n\t\t\t\t\t\ttype: 'UpdateExpression',\r\n\t\t\t\t\t\toperator: code === PLUS_CODE ? '++' : '--',\r\n\t\t\t\t\t\targument: env.node,\r\n\t\t\t\t\t\tprefix: false,\r\n\t\t\t\t\t};\r\n\t\t\t\t}\r\n\t\t\t}\r\n\t\t});\r\n\r\n\t\tjsep.hooks.add('after-expression', function gobbleAssignment(env) {\r\n\t\t\tif (env.node && assignmentOperators.has(env.node.operator)) {\r\n\t\t\t\tenv.node.type = 'AssignmentExpression';\r\n\t\t\t}\r\n\t\t});\r\n\t},\r\n};\r\n"],"names":["name","[object Object]","jsep","assignmentOperators","Set","updateOperators","updateNodeTypes","IDENTIFIER","MEMBER_EXP","forEach","op","addBinaryOp","hooks","add","env","code","this","some","c","expr","charCodeAt","index","node","type","operator","argument","gobbleTokenProperty","gobbleIdentifier","prefix","includes","throwError","has"],"mappings":"wCAGe,CACdA,KAAM,aAENC,KAAKC,GAEJ,MAAMC,EAAsB,IAAIC,IAAI,CACnC,IACA,KACA,MACA,KACA,KACA,KACA,KACA,MACA,MACA,OACA,KACA,KACA,OAEKC,EAAkB,CAvBR,GACC,IAuBXC,EAAkB,CAACJ,EAAKK,WAAYL,EAAKM,YAI/CL,EAAoBM,SAAQC,GAAMR,EAAKS,YAAYD,EAAI,MAEvDR,EAAKU,MAAMC,IAAI,gBAAgB,SAA4BC,GAC1D,MAAMC,EAAOC,KAAKD,KACdV,EAAgBY,MAAKC,GAAKA,IAAMH,GAAQG,IAAMF,KAAKG,KAAKC,WAAWJ,KAAKK,MAAQ,OACnFL,KAAKK,OAAS,EACdP,EAAIQ,KAAO,CACVC,KAAM,mBACNC,SApCa,KAoCHT,EAAqB,KAAO,KACtCU,SAAUT,KAAKU,oBAAoBV,KAAKW,oBACxCC,QAAQ,GAEJd,EAAIQ,KAAKG,UAAanB,EAAgBuB,SAASf,EAAIQ,KAAKG,SAASF,OACrEP,KAAKc,WAAW,cAAchB,EAAIQ,KAAKE,gBAK1CtB,EAAKU,MAAMC,IAAI,eAAe,SAA6BC,GAC1D,GAAIA,EAAIQ,KAAM,CACb,MAAMP,EAAOC,KAAKD,KACdV,EAAgBY,MAAKC,GAAKA,IAAMH,GAAQG,IAAMF,KAAKG,KAAKC,WAAWJ,KAAKK,MAAQ,OAC9Ef,EAAgBuB,SAASf,EAAIQ,KAAKC,OACtCP,KAAKc,WAAW,cAAchB,EAAIQ,KAAKE,YAExCR,KAAKK,OAAS,EACdP,EAAIQ,KAAO,CACVC,KAAM,mBACNC,SAxDY,KAwDFT,EAAqB,KAAO,KACtCU,SAAUX,EAAIQ,KACdM,QAAQ,QAMZ1B,EAAKU,MAAMC,IAAI,oBAAoB,SAA0BC,GACxDA,EAAIQ,MAAQnB,EAAoB4B,IAAIjB,EAAIQ,KAAKE,YAChDV,EAAIQ,KAAKC,KAAO"} |
+4
-3
@@ -28,5 +28,6 @@ const PLUS_CODE = 43; // + | ||
| // See operator precedence https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Operators/Operator_Precedence | ||
| assignmentOperators.forEach(op => jsep.addBinaryOp(op, 11)); | ||
| // We need lower priority than || and && which start at 1 | ||
| assignmentOperators.forEach(op => jsep.addBinaryOp(op, 0.9)); | ||
| jsep.hooks.add('gobble-expression', function gobbleUpdatePrefix(env) { | ||
| jsep.hooks.add('gobble-token', function gobbleUpdatePrefix(env) { | ||
| const code = this.code; | ||
@@ -38,3 +39,3 @@ if (updateOperators.some(c => c === code && c === this.expr.charCodeAt(this.index + 1))) { | ||
| operator: code === PLUS_CODE ? '++' : '--', | ||
| argument: this.gobbleExpression(), | ||
| argument: this.gobbleTokenProperty(this.gobbleIdentifier()), | ||
| prefix: true, | ||
@@ -41,0 +42,0 @@ }; |
@@ -1,2 +0,2 @@ | ||
| var e={name:"assignment",init(e){const o=new Set(["=","*=","**=","/=","%=","+=","-=","<<=",">>=",">>>=","&=","^=","|="]),n=[43,45],t=[e.IDENTIFIER,e.MEMBER_EXP];o.forEach((o=>e.addBinaryOp(o,11))),e.hooks.add("gobble-expression",(function(e){const o=this.code;n.some((e=>e===o&&e===this.expr.charCodeAt(this.index+1)))&&(this.index+=2,e.node={type:"UpdateExpression",operator:43===o?"++":"--",argument:this.gobbleExpression(),prefix:!0},e.node.argument&&t.includes(e.node.argument.type)||this.throwError(`Unexpected ${e.node.operator}`))})),e.hooks.add("after-token",(function(e){if(e.node){const o=this.code;n.some((e=>e===o&&e===this.expr.charCodeAt(this.index+1)))&&(t.includes(e.node.type)||this.throwError(`Unexpected ${e.node.operator}`),this.index+=2,e.node={type:"UpdateExpression",operator:43===o?"++":"--",argument:e.node,prefix:!1})}})),e.hooks.add("after-expression",(function(e){e.node&&o.has(e.node.operator)&&(e.node.type="AssignmentExpression")}))}};export{e as default}; | ||
| var e={name:"assignment",init(e){const o=new Set(["=","*=","**=","/=","%=","+=","-=","<<=",">>=",">>>=","&=","^=","|="]),t=[43,45],n=[e.IDENTIFIER,e.MEMBER_EXP];o.forEach((o=>e.addBinaryOp(o,.9))),e.hooks.add("gobble-token",(function(e){const o=this.code;t.some((e=>e===o&&e===this.expr.charCodeAt(this.index+1)))&&(this.index+=2,e.node={type:"UpdateExpression",operator:43===o?"++":"--",argument:this.gobbleTokenProperty(this.gobbleIdentifier()),prefix:!0},e.node.argument&&n.includes(e.node.argument.type)||this.throwError(`Unexpected ${e.node.operator}`))})),e.hooks.add("after-token",(function(e){if(e.node){const o=this.code;t.some((e=>e===o&&e===this.expr.charCodeAt(this.index+1)))&&(n.includes(e.node.type)||this.throwError(`Unexpected ${e.node.operator}`),this.index+=2,e.node={type:"UpdateExpression",operator:43===o?"++":"--",argument:e.node,prefix:!1})}})),e.hooks.add("after-expression",(function(e){e.node&&o.has(e.node.operator)&&(e.node.type="AssignmentExpression")}))}};export{e as default}; | ||
| //# sourceMappingURL=index.min.js.map |
@@ -1,1 +0,1 @@ | ||
| {"version":3,"file":"index.min.js","sources":["../src/index.js"],"sourcesContent":["const PLUS_CODE = 43; // +\r\nconst MINUS_CODE = 45; // -\r\n\r\nexport default {\r\n\tname: 'assignment',\r\n\r\n\tinit(jsep) {\r\n\t\t// Assignment and Update support\r\n\t\tconst assignmentOperators = new Set([\r\n\t\t\t'=',\r\n\t\t\t'*=',\r\n\t\t\t'**=',\r\n\t\t\t'/=',\r\n\t\t\t'%=',\r\n\t\t\t'+=',\r\n\t\t\t'-=',\r\n\t\t\t'<<=',\r\n\t\t\t'>>=',\r\n\t\t\t'>>>=',\r\n\t\t\t'&=',\r\n\t\t\t'^=',\r\n\t\t\t'|=',\r\n\t\t]);\r\n\t\tconst updateOperators = [PLUS_CODE, MINUS_CODE];\r\n\t\tconst updateNodeTypes = [jsep.IDENTIFIER, jsep.MEMBER_EXP];\r\n\r\n\t\t// See operator precedence https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Operators/Operator_Precedence\r\n\t\tassignmentOperators.forEach(op => jsep.addBinaryOp(op, 11));\r\n\r\n\t\tjsep.hooks.add('gobble-expression', function gobbleUpdatePrefix(env) {\r\n\t\t\tconst code = this.code;\r\n\t\t\tif (updateOperators.some(c => c === code && c === this.expr.charCodeAt(this.index + 1))) {\r\n\t\t\t\tthis.index += 2;\r\n\t\t\t\tenv.node = {\r\n\t\t\t\t\ttype: 'UpdateExpression',\r\n\t\t\t\t\toperator: code === PLUS_CODE ? '++' : '--',\r\n\t\t\t\t\targument: this.gobbleExpression(),\r\n\t\t\t\t\tprefix: true,\r\n\t\t\t\t};\r\n\t\t\t\tif (!env.node.argument || !updateNodeTypes.includes(env.node.argument.type)) {\r\n\t\t\t\t\tthis.throwError(`Unexpected ${env.node.operator}`);\r\n\t\t\t\t}\r\n\t\t\t}\r\n\t\t});\r\n\r\n\t\tjsep.hooks.add('after-token', function gobbleUpdatePostfix(env) {\r\n\t\t\tif (env.node) {\r\n\t\t\t\tconst code = this.code;\r\n\t\t\t\tif (updateOperators.some(c => c === code && c === this.expr.charCodeAt(this.index + 1))) {\r\n\t\t\t\t\tif (!updateNodeTypes.includes(env.node.type)) {\r\n\t\t\t\t\t\tthis.throwError(`Unexpected ${env.node.operator}`);\r\n\t\t\t\t\t}\r\n\t\t\t\t\tthis.index += 2;\r\n\t\t\t\t\tenv.node = {\r\n\t\t\t\t\t\ttype: 'UpdateExpression',\r\n\t\t\t\t\t\toperator: code === PLUS_CODE ? '++' : '--',\r\n\t\t\t\t\t\targument: env.node,\r\n\t\t\t\t\t\tprefix: false,\r\n\t\t\t\t\t};\r\n\t\t\t\t}\r\n\t\t\t}\r\n\t\t});\r\n\r\n\t\tjsep.hooks.add('after-expression', function gobbleAssignment(env) {\r\n\t\t\tif (env.node && assignmentOperators.has(env.node.operator)) {\r\n\t\t\t\tenv.node.type = 'AssignmentExpression';\r\n\t\t\t}\r\n\t\t});\r\n\t},\r\n};\r\n"],"names":["name","[object Object]","jsep","assignmentOperators","Set","updateOperators","updateNodeTypes","IDENTIFIER","MEMBER_EXP","forEach","op","addBinaryOp","hooks","add","env","code","this","some","c","expr","charCodeAt","index","node","type","operator","argument","gobbleExpression","prefix","includes","throwError","has"],"mappings":"AAGA,MAAe,CACdA,KAAM,aAENC,KAAKC,GAEJ,MAAMC,EAAsB,IAAIC,IAAI,CACnC,IACA,KACA,MACA,KACA,KACA,KACA,KACA,MACA,MACA,OACA,KACA,KACA,OAEKC,EAAkB,CAvBR,GACC,IAuBXC,EAAkB,CAACJ,EAAKK,WAAYL,EAAKM,YAG/CL,EAAoBM,SAAQC,GAAMR,EAAKS,YAAYD,EAAI,MAEvDR,EAAKU,MAAMC,IAAI,qBAAqB,SAA4BC,GAC/D,MAAMC,EAAOC,KAAKD,KACdV,EAAgBY,MAAKC,GAAKA,IAAMH,GAAQG,IAAMF,KAAKG,KAAKC,WAAWJ,KAAKK,MAAQ,OACnFL,KAAKK,OAAS,EACdP,EAAIQ,KAAO,CACVC,KAAM,mBACNC,SAnCa,KAmCHT,EAAqB,KAAO,KACtCU,SAAUT,KAAKU,mBACfC,QAAQ,GAEJb,EAAIQ,KAAKG,UAAanB,EAAgBsB,SAASd,EAAIQ,KAAKG,SAASF,OACrEP,KAAKa,WAAW,cAAcf,EAAIQ,KAAKE,gBAK1CtB,EAAKU,MAAMC,IAAI,eAAe,SAA6BC,GAC1D,GAAIA,EAAIQ,KAAM,CACb,MAAMP,EAAOC,KAAKD,KACdV,EAAgBY,MAAKC,GAAKA,IAAMH,GAAQG,IAAMF,KAAKG,KAAKC,WAAWJ,KAAKK,MAAQ,OAC9Ef,EAAgBsB,SAASd,EAAIQ,KAAKC,OACtCP,KAAKa,WAAW,cAAcf,EAAIQ,KAAKE,YAExCR,KAAKK,OAAS,EACdP,EAAIQ,KAAO,CACVC,KAAM,mBACNC,SAvDY,KAuDFT,EAAqB,KAAO,KACtCU,SAAUX,EAAIQ,KACdK,QAAQ,QAMZzB,EAAKU,MAAMC,IAAI,oBAAoB,SAA0BC,GACxDA,EAAIQ,MAAQnB,EAAoB2B,IAAIhB,EAAIQ,KAAKE,YAChDV,EAAIQ,KAAKC,KAAO"} | ||
| {"version":3,"file":"index.min.js","sources":["../src/index.js"],"sourcesContent":["const PLUS_CODE = 43; // +\r\nconst MINUS_CODE = 45; // -\r\n\r\nexport default {\r\n\tname: 'assignment',\r\n\r\n\tinit(jsep) {\r\n\t\t// Assignment and Update support\r\n\t\tconst assignmentOperators = new Set([\r\n\t\t\t'=',\r\n\t\t\t'*=',\r\n\t\t\t'**=',\r\n\t\t\t'/=',\r\n\t\t\t'%=',\r\n\t\t\t'+=',\r\n\t\t\t'-=',\r\n\t\t\t'<<=',\r\n\t\t\t'>>=',\r\n\t\t\t'>>>=',\r\n\t\t\t'&=',\r\n\t\t\t'^=',\r\n\t\t\t'|=',\r\n\t\t]);\r\n\t\tconst updateOperators = [PLUS_CODE, MINUS_CODE];\r\n\t\tconst updateNodeTypes = [jsep.IDENTIFIER, jsep.MEMBER_EXP];\r\n\r\n\t\t// See operator precedence https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Operators/Operator_Precedence\r\n\t\t// We need lower priority than || and && which start at 1\r\n\t\tassignmentOperators.forEach(op => jsep.addBinaryOp(op, 0.9));\r\n\r\n\t\tjsep.hooks.add('gobble-token', function gobbleUpdatePrefix(env) {\r\n\t\t\tconst code = this.code;\r\n\t\t\tif (updateOperators.some(c => c === code && c === this.expr.charCodeAt(this.index + 1))) {\r\n\t\t\t\tthis.index += 2;\r\n\t\t\t\tenv.node = {\r\n\t\t\t\t\ttype: 'UpdateExpression',\r\n\t\t\t\t\toperator: code === PLUS_CODE ? '++' : '--',\r\n\t\t\t\t\targument: this.gobbleTokenProperty(this.gobbleIdentifier()),\r\n\t\t\t\t\tprefix: true,\r\n\t\t\t\t};\r\n\t\t\t\tif (!env.node.argument || !updateNodeTypes.includes(env.node.argument.type)) {\r\n\t\t\t\t\tthis.throwError(`Unexpected ${env.node.operator}`);\r\n\t\t\t\t}\r\n\t\t\t}\r\n\t\t});\r\n\r\n\t\tjsep.hooks.add('after-token', function gobbleUpdatePostfix(env) {\r\n\t\t\tif (env.node) {\r\n\t\t\t\tconst code = this.code;\r\n\t\t\t\tif (updateOperators.some(c => c === code && c === this.expr.charCodeAt(this.index + 1))) {\r\n\t\t\t\t\tif (!updateNodeTypes.includes(env.node.type)) {\r\n\t\t\t\t\t\tthis.throwError(`Unexpected ${env.node.operator}`);\r\n\t\t\t\t\t}\r\n\t\t\t\t\tthis.index += 2;\r\n\t\t\t\t\tenv.node = {\r\n\t\t\t\t\t\ttype: 'UpdateExpression',\r\n\t\t\t\t\t\toperator: code === PLUS_CODE ? '++' : '--',\r\n\t\t\t\t\t\targument: env.node,\r\n\t\t\t\t\t\tprefix: false,\r\n\t\t\t\t\t};\r\n\t\t\t\t}\r\n\t\t\t}\r\n\t\t});\r\n\r\n\t\tjsep.hooks.add('after-expression', function gobbleAssignment(env) {\r\n\t\t\tif (env.node && assignmentOperators.has(env.node.operator)) {\r\n\t\t\t\tenv.node.type = 'AssignmentExpression';\r\n\t\t\t}\r\n\t\t});\r\n\t},\r\n};\r\n"],"names":["name","[object Object]","jsep","assignmentOperators","Set","updateOperators","updateNodeTypes","IDENTIFIER","MEMBER_EXP","forEach","op","addBinaryOp","hooks","add","env","code","this","some","c","expr","charCodeAt","index","node","type","operator","argument","gobbleTokenProperty","gobbleIdentifier","prefix","includes","throwError","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||
| "name": "@jsep-plugin/assignment", | ||
| "version": "1.0.0", | ||
| "version": "1.0.1", | ||
| "description": "Adds assignment expression support", | ||
@@ -5,0 +5,0 @@ "author": "Shelly (https://github.com/6utt3rfly)", |
33646
4.68%15
7.14%247
14.35%