Giter Site home page Giter Site logo

andersy005 / zarrita.js Goto Github PK

View Code? Open in Web Editor NEW

This project forked from manzt/zarrita.js

0.0 1.0 0.0 407 KB

A JavaScript toolkit for working with chunked, compressed, n-dimensional arrays

Home Page: https://manzt.github.io/zarrita.js/

License: MIT License

JavaScript 2.93% Python 6.88% TypeScript 88.60% HTML 1.60%

zarrita.js's Introduction

Here be dragons ๐Ÿ‰

zarrita.js

zarrita is a minimal & modular Zarr implementation in TypeScript.

  • Zero dependencies (optionally scijs/ndarray)
  • Runs natively in Node, Browsers, and Deno (ESM)
  • Supports v2 or v3 protocols, C & F-order arrays, and diverse data-types
  • Allows flexible storage backends and compression codecs
  • Provides rich, in-editor type information via template literal types

Usage

import * as zarr from "zarrita";
import { FetchStore } from "@zarrita/storage";

const store = new FetchStore("http://localhost:8080/data.zarr");
const arr = await zarr.open(store, { kind: "array" }); // zarr.Array<DataType, FetchStore>

// read chunk
const chunk = await arr.getChunk([0, 0]);

// Option 1: Builtin getter, no dependencies
const full = await zarr.get(arr); // { data: Int32Array, shape: number[], stride: number[] }

// Option 2: scijs/ndarray getter, includes `ndarray` and `ndarray-ops` dependencies
import { get } from "@zarrita/ndarray";
const full = await get(arr); // ndarray.Ndarray<Int32Array>

// read region
const region = await get(arr, [null, zarr.slice(6)]);

Zarr building blocks

zarrita's API is almost entirely tree-shakeable, meaning users are able to pick and choose only the features of Zarr which are necessary for an applications. At its core, the zarr.Array class allows accessing and decoding individual array chunks. "Fancy-indexing" and "slicing" are accomplished via (optional) functions which operate on zarr.Array objects.

Thus, you only pay for these features if used (when bundling for the web). This design choice differs from existing implemenations of Zarr in JavaScript, and allows zarrita to be both minimal and more feature-complete if necessary.

classDiagram
    indexing --|> core : uses
    ndarray --|> indexing : uses
    ndarray --|> core : uses
    core --|> storage : uses

    class indexing {
        - get(arr: zarr.Array, selection)
        - set(arr: zarr.Array, selection, view)
        - slice and index multiple chunks
        - returns strided arrays
    }

    class ndarray {
        - get(arr: zarr.Array, selection)
        - set(arr: zarr.Array,  selection, view)
        - slice and index multiple chunks
        - returns scijs/ndarray objects
    }

    class core {
        - open(store: Readable)
        - create(store: Writeable)
        - zarr.Array and zarr.Group
        - access and decode individual chunks
    }

    class storage {
        - Readable
        - Writeable
        - Map()
        - FetchStore()
        - FileSystemStore()
        - ReferenceStore()
        - ZipStore()
    }
Loading

In Browser (or Deno)

import * as zarr from "https://esm.sh/zarrita";

In Node.js or Application Bundles

Import using ES module syntax as a namespace:

import * as zarr from "zarrita";

or with targeted named imports:

import { open } from "zarrita";

Development

This library uses the pnpm package manager.

pnpm install
pnpm build
pnpm test

zarrita.js's People

Contributors

manzt avatar github-actions[bot] avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.