npm.io
1.0.1 • Published 7 months ago

@frosted/array-at

Licence
MIT
Version
1.0.1
Deps
10
Size
3 kB
Vulns
0
Weekly
0

@frosted/array-at

Ponyfill for Array.prototype.at

Installation

npm install @frosted/array-at

Usage

const at = require("@frosted/array-at")

console.log(at([1, 2, 3], 1)) // 2

console.log(at([20, 40, 60, 80], -2)) // 60

console.log(at("not array", 2)) // Error: Expects an array

Shimming Array.prototype.at:

require("@frosted/array-at/shim")

console.log([1, 2, 3].at(1)) // 2

Tests

Simply clone the repo and run npm test

Keywords