Socket
Socket
Sign inDemoInstall

array-includes

Package Overview
Dependencies
65
Maintainers
2
Versions
23
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

Comparing version 3.0.3 to 3.1.0

.github/FUNDING.yml

18

CHANGELOG.md

@@ -0,1 +1,19 @@

3.1.0 / 2019-12-11
=================
* [New] add `auto` entry point
* [Refactor] use split-up `es-abstract` (68% bundle size decrease)
* [readme] fix repo URLs, remove testling, fix readme parsing
* [Deps] update `es-abstract`, `define-properties`
* [Dev Deps] update `eslint`, `@ljharb/eslint-config`, `evalmd`, `covert`, `functions-have-names`, `replace`, `semver`, `tape`, `@es-shims/api`, `function-bind`
* [meta] add `funding` field, FUNDING.yml
* [meta] Only apps should have lockfiles
* [Tests] add more `fromIndex` tests
* [Tests] use shared travis-ci configs
* [Tests] use `npx aud` instead of `nsp` or `npm audit` with hoops
* [Tests] remove `jscs`
* [Tests] use `functions-have-names`
* [Tests] use `npm audit` instead of `nsp`
* [Tests] remove `jscs`
* [actions] add automatic rebasing / merge commit blocking
3.0.3 / 2017-04-18

@@ -2,0 +20,0 @@ =================

30

