commit 9023e01
Artur Manuel
·
2025-07-06 13:57:18 +0000 UTC
parent a5b0328
feat(typescript): init typescript
5 files changed,
+206,
-0
+139,
-0
1@@ -0,0 +1,139 @@
2+# Logs
3+logs
4+*.log
5+npm-debug.log*
6+yarn-debug.log*
7+yarn-error.log*
8+lerna-debug.log*
9+
10+# Diagnostic reports (https://nodejs.org/api/report.html)
11+report.[0-9]*.[0-9]*.[0-9]*.[0-9]*.json
12+
13+# Runtime data
14+pids
15+*.pid
16+*.seed
17+*.pid.lock
18+
19+# Directory for instrumented libs generated by jscoverage/JSCover
20+lib-cov
21+
22+# Coverage directory used by tools like istanbul
23+coverage
24+*.lcov
25+
26+# nyc test coverage
27+.nyc_output
28+
29+# Grunt intermediate storage (https://gruntjs.com/creating-plugins#storing-task-files)
30+.grunt
31+
32+# Bower dependency directory (https://bower.io/)
33+bower_components
34+
35+# node-waf configuration
36+.lock-wscript
37+
38+# Compiled binary addons (https://nodejs.org/api/addons.html)
39+build/Release
40+
41+# Dependency directories
42+node_modules/
43+jspm_packages/
44+
45+# Snowpack dependency directory (https://snowpack.dev/)
46+web_modules/
47+
48+# TypeScript cache
49+*.tsbuildinfo
50+
51+# Optional npm cache directory
52+.npm
53+
54+# Optional eslint cache
55+.eslintcache
56+
57+# Optional stylelint cache
58+.stylelintcache
59+
60+# Optional REPL history
61+.node_repl_history
62+
63+# Output of 'npm pack'
64+*.tgz
65+
66+# Yarn Integrity file
67+.yarn-integrity
68+
69+# dotenv environment variable files
70+.env
71+.env.*
72+!.env.example
73+
74+# parcel-bundler cache (https://parceljs.org/)
75+.cache
76+.parcel-cache
77+
78+# Next.js build output
79+.next
80+out
81+
82+# Nuxt.js build / generate output
83+.nuxt
84+dist
85+
86+# Gatsby files
87+.cache/
88+# Comment in the public line in if your project uses Gatsby and not Next.js
89+# https://nextjs.org/blog/next-9-1#public-directory-support
90+# public
91+
92+# vuepress build output
93+.vuepress/dist
94+
95+# vuepress v2.x temp and cache directory
96+.temp
97+.cache
98+
99+# Sveltekit cache directory
100+.svelte-kit/
101+
102+# vitepress build output
103+**/.vitepress/dist
104+
105+# vitepress cache directory
106+**/.vitepress/cache
107+
108+# Docusaurus cache and generated files
109+.docusaurus
110+
111+# Serverless directories
112+.serverless/
113+
114+# FuseBox cache
115+.fusebox/
116+
117+# DynamoDB Local files
118+.dynamodb/
119+
120+# Firebase cache directory
121+.firebase/
122+
123+# TernJS port file
124+.tern-port
125+
126+# Stores VSCode versions used for testing VSCode extensions
127+.vscode-test
128+
129+# yarn v3
130+.pnp.*
131+.yarn/*
132+!.yarn/patches
133+!.yarn/plugins
134+!.yarn/releases
135+!.yarn/sdks
136+!.yarn/versions
137+
138+# Vite logs files
139+vite.config.js.timestamp-*
140+vite.config.ts.timestamp-*
+8,
-0
1@@ -0,0 +1,8 @@
2+{
3+ "tasks": {
4+ "dev": "deno run --watch main.ts"
5+ },
6+ "imports": {
7+ "@std/assert": "jsr:@std/assert@1"
8+ }
9+}
+23,
-0
1@@ -0,0 +1,23 @@
2+{
3+ "version": "4",
4+ "specifiers": {
5+ "jsr:@std/assert@1": "1.0.13",
6+ "jsr:@std/internal@^1.0.6": "1.0.9"
7+ },
8+ "jsr": {
9+ "@std/assert@1.0.13": {
10+ "integrity": "ae0d31e41919b12c656c742b22522c32fb26ed0cba32975cb0de2a273cb68b29",
11+ "dependencies": [
12+ "jsr:@std/internal"
13+ ]
14+ },
15+ "@std/internal@1.0.9": {
16+ "integrity": "bdfb97f83e4db7a13e8faab26fb1958d1b80cc64366501af78a0aee151696eb8"
17+ }
18+ },
19+ "workspace": {
20+ "dependencies": [
21+ "jsr:@std/assert@1"
22+ ]
23+ }
24+}
+24,
-0
1@@ -0,0 +1,24 @@
2+export function collatz(a: number): number {
3+ if (a % 2 == 0)
4+ return Math.floor(a / 2);
5+ return 3 * a + 1;
6+}
7+
8+export function collatzSequence(a: number): string {
9+ let result: string = `${a}: `;
10+ for (let i = a; i >= 1; i = collatz(i)) {
11+ if (i == 1) {
12+ result += "1";
13+ break;
14+ }
15+ result += `${i}, `;
16+ }
17+ return result;
18+}
19+
20+// Learn more at https://docs.deno.com/runtime/manual/examples/module_metadata#concepts
21+if (import.meta.main) {
22+ for (let i = 1; i <= 10000; i++) {
23+ console.log(collatzSequence(i));
24+ }
25+}
+12,
-0
1@@ -0,0 +1,12 @@
2+import { assertEquals } from "@std/assert";
3+import { collatz, collatzSequence } from "./main.ts";
4+
5+Deno.test(function collatzTest() {
6+ assertEquals(collatz(1), 4);
7+ assertEquals(collatz(2), 1);
8+});
9+
10+Deno.test(function collatzSequenceTest() {
11+ assertEquals(collatzSequence(1), "1: 1");
12+ assertEquals(collatzSequence(4), "4: 4, 2, 1");
13+});