Skip to content
This repository was archived by the owner on May 14, 2025. It is now read-only.

pillarjs/extend-proto

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

8 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Caution

This repository is archived and no longer actively maintained.

We are no longer accepting issues, feature requests, or pull requests. For additional support or questions, please visit the Express.js Discussions page.

extend-proto

NPM Version NPM Downloads Node.js Version Build Status Test Coverage

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.

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
})