1.0.0 • Published 2 years ago

tycheck v1.0.0

Weekly downloads
-
License
MIT
Repository
-
Last release
2 years ago

TyCheck

TyCheck is a library used to make types both JavaScript and TypeScript and check them at runtime.

Install

On your project, using npm (or any other node package manager).

npm i tycheck

Usage

Simple usage

import { typeChecker, typeString } from 'tycheck';

const checker = typeChecker(typeString);

const validString = checker('Valid string'); // validString will have "Valid string" value
const invalidString = checker(42); // The checker will throw a type error

More complex usage

import { beArray, typeBoolean, typeChecker, typeNumber, beInterface, typeString } from 'tycheck';

const checker = typeChecker(
  beInterface({
    string: typeString,
    boolean: typeBoolean,
    array: beArray(typeNumber)
  })
);

type CheckedType = ReturnType<typeof checker>;

const checkedValue = checker({
  string: 'string value',
  boolean: true,
  array: [33, 42],
}); // Will pass and be type of CheckedType (by inference)

Contribute

Just create a Pull Request with your contribution.

The Pull Request is used to add/remove code but also as a discussion place to know if the contribution is relevant.

Install

npm i

Tests

npm test

Build

npm run build
1.0.0

2 years ago

1.0.0-alpha.4

2 years ago

1.0.0-alpha.3

2 years ago

1.0.0-alpha.2

2 years ago

1.0.0-alpha.1

2 years ago

1.0.0-alpha.0

2 years ago