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

bells

v0.1.1

Published

Bell schedule computation and formatting

Downloads

1

Readme

bells Build Status

This is an npm module that helps with the computation of bell schedules.

Install

npm install --save bells once it is published

Features

  • Awesomeness
  • Store names for certain periods, not necessarily numerical or in order
  • Get the current period
  • Get when the next bell is
  • Have bells not associated with a specific period
  • Guess the bell schedule for a specific day based on a given set of criteria

API

Times are passed around as instances of Moment().

When an argument is a time, Bells attempts to parse it as a HH:mm time (24hr time). A date argument must be given in a format specified here.

Bells(bellScheduleRepresentation)

Create a Bells object. See below for the layout of bellScheduleRepresentation.

var Bells = require('bells');

// Steinbrenner High School of Lutz, FL's normal bell schedule
var schedule = Bells({
	periods: {
		'1': ['7:33', '8:23'], // [start-time, end-time]
		'2': ['8:29', '9:24'], // Where time between 00:00 and 23:59
		'3': ['9:30', '10:20'],
		'4 (1st lunch)': ['10:26', '11:16'],
		'5 (2nd lunch)': ['11:22', '12:12'],
		'6 (3rd lunch)': ['12:18', '13:08'],
		'7': ['13:14', '14:04'],
		'8': ['14:10', '15:00'],
	},
	other: [
		'7:15',
		'7:25',
	],
});
// => Object

Bells#currentPeriod([now])

Get the name of the current period, or null. See above for more info about time parameters.

schedule.currentPeriod('13:00');
// => '6 (3rd lunch)'
schedule.currentPeriod('14:15');
// => '8'
schedule.currentPeriod('16:00');
// => null

Bells#nextBell([now])

Get the time of the next bell, as a Moment(). See above for more info about time parameters.

schedule.nextBell('7:10');
// => '07:15'
schedule.nextBell('8:23');
// => '08:29'
schedule.nextBell('16:00');
// => null

Bells#periods()

Get all class periods passed to the initializer.

schedule.periods();
/* => {
	'1': ['7:33', '8:23'],
	...
	'8': ['14:10', '15:00'],
} */

Bells.allBells()

Get all bells in the schedule, sorted in ascending order.

schedule.allBells()
/* => [
	'7:15',
	'7:25',
	...
	'15:00',
] */

Bells.Predictor(criteria)

Create a Predictor object. See below for the layout of criteria.

Note that a predictor only associates a string to a specific set of criteria. It does not associate a Bells object to that string.

var Bells = require('bells');

var Predictor = Bells.Predictor({
	// 'default' is the fallback bell schedule.
	// This is returned when there is no other bell schedule specified for a day.
	'default': 'Normal Day',

	// 'none' is interpreted to mean there is no school.
	// 0&6 mean that this applies on those days of the week, where
	// 	0 is Sunday and 6 is Saturday.
	// SMTWTFS
	// 0123456
	'0': 'none',
	'6': 'none',

	// This applies on 4/18/14.
	// A specific date overrides any day-of-week selector and the 'default'.
	// The dates *MUST* be zero-padded or the predictor won't find it
	'04/18/2014': 'none',

	'04/17/2014': 'FCAT',
	'04/22/2014': 'FCAT',
	'04/23/2014': 'FCAT',

	'04/14/2014': 'FCAT - Monday',
});

// A possible future implementation
/*var Predictor = Bells.Predictor({
	// 'none' is interpreted to mean there is no school.
	// [0, 6] means that this applies on those days of the week, where
	// 	0 is Sunday and 6 is Saturday.
	'none': [0, 6],

	// 'default' is the fallback bell schedule.
	// There can only be one default.
	'Normal Day': 'default',

	// This applies when the day equals 1 (Monday).
	// A specific day of the week gets higher priority than 'default', but lower
	// 	than a specific date.
	'Monday': 1,

	// This applies on 4/14/14 and 4/17/14.
	// A specific date overrides any day-of-week selector or the 'default'.
	'FCAT': ['4/17/2014', '4/22/2014', '4/23/2014'],

	// You can also specify a string with a date instead of an array of strings
	'FCAT - Monday': '4/14/2014',
});*/
// => Object

Predictor#predict([date])

Predict the bell schedule for a certain date, or today if omitted. (The date must be a full month/day/year, in any format guessable by Moment.)

Predictor.predict('2014-04-15'); // normal Tuesday
// => 'Normal Day'
Predictor.predict('2014-04-21'); // normal Monday
// => 'Monday'
Predictor.predict('2014-04-14'); // FCAT Monday
// => 'FCAT - Monday'
Predictor.predict('2014-04-19'); // Saturday
// => 'none'