npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2025 – Pkg Stats / Ryan Hefner

time-hash

v1.2.2

Published

UTC/GMT Time Hash for milliseconds/timestamps

Downloads

29

Readme

timehash

About

timehash is an algorithm (with multiple reference implementations) for calculating variable precision sliding windows of time. When performing aggregations and correlations on large-scale data sets, the ability to convert precise time values into 'malleable intervals' allows for many novel analytics.

Using `sliding windows of time is a common practice in data analysis but prior to the timehash algorithm it was more of an art than a science. -- abeusher/timehash

Installation

npm install time-hash -s

npm install

npm run:cover

Usage

Version 1.2.0 Update

Improved browser compatability in Rollup

Version 1.1.1 Update

    timehash.encodems(new Date().getTime()) // encodes from milliseconds epoch instead of timeseconds
    timehash.decodems('000000000b') // decodes to milliseconds epoch instead of timeseconds

reason: Better compatability with Javascript Date() functions

Version 1.0

    var TimeHash = require('time-hash') // or import TimeHash from 'time-hash'

    let timehash = new TimeHash()

    let [begin, cease] = ['1970-01-01 00:00:00 GMT', '2098-01-01 00:00:00 GMT'] // should use UTC/GMT
    
    let begin_input = new Date(begin) 
    let pivot_input = new Date('2034-01-01 00:00:00 GMT') 
    let cease_input = new Date(cease)

    let begin_hash = timehash.encode_from_datetime(begin_input)
    let pivot_hash = timehash.encode_from_datetime(pivot_input)
    let cease_hash = timehash.encode_from_datetime(cease_input)

    `${begin_hash}`
    '0000000000'
    
    `${pivot_hash}`
    'bfffffffff'
    
    `${cease_hash}`
    'ffffffffff'
    
    begin_hash_after = timehash.after(begin_hash)
    `${begin_hash_after}`
    '0000000001'
    `${timehash.before(begin_hash_after)}` === begin_hash

    let [neighbor_before, neighbor_after] = timehash.neighbors('000000000a')
    `${timehash.before(neighbor_before)}` === begin_hash
    `${neighbor_after}` === '000000000b'

    let input = '000000000a'
    let expand = timehash.expand(input)
    let [expand_before, input_clone, expand_after] = expand
    `${expand_before}` === timehash.before(input_clone)
    `${expand_after}` === timehash.after(input_clone)

    let [begin_value, begin_error] = timehash.decode_exactly('0000000000')
    new Date(begin_value - begin_error).toString() === begin_input.toString()

Other Compatible Implementations

  • python timehash
    • a reference implementation in pure python
  • perl timehash
    • a reference implementation in perl
  • java timehash
    • a reference implementation in java

License

Copyright © 2017 LoreFolk, LLC. This source code is licensed under the MIT license found in the LICENSE.txt file. The documentation to the project is licensed under the CC BY-SA 4.0 license.


Reference implement made with ♥ by Abe Usher Abe Usher and [contributors] (https://github.com/abeusher/timehash/blob/master/CONTRIBUTORS.md)

Testing/DepoymentTemplate made with ♥ by Konstantin Tarkus (@koistya) and contributors