@stdlib/ndarray-base-bytes-per-element 0.2.2 → 0.3.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/NOTICE CHANGED
@@ -1 +1 @@
1
- Copyright (c) 2016-2024 The Stdlib Authors.
1
+ Copyright (c) 2016-2026 The Stdlib Authors.
package/README.md CHANGED
@@ -33,7 +33,7 @@ limitations under the License.
33
33
 
34
34
  [![NPM version][npm-image]][npm-url] [![Build Status][test-image]][test-url] [![Coverage Status][coverage-image]][coverage-url] <!-- [![dependencies][dependencies-image]][dependencies-url] -->
35
35
 
36
- > Return the number of bytes per element provided an underlying [array data type][@stdlib/ndarray/dtypes].
36
+ > Return the number of bytes per element for a provided underlying [ndarray data type][@stdlib/ndarray/dtypes].
37
37
 
38
38
  <!-- Section to include introductory text. Make sure to keep an empty line after the intro `section` element and another before the `/section` close. -->
39
39
 
@@ -65,7 +65,7 @@ var bytesPerElement = require( '@stdlib/ndarray-base-bytes-per-element' );
65
65
 
66
66
  #### bytesPerElement( dtype )
67
67
 
68
- Returns the number of bytes per element provided an underlying [array data type][@stdlib/ndarray/dtypes].
68
+ Returns the number of bytes per element for a provided underlying [ndarray data type][@stdlib/ndarray/dtypes].
69
69
 
70
70
  ```javascript
71
71
  var nbytes = bytesPerElement( 'float64' );
@@ -105,11 +105,7 @@ var nbytes = bytesPerElement( 'foobar' );
105
105
  ```javascript
106
106
  var bytesPerElement = require( '@stdlib/ndarray-base-bytes-per-element' );
107
107
 
