Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* Add known globals * change Object.values/Object.entries to O from PF * tree shake Object.entries/values
- Loading branch information
1 parent
1f2f0ce
commit 80747e3
Showing
4 changed files
with
82 additions
and
5 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
3 changes: 3 additions & 0 deletions
3
test/form/samples/tree-shake-object-with-sideeffctful-getter/_config.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
module.exports = { | ||
description: 'retain functions that accept a object with a getter that has side effects' | ||
}; |
13 changes: 13 additions & 0 deletions
13
test/form/samples/tree-shake-object-with-sideeffctful-getter/_expected.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
let effects = 0; | ||
|
||
const objWithEffect = { | ||
get foo() { | ||
effects++; | ||
return 'foo'; | ||
} | ||
}; | ||
|
||
Object.values(objWithEffect); | ||
Object.entries(objWithEffect); | ||
|
||
assert.equal(effects, 2); |
27 changes: 27 additions & 0 deletions
27
test/form/samples/tree-shake-object-with-sideeffctful-getter/main.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
let effects = 0; | ||
|
||
const objWithEffect = { | ||
get foo() { | ||
effects++; | ||
return 'foo'; | ||
} | ||
}; | ||
|
||
const objWithoutEffect1 = { | ||
get foo() { | ||
return 'foo'; | ||
} | ||
}; | ||
const objWithoutEffect2 = { | ||
foo: 'foo' | ||
}; | ||
|
||
Object.values(objWithEffect); | ||
Object.entries(objWithEffect); | ||
|
||
Object.values(objWithoutEffect1); | ||
Object.entries(objWithoutEffect1); | ||
Object.values(objWithoutEffect2); | ||
Object.entries(objWithoutEffect2); | ||
|
||
assert.equal(effects, 2); |