2.5.1 • Published 11 months ago

@sapphire/type v2.5.1

Weekly downloads
223
License
MIT
Repository
github
Last release
11 months ago

Sapphire Logo

@sapphire/type

A type detection utility for JavaScript.

GitHub codecov npm bundle size npm Depfu

Table of Contents

Description

Sometimes there is a need to know what a value's type of something is, this package exists to satisfy those needs by implementing a parser that can retrieve the type of the value recursively and process a string similar to TypeScript's types.

Features

  • Written in TypeScript
  • Bundled with Rollup so it can be used in NodeJS and browsers
  • Offers CommonJS, ESM and UMD bundles
  • Fully tested

Installation

yarn add @sapphire/type
# npm install @sapphire/type

Usage

Note: While this section uses require, the imports match 1:1 with ESM imports. For example const { Type } = require('@sapphire/type') equals import { Type } from '@sapphire/type'.

Note: When using ESM syntax you can also default-import Type class: import Type from '@sapphire/type'.

Note: The internal functions of getPromiseDetails and getProxyDetails are also exported. If you don't know what these are, then you need not be concerned about this.

Basic Usage

// Import the Type class
const { Type } = require('@sapphire/type');

// Define a Type with an array of two numbers
const type = new Type([1, 2]);

console.log(type.toString());
// Logs: Array<number>

API Documentation

For the full API documentation please refer to the TypeDoc generated documentation.

Buy us some doughnuts

Sapphire Community is and always will be open source, even if we don't get donations. That being said, we know there are amazing people who may still want to donate just to show their appreciation. Thank you very much in advance!

We accept donations through Open Collective, Ko-fi, PayPal, Patreon and GitHub Sponsorships. You can use the buttons below to donate through your method of choice.

Donate WithAddress
Open CollectiveClick Here
Ko-fiClick Here
PatreonClick Here
PayPalClick Here

Contributors ✨

Thanks goes to these wonderful people (emoji key):

This project follows the all-contributors specification. Contributions of any kind welcome!

2.5.2-next.0b63543

11 months ago

2.5.2-next.b5ab21d

11 months ago

2.5.2-next.1de90a0

11 months ago

2.5.2-next.15b3df8

11 months ago

2.5.2-next.0aaea62

11 months ago

2.5.2-next.3089c20

11 months ago

2.5.2-next.915e9ca

11 months ago

2.5.2-next.a70f8a4

11 months ago

2.5.2-next.0451ac9

12 months ago

2.5.2-next.47f3ecd

12 months ago

2.5.2-next.1597965

12 months ago

2.5.2-next.1630623

12 months ago

2.5.0

1 year ago

2.5.1

1 year ago

2.4.4

2 years ago

2.4.3

2 years ago

2.4.2

2 years ago

2.4.1

2 years ago

2.4.0

2 years ago

2.3.0

3 years ago

2.2.5

3 years ago

2.2.6

3 years ago

2.2.1

3 years ago

2.2.3

3 years ago

2.2.2

3 years ago

2.2.4

3 years ago

2.2.0

4 years ago

2.1.2

4 years ago

2.1.1

4 years ago

2.1.0

4 years ago

2.0.11

4 years ago

2.0.10

4 years ago

2.0.9

4 years ago

2.0.7

4 years ago

2.0.6

4 years ago

2.0.8

4 years ago

2.0.5

4 years ago

2.0.3

4 years ago

2.0.4

4 years ago

2.0.2

4 years ago

2.0.1

4 years ago

2.0.0

4 years ago

1.2.0

4 years ago

1.1.8

4 years ago

1.1.7

4 years ago

1.1.6

5 years ago

1.1.5

5 years ago

1.1.4

5 years ago

1.1.3

5 years ago

1.1.2

5 years ago

1.1.1

5 years ago

1.1.0

5 years ago

1.0.1

5 years ago

1.0.0

5 years ago