Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

@agoric/evaluate

Package Overview
Dependencies
Maintainers
4
Versions
18
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@agoric/evaluate - npm Package Compare versions

Comparing version 1.1.0 to 1.2.0

5

package.json
{
"name": "@agoric/evaluate",
"version": "1.1.0",
"version": "1.2.0",
"description": "(unsafe) three-argument evaluator function",

@@ -28,3 +28,4 @@ "main": "src/main.js",

},
"dependencies": {
"dependencies": {
"@agoric/default-evaluate-options": "0.0.2",
"esm": "^3.2.5"

@@ -31,0 +32,0 @@ },

27

src/index.js

@@ -0,4 +1,9 @@

import makeDefaultEvaluateOptions from '@agoric/default-evaluate-options';
// The evaluate maker, which curries the makerOptions.
export const makeEvaluators = (makerOptions = {}) => {
const makeEvaluator = isExpr => (source, endowments = {}, options = {}) => {
// Evaluate any shims, globally!
(makerOptions.shims || []).forEach(shim => (1, eval)(shim));
const makeEvaluator = sourceType => (source, endowments = {}, options = {}) => {
const fullTransforms = [

@@ -20,7 +25,14 @@ ...(options.transforms || []),

(ss, transform) => (transform.rewrite ? transform.rewrite(ss) : ss),
{ isExpr, src: source },
{ sourceType, src: source },
);
// Work around Babel appending semicolons.
const maybeSource = sourceState.src;
const actualSource = maybeSource.endsWith(';') && !source.endsWith(';') ?
maybeSource.slice(0, -1) : maybeSource;
// Generate the expression context, if necessary.
const src = isExpr ? `(${sourceState.src}\n)` : sourceState.src;
const src = sourceType === 'expression' ? `(${actualSource}\n)` : actualSource;
// console.error(`have rewritten`, src);
const names = Object.getOwnPropertyNames(endowmentState.endowments);

@@ -45,4 +57,4 @@

return {
evaluateProgram: makeEvaluator(false),
evaluateExpr: makeEvaluator(true),
evaluateProgram: makeEvaluator('program'),
evaluateExpr: makeEvaluator('expression'),
};

@@ -52,4 +64,5 @@ };

// Export the default evaluators.
const { evaluateExpr, evaluateProgram } = makeEvaluators();
export { evaluateExpr, evaluateProgram };
const defaultEvaluateOptions = makeDefaultEvaluateOptions();
const { evaluateExpr, evaluateProgram } = makeEvaluators(defaultEvaluateOptions);
export { defaultEvaluateOptions, evaluateExpr, evaluateProgram };
export default evaluateExpr;
SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc