0
Fork 0
mirror of https://github.com/penpot/penpot.git synced 2025-01-26 08:29:42 -05:00

Add cljs abstraction for jszip library under uxbox.util.zip ns.

This commit is contained in:
Andrey Antukh 2016-08-30 18:29:34 +03:00
parent 8bcb373d07
commit 224c410ec3
No known key found for this signature in database
GPG key ID: 4DFEBCB8316A8B95

24
src/uxbox/util/zip.cljs Normal file
View file

@ -0,0 +1,24 @@
;; This Source Code Form is subject to the terms of the Mozilla Public
;; License, v. 2.0. If a copy of the MPL was not distributed with this
;; file, You can obtain one at http://mozilla.org/MPL/2.0/.
;;
;; Copyright (c) 2016 Andrey Antukh <niwi@niwi.nz>
(ns uxbox.util.zip
"Helpers for make zip file (using jszip)."
(:require [vendor.jszip]
[promesa.core :as p]))
(defn build*
[files resolve reject]
(let [zipobj (js/JSZip.)]
(run! (fn [[name content]]
(.file zipobj name content))
files)
(-> (.generateAsync zipobj #js {:type "blob"})
(.then resolve reject))))
(defn build
[files]
(p/promise (fn [resolve reject]
(build* files resolve reject))))