标签:http cal nload dem func git mode for ++
deno 介绍是安全的ts 运行时
console.log("demoapp")
dalongdemo
console.log("demoapp")
dalongdemo
├── rong.js
└── user
└── userlogin.ts
user/userlogin.ts
export function userlogin(){
console.log("user login")
}
rong.js
import {userlogin } from "./user/userlogin.ts";
userlogin();
deno rong.js
user login
类似golang 的包格式
remote module code
user.ts
export function userapp(){
console.log("userapp")
}
call remote module code
import {userapp} from "http://101.200.137.80/user.ts";
userapp();
Downloading http://101.200.137.80/user.ts
userapp
内置的发布订阅模型
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()");
Before deno.pub()
After deno.pub()
Got message hello
https://github.com/ry/deno
https://github.com/ry/deno/tree/master/testdata
标签:http cal nload dem func git mode for ++
原文地址:https://www.cnblogs.com/rongfengliang/p/9153035.html