https://github.com/pillarjs/extend-proto
generic __proto__ injection utility
https://github.com/pillarjs/extend-proto
Last synced: over 1 year ago
JSON representation
generic __proto__ injection utility
- Host: GitHub
- URL: https://github.com/pillarjs/extend-proto
- Owner: pillarjs
- License: mit
- Created: 2016-01-30T18:34:07.000Z (over 10 years ago)
- Default Branch: master
- Last Pushed: 2016-02-23T01:25:54.000Z (over 10 years ago)
- Last Synced: 2025-01-03T09:36:16.116Z (over 1 year ago)
- Language: JavaScript
- Size: 7.81 KB
- Stars: 3
- Watchers: 10
- Forks: 4
- Open Issues: 5
-
Metadata Files:
- Readme: README.md
- Changelog: HISTORY.md
- License: LICENSE
Awesome Lists containing this project
README
# extend-proto
[![NPM Version][npm-image]][npm-url]
[![NPM Downloads][downloads-image]][downloads-url]
[![Node.js Version][node-version-image]][node-version-url]
[![Build Status][travis-image]][travis-url]
[![Test Coverage][coveralls-image]][coveralls-url]
A utility to inject a prototype chain, fully generic and adaptable.
This largely exists for performance. Injecting a single prototype with many properties on it has been historically faster than adding those properties to an existing instance.
```js
var http = require('http')
var proto = require('extend-proto')
var proto = Proto({
req: http.IncomingMessage,
res: http.ServerResponse
})
proto.req.defineProperty('kittens', { value: 'the best' })
http.createServer(function(req, res) {
proto(req, res)
req.kittens // the best
})
```
## [MIT Licensed](LICENSE)
[npm-image]: https://img.shields.io/npm/v/extend-proto.svg?style=flat
[npm-url]: https://npmjs.org/package/extend-proto
[node-version-image]: https://img.shields.io/node/v/extend-proto.svg?style=flat
[node-version-url]: http://nodejs.org/download/
[travis-image]: https://img.shields.io/travis/pillarjs/extend-proto.svg?style=flat
[travis-url]: https://travis-ci.org/pillarjs/extend-proto
[coveralls-image]: https://img.shields.io/coveralls/pillarjs/extend-proto.svg?style=flat
[coveralls-url]: https://coveralls.io/r/pillarjs/extend-proto?branch=master
[downloads-image]: https://img.shields.io/npm/dm/extend-proto.svg?style=flat
[downloads-url]: https://npmjs.org/package/extend-proto