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

checklist-js

v1.2.3

Published

A simple checklist for when you need to keep track of things presistetly

Downloads

22

Readme

checklist-js

A simple checklist for when you need to keep track of things presistetly

Installation

npm install checklist-js

Usage

import Checklist from 'checklist-js'

const shoppingList = [ 
  '🥚 eggs', 
  '🥩 ham', 
  '🧀 cheese', 
  '🍎 apple', 
  '🥦 broccoli' 
];

// create a checklist
const checklist = new Checklist(shopping_lits);

let eggs = await fetch('https://emojipedia.org/egg/');
// check eggs
if(eggs) checklist.check('🥚 eggs');

let ham = await fetch('https://emojipedia.org/ham/');
// check ham
if(ham) checklist.check('🥩 ham');

checklist.next() // '🧀 cheese'

checklist.next() // '🍎 apple'

// uncheck 🥚 eggs
checklist.uncheck('🥚 eggs')

/* 🥚 eggs ? */
checklist.isChecked('🥚 eggs') // false

/* 🥩 ham ? */
checklist.isChecked('🥚 eggs') // true

/*[ 
  '🥚 eggs', 
  '🧀 cheese',
  '🍎 apple',
  '🥦 broccoli',
]*/
checklist.getMissingValues();
checklist.missingLeft(); // 4

/*[ 
  '🥩 ham',
]*/
checklist.getCheckedValues()
checklist.valuesDone() // 1

/* check if all the values have been checked */
checklist.isDone() // false
checklist.isNotDone() // true

/*
false : 🥚 eggs 
true : 🥩 ham
false : 🧀 cheese
false : 🍎 apple
false : 🥦 broccoli
*/
checklist.log()

// delete the checklist in the files system
checklist.delete()

while loop usage

while(checklist.isNotDone()){
  // get the next missing value on the checklist
  let value  = checklist.next()
  // perform some operation 
  let result = await fetch('https://emojipedia.org/');
  // check the value if successful
  if(result) checklist.check(value);
}

// delete the checklist in the files system
if(checklist.isDone())
  checklist.delete()

Permenance

you can recover the same checklist by creating it again with the same values

const checklist = new Checklist([ 
  '🥚 eggs', 
  '🥩 ham',  
  '🥦 broccoli' 
]);

// check
checklist.check('🥚 eggs');
checklist.check('🥩 ham');

/*
true : 🥚 eggs 
true : 🥩 ham
false : 🥦 broccoli
*/
checklist.log()
/* after crash or diffrent file*/
const checklist = new Checklist([ 
  '🥚 eggs', 
  '🥩 ham',  
  '🥦 broccoli' 
]);

/*
true : 🥚 eggs 
true : 🥩 ham
false : 🥦 broccoli
*/
checklist.log()

the order values does not matter when recovering the checklist

/* after crash or diffrent file*/
const checklist = new Checklist([ 
  '🥦 broccoli' 
  '🥩 ham',
  '🥚 eggs', 
]);

/*
false : 🥦 broccoli 
true : 🥩 ham
true : 🥚 eggs
*/
checklist.log()

pass the name options to make it the checklist unique

let shoppingList = [ 
  '🥦 broccoli' 
  '🥩 ham',
  '🥚 eggs', 
];

const bobs_checklist = new Checklist(
  shoppingList, { name: 'bobs shoppinglist' } 
);
bobs_checklist.check(['🥩 ham', '🥚 eggs'])

const alices_checklist = new Checklist(
  shoppingList, { name: 'alices shoppinglist' } 
);
alices_checklist.check('🥦 broccoli')

recover the checklist with the name option

/* after crash or diffrent file*/
const bobs_checklist = 
  new Checklist(null, { name: 'bobs shoppinglist' });
  
/*
false : 🥦 broccoli 
true : 🥩 ham
true : 🥚 eggs
*/
bobs_checklist.log()

const alices_checklist = 
  new Checklist(null, { name: 'alices shoppinglist' });
  
/*
false : 🥦 broccoli 
true : 🥩 ham
true : 🥚 eggs
*/
bobs_checklist.log()

pass the path where to make the filesystem

  new Checklist([], { 
    name: 'my_checklist',
    path: process.cwd()
  });
  

Recalculate missing values on Check

sometime when you are working with multiple concurrent processes you don't want the completion of one process to alter the order you would get the missing vlaue

this can lead to a missing values being drawn twice after a check.

There is also the senario where you have too many values and doing recalc on every check will take too long

For this senarios you can set the option recalc_on_check to false

pass the path where to make the filesystem

  new Checklist([], { 
    recalc_on_check: false
  });
  

Adding, Removing and Checking multiple values

// add 🥓 bacon
checklist.add('🥓 bacon')
// or 
checklist.add(['🍞 Bread', '🍆 Eggplant', '🥛 Milk'])

// remove 🥚 eggs
checklist.remove('🥚 eggs')
// or 
checklist.remove(['🥩 ham', '🥓 bacon', '🍞 Bread', '🥛 Milk'])

// check 🧀 cheese
checklist.check('🧀 cheese')
// or 
checklist.check([ '🍆 Eggplant', '🍎 apple' , '🥦 broccoli'])

// uncheck 🧀 cheese
checklist.unchek('🧀 cheese')
// or 
checklist.uncheck([ '🍆 Eggplant', '🍎 apple' , '🥦 broccoli'])

OPTIONS

All options

new Checklist( valus, {
        name, // name of the checklist to save

        path, // path to save the checklist at

        recalc_on_check, // recalcuate the missing values on check
        
        save_every_check, // save the checklist every n checks

        enqueue, // if false, do not add missing values to the end of the list

        shuffle, // if true, shuffle the values before checking

        save // if false, Checklist has not presistense. it does not save to disk, default true
        })