@ztimson/utils 0.24.0 → 0.24.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.cjs CHANGED
@@ -1426,6 +1426,10 @@ ${opts.message || this.desc}`;
1426
1426
  split = split.pop().split("/");
1427
1427
  return whole + Number(split[0]) / Number(split[1]);
1428
1428
  }
1429
+ function asyncFunction(args, fn) {
1430
+ const keys = Object.keys(args);
1431
+ return new Function(...keys, `return (async (${keys.join(",")}) => { ${fn} })(${keys.join(",")})`)(...keys.map((k) => args[k]));
1432
+ }
1429
1433
  function gravatar(email, def = "mp") {
1430
1434
  if (!email) return "";
1431
1435
  return `https://www.gravatar.com/avatar/${md5(email)}?d=${def}`;
@@ -1758,6 +1762,7 @@ ${opts.message || this.desc}`;
1758
1762
  exports2.addUnique = addUnique;
1759
1763
  exports2.adjustedInterval = adjustedInterval;
1760
1764
  exports2.arrayDiff = arrayDiff;
1765
+ exports2.asyncFunction = asyncFunction;
1761
1766
  exports2.blackOrWhite = blackOrWhite;
1762
1767
  exports2.camelCase = camelCase;
1763
1768
  exports2.caseInsensitiveSort = caseInsensitiveSort;