clean-deep
clean-deep copied to clipboard
Functions/methods options
First of all, thank you! This is one of the first packages I add to new projects.
I typically use this plugin to create db/json-friendly objects from third-party APIs, and end up using the cleanKeys option once I've sussed-out those functions.
Thanks again!
EDIT
Current trial-and-error solution
With some trial and error I can usually find and clean functions in an object with the cleanKeys
option.
It's not always easy to find every key associated with a function, especially deeply nested functions.
My current struggles
const cleanDeep = require("clean-deep");
const object = {
foo: "bar",
fn: () => {
return `I wish clean-deep had an option to remove functions like this`;
},
someUnknownFunctionKey: () => {
return `I'm a pain in the ass to find`;
},
};
const result = cleanDeep(object, {
cleanKeys: ["fn"],
});
/** Output
{
foo: 'bar'
},
someUnknownFunctionKey: () => {
return `I'm a pain in the ass to find`;
},
*/
. . .
In an ideal world...
... an ideal world where saving a split second actually made a difference...
I'm really looking for an option like cleanKeys
, emptyArrays
, etc., but for functions.
In my head the functions
option looks like this...
const cleanDeep = require("clean-deep");
const object = {
foo: "bar",
fn: () => {
return `I wish clean-deep had an option to remove functions like this`;
},
someUnknownFunctionKey: () => {
return `I'm a pain in the ass to find`;
},
};
const result = cleanDeep(object, {
functions: true
});
/** Successful Output
{
foo: 'bar'
}
*/
Hi @tylergrow, thank you for the kind words. The issue title seems to refer to something you might need. Can you elaborate?
I'm sorry - I deleted the meat of the issue, then hit submit and went on my way. :/
@nunofgs I've updated the issue above :)