2121// MODULES //
2222
2323var tape = require ( 'tape' ) ;
24- var floor = require ( '@stdlib/math/base/special/floor' ) ;
2524var toAccessorArray = require ( '@stdlib/array/base/to-accessor-array' ) ;
2625var isnan = require ( '@stdlib/math/base/assert/is-nan' ) ;
2726var isPositiveZero = require ( '@stdlib/math/base/assert/is-positive-zero' ) ;
2827var Float64Array = require ( '@stdlib/array/float64' ) ;
29- var nanrangeBy = require ( './../lib/nanrange_by.js ' ) ;
28+ var nanrangeBy = require ( './../lib' ) ;
3029
3130
3231// FUNCTIONS //
@@ -76,11 +75,11 @@ tape( 'the function calculates the range of a strided array via a callback funct
7675 v = nanrangeBy ( x . length , x , 1 , accessor ) ;
7776 t . strictEqual ( isnan ( v ) , true , 'returns expected value' ) ;
7877
79- x = new Array ( 5 ) ; // sparse array
78+ x = new Array ( 5 ) ; // eslint-disable-line stdlib/no-new- array
8079 v = nanrangeBy ( x . length , x , 1 , accessor ) ;
8180 t . strictEqual ( isnan ( v ) , true , 'returns expected value' ) ;
8281
83- x = new Array ( 5 ) ; // sparse array
82+ x = new Array ( 5 ) ; // eslint-disable-line stdlib/no-new- array
8483 x [ 2 ] = 1.0 ;
8584 v = nanrangeBy ( x . length , x , 1 , accessor ) ;
8685 t . strictEqual ( v , 0.0 , 'returns expected value' ) ;
@@ -93,32 +92,32 @@ tape( 'the function calculates the range of a strided array via a callback funct
9392 var v ;
9493
9594 x = [ 1.0 , - 2.0 , - 4.0 , NaN , 5.0 , 0.0 , NaN , 3.0 ] ;
96- v = nanrangeBy ( x . length , toAccessorArray ( x ) , 1 , accessor ) ;
95+ v = nanrangeBy ( x . length , toAccessorArray ( x ) , 1 , accessor ) ;
9796 t . strictEqual ( v , 18.0 , 'returns expected value' ) ;
9897
9998 x = [ - 4.0 , NaN , - 5.0 ] ;
100- v = nanrangeBy ( x . length , toAccessorArray ( x ) , 1 , accessor ) ;
99+ v = nanrangeBy ( x . length , toAccessorArray ( x ) , 1 , accessor ) ;
101100 t . strictEqual ( v , 2.0 , 'returns expected value' ) ;
102101
103102 x = [ - 0.0 , 0.0 , NaN , - 0.0 ] ;
104- v = nanrangeBy ( x . length , toAccessorArray ( x ) , 1 , accessor ) ;
103+ v = nanrangeBy ( x . length , toAccessorArray ( x ) , 1 , accessor ) ;
105104 t . strictEqual ( isPositiveZero ( v ) , true , 'returns expected value' ) ;
106105
107106 x = [ NaN ] ;
108- v = nanrangeBy ( x . length , toAccessorArray ( x ) , 1 , accessor ) ;
107+ v = nanrangeBy ( x . length , toAccessorArray ( x ) , 1 , accessor ) ;
109108 t . strictEqual ( isnan ( v ) , true , 'returns expected value' ) ;
110109
111110 x = [ NaN , NaN ] ;
112- v = nanrangeBy ( x . length , toAccessorArray ( x ) , 1 , accessor ) ;
111+ v = nanrangeBy ( x . length , toAccessorArray ( x ) , 1 , accessor ) ;
113112 t . strictEqual ( isnan ( v ) , true , 'returns expected value' ) ;
114113
115- x = new Array ( 5 ) ; // sparse array
116- v = nanrangeBy ( x . length , toAccessorArray ( x ) , 1 , accessor ) ;
114+ x = new Array ( 5 ) ; // eslint-disable-line stdlib/no-new- array
115+ v = nanrangeBy ( x . length , toAccessorArray ( x ) , 1 , accessor ) ;
117116 t . strictEqual ( isnan ( v ) , true , 'returns expected value' ) ;
118117
119- x = new Array ( 5 ) ; // sparse array
118+ x = new Array ( 5 ) ; // eslint-disable-line stdlib/no-new- array
120119 x [ 2 ] = 1.0 ;
121- v = nanrangeBy ( x . length , toAccessorArray ( x ) , 1 , accessor ) ;
120+ v = nanrangeBy ( x . length , toAccessorArray ( x ) , 1 , accessor ) ;
122121 t . strictEqual ( v , 0.0 , 'returns expected value' ) ;
123122
124123 t . end ( ) ;
@@ -145,10 +144,10 @@ tape( 'if provided an `N` parameter less than or equal to `0`, the function retu
145144
146145 x = [ 1.0 , - 2.0 , - 4.0 , 5.0 , 3.0 ] ;
147146
148- v = nanrangeBy ( 0 , toAccessorArray ( x ) , 1 , accessor ) ;
147+ v = nanrangeBy ( 0 , toAccessorArray ( x ) , 1 , accessor ) ;
149148 t . strictEqual ( isnan ( v ) , true , 'returns expected value' ) ;
150149
151- v = nanrangeBy ( - 1 , toAccessorArray ( x ) , 1 , accessor ) ;
150+ v = nanrangeBy ( - 1 , toAccessorArray ( x ) , 1 , accessor ) ;
152151 t . strictEqual ( isnan ( v ) , true , 'returns expected value' ) ;
153152
154153 t . end ( ) ;
@@ -163,30 +162,30 @@ tape( 'if provided an `N` parameter equal to `1`, the function returns `0`', fun
163162 v = nanrangeBy ( 1 , x , 1 , accessor ) ;
164163 t . strictEqual ( v , 0.0 , 'returns expected value' ) ;
165164
166- x = new Array ( 1 ) ; // sparse array
165+ x = new Array ( 1 ) ; // eslint-disable-line stdlib/no-new- array
167166 v = nanrangeBy ( 1 , x , 1 , accessor ) ;
168167 t . strictEqual ( isnan ( v ) , true , 'returns expected value' ) ;
169168
170169 t . end ( ) ;
171170} ) ;
171+
172172tape ( 'if provided an `N` parameter equal to `1`, the function returns `0` (accessors)' , function test ( t ) {
173173 var x ;
174174 var v ;
175175
176176 x = [ 1.0 , - 2.0 , - 4.0 , 5.0 , 3.0 ] ;
177177
178- v = nanrangeBy ( 1 , toAccessorArray ( x ) , 1 , accessor ) ;
178+ v = nanrangeBy ( 1 , toAccessorArray ( x ) , 1 , accessor ) ;
179179 t . strictEqual ( v , 0.0 , 'returns expected value' ) ;
180180
181- x = new Array ( 1 ) ; // sparse array
182- v = nanrangeBy ( 1 , toAccessorArray ( x ) , 1 , accessor ) ;
181+ x = new Array ( 1 ) ; // eslint-disable-line stdlib/no-new- array
182+ v = nanrangeBy ( 1 , toAccessorArray ( x ) , 1 , accessor ) ;
183183 t . strictEqual ( isnan ( v ) , true , 'returns expected value' ) ;
184184
185185 t . end ( ) ;
186186} ) ;
187187
188188tape ( 'the function supports a `stride` parameter' , function test ( t ) {
189- var N ;
190189 var x ;
191190 var v ;
192191
@@ -203,15 +202,13 @@ tape( 'the function supports a `stride` parameter', function test( t ) {
203202 NaN
204203 ] ;
205204
206- N = floor ( x . length / 2 ) ;
207- v = nanrangeBy ( N , x , 2 , accessor ) ;
205+ v = nanrangeBy ( 5 , x , 2 , accessor ) ;
208206
209207 t . strictEqual ( v , 12.0 , 'returns expected value' ) ;
210208 t . end ( ) ;
211209} ) ;
212210
213211tape ( 'the function supports a `stride` parameter (accessors)' , function test ( t ) {
214- var N ;
215212 var x ;
216213 var v ;
217214
@@ -228,15 +225,13 @@ tape( 'the function supports a `stride` parameter (accessors)', function test( t
228225 NaN
229226 ] ;
230227
231- N = floor ( x . length / 2 ) ;
232- v = nanrangeBy ( N , toAccessorArray ( x ) , 2 , accessor ) ;
228+ v = nanrangeBy ( 5 , toAccessorArray ( x ) , 2 , accessor ) ;
233229
234230 t . strictEqual ( v , 12.0 , 'returns expected value' ) ;
235231 t . end ( ) ;
236232} ) ;
237233
238234tape ( 'the function supports a negative `stride` parameter' , function test ( t ) {
239- var N ;
240235 var x ;
241236 var v ;
242237
@@ -253,15 +248,13 @@ tape( 'the function supports a negative `stride` parameter', function test( t )
253248 2.0
254249 ] ;
255250
256- N = floor ( x . length / 2 ) ;
257- v = nanrangeBy ( N , x , - 2 , accessor ) ;
251+ v = nanrangeBy ( 5 , x , - 2 , accessor ) ;
258252
259253 t . strictEqual ( v , 12.0 , 'returns expected value' ) ;
260254 t . end ( ) ;
261255} ) ;
262256
263257tape ( 'the function supports a negative `stride` parameter (accessors)' , function test ( t ) {
264- var N ;
265258 var x ;
266259 var v ;
267260
@@ -278,8 +271,7 @@ tape( 'the function supports a negative `stride` parameter (accessors)', functio
278271 2.0
279272 ] ;
280273
281- N = floor ( x . length / 2 ) ;
282- v = nanrangeBy ( N , toAccessorArray ( x ) , - 2 , accessor ) ;
274+ v = nanrangeBy ( 5 , toAccessorArray ( x ) , - 2 , accessor ) ;
283275
284276 t . strictEqual ( v , 12.0 , 'returns expected value' ) ;
285277 t . end ( ) ;
@@ -291,10 +283,10 @@ tape( 'if provided a `stride` parameter equal to `0`, the function returns `0`',
291283
292284 x = [ 1.0 , - 2.0 , - 4.0 , 5.0 , 3.0 ] ;
293285
294- v = nanrangeBy ( x . length , toAccessorArray ( x ) , 0 , accessor ) ;
286+ v = nanrangeBy ( x . length , x , 0 , accessor ) ;
295287 t . strictEqual ( v , 0.0 , 'returns expected value' ) ;
296288
297- x = new Array ( 1 ) ; // sparse array
289+ x = new Array ( 1 ) ; // eslint-disable-line stdlib/no-new- array
298290 v = nanrangeBy ( 1 , x , 0 , accessor ) ;
299291 t . strictEqual ( isnan ( v ) , true , 'returns expected value' ) ;
300292
@@ -307,11 +299,11 @@ tape( 'if provided a `stride` parameter equal to `0`, the function returns `0` (
307299
308300 x = [ 1.0 , - 2.0 , - 4.0 , 5.0 , 3.0 ] ;
309301
310- v = nanrangeBy ( x . length , toAccessorArray ( x ) , 0 , accessor ) ;
302+ v = nanrangeBy ( x . length , toAccessorArray ( x ) , 0 , accessor ) ;
311303 t . strictEqual ( v , 0.0 , 'returns expected value' ) ;
312304
313- x = new Array ( 1 ) ; // sparse array
314- v = nanrangeBy ( 1 , toAccessorArray ( x ) , 0 , accessor ) ;
305+ x = new Array ( 1 ) ; // eslint-disable-line stdlib/no-new- array
306+ v = nanrangeBy ( 1 , toAccessorArray ( x ) , 0 , accessor ) ;
315307 t . strictEqual ( isnan ( v ) , true , 'returns expected value' ) ;
316308
317309 t . end ( ) ;
@@ -320,7 +312,6 @@ tape( 'if provided a `stride` parameter equal to `0`, the function returns `0` (
320312tape ( 'the function supports view offsets' , function test ( t ) {
321313 var x0 ;
322314 var x1 ;
323- var N ;
324315 var v ;
325316
326317 x0 = new Float64Array ( [
@@ -338,9 +329,8 @@ tape( 'the function supports view offsets', function test( t ) {
338329 ] ) ;
339330
340331 x1 = new Float64Array ( x0 . buffer , x0 . BYTES_PER_ELEMENT * 1 ) ; // start at 2nd element
341- N = floor ( x1 . length / 2 ) ;
342332
343- v = nanrangeBy ( N , x1 , 2 , accessor ) ;
333+ v = nanrangeBy ( 5 , x1 , 2 , accessor ) ;
344334 t . strictEqual ( v , 12.0 , 'returns expected value' ) ;
345335
346336 t . end ( ) ;
@@ -349,7 +339,6 @@ tape( 'the function supports view offsets', function test( t ) {
349339tape ( 'the function supports view offsets (accessors)' , function test ( t ) {
350340 var x0 ;
351341 var x1 ;
352- var N ;
353342 var v ;
354343
355344 x0 = new Float64Array ( [
@@ -367,9 +356,8 @@ tape( 'the function supports view offsets (accessors)', function test( t ) {
367356 ] ) ;
368357
369358 x1 = new Float64Array ( x0 . buffer , x0 . BYTES_PER_ELEMENT * 1 ) ; // start at 2nd element
370- N = floor ( x1 . length / 2 ) ;
371359
372- v = nanrangeBy ( N , toAccessorArray ( x1 ) , 2 , accessor ) ;
360+ v = nanrangeBy ( 5 , toAccessorArray ( x1 ) , 2 , accessor ) ;
373361 t . strictEqual ( v , 12.0 , 'returns expected value' ) ;
374362
375363 t . end ( ) ;
@@ -402,7 +390,7 @@ tape( 'the function supports providing a callback execution context (accessors)'
402390 ctx = {
403391 'count' : 0
404392 } ;
405- nanrangeBy ( x . length , toAccessorArray ( x ) , 1 , accessor , ctx ) ;
393+ nanrangeBy ( x . length , toAccessorArray ( x ) , 1 , accessor , ctx ) ;
406394
407395 t . strictEqual ( ctx . count , x . length , 'returns expected value' ) ;
408396 t . end ( ) ;
0 commit comments