Skip to content

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

Notifications You must be signed in to change notification settings

neuledge/typescript-runtime-type-benchmarks

ย 
ย 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 

Repository files navigation

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

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)

Benchmark Results

Data Type Checks

Node 10.x (JSON, CSV, SVG)

Bar Graph - Node 10.x

Node 12.x (JSON, CSV, SVG)

Bar Graph - Node 12.x

Node 13.x (JSON, CSV, SVG)

Bar Graph - Node 13.x

Data Type Checks Sans ts-json-validator

Because some packages are so performant it makes it difficult to see the benchmarks for other packages.

This benchmark run includes all of the above packages, but excludes ts-json-validator and quartet.

Node 10.x (JSON, CSV, SVG)

Bar Graph - Node 10.x

Node 12.x (JSON, CSV, SVG)

Bar Graph - Node 12.x

Node 13.x (JSON, CSV, SVG)

Bar Graph - Node 13.x

About

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

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • TypeScript 98.8%
  • Other 1.2%