Fork me on GitHub
#clojurescript
<
2019-12-28
>
siva05:12:24

(require '[cljs.build.api :as b])

(b/build "src"
  {:output-dir "out"
   :output-to "out/main.js"
   :target :nodejs
   :optimizations :simple
   :main 'cljs-fstore.core
   :install-deps true
   :npm-deps {:@google-cloud/firestore "3.1.0"}})

siva05:12:33

How to use this package in npm-deps?

siva05:12:19

I wish to use this package in the build script. @google-cloud/firestore This throws an error. How to make npm realise this package?

Karol Wójcik16:12:31

How can I remove the following warning?

(defn- recordStartTime
  []
  (this-as this
           (aset this "_startAt" (js/process.hrtime))))

Karol Wójcik16:12:19

Ok. I can just include @constructor doc to a function 🙂

yogthos02:12:50

this is what I ended up with, was just wondering if there's a better way

(js/setInterval
         (fn []
           (let [promise
                 (js/Promise.
                  (fn detect []
                    
                    (-> (face-api/detectAllFaces video (face-api/TinyFaceDetectorOptions.))
                        (.withFaceLandmarks)
                        (.withFaceExpressions)
                        (.then
                         (fn [detections]
                           (let [resized-detections (face-api/resizeResults detections (clj->js display-size))]
                             (.clearRect (.getContext canvas "2d") 0 0 (:width display-size) (:height display-size))
                             (-> face-api/draw (.drawDetections canvas resized-detections))
                             (-> face-api/draw (.drawFaceLandmarks canvas resized-detections))
                             (-> face-api/draw (.drawFaceExpressions canvas resized-detections))))))))]
             (set! (.-resolve promise) true)))
         100)

rakyi14:12:35

Maybe I’m missing something, but I think you should be able to loose the outer promise.

(js/setInterval
 (fn detect []
   (-> (face-api/detectAllFaces video (face-api/TinyFaceDetectorOptions.))
       (.withFaceLandmarks)
       (.withFaceExpressions)
       (.then
        (fn [detections]
          (let [resized-detections (face-api/resizeResults detections (clj->js display-size))]
            (.clearRect (.getContext canvas "2d") 0 0 (:width display-size) (:height display-size))
            (-> face-api/draw (.drawDetections canvas resized-detections))
            (-> face-api/draw (.drawFaceLandmarks canvas resized-detections))
            (-> face-api/draw (.drawFaceExpressions canvas resized-detections)))))))
 100)

yogthos16:12:50

you're right, I was going by the original code with setInterval(async () => {...}, 100) where it creates a variable for detections, and I was getting an error with that, but the promise gets resolved before the next setInterval call happens now