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

ko-calendar

v0.7.5

Published

Knockout Calendar ViewModel

Downloads

5

Readme

ko-calendar

An opinionated Knockout Calendar ViewModel in TypeScript

NPM version Travis build status

Requirements

Knockout (ko object) should be globally available or accessible via require('knockout')

Installation

Browser:

Make ko-calendar.js available to the client

<script src='https://rawgit.com/seikho/ko-calendar/master/ko-calendar.js'></script>
<script>
    var calendar = new Calender();
</script>
    
TypeScript:

Type definitions are available in src/typings/ko-calendar/ko-calendar.d.ts.
TypeScript ^1.6.0 will resolve the type definitions automatically if the package is a node_module.

npm install ko-calendar --save
Usage

Examples
Without RequireJS/Cajon
With RequireJS/Cajon

Basic usage:
If your objects are DateRange object, Date, string that are valid date string, or number that are valid date values:
then the default parser will correctly parse these objects.

var Calendar = require('ko-calendar').Calendar;
var calendar = new Calendar();

Better usage:
If you have more complex objects that might resemble something like { date: ..., id: ..., eventName: ... } You will need to provide a function to ko-calendar to tell it how to extract the Date or DateRange from your custom objects.

var Calendar = require('ko-calendar').Calendar;
//or
import { Calendar } from 'ko-calendar';

// Return a single date
var calParser = function(myObject) {
    return myObject.date;
}

//Return a date range
var calParser = function(myObject) {
    return {
        start: new Date(myObject.startDate),
        end: new Date(myObject.endDate)
    }
}
var calendar = new KoCal.Calendar(calParser);

API

All examples assume an instantiated Calendar object called calendar is available

startDay(dayOfWeek: number)

The day of week to use when performing week calculations.
This is based on JavaScript's dayOfWeek. This is zero-based where 0 is Sunday and 6 is Saturday.

addEvent

Also: addEvents
Usage: calendar.addEvent(object: any) or calendar.addEvents(object: any[])
Returns `void
Add an event to the collection. These objects must be parseable by the parser function

calendar.addEvent({ date: new Date() });
calendar.addEvents([{ date: new Date() }, { date: new Date(2015, 1, 1) }]);

eventsForDate

Usage: calendar.eventsForDate(date: Date)
Returns DayEvent object
Returns an ordered array of events that fall on the same day as the date provided.

var events = calender.eventsForDate(new Date(2015, 8, 18)); // Sep 18 2015

eventsByDay

Usage: calendar.eventsByDay() Returns Array<DayEvent> object
Returns an ordered array of DayEvent objects derived from the events collection.
The first DayEvent will always be start of week of the first Date in the events collection.
The last DayEvent will always be end of the week of the last Date in the events collection.

var events = calendar.eventsByDay();

eventsByWeek

Usage: calendar.eventsByWeek()
Returns Array<WeekEvent> object

var events = calendar.eventsByWeek();

eventsForMonth

Usage: calendar.eventsForMonth() Returns Array<WeekEvent> object

var events = calendar.eventsForMonth()`

previousMonth

Update the month that eventsForMonth will return Usage: calendar.previousMonth() Returns void

nextMonth

Update the month that eventsForMonth will return Usage: calendar.nextMonth() Returns void

DateRange

interface {
    start: Date;
    end: Date;
}

Event

interface Event {
    date: Date;
    value: any; // User object
}

DayEvent

interface DayEvent {
    date: Date;
    events: Event[]
}

WeekEvent

interface {
    start: Date;
    end: Date;
    weekNumber: number;
    days: Array<DayEvent>;
}

License

MIT