-
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
928a0eb
commit f04aa41
Showing
20 changed files
with
332 additions
and
259 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
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
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 |
---|---|---|
@@ -1,7 +1,11 @@ | ||
import { filter } from '../../../../src/inline-loops.macro'; | ||
|
||
const result = filter([1, 2, 3], (value) => { | ||
if (value === 2) { | ||
return true; | ||
} | ||
}); | ||
function getFoo(config) { | ||
const collection = config.collection || [1, 2, 3]; | ||
|
||
return filter(collection, (value) => { | ||
if (value === 2) { | ||
return true; | ||
} | ||
}); | ||
} |
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 |
---|---|---|
@@ -1,19 +1,23 @@ | ||
const _collection = [1, 2, 3]; | ||
const _fn = (_value) => { | ||
if (_value === 2) { | ||
return true; | ||
} | ||
}; | ||
const _results = []; | ||
for ( | ||
let _key = 0, _length = _collection.length, _value, _result; | ||
_key < _length; | ||
++_key | ||
) { | ||
_value = _collection[_key]; | ||
_result = _fn(_value, _key, _collection); | ||
if (_result) { | ||
_results.push(_value); | ||
} | ||
} | ||
const result = _results; | ||
function getFoo(config) { | ||
const collection = config.collection || [1, 2, 3]; | ||
return (() => { | ||
const _fn = (_value) => { | ||
if (_value === 2) { | ||
return true; | ||
} | ||
}; | ||
const _results = []; | ||
for ( | ||
let _key = 0, _length = collection.length, _value, _result; | ||
_key < _length; | ||
++_key | ||
) { | ||
_value = collection[_key]; | ||
_result = _fn(_value, _key, collection); | ||
if (_result) { | ||
_results.push(_value); | ||
} | ||
} | ||
return _results; | ||
})(); | ||
} |
4 changes: 2 additions & 2 deletions
4
.../__fixtures__/complex/conditional/code.js → ...fixtures__/complex/conditional-if/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
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, foo) { | ||
if (foo === 'bar') { | ||
return (() => { | ||
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 array; | ||
} |
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) { | ||
return array || map(array, (v) => v * 2); | ||
} |
14 changes: 14 additions & 0 deletions
14
__tests__/__fixtures__/complex/conditional-logical/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,14 @@ | ||
function getStuff(array) { | ||
return ( | ||
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 { map } from '../../../../src/inline-loops.macro'; | ||
|
||
function getStuff(array, foo) { | ||
return foo === 'bar' ? map(array, (v) => v * 2) : array; | ||
} |
13 changes: 13 additions & 0 deletions
13
__tests__/__fixtures__/complex/conditional-ternary/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' | ||
? (() => { | ||
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; | ||
})() | ||
: array; | ||
} |
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 |
---|---|---|
@@ -1,17 +1,23 @@ | ||
import React from 'react'; | ||
function List(props) { | ||
const _collection = props.items; | ||
const _length = _collection.length; | ||
const _results = Array(_length); | ||
for (let _key = 0, _item; _key < _length; ++_key) { | ||
_item = _collection[_key]; | ||
_results[_key] = /*#__PURE__*/ React.createElement( | ||
'li', | ||
{ | ||
key: _item.id, | ||
}, | ||
_item.value, | ||
); | ||
} | ||
return /*#__PURE__*/ React.createElement('ul', null, _results); | ||
return /*#__PURE__*/ React.createElement( | ||
'ul', | ||
null, | ||
(() => { | ||
const _collection = props.items; | ||
const _length = _collection.length; | ||
const _results = Array(_length); | ||
for (let _key = 0, _item; _key < _length; ++_key) { | ||
_item = _collection[_key]; | ||
_results[_key] = /*#__PURE__*/ React.createElement( | ||
'li', | ||
{ | ||
key: _item.id, | ||
}, | ||
_item.value, | ||
); | ||
} | ||
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 |
---|---|---|
@@ -1,12 +1,14 @@ | ||
function foo(array) { | ||
const _fn = function (_value) { | ||
return this && this.foo ? _value : null; | ||
}; | ||
const _length = array.length; | ||
const _results = Array(_length); | ||
for (let _key = 0, _value; _key < _length; ++_key) { | ||
_value = array[_key]; | ||
_results[_key] = _fn(_value, _key, array); | ||
} | ||
return _results; | ||
return (() => { | ||
const _fn = function (_value) { | ||
return this && this.foo ? _value : null; | ||
}; | ||
const _length = array.length; | ||
const _results = Array(_length); | ||
for (let _key = 0, _value; _key < _length; ++_key) { | ||
_value = array[_key]; | ||
_results[_key] = _fn(_value, _key, array); | ||
} | ||
return _results; | ||
})(); | ||
} |
Oops, something went wrong.