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 🙏

© 2024 – Pkg Stats / Ryan Hefner

hyperlog-calendar-index

v2.1.1

Published

hyperlog index for recurring and one-time events

Downloads

25

Readme

hyperlog-calendar-index

hyperlog index for recurring and one-time events

example

var hyperlog = require('hyperlog')
var memdb = require('memdb')
var xtend = require('xtend')
var cali = require('hyperlog-calendar-index')

var log = hyperlog(memdb(), { valueEncoding: 'json' })
var cal = cali({
  log: log,
  db: memdb(),
  map: function (row, next) {
    next(null, xtend(row, {
      type: 'put',
      time: row.value.time,
      created: row.value.created,
      value: { title: row.value.title }
    }))
  }
})
log.add(null, {
  title: 'javascript study group',
  time: 'every thursday at 7pm'
})
log.add(null, {
  title: 'hardware hack night',
  time: 'every tuesday at 7pm'
})
log.add(null, {
  title: 'cyberwizard institute',
  time: 'every day at 12:00 starting jan 15 until feb 10',
  created: '2015-12-25'
})

cal.query({
  gt: '2016-01-01',
  lt: '2016-01-31'
}).on('data', console.log)

output:

{ key: '5d368ce0cd31345a9bf9a0b2cb870460a2b1a1adbb651af1323afec1c0a1458f',
  time: Tue Jan 05 2016 19:00:00 GMT+0100 (CET),
  value: { title: 'hardware hack night' } }
{ key: 'c4c5ecdb896d0a13777d701e3dc8bed3e64a2b54812c9f8537c540bdef699fde',
  time: Thu Jan 07 2016 19:00:00 GMT+0100 (CET),
  value: { title: 'javascript study group' } }
{ key: '5d368ce0cd31345a9bf9a0b2cb870460a2b1a1adbb651af1323afec1c0a1458f',
  time: Tue Jan 12 2016 19:00:00 GMT+0100 (CET),
  value: { title: 'hardware hack night' } }
{ key: 'c4c5ecdb896d0a13777d701e3dc8bed3e64a2b54812c9f8537c540bdef699fde',
  time: Thu Jan 14 2016 19:00:00 GMT+0100 (CET),
  value: { title: 'javascript study group' } }
{ key: 'b293200589c8fc5c127b9fbe5901e0c102623598a797b8a204b1d8a1439d90cd',
  time: Fri Jan 15 2016 12:00:00 GMT+0100 (CET),
  value: { title: 'cyberwizard institute' } }
{ key: 'b293200589c8fc5c127b9fbe5901e0c102623598a797b8a204b1d8a1439d90cd',
  time: Sat Jan 16 2016 12:00:00 GMT+0100 (CET),
  value: { title: 'cyberwizard institute' } }
{ key: 'b293200589c8fc5c127b9fbe5901e0c102623598a797b8a204b1d8a1439d90cd',
  time: Sun Jan 17 2016 12:00:00 GMT+0100 (CET),
  value: { title: 'cyberwizard institute' } }
{ key: 'b293200589c8fc5c127b9fbe5901e0c102623598a797b8a204b1d8a1439d90cd',
  time: Mon Jan 18 2016 12:00:00 GMT+0100 (CET),
  value: { title: 'cyberwizard institute' } }
{ key: 'b293200589c8fc5c127b9fbe5901e0c102623598a797b8a204b1d8a1439d90cd',
  time: Tue Jan 19 2016 12:00:00 GMT+0100 (CET),
  value: { title: 'cyberwizard institute' } }
{ key: '5d368ce0cd31345a9bf9a0b2cb870460a2b1a1adbb651af1323afec1c0a1458f',
  time: Tue Jan 19 2016 19:00:00 GMT+0100 (CET),
  value: { title: 'hardware hack night' } }
{ key: 'b293200589c8fc5c127b9fbe5901e0c102623598a797b8a204b1d8a1439d90cd',
  time: Wed Jan 20 2016 12:00:00 GMT+0100 (CET),
  value: { title: 'cyberwizard institute' } }
{ key: 'b293200589c8fc5c127b9fbe5901e0c102623598a797b8a204b1d8a1439d90cd',
  time: Thu Jan 21 2016 12:00:00 GMT+0100 (CET),
  value: { title: 'cyberwizard institute' } }
{ key: 'c4c5ecdb896d0a13777d701e3dc8bed3e64a2b54812c9f8537c540bdef699fde',
  time: Thu Jan 21 2016 19:00:00 GMT+0100 (CET),
  value: { title: 'javascript study group' } }
{ key: 'b293200589c8fc5c127b9fbe5901e0c102623598a797b8a204b1d8a1439d90cd',
  time: Fri Jan 22 2016 12:00:00 GMT+0100 (CET),
  value: { title: 'cyberwizard institute' } }
{ key: 'b293200589c8fc5c127b9fbe5901e0c102623598a797b8a204b1d8a1439d90cd',
  time: Sat Jan 23 2016 12:00:00 GMT+0100 (CET),
  value: { title: 'cyberwizard institute' } }
{ key: 'b293200589c8fc5c127b9fbe5901e0c102623598a797b8a204b1d8a1439d90cd',
  time: Sun Jan 24 2016 12:00:00 GMT+0100 (CET),
  value: { title: 'cyberwizard institute' } }
{ key: 'b293200589c8fc5c127b9fbe5901e0c102623598a797b8a204b1d8a1439d90cd',
  time: Mon Jan 25 2016 12:00:00 GMT+0100 (CET),
  value: { title: 'cyberwizard institute' } }
{ key: 'b293200589c8fc5c127b9fbe5901e0c102623598a797b8a204b1d8a1439d90cd',
  time: Tue Jan 26 2016 12:00:00 GMT+0100 (CET),
  value: { title: 'cyberwizard institute' } }
{ key: '5d368ce0cd31345a9bf9a0b2cb870460a2b1a1adbb651af1323afec1c0a1458f',
  time: Tue Jan 26 2016 19:00:00 GMT+0100 (CET),
  value: { title: 'hardware hack night' } }
{ key: 'b293200589c8fc5c127b9fbe5901e0c102623598a797b8a204b1d8a1439d90cd',
  time: Wed Jan 27 2016 12:00:00 GMT+0100 (CET),
  value: { title: 'cyberwizard institute' } }
{ key: 'b293200589c8fc5c127b9fbe5901e0c102623598a797b8a204b1d8a1439d90cd',
  time: Thu Jan 28 2016 12:00:00 GMT+0100 (CET),
  value: { title: 'cyberwizard institute' } }
{ key: 'c4c5ecdb896d0a13777d701e3dc8bed3e64a2b54812c9f8537c540bdef699fde',
  time: Thu Jan 28 2016 19:00:00 GMT+0100 (CET),
  value: { title: 'javascript study group' } }
{ key: 'b293200589c8fc5c127b9fbe5901e0c102623598a797b8a204b1d8a1439d90cd',
  time: Fri Jan 29 2016 12:00:00 GMT+0100 (CET),
  value: { title: 'cyberwizard institute' } }
{ key: 'b293200589c8fc5c127b9fbe5901e0c102623598a797b8a204b1d8a1439d90cd',
  time: Sat Jan 30 2016 12:00:00 GMT+0100 (CET),
  value: { title: 'cyberwizard institute' } }

api

var cali = require('hyperlog-calendar-index')

var cal = cali(opts)

opts are:

  • opts.log - a hyperlog to index

  • opts.db - a leveldb to use for index storage

  • opts.map(row, next) - a function that is called with each row in the hyperlog and should call next(err, doc) with a falsy value or a doc object:

  • doc.type - 'put' or 'del' (default: 'put')

  • doc.time - the time string of the event

  • doc.created - the time (string or Date object) that the doc.time time string is relative to

  • doc.value - an additional value to associate with the event (default: {})

If you need to delete a record, all your map function needs to provide is a document with: { type: 'del' }.

The default map function is function (row) { return row.value }.

cal.ready(fn)

Calls fn() when the index is caught up.

cal.query(opts, cb)

Return a readable stream of all events between opts.gt and opts.lt, including all instances of recurring events.

If cb is given, cb(err, results) fires with an array of all the results.

install

npm install hyperlog-calendar-index

license

BSD