Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

skuba-dive

Package Overview
Dependencies
Maintainers
1
Versions
10
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

skuba-dive

Minimal runtime for skuba

  • 2.0.0
  • latest
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
4.5K
decreased by-34.21%
Maintainers
1
Weekly downloads
 
Created
Source

🤿🌊

GitHub Release GitHub Validate Node.js version npm package Powered by skuba

Minimal runtime for skuba.

Table of contents

API reference

Assert

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.

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
});

Env

Functions for reading values out of environment variables.

For example, in your /src/config.ts:

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.

Register

Runtime hook for import paths relative to /src.

Make a side-effectful import at the top of your entry point(s):

// /src/register.ts

import 'skuba-dive/register';
// /src/app.ts

import './register';

import { config } from 'src/config';

export = new Koa();

The hook must be imported from a module that sits directly under /src for module resolution to work correctly.

Design

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.

FAQs

Package last updated on 09 Feb 2022

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc