@stdlib/ndarray-base-dtypes2signatures 0.0.6 → 0.0.7

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/NOTICE CHANGED
@@ -1 +1 @@
1
- Copyright (c) 2016-2021 The Stdlib Authors.
1
+ Copyright (c) 2016-2022 The Stdlib Authors.
package/README.md CHANGED
@@ -20,7 +20,7 @@ limitations under the License.
20
20
 
21
21
  # dtypes2signatures
22
22
 
23
- [![NPM version][npm-image]][npm-url] [![Build Status][test-image]][test-url] [![Coverage Status][coverage-image]][coverage-url] [![dependencies][dependencies-image]][dependencies-url]
23
+ [![NPM version][npm-image]][npm-url] [![Build Status][test-image]][test-url] [![Coverage Status][coverage-image]][coverage-url] <!-- [![dependencies][dependencies-image]][dependencies-url] -->
24
24
 
25
25
  > Transform a list of array argument data types into a list of signatures.
26
26
 
@@ -176,6 +176,14 @@ console.log( sigs );
176
176
 
177
177
  <!-- /.references -->
178
178
 
179
+ <!-- Section for related `stdlib` packages. Do not manually edit this section, as it is automatically populated. -->
180
+
181
+ <section class="related">
182
+
183
+ </section>
184
+
185
+ <!-- /.related -->
186
+
179
187
  <!-- Section for all links. Make sure to keep an empty line after the `section` element and another before the `/section` close. -->
180
188
 
181
189
 
@@ -202,7 +210,7 @@ See [LICENSE][stdlib-license].
202
210
 
203
211
  ## Copyright
204
212
 
205
- Copyright &copy; 2016-2021. The Stdlib [Authors][stdlib-authors].
213
+ Copyright &copy; 2016-2022. The Stdlib [Authors][stdlib-authors].
206
214
 
207
215
  </section>
208
216
 
@@ -221,9 +229,20 @@ Copyright &copy; 2016-2021. The Stdlib [Authors][stdlib-authors].
221
229
  [coverage-image]: https://img.shields.io/codecov/c/github/stdlib-js/ndarray-base-dtypes2signatures/main.svg
222
230
  [coverage-url]: https://codecov.io/github/stdlib-js/ndarray-base-dtypes2signatures?branch=main
223
231
 
232
+ <!--
233
+
224
234
  [dependencies-image]: https://img.shields.io/david/stdlib-js/ndarray-base-dtypes2signatures.svg
225
235
  [dependencies-url]: https://david-dm.org/stdlib-js/ndarray-base-dtypes2signatures/main
226
236
 
237
+ -->
238
+
239
+ [umd]: https://github.com/umdjs/umd
240
+ [es-module]: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Guide/Modules
241
+
242
+ [deno-url]: https://github.com/stdlib-js/ndarray-base-dtypes2signatures/tree/deno
243
+ [umd-url]: https://github.com/stdlib-js/ndarray-base-dtypes2signatures/tree/umd
244
+ [esm-url]: https://github.com/stdlib-js/ndarray-base-dtypes2signatures/tree/esm
245
+
227
246
  [chat-image]: https://img.shields.io/gitter/room/stdlib-js/stdlib.svg
228
247
  [chat-url]: https://gitter.im/stdlib-js/stdlib/
229
248
 
package/docs/repl.txt CHANGED
@@ -4,7 +4,7 @@
4
4
 
5
5
  Parameters
6
6
  ----------
7
- dtypes: Array<string>
7
+ dtypes: ArrayLike
8
8
  List of array argument data types.
9
9
 
10
10
  nin: integer
@@ -28,7 +28,7 @@ import { ArrayLike } from '@stdlib/types/array';
28
28
  * @param dtypes - list of array argument data types
29
29
  * @param nin - number of input array arguments
30
30
  * @param nout - number of output array arguments
31
- * @throws first argument must be an array-like object containing strings
31
+ * @throws first argument must be an array-like object
32
32
  * @throws second argument must be a nonnegative integer
33
33
  * @throws third argument must be a nonnegative integer
34
34
  * @throws first argument must have at least one element
@@ -44,7 +44,7 @@ import { ArrayLike } from '@stdlib/types/array';
44
44
  * var sigs = dtypes2signatures( dtypes, 1, 1 );
45
45
  * // returns [ '(float64) => (float64)', '(float32) => (float32)' ]
46
46
  */
47
- declare function dtypes2signatures( dtypes: ArrayLike<string>, nin: number, nout: number ): ArrayLike<string>; // tslint:disable-line:max-line-length
47
+ declare function dtypes2signatures( dtypes: ArrayLike<any>, nin: number, nout: number ): ArrayLike<string>; // tslint:disable-line:max-line-length
48
48
 
49
49
 
50
50
  // EXPORTS //
@@ -26,7 +26,7 @@ import dtypes2signatures = require( './index' );
26
26
  dtypes2signatures( [ 'float64', 'float64' ], 1, 1 ); // $ExpectType ArrayLike<string>
