Skip to content

Commit d7cedfc

Browse files
committed
Ninja away variable names
Sorry Eve
1 parent 8a507e7 commit d7cedfc

File tree

4 files changed

+38
-41
lines changed

4 files changed

+38
-41
lines changed

plugin/__test__/proxy_demo.js

Lines changed: 14 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -1,24 +1,21 @@
11
(() => {
2-
const poop = proxify(
3-
Object.assign(
4-
Object.create({
5-
protoTest: 'old',
6-
}),
7-
{
8-
test: 'old',
9-
poop: {
10-
test: 'old',
11-
},
2+
const foo = proxify(
3+
Object.assign(Object.create({
4+
protoTest: "old"
5+
}), {
6+
test: "old",
7+
foo: {
8+
test: "old"
129
}
13-
),
14-
{
10+
}), {
1511
deep: true,
16-
prototype: true,
12+
prototype: true
1713
}
1814
);
1915

20-
// poop.test = "new"; // Errors
21-
// poop.poop.test = "new"; // Errors when `deep`
22-
// Object.getPrototypeOf(poop).test = "poop"; // Errors when `prototype`
23-
// Object.setPrototypeOf(poop, {}); // Errors
16+
// foo.test = "new"; // Errors
17+
// delete foo.test; // Errors
18+
// foo.foo.test = "new"; // Errors when `deep`
19+
// Object.getPrototypeOf(foo).test = "foo"; // Errors when `prototype`
20+
// Object.setPrototypeOf(foo, {}); // Errors when `prototype`
2421
})();

plugin/proxy.js

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -28,19 +28,19 @@ const proxify = (object, options = {}) => {
2828
},
2929

3030

31-
/*
31+
/*
3232
Set - Errors *sadface*
3333
*/
3434
set() {
35-
if (triggeredByFunction) throw new Error('Poop!');
35+
if (triggeredByFunction) throw new Error('Darn!');
3636
return Reflect.set(...arguments);
3737
},
3838
setPrototypeOf() {
39-
if (triggeredByFunction) throw new Error('Poop!');
39+
if (prototype && triggeredByFunction) throw new Error('Darn!');
4040
return Reflect.setPrototypeOf(...arguments);
4141
},
4242
deleteProperty() {
43-
if (triggeredByFunction) throw new Error('Poop!');
43+
if (triggeredByFunction) throw new Error('Darn!');
4444
return Reflect.deleteProperty(...arguments);
4545
}
4646
});

src/foo.js

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
const global = {prop: "test"};
2+
3+
$shouldNotMutate(foo);
4+
const foo = (foo) => {
5+
foo.prop = "pie";
6+
};
7+
8+
$shouldNotMutate(foo);
9+
function bar(foo) {
10+
foo.prop = 'Test';
11+
}
12+
13+
/**
14+
* This does not currently work
15+
*/
16+
$shouldNotMutate(foo);
17+
const pizza = foo => console.log(foo);
18+
19+
foo(global);
20+
bar(global);

src/poop.js

Lines changed: 0 additions & 20 deletions
This file was deleted.

0 commit comments

Comments
 (0)