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

w-mini-tools

v1.0.3

Published

some tools from my work

Downloads

2

Readme

🥳 w-mini-tools

分享一些我工作上用到的小工具(封装方法),不定时更新,欢迎 star🌟

安装

  npm install w-mini-tools

方法

🔖 flatArrFromData

  • 扁平化数组
  • 注意:仅匹配 value 值,需要递归处理的话,子级 key 为 children
import { flatArrFromData } from "w-mini-tools";
const inputData = [{ value: 1, children: [{ value: 2 }] }]; //源数据
console.log(flatArrFromData(inputData)); //[1, 2]

🔖 batchAddDel

  • 根据差集批量删除数据
import { batchAddDel } from "w-mini-tools";
const inputData = [1, 2, 3, 4, 5]; //源数据
const addition = [6]; //待新增数组
const reduce = [2]; //待删减数组
console.log(batchAddDel(addition, reduce, inputData)); //[1, 3, 4, 5, 6]

🔖 filterDataByCondition

  • 根据条件过滤数据
  • 注意:仅支持一个层级
const condition = { isDisable: false }; //过滤条件
const filterData = [
  { label: "a", value: 1, isDisable: false },
  { label: "b", value: 2, isDisable: true },
]; //源数据
console.log(filterDataByCondition(filterData, condition)); //[{ label: "b", value: 2, isDisable: true }]

🔖 setDataByStyleRecursion

  • 根据指定格式返回数据
  • 支持递归,需设置判断递归的 key 值,如传入数组希望将 children 值对应的数据也进行递归,则 recursionKey 传入 children
  • 注意:递归关键字需 style 内配置的 key
const inputData = [
  {
    name: "Tom",
    age: 30,
    child: [
      {
        name: "Jerry",
        age: 5,
      },
    ],
  },
]; //源数据
const style = {
  label: "name",
  value: "age",
  children: "child",
}; //期望处理后的格式
const recursionKey = "children"; //递归关键字
console.log(setDataByStyleRecursion(inputData, style, recursionKey));
/**
 * [{
    label: "Tom",
    value: 30,
    children: [
      {
        label: "Jerry",
        value: 5,
      },
    ],
   }]
 */

🔖 numMulti

  • 数字以某个系数放大,2*100 = 200
  • 解决数字精度丢失问题,如:19.9*100 ≠ 1990
const num = 19.9; //待转换数字
const multiple = 100; //倍数
console.log(numMulti(num, multiple)); //1990

其他帮助

  • 不明白的,你可以来我的 github 看看 🧐
  • 有错误的,希望你可以提出,我们一起进步 🤣

相关文档

Document Link