Skip to content

Commit

Permalink
refactor(x): make format executable without --allow-env flag #11
Browse files Browse the repository at this point in the history
  • Loading branch information
c4spar committed May 10, 2020
1 parent 70f2d6d commit 2db057e
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 50 deletions.
6 changes: 2 additions & 4 deletions packages/x/format.ts
@@ -1,16 +1,14 @@
// Copied from https://github.com/defunctzombie/node-util/blob/master/util.ts
// Modified to format %o and %O as deno objects
const { inspect } = Deno;
import { getInspectOpts } from './inspector-ops.ts';

const inspectOpts = getInspectOpts();
const formatRegExp = /%[sdjoO%]/g;

export default function format( ...args: any[] ) {
if ( typeof args[ 0 ] !== 'string' ) {
let objects = [];
for ( let i = 0; i < arguments.length; i++ ) {
objects.push( inspect( arguments[ i ], inspectOpts ) );
objects.push( inspect( arguments[ i ] ) );
}
return objects.join( ' ' );
}
Expand Down Expand Up @@ -38,7 +36,7 @@ export default function format( ...args: any[] ) {
}
case '%o':
case '%O':
return inspect( args[ i++ ], inspectOpts );
return inspect( args[ i++ ] );
default:
return x;
}
Expand Down
46 changes: 0 additions & 46 deletions packages/x/inspector-ops.ts

This file was deleted.

0 comments on commit 2db057e

Please sign in to comment.