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 🙏

© 2025 – Pkg Stats / Ryan Hefner

advanced-types

v1.1.17

Published

Advanced type for Typescript.

Downloads

36

Readme

advanced-types

Advanced type for Typescript.

TypeScript required! [ npm install -g typescript ]

If you have the desire to add any particular type you can apply at this link, if possible it will be satisfied as soon as possible.

Installation

yarn add advanced-types

Type list

Array:

| Name | Description | |-----------|---------------------------------------------| |FixedArray| Get an array with specific length and type | |ValuesArray| Get all values of readonly array | |IndexOfArrayByValue | Get all index of element of readonly with specific type | |IndexOf | Get all index of readonly array | |ArrayToString | Get a string from an array of strings |

Number:

| Name | Description | |-----------|---------------------------------------------| |Enumerate| Get a range of numbers starting from 0 | |Range| Get a range of numbers |

String:

| Name | Description | |-----------|---------------------------------------------| |Join| Get the union of two strings by a separator. | |NestedKeys| Get a string obtained from an object's key tree by following its complete path. | |NestedPathKeys |Get a string obtained from an object's key tree by following its complete and incomplete path | |RestrictedChars | Get string with only allowed chars | |CheckMaxLength | Check if string respect max length | |SnakeCaseToCamelCase | Get a string snake case in camel case |

Object:

| Name | Description | |-----------|---------------------------------------------| |ValueOf| Get values type of object | |Nullable| Get object with all values with possible value null or undefined | |FilterKeyObjectByTypes| Get keys object with specific keys with the type of the desired value. |

Usage

Array

FixedArray

import { FixedArray } from  "advanced-types";
const  array1: FixedArray<number, 4> = [1,2,3,4];     //OK
const  array2: FixedArray<number, 4> = [1,2,3,4,5];  // ERROR 
const  array3: FixedArray<number, 4> = [1,2,3,"4"];  // ERROR

ValuesArray

import { ValuesArray } from  "advanced-types";
const  array1: ValuesArray<[1,2,"2"]> = "2";     //OK
const  array2: ValuesArray<[1,2,"2"]> = 2;       //OK
const  array3: ValuesArray<[1,2,"2"]> = 3;       //ERROR, possible values: 1 | 2 | "2"

IndexOfArrayByValue

import { IndexOfArrayByValue } from  "advanced-types";
const  array1: IndexOfArrayByValue<[1,2,"3","4"], string> = 2; // OK
const  array1: IndexOfArrayByValue<[1,2,"3","4"], string> = 0; // ERROR, possible values: 2 | 3

IndexOf

import { IndexOf } from  "advanced-types";
const  array1: IndexOf<["1", 10, {name: "name"}]> = 0; // OK
const  array1: IndexOf<["1", 10, {name: "name"}]> = 3; // ERROR, possible values: 0 | 1 | 2

ArrayToString

import { ArrayToString } from  "advanced-types";
const  string = ["a", "r","r","a","y"] as  const;
const  array: ArrayToString<typeof  string> = "array"; // OK
const  array: ArrayToString<typeof  string> = "arr";   // ERROR

Number

Enumerate

import { Enumerate } from  "advanced-types";
const  number1: Enumerate<5> = 2; // OK
const  number2: Enumerate<5> = 7;   // ERROR, ERROR, possible values: 0 | 1 | 2 | 3 | 4 | 5

Range

import { Range } from  "advanced-types";
const  number1: Range<2, 5> = 2   // OK
const  number2: Range<2, 5> = 6   // ERROR, ERROR, possible values: 2 | 3 | 4 | 5

String

Join

import { Join } from  "advanced-types";
const  string1: Join<"GP" | "SN", "01" | "02", "-"> = "SN-02"; // OK
const  string2: Join<"GP" | "SN", "01" | "02", "_"> = "GP_01"; // OK
const  string3: Join<"GP" | "SN", "01" | "02", "-"> = "SN-03"; // ERROR, possible values: "GP-01" | "GP-02" | "SN-01" | "SN-02"

NestedKeys

import { NestedKeys } from  "advanced-types";
const  object = {example:  "", key: { nestedKey:  2}}
const  string1: NestedKeys<typeof  object> = "key/nestedKey";      // OK
const  string2: NestedKeys<typeof  object, "."> = "key.nestedKey"; // OK
const  string3: NestedKeys<typeof  object, "."> = "key".           // ERROR, possible values: "example" | "key.nestedKey"

NestedPathKeys

import { NestedPathKeys } from  "advanced-types";
const  object = {example:  "", key: { nestedKey:  2}}
const  string1: NestedKeys<typeof  object> = "key/nestedKey";      // OK
const  string2: NestedKeys<typeof  object, "."> = "key.nestedKey"; // OK
const  string3: NestedKeys<typeof  object, "."> = "key".           // OK
const  string4: NestedKeys<typeof  object, "."> = "nestedKey".     // ERROR, possible values: "example" | "key.nestedKey" | "key"

RestrictedChars

import { RestrictedChars, Lower, Upper } from  "advanced-types";
const  string1: RestrictedChars<"example", "e" | "x" | "a" | "m" | "p" | "l"> = "example"; // OK
const  string2: RestrictedChars<"example", Lower> = "example"; // OK, Lower is a type of all lowercase letters
const  string3: RestrictedChars<"example", Upper> = "example"; // ERROR, Upper is a type of all uppercase letters
const  string4: RestrictedChars<"example", "e" | "x" | "a" | "m" | "p"> = "example";       // ERROR

CheckMaxLength

import { CheckMaxLength } from  "advanced-types";
const  string1: CheckMaxLength<"example", 10> = "example"; // OK
const  string2: CheckMaxLength<"example", 4> = "example";  // ERROR, string too long

SnakeCaseToCamelCase

import { SnakeCaseToCamelCase } from  "advanced-types";
const  string1: SnakeCaseToCamelCase<"example_camel_case"> = "exampleCamelCase"; // OK
const  string2: SnakeCaseToCamelCase<"example_camel_case"> = "example_camelcase"; // ERROR

Object

ValueOf

import { ValueOf } from  "advanced-types";
type  IExample = {example: string}
const  value1: ValueOf<IExample, "example"> = "2"; //OK
const  value2: ValueOf<IExample, "example"> = 2;   // ERROR, type number is not assignable to string

Nullable

import { Nullable } from  "advanced-types";
type  IExample = {example: string, example2: number};
const  string1: Nullable<IExample> = {example:  undefined, example2:  null}; // OK

FilterKeyObjectByTypes

import { FilterKeyObjectByTypes } from  "advanced-types";
type  IExample = {example: string, example2: number}
const  string1: FilterKeyObjectByTypes<IExample, number> = "example2"; // OK
const  string2: FilterKeyObjectByTypes<IExample, number> = "example";  // ERROR ERROR, possible values: "example2"