Skip to content

Commit 5a6c68a

Browse files
authored
fix(primitives): expose console.debug method (vercel#174)
* fix(primitives): expose console.debug method * Create gold-news-melt.md
1 parent 411d358 commit 5a6c68a

3 files changed

Lines changed: 33 additions & 7 deletions

File tree

.changeset/gold-news-melt.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
"@edge-runtime/primitives": patch
3+
---
4+
5+
fix(primitives): expose console.debug method

packages/primitives/src/primitives/console.js

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,20 @@
11
import { createFormat } from '@edge-runtime/format'
22

33
const format = createFormat()
4-
const bareError = console.error.bind(console);
5-
const bareLog = console.log.bind(console);
6-
const assert = console.assert.bind(console);
7-
const time = console.time.bind(console);
8-
const timeEnd = console.timeEnd.bind(console);
9-
const timeLog = console.timeLog.bind(console);
10-
const trace = console.trace.bind(console);
4+
const bareError = console.error.bind(console)
5+
const bareLog = console.log.bind(console)
6+
const assert = console.assert.bind(console)
7+
const time = console.time.bind(console)
8+
const timeEnd = console.timeEnd.bind(console)
9+
const timeLog = console.timeLog.bind(console)
10+
const trace = console.trace.bind(console)
1111
const error = (...args) => bareError(format(...args))
1212
const log = (...args) => bareLog(format(...args))
1313

1414
const konsole = {
1515
assert: (assertion, ...args) => assert(assertion, format(...args)),
1616
count: console.count.bind(console),
17+
debug: log,
1718
dir: console.dir.bind(console),
1819
error: error,
1920
info: log,
Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
import { console as konsole } from '../console'
2+
3+
it.each([
4+
{ method: 'assert' },
5+
{ method: 'count' },
6+
{ method: 'debug' },
7+
{ method: 'dir' },
8+
{ method: 'error' },
9+
{ method: 'info' },
10+
{ method: 'time' },
11+
{ method: 'timeEnd' },
12+
{ method: 'timeLog' },
13+
{ method: 'trace' },
14+
{ method: 'warn' },
15+
])('$method', ({ method }) => {
16+
const key = method.toString()
17+
expect(konsole).toHaveProperty(key, expect.any(Function))
18+
const fn = konsole[key as keyof typeof konsole]
19+
expect(typeof fn.bind(console)).toBe('function')
20+
})

0 commit comments

Comments
 (0)