you should adapt this to follow the node.js stream api.
nodejs.org/api/stream.html
then it'll be a lot more useful because it will be compatible with
every sort of io module in node. for example, then you'd be able to
just do this:
read from a file:
var scope = {}
fs.createReadStream(file).pipe(new VarStream(scope, true))
.on('end', function () {console.log(scope)})
or write to a file
new VarStream(scope).pipe(fs.createWriteStream(file))
unfortunately, most websocket libraries do not follow the node.js
stream api (YET!).
but here is one: https://github.com/substack/shoe
On Tue, Jul 10, 2012 at 4:18 AM, Nicolas FROIDURE
<[email protected]> wrote:
> A small message to inform you of the creations of a new module called
> VarStream and recently published in npm.
>
> The idea behind VarStream is to linearize variables to be able to read them
> inside a stream sequentially instead of wait the datas to be fully loaded
> like with JSON or XML. It also allows to merge multiple stream sources for
> more flexibility.
>
> VarStream is also human readable, allowing to use it as a configuration and
> localization file format.
>
> Here is the repository : https://github.com/nfroidure/VarStream
> Here is a proof of concept use case that use VarStreams to synchronize
> variables beetween clients using web sockets :
> https://github.com/nfroidure/WebSockIPC
>
> I would like to have advices on VarStreams and pull requests since i'm new
> to NodeJS, it probably needs some improvements.
>
> --
> Job Board: http://jobs.nodejs.org/
> Posting guidelines:
> https://github.com/joyent/node/wiki/Mailing-List-Posting-Guidelines
> You received this message because you are subscribed to the Google
> Groups "nodejs" group.
> To post to this group, send email to [email protected]
> To unsubscribe from this group, send email to
> [email protected]
> For more options, visit this group at
> http://groups.google.com/group/nodejs?hl=en?hl=en
--
Job Board: http://jobs.nodejs.org/
Posting guidelines:
https://github.com/joyent/node/wiki/Mailing-List-Posting-Guidelines
You received this message because you are subscribed to the Google
Groups "nodejs" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/nodejs?hl=en?hl=en