mirror of
https://github.com/nodejs/node.git
synced 2026-12-06 10:48:45 -05:00
* install eslint-plugin-markdown * add doc/.eslintrc.yaml * add `<!-- eslint-disable rule -->` or `<!-- eslint-disable -->` for the rest of problematic code * .js files in doc folder added to .eslintignore * update Makefile and vcbuild.bat PR-URL: https://github.com/nodejs/node/pull/12563 Refs: https://github.com/nodejs/node/pull/12557#issuecomment-296015032 Reviewed-By: Teddy Katz <teddy.katz@gmail.com> Reviewed-By: James M Snell <jasnell@gmail.com> Reviewed-By: Timothy Gu <timothygu99@gmail.com> Reviewed-By: Gibson Fahnestock <gibfahn@gmail.com> Reviewed-By: Yuta Hiroto <hello@about-hiroppy.com>
68 lines
1.3 KiB
JavaScript
68 lines
1.3 KiB
JavaScript
/**
|
|
* @author Titus Wormer
|
|
* @copyright 2015 Titus Wormer
|
|
* @license MIT
|
|
* @module unherit
|
|
* @fileoverview Create a custom constructor which can be modified
|
|
* without affecting the original class.
|
|
*/
|
|
|
|
'use strict';
|
|
|
|
/* Dependencies. */
|
|
var xtend = require('xtend');
|
|
var inherits = require('inherits');
|
|
|
|
/* Expose. */
|
|
module.exports = unherit;
|
|
|
|
/**
|
|
* Create a custom constructor which can be modified
|
|
* without affecting the original class.
|
|
*
|
|
* @param {Function} Super - Super-class.
|
|
* @return {Function} - Constructor acting like `Super`,
|
|
* which can be modified without affecting the original
|
|
* class.
|
|
*/
|
|
function unherit(Super) {
|
|
var result;
|
|
var key;
|
|
var value;
|
|
|
|
inherits(Of, Super);
|
|
inherits(From, Of);
|
|
|
|
/* Clone values. */
|
|
result = Of.prototype;
|
|
|
|
for (key in result) {
|
|
value = result[key];
|
|
|
|
if (value && typeof value === 'object') {
|
|
result[key] = 'concat' in value ? value.concat() : xtend(value);
|
|
}
|
|
}
|
|
|
|
return Of;
|
|
|
|
/**
|
|
* Constructor accepting a single argument,
|
|
* which itself is an `arguments` object.
|
|
*/
|
|
function From(parameters) {
|
|
return Super.apply(this, parameters);
|
|
}
|
|
|
|
/**
|
|
* Constructor accepting variadic arguments.
|
|
*/
|
|
function Of() {
|
|
if (!(this instanceof Of)) {
|
|
return new From(arguments);
|
|
}
|
|
|
|
return Super.apply(this, arguments);
|
|
}
|
|
}
|