提交 55bdf71c 编写于 作者: Q qiang

feat: 增加API:uni.base64ToArrayBuffer、uni.arrayBufferToBase64

上级 53bd3bd2
......@@ -22,6 +22,7 @@
"@vue/test-utils": "^1.0.0-beta.25",
"babel-eslint": "^10.0.1",
"babylon": "^6.18.0",
"base64-arraybuffer": "^0.2.0",
"browserslist": "^4.4.2",
"caniuse-lite": "^1.0.30000940",
"chai": "^4.1.2",
......@@ -59,8 +60,8 @@
"globals": {
"App": true,
"Page": true,
"Component": true,
"Behavior":true,
"Component": true,
"Behavior": true,
"getApp": true,
"getCurrentPages": true,
"plus": true,
......@@ -76,8 +77,8 @@
"__PLATFORM__": true,
"__VERSION__": true,
"__GLOBAL__": true,
"__PLATFORM_TITLE__": true,
"__PLATFORM_PREFIX__":true
"__PLATFORM_TITLE__": true,
"__PLATFORM_PREFIX__": true
},
"rules": {
"no-tabs": 0,
......
......@@ -2,7 +2,7 @@ import {
isFn
} from 'uni-shared'
const SYNC_API_RE = /subNVue|requireNativePlugin|upx2px|hideKeyboard|canIUse|^create|Sync$|Manager$/
const SYNC_API_RE = /subNVue|requireNativePlugin|upx2px|hideKeyboard|canIUse|^create|Sync$|Manager$|base64ToArrayBuffer|arrayBufferToBase64/
const CONTEXT_API_RE = /^create|Manager$/
......@@ -56,18 +56,18 @@ export function promisify (name, api) {
success: resolve,
fail: reject
}), ...params)
/* eslint-disable no-extend-native */
if (!Promise.prototype.finally) {
Promise.prototype.finally = function (callback) {
const promise = this.constructor
return this.then(
value => promise.resolve(callback()).then(() => value),
reason => promise.resolve(callback()).then(() => {
throw reason
})
)
}
/* eslint-disable no-extend-native */
if (!Promise.prototype.finally) {
Promise.prototype.finally = function (callback) {
const promise = this.constructor
return this.then(
value => promise.resolve(callback()).then(() => value),
reason => promise.resolve(callback()).then(() => {
throw reason
})
)
}
}
}))
}
}
}
export const base64ToArrayBuffer = [{
name: 'base64',
type: String,
required: true
}]
export const arrayBufferToBase64 = [{
name: 'arrayBuffer',
type: [ArrayBuffer, Uint8Array],
required: true
}]
import { encode, decode } from 'base64-arraybuffer'
export const base64ToArrayBuffer = decode
export const arrayBufferToBase64 = encode
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册