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

@mznjs/utils

v0.0.12

Published

JavaScript 函数库、工具类

Downloads

3

Readme

@mznjs/utils

一些常用的自用 JavaScript 函数库、工具类。

安装

npm install @mznjs/utils

pnpm add @mznjs/utils

使用

CommonJS

const utils = require('@mznjs/utils')
const hello = require('@mznjs/utils').hello;
const CommonJS= require('@mznjs/utils')

test('CommonJS 输出 "hello world"', () => {
    expect(CommonJS.hello()).toBe('hello world');
  });

module

import { hello } from '@mznjs/utils';
 hello(); //输出 "hello world"

import * as utils from '@mznjs/utils';
utils.hello(); //输出 "hello world"

module

import * as module from '@mznjs/utils';

test('module 输出 "hello world"', () => {
    expect(module.hello()).toBe('hello world');
  });
  • 关于更多示例,请参考test目录下的测试用例。

API

函数名解释

  1. isEmpty

    • 检查提供的值是否为空,这可能意味着nullundefined、空对象、空数组或空字符串。
  2. isNotEmpty

    • 检查提供的值是否不为空(即不是null)。
  3. isEmptyOne

    • 在一系列参数中检查是否存在nullundefined值。
  4. isEmptyLish

    • 检查给定的值是否为nullundefined、空对象、空数组或空字符串。
  5. isEmptyAll

    • 检查所有传入的参数是否为nullundefined、空对象、空数组或空字符串。
  6. concat

    • 连接两个数组。
  7. isObject

    • 判断给定的值是否是非数组对象。
  8. isArray

    • 判断给定的值是否为数组。
  9. deepEqual

    • 递归地比较两个值是否完全相等,支持基本类型和嵌套数组。
  10. arrayEqual

    • 比较两个数组是否完全相等,包括它们的嵌套数组。
  11. arraySort

    • 根据提供的排序条件对数组进行排序。
  12. covArr

    • 计算数组的平均值(实际上,协方差通常需要两个数组来计算)。
  13. sumArr

    • 计算数组中所有数字元素的总和。
  14. filterOptionArray

    • 从数组中过滤掉具有特定键名的对象。
  15. removeKeyPathFromObjectArray

    • 从对象数组中删除具有特定路径的属性。
  16. getArrayNum

    • 获取数组中指定索引范围内的子数组。
  17. getCount

    • 统计数组中每个元素的出现次数,并返回排序后的结果。
  18. getEleCount

    • 计算数组中特定元素的出现次数。
  19. getOptionArray

    • 从数组中根据指定的键获取值,组成新数组。
  20. maxArr

    • 找到数组中的最大值。
  21. minArr

    • 找到数组中的最小值。
  22. randomOne

    • 从数组中随机选择一个元素。
  23. removeArrayForValue

    • 从数组中移除与给定值相等或模糊匹配的元素。
  24. removeRepeatArr

    • 移除数组中的重复元素。
  25. getRandomNumber

    • 生成指定范围内的随机数。
  26. hello

    • 一个简单的函数,可能用于返回问候语。