CoolFace
Apppublic

strong-tie/inbound-calls

sourceHugging Faceupdated 2y agoView on Hugging Face
0likes
reusify.js34 linesDownload Raw Back to reusify
1'use strict'2 3function reusify (Constructor) {4  var head = new Constructor()5  var tail = head6 7  function get () {8    var current = head9 10    if (current.next) {11      head = current.next12    } else {13      head = new Constructor()14      tail = head15    }16 17    current.next = null18 19    return current20  }21 22  function release (obj) {23    tail.next = obj24    tail = obj25  }26 27  return {28    get: get,29    release: release30  }31}32 33module.exports = reusify34