1
1
/**
2
2
* @license Apache-2.0
3
3
*
4
- * Copyright (c) 2025 The Stdlib Authors.
4
+ * Copyright (c) 2020 The Stdlib Authors.
5
5
*
6
6
* Licensed under the Apache License, Version 2.0 (the "License");
7
7
* you may not use this file except in compliance with the License.
21
21
// MODULES //
22
22
23
23
var tape = require ( 'tape' ) ;
24
- var floor = require ( '@stdlib/math/base/special/floor' ) ;
25
- var toAccessorArray = require ( '@stdlib/array/base/to-accessor-array' ) ;
26
24
var isnan = require ( '@stdlib/math/base/assert/is-nan' ) ;
27
25
var isNegativeZero = require ( '@stdlib/math/base/assert/is-negative-zero' ) ;
26
+ var toAccessorArray = require ( '@stdlib/array/base/to-accessor-array' ) ;
28
27
var Float64Array = require ( '@stdlib/array/float64' ) ;
29
- var nanminBy = require ( './../lib/nanmin_by .js' ) ;
28
+ var nanminBy = require ( './../lib/main .js' ) ;
30
29
31
30
32
31
// FUNCTIONS //
@@ -76,11 +75,11 @@ tape( 'the function calculates the minimum value of a strided array via a callba
76
75
v = nanminBy ( x . length , x , 1 , accessor ) ;
77
76
t . strictEqual ( isnan ( v ) , true , 'returns expected value' ) ;
78
77
79
- x = new Array ( 5 ) ; // sparse array
78
+ x = new Array ( 5 ) ; // eslint-disable-line stdlib/no-new- array
80
79
v = nanminBy ( x . length , x , 1 , accessor ) ;
81
80
t . strictEqual ( isnan ( v ) , true , 'returns expected value' ) ;
82
81
83
- x = new Array ( 5 ) ; // sparse array
82
+ x = new Array ( 5 ) ; // eslint-disable-line stdlib/no-new- array
84
83
x [ 2 ] = 1.0 ;
85
84
v = nanminBy ( x . length , x , 1 , accessor ) ;
86
85
t . strictEqual ( v , 2.0 , 'returns expected value' ) ;
@@ -112,13 +111,13 @@ tape( 'the function calculates the minimum value of a strided array via a callba
112
111
v = nanminBy ( x . length , toAccessorArray ( x ) , 1 , accessor ) ;
113
112
t . strictEqual ( isnan ( v ) , true , 'returns expected value' ) ;
114
113
115
- x = new Array ( 5 ) ; // sparse array
114
+ x = new Array ( 5 ) ; // eslint-disable-line stdlib/no-new- array
116
115
v = nanminBy ( x . length , toAccessorArray ( x ) , 1 , accessor ) ;
117
116
t . strictEqual ( isnan ( v ) , true , 'returns expected value' ) ;
118
117
119
- x = new Array ( 5 ) ; // sparse array
118
+ x = new Array ( 5 ) ; // eslint-disable-line stdlib/no-new- array
120
119
x [ 2 ] = 1.0 ;
121
- v = nanminBy ( x . length , toAccessorArray ( x ) , 1 , accessor ) ;
120
+ v = nanminBy ( x . length , toAccessorArray ( x ) , 1 , accessor ) ;
122
121
t . strictEqual ( v , 2.0 , 'returns expected value' ) ;
123
122
124
123
t . end ( ) ;
@@ -148,7 +147,7 @@ tape( 'if provided an `N` parameter less than or equal to `0`, the function retu
148
147
v = nanminBy ( 0 , toAccessorArray ( x ) , 1 , accessor ) ;
149
148
t . strictEqual ( isnan ( v ) , true , 'returns expected value' ) ;
150
149
151
- v = nanminBy ( - 1 , x , 1 , accessor ) ;
150
+ v = nanminBy ( - 1 , toAccessorArray ( x ) , 1 , accessor ) ;
152
151
t . strictEqual ( isnan ( v ) , true , 'returns expected value' ) ;
153
152
154
153
t . end ( ) ;
@@ -163,7 +162,7 @@ tape( 'if provided an `N` parameter equal to `1`, the function returns the first
163
162
v = nanminBy ( 1 , x , 1 , accessor ) ;
164
163
t . strictEqual ( v , 2.0 , 'returns expected value' ) ;
165
164
166
- x = new Array ( 1 ) ; // sparse array
165
+ x = new Array ( 1 ) ; // eslint-disable-line stdlib/no-new- array
167
166
v = nanminBy ( 1 , x , 1 , accessor ) ;
168
167
t . strictEqual ( isnan ( v ) , true , 'returns expected value' ) ;
169
168
@@ -179,15 +178,14 @@ tape( 'if provided an `N` parameter equal to `1`, the function returns the first
179
178
v = nanminBy ( 1 , toAccessorArray ( x ) , 1 , accessor ) ;
180
179
t . strictEqual ( v , 2.0 , 'returns expected value' ) ;
181
180
182
- x = new Array ( 1 ) ; // sparse array
181
+ x = new Array ( 1 ) ; // eslint-disable-line stdlib/no-new- array
183
182
v = nanminBy ( 1 , toAccessorArray ( x ) , 1 , accessor ) ;
184
183
t . strictEqual ( isnan ( v ) , true , 'returns expected value' ) ;
185
184
186
185
t . end ( ) ;
187
186
} ) ;
188
187
189
188
tape ( 'the function supports a `stride` parameter' , function test ( t ) {
190
- var N ;
191
189
var x ;
192
190
var v ;
193
191
@@ -204,15 +202,13 @@ tape( 'the function supports a `stride` parameter', function test( t ) {
204
202
NaN
205
203
] ;
206
204
207
- N = floor ( x . length / 2 ) ;
208
- v = nanminBy ( N , x , 2 , accessor ) ;
205
+ v = nanminBy ( 5 , x , 2 , accessor ) ;
209
206
210
207
t . strictEqual ( v , - 4.0 , 'returns expected value' ) ;
211
208
t . end ( ) ;
212
209
} ) ;
213
210
214
211
tape ( 'the function supports a `stride` parameter (accessors)' , function test ( t ) {
215
- var N ;
216
212
var x ;
217
213
var v ;
218
214
@@ -229,15 +225,13 @@ tape( 'the function supports a `stride` parameter (accessors)', function test( t
229
225
NaN
230
226
] ;
231
227
232
- N = floor ( x . length / 2 ) ;
233
- v = nanminBy ( N , toAccessorArray ( x ) , 2 , accessor ) ;
228
+ v = nanminBy ( 5 , toAccessorArray ( x ) , 2 , accessor ) ;
234
229
235
230
t . strictEqual ( v , - 4.0 , 'returns expected value' ) ;
236
231
t . end ( ) ;
237
232
} ) ;
238
233
239
234
tape ( 'the function supports a negative `stride` parameter' , function test ( t ) {
240
- var N ;
241
235
var x ;
242
236
var v ;
243
237
@@ -254,15 +248,13 @@ tape( 'the function supports a negative `stride` parameter', function test( t )
254
248
2.0
255
249
] ;
256
250
257
- N = floor ( x . length / 2 ) ;
258
- v = nanminBy ( N , x , - 2 , accessor ) ;
251
+ v = nanminBy ( 5 , x , - 2 , accessor ) ;
259
252
260
253
t . strictEqual ( v , - 4.0 , 'returns expected value' ) ;
261
254
t . end ( ) ;
262
255
} ) ;
263
256
264
257
tape ( 'the function supports a negative `stride` parameter (accessors)' , function test ( t ) {
265
- var N ;
266
258
var x ;
267
259
var v ;
268
260
@@ -279,8 +271,7 @@ tape( 'the function supports a negative `stride` parameter (accessors)', functio
279
271
2.0
280
272
] ;
281
273
282
- N = floor ( x . length / 2 ) ;
283
- v = nanminBy ( N , toAccessorArray ( x ) , - 2 , accessor ) ;
274
+ v = nanminBy ( 5 , toAccessorArray ( x ) , - 2 , accessor ) ;
284
275
285
276
t . strictEqual ( v , - 4.0 , 'returns expected value' ) ;
286
277
t . end ( ) ;
@@ -295,7 +286,7 @@ tape( 'if provided a `stride` parameter equal to `0`, the function returns the f
295
286
v = nanminBy ( x . length , x , 0 , accessor ) ;
296
287
t . strictEqual ( v , 2.0 , 'returns expected value' ) ;
297
288
298
- x = new Array ( 1 ) ; // sparse array
289
+ x = new Array ( 1 ) ; // eslint-disable-line stdlib/no-new- array
299
290
v = nanminBy ( 1 , x , 0 , accessor ) ;
300
291
t . strictEqual ( isnan ( v ) , true , 'returns expected value' ) ;
301
292
@@ -311,7 +302,7 @@ tape( 'if provided a `stride` parameter equal to `0`, the function returns the f
311
302
v = nanminBy ( x . length , toAccessorArray ( x ) , 0 , accessor ) ;
312
303
t . strictEqual ( v , 2.0 , 'returns expected value' ) ;
313
304
314
- x = new Array ( 1 ) ; // sparse array
305
+ x = new Array ( 1 ) ; // eslint-disable-line stdlib/no-new- array
315
306
v = nanminBy ( 1 , toAccessorArray ( x ) , 0 , accessor ) ;
316
307
t . strictEqual ( isnan ( v ) , true , 'returns expected value' ) ;
317
308
@@ -321,7 +312,6 @@ tape( 'if provided a `stride` parameter equal to `0`, the function returns the f
321
312
tape ( 'the function supports view offsets' , function test ( t ) {
322
313
var x0 ;
323
314
var x1 ;
324
- var N ;
325
315
var v ;
326
316
327
317
x0 = new Float64Array ( [
@@ -339,9 +329,8 @@ tape( 'the function supports view offsets', function test( t ) {
339
329
] ) ;
340
330
341
331
x1 = new Float64Array ( x0 . buffer , x0 . BYTES_PER_ELEMENT * 1 ) ; // start at 2nd element
342
- N = floor ( x1 . length / 2 ) ;
343
332
344
- v = nanminBy ( N , x1 , 2 , accessor ) ;
333
+ v = nanminBy ( 5 , x1 , 2 , accessor ) ;
345
334
t . strictEqual ( v , - 4.0 , 'returns expected value' ) ;
346
335
347
336
t . end ( ) ;
@@ -350,7 +339,6 @@ tape( 'the function supports view offsets', function test( t ) {
350
339
tape ( 'the function supports view offsets (accessors)' , function test ( t ) {
351
340
var x0 ;
352
341
var x1 ;
353
- var N ;
354
342
var v ;
355
343
356
344
x0 = new Float64Array ( [
@@ -368,9 +356,8 @@ tape( 'the function supports view offsets (accessors)', function test( t ) {
368
356
] ) ;
369
357
370
358
x1 = new Float64Array ( x0 . buffer , x0 . BYTES_PER_ELEMENT * 1 ) ; // start at 2nd element
371
- N = floor ( x1 . length / 2 ) ;
372
359
373
- v = nanminBy ( N , toAccessorArray ( x1 ) , 2 , accessor ) ;
360
+ v = nanminBy ( 5 , toAccessorArray ( x1 ) , 2 , accessor ) ;
374
361
t . strictEqual ( v , - 4.0 , 'returns expected value' ) ;
375
362
376
363
t . end ( ) ;
0 commit comments