0.5.0 • Published 8 months ago

@ninjalib/util v0.5.0

Weekly downloads
-
License
ISC
Repository
github
Last release
8 months ago

Ninja util library

A bunch of utilities for use on the browser, server or both

Note: Requires node v19.6.0 for testing

Features

  • Minimal dependencies
  • Easy to use

Usage

Import util and start using straight away:

import util from '@ninjalib/util';

if (!util.isNode()) {
    throw new Error('This code must be run on the server');
}

Docs

Shared

isBrowser

Returns true if in a browser/client context

if (util.isBrowser()) {
    throw new Error('This code can only be run on the server');
}

isNode

Returns true if in a server context

if (util.isNode()) {
    throw new Error('This code can only be run on the client');
}

Client

Server

loadEnv

Loads environment files into process.env, similar to dotenv package

Parameters:

  • filePath?: path to the env file (defaults to current working directory)
  • force?: forcefully overwrites existing environment variables (defaults to false)
// call this as early in your application as possible
util.loadEnv();
0.5.0

8 months ago

0.4.1

9 months ago

0.3.0

11 months ago

0.2.3

11 months ago

0.4.0

11 months ago

0.3.1

11 months ago

0.2.2

11 months ago

0.2.1

1 year ago

0.2.0

1 year ago

0.1.1

1 year ago

0.1.0

1 year ago

0.0.4

1 year ago

0.0.3

1 year ago

0.0.2

1 year ago

0.0.1

1 year ago