Coder Social home page Coder Social logo

nyxblabs / typiqus Goto Github PK

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

๐Ÿ”ค Empower your type handling with uniqueness and customization. Effortlessly create and manage tailored types for a robust and flexible codebase. ๐Ÿš€

Home Page: https://typiqus.nyxb.xyz

License: MIT License

TypeScript 82.19% JavaScript 1.20% Vue 16.60%
config generator markdown typescript

typiqus's Introduction

cover npm version npm downloads bundle License

๐Ÿงฌ Typiqus

๐Ÿ”ค Empower your type handling with uniqueness and customization. Effortlessly create and manage tailored types for a robust and flexible codebase. ๐Ÿš€

โ–ถ๏ธ Check online playground

๐Ÿ’พ Install

# nyxi
nyxi add typiqus

# pnpm
pnpm add typiqus

# npm
npm i typiqus

# yarn
yarn add typiqus

๐Ÿ“š Usage

First we have to define a reference object that describes types, defaults, and a $resolve method (normalizer).

const defaultPlanet = {
  name: 'earth',
  specs: {
    gravity: {
      $resolve: val => parseFloat(val),
      $default: '9.8'
    },
    moons: {
      $resolve: (val = ['moon']) => [].concat(val),
      $schema: {
        title: 'planet moons'
      }
    }
  }
}

๐ŸŒ API

๐Ÿงฉ resolveSchema

import { resolveSchema } from 'typiqus'

const schema = await resolveSchema(defaultPlanet)

๐Ÿ” Output:

{
  "properties": {
    "name": {
      "type": "string",
      "default": "earth"
    },
    "specs": {
      "properties": {
        "gravity": {
          "default": 9.8,
          "type": "number"
        },
        "moons": {
          "title": "planet moons",
          "default": [
            "moon"
          ],
          "type": "array",
          "items": [
            {
              "type": "string"
            }
          ]
        }
      },
      "type": "object"
    }
  },
  "type": "object"
}

๐Ÿญ generateTypes

import { resolveSchema, generateTypes } from 'typiqus'

const types = generateTypes(await resolveSchema(defaultPlanet))

๐Ÿ” Output:

interface Typiqus {
   /** @default "earth" */
  name: string,

  specs: {
    /** @default 9.8 */
    gravity: number,

    /**
     * planet moons
     * @default ["moon"]
    */
    moons: string[],
  },
}

๐Ÿ“„ generateMarkdown

import { resolveSchema, generateMarkdown } from 'typiqus'

const markdown = generateMarkdown(await resolveSchema(defaultPlanet))

๐Ÿ” Output:

# `name`
- **Type**: `string`
- **Default**: `"earth"`


# `specs`

## `gravity`
- **Type**: `number`
- **Default**: `9.8`


## `moons`
- **Type**: `array`
- **Default**: `["moon"]`

๐ŸŒฑ Development

  • ๐Ÿ™ Clone this repository
  • ๐Ÿ”ง Enable Corepack using corepack enable (use npm i -g corepack for Node.js < 16.10)
  • ๐Ÿ“ฆ Install dependencies using nyxi
  • ๐Ÿƒ Run interactive tests using nyxr dev
  • ๐Ÿƒ Run nyxr web to start playground website
  • ๐Ÿƒ Run pnpm test before push to ensure all tests and lint checks passing

๐Ÿ“œ License

MIT - Made with ๐Ÿ’ž

typiqus's People

Stargazers

Nikita Zhenev 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.