@stdlib/array-base-accessor-setter 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 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
  # accessorSetter
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] -->
@@ -199,8 +210,8 @@ Copyright &copy; 2016-2023. The Stdlib [Authors][stdlib-authors].
199
210
  [npm-image]: http://img.shields.io/npm/v/@stdlib/array-base-accessor-setter.svg
200
211
  [npm-url]: https://npmjs.org/package/@stdlib/array-base-accessor-setter
201
212
 
202
- [test-image]: https://github.com/stdlib-js/array-base-accessor-setter/actions/workflows/test.yml/badge.svg?branch=v0.0.1
203
- [test-url]: https://github.com/stdlib-js/array-base-accessor-setter/actions/workflows/test.yml?query=branch:v0.0.1
213
+ [test-image]: https://github.com/stdlib-js/array-base-accessor-setter/actions/workflows/test.yml/badge.svg?branch=v0.1.0
214
+ [test-url]: https://github.com/stdlib-js/array-base-accessor-setter/actions/workflows/test.yml?query=branch:v0.1.0
204
215
 
205
216
  [coverage-image]: https://img.shields.io/codecov/c/github/stdlib-js/array-base-accessor-setter/main.svg
206
217
  [coverage-url]: https://codecov.io/github/stdlib-js/array-base-accessor-setter?branch=main
@@ -213,7 +224,7 @@ Copyright &copy; 2016-2023. The Stdlib [Authors][stdlib-authors].
213
224
  -->
214
225
 
215
226
  [chat-image]: https://img.shields.io/gitter/room/stdlib-js/stdlib.svg
216
- [chat-url]: https://gitter.im/stdlib-js/stdlib/
227
+ [chat-url]: https://app.gitter.im/#/room/#stdlib-js_stdlib:gitter.im
217
228
 
218
229
  [stdlib]: https://github.com/stdlib-js/stdlib
219
230
 
