cando-util
v3.2.1
Published
utility functions for can-do web apps
Readme
cando-util
Utility functions for can-do web apps
📦 cando-util structure
browser.js → browser-safe functions only (no Node APIs)
server.js → everything, including Node tools like fs
index.js → routed by package.json, fallback to server build
Usage: import { fn } from 'cando-util' // auto picks browser or server import { fn } from 'cando-util/browser' // always browser-safe version import { fn } from 'cando-util/server' // always full version
"exports": {
".": { // auto routing
"browser": "./browser.js", // vite should pick up on this
"default": "./server.js"
},
"./browser": "./browser.js", // explicit import option
"./server": "./server.js" // explicit import option
},Adding a new function
- copy an existing function and start from there.
- then make sure you add the function and test function to the index.js file
- then add the function only to the index.mjs file
Testing
- for testing, do a npm link cando-util in the test folder
- do a node test [testFunction] to test the individual function
- then do node test to run all the tests
Updating the package
- first, commmit changes
- then we gotta move back to the root folder first
- then do npm version minor || npm version patch
- then just push changes
File Structure
michaelhartman@Michaels-MacBook-Pro cando-util % ls -al total 2472 drwxr-xr-x@ 21 michaelhartman staff 672 Nov 4 02:16 . drwxr-xr-x@ 26 michaelhartman staff 832 Sep 20 01:49 .. -rw-r--r--@ 1 michaelhartman staff 10244 Nov 4 02:16 .DS_Store drwxr-xr-x@ 15 michaelhartman staff 480 Nov 4 02:21 .git drwxr-xr-x@ 3 michaelhartman staff 96 Oct 16 2024 .github -rw-r--r--@ 1 michaelhartman staff 2058 Nov 4 01:37 .gitignore drwxr-xr-x@ 3 michaelhartman staff 96 Oct 16 2024 .vscode -rw-r--r--@ 1 michaelhartman staff 619 Aug 2 00:56 README.md -rw-r--r--@ 1 michaelhartman staff 77 Nov 2 18:47 browser.js -rw-r--r--@ 1 michaelhartman staff 5409 Nov 2 18:46 index.js -rw-r--r--@ 1 michaelhartman staff 5822 Nov 3 22:11 index.mjs drwxr-xr-x@ 101 michaelhartman staff 3232 Nov 4 00:42 node_modules -rw-r--r--@ 1 michaelhartman staff 42997 Nov 4 02:21 package-lock.json -rw-r--r--@ 1 michaelhartman staff 978 Nov 4 02:21 package.json -rw-r--r--@ 1 michaelhartman staff 631 Nov 3 22:11 server.js -rw-r--r--@ 1 michaelhartman staff 3172 Nov 4 02:16 test.js drwxr-xr-x@ 12 michaelhartman staff 384 Nov 4 02:15 testData drwxr-xr-x@ 5 michaelhartman staff 160 Nov 4 01:30 testDirectory -rw-r--r--@ 1 michaelhartman staff 1166382 Nov 4 02:18 testLog.txt drwxr-xr-x@ 87 michaelhartman staff 2784 Nov 4 01:39 utilities drwxr-xr-x@ 69 michaelhartman staff 2208 Nov 4 01:44 utilityTests michaelhartman@Michaels-MacBook-Pro cando-util %
