Skip to content

ewnd9/tcomb-property

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

3 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

tcomb-property

Build Status

Alternative syntax for defining default props in tcomb structures

Install

$ npm install --save tcomb-property

Usage

import t from 'tcomb';
import { property, createInstance } from 'tcomb-property';

const Show = t.struct({
  title: t.String,
  duration: property(t.String, '40m'),
  network: t.struct({
    country: property(t.String, 'USA')
  })
});

createInstance(Show)
/*
{
  title: undefined,
  duration: '40m',
  network: {
    country: 'USA'
  }
}
*/

createInstance(Show, { title: 'Top Gear', duration: '20m', network: { country: 'UK' } })
/*
{
  title: 'Top Gear',
  duration: '20m',
  network: {
    country: 'UK'
  }
}
*/

Related

License

MIT © ewnd9

About

Alternative syntax for defining default props in tcomb structures

Topics

Resources

License

Stars

Watchers

Forks

Packages

No packages published