开发者

CoffeeScript main?

开发者 https://www.devze.com 2023-03-21 18:38 出处:网络
I\'d like to have a main function that is run only if my is not imported but actually run and not imported.

I'd like to have a main function that is run only if my is not imported but actually run and not imported.

Is there an equivalent to python's name == "main" in coffeescript?

Right now I'm usin开发者_StackOverflow社区g

is_main = process.argv[1]==__filename
if is_main
    main()

but I don't know if something more idiomatic exists, and I noticed it did not work with older versions of coffeescript.


Related JS question

main() if require.main is module

0

精彩评论

暂无评论...
验证码 换一张
取 消