108
- var dtypes;
109
- var nbytes;
110
- var i;
111
-
112
- dtypes = [
108
+ var dtypes = [
113
109
  'float64',
114
110
  'float32',
115
111
  'int8',
@@ -124,6 +120,8 @@ dtypes = [
124
120
  'foobar'
125
121
  ];
126
122
 
123
+ var nbytes;
124
+ var i;
127
125
  for ( i = 0; i < dtypes.length; i++ ) {
128
126
  nbytes = bytesPerElement( dtypes[ i ] );
129
127
  nbytes = ( nbytes ) ? nbytes+' bytes' : 'null';
@@ -177,7 +175,7 @@ See [LICENSE][stdlib-license].
177
175
 
178
176
  ## Copyright
179
177
 
180
- Copyright &copy; 2016-2024. The Stdlib [Authors][stdlib-authors].
178
+ Copyright &copy; 2016-2026. The Stdlib [Authors][stdlib-authors].
181
179
 
182
180
  </section>
183
181
 
@@ -190,8 +188,8 @@ Copyright &copy; 2016-2024. The Stdlib [Authors][stdlib-authors].
190
188
  [npm-image]: http://img.shields.io/npm/v/@stdlib/ndarray-base-bytes-per-element.svg
191
189
  [npm-url]: https://npmjs.org/package/@stdlib/ndarray-base-bytes-per-element
192
190
 
193
- [test-image]: https://github.com/stdlib-js/ndarray-base-bytes-per-element/actions/workflows/test.yml/badge.svg?branch=v0.2.2
194
- [test-url]: https://github.com/stdlib-js/ndarray-base-bytes-per-element/actions/workflows/test.yml?query=branch:v0.2.2
191
+ [test-image]: https://github.com/stdlib-js/ndarray-base-bytes-per-element/actions/workflows/test.yml/badge.svg?branch=v0.3.0
192
+ [test-url]: https://github.com/stdlib-js/ndarray-base-bytes-per-element/actions/workflows/test.yml?query=branch:v0.3.0
195
193
 
196
194
  [coverage-image]: https://img.shields.io/codecov/c/github/stdlib-js/ndarray-base-bytes-per-element/main.svg
197
195
  [coverage-url]: https://codecov.io/github/stdlib-js/ndarray-base-bytes-per-element?branch=main
@@ -203,8 +201,8 @@ Copyright &copy; 2016-2024. The Stdlib [Authors][stdlib-authors].
203
201
 
204
202
  -->
205
203
 
206
- [chat-image]: https://img.shields.io/gitter/room/stdlib-js/stdlib.svg
207
- [chat-url]: https://app.gitter.im/#/room/#stdlib-js_stdlib:gitter.im
204
+ [chat-image]: https://img.shields.io/badge/zulip-join_chat-brightgreen.svg
205
+ [chat-url]: https://stdlib.zulipchat.com
208
206
 
209
207
  [stdlib]: https://github.com/stdlib-js/stdlib
210
208
 
package/dist/index.js CHANGED
@@ -1,5 +1,5 @@
1
- "use strict";var i=function(n,t){return function(){return t||n((t={exports:{}}).exports,t),t.exports}};var e=i(function(f,l){l.exports={binary:1,bool:1,complex64:8,complex128:16,float16:2,bfloat16:2,float32:4,float64:8,float128:16,generic:null,int8:1,int16:2,int32:4,int64:8,int128:16,int256:32,uint8:1,uint8c:1,uint16:2,uint32:4,uint64:8,uint128:16,uint256:32}});var u=i(function(E,r){
2
- var o=e();function a(n){return o[n]||null}r.exports=a
3
- });var c=u();module.exports=c;
1
+ "use strict";var t=function(i,r){return function(){return r||i((r={exports:{}}).exports,r),r.exports}};var e=t(function(q,s){s.exports={binary:1,bool:1,complex64:8,complex128:16,float16:2,bfloat16:2,float32:4,float64:8,float128:16,generic:null,int8:1,int16:2,int32:4,int64:8,int128:16,int256:32,uint8:1,uint8c:1,uint16:2,uint32:4,uint64:8,uint128:16,uint256:32}});var l=t(function(E,u){
2
+ var a=require('@stdlib/assert-is-string/dist').isPrimitive,o=require('@stdlib/assert-is-number/dist').isPrimitive,v=require('@stdlib/assert-is-positive-integer/dist').isPrimitive,f=require('@stdlib/ndarray-base-dtype-enum2str/dist'),n=e();function m(i){var r;return a(i)?n[i]||null:o(i)?n[f(i)]||null:i&&(r=i.byteLength,v(r))?r:null}u.exports=m
3
+ });var c=l();module.exports=c;
4
4
  /** @license Apache-2.0 */
5
5
  //# sourceMappingURL=index.js.map
package/dist/index.js.map CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "version": 3,
3
3
  "sources": ["../lib/bytes_per_element.json", "../lib/main.js", "../lib/index.js"],
4
- "sourcesContent": ["{\n\t\"binary\": 1,\n\t\"bool\": 1,\n\t\"complex64\": 8,\n\t\"complex128\": 16,\n\t\"float16\": 2,\n\t\"bfloat16\": 2,\n\t\"float32\": 4,\n\t\"float64\": 8,\n\t\"float128\": 16,\n\t\"generic\": null,\n\t\"int8\": 1,\n\t\"int16\": 2,\n\t\"int32\": 4,\n\t\"int64\": 8,\n\t\"int128\": 16,\n\t\"int256\": 32,\n\t\"uint8\": 1,\n\t\"uint8c\": 1,\n\t\"uint16\": 2,\n\t\"uint32\": 4,\n\t\"uint64\": 8,\n\t\"uint128\": 16,\n\t\"uint256\": 32\n}\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 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 BYTES_PER_ELEMENT = require( './bytes_per_element.json' );\n\n\n// MAIN //\n\n/**\n* Returns the number of bytes per element provided an underlying array data type.\n*\n* @param {string} dtype - data type\n* @returns {(NonNegativeInteger|null)} number of bytes per element\n*\n* @example\n* var nbytes = bytesPerElement( 'float64' );\n* // returns 8\n*\n* nbytes = bytesPerElement( 'generic' );\n* // returns null\n*/\nfunction bytesPerElement( dtype ) {\n\treturn BYTES_PER_ELEMENT[ dtype ] || null;\n}\n\n\n// EXPORTS //\n\nmodule.exports = bytesPerElement;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 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* Return the number of bytes per element provided an underlying array data type.\n*\n* @module @stdlib/ndarray-base-bytes-per-element\n*\n* @example\n* var bytesPerElement = require( '@stdlib/ndarray-base-bytes-per-element' );\n*\n* var nbytes = bytesPerElement( 'float64' );\n* // returns 8\n*\n* nbytes = bytesPerElement( 'generic' );\n* // returns null\n*/\n\n// MODULES //\n\nvar main = require( './main.js' );\n\n\n// EXPORTS //\n\nmodule.exports = main;\n"],
5
- "mappings": "uGAAA,IAAAA,EAAAC,EAAA,SAAAC,EAAAC,EAAA,CAAAA,EAAA,SACC,OAAU,EACV,KAAQ,EACR,UAAa,EACb,WAAc,GACd,QAAW,EACX,SAAY,EACZ,QAAW,EACX,QAAW,EACX,SAAY,GACZ,QAAW,KACX,KAAQ,EACR,MAAS,EACT,MAAS,EACT,MAAS,EACT,OAAU,GACV,OAAU,GACV,MAAS,EACT,OAAU,EACV,OAAU,EACV,OAAU,EACV,OAAU,EACV,QAAW,GACX,QAAW,EACZ,ICxBA,IAAAC,EAAAC,EAAA,SAAAC,EAAAC,EAAA,cAsBA,IAAIC,EAAoB,IAkBxB,SAASC,EAAiBC,EAAQ,CACjC,OAAOF,EAAmBE,CAAM,GAAK,IACtC,CAKAH,EAAO,QAAUE,ICVjB,IAAIE,EAAO,IAKX,OAAO,QAAUA",
6
- "names": ["require_bytes_per_element", "__commonJSMin", "exports", "module", "require_main", "__commonJSMin", "exports", "module", "BYTES_PER_ELEMENT", "bytesPerElement", "dtype", "main"]
4
+ "sourcesContent": ["{\n \"binary\": 1,\n \"bool\": 1,\n \"complex64\": 8,\n \"complex128\": 16,\n \"float16\": 2,\n \"bfloat16\": 2,\n \"float32\": 4,\n \"float64\": 8,\n \"float128\": 16,\n \"generic\": null,\n \"int8\": 1,\n \"int16\": 2,\n \"int32\": 4,\n \"int64\": 8,\n \"int128\": 16,\n \"int256\": 32,\n \"uint8\": 1,\n \"uint8c\": 1,\n \"uint16\": 2,\n \"uint32\": 4,\n \"uint64\": 8,\n \"uint128\": 16,\n \"uint256\": 32\n}\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 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 isNumber = require( '@stdlib/assert-is-number' ).isPrimitive;\nvar isPositiveInteger = require( '@stdlib/assert-is-positive-integer' ).isPrimitive;\nvar enum2str = require( '@stdlib/ndarray-base-dtype-enum2str' );\nvar BYTES_PER_ELEMENT = require( './bytes_per_element.json' );\n\n\n// MAIN //\n\n/**\n* Returns the number of bytes per element for a provided underlying ndarray data type.\n*\n* @param {*} dtype - data type\n* @returns {(PositiveInteger|null)} number of bytes per element\n*\n* @example\n* var nbytes = bytesPerElement( 'float64' );\n* // returns 8\n*\n* nbytes = bytesPerElement( 'generic' );\n* // returns null\n*\n* @example\n* var structFactory = require( '@stdlib/dstructs-struct' );\n*\n* var schema = [\n* {\n* 'name': 'value',\n* 'type': 'float64'\n* }\n* ];\n* var Struct = structFactory( schema );\n* // returns <Function>\n*\n* var nbytes = bytesPerElement( Struct );\n* // returns 8\n*/\nfunction bytesPerElement( dtype ) {\n\tvar v;\n\tif ( isString( dtype ) ) {\n\t\treturn BYTES_PER_ELEMENT[ dtype ] || null;\n\t}\n\tif ( isNumber( dtype ) ) {\n\t\treturn BYTES_PER_ELEMENT[ enum2str( dtype ) ] || null;\n\t}\n\tif ( dtype ) {\n\t\tv = dtype.byteLength;\n\t\tif ( isPositiveInteger( v ) ) {\n\t\t\treturn v;\n\t\t}\n\t}\n\treturn null;\n}\n\n\n// EXPORTS //\n\nmodule.exports = bytesPerElement;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 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* Return the number of bytes per element for a provided underlying ndarray data type.\n*\n* @module @stdlib/ndarray-base-bytes-per-element\n*\n* @example\n* var bytesPerElement = require( '@stdlib/ndarray-base-bytes-per-element' );\n*\n* var nbytes = bytesPerElement( 'float64' );\n* // returns 8\n*\n* nbytes = bytesPerElement( 'generic' );\n* // returns null\n*/\n\n// MODULES //\n\nvar main = require( './main.js' );\n\n\n// EXPORTS //\n\nmodule.exports = main;\n"],
5
+ "mappings": "uGAAA,IAAAA,EAAAC,EAAA,SAAAC,EAAAC,EAAA,CAAAA,EAAA,SACE,OAAU,EACV,KAAQ,EACR,UAAa,EACb,WAAc,GACd,QAAW,EACX,SAAY,EACZ,QAAW,EACX,QAAW,EACX,SAAY,GACZ,QAAW,KACX,KAAQ,EACR,MAAS,EACT,MAAS,EACT,MAAS,EACT,OAAU,GACV,OAAU,GACV,MAAS,EACT,OAAU,EACV,OAAU,EACV,OAAU,EACV,OAAU,EACV,QAAW,GACX,QAAW,EACb,ICxBA,IAAAC,EAAAC,EAAA,SAAAC,EAAAC,EAAA,cAsBA,IAAIC,EAAW,QAAS,0BAA2B,EAAE,YACjDC,EAAW,QAAS,0BAA2B,EAAE,YACjDC,EAAoB,QAAS,oCAAqC,EAAE,YACpEC,EAAW,QAAS,qCAAsC,EAC1DC,EAAoB,IAiCxB,SAASC,EAAiBC,EAAQ,CACjC,IAAIC,EACJ,OAAKP,EAAUM,CAAM,EACbF,EAAmBE,CAAM,GAAK,KAEjCL,EAAUK,CAAM,EACbF,EAAmBD,EAAUG,CAAM,CAAE,GAAK,KAE7CA,IACJC,EAAID,EAAM,WACLJ,EAAmBK,CAAE,GAClBA,EAGF,IACR,CAKAR,EAAO,QAAUM,IC1CjB,IAAIG,EAAO,IAKX,OAAO,QAAUA",
6
+ "names": ["require_bytes_per_element", "__commonJSMin", "exports", "module", "require_main", "__commonJSMin", "exports", "module", "isString", "isNumber", "isPositiveInteger", "enum2str", "BYTES_PER_ELEMENT", "bytesPerElement", "dtype", "v", "main"]
7
7
  }
@@ -19,7 +19,7 @@
19
19
  // TypeScript Version: 4.1
20
20
 
21
21
  /**
22
- * Returns the number of bytes per element provided an underlying array data type.
22
+ * Returns the number of bytes per element for a provided underlying ndarray data type.
23
23
  *
24
24
  * @param dtype - data type
25
25
  * @returns number of bytes per element
@@ -31,7 +31,7 @@
31
31
  * nbytes = bytesPerElement( 'generic' );
32
32
  * // returns null
33
33
  */
34
- declare function bytesPerElement( dtype: string ): number | null;
34
+ declare function bytesPerElement( dtype: any ): number | null;
35
35
 
36
36
 
37
37
  // EXPORTS //
@@ -63,9 +63,9 @@ enum STDLIB_NDARRAY_BYTES_PER_ELEMENT {
63
63
  };
64
64
 
65
65
  /**
66
- * Returns the number of bytes per element for a given data type.
66
+ * Returns the number of bytes per element for a provided data type.
67
67
  */
68
- int64_t stdlib_ndarray_bytes_per_element( enum STDLIB_NDARRAY_DTYPE dtype );
68
+ int64_t stdlib_ndarray_bytes_per_element( const enum STDLIB_NDARRAY_DTYPE dtype );
69
69
 
70
70
  #ifdef __cplusplus
71
71
  }
@@ -1,25 +1,25 @@
1
1
  {
2
- "binary": 1,
3
- "bool": 1,
4
- "complex64": 8,
5
- "complex128": 16,
6
- "float16": 2,
7
- "bfloat16": 2,
8
- "float32": 4,
9
- "float64": 8,
10
- "float128": 16,
11
- "generic": null,
12
- "int8": 1,
13
- "int16": 2,
14
- "int32": 4,
15
- "int64": 8,
16
- "int128": 16,
17
- "int256": 32,
18
- "uint8": 1,
19
- "uint8c": 1,
20
- "uint16": 2,
21
- "uint32": 4,
22
- "uint64": 8,
23
- "uint128": 16,
24
- "uint256": 32
2
+ "binary": 1,
3
+ "bool": 1,
4
+ "complex64": 8,
5
+ "complex128": 16,
6
+ "float16": 2,
7
+ "bfloat16": 2,
8
+ "float32": 4,
9
+ "float64": 8,
10
+ "float128": 16,
11
+ "generic": null,
12
+ "int8": 1,
13
+ "int16": 2,
14
+ "int32": 4,
15
+ "int64": 8,
16
+ "int128": 16,
17
+ "int256": 32,
18
+ "uint8": 1,
19
+ "uint8c": 1,
20
+ "uint16": 2,
21
+ "uint32": 4,
22
+ "uint64": 8,
23
+ "uint128": 16,
24
+ "uint256": 32
25
25
  }
package/lib/index.js CHANGED
@@ -19,7 +19,7 @@
19
19
  'use strict';
20
20
 
21
21
  /**
22
- * Return the number of bytes per element provided an underlying array data type.
22
+ * Return the number of bytes per element for a provided underlying ndarray data type.
23
23
  *
24
24
  * @module @stdlib/ndarray-base-bytes-per-element
25
25
  *
package/lib/main.js CHANGED
@@ -20,16 +20,20 @@
20
20
 
21
21
  // MODULES //
22
22
 
23
+ var isString = require( '@stdlib/assert-is-string' ).isPrimitive;
24
+ var isNumber = require( '@stdlib/assert-is-number' ).isPrimitive;
25
+ var isPositiveInteger = require( '@stdlib/assert-is-positive-integer' ).isPrimitive;
26
+ var enum2str = require( '@stdlib/ndarray-base-dtype-enum2str' );
23
27
  var BYTES_PER_ELEMENT = require( './bytes_per_element.json' );
24
28
 
25
29
 
26
30
  // MAIN //
27
31
 
28
32
  /**
29
- * Returns the number of bytes per element provided an underlying array data type.
33
+ * Returns the number of bytes per element for a provided underlying ndarray data type.
30
34
  *
31
- * @param {string} dtype - data type
32
- * @returns {(NonNegativeInteger|null)} number of bytes per element
35
+ * @param {*} dtype - data type
36
+ * @returns {(PositiveInteger|null)} number of bytes per element
33
37
  *
34
38
  * @example
35
39
  * var nbytes = bytesPerElement( 'float64' );
@@ -37,9 +41,37 @@ var BYTES_PER_ELEMENT = require( './bytes_per_element.json' );
37
41
  *
38
42
  * nbytes = bytesPerElement( 'generic' );
39
43
  * // returns null
44
+ *
45
+ * @example
46
+ * var structFactory = require( '@stdlib/dstructs-struct' );
47
+ *
48
+ * var schema = [
49
+ * {
50
+ * 'name': 'value',
51
+ * 'type': 'float64'
52
+ * }
53
+ * ];
54
+ * var Struct = structFactory( schema );
55
+ * // returns <Function>
56
+ *
57
+ * var nbytes = bytesPerElement( Struct );
58
+ * // returns 8
40
59
  */
41
60
  function bytesPerElement( dtype ) {
42
- return BYTES_PER_ELEMENT[ dtype ] || null;
61
+ var v;
62
+ if ( isString( dtype ) ) {
63
+ return BYTES_PER_ELEMENT[ dtype ] || null;
64
+ }
65
+ if ( isNumber( dtype ) ) {
66
+ return BYTES_PER_ELEMENT[ enum2str( dtype ) ] || null;
67
+ }
68
+ if ( dtype ) {
69
+ v = dtype.byteLength;
70
+ if ( isPositiveInteger( v ) ) {
71
+ return v;
72
+ }
73
+ }
74
+ return null;
43
75
  }
44
76
 
45
77
 
package/manifest.json CHANGED
@@ -1,40 +1,40 @@
1
1
  {
2
- "options": {},
3
- "fields": [
4
- {
5
- "field": "src",
6
- "resolve": true,
7
- "relative": true
8
- },
9
- {
10
- "field": "include",
11
- "resolve": true,
12
- "relative": true
13
- },
14
- {
15
- "field": "libraries",
16
- "resolve": false,
17
- "relative": false
18
- },
19
- {
20
- "field": "libpath",
21
- "resolve": true,
22
- "relative": false
23
- }
24
- ],
25
- "confs": [
26
- {
27
- "src": [
28
- "./src/main.c"
29
- ],
30
- "include": [
31
- "./include"
32
- ],
33
- "libraries": [],
34
- "libpath": [],
35
- "dependencies": [
36
- "@stdlib/ndarray-dtypes"
37
- ]
38
- }
39
- ]
2
+ "options": {},
3
+ "fields": [
4
+ {
5
+ "field": "src",
6
+ "resolve": true,
7
+ "relative": true
8
+ },
9
+ {
10
+ "field": "include",
11
+ "resolve": true,
12
+ "relative": true
13
+ },
14
+ {
15
+ "field": "libraries",
16
+ "resolve": false,
17
+ "relative": false
18
+ },
19
+ {
20
+ "field": "libpath",
21
+ "resolve": true,
22
+ "relative": false
23
+ }
24
+ ],
25
+ "confs": [
26
+ {
27
+ "src": [
28
+ "./src/main.c"
29
+ ],
30
+ "include": [
31
+ "./include"
32
+ ],
33
+ "libraries": [],
34
+ "libpath": [],
35
+ "dependencies": [
36
+ "@stdlib/ndarray-dtypes"
37
+ ]
38
+ }
39
+ ]
40
40
  }
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@stdlib/ndarray-base-bytes-per-element",
3
- "version": "0.2.2",
4
- "description": "Return the number of bytes per element provided an underlying array data type.",
3
+ "version": "0.3.0",
4
+ "description": "Return the number of bytes per element for a provided underlying ndarray data type.",
5
5
  "license": "Apache-2.0",
6
6
  "author": {
7
7
  "name": "The Stdlib Authors",
@@ -32,7 +32,11 @@
32
32
  "url": "https://github.com/stdlib-js/stdlib/issues"
33
33
  },
34
34
  "dependencies": {
35
- "@stdlib/ndarray-dtypes": "^0.2.1"
35
+ "@stdlib/assert-is-number": "^0.2.2",
36
+ "@stdlib/assert-is-positive-integer": "^0.2.2",
37
+ "@stdlib/assert-is-string": "^0.2.2",
38
+ "@stdlib/ndarray-base-dtype-enum2str": "^0.2.2",
39
+ "@stdlib/ndarray-dtypes": "^0.3.0"
36
40
  },
37
41
  "devDependencies": {},
38
42
  "engines": {
@@ -68,7 +72,6 @@
68
72
  "utils",
69
73
  "util"
70
74
  ],
71
- "__stdlib__": {},
72
75
  "funding": {
73
76
  "type": "opencollective",
74
77
  "url": "https://opencollective.com/stdlib"
package/src/main.c CHANGED
@@ -21,7 +21,7 @@
21
21
  #include <stdint.h>
22
22
 
23
23
  /**
24
- * Returns the number of bytes per element for a given data type.
24
+ * Returns the number of bytes per element for a provided data type.
25
25
  *
26
26
  * ## Notes
27
27
  *
@@ -38,7 +38,7 @@
38
38
  * int64_t nbytes = stdlib_ndarray_bytes_per_element( STDLIB_NDARRAY_FLOAT64 );
39
39
  * // returns 8
40
40
  */
41
- int64_t stdlib_ndarray_bytes_per_element( enum STDLIB_NDARRAY_DTYPE dtype ) {
41
+ int64_t stdlib_ndarray_bytes_per_element( const enum STDLIB_NDARRAY_DTYPE dtype ) {
42
42
  switch ( dtype ) {
43
43
  case STDLIB_NDARRAY_FLOAT64:
44
44
  return STDLIB_NDARRAY_FLOAT64_BYTES_PER_ELEMENT;