Information flows from one place to another place as a stream of bits. For example, this happens when two peers talking to each other via a network, or even when your application is communicating with the disk or a peripheral device. When such an I/O operation happens, the information is read from a device and is flowed towards an application, or vice versa.
However, it’s possible that one end of the above transaction is slower than the other for various reasons. Therefore, some of the data might need to be “buffered” in-between, while the receiver-end is ready to accept more data.
Have a look at the following picture where two faucets of different sizes are connected via a tank. The rate water flows from upstream is higher than the rate downstream can consume. Therefore, the tank has to temporarily store (“buffer”) the excess water while the downstream slowly consumes.
This is the fundamental idea of streams in NodeJS. stream module provides functionality to implement this behaviour when working with streaming data. There are two basic types of streams provided by NodeJS.
They are,
However, there are two additional types of streams which are hybrids of Readable and Writable streams, and serve special purposes.
Let’s get into more details, and try to visualise each of these.
Readable Stream
A readable stream can be used to read data from an underlying source such as a file descriptor. Data can be stored in a Buffer within the readable stream if the application consumes slower than the operating system reads from the source.
A few of the most common readable streams in NodeJS are process.stdin, fs.createReadStream and IncomingMessage object in an HTTP server.
Writable Stream
A Writable stream is used to write data from an application to a certain destination. To prevent data loss or overwhelming of the destination in case the destination is slower than the writing application, the data may be stored in an internal Buffer.
Duplex Stream
As I mentioned earlier, a duplex stream is a hybrid of a Readable stream and a Writable stream. An application connected to a duplex stream can both read from and write to the duplex stream. The most common example of a duplex stream is net.Socket. In a duplex stream, read and write parts are independent and have their own buffers.
Transform Stream
A transform stream is an even special hybrid, where the Readable part is connected to the Writable part in some way. A common example would be a crypto stream created using Cipher class. In this case, the application writes the plain data into the stream and reads encrypted data from the same stream.
]]>On one hand, business teams use task management tools – online task management tools like Asana and Trello can help you stay on top of your to-do lists, project progress, and calendars. They use collaborative tools so everyone the your team knows what’s been done, what’s outstanding, and who has been assigned to the task. Social Media Scheduling Tools are also of great help to business workers. For example, Buffer and HootSuite allow you to schedule posts to go out on the desired dates and times, without setting foot on the actual social media sites themselves, avoiding that distraction, as well as pump out your promotions right when you want them so you can grow your business. Setting up meetings can mean lots of emailing back and forth to find a mutually agreed upon time. Scheduling tools like Calendly and Acuity can help automate the process of setting up meetings.
On the other hand, tech teams use many kinds of tools to help them perform their tasks, such as collaboration tools, thanks to which the members of each team communicate with each other. For example, Microsoft teams. They also use project management tools like Microsoft project and Workfront, document co-creation tools that allow you to chat in real-time with your team members, like Skype. Scheduling tools are very important not only for business workers, but for software developers as well. Some of the most used scheduling tools are Doodle and ScheduleOnce.
What’s principal in the collaboration between business and software teams is open communication with each of the sides and focusing on building a great product together. This might seem like a simple task to perform, but, in fact, it can be very difficult. Gathering people in a group and making them create and innovate things is not quite easy, but with the right approach and patience, by making sure that each team is updated and involved in the process, the both the business and software teams will eventually learn how to work better together. One of the most important “rules” to follow is to measure the teams by their results, not by the time they spend in the office. Both the software and business team can have a parallel set of goals to guide each other and move forward.
Tools like Asana, Trello and GitHub are all useful tools, which the tech team can use to manage their work. These can all be visible online, and similar to Google’s OKR (Objectives and Key Results), will help to guide both the software and business team forward.
To conclude, with the right approach to each worker, with open communication, and of course, the right tools – great success can be achieved and products of good quality can be created.
Share your experience at [email protected]
]]>