Skip to content
Toggle navigation
Toggle navigation
This project
Loading...
Sign in
John McEleney
/
casperjs
Go to a project
Toggle navigation
Toggle navigation pinning
Projects
Groups
Snippets
Help
Project
Activity
Repository
Pipelines
Graphs
Issues
0
Merge Requests
0
Wiki
Network
Create a new issue
Builds
Commits
Issue Boards
Files
Commits
Network
Compare
Branches
Tags
Commit
4eb262d3
...
4eb262d3c7e6867c660005316dd84f85a8f3ca89
authored
2012-06-03 16:15:12 +0200
by
Nicolas Perriault
Browse Files
Options
Browse Files
Tag
Download
Email Patches
Plain Diff
keeping sync with nodejs' util.inherits()
1 parent
323a5c27
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
13 additions
and
18 deletions
modules/utils.js
modules/utils.js
View file @
4eb262d
...
...
@@ -131,27 +131,22 @@ function format(f) {
exports
.
format
=
format
;
/**
* Inherit the prototype methods from one constructor into another, also
* exposes the `__super__` property to child class.
* Inherit the prototype methods from one constructor into another.
*
* @param Function child Constructor function which needs to inherit the
* prototype.
* @param Function parent Constructor function to inherit prototype from.
* @return Function The child class
* @param {function} ctor Constructor function which needs to inherit the
* prototype.
* @param {function} superCtor Constructor function to inherit prototype from.
*/
function
inherits
(
child
,
parent
)
{
for
(
var
key
in
parent
)
{
if
(
Object
.
prototype
.
hasOwnProperty
.
call
(
parent
,
key
))
{
child
[
key
]
=
parent
[
key
];
function
inherits
(
ctor
,
superCtor
)
{
ctor
.
super_
=
ctor
.
__super__
=
superCtor
;
ctor
.
prototype
=
Object
.
create
(
superCtor
.
prototype
,
{
constructor
:
{
value
:
ctor
,
enumerable
:
false
,
writable
:
true
,
configurable
:
true
}
}
function
ctor
()
{
this
.
constructor
=
child
;
}
ctor
.
prototype
=
parent
.
prototype
;
child
.
prototype
=
new
ctor
();
child
.
__super__
=
parent
.
prototype
;
return
child
;
});
}
exports
.
inherits
=
inherits
;
...
...
Please
register
or
sign in
to post a comment