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 🙏

© 2025 – Pkg Stats / Ryan Hefner

arraylists

v2.1.1

Published

强大的ArrayList集合工具类

Readme

ArrayList API:

下载 npm install arraylists

引用包

	let ArrayList = require("arraylists");

创建一个ArrayList对象

	let list = new ArrayList();
	// 允许在创建对象时传入数组进构造函数,此操作会将数组中的所有元素直接在ArrayList对象初始化时添加进集合
	let list = new ArrayList([1,2,3]); // 栗子

设置泛型,可设置类型为string,number,boolean和function数据类型。设置泛型后如添加非泛型定义的类型进集合则抛出异常.如不设置泛型,则集合中元素可添加任意类型.

	list.setType(type);
	// 举个栗子
	// 设置集合中元素只允许添加数字
	list.setType("number");
	// 设置集合中元素只允许添加字符串
	list.setType("string");
	// 设置集合中元素只允许添加布尔值
	list.setType("boolean");
	// 设置集合中元素只允许添加函数类型
	list.setType("function");
	...

添加一个元素

	list.add(item);

添加多个元素

	list.add(item1,item2,item3...);

添加一个数组进集合

	list.addAll(array);

删除指定元素

	list.remove(item);

删除多个元素

	list.removeAll(item1,item2,item3...);

清空集合元素

	list.clear();

深克隆一个集合

	let list2 = list.clone();

检查集合中是否包含指定元素

	let bool = list.contains(item);

获取指定位置上的元素

	let temp = list.get(index);

返回此列表中首次出现的指定元素的索引,或如果此列表不包含元素,则返回 -1

	let index = list.indexOf(item);

判断集合是否为空

	let bool = list.isEmpty();

用指定的元素替代此列表中指定位置上的元素

	list.set(index,item);

遍历集合

	list.forEach(e => {
		console.log(e);
	});

获取元素中第一个元素

	list.first();

获取元素中最后一个元素

	list.last();

返回元素个数

	list.size();

去除重复元素

	list.unique();

将集合转换为数组,返回一个数组,但不改变原集合

	list.toArray();

判断两个集合中元素否相等

	list.equals(list2);

返回在此 ArrayList 的元素上进行迭代的迭代器。

	list.iterator();

点此查看iterator迭代器使用文档

https://www.npmjs.com/package/listiterator

关于作者: email:[email protected]

更新日志:

V2.0.9更新:

新增equals比较函数

新增unique函数去除集合中重复元素

新增toArray函数将集合转换为数组

新增addAll函数可直接添加一个数组进集合

V2.1.0更新:

新增泛型定义