open-index/open-npm huggingface dataset:
npm package: @jdmichaud/netpbm
Description: A library for reading netpbm files
Author: jdmichaud
Latest version: 0.2.1

# netpbm.js

A no-dependency library to parse Netpbm (and Netpgm and Netppm) files in javascript.

⚠️ Only manages ASCII format for now.

# Usage

Use the decode function who's signature is...:
```ts
function decode(data: Uint8Array): ImageData;
```
... this way:
```js
const content = fs.readFileSync(content).buffer;
const imageData = decode(content);
```

Or the fromString function who's signature is...:
```ts
function fromString(content: string): ImageData;
```
... this way:
```js
const J = `P1
# This is an example bitmap of the letter "J"
6 10
000010000010000010000010000010000010100010011100000000000000`;
const imageData = fromtString(J);
```

# Test

Execute:
```bash
npm test
```

and open your browser to:
```
http://localhost:10001
```

In the console, all tests should be passed.
npm package: @jdmichaud/observable
Description: tc-39 compatible observable
Author: jdmichaud
Latest version: 0.5.6

# Observable

An implementation of the Observable interfaces as presented in the
[tc-39 proposal](https://github.com/tc39/proposal-observable).

# How to use

```javascript
const observable = new Observable.Observable(observer => {
  observer.next(42);
  return () => {};
})

observable.subscribe(value => console.log(value));
```

outputs:
```
42
```

# Subject extension

In addition to the interfaces as described in the tc-39 proposal, more
convenient interfaces are proposed as the `Subject`:
```javascript
const subject = new Observable.Subject();
subject.subscribe({
  next: value => console.log(value),
  error: error => console.log(error),
});
subject.next(42);
subject.error('error!');
```
outputs:
```
42
error!
```

## There can be multiple observers to a subject

```javascript
const subject = new Observable.Subject();
subject.subscribe(value => console.log(`1: ${value}`));
subject.subscribe(value => console.log(`2: ${value}`));
subject.next(42);
```
outputs:
```
1: 42
2: 42
```

## BehaviorSubject to attach a variable to a Subject

A `BehaviorSubject` is a subject that always have a value and which can be
queried at any time:
```javascript
const answer = new Observable.BehaviorSubject(42);
console.log('the answer is:', answer.get());
answer.subscribe(value => console.log('oops, the answer changed:', value));
answer.next(666);
```

# Useful shortcuts

## `all`

`all` will wait for all the provided observable to have a value and will then
forward those values all at once:
```typescript
import { Observable } from '@jdmichaud/observable'

Observable.all([subject1, subject2], ([value1, value2] =>
  console.log(value1, value2)));
subject1.next(42);
// nothing happens, as subject2 has not yet been triggered.
subject2.next('the answer to everything');
// prints: "42 the answer to everything"
subject1.next(666);
// prints: "666 the answer to everything"
```

## `chain`

Chains observable in order to smoothly apply processing on next values.
Error and complete signals are being forwarded to returned observable.
Errors can be raised to the error parameter of the next function parameter:

```typescript
import { Observable } from '@jdmichaud/observable'

const observable = new Observable<number>(observer => {
  observer.next(42);
  return () => {};
});

let observedValue: string;
// First converts to string.
Observable.chain(observable, value => value.toString()).subscribe({
  next: value => observedValue = value,
});
```

## `to`

Converts the provided parameters to an observable:
```typescript
import { Observable } from '@jdmichaud/observable'

Observable.to(1, 2, 3).subscribe(console.log);
```

## `from`

Converts an array or an iterable to an Observable:
```typescript
import { Observable } from '@jdmichaud/observable'

const a = [1, 2, 3];
Observable.from(a).subscribe(console.log);
```
npm package: @jdmichaud/rdicom-web
Description: A Javascript DICOM parser
Author: jdmichaud
Latest version: 0.5.2

# rdicom-web

Provides DICOM access in Javascript. This packages relies on the [rdicom](https://github.com/jdmichaud/rdicom)
library to parse DICOM files.

### Usage

Install the package using npm:
```bash
npm install --save @jdmichaud/rdicom-web
```

To load a DICOM file
```typescript
import { LocalDataset, LocalDicomInstanceDecoder } from '../dist/index';

const instanceDecoder = new LocalDicomInstanceDecoder();
await instanceDecoder.init();
// We assume the file content is in a ArrayBuffer called buffer
const instance = instanceDecoder.getInstanceFromBuffer(buffer);
const columns = localDataset.getColumns();
const rows = localDataset.getRows();
console.log(`columns ${columns} rows ${rows}`);
```
npm package: @jdmichaud/smartgrid
Description: Arrange a grid according to the screen and item ratio
Author: jdmichaud
Latest version: 1.0.2

Arrange a grid of item to optimize space.

The items are arranged according to the ratio of the items and the ratio on the
containing div.

Test it with:
```
git clone https://github.com/jdmichaud/smart-grid.git
cd smart-grid
python -m SimpleHTTPServer
```

And open your browser to http://localhost:8000
npm package: @jdmichaud/ts-workers
Description: A typescript library to facilitate the usage of typesafe Web Workers.
Author: jdmichaud
Latest version: 0.1.1

# ts-workers

A thin typescript layer on top of the [Worker API](https://developer.mozilla.org/en-US/docs/Web/API/Worker)
to facilite its usage in a typesafe way. For example:
```typescript
import { Task } from '../src';

async function main(): Promise<void> {
  const res: number = await Task.create((b: number) => b * 2).createThread().run(21);
  console.log(res); // 42
}

window.onload = main;
```

Types are checked:
```typescript
  // Compilation will fail because the return type is not string but number.
  const res: string = await Task.create((b: number) => b * 2).createThread().run(21);
  // Here the parameter type is incorrect.
  const res: number = await Task.create((b: number) => b * 2).createThread().run('21');
```

Queue can be used to spread tasks to a pool of workers:
```typescript
import { Queue, ThreadBuilder, Thread } from '../src';

async function main(): Promise<void> {
  const queue = ThreadBuilder
    .create(delay => new Promise<void>(resolve => setTimeout(() => resolve(), delay)))
    .createThreads(navigator.hardwareConcurrency)
    .queue();
  const delays = Array.from(Array(navigator.hardwareConcurrency * 2))
    .map(_ => [Math.random() * 1000 | 0]);
  const promises = queue.run(delays as any);

  promises.forEach((promise, index) => {
    const span = document.createElement('span');
    span.innerText = Number(delays[index]).toString();
    span.style.backgroundColor = '#F00';
    const div = document.createElement('div');
    div.appendChild(span);
    document.body.appendChild(div);
    promise.then(() => span.style.backgroundColor = '#0F0')
  })
}

window.onload = main;
```

# How to use

Simply install it from the npm registry:
```bash
npm install @jdmichaud/ts-workers
```

# Limitations

* Works only on browsers implementing ES2020.

# Contributions

Clone the project:
```bash
git clone <this repo>
```

Install dependencies:
```bash
npm install
```

Build:
```bash
npm run all
```

Launch the developement application:
```bash
npm run dev
```

# License

MIT © Jean-Daniel Michaud
npm package: @jdmichaud/wasm-toolkit
Description: Statically compiled clang binary and friends for WASM accessible via npx
Author: jdmichaud
Latest version: 19.0.0

# wasm-toolkit

Ensures your environment can compile C/C++ code to freestanding WASM.
Either use the local `clang` installation or provides statically build binaries.

# How to install

```bash
npm install @jdmichaud/wasm-toolkit
```

### Build to wasm

```bash
cat > add.c
extern void *malloc(unsigned long size);

// add.c
int *add (int first, int second)
{
  int *i = malloc(sizeof (int));
  *i = first + second;
  return i;
}
<EOF>
npx clang --target=wasm32 \
  --no-standard-libraries \
  -Wl,--export-all -Wl,--no-entry -Wl,--allow-undefined \
  -o add.wasm add.c
```

### Inspect a WASM file

```bash
npx wasm-objdump -x add.wasm
```

# How to build

You will need:
- `cmake` version 3 or above

```bash
npm run build
```

And hopefully `npm pack` will suffice to package the built tools.

# Contribute

## How to build on linux

You will need a C/C++ compiler (gcc 11 is fine) and cmake (at least version 3).
To build clang, execute:
```bash
./make-clang-linux.sh
```

To build the WASM utilities:
```bash
./make-wabt-linux.sh
```

This should produce the clang/ldd and utilities statically linked binaries in
the appropriate `dist/` folder.

## How to build on windows

You will need a C/C++ compiler (Visual Studio 2019 is fine) and cmake (at least
version 3).

To build clang, execute:
```bash
./make-clang-win.sh
```

To build the WASM utilities:
```bash
./make-wabt-win.sh
```

## Windows VM on linux

Useful documentation here: https://wiki.gentoo.org/wiki/QEMU/Windows_guest

Create a drive:
```bash
qemu-img create -f qcow2 win10.img 30G
```

Download a Windows ISO from microsoft website.

Download the windows drivers ISO image:
```bash
curl -sOL https://fedorapeople.org/groups/virt/virtio-win/direct-downloads/stable-virtio/virtio-win.iso
```

Start the VM (replace the ISO name accordingly):
```bash
qemu-system-x86_64 -enable-kvm \
  -cpu host \
  -drive file=win10.img,if=virtio \
  -net nic,model=rtl8139 \
  -net user,hostname=windowsvm \
  -m 16G \
  -monitor stdio \
  -name "Windows" \
  -boot d \
  -drive file=WindowsISO.iso,media=cdrom \
  -drive file=virtio-win-0.X.XXX.iso,media=cdrom
```

You might want to install windows without the `-nic` option first to avoid
creating an online account and enable the option on the first boot.

Once virtdio drivers are install, you can add the options:
```bash
-vga virtio
-smp cores=$(nproc)
```

On windows, you will need build tools to be installed. You can find them
[there](https://visualstudio.microsoft.com/downloads/).

Additionally, you will need [cmake](https://cmake.org/download/) and
[python](https://github.com/winpython/winpython/releases/tag/4.7.20220709final)
(at least 3.9).