I am wondering if it is possible somehow to have two or more classes in two or more files added to the same module in TypeScript. Something like this:
//src/gui/uielement.ts
module mylib {
module gui {
export interface UIElement {
public draw() : void;
}
}
}
//src/gui/button.ts
///<reference path='uielement.ts'/>
module mylib {
module gui {
export class Button implements UIElement {
constructor(public str : string) { }
draw() : void { }
}
}
}
Run Code Online (Sandbox Code Playgroud)
There will probably be …
我正在使用TypesScript,但是当我使用浏览器类型(如HTMLCanvasElement)时,编译器会抱怨.我想我需要这些类型的定义文件.我打赌有一个DOM和大多数流行框架的定义文件存储库,但谷歌无法帮助我找到它.
你们知道这样的存储库吗?
我在node.js中读取二进制数据时遇到问题.这就是我做的:
$ cat test.js
var fs = require('fs'),
binary = fs.readFileSync('./binary', 'binary').toString('binary');
process.stdout.write(binary.substring(0, 48));
$ xxd binary
00000000: 7f45 4c46 0201 0100 0000 0000 0000 0000 .ELF............
00000010: 0300 3e00 0100 0000 0008 0000 0000 0000 ..>.............
00000020: 4000 0000 0000 0000 10a0 0000 0000 0000 @...............
$ node test.js | xxd
00000000: 7f45 4c46 0201 0100 0000 0000 0000 0000 .ELF............
00000010: 0300 3e00 0100 0000 0008 0000 0000 0000 ..>.............
00000020: 4000 0000 0000 0000 10c2 a000 0000 …Run Code Online (Sandbox Code Playgroud) 我正在尝试使用 HTTP 长轮询,大致是这样的:
@app.route('/get_stuff', methods=["GET"])
def get_stuff():
while True:
stuff = database.lookupSomething()
if stuff:
return json.dumps(stuff)
else:
time.sleep(1)
Run Code Online (Sandbox Code Playgroud)
这非常有效,但是如果客户端切断连接,服务器仍将运行循环。我想用这样的东西替换循环:
while client.is_connected():
....
Run Code Online (Sandbox Code Playgroud)
但是,我找不到任何方法来知道连接是否仍然有效。其他人也问过同样的问题,答案一直是使用SocketIO。但是,我不能这样做,而宁愿使用像上面这样的简单 GET 请求。有没有办法知道客户端是否关闭了他的连接?
我想在 powershell 中对字符串列表进行排序,但是当我尝试这样做时,我得到的结果根本没有排序。
PS C:\Windows\system32> "bbb", "aaa", "ccc" | sort
bbb
ccc
aaa
Run Code Online (Sandbox Code Playgroud)
难道我做错了什么?
typescript ×2
binary ×1
connection ×1
definitions ×1
flask ×1
javascript ×1
long-polling ×1
module ×1
node.js ×1
powershell ×1
python ×1
sorting ×1
string ×1