skyra-project / alestra Goto Github PK
View Code? Open in Web Editor NEWCanvas-Constructor helper bot
License: Apache License 2.0
Canvas-Constructor helper bot
License: Apache License 2.0
There are many plans for the new parser and we should investigate the fastest path. At this moment, the code is parsed like if it were evaluated with eval()
, then it's validated and run. When somebody mistypes a method or does not provide enough arguments (or arguments are invalid type), they are currently detected during validation, this comes as a performance cost because it takes a while to parse all methods in a long chain.
I propose making the parser a generator method and call it from the Evaluator class similarly to this (consider PARSE
be the generator method that parses everything):
const canvas = new Canvas(Number(result[1]), Number(result[2]));
let breakChain = null;
for (const [method, args] of PARSE(code)) {
if (breakChain) {
throw new MethodParseError(`The CanvasConstructor.prototype.${breakChain} call was not chainable.`);
}
if (!(method in Canvas.prototype)) {
throw new MethodParseError(`The method ${method} does not exist.`);
}
if (this.methods.has(method)) {
if (canvas[method](...await this.methods.get(method).validate(args)) !== canvas) breakChain = method;
} else {
throw new MethodParseError(`The method ${method} is blocked.`);
}
}
That way we can throw during parsing instead of waiting for everything to be parser and then validate.
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.