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

tsundere

v0.0.14

Published

Modern, lightweight and type-safe task runner for the stubborn ones

Downloads

25

Readme

🛠 Status: In Development

Tsundere is currently under heavy development. Feedback is always welcome, but be careful with using it in production. API is not ready yet and can receive large changes.

Tsundere

npm minified size dependency count jsDelivr downloads

ubuntu windows ubuntu

Tsundere is a modern, lightweight and type-safe task runner for the stubborn ones.

Install

Install Tsundere for Node, using NPM or Yarn.

npm install --save-dev tsundere

Tsundere can also be used inside a browser, as an ES Module.

<script type="module">
    import * as tsundere from 'https://esm.run/tsundere'           // jsDelivr
    import * as tsundere from 'https://cdn.skypack.dev/tsundere'   // Skypack
    import * as tsundere from 'https://unpkg.com/tsundere?module'  // Unpkg
</script>

Browser compatibility

| IE / Edge | Firefox | Chrome | Safari | iOS Safari | Opera | | ------------------------------------------------------------ | ------------------------------------------------------------ | ------------------------------------------------------------ | ------------------------------------------------------------ | ------------------------------------------------------------ | ------------------------------------------------------------ | | IE10+ / Edge 12 | Firefox 15 | Chrome 20 | Safari 8 | iOS Safari 9 | Opera 15 |

Tsundere is able to support up to Internet Explorer 10 and any browser with High Resolution Time API, using a few polyfills.

<script src="https://polyfill.io/v3/polyfill.min.js?features=es6%2CReflect%2CSymbol%2CObject.defineProperty"></script>
<script src="https://unpkg.com/tsundere/dist/legacy"></script>

Usage

The following section will soon provide the Tsundere CLI usage guide, once it's ready.

API

A task is defined by a callback function. Nameless tasks an be constructed via new TsundereTask(callback) or task(callback). A provided Jest-inspired describe function can help you label your tasks.

import { describe } from 'tsundere'
const job = describe('my-task', async () => await somePromiseWhichReturn(true))

You can subscribe to task events, using <TsundereTask>.on or <TsundereTask>.once.

job.once('start', () => console.log('it started.'))
job.once('end', () => console.log('it ended.'))
job.on('error', (e) => console.log(`Oops! Something went wrong..\n${e}`))

Using <TsundereTask>.run method, the task will run and return a report, including relevant data as well as the duration in milliseconds.

job.run().then(report => { console.log(report); })
/** 
 * Output: {
 *    "label": "my-task",
 *    "result": true,
 *    "duration": 1.4819
 * }
 */

Nameless or labelled tasks can be grouped and run concurrently, using parallel or in sequence, using series methods.

import { parallel, series } from 'tsundere'
parallel([/* Insert your tasks here */]).run().then(report => { console.log(report); })
series([/* Insert your tasks here */]]).run().then(report => { console.log(report); })

Using describeParallel or describeSeries allows you to create and label your task group.

import { describeParallel, describeSeries } from 'tsundere'
describeParallel('parallel-tasks', [/* Insert your tasks here */]).run()
describeSeries('sequence-tasks', [/* Insert your tasks here */]).run()

You can also set up a TsundereRunner task runner to run and chain tasks under a same context and reduce boilerplate code (e.g. events, formatting). Registered tasks will be run in parallel when using <TsundereRunner>.run.

Under the hood, when relying on <TsundereRunner>.parallel, <TsundereRunner>.series, <TsundereRunner>.describeParallel or <TsundereRunner>.describeSeries methods, the task runner is explicitly aware of the related sub-tasks and will correctly format the final report.

import { TsundereRunner, describe, task } from 'tsundere'

// Sample promise
function timeout(ms) {
    return new Promise(resolve => setTimeout(resolve(true), ms));
}

// Let's setup our task runner
const tsundere = new TsundereRunner() 
tsundere.task(async () => await timeout(300))
tsundere.describe('A', async () => await timeout(400))
tsundere.series([
  describe('B', async () => await timeout(700)),
  describe('C', async () => await timeout(450)),
])
tsundere.describeParallel('D', [
  describe('E', async () => await timeout(750)),
  task(async () => await timeout(600)),
])

tsundere.run().then(report => { console.log(report); })
/**
 * Output: [
 *   { label: undefined, result: true, duration: 301.2114 },
 *   { label: "A", result: true, duration: 402.8211 },
 *   { label: undefined, result: true, duration: 603.0201 },
 *   { label: "B", result: true, duration: 702.3147 },
 *   { label: "E", result: true, duration: 753.3701 },
 *   { label: "D", result: [ [...], [...] ], duration: 754.0116 }
 *   { label: "C", result: true, duration: 450.1668 },
 *   { label: undefined, result: [ [...], [...] ], duration: 1152.0446 }
 * ]
 */

Contributing

npm install     # Install dependencies
npm run build   # Transpile, generate typings, bundle for production
npm run test    # Run test(s)

License

Tsundere is licensed under Apache License, Version 2.0.

© Copyright 2020 Tom Bazarnik.