{"id":19009195,"url":"https://github.com/gamtiq/eva","last_synced_at":"2025-04-22T22:46:59.989Z","repository":{"id":15991696,"uuid":"18734876","full_name":"gamtiq/eva","owner":"gamtiq","description":"Functions to create and call functions and evaluate expressions","archived":false,"fork":false,"pushed_at":"2018-12-19T21:48:46.000Z","size":704,"stargazers_count":15,"open_issues_count":0,"forks_count":1,"subscribers_count":4,"default_branch":"master","last_synced_at":"2025-04-16T09:28:55.654Z","etag":null,"topics":["closure","delegate","dynamic","eval","evaluate","execute","expression","function","method"],"latest_commit_sha":null,"homepage":"","language":"JavaScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/gamtiq.png","metadata":{"files":{"readme":"README.md","changelog":"History.md","contributing":null,"funding":null,"license":"LICENSE-MIT","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2014-04-13T17:18:01.000Z","updated_at":"2023-03-04T18:55:38.000Z","dependencies_parsed_at":"2022-08-30T14:01:23.723Z","dependency_job_id":null,"html_url":"https://github.com/gamtiq/eva","commit_stats":null,"previous_names":[],"tags_count":5,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/gamtiq%2Feva","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/gamtiq%2Feva/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/gamtiq%2Feva/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/gamtiq%2Feva/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/gamtiq","download_url":"https://codeload.github.com/gamtiq/eva/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":250337908,"owners_count":21414102,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["closure","delegate","dynamic","eval","evaluate","execute","expression","function","method"],"created_at":"2024-11-08T19:07:04.516Z","updated_at":"2025-04-22T22:46:59.945Z","avatar_url":"https://github.com/gamtiq.png","language":"JavaScript","readme":"# eva\n\nFunctions to create and call functions and evaluate expressions.\n\n[![NPM version](https://badge.fury.io/js/eva.png)](http://badge.fury.io/js/eva)\n[![Build Status](https://travis-ci.org/gamtiq/eva.png)](https://travis-ci.org/gamtiq/eva)\n[![Built with Grunt](https://gruntjs.com/cdn/builtwith.png)](http://gruntjs.com/)\n\n## Installation\n\n### Node\n\n    npm install eva\n\n### [Bower](http://bower.io)\n\n    bower install eva\n\n### AMD, \u0026lt;script\u0026gt;\n\nUse `dist/eva.js` or `dist/eva.min.js` (minified version).\n\n## Usage\n\n### Node\n\n```js\nvar eva = require(\"eva\");\n```\n\n### AMD\n\n```js\ndefine([\"path/to/dist/eva.js\"], function(eva) {\n    ...\n});\n```\n\n### Bower, \u0026lt;script\u0026gt;\n\n```html\n\n\u003c!-- Use bower_components/eva/dist/eva.js if the library was installed by Bower --\u003e\n\n\u003cscript type=\"text/javascript\" src=\"path/to/dist/eva.js\"\u003e\u003c/script\u003e\n\u003cscript type=\"text/javascript\"\u003e\n    // eva is available via eva field of window object\n    ...\n\u003c/script\u003e\n```\n\n### Examples\n\n```js\nvar func = eva.createFunction(\"(a || 0) + (b || 0) + (c || 0)\", {paramNames: \"a, b, c\", expression: true});\nconsole.log(func(\"abc\"));   // abc00\nconsole.log(func(10, 1, 5, 8));   // 16\n\nfunc = eva.createFunction(\"if (obj.b) {return a + b;} else {return 'a=' + a;}\", {scope: true, paramNames: \"obj\"});\nconsole.log( func({a: \"a\", b: \"bc\"}) );   // abc\n\nconsole.log( eva.evalWith(\"this.a + this.b\", {a: 1, b: 9}) );   // 10\nconsole.log( eva.evalWith(\"fn(this.expr)\", {expr: \"Math.sin(0)\"}, {fn: eva.evalWith}) );   // 0\n\nvar obj = {};\neva.createDelegateMethod(eva, \"evalWith\", {destination: obj, destinationMethod: \"expr\"});\nconsole.log( obj.expr(\"Math.cos(0)\") );   // 1\n\nfunc = eva.closure(eva.evalWith, [\"this.a * this.b\"]);\nconsole.log( func({a: 4, b: 7}) );   // 28\nconsole.log( func({a: -3, b: 5}) );   // -15\n\nfunc = eva.closure(eva.evalWith, [{a: 3, b: -9}], null, {prependArgs: true});\nconsole.log( func(\"this.a + this.b\") );   // -6\nconsole.log( func(\"this.a - this.b\") );   // 12\n\nvar funcList = [\n    eva.closure(eva.evalWith, [\"this.a + this.b\"]),\n    eva.closure(eva.evalWith, [\"this.a * this.b\"]),\n    eva.closure(eva.evalWith, [\"Math.max(this.a, this.b)\"])\n];\nconsole.log( eva.map(funcList, [{a: 2, b: -7}]) );   // [-5, -14, 2]\n```\n\n## API\n\n### createFunction(code: String, [settings: Object]): Function\n\nCreate function to further use.\n\n### evalWith(expression: String, [context: Object], [scope: Object])\n\nCalculate/evaluate value of specified expression using given context and scope.\n\n### createDelegateMethod(delegate: Object, method: String, [settings: Object]): Function\n\nCreate function that executes specified method of the given object.\n\n### closure(action: Function, [paramList: Array], [context: Object], [settings: Object]): Function\n\nCreate function that executes specified function with given parameters and context and returns result of call.\n\n### map(funcList: Array, [paramList: Array | Function], [context: Object | Function], [settings: Object]): Array\n\nCall each function from specified list and return array containing results of calls.\n\nSee `doc` folder for details.\n\n## Related projects\n\n* [adam](https://github.com/gamtiq/adam)\n* [teo](https://github.com/gamtiq/teo)\n\n## Contributing\nIn lieu of a formal styleguide, take care to maintain the existing coding style.\nAdd unit tests for any new or changed functionality.\nLint and test your code using [Grunt](http://gruntjs.com/).\n\n## License\nCopyright (c) 2014-2018 Denis Sikuler  \nLicensed under the MIT license.\n","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fgamtiq%2Feva","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fgamtiq%2Feva","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fgamtiq%2Feva/lists"}