tus-js-client: Not needed anymore (#44863)

This commit is contained in:
Marius 2020-05-27 23:30:06 +02:00 committed by GitHub
parent 55e6ea8afd
commit c72fb78d37
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
5 changed files with 6 additions and 128 deletions

View File

@ -5178,6 +5178,12 @@
"sourceRepoURL": "https://github.com/samchon/tstl",
"asOfVersion": "1.5.7"
},
{
"libraryName": "tus-js-client",
"typingsPackageName": "tus-js-client",
"sourceRepoURL": "https://github.com/tus/tus-js-client",
"asOfVersion": "2.1.0"
},
{
"libraryName": "typed.js",
"typingsPackageName": "typed.js",

View File

@ -1,42 +0,0 @@
// Type definitions for tus-js-client 1.8
// Project: https://github.com/tus/tus-js-client/
// Definitions by: Kevin Somers-Higgins <https://github.com/kevhiggins>
// Marius Kleidl <https://github.com/Acconut>
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
// TypeScript Version: 3.2
export interface UploadOptions {
endpoint: string;
fingerprint?: (file: File, options?: UploadOptions) => string;
resume?: boolean;
metadata?: { [key: string]: string };
onProgress?: ((bytesSent: number, bytesTotal: number) => void) | null;
onChunkComplete?: ((chunkSize: number, bytesAccepted: number, bytesTotal: number) => void) | null;
onSuccess?: (() => void) | null;
onError?: ((error: Error) => void) | null;
headers?: { [key: string]: string };
chunkSize?: number;
withCredentials?: boolean;
uploadUrl?: string | null;
uploadSize?: number | null;
overridePatchMethod?: boolean;
retryDelays?: number[];
removeFingerprintOnSuccess?: boolean;
uploadLengthDeferred?: boolean;
}
export class Upload {
constructor(file: File | Blob | Pick<ReadableStreamDefaultReader, "read">, options: UploadOptions);
file: File | Blob | Pick<ReadableStreamDefaultReader, "read">;
options: UploadOptions;
url: string | null;
static terminate(url: string, options?: UploadOptions, callback?: (error?: Error) => void): void;
start(): void;
abort(shouldTerminate?: boolean, callback?: (error?: Error) => void): void;
}
export const isSupported: boolean;
export const canStoreURLs: boolean;
export const defaultOptions: UploadOptions;

View File

@ -1,24 +0,0 @@
{
"compilerOptions": {
"module": "commonjs",
"lib": [
"es6",
"dom"
],
"noImplicitAny": true,
"noImplicitThis": true,
"strictNullChecks": true,
"strictFunctionTypes": true,
"baseUrl": "../",
"typeRoots": [
"../"
],
"types": [],
"noEmit": true,
"forceConsistentCasingInFileNames": true
},
"files": [
"index.d.ts",
"tus-js-client-tests.ts"
]
}

View File

@ -1 +0,0 @@
{ "extends": "dtslint/dt.json" }

View File

@ -1,61 +0,0 @@
import * as Tus from 'tus-js-client';
const isSupported = Tus.isSupported;
const canStoreURLs = Tus.canStoreURLs;
const defaultChunkSize = Tus.defaultOptions.chunkSize;
const file = new File(["foo"], "foo.txt", {
type: "text/plain",
});
const upload = new Tus.Upload(file, {
endpoint: "",
fingerprint: (file: File) => file.name,
resume: true,
metadata: {
filename: "foo.txt"
},
onProgress: (bytesSent: number, bytesTotal: number) => {
const percentage = (bytesSent / bytesTotal * 100).toFixed(2);
console.log(bytesSent, bytesTotal, percentage + "%");
},
onChunkComplete: (chunkSize: number, bytesAccepted: number) => {},
onSuccess: () => {
console.log("Download from %s complete", upload.url);
},
onError: (error: Error) => {
console.log("Failed because: " + error);
},
headers: {TestHeader: 'TestValue'},
chunkSize: 100,
withCredentials: true,
uploadUrl: "",
uploadSize: 50,
overridePatchMethod: true,
retryDelays: [10, 20, 50],
removeFingerprintOnSuccess: true
});
upload.start();
upload.abort();
upload.abort(true);
upload.abort(true, (err?: Error) => {
console.log("Failed because: " + err);
});
const upload2 = new Tus.Upload(file, {
endpoint: ""
});
const reader = {
read: () => Promise.resolve({ done: true, value: '' }),
};
const upload3 = new Tus.Upload(reader, {
endpoint: '',
uploadLengthDeferred: true,
});
Tus.Upload.terminate('https://myurl.com', {
endpoint: ""
});