lexicographic-timestamp

0.0.2 • Public • Published

Adds lexicographically sortable timestamps to objects.

The following example places timestamps on objects. The object will have a key named 'key' and its value will be a lexicographically sortable timestamp.

 
var timestamp    = require('lexicographic-timestamp');
var timestamper  = timestamp.timestampStream(16, 9, 'key');
var JSONStream   = require('JSONStream');
 
var stringify    = JSONStream.stringify(false);
 
timestamper.pipe(stringify).pipe(process.stdout);
 
timestamper.write({value : 'hello wisconsin'});
 

Streams the following to stdout

{"value":"hello wisconsin","key":"0001427769510483.000000000"}

Notice the integer part has 16 characters with leading zeros and the fractional part has 9 characters. This format allows sortable references dating back to the 1970s.

/lexicographic-timestamp/

    Package Sidebar

    Install

    npm i lexicographic-timestamp

    Weekly Downloads

    6

    Version

    0.0.2

    License

    BSD3

    Last publish

    Collaborators

    • lakowske