# magic-globals

> Magic Globals, ex. `__line` and `__func`. Similar to Magic Constants in PHP

Latest version **0.9.1** (published 2017-08-03) · MIT license · 0 weekly downloads

## Install

```sh
npm install magic-globals
pnpm add magic-globals
yarn add magic-globals
bun add magic-globals
```

## Health

**Score 15/100 (F)** — status: abandoned.

Positive: no vulnerabilities.

Warnings: low downloads; no types; no esm support; pre 1.0.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 0.9.1 |
| Published | 2017-08-03 |
| First published | 2015-01-03 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 0 |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 21 |
| Author | Gavin Engel |
| Maintainers | gavinengel |
| Keywords | magic, globals, debug |

## Links

- npm: https://www.npmjs.com/package/magic-globals
- Repository: https://github.com/gavinengel/magic-globals
- Homepage: https://github.com/gavinengel/magic-globals#readme
- Issues: https://github.com/gavinengel/magic-globals/issues
- npm.io page: https://npm.io/package/magic-globals

## Alternatives

- [cli-color](https://npm.io/package/cli-color.md) — 3.4M weekly downloads
- [log](https://npm.io/package/log.md) — 1.3M weekly downloads
- [logstash-client](https://npm.io/package/logstash-client.md) — 4.5K weekly downloads
- [@nocobase/plugin-logger](https://npm.io/package/@nocobase/plugin-logger.md) — 2.0K weekly downloads
- [child-process-debug](https://npm.io/package/child-process-debug.md) — 695 weekly downloads

## Recent versions

- 0.9.1 (latest) — 2017-08-03
- 0.9.0 — 2017-08-03
- 0.5.2 — 2017-05-05
- 0.5.1 — 2016-10-14
- 0.5.0 — 2015-05-29
- 0.4.4 — 2015-04-30
- 0.4.3 — 2015-03-14
- 0.4.2 — 2015-03-14
- 0.4.1 — 2015-03-13
- 0.4.0 — 2015-03-13
- 0.3.3 — 2015-01-30
- 0.3.2 — 2015-01-26
- 0.3.1 — 2015-01-26
- 0.3.0 — 2015-01-05
- 0.2.0 — 2015-01-05
- … 5 more at https://npm.io/package/magic-globals/versions

## README

# Magic Globals
Similar to Magic Constants in PHP.  Useful for debugging.

[![npm version](https://badge.fury.io/js/magic-globals.svg)](http://badge.fury.io/js/magic-globals)
[![gluten](https://img.shields.io/badge/gluten-free-green.svg?style=flat)](http://i.imgur.com/Kua978a.jpg)


## Usage
```js
// 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](http://opensource.org/licenses/MIT))
Copyright (c) 2015 Gavin Engel <<gavin@engel.com>>

---
_Source: https://npm.io/package/magic-globals · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
