-
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.
initial implementation of working transform with existing unit tests
- Loading branch information
1 parent
37cfee0
commit f847f0c
Showing
166 changed files
with
2,786 additions
and
1,136 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 |
---|---|---|
@@ -1,12 +1,19 @@ | ||
const _iterable = [1, 2, 3]; | ||
const _fn = (value) => { | ||
if (value === 2) { | ||
const _collection = [1, 2, 3]; | ||
const _fn = (_value) => { | ||
if (_value === 2) { | ||
return true; | ||
} | ||
}; | ||
let _result = []; | ||
for (let _key = 0, _length = _iterable.length, _value; _key < _length; ++_key) { | ||
_value = _iterable[_key]; | ||
if (_fn(_value, _key, _iterable)) _result.push(_value); | ||
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 = _result; | ||
const result = _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,13 +1,14 @@ | ||
const _iterable = [1, 2, 3]; | ||
const _fn = (value) => { | ||
if (value === 2) { | ||
const _collection = [1, 2, 3]; | ||
const _fn = (_value) => { | ||
if (_value === 2) { | ||
return 82; | ||
} | ||
return value; | ||
return _value; | ||
}; | ||
let _result = []; | ||
for (let _key = 0, _length = _iterable.length, _value; _key < _length; ++_key) { | ||
_value = _iterable[_key]; | ||
_result[_key] = _fn(_value, _key, _iterable); | ||
const _length = _collection.length; | ||
const _results = Array(_length); | ||
for (let _key = 0, _value; _key < _length; ++_key) { | ||
_value = _collection[_key]; | ||
_results[_key] = _fn(_value, _key, _collection); | ||
} | ||
const result = _result; | ||
const result = _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,9 +1,14 @@ | ||
let _result = true; | ||
for (let _key = 0, _length = array.length, _value; _key < _length; ++_key) { | ||
let _determination = true; | ||
for ( | ||
let _key = 0, _length = array.length, _value, _result; | ||
_key < _length; | ||
++_key | ||
) { | ||
_value = array[_key]; | ||
if (!fn(_value, _key, array)) { | ||
_result = false; | ||
_result = fn(_value, _key, array); | ||
if (!_result) { | ||
_determination = false; | ||
break; | ||
} | ||
} | ||
const areAllEven = _result; | ||
const areAllEven = _determination; |
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,10 +1,12 @@ | ||
let _result = true; | ||
let _value; | ||
for (let _key in object) { | ||
let _determination = true, | ||
_value, | ||
_result; | ||
for (const _key in object) { | ||
_value = object[_key]; | ||
if (!fn(_value, _key, object)) { | ||
_result = false; | ||
_result = fn(_value, _key, object); | ||
if (!_result) { | ||
_determination = false; | ||
break; | ||
} | ||
} | ||
const areAllEven = _result; | ||
const areAllEven = _determination; |
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,9 +1,10 @@ | ||
let _result = true; | ||
for (let _key = array.length - 1, _value; _key >= 0; --_key) { | ||
let _determination = true; | ||
for (let _key = array.length, _value, _result; --_key >= 0; ) { | ||
_value = array[_key]; | ||
if (!fn(_value, _key, array)) { | ||
_result = false; | ||
_result = fn(_value, _key, array); | ||
if (!_result) { | ||
_determination = false; | ||
break; | ||
} | ||
} | ||
const areAllEven = _result; | ||
const areAllEven = _determination; |
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,6 +1,13 @@ | ||
let _result = []; | ||
for (let _key = 0, _length = array.length, _value; _key < _length; ++_key) { | ||
const _results = []; | ||
for ( | ||
let _key = 0, _length = array.length, _value, _result; | ||
_key < _length; | ||
++_key | ||
) { | ||
_value = array[_key]; | ||
if (fn(_value, _key, array)) _result.push(_value); | ||
_result = fn(_value, _key, array); | ||
if (_result) { | ||
_results.push(_value); | ||
} | ||
} | ||
const onlyEven = _result; | ||
const onlyEven = _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,7 +1,10 @@ | ||
let _result = {}; | ||
let _value; | ||
for (let _key in object) { | ||
const _results = {}; | ||
let _result, _value; | ||
for (const _key in object) { | ||
_value = object[_key]; | ||
if (fn(_value, _key, object)) _result[_key] = _value; | ||
_result = fn(_value, _key, object); | ||
if (_result) { | ||
_results[_key] = _value; | ||
} | ||
} | ||
const onlyEven = _result; | ||
const onlyEven = _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,6 +1,10 @@ | ||
let _result = []; | ||
for (let _key = array.length - 1, _value; _key >= 0; --_key) { | ||
const _results = []; | ||
let _result, _value; | ||
for (let _key = array.length, _value, _result; --_key >= 0; ) { | ||
_value = array[_key]; | ||
if (fn(_value, _key, array)) _result.push(_value); | ||
_result = fn(_value, _key, array); | ||
if (_result) { | ||
_results.push(_value); | ||
} | ||
} | ||
const onlyEven = _result; | ||
const onlyEven = _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,9 +1,14 @@ | ||
let _result; | ||
for (let _key = 0, _length = array.length, _value; _key < _length; ++_key) { | ||
let _match; | ||
for ( | ||
let _key = 0, _length = array.length, _value, _result; | ||
_key < _length; | ||
++_key | ||
) { | ||
_value = array[_key]; | ||
if (fn(_value, _key, array)) { | ||
_result = _value; | ||
_result = fn(_value, _key, array); | ||
if (_result) { | ||
_match = _value; | ||
break; | ||
} | ||
} | ||
const firstEven = _result; | ||
const firstEven = _match; |
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,9 +1,14 @@ | ||
let _result = -1; | ||
for (let _key = 0, _length = array.length, _value; _key < _length; ++_key) { | ||
let _match = -1; | ||
for ( | ||
let _key = 0, _length = array.length, _value, _result; | ||
_key < _length; | ||
++_key | ||
) { | ||
_value = array[_key]; | ||
if (fn(_value, _key, array)) { | ||
_result = _key; | ||
_result = fn(_value, _key, array); | ||
if (_result) { | ||
_match = _key; | ||
break; | ||
} | ||
} | ||
const firstEven = _result; | ||
const firstEven = _match; |
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,9 +1 @@ | ||
let _result = -1; | ||
for (let _key = array.length - 1, _value; _key >= 0; --_key) { | ||
_value = array[_key]; | ||
if (fn(_value, _key, array)) { | ||
_result = _key; | ||
break; | ||
} | ||
} | ||
const firstEven = _result; | ||
const firstEven = findIndexRight(array, fn); |
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,10 +1,12 @@ | ||
let _result; | ||
let _value; | ||
for (let _key in object) { | ||
let _match = -1, | ||
_value, | ||
_result; | ||
for (const _key in object) { | ||
_value = object[_key]; | ||
if (fn(_value, _key, object)) { | ||
_result = _key; | ||
_result = fn(_value, _key, object); | ||
if (_result) { | ||
_match = _key; | ||
break; | ||
} | ||
} | ||
const firstEven = _result; | ||
const firstEven = _match; |
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,10 +1,10 @@ | ||
let _result; | ||
let _value; | ||
for (let _key in object) { | ||
let _match, _value, _result; | ||
for (const _key in object) { | ||
_value = object[_key]; | ||
if (fn(_value, _key, object)) { | ||
_result = _value; | ||
_result = fn(_value, _key, object); | ||
if (_result) { | ||
_match = _value; | ||
break; | ||
} | ||
} | ||
const firstEven = _result; | ||
const firstEven = _match; |
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,9 +1 @@ | ||
let _result; | ||
for (let _key = array.length - 1, _value; _key >= 0; --_key) { | ||
_value = array[_key]; | ||
if (fn(_value, _key, array)) { | ||
_result = _value; | ||
break; | ||
} | ||
} | ||
const lastEven = _result; | ||
const lastEven = findRight(array, fn); |
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,6 +1,11 @@ | ||
let _result = []; | ||
for (let _key = 0, _length = array.length, _value; _key < _length; ++_key) { | ||
let _results = []; | ||
for ( | ||
let _key = 0, _length = array.length, _value, _result; | ||
_key < _length; | ||
++_key | ||
) { | ||
_value = array[_key]; | ||
_result.push.apply(_result, fn(_value, _key, array)); | ||
_result = fn(_value, _key, array); | ||
_results = _results.concat(_result); | ||
} | ||
const flattened = _result; | ||
const flattened = _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,6 +1,7 @@ | ||
let _result = []; | ||
for (let _key = array.length - 1, _value; _key >= 0; --_key) { | ||
let _results = []; | ||
for (let _key = array.length, _value, _result; --_key >= 0; ) { | ||
_value = array[_key]; | ||
_result.push.apply(_result, fn(_value, _key, array)); | ||
_result = fn(_value, _key, array); | ||
_results = _results.concat(_result); | ||
} | ||
const flattened = _result; | ||
const flattened = _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,5 +1,5 @@ | ||
let _value; | ||
for (let _key in object) { | ||
for (const _key in object) { | ||
_value = object[_key]; | ||
fn(_value, _key, object); | ||
} |
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,4 +1,4 @@ | ||
for (let _key = array.length - 1, _value; _key >= 0; --_key) { | ||
for (let _key = array.length, _value; --_key >= 0; ) { | ||
_value = array[_key]; | ||
fn(_value, _key, 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 |
---|---|---|
@@ -1,6 +1,7 @@ | ||
let _result = []; | ||
for (let _key = 0, _length = array.length, _value; _key < _length; ++_key) { | ||
const _length = array.length; | ||
const _results = Array(_length); | ||
for (let _key = 0, _value; _key < _length; ++_key) { | ||
_value = array[_key]; | ||
_result[_key] = fn(_value, _key, array); | ||
_results[_key] = fn(_value, _key, array); | ||
} | ||
const doubledValues = _result; | ||
const doubledValues = _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,7 +1,7 @@ | ||
let _result = {}; | ||
let _value; | ||
for (let _key in object) { | ||
const _results = {}; | ||
let _value, _result; | ||
for (const _key in object) { | ||
_value = object[_key]; | ||
_result[_key] = fn(_value, _key, object); | ||
_results[_key] = fn(_value, _key, object); | ||
} | ||
const doubledValues = _result; | ||
const doubledValues = _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,6 +1,8 @@ | ||
let _result = []; | ||
for (let _key = array.length - 1, _value; _key >= 0; --_key) { | ||
const _length = array.length; | ||
let _key = _length; | ||
const _results = Array(_length); | ||
for (let _value; --_key >= 0; ) { | ||
_value = array[_key]; | ||
_result[_result.length] = fn(_value, _key, array); | ||
_results[_length - _key - 1] = fn(_value, _key, array); | ||
} | ||
const doubledValues = _result; | ||
const doubledValues = _results; |
6 changes: 3 additions & 3 deletions
6
__tests__/__fixtures__/cached/reduce-no-initialValue/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 |
---|---|---|
@@ -1,6 +1,6 @@ | ||
let _result = array[0]; | ||
let _accumulated = array[0]; | ||
for (let _key = 1, _length = array.length, _value; _key < _length; ++_key) { | ||
_value = array[_key]; | ||
_result = fn(_result, _value, _key, array); | ||
_accumulated = fn(_accumulated, _value, _key, array); | ||
} | ||
const doubledValues = _result; | ||
const doubledValues = _accumulated; |
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,6 +1,6 @@ | ||
let _result = {}; | ||
let _accumulated = {}; | ||
for (let _key = 0, _length = array.length, _value; _key < _length; ++_key) { | ||
_value = array[_key]; | ||
_result = fn(_result, _value, _key, array); | ||
_accumulated = fn(_accumulated, _value, _key, array); | ||
} | ||
const doubledValues = _result; | ||
const doubledValues = _accumulated; |
Oops, something went wrong.