Repositorio del curso CCOM4030 el semestre B91 del proyecto Artesanías con el Instituto de Cultura

123456789101112131415161718192021222324252627282930313233
  1. 'use strict'
  2. function reusify (Constructor) {
  3. var head = new Constructor()
  4. var tail = head
  5. function get () {
  6. var current = head
  7. if (current.next) {
  8. head = current.next
  9. } else {
  10. head = new Constructor()
  11. tail = head
  12. }
  13. current.next = null
  14. return current
  15. }
  16. function release (obj) {
  17. tail.next = obj
  18. tail = obj
  19. }
  20. return {
  21. get: get,
  22. release: release
  23. }
  24. }
  25. module.exports = reusify