Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 0 additions & 8 deletions docs/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -24,11 +24,3 @@ list.push("lorem");
- [Working with other Data objects](methods/with-other-objects.md)
- [Searching and Filtering](methods/searching-filtering.md)
- [Transforming Lists](methods/transforming-lists.md)

## Planned Features:

- Support for asynchronous callback functions
- New Methods:
- `findNode`
- `values` (similar to entries)
- constructor that takes any iterable (replaces `List.fromArray`)
28 changes: 14 additions & 14 deletions docs/methods/adding-removing.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ list.toString(); // "lorem,ipsum,dolor"
Removes the last element from the List and returns it. If the List is empty `undefined` is returned.

```js
const list = List.fromArray(["lorem", "ipsum"]);
const list = new List(["lorem", "ipsum"]);

list.pop(); // "ipsum"
list.pop(); // "lorem"
Expand All @@ -28,7 +28,7 @@ list.pop(); // undefined
Removes the first element from the List and returns it. If the List is empty `undefined` is returned.

```js
const list = List.fromArray(["lorem", "ipsum"]);
const list = new List(["lorem", "ipsum"]);

list.shift(); // "lorem"
list.shift(); // "ipsum"
Expand All @@ -46,16 +46,6 @@ list.unshift("ipsum").unshift("dolor");
list.toString(); // "dolor,ipsum,lorem"
```

## `getNode`

Gets `ListNode` at specific index. If the index is outside of the range of the List `undefined` is returned.

```js
const list = new List();
list.pop("lorem");
list.getNode(0); // ListNode { value: "lorem" }
```

## `get`

Gets value at specific index. If the index is outside of the range of the List `undefined` is returned.
Expand Down Expand Up @@ -85,7 +75,7 @@ Inserts value at index and returns `true`. If the index is outside of the range
If the index would correspond to the next new element this method acts as an alias to `push`.

```js
const list = List.fromArray(["lorem", "ipsum"]);
const list = new List(["lorem", "ipsum"]);
list.insert(1, "foo");
list.insert(4, "bar");
list.toString(); // "lorem,foo,ipsum,bar"
Expand All @@ -97,7 +87,17 @@ Removes one or more elements starting at a given index and returns `true`.
If the index is outside the range of the List or a amount smaller than one is given `false` is returned.

```js
const list = List.fromArray("foobazzbar".split(""));
const list = new List("foobazzbar".split(""));
list.remove(3, 4);
list.join(""); // "foobar"
```

## `insertMany`

Inserts all values from an Iterable into List at a given index. Further methods can be chained after this method.

```js
const list = new List([0, 1, 2]);
list.insertMany(1, [0.5, 0.75]);
list.join(", "); // "0, 0.5, 0.75, 1, 2"
```
2 changes: 1 addition & 1 deletion docs/methods/searching-filtering.md
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ list.some(v => v.endsWith("foo")); // false
Creates new list with only the values that the test callback returns `true` for.

```js
const list = List.fromArray([0, 1, 2, 3, 4, 5, 6, 7, 8, 9]);
const list = new List([0, 1, 2, 3, 4, 5, 6, 7, 8, 9]);
const filtered = list.filter(v => v % 2 == 0);
filtered.toString(); // "0,2,4,6,8"
```
Expand Down
4 changes: 2 additions & 2 deletions docs/methods/transforming-lists.md
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,7 @@ Creates a new List that contains a slice of value from the original List startin
Values are copied to the new List, meaning that modifying either List will not manipulate the other!

```js
const list = List.fromArray(["foo", "bar", "baz", "foobar", "lorem", "ipsum"]);
const list = new List(["foo", "bar", "baz", "foobar", "lorem", "ipsum"]);
list.slice(2, 5).toString(); // "baz,foobar,lorem"
list.slice(-3, 6).toString(); // "foobar,lorem,ipsum"
list.slice(1, -1).toString(); // "bar,baz,foobar,lorem"
Expand All @@ -115,7 +115,7 @@ Creates a new List with all values sorted by a comparison callback function. The
If no callback is passed values are sorted in ascending ASCII character order.

```js
const list = List.fromArray([0, 7, 11, 8, 9, 15, -3]);
const list = new List([0, 7, 11, 8, 9, 15, -3]);
const sorted = list.sort((a, b) => a - b);
sorted.toString(); // -3,0,7,8,9,11,15
```
Expand Down
36 changes: 0 additions & 36 deletions docs/methods/with-other-objects.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,29 +10,6 @@ list.push("ipsum").push("dolor").unshift("lorem");
const arr = list.toArray(); // ["lorem", "ipsum", "dolor"]
```

## `insertArray`

Inserts all values from an Array into List at a given index and returns `true`.
If the index is outside of the range of the List `false` is returned.

```js
const list = List.fromArray([0, 1, 2]);
list.insertArray(1, [0.5, 0.75]);
list.join(", "); // "0, 0.5, 0.75, 1, 2"
```

## `insertList`

Inserts all values from another List into List at a given index and returns `true`.
If the index is outside of the range of the List `false` is returned.

```js
const listA = List.fromArray([0, 1, 2]);
const listB = List.fromArray("foo".split(""));
listA.insertList(2, listB);
listA.toString(); // "0,1,f,o,o,2"
```

## `clone`

Creates a copy of the current List
Expand All @@ -53,16 +30,3 @@ const newList = list.concat(["baz", "foobar"]);
list.toString(); // "foo,bar"
newList.toString(); // "foo,bar,baz,foobar"
```

## `entries`

Creates iterable of index, value pairs for every entry in the List.

```js
const list = List.fromArray(["foo", "bar"]);
for (const [i, v] of list.entries()) {
console.log(`Index: ${i}, Value: ${v}`);
// Index: 0, Value: foo
// Index: 1, Value: bar
}
```
8 changes: 0 additions & 8 deletions docs/static-methods.md
Original file line number Diff line number Diff line change
@@ -1,13 +1,5 @@
# Static Methods

## `fromArray`

Creates a new List from any Array. This method has been deprecated in v1.2.0 and will be removed in a future version. Use the new constructor instead (see [Creating a List](./README.md#creating-a-list))!

```js
const list = List.fromArray([1, 2, 3]);
```

## `isList`

Checks if an object (or any other value) is a List
Expand Down
Loading
Loading