You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
This is a small but mighty change that I consider absolutely amazing:
Pass in an initialiser object so we don't have to .map to add fixed fields
Don't bother saving fields that are not a string (eg. null)
This simple change replaced most of my uses of A.coroutine, and avoids having to map my namedSequenceOf's to remove a scratch field, or inject static ones.
exportfunctionnamedSequenceOf(pairedParsers,template){returnnewParser(functionnamedSequenceOf$state(state){if(state.isError)returnstate;constresults={};if(template){// copy the template into resultsObject.assign(results,template);}letnextState=state;for(const[key,parser]ofpairedParsers){constout=parser.p(nextState);if(out.isError){returnout;}else{nextState=out;if(typeofkey==='string'){// don't set null keysresults[key]=out.result;}}}returnupdateResult(nextState,results);});}
Plus, WeakValueMap (why isn't that built into JavaScript?!?) caching a bunch of the terminal parsers, and the mass decodes of the regex parser, also make for a huge improvement. (I also export those wrapped parsers as xxxUncached — though they are, but they won't be if WeakRef isn't available and I switch to a regular Map, so the name actually means "don't do dumb caching".) I apply these changes through a shim library that imports Arcsecond, and exports everything again with the handful of changes — I strongly recommend doing the same (the only issue with the shim library, is terminal parsers being used internally, but I haven't noticed any).
The text was updated successfully, but these errors were encountered:
This is a small but mighty change that I consider absolutely amazing:
This simple change replaced most of my uses of A.coroutine, and avoids having to map my namedSequenceOf's to remove a scratch field, or inject static ones.
Plus,
WeakValueMap
(why isn't that built into JavaScript?!?) caching a bunch of the terminal parsers, and the mass decodes of theregex
parser, also make for a huge improvement. (I also export those wrapped parsers as xxxUncached — though they are, but they won't be ifWeakRef
isn't available and I switch to a regular Map, so the name actually means "don't do dumb caching".) I apply these changes through a shim library that imports Arcsecond, and exports everything again with the handful of changes — I strongly recommend doing the same (the only issue with the shim library, is terminal parsers being used internally, but I haven't noticed any).The text was updated successfully, but these errors were encountered: