Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(67)

Side by Side Diff: src/harmony-array.js

Issue 1132163011: Add TypedArray.from method (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: improving style Created 5 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « no previous file | src/harmony-typedarray.js » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2013 the V8 project authors. All rights reserved. 1 // Copyright 2013 the V8 project authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 var $innerArrayCopyWithin; 5 var $innerArrayCopyWithin;
6 var $innerArrayFill; 6 var $innerArrayFill;
7 var $innerArrayFind; 7 var $innerArrayFind;
8 var $innerArrayFindIndex; 8 var $innerArrayFindIndex;
9 var $arrayFrom;
9 10
10 (function(global, exports) { 11 (function(global, exports) {
11 12
12 'use strict'; 13 'use strict';
13 14
14 %CheckIsBootstrapping(); 15 %CheckIsBootstrapping();
15 16
16 var GlobalArray = global.Array; 17 var GlobalArray = global.Array;
17 var GlobalSymbol = global.Symbol; 18 var GlobalSymbol = global.Symbol;
18 19
(...skipping 228 matching lines...) Expand 10 before | Expand all | Expand 10 after
247 } else { 248 } else {
248 mappedValue = nextValue; 249 mappedValue = nextValue;
249 } 250 }
250 %AddElement(result, k, mappedValue, NONE); 251 %AddElement(result, k, mappedValue, NONE);
251 } 252 }
252 253
253 result.length = k; 254 result.length = k;
254 return result; 255 return result;
255 } 256 }
256 } 257 }
258 $arrayFrom = ArrayFrom;
257 259
258 // ES6, draft 05-22-14, section 22.1.2.3 260 // ES6, draft 05-22-14, section 22.1.2.3
259 function ArrayOf() { 261 function ArrayOf() {
260 var length = %_ArgumentsLength(); 262 var length = %_ArgumentsLength();
261 var constructor = this; 263 var constructor = this;
262 // TODO: Implement IsConstructor (ES6 section 7.2.5) 264 // TODO: Implement IsConstructor (ES6 section 7.2.5)
263 var array = %IsConstructor(constructor) ? new constructor(length) : []; 265 var array = %IsConstructor(constructor) ? new constructor(length) : [];
264 for (var i = 0; i < length; i++) { 266 for (var i = 0; i < length; i++) {
265 %AddElement(array, i, %_Arguments(i), NONE); 267 %AddElement(array, i, %_Arguments(i), NONE);
266 } 268 }
(...skipping 22 matching lines...) Expand all
289 291
290 // Set up the non-enumerable functions on the Array prototype object. 292 // Set up the non-enumerable functions on the Array prototype object.
291 $installFunctions(GlobalArray.prototype, DONT_ENUM, [ 293 $installFunctions(GlobalArray.prototype, DONT_ENUM, [
292 "copyWithin", ArrayCopyWithin, 294 "copyWithin", ArrayCopyWithin,
293 "find", ArrayFind, 295 "find", ArrayFind,
294 "findIndex", ArrayFindIndex, 296 "findIndex", ArrayFindIndex,
295 "fill", ArrayFill 297 "fill", ArrayFill
296 ]); 298 ]);
297 299
298 }) 300 })
OLDNEW
« no previous file with comments | « no previous file | src/harmony-typedarray.js » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698