@stdlib/ndarray-base-buffer-ctors 0.2.1 → 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/README.md CHANGED
@@ -2,7 +2,7 @@
2
2
 
3
3
  @license Apache-2.0
4
4
 
5
- Copyright (c) 2018 The Stdlib Authors.
5
+ Copyright (c) 2024 The Stdlib Authors.
6
6
 
7
7
  Licensed under the Apache License, Version 2.0 (the "License");
8
8
  you may not use this file except in compliance with the License.
@@ -65,30 +65,14 @@ var ctors = require( '@stdlib/ndarray-base-buffer-ctors' );
65
65
 
66
66
  #### ctors( dtype )
67
67
 
68
- Returns an ndarray data buffer constructor for a specified data type.
68
+ Returns an ndarray data buffer constructor for a specified [data type][@stdlib/ndarray/dtypes].
69
69
 
70
70
  ```javascript
71
71
  var ctor = ctors( 'float64' );
72
72
  // returns <Function>
73
73
  ```
74
74
 
75
- The function returns constructors for the following data types:
76
-
77
- - `binary`: binary.
78
- - `complex64`: single-precision complex floating-point numbers.
79
- - `complex128`: double-precision complex floating-point numbers.
80
- - `float32`: single-precision floating-point numbers.
81
- - `float64`: double-precision floating-point numbers.
82
- - `generic`: values of any type.
83
- - `int16`: signed 16-bit integers.
84
- - `int32`: signed 32-bit integers.
85
- - `int8`: signed 8-bit integers.
86
- - `uint16`: unsigned 16-bit integers.
87
- - `uint32`: unsigned 32-bit integers.
88
- - `uint8`: unsigned 8-bit integers.
89
- - `uint8c`: unsigned clamped 8-bit integers.
90
-
91
- If provided an unknown or unsupported data type, the function returns `null`.
75
+ If provided an unknown or unsupported [data type][@stdlib/ndarray/dtypes], the function returns `null`.
92
76
 
