New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

it-peekable

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

it-peekable - npm Package Compare versions

Comparing version 3.0.2 to 3.0.3

62

dist/src/index.d.ts

@@ -1,12 +0,58 @@

interface Peek<T> {
peek: () => IteratorResult<T, undefined>;
/**
* @packageDocumentation
*
* Lets you look at the contents of an async iterator and decide what to do
*
* @example
*
* ```javascript
* import peekable from 'it-peekable'
*
* // This can also be an iterator, generator, etc
* const values = [0, 1, 2, 3, 4]
*
* const it = peekable(value)
*
* const first = it.peek()
*
* console.info(first) // 0
*
* it.push(first)
*
* console.info([...it])
* // [ 0, 1, 2, 3, 4 ]
* ```
*
* Async sources must be awaited:
*
* ```javascript
* import peekable from 'it-peekable'
*
* const values = async function * () {
* yield * [0, 1, 2, 3, 4]
* }
*
* const it = peekable(values())
*
* const first = await it.peek()
*
* console.info(first) // 0
*
* it.push(first)
*
* console.info(await all(it))
* // [ 0, 1, 2, 3, 4 ]
* ```
*/
export interface Peek<T> {
peek(): IteratorResult<T, undefined>;
}
interface AsyncPeek<T> {
peek: () => Promise<IteratorResult<T, undefined>>;
export interface AsyncPeek<T> {
peek(): Promise<IteratorResult<T, undefined>>;
}
interface Push<T> {
push: (value: T) => void;
export interface Push<T> {
push(value: T): void;
}
type Peekable<T> = Iterable<T> & Peek<T> & Push<T> & Iterator<T>;
type AsyncPeekable<T> = AsyncIterable<T> & AsyncPeek<T> & Push<T> & AsyncIterator<T>;
export type Peekable<T> = Iterable<T> & Peek<T> & Push<T> & Iterator<T>;
export type AsyncPeekable<T> = AsyncIterable<T> & AsyncPeek<T> & Push<T> & AsyncIterator<T>;
declare function peekable<T>(iterable: Iterable<T>): Peekable<T>;

@@ -13,0 +59,0 @@ declare function peekable<T>(iterable: AsyncIterable<T>): AsyncPeekable<T>;

@@ -0,1 +1,47 @@

/**
* @packageDocumentation
*
* Lets you look at the contents of an async iterator and decide what to do
*
* @example
*
* ```javascript
* import peekable from 'it-peekable'
*
* // This can also be an iterator, generator, etc
* const values = [0, 1, 2, 3, 4]
*
* const it = peekable(value)
*
* const first = it.peek()
*
* console.info(first) // 0
*
* it.push(first)
*
* console.info([...it])
* // [ 0, 1, 2, 3, 4 ]
* ```
*
* Async sources must be awaited:
*
* ```javascript
* import peekable from 'it-peekable'
*
* const values = async function * () {
* yield * [0, 1, 2, 3, 4]
* }
*
* const it = peekable(values())
*
* const first = await it.peek()
*
* console.info(first) // 0
*
* it.push(first)
*
* console.info(await all(it))
* // [ 0, 1, 2, 3, 4 ]
* ```
*/
function peekable(iterable) {

@@ -2,0 +48,0 @@ // @ts-expect-error can't use Symbol.asyncIterator to index iterable since it might be Iterable

5

package.json
{
"name": "it-peekable",
"version": "3.0.2",
"version": "3.0.3",
"description": "Allows peeking/pushing an iterable",

@@ -32,2 +32,3 @@ "author": "Alex Potsides <alex@achingbrain.net>",

"parserOptions": {
"project": true,
"sourceType": "module"

@@ -135,5 +136,5 @@ }

"devDependencies": {
"aegir": "^40.0.11",
"aegir": "^41.1.9",
"it-all": "^3.0.0"
}
}

@@ -1,3 +0,1 @@

# it-peekable <!-- omit in toc -->
[![codecov](https://img.shields.io/codecov/c/github/achingbrain/it.svg?style=flat-square)](https://codecov.io/gh/achingbrain/it)

@@ -8,27 +6,7 @@ [![CI](https://img.shields.io/github/actions/workflow/status/achingbrain/it/js-test-and-release.yml?branch=master\&style=flat-square)](https://github.com/achingbrain/it/actions/workflows/js-test-and-release.yml?query=branch%3Amaster)

## Table of contents <!-- omit in toc -->
# About
- [Install](#install)
- [Browser `<script>` tag](#browser-script-tag)
- [Usage](#usage)
- [License](#license)
- [Contribution](#contribution)
## Install
```console
$ npm i it-peekable
```
### Browser `<script>` tag
Loading this module through a script tag will make it's exports available as `ItPeekable` in the global namespace.
```html
<script src="https://unpkg.com/it-peekable/dist/index.min.js"></script>
```
Lets you look at the contents of an async iterator and decide what to do
## Usage
## Example

@@ -74,4 +52,18 @@ ```javascript

## License
# Install
```console
$ npm i it-peekable
```
## Browser `<script>` tag
Loading this module through a script tag will make it's exports available as `ItPeekable` in the global namespace.
```html
<script src="https://unpkg.com/it-peekable/dist/index.min.js"></script>
```
# License
Licensed under either of

@@ -82,4 +74,4 @@

## Contribution
# Contribution
Unless you explicitly state otherwise, any contribution intentionally submitted for inclusion in the work by you, as defined in the Apache-2.0 license, shall be dual licensed as above, without any additional terms or conditions.

@@ -1,16 +0,63 @@

interface Peek <T> {
peek: () => IteratorResult<T, undefined>
/**
* @packageDocumentation
*
* Lets you look at the contents of an async iterator and decide what to do
*
* @example
*
* ```javascript
* import peekable from 'it-peekable'
*
* // This can also be an iterator, generator, etc
* const values = [0, 1, 2, 3, 4]
*
* const it = peekable(value)
*
* const first = it.peek()
*
* console.info(first) // 0
*
* it.push(first)
*
* console.info([...it])
* // [ 0, 1, 2, 3, 4 ]
* ```
*
* Async sources must be awaited:
*
* ```javascript
* import peekable from 'it-peekable'
*
* const values = async function * () {
* yield * [0, 1, 2, 3, 4]
* }
*
* const it = peekable(values())
*
* const first = await it.peek()
*
* console.info(first) // 0
*
* it.push(first)
*
* console.info(await all(it))
* // [ 0, 1, 2, 3, 4 ]
* ```
*/
export interface Peek <T> {
peek(): IteratorResult<T, undefined>
}
interface AsyncPeek <T> {
peek: () => Promise<IteratorResult<T, undefined>>
export interface AsyncPeek <T> {
peek(): Promise<IteratorResult<T, undefined>>
}
interface Push <T> {
push: (value: T) => void
export interface Push <T> {
push(value: T): void
}
type Peekable <T> = Iterable<T> & Peek<T> & Push<T> & Iterator<T>
export type Peekable <T> = Iterable<T> & Peek<T> & Push<T> & Iterator<T>
type AsyncPeekable <T> = AsyncIterable<T> & AsyncPeek<T> & Push<T> & AsyncIterator<T>
export type AsyncPeekable <T> = AsyncIterable<T> & AsyncPeek<T> & Push<T> & AsyncIterator<T>

@@ -17,0 +64,0 @@ function peekable <T> (iterable: Iterable<T>): Peekable<T>

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

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