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

expanded-tree-tools

v1.0.4

Published

**要求的数组结构如下** ```js const yourArrayData = [ { id: 1, cj: 1, }, { id: 2, cj: 2, }, { id: 3, cj: 3, }, { id: 4, cj: 2, }, { id: 5, cj: 3, }, { id: 6, cj: 4, }, ] ``` **使用 id 判断唯一值,使用 cj 找到父级节点及子节点**

Readme

此插件用于拥有cj属性的数组的一些常见操作

要求的数组结构如下

const yourArrayData = [
    { id: 1, cj: 1, },
    { id: 2, cj: 2, },
    { id: 3, cj: 3, },
    { id: 4, cj: 2, },
    { id: 5, cj: 3, },
    { id: 6, cj: 4, },
]

使用 id 判断唯一值,使用 cj 找到父级节点及子节点

API

1.getParentIndexByRowIndex:根据当前行的index获取当前行的父节点的行index

import { getParentIndexByRowIndex } from 'expanded-tree-tools';
const parentRowIndex = getParentIndexByRowIndex(arrayList, rowIndex);

Params

  • arrayList {Array}: 数组
  • rowIndex {Number}: 当前行index

2.getRowIndexByIdValue:根据 idValue 获得此id所在行的rowIndex

import { getRowIndexByIdValue } from 'expanded-tree-tools';
const rowIndexById = getRowIndexByIdValue(arrayList, idValue, idLabel);

Params

  • arrayList {Array}: 数组
  • idValue {Number}: 所需要查找的行的id的值
  • idLabel {Number}: id属性的字段名称,如:'id','jdid'

3.findNextSameLevelRow:根据 rowIndex 找到此行的同一级的下一行的index

import { findNextSameLevelRow } from 'expanded-tree-tools';
const nextSameLevelRowIndex = findNextSameLevelRow(arrayList, rowIndex);

Params

  • arrayList {Array}: 数组
  • rowIndex {Number}: 当前行index

4.findPreviousSameLevelRow:根据 rowIndex 找到此行的同一级上一行的index

import { findPreviousSameLevelRow } from 'expanded-tree-tools';
const previousSameLevelRowIndex = findPreviousSameLevelRow(arrayList, rowIndex);

Params

  • arrayList {Array}: 数组
  • rowIndex {Number}: 当前行index

5.isLastNodeInParent:根据 rowIndex 判断 当前节点是不是其父节点的最后一个子节点

import { isLastNodeInParent } from 'expanded-tree-tools';
const isLastNode = isLastNodeInParent(arrayList, rowIndex);

Params

  • arrayList {Array}: 数组
  • rowIndex {Number}: 当前行index

6.getChildArrayInParent:获取 此节点下所有的直接子节点

返回值结构为 { n: XX, obj: XX } n表示rowIndex, obj表示当前行的数据

import { getChildArrayInParent } from 'expanded-tree-tools';
const childArray = getChildArrayInParent(arrayList, rowIndex);

Params

  • arrayList {Array}: 数组
  • rowIndex {Number}: 当前行index

7.getIndexInParentByRowIndex:根据 当前节点的 rowIndex 获得 其在其直接父节点 中的 索引位置

import { getIndexInParentByRowIndex } from 'expanded-tree-tools';
const indexInParent = getIndexInParentByRowIndex(arrayList, rowIndex);

Params

  • arrayList {Array}: 数组
  • rowIndex {Number}: 当前行index

8.isFirstNodeInParent:根据 rowIndex 判断 当前节点是不是其父节点的第一个子节点

import { isFirstNodeInParent } from 'expanded-tree-tools';
const isFirstNode = isFirstNodeInParent(arrayList, rowIndex);

Params

  • arrayList {Array}: 数组
  • rowIndex {Number}: 当前行index

9.getLastChildNodeIndexByParentIndex:根据父节点的 rowIndex 获取 此父节点最后一个子孙节点的位置

import { getLastChildNodeIndexByParentIndex } from 'expanded-tree-tools';
const lastChildNodeIndex = getLastChildNodeIndexByParentIndex(arrayList, rowIndex);

Params

  • arrayList {Array}: 数组
  • rowIndex {Number}: 当前行index

About

Author

coyle

License

Released under the [MIT license].