93
77
  ```javascript
94
78
  var ctor = ctors( 'float' );
@@ -120,9 +104,9 @@ var dtypes = require( '@stdlib/ndarray-dtypes' );
120
104
  var ctors = require( '@stdlib/ndarray-base-buffer-ctors' );
121
105
 
122
106
  var DTYPES = dtypes();
107
+
123
108
  var ctor;
124
109
  var i;
125
-
126
110
  for ( i = 0; i < DTYPES.length; i++ ) {
127
111
  ctor = ctors( DTYPES[ i ] );
128
112
  console.log( ctor );
@@ -188,8 +172,8 @@ Copyright &copy; 2016-2024. The Stdlib [Authors][stdlib-authors].
188
172
  [npm-image]: http://img.shields.io/npm/v/@stdlib/ndarray-base-buffer-ctors.svg
189
173
  [npm-url]: https://npmjs.org/package/@stdlib/ndarray-base-buffer-ctors
190
174
 
191
- [test-image]: https://github.com/stdlib-js/ndarray-base-buffer-ctors/actions/workflows/test.yml/badge.svg?branch=v0.2.1
192
- [test-url]: https://github.com/stdlib-js/ndarray-base-buffer-ctors/actions/workflows/test.yml?query=branch:v0.2.1
175
+ [test-image]: https://github.com/stdlib-js/ndarray-base-buffer-ctors/actions/workflows/test.yml/badge.svg?branch=v0.3.0
176
+ [test-url]: https://github.com/stdlib-js/ndarray-base-buffer-ctors/actions/workflows/test.yml?query=branch:v0.3.0
193
177
 
194
178
  [coverage-image]: https://img.shields.io/codecov/c/github/stdlib-js/ndarray-base-buffer-ctors/main.svg
195
179
  [coverage-url]: https://codecov.io/github/stdlib-js/ndarray-base-buffer-ctors?branch=main
@@ -221,6 +205,8 @@ Copyright &copy; 2016-2024. The Stdlib [Authors][stdlib-authors].
221
205
 
222
206
  [stdlib-license]: https://raw.githubusercontent.com/stdlib-js/ndarray-base-buffer-ctors/main/LICENSE
223
207
 
208
+ [@stdlib/ndarray/dtypes]: https://www.npmjs.com/package/@stdlib/ndarray-dtypes
209
+
224
210
  </section>
225
211
 
226
212
  <!-- /.links -->
package/dist/index.js CHANGED
@@ -1,7 +1,8 @@
1
1
  "use strict";var a=function(e,r){return function(){return r||e((r={exports:{}}).exports,r),r.exports}};var t=a(function(d,i){
2
- var v=require('@stdlib/buffer-ctor/dist'),o=require('@stdlib/array-float64/dist'),q=require('@stdlib/array-float32/dist'),y=require('@stdlib/array-int16/dist'),l=require('@stdlib/array-int32/dist'),A=require('@stdlib/array-int8/dist'),s=require('@stdlib/array-uint16/dist'),c=require('@stdlib/array-uint32/dist'),p=require('@stdlib/array-uint8/dist'),x=require('@stdlib/array-uint8c/dist'),m=require('@stdlib/array-complex64/dist'),f=require('@stdlib/array-complex128/dist'),U={binary:v,float64:o,float32:q,generic:Array,int16:y,int32:l,int8:A,uint16:s,uint32:c,uint8:p,uint8c:x,complex64:m,complex128:f};i.exports=U
2
+ var o=require('@stdlib/buffer-ctor/dist'),v=require('@stdlib/array-float64/dist'),q=require('@stdlib/array-float32/dist'),l=require('@stdlib/array-int16/dist'),y=require('@stdlib/array-int32/dist'),A=require('@stdlib/array-int8/dist'),s=require('@stdlib/array-uint16/dist'),c=require('@stdlib/array-uint32/dist'),p=require('@stdlib/array-uint8/dist'),x=require('@stdlib/array-uint8c/dist'),m=require('@stdlib/array-complex64/dist'),f=require('@stdlib/array-complex128/dist'),U=require('@stdlib/array-bool/dist'),b={binary:o,float64:v,float32:q,generic:Array,int16:l,int32:y,int8:A,uint16:s,uint32:c,uint8:p,uint8c:x,complex64:m,complex128:f,bool:U};i.exports=b
3
3
  });var n=a(function(g,u){
4
4
  var C=t();function I(e){return C[e]||null}u.exports=I
5
- });var b=n();module.exports=b;
5
+ });var B=n();module.exports=B;
6
+ /** @license Apache-2.0 */
6
7
  /** @license Apache-2.0 */
7
8
  //# sourceMappingURL=index.js.map
package/dist/index.js.map CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "version": 3,
3
3
  "sources": ["../lib/ctors.js", "../lib/main.js", "../lib/index.js"],
4
- "sourcesContent": ["/**\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 Buffer = require( '@stdlib/buffer-ctor' );\nvar Float64Array = require( '@stdlib/array-float64' );\nvar Float32Array = require( '@stdlib/array-float32' );\nvar Int16Array = require( '@stdlib/array-int16' );\nvar Int32Array = require( '@stdlib/array-int32' );\nvar Int8Array = require( '@stdlib/array-int8' );\nvar Uint16Array = require( '@stdlib/array-uint16' );\nvar Uint32Array = require( '@stdlib/array-uint32' );\nvar Uint8Array = require( '@stdlib/array-uint8' );\nvar Uint8ClampedArray = require( '@stdlib/array-uint8c' );\nvar Complex64Array = require( '@stdlib/array-complex64' );\nvar Complex128Array = require( '@stdlib/array-complex128' );\n\n\n// MAIN //\n\n// Mapping from data types to underlying buffer constructors...\nvar ctors = {\n\t'binary': Buffer,\n\t'float64': Float64Array,\n\t'float32': Float32Array,\n\t'generic': Array, // TODO: replace with `stdlib` pkg\n\t'int16': Int16Array,\n\t'int32': Int32Array,\n\t'int8': Int8Array,\n\t'uint16': Uint16Array,\n\t'uint32': Uint32Array,\n\t'uint8': Uint8Array,\n\t'uint8c': Uint8ClampedArray,\n\t'complex64': Complex64Array,\n\t'complex128': Complex128Array\n};\n\n\n// EXPORTS //\n\nmodule.exports = ctors;\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 table = require( './ctors.js' );\n\n\n// MAIN //\n\n/**\n* Returns an ndarray data buffer constructor.\n*\n* @param {string} dtype - data type\n* @returns {(Function|null)} data buffer constructor or null\n*\n* @example\n* var ctor = ctors( 'float64' );\n* // returns <Function>\n*\n* @example\n* var ctor = ctors( 'float' );\n* // returns null\n*/\nfunction ctors( dtype ) {\n\treturn table[ dtype ] || null;\n}\n\n\n// EXPORTS //\n\nmodule.exports = ctors;\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* ndarray data buffer constructors.\n*\n* @module @stdlib/ndarray-base-buffer-ctors\n*\n* @example\n* var ctors = require( '@stdlib/ndarray-base-buffer-ctors' );\n*\n* var ctor = ctors( 'float64' );\n* // returns <Function>\n*\n* ctor = ctors( 'int' );\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,cAsBA,IAAIC,EAAS,QAAS,qBAAsB,EACxCC,EAAe,QAAS,uBAAwB,EAChDC,EAAe,QAAS,uBAAwB,EAChDC,EAAa,QAAS,qBAAsB,EAC5CC,EAAa,QAAS,qBAAsB,EAC5CC,EAAY,QAAS,oBAAqB,EAC1CC,EAAc,QAAS,sBAAuB,EAC9CC,EAAc,QAAS,sBAAuB,EAC9CC,EAAa,QAAS,qBAAsB,EAC5CC,EAAoB,QAAS,sBAAuB,EACpDC,EAAiB,QAAS,yBAA0B,EACpDC,EAAkB,QAAS,0BAA2B,EAMtDC,EAAQ,CACX,OAAUZ,EACV,QAAWC,EACX,QAAWC,EACX,QAAW,MACX,MAASC,EACT,MAASC,EACT,KAAQC,EACR,OAAUC,EACV,OAAUC,EACV,MAASC,EACT,OAAUC,EACV,UAAaC,EACb,WAAcC,CACf,EAKAZ,EAAO,QAAUa,IC1DjB,IAAAC,EAAAC,EAAA,SAAAC,EAAAC,EAAA,cAsBA,IAAIC,EAAQ,IAmBZ,SAASC,EAAOC,EAAQ,CACvB,OAAOF,EAAOE,CAAM,GAAK,IAC1B,CAKAH,EAAO,QAAUE,ICXjB,IAAIE,EAAO,IAKX,OAAO,QAAUA",
6
- "names": ["require_ctors", "__commonJSMin", "exports", "module", "Buffer", "Float64Array", "Float32Array", "Int16Array", "Int32Array", "Int8Array", "Uint16Array", "Uint32Array", "Uint8Array", "Uint8ClampedArray", "Complex64Array", "Complex128Array", "ctors", "require_main", "__commonJSMin", "exports", "module", "table", "ctors", "dtype", "main"]
4
+ "sourcesContent": ["/**\n* @license Apache-2.0\n*\n* Copyright (c) 2024 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 Buffer = require( '@stdlib/buffer-ctor' );\nvar Float64Array = require( '@stdlib/array-float64' );\nvar Float32Array = require( '@stdlib/array-float32' );\nvar Int16Array = require( '@stdlib/array-int16' );\nvar Int32Array = require( '@stdlib/array-int32' );\nvar Int8Array = require( '@stdlib/array-int8' );\nvar Uint16Array = require( '@stdlib/array-uint16' );\nvar Uint32Array = require( '@stdlib/array-uint32' );\nvar Uint8Array = require( '@stdlib/array-uint8' );\nvar Uint8ClampedArray = require( '@stdlib/array-uint8c' );\nvar Complex64Array = require( '@stdlib/array-complex64' );\nvar Complex128Array = require( '@stdlib/array-complex128' );\nvar BooleanArray = require( '@stdlib/array-bool' );\n\n\n// MAIN //\n\n// Mapping from data types to underlying buffer constructors...\nvar ctors = {\n\t'binary': Buffer,\n\t'float64': Float64Array,\n\t'float32': Float32Array,\n\t'generic': Array, // TODO: replace with `stdlib` pkg\n\t'int16': Int16Array,\n\t'int32': Int32Array,\n\t'int8': Int8Array,\n\t'uint16': Uint16Array,\n\t'uint32': Uint32Array,\n\t'uint8': Uint8Array,\n\t'uint8c': Uint8ClampedArray,\n\t'complex64': Complex64Array,\n\t'complex128': Complex128Array,\n\t'bool': BooleanArray\n};\n\n\n// EXPORTS //\n\nmodule.exports = ctors;\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 table = require( './ctors.js' );\n\n\n// MAIN //\n\n/**\n* Returns an ndarray data buffer constructor.\n*\n* @param {string} dtype - data type\n* @returns {(Function|null)} data buffer constructor or null\n*\n* @example\n* var ctor = ctors( 'float64' );\n* // returns <Function>\n*\n* @example\n* var ctor = ctors( 'float' );\n* // returns null\n*/\nfunction ctors( dtype ) {\n\treturn table[ dtype ] || null;\n}\n\n\n// EXPORTS //\n\nmodule.exports = ctors;\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* ndarray data buffer constructors.\n*\n* @module @stdlib/ndarray-base-buffer-ctors\n*\n* @example\n* var ctors = require( '@stdlib/ndarray-base-buffer-ctors' );\n*\n* var ctor = ctors( 'float64' );\n* // returns <Function>\n*\n* ctor = ctors( 'int' );\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,cAsBA,IAAIC,EAAS,QAAS,qBAAsB,EACxCC,EAAe,QAAS,uBAAwB,EAChDC,EAAe,QAAS,uBAAwB,EAChDC,EAAa,QAAS,qBAAsB,EAC5CC,EAAa,QAAS,qBAAsB,EAC5CC,EAAY,QAAS,oBAAqB,EAC1CC,EAAc,QAAS,sBAAuB,EAC9CC,EAAc,QAAS,sBAAuB,EAC9CC,EAAa,QAAS,qBAAsB,EAC5CC,EAAoB,QAAS,sBAAuB,EACpDC,EAAiB,QAAS,yBAA0B,EACpDC,EAAkB,QAAS,0BAA2B,EACtDC,EAAe,QAAS,oBAAqB,EAM7CC,EAAQ,CACX,OAAUb,EACV,QAAWC,EACX,QAAWC,EACX,QAAW,MACX,MAASC,EACT,MAASC,EACT,KAAQC,EACR,OAAUC,EACV,OAAUC,EACV,MAASC,EACT,OAAUC,EACV,UAAaC,EACb,WAAcC,EACd,KAAQC,CACT,EAKAb,EAAO,QAAUc,IC5DjB,IAAAC,EAAAC,EAAA,SAAAC,EAAAC,EAAA,cAsBA,IAAIC,EAAQ,IAmBZ,SAASC,EAAOC,EAAQ,CACvB,OAAOF,EAAOE,CAAM,GAAK,IAC1B,CAKAH,EAAO,QAAUE,ICXjB,IAAIE,EAAO,IAKX,OAAO,QAAUA",
6
+ "names": ["require_ctors", "__commonJSMin", "exports", "module", "Buffer", "Float64Array", "Float32Array", "Int16Array", "Int32Array", "Int8Array", "Uint16Array", "Uint32Array", "Uint8Array", "Uint8ClampedArray", "Complex64Array", "Complex128Array", "BooleanArray", "ctors", "require_main", "__commonJSMin", "exports", "module", "table", "ctors", "dtype", "main"]
7
7
  }
package/lib/ctors.js CHANGED
@@ -1,7 +1,7 @@
1
1
  /**
2
2
  * @license Apache-2.0
3
3
  *
4
- * Copyright (c) 2018 The Stdlib Authors.
4
+ * Copyright (c) 2024 The Stdlib Authors.
5
5
  *
6
6
  * Licensed under the Apache License, Version 2.0 (the "License");
7
7
  * you may not use this file except in compliance with the License.
@@ -32,6 +32,7 @@ var Uint8Array = require( '@stdlib/array-uint8' );
32
32
  var Uint8ClampedArray = require( '@stdlib/array-uint8c' );
33
33
  var Complex64Array = require( '@stdlib/array-complex64' );
34
34
  var Complex128Array = require( '@stdlib/array-complex128' );
35
+ var BooleanArray = require( '@stdlib/array-bool' );
35
36
 
36
37
 
37
38
  // MAIN //
@@ -50,7 +51,8 @@ var ctors = {
50
51
  'uint8': Uint8Array,
51
52
  'uint8c': Uint8ClampedArray,
52
53
  'complex64': Complex64Array,
53
- 'complex128': Complex128Array
54
+ 'complex128': Complex128Array,
55
+ 'bool': BooleanArray
54
56
  };
55
57
 
56
58
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@stdlib/ndarray-base-buffer-ctors",
3
- "version": "0.2.1",
3
+ "version": "0.3.0",
4
4
  "description": "ndarray data buffer constructors.",
5
5
  "license": "Apache-2.0",
6
6
  "author": {
@@ -30,18 +30,19 @@
30
30
  "url": "https://github.com/stdlib-js/stdlib/issues"
31
31
  },
32
32
  "dependencies": {
33
+ "@stdlib/array-bool": "^0.0.1",
33
34
  "@stdlib/array-complex128": "^0.2.1",
34
35
  "@stdlib/array-complex64": "^0.2.1",
35
- "@stdlib/array-float32": "^0.2.1",
36
- "@stdlib/array-float64": "^0.2.1",
37
- "@stdlib/array-int16": "^0.2.1",
38
- "@stdlib/array-int32": "^0.2.1",
39
- "@stdlib/array-int8": "^0.2.1",
40
- "@stdlib/array-uint16": "^0.2.1",
41
- "@stdlib/array-uint32": "^0.2.1",
42
- "@stdlib/array-uint8": "^0.2.1",
43
- "@stdlib/array-uint8c": "^0.2.1",
44
- "@stdlib/buffer-ctor": "^0.2.1"
36
+ "@stdlib/array-float32": "^0.2.2",
37
+ "@stdlib/array-float64": "^0.2.2",
38
+ "@stdlib/array-int16": "^0.2.2",
39
+ "@stdlib/array-int32": "^0.2.2",
40
+ "@stdlib/array-int8": "^0.2.2",
41
+ "@stdlib/array-uint16": "^0.2.2",
42
+ "@stdlib/array-uint32": "^0.2.2",
43
+ "@stdlib/array-uint8": "^0.2.2",
44
+ "@stdlib/array-uint8c": "^0.2.2",
45
+ "@stdlib/buffer-ctor": "^0.2.2"
45
46
  },
46
47
  "devDependencies": {},
47
48
  "engines": {