Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8707439
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 13, 20262026-06-13T03:52:15+00:00 2026-06-13T03:52:15+00:00

I’m trying to wrap my head around Node.js streams, not that I’m pretty new

  • 0

I’m trying to wrap my head around Node.js streams, not that I’m pretty new to JavaScript and node, the last languages I really got were Perl and PHP 😀

I’ve read the Buffer/Streams documentation @ nodejs.org, watched James Halliday @ LXJS, read his stream-handbook and Thorsten Lorenz event-stream post. I start to understand the basics 🙂

I process data which is serialized in RDF (which is neither JSON nor XML). I manage to fetch the data (in real code via request) and parse it into a JS object using rdfstore module.

So far I do this:

s.createReadStream('myRDFdata.ttl').pipe(serialize()).pipe(process.stdout);

Where serialize()does the job of parsing an serializing the code at the same time right now. I use through module to interface to the stream.

Now I have some more methods (not the real function declaration but I hope you get the point):

  • getRecipe(parsedRDF) -> takes the parsed RDF (as a JavaScript object) and tells me how to use it
  • createMeal(parsedRDF, recipe) -> takes the parsed RDF and the recipe from above and creates a new RDF object out of it
  • this new object needs to get serialized and sent to the browser
  • (In the real world getRecipe will have to do a user interaction in the browser)

I like the idea of chaining this together via pipes for higher flexibility when I enhance the code later. But I don’t want to serialize it to a RDF serialization every time but just send around the JS object. From what I’ve read in the documentation I could use the stringify module to get a string out of each step for piping it to the next step. But:

  • does this actually make sense? In terms of do I add unnecessary overhead or is this negligible?
  • I don’t see how I could give the parsedRDF to both methods with the dependency that getRecipe would have to be called first and the output is input for createMeal as well. Are there modules which help me on that?
  • It might be that I have to ask the user for the final recipe selection so I might need to send stuff to the browser there to get the final answer. Can I do something like this over sockets while the pipe is “waiting”?

I hope this shows what I’m trying to do, if not I will try to give more details/rephrase.

Update: After sleeping over it I figured out some more things:

  • It probably doesn’t make sense to serialize a format like RDF into something non-standard if there are official serialization formats. So instead of using stringify I will simply pass an official RDF serialization between the steps
  • This does imply that I parse/serialize the objects in each step and this surely does add overhead. Question is do I care? I could extend the RDF module I use to parse from stream and serialize into one
  • I can solve the problem with the dependency between getRecipe and createMeal by simply adding some information from getRecipe to parseRDF, this can be done very easily with RDF without breaking the original data model. But I would still be interested to know if I could handle dependencies like this with pipes
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-13T03:52:18+00:00Added an answer on June 13, 2026 at 3:52 am

    yes, It’s okay to make a stream of js objects,
    you just have to remember to pipe it through something that will serialize the stream again after before writing it to IO.

    I’d recomend writing a module called rdfStream that parses and serializes rdf, you would use it like this

    var rdf = require('rdf-stream')
    
    fs.createReadStream(file) //get a text stream
      .pipe(rdf.parse())      //turn it into objects 
      .pipe(transform)        //optional, do something with the objects
      .pipe(rdf.stringify())  //turn back into text
      .pipe(process.stdout)   //write to IO.
    

    and it could also be used by other people working with rdf in node, awesome!

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

That's pretty much it. I'm using Nokogiri to scrape a web page what has
I am trying to render a haml file in a javascript response like so:
I'm parsing an RSS feed that has an ’ in it. SimpleXML turns this
I need a function that will clean a strings' special characters. I do NOT
I'm trying to create an if statement in PHP that prevents a single post
Is it possible to replace javascript w/ HTML if JavaScript is not enabled on
I have a small JavaScript validation script that validates inputs based on Regex. I
I am trying to understand how to use SyndicationItem to display feed which is
Basically, what I'm trying to create is a page of div tags, each has
I'm new to using the Perl treebuilder module for HTML parsing and can't figure

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.