|
Last change
on this file was 9af201e, checked in by MBK <marija.karapandzova@…>, 11 days ago |
|
Fix frontend appearance
|
-
Property mode
set to
100644
|
|
File size:
454 bytes
|
| Line | |
|---|
| 1 | 'use strict'
|
|---|
| 2 |
|
|---|
| 3 | function 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 |
|
|---|
| 33 | module.exports = reusify
|
|---|
Note:
See
TracBrowser
for help on using the repository browser.