@@ -0,0 +1,3 @@
1
+ /// <reference path="../docs/types/index.d.ts" />
2
+ import setter from '../docs/types/index';
3
+ export = setter;
package/dist/index.js ADDED
@@ -0,0 +1,5 @@
1
+ "use strict";var u=function(t,e){return function(){return e||t((e={exports:{}}).exports,e),e.exports}};var o=u(function(x,s){
2
+ var n={complex128:i,complex64:f,default:c};function i(t,e,r){t.set(r,e)}function f(t,e,r){t.set(r,e)}function c(t,e,r){t.set(r,e)}function a(t){var e=n[t];return typeof e=="function"?e:n.default}s.exports=a
3
+ });var p=o();module.exports=p;
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) 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// VARIABLES //\n\nvar SETTERS = {\n\t'complex128': setComplex128,\n\t'complex64': setComplex64,\n\t'default': setArrayLike\n};\n\n\n// FUNCTIONS //\n\n/**\n* Sets an element in a `Complex128Array`.\n*\n* @private\n* @param {Complex128Array} arr - input array\n* @param {NonNegativeInteger} idx - element index\n* @param {(Collection|Complex|ComplexArray)} value - value(s)\n*\n* @example\n* var Complex128Array = require( '@stdlib/array-complex128' );\n* var Complex128 = require( '@stdlib/complex-float64' );\n* var real = require( '@stdlib/complex-real' );\n* var imag = require( '@stdlib/complex-imag' );\n*\n* var arr = new Complex128Array( [ 1, 2, 3, 4 ] );\n*\n* setComplex128( arr, 1, new Complex128( 10.0, 11.0 ) );\n* var v = arr.get( 1 );\n* // returns <Complex128>\n*\n* var re = real( v );\n* // returns 10.0\n*\n* var im = imag( v );\n* // returns 11.0\n*/\nfunction setComplex128( arr, idx, value ) {\n\tarr.set( value, idx );\n}\n\n/**\n* Sets an element in a `Complex64Array`.\n*\n* @private\n* @param {Complex64Array} arr - input array\n* @param {NonNegativeInteger} idx - element index\n* @param {(Collection|Complex|ComplexArray)} value - value(s)\n*\n* @example\n* var Complex64Array = require( '@stdlib/array-complex64' );\n* var Complex64 = require( '@stdlib/complex-float32' );\n* var realf = require( '@stdlib/complex-realf' );\n* var imagf = require( '@stdlib/complex-imagf' );\n*\n* var arr = new Complex64Array( [ 1, 2, 3, 4 ] );\n*\n* setComplex64( arr, 1, new Complex64( 10.0, 11.0 ) );\n* var v = arr.get( 1 );\n* // returns <Complex64>\n*\n* var re = realf( v );\n* // returns 10.0\n*\n* var im = imagf( v );\n* // returns 11.0\n*/\nfunction setComplex64( arr, idx, value ) {\n\tarr.set( value, idx );\n}\n\n/**\n* Sets an element in an array-like object supporting the get/set protocol.\n*\n* @private\n* @param {Collection} arr - input array\n* @param {NonNegativeInteger} idx - element index\n* @param {(Collection|Complex|ComplexArray)} value - value(s)\n*\n* @example\n* var arr = [ 1, 2, 3, 4 ];\n*\n* function get( idx ) {\n* return arr[ idx ];\n* }\n*\n* function set( value, idx ) {\n* arr[ idx ] = value;\n* }\n*\n* arr.get = get;\n* arr.set = set;\n*\n* setArrayLike( arr, 2, 10 );\n*\n* var v = arr[ 2 ];\n* // returns 10\n*/\nfunction setArrayLike( arr, idx, value ) {\n\tarr.set( value, idx );\n}\n\n\n// MAIN //\n\n/**\n* Returns an accessor function for setting an element in an array-like object supporting the get/set protocol.\n*\n* @param {string} dtype - array dtype\n* @returns {Function} accessor\n*\n* @example\n* var Complex64Array = require( '@stdlib/array-complex64' );\n* var Complex64 = require( '@stdlib/complex-float32' );\n* var realf = require( '@stdlib/complex-realf' );\n* var imagf = require( '@stdlib/complex-imagf' );\n* var dtype = require( '@stdlib/array-dtype' );\n*\n* var arr = new Complex64Array( [ 1, 2, 3, 4 ] );\n*\n* var set = setter( dtype( arr ) );\n* set( arr, 1, new Complex64( 10.0, 11.0 ) );\n*\n* var v = arr.get( 1 );\n* // returns <Complex64>\n*\n* var re = realf( v );\n* // returns 10.0\n*\n* var im = imagf( v );\n* // returns 11.0\n*/\nfunction setter( dtype ) {\n\tvar f = SETTERS[ dtype ];\n\tif ( typeof f === 'function' ) {\n\t\treturn f;\n\t}\n\treturn SETTERS.default;\n}\n\n\n// EXPORTS //\n\nmodule.exports = setter;\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* Return an accessor function for setting an element in an array-like object supporting the get/set protocol.\n*\n* @module @stdlib/array-base-accessor-setter\n*\n* @example\n* var Complex64Array = require( '@stdlib/array-complex64' );\n* var Complex64 = require( '@stdlib/complex-float32' );\n* var realf = require( '@stdlib/complex-realf' );\n* var imagf = require( '@stdlib/complex-imagf' );\n* var dtype = require( '@stdlib/array-dtype' );\n* var setter = require( '@stdlib/array-base-accessor-setter' );\n*\n* var arr = new Complex64Array( [ 1, 2, 3, 4 ] );\n*\n* var set = setter( dtype( arr ) );\n* set( arr, 1, new Complex64( 10.0, 11.0 ) );\n*\n* var v = arr.get( 1 );\n* // returns <Complex64>\n*\n* var re = realf( v );\n* // returns 10.0\n*\n* var im = imagf( v );\n* // returns 11.0\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,CACb,WAAcC,EACd,UAAaC,EACb,QAAWC,CACZ,EA+BA,SAASF,EAAeG,EAAKC,EAAKC,EAAQ,CACzCF,EAAI,IAAKE,EAAOD,CAAI,CACrB,CA4BA,SAASH,EAAcE,EAAKC,EAAKC,EAAQ,CACxCF,EAAI,IAAKE,EAAOD,CAAI,CACrB,CA6BA,SAASF,EAAcC,EAAKC,EAAKC,EAAQ,CACxCF,EAAI,IAAKE,EAAOD,CAAI,CACrB,CAgCA,SAASE,EAAQC,EAAQ,CACxB,IAAIC,EAAIT,EAASQ,CAAM,EACvB,OAAK,OAAOC,GAAM,WACVA,EAEDT,EAAQ,OAChB,CAKAD,EAAO,QAAUQ,ICjHjB,IAAIG,EAAO,IAKX,OAAO,QAAUA",
6
+ "names": ["require_main", "__commonJSMin", "exports", "module", "SETTERS", "setComplex128", "setComplex64", "setArrayLike", "arr", "idx", "value", "setter", "dtype", "f", "main"]
7
+ }
@@ -16,11 +16,11 @@
16
16
  * limitations under the License.
