Skip to content

Commit

Permalink
It... worked!
Browse files Browse the repository at this point in the history
  • Loading branch information
moofMonkey committed Jan 18, 2019
1 parent b4d42dd commit 56d3441
Show file tree
Hide file tree
Showing 3 changed files with 27 additions and 5 deletions.
8 changes: 5 additions & 3 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
"scripts": {
"build": "babel -d ./lib ./src",
"prepublish": "babel -d ./lib ./src --minified",
"test": "babel --no-babelrc --plugins=./lib/index.js test.js --out-file test.opt.js"
"test": "babel --no-babelrc --plugins=./lib/index.js test.ts --out-file test.opt.js"
},
"repository": {
"type": "git",
Expand All @@ -19,7 +19,9 @@
},
"homepage": "https://github.com/vihanb/babel-plugin-loop-optimizer#readme",
"devDependencies": {
"babel-cli": "next",
"babel-preset-env": "next"
"@babel/core": "latest",
"@babel/preset-env": "latest",
"@babel/preset-typescript": "latest",
"@babel/cli": "latest"
}
}
4 changes: 2 additions & 2 deletions test.opt.js
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
{
console.log("FORWARD");
let ar = [1, 2, 3]; // loop-optimizer: FORWARD
let ar = [1, 2, 3]; // loop-optimizer: FORWARD, POSSIBLE_UNDEFINED

let _a = ar;
let _f = console.log;

for (let _i = 0; _i < _a.length; _i++) {
for (let _i = 0; _i < _a.length && _a[_i] !== undefined; _i++) {
_f(_a[_i], _i, _a);
}
}
Expand Down
20 changes: 20 additions & 0 deletions test.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
{
console.log("FORWARD")
let ar = [1,2,3]
// loop-optimizer: FORWARD, POSSIBLE_UNDEFINED
ar.forEach(console.log)
}

{
console.log("KEEP")
let ar = [1,2,3]
// loop-optimizer: KEEP
ar.forEach(console.log)
}

{
console.log("nothing")
let ar = [1,2,3]
// nothing
ar.forEach(console.log)
}

0 comments on commit 56d3441

Please sign in to comment.