Skip to content
This repository was archived by the owner on Aug 12, 2020. It is now read-only.

Commit 69d8e4d

Browse files
Setup dignified.js
1 parent 5a400b4 commit 69d8e4d

File tree

103 files changed

+472
-214
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

103 files changed

+472
-214
lines changed

.gitignore

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,3 +29,6 @@ build/Release
2929
# Dependency directory
3030
# https://www.npmjs.org/doc/misc/npm-faq.html#should-i-check-my-node_modules-folder-into-git
3131
node_modules
32+
33+
dist
34+
lib

karma.conf.js

Lines changed: 0 additions & 54 deletions
This file was deleted.

package.json

Lines changed: 9 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -4,18 +4,20 @@
44
"description": "JavaScript implementation of the layout and chunking mechanisms used by IPFS",
55
"main": "src/index.js",
66
"scripts": {
7-
"lint": "standard",
8-
"test": "npm run test:node && npm run test:browser",
9-
"test:node": "mocha tests/index.js",
10-
"test:browser": "karma start karma.conf.js"
7+
"lint": "dignified-lint",
8+
"build": "dignified-build",
9+
"test": "dignified-test",
10+
"test:node": "dignified-test node",
11+
"test:browser": "dignified-test browser",
12+
"release": "dignified-release"
1113
},
1214
"pre-commit": [
1315
"lint",
1416
"test"
1517
],
1618
"repository": {
1719
"type": "git",
18-
"url": "git+https://github.com/diasdavid/js-ipfs-data-importing.git"
20+
"url": "git+https://github.com/ipfs/js-ipfs-data-importing.git"
1921
},
2022
"keywords": [
2123
"IPFS"
@@ -27,33 +29,21 @@
2729
},
2830
"homepage": "https://github.com/diasdavid/js-ipfs-data-importing#readme",
2931
"devDependencies": {
30-
"brfs": "^1.4.3",
3132
"bs58": "^3.0.0",
3233
"buffer-loader": "0.0.1",
3334
"chai": "^3.4.1",
35+
"dignified.js": "github:dignifiedquire/dignified.js",
3436
"fs-blob-store": "^5.2.1",
3537
"highland": "^2.7.1",
3638
"idb-plus-blob-store": "^1.0.0",
3739
"ipfs-repo": "^0.5.1",
3840
"istanbul": "^0.4.1",
3941
"json-loader": "^0.5.4",
40-
"karma": "^0.13.19",
41-
"karma-chrome-launcher": "^0.2.2",
42-
"karma-cli": "^0.1.2",
43-
"karma-firefox-launcher": "^0.1.7",
44-
"karma-mocha": "^0.2.1",
45-
"karma-sourcemap-loader": "^0.3.7",
46-
"karma-spec-reporter": "0.0.24",
47-
"karma-webpack": "^1.7.0",
48-
"mocha": "^2.3.4",
4942
"ncp": "^2.0.0",
5043
"pre-commit": "^1.1.2",
5144
"raw-loader": "^0.5.1",
5245
"rimraf": "^2.5.1",
53-
"standard": "^6.0.8",
54-
"string-to-stream": "^1.0.1",
55-
"transform-loader": "^0.2.3",
56-
"webpack": "^2.0.7-beta"
46+
"string-to-stream": "^1.0.1"
5747
},
5848
"dependencies": {
5949
"async": "^1.5.2",

src/chunker-fixed-size.js

Lines changed: 13 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,27 +1,19 @@
1-
var through2 = require('through2')
1+
'use strict'
22

3-
exports = module.exports = FixedSizeChunker
3+
const through2 = require('through2')
44

55
// The difference of this chunker compared to other fixed size chunkers
66
// available, is that it doesn't add padding the last chunk
7-
87
function FixedSizeChunker (size) {
9-
var stream = through2(transform, flush)
10-
11-
var buf = new Buffer(0)
8+
let buf = new Buffer(0)
129

1310
function transform (chunk, enc, cb) {
14-
var that = this
15-
11+
const that = this
1612
buf = Buffer.concat([buf, chunk])
1713

18-
if (buf.length >= size) {
19-
slice()
20-
}
21-
2214
function slice () {
23-
var chunk = new Buffer(size, 'binary')
24-
var newBuf = new Buffer(buf.length - size, 'binary')
15+
const chunk = new Buffer(size, 'binary')
16+
const newBuf = new Buffer(buf.length - size, 'binary')
2517
buf.copy(chunk, 0, 0, size)
2618
buf.copy(newBuf, 0, size, buf.length)
2719
buf = newBuf
@@ -32,6 +24,10 @@ function FixedSizeChunker (size) {
3224
}
3325
}
3426

27+
if (buf.length >= size) {
28+
slice()
29+
}
30+
3531
cb()
3632
}
3733

@@ -41,5 +37,7 @@ function FixedSizeChunker (size) {
4137
cb()
4238
}
4339

44-
return stream
40+
return through2(transform, flush)
4541
}
42+
43+
exports = module.exports = FixedSizeChunker

0 commit comments

Comments
 (0)