17
17
  */
18
18
 
19
- // TypeScript Version: 2.0
19
+ // TypeScript Version: 4.1
20
20
 
21
21
  /// <reference types="@stdlib/types"/>
22
22
 
23
- import { ComplexLike } from '@stdlib/types/object';
23
+ import { ComplexLike } from '@stdlib/types/complex';
24
24
  import { Complex64Array, Complex128Array, AccessorArrayLike } from '@stdlib/types/array';
25
25
 
26
26
  /**
@@ -30,7 +30,7 @@ import { Complex64Array, Complex128Array, AccessorArrayLike } from '@stdlib/type
30
30
  * @param idx - element index
31
31
  * @param value - value to set
32
32
  */
33
- type SetComplex128 = ( arr: Complex128Array, idx: number, value: ComplexLike ) => void; // tslint:disable-line:max-line-length
33
+ type SetComplex128 = ( arr: Complex128Array, idx: number, value: ComplexLike ) => void;
34
34
 
35
35
  /**
36
36
  * Sets an element in a `Complex64Array`.
@@ -39,7 +39,7 @@ type SetComplex128 = ( arr: Complex128Array, idx: number, value: ComplexLike ) =
39
39
  * @param idx - element index
40
40
  * @param value - value to set
41
41
  */
42
- type SetComplex64 = ( arr: Complex64Array, idx: number, value: ComplexLike ) => void; // tslint:disable-line:max-line-length
42
+ type SetComplex64 = ( arr: Complex64Array, idx: number, value: ComplexLike ) => void;
43
43
 
44
44
  /**
45
45
  * Sets an element in an array-like object supporting the get/set protocol.
@@ -48,7 +48,7 @@ type SetComplex64 = ( arr: Complex64Array, idx: number, value: ComplexLike ) =>
48
48
  * @param idx - element index
49
49
  * @param value - value to set
50
50
  */
51
- type SetArrayLike = ( arr: AccessorArrayLike<any>, idx: number, value: any ) => void; // tslint:disable-line:max-line-length
51
+ type SetArrayLike<T> = ( arr: AccessorArrayLike<T>, idx: number, value: T ) => void;
52
52
 
53
53
  /**
54
54
  * Returns an accessor function for setting an element in a `Complex128Array`.
@@ -132,7 +132,7 @@ declare function setter( dtype: 'complex64' ): SetComplex64;
132
132
  * var v = arr.get( 2 );
133
133
  * // returns 3
134
134
  */
135
- declare function setter( dtype: string ): SetArrayLike;
135
+ declare function setter<T = unknown>( dtype: string ): SetArrayLike<T>; // tslint:disable-line:no-unnecessary-generics
136
136
 
137
137
 
138
138
  // EXPORTS //
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@stdlib/array-base-accessor-setter",
3
- "version": "0.0.1",
3
+ "version": "0.1.0",
4
4
  "description": "Return an accessor function for setting an element in an array-like object supporting the get/set protocol.",
5
5
  "license": "Apache-2.0",
6
6
  "author": {
@@ -37,25 +37,25 @@
37
37
  "url": "https://github.com/stdlib-js/stdlib/issues"
38
38
  },
39
39
  "dependencies": {
40
- "@stdlib/types": "^0.0.x"
40
+ "@stdlib/types": "^0.1.0"
41
41
  },
