JSPM

  • ESM via JSPM
  • ES Module Entrypoint
  • Export Map
  • Keywords
  • License
  • Repository URL
  • TypeScript Types
  • README
  • Created
  • Published
  • Downloads 29
  • Score
    100M100P100Q84755F
  • License MIT

Magic Globals, similar to Magic Constants in PHP

Package Exports

  • magic-globals

This package does not declare an exports field, so the exports above have been automatically detected and optimized by JSPM instead. If any package subpath is missing, it is recommended to post an issue to the original package (magic-globals) to support the "exports" field. If that is not possible, create a JSPM override to customize the exports field for this package.

Readme

Magic Globals

Similar to Magic Constants in PHP. Useful for debugging.

npm version gluten

Usage

// require this module without assigning export
require('magic-globals')

// you may now use additional global objects,
// in addition to built-ins: __filename and __dirname
console.log(__filename) // /home/node/myapp/server/server.js
console.log(__file) // server
console.log(__line) // 6
console.log(__fili) // /home/node/myapp/server/server.js:6
console.log(__ext) // js
console.log(__base) // /home/node/myapp
console.log(__func) // someFunction or (anonymous) 
console.log(__dirname) // /home/node/myapp/server

Credits

These sources have helped to create this module by sharing their code:

Alternatives

These are alternative projects which can yield achieve a similar result:

License

(The MIT License) Copyright (c) 2015 Gavin Engel <gavin@engel.com>