Code Utilities and how to find them
Summary
Utility functions are modules with minimal inter-package dependencies that can be used widely within other packages.
Utility functions can be located in any package. They are generally located in src/utils/
.
Finding a utility
We currently don't do a great job at documenting all utility functions. The convention right now is to create a static class named {Module}Utils
that encasulates some set of functionality.
For example, the class VaultUtils
in ../packages/common-all/src/vault.ts (Private) has static methods that work with accessing vaults.
Adding a new utility
When writing a new utility, think about where it would best fit. If the utility is only applicable to the current package or depends on dependencies that only make sense for the current package, then add it only for that package.
For example, showInitProgress in plugin-core
is specifically tied to the vscode.window.showProgress
api and wouldn't be applicable in other packages.
If the utility is generally useful across multiple places, you should aim to add it to the most accessible package. Package accessibility vary according to the following, from most accessible to least:
- Common All: accessible from all packages
- Common Server: accessible from all packages that run in a nodejs environment
- Dendron Engine: accessible from all packages requiring the dendron engine
Some other packages that don't quite fix the above scheme:
- Common Frontend: accessible from all packages that run in a browser only environment
- Pods Core: accessible from all packages that require pods (currently this is Plugin Core and Dendron CLI)
Backlinks