您最多选择25个主题 主题必须以字母或数字开头,可以包含连字符 (-),并且长度不得超过35个字符

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