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

@traversable/typebox-test

v0.0.20

Published

<br> <h1 align="center">แฏ“๐˜๐—ฟ๐—ฎ๐˜ƒ๐—ฒ๐—ฟ๐˜€๐—ฎ๐—ฏ๐—น๐—ฒ/๐˜๐˜†๐—ฝ๐—ฒ๐—ฏ๐—ผ๐˜…-๐˜๐—ฒ๐˜€๐˜</h1> <br>

Readme

Requirements

@traversable/typebox-test has 2 peer dependencies:

  1. @sinclair/typebox (v0.34)
  2. fast-check

Usage

$ pnpm add -D @traversable/typebox-test @sinclair/typebox fast-check

Here's an example of importing the library:

import * as T from '@sinclair/typebox'
import { boxTest } from '@traversable/typebox-test'

// see below for specifc examples

Table of contents

boxTest.seedToSchema

Use boxTest.seedToSchema to convert a seed generated by boxTest.SeedGenerator into a TypeBox schema that satisfies the configuration options you specified.

Example

import * as T from '@sinclair/typebox'
import { boxTest } from '@traversable/typebox-test'
import * as fc from 'fast-check'

const builder = boxTest.SeedGenerator()['*']
const [mySeed] = fc.sample(builder.object, 1)

const mySchema = boxTest.seedToSchema(mySeed)
//    ^? const mySchema: T.TSchema

boxTest.seedToValidData

Use boxTest.seedToValidData to convert a seed generated by boxTest.SeedGenerator into data that satisfies the schema that the seed represents.

Example

import * as T from '@sinclair/typebox'
import * as Value from '@sinclair/typebox/value'
import { boxTest } from '@traversable/typebox-test'
import * as fc from 'fast-check'

const builder = boxTest.SeedGenerator()['*']
const [mySeed] = fc.sample(builder.object, 1)

const mySchema = boxTest.seedToSchema(mySeed)
//    ^? const mySchema: T.TSchema

const validData = boxTest.seedToValidData(mySeed)

Value.Check(mySchema, validData) // always `true`

boxTest.seedToInvalidData

Use boxTest.seedToInvalidData to convert a seed generated by boxTest.SeedGenerator into data that does not satisfy the schema that the seed represents.

Example

import * as T from '@sinclair/typebox'
import * as Value from '@sinclair/typebox/value'
import { boxTest } from '@traversable/typebox-test'
import * as fc from 'fast-check'

const builder = boxTest.SeedGenerator()['*']
const [mySeed] = fc.sample(builder.object, 1)

const mySchema = boxTest.seedToSchema(mySeed)
//    ^? const mySchema: T.TSchema

const invalidData = boxTest.seedToValidData(mySeed)

Value.Check(mySchema, invalidData) // always `false`

boxTest.SeedGenerator

[!NOTE]

boxTest.SeedGenerator is fairly low-level. All of the other exports of this library have been implemented in terms of boxTest.SeedGenerator.

Generates a configurable, pseudo-random "seed builder".

Example

import { type } from '@sinclair/typebox'
import * as fc from 'fast-check'
import { boxTest } from '@traversable/typebox-test'

const builder = boxTest.SeedGenerator({
  include: ["boolean", "string", "object"],
  // ๐™˜ use `include` to only include certain schema types
  exclude: ["boolean", "any"],
  // ๐™˜ use `exclude` to exclude certain schema types altogether (overrides `include`)
  object: { maxKeys: 5 },
  // ๐™˜ specific arbitraries are configurable by name
})

// included schemas are present as properties on your generator...
builder.string
builder.object

// ...excluded schemas are not present...
builder.boolean // ๐Ÿšซ TypeError

// ...a special wildcard `"*"` property (pronounced "surprise me") is always present:
builder["*"]

/**
 * `fast-check` will generate a seed, which is a data structure containing
 * integers that represent a kind of AST.
 *
 * To use a seed, you need to pass it to an interpreter like `boxTest.seedToSchema`,
 * `boxTest.seedToValidData` or `boxTest.seedToInvalidData`:
 */

const [mySeed] = fc.sample(builder.object, 1)

const mySchema = boxTest.seedToSchema(mySeed)
//    ^? const mySchema: type.Any

const validData = boxTest.seedToValidData(mySeed)
//    ^? since the `mySeed` was also used to generate `mySchema`,
//       parsing `validData` should always succeed

const invalidData = boxTest.seedToInvalidData(mySeed)
//    ^? since the `mySeed` was also used to generate `mySchema`,
//       parsing `invalidData` should always fail

boxTest.SeedValidDataGenerator

Like boxTest.SeedGenerator, except boxTest.SeedValidDataGenerator comes pre-configured to exclude schemas that make it impossible to reliably generate valid data.

[!NOTE]

boxTest.SeedValidDataGenerator does not accept any options. If you need more fine-grained control of the schemas being generated, use boxTest.SeedGenerator.

boxTest.SeedInvalidDataGenerator

Like boxTest.SeedGenerator, except boxTest.SeedValidDataGenerator comes pre-configured to exclude schemas that make it impossible to reliably generate invalid data.

[!NOTE]

boxTest.SeedInvalidDataGenerator does not accept any options. If you need more fine-grained control of the schemas being generated, use boxTest.SeedGenerator.