KO
|
EN
gitlite — search
Search
#python
#java
#python3
#arduino
#golang
#machine-learning
#rust
#html
#flask
#javascript
#seismology
#nodejs
stream-set
★ 26
Open GitHub ↗
Maintain a set of open streams
Download README (.md)
Explore Similar Repositories
brucezhaor.github.io
:
Bruce Zhao's Blog
LLMListView
:
super list view for uwp
AssetsPickerToUpLoad
:
媒体(文件)上传库 - 串行和并发 - IOS客户端 (带PHP脚本测试)
django-docker-compose
:
A production oriented dockerized django app
FaceLibarayServer
:
使用OpenCV与C++ Socket实现的人脸识别系统服务器
// repository documentation
Was this content helpful?
★ 0
(0 ratings)
Select Rating:
★
★
★
★
★
Submit Feedback
Recent Feedback
×
Download README
Do you want to download the
README.md
file for
stream-set
?
Download (.md)
# stream-set Maintain a set of open streams ``` npm install stream-set ``` [](http://travis-ci.org/mafintosh/stream-set) ## Usage ``` js var streamSet = require('stream-set') var net = require('net') var activeSockets = streamSet() var server = net.createServer(function (socket) { // when the socket ends/errors it will automatically be removed from the set activeSockets.add(socket) // will print "set size is 1" console.log('set size is', activeSockets.size) socket.on('close', function () { // will print "set size is 0" console.log('set size is', activeSockets.size) }) }) server.listen(10000, function () { var socket = net.connect(10000) // connect and destroy socket.on('connect', function () { socket.destroy() }) }) ``` ## API #### `var set = streamSet()` Create a new set #### `set.add(stream)` Add a stream to the set. If the stream ends/errors it will be removed from the set #### `set.remove(stream)` Manually remove a stream from the set #### `set.has(stream)` Check if a stream is in the set #### `set.streams` An array of streams in the set #### `set.size` The current size of the set #### `set.forEach(fn)` Iterate over all streams in the set #### `stream = set.get(index)` Get a stream from the set ## License MIT