
Company News
Socket Named Top Sales Organization by RepVue
Socket won two 2026 Reppy Awards from RepVue, ranking in the top 5% of all sales orgs. AE Alexandra Lister shares what it's like to grow a sales career here.
dotprune is a simple tool that allows you to remove all properties from a JavaScript object that are not present in present in an array of properties. dot notation can be used to specify sub properties to keep or prefix propertied with an ! to keep everything but them. If you do not want to alter the original object, a boolean true value can be supplied as the third argument in the prune function.
dotprune can now also replace circular references
dotprune.prune( object, fields, [perserve] )object Object - the object to prune.fields Array - Array of paths to keep or not keep. Can use dot notation (i.e. ['!name.value'] or ['name.value', 'name.id'])perserve=false] Boolean - Create a pruned copy of the object instead of pruning it in placedotprune.circular( object, [replacement] )object Object - the object in which to replace circular references.replacement="[Circular]"] * - The value to use as a replacement. If replacement is a function it will be passed the circular object and its return value will be used as the replacementvar dotprune = require('dotprune');
// define a javascript object with sub-properties
var obj = [
{
id: 1,
name: "Jack Shepard",
groups: [
{
id: 1,
name: "survivors",
station: {
id: 2,
name: "swan"
}
},
{
id: 2,
name: "chosen ones",
station: {
id: 5,
name: "temple"
}
}
]
}
];
// call the prune function with the object and an array of properties
var prunedObject = dotprune.prune(obj, ['id', 'name', 'groups.name', 'groups.station.name']);
// format the output and print it to the console
var prettyObject = JSON.stringify(prunedObject, null, ' ');
console.log(prettyObject);
[
{
"id": 1,
"name": "Jack Shepard",
"groups": [
{
"name": "survivors",
"station": {
"name": "swan"
}
},
{
"name": "chosen ones",
"station": {
"name": "temple"
}
}
]
}
]
var dotprune = require('dotprune');
var main = {
name: 'main',
obj1: {
name: 'main'
}
};
main.obj1.main = main;
main.obj2 = main;
var main2 = {
name: 'main2',
obj: main
};
var obj = dotprune.circular([main, main2], function(obj) {
return '[CustomCircular]';
});
console.log(JSON.stringify(obj, null, ' '));
[
{
"name": "main",
"obj1": {
"name": "main",
"main": "[CustomCircular]"
},
"obj2": "[CustomCircular]"
},
{
"name": "main2",
"obj": {
"name": "main",
"obj1": {
"name": "main",
"main": "[CustomCircular]"
},
"obj2": "[CustomCircular]"
}
}
]
Created with Nodeclipse (Eclipse Marketplace, site)
Nodeclipse is free open-source project that grows with your contributions.
FAQs
Deep filters for Javascript objects using dot notation
We found that dotprune 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.

Company News
Socket won two 2026 Reppy Awards from RepVue, ranking in the top 5% of all sales orgs. AE Alexandra Lister shares what it's like to grow a sales career here.

Security News
NIST will stop enriching most CVEs under a new risk-based model, narrowing the NVD's scope as vulnerability submissions continue to surge.

Company News
/Security News
Socket is an initial recipient of OpenAI's Cybersecurity Grant Program, which commits $10M in API credits to defenders securing open source software.