Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/tirithen/node-simple-extend
Simple extend is a JavaScript constructor inheritance utility.
https://github.com/tirithen/node-simple-extend
Last synced: about 4 hours ago
JSON representation
Simple extend is a JavaScript constructor inheritance utility.
- Host: GitHub
- URL: https://github.com/tirithen/node-simple-extend
- Owner: tirithen
- License: mit
- Created: 2013-11-19T18:35:34.000Z (almost 11 years ago)
- Default Branch: master
- Last Pushed: 2013-11-20T14:03:05.000Z (almost 11 years ago)
- Last Synced: 2024-10-23T02:16:13.816Z (25 days ago)
- Language: JavaScript
- Size: 117 KB
- Stars: 0
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# node-simple-extend
Simple extend is a JavaScript constructor inheritance utility. The utility can be used in both browser environments and node environments. It strives to use as much of the standard JavaScript functionality as possible.
## Installation
To use Simple extend with node.js simply use npm:
$ npm install node-simple-extendTo use Simple extend in a browser environment, simply include the simple-extend.js file in a script tag.
## Usage
To use Simple extend you need to do two things:
1. Run the method extend with the first argument as the constructor you want to extend and the second argument as the constructor you like to inherit from.
2. Inside the child constructor, call the parent constructor with Parent.call(this, *argument1, argument2*);Below is a simple usage example:
function Parent() {}
Parent.prototype.swim = function () {
console.log(this.constructor.name + ' is swimming.');
}function Child() {
Parent.call(this);
}
extend(Child, Parent);var animal = new Child();
animal.swim();For a bit more involved example, look at the example/example.js file.
## License
The code for this module is released under the MIT license, for more details read the LICENSE file that is provided in this repository.