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..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 ) { @@ -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: @@ -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 + 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..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 @@ -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 = %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..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 @@ -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 = %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 37d9f4065b54..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 @@ -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 = %s', x, y, append ); +* // e.g., => 'foo+baz = foobaz\nbar+beep = barbeep\n' */ function logEachMap( str ) { var strides;