@@ -98,36 +98,16 @@ exports.transform = function(data, state) {
98
98
return newData ;
99
99
} ;
100
100
101
- function getDeepProp ( thing , propArray ) {
102
- var result = thing ;
103
- var i ;
104
- for ( i = 0 ; i < propArray . length ; i ++ ) {
105
- result = result [ propArray [ i ] ] ;
106
- if ( result === void ( 0 ) ) {
107
- return result ;
108
- }
109
- }
110
- return result ;
111
- }
112
-
113
- function setDeepProp ( thing , propArray , value ) {
114
- var current = thing ;
115
- var i ;
116
- for ( i = 0 ; i < propArray . length - 1 ; i ++ ) {
117
- if ( current [ propArray [ i ] ] === void ( 0 ) ) {
118
- current [ propArray [ i ] ] = { } ;
119
- }
120
- current = current [ propArray [ i ] ] ;
121
- }
122
- current [ propArray [ propArray . length - 1 ] ] = value ;
123
- }
124
-
125
101
function initializeArray ( newTrace , a ) {
126
- setDeepProp ( newTrace , a , [ ] ) ;
102
+ Lib . nestedProperty ( newTrace , a ) . set ( [ ] ) ;
127
103
}
128
104
129
105
function pasteArray ( newTrace , trace , j , a ) {
130
- getDeepProp ( newTrace , a ) . push ( getDeepProp ( trace , a ) [ j ] ) ;
106
+ Lib . nestedProperty ( newTrace , a ) . set (
107
+ Lib . nestedProperty ( newTrace , a ) . get ( ) . concat ( [
108
+ Lib . nestedProperty ( trace , a ) . get ( ) [ j ]
109
+ ] )
110
+ ) ;
131
111
}
132
112
133
113
function transformOne ( trace , state , attributeSet ) {
@@ -149,7 +129,7 @@ function transformOne(trace, state, attributeSet) {
149
129
var style = opts . style || { } ;
150
130
151
131
var arrayAttributes = attributeSet
152
- . filter ( function ( array ) { return Array . isArray ( getDeepProp ( trace , array ) ) ; } ) ;
132
+ . filter ( function ( array ) { return Array . isArray ( Lib . nestedProperty ( trace , array ) . get ( ) ) ; } ) ;
153
133
154
134
// fixme the O(n**3) complexity
155
135
for ( var i = 0 ; i < groupNames . length ; i ++ ) {
0 commit comments