GithubHelp home page GithubHelp logo

jameskyburz / content-addressable-blob-store Goto Github PK

View Code? Open in Web Editor NEW

This project forked from mafintosh/content-addressable-blob-store

0.0 2.0 0.0 21 KB

Streamable content addressable blob object store that is streams2 and implements the blob store interface

License: MIT License

JavaScript 100.00%

content-addressable-blob-store's Introduction

content-addressable-blob-store

Streamable content addressable blob object store that is streams2 and implements the blob store interface on top of the fs module.

Conforms to the abstract-blob-store API and passes it's test suite.

npm install content-addressable-blob-store

build status dat

blob-store-compatible

Usage

var blobs = require('content-addressable-blob-store')
var store = blobs('./data')

var w = store.createWriteStream()

w.write('hello ')
w.write('world\n')

w.end(function() {
  console.log('blob written: '+w.key)
  store.createReadStream(w).pipe(process.stdout)
})

API

var store = blobs(opts)

Creates a new instance. Opts should have a path property to where the blobs should live on the fs. The directory will be created if it doesn't exist. If not supplied it will default to path.join(process.cwd(), 'blobs')

You can also specify a node crypto module hashing algorithm to use using the algo key in options. The default is sha256. If you pass a string instead of an options map it will be used as the path as well.

var readStream = store.createReadStream(opts)

Open a read stream to a blob. opts must have a key key with the hash of the blob you want to read. opts can optionally contain a start or end key if you only want part of the blob.

var writeStream = store.createWriteStream([cb])

Add a new blob to the store. Use writeStream.key to get the hash after the finish event has fired or add a callback which will be called with callback(err, metadata).

store.exists(metadata, cb)

Check if an blob exists in the blob store. metadata must have a key property. Callback is called with callback(err, exists)

store.remove(metadata, [cb])

Remove a blob from the store. metadata must have a key property. Callback is called with callback(err, wasDeleted)

License

MIT

content-addressable-blob-store's People

Contributors

djblue avatar dweinstein avatar mafintosh avatar maxogden avatar

Watchers

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