@stdlib/console-log-each 0.0.2 → 0.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CITATION.cff +30 -0
- package/README.md +14 -3
- package/dist/index.d.ts +3 -0
- package/dist/index.js +5 -0
- package/dist/index.js.map +7 -0
- package/docs/types/index.d.ts +2 -2
- package/package.json +13 -12
- package/docs/repl.txt +0 -24
- package/docs/types/test.ts +0 -39
package/CITATION.cff
ADDED
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
cff-version: 1.2.0
|
|
2
|
+
title: stdlib
|
|
3
|
+
message: >-
|
|
4
|
+
If you use this software, please cite it using the
|
|
5
|
+
metadata from this file.
|
|
6
|
+
|
|
7
|
+
type: software
|
|
8
|
+
|
|
9
|
+
authors:
|
|
10
|
+
- name: The Stdlib Authors
|
|
11
|
+
url: https://github.com/stdlib-js/stdlib/graphs/contributors
|
|
12
|
+
|
|
13
|
+
repository-code: https://github.com/stdlib-js/stdlib
|
|
14
|
+
url: https://stdlib.io
|
|
15
|
+
|
|
16
|
+
abstract: |
|
|
17
|
+
Standard library for JavaScript and Node.js.
|
|
18
|
+
|
|
19
|
+
keywords:
|
|
20
|
+
- JavaScript
|
|
21
|
+
- Node.js
|
|
22
|
+
- TypeScript
|
|
23
|
+
- standard library
|
|
24
|
+
- scientific computing
|
|
25
|
+
- numerical computing
|
|
26
|
+
- statistical computing
|
|
27
|
+
|
|
28
|
+
license: Apache-2.0 AND BSL-1.0
|
|
29
|
+
|
|
30
|
+
date-released: 2016
|
package/README.md
CHANGED
|
@@ -18,6 +18,17 @@ limitations under the License.
|
|
|
18
18
|
|
|
19
19
|
-->
|
|
20
20
|
|
|
21
|
+
|
|
22
|
+
<details>
|
|
23
|
+
<summary>
|
|
24
|
+
About stdlib...
|
|
25
|
+
</summary>
|
|
26
|
+
<p>We believe in a future in which the web is a preferred environment for numerical computation. To help realize this future, we've built stdlib. stdlib is a standard library, with an emphasis on numerical and scientific computation, written in JavaScript (and C) for execution in browsers and in Node.js.</p>
|
|
27
|
+
<p>The library is fully decomposable, being architected in such a way that you can swap out and mix and match APIs and functionality to cater to your exact preferences and use cases.</p>
|
|
28
|
+
<p>When you use stdlib, you can be absolutely certain that you are using the most thorough, rigorous, well-written, studied, documented, tested, measured, and high-quality code out there.</p>
|
|
29
|
+
<p>To join us in bringing numerical computing to the web, get started by checking us out on <a href="https://github.com/stdlib-js/stdlib">GitHub</a>, and please consider <a href="https://opencollective.com/stdlib">financially supporting stdlib</a>. We greatly appreciate your continued support!</p>
|
|
30
|
+
</details>
|
|
31
|
+
|
|
21
32
|
# logEach
|
|
22
33
|
|
|
23
34
|
[![NPM version][npm-image]][npm-url] [![Build Status][test-image]][test-url] [![Coverage Status][coverage-image]][coverage-url] <!-- [![dependencies][dependencies-image]][dependencies-url] -->
|
|
@@ -173,8 +184,8 @@ Copyright © 2016-2023. The Stdlib [Authors][stdlib-authors].
|
|
|
173
184
|
[npm-image]: http://img.shields.io/npm/v/@stdlib/console-log-each.svg
|
|
174
185
|
[npm-url]: https://npmjs.org/package/@stdlib/console-log-each
|
|
175
186
|
|
|
176
|
-
[test-image]: https://github.com/stdlib-js/console-log-each/actions/workflows/test.yml/badge.svg?branch=v0.0
|
|
177
|
-
[test-url]: https://github.com/stdlib-js/console-log-each/actions/workflows/test.yml?query=branch:v0.0
|
|
187
|
+
[test-image]: https://github.com/stdlib-js/console-log-each/actions/workflows/test.yml/badge.svg?branch=v0.1.0
|
|
188
|
+
[test-url]: https://github.com/stdlib-js/console-log-each/actions/workflows/test.yml?query=branch:v0.1.0
|
|
178
189
|
|
|
179
190
|
[coverage-image]: https://img.shields.io/codecov/c/github/stdlib-js/console-log-each/main.svg
|
|
180
191
|
[coverage-url]: https://codecov.io/github/stdlib-js/console-log-each?branch=main
|
|
@@ -187,7 +198,7 @@ Copyright © 2016-2023. The Stdlib [Authors][stdlib-authors].
|
|
|
187
198
|
-->
|
|
188
199
|
|
|
189
200
|
[chat-image]: https://img.shields.io/gitter/room/stdlib-js/stdlib.svg
|
|
190
|
-
[chat-url]: https://gitter.im
|
|
201
|
+
[chat-url]: https://app.gitter.im/#/room/#stdlib-js_stdlib:gitter.im
|
|
191
202
|
|
|
192
203
|
[stdlib]: https://github.com/stdlib-js/stdlib
|
|
193
204
|
|
package/dist/index.d.ts
ADDED
package/dist/index.js
ADDED
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
"use strict";var q=function(u,s){return function(){return s||u((s={exports:{}}).exports,s),s.exports}};var d=q(function(P,m){
|
|
2
|
+
var w=require('@stdlib/assert-is-string/dist').isPrimitive,c=require('@stdlib/assert-is-collection/dist'),p=require('@stdlib/array-base-accessors/dist'),f=require('@stdlib/error-tools-fmtprodmsg/dist'),E=require('@stdlib/console-log/dist');function b(u){var s,l,t,h,o,n,v,r,g,i,e,a;if(!w(u))throw new TypeError(f('1aZ3F',u));for(o=arguments.length,t=[],s=[],n=[],e=1;e<o;e++)if(r=arguments[e],c(r)){i=p(r),t.push(i.accessors[0]),n.push(r),s.push(1),v=r.length,e+=1;break}else r=[r],i=p(r),t.push(i.accessors[0]),n.push(r),s.push(0);for(v===void 0&&(v=1);e<o;e++){if(r=arguments[e],c(r)){if(r.length!==v)throw new RangeError(format('1aZD1'));g=1}else r=[r],g=0;i=p(r),t.push(i.accessors[0]),n.push(r),s.push(g)}for(h=[u],l=[],e=1;e<o;e++)h.push(null),l.push(0);for(e=0;e<v;e++){for(a=0;a<o-1;a++)h[a+1]=t[a](n[a],l[a]),l[a]+=s[a];E(f.apply(null,h))}}m.exports=b
|
|
3
|
+
});var x=d();module.exports=x;
|
|
4
|
+
/** @license Apache-2.0 */
|
|
5
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../lib/main.js", "../lib/index.js"],
|
|
4
|
+
"sourcesContent": ["/**\n* @license Apache-2.0\n*\n* Copyright (c) 2022 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nvar isString = require( '@stdlib/assert-is-string' ).isPrimitive;\nvar isCollection = require( '@stdlib/assert-is-collection' );\nvar accessors = require( '@stdlib/array-base-accessors' );\nvar format = require( '@stdlib/string-format' );\nvar logger = require( '@stdlib/console-log' );\n\n\n// MAIN //\n\n/**\n* Inserts array element values into a format string and prints the result.\n*\n* @param {string} str - format string\n* @param {...(Collection|*)} args - collections or values\n* @throws {TypeError} first argument must be a string\n* @throws {RangeError} provided collections must have the same length\n* @returns {void}\n*/\nfunction logEach( str ) {\n\tvar strides;\n\tvar offsets;\n\tvar getters;\n\tvar values;\n\tvar nargs;\n\tvar args;\n\tvar len;\n\tvar v;\n\tvar s;\n\tvar o;\n\tvar i;\n\tvar j;\n\tif ( !isString( str ) ) {\n\t\tthrow new TypeError( format( 'invalid argument. First argument must be a string. Value: `%s`.', str ) );\n\t}\n\tnargs = arguments.length;\n\tgetters = [];\n\tstrides = [];\n\targs = [];\n\tfor ( i = 1; i < nargs; i++ ) {\n\t\tv = arguments[ i ];\n\t\tif ( isCollection( v ) ) {\n\t\t\to = accessors( v );\n\t\t\tgetters.push( o.accessors[ 0 ] );\n\t\t\targs.push( v );\n\t\t\tstrides.push( 1 );\n\t\t\tlen = v.length;\n\t\t\ti += 1;\n\t\t\tbreak;\n\t\t} else {\n\t\t\tv = [ v ];\n\t\t\to = accessors( v );\n\t\t\tgetters.push( o.accessors[ 0 ] );\n\t\t\targs.push( v );\n\t\t\tstrides.push( 0 );\n\t\t}\n\t}\n\tif ( len === void 0 ) {\n\t\tlen = 1;\n\t}\n\tfor ( ; i < nargs; i++ ) {\n\t\tv = arguments[ i ];\n\t\tif ( isCollection( v ) ) {\n\t\t\tif ( v.length !== len ) {\n\t\t\t\tthrow new RangeError( 'invalid argument. Provided collections must have the same length.' );\n\t\t\t}\n\t\t\ts = 1;\n\t\t} else {\n\t\t\tv = [ v ];\n\t\t\ts = 0;\n\t\t}\n\t\to = accessors( v );\n\t\tgetters.push( o.accessors[ 0 ] );\n\t\targs.push( v );\n\t\tstrides.push( s );\n\t}\n\tvalues = [ str ];\n\toffsets = [];\n\tfor ( i = 1; i < nargs; i++ ) {\n\t\tvalues.push( null );\n\t\toffsets.push( 0 );\n\t}\n\tfor ( i = 0; i < len; i++ ) {\n\t\tfor ( j = 0; j < nargs-1; j++ ) {\n\t\t\tvalues[ j+1 ] = getters[ j ]( args[ j ], offsets[ j ] );\n\t\t\toffsets[ j ] += strides[ j ];\n\t\t}\n\t\tlogger( format.apply( null, values ) );\n\t}\n}\n\n\n// EXPORTS //\n\nmodule.exports = logEach;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2022 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n/**\n* Insert array element values into a format string and print the result.\n*\n* @module @stdlib/console-log-each\n*\n* @example\n* var logEach = require( '@stdlib/console-log-each' );\n*\n* var x = [ 1, 2, 3 ];\n* var y = [ 4, 5, 6 ];\n*\n* logEach( '%d < %d ', x, y );\n* // e.g., => '1 < 4\\n2 < 5\\n3 < 6\\n'\n*/\n\n// MODULES //\n\nvar main = require( './main.js' );\n\n\n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AAE,EAC/BJ,EAAK,KAAME,CAAE,EACbP,EAAQ,KAAMQ,CAAE,CACjB,CAGA,IAFAL,EAAS,CAAEJ,CAAI,EACfE,EAAU,CAAC,EACLS,EAAI,EAAGA,EAAIN,EAAOM,IACvBP,EAAO,KAAM,IAAK,EAClBF,EAAQ,KAAM,CAAE,EAEjB,IAAMS,EAAI,EAAGA,EAAIJ,EAAKI,IAAM,CAC3B,IAAMC,EAAI,EAAGA,EAAIP,EAAM,EAAGO,IACzBR,EAAQQ,EAAE,CAAE,EAAIT,EAASS,CAAE,EAAGN,EAAMM,CAAE,EAAGV,EAASU,CAAE,CAAE,EACtDV,EAASU,CAAE,GAAKX,EAASW,CAAE,EAE5Bd,EAAQD,EAAO,MAAO,KAAMO,CAAO,CAAE,CACtC,CACD,CAKAX,EAAO,QAAUM,IC9EjB,IAAIc,EAAO,IAKX,OAAO,QAAUA",
|
|
6
|
+
"names": ["require_main", "__commonJSMin", "exports", "module", "isString", "isCollection", "accessors", "format", "logger", "logEach", "str", "strides", "offsets", "getters", "values", "nargs", "args", "len", "v", "s", "o", "i", "j", "main"]
|
|
7
|
+
}
|
package/docs/types/index.d.ts
CHANGED
|
@@ -16,7 +16,7 @@
|
|
|
16
16
|
* limitations under the License.
|
|
17
17
|
*/
|
|
18
18
|
|
|
19
|
-
// TypeScript Version:
|
|
19
|
+
// TypeScript Version: 4.1
|
|
20
20
|
|
|
21
21
|
/**
|
|
22
22
|
* Inserts array element values into a format string and prints the result.
|
|
@@ -27,7 +27,7 @@
|
|
|
27
27
|
*
|
|
28
28
|
* @param str - format string
|
|
29
29
|
* @param args - collections or values
|
|
30
|
-
* @throws
|
|
30
|
+
* @throws provided collections must have the same length
|
|
31
31
|
*
|
|
32
32
|
* @example
|
|
33
33
|
* var logEach = require( `@stdlib/console/log-each` );
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@stdlib/console-log-each",
|
|
3
|
-
"version": "0.0
|
|
3
|
+
"version": "0.1.0",
|
|
4
4
|
"description": "Insert array element values into a format string and print the result.",
|
|
5
5
|
"license": "Apache-2.0",
|
|
6
6
|
"author": {
|
|
@@ -37,22 +37,23 @@
|
|
|
37
37
|
"url": "https://github.com/stdlib-js/stdlib/issues"
|
|
38
38
|
},
|
|
39
39
|
"dependencies": {
|
|
40
|
-
"@stdlib/array-base-accessors": "^0.0
|
|
41
|
-
"@stdlib/assert-is-collection": "^0.0
|
|
42
|
-
"@stdlib/assert-is-string": "^0.0
|
|
43
|
-
"@stdlib/console-log": "^0.0
|
|
44
|
-
"@stdlib/string-format": "^0.0
|
|
40
|
+
"@stdlib/array-base-accessors": "^0.1.0",
|
|
41
|
+
"@stdlib/assert-is-collection": "^0.1.0",
|
|
42
|
+
"@stdlib/assert-is-string": "^0.1.0",
|
|
43
|
+
"@stdlib/console-log": "^0.1.0",
|
|
44
|
+
"@stdlib/string-format": "^0.1.0",
|
|
45
|
+
"@stdlib/error-tools-fmtprodmsg": "^0.1.0"
|
|
45
46
|
},
|
|
46
47
|
"devDependencies": {
|
|
47
|
-
"@stdlib/array-complex128": "^0.0
|
|
48
|
+
"@stdlib/array-complex128": "^0.1.0",
|
|
48
49
|
"@stdlib/array-filled-by": "^0.0.2",
|
|
49
|
-
"@stdlib/array-zeros": "^0.0
|
|
50
|
-
"@stdlib/bench": "^0.0
|
|
51
|
-
"@stdlib/math-base-special-abs": "^0.0
|
|
52
|
-
"@stdlib/math-base-special-pow": "^0.0
|
|
50
|
+
"@stdlib/array-zeros": "^0.1.0",
|
|
51
|
+
"@stdlib/bench": "^0.1.0",
|
|
52
|
+
"@stdlib/math-base-special-abs": "^0.1.0",
|
|
53
|
+
"@stdlib/math-base-special-pow": "^0.1.0",
|
|
53
54
|
"@stdlib/random-base-discrete-uniform": "^0.0.6",
|
|
54
55
|
"@stdlib/utils-map": "^0.0.1",
|
|
55
|
-
"@stdlib/utils-nary-function": "^0.0
|
|
56
|
+
"@stdlib/utils-nary-function": "^0.1.0",
|
|
56
57
|
"proxyquire": "^2.0.0",
|
|
57
58
|
"tape": "git+https://github.com/kgryte/tape.git#fix/globby",
|
|
58
59
|
"istanbul": "^0.4.1",
|
package/docs/repl.txt
DELETED
|
@@ -1,24 +0,0 @@
|
|
|
1
|
-
|
|
2
|
-
{{alias}}( str[, ...args] )
|
|
3
|
-
Inserts array element values into a format string and prints the result.
|
|
4
|
-
|
|
5
|
-
If an interpolated argument is not a collection, the argument is broadcasted
|
|
6
|
-
for each iteration.
|
|
7
|
-
|
|
8
|
-
Parameters
|
|
9
|
-
----------
|
|
10
|
-
str: String
|
|
11
|
-
Format string.
|
|
12
|
-
|
|
13
|
-
args: ...any (optional)
|
|
14
|
-
Collections or values.
|
|
15
|
-
|
|
16
|
-
Examples
|
|
17
|
-
--------
|
|
18
|
-
> var x = [ 1, 2, 3 ];
|
|
19
|
-
> var y = [ 4, 5, 6 ];
|
|
20
|
-
> {{alias}}( '%d < %d ', x, y );
|
|
21
|
-
|
|
22
|
-
See Also
|
|
23
|
-
--------
|
|
24
|
-
|
package/docs/types/test.ts
DELETED
|
@@ -1,39 +0,0 @@
|
|
|
1
|
-
/*
|
|
2
|
-
* @license Apache-2.0
|
|
3
|
-
*
|
|
4
|
-
* Copyright (c) 2022 The Stdlib Authors.
|
|
5
|
-
*
|
|
6
|
-
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
7
|
-
* you may not use this file except in compliance with the License.
|
|
8
|
-
* You may obtain a copy of the License at
|
|
9
|
-
*
|
|
10
|
-
* http://www.apache.org/licenses/LICENSE-2.0
|
|
11
|
-
*
|
|
12
|
-
* Unless required by applicable law or agreed to in writing, software
|
|
13
|
-
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
14
|
-
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
15
|
-
* See the License for the specific language governing permissions and
|
|
16
|
-
* limitations under the License.
|
|
17
|
-
*/
|
|
18
|
-
|
|
19
|
-
import logEach = require( './index' );
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
// TESTS //
|
|
23
|
-
|
|
24
|
-
// The function returns undefined...
|
|
25
|
-
{
|
|
26
|
-
logEach( '%d', [ 1, 2, 3 ] ); // $ExpectType void
|
|
27
|
-
logEach( '%d, %d', [ 1, 2, 3 ], 2 ); // $ExpectType void
|
|
28
|
-
logEach( '%d, %d', [ 1, 2, 3 ], [ 2, 3, 4 ] ); // $ExpectType void
|
|
29
|
-
}
|
|
30
|
-
|
|
31
|
-
// The compiler throws an error if the function is provided a first argument which is not string...
|
|
32
|
-
{
|
|
33
|
-
logEach( 123, [ 1, 2, 3 ] ); // $ExpectError
|
|
34
|
-
logEach( true, [ 1, 2, 3 ] ); // $ExpectError
|
|
35
|
-
logEach( false, [ 1, 2, 3 ] ); // $ExpectError
|
|
36
|
-
logEach( {}, [ 1, 2, 3 ] ); // $ExpectError
|
|
37
|
-
logEach( null, [ 1, 2, 3 ] ); // $ExpectError
|
|
38
|
-
logEach( undefined, [ 1, 2, 3 ] ); // $ExpectError
|
|
39
|
-
}
|