value-type

little type system for values

npm install value-type
4 downloads in the last month

value-type

Annotates a value by wrapping it with a type label. Kinda handy for passing around mixed typed query parameter values over urls when you don't want to use JSON.

Installation

component

  $ component install gjohnson/value-type

or

npm

  $ npm install value-type

Example

var vt = require('value-type');
var assert = require('better-assert');

var str = qs.stringify({
  name: vt.encode('foobar'),
  number: vt.encode(100),
  email: vt.encode(null)
});

var expected = 'name=$1(foobar)&number=$2(100)&email=$4(null)';
assert(decodeURIComponent(str) == expected);

License

MIT

npm loves you