Skip to content
This repository has been archived by the owner on Dec 6, 2022. It is now read-only.

feat: convert String values to buffers to avoid strange situations in the browser #19

Merged
merged 2 commits into from
Dec 11, 2016
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -42,11 +42,11 @@
"multihashes": "^0.3.0"
},
"dependencies": {
"async": "^2.1.4",
"multihashing-async": "^0.3.0"
},
"engines": {
"node": ">=4.0.0"
"node": ">=4.0.0",
"npm": ">=3.0.0"
},
"contributors": [
"David Dias <daviddias.p@gmail.com>",
Expand All @@ -55,4 +55,4 @@
"greenkeeperio-bot <support@greenkeeper.io>",
"npmcdn-to-unpkg-bot <npmcdn-to-unpkg-bot@users.noreply.github.com>"
]
}
}
8 changes: 8 additions & 0 deletions src/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,14 @@ function Block (data) {
throw new Error('Block must be constructed with data')
}

if (typeof data !== 'string' || Buffer.isBuffer(data)) {
throw new Error('data should be Buffer')
}

if (!Buffer.isBuffer(data)) {
data = new Buffer(data)
}

this._cache = {}

data = ensureBuffer(data)
Expand Down