Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
64 changes: 64 additions & 0 deletions src/pivots/index.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,64 @@
// ['0', (...), '9']
const numbers = Array.from({ length: 10 }, (_, i) => String.fromCharCode(48 + i));

// ['a', (...), 'z']
const alphabet = Array.from({ length: 26 }, (_, i) => String.fromCharCode(97 + i));

/*
azExpand('a') => [
'aa', 'ab', 'ac', 'ad', 'ae',
'af', 'ag', 'ah', 'ai', 'aj',
'ak', 'al', 'am', 'an', 'ao',
'ap', 'aq', 'ar', 'as', 'at',
'au', 'av', 'aw', 'ax', 'ay',
'az'
]
*/
function azExpand(prefix) {
return [
...alphabet.map(c => `${prefix}${c}`)
];
}

// ['a', (...), 'zzz']
const atozzz = alphabet.reduce((acc, a) => {
acc.push(a); // ['a', (...)

azExpand(a)
.forEach(aa => {
acc.push(...azExpand(aa)) // (...) aaa', 'aab', 'aac']
});

return acc;
}, []);

const allPivots = [
null,
/* 0 – 9 */
...numbers,
'@!',
/* @0 – @9 */
...numbers.map(c => `@${c}`),
'@_',
//
// TODO (cjr) must partition @ali__@alj
// [@ali, @alicn, @alifd, @alifd/theme-{???}, @aligov, @aliwind, @alj]
//
/* @a[a-z] - @z[a-z] */
...atozzz.map(cc => `@${cc}`),
//
// TODO (cjr) must partition nod_noe
// entire `node-*` package namespace
//
'@~',
'A',
'Z',
...atozzz,
null
]

const pivots = allPivots;

export {
pivots
}
12 changes: 12 additions & 0 deletions src/pivots/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
{
"name": "@_all_docs/partition",
"version": "0.1.0",
"description": "Default pivots from which _all_docs partitions are derived",
"repository": {
"type": "git",
"url": "git+https://github.com/indexzero/_all_docs.git",
"directory": "src/partition"
},
"author": "Charlie Robbins <npm@charlie.dev>",
"license": "Apache-2.0"
}