-
Notifications
You must be signed in to change notification settings - Fork 5
🚧 Remove lodash from immutadot package #143
Conversation
Codecov Report
@@ Coverage Diff @@
## master #143 +/- ##
=====================================
Coverage 100% 100%
=====================================
Files 76 77 +1
Lines 252 280 +28
=====================================
+ Hits 252 280 +28
Continue to review full report at Codecov.
|
937021f
to
c3a0d6a
Compare
8e0541a
to
e0fa69b
Compare
e0fa69b
to
b9ea095
Compare
@@ -0,0 +1,10 @@ | |||
import { convert } from './convert' |
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.
This import is undefined, only convertLodashFp
is exported.
I think no index is necessary for util namespace in immutadot-lodash...
@@ -2,3 +2,4 @@ export * from './array' | |||
export * from './collection' | |||
export * from './object' | |||
export * from './string' | |||
export * from './util' |
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.
Not sure this should be exported
import map from 'lodash/map' | ||
import mapValues from 'lodash/mapValues' | ||
import omit from 'lodash/omit' | ||
const isSymbol = sym => typeof sym === 'symbol' |
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.
This one exists in util/lang
@@ -45,7 +53,7 @@ class ChainWrapper { | |||
* @since 0.1.11 | |||
*/ | |||
_absolutePath(path) { | |||
return concat(toPath(this._path), toPath(path)) | |||
return [].concat(unsafeToPath(this._path), unsafeToPath(path)) |
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.
unsafeToPath is guaranted to return an array, and concat doesn't mutate the array, so you can do unsafeToPath(this._path).concat(unsafeToPath(path))
|
||
const head = arr => arr[0] | ||
|
||
const drop = (arr, n = 1) => arr.slice(n) |
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.
Inline this one
const args = concat( | ||
map(this._paths, usingPath => { | ||
const args = [].concat( | ||
this._paths.map(usingPath => { |
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.
this._paths
is guaranted to be an array, and concat doesn't mutate, call this._paths.concat
@@ -34,7 +36,7 @@ class ProtectHandler { | |||
get(target, property) { | |||
const reference = this._peek()[property] | |||
if (!isObject(reference)) return reference | |||
return new Proxy(reference, new ProtectHandler(this.chainWrapperRef, concat(this.path, property))) | |||
return new Proxy(reference, new ProtectHandler(this.chainWrapperRef, [].concat(this.path, property))) |
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.
Same remark
@@ -46,7 +48,7 @@ class ProtectHandler { | |||
* @since 0.3.0 | |||
*/ | |||
set(target, property, value) { | |||
this.chainWrapperRef.chainWrapper = this.chainWrapperRef.chainWrapper.set(concat(this.path, property), value) | |||
this.chainWrapperRef.chainWrapper = this.chainWrapperRef.chainWrapper.set([].concat(this.path, property), value) |
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.
Same remark
@@ -58,7 +60,7 @@ class ProtectHandler { | |||
* @since 0.3.0 | |||
*/ | |||
deleteProperty(target, property) { | |||
this.chainWrapperRef.chainWrapper = this.chainWrapperRef.chainWrapper.unset(concat(this.path, property)) | |||
this.chainWrapperRef.chainWrapper = this.chainWrapperRef.chainWrapper.unset([].concat(this.path, property)) |
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.
Same remark
@@ -60,7 +68,7 @@ class ChainWrapper { | |||
return new ChainWrapper( | |||
this._wrapped, | |||
this._path, | |||
concat(this._flow, object => fn(object, this._absolutePath(path), ...args)), | |||
[].concat(this._flow, object => fn(object, this._absolutePath(path), ...args)), |
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.
We only add one element, I think we can use this._flow.push
Prerequisites
Description
Remove lodash from immutadot package
Issue : #78