Skip to content

Commit

Permalink
made text() and json() aync
Browse files Browse the repository at this point in the history
  • Loading branch information
jeff-zucker committed Jun 15, 2019
1 parent 5f3ee87 commit b141644
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 5 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "solid-rest",
"version": "1.0.2",
"version": "1.0.3",
"author": "Jeff Zucker",
"license": "MIT",
"description": "treat any storage as a mini Solid server",
Expand Down
4 changes: 2 additions & 2 deletions src/file.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ class SolidFileStorage {
s.push(null)
return s;
}
text (stream) {
async text (stream) {
return new Promise((resolve, reject) => {
stream = stream || ""
if(typeof stream === "string") return resolve(stream);
Expand All @@ -27,7 +27,7 @@ class SolidFileStorage {
stream.on('error', reject())
})
}
json (stream) {
async json (stream) {
return text(stream).then(text => JSON.parse(text))
}

Expand Down
4 changes: 2 additions & 2 deletions src/rest.js
Original file line number Diff line number Diff line change
Expand Up @@ -119,12 +119,12 @@ async fetch(uri, options) {
json: _json.bind(null, body)
}
}
function _text (stream) {
async function _text (stream) {
if(typeof self.storage.text !="undefined")
return self.storage.text(stream)
else return stream
}
function _json (stream) {
async function _json (stream) {
if(typeof self.storage.json != "undefined") return self.storage.json(stream)
else return JSON.parse(stream)
}
Expand Down

0 comments on commit b141644

Please sign in to comment.