diff --git a/.vscode/settings.json b/.vscode/settings.json index cbac569..974a2b4 100644 --- a/.vscode/settings.json +++ b/.vscode/settings.json @@ -1,3 +1,3 @@ { - "deno.enable": true + "deno.enable": false } diff --git a/robo-readme.pdf b/robo-readme.pdf new file mode 100644 index 0000000..57a347f Binary files /dev/null and b/robo-readme.pdf differ diff --git a/src/08-code-organisation/deno.json b/src/08-code-organisation/deno.json new file mode 100644 index 0000000..f612c5f --- /dev/null +++ b/src/08-code-organisation/deno.json @@ -0,0 +1,10 @@ +{ + "tasks": { + "dev": "deno run --watch ./src/main.ts" + }, + "imports": { + "@std/assert": "jsr:@std/assert@1", + "date-fns": "npm:date-fns" + } +} + diff --git a/src/08-code-organisation/deno.lock b/src/08-code-organisation/deno.lock new file mode 100644 index 0000000..aec4ad5 --- /dev/null +++ b/src/08-code-organisation/deno.lock @@ -0,0 +1,30 @@ +{ + "version": "5", + "specifiers": { + "jsr:@std/assert@1": "1.0.11", + "jsr:@std/internal@^1.0.5": "1.0.5", + "npm:date-fns@*": "4.1.0" + }, + "jsr": { + "@std/assert@1.0.11": { + "integrity": "2461ef3c368fe88bc60e186e7744a93112f16fd110022e113a0849e94d1c83c1", + "dependencies": [ + "jsr:@std/internal" + ] + }, + "@std/internal@1.0.5": { + "integrity": "54a546004f769c1ac9e025abd15a76b6671ddc9687e2313b67376125650dc7ba" + } + }, + "npm": { + "date-fns@4.1.0": { + "integrity": "sha512-Ukq0owbQXxa/U3EGtsdVBkR1w7KOQ5gIBqdH2hkvknzZPYvBxb/aa6E8L7tmjFtkwZBu3UXBbjIgPo/Ez4xaNg==" + } + }, + "workspace": { + "dependencies": [ + "jsr:@std/assert@1", + "npm:date-fns@*" + ] + } +} diff --git a/src/08-code-organisation/src/main.ts b/src/08-code-organisation/src/main.ts new file mode 100644 index 0000000..15759c4 --- /dev/null +++ b/src/08-code-organisation/src/main.ts @@ -0,0 +1,6 @@ +import { add, log as alternativLog, log } from '@utils'; + +const today = new Date(); +console.log('Addition: ', add(5, 3)); +log('Hello from Log'); +alternativLog('Hello from alternativ log'); diff --git a/src/08-code-organisation/src/utils/dateUtils.ts b/src/08-code-organisation/src/utils/dateUtils.ts new file mode 100644 index 0000000..af14082 --- /dev/null +++ b/src/08-code-organisation/src/utils/dateUtils.ts @@ -0,0 +1,11 @@ +import { addDays, format } from 'date-fns'; + +const today = new Date(); +// console.log('Heute ist: ', format(today, 'yyyy-MM-dd')); + +const nextWeek = addDays(today, 7); +// console.log('Nächste Woche: ', format(nextWeek, 'yyyy-MM-dd')); + +export const formatDate = (date: Date, formatString = 'yyyy-MM-dd') => { + return format(date, formatString); +}; diff --git a/src/08-code-organisation/src/utils/index.ts b/src/08-code-organisation/src/utils/index.ts new file mode 100644 index 0000000..a993fad --- /dev/null +++ b/src/08-code-organisation/src/utils/index.ts @@ -0,0 +1,3 @@ +export * from './dateUtils.ts'; +export { default as log } from './logger.ts'; +export * from './mathUtils.ts'; diff --git a/src/08-code-organisation/src/utils/logger.ts b/src/08-code-organisation/src/utils/logger.ts new file mode 100644 index 0000000..192bf38 --- /dev/null +++ b/src/08-code-organisation/src/utils/logger.ts @@ -0,0 +1,3 @@ +export default function log(message: string) { + console.log(`Log: ${message}`); +} diff --git a/src/08-code-organisation/src/utils/mathUtils.ts b/src/08-code-organisation/src/utils/mathUtils.ts new file mode 100644 index 0000000..8eb502a --- /dev/null +++ b/src/08-code-organisation/src/utils/mathUtils.ts @@ -0,0 +1,7 @@ +export function add(a: number, b: number): number { + return a + b; +} + +export function sub(a: number, b: number): number { + return a - b; +} diff --git a/src/08-code-organisation/tsconfig.json b/src/08-code-organisation/tsconfig.json new file mode 100644 index 0000000..0877a8a --- /dev/null +++ b/src/08-code-organisation/tsconfig.json @@ -0,0 +1,18 @@ +{ + "compilerOptions": { + "baseUrl": ".", + "paths": { + "@/*": ["./src"], + "@utils": ["./src/utils/index.ts"] + }, + + "target": "es2016", + + "module": "ESNext", + "esModuleInterop": true, + "forceConsistentCasingInFileNames": true, + + "strict": true, + "skipLibCheck": true + } +}