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

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

上级 53bd3bd2
...@@ -22,6 +22,7 @@ ...@@ -22,6 +22,7 @@
"@vue/test-utils": "^1.0.0-beta.25", "@vue/test-utils": "^1.0.0-beta.25",
"babel-eslint": "^10.0.1", "babel-eslint": "^10.0.1",
"babylon": "^6.18.0", "babylon": "^6.18.0",
"base64-arraybuffer": "^0.2.0",
"browserslist": "^4.4.2", "browserslist": "^4.4.2",
"caniuse-lite": "^1.0.30000940", "caniuse-lite": "^1.0.30000940",
"chai": "^4.1.2", "chai": "^4.1.2",
...@@ -59,8 +60,8 @@ ...@@ -59,8 +60,8 @@
"globals": { "globals": {
"App": true, "App": true,
"Page": true, "Page": true,
"Component": true, "Component": true,
"Behavior":true, "Behavior": true,
"getApp": true, "getApp": true,
"getCurrentPages": true, "getCurrentPages": true,
"plus": true, "plus": true,
...@@ -76,8 +77,8 @@ ...@@ -76,8 +77,8 @@
"__PLATFORM__": true, "__PLATFORM__": true,
"__VERSION__": true, "__VERSION__": true,
"__GLOBAL__": true, "__GLOBAL__": true,
"__PLATFORM_TITLE__": true, "__PLATFORM_TITLE__": true,
"__PLATFORM_PREFIX__":true "__PLATFORM_PREFIX__": true
}, },
"rules": { "rules": {
"no-tabs": 0, "no-tabs": 0,
......
...@@ -2,7 +2,7 @@ import { ...@@ -2,7 +2,7 @@ import {
isFn isFn
} from 'uni-shared' } 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$/ const CONTEXT_API_RE = /^create|Manager$/
...@@ -56,18 +56,18 @@ export function promisify (name, api) { ...@@ -56,18 +56,18 @@ export function promisify (name, api) {
success: resolve, success: resolve,
fail: reject fail: reject
}), ...params) }), ...params)
/* eslint-disable no-extend-native */ /* eslint-disable no-extend-native */
if (!Promise.prototype.finally) { if (!Promise.prototype.finally) {
Promise.prototype.finally = function (callback) { Promise.prototype.finally = function (callback) {
const promise = this.constructor const promise = this.constructor
return this.then( return this.then(
value => promise.resolve(callback()).then(() => value), value => promise.resolve(callback()).then(() => value),
reason => promise.resolve(callback()).then(() => { reason => promise.resolve(callback()).then(() => {
throw reason 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.
先完成此消息的编辑!
想要评论请 注册