npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2026 – Pkg Stats / Ryan Hefner

dotenv-caster

v2.2.6

Published

This package is a tiny package that converts `string | undefined` to certain `primitive types`.

Readme

dotenv-caster

Test Docs NPM Version GitHub Release NPM Type Definitions Download NPM NPM Downloads All Time GitHub License Vitest Typedoc RenovateBot

dotenv-caster is a tiny package that converts string | undefined to certain primitive types.

[!WARNING] A critical bug has been discovered in this package in versions 2.2.0 and below.

Please ensure that you are using the latest version (at least v2.2.1 or newer) when using this package.

[!IMPORTANT] Be sure to use the latest version.

HTML Documentation Generated by typedoc

https://myxogastria0808.github.io/dotenv-caster/

Test Result Generated by @vitest/coverage-v8

https://myxogastria0808.github.io/dotenv-caster/coverage/

Test Coverage Generated by @vitest/ui

https://myxogastria0808.github.io/dotenv-caster/html/

DeepWiki

[!WARNING] The accuracy of the contents of generated deepwiki has not been verified by me.

I recommend that you look at the documentation at typedoc.

https://deepwiki.com/Myxogastria0808/dotenv-caster/

How to Use

This is an example of use if the following is written in .env.

STRING_SAMPLE=Hello
NUMBER_SAMPLE=0
BIGINT_SAMPLE=1234567890123456789012345678901234567890
SYMBOL_SAMPLE=SYMBOL
BOOLEAN_SAMPLE=true
NULL_SAMPLE=null

The following is an example of use. dotenv-caster is intended for use in projects that use dotenv.

import * as dotenv from "dotenv";
// Import dotenv-caster
import { DotEnvCaster } from "dotenv-caster";

dotenv.config();

// Create an instance
const dotenvCaster = new DotEnvCaster();

// string | undefined -> string
const stringSample: string = dotenvCaster.castString(process.env.STRING_SAMPLE);
// string | undefined -> number
const numberSample: number = dotenvCaster.castNumber(process.env.NUMBER_SAMPLE);
// string | undefined -> bigint
const bigIntSample: bigint = dotenvCaster.castBigInt(process.env.BIGINT_SAMPLE);
// string | undefined -> symbol
const symbolSample: symbol = dotenvCaster.castSymbol(process.env.SYMBOL_SAMPLE);
// string | undefined -> boolean
const booleanSample: boolean = dotenvCaster.castBoolean(process.env.BOOLEAN_SAMPLE);
// string | undefined -> null
const nullSample: null = dotenvCaster.castNull(process.env.NULL_SAMPLE);

Detail

Create an instance

When using dotenv-caster, first import dotenv-caster and create an instance as follows.

// Import dotenv-caster
import { DotEnvCaster } from "dotenv-caster";

// Create an instance
const dotenvCaster = new DotEnvCaster();

string | undefined → string

// string | undefined -> string
const stringSample: string = dotenvCaster.castString(process.env.STRING_SAMPLE);

string | undefined → number

// string | undefined -> number
const numberSample: number = dotenvCaster.castNumber(process.env.NUMBER_SAMPLE);

string | undefined → bigint

// string | undefined -> bigint
const bigIntSample: bigint = dotenvCaster.castBigInt(process.env.BIGINT_SAMPLE);

string | undefined → symbol

// string | undefined -> symbol
const symbolSample: symbol = dotenvCaster.castSymbol(process.env.SYMBOL_SAMPLE);

string | undefined → boolean

// string | undefined -> boolean
const booleanSample: boolean = dotenvCaster.castBoolean(process.env.BOOLEAN_SAMPLE);

string | undefined → null

// string | undefined -> null
const nullSample: null = dotenvCaster.castNull(process.env.NULL_SAMPLE);