-
Notifications
You must be signed in to change notification settings - Fork 5
Conversation
Codecov Report
@@ Coverage Diff @@
## master #124 +/- ##
=====================================
Coverage 100% 100%
=====================================
Files 74 74
Lines 247 259 +12
Branches 48 54 +6
=====================================
+ Hits 247 259 +12
Continue to review full report at Codecov.
|
a37d9c7
to
bbb85da
Compare
This isn't WIP anymore, I think we can merge this. |
const copyArray = array => { | ||
if (array === undefined || array === null) return [] | ||
if (isNil(array)) return [] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
👍
const [prop, ...pathRest] = curPath | ||
|
||
const value = callback(curObj, prop) | ||
if (isSlice(prop)) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
👏
|
||
const newObj = copy(curObj, isArrayProp(prop)) | ||
let newObj = curObj | ||
if (doCopy) newObj = copy(curObj, isIndex(prop)) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why do we need it ?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
When we are iterating on a slice, only one copy of the array is necessary, so this is to avoid several copies
if (isSlice(prop)) { | ||
const [start, end] = getSliceBounds(prop, length(curObj)) | ||
|
||
const newArr = copy(curObj, true) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
the second param is not clear. Usually the second param in a copy function is for deep not asArray
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
As long as this is documented...
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
And this is private code
…ly callback for now
* @private | ||
* @since 0.4.0 | ||
*/ | ||
const getSliceBounds = ([start, end], length) => ([ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
👍
* @since 0.4.0 | ||
*/ | ||
const length = arg => { | ||
if (isNil(arg) || !isNaturalInteger(arg.length)) return 0 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
👍
Description
Slice walking implementation
Issue : #94