File tree Expand file tree Collapse file tree 2 files changed +14
-6
lines changed Expand file tree Collapse file tree 2 files changed +14
-6
lines changed Original file line number Diff line number Diff line change 6
6
*/
7
7
8
8
import { Seq } from './Seq' ;
9
+ import { isIndexed } from './Predicates' ;
9
10
import isDataStructure from './utils/isDataStructure' ;
10
11
11
12
export function toJS ( value ) {
12
- return isDataStructure ( value )
13
- ? Seq ( value )
14
- . map ( toJS )
15
- . toJSON ( )
16
- : value ;
13
+ if ( isDataStructure ( value ) ) {
14
+ value = Seq ( value ) ;
15
+ const result = isIndexed ( value ) ? [ ] : { } ;
16
+ value . forEach ( ( v , k ) => {
17
+ result [ k ] = toJS ( v ) ;
18
+ } ) ;
19
+ return result ;
20
+ }
21
+ return value ;
17
22
}
Original file line number Diff line number Diff line change @@ -13,5 +13,8 @@ import isPlainObj from './isPlainObj';
13
13
* provided by Immutable.js or a plain Array or Object.
14
14
*/
15
15
export default function isDataStructure ( value ) {
16
- return isImmutable ( value ) || Array . isArray ( value ) || isPlainObj ( value ) ;
16
+ return (
17
+ typeof value === 'object' &&
18
+ ( isImmutable ( value ) || Array . isArray ( value ) || isPlainObj ( value ) )
19
+ ) ;
17
20
}
You can’t perform that action at this time.
0 commit comments