/blog notes

portfolio & contact info

Notes on Node.js

summary of the Global Objects Node.js v5.4.1 Documentation

Class:Buffer function

{ [Function: Buffer]
  poolSize: 8192,
  isBuffer: [Function: isBuffer],
  compare: [Function: compare],
  isEncoding: [Function],
  concat: [Function],
  byteLength: [Function: byteLength] }
  • function, used to handle binary data
  • TCP streams and file system
  • more info
  • usually use 'utf8' to convert into string object

__dirname string


  • dir of this js file
  • local to each module

__filename string


  • absolute file path
  • local to each module

console object

  • used to pring stdout, stderr

global object

  • unlike browsers, the top-level scope is not the global scope

module object

  • reference to current module
  • module.exports defines what is available from require()
  • lots more
Module {
  id: '.',
  exports: {},
  parent: null,
  filename: '/Users/jon/GalvanizeProjects/unit2/nodeModules.js',
  loaded: false,
  children: [],
   [ '/Users/jon/GalvanizeProjects/unit2/node_modules',
     '/node_modules' ] }

exports a reference to module.exports

  • local to each module

process object

  • global object
  • instance of EventEmitter
  • lots more
  • process.argv is an array of the command line arguments

require() function

  • to require modules
  • local to each module

setInterval(cb,ms) function

  • run cb repeatedly every ms milliseconds (at minimum)

clearInterval(t) function

  • stop a setInterval() timer, preventing callback execution
  • t is the intervalID
  • timers are global

setTimeout(cb,ms) function

  • run cb after at least ms milliseconds

clearTimeout(t) function

  • stop a setTimeout() timer, preventing callback execution