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

tsukiko

v1.4.2

Published

Dynamic Types Cheker At Runtime Which Develop

Downloads

88

Readme

Tsukiko

npm GitHub License GitHub last commit (by committer)

⚡ Dynamic Types Cheker At Runtime Which Develop Base On TypeScript ⚡

Tsukiko Docs

📃 Install

  • NPM
npm install tsukiko
  • YAYN
yarn add tsukiko
  • PNPM
pnpm install tsukiko

🎯 Internationalization

  • English
  • 日本語 (Japanese)
  • 繁體中文 (Traditional Chinese)
  • 简体中文(Simplified Chinese)

🚀 Parser

  • NumberParser
  • StringParser
  • BooleanParser
  • NullParser
  • UndefinedParser
  • AnyParser
  • UnknownParser
  • NeverParser
  • ArrayParser
  • TupleParser
  • ObjectParser
  • EnumParser
  • LiteralParser
  • IntersectionParser
  • UnionParser
  • CustomParser
  • FunctionParser
  • ClassParser

🛠️ Tools

  • ParserInfer
  • tsuFactory
  • TsuError

📝 Json-Schema

All parsers' methods which are supported list:

  • NumberParser
    • int()
    • multiple()
    • natural()
    • positive()
    • negative()
    • percent()
    • port()
  • StringParser
    • regexp()
    • email()
    • domain()
    • url()
    • max()
    • min()
    • range()
  • BooleanParser
    • Fully support
  • NullParser
    • Fully support
  • ArrayParser
    • Fully support
  • TupleParser
    • Fully support
  • ObjectParser
    • strict()
    • index()
    • max()
    • min()
    • range()
  • EnumParser
    • Only support literal values (string, number, boolean constants)
  • LiteralParser
    • Fully support
  • IntersectionParser
    • Fully support
  • UnionParser
    • Fully support

The parsers and methods which no listed are all not supported.

🌰 Example

// example/example1.ts
import Tsu, { tsuFactory } from "tsukiko";

const schema = Tsu.Tuple([Tsu.Number()]);
export type Schema = Tsu.infer<typeof schema>;

const schema2 = Tsu.Array(Tsu.String());
export type Schema2 = Tsu.infer<typeof schema2>;

const schema3 = Tsu.Object({
  value: Tsu.Number(),
  name: schema2,
  host: Tsu.String().regexp(/http(s)?:\/\/(.*)/),
  port: Tsu.Number().range(1, 65565).int(),
  allowList: Tsu.Array(Tsu.String()),
  listType: Tsu.Union([Tsu.Literal("include"), Tsu.Literal("exclude")]),
});

export type Schema3 = Tsu.infer<typeof schema3>;

const schema4 = Tsu.Intersection([Tsu.Number(), Tsu.Literal(1)]);
export type Schema4 = Tsu.infer<typeof schema4>;

const schema5 = Tsu.Intersection([
  Tsu.Literal("hello world"),
  Tsu.Union([schema, Tsu.Union([Tsu.Number().optional(), schema2])]),
]);
export type Schema5 = Tsu.infer<typeof schema5>;

const schema6 = Tsu.Object({}).index(
  Tsu.String().regexp(/[0-9]+\.[0-9]+\.[0-9]+/),
  Tsu.String().regexp(/kotori-plugin-(.*)/)
);

export type Schema6 = Tsu.infer<typeof schema6>;
export const example6: Schema6 = {
  "kotori-plugin-adapter-qq": "1.5.0",
  "kotori-plugin-adapter-wechat": "0.2.0",
  "kotori-plugin-database-sqlite": "2.1.0",
  "kotori-plugin-database-mysql": "3.1.0",
  "kotori-plugin-help": "1.2.0",
  "kotori-plugin-wiki": "1.0.0",
};

const newTsu = tsuFactory("ja_JP");

export const localeTypeSchema = newTsu.Union([
  newTsu.Union([newTsu.Literal("en_US"), newTsu.Literal("ja_JP")]),
  newTsu.Union([newTsu.Literal("zh_CN"), newTsu.Literal("zh_TW")]),
]);

const globalConfigBaseSchema = newTsu.Object({
  lang: localeTypeSchema.default("ja_JP"),
  "command-prefix": newTsu.String().default("/"),
});

const adapterConfigBaseSchema = newTsu.Intersection([
  newTsu.Object({
    extends: newTsu.String(),
    master: newTsu.Union([newTsu.Number(), newTsu.String()]),
  }),
  globalConfigBaseSchema,
]);

export const globalConfigSchema = newTsu.Object({
  global: globalConfigBaseSchema,
  adapter: newTsu.Object({}).index(adapterConfigBaseSchema).default({}),
  plugin: newTsu.Object({}).index(newTsu.Unknown()).default({}),
});

export type GlobalConfig = Tsu.infer<typeof globalConfigSchema>;

console.log(
  globalConfigSchema.parse({
    global: { lang: "zh_CN" },
    adapter: { aa: { master: "1", lang: "ja_JP" } },
  })
);