better-eval
Advanced tools
Comparing version 1.2.2 to 1.2.3
{ | ||
"name": "better-eval", | ||
"version": "1.2.2", | ||
"version": "1.2.3", | ||
"description": "🔧 An alternative to the 'eval' function in JavaScript that is faster, easier/better to use, and has less security issues.", | ||
@@ -5,0 +5,0 @@ "main": "src/index.js", |
# 🔧 better-eval | ||
> 🚩 better-eval should not be used with code that could harm your application. | ||
### An alternative to `eval()` in JavaScript that is customizable and safer! | ||
### An alternative to ```eval()``` in JavaScript that is customizable and safer! | ||
The eval function in JavaScript sucks, and there lacks alternatives that provide the same simplicity that the original eval function had. **better-eval** solves this problem by adressing the security and spped issues, while delivering the same easy-to-use API. | ||
<a href="https://www.producthunt.com/posts/better-eval?utm_source=badge-featured&utm_medium=badge&utm_souce=badge-better-eval" target="_blank"><img src="https://api.producthunt.com/widgets/embed-image/v1/featured.svg?post_id=327967&theme=light" alt="better-eval - 🔧 An alternative to 'eval' that is just better! | Product Hunt" style="width: 250px; height: 54px;" width="250" height="54" /></a> | ||
<br /><br /> | ||
<a href="https://www.npmjs.com/package/better-eval"> | ||
<img src="https://img.shields.io/npm/v/better-eval?style=flat-square&color=FF524C&labelColor=000" alt="NPM Version"> | ||
<img src="https://img.shields.io/npm/dt/better-eval.svg?style=flat-square&color=FF524C&labelColor=000" alt="NPM Version"> | ||
<img src="https://badgen.net/badgesize/brotli/https/unpkg.com/better-eval/src?style=flat-square&label=size&color=FF524C&labelColor=000" alt="NPM Version"> | ||
<img src="https://img.shields.io/npm/v/better-eval?style=flat-square&color=FF524C&labelColor=000" alt="NPM Version"> | ||
<img src="https://img.shields.io/npm/dt/better-eval.svg?style=flat-square&color=FF524C&labelColor=000" alt="NPM Version"> | ||
<img src="https://badgen.net/badgesize/brotli/https/unpkg.com/better-eval/src?style=flat-square&label=size&color=FF524C&labelColor=000" alt="NPM Version"> | ||
</a> | ||
@@ -19,6 +19,7 @@ | ||
- ⚡ A simple and easy to use API. | ||
- 🛠️ Easily customizable for your needs. | ||
- 🛠️ Easily customizable for your needs. | ||
- ✅ Tested and Mantained. | ||
## Installation | ||
```sh | ||
@@ -62,4 +63,17 @@ npm install better-eval | ||
However, for your safety, usage of the `Function` constructor, `eval` function and `require` function are disabled, and will not be added to your variables. | ||
## Blacklist | ||
For your safety, any of these global variables on the blacklist will not be added to your variables: | ||
- global | ||
- process | ||
- module | ||
- require | ||
- document | ||
- window | ||
- Window | ||
- eval | ||
- Function | ||
Here is how they will be handled: | ||
```js | ||
@@ -75,3 +89,4 @@ betterEval("`Sum is ${eval('1+1')}`", { eval }); // eval is null! | ||
betterEval( | ||
"1+1", {}, | ||
"1+1", | ||
{}, | ||
{ | ||
@@ -88,2 +103,2 @@ fileName: "counting", | ||
Better-Eval is [MIT-licensed](LICENSE) open-source software created by Bharadwaj Duggaraju. | ||
better-eval is [MIT-licensed](LICENSE) open-source software created by Bharadwaj Duggaraju. |
// blacklisted variables (no fn) to be passed in through vars param in betterEval | ||
const blackListedVariablesNode = [eval, Function, global, process]; | ||
// functions that will be set to null in the betterEval default context for double safet | ||
// functions that will be set to null in the betterEval default context for double safety | ||
const blackListedVariableStrings = [ | ||
@@ -6,0 +6,0 @@ "global", |
8266
101