Closed
Description
Hi
I tried to replicate your example of adding a custom field to my directory and I got the below error
TypeError: Cannot set properties of undefined (setting 'id')
Code used
const callback: DirectoryTreeCallback = (
item: DirectoryTree,
path: string
) => {
item.custom.id = createHash('sha1').update(path).digest('base64');
};
const dirTree: DirectoryTree & { id?: string } = directoryTree(
unzipTargetPath,
{},
callback,
callback
);
console.log(JSON.stringify(dirTree, null, 2));
Can you please advice ? I am using Typescript.
Regards,
Ameya
Activity
mihneadb commentedon May 10, 2022
Hi, you are right, there was an issue with the readme. I pushed an update to it, you should actually define the
custom
obj yourself.