
Product
Announcing Precomputed Reachability Analysis in Socket
Socket’s precomputed reachability slashes false positives by flagging up to 80% of vulnerabilities as irrelevant, with no setup and instant results.
Silly (but lowkey kinda good?) idea for a immer-like tool that is super lightweight (and probably faster?) but most importantly doesn't pollute your stack frames with Proxies.
type Todo = {
id: string;
title: string;
completed: boolean;
};
type AppState = {
todos: Todo[];
filter: "all" | "active" | "completed";
};
const baseState: AppState = {
todos: [
{ id: "1", title: "Buy milk", completed: false },
{ id: "2", title: "Clean the bath", completed: false },
],
filter: "all",
};
const nextState = produce(baseState, (draft) => {
// draft is a proxy (boo)
draft.todos[1].completed = true;
});
const nextState2 = edit(baseState).todos[1]((todo) => {
// todo is a regular ass JS object, via structuredClone
todo.completed = true;
});
// or just
const nextState3 = edit(baseState).todos[1].completed(true);
The main api issue is that it does a deep structuredClone
on the target object by default, so if you want to do minimum copying while making multiple edits you'd need to be aware of the shallow
option.
const nextState4 = edit(baseState, {shallow: true})(state => {
state.filer = 'active'
state.todos = edit(state.todos)[0].completed(true)
})
It's also just a little weird as an API, but I reckon people would get used to it pretty quickly. Plus with TS and Object.freeze at dev time I reckon it could be pretty on-rails?
FAQs
better edit than immer
The npm package bedit receives a total of 2 weekly downloads. As such, bedit popularity was classified as not popular.
We found that bedit 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.
Product
Socket’s precomputed reachability slashes false positives by flagging up to 80% of vulnerabilities as irrelevant, with no setup and instant results.
Product
Socket is launching experimental protection for Chrome extensions, scanning for malware and risky permissions to prevent silent supply chain attacks.
Product
Add secure dependency scanning to Claude Desktop with Socket MCP, a one-click extension that keeps your coding conversations safe from malicious packages.