source: trip-planner-front/node_modules/reusify/reusify.js@ 1ad8e64

Last change on this file since 1ad8e64 was 6a3a178, checked in by Ema <ema_spirova@…>, 3 years ago

initial commit

  • Property mode set to 100644
File size: 454 bytes
Line 
1'use strict'
2
3function reusify (Constructor) {
4 var head = new Constructor()
5 var tail = head
6
7 function get () {
8 var current = head
9
10 if (current.next) {
11 head = current.next
12 } else {
13 head = new Constructor()
14 tail = head
15 }
16
17 current.next = null
18
19 return current
20 }
21
22 function release (obj) {
23 tail.next = obj
24 tail = obj
25 }
26
27 return {
28 get: get,
29 release: release
30 }
31}
32
33module.exports = reusify
Note: See TracBrowser for help on using the repository browser.