From c194f84cab66fa6e18b78c32f9cdf2bddf8d1e68 Mon Sep 17 00:00:00 2001 From: eric thul Date: Wed, 8 Apr 2015 19:49:24 -0400 Subject: Rewrite using purescript for the implementation --- src/Glob.purs | 31 +++++++++++++++++++++++++++++++ 1 file changed, 31 insertions(+) create mode 100644 src/Glob.purs (limited to 'src/Glob.purs') diff --git a/src/Glob.purs b/src/Glob.purs new file mode 100644 index 0000000..7bc9212 --- /dev/null +++ b/src/Glob.purs @@ -0,0 +1,31 @@ +module PursLoader.Glob + ( Glob() + , glob + ) where + +import Control.Monad.Aff (Aff(), makeAff) +import Control.Monad.Eff (Eff()) +import Control.Monad.Eff.Exception (Error()) + +import Data.Function + +foreign import data Glob :: ! + +glob :: forall eff. String -> Aff (glob :: Glob | eff) [String] +glob pattern = makeAff $ runFn3 globFn pattern + +foreign import globFn """ +function globFn(pattern, errback, callback) { + return function(){ + var glob = require('glob'); + + glob(pattern, function(e, data){ + if (e) errback(e)(); + else callback(data)(); + }); + }; +} +""" :: forall eff. Fn3 String + (Error -> Eff (glob :: Glob | eff) Unit) + ([String] -> Eff (glob :: Glob | eff) Unit) + (Eff (glob :: Glob | eff) Unit) -- cgit v1.2.3