GitHub

@liuli-util/dom

Install using

npm install @liuli-util/dom

Exported Members

You can access these members by importing the module:

import { member } from '@liuli-util/dom';

BinaryUtil

class BinaryUtil

二进制相关工具类

Constructors

Properties

static ArrayBufferToJson

Type: undefined

@deprecated:

已废弃,请使用小谢驼峰的 arrayBufferToJson

Methods

static dataURItoBlob (...)

function dataURItoBlob (
   dataURI : string
) : any

转换 data url 为 blob 对象

@param:

dataURI

@ref:

static blobToFile (...)

function blobToFile (
   blob : Blob ,
   fileName : string
) : File

转换 Blob 为 File

@param:

blob

@param:

fileName 文件名

@ref:

static arrayBufferToBlob (...)

function arrayBufferToBlob (
   buffer : ArrayBuffer ,
   options ? : Omit<BlobPropertyBag, 'type'> & { type: BasicMemeTypeEnum }
) : Blob

转换 arraybuffer 为 blob 对象

@param:

buffer

@param:

options

static arrayBufferToBase64 (...)

function arrayBufferToBase64 (
   arraybuffer : ArrayBuffer
) : string

转换 arrayBuffer 为 base64 copy as by base64-arraybuffer

static base64ToArrayBuffer (...)

function base64ToArrayBuffer (
   base64 : string
) : ArrayBuffer

转换 base64 为 arrayBuffer copy as by base64-arraybuffer

static arrayBufferToString (...)

function arrayBufferToString (
   ArrayBuffer : ArrayBuffer
) : Promise<string>

arrayBuffer 转 string

static async arrayBufferToJson (...)

async function arrayBufferToJson < T > (
   arraybuffer : ArrayBuffer
) : Promise<T>

arrayBuffer 转 JSON

EventUtil

class EventUtil

事件工具类

Constructors

Properties

Methods

static add (...)

function add (
   dom : EventOriginType ,
   type : any ,
   listener : any ,
   options ? : boolean
) : void

No docs provided

static remove (...)

function remove (
   dom : EventOriginType ,
   type : any ,
   listener : any ,
   options ? : boolean
) : void

No docs provided

static removeByType (...)

function removeByType (
   dom : EventOriginType ,
   type : any ,
   options ? : boolean
) : CacheListener[]

No docs provided

proxyStorage

function proxyStorage < T : object > (
   storage : Storage
) : Storage & StorageObject<T>

代理 Storage 使之更简单易用

@param:

storage

downloadUrl

async function downloadUrl (
   url : string ,
   filename : string = url.substr(url.lastIndexOf('/') + 1)
) : any

根据 url 下载二进制资源

@param:

url 下载请求信息

@param:

filename 下载文件名,没有则默认为链接中的文件名

download

function download (
   blob : Blob ,
   filename : undefined = 'unknown'
) : any

在浏览器上下载二进制资源

@param:

blob 要下载的二进制资源

@param:

filename 文件名