1.0.1 • Published 3 years ago

indexable-at v1.0.1

Weekly downloads
-
License
MIT
Repository
github
Last release
3 years ago

indexable-at NPM version

polyfill for Array#at https://github.com/tc39/proposal-relative-indexing-method

Install

Install with npm:

$ npm install --save indexable-at

Usage

require('indexable-at');

const arr = [1, 2, 3, 4, 5, 6];
console.log(arr.at(1)); // 2
console.log(arr.at(-1)); // 6

const str = 'abcde';
console.log(str.at(1)); // 'b'
console.log(str.at(-1)); // 'e'

const int8 = new Int8Array([1, 2, 3, 4]);
console.log(int8.at(-1)); // 4