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

@miapp/utils

v1.0.8

Published

工具集

Downloads

14

Readme

utils

工具集

使用

import {
  // type
  typeOf,
  isNull,
  isUndefined,
  isNumber,
  isDate,
  isRegExp,
  isArray,
  isObject,
  isString,
  isFunction,
  isBoolean,
  isValue,

  // object
  forEach,
  mix,
  merge,
  clone,

  // data
  getData,
  setData,
  ellipsis,
  tryParse,
  escapeHTML,
  paramsToObj,
  objToParams,
  simpleDeepCompare,

  // params
  parseURL,
  getParams,
  getLaunchOptions,
  initParams,
  initLaunchOptions,
  getUrlParam,
  setUrlParam,
  deleteUrlParam,

  // navigate
  open,
  close
} from "@miapp/utils";

// type
typeOf({}); // object
isArray([]); // true

// data
const data = { a: { b: { c: 1 } } };
getData(data, 'a.b.c'); // 1
setData(data, 'a.b.c', 2); // 2
paramsToObj('a=1&b=2'); // { a: '1', b: '2' }
objToParams({ a: 1, b: 2 }); // a=1&b=2

// object
forEach(obj, (v, k) => console.log(v));
forEach(arr, (v, i) => console.log(v));
mix(obj1, obj2); // mix obj2 into obj1
merge(obj1, obj2); // return a new object
merge(obj1, obj2, obj3, true); // including undefined
clone(obj); // clone a new object

// params
const href = 'https://m.taobao.com?a=1&b=2&c=true';
getUrlParam(href); // like getParam()
getUrlParam(href, 'a'); // like getParam('a')
setUrlParam(href, 'a', 6); // https://m.taobao.com?a=6&b=2&c=true
setUrlParam(href, { a: 6, c: null }); // https://m.taobao.com?a=6&b=2
deleteUrlParam(href, 'a'); // https://m.taobao.com?b=2&c=true

App({
  onLaunch(opts) {
    initLaunchOptions(this, opts);
  }
})

// 页面
Page({
  onLoad(query) {
    initParams(this, query); // 初始化页面参数
  }
});

// 组件
Component({
  didMount() {
    const params = getParams(this); // { a: '1', b: '2', c: 'true' }
    const launchOpts = getLaunchOptions(this);
  }
})

// navigate
// https://m.taobao.com
close();
open(url);
open(url, { params: { a: 1, b: 2 } });

// 相对路径兼容小程序不带后缀
open('/pages/detail/index?a=1');
open('../detail/index');

// 数据回传
open(url, { backListener: data => console.log(data) }); // 前一个页面
close({ data: { a: 1, b: 2 } }); // 后一个页面

// 小程序跳转 webview 页面
open(url, { webview: true }); // /pages/webview/index?url=encodeURIComponent(url)

开发

  1. yarn 或者 ayarn阿里内网)安装依赖
  2. 小程序 IDE 打开组件(下载地址

更多命令

  • miapp newbranch: 新建分支
  • miapp push: 提交代码
  • miapp prepub: 预发(发布 beta 版本)
  • miapp publish: 正式发布