@ohos-ports/doublylinked 2.5.6-beta.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +21 -0
- package/README.md +549 -0
- package/lib/doubly-linked.d.ts +129 -0
- package/lib/doubly-linked.js +746 -0
- package/package.json +40 -0
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2017 Panates
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
package/README.md
ADDED
|
@@ -0,0 +1,549 @@
|
|
|
1
|
+
# doublylinked
|
|
2
|
+
|
|
3
|
+
[![NPM Version][npm-image]][npm-url]
|
|
4
|
+
[![NPM Downloads][downloads-image]][downloads-url]
|
|
5
|
+
[![Build Status][travis-image]][travis-url]
|
|
6
|
+
[![Test Coverage][coveralls-image]][coveralls-url]
|
|
7
|
+
[![Dependencies][dependencies-image]][dependencies-url]
|
|
8
|
+
[![DevDependencies][devdependencies-image]][devdependencies-url]
|
|
9
|
+
|
|
10
|
+
## About
|
|
11
|
+
|
|
12
|
+
Doubly linked list implementation for JavaScript with iterator and array-like interface
|
|
13
|
+
|
|
14
|
+
## Installation
|
|
15
|
+
|
|
16
|
+
`$ npm install doublylinked [--save]`
|
|
17
|
+
|
|
18
|
+
## Constructor
|
|
19
|
+
|
|
20
|
+
```js
|
|
21
|
+
const list = new DoublyLinked([element1[, ..[, elementN]]]);
|
|
22
|
+
```
|
|
23
|
+
|
|
24
|
+
##### Parameters
|
|
25
|
+
|
|
26
|
+
- *elementN :* The elements will list contains
|
|
27
|
+
|
|
28
|
+
|
|
29
|
+
## Methods
|
|
30
|
+
|
|
31
|
+
* [`DoublyLinked.prototype.concat()`](#doublylinkedprototypeconcat)
|
|
32
|
+
* [`DoublyLinked.prototype.entries()`](#doublylinkedprototypeentries)
|
|
33
|
+
* [`DoublyLinked.prototype.every()`](#doublylinkedprototypeevery)
|
|
34
|
+
* [`DoublyLinked.prototype.everyRight()`](#doublylinkedprototypeeveryright)
|
|
35
|
+
* [`DoublyLinked.prototype.filter()`](#doublylinkedprototypefilter)
|
|
36
|
+
* [`DoublyLinked.prototype.find()`](#doublylinkedprototypefind)
|
|
37
|
+
* [`DoublyLinked.prototype.forEach()`](#doublylinkedprototypeforeach)
|
|
38
|
+
* [`DoublyLinked.prototype.forEachRight()`](#doublylinkedprototypeforeachright)
|
|
39
|
+
* [`DoublyLinked.prototype.includes()`](#doublylinkedprototypeincludes)
|
|
40
|
+
* [`DoublyLinked.prototype.insert()`](#doublylinkedprototypeinsert)
|
|
41
|
+
* [`DoublyLinked.prototype.join()`](#doublylinkedprototypejoin)
|
|
42
|
+
* [`DoublyLinked.prototype.map()`](#doublylinkedprototypemap)
|
|
43
|
+
* [`DoublyLinked.prototype.next()`](#doublylinkedprototypenext)
|
|
44
|
+
* [`DoublyLinked.prototype.prev()`](#doublylinkedprototypeprev)
|
|
45
|
+
* [`DoublyLinked.prototype.pop()`](#doublylinkedprototypepop)
|
|
46
|
+
* [`DoublyLinked.prototype.push()`](#doublylinkedprototypepush)
|
|
47
|
+
* [`DoublyLinked.prototype.reduce()`](#doublylinkedprototypereduce)
|
|
48
|
+
* [`DoublyLinked.prototype.reduce()`](#doublylinkedprototypereduce)
|
|
49
|
+
* [`DoublyLinked.prototype.reduceRight()`](#doublylinkedprototypereduceright)
|
|
50
|
+
* [`DoublyLinked.prototype.remove()`](#doublylinkedprototyperemove)
|
|
51
|
+
* [`DoublyLinked.prototype.reset()`](#doublylinkedprototypereset)
|
|
52
|
+
* [`DoublyLinked.prototype.reverse()`](#doublylinkedprototypereverse)
|
|
53
|
+
* [`DoublyLinked.prototype.shift()`](#doublylinkedprototypeshift)
|
|
54
|
+
* [`DoublyLinked.prototype.some()`](#doublylinkedprototypesome)
|
|
55
|
+
* [`DoublyLinked.prototype.someRight()`](#doublylinkedprototypesomeright)
|
|
56
|
+
* [`DoublyLinked.prototype.toArray()`](#doublylinkedprototypetoarray)
|
|
57
|
+
* [`DoublyLinked.prototype.toString()`](#doublylinkedprototypetostring)
|
|
58
|
+
* [`DoublyLinked.prototype.unshift()`](#doublylinkedprototypeunshift)
|
|
59
|
+
* [`DoublyLinked.prototype[@@iterator]`](#doublylinkedprototypeiterator)
|
|
60
|
+
|
|
61
|
+
### DoublyLinked.prototype.concat()
|
|
62
|
+
|
|
63
|
+
Merges cursor list with and given lists/values into new list.
|
|
64
|
+
|
|
65
|
+
`list.concat(otherList1[, element1[, ...[otherList2]]])`
|
|
66
|
+
|
|
67
|
+
##### Parameters
|
|
68
|
+
|
|
69
|
+
- *valueN :* Lists and/or values to concatenate into a new list
|
|
70
|
+
|
|
71
|
+
- *Return value :* A new DoublyLinked instance
|
|
72
|
+
|
|
73
|
+
|
|
74
|
+
|
|
75
|
+
### DoublyLinked.prototype.entries()
|
|
76
|
+
|
|
77
|
+
Returns the iterator object contains entries
|
|
78
|
+
|
|
79
|
+
`list.entries()`
|
|
80
|
+
|
|
81
|
+
##### Parameters
|
|
82
|
+
|
|
83
|
+
- *Return value :* A new iterator object.
|
|
84
|
+
|
|
85
|
+
|
|
86
|
+
|
|
87
|
+
### DoublyLinked.prototype.every()
|
|
88
|
+
|
|
89
|
+
Tests whether all elements in the list pass the test implemented by the provided function (from left to right)
|
|
90
|
+
|
|
91
|
+
`list.every(callback[, thisArg])`
|
|
92
|
+
|
|
93
|
+
##### Parameters
|
|
94
|
+
|
|
95
|
+
- *callback :* Function to test for each element, taking three arguments:
|
|
96
|
+
|
|
97
|
+
- *currentValue :* The current element being processed in the list
|
|
98
|
+
|
|
99
|
+
- *index :* The index of the current element being processed in the list
|
|
100
|
+
|
|
101
|
+
- *list :* The list every was called upon
|
|
102
|
+
|
|
103
|
+
- *thisArg :* Value to use as this when executing callback
|
|
104
|
+
|
|
105
|
+
- *Return value :* true if the callback function returns a truthy value for every list element; otherwise, false
|
|
106
|
+
|
|
107
|
+
|
|
108
|
+
### DoublyLinked.prototype.everyRight()
|
|
109
|
+
|
|
110
|
+
Tests whether all elements in the list pass the test implemented by the provided function (from right to left)
|
|
111
|
+
|
|
112
|
+
`list.everyRight(callback[, thisArg])`
|
|
113
|
+
|
|
114
|
+
##### Parameters
|
|
115
|
+
|
|
116
|
+
- *callback :* Function to test for each element, taking three arguments:
|
|
117
|
+
|
|
118
|
+
- *currentValue :* The current element being processed in the list
|
|
119
|
+
|
|
120
|
+
- *index :* The index of the current element being processed in the list
|
|
121
|
+
|
|
122
|
+
- *list :* The list every was called upon
|
|
123
|
+
|
|
124
|
+
- *thisArg :* Value to use as this when executing callback
|
|
125
|
+
|
|
126
|
+
- *Return value :* true if the callback function returns a truthy value for every list element; otherwise, false
|
|
127
|
+
|
|
128
|
+
|
|
129
|
+
|
|
130
|
+
### DoublyLinked.prototype.filter()
|
|
131
|
+
|
|
132
|
+
Creates a new list with all elements that pass the test implemented by the provided function
|
|
133
|
+
|
|
134
|
+
`list.filter(callback[, thisArg])`
|
|
135
|
+
|
|
136
|
+
##### Parameters
|
|
137
|
+
|
|
138
|
+
- *callback :* Function to test for each element, taking three arguments:
|
|
139
|
+
|
|
140
|
+
- *element :* The current element being processed in the list
|
|
141
|
+
|
|
142
|
+
- *index :* The index of the current element being processed in the list
|
|
143
|
+
|
|
144
|
+
- *list :* The list every was called upon
|
|
145
|
+
|
|
146
|
+
- *thisArg :* Value to use as this when executing callback
|
|
147
|
+
|
|
148
|
+
- *Return value :* A new list with the elements that pass the test
|
|
149
|
+
|
|
150
|
+
|
|
151
|
+
|
|
152
|
+
### DoublyLinked.prototype.find()
|
|
153
|
+
|
|
154
|
+
Returns the value of the first element in the list that satisfies the provided testing function. Otherwise undefined is returned
|
|
155
|
+
|
|
156
|
+
`list.find(callback[, thisArg])`
|
|
157
|
+
|
|
158
|
+
##### Parameters
|
|
159
|
+
|
|
160
|
+
- *callback :* Function to test for each element, taking three arguments:
|
|
161
|
+
|
|
162
|
+
- *element :* The current element being processed in the list
|
|
163
|
+
|
|
164
|
+
- *index :* The index of the current element being processed in the list
|
|
165
|
+
|
|
166
|
+
- *list :* The list every was called upon
|
|
167
|
+
|
|
168
|
+
- *thisArg :* Value to use as this when executing callback
|
|
169
|
+
|
|
170
|
+
- *Return value :* A value in the list if an element passes the test; otherwise, undefined
|
|
171
|
+
|
|
172
|
+
|
|
173
|
+
|
|
174
|
+
### DoublyLinked.prototype.forEach()
|
|
175
|
+
|
|
176
|
+
Executes a provided function once for each list element (from left to right)
|
|
177
|
+
|
|
178
|
+
`list.forEach(callback[, thisArg])`
|
|
179
|
+
|
|
180
|
+
##### Parameters
|
|
181
|
+
|
|
182
|
+
- *callback :* Function to test for each element, taking three arguments:
|
|
183
|
+
|
|
184
|
+
- *element :* The current element being processed in the list
|
|
185
|
+
|
|
186
|
+
- *index :* The index of the current element being processed in the list
|
|
187
|
+
|
|
188
|
+
- *list :* The list every was called upon
|
|
189
|
+
|
|
190
|
+
- *thisArg :* Value to use as this when executing callback
|
|
191
|
+
|
|
192
|
+
- *Return value :* Value to use as this when executing callback
|
|
193
|
+
|
|
194
|
+
|
|
195
|
+
### DoublyLinked.prototype.forEachRight()
|
|
196
|
+
|
|
197
|
+
Executes a provided function once for each list element (from right to left)
|
|
198
|
+
|
|
199
|
+
`list.forEachRight(callback[, thisArg])`
|
|
200
|
+
|
|
201
|
+
##### Parameters
|
|
202
|
+
|
|
203
|
+
- *callback :* Function to test for each element, taking three arguments:
|
|
204
|
+
|
|
205
|
+
- *element :* The current element being processed in the list
|
|
206
|
+
|
|
207
|
+
- *index :* The index of the current element being processed in the list
|
|
208
|
+
|
|
209
|
+
- *list :* The list every was called upon
|
|
210
|
+
|
|
211
|
+
- *thisArg :* Value to use as this when executing callback
|
|
212
|
+
|
|
213
|
+
- *Return value :* Value to use as this when executing callback
|
|
214
|
+
|
|
215
|
+
|
|
216
|
+
### DoublyLinked.prototype.includes()
|
|
217
|
+
|
|
218
|
+
Determines whether an list includes a certain element, returning true or false as appropriate
|
|
219
|
+
|
|
220
|
+
`list.includes(searchElement[, fromIndex])`
|
|
221
|
+
|
|
222
|
+
##### Parameters
|
|
223
|
+
|
|
224
|
+
- *searchElement :* The element to search for
|
|
225
|
+
|
|
226
|
+
- *fromIndex :* The position in this list at which to begin searching for searchElement. A negative value searches from the index of list.length + fromIndex by asc. Defaults to 0.
|
|
227
|
+
|
|
228
|
+
- *Return value :* true if the searchElement found in the list; otherwise, false
|
|
229
|
+
|
|
230
|
+
|
|
231
|
+
|
|
232
|
+
### DoublyLinked.prototype.insert()
|
|
233
|
+
|
|
234
|
+
Adds one or more elements right after the cursor node of the list and returns the new length of the list
|
|
235
|
+
|
|
236
|
+
`list.insert(element1[, ...[, elementN]])`
|
|
237
|
+
|
|
238
|
+
##### Parameters
|
|
239
|
+
|
|
240
|
+
- *elementN :* The elements to add right after the cursor
|
|
241
|
+
|
|
242
|
+
- *Return value :* The new length of the list
|
|
243
|
+
|
|
244
|
+
|
|
245
|
+
### DoublyLinked.prototype.join()
|
|
246
|
+
|
|
247
|
+
Adds one or more elements right after the cursor node of the list and returns the new length of the list
|
|
248
|
+
|
|
249
|
+
`list.join([separator])`
|
|
250
|
+
|
|
251
|
+
##### Parameters
|
|
252
|
+
|
|
253
|
+
- *separator :* Specifies a string to separate each pair of adjacent elements of the list
|
|
254
|
+
|
|
255
|
+
- *Return value :* A string with all list elements joined. If length is 0, the empty string is returned
|
|
256
|
+
|
|
257
|
+
|
|
258
|
+
### DoublyLinked.prototype.map()
|
|
259
|
+
|
|
260
|
+
Creates a new list with the results of calling a provided function on every element in the calling list
|
|
261
|
+
|
|
262
|
+
`list.map(callback[, thisArg])`
|
|
263
|
+
|
|
264
|
+
##### Parameters
|
|
265
|
+
|
|
266
|
+
- *callback :* Function to test for each element, taking three arguments:
|
|
267
|
+
|
|
268
|
+
- *currentValue :* The current element being processed in the list
|
|
269
|
+
|
|
270
|
+
- *index :* The index of the current element being processed in the list
|
|
271
|
+
|
|
272
|
+
- *list :* The list every was called upon
|
|
273
|
+
|
|
274
|
+
- *thisArg :* Value to use as this when executing callback
|
|
275
|
+
|
|
276
|
+
- *Return value :* A new list with each element being the result of the callback function
|
|
277
|
+
|
|
278
|
+
|
|
279
|
+
|
|
280
|
+
### DoublyLinked.prototype.next()
|
|
281
|
+
|
|
282
|
+
Moves cursor to the next and returns its value
|
|
283
|
+
|
|
284
|
+
`list.next()`
|
|
285
|
+
|
|
286
|
+
##### Parameters
|
|
287
|
+
|
|
288
|
+
- *Return value :* Returns value of next node to the cursor. If cursor reaches to the end it returns undefined
|
|
289
|
+
|
|
290
|
+
|
|
291
|
+
|
|
292
|
+
### DoublyLinked.prototype.prev()
|
|
293
|
+
|
|
294
|
+
Moves cursor to the previous and returns its value
|
|
295
|
+
|
|
296
|
+
`list.prev()`
|
|
297
|
+
|
|
298
|
+
##### Parameters
|
|
299
|
+
|
|
300
|
+
- *Return value :* Returns value of previous node to the cursor. If cursor reaches to the head it returns undefined
|
|
301
|
+
|
|
302
|
+
|
|
303
|
+
|
|
304
|
+
### DoublyLinked.prototype.pop()
|
|
305
|
+
|
|
306
|
+
Removes the last element from the list and returns that element
|
|
307
|
+
|
|
308
|
+
`list.pop()`
|
|
309
|
+
|
|
310
|
+
##### Parameters
|
|
311
|
+
|
|
312
|
+
- *Return value :* The removed element from the list; undefined if the list is empty.
|
|
313
|
+
|
|
314
|
+
|
|
315
|
+
|
|
316
|
+
### DoublyLinked.prototype.push()
|
|
317
|
+
|
|
318
|
+
Adds one or more elements to the end of the list and returns the new length of the list
|
|
319
|
+
|
|
320
|
+
`list.push(element1[, ...[, elementN]])`
|
|
321
|
+
|
|
322
|
+
##### Parameters
|
|
323
|
+
|
|
324
|
+
- *elementN :* The elements to add to the end of the list
|
|
325
|
+
|
|
326
|
+
- *Return value :* The new length of the list
|
|
327
|
+
|
|
328
|
+
|
|
329
|
+
|
|
330
|
+
### DoublyLinked.prototype.reduce()
|
|
331
|
+
|
|
332
|
+
Applies a function against an accumulator and each element in the list (from left-to-right) to reduce it to a single value
|
|
333
|
+
|
|
334
|
+
`list.reduce(callback[, initialValue])`
|
|
335
|
+
|
|
336
|
+
##### Parameters
|
|
337
|
+
|
|
338
|
+
- *callback :* Function to test for each element, taking three arguments:
|
|
339
|
+
|
|
340
|
+
- *accumulator :* The accumulator accumulates the callback's return values; it is the accumulated value previously returned in the last invocation of the callback, or initialValue, if supplied.
|
|
341
|
+
|
|
342
|
+
- *currentValue :* The current element being processed in the list
|
|
343
|
+
|
|
344
|
+
- *currentIndex :* The index of the current element being processed in the list
|
|
345
|
+
|
|
346
|
+
- *list :* The list every was called upon
|
|
347
|
+
|
|
348
|
+
- *initialValue :* Value to use as the first argument to the first call of the callback
|
|
349
|
+
|
|
350
|
+
- *Return value :* The value that results from the reduction
|
|
351
|
+
|
|
352
|
+
|
|
353
|
+
### DoublyLinked.prototype.reduceRight()
|
|
354
|
+
|
|
355
|
+
Applies a function against an accumulator and each element in the list (from right-to-left) to reduce it to a single value
|
|
356
|
+
|
|
357
|
+
`list.reduceRight(callback[, initialValue])`
|
|
358
|
+
|
|
359
|
+
##### Parameters
|
|
360
|
+
|
|
361
|
+
- *callback :* Function to test for each element, taking three arguments:
|
|
362
|
+
|
|
363
|
+
- *accumulator :* The accumulator accumulates the callback's return values; it is the accumulated value previously returned in the last invocation of the callback, or initialValue, if supplied.
|
|
364
|
+
|
|
365
|
+
- *currentValue :* The current element being processed in the list
|
|
366
|
+
|
|
367
|
+
- *currentIndex :* The index of the current element being processed in the list
|
|
368
|
+
|
|
369
|
+
- *list :* The list every was called upon
|
|
370
|
+
|
|
371
|
+
- *initialValue :* Value to use as the first argument to the first call of the callback
|
|
372
|
+
|
|
373
|
+
- *Return value :* The value that results from the reduction
|
|
374
|
+
|
|
375
|
+
|
|
376
|
+
### DoublyLinked.prototype.reset()
|
|
377
|
+
|
|
378
|
+
Resets cursor to head
|
|
379
|
+
|
|
380
|
+
`list.reset()`
|
|
381
|
+
|
|
382
|
+
##### Parameters
|
|
383
|
+
|
|
384
|
+
- *Return value :* Returns the DoublyLinked instance which this method is called
|
|
385
|
+
|
|
386
|
+
|
|
387
|
+
|
|
388
|
+
### DoublyLinked.prototype.reverse()
|
|
389
|
+
|
|
390
|
+
Reverses a list in place. The first array element becomes the last, and the last list element becomes the first
|
|
391
|
+
|
|
392
|
+
`list.reverse()`
|
|
393
|
+
|
|
394
|
+
##### Parameters
|
|
395
|
+
|
|
396
|
+
- *Return value :* Returns the DoublyLinked instance which this method is called
|
|
397
|
+
|
|
398
|
+
|
|
399
|
+
### DoublyLinked.prototype.shift()
|
|
400
|
+
|
|
401
|
+
Removes the first element from the list and returns that element
|
|
402
|
+
|
|
403
|
+
`list.shift()`
|
|
404
|
+
|
|
405
|
+
##### Parameters
|
|
406
|
+
|
|
407
|
+
- *Return value :* The removed element from the list; undefined if the list is empty
|
|
408
|
+
|
|
409
|
+
|
|
410
|
+
|
|
411
|
+
### DoublyLinked.prototype.some()
|
|
412
|
+
|
|
413
|
+
Tests whether all elements in the list pass the test implemented by the provided function (from left to right)
|
|
414
|
+
|
|
415
|
+
`list.some(callback[, thisArg])`
|
|
416
|
+
|
|
417
|
+
##### Parameters
|
|
418
|
+
|
|
419
|
+
- *callback :* Function to test for each element, taking three arguments:
|
|
420
|
+
|
|
421
|
+
- *currentValue :* The current element being processed in the list
|
|
422
|
+
|
|
423
|
+
- *index :* The index of the current element being processed in the list
|
|
424
|
+
|
|
425
|
+
- *list :* The list every was called upon
|
|
426
|
+
|
|
427
|
+
- *thisArg :* Value to use as this when executing callback
|
|
428
|
+
|
|
429
|
+
- *Return value :* Value to use as this when executing callback
|
|
430
|
+
|
|
431
|
+
|
|
432
|
+
|
|
433
|
+
### DoublyLinked.prototype.someRight()
|
|
434
|
+
|
|
435
|
+
Tests whether all elements in the list pass the test implemented by the provided function (from right to left)
|
|
436
|
+
|
|
437
|
+
`list.someRight(callback[, thisArg])`
|
|
438
|
+
|
|
439
|
+
##### Parameters
|
|
440
|
+
|
|
441
|
+
- *callback :* Function to test for each element, taking three arguments:
|
|
442
|
+
|
|
443
|
+
- *currentValue :* The current element being processed in the list
|
|
444
|
+
|
|
445
|
+
- *index :* The index of the current element being processed in the list
|
|
446
|
+
|
|
447
|
+
- *list :* The list every was called upon
|
|
448
|
+
|
|
449
|
+
- *thisArg :* Value to use as this when executing callback
|
|
450
|
+
|
|
451
|
+
- *Return value :* Value to use as this when executing callback
|
|
452
|
+
|
|
453
|
+
|
|
454
|
+
### DoublyLinked.prototype.toArray()
|
|
455
|
+
|
|
456
|
+
Returns a new array containing elements of the list
|
|
457
|
+
|
|
458
|
+
`list.toArray()`
|
|
459
|
+
|
|
460
|
+
##### Parameters
|
|
461
|
+
|
|
462
|
+
- *Return value :* A new Array instance contains elements of the list
|
|
463
|
+
|
|
464
|
+
|
|
465
|
+
|
|
466
|
+
### DoublyLinked.prototype.toString()
|
|
467
|
+
|
|
468
|
+
Returns a string representing the specified list and its elements
|
|
469
|
+
|
|
470
|
+
`list.toString()`
|
|
471
|
+
|
|
472
|
+
##### Parameters
|
|
473
|
+
|
|
474
|
+
- *Return value :* Returns a string representing the specified list and its elements.
|
|
475
|
+
|
|
476
|
+
|
|
477
|
+
|
|
478
|
+
### DoublyLinked.prototype.unshift()
|
|
479
|
+
|
|
480
|
+
Adds one or more elements to the beginning of the list the new length of the list
|
|
481
|
+
|
|
482
|
+
`list.unshift(element1[, ...[, elementN]])`
|
|
483
|
+
|
|
484
|
+
##### Parameters
|
|
485
|
+
|
|
486
|
+
- *elementN :* The elements to add to the front of the list
|
|
487
|
+
|
|
488
|
+
- *Return value :* The new length of the list
|
|
489
|
+
|
|
490
|
+
|
|
491
|
+
### DoublyLinked.prototype\[@@iterator\]
|
|
492
|
+
|
|
493
|
+
Returns the iterator object contains entries
|
|
494
|
+
|
|
495
|
+
`const iterator = list[Symbol.iterator]()`
|
|
496
|
+
|
|
497
|
+
```js
|
|
498
|
+
for (const val in list) {
|
|
499
|
+
...
|
|
500
|
+
}
|
|
501
|
+
```
|
|
502
|
+
|
|
503
|
+
##### Parameters
|
|
504
|
+
|
|
505
|
+
- *Return value :* Returns the iterator object contains entries
|
|
506
|
+
|
|
507
|
+
|
|
508
|
+
|
|
509
|
+
## Properties
|
|
510
|
+
|
|
511
|
+
#### cursor
|
|
512
|
+
|
|
513
|
+
Returns current located node of the list
|
|
514
|
+
|
|
515
|
+
#### head
|
|
516
|
+
|
|
517
|
+
Returns first node of the list
|
|
518
|
+
|
|
519
|
+
#### length
|
|
520
|
+
|
|
521
|
+
Returns the element count of the list
|
|
522
|
+
|
|
523
|
+
#### head
|
|
524
|
+
|
|
525
|
+
Returns last node of the list
|
|
526
|
+
|
|
527
|
+
## Node Compatibility
|
|
528
|
+
|
|
529
|
+
- node `>= 6.0`;
|
|
530
|
+
|
|
531
|
+
### License
|
|
532
|
+
[MIT](LICENSE)
|
|
533
|
+
|
|
534
|
+
[npm-image]: https://img.shields.io/npm/v/doublylinked.svg
|
|
535
|
+
[npm-url]: https://npmjs.org/package/doublylinked
|
|
536
|
+
[travis-image]: https://img.shields.io/travis/panates/doublylinked/master.svg
|
|
537
|
+
[travis-url]: https://travis-ci.org/panates/doublylinked
|
|
538
|
+
[coveralls-image]: https://img.shields.io/coveralls/panates/doublylinked/master.svg
|
|
539
|
+
[coveralls-url]: https://coveralls.io/r/panates/doublylinked
|
|
540
|
+
[downloads-image]: https://img.shields.io/npm/dm/doublylinked.svg
|
|
541
|
+
[downloads-url]: https://npmjs.org/package/doublylinked
|
|
542
|
+
[gitter-image]: https://badges.gitter.im/panates/doublylinked.svg
|
|
543
|
+
[gitter-url]: https://gitter.im/panates/doublylinked?utm_source=badge&utm_medium=badge&utm_campaign=pr-badge&utm_content=badge
|
|
544
|
+
[dependencies-image]: https://david-dm.org/panates/doublylinked/status.svg
|
|
545
|
+
[dependencies-url]:https://david-dm.org/panates/doublylinked
|
|
546
|
+
[devdependencies-image]: https://david-dm.org/panates/doublylinked/dev-status.svg
|
|
547
|
+
[devdependencies-url]:https://david-dm.org/panates/doublylinked?type=dev
|
|
548
|
+
[quality-image]: http://npm.packagequality.com/shield/doublylinked.png
|
|
549
|
+
[quality-url]: http://packagequality.com/#?package=doublylinked
|
|
@@ -0,0 +1,129 @@
|
|
|
1
|
+
/// <reference lib="es2015.symbol" />
|
|
2
|
+
|
|
3
|
+
declare module 'doublylinked' {
|
|
4
|
+
type Maybe<T> = T | void;
|
|
5
|
+
|
|
6
|
+
export namespace DoublyLinked {
|
|
7
|
+
export interface Node<T> {
|
|
8
|
+
value: T;
|
|
9
|
+
readonly prev?: Node<T>;
|
|
10
|
+
readonly next?: Node<T>;
|
|
11
|
+
|
|
12
|
+
remove(): void;
|
|
13
|
+
}
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
export default class DoublyLinked<T = any> {
|
|
17
|
+
constructor(...element: T[]);
|
|
18
|
+
|
|
19
|
+
readonly cursor: DoublyLinked.Node<T>;
|
|
20
|
+
|
|
21
|
+
readonly head: DoublyLinked.Node<T>;
|
|
22
|
+
|
|
23
|
+
readonly length: number;
|
|
24
|
+
|
|
25
|
+
readonly tail: DoublyLinked.Node<T>;
|
|
26
|
+
|
|
27
|
+
concat(...element: T[]): DoublyLinked<T>;
|
|
28
|
+
|
|
29
|
+
entries(): IterableIterator<[number, T]>;
|
|
30
|
+
|
|
31
|
+
keys(): IterableIterator<number>;
|
|
32
|
+
|
|
33
|
+
values(): IterableIterator<T>;
|
|
34
|
+
|
|
35
|
+
every(
|
|
36
|
+
callback: (element: T, index?: number, thisArg?: any) => Maybe<boolean>,
|
|
37
|
+
thisArg?: any,
|
|
38
|
+
): boolean;
|
|
39
|
+
|
|
40
|
+
everyRight(
|
|
41
|
+
callback: (element: T, index?: number, thisArg?: any) => Maybe<boolean>,
|
|
42
|
+
thisArg?: any,
|
|
43
|
+
): boolean;
|
|
44
|
+
|
|
45
|
+
filter(
|
|
46
|
+
callback: (element: T, index?: number, thisArg?: any) => Maybe<boolean>,
|
|
47
|
+
thisArg?: any,
|
|
48
|
+
): DoublyLinked<T>;
|
|
49
|
+
|
|
50
|
+
find(
|
|
51
|
+
callback: (element: T, index?: number, thisArg?: any) => Maybe<boolean>,
|
|
52
|
+
thisArg?: any,
|
|
53
|
+
): T;
|
|
54
|
+
|
|
55
|
+
forEach(
|
|
56
|
+
callback: (element: T, index?: number, thisArg?: any) => void,
|
|
57
|
+
thisArg?: any,
|
|
58
|
+
): void;
|
|
59
|
+
|
|
60
|
+
forEachRight(
|
|
61
|
+
callback: (element: T, index?: number, thisArg?: any) => void,
|
|
62
|
+
thisArg?: any,
|
|
63
|
+
): void;
|
|
64
|
+
|
|
65
|
+
includes(element: T, fromIndex?: number): boolean;
|
|
66
|
+
|
|
67
|
+
insert(...element: T[]): number;
|
|
68
|
+
|
|
69
|
+
join(separator: string): string;
|
|
70
|
+
|
|
71
|
+
map(
|
|
72
|
+
callback: (element: T, index?: number, thisArg?: any) => void,
|
|
73
|
+
): DoublyLinked<T>;
|
|
74
|
+
|
|
75
|
+
next(): T;
|
|
76
|
+
|
|
77
|
+
pop(): T;
|
|
78
|
+
|
|
79
|
+
prev(): T;
|
|
80
|
+
|
|
81
|
+
push(...element: T[]): number;
|
|
82
|
+
|
|
83
|
+
reduce(
|
|
84
|
+
callback: (
|
|
85
|
+
accumulator: any,
|
|
86
|
+
element: T,
|
|
87
|
+
index?: number,
|
|
88
|
+
thisArg?: any,
|
|
89
|
+
) => any,
|
|
90
|
+
initialValue?: any,
|
|
91
|
+
): any;
|
|
92
|
+
|
|
93
|
+
reduceRight(
|
|
94
|
+
callback: (
|
|
95
|
+
accumulator: any,
|
|
96
|
+
element: T,
|
|
97
|
+
index?: number,
|
|
98
|
+
thisArg?: any,
|
|
99
|
+
) => any,
|
|
100
|
+
initialValue?: any,
|
|
101
|
+
): any;
|
|
102
|
+
|
|
103
|
+
remove(element: T, fromIndex?: number): any;
|
|
104
|
+
|
|
105
|
+
reset(): DoublyLinked<T>;
|
|
106
|
+
|
|
107
|
+
reverse(): DoublyLinked<T>;
|
|
108
|
+
|
|
109
|
+
shift(): T;
|
|
110
|
+
|
|
111
|
+
slice(start?: number, end?: number): T[];
|
|
112
|
+
|
|
113
|
+
some(
|
|
114
|
+
callback: (element: T, index?: number, thisArg?: any) => boolean,
|
|
115
|
+
thisArg?: any,
|
|
116
|
+
): boolean;
|
|
117
|
+
|
|
118
|
+
someRight(
|
|
119
|
+
callback: (element: T, index?: number, thisArg?: any) => boolean,
|
|
120
|
+
thisArg?: any,
|
|
121
|
+
): boolean;
|
|
122
|
+
|
|
123
|
+
toArray(): T[];
|
|
124
|
+
|
|
125
|
+
toString(): string;
|
|
126
|
+
|
|
127
|
+
unshift(...element: T[]): number;
|
|
128
|
+
}
|
|
129
|
+
}
|