From 02835b494d85823cd6623a8e615e23aab3e13675 Mon Sep 17 00:00:00 2001 From: foxxyz Date: Sun, 29 Oct 2023 12:13:49 -0700 Subject: [PATCH] refactor!: convert to ESM, simplify partial calls --- index.js | 26 +++++++------------------- package.json | 1 + test.js | 2 +- 3 files changed, 9 insertions(+), 20 deletions(-) diff --git a/index.js b/index.js index 6d090ac..0bb88db 100755 --- a/index.js +++ b/index.js @@ -20,24 +20,12 @@ console.warn = colored.bind(this, console.warn, YELLOW) console.error = colored.bind(this, console.error, RED) console.part = { - debug(...args) { - stdout.write(`${GREY}${args.join(' ')}${DEFAULT}`) - }, - error(...args) { - stdout.write(`${RED}${args.join(' ')}${DEFAULT}`) - }, - log(...args) { - stdout.write(args.join(' ')) - }, - info(...args) { - stdout.write(`${BLUE}${args.join(' ')}${DEFAULT}`) - }, - success(...args) { - stdout.write(`${GREEN}${args.join(' ')}${DEFAULT}`) - }, - warn(...args) { - stdout.write(`${YELLOW}${args.join(' ')}${DEFAULT}`) - } + debug: colored.bind(stdout, stdout.write, GREY), + error: colored.bind(stdout, stdout.write, RED), + log: colored.bind(stdout, stdout.write, DEFAULT), + info: colored.bind(stdout, stdout.write, BLUE), + success: colored.bind(stdout, stdout.write, GREEN), + warn: colored.bind(stdout, stdout.write, YELLOW), } -module.exports = console +export default console diff --git a/package.json b/package.json index 900265b..84450fc 100755 --- a/package.json +++ b/package.json @@ -7,6 +7,7 @@ "lint": "eslint .", "test": "node ./test.js" }, + "type": "module", "files": [ "index.js" ], diff --git a/test.js b/test.js index a3227e2..e827db9 100755 --- a/test.js +++ b/test.js @@ -1,6 +1,6 @@ #!/usr/bin/env node -require('.') +import './index.js' console.debug('👀 For developers only') console.log('🙈 Don\'t pay attention to me')