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

fitbit-schedule

v1.0.1

Published

Schedule persistent recurring and non-recurring events on Fitbit OS.

Downloads

37

Readme

Fitbit Schedule

Fitbit Schedule allows you to schedule persistent recurring and non-recurring events on Fitbit OS. This module is useful for reminders, timers, and other events that need to survive changes in the app life cycle. It also provides a method for handling missed events (e.g. if the event comes due when the device is off or another app is running).

Usage

This module assumes you're using the Fitbit CLI in your workflow, which allows you to manage packages using npm.

Installation

npm i fitbit-schedule

Fitbit Schedule has a uniform API that works on both the app and the companion. The only difference is the module name in the import statement, which is fitbit-schedule/app for the app and fitbit-schedule/companion for the companion.

Examples

A non-recurring event can be scheduled by supplying the due parameter with a UNIX timestamp (in milliseconds).

import schedule from "fitbit-schedule/app"

schedule.add({
  data: "See you in an hour...",
  due: Date.now() + 3600000
})

schedule.ondue = event => {
  console.log(event.data) // See you in an hour...
}

A recurring event can be scheduled by supplying the due parameter with an object that describes the recurrence pattern. Currently, only weekly patterns are supported.

import schedule from "fitbit-schedule/app"

schedule.add({
  data: "Lunch time!",
  due: {
    times: ["12:00"],
    days: [0, 1, 2, 3, 4, 5, 6]
  }
})

schedule.ondue = event => {
  console.log(event.data) // Lunch time!
}

API

schedule.add(event)

Add a new event. Returns the event ID.

event Object

The event to be created.

event.data Any

The data contained within the event.

event.due Number or Object

The time at which the event should be triggered. For a non-recurring event, due should be a UNIX timestamp in milliseconds. For a recurring event, due should be an object with the following properties:

  • times An array of 24-hour time strings in the format HH:MM. The default is 12:00.
  • dates An array of days of the week, where 0 = Sunday, 1 = Monday, etc. The default is [0, 1, 2, 3, 4, 5, 6].
event.tolerance Number

The amount of acceptable delay in milliseconds. It may not always be possible to trigger the event at the exact time specified by the due parameter (e.g. if the device is turned off or another app is running). If an event is past due when the app repoens, the ondue handler will be called only if the time elapsed since due is less than tolerance. Otherwise, the onmissed handler will be called. The default tolerance is 900000 (15 minutes).

schedule.remove(id)

Remove an event. If id is omitted, all events are removed.

id Number

The ID of the event to be deleted.

schedule.ondue = event => { ... }

Called when an event comes due.

schedule.onmissed = event => { ... }

Called when an event is missed.

Important: when multiple recurring events are missed, the onmissed handler will only fire for the first missed occurrence.