Skip to content

Commit

Permalink
fix(primitives): expose console.debug method (#174)
Browse files Browse the repository at this point in the history
* fix(primitives): expose console.debug method

* Create gold-news-melt.md
  • Loading branch information
Kikobeats committed Oct 18, 2022
1 parent 411d358 commit 5a6c68a
Show file tree
Hide file tree
Showing 3 changed files with 33 additions and 7 deletions.
5 changes: 5 additions & 0 deletions .changeset/gold-news-melt.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"@edge-runtime/primitives": patch
---

fix(primitives): expose console.debug method
15 changes: 8 additions & 7 deletions packages/primitives/src/primitives/console.js
Original file line number Diff line number Diff line change
@@ -1,19 +1,20 @@
import { createFormat } from '@edge-runtime/format'

const format = createFormat()
const bareError = console.error.bind(console);
const bareLog = console.log.bind(console);
const assert = console.assert.bind(console);
const time = console.time.bind(console);
const timeEnd = console.timeEnd.bind(console);
const timeLog = console.timeLog.bind(console);
const trace = console.trace.bind(console);
const bareError = console.error.bind(console)
const bareLog = console.log.bind(console)
const assert = console.assert.bind(console)
const time = console.time.bind(console)
const timeEnd = console.timeEnd.bind(console)
const timeLog = console.timeLog.bind(console)
const trace = console.trace.bind(console)
const error = (...args) => bareError(format(...args))
const log = (...args) => bareLog(format(...args))

const konsole = {
assert: (assertion, ...args) => assert(assertion, format(...args)),
count: console.count.bind(console),
debug: log,
dir: console.dir.bind(console),
error: error,
info: log,
Expand Down
20 changes: 20 additions & 0 deletions packages/primitives/tests/console.test.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
import { console as konsole } from '../console'

it.each([
{ method: 'assert' },
{ method: 'count' },
{ method: 'debug' },
{ method: 'dir' },
{ method: 'error' },
{ method: 'info' },
{ method: 'time' },
{ method: 'timeEnd' },
{ method: 'timeLog' },
{ method: 'trace' },
{ method: 'warn' },
])('$method', ({ method }) => {
const key = method.toString()
expect(konsole).toHaveProperty(key, expect.any(Function))
const fn = konsole[key as keyof typeof konsole]
expect(typeof fn.bind(console)).toBe('function')
})

1 comment on commit 5a6c68a

@vercel
Copy link

@vercel vercel bot commented on 5a6c68a Oct 18, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Successfully deployed to the following URLs:

edge-runtime – ./

edge-runtime.vercel.app
edge-runtime.vercel.sh
edge-runtime-git-main.vercel.sh

Please sign in to comment.