0.5.1 • Published 7 years ago

revtype v0.5.1

Weekly downloads
5
License
ISC
Repository
-
Last release
7 years ago

revType

Convert Javascript data structures into their typed counterparts.

Input:

import revtype from 'revtype';

const object = {
  stuff: {},
  things: [],
  nil: null,
	name: 'tommy',
	male: false,
	age: 29,
	mom: {
		name: 'mommy',
		male: false,
		age: 28,
		jobs: [
			'cooking',
			'cleaning',
			'beasting',
			{
				title: 'boss',
				location: 'home',
				salary: 0
			}
		]
	}
};

const revved = revtype.parse(object);
console.log(JSON.stringify(revved));

Output:

{
	"stuff": {},
	"things": [],
	"nil": "null",
	"name": "string",
	"male": "boolean",
	"age": "number",
	"mom": {
		"name": "string",
		"male": "boolean",
		"age": "number",
		"jobs": [
			"string",
			"string",
			"string",
			{
        "title": "string",
        "location": "string",
        "salary": "number"
      }
		]
	}
}

Todo:

  • Support for Map
  • Support for WeakMap
  • Support for Set
  • Support for homeless people.