This repository was archived by the owner on Aug 23, 2022. It is now read-only.
File tree Expand file tree Collapse file tree 4 files changed +36
-16
lines changed Expand file tree Collapse file tree 4 files changed +36
-16
lines changed Original file line number Diff line number Diff line change @@ -15,6 +15,7 @@ import getValue from './utils/get-value';
15
15
import immutableGetFromState from './utils/get-from-immutable-state' ;
16
16
import getForm , { getFormStateKey } from './utils/get-form' ;
17
17
import isPlainObject from './utils/is-plain-object' ;
18
+ import immutableFindKey from './utils/find-key-immutable' ;
18
19
import Immutable from 'immutable' ;
19
20
20
21
import {
@@ -73,6 +74,7 @@ const immutableStrategy = {
73
74
...baseStrategy ,
74
75
getForm : immutableGetForm ,
75
76
getFieldFromState : immutableGetFieldFromState ,
77
+ findKey : immutableFindKey ,
76
78
} ;
77
79
78
80
function transformAction ( action ) {
Original file line number Diff line number Diff line change
1
+ import { List } from 'immutable' ;
2
+
3
+ export default function findKey ( object , predicate ) {
4
+ let resultKey ;
5
+
6
+ if ( List . isList ( object ) ) {
7
+ resultKey = object . findKey ( predicate ) ;
8
+ } else {
9
+ Object . keys ( object ) . some ( ( key ) => {
10
+ const isKey = predicate ( object [ key ] , key , object ) ;
11
+
12
+ if ( isKey ) {
13
+ resultKey = key ;
14
+ return true ;
15
+ }
16
+
17
+ return false ;
18
+ } ) ;
19
+ }
20
+
21
+ return resultKey ;
22
+ }
Original file line number Diff line number Diff line change 1
- import { List } from 'immutable' ;
2
1
3
2
export default function findKey ( object , predicate ) {
4
3
let resultKey ;
5
4
6
- if ( List . isList ( object ) ) {
7
- resultKey = object . findKey ( predicate ) ;
8
- } else {
9
- Object . keys ( object ) . some ( ( key ) => {
10
- const isKey = predicate ( object [ key ] , key , object ) ;
5
+ Object . keys ( object ) . some ( ( key ) => {
6
+ const isKey = predicate ( object [ key ] , key , object ) ;
11
7
12
- if ( isKey ) {
13
- resultKey = key ;
14
- return true ;
15
- }
8
+ if ( isKey ) {
9
+ resultKey = key ;
10
+ return true ;
11
+ }
16
12
17
- return false ;
18
- } ) ;
19
- }
13
+ return false ;
14
+ } ) ;
20
15
21
16
return resultKey ;
22
17
}
Original file line number Diff line number Diff line change 1
- import findKey from '../utils/find-key' ;
1
+ import _findKey from '../utils/find-key' ;
2
2
import _get from '../utils/get' ;
3
3
import { createIteratee } from '../utils/iteratee' ;
4
4
import isMulti from '../utils/is-multi' ;
5
5
6
6
const defaultStrategy = {
7
+ findKey : _findKey ,
7
8
get : _get ,
8
9
} ;
9
10
@@ -34,8 +35,8 @@ function createTrack(s = defaultStrategy) {
34
35
const predicateIteratee = iteratee ( predicate ) ;
35
36
36
37
const subPath = childModelPath
37
- ? `${ findKey ( subState , predicateIteratee ) } .${ childModelPath } `
38
- : `${ findKey ( subState , predicateIteratee ) } ` ;
38
+ ? `${ s . findKey ( subState , predicateIteratee ) } .${ childModelPath } `
39
+ : `${ s . findKey ( subState , predicateIteratee ) } ` ;
39
40
40
41
subState = s . get ( subState , subPath ) ;
41
42
fullPath += `.${ subPath } ` ;
You can’t perform that action at this time.
0 commit comments