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 🙏

© 2026 – Pkg Stats / Ryan Hefner

@variojs/schema

v0.0.2

Published

Vario Schema DSL - Schema definition, validation, normalization, and transformation

Readme

📋 @variojs/schema

Vario Schema DSL - Schema 定义、验证、规范化

特点

  • 🎯 类型安全:完整的 TypeScript 类型系统
  • 运行时验证:确保 Schema 正确性
  • 🔧 自动规范化:统一格式,优化性能
  • 💡 类型推导defineSchema 提供完整类型推导

安装

npm install @variojs/schema
# 或
pnpm add @variojs/schema

依赖的 @variojs/core 会自动安装。

快速开始

基础 Schema

import type { SchemaNode } from '@variojs/schema'

const schema: SchemaNode = {
  type: 'div',
  children: [
    {
      type: 'input',
      model: 'name',
      props: { placeholder: '请输入姓名' }
    },
    {
      type: 'div',
      children: '{{ name }}'
    }
  ]
}

使用 defineSchema(推荐)

import { defineSchema } from '@variojs/schema'

const view = defineSchema({
  state: {
    name: '',
    count: 0
  },
  services: {
    increment: (ctx) => {
      ctx._set('count', ctx._get('count') + 1)
    }
  },
  schema: (ctx) => ({
    type: 'div',
    children: [
      {
        type: 'input',
        model: 'name'
      },
      {
        type: 'button',
        events: {
          click: {
            type: 'call',
            method: 'increment'
          }
        },
        children: '计数: {{ count }}'
      }
    ]
  })
})

Schema 验证

import { validateSchema } from '@variojs/schema'

try {
  validateSchema(schema)
  console.log('Schema 验证通过')
} catch (error) {
  console.error('验证失败:', error.message)
}

优势

  • 类型推导:从 defineSchema 自动推导状态和服务类型
  • 运行时验证:结构验证、表达式安全验证、路径验证
  • 性能优化:规范化结果缓存
  • 易于维护:统一的 Schema 格式

许可证

MIT