Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

ipfs-unixfs

Package Overview
Dependencies
Maintainers
1
Versions
78
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

ipfs-unixfs - npm Package Compare versions

Comparing version 0.1.14 to 0.1.15

ci/Jenkinsfile

10

CHANGELOG.md

@@ -0,1 +1,11 @@

<a name="0.1.15"></a>
## [0.1.15](https://github.com/ipfs/js-ipfs-unixfs/compare/v0.1.14...v0.1.15) (2018-06-08)
### Bug Fixes
* a typo ([932b804](https://github.com/ipfs/js-ipfs-unixfs/commit/932b804))
<a name="0.1.14"></a>

@@ -2,0 +12,0 @@ ## [0.1.14](https://github.com/ipfs/js-ipfs-unixfs/compare/v0.1.13...v0.1.14) (2017-11-07)

16

package.json
{
"name": "ipfs-unixfs",
"version": "0.1.14",
"version": "0.1.15",
"description": "JavaScript implementation of IPFS' unixfs (a Unix FileSystem representation on top of a MerkleDAG)",
"leadMaintainer": "Alex Potsides <alex.potsides@protocol.ai>",
"main": "src/index.js",

@@ -10,5 +11,6 @@ "browser": {

"scripts": {
"test": "aegir test",
"test": "aegir test -f test/index.js",
"test:node": "aegir test -t node",
"test:browser": "aegir test -t browser -t webworker",
"test:browser": "aegir test -t browser -f test/index.js",
"test:webworker": "aegir test -t webworker -f test/index.js",
"build": "aegir build",

@@ -28,3 +30,2 @@ "lint": "aegir lint",

],
"author": "David Dias <daviddias@ipfs.io>",
"license": "MIT",

@@ -40,3 +41,3 @@ "bugs": {

"devDependencies": {
"aegir": "^12.1.3",
"aegir": "^14.0.0",
"chai": "^4.1.2",

@@ -58,7 +59,10 @@ "dirty-chai": "^2.0.1",

"JGAntunes <j.goncalo.antunes@gmail.com>",
"Marcin Rataj <lidel@lidel.org>",
"Mithgol <getgit@mithgol.ru>",
"Pedro Teixeira <i@pgte.me>",
"Richard Littauer <richard.littauer@gmail.com>",
"Richard Schneider <makaretu@gmail.com>"
"Richard Schneider <makaretu@gmail.com>",
"Victor Bjelkholm <victorbjelkholm@gmail.com>",
"achingbrain <alex@achingbrain.net>"
]
}

@@ -18,21 +18,28 @@ # ipfs-unixfs JavaScript Implementation

## Lead Maintainer
[Alex Potsides](https://github.com/achingbrain)
## Table of Contents
- [Install](#install)
- [npm](#npm)
- [Use in Node.js](#use-in-nodejs)
- [Use in a browser with browserify, webpack or any other bundler](#use-in-a-browser-with-browserify-webpack-or-any-other-bundler)
- [Use in a browser Using a script tag](#use-in-a-browser-using-a-script-tag)
- [Usage](#usage)
- [Examples](#examples)
- [Create a file composed by several blocks](#create-a-file-composed-by-several-blocks)
- [Create a directory that contains several files](#create-a-directory-that-contains-several-files)
- [API](#api)
- [unixfs Data Structure](#unixfs-data-structure)
- [create an unixfs Data element](#create-an-unixfs-data-element)
- [add and remove a block size to the block size list](#add-and-remove-a-block-size-to-the-block-size-list)
- [get total fileSize](#get-total-filesize)
- [marshal and unmarshal](#marshal-and-unmarshal)
- [Contribute](#contribute)
- [License](#license)
- [ipfs-unixfs JavaScript Implementation](#ipfs-unixfs-javascript-implementation)
- [Lead Maintainer](#lead-maintainer)
- [Table of Contents](#table-of-contents)
- [Install](#install)
- [npm](#npm)
- [Use in Node.js](#use-in-nodejs)
- [Use in a browser with browserify, webpack or any other bundler](#use-in-a-browser-with-browserify--webpack-or-any-other-bundler)
- [Use in a browser Using a script tag](#use-in-a-browser-using-a-script-tag)
- [Usage](#usage)
- [Examples](#examples)
- [Create a file composed by several blocks](#create-a-file-composed-by-several-blocks)
- [Create a directory that contains several files](#create-a-directory-that-contains-several-files)
- [API](#api)
- [unixfs Data Structure](#unixfs-data-structure)
- [create an unixfs Data element](#create-an-unixfs-data-element)
- [add and remove a block size to the block size list](#add-and-remove-a-block-size-to-the-block-size-list)
- [get total fileSize](#get-total-filesize)
- [marshal and unmarshal](#marshal-and-unmarshal)
- [Contribute](#contribute)
- [License](#license)

@@ -113,3 +120,3 @@ ## Install

message Metadata {
required string MimeType = 1;
optional string MimeType = 1;
}

@@ -145,4 +152,4 @@ ```

```
var marsheled = data.marshal()
var unmarsheled = Unixfs.unmarshal(marsheled)
var marshaled = data.marshal()
var unmarshaled = Unixfs.unmarshal(marshaled)
```

@@ -149,0 +156,0 @@

@@ -76,11 +76,19 @@ 'use strict'

if (!fileSize) {
fileSize = undefined
let data = this.data
if (!this.data || !this.data.length) {
data = undefined
}
let blockSizes = this.blockSizes
if (!this.blockSizes || !this.blockSizes.length) {
blockSizes = undefined
}
return unixfsData.encode({
Type: type,
Data: this.data,
Data: data,
filesize: fileSize,
blocksizes: this.blockSizes.length > 0 ? this.blockSizes : undefined,
blocksizes: blockSizes,
hashType: this.hashType,

@@ -87,0 +95,0 @@ fanout: this.fanout

@@ -23,3 +23,3 @@ 'use strict'

message Metadata {
required string MimeType = 1;
optional string MimeType = 1;
}`

@@ -11,91 +11,84 @@ /* eslint-env mocha */

const raw = loadFixture(__dirname, 'fixtures/raw.unixfs')
const directory = loadFixture(__dirname, 'fixtures/directory.unixfs')
const file = loadFixture(__dirname, 'fixtures/file.txt.unixfs')
const symlink = loadFixture(__dirname, 'fixtures/symlink.txt.unixfs')
const raw = loadFixture('test/fixtures/raw.unixfs')
const directory = loadFixture('test/fixtures/directory.unixfs')
const file = loadFixture('test/fixtures/file.txt.unixfs')
const symlink = loadFixture('test/fixtures/symlink.txt.unixfs')
const Buffer = require('safe-buffer').Buffer
describe('unixfs-format', () => {
it('raw', (done) => {
it('raw', () => {
const data = new UnixFS('raw', Buffer.from('bananas'))
const marsheled = data.marshal()
const unmarsheled = UnixFS.unmarshal(marsheled)
expect(data.type).to.equal(unmarsheled.type)
expect(data.data).to.deep.equal(unmarsheled.data)
expect(data.blockSizes).to.deep.equal(unmarsheled.blockSizes)
expect(data.fileSize()).to.deep.equal(unmarsheled.fileSize())
done()
const marshalled = data.marshal()
const unmarshalled = UnixFS.unmarshal(marshalled)
expect(data.type).to.equal(unmarshalled.type)
expect(data.data).to.deep.equal(unmarshalled.data)
expect(data.blockSizes).to.deep.equal(unmarshalled.blockSizes)
expect(data.fileSize()).to.deep.equal(unmarshalled.fileSize())
})
it('directory', (done) => {
it('directory', () => {
const data = new UnixFS('directory')
const marsheled = data.marshal()
const unmarsheled = UnixFS.unmarshal(marsheled)
expect(data.type).to.equal(unmarsheled.type)
expect(data.data).to.deep.equal(unmarsheled.data)
expect(data.blockSizes).to.deep.equal(unmarsheled.blockSizes)
expect(data.fileSize()).to.deep.equal(unmarsheled.fileSize())
done()
const marshalled = data.marshal()
const unmarshalled = UnixFS.unmarshal(marshalled)
expect(data.type).to.equal(unmarshalled.type)
expect(data.data).to.deep.equal(unmarshalled.data)
expect(data.blockSizes).to.deep.equal(unmarshalled.blockSizes)
expect(data.fileSize()).to.deep.equal(unmarshalled.fileSize())
})
it('hamt-sharded-directory', (done) => {
it('hamt-sharded-directory', () => {
const data = new UnixFS('hamt-sharded-directory')
const marsheled = data.marshal()
const unmarsheled = UnixFS.unmarshal(marsheled)
expect(data.type).to.equal(unmarsheled.type)
expect(data.data).to.deep.equal(unmarsheled.data)
expect(data.blockSizes).to.deep.equal(unmarsheled.blockSizes)
expect(data.fileSize()).to.deep.equal(unmarsheled.fileSize())
done()
const marshalled = data.marshal()
const unmarshalled = UnixFS.unmarshal(marshalled)
expect(data.type).to.equal(unmarshalled.type)
expect(data.data).to.deep.equal(unmarshalled.data)
expect(data.blockSizes).to.deep.equal(unmarshalled.blockSizes)
expect(data.fileSize()).to.deep.equal(unmarshalled.fileSize())
})
it('file', (done) => {
it('file', () => {
const data = new UnixFS('file', new Buffer('batata'))
const marsheled = data.marshal()
const unmarsheled = UnixFS.unmarshal(marsheled)
expect(data.type).to.equal(unmarsheled.type)
expect(data.data).to.deep.equal(unmarsheled.data)
expect(data.blockSizes).to.deep.equal(unmarsheled.blockSizes)
expect(data.fileSize()).to.deep.equal(unmarsheled.fileSize())
done()
const marshalled = data.marshal()
const unmarshalled = UnixFS.unmarshal(marshalled)
expect(data.type).to.equal(unmarshalled.type)
expect(data.data).to.deep.equal(unmarshalled.data)
expect(data.blockSizes).to.deep.equal(unmarshalled.blockSizes)
expect(data.fileSize()).to.deep.equal(unmarshalled.fileSize())
})
it('file add blocksize', (done) => {
it('file add blocksize', () => {
const data = new UnixFS('file')
data.addBlockSize(256)
const marsheled = data.marshal()
const unmarsheled = UnixFS.unmarshal(marsheled)
expect(data.type).to.equal(unmarsheled.type)
expect(data.data).to.deep.equal(unmarsheled.data)
expect(data.blockSizes).to.deep.equal(unmarsheled.blockSizes)
expect(data.fileSize()).to.deep.equal(unmarsheled.fileSize())
done()
const marshalled = data.marshal()
const unmarshalled = UnixFS.unmarshal(marshalled)
expect(data.type).to.equal(unmarshalled.type)
expect(data.data).to.deep.equal(unmarshalled.data)
expect(data.blockSizes).to.deep.equal(unmarshalled.blockSizes)
expect(data.fileSize()).to.deep.equal(unmarshalled.fileSize())
})
it('file add and remove blocksize', (done) => {
it('file add and remove blocksize', () => {
const data = new UnixFS('file')
data.addBlockSize(256)
const marsheled = data.marshal()
const unmarsheled = UnixFS.unmarshal(marsheled)
expect(data.type).to.equal(unmarsheled.type)
expect(data.data).to.deep.equal(unmarsheled.data)
expect(data.blockSizes).to.deep.equal(unmarsheled.blockSizes)
expect(data.fileSize()).to.deep.equal(unmarsheled.fileSize())
unmarsheled.removeBlockSize(0)
expect(data.blockSizes).to.not.deep.equal(unmarsheled.blockSizes)
done()
const marshalled = data.marshal()
const unmarshalled = UnixFS.unmarshal(marshalled)
expect(data.type).to.equal(unmarshalled.type)
expect(data.data).to.deep.equal(unmarshalled.data)
expect(data.blockSizes).to.deep.equal(unmarshalled.blockSizes)
expect(data.fileSize()).to.deep.equal(unmarshalled.fileSize())
unmarshalled.removeBlockSize(0)
expect(data.blockSizes).to.not.deep.equal(unmarshalled.blockSizes)
})
// figuring out what is this metadata for https://github.com/ipfs/js-ipfs-data-importing/issues/3#issuecomment-182336526
it.skip('metadata', (done) => {})
it.skip('metadata', () => {})
it('symlink', (done) => {
it('symlink', () => {
const data = new UnixFS('symlink')
const marsheled = data.marshal()
const unmarsheled = UnixFS.unmarshal(marsheled)
expect(data.type).to.equal(unmarsheled.type)
expect(data.data).to.deep.equal(unmarsheled.data)
expect(data.blockSizes).to.deep.equal(unmarsheled.blockSizes)
expect(data.fileSize()).to.deep.equal(unmarsheled.fileSize())
done()
const marshalled = data.marshal()
const unmarshalled = UnixFS.unmarshal(marshalled)
expect(data.type).to.equal(unmarshalled.type)
expect(data.data).to.deep.equal(unmarshalled.data)
expect(data.blockSizes).to.deep.equal(unmarshalled.blockSizes)
expect(data.fileSize()).to.deep.equal(unmarshalled.fileSize())
})

@@ -114,38 +107,41 @@ it('wrong type', (done) => {

describe('interop', () => {
it('raw', (done) => {
const unmarsheled = UnixFS.unmarshal(raw)
expect(unmarsheled.data).to.eql(Buffer.from('Hello UnixFS\n'))
expect(unmarsheled.type).to.equal('file')
expect(unmarsheled.marshal()).to.deep.equal(raw)
done()
it('raw', () => {
const unmarshalled = UnixFS.unmarshal(raw)
expect(unmarshalled.data).to.eql(Buffer.from('Hello UnixFS\n'))
expect(unmarshalled.type).to.equal('file')
expect(unmarshalled.marshal()).to.deep.equal(raw)
})
it('directory', (done) => {
const unmarsheled = UnixFS.unmarshal(directory)
expect(unmarsheled.data).to.deep.equal(undefined)
expect(unmarsheled.type).to.equal('directory')
expect(unmarsheled.marshal()).to.deep.equal(directory)
done()
it('directory', () => {
const unmarshalled = UnixFS.unmarshal(directory)
expect(unmarshalled.data).to.deep.equal(undefined)
expect(unmarshalled.type).to.equal('directory')
expect(unmarshalled.marshal()).to.deep.equal(directory)
})
it('file', (done) => {
const unmarsheled = UnixFS.unmarshal(file)
expect(unmarsheled.data).to.deep.equal(Buffer.from('Hello UnixFS\n'))
expect(unmarsheled.type).to.equal('file')
expect(unmarsheled.marshal()).to.deep.equal(file)
done()
it('file', () => {
const unmarshalled = UnixFS.unmarshal(file)
expect(unmarshalled.data).to.deep.equal(Buffer.from('Hello UnixFS\n'))
expect(unmarshalled.type).to.equal('file')
expect(unmarshalled.marshal()).to.deep.equal(file)
})
it.skip('metadata', (done) => {
it.skip('metadata', () => {
})
it('symlink', (done) => {
const unmarsheled = UnixFS.unmarshal(symlink)
expect(unmarsheled.data).to.deep.equal(Buffer.from('file.txt'))
expect(unmarsheled.type).to.equal('symlink')
it('symlink', () => {
const unmarshalled = UnixFS.unmarshal(symlink)
expect(unmarshalled.data).to.deep.equal(Buffer.from('file.txt'))
expect(unmarshalled.type).to.equal('symlink')
// TODO: waiting on https://github.com/ipfs/js-ipfs-data-importing/issues/3#issuecomment-182440079
// expect(unmarsheled.marshal()).to.deep.equal(symlink)
done()
// expect(unmarshalled.marshal()).to.deep.equal(symlink)
})
})
it('empty', () => {
const data = new UnixFS('file')
const marshalled = data.marshal()
expect(marshalled).to.deep.equal(Buffer.from([0x08, 0x02, 0x18, 0x00]))
})
})

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is too big to display

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is too big to display

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc