@frosted/array-at
v1.0.1
Published
Get the item at a specified index in an array, allowing for positive and negative integers
Maintainers
Readme
@frosted/array-at
Ponyfill for Array.prototype.at
Installation
npm install @frosted/array-atUsage
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 arrayShimming Array.prototype.at:
require("@frosted/array-at/shim")
console.log([1, 2, 3].at(1)) // 2Tests
Simply clone the repo and run npm test
