
Company News
Socket Named Top Sales Organization by RepVue
Socket won two 2026 Reppy Awards from RepVue, ranking in the top 5% of all sales orgs. AE Alexandra Lister shares what it's like to grow a sales career here.
Node method and accessor delegation utilty.
$ npm install delegates
var delegate = require('delegates');
...
delegate(proto, 'request')
.method('acceptsLanguages')
.method('acceptsEncodings')
.method('acceptsCharsets')
.method('accepts')
.method('is')
.access('querystring')
.access('idempotent')
.access('socket')
.access('length')
.access('query')
.access('search')
.access('status')
.access('method')
.access('path')
.access('body')
.access('host')
.access('url')
.getter('subdomains')
.getter('protocol')
.getter('header')
.getter('stale')
.getter('fresh')
.getter('secure')
.getter('ips')
.getter('ip')
Creates a delegator instance used to configure using the prop on the given
proto object. (which is usually a prototype)
Allows the given method name to be accessed on the host.
Creates a "getter" for the property with the given name on the delegated
object.
Creates a "setter" for the property with the given name on the delegated
object.
Creates an "accessor" (ie: both getter and setter) for the property with the
given name on the delegated object.
A unique type of "accessor" that works for a "fluent" API. When called as a getter, the method returns the expected value. However, if the method is called with a value, it will return itself so it can be chained. For example:
delegate(proto, 'request')
.fluent('query')
// getter
var q = request.query();
// setter (chainable)
request
.query({ a: 1 })
.query({ b: 2 });
MIT
Similar to 'delegates', 'auto-bind' helps in managing 'this' context in classes by automatically binding methods to the instance. While 'delegates' focuses on forwarding methods and properties to another object, 'auto-bind' is more about ensuring that methods in a class maintain their context.
Proxyquire is used for mocking modules in tests, which can indirectly provide functionality similar to method delegation by replacing certain methods of a module with mock functions. However, unlike 'delegates', which is used in production code for delegation, proxyquire is specifically designed for testing environments.
FAQs
delegate methods and accessors to another property
The npm package delegates receives a total of 17,009,202 weekly downloads. As such, delegates popularity was classified as popular.
We found that delegates demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 2 open source maintainers collaborating on the project.
Did you know?

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Company News
Socket won two 2026 Reppy Awards from RepVue, ranking in the top 5% of all sales orgs. AE Alexandra Lister shares what it's like to grow a sales career here.

Security News
NIST will stop enriching most CVEs under a new risk-based model, narrowing the NVD's scope as vulnerability submissions continue to surge.

Company News
/Security News
Socket is an initial recipient of OpenAI's Cybersecurity Grant Program, which commits $10M in API credits to defenders securing open source software.