MCPcopy Index your code
hub / github.com/mailru/FileAPI / _readAs

Function _readAs

lib/FileAPI.core.js:1473–1509  ·  view source on GitHub ↗
(file, fn, method, encoding)

Source from the content-addressed store, hash-verified

1471
1472
1473 function _readAs(file, fn, method, encoding){
1474 if( api.isBlob(file) && _hasSupportReadAs(method) ){
1475 var Reader = new FileReader;
1476
1477 // Add event listener
1478 _on(Reader, _readerEvents, function _fn(evt){
1479 var type = evt.type;
1480 if( type == 'progress' ){
1481 _emit(file, fn, evt, evt.target.result, { loaded: evt.loaded, total: evt.total });
1482 }
1483 else if( type == 'loadend' ){
1484 _off(Reader, _readerEvents, _fn);
1485 Reader = null;
1486 }
1487 else {
1488 _emit(file, fn, evt, evt.target.result);
1489 }
1490 });
1491
1492
1493 try {
1494 // ReadAs ...
1495 if( encoding ){
1496 Reader['readAs' + method](file, encoding);
1497 }
1498 else {
1499 Reader['readAs' + method](file);
1500 }
1501 }
1502 catch (err){
1503 _emit(file, fn, 'error', undef, { error: err.toString() });
1504 }
1505 }
1506 else {
1507 _emit(file, fn, 'error', undef, { error: 'filreader_not_support_' + method });
1508 }
1509 }
1510
1511
1512 function _isRegularFile(file, callback){

Callers 1

FileAPI.core.jsFile · 0.85

Calls 4

_hasSupportReadAsFunction · 0.85
_onFunction · 0.85
_emitFunction · 0.85
_offFunction · 0.85

Tested by

no test coverage detected