42
42
  "devDependencies": {
43
- "@stdlib/array-base-zero-to": "^0.0.x",
44
- "@stdlib/array-complex128": "^0.0.x",
45
- "@stdlib/array-complex64": "^0.0.x",
46
- "@stdlib/array-dtype": "^0.0.x",
47
- "@stdlib/array-filled-by": "^0.0.x",
48
- "@stdlib/assert-is-function": "^0.0.x",
49
- "@stdlib/bench": "^0.0.x",
50
- "@stdlib/complex-float32": "^0.0.x",
51
- "@stdlib/complex-float64": "^0.0.x",
52
- "@stdlib/complex-imag": "^0.0.x",
53
- "@stdlib/complex-imagf": "^0.0.x",
54
- "@stdlib/complex-real": "^0.0.x",
55
- "@stdlib/complex-realf": "^0.0.x",
56
- "@stdlib/math-base-assert-is-nan": "^0.0.x",
57
- "@stdlib/math-base-assert-is-nanf": "^0.0.x",
58
- "@stdlib/random-base-discrete-uniform": "^0.0.x",
43
+ "@stdlib/array-base-zero-to": "^0.1.0",
44
+ "@stdlib/array-complex128": "^0.0.6",
45
+ "@stdlib/array-complex64": "^0.0.6",
46
+ "@stdlib/array-dtype": "^0.0.6",
47
+ "@stdlib/array-filled-by": "^0.0.2",
48
+ "@stdlib/assert-is-function": "^0.1.0",
49
+ "@stdlib/bench": "^0.1.0",
50
+ "@stdlib/complex-float32": "^0.1.0",
51
+ "@stdlib/complex-float64": "^0.1.0",
52
+ "@stdlib/complex-imag": "^0.1.0",
53
+ "@stdlib/complex-imagf": "^0.1.0",
54
+ "@stdlib/complex-real": "^0.1.0",
55
+ "@stdlib/complex-realf": "^0.1.0",
56
+ "@stdlib/math-base-assert-is-nan": "^0.1.0",
57
+ "@stdlib/math-base-assert-is-nanf": "^0.1.0",
58
+ "@stdlib/random-base-discrete-uniform": "^0.0.6",
59
59
  "tape": "git+https://github.com/kgryte/tape.git#fix/globby",
60
60
  "istanbul": "^0.4.1",
61
61
  "tap-min": "git+https://github.com/Planeshifter/tap-min.git"
@@ -86,7 +86,7 @@
86
86
  "setter"
87
87
  ],
88
88
  "funding": {
89
- "type": "patreon",
90
- "url": "https://www.patreon.com/athan"
89
+ "type": "opencollective",
90
+ "url": "https://opencollective.com/stdlib"
91
91
  }
92
92
  }
