From 8fcfe3d1344ea01aefaaebd8e653851f1db54528 Mon Sep 17 00:00:00 2001 From: Omar Rizwan Date: Mon, 26 Jul 2021 15:15:21 -0700 Subject: [PATCH] extension: more doc improvements --- extension/background.js | 27 +++++++++++++-------------- 1 file changed, 13 insertions(+), 14 deletions(-) diff --git a/extension/background.js b/extension/background.js index eae4661..59d8a5f 100644 --- a/extension/background.js +++ b/extension/background.js @@ -68,11 +68,11 @@ const utf8ArrayToString = (function() { // global so it can be hot-reloaded window.Routes = {}; -// Helper function: generates a full set of file operations that you -// can use as a route handler (so clients can read and write -// sections of the file, stat it to get its size and see it show up -// in ls, etc), given getData and setData functions that define the -// contents of the entire file. +// Helper function: you provide getData and setData functions that define +// the contents of an entire file => it returns a proper route handler +// object with a full set of file operations that you can put in +// `Routes` (so clients can read and write sections of the file, stat +// it to get its size and see it show up in ls, etc), const makeRouteWithContents = (function() { const Cache = { // used when you open a file to cache the content we got from the @@ -166,16 +166,15 @@ const makeRouteWithContents = (function() { return makeRouteWithContents; })(); +// Helper function: returns a route handler for `path` based on all +// the children of `path` that already exist in Routes. +// +// e.g., if `Routes['/tabs/create']` and `Routes['/tabs/by-id']` and +// `Routes['/tabs/last-focused']` are all already defined, then +// `makeDefaultRouteForDirectory('/tabs')` will return a route that +// defines a directory with entries 'create', 'by-id', and +// 'last-focused'. function makeDefaultRouteForDirectory(path) { - // Creates a route for `path` based on all the children of - // `path` that already exist in Routes. - // - // e.g., if `Routes['/tabs/create']` and `Routes['/tabs/by-id']` and - // `Routes['/tabs/last-focused']` are all already defined, then - // `makeDefaultRouteForDirectory('/tabs')` will return a route that - // defines a directory with entries 'create', 'by-id', and - // 'last-focused'. - function depth(p) { return p === '/' ? 0 : (p.match(/\//g) || []).length; } // find all direct children