
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.
nested-response
Advanced tools
Make nested response from flat records
$ npm install nested-response
const nestedResponse = require('nested-response');
// This is a sample of flat records that we're going to make it nested
// You might get these records from anywhere (i.e. SQL databases)
const records = [
{
storeId: 1,
storeName: 'store A',
productId: 1,
productName: 'product A',
}
{
storeId: 1,
storeName: 'store A',
productId: 2,
productName: 'product B',
}
{
storeId: 2,
storeName: 'store B',
productId: 3,
productName: 'product C',
}
];
// You need to define a pattern for nesting
// Also have some options for customizing the output
const definition = [{
storeId: 'storeId',
storeName: 'storeName',
products: [{
id: 'productId',
name: 'productName',
}]
}];
const nestedResult = nestedResponse(records, definition);
// nestedResult: [
// {
// storeId: 1,
// storeName: 'store A',
// products: [
// {
// id: 1,
// name: 'product A',
// },
// {
// id: 2,
// name: 'product B',
// }
// ]
// },
// {
// storeId: 2,
// storeName: 'store B',
// products: [
// {
// id: 3,
// name: 'product C',
// }
// ]
// }
// ];
The
primary keyis defined the first property in each level of nesting (by default)
You also have some options to customize the output
For example:
You can change the primary key field:
storeName: { $column: 'storeName', $pk: true }
You can also change the type of value or define a default value if the field doesn't exist on the record:
prodSerial: { $column: 'productSerialNumber', $type: 'number', $default: 123456 }
If you're going to use these options, the $column property is mandatory
FAQs
Make nested response from flat records
We found that nested-response 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.