0.3.0 • Published 14 days ago

@whi/into-struct v0.3.0

Weekly downloads
-
License
ISC
Repository
github
Last release
14 days ago

npm.io

Into Struct

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

npm.io npm.io npm.io

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