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

@myparcel/ts-utils

Package Overview
Dependencies
Maintainers
3
Versions
22
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@myparcel/ts-utils

TypeScript utilities

  • 1.0.0-alpha.1
  • npm
  • Socket score

Version published
Weekly downloads
228
decreased by-34.48%
Maintainers
3
Weekly downloads
 
Created
Source

TypeScript Utilities

This is a collection of TypeScript utilities that we reuse across all TS projects.

Installation

Using Yarn

yarn add @myparcel/ts-utils

Using pnpm

pnpm add @myparcel/ts-utils

Using npm

npm install @myparcel/ts-utils

⚠️ Note: You can install this package as a dev dependency if you are not using the type guards.

Contents

Type guards

isEnumValue

Type guard for checking if a value is a key of the given enum.

import { isEnumValue } from '@myparcel/ts-utils';

enum MyEnum {
  A = 'A',
  B = 'B',
}

const value = 'A';

if (isEnumValue(MyEnum, value)) {
  // value is of type MyEnum.A
}
isInArray
isOfType

Type guard for checking if an object value is of a specific type by checking if a given K exists.

import { isOfType } from '@myparcel/ts-utils';

interface BaseObject {
  a: string;
  b: number;
}

interface ObjectWithC extends BaseObject {
  c: string;
}

const value = {
  a: 'a',
  b: 1,
  c: 'c',
};

if (isOfType<ObjectWithC>(value, 'c')) {
  // value is of type ObjectWithC
}

Types

Utils

toArray

Keywords

FAQs

Package last updated on 10 Nov 2022

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