open-index/open-npm huggingface dataset:
npm package: @seahax/deep-copy
Description: Make a recursive deep copy, treating functions and class instances as atomic values.
Latest version: 0.1.0

# @seahax/semaphore

Make a recursive deep copy, treating functions and class instances as atomic values.

```ts
import deepCopy from '@seahax/deep-copy';

const copy = deepCopy({
  foo: 123,
  bar: () => console.log('hello world'),
  baz: new Date(),
});
```
npm package: @seahax/monorepo
Description: Recursively find and read monorepo package information.
Latest version: 0.1.1
Deprecated: Package no longer supported. Contact Support at https://www.npmjs.com/support for more info.

# @seahax/monorepo

Recursively find and read monorepo package information.

- Packages that are inside a `node_modules` directory are ignored.
- Results are ordered so that dependencies come before their dependents.
- Local dependencies are linked by name only (regardless of version).

```ts
import { getPackages } from '@seahax/monorepo';

const results = await getPackages(process.cwd());
```

The results are an array of objects with the following properties.

- `filename`: The absolute path to the package.json file.
- `data`: The contents of the package.json file.
- `localDependencies`: An array of references to other entries in the results array.
npm package: @seahax/publish-from-package
Description: Recursively publish new public package versions.
Latest version: 0.1.3
Deprecated: Package no longer supported. Contact Support at https://www.npmjs.com/support for more info.

# @seahax/publish-from-package

Recursively publish new public package versions.

## Usage

1. Update some package versions.
2. Execute this tool at the repo root.

```sh
# Publish new package versions.
npx @seahax/publish-from-package

# Just to see what would happen, without making any changes.
npx @seahax/publish-from-package --dry-run

# Extra args are passed through to the package manager.
npx @seahax/publish-from-package -- --tag beta
```

Your package manager is determined automatically by looking for lock files at the repo root. Supported package managers are: `npm`, `pnpm`, and `yarn` (berry).

If auto-detection doesn't work for you, you can specify the publish command manually.

```sh
npx @seahax/publish-from-package --command "npm publish"

# Run a different command.
npx @seahax/publish-from-package --command "npm pack"
```
npm package: @seahax/publish-precheck
Description: Check package.json files for problems to fix before publishing.
Latest version: 0.1.2
Deprecated: Package no longer supported. Contact Support at https://www.npmjs.com/support for more info.

# @seahax/publish-precheck

Check package.json files for problems to fix before publishing.

## Checks

Only checks packages that have a `name`, `version`, and are not marked
`private`.

- Ensure a `license` field.
- Ensure a `repository` field.
- Ensure a `files` field.
- Ensure a `bin`, `exports`, or `main` field.
  - If `exports` field exists...
    - Ensure `type` is `module`.
    - Ensure `types` field exists.
  - If `main` field exists...
    - Ensure `type` is `commonjs`.
- Ensure a `type` field exists.
  - If `type` is `module`...
    - Ensure `exports` or `bin` field exists.
    - Ensure `main` field does not exist.
  - If `type` is `commonjs`...
    - Ensure `main` or `bin` field exists.
    - Ensure `exports` field does not exist.
- Ensure no `workspace:` production dependencies.
- Ensure no `file:` production dependencies.
- Ensure no `*` production dependencies.
npm package: @seahax/run-all
Description: Because life's too short to type 'npm run test:unit && npm run test:integration && npm run test:e2e' when you could just say 'run-all test'.
Latest version: 0.1.9

# @seahax/run-all

Because life's too short to type `npm run test.unit && npm run test.integration && npm run test.e2e` when you could just say `run-all test.`.

- Supports NPM, PNPM, and Yarn.
- Must be run by a package script.
- Multiple prefixes can be given.
- Scripts are run sequentially.
- Passing arguments to the scripts is not supported.
npm package: @seahax/semaphore
Description: An asynchronous semaphore.
Latest version: 0.5.1

# @seahax/semaphore

Asynchronous semaphore.

