An open API service indexing awesome lists of open source software.

https://github.com/lamansky/last-value

[Node.js] Retrieves the last value of an Array, Iterator, Object, Map, Set, or Typed Array.
https://github.com/lamansky/last-value

Last synced: 2 months ago
JSON representation

[Node.js] Retrieves the last value of an Array, Iterator, Object, Map, Set, or Typed Array.

Awesome Lists containing this project

README

          

# last-value

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

Returns `undefined` if the collection is empty.

## Installation

Requires [Node.js](https://nodejs.org/) 7.0.0 or above.

```bash
npm i last-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 last value in the collection.

## Example

```javascript
const lastValue = require('last-value')

lastValue([1, 2, 3]) // 3
lastValue({a: 1, b: 2}) // 2

// Supports the bind operator
[1, 2, 3]::lastValue() // 3
```

## Related

* [first-value](https://github.com/lamansky/first-value)