Fix lint and missing async generator test.
MODIFY
src/index.js
src/index.js
@@ -37,8 +37,10 @@ function makeHardener(initialFringe, opts={}) {
const { ownKeys } = Reflect;
if (opts.fringeSet) {
- if (typeof opts.fringeSet.add !== 'function' ||
- typeof opts.fringeSet.has !== 'function') {
+ if (
+ typeof opts.fringeSet.add !== 'function' ||
+ typeof opts.fringeSet.has !== 'function'
+ ) {
throw new TypeError(`opts.fringeSet must have add() and has() methods`);
}
}

MODIFY
test/test.js
test/test.js
@@ -150,7 +150,7 @@ test('harden generator', t => {
t.end();
});
-/*test('harden async generator', t => {
+test('harden async generator', t => {
async function* agen() {
yield 1;
}
@@ -162,7 +162,7 @@ test('harden generator', t => {
t.equal(h(o), o);
t.ok(Object.isFrozen(o));
t.end();
-});*/
+});
test('harden generator instances', t => {
function* gen() {
@@ -189,9 +189,9 @@ test('harden generator instances', t => {
test('prepare objects', t => {
const o = { a: { b: 123 }, b: 123 };
- const naivePrepareObject = (obj) => {
+ const naivePrepareObject = obj => {
if (typeof obj.b === 'number') {
- obj.b ++;
+ obj.b += 1;
}
};
const h = makeHardener([Object.prototype], { naivePrepareObject });
@@ -203,8 +203,14 @@ test('prepare objects', t => {
test('fringeSet must support add/has', t => {
t.ok(makeHardener([], { fringeSet: { add() {}, has() {} } }));
- t.throws(() => makeHardener([], {fringeSet: {add: true, has() { }}}), TypeError);
- t.throws(() => makeHardener([], {fringeSet: {add() { }, has: true}}), TypeError);
+ t.throws(
+ () => makeHardener([], { fringeSet: { add: true, has() {} } }),
+ TypeError,
+ );
+ t.throws(
+ () => makeHardener([], { fringeSet: { add() {}, has: true } }),
+ TypeError,
+ );
t.end();
});
@@ -222,12 +228,15 @@ test('fringeSet is used', t => {
test('do not prepare objects already in the fringeSet', t => {
const fringeSet = new WeakSet();
const h = makeHardener([Object.prototype], { fringeSet });
- const naivePrepareObject = (obj) => {
+ const naivePrepareObject = obj => {
if (typeof obj.b === 'number') {
- obj.b ++;
+ obj.b += 1;
}
};
- const inch = makeHardener([Object.prototype], {fringeSet, naivePrepareObject});
+ const inch = makeHardener([Object.prototype], {
+ fringeSet,
+ naivePrepareObject,
+ });
const o = { a: { b: 123 }, b: 123 };
t.equal(h(o.a), o.a);
t.equal(o.a.b, 123);

Fix lint and missing async generator test.