@stdlib/strided-base-nullary-addon-dispatch 0.0.1 → 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 +7 -0
- package/dist/index.js.map +7 -0
- package/docs/types/index.d.ts +9 -9
- package/package.json +23 -22
- package/docs/repl.txt +0 -135
- package/docs/types/test.ts +0 -269
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
|
# dispatch
|
|
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] -->
|
|
@@ -293,8 +304,8 @@ Copyright © 2016-2023. The Stdlib [Authors][stdlib-authors].
|
|
|
293
304
|
[npm-image]: http://img.shields.io/npm/v/@stdlib/strided-base-nullary-addon-dispatch.svg
|
|
294
305
|
[npm-url]: https://npmjs.org/package/@stdlib/strided-base-nullary-addon-dispatch
|
|
295
306
|
|
|
296
|
-
[test-image]: https://github.com/stdlib-js/strided-base-nullary-addon-dispatch/actions/workflows/test.yml/badge.svg?branch=v0.0
|
|
297
|
-
[test-url]: https://github.com/stdlib-js/strided-base-nullary-addon-dispatch/actions/workflows/test.yml?query=branch:v0.0
|
|
307
|
+
[test-image]: https://github.com/stdlib-js/strided-base-nullary-addon-dispatch/actions/workflows/test.yml/badge.svg?branch=v0.1.0
|
|
308
|
+
[test-url]: https://github.com/stdlib-js/strided-base-nullary-addon-dispatch/actions/workflows/test.yml?query=branch:v0.1.0
|
|
298
309
|
|
|
299
310
|
[coverage-image]: https://img.shields.io/codecov/c/github/stdlib-js/strided-base-nullary-addon-dispatch/main.svg
|
|
300
311
|
[coverage-url]: https://codecov.io/github/stdlib-js/strided-base-nullary-addon-dispatch?branch=main
|
|
@@ -307,7 +318,7 @@ Copyright © 2016-2023. The Stdlib [Authors][stdlib-authors].
|
|
|
307
318
|
-->
|
|
308
319
|
|
|
309
320
|
[chat-image]: https://img.shields.io/gitter/room/stdlib-js/stdlib.svg
|
|
310
|
-
[chat-url]: https://gitter.im
|
|
321
|
+
[chat-url]: https://app.gitter.im/#/room/#stdlib-js_stdlib:gitter.im
|
|
311
322
|
|
|
312
323
|
[stdlib]: https://github.com/stdlib-js/stdlib
|
|
313
324
|
|
package/dist/index.d.ts
ADDED
package/dist/index.js
ADDED
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
"use strict";var p=function(a,n){return function(){return n||a((n={exports:{}}).exports,n),n.exports}};var w=p(function(z,q){
|
|
2
|
+
var c=require('@stdlib/assert-is-function/dist'),T=require('@stdlib/assert-is-typed-array-like/dist'),s=require('@stdlib/strided-base-dtype-resolve-enum/dist'),C=require('@stdlib/strided-base-reinterpret-complex64/dist'),V=require('@stdlib/strided-base-reinterpret-complex128/dist'),g=require('@stdlib/error-tools-fmtprodmsg/dist'),d=s("complex64"),L=s("complex128");function O(a,n){if(!c(a))throw new TypeError(g('1fR3c',a));if(!c(n))throw new TypeError(g('1fR2H',n));return v;function v(u,r,e,t){var i;if(!T(e))return n(u,r,e,t),e;if(r=s(r),r===null)throw new TypeError(format('1fR1L'));return r===d?i=C(e,0):r===L?i=V(e,0):i=e,a(u,r,i,t),e}}q.exports=O
|
|
3
|
+
});var E=p(function(D,h){
|
|
4
|
+
var f=require('@stdlib/assert-is-function/dist'),P=require('@stdlib/assert-is-typed-array-like/dist'),F=require('@stdlib/assert-is-nonnegative-integer/dist').isPrimitive,l=require('@stdlib/strided-base-dtype-resolve-enum/dist'),M=require('@stdlib/strided-base-reinterpret-complex64/dist'),b=require('@stdlib/strided-base-reinterpret-complex128/dist'),A=require('@stdlib/strided-base-offset-view/dist'),I=require('@stdlib/strided-base-min-view-buffer-index/dist'),m=require('@stdlib/error-tools-fmtprodmsg/dist'),S=l("complex64"),U=l("complex128");function B(a,n){if(!f(a))throw new TypeError(m('1fR3c',a));if(!f(n))throw new TypeError(m('1fR2H',n));return v;function v(u,r,e,t,i){var o;if(!P(e))return n(u,r,e,t,i),e;if(r=l(r),r===null)throw new TypeError(format('1fR1L'));if(!F(i))throw new TypeError(m('1fRAE',i));return i=I(u,t,i),r===S?o=M(e,i):r===U?o=b(e,i):o=A(e,i),a(u,r,o,t),e}}h.exports=B
|
|
5
|
+
});var R=require('@stdlib/utils-define-nonenumerable-read-only-property/dist'),y=w(),j=E();R(y,"ndarray",j);module.exports=y;
|
|
6
|
+
/** @license Apache-2.0 */
|
|
7
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../lib/main.js", "../lib/ndarray.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 isFunction = require( '@stdlib/assert-is-function' );\nvar isTypedArrayLike = require( '@stdlib/assert-is-typed-array-like' );\nvar resolve = require( '@stdlib/strided-base-dtype-resolve-enum' );\nvar reinterpretComplex64 = require( '@stdlib/strided-base-reinterpret-complex64' );\nvar reinterpretComplex128 = require( '@stdlib/strided-base-reinterpret-complex128' );\nvar format = require( '@stdlib/string-format' );\n\n\n// VARIABLES //\n\nvar COMPLEX64 = resolve( 'complex64' );\nvar COMPLEX128 = resolve( 'complex128' );\n\n\n// MAIN //\n\n/**\n* Returns a function which dispatches to a native add-on applying a nullary function.\n*\n* ## Notes\n*\n* - The returned function has the following signature:\n*\n* ```text\n* f( N, dtypeX, x, strideX )\n* ```\n*\n* where\n*\n* - **N**: number of indexed elements.\n* - **dtypeX**: `x` data type.\n* - **x**: output array.\n* - **strideX**: `x` stride length.\n*\n* - The add-on function should have the following signature:\n*\n* ```text\n* f( N, dtypeX, x, strideX )\n* ```\n*\n* where\n*\n* - **N**: number of indexed elements.\n* - **dtypeX**: `x` data type (enumeration constant).\n* - **x**: output array.\n* - **strideX**: `x` stride length.\n*\n* - The fallback function should have the following signature:\n*\n* ```text\n* f( N, dtypeX, x, strideX )\n* ```\n*\n* where\n*\n* - **N**: number of indexed elements.\n* - **dtypeX**: `x` data type.\n* - **x**: output array.\n* - **strideX**: `x` stride length.\n*\n* @param {Function} addon - add-on interface\n* @param {Function} fallback - fallback function\n* @throws {TypeError} first argument must be a function\n* @throws {TypeError} second argument must be a function\n* @returns {Function} dispatch function\n*\n* @example\n* function addon( N, dtypeX, x, strideX ) {\n* // Call into native add-on...\n* }\n*\n* function fallback( N, dtypeX, x, strideX ) {\n* // Fallback JavaScript implementation...\n* }\n*\n* // Create a dispatch function:\n* var f = dispatch( addon, fallback );\n*\n* // ...\n*\n* // Invoke the dispatch function with strided array arguments:\n* f( 2, 'generic', [ 1, 2 ], 1 );\n*/\nfunction dispatch( addon, fallback ) {\n\tif ( !isFunction( addon ) ) {\n\t\tthrow new TypeError( format( 'invalid argument. First argument must be a function. Value: `%s`.', addon ) );\n\t}\n\tif ( !isFunction( fallback ) ) {\n\t\tthrow new TypeError( format( 'invalid argument. Second argument must be a function. Value: `%s`.', fallback ) );\n\t}\n\treturn dispatcher;\n\n\t/**\n\t* Dispatches to a native add-on.\n\t*\n\t* @private\n\t* @param {integer} N - number of indexed elements\n\t* @param {*} dtypeX - `x` data type\n\t* @param {Collection} x - output array\n\t* @param {integer} strideX - `x` stride length\n\t* @throws {TypeError} unable to resolve a strided array function supporting the provided array argument data types\n\t* @returns {Collection} `x`\n\t*/\n\tfunction dispatcher( N, dtypeX, x, strideX ) {\n\t\tvar viewX;\n\n\t\t// WARNING: we assume that, if we're provided something resembling a typed array, we're provided a typed array; however, this can lead to potential unintended errors as the native add-on may not work with non-typed array objects (e.g., generic arrays)...\n\t\tif ( !isTypedArrayLike( x ) ) {\n\t\t\tfallback( N, dtypeX, x, strideX );\n\t\t\treturn x;\n\t\t}\n\t\tdtypeX = resolve( dtypeX );\n\t\tif ( dtypeX === null ) {\n\t\t\tthrow new TypeError( 'invalid arguments. Unable to resolve a strided array function supporting the provided array argument data types.' );\n\t\t}\n\t\tif ( dtypeX === COMPLEX64 ) {\n\t\t\tviewX = reinterpretComplex64( x, 0 );\n\t\t} else if ( dtypeX === COMPLEX128 ) {\n\t\t\tviewX = reinterpretComplex128( x, 0 );\n\t\t} else {\n\t\t\tviewX = x;\n\t\t}\n\t\taddon( N, dtypeX, viewX, strideX );\n\t\treturn x;\n\t}\n}\n\n\n// EXPORTS //\n\nmodule.exports = dispatch;\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// MODULES //\n\nvar isFunction = require( '@stdlib/assert-is-function' );\nvar isTypedArrayLike = require( '@stdlib/assert-is-typed-array-like' );\nvar isNonNegativeInteger = require( '@stdlib/assert-is-nonnegative-integer' ).isPrimitive;\nvar resolve = require( '@stdlib/strided-base-dtype-resolve-enum' );\nvar reinterpretComplex64 = require( '@stdlib/strided-base-reinterpret-complex64' );\nvar reinterpretComplex128 = require( '@stdlib/strided-base-reinterpret-complex128' );\nvar offsetView = require( '@stdlib/strided-base-offset-view' );\nvar minViewBufferIndex = require( '@stdlib/strided-base-min-view-buffer-index' );\nvar format = require( '@stdlib/string-format' );\n\n\n// VARIABLES //\n\nvar COMPLEX64 = resolve( 'complex64' );\nvar COMPLEX128 = resolve( 'complex128' );\n\n\n// MAIN //\n\n/**\n* Returns a function which dispatches to a native add-on applying a nullary function using alternative indexing semantics.\n*\n* ## Notes\n*\n* - The returned function has the following signature:\n*\n* ```text\n* f( N, dtypeX, x, strideX, offsetX )\n* ```\n*\n* where\n*\n* - **N**: number of indexed elements.\n* - **dtypeX**: `x` data type.\n* - **x**: output array.\n* - **strideX**: `x` stride length.\n* - **offsetX**: starting `x` index.\n*\n* - The add-on function should have the following signature:\n*\n* ```text\n* f( N, dtypeX, x, strideX )\n* ```\n*\n* where\n*\n* - **N**: number of indexed elements.\n* - **dtypeX**: `x` data type (enumeration constant).\n* - **x**: output array.\n* - **strideX**: `x` stride length.\n*\n* - The fallback function should have the following signature:\n*\n* ```text\n* f( N, dtypeX, x, strideX, offsetX )\n* ```\n*\n* where\n*\n* - **N**: number of indexed elements.\n* - **dtypeX**: `x` data type.\n* - **x**: output array.\n* - **strideX**: `x` stride length.\n* - **offsetX**: starting `x` index.\n*\n* @param {Function} addon - add-on interface\n* @param {Function} fallback - fallback function\n* @throws {TypeError} first argument must be a function\n* @throws {TypeError} second argument must be a function\n* @returns {Function} dispatch function\n*\n* @example\n* function addon( N, dtypeX, x, strideX ) {\n* // Call into native add-on...\n* }\n*\n* function fallback( N, dtypeX, x, strideX, offsetX ) {\n* // Fallback JavaScript implementation...\n* }\n*\n* // Create a dispatch function:\n* var f = dispatch( addon, fallback );\n*\n* // ...\n*\n* // Invoke the dispatch function with strided array arguments:\n* f( 2, 'generic', [ 1, 2 ], 1, 0 );\n*/\nfunction dispatch( addon, fallback ) {\n\tif ( !isFunction( addon ) ) {\n\t\tthrow new TypeError( format( 'invalid argument. First argument must be a function. Value: `%s`.', addon ) );\n\t}\n\tif ( !isFunction( fallback ) ) {\n\t\tthrow new TypeError( format( 'invalid argument. Second argument must be a function. Value: `%s`.', fallback ) );\n\t}\n\treturn dispatcher;\n\n\t/**\n\t* Dispatches to a native add-on.\n\t*\n\t* @private\n\t* @param {integer} N - number of indexed elements\n\t* @param {*} dtypeX - `x` data type\n\t* @param {Collection} x - output array\n\t* @param {integer} strideX - `x` stride length\n\t* @param {NonNegativeInteger} offsetX - starting `x` index\n\t* @throws {TypeError} fifth argument must be a nonnegative integer\n\t* @throws {TypeError} unable to resolve a strided array function supporting the provided array argument data types\n\t* @returns {Collection} `x`\n\t*/\n\tfunction dispatcher( N, dtypeX, x, strideX, offsetX ) {\n\t\tvar viewX;\n\n\t\t// WARNING: we assume that, if we're provided something resembling a typed array, we're provided a typed array; however, this can lead to potential unintended errors as the native add-on may not work with non-typed array objects (e.g., generic arrays)...\n\t\tif ( !isTypedArrayLike( x ) ) {\n\t\t\tfallback( N, dtypeX, x, strideX, offsetX );\n\t\t\treturn x;\n\t\t}\n\t\tdtypeX = resolve( dtypeX );\n\t\tif ( dtypeX === null ) {\n\t\t\tthrow new TypeError( 'invalid arguments. Unable to resolve a strided array function supporting the provided array argument data types.' );\n\t\t}\n\t\tif ( !isNonNegativeInteger( offsetX ) ) {\n\t\t\tthrow new TypeError( format( 'invalid argument. Output array offset must be a nonnegative integer. Value: `%s`.', offsetX ) );\n\t\t}\n\t\toffsetX = minViewBufferIndex( N, strideX, offsetX );\n\t\tif ( dtypeX === COMPLEX64 ) {\n\t\t\tviewX = reinterpretComplex64( x, offsetX );\n\t\t} else if ( dtypeX === COMPLEX128 ) {\n\t\t\tviewX = reinterpretComplex128( x, offsetX );\n\t\t} else {\n\t\t\tviewX = offsetView( x, offsetX );\n\t\t}\n\t\taddon( N, dtypeX, viewX, strideX );\n\t\treturn x;\n\t}\n}\n\n\n// EXPORTS //\n\nmodule.exports = dispatch;\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* Dispatch to a native add-on applying a nullary function.\n*\n* @module @stdlib/strided-base-nullary-addon-dispatch\n*\n* @example\n* var dispatch = require( '@stdlib/strided-base-nullary-addon-dispatch' );\n*\n* function addon( N, dtypeX, x, strideX ) {\n* // Call into native add-on...\n* }\n*\n* function fallback( N, dtypeX, x, strideX ) {\n* // Fallback JavaScript implementation...\n* }\n*\n* // Create a dispatch function:\n* var f = dispatch( addon, fallback );\n*\n* // ...\n*\n* // Invoke the dispatch function with strided array arguments:\n* f( 2, 'generic', [ 1, 2 ], 1 );\n*/\n\n// MODULES //\n\nvar setReadOnly = require( '@stdlib/utils-define-nonenumerable-read-only-property' );\nvar main = require( './main.js' );\nvar ndarray = require( './ndarray.js' );\n\n\n// MAIN //\n\nsetReadOnly( main, 'ndarray', ndarray );\n\n\n// EXPORTS //\n\nmodule.exports = main;\n"],
|
|
5
|
+
"mappings": "uGAAA,IAAAA,EAAAC,EAAA,SAAAC,EAAAC,EAAA,cAsBA,IAAIC,EAAa,QAAS,4BAA6B,EACnDC,EAAmB,QAAS,oCAAqC,EACjEC,EAAU,QAAS,yCAA0C,EAC7DC,EAAuB,QAAS,4CAA6C,EAC7EC,EAAwB,QAAS,6CAA8C,EAC/EC,EAAS,QAAS,uBAAwB,EAK1CC,EAAYJ,EAAS,WAAY,EACjCK,EAAaL,EAAS,YAAa,EAwEvC,SAASM,EAAUC,EAAOC,EAAW,CACpC,GAAK,CAACV,EAAYS,CAAM,EACvB,MAAM,IAAI,UAAWJ,EAAQ,oEAAqEI,CAAM,CAAE,EAE3G,GAAK,CAACT,EAAYU,CAAS,EAC1B,MAAM,IAAI,UAAWL,EAAQ,qEAAsEK,CAAS,CAAE,EAE/G,OAAOC,EAaP,SAASA,EAAYC,EAAGC,EAAQC,EAAGC,EAAU,CAC5C,IAAIC,EAGJ,GAAK,CAACf,EAAkBa,CAAE,EACzB,OAAAJ,EAAUE,EAAGC,EAAQC,EAAGC,CAAQ,EACzBD,EAGR,GADAD,EAASX,EAASW,CAAO,EACpBA,IAAW,KACf,MAAM,IAAI,UAAW,kHAAmH,EAEzI,OAAKA,IAAWP,EACfU,EAAQb,EAAsBW,EAAG,CAAE,EACxBD,IAAWN,EACtBS,EAAQZ,EAAuBU,EAAG,CAAE,EAEpCE,EAAQF,EAETL,EAAOG,EAAGC,EAAQG,EAAOD,CAAQ,EAC1BD,CACR,CACD,CAKAf,EAAO,QAAUS,ICxJjB,IAAAS,EAAAC,EAAA,SAAAC,EAAAC,EAAA,cAsBA,IAAIC,EAAa,QAAS,4BAA6B,EACnDC,EAAmB,QAAS,oCAAqC,EACjEC,EAAuB,QAAS,uCAAwC,EAAE,YAC1EC,EAAU,QAAS,yCAA0C,EAC7DC,EAAuB,QAAS,4CAA6C,EAC7EC,EAAwB,QAAS,6CAA8C,EAC/EC,EAAa,QAAS,kCAAmC,EACzDC,EAAqB,QAAS,4CAA6C,EAC3EC,EAAS,QAAS,uBAAwB,EAK1CC,EAAYN,EAAS,WAAY,EACjCO,EAAaP,EAAS,YAAa,EA0EvC,SAASQ,EAAUC,EAAOC,EAAW,CACpC,GAAK,CAACb,EAAYY,CAAM,EACvB,MAAM,IAAI,UAAWJ,EAAQ,oEAAqEI,CAAM,CAAE,EAE3G,GAAK,CAACZ,EAAYa,CAAS,EAC1B,MAAM,IAAI,UAAWL,EAAQ,qEAAsEK,CAAS,CAAE,EAE/G,OAAOC,EAeP,SAASA,EAAYC,EAAGC,EAAQC,EAAGC,EAASC,EAAU,CACrD,IAAIC,EAGJ,GAAK,CAACnB,EAAkBgB,CAAE,EACzB,OAAAJ,EAAUE,EAAGC,EAAQC,EAAGC,EAASC,CAAQ,EAClCF,EAGR,GADAD,EAASb,EAASa,CAAO,EACpBA,IAAW,KACf,MAAM,IAAI,UAAW,kHAAmH,EAEzI,GAAK,CAACd,EAAsBiB,CAAQ,EACnC,MAAM,IAAI,UAAWX,EAAQ,oFAAqFW,CAAQ,CAAE,EAE7H,OAAAA,EAAUZ,EAAoBQ,EAAGG,EAASC,CAAQ,EAC7CH,IAAWP,EACfW,EAAQhB,EAAsBa,EAAGE,CAAQ,EAC9BH,IAAWN,EACtBU,EAAQf,EAAuBY,EAAGE,CAAQ,EAE1CC,EAAQd,EAAYW,EAAGE,CAAQ,EAEhCP,EAAOG,EAAGC,EAAQI,EAAOF,CAAQ,EAC1BD,CACR,CACD,CAKAlB,EAAO,QAAUY,ICpHjB,IAAIU,EAAc,QAAS,uDAAwD,EAC/EC,EAAO,IACPC,EAAU,IAKdF,EAAaC,EAAM,UAAWC,CAAQ,EAKtC,OAAO,QAAUD",
|
|
6
|
+
"names": ["require_main", "__commonJSMin", "exports", "module", "isFunction", "isTypedArrayLike", "resolve", "reinterpretComplex64", "reinterpretComplex128", "format", "COMPLEX64", "COMPLEX128", "dispatch", "addon", "fallback", "dispatcher", "N", "dtypeX", "x", "strideX", "viewX", "require_ndarray", "__commonJSMin", "exports", "module", "isFunction", "isTypedArrayLike", "isNonNegativeInteger", "resolve", "reinterpretComplex64", "reinterpretComplex128", "offsetView", "minViewBufferIndex", "format", "COMPLEX64", "COMPLEX128", "dispatch", "addon", "fallback", "dispatcher", "N", "dtypeX", "x", "strideX", "offsetX", "viewX", "setReadOnly", "main", "ndarray"]
|
|
7
|
+
}
|
package/docs/types/index.d.ts
CHANGED
|
@@ -16,11 +16,11 @@
|
|
|
16
16
|
* limitations under the License.
|
|
17
17
|
*/
|
|
18
18
|
|
|
19
|
-
// TypeScript Version:
|
|
19
|
+
// TypeScript Version: 4.1
|
|
20
20
|
|
|
21
21
|
/// <reference types="@stdlib/types"/>
|
|
22
22
|
|
|
23
|
-
import { Collection } from '@stdlib/types/
|
|
23
|
+
import { Collection } from '@stdlib/types/array';
|
|
24
24
|
|
|
25
25
|
/**
|
|
26
26
|
* Add-on function.
|
|
@@ -35,7 +35,7 @@ import { Collection } from '@stdlib/types/object';
|
|
|
35
35
|
* // Call into native add-on...
|
|
36
36
|
* }
|
|
37
37
|
*/
|
|
38
|
-
type AddonFcn = ( N: number, dtypeX: number, x: Collection
|
|
38
|
+
type AddonFcn<T, U> = ( N: number, dtypeX: number, x: Collection<T>, strideX: number ) => U;
|
|
39
39
|
|
|
40
40
|
/**
|
|
41
41
|
* Fallback function.
|
|
@@ -50,7 +50,7 @@ type AddonFcn = ( N: number, dtypeX: number, x: Collection, strideX: number ) =>
|
|
|
50
50
|
* // Fallback JavaScript implementation...
|
|
51
51
|
* }
|
|
52
52
|
*/
|
|
53
|
-
type FallbackFcn = ( N: number, dtypeX: any, x: Collection
|
|
53
|
+
type FallbackFcn<T, U> = ( N: number, dtypeX: any, x: Collection<T>, strideX: number ) => U;
|
|
54
54
|
|
|
55
55
|
/**
|
|
56
56
|
* Fallback function supporting alternative indexing semantics.
|
|
@@ -66,7 +66,7 @@ type FallbackFcn = ( N: number, dtypeX: any, x: Collection, strideX: number ) =>
|
|
|
66
66
|
* // Fallback JavaScript implementation...
|
|
67
67
|
* }
|
|
68
68
|
*/
|
|
69
|
-
type FallbackFcnWithOffsets = ( N: number, dtypeX: any, x: Collection
|
|
69
|
+
type FallbackFcnWithOffsets<T, U> = ( N: number, dtypeX: any, x: Collection<T>, strideX: number, offsetX: number ) => U;
|
|
70
70
|
|
|
71
71
|
/**
|
|
72
72
|
* Dispatches to a native add-on.
|
|
@@ -77,7 +77,7 @@ type FallbackFcnWithOffsets = ( N: number, dtypeX: any, x: Collection, strideX:
|
|
|
77
77
|
* @param strideX - `x` stride length
|
|
78
78
|
* @returns `x`
|
|
79
79
|
*/
|
|
80
|
-
type Dispatcher = ( N: number, dtypeX: any, x: Collection
|
|
80
|
+
type Dispatcher<T> = ( N: number, dtypeX: any, x: Collection<T>, strideX: number ) => Collection<T>;
|
|
81
81
|
|
|
82
82
|
/**
|
|
83
83
|
* Dispatches to a native add-on.
|
|
@@ -89,7 +89,7 @@ type Dispatcher = ( N: number, dtypeX: any, x: Collection, strideX: number ) =>
|
|
|
89
89
|
* @param offsetX - starting `x` index
|
|
90
90
|
* @returns `x`
|
|
91
91
|
*/
|
|
92
|
-
type DispatcherWithOffsets = ( N: number, dtypeX: any, x: Collection
|
|
92
|
+
type DispatcherWithOffsets<T> = ( N: number, dtypeX: any, x: Collection<T>, strideX: number, offsetX: number ) => Collection<T>;
|
|
93
93
|
|
|
94
94
|
/**
|
|
95
95
|
* Interface for creating a native add-on dispatcher.
|
|
@@ -119,7 +119,7 @@ interface Dispatch {
|
|
|
119
119
|
* // Invoke the dispatch function with strided array arguments:
|
|
120
120
|
* f( 2, 'generic', [ 1, 2 ], 1 );
|
|
121
121
|
*/
|
|
122
|
-
( addon: AddonFcn, fallback: FallbackFcn ): Dispatcher
|
|
122
|
+
<T = unknown, U = unknown>( addon: AddonFcn<T, U>, fallback: FallbackFcn<T, U> ): Dispatcher<T>;
|
|
123
123
|
|
|
124
124
|
/**
|
|
125
125
|
* Returns a function which dispatches to a native add-on applying a nullary function using alternative indexing semantics.
|
|
@@ -145,7 +145,7 @@ interface Dispatch {
|
|
|
145
145
|
* // Invoke the dispatch function with strided array arguments:
|
|
146
146
|
* f( 2, 'generic', [ 1, 2 ], 1, 0 );
|
|
147
147
|
*/
|
|
148
|
-
ndarray( addon: AddonFcn, fallback: FallbackFcnWithOffsets ): DispatcherWithOffsets
|
|
148
|
+
ndarray<T = unknown, U = unknown>( addon: AddonFcn<T, U>, fallback: FallbackFcnWithOffsets<T, U> ): DispatcherWithOffsets<T>;
|
|
149
149
|
}
|
|
150
150
|
|
|
151
151
|
/**
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@stdlib/strided-base-nullary-addon-dispatch",
|
|
3
|
-
"version": "0.0
|
|
3
|
+
"version": "0.1.0",
|
|
4
4
|
"description": "Dispatch to a native add-on applying a nullary function.",
|
|
5
5
|
"license": "Apache-2.0",
|
|
6
6
|
"author": {
|
|
@@ -37,27 +37,28 @@
|
|
|
37
37
|
"url": "https://github.com/stdlib-js/stdlib/issues"
|
|
38
38
|
},
|
|
39
39
|
"dependencies": {
|
|
40
|
-
"@stdlib/assert-is-function": "^0.0
|
|
41
|
-
"@stdlib/assert-is-nonnegative-integer": "^0.0
|
|
42
|
-
"@stdlib/assert-is-typed-array-like": "^0.0
|
|
43
|
-
"@stdlib/strided-base-dtype-resolve-enum": "^0.0
|
|
44
|
-
"@stdlib/strided-base-min-view-buffer-index": "^0.0
|
|
45
|
-
"@stdlib/strided-base-offset-view": "^0.0
|
|
46
|
-
"@stdlib/strided-base-reinterpret-complex128": "^0.0
|
|
47
|
-
"@stdlib/strided-base-reinterpret-complex64": "^0.0
|
|
48
|
-
"@stdlib/string-format": "^0.0
|
|
49
|
-
"@stdlib/types": "^0.0
|
|
50
|
-
"@stdlib/utils-define-nonenumerable-read-only-property": "^0.0
|
|
40
|
+
"@stdlib/assert-is-function": "^0.1.0",
|
|
41
|
+
"@stdlib/assert-is-nonnegative-integer": "^0.1.0",
|
|
42
|
+
"@stdlib/assert-is-typed-array-like": "^0.1.0",
|
|
43
|
+
"@stdlib/strided-base-dtype-resolve-enum": "^0.1.0",
|
|
44
|
+
"@stdlib/strided-base-min-view-buffer-index": "^0.1.0",
|
|
45
|
+
"@stdlib/strided-base-offset-view": "^0.1.0",
|
|
46
|
+
"@stdlib/strided-base-reinterpret-complex128": "^0.1.0",
|
|
47
|
+
"@stdlib/strided-base-reinterpret-complex64": "^0.1.0",
|
|
48
|
+
"@stdlib/string-format": "^0.1.0",
|
|
49
|
+
"@stdlib/types": "^0.1.0",
|
|
50
|
+
"@stdlib/utils-define-nonenumerable-read-only-property": "^0.1.0",
|
|
51
|
+
"@stdlib/error-tools-fmtprodmsg": "^0.1.0"
|
|
51
52
|
},
|
|
52
53
|
"devDependencies": {
|
|
53
|
-
"@stdlib/array-complex128": "^0.0.
|
|
54
|
-
"@stdlib/array-complex64": "^0.0.
|
|
55
|
-
"@stdlib/array-float64": "^0.0
|
|
56
|
-
"@stdlib/assert-has-own-property": "^0.0
|
|
57
|
-
"@stdlib/assert-is-float32array": "^0.0
|
|
58
|
-
"@stdlib/assert-is-float64array": "^0.0
|
|
59
|
-
"@stdlib/bench": "^0.0
|
|
60
|
-
"@stdlib/utils-noop": "^0.0
|
|
54
|
+
"@stdlib/array-complex128": "^0.0.6",
|
|
55
|
+
"@stdlib/array-complex64": "^0.0.6",
|
|
56
|
+
"@stdlib/array-float64": "^0.1.0",
|
|
57
|
+
"@stdlib/assert-has-own-property": "^0.1.0",
|
|
58
|
+
"@stdlib/assert-is-float32array": "^0.1.0",
|
|
59
|
+
"@stdlib/assert-is-float64array": "^0.1.0",
|
|
60
|
+
"@stdlib/bench": "^0.1.0",
|
|
61
|
+
"@stdlib/utils-noop": "^0.1.0",
|
|
61
62
|
"tape": "git+https://github.com/kgryte/tape.git#fix/globby",
|
|
62
63
|
"istanbul": "^0.4.1",
|
|
63
64
|
"tap-min": "git+https://github.com/Planeshifter/tap-min.git"
|
|
@@ -89,7 +90,7 @@
|
|
|
89
90
|
],
|
|
90
91
|
"__stdlib__": {},
|
|
91
92
|
"funding": {
|
|
92
|
-
"type": "
|
|
93
|
-
"url": "https://
|
|
93
|
+
"type": "opencollective",
|
|
94
|
+
"url": "https://opencollective.com/stdlib"
|
|
94
95
|
}
|
|
95
96
|
}
|
package/docs/repl.txt
DELETED
|
@@ -1,135 +0,0 @@
|
|
|
1
|
-
|
|
2
|
-
{{alias}}( addon, fallback )
|
|
3
|
-
Returns a function which dispatches to a native add-on applying a nullary
|
|
4
|
-
function.
|
|
5
|
-
|
|
6
|
-
The returned function has the following signature:
|
|
7
|
-
|
|
8
|
-
f( N, dtypeX, x, strideX )
|
|
9
|
-
|
|
10
|
-
where
|
|
11
|
-
|
|
12
|
-
- N: number of indexed elements.
|
|
13
|
-
- dtypeX: `x` data type.
|
|
14
|
-
- x: output array.
|
|
15
|
-
- strideX: `x` stride length.
|
|
16
|
-
|
|
17
|
-
To determine whether to dispatch to the `addon` function, the returned
|
|
18
|
-
dispatch function checks whether the provided arrays are typed arrays.
|
|
19
|
-
|
|
20
|
-
If the provided arrays are typed arrays, the dispatch function invokes the
|
|
21
|
-
`addon` function; otherwise, the dispatch function invokes the `fallback`
|
|
22
|
-
function.
|
|
23
|
-
|
|
24
|
-
Parameters
|
|
25
|
-
----------
|
|
26
|
-
addon: Function
|
|
27
|
-
Add-on interface. The function should have the following signature:
|
|
28
|
-
|
|
29
|
-
f( N, dtypeX, x, strideX )
|
|
30
|
-
|
|
31
|
-
where
|
|
32
|
-
|
|
33
|
-
- N: number of indexed elements.
|
|
34
|
-
- dtypeX: `x` data type (enumeration constant).
|
|
35
|
-
- x: output array.
|
|
36
|
-
- strideX: `x` stride length.
|
|
37
|
-
|
|
38
|
-
fallback: Function
|
|
39
|
-
Fallback function. The function should have the following signature:
|
|
40
|
-
|
|
41
|
-
f( N, dtypeX, x, strideX )
|
|
42
|
-
|
|
43
|
-
where
|
|
44
|
-
|
|
45
|
-
- N: number of indexed elements.
|
|
46
|
-
- dtypeX: `x` data type.
|
|
47
|
-
- x: output array.
|
|
48
|
-
- strideX: `x` stride length.
|
|
49
|
-
|
|
50
|
-
Returns
|
|
51
|
-
-------
|
|
52
|
-
fcn: Function
|
|
53
|
-
Dispatch function.
|
|
54
|
-
|
|
55
|
-
Examples
|
|
56
|
-
--------
|
|
57
|
-
> function addon( N, dx, x, sx ) {
|
|
58
|
-
... // Call into native add-on...
|
|
59
|
-
... };
|
|
60
|
-
> function fallback( N, dx, x, sx ) {
|
|
61
|
-
... // Fallback JavaScript implementation...
|
|
62
|
-
... };
|
|
63
|
-
> var f = {{alias}}( addon, fallback );
|
|
64
|
-
> f( 2, 'generic', [ 1, 2 ], 1 );
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
{{alias}}.ndarray( addon, fallback )
|
|
68
|
-
Returns a function which dispatches to a native add-on applying a nullary
|
|
69
|
-
function using alternative indexing semantics.
|
|
70
|
-
|
|
71
|
-
The returned function has the following signature:
|
|
72
|
-
|
|
73
|
-
f( N, dtypeX, x, strideX, offsetX )
|
|
74
|
-
|
|
75
|
-
where
|
|
76
|
-
|
|
77
|
-
- N: number of indexed elements.
|
|
78
|
-
- dtypeX: `x` data type.
|
|
79
|
-
- x: output array.
|
|
80
|
-
- strideX: `x` stride length.
|
|
81
|
-
- offsetX: starting `x` index.
|
|
82
|
-
|
|
83
|
-
To determine whether to dispatch to the `addon` function, the returned
|
|
84
|
-
dispatch function checks whether the provided arrays are typed arrays.
|
|
85
|
-
|
|
86
|
-
If the provided arrays are typed arrays, the dispatch function invokes the
|
|
87
|
-
`addon` function; otherwise, the dispatch function invokes the `fallback`
|
|
88
|
-
function.
|
|
89
|
-
|
|
90
|
-
Parameters
|
|
91
|
-
----------
|
|
92
|
-
addon: Function
|
|
93
|
-
Add-on interface. The function should have the following signature:
|
|
94
|
-
|
|
95
|
-
f( N, dtypeX, x, strideX )
|
|
96
|
-
|
|
97
|
-
where
|
|
98
|
-
|
|
99
|
-
- N: number of indexed elements.
|
|
100
|
-
- dtypeX: `x` data type (enumeration constant).
|
|
101
|
-
- x: output array.
|
|
102
|
-
- strideX: `x` stride length.
|
|
103
|
-
|
|
104
|
-
fallback: Function
|
|
105
|
-
Fallback function. The function should have the following signature:
|
|
106
|
-
|
|
107
|
-
f( N, dtypeX, x, strideX, offsetX )
|
|
108
|
-
|
|
109
|
-
where
|
|
110
|
-
|
|
111
|
-
- N: number of indexed elements.
|
|
112
|
-
- dtypeX: `x` data type.
|
|
113
|
-
- x: output array.
|
|
114
|
-
- strideX: `x` stride length.
|
|
115
|
-
- offsetX: starting `x` index.
|
|
116
|
-
|
|
117
|
-
Returns
|
|
118
|
-
-------
|
|
119
|
-
fcn: Function
|
|
120
|
-
Dispatch function.
|
|
121
|
-
|
|
122
|
-
Examples
|
|
123
|
-
--------
|
|
124
|
-
> function addon( N, dx, x, sx ) {
|
|
125
|
-
... // Call into native add-on...
|
|
126
|
-
... };
|
|
127
|
-
> function fallback( N, dx, x, sx, ox ) {
|
|
128
|
-
... // Fallback JavaScript implementation...
|
|
129
|
-
... };
|
|
130
|
-
> var f = {{alias}}.ndarray( addon, fallback );
|
|
131
|
-
> f( 2, 'generic', [ 1, 2 ], 1, 0 );
|
|
132
|
-
|
|
133
|
-
See Also
|
|
134
|
-
--------
|
|
135
|
-
|
package/docs/types/test.ts
DELETED
|
@@ -1,269 +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
|
-
/// <reference types="@stdlib/types"/>
|
|
20
|
-
|
|
21
|
-
import { Collection } from '@stdlib/types/object';
|
|
22
|
-
import dispatch = require( './index' );
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
// FUNCTIONS //
|
|
26
|
-
|
|
27
|
-
/**
|
|
28
|
-
* Add-on function.
|
|
29
|
-
*
|
|
30
|
-
* @param N - number of indexed elements
|
|
31
|
-
* @param dtypeX - `x` data type (enumeration constant)
|
|
32
|
-
* @param x - output array
|
|
33
|
-
* @param strideX - `x` stride length
|
|
34
|
-
*/
|
|
35
|
-
function addon( N: number, dtypeX: number, x: Collection, strideX: number ): void { // tslint:disable-line:max-line-length
|
|
36
|
-
let i;
|
|
37
|
-
if ( dtypeX !== dtypeX ) {
|
|
38
|
-
throw new Error( 'beep' );
|
|
39
|
-
}
|
|
40
|
-
for ( i = 0; i < N; i += 1 ) {
|
|
41
|
-
x[ i * strideX ] = i;
|
|
42
|
-
}
|
|
43
|
-
}
|
|
44
|
-
|
|
45
|
-
/**
|
|
46
|
-
* Fallback function.
|
|
47
|
-
*
|
|
48
|
-
* @param N - number of indexed elements
|
|
49
|
-
* @param dtypeX - `x` data type
|
|
50
|
-
* @param x - output array
|
|
51
|
-
* @param strideX - `x` stride length
|
|
52
|
-
*/
|
|
53
|
-
function fallback( N: number, dtypeX: any, x: Collection, strideX: number ): void { // tslint:disable-line:max-line-length
|
|
54
|
-
let i;
|
|
55
|
-
if ( dtypeX !== dtypeX ) {
|
|
56
|
-
throw new Error( 'beep' );
|
|
57
|
-
}
|
|
58
|
-
for ( i = 0; i < N; i += 1 ) {
|
|
59
|
-
x[ i * strideX ] = i;
|
|
60
|
-
}
|
|
61
|
-
}
|
|
62
|
-
|
|
63
|
-
/**
|
|
64
|
-
* Fallback function with alternative indexing semantics.
|
|
65
|
-
*
|
|
66
|
-
* @param N - number of indexed elements
|
|
67
|
-
* @param dtypeX - `x` data type
|
|
68
|
-
* @param x - output array
|
|
69
|
-
* @param strideX - `x` stride length
|
|
70
|
-
* @param offsetX - starting `x` index
|
|
71
|
-
*/
|
|
72
|
-
function fallbackWithOffsets( N: number, dtypeX: any, x: Collection, strideX: number, offsetX: number ): void { // tslint:disable-line:max-line-length
|
|
73
|
-
let i;
|
|
74
|
-
if ( dtypeX !== dtypeX ) {
|
|
75
|
-
throw new Error( 'beep' );
|
|
76
|
-
}
|
|
77
|
-
for ( i = 0; i < N; i += 1 ) {
|
|
78
|
-
x[ offsetX + ( i * strideX ) ] = i;
|
|
79
|
-
}
|
|
80
|
-
}
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
// TESTS //
|
|
84
|
-
|
|
85
|
-
// The function returns a dispatch function...
|
|
86
|
-
{
|
|
87
|
-
dispatch( addon, fallback ); // $ExpectType Dispatcher
|
|
88
|
-
}
|
|
89
|
-
|
|
90
|
-
// The compiler throws an error if not provided a first argument which is an add-on function...
|
|
91
|
-
{
|
|
92
|
-
dispatch( '10', fallback ); // $ExpectError
|
|
93
|
-
dispatch( 10, fallback ); // $ExpectError
|
|
94
|
-
dispatch( true, fallback ); // $ExpectError
|
|
95
|
-
dispatch( false, fallback ); // $ExpectError
|
|
96
|
-
dispatch( null, fallback ); // $ExpectError
|
|
97
|
-
dispatch( undefined, fallback ); // $ExpectError
|
|
98
|
-
dispatch( [], fallback ); // $ExpectError
|
|
99
|
-
dispatch( {}, fallback ); // $ExpectError
|
|
100
|
-
dispatch( ( x: string ): string => x, fallback ); // $ExpectError
|
|
101
|
-
}
|
|
102
|
-
|
|
103
|
-
// The compiler throws an error if not provided a second argument which is a fallback function...
|
|
104
|
-
{
|
|
105
|
-
dispatch( addon, '10' ); // $ExpectError
|
|
106
|
-
dispatch( addon, 10 ); // $ExpectError
|
|
107
|
-
dispatch( addon, true ); // $ExpectError
|
|
108
|
-
dispatch( addon, false ); // $ExpectError
|
|
109
|
-
dispatch( addon, null ); // $ExpectError
|
|
110
|
-
dispatch( addon, undefined ); // $ExpectError
|
|
111
|
-
dispatch( addon, [] ); // $ExpectError
|
|
112
|
-
dispatch( addon, {} ); // $ExpectError
|
|
113
|
-
dispatch( addon, ( x: string ): string => x ); // $ExpectError
|
|
114
|
-
}
|
|
115
|
-
|
|
116
|
-
// The returned function returns a collection...
|
|
117
|
-
{
|
|
118
|
-
const x = new Float64Array( 10 );
|
|
119
|
-
|
|
120
|
-
const f = dispatch( addon, fallback );
|
|
121
|
-
|
|
122
|
-
f( x.length, 'float64', x, 1 ); // $ExpectType Collection
|
|
123
|
-
}
|
|
124
|
-
|
|
125
|
-
// The compiler throws an error if the returned function is not provided a first argument which is a number...
|
|
126
|
-
{
|
|
127
|
-
const x = new Float64Array( 10 );
|
|
128
|
-
|
|
129
|
-
const f = dispatch( addon, fallback );
|
|
130
|
-
|
|
131
|
-
f( '10', 'float64', x, 1 ); // $ExpectError
|
|
132
|
-
f( true, 'float64', x, 1 ); // $ExpectError
|
|
133
|
-
f( false, 'float64', x, 1 ); // $ExpectError
|
|
134
|
-
f( null, 'float64', x, 1 ); // $ExpectError
|
|
135
|
-
f( undefined, 'float64', x, 1 ); // $ExpectError
|
|
136
|
-
f( [], 'float64', x, 1 ); // $ExpectError
|
|
137
|
-
f( {}, 'float64', x, 1 ); // $ExpectError
|
|
138
|
-
f( ( x: number ): number => x, 'float64', x, 1 ); // $ExpectError
|
|
139
|
-
}
|
|
140
|
-
|
|
141
|
-
// The compiler throws an error if the returned function is not provided a third argument which is a collection...
|
|
142
|
-
{
|
|
143
|
-
const x = new Float64Array( 10 );
|
|
144
|
-
|
|
145
|
-
const f = dispatch( addon, fallback );
|
|
146
|
-
|
|
147
|
-
f( x.length, 'float64', true, 1 ); // $ExpectError
|
|
148
|
-
f( x.length, 'float64', false, 1 ); // $ExpectError
|
|
149
|
-
f( x.length, 'float64', null, 1 ); // $ExpectError
|
|
150
|
-
f( x.length, 'float64', undefined, 1 ); // $ExpectError
|
|
151
|
-
f( x.length, 'float64', {}, 1 ); // $ExpectError
|
|
152
|
-
}
|
|
153
|
-
|
|
154
|
-
// The compiler throws an error if the returned function is not provided a fourth argument which is a number...
|
|
155
|
-
{
|
|
156
|
-
const x = new Float64Array( 10 );
|
|
157
|
-
|
|
158
|
-
const f = dispatch( addon, fallback );
|
|
159
|
-
|
|
160
|
-
f( x.length, 'float64', x, '10' ); // $ExpectError
|
|
161
|
-
f( x.length, 'float64', x, true ); // $ExpectError
|
|
162
|
-
f( x.length, 'float64', x, false ); // $ExpectError
|
|
163
|
-
f( x.length, 'float64', x, null ); // $ExpectError
|
|
164
|
-
f( x.length, 'float64', x, undefined ); // $ExpectError
|
|
165
|
-
f( x.length, 'float64', x, [] ); // $ExpectError
|
|
166
|
-
f( x.length, 'float64', x, {} ); // $ExpectError
|
|
167
|
-
f( x.length, 'float64', x, ( x: number ): number => x ); // $ExpectError
|
|
168
|
-
}
|
|
169
|
-
|
|
170
|
-
// Attached to the main export is an `ndarray` method which returns a dispatch function...
|
|
171
|
-
{
|
|
172
|
-
dispatch.ndarray( addon, fallbackWithOffsets ); // $ExpectType DispatcherWithOffsets
|
|
173
|
-
}
|
|
174
|
-
|
|
175
|
-
// The compiler throws an error if the `ndarray` method is not provided a first argument which is an add-on function...
|
|
176
|
-
{
|
|
177
|
-
dispatch.ndarray( '10', fallbackWithOffsets ); // $ExpectError
|
|
178
|
-
dispatch.ndarray( 10, fallbackWithOffsets ); // $ExpectError
|
|
179
|
-
dispatch.ndarray( true, fallbackWithOffsets ); // $ExpectError
|
|
180
|
-
dispatch.ndarray( false, fallbackWithOffsets ); // $ExpectError
|
|
181
|
-
dispatch.ndarray( null, fallbackWithOffsets ); // $ExpectError
|
|
182
|
-
dispatch.ndarray( undefined, fallbackWithOffsets ); // $ExpectError
|
|
183
|
-
dispatch.ndarray( [], fallbackWithOffsets ); // $ExpectError
|
|
184
|
-
dispatch.ndarray( {}, fallbackWithOffsets ); // $ExpectError
|
|
185
|
-
dispatch.ndarray( ( x: string ): string => x, fallbackWithOffsets ); // $ExpectError
|
|
186
|
-
}
|
|
187
|
-
|
|
188
|
-
// The compiler throws an error if the `ndarray` method is not provided a second argument which is a fallback function...
|
|
189
|
-
{
|
|
190
|
-
dispatch.ndarray( addon, '10' ); // $ExpectError
|
|
191
|
-
dispatch.ndarray( addon, 10 ); // $ExpectError
|
|
192
|
-
dispatch.ndarray( addon, true ); // $ExpectError
|
|
193
|
-
dispatch.ndarray( addon, false ); // $ExpectError
|
|
194
|
-
dispatch.ndarray( addon, null ); // $ExpectError
|
|
195
|
-
dispatch.ndarray( addon, undefined ); // $ExpectError
|
|
196
|
-
dispatch.ndarray( addon, [] ); // $ExpectError
|
|
197
|
-
dispatch.ndarray( addon, {} ); // $ExpectError
|
|
198
|
-
dispatch.ndarray( addon, ( x: string ): string => x ); // $ExpectError
|
|
199
|
-
}
|
|
200
|
-
|
|
201
|
-
// The `ndarray` method returns a function which returns a collection...
|
|
202
|
-
{
|
|
203
|
-
const x = new Float64Array( 10 );
|
|
204
|
-
|
|
205
|
-
const f = dispatch.ndarray( addon, fallbackWithOffsets );
|
|
206
|
-
|
|
207
|
-
f( x.length, 'float64', x, 1, 0 ); // $ExpectType Collection
|
|
208
|
-
}
|
|
209
|
-
|
|
210
|
-
// The compiler throws an error if the returned function is not provided a first argument which is a number...
|
|
211
|
-
{
|
|
212
|
-
const x = new Float64Array( 10 );
|
|
213
|
-
|
|
214
|
-
const f = dispatch.ndarray( addon, fallbackWithOffsets );
|
|
215
|
-
|
|
216
|
-
f( '10', 'float64', x, 1, 0 ); // $ExpectError
|
|
217
|
-
f( true, 'float64', x, 1, 0 ); // $ExpectError
|
|
218
|
-
f( false, 'float64', x, 1, 0 ); // $ExpectError
|
|
219
|
-
f( null, 'float64', x, 1, 0 ); // $ExpectError
|
|
220
|
-
f( undefined, 'float64', x, 1, 0 ); // $ExpectError
|
|
221
|
-
f( [], 'float64', x, 1, 0 ); // $ExpectError
|
|
222
|
-
f( {}, 'float64', x, 1, 0 ); // $ExpectError
|
|
223
|
-
f( ( x: number ): number => x, 'float64', x, 1, 0 ); // $ExpectError
|
|
224
|
-
}
|
|
225
|
-
|
|
226
|
-
// The compiler throws an error if the returned function is not provided a third argument which is a collection...
|
|
227
|
-
{
|
|
228
|
-
const x = new Float64Array( 10 );
|
|
229
|
-
|
|
230
|
-
const f = dispatch.ndarray( addon, fallbackWithOffsets );
|
|
231
|
-
|
|
232
|
-
f( x.length, 'float64', true, 1, 0 ); // $ExpectError
|
|
233
|
-
f( x.length, 'float64', false, 1, 0 ); // $ExpectError
|
|
234
|
-
f( x.length, 'float64', null, 1, 0 ); // $ExpectError
|
|
235
|
-
f( x.length, 'float64', undefined, 1, 0 ); // $ExpectError
|
|
236
|
-
f( x.length, 'float64', {}, 1, 0 ); // $ExpectError
|
|
237
|
-
}
|
|
238
|
-
|
|
239
|
-
// The compiler throws an error if the returned function is not provided a fourth argument which is a number...
|
|
240
|
-
{
|
|
241
|
-
const x = new Float64Array( 10 );
|
|
242
|
-
|
|
243
|
-
const f = dispatch.ndarray( addon, fallbackWithOffsets );
|
|
244
|
-
|
|
245
|
-
f( x.length, 'float64', x, '10', 0 ); // $ExpectError
|
|
246
|
-
f( x.length, 'float64', x, true, 0 ); // $ExpectError
|
|
247
|
-
f( x.length, 'float64', x, false, 0 ); // $ExpectError
|
|
248
|
-
f( x.length, 'float64', x, null, 0 ); // $ExpectError
|
|
249
|
-
f( x.length, 'float64', x, undefined, 0 ); // $ExpectError
|
|
250
|
-
f( x.length, 'float64', x, [], 0 ); // $ExpectError
|
|
251
|
-
f( x.length, 'float64', x, {}, 0 ); // $ExpectError
|
|
252
|
-
f( x.length, 'float64', x, ( x: number ): number => x, 0 ); // $ExpectError
|
|
253
|
-
}
|
|
254
|
-
|
|
255
|
-
// The compiler throws an error if the returned function is not provided a fifth argument which is a number...
|
|
256
|
-
{
|
|
257
|
-
const x = new Float64Array( 10 );
|
|
258
|
-
|
|
259
|
-
const f = dispatch.ndarray( addon, fallbackWithOffsets );
|
|
260
|
-
|
|
261
|
-
f( x.length, 'float64', x, 1, '10' ); // $ExpectError
|
|
262
|
-
f( x.length, 'float64', x, 1, true ); // $ExpectError
|
|
263
|
-
f( x.length, 'float64', x, 1, false ); // $ExpectError
|
|
264
|
-
f( x.length, 'float64', x, 1, null ); // $ExpectError
|
|
265
|
-
f( x.length, 'float64', x, 1, undefined ); // $ExpectError
|
|
266
|
-
f( x.length, 'float64', x, 1, [] ); // $ExpectError
|
|
267
|
-
f( x.length, 'float64', x, 1, {} ); // $ExpectError
|
|
268
|
-
f( x.length, 'float64', x, 1, ( x: number ): number => x ); // $ExpectError
|
|
269
|
-
}
|