repl.txt (1622B)
1 2 {{alias}}() 3 First-in-first-out (FIFO) queue constructor. 4 5 Returns 6 ------- 7 queue: Object 8 First-in-first-out queue. 9 10 queue.clear: Function 11 Clears the queue. 12 13 queue.first: Function 14 Returns the "oldest" queue value (i.e., the value which is "first-out"). 15 If the queue is empty, the returned value is `undefined`. 16 17 queue.iterator: Function 18 Returns an iterator for iterating over a queue. If an environment 19 supports Symbol.iterator, the returned iterator is iterable. Note that, 20 in order to prevent confusion arising from queue mutation during 21 iteration, a returned iterator **always** iterates over a queue 22 "snapshot", which is defined as the list of queue elements at the time 23 of the method's invocation. 24 25 queue.last: Function 26 Returns the "newest" queue value (i.e., the value which is "last-out"). 27 If the queue is empty, the returned value is `undefined`. 28 29 queue.length: integer 30 Queue length. 31 32 queue.pop: Function 33 Removes and returns the current "first-out" value from the queue. If the 34 queue is empty, the returned value is `undefined`. 35 36 queue.push: Function 37 Adds a value to the queue. 38 39 queue.toArray: Function 40 Returns an array of queue values. 41 42 queue.toJSON: Function 43 Serializes a queue as JSON. 44 45 Examples 46 -------- 47 > var q = {{alias}}(); 48 > q.push( 'foo' ).push( 'bar' ); 49 > q.length 50 2 51 > q.pop() 52 'foo' 53 > q.length 54 1 55 > q.pop() 56 'bar' 57 > q.length 58 0 59 60 See Also 61 -------- 62