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

@gilbarbara/types

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

@gilbarbara/types

Reusable typescript typings

  • 0.2.2
  • latest
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
33K
decreased by-16.22%
Maintainers
1
Weekly downloads
 
Created
Source

@gilbarbara/types

npm version CI

Reusable typescript typings.

Setup

npm i @gilbarbara/types

For convenience, the type-fest package is re-exported.

Types

Aliases

type NumberOrNull = number | null;
type StringOrNull = string | null;
type StringOrNumber = string | number;

type PlainObject<T = unknown> = Record<string, T>;

type GenericFunction<T = unknown> = (...arguments_: any[]) => T;
type VoidFunction = () => void;

Common

type AsyncStatus = 'IDLE' | 'PENDING' | 'SUCCESS' | 'ERROR';

interface AsyncFlow {
  message: string;
  status: AsyncStatus;
}

interface AsyncFlowWithCache extends AsyncFlow {
  updatedAt: number;
}

interface AsyncFlowWithData<T = any> extends AsyncFlow {
  data: T;
}

interface AsyncFlowWithDataAndCache<T = any> extends AsyncFlowWithData<T> {
  updatedAt: number;
}

type HttpMethods =
  | 'CONNECT'
  | 'DELETE'
  | 'GET'
  | 'HEAD'
  | 'OPTIONS'
  | 'PATCH'
  | 'POST'
  | 'PUT';

interface IdName {
  id: string;
  name: string;
}

interface LabelValue {
  label: string;
  value: string;
}

Utilities

/**
 * Narrow down a Record to a plain object.
 */
type NarrowPlainObject<T extends Record<string, any>> = Exclude<
  T,
  Array<unknown> | Function | Map<unknown, unknown> | Set<unknown>
>;
/**
 * An object without excluded types.
 */
type RemoveType<TObject, TExclude = undefined> = {
  [Key in keyof TObject as TObject[Key] extends TExclude ? never : Key]: TObject[Key];
};
/**
 * A strict plain object with a specific set of keys.
 */
type StrictObject<TObject extends Record<PropertyKey, unknown>, TExpected> = TExpected & {
  [Key in keyof TObject]: Key extends keyof TExpected ? TExpected[Key] : never;
};

Keywords

FAQs

Package last updated on 02 Aug 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