repl.txt (2078B)
1 2 {{alias}}() 3 Doubly linked list constructor. 4 5 Returns 6 ------- 7 list: Object 8 Doubly linked list. 9 10 list.clear: Function 11 Clears the list. 12 13 list.first: Function 14 Returns the first list node. If the list is empty, the returned value is 15 `undefined`. 16 17 list.insert: Function 18 Inserts a value after a provided list node. For its third argument, the 19 method accepts a location: 'before' or 'after'. Default: 'after'. 20 21 list.iterator: Function 22 Returns an iterator for iterating over a list. If an environment 23 supports Symbol.iterator, the returned iterator is iterable. Note that, 24 in order to prevent confusion arising from list mutation during 25 iteration, a returned iterator **always** iterates over a list 26 "snapshot", which is defined as the list of list elements at the time 27 of the method's invocation. For its sole argument, the method accepts a 28 direction: 'forward' or 'reverse'. Default: 'forward'. 29 30 list.last: Function 31 Returns the last list node. If the list is empty, the returned value is 32 `undefined`. 33 34 list.length: integer 35 List length. 36 37 list.pop: Function 38 Removes and returns the last list value. If the list is empty, the 39 returned value is `undefined`. 40 41 list.push: Function 42 Adds a value to the end of the list. 43 44 list.remove: Function 45 Removes a list node from the list. 46 47 list.shift: Function 48 Removes and returns the first list value. If the list is empty, the 49 returned value is `undefined`. 50 51 list.toArray: Function 52 Returns an array of list values. 53 54 list.toJSON: Function 55 Serializes a list as JSON. 56 57 list.unshift: Function 58 Adds a value to the beginning of the list. 59 60 Examples 61 -------- 62 > var list = {{alias}}(); 63 > list.push( 'foo' ).push( 'bar' ); 64 > list.length 65 2 66 > list.pop() 67 'bar' 68 > list.length 69 1 70 > list.pop() 71 'foo' 72 > list.length 73 0 74 75 See Also 76 -------- 77