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 🙏

© 2026 – Pkg Stats / Ryan Hefner

golikejs

v0.4.0

Published

Reimplementations of Go standard packages (e.g. sync, context) for JavaScript/TypeScript

Readme

golikejs

npm version License: MIT

golikejs reimplements selected parts of Go's standard library for JavaScript and TypeScript runtimes. The goal is practical API parity where it makes sense, so you can use familiar concurrency and context patterns from Go in JS/TS projects. The project is intentionally small and focused: it reproduces commonly used primitives (sync, context, channels, semaphores, etc.) and keeps semantics close to Go's originals.

Table of contents

  • Features
  • Installation
  • Quick examples
    • Mutex
    • Channel
    • Context
    • Cond
    • Semaphore
    • WaitGroup
  • API summary
  • Build & testing
  • Publishing
  • Contributing
  • License

Features

  • Mutex, RWMutex — mutual exclusion primitives matching Go semantics.
  • WaitGroup — wait for a collection of goroutine-like tasks.
  • Semaphore — counting semaphore.
  • Channel — unbuffered and buffered channels with send/receive semantics.
  • select() — multiplex channel operations like Go's select statement.
  • Cond — condition variables.
  • Context — cancellation propagation and done/error semantics.

Installation

npm install golikejs
# or with bun
bun add golikejs

Quick examples

Mutex

import { Mutex } from 'golikejs';

const m = new Mutex();
await m.lock();
try {
  // critical section
} finally {
  m.unlock();
}

Channel (buffered)

import { Channel } from 'golikejs';

const ch = new Channel<number>(3);
await ch.send(1);
const [value, ok] = await ch.receive();

Channel select (multiplexing)

import { Channel, select, receive, send, default_ } from 'golikejs';

const ch1 = new Channel<string>();
const ch2 = new Channel<number>();

// Intuitive API with helper functions
let result: string | undefined;
await select([
  receive(ch1).then((value, ok) => { result = `ch1: ${value}`; }),
  receive(ch2).then((value, ok) => { result = `ch2: ${value}`; }),
  send(ch1, 'hello').then(() => { result = 'sent to ch1'; }),
  default_(() => { result = 'no data available'; })
]);

// Or using the direct object API
await select([
  { channel: ch1, action: (value, ok) => { result = `ch1: ${value}`; } },
  { channel: ch2, action: (value, ok) => { result = `ch2: ${value}`; } },
  { channel: ch1, value: 'hello', action: () => { result = 'sent to ch1'; } },
  { default: () => { result = 'no data available'; } }
]);

Context (cancellation)

import { context } from 'golikejs';

const ctx = context.withCancel(context.Background());
// some async work that listens for cancellation
const task = async (ctx) => {
  await ctx.done; // resolves when canceled
};

// cancel the context
ctx.cancel(new Error('shutdown'));

Cond

import { Cond, Mutex } from 'golikejs';

const mu = new Mutex();
const cond = new Cond(mu);

// in a waiter
await mu.lock();
try {
  await cond.wait();
} finally {
  mu.unlock();
}

// elsewhere
await mu.lock();
try {
  cond.signal();
} finally {
  mu.unlock();
}

Semaphore

import { Semaphore } from 'golikejs';

const s = new Semaphore(2);
await s.acquire();
try {
  // limited concurrency section
} finally {
  s.release();
}

WaitGroup

import { WaitGroup } from 'golikejs';

const wg = new WaitGroup();
wg.add(1);
(async () => {
  try {
    // work
  } finally {
    wg.done();
  }
})();
await wg.wait();

API summary

  • Mutex: lock(), unlock(), tryLock()
  • RWMutex: rlock(), runlock(), lock(), unlock()
  • WaitGroup: add(), done(), wait()
  • Semaphore: acquire(), release(), tryAcquire()
  • Channel: send(), receive(), trySend(), tryReceive(), close()
  • select: select(), receive(), send(), default_()
  • Cond: wait(), signal(), broadcast()
  • Context helpers in context module: Background(), withCancel(), withTimeout(), and withDeadline() (see source API for details)

Build & testing

  • Run tests with Bun (recommended):
bun test
  • Build (if needed):
bun run build

Publishing

The repository contains a GitHub Actions workflow that can publish the package to npm when a release is created or a v* tag is pushed. To enable automated publishing:

  1. Create an npm token (Settings → Access Tokens on npmjs.com) and add it to your GitHub repository secrets as NPM_TOKEN.
  2. Push a tag such as v1.0.0 or create a GitHub Release. The publish workflow will run and publish to npm with the configured token.

Contributing

Contributions, bug reports, and PRs are welcome. Please open issues for proposals or file PRs with tests where appropriate. We try to keep the APIs stable and faithful to Go where possible.

License

MIT