From c3fcfc920a4dbf4b048107f2e355362dc6db875a Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Sat, 13 Jul 2024 21:18:13 +0000 Subject: [PATCH] Auto-generated commit --- CHANGELOG.md | 2 + bool/README.md | 80 +++++++ bool/benchmark/benchmark.keys.js | 51 +++++ bool/benchmark/benchmark.keys.length.js | 102 +++++++++ bool/benchmark/benchmark.values.js | 51 +++++ bool/benchmark/benchmark.values.length.js | 102 +++++++++ bool/benchmark/benchmark.with.js | 56 +++++ bool/benchmark/benchmark.with.length.js | 100 ++++++++ bool/docs/repl.txt | 69 ++++++ bool/docs/types/index.d.ts | 73 ++++++ bool/lib/main.js | 264 ++++++++++++++++++++++ bool/test/test.keys.js | 261 +++++++++++++++++++++ bool/test/test.values.js | 263 +++++++++++++++++++++ bool/test/test.with.js | 200 ++++++++++++++++ 14 files changed, 1674 insertions(+) create mode 100644 bool/benchmark/benchmark.keys.js create mode 100644 bool/benchmark/benchmark.keys.length.js create mode 100644 bool/benchmark/benchmark.values.js create mode 100644 bool/benchmark/benchmark.values.length.js create mode 100644 bool/benchmark/benchmark.with.js create mode 100644 bool/benchmark/benchmark.with.length.js create mode 100644 bool/test/test.keys.js create mode 100644 bool/test/test.values.js create mode 100644 bool/test/test.with.js diff --git a/CHANGELOG.md b/CHANGELOG.md index 704262dd..7458083e 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1324,6 +1324,7 @@ This release closes the following issue: ##### Features +- [`ce3ad9a`](https://github.com/stdlib-js/stdlib/commit/ce3ad9a98468829b294708ca188ec669056e58ed) - add `keys`, `values`, and `with` methods to `array/bool` [(#2590)](https://github.com/stdlib-js/stdlib/pull/2590) - [`5a66b4b`](https://github.com/stdlib-js/stdlib/commit/5a66b4bb677cdbc4706811ea9f776343297c9f87) - add `join` and `toString` methods to `array/bool` [(#2557)](https://github.com/stdlib-js/stdlib/pull/2557) - [`4a6be43`](https://github.com/stdlib-js/stdlib/commit/4a6be430830868fb181bfa0b8923f37dabaffe8a) - add `reduce` and `reduceRight` methods to `array/bool` [(#2509)](https://github.com/stdlib-js/stdlib/pull/2509) - [`29615af`](https://github.com/stdlib-js/stdlib/commit/29615af970796a43f65f4b00d29bd23a122f2208) - add `slice` and `subarray` methods to `array/bool` [(#2472)](https://github.com/stdlib-js/stdlib/pull/2472) @@ -2435,6 +2436,7 @@ A total of 13 people contributed to this release. Thank you to the following con
+- [`ce3ad9a`](https://github.com/stdlib-js/stdlib/commit/ce3ad9a98468829b294708ca188ec669056e58ed) - **feat:** add `keys`, `values`, and `with` methods to `array/bool` [(#2590)](https://github.com/stdlib-js/stdlib/pull/2590) _(by Jaysukh Makvana)_ - [`2cf1a24`](https://github.com/stdlib-js/stdlib/commit/2cf1a248120648c46ca4e5bd6535c62a6f3eba6e) - **docs:** update namespace TypeScript declarations [(#2582)](https://github.com/stdlib-js/stdlib/pull/2582) _(by stdlib-bot, Athan Reines)_ - [`66dce03`](https://github.com/stdlib-js/stdlib/commit/66dce034698fdbd71248cad9c7d277ac97cdf0ae) - **feat:** add boolean dtype support to `array/min-dtype` [(#2556)](https://github.com/stdlib-js/stdlib/pull/2556) _(by Jaysukh Makvana, Athan Reines)_ - [`5a66b4b`](https://github.com/stdlib-js/stdlib/commit/5a66b4bb677cdbc4706811ea9f776343297c9f87) - **feat:** add `join` and `toString` methods to `array/bool` [(#2557)](https://github.com/stdlib-js/stdlib/pull/2557) _(by Jaysukh Makvana, Athan Reines)_ diff --git a/bool/README.md b/bool/README.md index 6ad6b03c..597fcaa0 100644 --- a/bool/README.md +++ b/bool/README.md @@ -710,6 +710,35 @@ var str = arr.join( '|' ); // returns 'true|false|true' ``` + + +#### BooleanArray.prototype.keys() + +Returns an iterator for iterating over each index key in a typed array. + +```javascript +var arr = new BooleanArray( 2 ); + +arr.set( true, 0 ); +arr.set( false, 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. + #### BooleanArray.prototype.lastIndexOf( searchElement\[, fromIndex] ) @@ -1337,6 +1366,55 @@ var str = arr.toString(); // returns 'true,false,true' ``` + + +#### BooleanArray.prototype.values() + +Returns an iterator for iterating over each value in a typed array. + +```javascript +var arr = new BooleanArray( 2 ); + +arr.set( true, 0 ); +arr.set( false, 1 ); + +var iter = arr.values(); + +var v = iter.next().value; +// returns true + +v = iter.next().value; +// returns false + +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. + + + +#### BooleanArray.prototype.with( index, value ) + +Returns a new typed array with the element at a provided index replaced with a provided value. + +```javascript +var arr = new BooleanArray( 3 ); + +arr.set( true, 0 ); +arr.set( false, 1 ); +arr.set( true, 1 ); + +var out = arr.with( 0, false ); +// returns + +var v = out.get( 0 ); +// returns false +``` + @@ -1419,6 +1497,8 @@ console.log( '%s', false );