Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

smd

Package Overview
Dependencies
Maintainers
1
Versions
1
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

smd

Represent dates as tiny numbers, losing precision, for compact storage.

  • 0.1.1
  • latest
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
1
decreased by-50%
Maintainers
1
Weekly downloads
 
Created
Source

smd - Small Dates Build Status

Represents dates as 3-bytes in msgpack. We assume dates after 1970, and reasonably close to 'now'. Their best use is for fairly short-lived expiration dates (months), which don't require incredible precision (nearest hour or nearest minute is fine). These constraints yield a compression of around 66%, which is fantastic for the intended uses.

Examples

var SmD = require('smd');

var s = SmD.now();
// => 53391
var l = SmD.at(s);
// => 1371855692507
var d = SmD.date(s);
// => Fri Jun 21 2013 19:01:32 GMT-0400 (EDT)
var SmD = require('smd')
  , msg = require('msgpack');

var d = Date.now();
// => 1371855692507
var s = SmD.from(d);
// => 53391

msg.pack(d);
// => <SlowBuffer cb 42 73 f6 8f 8a 2d b0 00>
msg.pack(r);
// => Pack <SlowBuffer cd d0 8f>

License

MIT. See LICENSE for details.

Keywords

FAQs

Package last updated on 22 Jun 2013

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc