@jsonic/directive
Advanced tools
Comparing version 0.7.0 to 0.8.0
@@ -99,5 +99,4 @@ "use strict"; | ||
]) | ||
// .bc((...all: any[]) => (action as any)(...all)) | ||
.bc(function (rule, ctx) { | ||
let out = action.call(this, rule, ctx); | ||
.bc(function (rule, ctx, next, tkn) { | ||
let out = action.call(this, rule, ctx, next, tkn); | ||
if (out === null || out === void 0 ? void 0 : out.isToken) { | ||
@@ -104,0 +103,0 @@ return out; |
@@ -1,1 +0,1 @@ | ||
!function(e){if("object"==typeof exports&&"undefined"!=typeof module)module.exports=e();else if("function"==typeof define&&define.amd)define([],e);else{("undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof self?self:this).JsonicDirective=e()}}((function(){var e={};Object.defineProperty(e,"__esModule",{value:!0}),e.Directive=void 0;const n=(e,n)=>{let l,t=("string"==typeof n.rules?n.rules.split(/\s*,\s*/):n.rules||[]).filter(e=>""!==e),o=n.name,i=n.open,r=n.close;if("string"==typeof n.action){let t=n.action;l=n=>n.node=e.util.prop(e.options,t)}else l=n.action;let s={},u="#D_open_"+o,c="#D_close_"+o,d=e.fixed(i),f=null==r?null:e.fixed(r);if(null!=d)throw new Error("Directive open token already in use: "+i);s[u]=i,null==f&&null!=r&&(s[c]=r),e.options({fixed:{token:s},error:{[o+"_close"]:null==r?null:"directive "+o+' close "'+r+'" without open "'+i+'"'},hint:{[o+"_close"]:null==r?null:`\nThe ${o} directive must start with the characters "${i}" and end\nwith the characters "${r}". The end characters "${r}" may not\nappear without the start characters "${i}" appearing first:\n"${i}...${r}".\n`}});let a=e.token.CA;d=e.fixed(i),f=null==r?null:e.fixed(r),t.forEach(n=>{e.rule(n,e=>(e.open({s:[d],p:o,n:{dr:1}}),null!=r&&(e.open([{s:[f],c:{n:{dr:0}},e:(e,n)=>n.t0.bad(o+"_close")},{s:[f],b:1}]),e.close({s:[f],b:1})),e))}),e.rule(o,e=>e.clear().bo(e=>{e.node={}}).open([{p:"val",n:null==r?{}:{pk:-1,il:0}}]).bc((function(e,n){let t=l.call(this,e,n);if(null==t?void 0:t.isToken)return t})).close(null!=r?[{s:[f]},{s:[a,f]}]:[]))};return e.Directive=n,n.defaults={rules:"val,pair,elem"},e})); | ||
!function(e){if("object"==typeof exports&&"undefined"!=typeof module)module.exports=e();else if("function"==typeof define&&define.amd)define([],e);else{("undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof self?self:this).JsonicDirective=e()}}((function(){var e={};Object.defineProperty(e,"__esModule",{value:!0}),e.Directive=void 0;const n=(e,n)=>{let l,t=("string"==typeof n.rules?n.rules.split(/\s*,\s*/):n.rules||[]).filter(e=>""!==e),o=n.name,i=n.open,r=n.close;if("string"==typeof n.action){let t=n.action;l=n=>n.node=e.util.prop(e.options,t)}else l=n.action;let s={},u="#D_open_"+o,c="#D_close_"+o,d=e.fixed(i),f=null==r?null:e.fixed(r);if(null!=d)throw new Error("Directive open token already in use: "+i);s[u]=i,null==f&&null!=r&&(s[c]=r),e.options({fixed:{token:s},error:{[o+"_close"]:null==r?null:"directive "+o+' close "'+r+'" without open "'+i+'"'},hint:{[o+"_close"]:null==r?null:`\nThe ${o} directive must start with the characters "${i}" and end\nwith the characters "${r}". The end characters "${r}" may not\nappear without the start characters "${i}" appearing first:\n"${i}...${r}".\n`}});let a=e.token.CA;d=e.fixed(i),f=null==r?null:e.fixed(r),t.forEach(n=>{e.rule(n,e=>(e.open({s:[d],p:o,n:{dr:1}}),null!=r&&(e.open([{s:[f],c:{n:{dr:0}},e:(e,n)=>n.t0.bad(o+"_close")},{s:[f],b:1}]),e.close({s:[f],b:1})),e))}),e.rule(o,e=>e.clear().bo(e=>{e.node={}}).open([{p:"val",n:null==r?{}:{pk:-1,il:0}}]).bc((function(e,n,t,o){let i=l.call(this,e,n,t,o);if(null==i?void 0:i.isToken)return i})).close(null!=r?[{s:[f]},{s:[a,f]}]:[]))};return e.Directive=n,n.defaults={rules:"val,pair,elem"},e})); |
@@ -10,2 +10,3 @@ /* Copyright (c) 2021-2022 Richard Rodger, MIT License */ | ||
Context, | ||
Token, | ||
} from '@jsonic/jsonic-next' | ||
@@ -135,5 +136,10 @@ | ||
]) | ||
// .bc((...all: any[]) => (action as any)(...all)) | ||
.bc(function (this: RuleSpec, rule: Rule, ctx: Context) { | ||
let out = action.call(this, rule, ctx) | ||
.bc(function ( | ||
this: RuleSpec, | ||
rule: Rule, | ||
ctx: Context, | ||
next: Rule, | ||
tkn?: Token | void | ||
) { | ||
let out = action.call(this, rule, ctx, next, tkn) | ||
if (out?.isToken) { | ||
@@ -140,0 +146,0 @@ return out |
{ | ||
"name": "@jsonic/directive", | ||
"version": "0.7.0", | ||
"version": "0.8.0", | ||
"description": "This plugin allows the [Jsonic](https://jsonic.senecajs.org) JSON parser to support directive syntax.", | ||
@@ -43,14 +43,16 @@ "main": "directive.js", | ||
"devDependencies": { | ||
"@types/jest": "^27.5.1", | ||
"@types/jest": "^28.1.4", | ||
"browserify": "^17.0.0", | ||
"esbuild": "^0.14.42", | ||
"esbuild": "^0.14.48", | ||
"esbuild-jest": "^0.5.0", | ||
"jest": "^28.1.0", | ||
"@jsonic/jsonic-next": "2.0.2", | ||
"prettier": "^2.6.2", | ||
"tinyify": "^3.0.0", | ||
"ts-jest": "^28.0.3", | ||
"typescript": "^4.7.2" | ||
"jest": "^28.1.2", | ||
"prettier": "^2.7.1", | ||
"tinyify": "^3.1.0", | ||
"ts-jest": "^28.0.5", | ||
"typescript": "^4.7.4" | ||
}, | ||
"peerDependencies": { | ||
"@jsonic/jsonic-next": ">=2" | ||
}, | ||
"dependencies": {} | ||
} |
Sorry, the diff of this file is not supported yet
16211
9
265
1