You're Invited:Meet the Socket Team at RSAC and BSidesSF 2026, March 23–26.RSVP
Socket
Book a DemoSign in
Socket

it-first

Package Overview
Dependencies
Maintainers
1
Versions
20
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

it-first

Returns the first result from an async iterator

Source
npmnpm
Version
3.0.8
Version published
Weekly downloads
123K
-4.47%
Maintainers
1
Weekly downloads
 
Created
Source

it-first

codecov CI

Returns the first result from an async iterator

About

Return the first value in an (async)iterable

Example

import first from 'it-first'

// This can also be an iterator, generator, etc
const values = [0, 1, 2, 3, 4]

const res = first(values)

console.info(res) // 0

Async sources must be awaited:

import first from 'it-first'

const values = async function * () {
  yield * [0, 1, 2, 3, 4]
}

const res = await first(values())

console.info(res) // 0

Install

$ npm i it-first

Browser <script> tag

Loading this module through a script tag will make its exports available as ItFirst in the global namespace.

<script src="https://unpkg.com/it-first/dist/index.min.js"></script>

API Docs

License

Licensed under either of

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.

FAQs

Package last updated on 13 May 2025

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts