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

@ayte/archetype.core

v0.2.0

Published

Some core types definitions extending standard library, part of @ayte/archetype

Downloads

8

Readme

Ayte / TypeScript / Archetype / Core

npm CircleCI/Master

This package contains some low-level types that are also used in other archetype packages.

Installation

yarn add @ayte/archetype.core

# - or -

npm install -S @ayte/archetype.core

Structure

Basic types

All non-object types (array is considered to be object type, while string is not) are described using three union types: Absent, union of null and undefined, Scalar, union of boolean, number, string, symbol and bigint, and Primitive, which joins the two above.

Is<T, U> type equals to true or false whether T is a subset of U, while Not<T, U> does the opposite. This may be useful for explicit value hinting, for example:

import {Is, Scalar} from '@ayte/archetype.core';

export function isScalar<T>(subject: T): Is<T, Scalar>;
export function isScalar(subject: any): boolean {
  return ['string', 'boolean', 'number'].indexOf(typeof subject) > -1;
}
// now compiler and IDE will know that following is not just boolean,
// but true:
const check = isScalar('test');

Except<T> type allows matching any type but T, basically it's just an alias for Exclude<any, T>.

Constraints

Most constraints comes with one or two additional types contained in same-named namespace. Those types are Nested, which applies constraint not only to type itself, but to it's properties as well, and Descendant, which applies constraint to type properties, but not to type itself. Some constraints repeat semantics of similar constraints in es5 library, but since derivative constraints like Readonly.Nested<T> would only cause confusion with native types from es5 lib, this project maintains such constraints under different names, even if they have exactly same semantics.

Determinate<T> / Indeterminate<T> pair allows matching type against Absent (null / undefined), the same as native NonNullable<T>.

NullTolerant<T> / NullIntolerant<T> provides means to allow or disallow type to match null (not regarding undefined in any way).

Complete<T> / Incomplete<T> allows or disallows type to have optional properties.

Mutable<T> / Immutable<T> controls ability to change type properties.

Solid<T> and Loose<T> are union constraint types. Solid<T> ensures that all type properties are readonly and not optional, while Loose<T> allows all options to be writeable or missing.

Licensing

MIT / UPL-1.0

Ayte Labs, 2020