From 325ec43ddf2532e37193989d5fb5531dcecfe3f3 Mon Sep 17 00:00:00 2001 From: Karan Anand Date: Fri, 21 Mar 2025 21:51:08 -0700 Subject: [PATCH 1/3] docs: add string and float examples --- 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: passed - task: lint_javascript_src status: passed - task: lint_javascript_cli status: na - task: lint_javascript_examples status: na - 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: na - task: lint_typescript_tests status: na - task: lint_license_headers status: passed --- --- .../@stdlib/console/log-each-map/README.md | 6 ++--- .../console/log-each-map/docs/repl.txt | 10 +++++++++ .../@stdlib/console/log-each-map/lib/index.js | 20 +++++++++++++++++ .../@stdlib/console/log-each-map/lib/main.js | 22 +++++++++++++++++++ 4 files changed, 55 insertions(+), 3 deletions(-) diff --git a/lib/node_modules/@stdlib/console/log-each-map/README.md b/lib/node_modules/@stdlib/console/log-each-map/README.md index 877fd1c264d1..26d7839c2664 100644 --- a/lib/node_modules/@stdlib/console/log-each-map/README.md +++ b/lib/node_modules/@stdlib/console/log-each-map/README.md @@ -95,10 +95,10 @@ function multiply( x, y ) { } var x = [ 1, 2, 3 ]; -var y = 2; +var y = 0.5; -logEachMap( '%d * %d = %d', x, y, multiply ); -// e.g., => '1 * 2 = 2\n2 * 2 = 4\n3 * 2 = 6\n' +logEachMap( '%0.1f * %0.1f = %0.1f', x, y, multiply ); +// e.g., => '1.0 * 0.5 = 0.5\n2.0 * 0.5 = 1.0\n3.0 * 0.5 = 1.5\n' ``` The callback function is provided the following arguments: diff --git a/lib/node_modules/@stdlib/console/log-each-map/docs/repl.txt b/lib/node_modules/@stdlib/console/log-each-map/docs/repl.txt index bb81e87a2b2b..4df5895f3d33 100644 --- a/lib/node_modules/@stdlib/console/log-each-map/docs/repl.txt +++ b/lib/node_modules/@stdlib/console/log-each-map/docs/repl.txt @@ -27,5 +27,15 @@ > function f( x, y ) { return x + y; }; > {{alias}}( '%d + %d = %d', x, y, f ); + > var x = [ 0.5, 1.0, 1.5 ]; + > var y = [ 0.5, 0.75, 1.0 ]; + > function f( x, y ) { return x * y; }; + > {{alias}}( '%0.2f * %0.2f = %0.2f', x, y, f ); + + > var x = [ 'foo', 'bar' ]; + > var y = [ 'baz', 'beep' ]; + > function f( x, y ) { return x + y; }; + > {{alias}}( '%s-%s', x, y, f ); + See Also -------- diff --git a/lib/node_modules/@stdlib/console/log-each-map/lib/index.js b/lib/node_modules/@stdlib/console/log-each-map/lib/index.js index 27e046b5d53b..884b1bf6a34a 100644 --- a/lib/node_modules/@stdlib/console/log-each-map/lib/index.js +++ b/lib/node_modules/@stdlib/console/log-each-map/lib/index.js @@ -35,6 +35,26 @@ * * logEachMap( '%d + %d = %d', x, y, add ); * // e.g., => '1 + 4 = 5\n2 + 5 = 7\n3 + 6 = 9\n' +* +* function multiply( x, y ) { +* return x * y; +* } +* +* var x = [ 0.5, 1.0, 1.5 ]; +* var y = [ 0.5, 0.75, 1.0 ]; +* +* logEachMap( '%0.2f * %0.2f = %0.2f', x, y, multiply ); +* // e.g., => '0.50 * 0.50 = 0.25\n1.00 * 0.75 = 0.75\n1.50 * 1.00 = 1.50\n' +* +* function append( x, y ) { +* return x + y; +* } +* +* var x = [ 'foo', 'bar' ]; +* var y = [ 'baz', 'beep' ]; +* +* logEachMap( '%s-%s', x, y, append ); +* // e.g., => 'foo-baz\nbar-beep\n' */ // MODULES // diff --git a/lib/node_modules/@stdlib/console/log-each-map/lib/main.js b/lib/node_modules/@stdlib/console/log-each-map/lib/main.js index 37d9f4065b54..4d13754bf389 100644 --- a/lib/node_modules/@stdlib/console/log-each-map/lib/main.js +++ b/lib/node_modules/@stdlib/console/log-each-map/lib/main.js @@ -54,6 +54,28 @@ var logger = require( '@stdlib/console/log' ); * * logEachMap( '%d + %d = %d', x, y, add ); * // e.g., => '1 + 4 = 5\n2 + 5 = 7\n3 + 6 = 9\n' +* +* @example +* function multiply( x, y ) { +* return x * y; +* } +* +* var x = [ 0.5, 1.0, 1.5 ]; +* var y = [ 0.5, 0.75, 1.0 ]; +* +* logEachMap( '%0.2f * %0.2f = %0.2f', x, y, multiply ); +* // e.g., => '0.50 * 0.50 = 0.25\n1.00 * 0.75 = 0.75\n1.50 * 1.00 = 1.50\n' +* +* @example +* function append( x, y ) { +* return x + y; +* } +* +* var x = [ 'foo', 'bar' ]; +* var y = [ 'baz', 'beep' ]; +* +* logEachMap( '%s-%s', x, y, append ); +* // e.g., => 'foo-baz\nbar-beep\n' */ function logEachMap( str ) { var strides; From 69887a0ead6fc87e9630054234a282e0fe584362 Mon Sep 17 00:00:00 2001 From: Athan Date: Sat, 22 Mar 2025 16:00:36 -0700 Subject: [PATCH 2/3] docs: link to `string/format` Signed-off-by: Athan --- lib/node_modules/@stdlib/console/log-each-map/README.md | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/lib/node_modules/@stdlib/console/log-each-map/README.md b/lib/node_modules/@stdlib/console/log-each-map/README.md index 26d7839c2664..f31d9a26f270 100644 --- a/lib/node_modules/@stdlib/console/log-each-map/README.md +++ b/lib/node_modules/@stdlib/console/log-each-map/README.md @@ -20,7 +20,7 @@ limitations under the License. # logEachMap -> Insert array element values and the result of a callback function into a format string and print the result. +> Insert array element values and the result of a callback function into a [format string][@stdlib/string/format] and print the result. @@ -42,7 +42,7 @@ var logEachMap = require( '@stdlib/console/log-each-map' ); #### logEachMap( str\[, ...args], clbk\[, thisArg] ) -Inserts array element values and the result of a callback function into a format string and prints the result. +Inserts array element values and the result of a callback function into a [format string][@stdlib/string/format] and prints the result. ```javascript function add( a, b ) { @@ -182,6 +182,8 @@ logEachMap( '%d + %d = %d', x, y, add ); [@stdlib/array/complex64]: https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/array/complex64 +[@stdlib/string/format]: https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/string/format + From 50aaffad165a5773c9ee680fc22a4ef86390438a Mon Sep 17 00:00:00 2001 From: Athan Date: Sat, 22 Mar 2025 16:01:29 -0700 Subject: [PATCH 3/3] Apply suggestions from code review Signed-off-by: Athan --- lib/node_modules/@stdlib/console/log-each-map/docs/repl.txt | 2 +- lib/node_modules/@stdlib/console/log-each-map/lib/index.js | 4 ++-- lib/node_modules/@stdlib/console/log-each-map/lib/main.js | 4 ++-- 3 files changed, 5 insertions(+), 5 deletions(-) diff --git a/lib/node_modules/@stdlib/console/log-each-map/docs/repl.txt b/lib/node_modules/@stdlib/console/log-each-map/docs/repl.txt index 4df5895f3d33..d3413c161a40 100644 --- a/lib/node_modules/@stdlib/console/log-each-map/docs/repl.txt +++ b/lib/node_modules/@stdlib/console/log-each-map/docs/repl.txt @@ -35,7 +35,7 @@ > var x = [ 'foo', 'bar' ]; > var y = [ 'baz', 'beep' ]; > function f( x, y ) { return x + y; }; - > {{alias}}( '%s-%s', x, y, f ); + > {{alias}}( '%s+%s = %s', x, y, f ); See Also -------- diff --git a/lib/node_modules/@stdlib/console/log-each-map/lib/index.js b/lib/node_modules/@stdlib/console/log-each-map/lib/index.js index 884b1bf6a34a..eeba0935376b 100644 --- a/lib/node_modules/@stdlib/console/log-each-map/lib/index.js +++ b/lib/node_modules/@stdlib/console/log-each-map/lib/index.js @@ -53,8 +53,8 @@ * var x = [ 'foo', 'bar' ]; * var y = [ 'baz', 'beep' ]; * -* logEachMap( '%s-%s', x, y, append ); -* // e.g., => 'foo-baz\nbar-beep\n' +* logEachMap( '%s+%s = %s', x, y, append ); +* // e.g., => 'foo+baz = foobaz\nbar+beep = barbeep\n' */ // MODULES // diff --git a/lib/node_modules/@stdlib/console/log-each-map/lib/main.js b/lib/node_modules/@stdlib/console/log-each-map/lib/main.js index 4d13754bf389..7ef77d2998fb 100644 --- a/lib/node_modules/@stdlib/console/log-each-map/lib/main.js +++ b/lib/node_modules/@stdlib/console/log-each-map/lib/main.js @@ -74,8 +74,8 @@ var logger = require( '@stdlib/console/log' ); * var x = [ 'foo', 'bar' ]; * var y = [ 'baz', 'beep' ]; * -* logEachMap( '%s-%s', x, y, append ); -* // e.g., => 'foo-baz\nbar-beep\n' +* logEachMap( '%s+%s = %s', x, y, append ); +* // e.g., => 'foo+baz = foobaz\nbar+beep = barbeep\n' */ function logEachMap( str ) { var strides;