Use LEFT and RIGHT arrow keys to navigate between flashcards;
Use UP and DOWN arrow keys to flip the card;
H to show hint;
A reads text to speech;
8 Cards in this Set
- Front
- Back
Order of param in nodes callbacks? |
The first param of a callback you sent to a node's function is an error. The last param of a node's function is the callback. |
|
How to inherit? |
var util = require("util"); util.inherit(ChildClass, ParentClass); |
|
Events and interface of a ReadableStream? |
property: readable [boolean] event:'data' event:'end' event:'error' event:'close' pause() resume() destroy() pipe() |
|
Events and interface of a WriteableStream? |
property: writable[boolean] event:'drain' event: 'error' event: 'close' event: 'pipe' write() end() destroy() destroySoon() |
|
How do you read content from a file? |
fs.readFile(path, callback). The callback receives a Buffer class as a 2nd param, and you can call .toString(encoding:string ,startChar:int, numOfChar:int). |
|
How do to easily write a string to a file a file? |
fs.writeFile(path,string|buffer, callback). This will either create or overwrite the file. fs.appendFile(path,string|buffer, callback) . This will append to the end. |
|
Difference between http and request modules? |
- http doesn't follow redirects. |
|
What is diff betwee spawn, exec, fork? |
execFile: Runs a program, waits for it to finish, and when it finished returns the answer in a buffer. Use: When you just care about the final output and just want to know if succeed or not.
spawn: Runs a program in a new process. It returns a Writable and readable stream to communicate in real time. Use: When you need to communicate with the other program and large amounts of data needs to be exchanged.
exec: This will span a new shell and run a command on it and return a buffer with the result. Use: When you need to use shell functionalities like pipe, redirect and run things in background.
fork: Its like spawn, but is has some utilities for communicating with a 2 node proceesss. Uses: When the child command is another Node instance. It has process.send and "message" event emmited by process object.
|