array-includes
Advanced tools
Comparing version 3.1.0 to 3.1.1
@@ -0,1 +1,9 @@ | ||
3.1.1 / 2019-12-21 | ||
================= | ||
* [Fix] IE < 9 does not have index access on strings | ||
* [Deps] update `es-abstract` | ||
* [Dev Deps] update `eslint`, `@ljharb/eslint-config`, `tape` | ||
* [meta] remove unused Makefile and associated utilities | ||
* [Tests] add string tests | ||
3.1.0 / 2019-12-11 | ||
@@ -2,0 +10,0 @@ ================= |
@@ -10,5 +10,7 @@ 'use strict'; | ||
var GetIntrinsic = require('es-abstract/GetIntrinsic'); | ||
var callBind = require('es-abstract/helpers/callBind'); | ||
var callBound = require('es-abstract/helpers/callBound'); | ||
var isString = require('is-string'); | ||
var $indexOf = callBind.apply(GetIntrinsic('%Array.prototype.indexOf%')); | ||
var $charAt = callBound('String.prototype.charAt'); | ||
var $indexOf = GetIntrinsic('%Array.prototype.indexOf%'); // TODO: use callBind.apply without breaking IE 8 | ||
@@ -18,3 +20,3 @@ module.exports = function includes(searchElement) { | ||
if ($indexOf && !$isNaN(searchElement) && $isFinite(fromIndex) && typeof searchElement !== 'undefined') { | ||
return $indexOf(this, arguments) > -1; | ||
return $indexOf.apply(this, arguments) > -1; | ||
} | ||
@@ -29,3 +31,3 @@ | ||
while (k < length) { | ||
if (SameValueZero(searchElement, O[k])) { | ||
if (SameValueZero(searchElement, isString(O) ? $charAt(O, k) : O[k])) { | ||
return true; | ||
@@ -32,0 +34,0 @@ } |
{ | ||
"name": "array-includes", | ||
"version": "3.1.0", | ||
"version": "3.1.1", | ||
"author": { | ||
@@ -50,9 +50,10 @@ "name": "Jordan Harband", | ||
"define-properties": "^1.1.3", | ||
"es-abstract": "^1.17.0-next.0" | ||
"es-abstract": "^1.17.0", | ||
"is-string": "^1.0.5" | ||
}, | ||
"devDependencies": { | ||
"@es-shims/api": "^2.1.2", | ||
"@ljharb/eslint-config": "^15.0.2", | ||
"@ljharb/eslint-config": "^15.1.0", | ||
"covert": "^1.1.1", | ||
"eslint": "^6.7.2", | ||
"eslint": "^6.8.0", | ||
"evalmd": "0.0.19", | ||
@@ -63,5 +64,3 @@ "foreach": "^2.0.5", | ||
"indexof": "^0.0.1", | ||
"replace": "^1.1.1", | ||
"semver": "^6.3.0", | ||
"tape": "^4.11.0" | ||
"tape": "^4.12.0" | ||
}, | ||
@@ -68,0 +67,0 @@ "testling": { |
@@ -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'](function () { includes(undefined, 'a'); }, TypeError, 'undefined is not an object'); | ||
st['throws'](function () { includes(null, 'a'); }, TypeError, 'null is not an object'); | ||
st.end(); | ||
@@ -13,0 +13,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'](function () { includes([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'](function () { includes({ length: thrower, 0: true }, true); }, RangeError, 'ToLength conversion throws'); | ||
st.end(); | ||
@@ -86,2 +86,12 @@ }); | ||
}); | ||
t.test('strings', function (st) { | ||
st.equal(true, includes('abc', 'c'), 'string includes one of its chars'); | ||
st.equal(false, includes('abc', 'd'), 'string does not include a char it should not'); | ||
st.equal(true, includes(Object('abc'), 'c'), 'boxed string includes one of its chars'); | ||
st.equal(false, includes(Object('abc'), 'd'), 'boxed string does not include a char it should not'); | ||
st.end(); | ||
}); | ||
}; |
Sorry, the diff of this file is not supported yet
821671
10
186
3
18
+ Addedis-string@^1.0.5
Updatedes-abstract@^1.17.0