From 851f39ca3ba4c477bfc40b5d542d2e8ba5a97c45 Mon Sep 17 00:00:00 2001 From: Jaysukh-409 Date: Tue, 16 Apr 2024 10:46:38 +0530 Subject: [PATCH] feat: add keys method to array/complex128 --- .../@stdlib/array/complex128/README.md | 33 ++- .../complex128/benchmark/benchmark.keys.js | 51 ++++ .../benchmark/benchmark.keys.length.js | 103 +++++++ .../array/complex128/docs/types/index.d.ts | 26 +- .../@stdlib/array/complex128/lib/main.js | 103 ++++++- .../array/complex128/test/test.keys.js | 261 ++++++++++++++++++ 6 files changed, 574 insertions(+), 3 deletions(-) create mode 100644 lib/node_modules/@stdlib/array/complex128/benchmark/benchmark.keys.js create mode 100644 lib/node_modules/@stdlib/array/complex128/benchmark/benchmark.keys.length.js create mode 100644 lib/node_modules/@stdlib/array/complex128/test/test.keys.js diff --git a/lib/node_modules/@stdlib/array/complex128/README.md b/lib/node_modules/@stdlib/array/complex128/README.md index f93ab08a8a02..2715f55acff3 100644 --- a/lib/node_modules/@stdlib/array/complex128/README.md +++ b/lib/node_modules/@stdlib/array/complex128/README.md @@ -2,7 +2,7 @@ @license Apache-2.0 -Copyright (c) 2018 The Stdlib Authors. +Copyright (c) 2024 The Stdlib Authors. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. @@ -1505,6 +1505,35 @@ var str = arr.join( '/' ); // returns '1 + 1i/2 - 2i/3 + 3i' ``` + + +#### Complex128Array.prototype.keys() + +Returns an iterator for iterating over each index key in a typed array. + +```javascript +var arr = new Complex128Array( 2 ); + +arr.set( [ 1.0, -1.0 ], 0 ); +arr.set( [ 2.0, -2.0 ], 1 ); + +var iter = arr.keys(); + +var v = iter.next().value; +// returns 0 + +v = iter.next().value; +// returns 1 + +var bool = iter.next().done; +// returns true +``` + +The returned [iterator][mdn-iterator-protocol] protocol-compliant object has the following properties: + +- **next**: function which returns an [iterator][mdn-iterator-protocol] protocol-compliant object containing the next iterated value (if one exists) assigned to a `value` property and a `done` property having a `boolean` value indicating whether the [iterator][mdn-iterator-protocol] is finished. +- **return**: function which closes an [iterator][mdn-iterator-protocol] and returns a single (optional) argument in an [iterator][mdn-iterator-protocol] protocol-compliant object. + #### Complex128Array.prototype.lastIndexOf( searchElement\[, fromIndex] ) @@ -2350,6 +2379,8 @@ logEach( '%s', out );