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.
@jalik/observer
Advanced tools
Make anything observable.
The Observer design pattern is a well known pattern to create reactive applications.
You can attach observers to a form text field, then when the text field value changes, all
observers are notified of that change and thus can do something in response.
Play with the lib here: https://codesandbox.io/s/jalik-observer-demo-de16gw?file=/src/index.js
import { Observer } from '@jalik/observer'
class Person {
constructor (name) {
this.name = name
// Create the observer with current context
this.observer = new Observer(this)
}
on (event, observer) {
// Attach observer
this.observer.on(event, observer)
}
say (words) {
// Notify observers
this.observer.emit('say', words, new Date())
}
}
const karl = new Person('karl')
karl.on('say', function (words, date) {
console.log(`${this.name} said: "${words}"`)
})
// this will show: karl said: "hello"
karl.say('hello')
import { Observer } from '@jalik/observer'
const listener = function () {
console.log('double click detected')
// This avoid the current function to be called
// on the next "doubleClick" event notification.
observer.off('doubleClick', listener)
}
const observer = new Observer()
observer.on('doubleClick', listener)
// This will call the doubleClickListener once.
observer.emit('doubleClick')
// This will not call the doubleClickListener
// since it has been detached in the previous call.
observer.emit('doubleClick')
History of releases is in the changelog.
The code is released under the MIT License.
v2.2.0 (2024-02-20)
Observable
to add on()
, off()
and emit()
to any classFAQs
A library to observe events and trigger callbacks.
The npm package @jalik/observer receives a total of 71 weekly downloads. As such, @jalik/observer popularity was classified as not popular.
We found that @jalik/observer demonstrated a healthy version release cadence and project activity because the last version was released less than 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.