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

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

Issue 548833002: [es6] implement Object.assign (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: Rebased again Created 5 years, 8 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 | Annotate | Revision Log
OLDNEW
(Empty)
1 // Copyright 2014 the V8 project authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
4 //
5
6 'use strict';
7
8 // ES6, draft 10-14-14, section 19.1.2.1
9 function ObjectAssign(target, sources) {
10 var to = ToObject(target);
11 var argsLen = %_ArgumentsLength();
12 if (argsLen < 2) return to;
13
14 for (var i = 1; i < argsLen; ++i) {
15 var nextSource = %_Arguments(i);
16 if (IS_NULL_OR_UNDEFINED(nextSource)) {
17 continue;
18 }
19
20 var from = ToObject(nextSource);
21 var keys = ObjectGetOwnPropertyKeys(from);
arv (Not doing code reviews) 2015/04/03 21:15:09 ObjectGetOwnPropertyKeys takes 2 params
arv (Not doing code reviews) 2015/04/03 21:15:09 This will not include proxies. Maybe call a higher
caitp (gmail) 2015/04/03 21:28:41 The filter is optional-ish, but will do On 2015/0
arv (Not doing code reviews) 2015/04/03 21:43:02 Yes, but it adds an adapter frame for no good reas
22 var len = keys.length;
23
24 for (var j = 0; j < len; ++j) {
25 var key = keys[j];
26 if (%_CallFunction(from, key, ObjectPropertyIsEnumerable)) {
27 var propValue = from[key];
28 to[key] = propValue;
29 }
30 }
31 }
32 return to;
33 }
34
35
36 function HarmonyObjectExtendObjectPrototype() {
37 %CheckIsBootstrapping();
38
39 // Set up non-enumerable functions on the Object object.
40 InstallFunctions($Object, DONT_ENUM, $Array(
41 "assign", ObjectAssign
42 ));
43 }
44
45 HarmonyObjectExtendObjectPrototype();
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698