cjss-group / CJSS

A CSS based web framework
https://cjss.js.org/
MIT License
670 stars 20 forks source link

functionFromString seems to be a pointless abstraction of Function #44

Closed c-harding closed 5 years ago

c-harding commented 5 years ago

The function functionFromString seems to just be the Function constructor with the arguments in a different order. It then returns a subclass of Function, with a method run which is just a rearrangement of the argument order of apply inherited from Function.

I would propose removing the EvalFunction class, as it does nothing that can’t be done with Function.prototype.apply, Function.prototype.call and the function itself.

I would also propose removing functionFromString, it is just new Function with a different argument order.

https://github.com/scottkellum/CJSS/blob/367dad1d442b7df2adf74b705b7934a7018b0f67/src/functionFromString.js#L4

KargJonas commented 5 years ago

Sure. Originally I left it in to allow us to omit context, which allowed for cleaner code.

c-harding commented 5 years ago

Sure. Originally I left it in to allow us to omit context, which allowed for cleaner code.

That can be done by just calling the function, e.g.

const render = new Function(arg1, arg2, "...");
render(a, b);