File tree Expand file tree Collapse file tree 4 files changed +61
-0
lines changed
Expand file tree Collapse file tree 4 files changed +61
-0
lines changed Original file line number Diff line number Diff line change @@ -59,6 +59,8 @@ deepStrictEqual(decode(encoded), object);
5959 - [ NodeJS] ( #nodejs )
6060- [ Benchmark] ( #benchmark )
6161- [ Distribution] ( #distribution )
62+ - [ NPM / npmjs.com] ( #npm--npmjscom )
63+ - [ CDN / unpkg.com] ( #cdn--unpkgcom )
6264- [ Maintenance] ( #maintenance )
6365 - [ Testing] ( #testing )
6466 - [ Continuous Integration] ( #continuous-integration )
@@ -388,6 +390,8 @@ Note that `Buffer.from()` for `JSON.stringify()` is added to emulate I/O where a
388390
389391## Distribution
390392
393+ ### NPM / npmjs.com
394+
391395The NPM package distributed in npmjs.com includes both ES2015+ and ES5 files:
392396
393397* ` dist/ ` is compiled into ES2015+
@@ -397,6 +401,16 @@ The NPM package distributed in npmjs.com includes both ES2015+ and ES5 files:
397401
398402If you use NodeJS and/or webpack, their module resolvers use the suitable one automatically.
399403
404+ ### CDN / unpkg.com
405+
406+ This library is availble via CDN:
407+
408+ ``` html
409+ <script crossorigin src =" https://unpkg.com/@msgpack/msgpack" ></script >
410+ ```
411+
412+ It loads ` MessagePack ` module to the global object.
413+
400414## Maintenance
401415
402416### Testing
Original file line number Diff line number Diff line change 1+ <!DOCTYPE html>
2+ < html lang ="en ">
3+ < head >
4+ < script src ="../dist.es5/msgpack.min.js "> </ script >
5+ < style >
6+ main {
7+ width : 80% ;
8+ margin : 20px auto;
9+ }
10+ </ style >
11+ </ head >
12+ < body >
13+ < main >
14+ < h1 > AMD for @msgpack/msgpack</ h1 >
15+ < pre > < code > <script src="https://unpkg.com/@msgpack/msgpack"></script></ code > </ pre >
16+ < script src ="./amd-example.js "> </ script >
17+ </ main >
18+ </ body >
19+ </ html >
Original file line number Diff line number Diff line change 1+ /* eslint-disable no-console */
2+ "use strict" ;
3+
4+ try {
5+ const object = {
6+ nil : null ,
7+ integer : 1 ,
8+ float : Math . PI ,
9+ string : "Hello, world!" ,
10+ binary : Uint8Array . from ( [ 1 , 2 , 3 ] ) ,
11+ array : [ 10 , 20 , 30 ] ,
12+ map : { foo : "bar" } ,
13+ timestampExt : new Date ( ) ,
14+ } ;
15+
16+ document . writeln ( "<p>input:</p>" ) ;
17+ document . writeln ( `<pre><code>${ JSON . stringify ( object , undefined , 2 ) } </code></pre>` ) ;
18+
19+ const encoded = MessagePack . encode ( object ) ;
20+
21+ document . writeln ( "<p>output:</p>" ) ;
22+ document . writeln ( `<pre><code>${ JSON . stringify ( MessagePack . decode ( encoded ) , undefined , 2 ) } </code></pre>` ) ;
23+ } catch ( e ) {
24+ console . error ( e ) ;
25+ document . write ( `<p style="color: red">${ e . constructor . name } : ${ e . message } </p>` ) ;
26+ }
Original file line number Diff line number Diff line change @@ -12,6 +12,7 @@ const config = {
1212 entry : "./src/index.ts" ,
1313 output : {
1414 path : path . resolve ( __dirname , "dist.es5" ) ,
15+ library : "MessagePack" ,
1516 libraryTarget : "umd" ,
1617 globalObject : "this" ,
1718 } ,
@@ -37,6 +38,7 @@ const config = {
3738 new webpack . DefinePlugin ( {
3839 "process.env.WASM" : JSON . stringify ( null ) , // use only MSGPACK_WASM
3940 "process.env.TEXT_ENCODING" : JSON . stringify ( "null" ) ,
41+ "process.env.TEXT_DECODER" : JSON . stringify ( null ) ,
4042 } ) ,
4143 ] ,
4244 externals : {
You can’t perform that action at this time.
0 commit comments