open-index/open-npm huggingface dataset:
npm package: @omegajs/errors
Description: Module for logging Omega Scroll-derived errors.
Latest version: 1.0.1

# @omegajs/errors

Module for logging oScroll-derived errors.

## Install Via L1FE's NPM
```
npm config set registry https://npm.l1fe.tech
npm install @omegajs/errors
```

## Install Via L1FE's Git Repository
```
git clone https://lab.l1fe.tech/omega/errors.git
cd errors
npm install
```

## Usage

```js
const { BLOCK_NOT_AVAILABLE } = require('@omegajs/errors')

throw BLOCK_NOT_AVAILABLE()
```

## List

- BAD_ARGUMENT
- STORAGE_EMPTY
- STORAGE_CONFLICT
- INVALID_SIGNATURE
- INVALID_CAPABILITY
- INVALID_CHECKSUM
- INVALID_OPERATION
- INVALID_PROOF
- BLOCK_NOT_AVAILABLE
- SNAPSHOT_NOT_AVAILABLE
- REQUEST_CANCELLED
- REQUEST_TIMEOUT
- SESSION_NOT_WRITABLE
- SESSION_CLOSED
- BATCH_UNFLUSHED
- BATCH_ALREADY_EXISTS
- BATCH_ALREADY_FLUSHED
- OPLOG_CORRUPT
- OPLOG_HEADER_OVERFLOW
- INVALID_OPLOG_VERSION
- WRITE_FAILED

## License

Apache-2.0
npm package: @omegajs/id-encoding
Description: Transforms Scroll keys between z-base32 and hexadecimal formats, enabling seamless conversion and compatibility.
Latest version: 1.0.0

# Scroll ID Encoding
## @omegajs/id-encoding
Transforms Scroll keys between z-base32 and hexadecimal formats, enabling seamless conversion and compatibility.


## Install Via L1FE's NPM
```
npm config set registry https://npm.l1fe.tech
npm install @omegajs/id-encoding
```

## Install Via L1FE's Git Repository
```
git clone https://lab.l1fe.tech/omega/id-encoding.git
cd id-encoding
npm install
```

## Usage

```js
const { encode, decode, normalize } = require('@omegajs/id-encoding')

const id = encode(scroll.key) // (z-base32 String)
const hexEncoded = scroll.key.toString('hex')

const scroll = new Scroll(ram, decode(id)) 
const scroll2 = new Scroll(ram, decode(hexEncoded)) // Will also work with hex

const id2 = normalize(id)
const id3 = normalize(hexEncoded)
```

## API

#### `const id = encode(scrollKey)`

Encodes a 32-byte Scroll key into a z-base32 id.

`scrollKey` must be a Buffer or an ArrayBuffer.

#### `const buf = decode(scrollId)`

Decodes an id into a Scroll key.

If `scrollId` is a 52-character String, it will be decoded as z-base32.

If `scrollId` is a 64-character String, it will be decoded as hex.

If `scrollId` is already a Buffer and is a valid id, it will be returned as-is.

#### `const id = normalize(any)`

Decodes and encodes the input `any` to always return a z-base32 id.

#### `isValid(any)`

Returns a boolean indicating whether the key is a valid Scroll key (meaning that it can be decoded/normalised).

## License

Apache-2.0
npm package: @omegajs/mirror-drive
Description: Mirror a Omega Drive or Local Drive into another one
Latest version: 1.0.0

# Mirror Omega Drives
## @omegajs/mirror-drive

Mirror an Omega Drive or Localdrive into another one

## Install Via L1FE's NPM
```
npm config set registry https://npm.l1fe.tech
npm install @omegajs/mirror-drive
```

## Install Via L1FE's Git Repository
```
git clone https://lab.l1fe.tech/omega/mirror-drive.git
cd mirror-drive
npm install
```

## Usage
```js
import MirrorDrive from '@omegajs/mirror-drive'

const src = new Localdrive('./src')
const dst = new Drive(vault)

const mirror = new MirrorDrive(src, dst)
console.log(mirror.count) // => { files: 0, add: 0, remove: 0, change: 0 }

for await (const diff of mirror) {
  console.log(diff) /* {
    op: 'add',
    key: '/new-file.txt',
    bytesRemoved: 0,
    bytesAdded: 4
  }*/
}

console.log(mirror.count) // => { files: 1, add: 1, remove: 0, change: 0 }
```

Another example:
```js
const mirror = new MirrorDrive(src, dst)

console.log(mirror.count) // => { files: 0, add: 0, remove: 0, change: 0 }
await mirror.done()
console.log(mirror.count) // => { files: 1, add: 1, remove: 0, change: 0 }
```

## API

#### `const mirror = new MirrorDrive(src, dst, [options])`

Creates a mirror instance to efficiently move `src` drive into `dst` drive.

Available `options`:
```js
{
  prefix: '/',
  dryRun: false,
  prune: true,
  includeEquals: false,
  filter: (key) => true,
  metadataEquals: (srcMetadata, dstMetadata) => { ... }
  batch: false,
  entries: null // Array of key entries (if you use this then prefix is ignored)
}
```

