eva
Functions to create and call functions and evaluate expressions.
Installation
Node
npm install eva
Bower
bower install eva
AMD, <script>
Use dist/eva.js
or dist/eva.min.js
(minified version).
Usage
Node
var eva = ;
AMD
;
Bower, <script>
<!-- Use bower_components/eva/dist/eva.js if the library was installed by Bower -->
Examples
var func = eva;console; // abc00console; // 16 func = eva;console; // abc console; // 10console; // 0 var obj = {};eva;console; // 1 func = eva;console; // 28console; // -15 func = eva;console; // -6console; // 12 var funcList = eva eva eva;console; // [-5, -14, 2]
API
createFunction(code: String, [settings: Object]): Function
Create function to further use.
evalWith(expression: String, [context: Object], [scope: Object])
Calculate/evaluate value of specified expression using given context and scope.
createDelegateMethod(delegate: Object, method: String, [settings: Object]): Function
Create function that executes specified method of the given object.
closure(action: Function, [paramList: Array], [context: Object], [settings: Object]): Function
Create function that executes specified function with given parameters and context and returns result of call.
map(funcList: Array, [paramList: Array | Function], [context: Object | Function], [settings: Object]): Array
Call each function from specified list and return array containing results of calls.
See doc
folder for details.
Related projects
Contributing
In lieu of a formal styleguide, take care to maintain the existing coding style. Add unit tests for any new or changed functionality. Lint and test your code using Grunt.
License
Copyright (c) 2014-2018 Denis Sikuler
Licensed under the MIT license.