The node stream module and making custom readable and writable streams

So I have wrote a few posts on streams when it comes to the create read stream and create write stream file system module methods, as well as many other such methods in various native nodejs modules. However I have not wrote much on the node stream module by itself, and how to go about using that module to make my own custom streams. Also it is important to know a thing or two about this module and the nature of streams in general when it comes to working on nodejs projects. So I thought I would put together a piece of content in which I am focusing on the node stream module and custom made streams, rather than something else in nodejs that inherits from the base classes in this module.

Read More

The node fork child process method.

I have been doing a lot of work revolving the use of the child process module as of late, so I thought I would write some demos about the node fork child process method. This node fork method does not launch a copy of the current process, but it does start a new node process with the given external script given as the first argument. It is similar to other methods in the child process module such as spawn, but it is set up a little different by default, and might be a better alternative to using spawn when it comes to launching an additional node process on the host os.

Read More

The buffer write method for writing to buffers in nodejs.

The buffer write method in the nodejs buffer global can be used to write data to a buffer that has been created before hand one way of another. There are a few basics to cover when it comes to putting data into a buffer such as encoding and byte index values. So I thought I would write a quick post on the buffer write prototype method in nodejs. In addition to this I may branch off with some other related topics on buffers in general.

Read More

The buffer length property and data length in nodejs

When working with arrays the length property is not really a good way to go about getting the data length of a string. The reason why is because of the nature of Unicode. However in nodejs when working with buffers the buffer length property of a buffer can be used to get the amount of memory that the buffer is taking up at least.

In addition if buffers are used the right way buffer length can be used as a way to get the actual data size of a string. When doing so it is impotent to be aware of the encoding that is used when creating the buffer in the first place. However if the correct encoding is used the length of the buffer should be the data size of the string. So this will be a quick post on the buffer length property in nodejs and some related topic when it comes to array length.

Read More

The node spawn child process method in action

I find myself using the node spawn child process module method often when it comes to calling external commands in a nodejs project. However still have not mastered all the little aspects of this method as well as the child process module in general. So one way to go about getting more proficient on the subject would be to write a whole bunch of little demos on the node span method and write a post on them.

The spawn method can be used as a way to call external commands that there might be to work with in the host operating system. The availability of these commands will change of course depending one the host operating system, and what might be installed to work with.

Te spawn method is one of two methods that come to mind in the built in nodejs module that have to do with calling external commands. The other method of interest in the child process module would be the exec method. This method works in more or less the same way as spawn, only the whole command options and all can be given via a single argument as a string.

Read More