GithubHelp home page GithubHelp logo

arktypeio / typescript-runtime-type-benchmarks Goto Github PK

View Code? Open in Web Editor NEW

This project forked from moltar/typescript-runtime-type-benchmarks

7.0 1.0 0.0 12.02 MB

๐Ÿ“Š Benchmark Comparison of Packages with Runtime Validation and TypeScript Support

Home Page: https://moltar.github.io/typescript-runtime-type-benchmarks/

Shell 0.15% JavaScript 0.20% TypeScript 99.65%

typescript-runtime-type-benchmarks's Introduction

๐Ÿ“Š Benchmark Comparison of Packages with Runtime Validation and TypeScript Support


โšกโš  Benchmark results have changed after switching to isolated node processes for each benchmarked package, see #864 โš โšก


Benchmark Results

Fastest Packages - click to view details

click here for result details

Packages Compared

Criteria

Validation

These packages are capable of validating the data for type correctness.

E.g. if string was expected, but a number was provided, the validator should fail.

Interface

It has a validator function or method that returns a valid type casted value or throws.

const data: any = {}

// `res` is now type casted to the right type
const res = isValid(data)

Or it has a type guard function that in a truthy block type casts the value.

const data: any = {}

function isMyDataValid(data: any) {
  // isValidGuard is the type guard function provided by the package
  if (isValidGuard(data)) {
    // data here is "guarded" and therefore inferred to be of the right type
    return data
  }

  throw new Error('Invalid!')
}

// `res` is now type casted to the right type
const res = isMyDataValid(data)

Local Development

  • npm run start - run benchmarks for all modules
  • npm run start run zod myzod valita - run benchmarks only for a few selected modules
  • npm run docs:serve - result viewer
  • npm run test - run tests on all modules

Adding a new node version

  • update node version matrix in .github/workflows/pr.yml and .github/workflows/release.yml
  • update NODE_VERSIONS in docs/dist/app.tsx and run npm run docs:build
  • optionally set NODE_VERSION_FOR_PREVIEW in benchmarks/helpers/main.ts

typescript-runtime-type-benchmarks's People

Contributors

aslilac avatar dbartholomae avatar dependabot-preview[bot] avatar dependabot[bot] avatar dsagal avatar dzakh avatar fabian-hiller avatar gervinfung avatar hoeck avatar imranbarbhuiya avatar iyegoroff avatar jayakrishnanamburu avatar jeengbe avatar jsoldi avatar jviide avatar marcj avatar micnic avatar mmamedel avatar moltar avatar naruaway avatar patsissons avatar renovate-bot avatar renovate[bot] avatar richardscarrott avatar ryasmi avatar samchon avatar satvik-s avatar sinclairzx81 avatar skarab42 avatar typeofweb avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.