Exports Meteor's CoffeeScript __coffeescriptShare
object so that you can 'use strict' in your CoffeeScript
files.
Warning
fds:coffeescript-share is only for use with Meteor applications and is not for use by other packages.
fds:coffeescript-share makes the same share object available to everything that uses it. This allows shared objects to leak outside of their package. This is only a problem when fds:coffeescript-share is used by other packages.
$ meteor add fds:coffeescript-shareMeteor allows CoffeeScript users to share objects between files without
polluting the global namespace by creating properties on a special object,
share, e.g.;
1_first.coffee
share.greet = (name) ->
console.log "Hello, #{ name }!"2_second.coffee
share.greet 'World'This works because when Meteor compiles a CoffeeScript file, it prepends;
__coffeescriptShare = typeof __coffeescriptShare === 'object' ?
__coffeescriptShare : {};
var share = __coffeescriptShare;These statements ensure the global __coffeescriptShare exists and assigns it to
a file-scope variable share.
However, strict mode wont let you create a global like this. Instead, a
ReferenceError is thrown (try adding 'use strict' to the example above).
This package safely creates and exports __coffeescriptShare so that you can
'use strict' in your CoffeeScript files.
To run the example;
$ cd example
$ meteorOpen a browser and navigate to http://localhost:3000 and check that
Hello, World! appears on the console. Then remove fds:coffeescipt-share and
watch it explode;
$ meteor remove fds:coffeescript-shareThen remove the 'use strict' and see it work again (but in lax mode*).
*I just made that name up.