- [Getting Started](#getting-started)
- [Mutex](#mutex)
- [Controlled Functions](#controlled-functions)
- [Draining](#draining)


## Getting Started

Declare a semaphore.

```ts
import { createSemaphore } from '@seahax/semaphore';

const abortController = new AbortController();
const semaphore = createSemaphore({
  // Abort signal to prevent new acquisitions (optional).
  signal: abortController.signal,
  // Maximum number of locks (Default: 1)
  capacity: 1
});
```

Acquire a lock, waiting until one is available if necessary.

```ts
const lock = await semaphore.acquire();
```

Release the lock when it is no longer needed.

```ts
try {
  // Do something with limited concurrency...
} finally {
  lock.release();
}
```

## Mutex

A mutex (mutually exclusive lock) is a semaphore with a capacity of 1.

```ts
import { createMutex } from '@seahax/semaphore';

const mutex = createMutex({
  // Options are the same as createMetaphore, except capacity is always 1.
});
```

## Controlled Functions

Async functions can be decorated so that they automatically acquire and release locks when called.

```ts
const callback = semaphore.controlled(async (arg: string): Promise<void> => {
  // Do something with limited concurrency...
});

// The returned callback is curried so that the signal is provided by the
// semaphore. The signal is not passed in as an argument.
await callback('Hello, World!');
```

## Draining

It is possible to wait for all semaphore locks to be released. This is useful for cleanup.

```ts
await semaphore.drain();
```
npm package: @seahax/vite-plugin-prefetch
Description: Vite plugin that injects dynamic import prefetching into each chunk.
Latest version: 0.1.6
Deprecated: Package no longer supported. Contact Support at https://www.npmjs.com/support for more info.

# @seahax/vite-plugin-prefetch

Vite plugin that injects dynamic import prefetching into each chunk.

Appends a small snippet of code to the end of each entry chunk. The snippet prefetches all of the chunk's dynamic imports by calling `import(dynamicImportPath)` early, but with a short delay to prevent blocking resources that are critical for initial rendering. When the real dynamic import is used, it is handled by the module cache.

The injected snippet looks like this:

```js
setTimeout(()=>["./index-BpbxaBtl.js"].forEach((v)=>import(v).catch(()=>{})),200);
```

This has the following benefits:

1. Reduces site latency when using lazy-loaded modules.
2. Avoids 404 responses when an app has been redeployed causing the old chunks to be unavailable, but the client still has an entry script loaded that references the old chunks.

Turning off Vite's `build.modulePreload` option is recommended when using this plugin. The capabilities mostly overlap, but Vite doesn't include all dynamic imports in a chunk (only the "immediate" ones?). Vite injects `<link rel="modulepreload" href="..." />` elements which don't have consistent behavior across browsers, and the polyfill that Vite injects uses fetch instead of import.
npm package: @seahax/vitest
Description: Vitest config helpers.
Latest version: 0.1.8

# @seahax/vitest

Vitest config helpers.

## Test Config

- Pass with no tests.
- Pin the timezone to UTC.
- Restores all mocks _after_ each test (not before).
- Enables real timers _after_ each test (not before).

File: `vitest.config.ts`

```ts
import { testDefaults } from '@seahax/vitest';
import { defineConfig } from 'vitest/config';

export default defineConfig({
  test: {
    ...testDefaults,
    // Additional test options...
  }
});
```

## Workspace Config

- Automatically detect workspace directory globs from `pnpm-workspace.yaml` or `package.json` (optional).
- Find all `vitest.config.*` files in workspace directories.

Vitest doesn't normally require a `vitest.config.*` file to be present in each workspace directory. This utility enforces the config file requirement so that: a) testing a package can be disabled by omitting the config file, or b) multiple test configurations can be defined for a single package by creating multiple config files.

File: `vitest.workspace.ts`

```ts
import { defineWorkspace } from '@seahax/vitest';

export default defineWorkspace();
```

Workspace directory globs can also be provided manually.

```ts
export default defineWorkspace(['packages/*']);
```
npm package: @seahax/zod-codec
Description: Bi-directional transformation between two Zod schemas (ie. encode and decode, codec).
Latest version: 0.3.6

# @seahax/zod-codec

Bi-directional transformation between two Zod schemas (ie. encode and decode, codec).

## Example

Declare a codec which translates bi-directionally between a `Date` and a `string` in ISO format.

```ts
import { zodCodec } from '@seahax/zod-codec';

const [DATE, DATE_STRING] = zodCodec(
  {
    input: z.instanceof(Date),
    transform: (input) => {
      // The input is typed as Date.
      // The return type must be the other input type (ISO datetime string).
      return input.toISOString();
    },
  },
  {
    input: z.string().datetime(),
    transform: (input) => {
      // The input is typed as an ISO datetime string.
      // The return type must be the other input type (Date).
      return Date.parse(input)
    },
  },
});
```

Use the codec to transform (encode/decode) dates to strings and vice versa.

```ts
const date: Date = DATE.parse('2023-01-01T00:00:00Z');
const dateString: string = DATE_STRING.parse(date);
```