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

zurk

v0.9.3

Published

A generic process spawner

Downloads

7,007

Readme

zurk

🔬🧫

This subproject is a kind of experiment, addressed to the google/zx/issues/589. Just a testing ground for verifying ideas and approaches aimed at improve the zx architecture.

Concepts

  • Layered architecture:
    • spawn builds a configurable exec context around the node:child_process API.
    • zurk implements the API for sync and async executions.
    • x provides the basic template-string API.
  • Granularity: the package provides several entry points to help user to choose the right level of abstraction and/or to assist with tree-shaking.
  • Extensibility:
    • The context object at every layer is accessible fo modify.
    • Typings are mostly represented by interfaces, so it's easy to tweak up if necessary.

Requirements

  • OS
    • Linux
    • MacOS
    • Windows
  • JS Runtime
    • Node.js >= 6 (CJS)
    • Node.js >= 12 (ESM)
    • Bun >= 1.0.0
    • Deno >= 1.7.0

Install

yarn add zurk

API

import {$, exec, zurk} from 'zurk'

const r1 = exec({sync: true, cmd: 'echo foo'})
const r2 = await zurk({sync: false, cmd: 'echo foo'})
const r3 = await $`echo foo`

Proposals

  • [x] Promises in cmd literals
const foo = $`echo foo`
const foobarbaz = (await $`echo ${foo} ${$`echo bar`} ${await $`echo baz`}`)
  • [x] Both sync and async executions
const p1 = $`echo foo`
const p2 = $({sync: true})`echo foo`

const o1 = (await p1).toString()  // foo
const o2 = await p1.stdout        // foo
const o3 = p2.stdout              // foo
  • [x] Configurable input
const input = '{"name": "foo"}'
const name = await $({input})`jq -r .name` // foo

const stdin = fs.createReadStream(path.join(fixtures, 'foo.json'))
const data = await $({stdin})`jq -r .data` // foo

const p = $`echo "5\\n3\\n1\\n4\\n2"`
const sorted = $({input: p})`sort`          // 1\n2\n3\n4\n5
  • [x] Pipe literals
const result = $`echo "5\\n3\\n1\\n4\\n2"`

const piped0 = result.pipe`sort | cat`     // '1\n2\n3\n4\n5'
const piped1 = result.pipe`sort`.pipe`cat` // ...
const piped2 = (await result).pipe`sort`
const piped3 = result.pipe($`sort`)
  • [x] Pipe splitting
const result = $`echo 1; sleep 1; echo 2; sleep 1; echo 3`
const piped1 = result.pipe`cat`
let piped2: any

setTimeout(() => {
  piped2 = result.pipe`cat`
}, 1500)

await piped1
assert.equal((await piped1).toString(), '1\n2\n3')
assert.equal((await piped2).toString(), '1\n2\n3')
  • [x] Presets
const $$ = $({sync: true, cmd: 'echo foo'})
const $$$ = $$({cmd: 'echo bar'})

const p1 = $$()           // foo
const p2 = $$$()          // bar
const p3 = $$`echo baz`   // baz
  • [x] AbortController
const ac = new AbortController()
const p = $({nothrow: true, ac})`sleep 10`
setTimeout(() => {
  ac.signal.abort() // or just `p.abort()`
}, 500)

const { error } = await p
error.message // 'The operation was aborted'
  • [x] Stdout limit
import {type TSpawnStore, $} from 'zurk'

const getFixedSizeArray = (size: number) => {
  const arr: any[] = []
  return new Proxy(arr, {
    get: (target: any, prop) =>
      prop === 'push' && arr.length >= size
        ? () => {}
        : target[prop]
  })
}
const store: TSpawnStore = {
  stdout: getFixedSizeArray(1),
  stderr: getFixedSizeArray(2),
  stdall: getFixedSizeArray(0)
}

const result = await $({store})`echo hello`
result.stdout // 'hello\n'
result.stdall // ''

License

MIT