@stdlib/wasm-types 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/LICENSE ADDED
@@ -0,0 +1,177 @@
1
+
2
+ Apache License
3
+ Version 2.0, January 2004
4
+ http://www.apache.org/licenses/
5
+
6
+ TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
7
+
8
+ 1. Definitions.
9
+
10
+ "License" shall mean the terms and conditions for use, reproduction,
11
+ and distribution as defined by Sections 1 through 9 of this document.
12
+
13
+ "Licensor" shall mean the copyright owner or entity authorized by
14
+ the copyright owner that is granting the License.
15
+
16
+ "Legal Entity" shall mean the union of the acting entity and all
17
+ other entities that control, are controlled by, or are under common
18
+ control with that entity. For the purposes of this definition,
19
+ "control" means (i) the power, direct or indirect, to cause the
20
+ direction or management of such entity, whether by contract or
21
+ otherwise, or (ii) ownership of fifty percent (50%) or more of the
22
+ outstanding shares, or (iii) beneficial ownership of such entity.
23
+
24
+ "You" (or "Your") shall mean an individual or Legal Entity
25
+ exercising permissions granted by this License.
26
+
27
+ "Source" form shall mean the preferred form for making modifications,
28
+ including but not limited to software source code, documentation
29
+ source, and configuration files.
30
+
31
+ "Object" form shall mean any form resulting from mechanical
32
+ transformation or translation of a Source form, including but
33
+ not limited to compiled object code, generated documentation,
34
+ and conversions to other media types.
35
+
36
+ "Work" shall mean the work of authorship, whether in Source or
37
+ Object form, made available under the License, as indicated by a
38
+ copyright notice that is included in or attached to the work
39
+ (an example is provided in the Appendix below).
40
+
41
+ "Derivative Works" shall mean any work, whether in Source or Object
42
+ form, that is based on (or derived from) the Work and for which the
43
+ editorial revisions, annotations, elaborations, or other modifications
44
+ represent, as a whole, an original work of authorship. For the purposes
45
+ of this License, Derivative Works shall not include works that remain
46
+ separable from, or merely link (or bind by name) to the interfaces of,
47
+ the Work and Derivative Works thereof.
48
+
49
+ "Contribution" shall mean any work of authorship, including
50
+ the original version of the Work and any modifications or additions
51
+ to that Work or Derivative Works thereof, that is intentionally
52
+ submitted to Licensor for inclusion in the Work by the copyright owner
53
+ or by an individual or Legal Entity authorized to submit on behalf of
54
+ the copyright owner. For the purposes of this definition, "submitted"
55
+ means any form of electronic, verbal, or written communication sent
56
+ to the Licensor or its representatives, including but not limited to
57
+ communication on electronic mailing lists, source code control systems,
58
+ and issue tracking systems that are managed by, or on behalf of, the
59
+ Licensor for the purpose of discussing and improving the Work, but
60
+ excluding communication that is conspicuously marked or otherwise
61
+ designated in writing by the copyright owner as "Not a Contribution."
62
+
63
+ "Contributor" shall mean Licensor and any individual or Legal Entity
64
+ on behalf of whom a Contribution has been received by Licensor and
65
+ subsequently incorporated within the Work.
66
+
67
+ 2. Grant of Copyright License. Subject to the terms and conditions of
68
+ this License, each Contributor hereby grants to You a perpetual,
69
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
70
+ copyright license to reproduce, prepare Derivative Works of,
71
+ publicly display, publicly perform, sublicense, and distribute the
72
+ Work and such Derivative Works in Source or Object form.
73
+
74
+ 3. Grant of Patent License. Subject to the terms and conditions of
75
+ this License, each Contributor hereby grants to You a perpetual,
76
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
77
+ (except as stated in this section) patent license to make, have made,
78
+ use, offer to sell, sell, import, and otherwise transfer the Work,
79
+ where such license applies only to those patent claims licensable
80
+ by such Contributor that are necessarily infringed by their
81
+ Contribution(s) alone or by combination of their Contribution(s)
82
+ with the Work to which such Contribution(s) was submitted. If You
83
+ institute patent litigation against any entity (including a
84
+ cross-claim or counterclaim in a lawsuit) alleging that the Work
85
+ or a Contribution incorporated within the Work constitutes direct
86
+ or contributory patent infringement, then any patent licenses
87
+ granted to You under this License for that Work shall terminate
88
+ as of the date such litigation is filed.
89
+
90
+ 4. Redistribution. You may reproduce and distribute copies of the
91
+ Work or Derivative Works thereof in any medium, with or without
92
+ modifications, and in Source or Object form, provided that You
93
+ meet the following conditions:
94
+
95
+ (a) You must give any other recipients of the Work or
96
+ Derivative Works a copy of this License; and
97
+
98
+ (b) You must cause any modified files to carry prominent notices
99
+ stating that You changed the files; and
100
+
101
+ (c) You must retain, in the Source form of any Derivative Works
102
+ that You distribute, all copyright, patent, trademark, and
103
+ attribution notices from the Source form of the Work,
104
+ excluding those notices that do not pertain to any part of
105
+ the Derivative Works; and
106
+
107
+ (d) If the Work includes a "NOTICE" text file as part of its
108
+ distribution, then any Derivative Works that You distribute must
109
+ include a readable copy of the attribution notices contained
110
+ within such NOTICE file, excluding those notices that do not
111
+ pertain to any part of the Derivative Works, in at least one
112
+ of the following places: within a NOTICE text file distributed
113
+ as part of the Derivative Works; within the Source form or
114
+ documentation, if provided along with the Derivative Works; or,
115
+ within a display generated by the Derivative Works, if and
116
+ wherever such third-party notices normally appear. The contents
117
+ of the NOTICE file are for informational purposes only and
118
+ do not modify the License. You may add Your own attribution
119
+ notices within Derivative Works that You distribute, alongside
120
+ or as an addendum to the NOTICE text from the Work, provided
121
+ that such additional attribution notices cannot be construed
122
+ as modifying the License.
123
+
124
+ You may add Your own copyright statement to Your modifications and
125
+ may provide additional or different license terms and conditions
126
+ for use, reproduction, or distribution of Your modifications, or
127
+ for any such Derivative Works as a whole, provided Your use,
128
+ reproduction, and distribution of the Work otherwise complies with
129
+ the conditions stated in this License.
130
+
131
+ 5. Submission of Contributions. Unless You explicitly state otherwise,
132
+ any Contribution intentionally submitted for inclusion in the Work
133
+ by You to the Licensor shall be under the terms and conditions of
134
+ this License, without any additional terms or conditions.
135
+ Notwithstanding the above, nothing herein shall supersede or modify
136
+ the terms of any separate license agreement you may have executed
137
+ with Licensor regarding such Contributions.
138
+
139
+ 6. Trademarks. This License does not grant permission to use the trade
140
+ names, trademarks, service marks, or product names of the Licensor,
141
+ except as required for reasonable and customary use in describing the
142
+ origin of the Work and reproducing the content of the NOTICE file.
143
+
144
+ 7. Disclaimer of Warranty. Unless required by applicable law or
145
+ agreed to in writing, Licensor provides the Work (and each
146
+ Contributor provides its Contributions) on an "AS IS" BASIS,
147
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
148
+ implied, including, without limitation, any warranties or conditions
149
+ of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
150
+ PARTICULAR PURPOSE. You are solely responsible for determining the
151
+ appropriateness of using or redistributing the Work and assume any
152
+ risks associated with Your exercise of permissions under this License.
153
+
154
+ 8. Limitation of Liability. In no event and under no legal theory,
155
+ whether in tort (including negligence), contract, or otherwise,
156
+ unless required by applicable law (such as deliberate and grossly
157
+ negligent acts) or agreed to in writing, shall any Contributor be
158
+ liable to You for damages, including any direct, indirect, special,
159
+ incidental, or consequential damages of any character arising as a
160
+ result of this License or out of the use or inability to use the
161
+ Work (including but not limited to damages for loss of goodwill,
162
+ work stoppage, computer failure or malfunction, or any and all
163
+ other commercial damages or losses), even if such Contributor
164
+ has been advised of the possibility of such damages.
165
+
166
+ 9. Accepting Warranty or Additional Liability. While redistributing
167
+ the Work or Derivative Works thereof, You may choose to offer,
168
+ and charge a fee for, acceptance of support, warranty, indemnity,
169
+ or other liability obligations and/or rights consistent with this
170
+ License. However, in accepting such obligations, You may act only
171
+ on Your own behalf and on Your sole responsibility, not on behalf
172
+ of any other Contributor, and only if You agree to indemnify,
173
+ defend, and hold each Contributor harmless for any liability
174
+ incurred by, or claims asserted against, such Contributor by reason
175
+ of your accepting any such warranty or additional liability.
176
+
177
+ END OF TERMS AND CONDITIONS
package/NOTICE ADDED
@@ -0,0 +1 @@
1
+ Copyright (c) 2016-2026 The Stdlib Authors.
package/README.md ADDED
@@ -0,0 +1,188 @@
1
+ <!--
2
+
3
+ @license Apache-2.0
4
+
5
+ Copyright (c) 2025 The Stdlib Authors.
6
+
7
+ Licensed under the Apache License, Version 2.0 (the "License");
8
+ you may not use this file except in compliance with the License.
9
+ You may obtain a copy of the License at
10
+
11
+ http://www.apache.org/licenses/LICENSE-2.0
12
+
13
+ Unless required by applicable law or agreed to in writing, software
14
+ distributed under the License is distributed on an "AS IS" BASIS,
15
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16
+ See the License for the specific language governing permissions and
17
+ limitations under the License.
18
+
19
+ -->
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
+
32
+ # Type Declarations
33
+
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
+
36
+ > WebAssembly TypeScript type declarations.
37
+
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
+
40
+ <section class="intro">
41
+
42
+ </section>
43
+
44
+ <!-- /.intro -->
45
+
46
+ <!-- Package usage documentation. -->
47
+
48
+ <section class="installation">
49
+
50
+ ## Installation
51
+
52
+ ```bash
53
+ npm install @stdlib/wasm-types
54
+ ```
55
+
56
+ </section>
57
+
58
+ <section class="usage">
59
+
60
+ ## Usage
61
+
62
+ ```typescript
63
+ /// <reference types="@stdlib/wasm/types"/>
64
+
65
+ import { Memory } from '@stdlib/wasm-types';
66
+
67
+ // TODO: more extensive example
68
+ ```
69
+
70
+ For the complete list of declared types, see the `index.d.ts` type declaration file.
71
+
72
+ TODO: explicitly document exported types
73
+
74
+ </section>
75
+
76
+ <!-- /.usage -->
77
+
78
+ <!-- Package usage notes. Make sure to keep an empty line after the `section` element and another before the `/section` close. -->
79
+
80
+ <section class="notes">
81
+
82
+ ## Notes
83
+
84
+ - In order to use included TypeScript declarations, configure your `tsconfig.json` file accordingly. For example,
85
+
86
+ ```text
87
+ {
88
+ "compilerOptions": {
89
+ ...
90
+ "typeRoots": [ "./path/to/@stdlib/wasm/types" ],
91
+ ...
92
+ },
93
+ ...
94
+ }
95
+ ```
96
+
97
+ </section>
98
+
99
+ <!-- /.notes -->
100
+
101
+ <!-- Package usage examples. -->
102
+
103
+ <section class="examples">
104
+
105
+ </section>
106
+
107
+ <!-- /.examples -->
108
+
109
+ <!-- Section to include cited references. If references are included, add a horizontal rule *before* the section. Make sure to keep an empty line after the `section` element and another before the `/section` close. -->
110
+
111
+ <section class="references">
112
+
113
+ </section>
114
+
115
+ <!-- /.references -->
116
+
117
+ <!-- Section for related `stdlib` packages. Do not manually edit this section, as it is automatically populated. -->
118
+
119
+ <section class="related">
120
+
121
+ </section>
122
+
123
+ <!-- /.related -->
124
+
125
+ <!-- Section for all links. Make sure to keep an empty line after the `section` element and another before the `/section` close. -->
126
+
127
+
128
+ <section class="main-repo" >
129
+
130
+ * * *
131
+
132
+ ## Notice
133
+
134
+ This package is part of [stdlib][stdlib], a standard library for JavaScript and Node.js, with an emphasis on numerical and scientific computing. The library provides a collection of robust, high performance libraries for mathematics, statistics, streams, utilities, and more.
135
+
136
+ For more information on the project, filing bug reports and feature requests, and guidance on how to develop [stdlib][stdlib], see the main project [repository][stdlib].
137
+
138
+ #### Community
139
+
140
+ [![Chat][chat-image]][chat-url]
141
+
142
+ ---
143
+
144
+ ## License
145
+
146
+ See [LICENSE][stdlib-license].
147
+
148
+
149
+ ## Copyright
150
+
151
+ Copyright &copy; 2016-2026. The Stdlib [Authors][stdlib-authors].
152
+
153
+ </section>
154
+
155
+ <!-- /.stdlib -->
156
+
157
+ <!-- Section for all links. Make sure to keep an empty line after the `section` element and another before the `/section` close. -->
158
+
159
+ <section class="links">
160
+
161
+ [npm-image]: http://img.shields.io/npm/v/@stdlib/wasm-types.svg
162
+ [npm-url]: https://npmjs.org/package/@stdlib/wasm-types
163
+
164
+ [test-image]: https://github.com/stdlib-js/wasm-types/actions/workflows/test.yml/badge.svg?branch=v0.1.0
165
+ [test-url]: https://github.com/stdlib-js/wasm-types/actions/workflows/test.yml?query=branch:v0.1.0
166
+
167
+ [coverage-image]: https://img.shields.io/codecov/c/github/stdlib-js/wasm-types/main.svg
168
+ [coverage-url]: https://codecov.io/github/stdlib-js/wasm-types?branch=main
169
+
170
+ <!--
171
+
172
+ [dependencies-image]: https://img.shields.io/david/stdlib-js/wasm-types.svg
173
+ [dependencies-url]: https://david-dm.org/stdlib-js/wasm-types/main
174
+
175
+ -->
176
+
177
+ [chat-image]: https://img.shields.io/badge/zulip-join_chat-brightgreen.svg
178
+ [chat-url]: https://stdlib.zulipchat.com
179
+
180
+ [stdlib]: https://github.com/stdlib-js/stdlib
181
+
182
+ [stdlib-authors]: https://github.com/stdlib-js/stdlib/graphs/contributors
183
+
184
+ [stdlib-license]: https://raw.githubusercontent.com/stdlib-js/wasm-types/main/LICENSE
185
+
186
+ </section>
187
+
188
+ <!-- /.links -->
package/SECURITY.md ADDED
@@ -0,0 +1,5 @@
1
+ # Security
2
+
3
+ > Policy for reporting security vulnerabilities.
4
+
5
+ See the security policy [in the main project repository](https://github.com/stdlib-js/stdlib/security).
package/dist/index.js ADDED
@@ -0,0 +1,5 @@
1
+ "use strict";var t=function(i,r){return function(){return r||i((r={exports:{}}).exports,r),r.exports}};var s=t(function(c,e){
2
+ var a=require("path").resolve,v=a(__dirname,"..");e.exports=v
3
+ });var o=s();module.exports=o;
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) 2025 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 resolve = require( 'path' ).resolve;\n\n\n// MAIN //\n\n/**\n* Absolute file path for the directory containing type declarations.\n*\n* @name dir\n* @constant\n* @type {string}\n*/\nvar dir = resolve( __dirname, '..' );\n\n\n// EXPORTS //\n\nmodule.exports = dir;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 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* Absolute file path for the directory containing TypeScript declarations.\n*\n* @module @stdlib/wasm-types\n*\n* @example\n* var dir = require( '@stdlib/wasm-types' );\n*\n* console.log( dir );\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,EAAU,QAAS,MAAO,EAAE,QAY5BC,EAAMD,EAAS,UAAW,IAAK,EAKnCD,EAAO,QAAUE,ICNjB,IAAIC,EAAO,IAKX,OAAO,QAAUA",
6
+ "names": ["require_main", "__commonJSMin", "exports", "module", "resolve", "dir", "main"]
7
+ }
package/index.d.ts ADDED
@@ -0,0 +1,161 @@
1
+ /*
2
+ * @license Apache-2.0
3
+ *
4
+ * Copyright (c) 2025 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
+ // TypeScript Version: 4.1
20
+
21
+ /// <reference types="@stdlib/types"/>
22
+
23
+ import { Collection, AccessorArrayLike } from '@stdlib/types/array';
24
+
25
+ /**
26
+ * WebAssembly memory interface.
27
+ */
28
+ export interface Memory {
29
+ /**
30
+ * Underlying `ArrayBuffer` (or `SharedArrayBuffer`) associated with a memory instance.
31
+ */
32
+ buffer: ArrayBuffer;
33
+
34
+ /**
35
+ * Increases the size of the memory instance by a specified number of WebAssembly pages (i.e., 64KiB).
36
+ *
37
+ * ## Notes
38
+ *
39
+ * - Upon increasing the size, the previous `ArrayBuffer` is detached, thus invalidating any typed arrays which were views over the previous `ArrayBuffer`.
40
+ * - Detachment means that the previous `ArrayBuffer` byte length becomes zero, and it no longer has bytes accessible to JavaScript.
41
+ * - `ArrayBuffer` detachment applies even when `delta` is zero.
42
+ * - Detachment only applies for non-shared memory instances. For a shared memory instance, the initial buffer (which is a `SharedArrayBuffer`) will not become detached and, instead, its length will not be updated.
43
+ * - Accesses to the `buffer` property after growing a `SharedArrayBuffer` will yield a larger `SharedArrayBuffer` which may access a larger span of memory than the buffer before growing memory.
44
+ * - Every `SharedArrayBuffer` accessed via the `buffer` property will always refer to the start of the same memory address range and thus manipulate the same data.
45
+ *
46
+ * @param delta - number of WebAssembly pages (i.e., 64KiB) by which to grow the underlying memory
47
+ * @returns size of the previous `ArrayBuffer` (or `SharedArrayBuffer`)
48
+ */
49
+ grow( delta: number ): number;
50
+ }
51
+
52
+ /**
53
+ * WebAssembly module wrapper interface.
54
+ */
55
+ export interface ModuleWrapper {
56
+ /**
57
+ * WebAssembly binary code.
58
+ */
59
+ binary: Uint8Array;
60
+
61
+ /**
62
+ * WebAssembly memory.
63
+ */
64
+ memory: Memory | null;
65
+
66
+ /**
67
+ * WebAssembly memory buffer as a Uint8Array.
68
+ */
69
+ buffer: Uint8Array | null;
70
+
71
+ /**
72
+ * WebAssembly memory buffer as a DataView.
73
+ */
74
+ view: DataView | null;
75
+
76
+ /**
77
+ * "Raw" WebAssembly module exports.
78
+ */
79
+ exports: Object | null;
80
+
81
+ /**
82
+ * Asynchronously initializes a WebAssembly module instance.
83
+ *
84
+ * @returns promise which resolves upon initializing a WebAssembly module instance
85
+ */
86
+ initialize(): Promise<ModuleWrapper>;
87
+
88
+ /**
89
+ * Asynchronously initializes a WebAssembly module instance.
90
+ *
91
+ * @param clbk - callback to invoke upon initializing a WebAssembly module
92
+ */
93
+ initializeAsync( clbk: ( error: Error | null, mod?: ModuleWrapper ) => void ): void;
94
+
95
+ /**
96
+ * Synchronously initializes a WebAssembly module instance.
97
+ *
98
+ * @returns module wrapper instance
99
+ */
100
+ initializeSync(): ModuleWrapper;
101
+
102
+ /**
103
+ * Reallocates the underlying WebAssembly memory instance to a specified number of bytes.
104
+ *
105
+ * ## Notes
106
+ *
107
+ * - WebAssembly memory can only **grow**, not shrink. Hence, if provided a number of bytes which is less than or equal to the size of the current memory, the function does nothing.
108
+ * - When non-shared memory is resized, the underlying the `ArrayBuffer` is detached, consequently invalidating any associated typed array views. Before resizing non-shared memory, ensure that associated typed array views no longer need byte access and can be garbage collected.
109
+ *
110
+ * @param nbytes - memory size (in bytes)
111
+ * @returns boolean indicating whether the resize operation was successful
112
+ */
113
+ realloc( nbytes: number ): boolean;
114
+
115
+ /**
116
+ * Returns a boolean indicating whether the underlying WebAssembly memory instance has the capacity to store a provided list of values starting from a specified byte offset.
117
+ *
118
+ * @param byteOffset - byte offset at which to start writing values
119
+ * @param values - input array containing values to write
120
+ * @returns boolean indicating whether the underlying WebAssembly memory instance has enough capacity
121
+ */
122
+ hasCapacity( byteOffset: number, values: Collection | AccessorArrayLike<any> ): boolean;
123
+
124
+ /**
125
+ * Returns a boolean indicating whether a provided list of values is a view of the underlying memory of the WebAssembly module.
126
+ *
127
+ * @param values - input array
128
+ * @returns boolean indicating whether the list is a memory view
129
+ */
130
+ isView( values: Collection | AccessorArrayLike<any> ): boolean;
131
+
132
+ /**
133
+ * Writes values to the underlying WebAssembly memory instance.
134
+ *
135
+ * ## Notes
136
+ *
137
+ * - The function infers element size (i.e., number of bytes per element) from the data type of the input array. For example, if provided a `Float32Array`, the function writes each element as a single-precision floating-point number to the underlying WebAssembly memory instance.
138
+ * - In order to write elements as a different data type, you need to perform an explicit cast **before** calling this method. For example, in order to write single-precision floating-point numbers contained in a `Float32Array` as signed 32-bit integers, you must first convert the `Float32Array` to an `Int32Array` before passing the values to this method.
139
+ * - If provided an array having an unknown or "generic" data type, elements are written as double-precision floating-point numbers.
140
+ *
141
+ * @param byteOffset - byte offset at which to start writing values
142
+ * @param values - input array containing values to write
143
+ * @returns module wrapper instance
144
+ */
145
+ write( byteOffset: number, values: Collection | AccessorArrayLike<any> ): ModuleWrapper;
146
+
147
+ /**
148
+ * Reads values from the underlying WebAssembly memory instance.
149
+ *
150
+ * ## Notes
151
+ *
152
+ * - The function infers element size (i.e., number of bytes per element) from the data type of the output array. For example, if provided a `Float32Array`, the function reads each element as a single-precision floating-point number from the underlying WebAssembly memory instance.
153
+ * - In order to read elements as a different data type, you need to perform an explicit cast **after** calling this method. For example, in order to read single-precision floating-point numbers contained in a `Float32Array` as signed 32-bit integers, you must convert the `Float32Array` to an `Int32Array` after reading memory values using this method.
154
+ * - If provided an output array having an unknown or "generic" data type, elements are read as double-precision floating-point numbers.
155
+ *
156
+ * @param byteOffset - byte offset at which to start reading values
157
+ * @param out - output array
158
+ * @returns module wrapper instance
159
+ */
160
+ read( byteOffset: number, out: Collection | AccessorArrayLike<any> ): ModuleWrapper;
161
+ }
package/lib/browser.js ADDED
@@ -0,0 +1,28 @@
1
+ /**
2
+ * @license Apache-2.0
3
+ *
4
+ * Copyright (c) 2025 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
+ 'use strict';
20
+
21
+ // MAIN //
22
+
23
+ var dir = null;
24
+
25
+
26
+ // EXPORTS //
27
+
28
+ module.exports = dir;
package/lib/index.js ADDED
@@ -0,0 +1,39 @@
1
+ /**
2
+ * @license Apache-2.0
3
+ *
4
+ * Copyright (c) 2025 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
+ 'use strict';
20
+
21
+ /**
22
+ * Absolute file path for the directory containing TypeScript declarations.
23
+ *
24
+ * @module @stdlib/wasm-types
25
+ *
26
+ * @example
27
+ * var dir = require( '@stdlib/wasm-types' );
28
+ *
29
+ * console.log( dir );
30
+ */
31
+
32
+ // MODULES //
33
+
34
+ var main = require( './main.js' );
35
+
36
+
37
+ // EXPORTS //
38
+
39
+ module.exports = main;
package/lib/main.js ADDED
@@ -0,0 +1,40 @@
1
+ /**
2
+ * @license Apache-2.0
3
+ *
4
+ * Copyright (c) 2025 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
+ 'use strict';
20
+
21
+ // MODULES //
22
+
23
+ var resolve = require( 'path' ).resolve;
24
+
25
+
26
+ // MAIN //
27
+
28
+ /**
29
+ * Absolute file path for the directory containing type declarations.
30
+ *
31
+ * @name dir
32
+ * @constant
33
+ * @type {string}
34
+ */
35
+ var dir = resolve( __dirname, '..' );
36
+
37
+
38
+ // EXPORTS //
39
+
40
+ module.exports = dir;
package/package.json ADDED
@@ -0,0 +1,70 @@
1
+ {
2
+ "name": "@stdlib/wasm-types",
3
+ "version": "0.1.0",
4
+ "description": "WebAssembly TypeScript type declarations.",
5
+ "license": "Apache-2.0",
6
+ "author": {
7
+ "name": "The Stdlib Authors",
8
+ "url": "https://github.com/stdlib-js/stdlib/graphs/contributors"
9
+ },
10
+ "contributors": [
11
+ {
12
+ "name": "The Stdlib Authors",
13
+ "url": "https://github.com/stdlib-js/stdlib/graphs/contributors"
14
+ }
15
+ ],
16
+ "main": "./lib",
17
+ "browser": "./lib/browser.js",
18
+ "directories": {
19
+ "lib": "./lib",
20
+ "dist": "./dist"
21
+ },
22
+ "types": ".",
23
+ "scripts": {},
24
+ "homepage": "https://stdlib.io",
25
+ "repository": {
26
+ "type": "git",
27
+ "url": "git://github.com/stdlib-js/wasm-types.git"
28
+ },
29
+ "bugs": {
30
+ "url": "https://github.com/stdlib-js/stdlib/issues"
31
+ },
32
+ "dependencies": {},
33
+ "devDependencies": {},
34
+ "engines": {
35
+ "node": ">=0.10.0",
36
+ "npm": ">2.7.0"
37
+ },
38
+ "os": [
39
+ "aix",
40
+ "darwin",
41
+ "freebsd",
42
+ "linux",
43
+ "macos",
44
+ "openbsd",
45
+ "sunos",
46
+ "win32",
47
+ "windows"
48
+ ],
49
+ "keywords": [
50
+ "stdlib",
51
+ "standard",
52
+ "library",
53
+ "types",
54
+ "typescript",
55
+ "ts",
56
+ "declarations",
57
+ "definitions",
58
+ "wasm",
59
+ "webassembly"
60
+ ],
61
+ "__stdlib__": {
62
+ "envs": {
63
+ "browser": false
64
+ }
65
+ },
66
+ "funding": {
67
+ "type": "opencollective",
68
+ "url": "https://opencollective.com/stdlib"
69
+ }
70
+ }
package/test.ts ADDED
@@ -0,0 +1,34 @@
1
+ /*
2
+ * @license Apache-2.0
3
+ *
4
+ * Copyright (c) 2025 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
+ /// <reference types="@stdlib/types"/>
20
+
21
+ import * as wasm from '@stdlib/wasm-types';
22
+
23
+
24
+ // TESTS //
25
+
26
+ // The compiler should not throw an error when using exported types...
27
+ {
28
+ const mem: wasm.Memory = new WebAssembly.Memory({
29
+ 'initial': 0
30
+ });
31
+ if ( mem !== mem ) {
32
+ throw new Error( 'something went wrong' );
33
+ }
34
+ }