Research
Security News
Quasar RAT Disguised as an npm Package for Detecting Vulnerabilities in Ethereum Smart Contracts
Socket researchers uncover a malicious npm package posing as a tool for detecting vulnerabilities in Etherium smart contracts.
chopped-redux
Advanced tools
A very small Flux implementation based on [@gaearon](https://github.com/gaearon) [Redux](https://github.com/gaearon/redux), mainly inspired by this https://github.com/gaearon/redux/pull/166 and this https://github.com/gaearon/redux/issues/113#issuecomment
A very small Flux implementation based on @gaearon Redux, mainly inspired by this https://github.com/gaearon/redux/pull/166 and this https://github.com/gaearon/redux/issues/113#issuecomment-114049804
The idea is to provide a minimal, solid base without the React glue (you have to do that yourself). No hot reloading or time travelling (yet?).
This project follows SemVer. 1.0 doesn't mean it's stable or production-ready.
With npm
do:
npm install chopped-redux --save
Stores are pure functions, just like in Redux. They don't hold the state and don't emit events either. They just receive the state, update it, and return the new state.
var actionTypes = require('../constants/action-types')
var initialState = 0
module.exports = function (state, action) {
state = state || initialState
switch (action.type) {
case actionTypes.INCREMENT_COUNTER:
return state + 1
break
case actionTypes.DECREMENT_COUNTER:
return state - 1
break
default:
return state
}
}
Actions should have the following signature, always receiving a dispatch
function as last argument. (There's a utility wrapper function to make this easy)
var actionTypes = require('../constants/action-types')
exports.increment = function (dispatch) {
return dispatch({
type: actionTypes.INCREMENT_COUNTER
})
}
exports.decrement = function (dispatch) {
return dispatch({
type: actionTypes.DECREMENT_COUNTER
})
}
Yep.
module.exports = {
INCREMENT_COUNTER: 'INCREMENT_COUNTER',
DECREMENT_COUNTER: 'DECREMENT_COUNTER',
}
var fluxFactory = require('chopped-redux')
var wrap = fluxFactory.wrapActionCreators
var stores = {
counter: require('./stores/counter'),
beep: function (state, action) {
return action.type === SOME_ACTION_TYPE_CONSTANT
? 'boop'
: state || undefined
}
}
var actionCreators = {
counter: require('./actions/counter'),
}
var flux = fluxFactory(stores, { counter: 1 })
var actions = wrap(actionCreators, flux.getDispatcher())
var unsubscribe = flux.subscribe(function () {
console.log(flux.getState())
})
actions.increment()
// => { counter: 2 }
unsubscribe()
MIT
FAQs
An implementation of @gaearon Redux
The npm package chopped-redux receives a total of 4 weekly downloads. As such, chopped-redux popularity was classified as not popular.
We found that chopped-redux 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.
Research
Security News
Socket researchers uncover a malicious npm package posing as a tool for detecting vulnerabilities in Etherium smart contracts.
Security News
Research
A supply chain attack on Rspack's npm packages injected cryptomining malware, potentially impacting thousands of developers.
Research
Security News
Socket researchers discovered a malware campaign on npm delivering the Skuld infostealer via typosquatted packages, exposing sensitive data.