KnowledgeHub
Questions
Tags
Users
Search
Alex Rivera
|
Logout
Edit Question
Title
Body
I don't much like the standard way to require modules, which goes something like this: connect = require 'connect' express = require 'express' redis = require 'redis' sys = require 'sys' coffee = require 'coffee-script' fs = require 'fs' It's not exactly DRY. In a modest CoffeeScript server, the require dance takes up a fair chunk of the entire script! I've been toying with the following alternative: "connect,express,redis,sys,coffee-script,fs" .split(',').forEach (lib) -> global[lib] = require lib Since I haven't seen people try to refactor the standard approach, I thought I'd ask if it seems reasonable to do so, and if so, are there any better ways to do it?
Tags (comma-separated)
Save Edits
Cancel