Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

dudup

Package Overview
Dependencies
Maintainers
1
Versions
4
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

dudup

## 安装

  • 1.0.1-alpha.5
  • latest
  • npm
  • Socket score

Version published
Maintainers
1
Created
Source

上传基类

安装

# NPM
$ npm i dudup
# YARN
$ yarn add dudup

拓展平台

import { Sender, Typings } from 'dudup'

export default class CustomSender extends Sender {
  public upload(): Promise<{ file: string }> {
    // something todo...
  }
}

拓展客户端

一般情况下, 我们只需根据平台继承 RequestorUploadFile 即可

import { Requestor, UploadFile, Typings } from 'dudup'

class CustomRequestor extends Requestor implements Typings.Requestor {
  send(): Promise<any> {
    // something todo...
  }
  cancel(): Promise<void> {
    // something todo...
  }
}

class CustomUploadFile extends UploadFile implements Typings.UploadFile {
  get extname(): string {
    // something todo...
  }
  get size(): number {
    // something todo...
  }
  get hash(): string {
    // something todo...
  }
  public slice(beginPos: number, endPos: number, mimeType?: string): any {
    // something todo...
  }
  public async genContentHash(): Promise<string> {
    // something todo...
  }
  public async saveCache(token?: string): Promise<boolean> {
    // something todo...
    // 如果没有, 返回 true
  }
  public async loadCache(token?: string): Promise<boolean> {
    // something todo...
    // 如果没有, 返回 true
  }
  public async clearCache(token?: string): Promise<boolean> {
    // something todo...
    // 如果没有, 返回 true
  }
}

export default class CustomUploader extends CustomSender {
  constructor(options?: Typings.SenderOptions) {
    super(CustomRequestor, CustomUploadFile, options)
  }
}

注意

因为继承需要重写的函数比较多, 建议使用 Typescript 进行拓展, 否则容易错漏.

FAQs

Package last updated on 28 Jul 2020

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc