
Security News
Deno 2.2 Improves Dependency Management and Expands Node.js Compatibility
Deno 2.2 enhances Node.js compatibility, improves dependency management, adds OpenTelemetry support, and expands linting and task automation for developers.
daisy-chain
Advanced tools
Create a pipeline of proxy objects that will wrap over a target object.
Create a pipeline of proxy objects that will wrap over a target object.
npm install --save daisy-chain
const { daisyChain } = require('daisy-chain');
proxies
(Object[]): an array of proxy objects.target
(Object): a target object.prop
(String): an optional property on the target the proxies will wrap over. (If not provided, the proxies will wrap over target
).A proxy can provide a wrapper over any property/ function on the target object (or property on the target object).
The order of the proxies in the proxy array determines their execution order.
Each proxy object can wrap a target property/ function with the signature:
foobar(next, ...args)
next
is the next foobar
proxy call in the pipeline (or the original foobar
call) on the target object/ specified target object property.args
are the provided arguments to foobar
.const { daisyChain } = require('daisy-chain');
class Greeting {
constructor() {
this.message = 'hello';
}
greet() {
return this.message;
}
}
class GreetingWorld {
constructor() {
this.message = ' world';
}
greet(next, ...args) {
return next(...args) + this.message;
}
}
class GreetingLogger {
greet(next, ...args) {
const result = next(...args);
console.log(result);
return result;
}
}
const target = new Greeting();
const proxyPipeline = [new GreetingLogger(), new GreetingWorld()];
const wrappedTarget = daisyChain(proxyPipeline, target);
wrappedTarget.greet(); // hello world
see examples
FAQs
Create a pipeline of proxy objects that will wrap over a target object.
The npm package daisy-chain receives a total of 11 weekly downloads. As such, daisy-chain popularity was classified as not popular.
We found that daisy-chain demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer 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.
Security News
Deno 2.2 enhances Node.js compatibility, improves dependency management, adds OpenTelemetry support, and expands linting and task automation for developers.
Security News
React's CRA deprecation announcement sparked community criticism over framework recommendations, leading to quick updates acknowledging build tools like Vite as valid alternatives.
Security News
Ransomware payment rates hit an all-time low in 2024 as law enforcement crackdowns, stronger defenses, and shifting policies make attacks riskier and less profitable.