Skip to content

Instantly share code, notes, and snippets.

@baofengyv
Last active January 25, 2018 05:19
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save baofengyv/83944a28ed2d63dfd63a6621a9cb15b8 to your computer and use it in GitHub Desktop.
Save baofengyv/83944a28ed2d63dfd63a6621a9cb15b8 to your computer and use it in GitHub Desktop.
NodeJs 代码片段 及解释
@baofengyv
Copy link
Author

baofengyv commented Jan 25, 2018

判断当前文件是直接执行 or 被别的文件require执行的
determine if the script is being required or run directly.

if (require.main !== module) {
  //...
}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment