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

jxk

v0.1.11

Published

A relatively commonly used tool and function

Downloads

3,105

Readme

中文 | English

目录

简介

jxk(意为: 极速、小巧、快捷) 库旨在为开发人员提供一系列便捷工具,可以在客户端和服务器端的 JavaScript 环境中使用。它包括处理对象和数组、字符串操作、类型检查等功能的常用函数。

安装

要使用 jxk ,您可以通过 npm 进行安装:

pnpm add jxk
yarn add jxk
npm i jxk

使用

安装后,您可以在项目中导入库:

import jxk from 'jxk';

// Or if you are using a function:
import {
    sm4
} from 'jxk';

函数

所有函数请访问:https://www.jixiaokang.com/jxk/

以下是 jxk 库中包含的一些函数列表:

HTML 标签处理

  • browser_decode: HTML 标签反转义。

    • 用途: 将 HTML 实体转换回原始字符。
    • 示例:
      browser_decode('&lt;p&gt;Hello&lt;/p&gt;'); // 返回 "<p>Hello</p>"
  • browser_encode: HTML 标签转义。

    • 用途: 将特殊字符转换为 HTML 实体以防止 XSS 攻击。
    • 示例:
      browser_encode('<p>Hello</p>'); // 返回 "&lt;p&gt;Hello&lt;/p&gt;"

加密算法

  • sm2: SM2 国密算法,包括生成密钥对、加密、解密、签名、验签等功能。
  • sm3: SM3 消息摘要算法。
  • sm4: SM4 加密和解密功能。

时间格式化

  • time_date: 格式化时间,参考文档为 date-fns
  • time_format: 格式化时间。

地址分析

  • analysis_address: 省、市、区分析提取。
  • analysis_idcard: 对身份证号解析。

数组处理

  • array_chunk: 根据指定大小将数组分割成二维数组。

    • 示例:
      array_chunk([1, 2, 3, 4, 5], 2); // 返回 [[1, 2], [3, 4], [5]]
  • array_concat: 合并数组。

    • 示例:
      array_concat([1, 2], [3, 4]); // 返回 [1, 2, 3, 4]
  • array_countOccurrences: 统计数组中各项出现的次数。

    • 示例:
      array_countOccurrences(['apple', 'banana', 'apple', 'orange', 'banana', 'banana']);
      // 返回 { apple: 2, banana: 3, orange: 1 }
  • array_diffBoth: 数组的差集。

  • array_diffFirst: 取第一个数组的差集。

  • array_durstenfeldShuffle: Durstenfeld 随机洗牌算法。

  • array_findIndex: 查找数组中匹配的索引。

  • array_findObj: 查找数组中匹配的值。

  • array_findParent: 在数组中获取指定子 ID 的祖级数据。

  • array_findParent (另一个): 在 Tree 中获取指定子 ID 的祖级数据。

  • array_flatten: 将多维数组拍平为一维数组。

  • array_fromTree: 将树形结构转换为扁平化的数组。

  • array_groupBy: 数组数据分组。

  • array_intersection: 计算两个数组的交集。

  • array_keyBy: 数组按 key 排序。

  • array_max: 计算数组中的最大值。

  • array_merge: 合并多个数组并返回它们的并集。

  • array_min: 计算数组中的最小值。

  • array_omitBy: 从数组中排除指定标签的项。

  • array_paging: 对数组进行分页。

  • array_pick: 从数组中选择指定标签的项。

  • array_randomItem: 随机取数组中的元素。

  • array_remove: 根据元素删除。

  • array_sattoloShuffle: Sattolo 洗牌算法。

  • array_shuffle: 数组随机排序(俗称洗牌)。

  • array_sort: 排序。

  • array_sumBy: 数组求和。

  • array_toMapByKey: 根据某个键的值将数组转换为 Map 对象。

  • array_toTree: 将数组转换为树形结构。

  • array_uniqWith: 数组去重。

  • array_unique: 数组去重。

  • array_uniqueByField: 对象数组根据某个字段去重。

浏览器操作

  • browser_copyText: 复制文本。
    • 示例:
      browser_copyText('Hello, world!');

贡献

欢迎贡献!请阅读 CONTRIBUTING.md 文件以了解我们的行为准则、提交拉取请求的方式等详情。

许可证

MIT License © 2024 xkloveme