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

limitlessjs

v2.0.14

Published

A flexible event handler

Downloads

7

Readme

Node.js Package Node.js Test

Limitless

A small configurable dependency-free event handler that targets ES6.

Installation

yarn add limitlessjs

npm install --save limitlessjs

Usage

import {Limitless} from 'limitlessjs'

const limitless = new Limitless()
 // or
const limitless = Limitless.create()

Upgrading to 2.x

Breaking changes

  • This library has been converted to Typescript, Limitless is a class (new is required)
  • RunHandlers, TriggerHandlers, and ArgumentHandlers now accept an object instead of positional arguments.
  • Event Modifiers have been removed, use Array.prototype and #flat(Infinity) on the Event instead.
  • Limitless#forFile and defaultFileHandler have been removed, here's the equivalent if you need a replacement.
const contents = fs.readFileSync(filename, 'utf8')
const {config = {}, jobs = [], pipeline = [], ...rest} = JSON.parse(contents)
jobs.forEach(core.withJobDefinition)
core.withConfig(config)
pipeline.forEach(core.withPipeline)

Components

  • Events
  • Job Definitions
  • Run Handlers
  • Triggers & Trigger Handlers
  • Arguments & Argument Handlers
  • Config
  • Pipeline

Events

The input to Limitless, one or more passed into #process

    EventHandler.create()
      .withJobDefinition({runType: '__identity'})
      .process(1, 2, 3, 4) // Output: [1, 2, 3, 4]

Job Definitions

Core building block of Limitless that defines what can happen when an Event is received.

    // JobDefinition
    { 
        runType: string, 
        name: string, 
        triggers: [Trigger], 
        arguments: [Argument], 
        ...rest 
    } 
  • runType (required) - the name of the RunHandler that should be called to process this job
  • name (required, defaults to job-[number], e.g. job-0) - the name of this job
  • triggers (optional, see Triggers) - What triggers this job to run
  • arguments (optional, defaults to event) - How should event be passed to job runner
  • add any additional fields that would be useful for your Run Handlers

Run Handlers

Run a job definition, if triggered.

    // Run Handler
    (
        args: [], 
        job: JobDefinition, 
        name: string, 
        pastResults: [], 
        event: any, 
        config: Config
    ) => any
  • argsFromEvent - result of applying Argument Handlers on the Event
  • job - the full job definition
  • name - the name of the job (e.g job-0)
  • pastResults - anything that has already been processed
  • event - the event that was passed into Argument Handlers

Built In Run Handlers

  • __identity - returns input
  • __toJson - converts input to json string
  • __fromJson - converts string to json object

Triggers & Trigger Handlers

Decides when a job should run. By default if no trigger handlers are registered then all jobs are run, if any trigger handlers have been registered then only the jobs with matching triggers will run.

Arguments

  • type (required) - the name of the TriggerHandler that should be called to process this trigger
  • definition (optional, defaults to undefined) - additional config required by Trigger

Trigger Handlers

    // Trigger Handler
    ({
        definition: any,
        event: any, 
        handlers: Object
    }) => boolean 

Built In Trigger Handlers

  • __all - Requires all triggers to match
  • __any - Requires any triggers to match, default behavior
  • __not - Inverts the result of trigger

Arguments

The object passed into a RunHandler, the result of applying Argument Handlers on the event

Argument Handler

    // Argument Handler
    ({
        event: any, 
        definition: Object
    }) => any

Built In Argument Handlers

  • __identity - returns input
  • __toJson - converts input to json string
  • __fromJson - converts string to json object
  • __fromRegex - definition is a regular expression
  • __keyword - definition is an object of keys to argument handlers
  • __positional - definition is an array of argument handlers
  • __env - definition is the name of the environment variable to read
  • __value - use the value from definition

Config

Shared object passed into Run Handlers

Pipeline

Define sets of jobs that should run into each other. e.g. job3(job2(job1(event)))

Arguments

  • triggers (required) - the names of jobs that start this pipeline
  • steps (required) - the names of jobs that run, in order, in this pipeline