All Projects → krismuniz → dat-utils

krismuniz / dat-utils

Licence: MIT license
Utility functions for Beaker Browser's DatArchive API

Programming Languages

HTML
75241 projects
javascript
184084 projects - #8 most used programming language

Projects that are alternatives of or similar to dat-utils

decent-dat-intro
a buffet of tiny demos for easing in everyone with developing decentralized apps
Stars: ✭ 67 (+415.38%)
Mutual labels:  dat, beaker
dat-desktop
Peer to peer data syncronization [ DEPRECATED - More info on active projects and modules at https://dat-ecosystem.org/ ]
Stars: ✭ 646 (+4869.23%)
Mutual labels:  dat
Hypertweet
concept tweet -> hypercore thingy
Stars: ✭ 69 (+430.77%)
Mutual labels:  dat
Enoki
ultralight tools for creating p2p sites
Stars: ✭ 222 (+1607.69%)
Mutual labels:  dat
Blockchain Parser
The simpliest script for parsing Bitcoin blockchain. It made convertion of blk*****.dat files to the simple text.
Stars: ✭ 84 (+546.15%)
Mutual labels:  dat
Datbase
[DEPRECATED] Open data sharing powered by Dat
Stars: ✭ 251 (+1830.77%)
Mutual labels:  dat
Dat
💾 peer-to-peer sharing & live syncronization of files via command line
Stars: ✭ 8,259 (+63430.77%)
Mutual labels:  dat
caracara
GEUT LABS. An experimental Dat based collaborative editor.
Stars: ✭ 33 (+153.85%)
Mutual labels:  dat
geniza
hobby implementation of dat in rust
Stars: ✭ 32 (+146.15%)
Mutual labels:  dat
Sdk
Write your own dat app!
Stars: ✭ 215 (+1553.85%)
Mutual labels:  dat
How Dat Works
Protocol documentation for Dat
Stars: ✭ 164 (+1161.54%)
Mutual labels:  dat
Dat Keyserver
a distributed PGP keyserver project based on the dat protocol
Stars: ✭ 89 (+584.62%)
Mutual labels:  dat
dat-wot
[WIP] A decentralized public key network with encryption utilities for data collaboration
Stars: ✭ 52 (+300%)
Mutual labels:  dat
Datradio
p2p music player for {old} beaker and dat
Stars: ✭ 77 (+492.31%)
Mutual labels:  dat
olaf
A P2P chat using Dat.
Stars: ✭ 24 (+84.62%)
Mutual labels:  dat
Hyperfeed
decentralized rss publishing
Stars: ✭ 60 (+361.54%)
Mutual labels:  dat
Mdfreader
Read Measurement Data Format (MDF) versions 3.x and 4.x file formats in python
Stars: ✭ 131 (+907.69%)
Mutual labels:  dat
Hashbase
A Dat-hosting service for multiple users
Stars: ✭ 226 (+1638.46%)
Mutual labels:  dat
ACViewer
Viewer / Utility for DAT files for the game Asheron's Call
Stars: ✭ 19 (+46.15%)
Mutual labels:  dat
frostpunk mod
Frostpunk / Mod Tools / 非公式日本語化MODツール
Stars: ✭ 17 (+30.77%)
Mutual labels:  dat

Dat Utils

Dat License:MIT

A small set of utilities to ease the process of building decentralized apps on top of the DatArchive API in the form of an ES6 module.

With this module you can copy files from one archive to another (copyFile), deep-write files (deepWriteFile), check if a file exists (fileExists), and create dirs without worrying about about the directory-tree (deepMkdir).

Quick Example:
import { copyFile } from '/modules/dat-utils.js'

const archiveA = await DatArchive.select() // or new DatArchive(<dat_url>)
const archiveB = await DatArchive.select() // or new DatArchive(<dat_url>)

copyFile(archiveA, archiveB, '/deep/path/to/index.html')

The code above deep-copies /deep/path/to/index.html from archiveA to archiveB. No need to create /deep, /deep/path, or /deep/path/to/ directories, it creates parent directories as needed.

Requirements

Installation

If you are using Beaker Browser, go to dat://utils-krismuniz.hashbase.io and click the "Install Module" button. You will be prompted to select your Dat site/app and when you select it, the installer will automatically add the module to your Dat site's source code!

Alternatively, you can download the source code straight from the GitHub repo.

Usage

To use dat-utils, you need to have Beaker Browser v0.8 installed since this is an ES6 module.

Importing the Module

To import dat-utils into your JavaScript code, use the ES6 import syntax.

import * as utils from '/modules/dat-utils.js'

utils.copyFile(archiveA, archiveB, '/index.html')

Remember to add the type="module" instead of type="text/javascript" attribute to your <script> tag so you can import ES6 modules!

copyFile

copyFile(source, target, path[, options])

Deep-copy files from one Dat Archive to another using .copyFile().

Example
import { copyFile } from '/modules/dat-utils.js'

const from = await DatArchive.select() // or new DatArchive(<dat_url>)
const to = await DatArchive.select() // or new DatArchive(<dat_url>)

await copyFile(from, to, '/index.html')
// writes contents of '/index.html' from one archive to the other, regardless of directory-tree

writeOrModifyFile

writeOrModifyFile(archive, path, data[, options])

Write a file, or modify it if it already exists.

Example
import { writeOrModifyFile } from '/modules/dat-utils.js'

const archive = new DatArchive(<dat_url>)

await writeOrModifyFile(archive, '/data.txt', 'hello world')
// -> deep-writes to /data.txt, or modifies if it already exists

fileExists

fileExists(archive, path)

Returns true if the file exists, or false if it doesn't

Example
import { fileExists } from '/modules/dat-utils.js'

const archive = new DatArchive(<dat_url>)

await fileExists(archive, '/data.txt')
// -> checks if /data.txt exists

deepWriteFile

deepWriteFile(archive, path, data[, options])

Deep-writes a file to an archive, creates parent directories as needed.

Example
import { deepWriteFile } from '/modules/dat-utils.js'

const archive = new DatArchive(<dat_url>)

await deepWriteFile(archive, '/path/to/data.txt', 'hello world!')

// -> writes 'hello world' to /path/to/data.txt

deepMkdir

deepMkdir(archive, path)

Recursively creates a directory on the path specified, creates parent directories as needed.

Example
import { deepMkdir } from '/modules/dat-utils.js'

const archive = new DatArchive(<dat_url>)

await deepMkdir(archive, '/path/to/other/dir')

// -> creates /path, /path/to, /path/to/other, and /path/to/other/dir

Reference

API Reference

License

MIT

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].