From 38b75c100be1068fcbfdd1855f1d98597b3ee004 Mon Sep 17 00:00:00 2001 From: Udit Agarwal Date: Mon, 13 Oct 2025 19:38:28 +0530 Subject: [PATCH] fix(utils/some-by-right): refactor example to use array PRNG Updates the example for `someByRight` to use `@stdlib/random/array/randu` for creating the example array. This change addresses a `no-new-array` linting error and improves the example's conciseness by replacing a `for` loop with a direct function call. The refactoring has been applied to both the runnable example (`examples/index.js`) and the example included in the package `README.md`. A `no-redeclare` directive has been added to the `README.md` to resolve a linter error caused by multiple example blocks declaring the same variable name. --- 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: passed - 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: passed - task: lint_javascript_tests status: na - 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: passed - task: lint_typescript_tests status: na - task: lint_license_headers status: passed --- --- .../@stdlib/utils/some-by-right/README.md | 13 +++---------- .../utils/some-by-right/examples/index.js | 19 ++++++------------- 2 files changed, 9 insertions(+), 23 deletions(-) diff --git a/lib/node_modules/@stdlib/utils/some-by-right/README.md b/lib/node_modules/@stdlib/utils/some-by-right/README.md index 6feba827de21..db56dd8c4063 100644 --- a/lib/node_modules/@stdlib/utils/some-by-right/README.md +++ b/lib/node_modules/@stdlib/utils/some-by-right/README.md @@ -159,23 +159,16 @@ var mean = context.sum / context.count; ```javascript -var randu = require( '@stdlib/random/base/randu' ); +var randu = require( '@stdlib/random/array/randu' ); var someByRight = require( '@stdlib/utils/some-by-right' ); function threshold( value ) { return ( value > 0.95 ); } -var bool; -var arr; -var i; +var arr = randu( 100 ); // eslint-disable-line stdlib/no-redeclare -arr = new Array( 100 ); -for ( i = 0; i < arr.length; i++ ) { - arr[ i ] = randu(); -} - -bool = someByRight( arr, 5, threshold ); +var bool = someByRight( arr, 5, threshold ); // returns ``` diff --git a/lib/node_modules/@stdlib/utils/some-by-right/examples/index.js b/lib/node_modules/@stdlib/utils/some-by-right/examples/index.js index 1db41922db1b..5dfb2493c568 100644 --- a/lib/node_modules/@stdlib/utils/some-by-right/examples/index.js +++ b/lib/node_modules/@stdlib/utils/some-by-right/examples/index.js @@ -18,21 +18,14 @@ 'use strict'; -var randu = require( '@stdlib/random/base/randu' ); +var randu = require( '@stdlib/random/array/randu' ); var someByRight = require( './../lib' ); -function threshold( value ) { - return ( value > 0.95 ); +function threshold(value) { + return (value > 0.95); } -var bool; -var arr; -var i; +var arr = randu(100); -arr = new Array( 100 ); -for ( i = 0; i < arr.length; i++ ) { - arr[ i ] = randu(); -} - -bool = someByRight( arr, 5, threshold ); -console.log( bool ); +var bool = someByRight(arr, 5, threshold); +console.log(bool);