cafe-utility 16.2.0 → 16.3.0

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.
Files changed (3) hide show
  1. package/index.d.ts +2 -0
  2. package/index.js +140 -132
  3. package/package.json +1 -1
package/index.d.ts CHANGED
@@ -127,6 +127,7 @@ declare function splitOnce(string: string, separator: string, last?: boolean): [
127
127
  declare function splitAll(string: string, separators: string[]): string[];
128
128
  declare function getExtension(path: string): string;
129
129
  declare function getBasename(path: string): string;
130
+ declare function normalizeEmail(email: string): string;
130
131
  declare function normalizeFilename(path: string): string;
131
132
  interface ParsedFilename {
132
133
  basename: string;
@@ -628,6 +629,7 @@ export declare const Strings: {
628
629
  surroundInOut: typeof surroundInOut;
629
630
  getExtension: typeof getExtension;
630
631
  getBasename: typeof getBasename;
632
+ normalizeEmail: typeof normalizeEmail;
631
633
  normalizeFilename: typeof normalizeFilename;
632
634
  parseFilename: typeof parseFilename;
633
635
  camelToTitle: typeof camelToTitle;
package/index.js CHANGED
@@ -24,7 +24,7 @@ async function runInParallelBatches(n, e = 1) {
24
24
  const t = splitByCount(n, e),
25
25
  r = [],
26
26
  o = t.map(async i => {
27
- for (const u of i) r.push(await u())
27
+ for (const s of i) r.push(await s())
28
28
  })
29
29
  return await Promise.all(o), r
30
30
  }
@@ -120,16 +120,16 @@ function pickManyUnique(n, e, t, r = Math.random) {
120
120
  const o = []
121
121
  for (; o.length < e; ) {
122
122
  const i = pick(n, r)
123
- o.some(u => t(u, i)) || o.push(i)
123
+ o.some(s => t(s, i)) || o.push(i)
124
124
  }
125
125
  return o
126
126
  }
127
127
  function pickGuaranteed(n, e, t, r, o, i = Math.random) {
128
- const u = n.filter(s => s !== e && s !== t),
128
+ const s = n.filter(u => u !== e && u !== t),
129
129
  c = []
130
- for (e !== null && c.push(e); u.length && c.length < r; ) {
131
- const s = exports.Random.intBetween(0, u.length - 1, i)
132
- o(u[s], c) && c.push(u[s]), u.splice(s, 1)
130
+ for (e !== null && c.push(e); s.length && c.length < r; ) {
131
+ const u = exports.Random.intBetween(0, s.length - 1, i)
132
+ o(s[u], c) && c.push(s[u]), s.splice(u, 1)
133
133
  }
134
134
  return shuffle(c, i), { values: c, indexOfGuaranteed: e !== null ? c.indexOf(e) : -1 }
135
135
  }
@@ -138,7 +138,7 @@ function last(n) {
138
138
  }
139
139
  function pickWeighted(n, e, t) {
140
140
  if ((isUndefined(t) && (t = Math.random()), n.length !== e.length)) throw new Error('Array length mismatch')
141
- let r = e.reduce((i, u) => i + u, 0)
141
+ let r = e.reduce((i, s) => i + s, 0)
142
142
  const o = t * r
143
143
  for (let i = 0; i < n.length - 1; i++) if (((r -= e[i]), o >= r)) return n[i]
144
144
  return last(n)
@@ -147,7 +147,7 @@ function sortWeighted(n, e, t = Math.random) {
147
147
  const r = e.map(i => t() * i),
148
148
  o = []
149
149
  for (let i = 0; i < n.length; i++) o.push([n[i], r[i]])
150
- return o.sort((i, u) => u[1] - i[1]).map(i => i[0])
150
+ return o.sort((i, s) => s[1] - i[1]).map(i => i[0])
151
151
  }
152
152
  function getDeep(n, e) {
153
153
  const t = e.split('.')
@@ -165,9 +165,9 @@ function setDeep(n, e, t) {
165
165
  const r = e.split(/\.|\[/)
166
166
  let o = n
167
167
  for (let i = 0; i < r.length; i++) {
168
- const u = r[i],
168
+ const s = r[i],
169
169
  c = i < r.length - 1 && r[i + 1].includes(']'),
170
- l = u.includes(']') ? u.replace(/\[|\]/g, '') : u
170
+ l = s.includes(']') ? s.replace(/\[|\]/g, '') : s
171
171
  if (i === r.length - 1) return (o[l] = t), t
172
172
  isObject(o[l]) || (c ? (o[l] = []) : (o[l] = {})), (o = o[l])
173
173
  }
@@ -664,6 +664,13 @@ function getBasename(n) {
664
664
  t = e.lastIndexOf('.', e.length - 1)
665
665
  return t <= 0 ? e : e.slice(0, t)
666
666
  }
667
+ function normalizeEmail(n) {
668
+ let [e, t] = n.split('@')
669
+ e = e.replaceAll('.', '').toLowerCase()
670
+ const [r] = e.split('+')
671
+ if (!r || !t || t.indexOf('.') === -1 || t.indexOf('.') === t.length - 1) throw new Error('Invalid email')
672
+ return `${r}@${t.toLowerCase()}`
673
+ }
667
674
  function normalizeFilename(n) {
668
675
  const e = getBasename(n),
669
676
  t = getExtension(n)
@@ -684,12 +691,12 @@ function expand(n) {
684
691
  const r = t[1].split(','),
685
692
  o = n.slice(0, t.index),
686
693
  i = n.slice(t.index + t[0].length)
687
- let u = []
694
+ let s = []
688
695
  for (const c of r) {
689
- const s = expand(o + c + i)
690
- u = u.concat(s)
696
+ const u = expand(o + c + i)
697
+ s = s.concat(u)
691
698
  }
692
- return u
699
+ return s
693
700
  }
694
701
  function shrinkTrim(n) {
695
702
  return n.replace(/\s+/g, ' ').replace(/\s$|^\s/g, '')
@@ -913,13 +920,13 @@ function base64ToUint8Array(n) {
913
920
  let o = 0,
914
921
  i = 0
915
922
  for (; o < n.length; ) {
916
- const u = BASE64_CHARS.indexOf(n.charAt(o++)),
923
+ const s = BASE64_CHARS.indexOf(n.charAt(o++)),
917
924
  c = BASE64_CHARS.indexOf(n.charAt(o++)),
918
- s = BASE64_CHARS.indexOf(n.charAt(o++)),
925
+ u = BASE64_CHARS.indexOf(n.charAt(o++)),
919
926
  l = BASE64_CHARS.indexOf(n.charAt(o++)),
920
- f = (u << 2) | (c >> 4),
921
- a = ((c & 15) << 4) | (s >> 2),
922
- h = ((s & 3) << 6) | l
927
+ f = (s << 2) | (c >> 4),
928
+ a = ((c & 15) << 4) | (u >> 2),
929
+ h = ((u & 3) << 6) | l
923
930
  ;(r[i++] = f), i < t && (r[i++] = a), i < t && (r[i++] = h)
924
931
  }
925
932
  return r
@@ -930,12 +937,12 @@ function uint8ArrayToBase64(n) {
930
937
  for (let r = 0; r < n.length; r += 3) {
931
938
  const o = n[r],
932
939
  i = n[r + 1],
933
- u = n[r + 2],
940
+ s = n[r + 2],
934
941
  c = o >> 2,
935
- s = ((o & 3) << 4) | (i >> 4),
936
- l = ((i & 15) << 2) | (u >> 6),
937
- f = u & 63
938
- ;(e += BASE64_CHARS[c] + BASE64_CHARS[s]),
942
+ u = ((o & 3) << 4) | (i >> 4),
943
+ l = ((i & 15) << 2) | (s >> 6),
944
+ f = s & 63
945
+ ;(e += BASE64_CHARS[c] + BASE64_CHARS[u]),
939
946
  r + 1 < n.length ? (e += BASE64_CHARS[l]) : t++,
940
947
  r + 2 < n.length ? (e += BASE64_CHARS[f]) : t++
941
948
  }
@@ -962,9 +969,9 @@ function route(n, e) {
962
969
  if (t.length !== r.length) return null
963
970
  const o = {}
964
971
  for (let i = 0; i < t.length; i++) {
965
- const u = t[i]
966
- if (u.startsWith(':')) o[u.slice(1)] = r[i]
967
- else if (u !== r[i]) return null
972
+ const s = t[i]
973
+ if (s.startsWith(':')) o[s.slice(1)] = r[i]
974
+ else if (s !== r[i]) return null
968
975
  }
969
976
  return o
970
977
  }
@@ -975,25 +982,25 @@ function explodeReplace(n, e, t) {
975
982
  }
976
983
  function generateVariants(n, e, t, r = Math.random) {
977
984
  const o = exports.Arrays.shuffle(
978
- e.map(u => ({
985
+ e.map(s => ({
979
986
  variants: exports.Arrays.shuffle(
980
- u.variants.map(c => c),
987
+ s.variants.map(c => c),
981
988
  r
982
989
  ),
983
- avoid: u.avoid
990
+ avoid: s.avoid
984
991
  })),
985
992
  r
986
993
  ),
987
994
  i = []
988
- for (const u of o) {
989
- const c = u.variants.filter(l => l !== u.avoid),
990
- s = c.find(l => n.includes(l))
991
- if (s && (pushAll(i, explodeReplace(n, s, c)), i.length >= t)) break
995
+ for (const s of o) {
996
+ const c = s.variants.filter(l => l !== s.avoid),
997
+ u = c.find(l => n.includes(l))
998
+ if (u && (pushAll(i, explodeReplace(n, u, c)), i.length >= t)) break
992
999
  }
993
1000
  if (i.length < t)
994
- for (const u of o) {
995
- const c = u.variants.find(s => n.includes(s))
996
- if (c && (pushAll(i, explodeReplace(n, c, u.variants)), i.length >= t)) break
1001
+ for (const s of o) {
1002
+ const c = s.variants.find(u => n.includes(u))
1003
+ if (c && (pushAll(i, explodeReplace(n, c, s.variants)), i.length >= t)) break
997
1004
  }
998
1005
  return i.slice(0, t)
999
1006
  }
@@ -1060,8 +1067,8 @@ function resolveRemainingVariablesWithDefaults(n, e = '$', t = ':') {
1060
1067
  if (n[r + o.length + 1] === t)
1061
1068
  if (n[r + o.length + 2] === t) n = n.replace(`${e}${o}${t}${t}`, '')
1062
1069
  else {
1063
- const u = readNextWord(n, r + o.length + 2)
1064
- n = n.replace(`${e}${o}${t}${u}`, u)
1070
+ const s = readNextWord(n, r + o.length + 2)
1071
+ n = n.replace(`${e}${o}${t}${s}`, s)
1065
1072
  }
1066
1073
  r = n.indexOf(e, r + 1)
1067
1074
  }
@@ -1073,8 +1080,8 @@ function resolveMarkdownLinks(n, e) {
1073
1080
  const r = lastIndexOfBefore(n, '[', t),
1074
1081
  o = n.indexOf(')', t)
1075
1082
  if (r !== -1 && o !== -1) {
1076
- const [i, u] = n.slice(r + 1, o).split(']('),
1077
- c = e(i, u)
1083
+ const [i, s] = n.slice(r + 1, o).split(']('),
1084
+ c = e(i, s)
1078
1085
  n = n.slice(0, r) + c + n.slice(o + 1)
1079
1086
  }
1080
1087
  t = n.indexOf('](', t + 1)
@@ -1107,8 +1114,8 @@ function parseCsv(n, e = ',', t = '"') {
1107
1114
  const r = []
1108
1115
  let o = '',
1109
1116
  i = !1
1110
- const u = n.split('')
1111
- for (const c of u) c === e && !i ? (r.push(o), (o = '')) : c === t && ((!o && !i) || i) ? (i = !i) : (o += c)
1117
+ const s = n.split('')
1118
+ for (const c of s) c === e && !i ? (r.push(o), (o = '')) : c === t && ((!o && !i) || i) ? (i = !i) : (o += c)
1112
1119
  return r.push(o), r
1113
1120
  }
1114
1121
  function humanizeProgress(n) {
@@ -1190,11 +1197,11 @@ function getAgoStructured(n, e) {
1190
1197
  function countCycles(n, e, t) {
1191
1198
  var r, o, i
1192
1199
  const c = ((r = t?.now) !== null && r !== void 0 ? r : Date.now()) - n,
1193
- s = Math.floor(c / e),
1200
+ u = Math.floor(c / e),
1194
1201
  l =
1195
1202
  e / ((o = t?.precision) !== null && o !== void 0 ? o : 1) -
1196
1203
  Math.ceil((c % e) / ((i = t?.precision) !== null && i !== void 0 ? i : 1))
1197
- return { cycles: s, remaining: l }
1204
+ return { cycles: u, remaining: l }
1198
1205
  }
1199
1206
  const throttleTimers = {}
1200
1207
  function throttle(n, e) {
@@ -1210,10 +1217,10 @@ function getProgress(n, e, t, r) {
1210
1217
  r || (r = Date.now())
1211
1218
  const o = e / t,
1212
1219
  i = r - n,
1213
- u = i / e,
1214
- c = u * t,
1215
- s = c - i
1216
- return { deltaMs: i, progress: o, baseTimeMs: u, totalTimeMs: c, remainingTimeMs: s }
1220
+ s = i / e,
1221
+ c = s * t,
1222
+ u = c - i
1223
+ return { deltaMs: i, progress: o, baseTimeMs: s, totalTimeMs: c, remainingTimeMs: u }
1217
1224
  }
1218
1225
  const dayNumberIndex = {
1219
1226
  0: 'sunday',
@@ -1282,8 +1289,8 @@ async function getCached(n, e, t) {
1282
1289
  o = tinyCache[n]
1283
1290
  if (o && o.validUntil > r) return o.value
1284
1291
  const i = await t(),
1285
- u = r + e
1286
- return (tinyCache[n] = { value: i, validUntil: u }), i
1292
+ s = r + e
1293
+ return (tinyCache[n] = { value: i, validUntil: s }), i
1287
1294
  }
1288
1295
  function joinUrl(...n) {
1289
1296
  return n
@@ -1293,9 +1300,9 @@ function joinUrl(...n) {
1293
1300
  }
1294
1301
  function replaceBetweenStrings(n, e, t, r, o = !0) {
1295
1302
  const i = n.indexOf(e),
1296
- u = n.indexOf(t, i + e.length)
1297
- if (i === -1 || u === -1) throw Error('Start or end not found')
1298
- return o ? n.substring(0, i + e.length) + r + n.substring(u) : n.substring(0, i) + r + n.substring(u + t.length)
1303
+ s = n.indexOf(t, i + e.length)
1304
+ if (i === -1 || s === -1) throw Error('Start or end not found')
1305
+ return o ? n.substring(0, i + e.length) + r + n.substring(s) : n.substring(0, i) + r + n.substring(s + t.length)
1299
1306
  }
1300
1307
  function describeMarkdown(n) {
1301
1308
  let e = 'p'
@@ -1375,20 +1382,20 @@ function createStatefulToggle(n) {
1375
1382
  }
1376
1383
  function organiseWithLimits(n, e, t, r, o) {
1377
1384
  const i = {}
1378
- for (const u of Object.keys(e)) i[u] = []
1385
+ for (const s of Object.keys(e)) i[s] = []
1379
1386
  ;(i[r] = []), o && (n = n.sort(o))
1380
- for (const u of n) {
1381
- const c = u[t],
1382
- s = e[c] ? c : r
1383
- i[s].length >= e[s] ? i[r].push(u) : i[s].push(u)
1387
+ for (const s of n) {
1388
+ const c = s[t],
1389
+ u = e[c] ? c : r
1390
+ i[u].length >= e[u] ? i[r].push(s) : i[u].push(s)
1384
1391
  }
1385
1392
  return i
1386
1393
  }
1387
1394
  function diffKeys(n, e) {
1388
1395
  const t = Object.keys(n),
1389
1396
  r = Object.keys(e),
1390
- o = t.filter(u => !r.includes(u)),
1391
- i = r.filter(u => !t.includes(u))
1397
+ o = t.filter(s => !r.includes(s)),
1398
+ i = r.filter(s => !t.includes(s))
1392
1399
  return { uniqueToA: o, uniqueToB: i }
1393
1400
  }
1394
1401
  function pickRandomKey(n) {
@@ -1443,12 +1450,12 @@ function formatNumber(n, e) {
1443
1450
  var t, r
1444
1451
  const o = (t = e?.longForm) !== null && t !== void 0 ? t : !1,
1445
1452
  i = e?.unit ? ` ${e.unit}` : '',
1446
- u = o ? longNumberUnits : shortNumberUnits,
1453
+ s = o ? longNumberUnits : shortNumberUnits,
1447
1454
  c = (r = e?.precision) !== null && r !== void 0 ? r : 1
1448
1455
  if (n < thresholds[0]) return `${n}${i}`
1449
- for (let s = 0; s < thresholds.length - 1; s++)
1450
- if (n < thresholds[s + 1]) return `${(n / thresholds[s]).toFixed(c)}${o ? ' ' : ''}${u[s]}${i}`
1451
- return `${(n / thresholds[thresholds.length - 1]).toFixed(c)}${o ? ' ' : ''}${u[thresholds.length - 1]}${i}`
1456
+ for (let u = 0; u < thresholds.length - 1; u++)
1457
+ if (n < thresholds[u + 1]) return `${(n / thresholds[u]).toFixed(c)}${o ? ' ' : ''}${s[u]}${i}`
1458
+ return `${(n / thresholds[thresholds.length - 1]).toFixed(c)}${o ? ' ' : ''}${s[thresholds.length - 1]}${i}`
1452
1459
  }
1453
1460
  function makeNumber(n) {
1454
1461
  const e = parseFloat(n)
@@ -1528,21 +1535,21 @@ function flip(n) {
1528
1535
  function getAllPermutations(n) {
1529
1536
  const e = Object.keys(n),
1530
1537
  t = e.map(c => n[c].length),
1531
- r = t.reduce((c, s) => (c *= s))
1538
+ r = t.reduce((c, u) => (c *= u))
1532
1539
  let o = 1
1533
1540
  const i = [1]
1534
1541
  for (let c = 0; c < t.length - 1; c++) (o *= t[c]), i.push(o)
1535
- const u = []
1542
+ const s = []
1536
1543
  for (let c = 0; c < r; c++) {
1537
- const s = {}
1544
+ const u = {}
1538
1545
  for (let l = 0; l < e.length; l++) {
1539
1546
  const f = n[e[l]],
1540
1547
  a = Math.floor(c / i[l]) % f.length
1541
- s[e[l]] = f[a]
1548
+ u[e[l]] = f[a]
1542
1549
  }
1543
- u.push(s)
1550
+ s.push(u)
1544
1551
  }
1545
- return u
1552
+ return s
1546
1553
  }
1547
1554
  function countTruthyValues(n) {
1548
1555
  return Object.values(n).filter(e => e).length
@@ -1552,15 +1559,15 @@ function getFlatNotation(n, e, t) {
1552
1559
  }
1553
1560
  function flattenInner(n, e, t, r, o) {
1554
1561
  if (!isObject(e)) return e
1555
- for (const [i, u] of Object.entries(e)) {
1562
+ for (const [i, s] of Object.entries(e)) {
1556
1563
  const c = getFlatNotation(t, i, r)
1557
- Array.isArray(u)
1564
+ Array.isArray(s)
1558
1565
  ? o
1559
- ? flattenInner(n, u, c, !0, o)
1560
- : (n[c] = u.map(s => flattenInner(Array.isArray(s) ? [] : {}, s, '', !1, o)))
1561
- : isObject(u)
1562
- ? flattenInner(n, u, c, !1, o)
1563
- : (n[c] = u)
1566
+ ? flattenInner(n, s, c, !0, o)
1567
+ : (n[c] = s.map(u => flattenInner(Array.isArray(u) ? [] : {}, u, '', !1, o)))
1568
+ : isObject(s)
1569
+ ? flattenInner(n, s, c, !1, o)
1570
+ : (n[c] = s)
1564
1571
  }
1565
1572
  return n
1566
1573
  }
@@ -1625,9 +1632,9 @@ function makeUnique(n, e) {
1625
1632
  }
1626
1633
  function countUnique(n, e, t, r, o) {
1627
1634
  const i = e ? n.map(e) : n,
1628
- u = {}
1629
- for (const s of i) u[s] = (u[s] || 0) + 1
1630
- const c = r ? sortObjectValues(u, o ? (s, l) => s[1] - l[1] : (s, l) => l[1] - s[1]) : u
1635
+ s = {}
1636
+ for (const u of i) s[u] = (s[u] || 0) + 1
1637
+ const c = r ? sortObjectValues(s, o ? (u, l) => u[1] - l[1] : (u, l) => l[1] - u[1]) : s
1631
1638
  return t ? Object.keys(c) : c
1632
1639
  }
1633
1640
  function sortObjectValues(n, e) {
@@ -1639,7 +1646,7 @@ function transformToArray(n) {
1639
1646
  r = n[t[0]].length
1640
1647
  for (let o = 0; o < r; o++) {
1641
1648
  const i = {}
1642
- for (const u of t) i[u] = n[u][o]
1649
+ for (const s of t) i[s] = n[s][o]
1643
1650
  e.push(i)
1644
1651
  }
1645
1652
  return e
@@ -1697,9 +1704,9 @@ function makeAsyncQueue(n = 1) {
1697
1704
  async function o() {
1698
1705
  if (e.length > 0 && r < n) {
1699
1706
  r++
1700
- const u = e.shift()
1707
+ const s = e.shift()
1701
1708
  try {
1702
- u && (await u())
1709
+ s && (await s())
1703
1710
  } finally {
1704
1711
  if (--r === 0) for (; t.length > 0; ) t.shift()()
1705
1712
  o()
@@ -1708,14 +1715,14 @@ function makeAsyncQueue(n = 1) {
1708
1715
  }
1709
1716
  async function i() {
1710
1717
  return r
1711
- ? new Promise(u => {
1712
- t.push(u)
1718
+ ? new Promise(s => {
1719
+ t.push(s)
1713
1720
  })
1714
1721
  : Promise.resolve()
1715
1722
  }
1716
1723
  return {
1717
- enqueue(u) {
1718
- e.push(u), o()
1724
+ enqueue(s) {
1725
+ e.push(s), o()
1719
1726
  },
1720
1727
  drain: i
1721
1728
  }
@@ -1756,8 +1763,8 @@ function getArgument(n, e, t, r) {
1756
1763
  i = n[o]
1757
1764
  if (!i) return (t || {})[r || e || ''] || null
1758
1765
  if (i.includes('=')) return i.split('=')[1]
1759
- const u = n[o + 1]
1760
- return u && !u.startsWith('-') ? u : (t || {})[r || e || ''] || null
1766
+ const s = n[o + 1]
1767
+ return s && !s.startsWith('-') ? s : (t || {})[r || e || ''] || null
1761
1768
  }
1762
1769
  function getNumberArgument(n, e, t, r) {
1763
1770
  const o = getArgument(n, e, t, r)
@@ -1769,13 +1776,13 @@ function getNumberArgument(n, e, t, r) {
1769
1776
  }
1770
1777
  }
1771
1778
  function getBooleanArgument(n, e, t, r) {
1772
- const o = n.some(s => s.endsWith('-' + e)),
1779
+ const o = n.some(u => u.endsWith('-' + e)),
1773
1780
  i = getArgument(n, e, t, r)
1774
1781
  if (!i && o) return !0
1775
1782
  if (!i && !o) return null
1776
- const u = ['true', '1', 'yes', 'y', 'on'],
1783
+ const s = ['true', '1', 'yes', 'y', 'on'],
1777
1784
  c = ['false', '0', 'no', 'n', 'off']
1778
- if (u.includes(i.toLowerCase())) return !0
1785
+ if (s.includes(i.toLowerCase())) return !0
1779
1786
  if (c.includes(i.toLowerCase())) return !1
1780
1787
  throw Error(`Invalid boolean argument ${e}: ${i}`)
1781
1788
  }
@@ -1859,7 +1866,7 @@ function isBottommost(n, e, t) {
1859
1866
  return !n[e][t + 1]
1860
1867
  }
1861
1868
  function getCorners(n, e, t) {
1862
- var r, o, i, u, c, s, l, f
1869
+ var r, o, i, s, c, u, l, f
1863
1870
  const a = []
1864
1871
  return n[e][t]
1865
1872
  ? isHorizontalLine(n, e, t) || isVerticalLine(n, e, t)
@@ -1868,7 +1875,7 @@ function getCorners(n, e, t) {
1868
1875
  isLeftmost(n, e, t) &&
1869
1876
  isTopmost(n, e, t) &&
1870
1877
  a.push({ x: e, y: t }),
1871
- !(!((s = n[e + 1]) === null || s === void 0) && s[t - 1]) &&
1878
+ !(!((u = n[e + 1]) === null || u === void 0) && u[t - 1]) &&
1872
1879
  isRightmost(n, e, t) &&
1873
1880
  isTopmost(n, e, t) &&
1874
1881
  a.push({ x: e + 1, y: t }),
@@ -1884,7 +1891,7 @@ function getCorners(n, e, t) {
1884
1891
  : (!((r = n[e - 1]) === null || r === void 0) && r[t] && n[e][t - 1] && a.push({ x: e, y: t }),
1885
1892
  !((o = n[e + 1]) === null || o === void 0) && o[t] && n[e][t - 1] && a.push({ x: e + 1, y: t }),
1886
1893
  !((i = n[e - 1]) === null || i === void 0) && i[t] && n[e][t + 1] && a.push({ x: e, y: t + 1 }),
1887
- !((u = n[e + 1]) === null || u === void 0) && u[t] && n[e][t + 1] && a.push({ x: e + 1, y: t + 1 }),
1894
+ !((s = n[e + 1]) === null || s === void 0) && s[t] && n[e][t + 1] && a.push({ x: e + 1, y: t + 1 }),
1888
1895
  a)
1889
1896
  }
1890
1897
  function findCorners(n, e, t, r) {
@@ -1895,43 +1902,43 @@ function findCorners(n, e, t, r) {
1895
1902
  { x: t, y: r }
1896
1903
  ]
1897
1904
  for (let i = 0; i < n.length; i++)
1898
- for (let u = 0; u < n[0].length; u++) {
1899
- const c = getCorners(n, i, u)
1900
- for (const s of c) o.some(l => l.x === s.x && l.y === s.y) || o.push(s)
1905
+ for (let s = 0; s < n[0].length; s++) {
1906
+ const c = getCorners(n, i, s)
1907
+ for (const u of c) o.some(l => l.x === u.x && l.y === u.y) || o.push(u)
1901
1908
  }
1902
1909
  return o.map(i => ({ x: i.x * e, y: i.y * e }))
1903
1910
  }
1904
1911
  function findLines(n, e) {
1905
- const t = filterCoordinates(n, (s, l) => n[s][l] === 0 && n[s][l + 1] !== 0, 'row-first').map(s =>
1906
- Object.assign(Object.assign({}, s), { dx: 1, dy: 0 })
1912
+ const t = filterCoordinates(n, (u, l) => n[u][l] === 0 && n[u][l + 1] !== 0, 'row-first').map(u =>
1913
+ Object.assign(Object.assign({}, u), { dx: 1, dy: 0 })
1907
1914
  ),
1908
- r = filterCoordinates(n, (s, l) => n[s][l] === 0 && n[s][l - 1] !== 0, 'row-first').map(s =>
1909
- Object.assign(Object.assign({}, s), { dx: 1, dy: 0 })
1915
+ r = filterCoordinates(n, (u, l) => n[u][l] === 0 && n[u][l - 1] !== 0, 'row-first').map(u =>
1916
+ Object.assign(Object.assign({}, u), { dx: 1, dy: 0 })
1910
1917
  ),
1911
1918
  o = filterCoordinates(
1912
1919
  n,
1913
- (s, l) => {
1920
+ (u, l) => {
1914
1921
  var f
1915
- return n[s][l] === 0 && ((f = n[s - 1]) === null || f === void 0 ? void 0 : f[l]) !== 0
1922
+ return n[u][l] === 0 && ((f = n[u - 1]) === null || f === void 0 ? void 0 : f[l]) !== 0
1916
1923
  },
1917
1924
  'column-first'
1918
- ).map(s => Object.assign(Object.assign({}, s), { dx: 0, dy: 1 })),
1925
+ ).map(u => Object.assign(Object.assign({}, u), { dx: 0, dy: 1 })),
1919
1926
  i = filterCoordinates(
1920
1927
  n,
1921
- (s, l) => {
1928
+ (u, l) => {
1922
1929
  var f
1923
- return n[s][l] === 0 && ((f = n[s + 1]) === null || f === void 0 ? void 0 : f[l]) !== 0
1930
+ return n[u][l] === 0 && ((f = n[u + 1]) === null || f === void 0 ? void 0 : f[l]) !== 0
1924
1931
  },
1925
1932
  'column-first'
1926
- ).map(s => Object.assign(Object.assign({}, s), { dx: 0, dy: 1 }))
1927
- t.forEach(s => s.y++), i.forEach(s => s.x++)
1928
- const u = group([...o, ...i], (s, l) => s.x === l.x && s.y - 1 === l.y),
1929
- c = group([...r, ...t], (s, l) => s.y === l.y && s.x - 1 === l.x)
1930
- return [...u, ...c]
1931
- .map(s => ({ start: s[0], end: last(s) }))
1932
- .map(s => ({
1933
- start: multiplyPoint(s.start, e),
1934
- end: multiplyPoint(addPoint(s.end, { x: s.start.dx, y: s.start.dy }), e)
1933
+ ).map(u => Object.assign(Object.assign({}, u), { dx: 0, dy: 1 }))
1934
+ t.forEach(u => u.y++), i.forEach(u => u.x++)
1935
+ const s = group([...o, ...i], (u, l) => u.x === l.x && u.y - 1 === l.y),
1936
+ c = group([...r, ...t], (u, l) => u.y === l.y && u.x - 1 === l.x)
1937
+ return [...s, ...c]
1938
+ .map(u => ({ start: u[0], end: last(u) }))
1939
+ .map(u => ({
1940
+ start: multiplyPoint(u.start, e),
1941
+ end: multiplyPoint(addPoint(u.end, { x: u.start.dx, y: u.start.dy }), e)
1935
1942
  }))
1936
1943
  }
1937
1944
  function getAngleInRadians(n, e) {
@@ -1944,37 +1951,37 @@ function getLineIntersectionPoint(n, e, t, r) {
1944
1951
  const o = (r.y - t.y) * (e.x - n.x) - (r.x - t.x) * (e.y - n.y)
1945
1952
  if (o === 0) return null
1946
1953
  let i = n.y - t.y,
1947
- u = n.x - t.x
1948
- const c = (r.x - t.x) * i - (r.y - t.y) * u,
1949
- s = (e.x - n.x) * i - (e.y - n.y) * u
1954
+ s = n.x - t.x
1955
+ const c = (r.x - t.x) * i - (r.y - t.y) * s,
1956
+ u = (e.x - n.x) * i - (e.y - n.y) * s
1950
1957
  return (
1951
1958
  (i = c / o),
1952
- (u = s / o),
1953
- i > 0 && i < 1 && u > 0 && u < 1 ? { x: n.x + i * (e.x - n.x), y: n.y + i * (e.y - n.y) } : null
1959
+ (s = u / o),
1960
+ i > 0 && i < 1 && s > 0 && s < 1 ? { x: n.x + i * (e.x - n.x), y: n.y + i * (e.y - n.y) } : null
1954
1961
  )
1955
1962
  }
1956
1963
  function raycast(n, e, t) {
1957
1964
  const r = [],
1958
1965
  o = pushPoint(n, t, 1e4)
1959
1966
  for (const i of e) {
1960
- const u = getLineIntersectionPoint(n, o, i.start, i.end)
1961
- u && r.push(u)
1967
+ const s = getLineIntersectionPoint(n, o, i.start, i.end)
1968
+ s && r.push(s)
1962
1969
  }
1963
1970
  return r.length
1964
- ? r.reduce((i, u) => {
1965
- const c = getDistanceBetweenPoints(n, u),
1966
- s = getDistanceBetweenPoints(n, i)
1967
- return c < s ? u : i
1971
+ ? r.reduce((i, s) => {
1972
+ const c = getDistanceBetweenPoints(n, s),
1973
+ u = getDistanceBetweenPoints(n, i)
1974
+ return c < u ? s : i
1968
1975
  })
1969
1976
  : null
1970
1977
  }
1971
1978
  function raycastCircle(n, e, t) {
1972
1979
  const o = getSortedRayAngles(n, t),
1973
1980
  i = []
1974
- for (const u of o) {
1975
- const c = raycast(n, e, u - 0.001),
1976
- s = raycast(n, e, u + 0.001)
1977
- c && i.push(c), s && i.push(s)
1981
+ for (const s of o) {
1982
+ const c = raycast(n, e, s - 0.001),
1983
+ u = raycast(n, e, s + 0.001)
1984
+ c && i.push(c), u && i.push(u)
1978
1985
  }
1979
1986
  return i
1980
1987
  }
@@ -2195,6 +2202,7 @@ function raycastCircle(n, e, t) {
2195
2202
  surroundInOut,
2196
2203
  getExtension,
2197
2204
  getBasename,
2205
+ normalizeEmail,
2198
2206
  normalizeFilename,
2199
2207
  parseFilename,
2200
2208
  camelToTitle,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "cafe-utility",
3
- "version": "16.2.0",
3
+ "version": "16.3.0",
4
4
  "description": "",
5
5
  "main": "index.js",
6
6
  "exports": {