Skip to content

Commit

Permalink
chore: Transition to typescript
Browse files Browse the repository at this point in the history
  • Loading branch information
angelnext committed Mar 3, 2024
1 parent 3b7cd10 commit 21eefa4
Show file tree
Hide file tree
Showing 14 changed files with 324 additions and 595 deletions.
24 changes: 0 additions & 24 deletions .github/workflows/publish.yml

This file was deleted.

1 change: 0 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
# Rubiks

[![deno module](https://shield.deno.dev/x/rubiks)](https://deno.land/x/rubiks)
![NPM Version](https://img.shields.io/npm/v/rubiks)

Rubiks is a 0 dependency extendable logging library for modern applications.

Expand Down
5 changes: 5 additions & 0 deletions deno.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
{
"name": "@rubiks/rubiks",
"version": "1.2.0",
"exports": "./mod.ts"
}
83 changes: 83 additions & 0 deletions levels.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,83 @@
import { type Rubiks } from "./rubiks.ts";

export type Level = (self: Rubiks, content: string) => void;

/**
* Default log level.
* @param self - The instance
* @param content - The content you provide.
*/
export function log(self: Rubiks, content: string) {
console.log(`${self.prefixes.all || ""}${content}${self.suffixes.all || ""}`);
}

/**
* Error log level.
* @param self - The instance
* @param content - The content you provide.
*/
export function error(self: Rubiks, content: string) {
self.level = "error";
console.error(
`${self.prefixes.all || ""}${self.prefixes[self.level] || ""}${self.noColor ? "" : "\x1b[31;1m"
}error\x1b[0m: ${content}${self.suffixes.all || ""}`,
);
self.level = "";
}

/**
* Error log level.
* @param self - The instance
* @param content - The content you provide.
*/
export function fatal(self: Rubiks, content: string) {
self.level = "fatal";
console.error(
`${self.prefixes.all || ""}${self.prefixes[self.level] || ""}${self.noColor ? "" : "\x1b[31;1m"
}fatal\x1b[0m: ${self.noColor ? "" : "\x1b[31m"}${content}\x1b[0m${self.suffixes.all || ""
}`,
);
self.level = "";
}

/**
* Warn log level.
* @param self - The instance
* @param content - The content you provide.
*/
export function warn(self: Rubiks, content: string) {
self.level = "warn";
console.warn(
`${self.prefixes.all || ""}${self.prefixes[self.level] || ""}${self.noColor ? "" : "\x1b[33;1m"
}warning\x1b[0m: ${content}${self.suffixes.all || ""}`,
);
self.level = "";
}

/**
* Success log level.
* @param self - The instance
* @param content - The content you provide.
*/
export function success(self: Rubiks, content: string) {
self.level = "success";
console.log(
`${self.prefixes.all || ""}${self.prefixes[self.level] || ""}${self.noColor ? "" : "\x1b[32;1m"
}success\x1b[0m: ${content}${self.suffixes.all || ""}`,
);
self.level = "";
}

/**
* Info log level.
* @param self - The instance
* @param content - The content you provide.
*/
export function info(self: Rubiks, content: string) {
self.level = "info";
console.log(
`${self.prefixes.all || ""}${self.prefixes[self.level] || ""}${self.noColor ? "" : "\x1b[34;1m"
}info\x1b[0m: ${content}${self.suffixes.all || ""}`,
);
self.level = "";
}
3 changes: 0 additions & 3 deletions lib/index.js

This file was deleted.

96 changes: 0 additions & 96 deletions lib/levels.js

This file was deleted.

80 changes: 0 additions & 80 deletions lib/modifiers.js

This file was deleted.

Loading

0 comments on commit 21eefa4

Please sign in to comment.