New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

@wkovacs64/booleanize

Package Overview
Dependencies
Maintainers
1
Versions
5
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@wkovacs64/booleanize

Small utility to coerce a value to its boolean equivalent

  • 2.0.2
  • latest
  • Source
  • npm
  • Socket score

Version published
Maintainers
1
Created
Source

@wkovacs64/booleanize

A small utility to coerce a value to its boolean equivalent.

npm Version Build Status Code Coverage

Installation

npm install @wkovacs64/booleanize

Usage

The primary purpose of this package is to deal with environment variables received as strings. For example, SOME_CONDITIONAL=false will be truthy if you just pass it to the Boolean constructor as it comes through as a non-empty string. Instead, pass it to booleanize and you will get the value back that I expect. Please note that it may not be the value YOU expect, but I created this primarily for myself. 🙂

Basically, the following strings are considered falsy:

  • 'null'
  • 'undefined'
  • 'false'
  • 'no'
  • '0'

Example

# .env
SOME_CONDITIONAL=false
import { booleanize } from '@wkovacs64/booleanize';

Boolean(process.env.SOME_CONDITIONAL); // true 😕
booleanize(process.env.SOME_CONDITIONAL); // false 😊

License

This module is distributed under the MIT License.

FAQs

Package last updated on 16 Mar 2023

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