Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
J
jio-main
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
Hardik Juneja
jio-main
Commits
e7a83798
Commit
e7a83798
authored
Dec 18, 2014
by
Romain Courteaud
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Move blob reader promises
parent
7afa86e8
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
29 additions
and
30 deletions
+29
-30
src/jio.js
src/jio.js
+29
-3
src/jio/core/util.js
src/jio/core/util.js
+0
-27
No files found.
src/jio.js
View file @
e7a83798
/*global window, RSVP, Blob, XMLHttpRequest, QueryFactory, Query, console */
/*jslint maxlen: 200*/
(
function
(
window
,
RSVP
,
Blob
,
QueryFactory
,
Query
)
{
/*global window, RSVP, Blob, XMLHttpRequest, QueryFactory, Query, console, FileReader */
(
function
(
window
,
RSVP
,
Blob
,
QueryFactory
,
Query
,
FileReader
)
{
"
use strict
"
;
var
util
=
{},
...
...
@@ -152,6 +152,32 @@
function
readBlobAsText
(
blob
)
{
var
fr
=
new
FileReader
();
return
new
RSVP
.
Promise
(
function
(
resolve
,
reject
,
notify
)
{
fr
.
addEventListener
(
"
load
"
,
resolve
);
fr
.
addEventListener
(
"
error
"
,
reject
);
fr
.
addEventListener
(
"
progress
"
,
notify
);
fr
.
readAsText
(
blob
);
},
function
()
{
fr
.
abort
();
});
}
util
.
readBlobAsText
=
readBlobAsText
;
function
readBlobAsArrayBuffer
(
blob
)
{
var
fr
=
new
FileReader
();
return
new
RSVP
.
Promise
(
function
(
resolve
,
reject
,
notify
)
{
fr
.
addEventListener
(
"
load
"
,
resolve
);
fr
.
addEventListener
(
"
error
"
,
reject
);
fr
.
addEventListener
(
"
progress
"
,
notify
);
fr
.
readAsArrayBuffer
(
blob
);
},
function
()
{
fr
.
abort
();
});
}
util
.
readBlobAsArrayBuffer
=
readBlobAsArrayBuffer
;
...
...
@@ -429,4 +455,4 @@
jIO
=
new
JioBuilder
();
window
.
jIO
=
jIO
;
}(
window
,
RSVP
,
Blob
,
QueryFactory
,
Query
));
}(
window
,
RSVP
,
Blob
,
QueryFactory
,
Query
,
FileReader
));
src/jio/core/util.js
View file @
e7a83798
...
...
@@ -245,33 +245,6 @@ function readBlobAsBinaryString(blob) {
}
exports
.
util
.
readBlobAsBinaryString
=
readBlobAsBinaryString
;
function
readBlobAsArrayBuffer
(
blob
)
{
var
fr
=
new
FileReader
();
return
new
RSVP
.
Promise
(
function
(
resolve
,
reject
,
notify
)
{
fr
.
addEventListener
(
"
load
"
,
resolve
);
fr
.
addEventListener
(
"
error
"
,
reject
);
fr
.
addEventListener
(
"
progress
"
,
notify
);
fr
.
readAsArrayBuffer
(
blob
);
},
function
()
{
fr
.
abort
();
});
}
exports
.
util
.
readBlobAsArrayBuffer
=
readBlobAsArrayBuffer
;
function
readBlobAsText
(
blob
)
{
var
fr
=
new
FileReader
();
return
new
RSVP
.
Promise
(
function
(
resolve
,
reject
,
notify
)
{
fr
.
addEventListener
(
"
load
"
,
resolve
);
fr
.
addEventListener
(
"
error
"
,
reject
);
fr
.
addEventListener
(
"
progress
"
,
notify
);
fr
.
readAsText
(
blob
);
},
function
()
{
fr
.
abort
();
});
}
exports
.
util
.
readBlobAsText
=
readBlobAsText
;
/**
* Acts like `Array.prototype.concat` but does not create a copy of the original
* array. It extends the original array and return it.
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment