@ztimson/utils 0.23.5 → 0.23.7

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.d.ts CHANGED
@@ -2,6 +2,7 @@ export * from './arg-parser';
2
2
  export * from './array';
3
3
  export * from './aset';
4
4
  export * from './cache';
5
+ export * from './color';
5
6
  export * from './csv';
6
7
  export * from './files';
7
8
  export * from './emitter';
package/dist/index.mjs CHANGED
@@ -528,6 +528,13 @@ class Cache {
528
528
  return this;
529
529
  }
530
530
  }
531
+ function blackOrWhite(background) {
532
+ const exploded = background.match(background.length >= 6 ? /\w\w/g : /\w/g);
533
+ if (!exploded) return "black";
534
+ const [r2, g, b2] = exploded.map((hex) => parseInt(hex, 16));
535
+ const luminance = (0.299 * r2 + 0.587 * g + 0.114 * b2) / 255;
536
+ return luminance > 0.5 ? "black" : "white";
537
+ }
531
538
  const LETTER_LIST = "ABCDEFGHIJKLMNOPQRSTUVWXYZ";
532
539
  const NUMBER_LIST = "0123456789";
533
540
  const SYMBOL_LIST = "~`!@#$%^&*()_-+={[}]|\\:;\"'<,>.?/";
@@ -1365,7 +1372,7 @@ class PathEvent {
1365
1372
  const parsedFind = makeArray(filter).map((pe) => new PathEvent(pe));
1366
1373
  return parsedTarget.filter((t) => {
1367
1374
  if (!t.fullPath && t.all) return true;
1368
- return !!parsedFind.find((f) => t.fullPath.startsWith(f.fullPath) && (f.all || t.all || t.methods.intersection(f.methods).length));
1375
+ return !!parsedFind.find((f) => f.fullPath.startsWith(t.fullPath) && (f.all || t.all || t.methods.intersection(f.methods).length));
1369
1376
  });
1370
1377
  }
1371
1378
  /**
@@ -1692,6 +1699,7 @@ export {
1692
1699
  addUnique,
1693
1700
  adjustedInterval,
1694
1701
  arrayDiff,
1702
+ blackOrWhite,
1695
1703
  caseInsensitiveSort,
1696
1704
  clean,
1697
1705
  dec2Frac,