implementation.js
'use strict';
var ES = require('es-abstract/es6');
var $isNaN = Number.isNaN || function isNaN(a) {
return a !== a;
};
var $isFinite = Number.isFinite || function isFinite(n) {
return typeof n === 'number' && global.isFinite(n);
};
var indexOf = Array.prototype.indexOf;
var ToInteger = require('es-abstract/2018/ToInteger');
var ToLength = require('es-abstract/2018/ToLength');
var ToObject = require('es-abstract/2018/ToObject');
var SameValueZero = require('es-abstract/2018/SameValueZero');
var $isNaN = require('es-abstract/helpers/isNaN');
var $isFinite = require('es-abstract/helpers/isFinite');
var GetIntrinsic = require('es-abstract/GetIntrinsic');
var callBind = require('es-abstract/helpers/callBind');
var $indexOf = callBind.apply(GetIntrinsic('%Array.prototype.indexOf%'));
module.exports = function includes(searchElement) {
var fromIndex = arguments.length > 1 ? ES.ToInteger(arguments[1]) : 0;
if (indexOf && !$isNaN(searchElement) && $isFinite(fromIndex) && typeof searchElement !== 'undefined') {
return indexOf.apply(this, arguments) > -1;
var fromIndex = arguments.length > 1 ? ToInteger(arguments[1]) : 0;
if ($indexOf && !$isNaN(searchElement) && $isFinite(fromIndex) && typeof searchElement !== 'undefined') {
return $indexOf(this, arguments) > -1;
}
var O = ES.ToObject(this);
var length = ES.ToLength(O.length);
var O = ToObject(this);
var length = ToLength(O.length);
if (length === 0) {

@@ -25,3 +27,3 @@ return false;

while (k < length) {
if (ES.SameValueZero(searchElement, O[k])) {
if (SameValueZero(searchElement, O[k])) {
return true;

@@ -28,0 +30,0 @@ }

'use strict';
var define = require('define-properties');
var ES = require('es-abstract/es6');
var RequireObjectCoercible = require('es-abstract/2018/RequireObjectCoercible');
var callBound = require('es-abstract/helpers/callBound');

@@ -11,3 +12,3 @@ var implementation = require('./implementation');

var slice = Array.prototype.slice;
var $slice = callBound('Array.prototype.slice');

@@ -17,4 +18,4 @@ /* eslint-disable no-unused-vars */

/* eslint-enable no-unused-vars */
ES.RequireObjectCoercible(array);
return polyfill.apply(array, slice.call(arguments, 1));
RequireObjectCoercible(array);
return polyfill.apply(array, $slice(arguments, 1));
};

@@ -21,0 +22,0 @@ define(boundIncludesShim, {

{
"name": "array-includes",
"version": "3.0.3",
"version": "3.1.0",
"author": {

@@ -9,2 +9,5 @@ "name": "Jordan Harband",

},
"funding": {
"url": "https://github.com/sponsors/ljharb"
},
"contributors": [

@@ -23,3 +26,3 @@ {

"test": "npm run --silent tests-only",
"posttest": "npm run --silent security",
"posttest": "npx aud",
"tests-only": "es-shim-api --bound && npm run --silent test:shimmed && npm run --silent test:module",

@@ -30,10 +33,7 @@ "test:shimmed": "node test/shimmed.js",

"coverage:quiet": "covert test/*.js --quiet",
"lint": "npm run --silent jscs && npm run --silent eslint",
"jscs": "jscs test/*.js *.js",
"eslint": "eslint test/*.js *.js",
"security": "nsp check"
"lint": "eslint ."
},
"repository": {
"type": "git",
"url": "git://github.com/ljharb/array-includes.git"
"url": "git://github.com/es-shims/array-includes.git"
},

@@ -52,19 +52,18 @@ "keywords": [

"dependencies": {
"define-properties": "^1.1.2",
"es-abstract": "^1.7.0"
"define-properties": "^1.1.3",
"es-abstract": "^1.17.0-next.0"
},
"devDependencies": {
"@es-shims/api": "^2.1.2",
"@ljharb/eslint-config": "^15.0.2",
"covert": "^1.1.1",
"eslint": "^6.7.2",
"evalmd": "0.0.19",
"foreach": "^2.0.5",
"function-bind": "^1.1.0",
"tape": "^4.6.3",
"function-bind": "^1.1.1",
"functions-have-names": "^1.2.0",
"indexof": "^0.0.1",
"covert": "^1.1.0",
"jscs": "^3.0.7",
"nsp": "^2.6.3",
"eslint": "^3.19.0",
"@ljharb/eslint-config": "^11.0.0",
"semver": "^5.3.0",
"replace": "^0.3.0",
"@es-shims/api": "^1.2.0",
"evalmd": "^0.0.17"
"replace": "^1.1.1",
"semver": "^6.3.0",
"tape": "^4.11.0"
},

@@ -96,2 +95,1 @@ "testling": {

}

@@ -1,2 +0,2 @@

#array-includes <sup>[![Version Badge][npm-version-svg]][package-url]</sup>
# array-includes <sup>[![Version Badge][npm-version-svg]][package-url]</sup>

@@ -11,4 +11,2 @@ [![Build Status][travis-svg]][travis-url]

[![browser support][testling-svg]][testling-url]
An ES7/ES2016 spec-compliant `Array.prototype.includes` shim/polyfill/replacement that works as far down as ES3.

@@ -32,2 +30,3 @@

var includes = require('array-includes');
var assert = require('assert');
var arr = [ 'one', 'two' ];

@@ -45,4 +44,2 @@

```js
var includes = require('array-includes');
var assert = require('assert');
var arr = [

@@ -69,4 +66,2 @@ 1,

```js
var includes = require('array-includes');
var assert = require('assert');
/* when Array#includes is not present */

@@ -77,8 +72,6 @@ delete Array.prototype.includes;

assert.equal(shimmedIncludes, includes.getPolyfill());
assert.deepEqual(arr.includes('foo', 1), includes(arr, 'foo', 1));
assert.equal(arr.includes('foo', 1), includes(arr, 'foo', 1));
```
```js
var includes = require('array-includes');
var assert = require('assert');
/* when Array#includes is present */

@@ -88,3 +81,3 @@ var shimmedIncludes = includes.shim();

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

@@ -96,11 +89,9 @@

[package-url]: https://npmjs.org/package/array-includes
[npm-version-svg]: http://versionbadg.es/ljharb/array-includes.svg
[travis-svg]: https://travis-ci.org/ljharb/array-includes.svg
[travis-url]: https://travis-ci.org/ljharb/array-includes
[deps-svg]: https://david-dm.org/ljharb/array-includes.svg
[deps-url]: https://david-dm.org/ljharb/array-includes
[dev-deps-svg]: https://david-dm.org/ljharb/array-includes/dev-status.svg
[dev-deps-url]: https://david-dm.org/ljharb/array-includes#info=devDependencies
[testling-svg]: https://ci.testling.com/ljharb/array-includes.png
[testling-url]: https://ci.testling.com/ljharb/array-includes
[npm-version-svg]: http://versionbadg.es/es-shims/array-includes.svg
[travis-svg]: https://travis-ci.org/es-shims/array-includes.svg
[travis-url]: https://travis-ci.org/es-shims/array-includes
[deps-svg]: https://david-dm.org/es-shims/array-includes.svg
[deps-url]: https://david-dm.org/es-shims/array-includes
[dev-deps-svg]: https://david-dm.org/es-shims/array-includes/dev-status.svg
[dev-deps-url]: https://david-dm.org/es-shims/array-includes#info=devDependencies
[npm-badge-png]: https://nodei.co/npm/array-includes.png?downloads=true&stars=true

@@ -107,0 +98,0 @@ [license-image]: http://img.shields.io/npm/l/array-includes.svg

@@ -9,4 +9,4 @@ 'use strict';

t.test('bad array/this value', function (st) {
st.throws(includes.bind(null, undefined, 'a'), TypeError, 'undefined is not an object');
st.throws(includes.bind(null, null, 'a'), TypeError, 'null is not an object');
st['throws'](includes.bind(null, undefined, 'a'), TypeError, 'undefined is not an object');
st['throws'](includes.bind(null, null, 'a'), TypeError, 'null is not an object');
st.end();

@@ -13,0 +13,0 @@ });

@@ -9,3 +9,3 @@ 'use strict';

var isEnumerable = Object.prototype.propertyIsEnumerable;
var functionsHaveNames = function f() {}.name === 'f';
var functionsHaveNames = require('functions-have-names')();

@@ -29,4 +29,4 @@ var runTests = require('./tests');

t.test('bad array/this value', { skip: !supportsStrictMode }, function (st) {
st.throws(function () { return Array.prototype.includes.call(undefined, 'a'); }, TypeError, 'undefined is not an object');
st.throws(function () { return Array.prototype.includes.call(null, 'a'); }, TypeError, 'null is not an object');
st['throws'](function () { return Array.prototype.includes.call(undefined, 'a'); }, TypeError, 'undefined is not an object');
st['throws'](function () { return Array.prototype.includes.call(null, 'a'); }, TypeError, 'null is not an object');
st.end();

@@ -33,0 +33,0 @@ });

@@ -23,3 +23,3 @@ 'use strict';

et.test('fromIndex conversion', function (st) {
st.throws(includes.bind(null, [0], 0, thrower), RangeError, 'fromIndex conversion throws');
st['throws'](includes.bind(null, [0], 0, thrower), RangeError, 'fromIndex conversion throws');
st.end();

@@ -29,3 +29,3 @@ });

et.test('ToLength', function (st) {
st.throws(includes.bind(null, { length: thrower, 0: true }, true), RangeError, 'ToLength conversion throws');
st['throws'](includes.bind(null, { length: thrower, 0: true }, true), RangeError, 'ToLength conversion throws');
st.end();

@@ -49,2 +49,6 @@ });

ft.equal(true, includes([0, 1, 2], 1, 0), 'starting from 0 finds index 1');
ft.equal(true, includes([0, 1, 2], 1, 1), 'starting from 1 finds index 1');
ft.equal(false, includes([0, 1, 2], 1, 2), 'starting from 2 does not find index 1');
ft.test('number coercion', function (st) {

@@ -51,0 +55,0 @@ st.equal(false, includes(['a', 'b', 'c'], 'a', numberish), 'does not find "a" with object fromIndex coercing to 2');

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc