Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

iterator-helper

Package Overview
Dependencies
Maintainers
1
Versions
13
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

iterator-helper - npm Package Compare versions

Comparing version 1.3.1 to 1.3.2

2

package.json
{
"name": "iterator-helper",
"version": "1.3.1",
"version": "1.3.2",
"description": "",

@@ -5,0 +5,0 @@ "main": "dist/index.js",

@@ -249,1 +249,21 @@ # iterator-helper

```
### Example
```ts
for (const i of iter.range(10)) {
// i will goes from 0 to 9 (included)
}
for (const _ of iter.repeat(null, 10)) {
// This loop content will be executed 10 times
}
iter.repeat({ id: 1, name: 'Sialae' }) // Create an infinite iterator that yield { id: 1, name: 'Sialae' }
.asIndexedPairs() // Yield [index, element]
.map(([index, item]) => ({ ...item, id: index + 1 })) // For [index, element], returns { ...element, id: index + 1 }
.filter(item => item.id % 2 !== 0) // Yield only elements with element.id % 2 !== 0
.take(3) // Yield 3 items maximum then close the iterator
.toArray(); // Store the remaining iterator items into an array (3 elements)
// Result: [{ name: 'Sialae', id: 0 }, { name: 'Sialae', id: 2 }, { name: 'Sialae', id: 4 }]
```
SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc