JSPM

larvitutils

0.4.3
  • ESM via JSPM
  • ES Module Entrypoint
  • Export Map
  • Keywords
  • License
  • Repository URL
  • TypeScript Types
  • README
  • Created
  • Published
  • Downloads 3320
  • Score
    100M100P100Q110445F
  • License MIT

Misc utilites

Package Exports

  • larvitutils

This package does not declare an exports field, so the exports above have been automatically detected and optimized by JSPM instead. If any package subpath is missing, it is recommended to post an issue to the original package (larvitutils) to support the "exports" field. If that is not possible, create a JSPM override to customize the exports field for this package.

Readme

Build Status Dependencies

larvitutils

Misc utilities

Convert a buffer to an Uuid

var utils = require('larvitutils'),
    uuid  = utils.formatUuid(new Buffer('f9684592b24542fa88c69f16b9236ac3', 'hex'));

console.log(uuid); // f9684592-b245-42fa-88c6-9f16b9236ac3

Example usecase: fetch a binary column from a database and convert to a readable Uuid string

Format a hex string to uuid

var utils = require('larvitutils'),
    uuid  = utils.formatUuid(' f9684592b24542fa88c69f16b9236ac3'); // Notice the starting space getting trimmed away

console.log(uuid); // f9684592-b245-42fa-88c6-9f16b9236ac3

hrtimeToMs()

Used to convert hrtime() calls to milliseconds, since hrtime() output is messy (seconrds + nanoseconrds)

Usage:

var utils     = require('larvitutils'),
    startTime = process.hrtime();

setTimeout(function() {
    console.log('benchmark took %d ms', utils.hrtimeToMs(startTime, 4));
    // benchmark took 34.0005 ms
}, 34);

Uuid string to buffer

var utils   = require('larvitutils'),
    uuidStr = 'f9684592-b245-42fa-88c6-9f16b9236ac3';

utils.uuidToBuffer(uuidStr); // Will return a buffer