typeson-registry
Advanced tools
Comparing version 0.6.0 to 0.6.1
{ | ||
"name": "typeson-registry", | ||
"version": "0.6.0", | ||
"version": "0.6.1", | ||
"description": "Official registry for typeson type definitions", | ||
@@ -31,3 +31,4 @@ "scripts": { | ||
"base64-arraybuffer": "^0.1.5" | ||
} | ||
}, | ||
"tonicExample": "var Typeson = require('typeson');\nvar TSON = new Typeson().register(require('typeson-registry/presets/builtin'));\n\nTSON.stringify({foo: new Date()});" | ||
} |
@@ -7,3 +7,3 @@ # typeson-registry | ||
# usage | ||
# usage (node) | ||
@@ -17,2 +17,3 @@ ```js | ||
require('typeson-registry/types/typed-arrays'), | ||
// ... | ||
]); | ||
@@ -59,8 +60,61 @@ | ||
assert(parsedBack.date instanceof Date); | ||
assert(parsedBack.binary instanceof Uint8Array); | ||
assert(parsedBack.inner.bin instanceof Uint8Array); | ||
``` | ||
# usage (browser) | ||
This sample uses plain script tags. All types and presets under dist are UMD modules so you can require using requirejs as well. | ||
```html | ||
<!DOCTYPE html> | ||
<html> | ||
<head> | ||
<script src="//npmcdn.com/typeson/dist/typeson.js"></script> | ||
<script src="//npmcdn.com/typeson-registry/dist/presets/builtin.js"></script> | ||
<script> | ||
var TSON = new Typeson().register(Typeson.presets.builtin); | ||
var tson = TSON.stringify({ | ||
Hello: "world", | ||
date: new Date(), | ||
error: new Error(), | ||
inner: { | ||
x: /foo/ig, | ||
bin: new Uint8Array(64) | ||
} | ||
}, null, 2); | ||
alert(tson); | ||
/* Alerts: | ||
{ | ||
"Hello": "world", | ||
"date": 1464049031538, | ||
"error": { | ||
"name": "Error", | ||
"message": "" | ||
}, | ||
"inner": { | ||
"x": { | ||
"source": "foo", | ||
"flags": "gi" | ||
}, | ||
"bin": "AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA==" | ||
}, | ||
"$types": { | ||
"date": "Date", | ||
"error": "Error", | ||
"inner.x": "RegExp", | ||
"inner.bin": "Uint8Array" | ||
} | ||
} | ||
*/ | ||
</script> | ||
</head> | ||
</html> | ||
``` | ||
# see also | ||
* [typeson](https://github.com/dfahlander/typeson) |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
265628
118