Skip to content
This repository
Browse code

Turns out setting .__proto__ to an array doesn't actually change JSON…

….stringify's view of an object. Revert those changes. Also, more minor formatting.
  • Loading branch information...
commit 6539c31e2c3766dc99d777221fd5ba580acfa789 1 parent 10f311c
Steve Wang authored June 22, 2011
16  lib/function.js
@@ -21,24 +21,24 @@ exports.init = function (nowjs) {
21 21
 
22 22
     remotecall: function () {
23 23
       // Coerce arguments to an array.
24  
-      arguments.__proto__ = nowUtil.arrayProto;
  24
+      var args = Array.prototype.slice.call(arguments);
25 25
 
26 26
       // Find functions in the arguments, and store functions in
27 27
       // closure table and serialize functions.
28 28
       var closureId;
29  
-      for (var i = 0, ii = arguments.length; i < ii; i++) {
30  
-        if (typeof arguments[i] === 'function') {
31  
-          closureId = 'closure_' + arguments[i].name + '_' +
  29
+      for (var i = 0, ii = args.length; i < ii; i++) {
  30
+        if (typeof args[i] === 'function') {
  31
+          closureId = 'closure_' + args[i].name + '_' +
32 32
             nowUtil.generateRandombString();
33  
-          nowjs.closures[closureId] = arguments[i];
34  
-          arguments[i] = {closure: closureId};
35  
-          setTimeout(function() {
  33
+          nowjs.closures[closureId] = args[i];
  34
+          args[i] = {closure: closureId};
  35
+          setTimeout(function () {
36 36
             nowjs.closures[closureId] = nowUtil.noop;
37 37
           }, 30000);
38 38
         }
39 39
       }
40 40
       // On the next tick, send the remoteCall request
41  
-      this.socket.emit('rfc', {fqn: this.fqn, args: arguments});
  41
+      this.socket.emit('rfc', {fqn: this.fqn, args: args});
42 42
     }
43 43
   };
44 44
 };
2  lib/nowUtil.js
@@ -7,8 +7,6 @@ var util = {
7 7
   noop: function () {
8 8
   },
9 9
 
10  
-  arrayProto: [],
11  
-
12 10
   clone: function (obj) {
13 11
     var output = {};
14 12
     output.__proto__ = obj;
2  lib/proxy.js
@@ -29,7 +29,7 @@ exports.wrap = function (entity) {
29 29
       enumerate : function () {
30 30
         return entity.get(path);
31 31
       },
32  
-      hasOwn : function(name) {
  32
+      hasOwn : function (name) {
33 33
         return entity.scopeTable.get(path+'.'+name) !== undefined;
34 34
       },
35 35
       delete : function (name) {
2  lib/scopeTable.js
@@ -25,7 +25,7 @@ ScopeTable.prototype.delete = function (fqn) {
25 25
   var lastIndex = fqn.lastIndexOf('.');
26 26
   var parent = fqn.substring(0, lastIndex);
27 27
 
28  
-  if(nowUtil.hasProperty(this.data, parent)){
  28
+  if (nowUtil.hasProperty(this.data, parent)) {
29 29
     // Remove from its parent.
30 30
     this.data[parent].splice(
31 31
       this.data[parent].indexOf(fqn.substring(lastIndex + 1)),
7  package.json
... ...
@@ -1,7 +1,7 @@
1 1
 {
2 2
   "author": "Flotype",
3 3
   "name": "now",
4  
-  "version": "0.0.1",
  4
+  "version": "0.7.0",
5 5
   "repository": {
6 6
     "type": "git",
7 7
     "url": "git://github.com/Flotype/now-bamf.git"
@@ -10,6 +10,9 @@
10 10
   "engines": {
11 11
     "node": "v0.4.5"
12 12
   },
13  
-  "dependencies": {},
  13
+  "dependencies": {
  14
+    "socket.io": "0.7.2",
  15
+    "node-proxy": "0.3.2"
  16
+},
14 17
   "devDependencies": {}
15 18
 }

0 notes on commit 6539c31

Please sign in to comment.
Something went wrong with that request. Please try again.