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.
Just another tiny, simple state machine
Nobody thinks the JS community needs another state management library, so I made one to spite you all.
npm install mehdux
import { stateManager } from 'mehdux'
const initialState = {
someValue: 'My value'
}
const actions = {
setName: state => value => ({
...state,
someValue: value
})
}
}
const store = stateManager(initialState, actions)
store.subscribe(console.log)
store.actions.setValue('A cooler value')
// logs { someValue: 'A cooler Value' }
import { connect } from 'mehdux/react' // or 'mehdux/preact
const SomeComponent = ({ myValue }) => <h1>{myValue}</h1>
export default connect(store)(SomeComponent)
// Some component has access the whole state and all the actions in the store
import { connect } from 'mehdux/react' // or 'mehdux/preact
const SomeComponent = ({ myValue }) => <h1>{myValue}</h1>
function mapStateToProps(state) {
return {
myValue: state.something.i.care.about
}
}
export default connect(store, state, mapStateToProps)(SomeComponent)
// Some component has access to myValue and all the actions in the store
import { connect } from 'mehdux/react' // or 'mehdux/preact'
const SomeComponent = ({ myValue }) => <h1>{myValue}</h1>
function mapStateToProps(state) {
return {
myValue: state.something.i.care.about
}
}
function mapActionsToProps(actions) {
return {
setName: actions.setName,
setUpperCaseName: (value) => actions.setName(value.toUpperCase())
}
}
export default connect(store, null, mapActionsToProps)(SomeComponent)
/*
Some component has access to the whole state tree
and the setName and setUpperCaseName functions
*/
const actions = {
setName: state => {
return value => ({
...state,
someValue: value
})
},
fetchAndSetName: async (state, dispatch) => {
const res = await fetch('https://myapi.com/v0')
const data = await res.json()
dispatch('setName', data.name)
}
}
MIT.
FAQs
A straight forward state container
The npm package mehdux receives a total of 43 weekly downloads. As such, mehdux popularity was classified as not popular.
We found that mehdux 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.