{"id":13711176,"url":"https://github.com/ethersphere/mantaray-js","last_synced_at":"2025-05-03T19:30:59.875Z","repository":{"id":42364896,"uuid":"385713690","full_name":"ethersphere/mantaray-js","owner":"ethersphere","description":"Mantaray data structure in JS","archived":true,"fork":false,"pushed_at":"2025-04-07T14:42:45.000Z","size":469,"stargazers_count":9,"open_issues_count":15,"forks_count":6,"subscribers_count":6,"default_branch":"master","last_synced_at":"2025-04-07T20:21:24.381Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"TypeScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"bsd-3-clause","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/ethersphere.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":"CODEOWNERS","security":null,"support":null}},"created_at":"2021-07-13T19:24:47.000Z","updated_at":"2025-04-07T14:43:38.000Z","dependencies_parsed_at":"2023-02-16T19:00:54.977Z","dependency_job_id":null,"html_url":"https://github.com/ethersphere/mantaray-js","commit_stats":null,"previous_names":[],"tags_count":5,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ethersphere%2Fmantaray-js","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ethersphere%2Fmantaray-js/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ethersphere%2Fmantaray-js/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ethersphere%2Fmantaray-js/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/ethersphere","download_url":"https://codeload.github.com/ethersphere/mantaray-js/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":252241954,"owners_count":21717076,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2024-08-02T23:01:05.381Z","updated_at":"2025-05-03T19:30:59.869Z","avatar_url":"https://github.com/ethersphere.png","language":"TypeScript","funding_links":[],"categories":["Projects"],"sub_categories":["Libraries"],"readme":"# ⚠️ Deprecation Notice\n\n**This project is no longer maintained.** The `MantarayNode` class has been merged into [bee-js](https://github.com/ethersphere/bee-js) with additional features and fixes. Please use that instead.\n\n# Description\n\nWith this package you can manipulate and interpret mantaray data via `MantarayNode` and `MantarayFork` abstractions.\n\n# Exported Functions and Classes\n\nYou can import the followings directly from `mantaray-js`:\n\n* MantarayNode        # class abstracting and manipulating Mantaray Node data\n* MantarayFork        # class abstracting and manipulating Mantaray Fork data\n* checkForSeparator   # checks for separator character in the node and its descendants prefixes\n* initManifestNode    # initialize a manifest node\n* loadAllNodes        # loads all mantaray nodes recursively from the storage\n* equalNodes          # checks whether the two given Mantaray Nodes objects are equal in the in-memory abstraction level\n* Utils               # all used utility functions in the library. Mostly operating on `Uint8Array` objects.\n* types*              # not callable, referring all types exported and reachable from the index\n\n# Basic usage\n\n## Construct Mantaray\n\n```ts\nimport { initManifestNode, Utils } from 'mantaray-js'\n\nconst node = initManifestNode()\nconst address1 = Utils.gen32Bytes() // instead of `gen32Bytes` some 32 bytes identifier that later could be retrieved from the storage\nconst address2 = Utils.gen32Bytes()\nconst address3 = Utils.gen32Bytes()\nconst address4 = Utils.gen32Bytes()\nconst address5 = Utils.gen32Bytes()\nconst path1 = new TextEncoder().encode('path1/valami/elso')\nconst path2 = new TextEncoder().encode('path1/valami/masodik')\nconst path3 = new TextEncoder().encode('path1/valami/masodik.ext')\nconst path4 = new TextEncoder().encode('path1/valami')\nconst path5 = new TextEncoder().encode('path2')\nnode.addFork(path1, address1)\nnode.addFork(path2, address2, { vmi: 'elso' }) // here 'vmi' is a key of metadata and 'elso' is its value\nnode.addFork(path3, address3)\nnode.addFork(path4, address4, { vmi: 'negy' })\nnode.addFork(path5, address5)\nnode.removePath(path3)\n// (...)\n```\n\n## Mantaray Storage Operations\n\n```ts\nimport { MantarayNode } from 'mantaray-js'\n\nconst node = new MantarayNode()\n// here `reference` parameter is a `Reference` type which can be a 32 or 64 bytes Uint8Array\n// and `loadFunction` is a [loadFunction: async (address: Reference): Promise\u003cUint8Array\u003e] typed function\n// that returns the serialised raw data of a MantarayNode of the given reference\nawait node.load(loadFunction, reference)\n\n// Manipulate `node` object then save it again\n// (...)\n\n// save into the storage with a storage handler [saveFuncion: async (data: Uint8Array): Promise\u003cReference\u003e]\nconst reference = await node.save(saveFunction)\n```\n\n# node binary format\n\nThe following describes the format of a node binary format.\n\n```\n┌────────────────────────────────┐\n│    obfuscationKey \u003c32 byte\u003e    │\n├────────────────────────────────┤\n│ hash(\"mantaray:0.1\") \u003c31 byte\u003e │\n├────────────────────────────────┤\n│     refBytesSize \u003c1 byte\u003e      │\n├────────────────────────────────┤\n│       entry \u003c32/64 byte\u003e       │\n├────────────────────────────────┤\n│   forksIndexBytes \u003c32 byte\u003e    │\n├────────────────────────────────┤\n│ ┌────────────────────────────┐ │\n│ │           Fork 1           │ │\n│ ├────────────────────────────┤ │\n│ │            ...             │ │\n│ ├────────────────────────────┤ │\n│ │           Fork N           │ │\n│ └────────────────────────────┘ │\n└────────────────────────────────┘\n```\n\n## Fork\n\n```\n┌───────────────────┬───────────────────────┬──────────────────┐\n│ nodeType \u003c1 byte\u003e │ prefixLength \u003c1 byte\u003e │ prefix \u003c30 byte\u003e │\n├───────────────────┴───────────────────────┴──────────────────┤\n│                    reference \u003c32/64 bytes\u003e                   │\n│                                                              │\n└──────────────────────────────────────────────────────────────┘\n```\n\n### Fork with metadata\n\n```\n┌───────────────────┬───────────────────────┬──────────────────┐\n│ nodeType \u003c1 byte\u003e │ prefixLength \u003c1 byte\u003e │ prefix \u003c30 byte\u003e │\n├───────────────────┴───────────────────────┴──────────────────┤\n│                    reference \u003c32/64 bytes\u003e                   │\n│                                                              │\n├─────────────────────────────┬────────────────────────────────┤\n│ metadataBytesSize \u003c2 bytes\u003e │     metadataBytes \u003cvarlen\u003e     │\n├─────────────────────────────┘                                │\n│                                                              │\n└──────────────────────────────────────────────────────────────┘\n```\n\n# Testing\n\nThe testing needs running Bee client node for integration testing.\nYou can set `BEE_POSTAGE` environment variable with a valid Postage batch or the test will create one for you.\n\nThe default value of the Bee Debug API endpoint is `http://localhost:1635`. \nIf your address diverges from that, please, set `BEE_DEBUG_API_URL` system environment variable with yours.\n\nTo run test execute\n\n```sh\nnpm run test\n```\n\n## Maintainers\n\n- [nugaon](https://github.com/nugaon)\n\nSee what \"Maintainer\" means [here](https://github.com/ethersphere/repo-maintainer).\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fethersphere%2Fmantaray-js","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fethersphere%2Fmantaray-js","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fethersphere%2Fmantaray-js/lists"}