docs: update README, add some more jsdoc

This commit is contained in:
Andy Burke 2025-07-15 00:15:28 -07:00
parent 22a8b4d03f
commit 55a73c3d0a
10 changed files with 155 additions and 30 deletions

View file

@ -1,3 +1,14 @@
/**
* FSDB Organizer: By Character
*
* Organizes by splitting a string up and using the characters
* for folders, eg:
*
* abcdefg.json => /a/ab/abc/abcdefg.json
*
* @module
*/
import sanitize from '../utils/sanitize.ts';
export default function by_character(value: string): string[] {

View file

@ -1,3 +1,18 @@
/**
* FSDB Organizer: By Email
*
* Organizes by splitting an email into its components, eg:
*
* com/example.com/soandso@example.com
*
* A symlinking index based on this organizer might look like:
* fsdb root index tld domain email
* [ ][ V ][ V ][ V ][ V ]
* /path/to/db/root/.indexes/email/com/example.com/soandso@example.com
*
* @module
*/
import sanitize from '../utils/sanitize.ts';
const EMAIL_REGEX = /^(?<username>.+)@(?<domain>(?<hostname>.+)\.(?<tld>.+))$/;
@ -16,9 +31,5 @@ export default function by_email(email: string): string[] {
return [];
}
// for example, a symlinking index based on this organizer might look like:
// fsdb root index tld domain email
// [ ][ V ][ V ][ V ][ V ]
// /path/to/db/root/.indexes/email/com/example.com/soandso@example.com
return [sanitize(tld), sanitize(domain), sanitize(email), `${sanitize(email)}.json`];
}

View file

@ -1,12 +1,19 @@
/**
* FSDB Organizer: By Lurid
*
* Organizes by splitting a lurid strategically:
*
* able-fish-cost-them/able-fish-cost-them-post-many-form/able-fish-cost-them-post-many-form-hope-wife-born.json
*
* @module
*/
import sanitize from '../utils/sanitize.ts';
export default function by_lurid(id: string): string[] {
// Replace invalid filename characters and leading dots
const sanitized_id = sanitize(id);
// assuming a lurid, eg: able-fish-cost-them-post-many-form-hope-wife-born
// ./able-fish-cost-them/able-fish-cost-them-post-many-form/able-fish-cost-them-post-many-form-hope-wife-born.json
const result: string[] = [
sanitized_id.slice(0, 14),
sanitized_id.slice(0, 34),

View file

@ -1,3 +1,13 @@
/**
* FSDB Organizer: By Phone
*
* Organizes by splitting a phone number into its components:
*
* Eg: 1-213-555-1234 => 1/213/555/213-555-1234.json
*
* @module
*/
import sanitize from '../utils/sanitize.ts';
const PHONE_REGEX =
@ -22,9 +32,6 @@ export default function by_phone(phone: string): string[] {
const normalized_number = `${sanitize(area_code)}-${sanitize(central_office_code)}-${sanitize(subscriber_code)}`;
// for example, a symlinking index based on this organizer might look like:
// fsdb root index country_code office_code area_code phone
// /path/to/db/root/.indexes/phone/1/213/555/213-555-1234
return [
sanitize(country_code ?? '1'),
sanitize(area_code),