Security News
The Risks of Misguided Research in Supply Chain Security
Snyk's use of malicious npm packages for research raises ethical concerns, highlighting risks in public deployment, data exfiltration, and unauthorized testing.
Create your own hook api with 2-dimensional hooks - better than events or simple hooks
Create your own hook api with 2-dimensional hooks - better than events or simple hooks.
npm install --save hook-up
hookUp = require("hook-up")
// hookUp(obj:Object, options:Object)
someObj = {}
hookUp(someObj)
// adds a function:
// registerHooks(names:String | Array of Strings)
someObj.registerHooks("start")
// adds functions
// to add a hook
// [name].register({prio: (optional) Number, cb: Function})
// to call all hooks
// [name].execute(obj)
// to delete all hooks
// [name].clear()
someArg = {}
someHook = async (arg) =>
// this == someObj
// arg == someArg
// do something async
someObj.start.register(someHook)
someObj.start.register({prio: 2, cb: someHook}) // bigger prio gets called first
// hooks with the same prio get called simultaneously
await someObj.start.execute(someArg)
Name | type | default | description |
---|---|---|---|
prefix | Array or String | - | to add a namespace for all hooks |
register | String | register | name of the register prop, can be empty |
execute | String | execute | name of the execute prop, can be empty |
Note, that only one of register or execute can be empty
hookUp = require("hook-up")
someObj = {}
hookUp(someObj,{prefix:["before","after"], register: "call", execute:""})
someObj.registerHooks("start")
// will result in the following api for hooks:
someObj.before.start.call(someHook)
someObj.after.start.call(someOtherHook)
// to execute
await someObj.before.start(someArg)
Copyright (c) 2017 Paul Pflugradt Licensed under the MIT license.
FAQs
Create your own hook api with 2-dimensional hooks - better than events or simple hooks
The npm package hook-up receives a total of 11 weekly downloads. As such, hook-up popularity was classified as not popular.
We found that hook-up 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
Snyk's use of malicious npm packages for research raises ethical concerns, highlighting risks in public deployment, data exfiltration, and unauthorized testing.
Research
Security News
Socket researchers found several malicious npm packages typosquatting Chalk and Chokidar, targeting Node.js developers with kill switches and data theft.
Security News
pnpm 10 blocks lifecycle scripts by default to improve security, addressing supply chain attack risks but sparking debate over compatibility and workflow changes.