0.5.1 • Published 10 years ago

node-typesafe v0.5.1

Weekly downloads
3
License
MIT License
Repository
github
Last release
10 years ago

node-typesafe

Typesafe data structures for Node.js

Example usage:

  • Define a typed structure:
var $ = require('node-typesafe');

var Location = $.Array($.Number);

var Product = $.Structure('Product', {
	name: $.String,
	added: $.Date,
	time: $.Time,
	removedAt: $.Datetime,
	price: $.Number,
	active: $.Boolean,
	location: Location
});

var getPrice = $.Function($.Number, [Product], function getPrice(product) {
	return product.price;
});
  • Create a typed object:
var product = new Product({
	added: '2009-08-10',
	time: '8:00:59',
	removedAt: '2013-12-22 01:44:22',
	price: 13.24,
	location: [1, 2, 56.2],
	active: true
});
  • Use typed object:
product.active = false;
console.log(product.price);
product.time = undefined;
console.log(product.json());

console.log(getPrice(product));
0.5.1

10 years ago

0.5.0

10 years ago

0.4.1

10 years ago

0.4.0

10 years ago

0.3.1

10 years ago

0.3.0

10 years ago

0.2.0

10 years ago

0.1.6

10 years ago

0.1.5

10 years ago

0.1.4

10 years ago

0.1.3

10 years ago

0.1.2

10 years ago

0.1.1

10 years ago

0.1.0

10 years ago