10
10
'use strict' ;
11
11
12
12
var isNumeric = require ( 'fast-isnumeric' ) ;
13
+ var isArray = require ( './is_array' ) ;
13
14
14
15
/**
15
16
* convert a string s (such as 'xaxis.range[0]')
@@ -93,7 +94,7 @@ function npGet(cont, parts) {
93
94
}
94
95
return allSame ? out [ 0 ] : out ;
95
96
}
96
- if ( typeof curPart === 'number' && ! Array . isArray ( curCont ) ) {
97
+ if ( typeof curPart === 'number' && ! isArray ( curCont ) ) {
97
98
return undefined ;
98
99
}
99
100
curCont = curCont [ curPart ] ;
@@ -122,7 +123,7 @@ function isDataArray(val, key) {
122
123
var containers = [ 'annotations' , 'shapes' , 'range' , 'domain' , 'buttons' ] ,
123
124
isNotAContainer = containers . indexOf ( key ) === - 1 ;
124
125
125
- return Array . isArray ( val ) && isNotAContainer ;
126
+ return isArray ( val ) && isNotAContainer ;
126
127
}
127
128
128
129
function npSet ( cont , parts ) {
@@ -136,7 +137,7 @@ function npSet(cont, parts) {
136
137
for ( i = 0 ; i < parts . length - 1 ; i ++ ) {
137
138
curPart = parts [ i ] ;
138
139
139
- if ( typeof curPart === 'number' && ! Array . isArray ( curCont ) ) {
140
+ if ( typeof curPart === 'number' && ! isArray ( curCont ) ) {
140
141
throw 'array index but container is not an array' ;
141
142
}
142
143
@@ -170,7 +171,7 @@ function npSet(cont, parts) {
170
171
171
172
// handle special -1 array index
172
173
function setArrayAll ( containerArray , innerParts , val ) {
173
- var arrayVal = Array . isArray ( val ) ,
174
+ var arrayVal = isArray ( val ) ,
174
175
allSet = true ,
175
176
thisVal = val ,
176
177
deleteThis = arrayVal ? false : emptyObj ( val ) ,
@@ -215,7 +216,7 @@ function pruneContainers(containerLevels) {
215
216
for ( i = containerLevels . length - 1 ; i >= 0 ; i -- ) {
216
217
curCont = containerLevels [ i ] ;
217
218
remainingKeys = false ;
218
- if ( Array . isArray ( curCont ) ) {
219
+ if ( isArray ( curCont ) ) {
219
220
for ( j = curCont . length - 1 ; j >= 0 ; j -- ) {
220
221
if ( emptyObj ( curCont [ j ] ) ) {
221
222
if ( remainingKeys ) curCont [ j ] = undefined ;
@@ -239,7 +240,7 @@ function pruneContainers(containerLevels) {
239
240
function emptyObj ( obj ) {
240
241
if ( obj === undefined || obj === null ) return true ;
241
242
if ( typeof obj !== 'object' ) return false ; // any plain value
242
- if ( Array . isArray ( obj ) ) return ! obj . length ; // []
243
+ if ( isArray ( obj ) ) return ! obj . length ; // []
243
244
return ! Object . keys ( obj ) . length ; // {}
244
245
}
245
246
0 commit comments