#### `mirror.count`

It counts the total files proccessed, added, removed, and changed.

Default value: `{ files: 0, add: 0, remove: 0, change: 0 }`

#### `await mirror.done()`

It starts processing all the diffing until is done.

## License

Apache-2.0
npm package: @omegajs/serve-drive
Description: HTTP drive server for entries delivery. Auto detects types like video, images, etc
Latest version: 1.0.0

# Serve Omega Drives
## @omegajs/serve-drive

HTTP Omega Drive server for entries delivery. Auto detects types like video, images, etc

## Install Via L1FE's NPM
```
npm config set registry https://npm.l1fe.tech
npm install @omegajs/serve-drive
```

## Install Via L1FE's Git Repository
```
git clone https://lab.l1fe.tech/omega/serve-drive.git
cd serve-drive
npm install
```

## Usage

Single drive:
```js
const ServeDrive = require('@omegajs/serve-drive')
const Localdrive = require('@omegajs/local-drive')

const drive = new Localdrive('./my-folder')
await drive.put('/index.html', Buffer.from('hi'))

const serve = new ServeDrive({ get: ({ key, filename, version }) => drive })
await serve.ready()
console.log('Listening on http://localhost:' + serve.address().port)

// Try visiting http://localhost:49833/index.html
```

Multiple drives:
```js
const Localdrive = require('@omegajs/local-drive')
const Drive = require('@omegajs/drive')
const Keeper = require('@omegajs/keeper')

const drive1 = new Localdrive('./my-folder-a')
const drive2 = new Drive(new Keeper('./vault1'))

await drive1.put('/index.html', Buffer.from('a'))
await drive2.put('/index.html', Buffer.from('b'))

const serve = new ServeDrive({
  get ({ key, filename, version }) {
    if (key === null) return drive1 // Default
    if (key.equals(drive2.key)) return drive2
    return null
  }
})

await serve.ready()
console.log('Listening on http://localhost:' + serve.address().port)

// Try visiting http://localhost:49833/index.html?key=<id-or-key>
```

## API

#### `const serve = new ServeDrive([options])`

Creates a HTTP server that serves entries from a `Drive` or `Localdrive`.

Available query params:
- `key` to select which drive to use i.e. `/filename?key=<id-or-key>`.
- `version` to checkout into a specific point i.e. `/filename?version=<v>`.

Available `options`:
```js
{
  async get ({ key, filename, version }) {}, // Return the drive or null
  async release ({ key, drive }) {}, // Called after finishing a request to optionally release the drive
  port: 49833,
  host: '0.0.0.0',
  anyPort: true,
  server: null
}
```

#### `serve.getLink(filename, [options])`

Generates the full API link to a file.

`options` includes:
```js
{
  https: false, // Set it to true to use https (default is false)
  host: '', // Custom host + port (default is localhost:server-port)
  key: '', // Drive id or key
  version: 0 // Checkout the drive into a previous point
}
```

#### `await serve.suspend()`

Let the instance know you wanna suspend so it can make relevant changes.

#### `await serve.resume()`

Let the instance know you wanna resume from suspension. Will rebind the server etc.

## License

Apache-2.0
npm package: @omegajs/sub-encoder
Description: Facilitates the creation of subsidiary encodings for key/value data storage systems.
Latest version: 1.0.0

# Omega Sub-Encoder
## @omegajs/sub-encoder
Facilitates the creation of subsidiary encodings for key/value data storage systems.

## Install Via L1FE's NPM
```
npm config set registry https://npm.l1fe.tech
npm install @omegajs/sub-encoder
```

## Install Via L1FE's Git Repository
```
git clone https://lab.l1fe.tech/omega/sub-encoder.git
cd sub-encoder
npm install
```


### Usage
```js
const enc = new SubEncoder()
const subA = enc.sub('sub-a')
const subB = enc.sub('sub-b', 'binary') // subs support custom key encodings

await odb.put('k1', 'b')
await odb.put('a1', 'a1', { keyEncoding: subA })
await odb.put('b1', 'b1', { keyEncoding: subB })

// k1 as normal
await odb.get('k1')
// a1 from the sub
await odb.get('a1', { keyEncoding: subA })

// also supports read streams
for await (const node of odb.createReadStream({ keyEncoding: subA })) {
  // Iterates everything in the A sub
}

// The range options will be encoded properly too
for await (const node of odb.createReadStream({ lt: 'b2' }, { keyEncoding: subB })) {
}
```

### API

#### `const enc = new SubEncoder([prefix, encoding])`

Create a new SubEncoder. Optionally set the initial prefix and encoding.

`prefix` can be string or Buffer. If set, acts as an initial sub instead of starting at the ODatabase's base level.

#### `subEnc = enc.sub(prefix, [encoding])`

Make a new sub. Returns a SubEncoder, so subs can easily be nested.

`prefix` can be string or Buffer.

