Filesystem API, Pure-JS glob implementation

57 views
Skip to first unread message

Kris Kowal

unread,
Aug 30, 2009, 4:25:28 AM8/30/09
to comm...@googlegroups.com
I believe Wes asked for a pure-javascript implementation of glob. I
finished one tonight, and it should work anywhere you implement:

* isAbsolute
* listDirectoryTree
returns an array of the directories under a given
directory, including itself
* list
returns an array of the names of every file or directory
under a given path

http://github.com/kriskowal/narwhal/blob/7eef0ee254993cebd7d8a046a87d547e6217ff52/lib/file.js#L240

It still needs a test suite. I'm probably going to do this by way of
creating a sandbox with a virtual file module implementation so I can
run various scenarios on a consistently reconstructed file system
view, without having to muddy up the disk and leave it in inconsistent
states when tests fail.

This comes out of Tom's and my experiments to assess how much of the
CommonJS specifications can be in pure-JavaScript and thus shared
among CommonJS implementations.

Kris Kowal

Wes Garland

unread,
Aug 30, 2009, 10:37:07 AM8/30/09
to comm...@googlegroups.com
Hi Kris!

That's a particularly valuable piece of kit.

Along the lines with those experiments, we are currently implementing narwhal's file API by substituting GPSEE FFI calls in file-(platform|engine).js. I think this is a pretty good way to build CommonJS.  Emacs has certainly shown that the technique works!

Wes
--
Wesley W. Garland
Director, Product Development
PageMail, Inc.
+1 613 542 2787 x 102
Reply all
Reply to author
Forward
0 new messages