小编Rob*_*sen的帖子

TypeScript modules

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 …

module typescript

12
推荐指数
1
解决办法
5266
查看次数

TypeScript定义文件

我正在使用TypesScript,但是当我使用浏览器类型(如HTMLCanvasElement)时,编译器会抱怨.我想我需要这些类型的定义文件.我打赌有一个DOM和大多数流行框架的定义文件存储库,但谷歌无法帮助我找到它.

你们知道这样的存储库吗?

definitions typescript

8
推荐指数
2
解决办法
1万
查看次数

读取node.js中的二进制数据

我在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)

javascript binary node.js

6
推荐指数
2
解决办法
2万
查看次数

如何知道客户端何时在 Flask 应用程序中断开连接

我正在尝试使用 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 请求。有没有办法知道客户端是否关闭了他的连接?

python connection long-polling flask

6
推荐指数
0
解决办法
1001
查看次数

为什么 PowerShell 不能正确排序字符串?

我想在 powershell 中对字符串列表进行排序,但是当我尝试这样做时,我得到的结果根本没有排序。

  PS C:\Windows\system32> "bbb", "aaa", "ccc" | sort
    bbb
    ccc
    aaa

Run Code Online (Sandbox Code Playgroud)

难道我做错了什么?

sorting string powershell

2
推荐指数
1
解决办法
73
查看次数