npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

minapp-promise

v0.1.0

Published

不到 1KB 的小程序异步接口 Promise 化

Downloads

4

Readme

minapp-promise

不到 1KB 的小程序异步接口 Promise 化,支持所有小程序异步接口

如何使用

  1. 通过 npm 安装(确保已开启 使用 npm 模块 功能)

    npm install minapp-promise
  2. 构建

    在微信开发者工具中依次点击 工具 - 构建 npm

  3. 在代码中引入

    import pro from 'minapp-promise'
    
    pro.showToast({ title }).then(doSomething)
    pro.request({ url }).then(handleResponse).catch(handleError)
  4. 配合 VSCode 使用可获得代码提示

注意事项

  • 确保开发者工具中 ES6 转 ES5 选项开启

    minapp-promise 使用 ES6 新特性 Proxy 来代理 wx 对象,而现阶段仅有 iOS 10+ 支持这个特性(信息来源)。

  • 仅支持带有 successfail 回调的异步接口

    为了实现起来更方便,并未对 wx 对象中的同步接口进行特殊处理,使用者须自行甄别接口文档中的异步接口

  • complete 支持

    原生 Promise 并不支持 finally 方法,为此,如果你想使用 complete 回调,请作为参数传递

    pro.showToast({
      title: 'Hello, world',
      complete: () => console.log('showToast completed'),
    })
      .then(() => console.log('showToast succeeded'))
      .catch(() => console.log('showToast failed'))
  • d.ts 文件

    由于个人精力有限,且小程序接口太多,所以目前只写了一部分接口的类型声明,预计将在一个月之内完成全部类型声明。

更新记录

v0.1.0

Feats:

  • 添加部分接口的 d.ts,可在 VSCode 中进行代码提示

Fixes:

  • 解决新版开发者工具中打开 上传时进行代码保护 后编译报错

v0.0.2

Chores:

  • 更新文档
  • 添加 wx declare 以去除 flow 报错

v0.0.1

Feats:

  • 实现功能