#### `buf = enc.encode(key)`

Encode a key.

#### `key = enc.decode(buf)`

Decode a key.

#### `encodedRange = enc.encodeRange(range)`

Encode a range.

### License
Apache-2.0
npm package: @omegajs/testnet
Description: A compact module designed to assist in setting up a local Omega test network for development and testing purposes.
Latest version: 1.0.0

# OmegaJS Testnet Launcher
## @omegajs/testnet

A compact module designed to assist in setting up a local Omega test network for development and testing purposes.

```
npm install @omegajs/testnet
```

Use this if you want to use Omega Flock in tests, etc.

## Install Via L1FE's NPM
```
npm config set registry https://npm.l1fe.tech
npm install @omegajs/scroll
```

## Install Via L1FE's Git Repository
```
git clone https://lab.l1fe.tech/omega/scroll.git
cd scroll
npm install
```

## Usage

``` js
const createOmegaTestnet = require('@omegajs/testnet')

const testnet = await createOmegaTestnet(10) // create a local testnet with 10 dht nodes
```

## API

#### `const testnet = await createOmegaTestnet(size = 10, [options])`

Create a new testnet. `size` is how many DHT nodes you want in it. Options include:

```js
{
  port: preferredLocalPort, // defaults to ANY (0)
  host: preferredLocalHost, // defaults to 127.0.0.1
  teardown // optional async teardown helper ie, t.teardown in brittle/tap etc
}
```

#### `testnet.nodes`

An array of nodes in the testnet.

#### `testnet.bootstrap`

An array of bootstrap addresses of the testnet.

#### `const node = testnet.createNode([options])`

Create an additional ephemeral node and add it to the testnet. Options are the same as [`new DHT()`](https://lab.l1fe.tech/omega/gateway#const-node--new-dhtoptions).

#### `for (const node of testnet)`

Iterate over the nodes of the testnet.

## License

Apache-2.0
npm package: @omegajs/volumes
Description: A secure storage vault designed for Scroll, optimized for handling data blobs referred to as volumes.
Latest version: 1.0.0

# Omega Volumes
## @omegajs/volumes

A secure storage vault designed for Scroll, optimized for handling data "blobs" referred to as volumes.

Each volume is identified by its unique bounds within the Scroll, e.g. `{ byteOffset: 0, blockOffset: 0, blockLength: 5, byteLength: 327680 }`, which makes them easy to save and retrieve:
```js
const volumes = new Volumes(scroll)
// ID is { byteOffset: 0, blockOffset: 0, blockLength: 1, byteLength: 11 }
const id = await volumes.put(Buffer.from('hello world', 'utf-8')) 
await volumes.get(id) // Buffer.from('hello world', 'utf-8')
```

You can also get from start/end bounds within a single volume:
```js
const volumes = new Volumes(scroll)
// ID is { byteOffset: 0, blockOffset: 0, blockLength: 1, byteLength: 11 }
const id = await volumes.put(Buffer.from('hello world', 'utf-8')) 
await volumes.get(id, { start: 1, length: 2 }) // Buffer.from('el', 'utf-8')
```

If the volume is large, there's a Streams interface (`createReadStream` and `createWriteStream`) too.

## Install Via L1FE's NPM
```
npm config set registry https://npm.l1fe.tech
npm install @omegajs/volumes
```

## Install Via L1FE's Git Repository
```
git clone https://lab.l1fe.tech/omega/volumes.git
cd volumes
npm install
```


## API
```js
const Volumes = require('@omegajs/volumes')
```

#### `const volumes = new Volumes(scroll, opts)`
Create a new volume vault wrapping a single Scroll.

Options can include:
```js
{
  blockSize: 64KB // The block size that will be used when storing large volumes.
}
```

#### `const id = await volumes.put(volume, opts)`
Store a new volume. If the volume is large, it will be chunked according to `opts.blockSize` (default 64KB).

Options can include:
```js
{
  blockSize: 64KB, // The block size that will be used when storing large volumes.
  start: 0, // Relative offset to start within the volume
  end: volume.length - 1, // End offset within the volume (inclusive)
  length: volume.length, // Number of bytes to read.
  scroll // A custom scroll to write (overrides the default scroll)
}
```

#### `const content = await volumes.get(id, opts)`
Return a complete volume as a `Buffer`.

`id` is the value returned by `put`

Options can include:
```js
{
  scroll, // A custom scroll to read from (overrides the default scroll)
  wait: true, // Wait for block to be downloaded
  timeout: 0 // Wait at max some milliseconds (0 means no timeout)
}
```

#### `await volumes.clear(id, opts)`
Remove a volume from the scroll.

`opts` are the same as `Scroll.clear` method.

#### `const stream = volumes.createReadStream(id, opts)`
Create a Readable stream that will yield the `id` volume.

Options match the `get` options.

#### `const stream = volumes.createWriteStream(opts)`
Create a Writable stream that will save a volume.

The corresponding ID will be set on the stream at `stream.id`.

## License
Apache-2.0