Socket
Book a DemoInstallSign in
Socket

@causaly/isnt

Package Overview
Dependencies
Maintainers
2
Versions
1
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install
Package was removed
Sorry, it seems this package was removed from the registry

@causaly/isnt

A collection of common runtime predicates that TypeScript actually understands.

0.1.1
unpublished
latest
Source
npmnpm
Version published
Weekly downloads
0
Maintainers
2
Weekly downloads
 
Created
Source

@causaly/isnt

A collection of common runtime predicates that TypeScript actually understands.

Build Status

Features

  • Simple API;
  • Extensive tests;
  • Isomorphic library, works on the browser or Node.js.

Installation

npm install @causaly/isnt

Requirements

  • Node.js v.14+

Quick start

import { isNotNull } from '@causaly/isnt';

// given an array containing null and number values
const array = [1, 2, null]; // ts infers Array<null | number>

// ...remove null values by using isNotNull
const arrayWithoutNull = array.filter(isNotNull); // ts infers Array<number>

API

  • isNotEmptyArray
  • isNotEmptyString
  • isNotNull
  • isNotUndefined

Motivation

It's easy to perform a check using lodash or vanilla JavaScript, e.g.

const array = [1, 2, null].filter(Boolean);

The example above will filter out the null value as expected (because null is considered to be faulty).

However, TypeScript will NOT infer the correct type [playground link]. It will understand the type of array as being Array<null | number> instead of Array<null>.

@causaly/isnt provides a simple API to test for predicates, while making TypeScript understand.

Contribute

Source code contributions are most welcome, as long as the linter is satisfied.

We are hiring

Causaly is building the world's largest biomedical knowledge platform, using technologies such as TypeScript, React and Node.js. Find out more about our openings at https://apply.workable.com/causaly/.

License

MIT

Keywords

typescript

FAQs

Package last updated on 24 Dec 2021

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

About

Packages

Stay in touch

Get open source security insights delivered straight into your inbox.

  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc

U.S. Patent No. 12,346,443 & 12,314,394. Other pending.