10.node.js Core Modules

Source: Internet
Author: User

1. Global objects
2. Common Tools
3. Event mechanism
4. File system access
5.HTTP Service and Client

I. Global object, as with the Window object

Process ==> global variable, an object that describes the state of the current node. JS process, provides a simple interface for an operating system

1.PROCESS.ARGV ==> command line parameter array, the first element is node, the second element is the script file name, the third element starts each element is a run parameter
2.process.stdout ==> standard output stream, usually we use Console.log () to print characters to the standard output, while the Process.stdout.write () function provides a lower level interface.
3.process.stdin ==> is the standard input stream, initially it is paused, to read data from the standard input, you must resume the stream and manually write the stream's event response function.
The function of the 4.process.nexttick (callback) ==> is to set a task for the event loop, and node. JS calls callback the next time the event loops over the response.

function  dosomething (args, callback) {   somethingcomplicated (args);   Callback (); }  dosomething (function  onEnd () {   compute ();});//Process.nexttick () provides a tool to break up complex work into smaller events. The rewritten program splits the time-consuming operation into two events, reducing the execution times of each event and increasing the response speed of the event. function  dosomething (args, callback) {   somethingcomplicated (args);   Process.nexttick (callback); }  dosomething (function  onEnd () {   

5. Besides, the process also shows the methods of Process.platform, Process.pid, Process.execpath, Process.memoryusage (), etc.

Two. Common Tools util

1.util.inherits ==> between Objects 2.util.inspect ==> is a method of converting any object to a string, typically for debugging and error output. It accepts at least one parameter, object, which is to be converted. ShowHidden is an optional parameter, and if the value is  true, more hidden information will be output. 3. Four types of test Tools 3.util.isarray () 4.util.isregexp () 5.util.isdate () 6.util.iserror () 7.util.format () 8.util.debug ()

Http://nodejs.org/api/util.html Learn more.

10.node.js Core Modules

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.