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.
- Host: GitHub
- URL: https://github.com/lamansky/last-value
- Owner: lamansky
- License: mit
- Created: 2018-02-24T16:59:01.000Z (over 8 years ago)
- Default Branch: master
- Last Pushed: 2018-02-24T16:59:42.000Z (over 8 years ago)
- Last Synced: 2025-10-19T06:04:07.711Z (8 months ago)
- Language: JavaScript
- Size: 1.95 KB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: readme.md
- License: license.txt
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)