ArrayList
ArrayList inherits from JavaScript Array, without overwriting or populate this class.
Install:
# npm install arraylist
API:
-
get(index)
Returns an element by position:
var list = ;list;list; // 1list; // 2list == list0; // true
-
set(index, value)
Set an element by position
var list = ;list;list;list; // hellolist; // world
-
contains(element)
Check if an element is in the list
var list = ;list;list); // truelist); // truelist); // truelist); // false
-
add(elements)
Add elements to the list
var list = ;list;list;list;listlength; // 5
-
isEmpty()
Check if the list contains no elements
var list = ;list; // truelist;list; // false
-
equals(list)
Check if two lists are equals
var list = ;var list2 = ;list;list; // falselist2;list; // true
-
clone()
Creates a copy of the list
var list = ;list;var list2 = list;list; // true
-
remove(index)
Removes an element by position
var list = ;list;list;list; // [2, 3]
-
removeElement(element)
Removes a specified element
var list = ;list;list;list; // [1, 3]
-
removeAll(list)
Remove all the elements in another collection
var list = ;var list2 = ;list;list2;list;list; // [2, 4]
-
replaceAll(list)
Replace all the elements of the list
var list = ;var list2 = ;list;list2;list;list; // [1, 3, 5]
-
clear()
Remove all the elements in the list
var list = ;list;listclear;list; // true
-
toArray()
Return a new array with all the elements in the same order
var list = ;list;list; // [1, 2, 3]
-
first([n])
Returns the first element of the list. [see]
var list = ;list;list; // 1list; // [1, 2]
-
initial([n])
Returns everything but the last entry of the list. [see]
var list = ;list;list; // [1, 2, 3, 4]
-
last([n])
Returns the last element of the list. [see]
var list = ;list;list; // 3
-
rest(index)
Returns the rest of the elements in the list. [see]
var list = ;list;list; // [1, 2, 3, 4]
-
compact()
Returns a new list with the false values removed. [see]
var list = ;list;listcompact; // [1, 5]
-
flatten()
Returns a new list flattened. [see]
var list = ;list;list; // [1, 2, 3]
-
*without(values)
Returns a new list without the specified values. [see]
var list = ;list;list; // [2, 4]
-
partition(predicate)
Split the list into two lists. [see]
var list = ;list;list; // [[1, 3], [2, 4]]
-
*union(lists)
Returns the list joined with the arrays specified, the join is unique. [see]
var list = ;var list2 = ;list;list2;list; // [1, 2, 3, 4, 5]
-
*intersection(lists)
Returns the list intercepted with the arrays specified, the intersection is unique. [see]
var list = ;var list2 = ;list;list2;list; // [1, 2]
-
*difference(lists)
Returns the list minus the lists specified, the difference is unique. [see]
var list = ;var list2 = ;list;list2;list; // [2, 4]
-
unique()
Returns a list with the duplicated values removed. [see]
var list = ;list;list; // [1, 2, 3, 4]
-
uniq()
Alias for unique.
-
*zip(lists)
Merges together the values of each of the lists with the values at the corresponding position. [see]
-
object([values])
Converts lists into objects. [see]
-
sortedIndex(value, [iterator], [context])
Returns the index at which the value should be inserted into the list. [see]
var list = ;list;list; // 2
-
each()
Alias for forEach.
-
map(iterator, [context])
Returns a new list with each value mapped through a transformation. [see]
var list = ;list;list; // [2, 4, 6]
-
reduce(iterator, memo, [context])
[see]
-
reduceRight(iterator, memo, [context])
[see]
-
find(predicate, [context])
Returns a new list with the occurrences that passes the test. [see]
var list = ;list;list; // [2, 4, 6]
-
findOne(predicate, [context])
Returns the first occurrence that passes the test. [see]
var list = ;list;list; // 2
-
where(properties)
[see]
-
findWhere(properties)
[see]
-
reject(predicate, [context])
Returns the values in list without the elements that the truth test passes. [see]
-
every([predicate], [context])
Returns true if all of the values in the list pass the predicate truth test. [see]
var list = ;list;list; // true
-
some([predicate], [context])
Returns true if any of the values in the list pass the predicate truth test. [see]
var list = ;list;list; // true
-
*invoke(methodName, arguments)
Calls the method on each value in the list. [see]
var list = ;list;
var list = ;list;list; // 5
-
min([iterator], [context])
Returns the minimum value in list. [see]
var list = ;list;list; // 1
-
sortBy(iterator, [context])
Returns a new list with the values sorted. [see]
-
groupBy(iterator, [context])
[see]
-
indexBy(iterator, [context])
[see]
-
countBy(iterator, [context])
[see]
-
shuffle()
Returns a shuffled copy of the list, using a version of the Fisher-Yates shuffle. [see]
var list = ;list;list; // [3, 1, 5, 4, 2]
-
sample([n])
Returns a random sample from the list. [see]
var list = ;list;list; // 4
-
size()
Returns the length of the list.
var list = ;list;listsize; // 5
인덱스 한번에 찾기
var index =어레이리스트.indexOf(값);
'node.js & js' 카테고리의 다른 글
node js에서 fcm 푸시 메세지 보내기 (0) | 2018.06.15 |
---|---|
node.js js 에서 hash map 사용 (2) | 2018.06.14 |
노드 js에서 배열 사용 하기 (0) | 2018.06.10 |
안드로이 <--> 서버로 메세지 주고받기 (0) | 2018.06.08 |
안드로이드와 node.js 소켓 연결 (0) | 2018.06.08 |