rename "rootSet" to "fringeSet" for clarity
update the docs to reference "fringe" too
MODIFY
README.md
README.md
@@ -17,7 +17,7 @@ Please see the [harden()](https://github.com/Agoric/Harden) package for more doc
## Creating a custom harden() Function
-This package (`@agoric/make-hardener`) provides a `makeHardener()` which can be used to build your own `harden()` function. When you call `makeHardener()`, you give it a set of stopping points, and the recursive property walk will stop its search when it runs into one of these points. The resulting `harden()` will throw an exception if anything it freezes has a prototype that is not already in the set of stopping points (or was frozen during the same call).
+This package (`@agoric/make-hardener`) provides a `makeHardener()` which can be used to build your own `harden()` function. When you call `makeHardener()`, you give it an iterable of stopping points (the "fringe"), and the recursive property walk will stop its search when it runs into the fringe. The resulting `harden()` will throw an exception if anything it freezes has a prototype that is not already in the fringe, or was frozen during the same call (and thus added to the fringe).
[travis-svg]: https://travis-ci.com/Agoric/MakeHardener.svg?branch=master
[travis-url]: https://travis-ci.com/Agoric/MakeHardener

MODIFY
index.js
index.js
// then copied from proposal-frozen-realms deep-freeze.js
// then copied from SES/src/bundle/deepFreeze.js
-function makeHardener(initialRoots) {
+function makeHardener(initialFringe) {
const { freeze, getOwnPropertyDescriptors, getPrototypeOf } = Object;
const { ownKeys } = Reflect;
// Objects that we won't freeze, either because we've frozen them already,
- // or they were one of the initial roots (terminals)
- const rootSet = new WeakSet(initialRoots);
+ // or they were one of the initial roots (terminals). These objects form
+ // the "fringe" of the hardened object graph.
+ const fringeSet = new WeakSet(initialFringe);
function harden(root) {
const toFreeze = new Set();
@@ -43,7 +44,7 @@ function makeHardener(initialRoots) {
// future proof: break until someone figures out what it should do
throw new TypeError(`Unexpected typeof: ${type}`);
}
- if (rootSet.has(val) || toFreeze.has(val)) {
+ if (fringeSet.has(val) || toFreeze.has(val)) {
// Ignore if this is an exit, or we've already visited it
return;
}
@@ -104,10 +105,10 @@ function makeHardener(initialRoots) {
function checkPrototypes() {
prototypes.forEach((path, p) => {
- if (!(toFreeze.has(p) || rootSet.has(p))) {
+ if (!(toFreeze.has(p) || fringeSet.has(p))) {
// all reachable properties have already been frozen by this point
throw new TypeError(
- `prototype ${p} of ${path} is not already in the rootSet`,
+ `prototype ${p} of ${path} is not already in the fringeSet`,
);
}
});
@@ -118,12 +119,12 @@ function makeHardener(initialRoots) {
// we capture the real WeakSet.prototype.add above, in case someone
// changes it. The two-argument form of forEach passes the second
// argument as the 'this' binding, so we add to the correct set.
- toFreeze.forEach(rootSet.add, rootSet);
+ toFreeze.forEach(fringeSet.add, fringeSet);
}
enqueue(root);
dequeue();
- // console.log("rootSet", rootSet);
+ // console.log("fringeSet", fringeSet);
// console.log("prototype set:", prototypes);
// console.log("toFreeze set:", toFreeze);
checkPrototypes();

rename "rootSet" to "fringeSet" for clarity

update the docs to reference "fringe" too