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

@mpxjs/api-proxy

Package Overview
Dependencies
Maintainers
3
Versions
167
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@mpxjs/api-proxy - npm Package Compare versions

Comparing version 2.0.0 to 2.0.3

4

package.json
{
"name": "@mpxjs/api-proxy",
"version": "2.0.0",
"version": "2.0.3",
"description": "convert miniprogram API at each end",

@@ -30,3 +30,3 @@ "module": "src/index.js",

"homepage": "https://github.com/didi/mpx#readme",
"gitHead": "31590c823b8378fb8b81e2b82e989b00b20ce9cd"
"gitHead": "d3d589ead81928e7f2d3ad9b1ca46cc031d2f81d"
}

@@ -31,3 +31,3 @@ # mpx-api-proxy

|usePromise|Boolean|是否将 api 转化为 promise 格式使用|否|false|-|
|whiteList|Array(String)|不需要转化 promise 格式的 api|否|[]|需要 usePromise 设为 true|
|whiteList|Array(String)|强行转化为 promise 格式的 api|否|[]|需要 usePromise 设为 true|

@@ -34,0 +34,0 @@ ## example

@@ -9,3 +9,4 @@ import { error } from '../utils'

'qq_ali': wxToAliApi,
'swan_ali': wxToAliApi
'swan_ali': wxToAliApi,
'tt_ali': wxToAliApi
}

@@ -12,0 +13,0 @@ const platforms = ['wx', 'ali', 'swan', 'qq', 'tt']

@@ -38,20 +38,19 @@ import { getEnvObj, noop } from './utils'

function promisifyFilter (key, whiteList) {
function promisify (listObj, usePromise, whiteList) {
const result = {}
const whiteListMap = getMapFromList(whiteList)
const blackListMap = getMapFromList(blackList)
if (whiteListMap) {
return !!whiteListMap[key]
} else {
return !(blackListMap[key] || // 特别指定的方法
/^get\w*Manager$/.test(key) || // 获取manager的api
/^create\w*Context$/.test(key) || // 创建上下文相关api
/^(on|off)/.test(key) || // 以 on* 或 off开头的方法
/\w+Sync$/.test(key))
function promisifyFilter (key) {
if (whiteListMap) {
return !!whiteListMap[key]
} else {
return !(blackListMap[key] || // 特别指定的方法
/^get\w*Manager$/.test(key) || // 获取manager的api
/^create\w*Context$/.test(key) || // 创建上下文相关api
/^(on|off)/.test(key) || // 以 on* 或 off开头的方法
/\w+Sync$/.test(key))
}
}
}
function promisify (listObj, usePromise, whiteList) {
const result = {}
Object.keys(listObj).forEach(key => {

@@ -63,3 +62,3 @@ if (typeof listObj[key] !== 'function') {

result[key] = function (...args) {
if (usePromise && promisifyFilter(key, whiteList)) {
if (usePromise && promisifyFilter(key)) {
if (!args[0]) {

@@ -66,0 +65,0 @@ args[0] = { success: noop, fail: noop }

@@ -8,5 +8,9 @@ import { getEnvObj } from './utils'

Object.assign(target, list)
Object.keys(list).forEach(key => {
try {
target[key] = list[key]
} catch (e) {}
})
}
export default proxyAll
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