A common set of utilities for use in the Dash framework (or any node app)
npm install dash-utils
or just clone this repo.
The module contains the following utilities
walk(myPath, callback)
is a synchronous function (I know, i know!) that walks the given path recursively and returns all files.
It's used in Dash for walking path trees and pre-loading models and routes when the application bootstraps, thus it being synchronous.
Example:
walk('api/models', function (err, file) {
if (err) return console.log(err);
if (file == 'api/models/schema.js') {
// DO SOMETHING
}
});
escapeRegExp()
is just a small utility to help make a string more regexp friendly.
It's used in Dash for making path matches easier.