File tree Expand file tree Collapse file tree 4 files changed +38
-41
lines changed Expand file tree Collapse file tree 4 files changed +38
-41
lines changed Original file line number Diff line number Diff line change 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} ) ( ) ;
Original file line number Diff line number Diff 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 } ) ;
Original file line number Diff line number Diff line change 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 ) ;
Load Diff This file was deleted.
You can’t perform that action at this time.
0 commit comments