Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Refactor #19

Open
wants to merge 18 commits into
base: master
Choose a base branch
from
21 changes: 13 additions & 8 deletions index.js
Original file line number Diff line number Diff line change
Expand Up @@ -123,18 +123,23 @@ class AsyncHelpers {
}

const self = this;
const argz = args.map(function func(arg) {
const argz = args.map(async function func(arg) {
const item = self.helperIds[arg];
if (item) {
return self.resolveId(item.id);
}
// if (isObject(arg) && isObject(arg.hash)) {
// Object.keys(arg.hash).forEach(async(k) => {
// arg.hash[k] = arg.hash[k] && arg.hash[k].includes(self.prefix)
// ? await func(arg.hash[k])
// : arg.hash[k];
// });
// }
if (isObject(arg) && isObject(arg.hash)) {
for (const key of Object.keys(arg.hash)) {
arg.hash[key] = await func(arg.hash[key]);
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Absolutely intentionally using a recursive call to func() instead to the this.resolveId or this.resolveIds, because when the passed value is actual value and not an async id, then it (resolveId method) will throw.

}
}
if (Array.isArray(arg)) {
const res = [];
for (const ele of arg) {
res.push(await func(ele));
}
return res;
}
return arg;
});

Expand Down