0.9.1 • Published 7 years ago
magic-globals v0.9.1
Magic Globals
Similar to Magic Constants in PHP. Useful for debugging.
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:
- http://stackoverflow.com/questions/13591785/does-node-js-have-anything-like-file-and-line-like-the-c-preprocessor
- http://stackoverflow.com/questions/11386492/accessing-line-number-in-v8-javascript-chrome-node-js
- https://gist.github.com/lordvlad/ec81834ddff73aaa1ab0
Alternatives
These are alternative projects which can yield achieve a similar result:
- https://www.npmjs.com/package/nor-debug
- https://www.npmjs.com/package/pitestglobals
- https://www.npmjs.com/package/magicmethods
License
(The MIT License) Copyright (c) 2015 Gavin Engel <gavin@engel.com>
0.9.1
7 years ago
0.9.0
7 years ago
0.5.2
8 years ago
0.5.1
8 years ago
0.5.0
9 years ago
0.4.4
10 years ago
0.4.3
10 years ago
0.4.2
10 years ago
0.4.1
10 years ago
0.4.0
10 years ago
0.3.3
10 years ago
0.3.2
10 years ago
0.3.1
10 years ago
0.3.0
10 years ago
0.2.0
10 years ago
0.0.3
10 years ago
0.0.2
10 years ago
0.0.1
10 years ago
0.0.0
10 years ago
0.1.0
10 years ago