Skip to content

docs: update examples for array/base/accessor-setter #6078

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
26 changes: 4 additions & 22 deletions lib/node_modules/@stdlib/array/base/accessor-setter/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -47,22 +47,13 @@ Returns an accessor function for setting an element in an array-like object supp
```javascript
var Complex64Array = require( '@stdlib/array/complex64' );
var Complex64 = require( '@stdlib/complex/float32/ctor' );
var realf = require( '@stdlib/complex/float32/real' );
var imagf = require( '@stdlib/complex/float32/imag' );

var arr = new Complex64Array( [ 1, 2, 3, 4 ] );
var arr = new Complex64Array( [ 1.0, 2.0, 3.0, 4.0 ] );

var set = accessorSetter( 'complex64' );
set( arr, 1, new Complex64( 10.0, 11.0 ) );

var v = arr.get( 1 );
// returns <Complex64>

var re = realf( v );
// returns 10.0

var im = imagf( v );
// returns 11.0
// arr => <Complex64Array>[ 1.0, 2.0, 10.0, 11.0 ]
```

The returned accessor function accepts the following arguments:
Expand Down Expand Up @@ -112,22 +103,13 @@ var accessorSetter = require( '@stdlib/array/base/accessor-setter' );
var arr = new Complex128Array( zeroTo( 10 ) );
accessorSetter( dtype( arr ) )( arr, 2, new Complex128( 100.0, 101.0 ) );

var v = arr.get( 2 );
// returns <Complex128>

console.log( '%s', v.toString() );
// => '100 + 101i'
// arr=> <Complex128Array>[ 0.0, 1.0, 100.0, 101.0, 4.0, 5.0, 6.0, 7.0, 8.0, 9.0 ]

arr = new Complex64Array( zeroTo( 10 ) );
accessorSetter( dtype( arr ) )( arr, 4, new Complex64( 102.0, 103.0 ) );

v = arr.get( 4 );
// returns <Complex64>

console.log( '%s', v.toString() );
// => '102 + 103i'
// arr => <Complex64Array>[ 0.0, 1.0, 2.0, 3.0, 102.0, 103.0, 6.0, 7.0, 8.0, 9.0 ]
```

</section>

<!-- /.examples -->
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -46,15 +46,11 @@
Examples
--------
> var f = {{alias}}( 'complex64' );
> var x = {{alias:@stdlib/array/complex64}}( [ 1, 2, 3, 4 ] );
> var x = {{alias:@stdlib/array/complex64}}( [ 1.0, 2.0, 3.0, 4.0 ] );
> f( x, 1, new {{alias:@stdlib/complex/float32/ctor}}( 10.0, 11.0 ) );
> var v = x.get( 1 )
<Complex64>
> var r = {{alias:@stdlib/complex/float32/real}}( v )
10.0
> var i = {{alias:@stdlib/complex/float32/imag}}( v )
11.0

> x
<Complex64Array>[ 1.0, 2.0, 10.0, 11.0 ]

See Also
--------

Original file line number Diff line number Diff line change
Expand Up @@ -59,22 +59,13 @@
* @example
* var Complex128Array = require( '@stdlib/array/complex128' );
* var Complex128 = require( '@stdlib/complex/float64/ctor' );
* var real = require( '@stdlib/array/real' );
* var imag = require( '@stdlib/array/imag' );
*
* var arr = new Complex128Array( [ 1, 2, 3, 4 ] );
*

Check failure on line 62 in lib/node_modules/@stdlib/array/base/accessor-setter/docs/types/index.d.ts

View workflow job for this annotation

GitHub Actions / Lint Changed Files

Trailing spaces not allowed
* var arr = new Complex128Array( [ 1.0, 2.0, 3.0, 4.0 ] );
*
* var set = setter( 'complex128' );
* set( arr, 1, new Complex128( 10.0, 11.0 ) );
*
* var v = arr.get( 1 );
* // returns <Complex128>
*
* var re = real( v );
* // returns 10.0
*
* var im = imag( v );
* // returns 11.0
* // arr => <Complex128Array>[ 1.0, 2.0, 10.0, 11.0 ]
*/
declare function setter( dtype: 'complex128' ): SetComplex128;

Expand All @@ -87,22 +78,13 @@
* @example
* var Complex64Array = require( '@stdlib/array/complex64' );
* var Complex64 = require( '@stdlib/complex/float32/ctor' );
* var realf = require( '@stdlib/array/realf' );
* var imagf = require( '@stdlib/array/imagf' );
*
* var arr = new Complex64Array( [ 1, 2, 3, 4 ] );
*

Check failure on line 81 in lib/node_modules/@stdlib/array/base/accessor-setter/docs/types/index.d.ts

View workflow job for this annotation

GitHub Actions / Lint Changed Files

Trailing spaces not allowed
* var arr = new Complex64Array( [ 1.0, 2.0, 3.0, 4.0 ] );
*
* var set = setter( 'complex64' );
* set( arr, 1, new Complex64( 10.0, 11.0 ) );
*
* var v = arr.get( 1 );
* // returns <Complex64>
*
* var re = realf( v );
* // returns 3.0
*
* var im = imagf( v );
* // returns 4.0
*

Check failure on line 86 in lib/node_modules/@stdlib/array/base/accessor-setter/docs/types/index.d.ts

View workflow job for this annotation

GitHub Actions / Lint Changed Files

Trailing spaces not allowed
* // arr => <Complex64Array>[ 1.0, 2.0, 10.0, 11.0 ]
*/
declare function setter( dtype: 'complex64' ): SetComplex64;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,17 +29,10 @@
var arr = new Complex128Array( zeroTo( 10 ) );
accessorSetter( dtype( arr ) )( arr, 2, new Complex128( 100.0, 101.0 ) );

var v = arr.get( 2 );
// returns <Complex128>

console.log( '%s', v.toString() );
// => '100 + 101i'
// arr=> <Complex128Array>[ 0.0, 1.0, 100.0, 101.0, 4.0, 5.0, 6.0, 7.0, 8.0, 9.0 ]

arr = new Complex64Array( zeroTo( 10 ) );
accessorSetter( dtype( arr ) )( arr, 4, new Complex64( 102.0, 103.0 ) );

v = arr.get( 4 );
// returns <Complex64>
// arr => <Complex64Array>[ 0.0, 1.0, 2.0, 3.0, 102.0, 103.0, 6.0, 7.0, 8.0, 9.0 ]

Check failure on line 37 in lib/node_modules/@stdlib/array/base/accessor-setter/examples/index.js

View workflow job for this annotation

GitHub Actions / Lint Changed Files

Only one blank line is allowed

console.log( '%s', v.toString() );
// => '102 + 103i'
Loading