# node-typesafe

> Typesafe data structures for Javascript

Latest version **0.5.1** (published 2014-04-24) · MIT License license · 0 weekly downloads

## Install

```sh
npm install node-typesafe
pnpm add node-typesafe
yarn add node-typesafe
bun add node-typesafe
```

## Health

**Score 15/100 (F)** — status: abandoned.

Positive: no vulnerabilities.

Warnings: low downloads; no types; no esm support; pre 1.0.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 0.5.1 |
| Published | 2014-04-24 |
| First published | 2014-04-17 |
| Weekly downloads | 0 |
| License | MIT License |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 1 |
| Known vulnerabilities | 0 (+3 in 1 direct dependencies) |
| Install scripts | no |
| Author | Adrian Punga |
| Maintainers | sqreept |
| Keywords | typesafe, javascript, data, structures |

## Links

- npm: https://www.npmjs.com/package/node-typesafe
- Repository: https://github.com/sqreept/node-typesafe
- Issues: https://github.com/sqreept/node-typesafe/issues
- npm.io page: https://npm.io/package/node-typesafe

## Dependencies (1)

- [moment](https://npm.io/package/moment.md) ~2.6.0

## Alternatives

- [gamedig](https://npm.io/package/gamedig.md) — 29.3K weekly downloads
- [join-monster](https://npm.io/package/join-monster.md) — 12.8K weekly downloads
- [masked](https://npm.io/package/masked.md) — 5.5K weekly downloads
- [@comunica/actor-query-process-explain-logical](https://npm.io/package/@comunica/actor-query-process-explain-logical.md) — 4.7K weekly downloads
- [@veracity/vui](https://npm.io/package/@veracity/vui.md) — 4.6K weekly downloads

## Recent versions

- 0.5.1 (latest) — 2014-04-24
- 0.5.0 — 2014-04-24
- 0.4.1 — 2014-04-24
- 0.4.0 — 2014-04-24
- 0.3.1 — 2014-04-23
- 0.3.0 — 2014-04-21
- 0.2.0 — 2014-04-20
- 0.1.6 — 2014-04-19
- 0.1.5 — 2014-04-19
- 0.1.4 — 2014-04-18
- 0.1.3 — 2014-04-18
- 0.1.2 — 2014-04-18
- 0.1.1 — 2014-04-17
- 0.1.0 — 2014-04-17

## README

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));

```

---
_Source: https://npm.io/package/node-typesafe · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
