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

tplus-mutants

v1.0.1

Published

mutants框架应用 , 包含环境检测,cordova/微信native状态检测等初始化功能.

Downloads

2

Readme

Chanjet-Mutants v0.0.6

作为Mutants框架的入口,提供以下功能:

  • 不同平台(工作圈 , 微信 , 钉钉等)的统一预处理.
  • 环境检测
  • native能力

加载

目前还是使用 import 方式进行进入 , 在适当时候 , 我们会将 mutants 更新到cdn服务器 , 使用script方式加载 . 目的是为了当工作圈native能力发生更新时 , mutants 提供的插件能力也能够同步更新 , 减少npm包管理导致的依赖复杂性.

我们会通过版本号来管理不同版本 , 这样可以兼容不同版本的工作圈.

安装

npm install chanjet-mutants

ready

mutants.ready 作为 mutants 整个框架的入口 , 会先检测不同平台 native 能力是否准备完成 . 当准备完成后 , 将会执行通过 ready 传入的回调函数

import mutants from 'chanjet-mutants';

mutants.ready( () => {
  //启动应用
});

环境检测

mutants 提供环境检测之前 , 环境检测是有 chanjet-env-check 这个包来完成的. 现在 mutants 中已经整合了环境检测 , 也是使用 chanjet-env-check , 挂载在 mutants.env 对象上.

import mutants from 'chanjet-mutants'

/*
mutants封装了chanjet-env-check对象,可以快速获取当前环境,无需在引入chanjet-env-check包,详见接口文档
*/

//当前平台
console.log(mutants.env.platform);
//当前系统或设备
console.log(mutants.env.os);
//当前浏览器
console.log(mutants.env.browser);

//可以通过constant来判断

//判断是否是chanjet平台
mutants.env.platform == mutants.constant.platform.chanjet
//判断是否是ios操作系统
mutants.env.os == mutants.constant.os.ios
//判断是否是chrome浏览器
mutants.env.browser == mutants.constant.browser.chrome

Native能力

目前提供的Native能力 , 都可以在 mutants.plugin 对象上找到.

具体能力见下表:

| API | Native能力 | 文档 | | -------------------------------- | ---------------------- | ------------------------------------- | | mutants.plugin.auth | 企业信息及权限相关 | 去看看 | | mutants.plugin.choosePhoto | 读取相册选照片 | 去看看 | | mutants.plugin.takePhoto | 拍照 | 去看看 | | mutants.plugin.preview | 预览 | 去看看 | | mutants.plugin.upload | 上传 | 去看看 | | mutants.plugin.geo | 定位 | 去看看 | | mutants.plugin.phone | 电话 | 去看看 | | mutants.plugin.sms | 短信 | 去看看 | | mutants.plugin.share | 分享 | 去看看 | | mutants.plugin.speechReco | 语音识别 | 去看看 | | mutants.plugin.restoreStatus | 安卓restore状态查询(Private) | |

所有插件的方法, 都可以在对应的 mutants.plugin[pluginName] 上直接使用.

为了兼容好会计之前的调用方式, 每一个插件的包依旧支持独立使用 , 等好会计调整过后. 将不再提供.

Mock

在开发过程中, 可以在浏览器环境中 , 使用 mock 数据来模拟Native能力的调用返回. 上表中 , 详细文档中会有每个插件的 mock 数据格式 .

通过 mutants.plugin.setMockData 可以进行 mock 数据的绑定.

choosePhoto 为例:

import mutants from 'chanjet-mutants'

const mockData = {
  //读取相册成功
  ChoosePhotoPlugin: {
    status: 'success',
    //替换成自己想显示的图片
    data: ['http://www.example.com/example.png']
  },
};

//设置mock数据
mutants.plugin.setMockData(mockData);


//详细文档参见ChoosePhotoPlugin文档
const choosePhotoOptions = {
  maxCount : 2,
  quality : 0
};
mutants.plugin.choosePhoto.choosePhoto(choosePhotoOpitons , (rs) => {
  //rs.body.data 中得数据 应该是mockData中所设置的
  console.log(rs);
});