From 3171ba4c3ff4046aaca0d70321f1dfec4c0728bb Mon Sep 17 00:00:00 2001 From: Ryan Dahl Date: Wed, 23 May 2018 16:45:01 -0400 Subject: Add special deno module to public api --- testdata/009_pub_sub.ts | 18 ++++++++++++++++++ testdata/009_pub_sub.ts.out | 3 +++ 2 files changed, 21 insertions(+) create mode 100644 testdata/009_pub_sub.ts create mode 100644 testdata/009_pub_sub.ts.out (limited to 'testdata') diff --git a/testdata/009_pub_sub.ts b/testdata/009_pub_sub.ts new file mode 100644 index 000000000..3d33c820d --- /dev/null +++ b/testdata/009_pub_sub.ts @@ -0,0 +1,18 @@ +import * as deno from "deno"; + +deno.sub("echo", (ui8: Uint8Array) => { + const str = String.fromCharCode.apply(null, ui8); + console.log("Got message", str); +}); + +function str2ui8(str: string): Uint8Array { + const ui8 = new Uint8Array(str.length); + for (let i = 0; i < str.length; i++) { + ui8[i] = str.charCodeAt(i); + } + return ui8; +} + +console.log("Before deno.pub()"); +deno.pub("echo", str2ui8("hello")); +console.log("After deno.pub()"); diff --git a/testdata/009_pub_sub.ts.out b/testdata/009_pub_sub.ts.out new file mode 100644 index 000000000..d5581cafb --- /dev/null +++ b/testdata/009_pub_sub.ts.out @@ -0,0 +1,3 @@ +Before deno.pub() +After deno.pub() +Got message hello -- cgit v1.2.3