Node.js Snippets

The Node.js snippet collection contains JavaScript utilities for Node.js 14.x. It includes helper functions related to server-side code and filesystem operations, while general-purpose helpers can be found in the JavaScript snippet collection.

  • hashNode

    JavaScript, Node

    Creates a hash for a value using the SHA-256 algorithm. Returns a promise.

  • isDuplexStream

    JavaScript, Node

    Checks if the given argument is a duplex (readable and writable) stream.

  • isWritableStream

    JavaScript, Node

    Checks if the given argument is a writable stream.

  • isReadableStream

    JavaScript, Node

    Checks if the given argument is a readable stream.

  • readFileLines

    JavaScript, Node

    Returns an array of lines from the specified file.

  • UUIDGeneratorNode

    JavaScript, Node

    Generates a UUID in Node.JS.

  • isBrowser

    JavaScript, Browser

    Determines if the current runtime environment is a browser so that front-end modules can run on the server (Node) without throwing errors.

  • JSONToFile

    JavaScript, Node

    Writes a JSON object to a file.

  • colorize

    JavaScript, Node

    Adds special characters to text to print in color in the console (combined with console.log()).

  • isNode

    JavaScript, Node

    Determines if the current runtime environment is Node.js.

  • isStream

    JavaScript, Node

    Checks if the given argument is a stream.

  • hasFlags

    JavaScript, Node

    Checks if the current process's arguments contain the specified flags.

  • btoa

    JavaScript, Node

    Creates a base-64 encoded ASCII string from a String object in which each character in the string is treated as a byte of binary data.

  • untildify

    JavaScript, Node

    Converts a tilde path to an absolute path.

  • Did you know you can use Chrome Developer Tools to debug your Node.js code? Find out how in this short guide.