
Security News
The Hidden Blast Radius of the Axios Compromise
The Axios compromise shows how time-dependent dependency resolution makes exposure harder to detect and contain.
@uniiem/object-trim
Advanced tools
Calculate and trim object size by specifying properties
It can be used for the context length limit of LLM Chatbot histories.
npm i @uniiem/object-trim
// import trimObject
import { trimObject } from '@uniiem/object-trim'
// A object list, e.g. LLM chatbot history
const case_obj_list = [
{
id: 'fb3dd9ed-52bf-4aff-b4be-2ac9ddc95319',
role: 'user',
content: 'How is the weather today?'
},
{
id: '33643516-554b-453c-8375-4e032fe07232',
role: 'assistant',
content: 'It is sunny today.'
},
{
id: '78af377f-aa79-453a-b0df-0ef702c8f3a6',
role: 'user',
content: 'What is the temperature?'
},
{
id: '3d722395-3ab8-423f-a290-9a132a3c6dd7',
role: 'assistant',
content: 'It is 25 degrees.'
}
]
// Trim the object list by the key 'content' and max length 50
const trimmed_obj_list = trimObject(case_obj_list, 50, { keys: ['content'] })
console.log(trimmed_obj_list)
// output
/*
[
{
id: '78af377f-aa79-453a-b0df-0ef702c8f3a6',
role: 'user',
content: 'What is the temperature?'
},
{
id: '3d722395-3ab8-423f-a290-9a132a3c6dd7',
role: 'assistant',
content: 'It is 25 degrees.'
}
]
*/
const trimObject: <T>(objectList: T[], maxLength: number, props: TrimObjectProperties<T>) => T[];
interface TrimObjectProperties<T> {
keys: (keyof T)[];
fromStart?: boolean; // default: false
}
FAQs
Calculate and trim object size by specifying properties
We found that @uniiem/object-trim 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
The Axios compromise shows how time-dependent dependency resolution makes exposure harder to detect and contain.

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.