Permalink
Browse files

Implement a shallow copy mixin since node removed mixin from process.

  • Loading branch information...
1 parent 3852d41 commit de012d8ec035b197991258a0e60bf33298dbb9d6 @creationix committed Mar 18, 2010
Showing with 13 additions and 0 deletions.
  1. +13 −0 lib/proto.js
View
@@ -28,4 +28,17 @@ if (typeof proto.map !== 'function') {
}});
}
+// Implements a shallow copy onto the current object.
+if (typeof proto.mixin !== 'function') {
+ Object.defineProperty(proto, "mixin", {enumarable: false, value: function (obj) {
+ var keys = Object.keys(obj);
+ var length = keys.length;
+ for (var i = 0; i < length; i++){
+ key = keys[i];
+ this[key] = obj[key];
+ }
+ return this;
+ }});
+}
+

0 comments on commit de012d8

Please sign in to comment.