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

ts-extras

Package Overview
Dependencies
Maintainers
0
Versions
18
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

ts-extras

Essential utilities for TypeScript projects

  • 0.13.0
  • latest
  • Source
  • npm
  • Socket score

Version published
Maintainers
0
Created
Source

ts-extras npm dependents npm downloads

Essential utilities for TypeScript projects

Ideas for additional essential utilities welcome. Type-only utilities belong in type-fest.

Install

npm install ts-extras

Usage

import {isDefined} from 'ts-extras';

[1, undefined, 2].filter(isDefined);
//=> [1, 2]

API

General

Type guard

  • isDefined - Check whether a value is defined (not undefined).
  • isPresent - Check whether a value is present (not null or undefined).
  • isEmpty - Check whether an array is empty.
  • assertError - Assert that the given value is an Error.
  • isInfinite - Check whether a value is infinite.

Improved builtin

  • arrayIncludes - An alternative to Array#includes() that properly acts as a type guard.
  • setHas - An alternative to Set#has() that properly acts as a type guard.
  • objectKeys - A strongly-typed version of Object.keys().
  • objectEntries - A strongly-typed version of Object.entries().
  • objectFromEntries - A strongly-typed version of Object.fromEntries().
  • objectHasOwn - A strongly-typed version of Object.hasOwn().
  • isFinite - A strongly-typed version of Number.isFinite().
  • isInteger - A strongly-typed version of Number.isInteger().
  • isSafeInteger - A strongly-typed version of Number.isSafeInteger().

FAQ

What is the difference between this and type-fest?

The type-fest package contains only types, meaning they are only used at compile-time and nothing is ever compiled into actual JavaScript code. This package contains functions that are compiled into JavaScript code and used at runtime.

  • type-fest - A collection of essential TypeScript types
  • is - Type guards for any situation

Keywords

FAQs

Package last updated on 24 Aug 2024

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