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

cucu

v0.11.1

Published

Cucu a tiny module to schedule repeated execution of (single process) methods/tasks.

Downloads

178

Readme

Cucu

NPM VERSION CODACY BADGE CODECLIMATE-TEST-COVERAGE LICENSE

NODE VERSION TRAVIS CI BUILD BUILD STATUS DEVDEPENDENCY STATUS

NPM MONTHLY NPM YEARLY

NPM GRAPH

Cucu, a tiny module to schedule repeated execution of ( single process ) methods/tasks.

Install

$ npm install cucu [-g]

require:

var Cucu  = require( 'cucu' );

Run Tests

$ cd cucu/
$ npm test

Constructor

Cucu()
// or
new Cucu()

Properties

/*
 * The current number of running tasks.
 */
Cucu.running : Number

/*
 * Task table, an obj/hash containing tasks by id/key/name.
 *
 * A table entry for a task named 'id' is an obj/hash like:
 *
 *  ttable[ 'id' ] = {
 *      id : 'id'
 *      , fn : fn
 *      , interval : Number
 *      , args : Array
 *      , scope : Object
 *      , status : Number | Object
 *      , repeat : Number
 *      // timestamps for task start, current iteration and task stop/halt/end.
 *      , stime : Number
 *      , itime : Number
 *      , etime : Number
 *      // get task time infos
 *      , timetable : Function
 *      // Cucu method shortcuts
 *      , run : Function
 *      , stop : Function
 *      , del : Function
 *  };
 *
 * NOTE: Every entry contains shortcuts to Cucu#run, #stop and #del methods, already
 * curried with their own ids. For example, if exists a task named 'dumb' in the task
 * table, you could also use the methods below, for running, stopping or deleting an
 * existing task:
 * 
 * Cucu.ttable.dumb.run( [ Number interval [, Array args [, Number times ] ] ] ) : Number
 *
 * Cucu.ttable.dumb.stop() : Array
 *
 * Cucu.ttable.dumb.del() : Array
 *
 *
 */
Cucu.ttable : Object

Methods

Arguments within [ ] are optional.

/*
 * Add a task; a task will be added only if there is no other task already running
 * with this name/id.
 * It returns 1 if task is added, 0 if the same task id is already running, -1 if
 * an error occurs.
 */
Cucu#add( String id, Function fn [, Array args [, Object scope [, Number interval ] ] ] ) : Number

/*
 * Run a task by name/id. Optionally you can specify interval, function arguments and 
 * the max number executions for a task.
 * It returns 1 if task is started, 0 if the task is already running, -1 if no task
 * exists.
 *
 * NOTE: if 'times' option is specified, the scheduled function 'fn' will get, as the
 * first argument, a function to execute when task will be done.
 */
Cucu#run( String id [, Number interval [, Array args [, Number times ] ] ] ) : Number

/*
 * Remove tasks by id/name; a task will be removed only if it is not currently running.
 * It returns a list of ids/names for all the removed tasks.
 */
Cucu#del( String id | Array ids ) : Array

/*
 * Stop a running method/task by name/id.
 * It returns a list of ids/names for all the stopped tasks.
 */
Cucu#stop( String id | Array ids ) : Number

/*
 * Start all non-running tasks.
 * It returns the total number of non-running tasks started.
 */
Cucu#awake() : Number

/*
 * Halt all running tasks.
 * It returns a list of ids/names for all the stopped tasks.
 */
Cucu#halt() : Array

/*
 * Stop and delete all tasks.
 * It returns the list of ids/names for all the removed tasks.
 */
Cucu#flush() : Array

/*
 * Get a list of names/ids for all the currently active/running tasks.
 */
Cucu#active() : Array

/*
 * It returns the total number of tasks.
 */
Cucu#size() : Number

MIT License

Copyright (c) 2014-present < Guglielmo Ferri : [email protected] >

Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the 'Software'), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED 'AS IS', WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.