Skip to content

Commit

Permalink
remove process.env use from core
Browse files Browse the repository at this point in the history
  • Loading branch information
justjake committed Dec 27, 2023
1 parent f2f4078 commit 3fe3013
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 62 deletions.
39 changes: 0 additions & 39 deletions doc/quickjs-emscripten-core/exports.md
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,6 @@
- [EvalFlags](exports.md#evalflags)
- [Functions](exports.md#functions)
- [assertSync()](exports.md#assertsync)
- [debugLog()](exports.md#debuglog)
- [isFail()](exports.md#isfail)
- [isSuccess()](exports.md#issuccess)
- [memoizePromiseFactory()](exports.md#memoizepromisefactory)
Expand Down Expand Up @@ -739,44 +738,6 @@ packages/quickjs-ffi-types/dist/index.d.ts:85

***

### debugLog()

> **debugLog**(`message`?, ...`optionalParams`?): `void`
Prints to `stdout` with newline. Multiple arguments can be passed, with the
first used as the primary message and all additional used as substitution
values similar to [`printf(3)`](http://man7.org/linux/man-pages/man3/printf.3.html) (the arguments are all passed to `util.format()`).

```js
const count = 5;
console.log('count: %d', count);
// Prints: count: 5, to stdout
console.log('count:', count);
// Prints: count: 5, to stdout
```

See `util.format()` for more information.

#### Parameters

**message?**: `any`

• ...**optionalParams?**: `any`[]

#### Returns

`void`

#### Since

v0.1.100

#### Source

node\_modules/@types/node/console.d.ts:221

***

### isFail()

> **isFail**\<`S`, `F`\>(`successOrFail`): `successOrFail is Object`
Expand Down
21 changes: 0 additions & 21 deletions doc/quickjs-emscripten/exports.md
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,6 @@
- [[@jitl/quickjs-wasmfile-release-sync](https://github.com/justjake/quickjs-emscripten/blob/main/doc/@jitl/quickjs-wasmfile-release-sync/README.md)](exports.md#jitlquickjs-wasmfile-release-synchttpsgithubcomjustjakequickjs-emscriptenblobmaindocjitlquickjs-wasmfile-release-syncreadmemd)
- [Functions](exports.md#functions)
- [assertSync()](exports.md#assertsync)
- [debugLog()](exports.md#debuglog)
- [getQuickJS()](exports.md#getquickjs)
- [getQuickJSSync()](exports.md#getquickjssync)
- [isFail()](exports.md#isfail)
Expand Down Expand Up @@ -841,26 +840,6 @@ quickjs-ffi-types/dist/index.d.ts:85

***

### debugLog()

> **debugLog**(`message`?, ...`optionalParams`?): `void`
#### Parameters

**message?**: `any`

• ...**optionalParams?**: `any`[]

#### Returns

`void`

#### Source

quickjs-emscripten-core/dist/index.d.ts:1389

***

### getQuickJS()

> **getQuickJS**(): `Promise`\<[`QuickJSWASMModule`](classes/QuickJSWASMModule.md)\>
Expand Down
24 changes: 22 additions & 2 deletions packages/quickjs-emscripten-core/src/debug.ts
Original file line number Diff line number Diff line change
@@ -1,2 +1,22 @@
export const QTS_DEBUG = false || Boolean(typeof process === "object" && process.env.QTS_DEBUG)
export const debugLog = QTS_DEBUG ? console.log.bind(console) : () => {}
/**
* @private
* Mutable variable. Use {@link setDebugMode} to enable.
*/
export let QTS_DEBUG = false

/**
* Enable (or disable) debug logging and object creation tracking in the Javascript API.
* To get debug logging in the WebAssembly module, you need to use a debug build variant.
*/
export function setDebugMode(enabled: boolean = true) {
QTS_DEBUG = enabled
}

/**
* @private
*/
export function debugLog(...args: any[]) {
if (QTS_DEBUG) {
console.log(...args)
}
}

0 comments on commit 3fe3013

Please sign in to comment.