@namchee/decora
Advanced tools
Comparing version 1.0.3 to 1.0.4-canary.3.af4835fca9cd0c1c8789968bce33833cfbd510ad.0
{ | ||
"name": "@namchee/decora", | ||
"version": "1.0.3", | ||
"version": "1.0.4-canary.3.af4835fca9cd0c1c8789968bce33833cfbd510ad.0", | ||
"description": "Useful ECMAScript-compliant decorators to enhance JS (specifically, TypeScript) development experience", | ||
@@ -5,0 +5,0 @@ "main": "index.js", |
@@ -46,4 +46,3 @@ # Decora | ||
`precision` | `false` | `number, n > 1` | `undefined` | Number of digits after comma. Passing `undefined` will print an abruptly long string. | ||
`stream` | `true` | `NodeJS.WritableStream` | `process.stdout` | Destination for the log to be written to. [Detailed Explanation](https://nodejs.org/api/stream.html#stream_writable_streams) | ||
`stream` | `true` | `NodeJS.WritableStream` | `process.stdout` | Destination for the log to be written to. [Detailed Explanation](https://nodejs.org/api/stream.html#stream_writable_streams). This option is **ONLY** available on NodeJS environment. | ||
## `@timeout` | ||
@@ -50,0 +49,0 @@ |
@@ -1,3 +0,2 @@ | ||
import { Console } from 'console'; | ||
import { performance } from 'perf_hooks'; | ||
import { isNode, isBrowser } from './utils'; | ||
@@ -29,4 +28,25 @@ /** | ||
const logger = new Console({ stdout: stream }); | ||
let logger: Console; | ||
let performance: Performance; | ||
if (isNode) { // node environment | ||
const Console = require('console').Console; | ||
logger = new Console({ stdout: stream }); | ||
performance = require('perf_hooks').performance; | ||
} else if (isBrowser) { // browser | ||
logger = window.console; | ||
performance = window.performance; | ||
// if stream is somehow defined, ignore it | ||
if (stream) { | ||
logger.warn( | ||
/* eslint-disable-next-line */ | ||
'The `stream` option only available on Node.JS environment. This option will be ignored.', | ||
); | ||
} | ||
} else { // do nothing, for now | ||
return; | ||
} | ||
const fn: Function = descriptor.value; | ||
@@ -33,0 +53,0 @@ |
No v1
QualityPackage is not semver >=1. This means it is not stable and does not support ^ ranges.
Found 1 instance in 1 package
22069
18
352
1
70