New Research: Supply Chain Attack on Axios Pulls Malicious Dependency from npm.Details →
Socket
Book a DemoSign in
Socket

@skit/wxjssdk-promisify

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

@skit/wxjssdk-promisify

为微信 JS-SDK 提供 TypeScript 支持,同时将其基于回调函数的异步 API 转化为 Promise 形式。

latest
Source
npmnpm
Version
1.6.0-2
Version published
Maintainers
1
Created
Source

@skit/wxjssdk-promisify

NPM Version NPM Download Dependency Status License

特性

  • 将微信 JS-SDK 中提供的基于回调函数的 API,转化为 Promise 形式(wx.func 将转换成同名的 wx.funcAsync 形式);
  • 可单独拷贝到项目中使用;
  • 支持 TypeScript;
  • 与微信 JS-SDK(当前版本:1.6.0)同步更新。

用法

安装:

npm install @skit/wxjssdk-promisify

导入:

const $ = require('@skit/wxjssdk-promisify');

$.promisifyAll({
    root: wx, // (可选)指定异步方法挂载到某个对象的属性上。默认挂载到 wx。
    extends: ['checkJsApi'] // (可选)若 JS-SDK 新增了某些 API 而本库尚未更新,可由此传入相应的方法名数组以转换成异步方法。
});

使用异步方法:

wx.checkJsApiAsync({ jsApiList: ['chooseWXPay'] })
    .then((res) => {
        console.info('success', res.checkResult);
    })
    .catch((err) => {
        console.error('fail', err);
    })
    .finally(() => {
        console.log('complete');
    });

/**
 * @example 以上示例代码等同于下方原生实现:
 */
wx.checkJsApi({
    jsApiList: ['chooseWXPay'],
    success: (res) => {
        console.info('success', res.checkResult);
    },
    fail: (err) => {
        console.error('fail', err);
    },
    complete: () => {
        console.log('complete');
    }
});

Keywords

微信

FAQs

Package last updated on 15 Apr 2022

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