All Projects → es-shims → Array.prototype.at

es-shims / Array.prototype.at

Licence: MIT license
An ES-spec-compliant (proposed) `Array.prototype.at`shim/polyfill/replacement that works as far down as ES3.

Programming Languages

javascript
184084 projects - #8 most used programming language

Projects that are alternatives of or similar to Array.prototype.at

array-includes
Array.prototype.includes spec-compliant polyfill
Stars: ✭ 42 (+110%)
Mutual labels:  polyfill, array, shim
object-keys
Object.keys shim
Stars: ✭ 41 (+105%)
Mutual labels:  polyfill, shim
Object.getOwnPropertyDescriptors
Spec-compliant shim for `Object.getOwnPropertyDescriptors` that works in ES5.
Stars: ✭ 19 (-5%)
Mutual labels:  polyfill, shim
String.prototype.matchAll
Spec-compliant polyfill for String.prototype.matchAll, in ES2020
Stars: ✭ 14 (-30%)
Mutual labels:  polyfill, shim
barcode-detector
Spec compliant polyfill of the Barcode Detection API 🤳
Stars: ✭ 31 (+55%)
Mutual labels:  polyfill, shim
Core Js
Standard Library
Stars: ✭ 15,854 (+79170%)
Mutual labels:  polyfill, shim
Proposal Array Unique
ECMAScript proposal for Deduplicating method of Array
Stars: ✭ 96 (+380%)
Mutual labels:  polyfill, array
String.prototype.trim
ES5 spec-compliant shim for String.prototype.trim
Stars: ✭ 13 (-35%)
Mutual labels:  polyfill, shim
Promise.allSettled
ES Proposal spec-compliant shim for Promise.allSettled
Stars: ✭ 93 (+365%)
Mutual labels:  polyfill, shim
react-smart-key
Pass anything as key without re-renders
Stars: ✭ 17 (-15%)
Mutual labels:  array
Polyfiller
Never worry about polyfills again.
Stars: ✭ 114 (+470%)
Mutual labels:  shim
react-native-wasm
A polyfill to use WebAssembly in React Native.
Stars: ✭ 39 (+95%)
Mutual labels:  polyfill
appHistory
A polyfill for the AppHistory proposal
Stars: ✭ 21 (+5%)
Mutual labels:  polyfill
arr
数组增强组件主要是对数组等数据进行处理,如无限级分类操作、商品规格的迪卡尔乘积运算等。
Stars: ✭ 62 (+210%)
Mutual labels:  array
lazy-arr
Arrays that look just like regular JavaScript arrays, but are computed lazily.
Stars: ✭ 67 (+235%)
Mutual labels:  array
arrayfire-haskell
Haskell bindings to ArrayFire
Stars: ✭ 52 (+160%)
Mutual labels:  array
HashMapC
A tiny library for using easily HashMap, arraylist in the C.
Stars: ✭ 21 (+5%)
Mutual labels:  array
ustd
Micro-standard-library providing minimal and portable array, queue and map for attiny avr, arduinos, esp8266/32 and linux, mac
Stars: ✭ 14 (-30%)
Mutual labels:  array
SELoader
Secure EFI Loader designed to authenticate the non-PE files
Stars: ✭ 38 (+90%)
Mutual labels:  shim
NetStandardPolyfills
Type and Reflection polyfill extension methods. .NET 3.5+ and .NET Standard 1.0+.
Stars: ✭ 22 (+10%)
Mutual labels:  polyfill

array.prototype.at Version Badge

github actions coverage dependency status dev dependency status License Downloads

npm badge

An ESnext spec-compliant Array.prototype.at shim/polyfill/replacement that works as far down as ES3.

This package implements the es-shim API interface. It works in an ES3-supported environment and complies with the proposed spec.

Because Array.prototype.at depends on a receiver (the this value), the main export takes the array to operate on as the first argument.

Getting started

npm install --save array.prototype.at

Usage/Examples

var at = require('array.prototype.at');
var assert = require('assert');

var arr = [1, [2], [], 3];

var results = at(arr, function (x, i) {
	assert.equal(x, arr[i]);
	return x;
});

assert.deepEqual(results, [1, 2, 3]);
var at = require('array.prototype.at');
var assert = require('assert');
/* when Array#at is not present */
delete Array.prototype.at;
var shimmedFlatMap = at.shim();

var mapper = function (x) { return [x, 1]; };

assert.equal(shimmedFlatMap, at.getPolyfill());
assert.deepEqual(arr.at(mapper), at(arr, mapper));
var at = require('array.prototype.at');
var assert = require('assert');
/* when Array#at is present */
var shimmedIncludes = at.shim();

var mapper = function (x) { return [x, 1]; };

assert.equal(shimmedIncludes, Array.prototype.at);
assert.deepEqual(arr.at(mapper), at(arr, mapper));

Tests

Simply clone the repo, npm install, and run npm test

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].