Giter Site home page Giter Site logo

klaby / chork Goto Github PK

View Code? Open in Web Editor NEW
0.0 1.0 0.0 670 KB

๐Ÿ”ฌ Minimalistic JS data type checking and serialization utility..

License: MIT License

TypeScript 98.62% JavaScript 1.38%
nodejs typeof typechecker minimalist-js-data serializer

chork's Introduction

chork logo

Minimalist JS data type checking utility.

Built with โค๏ธŽ by Hiukky


About

Chork is a minimal library for checking data types in javascript.

Typeof typeof works well, but only for variables of the primitive type and not for structures like Array, Date and others. Chork solves this by bringing the real type of past value.


Installation

Using NPM

npm i chork

Using Yarn

yarn add chork

Use

Currently, chork has two test functions which are check and checkAll.

  • check

It receives only one argument of any kind.

import { check } from 'chork'

check(1) // 'number'
check('foo') // 'string'
check([1, 'foo']) // 'array'
check({ key: 1 }) // 'object'
check(new Date()) // 'date'
  • checkAll

The checkAll function works in the same way as check, the only difference is that it returns an object with a key being its own value and a value being the result with the type of data tested.

import { check } from 'chork'

checkAll(1) // { '1': 'number' }
checkAll('foo') // { foo: 'string' }
checkAll([1, 'foo']) // { '1': 'number', foo: 'string' }
checkAll({ key: 1 }) // { key: 'number' }
checkAll(new Date()) // { 'Sat Feb 06 2021 12:35:41 GMT-0300 (Brasilia Standard Time)': 'date' }

Available types

  • string
  • number
  • bigint
  • boolean
  • undefined
  • symbol
  • null
  • object
  • array
  • map
  • date
  • function

Contributing

Chork is in an initial version without many features yet, but you can feel free to send your suggestion or open a PR.



chork's People

Contributors

hiukky 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.