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

gamaas

v1.0.7

Published

Gamify your web app

Downloads

23

Readme

GAMaaS

npm version

Add locally stored achievements to your web application and encourage users to continue using and learning.

Installation

npm install gamaas --save

Usage

Most functions in this project are chain-able and allow you to append a . and the next function you wish to call.

Quickstart

To get started quickly, run the below command to run the application in a Webpack'd server.

npm run start

Now point your browser to http://localhost:8090/, open your browser's console, and access the gamaas object directly as it is attached to the window.

Getting started

.init(configOnject: Object): Gamaas

This method is used when setting up your achievements. It accepts an object with specific properties to setup GAMaaS.

Parameters

|Param|Required|Type|Description| |---|---|---|---| |configOnject|Yes|Object|An object with specific properties to setup GAMaaS|

Returns

|Return|Type| |---|---| |gamaas|Object|

Example

import gamaas from 'gamaas';

gamaas.init({
    achievements: {
        // One to many achievements
        uniqueAchievementId : {
            title          : "Achievement Title", // The title of your achievement
            worth          : 5, // Number of points the achievement is worth
            required       : 5, // Amount of progress required to achieve the achievement
            exceedRequired : false // Whether or not the achievement progress can exceed what is required
        },
        ...
    },
    store : {
        when    : "always", // Whether to store the progress upon every action or when you call .store()
        dataKey : "achievements" // Namespace for where to save your achievement progress within localStorage
    }
});

.on(event: string, callback: Function): Gamaas

The .on() method requires two parameters, event and callback. The event can be one of four different types which include progress, regress, reset or award. .on() is not required for GAMaaS to function. When any of the events occur, their associated callback function is called. The parameter passed to the callback function is a single object containing the id of the achievement affected along with the event that fired.

Parameters

|Param|Required|Type|Description| |---|---|---|---| |event|Yes|String|progress or regress or reset or award| |callback|Yes|Function|The function to be called when event occurs.|

Returns

|Return|Type| |---|---| |gamaas|Object|

Example

import gamaas from 'gamaas';

gamaas.init({
    // Config Object
}).on('progress', ({id, event}) => {
    console.log("A progress event!", id, event);
});

.progress(id: string, awarded?: Boolean = true): Gamaas

The .progress() method is used when incrementing the progress (by 1) of the achievement. In this way if an achievement's progress is currently 1 and you .progress() the achievement, it will then be 2. if exceedRequired is specified and is truthy, then .progress() will not allow the progress to exceed the value specified in the required property of the achievement.

Parameters

|Param|Required|Type|Description| |---|---|---|---| |id|Yes|string|The id of the achievement you wish to progress.| |awarded|No|Boolean|Whether or not you want to award the achievement when the progress meets its requirements. Defaults to true.|

Returns

|Return|Type| |---|---| |gamaas|Object|

Example

import gamaas from 'gamaas';

gamaas.init({
    // Config Object
}).progress('achievementId');

.regress(id: string, awarded?: Boolean = true): Gamaas

The .regress() method is used when decrementing the progress (by 1) of the achievement. In this way if an achievement's progress is currently 3 and you .regress() the achievement, it will then be 2. Achievements can not be reduced below 0.

Parameters

|Param|Required|Type|Description| |---|---|---|---| |id|Yes|string|The id of the achievement you wish to regress.| |awarded|No|Boolean|Whether or not you want to un-award the achievement when the progress is below or equal to its requirements. Defaults to true.|

Returns

|Return|Type| |---|---| |gamaas|Object|

Example

import gamaas from 'gamaas';

gamaas.init({
    // Config Object
}).regress('achievementId');

.award(id: string, awarded?: Boolean = true, reason: string = "Unknown"): Gamaas

The .award() method allows you to set the awarded status of an achievement which causes the progress event to be fired.

Parameters

|Param|Required|Type|Description| |---|---|---|---| |id|Yes|string|The id of the achievement you wish to award.| |awarded|No|Boolean|The awarded state of the achievement id specified. Defaults to true.| |reason|No|string|A short description of why the award was given (or taken away). Defaults to Unknown.|

Returns

|Return|Type| |---|---| |gamaas|Object|

Example

import gamaas from 'gamaas';

gamaas.init({
    // Config Object
}).award('achievementId');

.reset(id: string, awarded?: Boolean = true): Gamaas

Parameters

|Param|Required|Type|Description| |---|---|---|---| |id|Yes|string|The id of the achievement you wish to reset.| |awarded|No|Boolean|Whether or not you want to un-award the achievement when the achievement is rest. Defaults to true.|

Returns

|Return|Type| |---|---| |gamaas|Object|

.store(): Gamaas

Stores the progress of the achievements to localStorage. This is called automatically when you progress, regress, award or reset achievements when the store.when config value is set to always when you .init() GAMaaS.

Returns

|Return|Type| |---|---| |gamaas|Object|