Skip to content

Commit 14b20f6

Browse files
committed
Initial commit
1 parent 4c189db commit 14b20f6

17 files changed

Lines changed: 3581 additions & 2 deletions

.editorconfig

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
root = true
2+
3+
[*]
4+
indent_style = space
5+
end_of_line = lf
6+
insert_final_newline = false
7+
8+
[*.md]
9+
indent_size = 2
10+
11+
[*.js]
12+
indent_size = 4
13+
14+
[*.yml]
15+
indent_size = 2
16+
17+
[*.yaml]
18+
indent_size = 2
19+
20+
[*.json]
21+
indent_size = 4

.eslintrc.json

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
{
2+
"env": {
3+
"commonjs": true,
4+
"es2021": true,
5+
"node": true
6+
},
7+
"extends": "eslint:recommended",
8+
"parserOptions": {
9+
"ecmaVersion": "latest"
10+
},
11+
"rules": {
12+
"indent": [
13+
"warn",
14+
4
15+
],
16+
"semi": [
17+
"error",
18+
"always"
19+
]
20+
}
21+
}

.github/FUNDING.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
github: GreepTheSheep

.github/workflows/publish.yml

Lines changed: 51 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,51 @@
1+
name: Publish on Release created
2+
3+
on:
4+
release:
5+
types: [created]
6+
7+
jobs:
8+
publish-npm:
9+
name: Publish on NPM
10+
runs-on: ubuntu-latest
11+
12+
steps:
13+
- name: Checkout
14+
uses: actions/checkout@v2
15+
16+
- name: Setup Node.js 16
17+
uses: actions/setup-node@v1
18+
with:
19+
node-version: 16
20+
registry-url: https://registry.npmjs.org/
21+
22+
- name: Install dependencies
23+
run: npm ci
24+
25+
- name: Publish on NPM
26+
run: npm publish
27+
env:
28+
NODE_AUTH_TOKEN: ${{secrets.npm_token}}
29+
30+
publish-gpr:
31+
name: Publish on Github Packages
32+
runs-on: ubuntu-latest
33+
34+
steps:
35+
- name: Checkout
36+
uses: actions/checkout@v2
37+
38+
- name: Setup Node.js 16
39+
uses: actions/setup-node@v1
40+
with:
41+
node-version: 16
42+
registry-url: https://npm.pkg.github.com/
43+
scope: '@greepthesheep'
44+
45+
- name: Install dependencies
46+
run: npm ci
47+
48+
- name: Publish on Github Packages
49+
run: npm publish --registry=https://npm.pkg.github.com/@greepthesheep
50+
env:
51+
NODE_AUTH_TOKEN: ${{secrets.gh_token}}

.github/workflows/test.yml

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
name: Unit Tests
2+
3+
on:
4+
push:
5+
branches:
6+
- main
7+
paths:
8+
- 'src/**.js'
9+
- 'test/**.test.js'
10+
pull_request:
11+
branches:
12+
- main
13+
paths:
14+
- 'src/**.js'
15+
- 'test/**.test.js'
16+
workflow_dispatch:
17+
18+
jobs:
19+
test:
20+
name: Unit Tests
21+
runs-on: ubuntu-latest
22+
23+
steps:
24+
- name: Checkout repository
25+
uses: actions/checkout@v2
26+
27+
- name: Install Node v16
28+
uses: actions/setup-node@v2
29+
with:
30+
node-version: 16
31+
cache: npm
32+
33+
- name: Install dependencies
34+
run: npm ci
35+
36+
- name: Run tests
37+
run: npm test

.vscode/launch.json

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
{
2+
// Use IntelliSense to learn about possible attributes.
3+
// Hover to view descriptions of existing attributes.
4+
// For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387
5+
"version": "0.2.0",
6+
"configurations": [
7+
{
8+
"type": "node",
9+
"request": "launch",
10+
"name": "Launch Program",
11+
"skipFiles": [
12+
"<node_internals>/**"
13+
],
14+
"program": "${file}"
15+
}
16+
]
17+
}

README.md

Lines changed: 67 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,67 @@
1-
# node-tm-essentials
2-
A lightweight library in Node.js that provides formatting features and little additions for any development related to Trackmania.
1+
# Trackmania Essentials (for Node.js)
2+
3+
[![npm](https://img.shields.io/npm/v/tm-essentials?logo=npm&style=for-the-badge)](https://npmjs.com/tm-essentials)
4+
[![GitHub release](https://img.shields.io/github/v/release/GreepTheSheep/node-tm-essentials?logo=github&style=for-the-badge)](https://github.com/GreepTheSheep/node-tm-essentials/releases/latest)
5+
6+
A light-weight library that provides formatting features for Trackmania games.
7+
8+
## Text formatting
9+
10+
`TextFormatter.deformat()`
11+
12+
```js
13+
let formatted = "$F00T$D01M$C13U$A14.$815K$727r$528a$329z$23By$03CC$03Co$04Bl$059o$068r$077s$085 $094v$0A30$0B1.$0C01";
14+
let deformatted = TextFormatter.deformat(formatted);
15+
console.log(deformatted);
16+
17+
// Output: TMU.KrazyColors v0.1
18+
```
19+
20+
`TextFormatter.formatAnsi()`
21+
22+
Will parse the color formatting and convert it to ANSI escape codes. Works best on console output.
23+
24+
```js
25+
let formatted = "$F00T$D01M$C13U$A14.$815K$727r$528a$329z$23By$03CC$03Co$04Bl$059o$068r$077s$085 $094v$0A30$0B1.$0C01";
26+
let ansiFormat = TextFormatter.formatAnsi(formatted);
27+
console.log(deformatted);
28+
```
29+
30+
This will not deformat basic formatting codes, but you can combine them with `TextFormatter.deformat()` to get the original text.
31+
32+
```js
33+
let formatted = "$F00T$D01M$C13U$A14.$815K$727r$528a$329z$23By$03CC$03Co$04Bl$059o$068r$077s$085 $094v$0A30$0B1.$0C01";
34+
let ansiFormat = TextFormatter.deformat(TextFormatter.formatAnsi(formatted));
35+
console.log(deformatted);
36+
```
37+
38+
## Time formatting
39+
40+
`Time.time` - Total milliseconds as integer value.
41+
42+
`Time.toTmString()`
43+
44+
```js
45+
Time.fromMilliseconds(1337).toTmString(); // "0:01.337"
46+
Time.fromMilliseconds(1337).toTmString(true); // Will use hundredths as output: "0:01.33"
47+
48+
Time.fromSeconds(13.37).toTmString(); // "0:13.370"
49+
Time.fromMinutes(13.37).toTmString(); // "13:37.000"
50+
Time.fromHours(13.37).toTmString(); // "13:37:00.000"
51+
52+
Time.noTime.toTmString(); // "-:--.---"
53+
```
54+
55+
## Accounts formatting
56+
57+
`Accounts.toAccountId()`
58+
59+
```js
60+
Accounts.toAccountId("Jtmn3kBnSSadky_mLNhp_A") // "26d9a7de-4067-4926-9d93-2fe62cd869fc"
61+
```
62+
63+
`Accounts.toLogin()`
64+
65+
```js
66+
Accounts.toLogin("26d9a7de-4067-4926-9d93-2fe62cd869fc") // "Jtmn3kBnSSadky_mLNhp_A"
67+
```

0 commit comments

Comments
 (0)