|
| 1 | +// ['0', (...), '9'] |
| 2 | +const numbers = Array.from({ length: 10 }, (_, i) => String.fromCharCode(48 + i)); |
| 3 | + |
| 4 | +// ['a', (...), 'z'] |
| 5 | +const alphabet = Array.from({ length: 26 }, (_, i) => String.fromCharCode(97 + i)); |
| 6 | + |
| 7 | +/* |
| 8 | + azExpand('a') => [ |
| 9 | + 'aa', 'ab', 'ac', 'ad', 'ae', |
| 10 | + 'af', 'ag', 'ah', 'ai', 'aj', |
| 11 | + 'ak', 'al', 'am', 'an', 'ao', |
| 12 | + 'ap', 'aq', 'ar', 'as', 'at', |
| 13 | + 'au', 'av', 'aw', 'ax', 'ay', |
| 14 | + 'az' |
| 15 | + ] |
| 16 | +*/ |
| 17 | +function azExpand(prefix) { |
| 18 | + return [ |
| 19 | + ...alphabet.map(c => `${prefix}${c}`) |
| 20 | + ]; |
| 21 | +} |
| 22 | + |
| 23 | +// ['a', (...), 'zzz'] |
| 24 | +const atozzz = alphabet.reduce((acc, a) => { |
| 25 | + acc.push(a); // ['a', (...) |
| 26 | + |
| 27 | + azExpand(a) |
| 28 | + .forEach(aa => { |
| 29 | + acc.push(...azExpand(aa)) // (...) aaa', 'aab', 'aac'] |
| 30 | + }); |
| 31 | + |
| 32 | + return acc; |
| 33 | +}, []); |
| 34 | + |
| 35 | +const allPivots = [ |
| 36 | + null, |
| 37 | + /* 0 – 9 */ |
| 38 | + ...numbers, |
| 39 | + '@!', |
| 40 | + /* @0 – @9 */ |
| 41 | + ...numbers.map(c => `@${c}`), |
| 42 | + '@_', |
| 43 | + // |
| 44 | + // TODO (cjr) must partition @ali__@alj |
| 45 | + // [@ali, @alicn, @alifd, @alifd/theme-{???}, @aligov, @aliwind, @alj] |
| 46 | + // |
| 47 | + /* @a[a-z] - @z[a-z] */ |
| 48 | + ...atozzz.map(cc => `@${cc}`), |
| 49 | + // |
| 50 | + // TODO (cjr) must partition nod_noe |
| 51 | + // entire `node-*` package namespace |
| 52 | + // |
| 53 | + '@~', |
| 54 | + 'A', |
| 55 | + 'Z', |
| 56 | + ...atozzz, |
| 57 | + null |
| 58 | +] |
| 59 | + |
| 60 | +const pivots = allPivots; |
| 61 | + |
| 62 | +export { |
| 63 | + pivots |
| 64 | +} |
0 commit comments