Skip to content

Commit d88ccc1

Browse files
committed
feat: add readme for entries method of array/fixed-endian-factory
1 parent 6f1c381 commit d88ccc1

File tree

1 file changed

+57
-0
lines changed
  • lib/node_modules/@stdlib/array/fixed-endian-factory

1 file changed

+57
-0
lines changed

lib/node_modules/@stdlib/array/fixed-endian-factory/README.md

Lines changed: 57 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -705,6 +705,60 @@ var str = arr.toString();
705705

706706
* * *
707707

708+
<a name="method-entries"></a>
709+
710+
#### TypedArrayFE.prototype.entries()
711+
712+
Return and iterator for iterating over array key-value pairs.
713+
714+
```javascript
715+
var factory = require( '@stdlib/array/fixed-endian-factory' );
716+
var int32arr = factory( 'int32' );
717+
var arr = int32arr( 'little-endian', [ 1, 2, 3, 4, 5 ] );
718+
719+
// Creat an iterator:
720+
var itr = arr.entries();
721+
722+
// Iterate over the key-value pairs...
723+
var v = itr.next().value;
724+
// returns [ 0, 1 ];
725+
726+
var i = v[1];
727+
// returns 1;
728+
729+
v = itr.next().value;
730+
// returns [ 1, 2 ];
731+
732+
i = v[1];
733+
// returns 2;
734+
735+
v = itr.next().value;
736+
// returns [ 2, 3 ];
737+
738+
i = v[1];
739+
// returns 3;
740+
741+
v = itr.next().value;
742+
// returns [ 3, 4 ]
743+
744+
i = v[1];
745+
// returns 4
746+
747+
v = itr.next().value;
748+
// returns [ 4, 5 ];
749+
750+
i = v[1];
751+
// returns 5
752+
753+
var bool = itr.next().done;
754+
// returns true
755+
```
756+
757+
The returned [iterator][mdn-iterator-protocol] protocol-compliant object has the following properties:
758+
759+
- **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.
760+
- **return**: function which closes an [iterator][mdn-iterator-protocol] and returns a single (optional) argument in an [iterator][mdn-iterator-protocol] protocol-compliant object.
761+
708762
## Notes
709763

710764
- A returned constructor supports the following byte orders:
@@ -782,6 +836,8 @@ logEach( '%s', out );
782836

783837
<section class="links">
784838

839+
[mdn-iterator-protocol]: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Iteration_protocols#The_iterator_protocol
840+
785841
[@stdlib/array/typed]: https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/array/typed
786842

787843
[@stdlib/array/buffer]: https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/array/buffer
@@ -793,3 +849,4 @@ logEach( '%s', out );
793849
</section>
794850

795851
<!-- /.links -->
852+

0 commit comments

Comments
 (0)