Skip to content

frosted-javascript/array-at

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

2 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

@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