cordova-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From riknoll <...@git.apache.org>
Subject [GitHub] cordova-plugin-file pull request: CB-7862: FileReader reads large ...
Date Wed, 09 Mar 2016 00:01:23 GMT
Github user riknoll commented on a diff in the pull request:

    https://github.com/apache/cordova-plugin-file/pull/168#discussion_r55451426
  
    --- Diff: www/FileReader.js ---
    @@ -96,6 +106,78 @@ function initRead(reader, file) {
     }
     
     /**
    + * Callback used by the following read* functions to handle incremental or final success.
    + * Must be bound to the FileReader's this along with all but the last parameter,
    + * e.g. readSuccessCallback.bind(this, "readAsText", "UTF-8", offset, totalSize, accumulate)
    + * @param readType The name of the read function to call.
    + * @param encoding Text encoding, or null if this is not a text type read.
    + * @param offset Starting offset of the read.
    + * @param totalSize Total number of bytes or chars to read.
    + * @param accumulate A function that takes the callback result and accumulates it in
this._result.
    + * @param r Callback result returned by the last read exec() call, or null to begin reading.
    + */
    +function readSuccessCallback(readType, encoding, offset, totalSize, accumulate, r) {
    +    if (this._readyState === FileReader.DONE) {
    +        return;
    +    }
    +
    +    if (typeof r !== "undefined") {
    +        accumulate(r);
    +        this._progress = Math.min(this._progress + FileReader.READ_CHUNK_SIZE, totalSize);
    +
    +        if (typeof this.onprogress === "function") {
    +            this.onprogress(new ProgressEvent("progress", {loaded:this._progress, total:totalSize}));
    +        }
    +    }
    +
    +    if (typeof r === "undefined" || this._progress < totalSize) {
    +        var execArgs = [
    +            this._localURL,
    +            offset + this._progress,
    +            offset + this._progress + Math.min(totalSize - this._progress, FileReader.READ_CHUNK_SIZE)];
    +        if (encoding) {
    --- End diff --
    
    Nitpick: It would be nice to have a comment explaining that you only insert the encoding
when reading as text


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@cordova.apache.org
For additional commands, e-mail: dev-help@cordova.apache.org


Mime
View raw message