@whi/into-struct

v0.1.1
Validate and/or convert input based on a given struct definition

Into Struct

This package is intended to validate and/or convert input against a given struct definition.

Overview

Install

npm i @whi/into-struct

Usage

import { intoStruct } from '@whi/into-struct';

const PostStruct = {
    "message": String,
    "tags": VecType( String ),
    "published_at": Number,
    "last_updated": Number,
};

const post = intoStruct({
    "message":		"Hello, world!",
    "tags":		[ "greeting" ],

    "published_at":	Date.now(),
    "last_updated":	Date.now(),
}, PostStruct );

Contributing

See CONTRIBUTING.md

npm i @whi/[email protected]

Metadata

  • ISC
  • Whatever
  • Matthew Brisebois
  • released 10/5/2023

Downloads

Maintainers