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 🙏

© 2026 – Pkg Stats / Ryan Hefner

array-utils-cross

v1.0.4

Published

Cross-framework array merging and deduplication utilities

Downloads

3

Readme

npm npm downloads GitHub CI

array-utils-cross

安装

npm install array-utils-cross
# 或
yarn add array-utils-cross

使用

/**
 * # array-utils-cross 使用文档
 * 
 * ## 安装
 * ```bash
 * npm install array-utils-cross
 * # 或
 * yarn add array-utils-cross
 * ```
 * 
 * ## 导入方式
 * ```javascript
 * // ES6 模块
 * import { merge, unique, uniqueBy, mergeByKey } from 'array-utils-cross';
 * import ArrayUtils from 'array-utils-cross';
 * 
 * // CommonJS
 * const { merge, unique } = require('array-utils-cross');
 * ```
 * 
 * ## 核心功能示例
 * ### 1. 基本操作
 * ```javascript
 * // 合并数组
 * const merged = merge([1, 2], [2, 3]); // [1, 2, 2, 3]
 * 
 * // 去重
 * const uniqueArr = unique(merged); // [1, 2, 3]
 * ```
 * 
 * ### 2. 对象数组去重
 * ```javascript
 * const users = [
 *   { id: 1, name: 'A' },
 *   { id: 2, name: 'B' },
 *   { id: 1, name: 'C' }
 * ];
 * 
 * const uniqueUsers = uniqueBy(users, 'id');
 * // 结果: [{ id: 1, name: 'A' }, { id: 2, name: 'B' }]
 * ```
 * 
 * ### 3. 深度合并
 * ```javascript
 * const arr1 = [{ id: 1, age: 20 }];
 * const arr2 = [{ id: 1, name: 'Alice' }];
 * 
 * const mergedUsers = mergeByKey('id', arr1, arr2);
 * // 结果: [{ id: 1, age: 20, name: 'Alice' }]
 * ```
 * 
 * ### 4. 链式操作
 * ```javascript
 * const result = new ArrayUtils([1, 2, 2])
 *   .merge([3, 3, 4])
 *   .unique()
 *   .value(); // [1, 2, 3, 4]
 * ```
 * 
 * ## 在框架中使用
 * ### React 示例
 * ```jsx
 * import { uniqueBy } from 'array-utils-cross';
 * 
 * function UserList({ users }) {
 *   const uniqueUsers = uniqueBy(users, 'id');
 *   return (
 *     <div>
 *       {uniqueUsers.map(user => (
 *         <div key={user.id}>{user.name}</div>
 *       ))}
 *     </div>
 *   );
 * }
 * ```
 * 
 * ### Vue 示例
 * ```vue
 * <template>
 *   <div v-for="user in uniqueUsers" :key="user.id">{{ user.name }}</div>
 * </template>
 * 
 * <script>
 * import { uniqueBy } from 'array-utils-cross';
 * export default {
 *   props: { users: Array },
 *   computed: {
 *     uniqueUsers() { return uniqueBy(this.users, 'id'); }
 *   }
 * };
 * </script>
 * ```
 * 
 * ## API 参考
 * | 方法名          | 说明                                                                 |
 * |-----------------|----------------------------------------------------------------------|
 * | `merge(...arrays)` | 合并多个数组,返回新数组                                             |
 * | `unique(array)` | 基本类型数组去重,返回新数组                                         |
 * | `uniqueBy(array, keyOrFn)` | 对象数组去重(key 或自定义函数),返回新数组                         |
 * | `mergeByKey(key, ...arrays)` | 基于 key 深度合并对象数组,返回新数组                                |
 * | `ArrayUtils` 类  | 支持 `merge()`, `unique()`, `uniqueBy()`, `value()` 链式操作          |
 */