Security News
38% of CISOs Fear They’re Not Moving Fast Enough on AI
CISOs are racing to adopt AI for cybersecurity, but hurdles in budgets and governance may leave some falling behind in the fight against cyber threats.
bookshelf-signals
Advanced tools
A Bookshelf plugin that translates all models and collection events to a single hub
The Bookshelf plugin that translates bookshelf events to a central hub. By default that hub is a bookshelf instance itself. That's useful if you want to subscribe to an event but don't want to modify model or collection initializer.
Signals = require 'bookshelf-signals'
db = bookshelf(knex)
db.plugin Signals()
class User extend db.Model
tabeName: 'users'
db.on 'saved', User, ->
console.log 'user was saved!'
db.plugin Signals(hub)
Argument passed to plugin is a hub to that all bookshelf events will be translated. It should at least implement methods trigger
and triggerThen
. If undefined then events will be translated to bookshelf instance and required methods will be added to it.
Default hub implementation has a behaviour different from EventEmitter. Its methods on, addListener, once, off, removeListener, removeAllListeners accepts class or model/collection name as a second parameter and performs events filtration according to it.
Methods:
on(String event, [(Class|String) cls], Function handler)
Subscribe to event with optional filtration by source class.
addListener - alias for on
removeListener(String event, [(Class|String) cls], Function handler)
Unsubscribe from event. If class/name was used for subscription you have to use the same class/name to unsubscribe.
off - alias for removeListener
once(String event, [(Class|String) cls], handler)
Subscribe to first event of that type and source class, if filtered.
removeAllListeners([String event], [(Class|String) cls])
Unsubscribe all listeners for that event and source class.
FAQs
A Bookshelf plugin that translates all models and collection events to a single hub
The npm package bookshelf-signals receives a total of 0 weekly downloads. As such, bookshelf-signals popularity was classified as not popular.
We found that bookshelf-signals 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
CISOs are racing to adopt AI for cybersecurity, but hurdles in budgets and governance may leave some falling behind in the fight against cyber threats.
Research
Security News
Socket researchers uncovered a backdoored typosquat of BoltDB in the Go ecosystem, exploiting Go Module Proxy caching to persist undetected for years.
Security News
Company News
Socket is joining TC54 to help develop standards for software supply chain security, contributing to the evolution of SBOMs, CycloneDX, and Package URL specifications.