             (doseq [p packets]
               (aset chunk @idx p)
               (swap! idx inc))
-;;             (println "loopin loopin" @idx n (not packets) (and packets (< @idx n)))
             (if (and packets (< @idx n))
               (recur)
               @idx)))]

             [tf2demo])
  (:require-macros
   [cljs.core.async.macros :as asyncm :refer [go go-loop]]))

(def obj-proto (js/Object.getPrototypeOf #js {}))

(extend-type js/tf2demo.PacketEntity
  IEncodeClojure
  (-js->clj [x opts]
    (js/Object.setPrototypeOf x obj-proto)
    ))

;; (extend-type js/tf2demo.SendProp
;;   IEncodeClojure
;;   (-js->clj [x opts] (h/plainify x)))
;; (extend-type js/tf2demo.SendPropDefinition
;;   IEncodeClojure
;;   (-js->clj [x opts] (h/plainify x)))
;; (extend-type js/tf2demo.ServerClass
;;   IEncodeClojure
;;   (-js->clj [x opts] (h/plainify x)))


(defn setImmediate [fn] (js/setTimeout fn 50))


        (doseq [p packets] (.emit parser "packet" p))
        (when packets
          (.map packets (fn [p] (js-delete p "tables"))))
        (or packets (when msg []))))))

;; parse the next messages to get at least n packets (may return more than
;; the requested n packets), or until end of parser
