value-type

little type system for values

Usage no npm install needed!

<script type="module">
  import valueType from 'https://cdn.skypack.dev/value-type';
</script>

README

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