New Research: Supply Chain Attack on Axios Pulls Malicious Dependency from npm.Details →
Socket
Book a DemoSign in
Socket

first-value

Package Overview
Dependencies
Maintainers
1
Versions
1
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

first-value

Retrieves the first value of an Array, Iterator, Object, Map, Set, or Typed Array.

latest
Source
npmnpm
Version
1.0.0
Version published
Maintainers
1
Created
Source

first-value

Retrieves the first value of an Array, Iterator, Object, Map, Set, or Typed Array.

Returns undefined if the collection is empty.

Installation

Requires Node.js 7.0.0 or above.

npm i first-value

API

The module exports a single function.

Parameter

Bindable: c (Array, Iterator, Object, Map, Set, or Typed Array): The collection of entries/values.

Return Value

The first value in the collection.

Example

const firstValue = require('first-value')

firstValue([1, 2, 3]) // 1
firstValue({a: 1, b: 2}) // 1
firstValue(new Set([1, 2, 3])) // 1
firstValue(new Map([['a', 1], ['b', 2]])) // 1

firstValue([]) // undefined
  • last-value

Keywords

first

FAQs

Package last updated on 24 Feb 2018

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