Compartment shim cleanup
MODIFY
packages/compartment-shim/src/evaluate.js
packages/compartment-shim/src/evaluate.js
@@ -9,7 +9,7 @@ import { applyTransforms, mandatoryTransforms } from './transforms.js';
import { createEvaluateFactory } from './evaluateFactory.js';
/**
- * createEvalFunction()
+ * makeEvalFunction()
* The low-level operation used by all evaluators:
* eval(), Function(), Evalutator.prototype.evaluate().
*/

MODIFY
packages/compartment-shim/src/globalObject.js
packages/compartment-shim/src/globalObject.js
import { assert } from './assertions.js';
import { defineProperties, objectHasOwnProperty } from './commons.js';
-import { createEvalFunction } from './evalFunction.js';
-import { createFunctionConstructor } from './functionConstructor.js';
+import { makeEvalFunction } from './make-evalFunction.js';
+import { makeFunctionConstructor } from './make-functionConstructor.js';
/**
* globalPropertyNames
@@ -115,14 +115,14 @@ export function createGlobalObject(realmRec, { globalTransforms }) {
switch (name) {
case 'eval':
// Use an evaluator-specific instance of eval.
- value = createEvalFunction(realmRec, globalObject, {
+ value = makeEvalFunction(realmRec, globalObject, {
globalTransforms,
});
break;
case 'Function':
// Use an evaluator-specific instance of Function.
- value = createFunctionConstructor(realmRec, globalObject, {
+ value = makeFunctionConstructor(realmRec, globalObject, {
globalTransforms,
});
break;

RENAME
packages/compartment-shim/src/evalFunction.js
packages/compartment-shim/src/make-evalFunction.js
@@ -3,11 +3,11 @@ import { defineProperties, getConstructorOf } from './commons.js';
import { performEval } from './evaluate.js';
/**
- * createEvalFunction()
+ * makeEvalFunction()
* A safe version of the native eval function which relies on
* the safety of performEvaluate for confinement.
*/
-export const createEvalFunction = (realmRec, globalObject, options = {}) => {
+export const makeEvalFunction = (realmRec, globalObject, options = {}) => {
// We use the the concise method syntax to create an eval without a
// [[Construct]] behavior (such that the invocation "new eval()" throws
// TypeError: eval is not a constructor"), but which still accepts a

RENAME
packages/compartment-shim/src/functionConstructor.js
packages/compartment-shim/src/make-functionConstructor.js
@@ -8,11 +8,11 @@ import {
import { performEval } from './evaluate.js';
/**
- * createFunctionConstructor()
+ * makeFunctionConstructor()
* A safe version of the native Function which relies on
* the safety of performEvaluate for confinement.
*/
-export function createFunctionConstructor(realmRec, globaObject, options = {}) {
+export function makeFunctionConstructor(realmRec, globaObject, options = {}) {
// Define an unused parameter to ensure Function.length === 1
// eslint-disable-next-line no-unused-vars
const newFunction = function Function(body) {

RENAME
packages/compartment-shim/test/unit/evalFunction.test.js
packages/compartment-shim/test/unit/make-evalFunction.test.js
import tap from 'tap';
import sinon from 'sinon';
-import { createEvalFunction } from '../../src/evalFunction.js';
+import { makeEvalFunction } from '../../src/make-evalFunction.js';
import stubFunctionConstructors from '../stubFunctionConstructors.js';
const { test } = tap;
-test('createEvalFunction', t => {
+test('makeEvalFunction', t => {
t.plan(28);
// Mimic repairFunctions.
@@ -21,7 +21,7 @@ test('createEvalFunction', t => {
bar: { value: 2, writable: true },
},
);
- const safeEval = createEvalFunction(realmRec, globalObject);
+ const safeEval = makeEvalFunction(realmRec, globalObject);
t.equal(safeEval('foo'), 1);
t.equal(safeEval('bar'), 2);

RENAME
packages/compartment-shim/test/unit/functionConstructor.test.js
packages/compartment-shim/test/unit/make-functionConstructor.test.js
import tap from 'tap';
import sinon from 'sinon';
-import { createFunctionConstructor } from '../../src/functionConstructor.js';
+import { makeFunctionConstructor } from '../../src/make-functionConstructor.js';
import stubFunctionConstructors from '../stubFunctionConstructors.js';
const { test } = tap;
@@ -21,7 +21,7 @@ test('functionConstructor', t => {
bar: { value: 2, writable: true },
},
);
- const safeFunction = createFunctionConstructor(realmRec, globalObject);
+ const safeFunction = makeFunctionConstructor(realmRec, globalObject);
t.equal(safeFunction('return foo')(), 1);
t.equal(safeFunction('return bar')(), 2);

Compartment shim cleanup