# hdf5-io

> Simple utility for reading / writing HDF5 files

Latest version **0.0.33** (published 2023-05-13) · AGPL-3.0-or-later license · 0 weekly downloads

## Install

```sh
npm install hdf5-io
pnpm add hdf5-io
yarn add hdf5-io
bun add hdf5-io
```

## Health

**Score 30/100 (F)** — status: abandoned.

Positive: has types; esm support; no vulnerabilities; high quality score.

Warnings: low downloads; pre 1.0.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 0.0.33 |
| Published | 2023-05-13 |
| First published | 2022-02-17 |
| Weekly downloads | 0 |
| License | AGPL-3.0-or-later |
| TypeScript types | bundled |
| Module format | ESM + CommonJS |
| Node | >=18.0.0 |
| Dependencies | 0 |
| Unpacked size | 9.5 MB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 4 |
| Author | Garrett Flynn |
| Maintainers | garrettmflynn |
| Keywords | hdf5, data |

## Links

- npm: https://www.npmjs.com/package/hdf5-io
- Repository: https://github.com/garrettmflynn/hdf5-io
- npm.io page: https://npm.io/package/hdf5-io

## Alternatives

- [gamedig](https://npm.io/package/gamedig.md) — 29.3K weekly downloads
- [join-monster](https://npm.io/package/join-monster.md) — 12.8K weekly downloads
- [masked](https://npm.io/package/masked.md) — 5.5K weekly downloads
- [@comunica/actor-query-process-explain-logical](https://npm.io/package/@comunica/actor-query-process-explain-logical.md) — 4.7K weekly downloads
- [@veracity/vui](https://npm.io/package/@veracity/vui.md) — 4.6K weekly downloads

## Recent versions

- 0.0.33 (latest) — 2023-05-13
- 0.0.32 — 2023-05-13
- 0.0.31 — 2023-05-11
- 0.0.30 — 2023-05-11
- 0.0.29 — 2023-05-11
- 0.0.28 — 2023-05-05
- 0.0.27 — 2023-04-25
- 0.0.26 — 2023-04-24
- 0.0.25 — 2023-04-24
- 0.0.24 — 2023-04-24
- 0.0.23 — 2023-04-24
- 0.0.22 — 2023-04-24
- 0.0.21 — 2023-04-24
- 0.0.20 — 2023-04-24
- 0.0.19 — 2023-02-19
- … 19 more at https://npm.io/package/hdf5-io/versions

## README

# hdf5-io
Simple utility for reading / writing HDF5 files on the browser

![status](https://img.shields.io/npm/v/hdf5-io) 
![downloads](https://img.shields.io/npm/dt/hdf5-io)
![lic](https://img.shields.io/npm/l/hdf5-io)

## Description
**hdf5-io** is a simple utility for handling reading / writing HDF5IO files. As an extension to the **h5wasm** library, it immediately emits and consumes JavaScript objects containing all the relevent data.

## Getting Started

``` javascript 

// Import hdf5-io Library
import HDF5IO from "https://cdn.jsdelivr.net/npm/hdf5-io/dist/index.esm.js";

// Initialize HDF5IO instance (all optional parameters)
const io = new HDF5IO(
    {
        postprocess: (hdf5Object) => hdf5Object,
        debug: true
    },
    
)

await io.initFS('/hdf5-test') // initialize local filesystem

// load a remote file
const file = await io.fetch(
     'https://raw.githubusercontent.com/OpenSourceBrain/NWBShowcase/master/FergusonEtAl2015/FergusonEtAl2015.nwb', // URL to get file from
    'FergusonEtAl2015.nwb',  // Save the file with this name
    (ratio) => console.log('Load Status', `${(ratio * 100).toFixed(2)}%`),
    (remote) => console.log('Origin', (remote) ? path : 'Local')
)

// save the file to local storage
const filename = io.save(file)

// list files in local storage
const files = await io.list()

// get specific file from local storage
const lsFile = await io.load(filename)

```

## Conventions
### Datasets
When reading an HDF5 file, both datasets and attributes are transformed into JavaScript objects that hold their respective metadata:
```javascript
const datasetValue = 1 // From HDF5 file
const output = new Number(datasetValue)
```

If you are adding a new dataset, this **must** be an Object when written to the file:
```javascript
const object = {
    dataset: new Number(1),
    attribute: 1
}
```

## Known Issues
- Files that previous could be streamed (e.g. https://dandiarchive.s3.amazonaws.com/blobs/aff/5f6/aff5f64d-9a69-4ff3-a6fe-13a3f30dca50) no longer work
- Node.js doesn't work when bundled—unless you manually provide a `h5wasm` instance
- Streaming doesn't work in Node.js

## Acknowledgments
**hdf5-io** was originally prototyped by [Garrett Flynn](https;//github.com/garrettmflynn) as the [**WebNWB**](https;//github.com/brainsatplay/WebNWB) project at the [2022 NWB-DANDI Remote Developer Hackathon](https://neurodatawithoutborders.github.io/nwb_hackathons/HCK12_2022_Remote/).

---
_Source: https://npm.io/package/hdf5-io · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
