npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

@joookiwi/type

v1.1.0

Published

A typescript project to encapsulate a bunch of common type-aliases

Downloads

121

Readme

Types (javascript version)

downloads

Table of content

Installation

npm install @joookiwi/type
npm i @joookiwi/type

npm install --save @joookiwi/type
npm i -S @joookiwi/type

npm install --save-dev @joookiwi/type
npm i -D @joookiwi/type

Usage

The usage of the types is mostly for Typescript only. But if it can be used in the Javascript documentation if needed.

It can be used directly without an argument or with a specialized argument.

import type {Nullable, NullOrString, UndefinedOrNumeric, Template} from "@joookiwi/type"

type Correct1 = Nullable<| 'a' | 2 | false> // = 'a' | 2 | false | null | undefined
type Incorrect1 = Nullable                  // The argument is required. (Just like NullOr or UndefinedOr)

type Correct2a = NullOrString      // = string | null
type Correct2b = NullOrString<'a'> // = 'a'| null
type Incorrect2 = NullOrString<2>  // It can only receive a string as an argument

type Correct3a = UndefinedOrNumeric           // = number | bigint | undefined
type Correct3b = UndefinedOrNumeric<2>        // = 2 | undefined
type Correct3c = UndefinedOrNumeric<2n>       // = 2n | undefined
type Correct3c = UndefinedOrNumeric<| 2 | 2n> // = 2 | 2n | undefined
type Incorrect3 = UndefinedOrNumeric<boolean> // It can only receive a number or bigint as an argument

type Correct4a = Template          // = `${string | boolean | number | bigint | null | undefined}`
type Correct4b = Template<'a'>     // = 'a' (but is redontant, just 'a' should suffice)
type Correct4c = Template<2 | 3n>  // = '2' | '3'
type Incorrect4 = Template<symbol> // A symbol cannot be in a string template

Chart

To be coherent across the different types, a simplified chart of the types has been made on their associable values.

The only exception is the null and undefined.

| | Nullable | Stringtemplate | numbervalue | bigintvalue | Object | |----------------------------------------------------------------------------------------------------------|:--------:|:-------------------:|:----------------:|:----------------:|:------:| | null | | ✓* | | | | | undefined | | ✓* | | | | | | | | | | | | string | ✓ | | | | ✓ | | | | | | | | | boolean | ✓ | ✓ | | | ✓ | | true | ✓ | ✓ | | | | | false | ✓ | ✓ | | | | | | | | | | | | numeric(number & bigint) | ✓ | ✓ | | | ✓ | | number | ✓ | ✓ | | | ✓ | | bigint | ✓ | ✓ | | | ✓ | | -1 | ✓ | ✓ | ✓ | ✓ | | | 0 | ✓ | ✓ | ✓ | ✓ | | | 1 | ✓ | ✓ | ✓ | ✓ | | | 2 | ✓ | ✓ | ✓ | ✓ | | | | | | | | | | symbol | ✓ | | | | ✓ | | known js symbol | ✓ | | | | | | known ts symbol | ✓ | | | | | *: In a template, but not with a mix of the values

Combination

Almost each value can be associated with each other, but some defined values are not associated by design. It is to give simplicity and not too many types.

| | nullable | string | boolean | truefalse | numeric | number | bigint | -1 01 2 | symbol | known js / ts symbol | |---------------------------------------------------------------------------------------------------------------------------------------------------------------------------:|:--------:|:------:|:-------:|:--------------:|:-------:|:------:|:-------|:------------:|:------:|:----------------------------------------------------------------------------------------------------------------------------------------------------------------------:| | nullable | | ✓ | ✓ | ✓ | ✓ | ✓ | ✓ | ✓ | ✓ | ✓ | | string | ✓ | | ✓ | | ✓ | ✓ | ✓ | | ✓ | | | boolean | ✓ | ✓ | | | ✓ | ✓ | ✓ | | ✓ | | | truefalse | ✓ | | | | | | | | | | | numeric | ✓ | ✓ | ✓ | | | ✓ | ✓ | | ✓ | | | number | ✓ | ✓ | ✓ | | ✓ | | ✓ | | ✓ | | | bigint | ✓ | ✓ | ✓ | | ✓ | ✓ | | | ✓ | | | -1 01 2 | ✓ | | | | | | | | | | | symbol | ✓ | ✓ | ✓ | | ✓ | ✓ | ✓ | | | | | known js / ts symbol | ✓ | | | | | | | | | |

Contribution

You can contribute to great simple packages. All with similar behaviour, accessibility and usage (like Java, Kotlin, C# and PHP). It can be done 2 different ways: