LoginSignup
0
0

More than 5 years have passed since last update.

`using` in CoffeeScript

Last updated at Posted at 2013-11-21

Dirty. Names are assigned directly into GLOBAL. It breaks file scope.

main.coffee
using = require('using').using
using require './foo'
console.log new Foo #=> { name: 'Foo' }
require './bar'
using.coffee
exports.using = (mod) ->
  for name, obj of mod
    GLOBAL[name] = obj
foo.coffee
exports.Foo = class
  constructor: () ->
    @name = 'Foo'
bar.coffee
console.log new Foo #=> { name: 'Foo' }

There may be another way but I can't find it...

0
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
0