Security News
PyPI’s New Archival Feature Closes a Major Security Gap
PyPI now allows maintainers to archive projects, improving security and helping users make informed decisions about their dependencies.
change-emitter
Advanced tools
Listen for changes. Like an event emitter that only emits a single event type. Really tiny.
Listen for changes. Like an event emitter that only emits a single event type. Really tiny.
I extracted this from Redux's createStore()
because I found it to be useful in other contexts. Use it where you want the most minimal event subscription implementation possible.
import { createChangeEmitter } from 'change-emitter'
const emitter = createChangeEmitter()
// Called `listen` instead of `subscribe` to avoid confusion with observable spec
const unlisten = emitter.listen((...args) => {
console.log(args)
})
emitter.emit(1, 2, 3) // logs `[1, 2, 3]`
unlisten()
emitter.emit(4, 5, 6) // doesn't log
Here's a (partial) implementation of Redux's createStore
:
const createStore = (reducer, initialState) => {
let state = initialState
const emitter = createChangeEmitter()
function dispatch(action) {
state = reducer(state, action)
emitter.emit()
return action
}
function getState() {
return state
}
return {
dispatch,
getState,
subscribe: emitter.listen
}
}
FAQs
Listen for changes. Like an event emitter that only emits a single event type. Really tiny.
The npm package change-emitter receives a total of 493,469 weekly downloads. As such, change-emitter popularity was classified as popular.
We found that change-emitter 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.
Security News
PyPI now allows maintainers to archive projects, improving security and helping users make informed decisions about their dependencies.
Research
Security News
Malicious npm package postcss-optimizer delivers BeaverTail malware, targeting developer systems; similarities to past campaigns suggest a North Korean connection.
Security News
CISA's KEV data is now on GitHub, offering easier access, API integration, commit history tracking, and automated updates for security teams and researchers.