@rpldy/chunked-sender
Version:
adds chunked upload capabilities on top of the regular XHR uploads
28 lines • 591 B
JavaScript
import createState from "@rpldy/simple-state";
const getChunkedState = (chunks, url, sendOptions, chunkedOptions) => {
const {
state,
update
} = createState({
finished: false,
aborted: false,
error: false,
uploaded: {},
requests: {},
responses: [],
chunkCount: chunks.length,
startByte: sendOptions.startByte || 0,
lastChunkErrorData: null,
chunks,
url,
sendOptions,
...chunkedOptions
});
return {
getState: () => state,
updateState: updater => {
update(updater);
}
};
};
export default getChunkedState;