package/docs/repl.txt DELETED
@@ -1,60 +0,0 @@
1
-
2
- {{alias}}( dtype )
3
- Returns an accessor function for setting an element in an array-like object
4
- supporting the get/set protocol.
5
-
6
- An accessor function accepts the following arguments:
7
-
8
- - arr: input array
9
- - idx: element index
10
- - value: value to set
11
-
12
- If provided an unsupported `dtype`, the function returns a default accessor
13
- function for accessing elements in any indexed array-like object supporting
14
- the get/set protocol.
15
-
16
- Otherwise, the function returns an accessor function which should *only* be
17
- provided an array instance corresponding to `dtype` (e.g., if `dtype` is
18
- 'complex64', the returned accessor function should only be provided
19
- instances of Complex64Array).
20
-
21
- Accessor functions do *not* verify that provided input arrays are array
22
- instances corresponding to `dtype`, as doing so would introduce performance
23
- overhead. If array instances corresponding to other data types are provided
24
- to an accessor function, JavaScript runtimes will consider the function
25
- polymorphic, potentially triggering de-optimization. In order to ensure
26
- maximum performance, *always* ensure that an accessor function is
27
- monomorphic.
28
-
29
- Accessor functions do *not* perform bounds checking.
30
-
31
- Accessor functions do *not* validate input values.
32
-
33
- Accessor functions do *not* verify that provided input arrays actually
34
- implement the get/set protocol.
35
-
36
- Parameters
37
- ----------
38
- dtype: string
39
- Array data type.
40
-
41
- Returns
42
- -------
43
- f: Function
44
- Accessor function.
45
-
46
- Examples
47
- --------
48
- > var f = {{alias}}( 'complex64' );
49
- > var x = {{alias:@stdlib/array/complex64}}( [ 1, 2, 3, 4 ] );
50
- > f( x, 1, new {{alias:@stdlib/complex/float32}}( 10.0, 11.0 ) );
51
- > var v = x.get( 1 )
52
- <Complex64>
53
- > var r = {{alias:@stdlib/complex/realf}}( v )
54
- 10.0
55
- > var i = {{alias:@stdlib/complex/imagf}}( v )
56
- 11.0
57
-
58
- See Also
59
- --------
60
-
@@ -1,177 +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 { AccessorArrayLike } from '@stdlib/types/array';
22
- import Complex128Array = require( '@stdlib/array-complex128' );
23
- import Complex64Array = require( '@stdlib/array-complex64' );
24
- import Complex128 = require( '@stdlib/complex-float64' );
25
- import Complex64 = require( '@stdlib/complex-float32' );
26
- import setter = require( './index' );
27
-
28
- /**
29
- * Returns an array-like object supporting the get/set protocol.
30
- *
31
- * @return array-like object
32
- */
33
- function accessorArray(): AccessorArrayLike<number> {
34
- let arr: AccessorArrayLike<number>;
35
- arr = {
36
- '0': 1,
37
- '1': 2,
38
- '2': 3,
39
- '3': 4,
40
- 'length': 4,
41
- 'get': ( idx: number ): number => {
42
- return arr[ idx ]; // tslint:disable-line:no-unsafe-any
43
- },
44
- 'set': ( value: number, idx: number ): void => {
45
- arr[ idx ] = value;
46
- }
47
- };
48
- return arr;
49
- }
50
-
51
-
52
- // TESTS //
53
-
54
- // The function returns a function...
55
- {
56
- setter( 'complex128' ); // $ExpectType SetComplex128
57
- setter( 'complex64' ); // $ExpectType SetComplex64
58
- setter( 'foo' ); // $ExpectType SetArrayLike
59
- }
60
-
61
- // The compiler throws an error if the function is provided a first argument which is not a string...
62
- {
63
- setter( 5 ); // $ExpectError
64
- setter( true ); // $ExpectError
65
- setter( false ); // $ExpectError
66
- setter( null ); // $ExpectError
67
- setter( {} ); // $ExpectError
68
- setter( [] ); // $ExpectError
69
- setter( ( x: number ): number => x ); // $ExpectError
70
- }
71
-
72
- // The compiler throws an error if the function is provided an unsupported number of arguments...
73
- {
74
- setter(); // $ExpectError
75
- setter( 'complex128', {} ); // $ExpectError
76
- }
77
-
78
- // The function returns a function which sets an array element...
79
- {
80
- const set1 = setter( 'foo' );
81
- const x1 = accessorArray();
82
- set1( x1, 2, 10 ); // $ExpectType void
83
-
84
- const set2 = setter( 'complex128' );
85
- const x2 = new Complex128Array( [ 1, 2, 3, 4 ] );
86
- set2( x2, 1, new Complex128( 5, 6 ) ); // $ExpectType void
87
-
88
- const set3 = setter( 'complex64' );
89
- const x3 = new Complex64Array( [ 1, 2, 3, 4 ] );
90
- set3( x3, 1, new Complex64( 7, 8 ) ); // $ExpectType void
91
- }
92
-
93
- // The compiler throws an error if the returned function is provided a first argument which is not a accessor array...
94
- {
95
- const set1 = setter( 'foo' );
96
- set1( 5, 1, 3 ); // $ExpectError
97
- set1( true, 1, 3 ); // $ExpectError
98
- set1( false, 1, 3 ); // $ExpectError
99
- set1( null, 1, 3 ); // $ExpectError
100
- set1( {}, 1, 3 ); // $ExpectError
101
-
102
- const set2 = setter( 'complex128' );
103
- set2( 5, 1, new Complex128( 5, 6 ) ); // $ExpectError
104
- set2( true, 1, new Complex128( 5, 6 ) ); // $ExpectError
105
- set2( false, 1, new Complex128( 5, 6 ) ); // $ExpectError
106
- set2( null, 1, new Complex128( 5, 6 ) ); // $ExpectError
107
- set2( {}, 1, new Complex128( 5, 6 ) ); // $ExpectError
108
-
109
- const set3 = setter( 'complex64' );
110
- set3( 5, 1, new Complex64( 7, 8 ) ); // $ExpectError
111
- set3( true, 1, new Complex64( 7, 8 ) ); // $ExpectError
112
- set3( false, 1, new Complex64( 7, 8 ) ); // $ExpectError
113
- set3( null, 1, new Complex64( 7, 8 ) ); // $ExpectError
114
- set3( {}, 1, new Complex64( 7, 8 ) ); // $ExpectError
115
- }
116
-
117
- // The compiler throws an error if the returned function is provided a second argument which is not a number...
118
- {
119
- const set1 = setter( 'foo' );
120
- set1( accessorArray(), '5', 3 ); // $ExpectError
121
- set1( accessorArray(), true, 3 ); // $ExpectError
122
- set1( accessorArray(), false, 3 ); // $ExpectError
123
- set1( accessorArray(), null, 3 ); // $ExpectError
124
- set1( accessorArray(), {}, 3 ); // $ExpectError
125
-
126
- const set2 = setter( 'complex128' );
127
- set2( new Complex128Array( [ 1, 2, 3, 4 ] ), '5', new Complex128( 5, 6 ) ); // $ExpectError
128
- set2( new Complex128Array( [ 1, 2, 3, 4 ] ), true, new Complex128( 5, 6 ) ); // $ExpectError
129
- set2( new Complex128Array( [ 1, 2, 3, 4 ] ), false, new Complex128( 5, 6 ) ); // $ExpectError
130
- set2( new Complex128Array( [ 1, 2, 3, 4 ] ), null, new Complex128( 5, 6 ) ); // $ExpectError
131
- set2( new Complex128Array( [ 1, 2, 3, 4 ] ), {}, new Complex128( 5, 6 ) ); // $ExpectError
132
-
133
- const set3 = setter( 'complex64' );
134
- set3( new Complex64Array( [ 1, 2, 3, 4 ] ), '5', new Complex64( 7, 8 ) ); // $ExpectError
135
- set3( new Complex64Array( [ 1, 2, 3, 4 ] ), true, new Complex64( 7, 8 ) ); // $ExpectError
136
- set3( new Complex64Array( [ 1, 2, 3, 4 ] ), false, new Complex64( 7, 8 ) ); // $ExpectError
137
- set3( new Complex64Array( [ 1, 2, 3, 4 ] ), null, new Complex64( 7, 8 ) ); // $ExpectError
138
- set3( new Complex64Array( [ 1, 2, 3, 4 ] ), {}, new Complex64( 7, 8 ) ); // $ExpectError
139
- }
140
-
141
- // The compiler throws an error if the returned function is provided a third argument which is not a valid value...
142
- {
143
- const set2 = setter( 'complex128' );
144
- set2( new Complex128Array( [ 1, 2, 3, 4 ] ), 1, '5' ); // $ExpectError
145
- set2( new Complex128Array( [ 1, 2, 3, 4 ] ), 1, true ); // $ExpectError
146
- set2( new Complex128Array( [ 1, 2, 3, 4 ] ), 1, false ); // $ExpectError
147
- set2( new Complex128Array( [ 1, 2, 3, 4 ] ), 1, null ); // $ExpectError
148
- set2( new Complex128Array( [ 1, 2, 3, 4 ] ), 1, {} ); // $ExpectError
149
-
150
- const set3 = setter( 'complex64' );
151
- set3( new Complex64Array( [ 1, 2, 3, 4 ] ), 1, '5' ); // $ExpectError
152
- set3( new Complex64Array( [ 1, 2, 3, 4 ] ), 1, true ); // $ExpectError
153
- set3( new Complex64Array( [ 1, 2, 3, 4 ] ), 1, false ); // $ExpectError
154
- set3( new Complex64Array( [ 1, 2, 3, 4 ] ), 1, null ); // $ExpectError
155
- set3( new Complex64Array( [ 1, 2, 3, 4 ] ), 1, {} ); // $ExpectError
156
- }
157
-
158
- // The compiler throws an error if the returned function is provided an unsupported number of arguments...
159
- {
160
- const set1 = setter( 'foo' );
161
- set1(); // $ExpectError
162
- set1( [] ); // $ExpectError
163
- set1( [], 1 ); // $ExpectError
164
- set1( [], 1, 2, 2 ); // $ExpectError
165
-
166
- const set2 = setter( 'complex128' );
167
- set2(); // $ExpectError
168
- set2( new Complex128Array( [] ) ); // $ExpectError
169
- set2( new Complex128Array( [] ), 1 ); // $ExpectError
170
- set2( new Complex128Array( [] ), 1, new Complex128( 5, 6 ), 2 ); // $ExpectError
171
-
172
- const set3 = setter( 'complex64' );
173
- set3(); // $ExpectError
174
- set3( new Complex64Array( [] ) ); // $ExpectError
175
- set3( new Complex64Array( [] ), 1 ); // $ExpectError
176
- set3( new Complex64Array( [] ), 1, new Complex64( 7, 8 ), 2 ); // $ExpectError
177
- }