
Security News
Attackers Are Hunting High-Impact Node.js Maintainers in a Coordinated Social Engineering Campaign
Multiple high-impact npm maintainers confirm they have been targeted in the same social engineering campaign that compromised Axios.
Srimmer provides simple api to use react, immer and TypeScript.
inspired react-copy-write.
import { define, Select } from "srimmer";
/**
* Extract consumer's selected state. `Select<typeof Consumer>`
*/
export { Select };
/**
* Your state.
*/
type State = {
todos: {
name: string;
status: string;
}[];
};
/**
* Define some state utilities from your state type.
*/
const defined = define<State>();
export const {
/**
* State provider.
* @type {React.ComponentType<{ state: State; }>}
*/
Provider,
/**
* State updater.
* @type {(updater: (state: State) => void) => void}
*/
update,
/**
* immer's patchListener.
* @type {(patchListener: PatchListener) => void}
*/
patches,
/**
* State selector.
* @type {<T>(select: (state: State) => T) => Consumer<T>}
*/
select,
/**
* State getter.
* Note: Carefully. It makes implicit depends to state values.
* @type {() => State}
*/
get,
/**
* State setter.
* Note: For testing.
* @type {(state: State) => void}
*/
set
} = defined;
import { define, Select } from 'srimmer';
export type State = { ... };
export const {
Provider,
select,
update,
patches,
get,
set
} = define<State>();
export { Select };
import { update } from "../../state";
export const addNewTask = () => {
update(state => {
state.todos.push({
name: `new todo ${state.todos.length}`,
status: "todo"
});
});
};
import React from "react";
import ReactDOM from "react-dom";
import { Provider } from "./state";
ReactDOM.render(
<Provider state={createInitialState()}>
<App />
</Provider>,
document.getElementById("app")!
);
function createInitialState() {
return JSON.stringify(document.getElementById("app")!.getAttribute("data"));
}
import { select, Select } from '../../state';
import { addNewTask } from '../action';
const Consumer = select(state => ({
todos: state.todos
}));
export default () => (
<Consumer>
{state => (
<button onClick={() => onAddButtonClick(state)}>add</button>
<div>{todos(state)}</div>
)}
</Consumer>
);
const todos = (state: Select<typeof Consumer>) => {
return state.todos.map(todo => (
<div key={todo.id}>{todo.name} - {todo.status}</div>
));
}
const onAddButtonClick = () => {
addNewTask();
};
import diff from 'snapshot-diff'; # https://github.com/jest-community/snapshot-diff
import { set, get } from '../../../src/state';
import { addNewTask } from '../../../src/action';
beforeEach(() => {
set({ ...fixture });
});
test('addNewTask', () => {
const state = get()!;
addNewTask();
expect(diff(state, get()!)).toMatchSnapshot();
});
/src
/state # State schemas and querying utility functions.
index.ts
/action # State updators.
index.ts
/component # State selectors.
index.tsx
index.tsx # Bootstrap.
See hrsh7th/ganttcharty.
FAQs
Simple seact state management library. powered by immer.
The npm package srimmer receives a total of 2 weekly downloads. As such, srimmer popularity was classified as not popular.
We found that srimmer 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
Multiple high-impact npm maintainers confirm they have been targeted in the same social engineering campaign that compromised Axios.

Security News
Axios compromise traced to social engineering, showing how attacks on maintainers can bypass controls and expose the broader software supply chain.

Security News
Node.js has paused its bug bounty program after funding ended, removing payouts for vulnerability reports but keeping its security process unchanged.