Skip to content

Commit

Permalink
Merge pull request #40 from atonoy/feature/console-function
Browse files Browse the repository at this point in the history
No need console.error, terminal color code is no need when use none t…
  • Loading branch information
fukaoi authored Feb 26, 2022
2 parents 44d95fa + 367b7d9 commit 6b63e0b
Show file tree
Hide file tree
Showing 2 changed files with 1 addition and 37 deletions.
20 changes: 1 addition & 19 deletions packages/shared/src/global.ts
Original file line number Diff line number Diff line change
Expand Up @@ -67,25 +67,7 @@ console.debug = (
data: unknown,
data2: unknown = '',
data3: unknown = ''
) => {
if (Constants.isDebugging) console.log(
`\u001b[34m`, data,
`\u001b[35m`, data2,
`\u001b[36m`, data3
);
}

console.error = (
data: unknown,
data2: unknown = '',
data3: unknown = ''
) => {
console.log(
`\u001b[31m`, data,
`\u001b[4m\u001b[31m`, data2,
`\u001b[0m\u001b[31m`, data3,
);
}
) => Constants.isDebugging && console.log(data, data2, data3);

export const tryCatch = (fn: () => {}) => {
try {
Expand Down
18 changes: 0 additions & 18 deletions packages/shared/test/global.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -34,27 +34,9 @@ describe('Global', () => {
}
});

it('try catch. Handling error object', async () => {
const message = 'test';
const res = tryCatch(() => {
throw new Error(message);
});
assert.isTrue(res.isErr);
if (res.isErr) {
assert.equal(res.error.message, message);
}
});

it('console.debug', async () => {
console.debug(
'debug test', {title: 'test'}, () => {return }
);
});

it('console.error', async () => {
console.error(
'error test', {title: 'error'}, () => {return}
);
});

})

0 comments on commit 6b63e0b

Please sign in to comment.