v8/src/harmony-array-includes.js
machenbach 4c2690a475 Revert of Hook up more import/exports in natives. (patchset #2 id:20001 of https://codereview.chromium.org/1154483002/)
Reason for revert:
[Sheriff] Breaks nosnap:
http://build.chromium.org/p/client.v8/builders/V8%20Win32%20-%20nosnap%20-%20shared/builds/6943

Original issue's description:
> Hook up more import/exports in natives.
>
> R=jkummerow@chromium.org
>
> Committed: https://crrev.com/7a918ac9658d11778f39593bfcc19d7c506defd9
> Cr-Commit-Position: refs/heads/master@{#28573}

TBR=jkummerow@chromium.org,erik.corry@gmail.com,yangguo@chromium.org
NOPRESUBMIT=true
NOTREECHECKS=true
NOTRY=true

Review URL: https://codereview.chromium.org/1154793003

Cr-Commit-Position: refs/heads/master@{#28574}
2015-05-22 08:53:05 +00:00

60 lines
1.2 KiB
JavaScript

// Copyright 2014 the V8 project authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
(function(global, utils) {
'use strict';
%CheckIsBootstrapping();
var GlobalArray = global.Array;
// -------------------------------------------------------------------
// Proposed for ES7
// https://github.com/tc39/Array.prototype.includes
// 6e3b78c927aeda20b9d40e81303f9d44596cd904
function ArrayIncludes(searchElement, fromIndex) {
var array = $toObject(this);
var len = $toLength(array.length);
if (len === 0) {
return false;
}
var n = $toInteger(fromIndex);
var k;
if (n >= 0) {
k = n;
} else {
k = len + n;
if (k < 0) {
k = 0;
}
}
while (k < len) {
var elementK = array[k];
if ($sameValueZero(searchElement, elementK)) {
return true;
}
++k;
}
return false;
}
// -------------------------------------------------------------------
%FunctionSetLength(ArrayIncludes, 1);
// Set up the non-enumerable functions on the Array prototype object.
$installFunctions(GlobalArray.prototype, DONT_ENUM, [
"includes", ArrayIncludes
]);
})