Skip to content

Commit 9c342d1

Browse files
committed
update readme .travis.yml
1 parent b20d7e2 commit 9c342d1

File tree

3 files changed

+120
-5
lines changed

3 files changed

+120
-5
lines changed

.travis.yml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,10 @@ node_js:
44
- '5'
55
- stable
66

7+
# always use npm latest
8+
before_install:
9+
- npm i -g npm
10+
711
addons:
812
firefox: 'latest'
913

README.md

Lines changed: 113 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,122 @@
1-
ipfs-unixfs
2-
===========
1+
ipfs-unixfs JavaScript Implementation
2+
=====================================
33

44
[![](https://img.shields.io/badge/made%20by-Protocol%20Labs-blue.svg?style=flat-square)](http://ipn.io)
5-
[[![](https://img.shields.io/badge/freenode-%23ipfs-blue.svg?style=flat-square)](http://webchat.freenode.net/?channels=%23ipfs)
6-
[![Build Status](https://travis-ci.org/ipfs/js-ipfs-unixfs.svg?style=flat-square)](https://travis-ci.org/ipfs/js-ipfs-unixfs)
5+
[![](https://img.shields.io/badge/freenode-%23ipfs-blue.svg?style=flat-square)](http://webchat.freenode.net/?channels=%23ipfs)
6+
[![Build Status](https://travis-ci.org/ipfs/js-ipfs-unixfs.svg?style=flat-square&branch=master)](https://travis-ci.org/ipfs/js-ipfs-unixfs)
77
![](https://img.shields.io/badge/coverage-%3F%25-yellow.svg?style=flat-square)
88
[![Dependency Status](https://david-dm.org/ipfs/js-ipfs-unixfs.svg?style=flat-square)](https://david-dm.org/ipfs/js-ipfs-unixfs)
99
[![js-standard-style](https://img.shields.io/badge/code%20style-standard-brightgreen.svg?style=flat-square)](https://github.com/feross/standard)
1010

1111
> JavaScript implementation of IPFS' unixfs (a Unix FileSystem representation on top of a MerkleDAG)
1212
13+
[The unixfs spec can be found inside the ipfs/specs repository](http://github.com/ipfs/specs)
14+
15+
# Installation
16+
17+
## npm
18+
19+
```sh
20+
> npm i ipfs-unixfs
21+
```
22+
23+
## Use in Node.js
24+
25+
```JavaScript
26+
var Unixfs = require('ipfs-unixfs')
27+
```
28+
29+
## Use in a browser with browserify, webpack or any other bundler
30+
31+
The code published to npm that gets loaded on require is in fact a ES5 transpiled version with the right shims added. This means that you can require it and use with your favourite bundler without having to adjust asset management process.
32+
33+
```JavaScript
34+
var Unixfs = require('ipfs-unixfs')
35+
```
36+
37+
## Use in a browser Using a script tag
38+
39+
Loading this module through a script tag will make the `Unixfs` obj available in the global namespace.
40+
41+
```html
42+
<script src="https://npmcdn.com/ipfs-unixfs/dist/index.min.js"></script>
43+
<!-- OR -->
44+
<script src="https://npmcdn.com/ipfs-unixfs/dist/index.js"></script>
45+
```
46+
1347
# Usage
48+
49+
## Examples
50+
51+
#### Create a file composed by several blocks
52+
53+
```JavaScript
54+
var data = new Unixfs('file')
55+
data.addBlockSize(256) // add the size of each block
56+
data.addBlockSize(256)
57+
// ...
58+
```
59+
60+
#### Create a directory that contains several files
61+
62+
Creating a directory that contains several files is achieve by creating a unixfs element that identifies a MerkleDAG node as a directory. The links of that MerkleDAG node are the files that are contained in this directory.
63+
64+
```JavaScript
65+
var data = new Unixfs('directory')
66+
```
67+
68+
## API
69+
70+
#### unixfs Data Structure
71+
72+
```protobuf
73+
message Data {
74+
enum DataType {
75+
Raw = 0;
76+
Directory = 1;
77+
File = 2;
78+
Metadata = 3;
79+
Symlink = 4;
80+
}
81+
82+
required DataType Type = 1;
83+
optional bytes Data = 2;
84+
optional uint64 filesize = 3;
85+
repeated uint64 blocksizes = 4;
86+
}
87+
88+
message Metadata {
89+
required string MimeType = 1;
90+
}
91+
```
92+
93+
#### create an unixfs Data element
94+
95+
```JavaScript
96+
var data = new UnixFS(<type>, [<content>])
97+
```
98+
99+
Type can be: `['raw', 'directory', 'file', 'metadata', 'symlink']`
100+
101+
#### add and remove a block size to the block size list
102+
103+
```JavaScript
104+
data.addBlockSize(<size in bytes>)
105+
```
106+
107+
```JavaScript
108+
data.removeBlockSize(<index>)
109+
```
110+
111+
#### get total fileSize
112+
113+
```JavaScript
114+
data.fileSize() // => size in bytes
115+
```
116+
117+
#### marshal and unmarshal
118+
119+
```
120+
var marsheled = data.marshal()
121+
var unmarsheled = Unixfs.unmarshal(marsheled)
122+
```

package.json

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,9 @@
1010
"test:browser": "dignified-test browser",
1111
"build": "dignified-build",
1212
"lint": "dignified-lint",
13-
"release": "dignified-release"
13+
"release": "dignified-release",
14+
"release-minor": "dignified-release --minor",
15+
"release-major": "dignified-release --major"
1416
},
1517
"repository": {
1618
"type": "git",

0 commit comments

Comments
 (0)