Skip to content

Commit

Permalink
feat(utils): check object is a non-empty primitive type
Browse files Browse the repository at this point in the history
  • Loading branch information
h2non committed Jul 17, 2014
1 parent 6067dc3 commit 3f3ef13
Showing 1 changed file with 7 additions and 3 deletions.
10 changes: 7 additions & 3 deletions src/utils.wisp
Expand Up @@ -14,20 +14,24 @@
[o]
(? (typeof o) :function))

(defn ^:private not-empty
[o]
(and (!? o nil) (!? o null)))

(defn ^boolean str?
"Check if the given value is a string"
[o]
(? (.call ->string o) "[object String]"))
(and (not-empty o) (? (.call ->string o) "[object String]")))

(defn ^boolean obj?
"Check if the given value is a plain object"
[o]
(? (.call ->string o) "[object Object]"))
(and (not-empty o) (? (.call ->string o) "[object Object]")))

(defn ^boolean arr?
"Check if the given value is an array"
[o]
(? (.call ->string o) "[object Array]"))
(and (not-empty o) (? (.call ->string o) "[object Array]")))

(defn ^fn chain
"Make function chainable"
Expand Down

0 comments on commit 3f3ef13

Please sign in to comment.