Skip to content

Commit d0d4943

Browse files
committed
Merge pull request #30 from dignifiedquire/dignified
Use dignified.js
2 parents 805aa79 + 27f81b3 commit d0d4943

File tree

51 files changed

+41
-86
lines changed

Some content is hidden

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

51 files changed

+41
-86
lines changed

.gitignore

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -31,5 +31,8 @@ atlassian-ide-plugin.xml
3131
com_crashlytics_export_strings.xml
3232
/node_modules
3333
**/*.log
34-
tests/repo-just-for-test*
35-
/tests/blocks
34+
test/repo-just-for-test*
35+
/test/blocks
36+
37+
dist
38+
lib

karma.conf.js

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

package.json

Lines changed: 15 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -2,27 +2,34 @@
22
"name": "ipfs-merkle-dag",
33
"version": "0.3.0",
44
"description": "A JavaScript implementations of the IPFS MerkleDAG implementations (protobufs)",
5-
"main": "./src/index.js",
5+
"main": "lib/index.js",
6+
"jsnext:main": "src/index.js",
67
"scripts": {
7-
"test": "npm run test:node && npm run test:browser",
8-
"test:node": "mocha tests/index.js",
9-
"test:browser": "karma start --single-run=true karma.conf.js",
10-
"lint": "standard"
8+
"lint": "dignified-lint",
9+
"build": "dignified-build",
10+
"test": "dignified-test",
11+
"test:node": "dignified-test node",
12+
"test:browser": "dignified-test browser",
13+
"release": "dignified-release",
14+
"coverage": "dignified-coverage"
1115
},
1216
"pre-commit": [
1317
"lint",
1418
"test"
1519
],
1620
"author": "Vijayee Kulkaa <[email protected]>",
1721
"contributors": [
18-
"David Dias <[email protected]>"
22+
"David Dias <[email protected]>",
23+
"Friedel Ziegelmayer <[email protected]>"
1924
],
2025
"license": "ISC",
2126
"repository": {
2227
"type": "git",
2328
"url": "https://github.com/vijayee/js-ipfs-merkle-dag.git"
2429
},
2530
"dependencies": {
31+
"bs58": "^3.0.0",
32+
"detect-node": "^2.0.3",
2633
"ipfs-blocks": "^0.1.0",
2734
"is-ipfs": "^0.2.0",
2835
"multihashing": "^0.2.0",
@@ -31,29 +38,15 @@
3138
},
3239
"devDependencies": {
3340
"async": "^1.5.2",
34-
"brfs": "^1.4.3",
35-
"bs58": "^3.0.0",
3641
"buffer-loader": "0.0.1",
3742
"chai": "^3.5.0",
43+
"dignified.js": "^1.0.0",
3844
"fs-blob-store": "^5.2.1",
3945
"idb-plus-blob-store": "^1.0.0",
4046
"ipfs-repo": "^0.5.3",
41-
"json-loader": "^0.5.4",
42-
"karma": "^0.13.19",
43-
"karma-chrome-launcher": "^0.2.2",
44-
"karma-cli": "^0.1.2",
45-
"karma-firefox-launcher": "^0.1.7",
46-
"karma-mocha": "^0.2.1",
47-
"karma-sourcemap-loader": "^0.3.7",
48-
"karma-spec-reporter": "0.0.24",
49-
"karma-webpack": "^1.7.0",
5047
"lodash": "^4.6.1",
51-
"mocha": "^2.4.5",
5248
"ncp": "^2.0.0",
5349
"pre-commit": "^1.1.2",
54-
"rimraf": "^2.5.0",
55-
"standard": "^6.0.8",
56-
"transform-loader": "^0.2.3",
57-
"webpack": "^2.0.7-beta"
50+
"rimraf": "^2.5.0"
5851
}
5952
}

src/dag-node.js

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
'use strict'
2+
13
var util = require('./util')
24
var protobuf = require('protocol-buffers')
35
var stable = require('stable')

src/dag-service-batch.js

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
'use strict'
2+
13
var Block = require('ipfs-blocks').Block
24

35
exports = module.exports = Batch

src/dag-service.js

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
'use strict'
2+
13
const DAGNode = require('./dag-node').DAGNode
24
const Block = require('ipfs-blocks').Block
35
const isIPFS = require('is-ipfs')
@@ -70,8 +72,9 @@ function DAGService (blockService) {
7072
nodeStack.push(node)
7173

7274
var keys = []
75+
var link
7376
for (var i = 0; i < node.links.length; i++) {
74-
var link = node.links[i]
77+
link = node.links[i]
7578
keys.push(link.hash)
7679
}
7780
linkStack = linkStack.concat(keys)
@@ -81,13 +84,14 @@ function DAGService (blockService) {
8184
if (next) {
8285
this.getRecursive(next, callback, linkStack, nodeStack)
8386
} else {
87+
const compare = (hash) => (node) => {
88+
node.multihash().equals(hash)
89+
}
8490
for (var k = 0; k < nodeStack.length; k++) {
8591
var current = nodeStack[k]
8692
for (var j = 0; j < current.links.length; j++) {
8793
link = current.links[j]
88-
var index = nodeStack.findIndex((node) => {
89-
return node.multihash().equals(link.hash)
90-
})
94+
var index = nodeStack.findIndex(compare(link.hash))
9195
if (index !== -1) {
9296
link.node = nodeStack[index]
9397
}

src/index.js

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
'use strict'
2+
13
exports.DAGNode = require('./dag-node.js').DAGNode
24
exports.DAGLink = require('./dag-node.js').DAGLink
35
exports.DAGService = require('./dag-service.js')

src/util.js

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,10 @@
1+
'use strict'
2+
13
var multihashing = require('multihashing')
4+
var isNode = require('detect-node')
25

36
exports = module.exports
47

58
// Hash is the global IPFS hash function. uses multihash SHA2_256, 256 bits
6-
exports.hash = (data) => { return multihashing(data, 'sha2-256') }
7-
exports.isBrowser = () => { return !!global.window }
9+
exports.hash = (data) => multihashing(data, 'sha2-256')
10+
exports.isBrowser = () => !isNode
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.

tests/index.js renamed to test/node.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,8 @@ const expect = require('chai').expect
77
const IPFSRepo = require('ipfs-repo')
88

99
describe('node test blocks', () => {
10-
const repoExample = process.cwd() + '/tests/example-repo'
11-
const repoTests = process.cwd() + '/tests/repo-just-for-test' + Date.now()
10+
const repoExample = process.cwd() + '/test/example-repo'
11+
const repoTests = process.cwd() + '/test/repo-just-for-test' + Date.now()
1212

1313
before((done) => {
1414
ncp(repoExample, repoTests, (err) => {

0 commit comments

Comments
 (0)