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

@marble-seeds/task

v1.0.0-rc.8

Published

## Install with

Downloads

55

Readme

Marble seeds Tasks module

Install with

npm i @marble-seeds/@marble-seeds/tasks

Docs

In your tasks folder create your file with

const Task = require('@marble-seeds/tasks')

const task = new Task(async function (argv) {
  console.log(argv)

  return { foo: true }
})

if (require.main === module) {
  task.setCliHandlers()
  task.run()
} else {
  module.exports = task
}

The last part will allow you to call it as a CLI or be loaded on your app and run as part of you app

Task philosophy

Task are small units of logic that should be repetable and composable.

Task to be able have repetable tasks, we need to care about 2 concepts:

  • Input/Output: To handle the inputs and outputs of a task in a easy way, task are build to be black boxes.
  • Boundaries of the box

By carring about this elements logs test of task can be created by recording the 3 elements and then replay them.

boundary

To be able to treat task as black boxes, all the interactions to fetch data, save elements need to be moved to boundaries.

const task = new Task(async function (argv, { getData }) {
  const data = async getData()
  console.log(argv, data)

  return { ...data, ...argv }
}, {
  boundaries : {
    getData: async () => {
      // someting
      return data
    }
  }
})

By defining bounderies in this form, we can record the interactions from the task with other elements allowing to track them and mock them.

Boundary have 4 modes:

  • Proxy: execute the function and records it
  • Proxy-pass: review if the input exist, it it exist returns the previous value and if not execute the functions
  • Proxy-catch: executes the function and if it throws and error, it tries to use a previews output if it exists for the input.
  • Replay: review if the input exist and if it doesnt throws and error.

With this modes bounderies can be used as cache or to generate test by passing the data to a RecordTape to re-run the calls.

Task API

constructor

Takes a task action(function) and a timeout as params.

run

Runs the task action asynchronously. Takes the function arguments and a config object with a timeout option.

setCliHandlers

Lets the taks that it will run as a CLI program.

ToDos

  • CLI run test and argv handler
  • Document boundaries