@xananax/convenient
v0.0.9931
Published
A bunch of disparate, but convenient functions
Downloads
12
Readme
Convenient
A bunch of functions that I keep re-using. All collected here for profit & glory.
Contract
- all functions are as small as possible (but no smaller). You can read the entire codebase quickly, and you can understand any function you want simply. They were designed so people can copy-paste them if needed.
- no magic, everything is explicit.
- functional when possible, but no dogma.
- snake_case or camelCase names. Additionally, each function is exported as a name export and as a default, to please everyone.
- all functions work in the browser and the server. When functionality doesn't make sense in one environment, then the function is replaced with a noOp procedure that does nothing. Feel free to use universal javascript
- all and any async operations returns a promise, unless it really doesn't make sense
- no stubs, polyfills, or other workarounds; you bring those yourself
- entirely typescript-ed
- each function is its own file, so you can import just what's needed
- fully tested (not all of it yet, but coming up)
Be careful, the API is still in flux!
How to Use
Include the desired file:
import { load_image } from '@xananax/convenient/load_image'
// or, if you prefer camelCased identifiers:
import { loadImage } from '@xananax/convenient/load_image'
Or import everything at once:
import * as C from '@xananax/convenient'
C.load_image('path_to_image') // or C.loadImage
Another way to use the library is to simply refer to it as an example, and add your own implementation. There are no dependencies, nothing to install. Most modules are trying to be as independent as possible, and are designed to be easy to copy-paste elsewhere.
Using as little modules as possible is advised, both to avoid security fiascos (everyone remembers leftpad), and to keep the weight out of node_modules.
It also means you can tweak functions to do specifically what you need them to.
License
MIT