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

fantasy-time-crunch

v0.1.0

Published

A way of handling time and time-related state changes in a highly customizable way, for use with games and virtual worlds

Downloads

3

Readme

fantasy-time-crunch

I needed a way of handling a made-up time system in a game, so I made this.

Sample Configuration

const time = {
  // One and only one unit is the smallest measured subdivision of time, defined as a 'tick'
  second: {
    tick: true,
    makes: {minute: 60},
  },

  // Larger units are defined by how many of a smaller unit they are subdivided into
  minute: {
    makes: {hour: 60},
  },

  // Optionally one can define a function to be called when
  // a unit increments (having a bell toll, etc.)
  hour: {
    makes: {day: 24},
    onIncrement() {
      console.log('BING!');
      console.log('Hour: ', this.time.hour);
    },
    // Units can be divided into multiple state changes. For example, a day has two or more states defined
    // by how many hours have passed.
    // 'states' can be an object or a function.
    // In this case, dawn and dusk are different depending
    // on the season
    states() {
      if (this.states.is('winter')) {
        return {
          day: 9, // 0900 -- by default this number represents hours. however, each property returned can also be a function that has access to any time unit.
          night: 20, // 2000
        };
      }
      return {
        day: 6, // 0900
        night: 23, // 2200
      };
    }
  },


  day: {
    makes() {
      const days = this.time.month % 2 ? 31 : 30;
      return {month: days};
    },
    onIncrement() {
      const names = 'MTWHFSU';
      console.log('Day:', names[this.time.day - 1]);
    },
  },
  month: {
    // The 'of' property can also be a function called
    // In this case, even months have 30 days and odd have 31.
    makes: { year: 12},

    // For simpler state changes, an object marking the
    // transitional thresholds is fine.
    states: {
      winter: 11,
      spring: 3,
      summer: 5,
      fall: 9
    }
  }
};