open-index/open-npm huggingface dataset:
npm package: @probedjs/liberator
Description: A stubornly opiniated environment for typescript libraries.
Author: Francois Chabot
Latest version: 0.2.2

# Liberator

A stubornly opiniated environment for typescript libraries. 

Using Liberator, you get:
- Typescript.
- A clean `dist/` containing only what users of the library need. 
- Multiple build targets: esm, cjs, umd, prod, dev.
- Test and coverage of both the source and the various built libraries.
- Linting with eslint and prettier.
- A clean repository without a bazillion config files.

## Getting started

Here's the very few rules of thumb you need to keep in mind:

1. All the source code goes in `src/`.
2. `src/index.ts` is the sole entrypoint.
3. Specs and tests can be either in `src/` or `tests/`
4. You do **not** publish the root repository, the `dist/` directory itself is published.
5. `*.spec.ts` runs on both the source **and** the built library. 

### From scracth:
```
npx @probedjs/liberator my-library
// or
npx @probedjs/liberator @my-scope/my-library
```

### For an existing library

The easiest way to go about this is to create a placeholder library using `npx @probedjs/liberator placeholderLib`, and use it as a reference point.

Make sure you don't forget to set `"private": true` in your package.json so that you don't accidentally publish the source version of the library.

## Configuring

For the time being, there is no configuration options whatsoever, since the main reason for it existing is to unify configuration accross a bunch of projects.
That being said, if there is a demand for it, we can make things a bit more parametrizable.

## Building

The following command will populate the `dist/` directory with the library ready to be published.
```
npm run build
```

## Testing

Testing the source. This will run all files named `*.test.ts` as well as `*.spec.ts` on the library as present in the `src/` directory:
```
npm run test
```

Testing the built library. This will run all files named `*.spec.ts` on all versions of the library present in the `dist/` directory:
```
npm run testDist
```

## Misc.

### Keeping Visual Studio Code happy

If you are using the eslint VSCode extension, you need to point it in the right direction:

.vscode/settings.json
```
{
    "eslint.options": {
        "configFile" : "node_modules/@probedjs/eslint-config/index.js"
    }
}
```
npm package: @probedjs/task-runner
Description: A straightforward batch task runner with good looking logs.
Author: Francois Chabot
Latest version: 0.2.1

#  Task Runner

A straightforward batch task runner with good looking logs.

N.B. This library does not use (liberator)[http://example.com], because it is a dependency of it.


## Usage:

### Creating and running a task:
```
import { run } from '@probedjs/task-runner';

const result = run("My Build", async () => {
    // Do the build here.

    return "all done!";
})

console.log(await result); // Will print "all done!"
```

### Running Subtasks:

When `run()` is called from within a task, that creates a subtask.

```
import {run} from '@probedjs/task-runner';

await run("My Build", async () => {
    run("step 1", async ()=>{
        //...
    })

    run("step 2", async ()=>{
        //...
    })

    // No need to explicitely await the subtasks
})
```

### Dependencies:

If a task depends on the results of another, simply await the results 

```
import {run} from '@probedjs/task-runner';

await run("My Build", async () => {
    const dataProm = run("step 1", async ()=>{
        return { filename: "path/to/file" };
    })

    run("step 2", async () => {
        const data = await dataProm;

        // use data.
    })
})
```

### Dynamic tasks:

Task lists do not have to be fixed. They can even depend on the result of some other task:

```
import {run} from '@probedjs/task-runner';

await run("My Build", async () => {
    const cacheProm = run("Load Cache", async ()=>{
        // return either a cache or undefined.
    })


    if(await cacheProm === undefined) {
        run("full build", async()=>{
            //...
        });
    }
})
```

### Optional tasks:

Optional tasks do not fail their parent if they fail themselves:

```
import {run, runOptional} from '@probedjs/task-runner';
import { default as fs } from 'fs-extra';

await run("My Build", async () => {
    const cleanupDone = runOptional("Remove old build", ()=>fs.rm("path/to/dist"));

    run("Build", async () => {
        await cleanupDone;

        // Do the build
    });
})
```

### Messages and status:

For the most part, status is handled automatically. However, you still can set the status of a
task manually.

```
import { run, setMessage, setStatus } from '@probedjs/task-runner';

await run("My Build", async () => {
    setMessage("Hi There");
    setStatus('warn');
})
```
npm package: @probedjs/work-pool
Description: A high-performance and flexible work pool
Author: Francois Chabot
Latest version: 0.4.0

#  work-pool

A high-performance and flexible work pool. This was built specifically to address the specific needs of @probedjs/testing.

- Works with both CommonJS and ECMAScript modules.
- Heuristic-based task assignment.
- Supports both synchronous and asynchronous tasks.
- Work stealing.

## Getting Started

### Entrypoint module

In order to queue and perform tasks, you need an entrypoint module:

```javascript
// MyWorker.js
export const workerEntrypoint = (taskArg) => {
    return `Hello, ${taskArg}!`;
  },
};

workerEntrypoint.modulePath = import.meta.url;
workerEntrypoint.moduleSymbol = 'workerEntrypoint';
```

### Creating a work pool and dispatching work.

```javascript
import { WorkerPool } from '@probedjs/work-pool';
import { workerEntrypoint } from './MyWorker'

const main = async () => {
  const pool = new WorkerPool(workerEntrypoint);

  const result = await pool.addTask('World');
  console.log(result);

  pool.dispose();
};

main();
```

### Init and teardown

You can also register lifetime callbacks for the worker. These functions will be called once per worker.

```javascript
export const workerEntrypoint = (taskArg) => {
  return `Hello, ${taskArg}!`;
};

workerEntrypoint.modulePath = import.meta.url;
workerEntrypoint.moduleSymbol = 'workerEntrypoint';
workerEntrypoint.onWorkerStart = (client) => {}
workerEntrypoint.onWorkerExit = (client) => {}
```

### Sending and receiving messages

On top of dispatching tasks, messages can be send to and from workers.

```javascript
import { WorkerPool } from '@probedjs/work-pool';

export const workerEntrypoint = (taskArg, client) => {
  client.postMessageToPool("starting", taskArg);
  return `Hello, ${taskArg}!`;
};
workerEntrypoint.modulePath = fileURLToPath(import.meta.url);
workerEntrypoint.moduleSymbol = 'workerEntrypoint';

workerEntrypoint.onWorkerStart = (client) => {
  client.onMessage("hi", (contents, client)=>{
    console.log(`pool says hi: ${contents}`);
  })
}

const main = async () => {
  const pool = new WorkerPool(workerEntrypoint);

  pool.onMessage("starting", (content, origin) => {
    console.log(`got starting message ${content} from worker ${origin}`);
  });


  pool.addTask("joe");

  // Send a message to every worker.
  pool.postMessageToWorkers("Hi!");

  await pool.whenIdle();

  pool.dispose();
};

if(isMainThread) {
  main();
}
```