
Security News
vlt Launches "reproduce": A New Tool Challenging the Limits of Package Provenance
vlt's new "reproduce" tool verifies npm packages against their source code, outperforming traditional provenance adoption in the JavaScript ecosystem.
@erickmerchant/framework
Advanced tools
This scoped package is my personal framework. I use it on a number of small projects.
This example uses yo-yo (which uses hyperx), but you should be able to use diffHTML and possibly other solutions.
const framework = require('@erickmerchant/framework')
const html = require('yo-yo')
const diff = html.update
const target = document.querySelector('main')
framework({target, store, component, diff})()
function store (commit) {
commit(() => 0)
return function (action) {
switch (action) {
case 'increment':
commit((state) => state + 1)
break
case 'decrement':
commit((state) => state - 1)
break
}
}
}
function component ({state, dispatch}) {
return html`<main>
<output>${state}</output>
<br>
<button onclick=${() => dispatch('decrement')}>--</button>
<button onclick=${() => dispatch('increment')}>++</button>
</main>`
}
framework({target, store, component, diff, raf})
The function exported by this module.
Returns a function. See init
This is what is passed to commit. It can be anything from simply a number like in the example, but a plain object makes sense in most cases.
commit((current) => next)
It's passed a callback that receives the current state and should return the new state.
dispatch(...arguments)
Initializes a change in state and causes a render. If the length of arguments is 0, the agent is not called, but a render is triggered.
next((target) => { ... })
A convenient helper to pass a callback to process.nextTick. Can be used to manipulate the page in some way after a render. For example scrolling to a specific element or focusing an input element.
init((dispatch) => { ... })
Call init to do some initial work that may require dispatch.
store(commit)
It should return the agent.
agent(..arguments)
Anything returned will be ignored
component({state, dispatch, next})
Should return the element to pass to diff
diff(target, element)
A module to do routing inside your components.
The source code can be found here
FAQs
A front-end framework.
The npm package @erickmerchant/framework receives a total of 5 weekly downloads. As such, @erickmerchant/framework popularity was classified as not popular.
We found that @erickmerchant/framework 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
vlt's new "reproduce" tool verifies npm packages against their source code, outperforming traditional provenance adoption in the JavaScript ecosystem.
Research
Security News
Socket researchers uncovered a malicious PyPI package exploiting Deezer’s API to enable coordinated music piracy through API abuse and C2 server control.
Research
The Socket Research Team discovered a malicious npm package, '@ton-wallet/create', stealing cryptocurrency wallet keys from developers and users in the TON ecosystem.