All Projects → poga → hyperdrive-ln

poga / hyperdrive-ln

Licence: MIT license
create symbolic link between hyperdrives

Programming Languages

javascript
184084 projects - #8 most used programming language

Projects that are alternatives of or similar to hyperdrive-ln

toml-bombadil
A dotfile manager with templating
Stars: ✭ 127 (+876.92%)
Mutual labels:  symlink
hyper-content-db
A Kappa-style peer-to-peer content database, on top of hyperdrives.
Stars: ✭ 34 (+161.54%)
Mutual labels:  hyperdrive
shu-shell
Webshell Jumping Edition
Stars: ✭ 23 (+76.92%)
Mutual labels:  symlink
Beaker
An experimental peer-to-peer Web browser
Stars: ✭ 6,411 (+49215.38%)
Mutual labels:  hyperdrive
hyperhealth
Monitor the health of a hyperfeed (hypercore or hyperdrive), including peer count and peer mirror percentages.
Stars: ✭ 38 (+192.31%)
Mutual labels:  hyperdrive
permanent-seeder
A super seeder for hyperdrives. By GEUT.
Stars: ✭ 22 (+69.23%)
Mutual labels:  hyperdrive
dat-shell
Dat shell. Open a remote dat and explore with cd, ls, etc.
Stars: ✭ 62 (+376.92%)
Mutual labels:  hyperdrive
filepath-securejoin
Proposed filepath.SecureJoin implementation
Stars: ✭ 61 (+369.23%)
Mutual labels:  symlink
SharpLink
Create file system symbolic links from low privileged user accounts within PowerShell
Stars: ✭ 51 (+292.31%)
Mutual labels:  symlink
dotfiles
Config files for i3, polybar, rofi, mpv, Xresources, kitty and some bash-things...
Stars: ✭ 52 (+300%)
Mutual labels:  symlink
PHP-web-shells
when i started web application security testing, i fall in love with web shell development and designed some PHP based web shells. This repository contains all my codes which i released in public.
Stars: ✭ 38 (+192.31%)
Mutual labels:  symlink
dotfiles
These dotfiles could be your life.
Stars: ✭ 42 (+223.08%)
Mutual labels:  symlink

hyperdrive-ln

NPM Version JavaScript Style Guide

create symbolic link between hyperdrives

npm i hyperdrive-ln

Usage

const ln = require('hyperdrive-ln')

var drive = hyperdrive(memdb())
var archive = drive.createArchive()

ln.link(archive, 'linkfile', <ARCHIVE KEY>, [meta], err => {}) // create symlink to another archive
ln.readlink(archive, 'linkfile', (err, link) => {}) // get link data

// assume ln.link(archive, 'path/to/file', <ARCHIVE KEY>)
ln.resolve(archive, 'path/to/file/within/linked/archive', (err, link, restOfThePath)) // returns (err, {link: <ARCHIVE_KEY>, meta: {...}}, 'within/linked/archive')

// resolve through archives
ln.deepResolve(drive, swarmer, archive, path, (err, result) => {})

ln.encode(key, [meta]) // encode a key for linkfile
ln.decode(data) // decode a linkfile content to key

API

ln.link(archive, path, archiveKey, [meta], cb)

Create a symlink at path point to archiveKey.

You can pass a meta object to store it in the symlink.

ln.readlink(archive, path, cb)

Get the link data stored inside a symlink.

ln.resolve(archive, path, cb)

Resolve a path. Returns an archive and a path within that archive with cb(err, linkedArchiveKey, pathWithinLinkedArchive)

  • If there's a symlink encountered in the path. cb(err, link, pathWithinLinkedArchive) will be invoked.
  • If there's no symlink in the path, cb(err, {}, path) will be called.

for example:

ln.link(archive, 'foo/bar', '<LINK_KEY>', (err) => {
    ln.resolve(archive, 'foo/bar/baz', (err, link, path) => {
      // link === {link: '<LINK_KEY>', meta: {...}}
      // path === 'baz'
    })
})

ln.deepResolve(drive, swarmer, archive, path, cb)

Recursively resolve a path through archives. Create swarm connection when necessary.

swarmer is anything let you join swarm . For example: hyperdiscovery.

callback cb(err, result) where result is a recursive structure:

{
  archive: // traversed archive,
  path: // consumed path,
  swarm: // swarm instance,
  next: result // next component if there's one
}

For example: Assume we have an archive1 which /foo/bar linked to archive2.

ln.deepResolve(drive, swarmer, archive1, '/foo/bar/baz/baz.txt', cb)

will get the result:

{
  archive: archive1,
  path: '/foo/bar',
  swarm: // a swarm instance,
  next: {
    archive: archive2,
    path: 'baz/baz.txt',
    swarm: // another swarm instance
  }
}

use deepClose(result) to close all swarm instance in the result.

ln.deepClose(result)

Close all swarm instance in the result.

body = ln.encode(key, [meta])

Encode a key to symlink file body.

ln.decode(body)

Decode a symlink file body to linked archive key.

License

The MIT License

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].