Security News
tea.xyz Spam Plagues npm and RubyGems Package Registries
Tea.xyz, a crypto project aimed at rewarding open source contributions, is once again facing backlash due to an influx of spam packages flooding public package registries.
Changelog
1.0.0 / 2018-12-20
Readme
Functions to create and call functions and evaluate expressions.
npm install eva
bower install eva
Use dist/eva.js
or dist/eva.min.js
(minified version).
var eva = require("eva");
define(["path/to/dist/eva.js"], function(eva) {
...
});
<!-- Use bower_components/eva/dist/eva.js if the library was installed by Bower -->
<script type="text/javascript" src="path/to/dist/eva.js"></script>
<script type="text/javascript">
// eva is available via eva field of window object
...
</script>
var func = eva.createFunction("(a || 0) + (b || 0) + (c || 0)", {paramNames: "a, b, c", expression: true});
console.log(func("abc")); // abc00
console.log(func(10, 1, 5, 8)); // 16
func = eva.createFunction("if (obj.b) {return a + b;} else {return 'a=' + a;}", {scope: true, paramNames: "obj"});
console.log( func({a: "a", b: "bc"}) ); // abc
console.log( eva.evalWith("this.a + this.b", {a: 1, b: 9}) ); // 10
console.log( eva.evalWith("fn(this.expr)", {expr: "Math.sin(0)"}, {fn: eva.evalWith}) ); // 0
var obj = {};
eva.createDelegateMethod(eva, "evalWith", {destination: obj, destinationMethod: "expr"});
console.log( obj.expr("Math.cos(0)") ); // 1
func = eva.closure(eva.evalWith, ["this.a * this.b"]);
console.log( func({a: 4, b: 7}) ); // 28
console.log( func({a: -3, b: 5}) ); // -15
func = eva.closure(eva.evalWith, [{a: 3, b: -9}], null, {prependArgs: true});
console.log( func("this.a + this.b") ); // -6
console.log( func("this.a - this.b") ); // 12
var funcList = [
eva.closure(eva.evalWith, ["this.a + this.b"]),
eva.closure(eva.evalWith, ["this.a * this.b"]),
eva.closure(eva.evalWith, ["Math.max(this.a, this.b)"])
];
console.log( eva.map(funcList, [{a: 2, b: -7}]) ); // [-5, -14, 2]
Create function to further use.
Calculate/evaluate value of specified expression using given context and scope.
Create function that executes specified method of the given object.
Create function that executes specified function with given parameters and context and returns result of call.
Call each function from specified list and return array containing results of calls.
See doc
folder for details.
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.
Copyright (c) 2014-2018 Denis Sikuler
Licensed under the MIT license.
FAQs
Functions to create and call functions and evaluate expressions
The npm package eva receives a total of 27 weekly downloads. As such, eva popularity was classified as not popular.
We found that eva demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
Tea.xyz, a crypto project aimed at rewarding open source contributions, is once again facing backlash due to an influx of spam packages flooding public package registries.
Security News
As cyber threats become more autonomous, AI-powered defenses are crucial for businesses to stay ahead of attackers who can exploit software vulnerabilities at scale.
Security News
UnitedHealth Group disclosed that the ransomware attack on Change Healthcare compromised protected health information for millions in the U.S., with estimated costs to the company expected to reach $1 billion.