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

momo-util-types

v0.1.3

Published

⭐️ 모두모여라 유틸 타입 라이브러리입니다 ⭐️

Downloads

72

Readme

momo-util-types

npm npm downloads install size npm bundle size

⭐️ 모두모여라의 유틸 타입 라이브러리입니다 ⭐️

Quick Start

$ npm install -D momo-util-types

// or yarn
$ yarn add -D momo-util-types

API

PartialRequired<Type, Keys>

Keys 에서 Required로 변경할 속성 집합을 선택하여 타입을 구성합니다.

type PartialObject = Partial<{ a: 1; b: 2; c: 3 }>;
// { a?: 1, b?: 2, c?: 3 }

type RequiredObject = PartialRequired<PartialObject, "a" | "b" | "c">;
// result : { a: 1, b: 2, c: 3 }

PartialOptional<Type, Keys>

Keys 에서 Optional로 변경할 속성 집합을 선택하여 타입을 구성합니다.

type RequiredObject = { a: 1; b: 2; c: 3 };

type OptinalObject = PartialOptional<RequiredObject, "a" | "b">;
// result : { a?: 1, b?: 2, c: 3 }

Override<Type, Keys>

Keys 에서 속성 집합을 선택하여 기존 타입에 오버라이딩한 새 타입을 구성합니다.

type OriginalObject = { a: 1; b: 2 };
type TargetObject = { a: 3 };

type OverridedObject = Override<OriginalObject, TargetObject>;
// result : { a: 3, b: 2 }

Equal<Type1, Type2>

두 타입의 구성을 비교합니다.

같으면 true, 다르면 false를 타입을 반환합니다.

type TypeA = { a: 1 };
type TypeB = { a: 1 };
type TypeC = { a: 2 };

type MayBeTrue = Equal<TypeA, TypeB>;
// result : true

type MayBeFalse = Equal<TypeA, TypeC>;
// result : false

If<ConditionType, ReturnTypeA, ReturnTypeB>

ConditionType에 따라 다른 타입을 반환합니다.

true일 경우 앞의 타입을, false일 경우 뒤의 타입을 반환합니다.

ConditionTypetrue | false 이어야 합니다.

type LiteralType = If<true, "LiteralTypeA", "LiteralTypeB">;
// result : "LiteralTypeA"

Unionize

객체 타입의 각 요소를 Union 으로 결합시킨 타입을 구성합니다.

type TargetObject = { a: 1; b: 2; c: 3 };

type UnionizedType = Unionize<TargetObject>;
// result : { a: 1 } | { b: 2 } | { c: 3 };

ObjectKey>

객체 타입의 KeyUnion 으로 결합시킨 타입을 구성합니다.

type TargetObject = { a: 1; b: 2; c: 3 };

type KeyType = ObjectKey<TargetObject>;
// result : "a" | "b" | "c";

ObjectValue

객체 타입의 ValueUnion 으로 결합시킨 타입을 구성합니다.

type TargetObject = { a: 1; b: 2; c: 3 };

type ValueType = ObjectKey<TargetObject>;
// result : 1 | 2 | 3

ObjectType<T, Keys?>

객체의 KeyValue의 타입을 지정한 새로운 객체 타입을 구성합니다.

Key 타입의 기본값은 string이며, string | number | symbol 의 하위 타입만 입력할 수 있습니다.

type NewObjectTypeWithStringValue = ObjectKey<string>;
// result : Record<string, string>

type NewObjectTypeWithNumberKey = ObjectKey<string, number>;
// result : Record<number, string>

ArrayElement

대상 배열 타입의 요소들로 구성된 새로운 타입을 구성합니다.

const array = ["a", 1, Symbol("b")];
type NewObjectTypeWithStringValue = ArrayElement<typeof array>;
// result : string | number | symbol