
Research
Supply Chain Attack on Axios Pulls Malicious Dependency from npm
A supply chain attack on Axios introduced a malicious dependency, plain-crypto-js@4.2.1, published minutes earlier and absent from the project’s GitHub releases.
resource-state-management
Advanced tools
A lightweight utility for efficient patching and pruning of objects in JavaScript/TypeScript state trees.
A lightweight utility for efficient patching and pruning of objects in JavaScript/TypeScript state trees.
To use this library effectively, ensure the following:
{
"id": 1,
"integrity": "company-1",
"name": "ACME Corp",
"employees": [
{
"id": 2,
"integrity": "employee-2",
"name": "John Doe"
}
]
}
Install the package using npm:
npm install resource-state-management
An integrity key is a unique code for each object in your state tree. It helps keep things consistent and avoids errors.
import md5 from 'md5';
function calculateResourceIntegrity(objectType, id) {
return md5(`${objectType}-${id}`);
}
function calculateResourceIntegrity(string $objectType, int $id) {
return md5("$objectType-$id");
}
Map<integrity, object> of all nested resources.integrity matches the provided integrity key, and prunes undefined values from the tree.Here's how you can integrate resource-state-management into an SWR-based application:
import { mutate } from 'swr';
+ import { collectResourceMap, patchResources, pruneResources } from 'resource-state-management';
+ async function patchResource(response: any) {
+ const map = collectResourceMap(response);
+ await mutate(
+ () => true, // Update global state
+ (cache: any) => patchResources(cache, map),
+ false
+ );
+ }
+ async function pruneResource(key: string) {
+ await mutate(
+ () => true,
+ (cache: any) => pruneResources(cache, key),
+ false
+ );
+ }
export async function createCompany(data) {
const response = await api.createCompany(data);
await mutate(
"api/companies",
(cache: any) => [response, ...cache],
false
);
}
export async function updateCompany(data) {
const response = await api.updateCompany(data);
+ await patchResource(response);
- await mutate(
- "api/companies",
- (cache: any) => cache.map(company => company.id === response.id ? response : company),
- false
- );
}
async function deleteCompany(company) {
const response = await api.deleteCompany(company);
- await mutate(
- "api/companies",
- (currentData: any) => currentData.filter(company => company.id !== response.id),
- false
- );
+ await pruneResource(response);
}
patchResources call for better performance.() => true).This plugin is licensed under the MIT license. See LICENSE.
FAQs
A lightweight utility for efficient patching and pruning of objects in JavaScript/TypeScript state trees.
We found that resource-state-management 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.

Research
A supply chain attack on Axios introduced a malicious dependency, plain-crypto-js@4.2.1, published minutes earlier and absent from the project’s GitHub releases.

Research
Malicious versions of the Telnyx Python SDK on PyPI delivered credential-stealing malware via a multi-stage supply chain attack.

Security News
TeamPCP is partnering with ransomware group Vect to turn open source supply chain attacks on tools like Trivy and LiteLLM into large-scale ransomware operations.