-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
0ce46f3
commit d7a62cf
Showing
23 changed files
with
126 additions
and
35 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
import { find } from '../../../../src/inline-loops.macro'; | ||
|
||
async function getStuff(promises) { | ||
return await find(promises, (promise) => !!promise); | ||
} |
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,16 @@ | ||
async function getStuff(promises) { | ||
let _match; | ||
for ( | ||
let _key = 0, _length = promises.length, _promise, _result; | ||
_key < _length; | ||
++_key | ||
) { | ||
_promise = promises[_key]; | ||
_result = !!_promise; | ||
if (_result) { | ||
_match = _promise; | ||
break; | ||
} | ||
} | ||
return await _match; | ||
} |
File renamed without changes.
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,8 @@ | ||
function getStuff(array) { | ||
let _a = array[0]; | ||
for (let _key = 1, _length = array.length, _v; _key < _length; ++_key) { | ||
_v = array[_key]; | ||
_a = _a + _v * 2; | ||
} | ||
return array ** _a; | ||
} |
13 changes: 0 additions & 13 deletions
13
__tests__/__fixtures__/complex/conditional-binary/output.js
This file was deleted.
Oops, something went wrong.
13 changes: 0 additions & 13 deletions
13
__tests__/__fixtures__/complex/conditional-unary/output.js
This file was deleted.
Oops, something went wrong.
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,5 @@ | ||
import { map } from '../../../../src/inline-loops.macro'; | ||
|
||
function getStuff(array, doubled = map(array, (v) => v * 2)) { | ||
return doubled; | ||
} |
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,14 @@ | ||
function getStuff( | ||
array, | ||
doubled = (() => { | ||
const _length = array.length; | ||
const _results = Array(_length); | ||
for (let _key = 0, _v; _key < _length; ++_key) { | ||
_v = array[_key]; | ||
_results[_key] = _v * 2; | ||
} | ||
return _results; | ||
})(), | ||
) { | ||
return doubled; | ||
} |
File renamed without changes.
File renamed without changes.
5 changes: 5 additions & 0 deletions
5
__tests__/__fixtures__/complex/logical-expression-left/code.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,5 @@ | ||
import { reduce } from '../../../../src/inline-loops.macro'; | ||
|
||
function getStuff(array) { | ||
return reduce(array, (a, v) => a + v * 2, 0) || 1; | ||
} |
8 changes: 8 additions & 0 deletions
8
__tests__/__fixtures__/complex/logical-expression-left/output.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,8 @@ | ||
function getStuff(array) { | ||
let _a = 0; | ||
for (let _key = 0, _length = array.length, _v; _key < _length; ++_key) { | ||
_v = array[_key]; | ||
_a = _a + _v * 2; | ||
} | ||
return _a || 1; | ||
} |
File renamed without changes.
File renamed without changes.
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,5 @@ | ||
import { map } from '../../../../src/inline-loops.macro'; | ||
|
||
function getStuff(array, foo) { | ||
return foo === 'bar' ? array : map(array, (v) => v * 2); | ||
} |
13 changes: 13 additions & 0 deletions
13
__tests__/__fixtures__/complex/ternary-alternative/output.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 @@ | ||
function getStuff(array, foo) { | ||
return foo === 'bar' | ||
? array | ||
: (() => { | ||
const _length = array.length; | ||
const _results = Array(_length); | ||
for (let _key = 0, _v; _key < _length; ++_key) { | ||
_v = array[_key]; | ||
_results[_key] = _v * 2; | ||
} | ||
return _results; | ||
})(); | ||
} |
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,5 @@ | ||
import { reduce } from '../../../../src/inline-loops.macro'; | ||
|
||
function getStuff(array, foo) { | ||
return reduce(array, (a, v) => a + v * 2, 0) ? 'stuff' : null; | ||
} |
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,8 @@ | ||
function getStuff(array, foo) { | ||
let _a = 0; | ||
for (let _key = 0, _length = array.length, _v; _key < _length; ++_key) { | ||
_v = array[_key]; | ||
_a = _a + _v * 2; | ||
} | ||
return _a ? 'stuff' : null; | ||
} |
File renamed without changes.
File renamed without changes.
File renamed without changes.
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,8 @@ | ||
function getStuff(array) { | ||
let _a = array[0]; | ||
for (let _key = 1, _length = array.length, _v; _key < _length; ++_key) { | ||
_v = array[_key]; | ||
_a = _a + _v * 2; | ||
} | ||
return array + +_a; | ||
} |
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