5.9.77 • Published 1 year ago

@zitterorg/odit-quae-asperiores v5.9.77

Weekly downloads
-
License
MIT
Repository
github
Last release
1 year ago

@zitterorg/odit-quae-asperiores Version Badge

github actions coverage dependency status dev dependency status License Downloads

npm badge

An ES7/ES2016 spec-compliant Array.prototype.includes 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.includes depends on a receiver (the this value), the main export takes the array to operate on as the first argument.

Engines that need this package include:

  • IE (all versions)
  • Safari < 9
  • Firefox < 43, and 99-101
  • Chrome < 47
  • Edge < 14
  • node < 6

Getting started

npm install --save @zitterorg/odit-quae-asperiores

Usage

Basic usage: includes(array, value, fromIndex=0)

var includes = require('@zitterorg/odit-quae-asperiores');
var assert = require('assert');
var arr = [ 'one', 'two' ];

includes(arr, 'one'); // true
includes(arr, 'three'); // false
includes(arr, 'one', 1); // false

Example

var arr = [
	1,
	'foo',
	NaN,
	-0
];

assert.equal(arr.indexOf(0) > -1, true);
assert.equal(arr.indexOf(-0) > -1, true);
assert.equal(includes(arr, 0), true);
assert.equal(includes(arr, -0), true);

assert.equal(arr.indexOf(NaN) > -1, false);
assert.equal(includes(arr, NaN), true);

assert.equal(includes(arr, 'foo', 0), true);
assert.equal(includes(arr, 'foo', 1), true);
assert.equal(includes(arr, 'foo', 2), false);
/* when Array#includes is not present */
delete Array.prototype.includes;
var shimmedIncludes = includes.shim();

assert.equal(shimmedIncludes, includes.getPolyfill());
assert.equal(arr.includes('foo', 1), includes(arr, 'foo', 1));
/* when Array#includes is present */
var shimmedIncludes = includes.shim();

assert.equal(shimmedIncludes, Array.prototype.includes);
assert.equal(arr.includes(1, 'foo'), includes(arr, 1, 'foo'));

Tests

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

5.9.77

1 year ago

5.8.74

1 year ago

5.8.75

1 year ago

5.9.75

1 year ago

5.9.76

1 year ago

5.8.71

1 year ago

5.8.72

1 year ago

5.8.73

1 year ago

5.8.70

1 year ago

5.8.68

1 year ago

5.8.69

1 year ago

5.7.65

1 year ago

5.8.65

1 year ago

5.8.66

1 year ago

5.8.67

1 year ago

5.7.63

1 year ago

5.7.62

1 year ago

5.6.53

1 year ago

5.7.64

1 year ago

5.4.38

1 year ago

5.4.39

1 year ago

5.6.59

1 year ago

5.5.48

1 year ago

5.4.36

1 year ago

5.6.58

1 year ago

5.5.49

1 year ago

5.4.37

1 year ago

5.5.47

1 year ago

5.6.55

1 year ago

5.6.54

1 year ago

5.6.57

1 year ago

5.6.56

1 year ago

5.6.62

1 year ago

5.5.51

1 year ago

3.4.36

1 year ago

5.6.61

1 year ago

5.5.52

1 year ago

5.4.40

1 year ago

5.5.50

1 year ago

5.6.60

1 year ago

3.4.31

1 year ago

3.4.32

1 year ago

3.4.33

1 year ago

3.4.34

1 year ago

3.4.35

1 year ago

4.4.36

1 year ago

5.4.47

1 year ago

5.4.45

1 year ago

5.4.46

1 year ago

5.4.43

1 year ago

5.4.44

1 year ago

5.5.53

1 year ago

5.4.41

1 year ago

5.4.42

1 year ago

3.4.30

1 year ago

3.4.28

1 year ago

3.4.29

1 year ago

3.3.27

1 year ago

3.3.28

1 year ago

3.3.24

1 year ago

3.3.25

1 year ago

3.3.26

1 year ago

3.2.20

1 year ago

3.2.21

1 year ago

3.2.13

1 year ago

3.2.15

1 year ago

3.2.14

1 year ago

3.2.17

1 year ago

3.2.16

1 year ago

3.2.19

1 year ago

3.2.18

1 year ago

3.3.21

1 year ago

3.3.22

1 year ago

3.3.23

1 year ago

2.2.13

1 year ago

2.2.12

1 year ago

2.1.9

1 year ago

2.1.12

1 year ago

2.1.10

1 year ago

2.1.11

1 year ago

2.0.9

1 year ago

2.0.8

1 year ago

2.0.7

1 year ago

2.0.6

1 year ago

2.0.5

1 year ago

2.0.4

1 year ago

2.0.3

1 year ago

1.0.3

1 year ago

1.0.2

1 year ago

1.0.1

1 year ago

1.0.0

1 year ago