Browse files

process.mixin: deprecation -> removed

  • Loading branch information...
1 parent 57ea07a commit b98cd6753b44563662f60ccf4feb22cfab404858 @ry ry committed Apr 13, 2010
Showing with 1 addition and 113 deletions.
  1. +1 −67 src/node.js
  2. +0 −46 test/simple/test-process-mixin.js
View
68 src/node.js
@@ -21,6 +21,7 @@ process.debug = removed("process.debug() has moved. Use require('sys') to bring
process.error = removed("process.error() has moved. Use require('sys') to bring it back.");
process.watchFile = removed("process.watchFile() has moved to fs.watchFile()");
process.unwatchFile = removed("process.unwatchFile() has moved to fs.unwatchFile()");
+process.mixin = removed('process.mixin() has been removed.');
GLOBAL.node = {};
@@ -100,73 +101,6 @@ process.assert = function (x, msg) {
};
-// From jQuery.extend in the jQuery JavaScript Library v1.3.2
-// Copyright (c) 2009 John Resig
-// Dual licensed under the MIT and GPL licenses.
-// http://docs.jquery.com/License
-// Modified for node.js (formely for copying properties correctly)
-var mixinMessage;
-process.mixin = function() {
- if (!mixinMessage) {
- mixinMessage = 'deprecation warning: process.mixin will be removed from node-core future releases.\n'
- process.binding('stdio').writeError(mixinMessage);
- }
- // copy reference to target object
- var target = arguments[0] || {}, i = 1, length = arguments.length, deep = false, source;
-
- // Handle a deep copy situation
- if ( typeof target === "boolean" ) {
- deep = target;
- target = arguments[1] || {};
- // skip the boolean and the target
- i = 2;
- }
-
- // Handle case when target is a string or something (possible in deep copy)
- if ( typeof target !== "object" && !(typeof target === 'function') )
- target = {};
-
- // mixin process itself if only one argument is passed
- if ( length == i ) {
- target = GLOBAL;
- --i;
- }
-
- for ( ; i < length; i++ ) {
- // Only deal with non-null/undefined values
- if ( (source = arguments[i]) != null ) {
- // Extend the base object
- Object.getOwnPropertyNames(source).forEach(function(k){
- var d = Object.getOwnPropertyDescriptor(source, k) || {value: source[k]};
- if (d.get) {
- target.__defineGetter__(k, d.get);
- if (d.set) {
- target.__defineSetter__(k, d.set);
- }
- }
- else {
- // Prevent never-ending loop
- if (target === d.value) {
- return;
- }
-
- if (deep && d.value && typeof d.value === "object") {
- target[k] = process.mixin(deep,
- // Never move original objects, clone them
- source[k] || (d.value.length != null ? [] : {})
- , d.value);
- }
- else {
- target[k] = d.value;
- }
- }
- });
- }
- }
- // Return the modified object
- return target;
-};
-
// Event
var eventsModule = createInternalModule('events', function (exports) {
View
46 test/simple/test-process-mixin.js
@@ -1,46 +0,0 @@
-require("../common");
-
-var target = function() {};
-process.mixin(target, {
- foo: 'bar'
-});
-
-assert.equal('bar', target.foo);
-
-// This test verifies there are no DOM-related aspects to process.mixin which
-// originally had been in there due to its jQuery origin.
-var fakeDomElement = {deep: {nodeType: 4}};
-target = {};
-process.mixin(true, target, fakeDomElement);
-
-assert.deepEqual(target.deep, fakeDomElement.deep);
-
-var objectWithUndefinedValue = {foo: undefined};
-target = {};
-
-process.mixin(target, objectWithUndefinedValue);
-assert.ok(target.hasOwnProperty('foo'));
-
-// This test verifies getters and setters being copied correctly
-
-var source = {
- _foo:'a',
- get foo(){ return this._foo; },
- set foo(value){ this._foo = "did set to "+value; }
-};
-target = {};
-process.mixin(target, source);
-target._foo = 'b';
-assert.equal(source.foo, 'a');
-assert.equal('b', target.foo, 'target.foo != "b" -- value/result was copied instead of getter function');
-source.foo = 'c';
-assert.equal('did set to c', source.foo, 'source.foo != "c" -- value was set instead of calling setter function');
-
-// Test that nested arrays are handled properly
-target = {};
-process.mixin(true, target, {
- foo: ['bar'],
-});
-
-assert.notStrictEqual(['bar'], target.foo);
-assert.deepEqual(['bar'], target.foo);

0 comments on commit b98cd67

Please sign in to comment.