Minimal runtime for skuba
npm install skuba-dive

Minimal runtime for skuba.
- API reference
- Assert
- Env
- Register
- Design
[TypeScript assertion functions] for narrowing down types in unit tests and the like.
These may be used for input validation in your application code at a pinch,
but consider a proper validation library with richer error handling and reporting.
[typescript assertion functions]: https://www.typescriptlang.org/docs/handbook/release-notes/typescript-3-7.html#assertion-functions
``typescript
import { Assert } from 'skuba-dive';
it('should think of a good test case name', () => {
const result = numberOrNull();
// result is number | null
Assert.notNullish(result);
// result is number
});
`
Functions for reading values out of environment variables.
For example, in your /src/config.ts:
`typescript
import { Env } from 'skuba-dive';
const ENVIRONMENTS = ['dev', 'prod'] as const;
export type Environment = (typeof ENVIRONMENTS)[number];
export const environment = Env.oneOf(ENVIRONMENTS)('ENVIRONMENT');
// 'dev' | 'prod'
export const port = Env.nonNegativeInteger('PORT', { default: undefined });
// number | undefined
export const version = Env.string('VERSION', { default: 'local' });
// string | 'local'
export const flag = Env.boolean('FLAG');
// boolean
`
Each function will throw if its environment variable is not set and opts.default is not provided.
skuba-dive/register has been replaced with native subpath imports supported by both TypeScript and Node.js as a part of our ESM migration. Please upgrade to skuba 13 to automatically migrate your codebase.
skuba-dive packages up:
- General application boilerplate that doesn't justify a standalone module
- Runtime functionality that complements skuba
See skuba`'s [goals] and [non-goals] for more information.
[goals]: https://seek-oss.github.io/skuba/docs/about.html#goals
[non-goals]: https://seek-oss.github.io/skuba/docs/about.html#non-goals