@stdlib/dstructs-doubly-linked-list 0.1.0

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/README.md ADDED
@@ -0,0 +1,628 @@
1
+ <!--
2
+
3
+ @license Apache-2.0
4
+
5
+ Copyright (c) 2018 The Stdlib Authors.
6
+
7
+ Licensed under the Apache License, Version 2.0 (the "License");
8
+ you may not use this file except in compliance with the License.
9
+ You may obtain a copy of the License at
10
+
11
+ http://www.apache.org/licenses/LICENSE-2.0
12
+
13
+ Unless required by applicable law or agreed to in writing, software
14
+ distributed under the License is distributed on an "AS IS" BASIS,
15
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16
+ See the License for the specific language governing permissions and
17
+ limitations under the License.
18
+
19
+ -->
20
+
21
+
22
+ <details>
23
+ <summary>
24
+ About stdlib...
25
+ </summary>
26
+ <p>We believe in a future in which the web is a preferred environment for numerical computation. To help realize this future, we've built stdlib. stdlib is a standard library, with an emphasis on numerical and scientific computation, written in JavaScript (and C) for execution in browsers and in Node.js.</p>
27
+ <p>The library is fully decomposable, being architected in such a way that you can swap out and mix and match APIs and functionality to cater to your exact preferences and use cases.</p>
28
+ <p>When you use stdlib, you can be absolutely certain that you are using the most thorough, rigorous, well-written, studied, documented, tested, measured, and high-quality code out there.</p>
29
+ <p>To join us in bringing numerical computing to the web, get started by checking us out on <a href="https://github.com/stdlib-js/stdlib">GitHub</a>, and please consider <a href="https://opencollective.com/stdlib">financially supporting stdlib</a>. We greatly appreciate your continued support!</p>
30
+ </details>
31
+
32
+ # Doubly Linked List
33
+
34
+ [![NPM version][npm-image]][npm-url] [![Build Status][test-image]][test-url] [![Coverage Status][coverage-image]][coverage-url] <!-- [![dependencies][dependencies-image]][dependencies-url] -->
35
+
36
+ > Doubly linked list constructor.
37
+
38
+ <!-- Section to include introductory text. Make sure to keep an empty line after the intro `section` element and another before the `/section` close. -->
39
+
40
+ <section class="intro">
41
+
42
+ </section>
43
+
44
+ <!-- /.intro -->
45
+
46
+ <!-- Package usage documentation. -->
47
+
48
+ <section class="installation">
49
+
50
+ ## Installation
51
+
52
+ ```bash
53
+ npm install @stdlib/dstructs-doubly-linked-list
54
+ ```
55
+
56
+ </section>
57
+
58
+ <section class="usage">
59
+
60
+ ## Usage
61
+
62
+ ```javascript
63
+ var doublyLinkedList = require( '@stdlib/dstructs-doubly-linked-list' );
64
+ ```
65
+
66
+ #### doublyLinkedList()
67
+
68
+ Returns a new doubly linked list instance.
69
+
70
+ ```javascript
71
+ var list = doublyLinkedList();
72
+ // returns <DoublyLinkedList>
73
+ ```
74
+
75
+ ##### list.clear()
76
+
77
+ Clears a list.
78
+
79
+ ```javascript
80
+ var list = doublyLinkedList();
81
+ // returns <DoublyLinkedList>
82
+
83
+ // Add values to the list:
84
+ list.push( 'foo' ).push( 'bar' );
85
+
86
+ // Peek at the first value:
87
+ var v = list.first().value;
88
+ // returns 'foo'
89
+
90
+ // Examine the list length:
91
+ var len = list.length;
92
+ // returns 2
93
+
94
+ // Clear all list items:
95
+ list.clear();
96
+
97
+ // Peek at the first value:
98
+ v = list.first();
99
+ // returns undefined
100
+
101
+ // Examine the list length:
102
+ len = list.length;
103
+ // returns 0
104
+ ```
105
+
106
+ ##### list.first()
107
+
108
+ Returns the first `node`. If the list is currently empty, the returned value is `undefined`.
109
+
110
+ ```javascript
111
+ var list = doublyLinkedList();
112
+ // returns <DoublyLinkedList>
113
+
114
+ // Add values to the list:
115
+ list.push( 'foo' ).push( 'bar' );
116
+
117
+ // Peek at the first value:
118
+ var v = list.first().value;
119
+ // returns 'foo'
120
+ ```
121
+
122
+ ##### list.insert( node, value\[, location] )
123
+
124
+ Inserts a `value` into the list either before or after a provided list `node`.
125
+
126
+ ```javascript
127
+ var list = doublyLinkedList();
128
+ // returns <DoublyLinkedList>
129
+
130
+ // Add values to the list:
131
+ list.push( 'foo' ).push( 'bar' ).push( 'beep' );
132
+
133
+ // Determine the list length:
134
+ var len = list.length;
135
+ // returns 3
136
+
137
+ // Get the second node:
138
+ var node = list.first().next;
139
+
140
+ // Insert a value after the second node:
141
+ list.insert( node, 'boop' );
142
+
143
+ // Determine the list length:
144
+ len = list.length;
145
+ // returns 4
146
+
147
+ // Return a list of values:
148
+ var values = list.toArray();
149
+ // returns [ 'foo', 'bar', 'boop', 'beep' ]
150
+ ```
151
+
152
+ The method supports the following insertion locations:
153
+
154
+ - `'before'`: insert a `value` into the list **before** a provided list `node`.
155
+ - `'after'`: insert a `value` into the list **after** a provided list `node`.
156
+
157
+ By default, the method inserts a `value` into the list **after** a provided list `node`. To insert a value **before** a provided list `node`, invoke the method with the `location` argument equal to `'before'`.
158
+
159
+ ```javascript
160
+ var list = doublyLinkedList();
161
+ // returns <DoublyLinkedList>
162
+
163
+ // Add values to the list:
164
+ list.push( 'foo' ).push( 'bar' ).push( 'beep' );
165
+
166
+ // Determine the list length:
167
+ var len = list.length;
168
+ // returns 3
169
+
170
+ // Get the second node:
171
+ var node = list.first().next;
172
+
173
+ // Insert a value before the second node:
174
+ list.insert( node, 'boop', 'before' );
175
+
176
+ // Determine the list length:
177
+ len = list.length;
178
+ // returns 4
179
+
180
+ // Return a list of values:
181
+ var values = list.toArray();
182
+ // returns [ 'foo', 'boop', 'bar', 'beep' ]
183
+ ```
184
+
185
+ ##### list.iterator( \[direction] )
186
+
187
+ Returns an iterator for iterating over a list. If an environment supports `Symbol.iterator`, the returned iterator is iterable.
188
+
189
+ ```javascript
190
+ var list = doublyLinkedList();
191
+
192
+ // Add values to the list:
193
+ list.push( 'foo' ).push( 'bar' );
194
+
195
+ // Create an iterator:
196
+ var it = list.iterator();
197
+
198
+ // Iterate over the list...
199
+ var v = it.next().value;
200
+ // returns 'foo'
201
+
202
+ v = it.next().value;
203
+ // returns 'bar'
204
+
205
+ var bool = it.next().done;
206
+ // returns true
207
+ ```
208
+
209
+ The method supports the following iteration directions:
210
+
211
+ - `'forward'`: iterate over a list from the first value until the last value.
212
+ - `'reverse'`: iterate over a list from the last value until the first value.
213
+
214
+ By default, the method returns an iterator which iterates over a list from the first value until the last value. To return an iterator which iterates in reverse order, invoke the method with the `direction` argument equal to `'reverse'`.
215
+
216
+ ```javascript
217
+ var list = doublyLinkedList();
218
+
219
+ // Add values to the list:
220
+ list.push( 'foo' ).push( 'bar' );
221
+
222
+ // Create an iterator:
223
+ var it = list.iterator( 'reverse' );
224
+
225
+ // Iterate over the list...
226
+ var v = it.next().value;
227
+ // returns 'bar'
228
+
229
+ v = it.next().value;
230
+ // returns 'foo'
231
+
232
+ var bool = it.next().done;
233
+ // returns true
234
+ ```
235
+
236
+ **Note**: in order to prevent confusion arising from list mutation during iteration, a returned iterator **always** iterates over a list "snapshot", which is defined as the list of list elements at the time of `list.iterator()` invocation.
237
+
238
+ ##### list.last()
239
+
240
+ Returns the last `node`. If the list is currently empty, the returned value is `undefined`.
241
+
242
+ ```javascript
243
+ var list = doublyLinkedList();
244
+ // returns <DoublyLinkedList>
245
+
246
+ // Add values to the list:
247
+ list.push( 'foo' ).push( 'bar' );
248
+
249
+ // Peek at the last value:
250
+ var v = list.last().value;
251
+ // returns 'bar'
252
+ ```
253
+
254
+ ##### list.length
255
+
256
+ List length.
257
+
258
+ ```javascript
259
+ var list = doublyLinkedList();
260
+
261
+ // Examine the initial list length:
262
+ var len = list.length;
263
+ // returns 0
264
+
265
+ // Add values to the list:
266
+ list.push( 'foo' ).push( 'bar' );
267
+
268
+ // Retrieve the current list length:
269
+ len = list.length;
270
+ // returns 2
271
+ ```
272
+
273
+ ##### list.pop()
274
+
275
+ Removes a value from the end of the list. If the list is currently empty, the returned value is `undefined`.
276
+
277
+ ```javascript
278
+ var list = doublyLinkedList();
279
+
280
+ // Add values to the list:
281
+ list.push( 'foo' ).push( 'bar' );
282
+
283
+ // Remove the last value:
284
+ var v = list.pop();
285
+ // returns 'bar'
286
+
287
+ // Add a new value to the list:
288
+ list.push( 'beep' );
289
+
290
+ // Remove the last value:
291
+ v = list.pop();
292
+ // returns 'beep'
293
+ ```
294
+
295
+ ##### list.push( value )
296
+
297
+ Adds a value to the end of the list.
298
+
299
+ ```javascript
300
+ var list = doublyLinkedList();
301
+
302
+ // Add values to the list:
303
+ list.push( 'foo' ).push( 'bar' );
304
+
305
+ // Remove the last value:
306
+ var v = list.pop();
307
+ // returns 'bar'
308
+
309
+ // Add a new value to the list:
310
+ list.push( 'beep' );
311
+
312
+ // Remove the last value:
313
+ v = list.pop();
314
+ // returns 'beep'
315
+ ```
316
+
317
+ ##### list.remove( node )
318
+
319
+ Removes a `node` from the list.
320
+
321
+ ```javascript
322
+ var list = doublyLinkedList();
323
+
324
+ // Add values to the list:
325
+ list.push( 'foo' ).push( 'bar' ).push( 'beep' );
326
+
327
+ // Determine the list length:
328
+ var len = list.length;
329
+ // returns 3
330
+
331
+ // Get the second node:
332
+ var node = list.first().next;
333
+
334
+ // Remove the second node:
335
+ var v = list.remove( node );
336
+ // returns 'bar'
337
+
338
+ // Determine the list length:
339
+ len = list.length;
340
+ // returns 2
341
+ ```
342
+
343
+ ##### list.shift()
344
+
345
+ Removes a value from the beginning of the list. If the list is currently empty, the returned value is `undefined`.
346
+
347
+ ```javascript
348
+ var list = doublyLinkedList();
349
+
350
+ // Add values to the list:
351
+ list.push( 'foo' ).push( 'bar' );
352
+
353
+ // Remove the first value:
354
+ var v = list.shift();
355
+ // returns 'foo'
356
+
357
+ // Add a new value to the list:
358
+ list.push( 'beep' );
359
+
360
+ // Remove the first value:
361
+ v = list.shift();
362
+ // returns 'bar'
363
+ ```
364
+
365
+ ##### list.toArray()
366
+
367
+ Returns an array of list values.
368
+
369
+ ```javascript
370
+ var list = doublyLinkedList();
371
+
372
+ // Add values to the list:
373
+ list.push( 'foo' ).push( 'bar' );
374
+
375
+ // Get an array of list values:
376
+ var vals = list.toArray();
377
+ // returns [ 'foo', 'bar' ]
378
+ ```
379
+
380
+ ##### list.toJSON()
381
+
382
+ Serializes a list as JSON.
383
+
384
+ ```javascript
385
+ var list = doublyLinkedList();
386
+
387
+ // Add values to the list:
388
+ list.push( 'foo' ).push( 'bar' );
389
+
390
+ // Serialize to JSON:
391
+ var o = list.toJSON();
392
+ // returns { 'type': 'doubly-linked-list', 'data': [ 'foo', 'bar' ] }
393
+ ```
394
+
395
+ **Note**: `JSON.stringify()` implicitly calls this method when stringifying a list instance.
396
+
397
+ ##### list.unshift( value )
398
+
399
+ Adds a value to the beginning of the list.
400
+
401
+ ```javascript
402
+ var list = doublyLinkedList();
403
+
404
+ // Add values to the list:
405
+ list.unshift( 'foo' ).unshift( 'bar' );
406
+
407
+ // Remove the last value:
408
+ var v = list.pop();
409
+ // returns 'foo'
410
+
411
+ // Add a new value to the list:
412
+ list.unshift( 'beep' );
413
+
414
+ // Remove the last value:
415
+ v = list.pop();
416
+ // returns 'bar'
417
+ ```
418
+
419
+ </section>
420
+
421
+ <!-- /.usage -->
422
+
423
+ <!-- Package usage notes. Make sure to keep an empty line after the `section` element and another before the `/section` close. -->
424
+
425
+ <section class="notes">
426
+
427
+ ## Notes
428
+
429
+ - To manually traverse a list, use list node `next` and `prev` properties.
430
+
431
+ ```javascript
432
+ var list = doublyLinkedList();
433
+
434
+ // Add values to the list:
435
+ list.push( 'foo' ).push( 'bar' ).push( 'beep' ).push( 'boop' );
436
+
437
+ // Get the first list node:
438
+ var n = list.first();
439
+
440
+ // Walk the list forward...
441
+ while ( n ) {
442
+ console.log( n.value );
443
+ n = n.next;
444
+ }
445
+
446
+ // Get the last list node:
447
+ n = list.last();
448
+
449
+ // Walk the list backward...
450
+ while ( n ) {
451
+ console.log( n.value );
452
+ n = n.prev;
453
+ }
454
+ ```
455
+
456
+ </section>
457
+
458
+ <!-- /.notes -->
459
+
460
+ <!-- Package usage examples. -->
461
+
462
+ <section class="examples">
463
+
464
+ ## Examples
465
+
466
+ <!-- eslint no-undef: "error" -->
467
+
468
+ ```javascript
469
+ var doublyLinkedList = require( '@stdlib/dstructs-doubly-linked-list' );
470
+
471
+ var list;
472
+ var iter;
473
+ var len;
474
+ var v;
475
+ var i;
476
+
477
+ // Create a new doubly linked list:
478
+ list = doublyLinkedList();
479
+
480
+ // Add some values to the list:
481
+ list.push( 'foo' );
482
+ list.push( 'bar' );
483
+ list.push( 'beep' );
484
+ list.push( 'boop' );
485
+
486
+ // Peek at the first and last list values:
487
+ v = list.first().value;
488
+ // returns 'foo'
489
+
490
+ v = list.last().value;
491
+ // returns 'boop'
492
+
493
+ // Inspect the list length:
494
+ len = list.length;
495
+ // returns 4
496
+
497
+ // Remove the last list value:
498
+ v = list.pop();
499
+ // returns 'boop'
500
+
501
+ // Inspect the list length:
502
+ len = list.length;
503
+ // returns 3
504
+
505
+ // Iterate over the list:
506
+ iter = list.iterator();
507
+ for ( i = 0; i < len; i++ ) {
508
+ console.log( 'List value #%d: %s', i+1, iter.next().value );
509
+ }
510
+
511
+ // Clear the list:
512
+ list.clear();
513
+
514
+ // Inspect the list length:
515
+ len = list.length;
516
+ // returns 0
517
+ ```
518
+
519
+ </section>
520
+
521
+ <!-- /.examples -->
522
+
523
+ <!-- Section to include cited references. If references are included, add a horizontal rule *before* the section. Make sure to keep an empty line after the `section` element and another before the `/section` close. -->
524
+
525
+ <section class="references">
526
+
527
+ </section>
528
+
529
+ <!-- /.references -->
530
+
531
+ <!-- Section for related `stdlib` packages. Do not manually edit this section, as it is automatically populated. -->
532
+
533
+ <section class="related">
534
+
535
+ * * *
536
+
537
+ ## See Also
538
+
539
+ - <span class="package-name">[`@stdlib/dstructs-linked-list`][@stdlib/dstructs/linked-list]</span><span class="delimiter">: </span><span class="description">linked list.</span>
540
+ - <span class="package-name">[`@stdlib/dstructs-stack`][@stdlib/dstructs/stack]</span><span class="delimiter">: </span><span class="description">stack.</span>
541
+
542
+ </section>
543
+
544
+ <!-- /.related -->
545
+
546
+ <!-- Section for all links. Make sure to keep an empty line after the `section` element and another before the `/section` close. -->
547
+
548
+
549
+ <section class="main-repo" >
550
+
551
+ * * *
552
+
553
+ ## Notice
554
+
555
+ This package is part of [stdlib][stdlib], a standard library for JavaScript and Node.js, with an emphasis on numerical and scientific computing. The library provides a collection of robust, high performance libraries for mathematics, statistics, streams, utilities, and more.
556
+
557
+ For more information on the project, filing bug reports and feature requests, and guidance on how to develop [stdlib][stdlib], see the main project [repository][stdlib].
558
+
559
+ #### Community
560
+
561
+ [![Chat][chat-image]][chat-url]
562
+
563
+ ---
564
+
565
+ ## License
566
+
567
+ See [LICENSE][stdlib-license].
568
+
569
+
570
+ ## Copyright
571
+
572
+ Copyright &copy; 2016-2026. The Stdlib [Authors][stdlib-authors].
573
+
574
+ </section>
575
+
576
+ <!-- /.stdlib -->
577
+
578
+ <!-- Section for all links. Make sure to keep an empty line after the `section` element and another before the `/section` close. -->
579
+
580
+ <section class="links">
581
+
582
+ [npm-image]: http://img.shields.io/npm/v/@stdlib/dstructs-doubly-linked-list.svg
583
+ [npm-url]: https://npmjs.org/package/@stdlib/dstructs-doubly-linked-list
584
+
585
+ [test-image]: https://github.com/stdlib-js/dstructs-doubly-linked-list/actions/workflows/test.yml/badge.svg?branch=v0.1.0
586
+ [test-url]: https://github.com/stdlib-js/dstructs-doubly-linked-list/actions/workflows/test.yml?query=branch:v0.1.0
587
+
588
+ [coverage-image]: https://img.shields.io/codecov/c/github/stdlib-js/dstructs-doubly-linked-list/main.svg
589
+ [coverage-url]: https://codecov.io/github/stdlib-js/dstructs-doubly-linked-list?branch=main
590
+
591
+ <!--
592
+
593
+ [dependencies-image]: https://img.shields.io/david/stdlib-js/dstructs-doubly-linked-list.svg
594
+ [dependencies-url]: https://david-dm.org/stdlib-js/dstructs-doubly-linked-list/main
595
+
596
+ -->
597
+
598
+ [chat-image]: https://img.shields.io/badge/zulip-join_chat-brightgreen.svg
599
+ [chat-url]: https://stdlib.zulipchat.com
600
+
601
+ [stdlib]: https://github.com/stdlib-js/stdlib
602
+
603
+ [stdlib-authors]: https://github.com/stdlib-js/stdlib/graphs/contributors
604
+
605
+ [umd]: https://github.com/umdjs/umd
606
+ [es-module]: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Guide/Modules
607
+
608
+ [deno-url]: https://github.com/stdlib-js/dstructs-doubly-linked-list/tree/deno
609
+ [deno-readme]: https://github.com/stdlib-js/dstructs-doubly-linked-list/blob/deno/README.md
610
+ [umd-url]: https://github.com/stdlib-js/dstructs-doubly-linked-list/tree/umd
611
+ [umd-readme]: https://github.com/stdlib-js/dstructs-doubly-linked-list/blob/umd/README.md
612
+ [esm-url]: https://github.com/stdlib-js/dstructs-doubly-linked-list/tree/esm
613
+ [esm-readme]: https://github.com/stdlib-js/dstructs-doubly-linked-list/blob/esm/README.md
614
+ [branches-url]: https://github.com/stdlib-js/dstructs-doubly-linked-list/blob/main/branches.md
615
+
616
+ [stdlib-license]: https://raw.githubusercontent.com/stdlib-js/dstructs-doubly-linked-list/main/LICENSE
617
+
618
+ <!-- <related-links> -->
619
+
620
+ [@stdlib/dstructs/linked-list]: https://www.npmjs.com/package/@stdlib/dstructs-linked-list
621
+
622
+ [@stdlib/dstructs/stack]: https://www.npmjs.com/package/@stdlib/dstructs-stack
623
+
624
+ <!-- </related-links> -->
625
+
626
+ </section>
627
+
628
+ <!-- /.links -->
package/SECURITY.md ADDED
@@ -0,0 +1,5 @@
1
+ # Security
2
+
3
+ > Policy for reporting security vulnerabilities.
4
+
5
+ See the security policy [in the main project repository](https://github.com/stdlib-js/stdlib/security).
@@ -0,0 +1,3 @@
1
+ /// <reference path="../docs/types/index.d.ts" />
2
+ import DoublyLinkedList from '../docs/types/index';
3
+ export = DoublyLinkedList;
package/dist/index.js ADDED
@@ -0,0 +1,19 @@
1
+ "use strict";var v=function(s,t){return function(){return t||s((t={exports:{}}).exports,t),t.exports}};var c=v(function(L,p){"use strict";var o=require("@stdlib/utils-define-property");function A(s){return o(this,"next",{configurable:!1,enumerable:!0,get:function(){return this._next}}),o(this,"prev",{configurable:!1,enumerable:!0,get:function(){return this._prev}}),this.value=s,o(this,"_next",{configurable:!1,enumerable:!1,writable:!0,value:null}),o(this,"_prev",{configurable:!1,enumerable:!1,writable:!0,value:null}),this}p.exports=A});var d=v(function(S,y){"use strict";var l=require("@stdlib/utils-define-nonenumerable-read-only-property"),E=require("@stdlib/utils-define-nonenumerable-read-only-accessor"),g=require("@stdlib/symbol-iterator"),x=require("@stdlib/string-format"),_=c();function n(){return this instanceof n?(this._length=0,this._first=null,this._last=null,this):new n}l(n.prototype,"clear",function(){return this._length=0,this._first=null,this._last=null,this});l(n.prototype,"first",function(){if(this._length)return this._first});l(n.prototype,"insert",function(t,e,i){var a,r;if(arguments.length>2){if(a=i,a!=="before"&&a!=="after")throw new Error(x("invalid argument. Third argument must be a recognized location. Value: `%s`.",a))}else a="after";if(a==="after"&&t===this._last)return this.push(e);if(a==="before"&&t===this._first)return this.unshift(e);for(r=this._first;r!==this._last&&r!==t;)r=r._next;if(r===this._last&&r!==t)throw new Error("invalid argument. The list does not contain the provided list node.");return r=new _(e),a==="after"?(t._next._prev=r,r._next=t._next,t._next=r,r._prev=t):(t._prev._next=r,r._prev=t._prev,t._prev=r,r._next=t),this._length+=1,this});l(n.prototype,"iterator",function(t){var e,i,a,r,h,f,u;if(arguments.length){if(h=t,h!=="forward"&&h!=="reverse")throw new Error(x("invalid argument. Must provide a recognized iteration direction. Value: `%s`.",h))}else h="forward";return a=this,h==="forward"?(u=-1,f=1):(u=this._length,f=-1),e=this.toArray(),i={},l(i,"next",w),l(i,"return",m),g&&l(i,g,b),i;function w(){return u+=f,r||u<0||u>=e.length?{done:!0}:{value:e[u],done:!1}}function m(q){return r=!0,arguments.length?{value:q,done:!0}:{done:!0}}function b(){return a.iterator()}});l(n.prototype,"last",function(){if(this._length)return this._last});E(n.prototype,"length",function(){return this._length});l(n.prototype,"pop",function(){var t;return this._length&&(t=this._last.value,this._last._prev?(this._last=this._last._prev,this._last._next=null):(this._first=null,this._last=null),this._length-=1),t});l(n.prototype,"push",function(t){var e;return e=new _(t),this._length===0?(this._first=e,this._last=e):(e._prev=this._last,this._last._next=e,this._last=e),this._length+=1,this});l(n.prototype,"remove",function(t){var e,i;if(t===this._first)return this.shift();if(t===this._last)return this.pop();for(e=t.value,i=this._first;i!==this._last&&i!==t;)i=i._next;if(i===this._last)throw new Error("invalid argument. The list does not contain the provided list node.");return t._prev._next=t._next,t._next._prev=t._prev,this._length-=1,e});l(n.prototype,"shift",function(){var t;return this._length&&(t=this._first.value,this._first._next?(this._first=this._first._next,this._first._prev=null):(this._first=null,this._last=null),this._length-=1),t});l(n.prototype,"toArray",function(){var t,e,i;for(e=[],t=this._first,i=0;i<this._length;i++)e.push(t.value),t=t.next;return e});l(n.prototype,"toJSON",function(){var t={};return t.type="doubly-linked-list",t.data=this.toArray(),t});l(n.prototype,"unshift",function(t){var e;return e=new _(t),this._length===0?(this._first=e,this._last=e):(e._next=this._first,this._first._prev=e,this._first=e),this._length+=1,this});y.exports=n});var N=d();module.exports=N;
2
+ /**
3
+ * @license Apache-2.0
4
+ *
5
+ * Copyright (c) 2018 The Stdlib Authors.
6
+ *
7
+ * Licensed under the Apache License, Version 2.0 (the "License");
8
+ * you may not use this file except in compliance with the License.
9
+ * You may obtain a copy of the License at
10
+ *
11
+ * http://www.apache.org/licenses/LICENSE-2.0
12
+ *
13
+ * Unless required by applicable law or agreed to in writing, software
14
+ * distributed under the License is distributed on an "AS IS" BASIS,
15
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16
+ * See the License for the specific language governing permissions and
17
+ * limitations under the License.
18
+ */
19
+ //# sourceMappingURL=index.js.map