Skip to content

Commit 3b768c0

Browse files
committed
feat: refactor and add protocol support to stats/base/max-by
--- type: pre_commit_static_analysis_report description: Results of running static analysis checks when committing changes. report: - task: lint_filenames status: passed - task: lint_editorconfig status: passed - task: lint_markdown status: na - task: lint_package_json status: na - task: lint_repl_help status: na - task: lint_javascript_src status: na - task: lint_javascript_cli status: na - task: lint_javascript_examples status: na - task: lint_javascript_tests status: passed - task: lint_javascript_benchmarks status: na - task: lint_python status: na - task: lint_r status: na - task: lint_c_src status: na - task: lint_c_examples status: na - task: lint_c_benchmarks status: na - task: lint_c_tests_fixtures status: na - task: lint_shell status: na - task: lint_typescript_declarations status: na - task: lint_typescript_tests status: na - task: lint_license_headers status: passed ---
1 parent 6945eb9 commit 3b768c0

File tree

1 file changed

+13
-4
lines changed

1 file changed

+13
-4
lines changed

lib/node_modules/@stdlib/stats/base/max-by/test/test.max_by.js

Lines changed: 13 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,15 @@ function accessor( v ) {
3838
return v * 2.0;
3939
}
4040

41+
function createArray( len ) {
42+
var arr = [];
43+
var i;
44+
for ( i = 0; i < len; i++ ) {
45+
arr.push(undefined);
46+
}
47+
return arr;
48+
}
49+
4150

4251
// TESTS //
4352

@@ -76,11 +85,11 @@ tape( 'the function calculates the maximum value of a strided array via a callba
7685
v = maxBy( x.length, x, 1, accessor );
7786
t.strictEqual( isnan( v ), true, 'returns expected value' );
7887

79-
x = [ 5 ]; // sparse array
88+
x = createArray(5); // sparse array
8089
v = maxBy( x.length, x, 1, accessor );
8190
t.strictEqual( isnan( v ), true, 'returns expected value' );
8291

83-
x = [ 5 ]; // sparse array
92+
x = createArray(5); // sparse array
8493
x[ 2 ] = 1.0;
8594
v = maxBy( x.length, x, 1, accessor );
8695
t.strictEqual( v, 2.0, 'returns expected value' );
@@ -112,7 +121,7 @@ tape( 'if provided an `N` parameter equal to `1`, the function returns the first
112121
v = maxBy( 1, x, 1, accessor );
113122
t.strictEqual( v, 2.0, 'returns expected value' );
114123

115-
x = [ 1 ]; // sparse array
124+
x = createArray(1); // sparse array
116125

117126
v = maxBy( 1, x, 1, accessor );
118127
t.strictEqual( isnan( v ), true, 'returns expected value' );
@@ -196,7 +205,7 @@ tape( 'if provided a `stride` parameter equal to `0`, the function returns the f
196205
v = maxBy( x.length, x, 0, accessor );
197206
t.strictEqual( v, 2.0, 'returns expected value' );
198207

199-
x = [ 1 ]; // sparse array
208+
x = createArray(1); // sparse array
200209

201210
v = maxBy( 1, x, 0, accessor );
202211
t.strictEqual( isnan( v ), true, 'returns expected value' );

0 commit comments

Comments
 (0)