Ryan Bensussan Harvey Instructor in Computer Science

Useful Code Samples
COSC A319 Internet Technologies
(Fall 2020)

The following code examples may be useful.

  • logger.js - A logger module exporting two functions, log and id.

    log - provides a console.log-like facility for logging arbitrary data, but adds nanosecond times (since process start) to each log entry, helpful in understanding asynchronous operations.

    id - provides the ability to create a prefixed random hexadecimal identifier of a given length.

  • ip-formatting.js - A module exporting a single function formatIPAddress.

    formatIPAddress - a function that takes a single Buffer argument of either 4 bytes or 16 bytes length, and returns the appropriately formatted human-readable IP address, either IPv4 or IPv6. If run directly, the module executes that function on an example IPv4 and IPv6 address.