summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/mf2clj/core.clj20
1 files changed, 13 insertions, 7 deletions
diff --git a/src/mf2clj/core.clj b/src/mf2clj/core.clj
index fd26203..f049222 100644
--- a/src/mf2clj/core.clj
+++ b/src/mf2clj/core.clj
@@ -14,11 +14,17 @@
manifest-from-wasm .build
Plugin/ofManifest .build))
-(defn parse [html-string]
- (let [charset StandardCharsets/UTF_8
- html-bytes (.getBytes html-string charset)]
- (-> (.call plugin "parse" html-bytes)
- (String. charset)
- json/parse-string
- keywordize-keys)))
+(def charset StandardCharsets/UTF_8)
+
+(defn parse-bytes [html-bytes]
+ {:pre [(bytes? html-bytes)]}
+ (-> (.call plugin "parse" html-bytes)
+ (String. charset)
+ json/parse-string
+ keywordize-keys))
+
+(defn parse [^String html-string]
+ {:pre [(string? html-string)]}
+ (let [html-bytes (.getBytes html-string charset)]
+ (parse-bytes html-bytes)))