27
27
  }
28
28
 
29
- // The compiler throws an error if the function is provided a first argument which is not an array-like object containing strings...
29
+ // The compiler throws an error if the function is provided a first argument which is not an array-like object...
30
30
  {
31
31
  dtypes2signatures( 5, 1, 1 ); // $ExpectError
32
32
  dtypes2signatures( true, 1, 1 ); // $ExpectError
@@ -34,7 +34,6 @@ import dtypes2signatures = require( './index' );
34
34
  dtypes2signatures( null, 1, 1 ); // $ExpectError
35
35
  dtypes2signatures( undefined, 1, 1 ); // $ExpectError
36
36
  dtypes2signatures( {}, 1, 1 ); // $ExpectError
37
- dtypes2signatures( ( x: number ): number => x, 1, 1 ); // $ExpectError
38
37
  }
39
38
 
40
39
  // The compiler throws an error if the function is provided a second argument which is not a number...
package/lib/main.js CHANGED
@@ -21,8 +21,8 @@
21
21
  // MODULES //
22
22
 
23
23
  var isArrayLikeObject = require( '@stdlib/assert-is-array-like-object' );
24
- var isString = require( '@stdlib/assert-is-string' ).isPrimitive;
25
24
  var isNonNegativeInteger = require( '@stdlib/assert-is-nonnegative-integer' ).isPrimitive;
25
+ var resolve = require( '@stdlib/ndarray-base-dtype-resolve-str' );
26
26
 
27
27
 
28
28
  // MAIN //
@@ -30,10 +30,10 @@ var isNonNegativeInteger = require( '@stdlib/assert-is-nonnegative-integer' ).is
30
30
  /**
31
31
  * Transforms a list of array argument data types into a list of signatures.
32
32
  *
33
- * @param {StringArray} dtypes - list of array argument data types
33
+ * @param {ArrayLikeObject} dtypes - list of array argument data types
34
34
  * @param {NonNegativeInteger} nin - number of input array arguments
35
35
  * @param {NonNegativeInteger} nout - number of output array arguments
36
- * @throws {TypeError} first argument must be an array-like object containing strings
36
+ * @throws {TypeError} first argument must be an array-like object
37
37
  * @throws {TypeError} second argument must be a nonnegative integer
38
38
  * @throws {TypeError} third argument must be a nonnegative integer
39
39
  * @throws {RangeError} first argument must have at least one element
@@ -53,13 +53,14 @@ function dtypes2signatures( dtypes, nin, nout ) {
53
53
  var len;
54
54
  var out;
55
55
  var tmp;
56
+ var dt;
56
57
  var N;
57
58
  var M;
58
59
  var i;
59
60
  var m;
60
61
 
61
62
  if ( !isArrayLikeObject( dtypes ) ) {
62
- throw new TypeError( 'invalid argument. First argument must be an array-like object containing strings. Value: `' + dtypes + '`.' );
63
+ throw new TypeError( 'invalid argument. First argument must be an array-like object. Value: `' + dtypes + '`.' );
63
64
  }
64
65
  if ( !isNonNegativeInteger( nin ) ) {
65
66
  throw new TypeError( 'invalid argument. Second argument must be a nonnegative integer. Value: `' + nin + '`.' );
@@ -105,11 +106,12 @@ function dtypes2signatures( dtypes, nin, nout ) {
105
106
  }
106
107
  }
107
108
  for ( i = 0; i < len; i++ ) {
108
- if ( !isString( dtypes[ i ] ) ) {
109
- throw new TypeError( 'invalid argument. First argument must be an array-like object containing strings. Value: `' + dtypes + '`.' );
109
+ dt = resolve( dtypes[ i ] );
110
+ if ( dt === null ) {
111
+ dt = dtypes[ i ];
110
112
  }
111
113
  m = i % N;
112
- tmp[ (2*m)+1 ] = dtypes[ i ];
114
+ tmp[ (2*m)+1 ] = dt;
113
115
  if ( m === N-1 ) {
114
116
  out.push( tmp.join( '' ) );
115
117
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@stdlib/ndarray-base-dtypes2signatures",
3
- "version": "0.0.6",
3
+ "version": "0.0.7",
4
4
  "description": "Transform a list of array argument data types into a list of signatures.",
5
5
  "license": "Apache-2.0",
6
6
  "author": {
@@ -39,7 +39,7 @@
39
39
  "dependencies": {
40
40
  "@stdlib/assert-is-array-like-object": "^0.0.x",
41
41
  "@stdlib/assert-is-nonnegative-integer": "^0.0.x",
42
- "@stdlib/assert-is-string": "^0.0.x",
42
+ "@stdlib/ndarray-base-dtype-resolve-str": "^0.0.x",
43
43
  "@stdlib/types": "^0.0.x"
44
44
  },
45
45
  "devDependencies": {