1010'use strict' ;
1111
1212var isNumeric = require ( 'fast-isnumeric' ) ;
13+ var isArray = require ( './is_array' ) ;
1314
1415/**
1516 * convert a string s (such as 'xaxis.range[0]')
@@ -93,7 +94,7 @@ function npGet(cont, parts) {
9394 }
9495 return allSame ? out [ 0 ] : out ;
9596 }
96- if ( typeof curPart === 'number' && ! Array . isArray ( curCont ) ) {
97+ if ( typeof curPart === 'number' && ! isArray ( curCont ) ) {
9798 return undefined ;
9899 }
99100 curCont = curCont [ curPart ] ;
@@ -122,7 +123,7 @@ function isDataArray(val, key) {
122123 var containers = [ 'annotations' , 'shapes' , 'range' , 'domain' , 'buttons' ] ,
123124 isNotAContainer = containers . indexOf ( key ) === - 1 ;
124125
125- return Array . isArray ( val ) && isNotAContainer ;
126+ return isArray ( val ) && isNotAContainer ;
126127}
127128
128129function npSet ( cont , parts ) {
@@ -136,7 +137,7 @@ function npSet(cont, parts) {
136137 for ( i = 0 ; i < parts . length - 1 ; i ++ ) {
137138 curPart = parts [ i ] ;
138139
139- if ( typeof curPart === 'number' && ! Array . isArray ( curCont ) ) {
140+ if ( typeof curPart === 'number' && ! isArray ( curCont ) ) {
140141 throw 'array index but container is not an array' ;
141142 }
142143
@@ -170,7 +171,7 @@ function npSet(cont, parts) {
170171
171172// handle special -1 array index
172173function setArrayAll ( containerArray , innerParts , val ) {
173- var arrayVal = Array . isArray ( val ) ,
174+ var arrayVal = isArray ( val ) ,
174175 allSet = true ,
175176 thisVal = val ,
176177 deleteThis = arrayVal ? false : emptyObj ( val ) ,
@@ -215,7 +216,7 @@ function pruneContainers(containerLevels) {
215216 for ( i = containerLevels . length - 1 ; i >= 0 ; i -- ) {
216217 curCont = containerLevels [ i ] ;
217218 remainingKeys = false ;
218- if ( Array . isArray ( curCont ) ) {
219+ if ( isArray ( curCont ) ) {
219220 for ( j = curCont . length - 1 ; j >= 0 ; j -- ) {
220221 if ( emptyObj ( curCont [ j ] ) ) {
221222 if ( remainingKeys ) curCont [ j ] = undefined ;
@@ -239,7 +240,7 @@ function pruneContainers(containerLevels) {
239240function emptyObj ( obj ) {
240241 if ( obj === undefined || obj === null ) return true ;
241242 if ( typeof obj !== 'object' ) return false ; // any plain value
242- if ( Array . isArray ( obj ) ) return ! obj . length ; // []
243+ if ( isArray ( obj ) ) return ! obj . length ; // []
243244 return ! Object . keys ( obj ) . length ; // {}
244245}
245246
0 commit comments