diff --git a/.gitignore b/.gitignore index 496ee2c..91dfed8 100644 --- a/.gitignore +++ b/.gitignore @@ -1 +1,2 @@ -.DS_Store \ No newline at end of file +.DS_Store +node_modules \ No newline at end of file diff --git a/README.md b/README.md new file mode 100644 index 0000000..7c4f72f --- /dev/null +++ b/README.md @@ -0,0 +1,3 @@ +# @nesterow/shortcuts + +Various functions for JS, Go and Jupyter Notebooks. diff --git a/bun.lockb b/bun.lockb new file mode 100755 index 0000000..388cbd8 Binary files /dev/null and b/bun.lockb differ diff --git a/deno.json b/deno.json index 5b320c2..08f662a 100644 --- a/deno.json +++ b/deno.json @@ -1,8 +1,6 @@ { "tasks": { - "dev": "deno run --watch main.ts" }, "imports": { - "@std/assert": "jsr:@std/assert@1" } } diff --git a/deno_tinygo_wasm.ipynb b/deno_tinygo_wasm.ipynb deleted file mode 100644 index e5027a4..0000000 --- a/deno_tinygo_wasm.ipynb +++ /dev/null @@ -1,79 +0,0 @@ -{ - "cells": [ - { - "cell_type": "code", - "execution_count": 7, - "metadata": {}, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "text": [ - "Estimated offset is: 0.982618\n", - "Estimated slope is: 3.000173\n", - "R^2: 0.999999\n", - "2 \n" - ] - }, - { - "data": { - "text/plain": [ - "\u001b[1mnull\u001b[22m" - ] - }, - "execution_count": 7, - "metadata": {}, - "output_type": "execute_result" - } - ], - "source": [ - "import stats from \"./stat/mod.ts\";\n", - "\n", - "stats.example();" - ] - }, - { - "cell_type": "code", - "execution_count": 3, - "metadata": {}, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "text": [ - "2 \u0001\u0002\u0003\n" - ] - }, - { - "data": { - "text/plain": [ - "\u001b[1mnull\u001b[22m" - ] - }, - "execution_count": 3, - "metadata": {}, - "output_type": "execute_result" - } - ], - "source": [] - } - ], - "metadata": { - "kernelspec": { - "display_name": "Deno", - "language": "typescript", - "name": "deno" - }, - "language_info": { - "codemirror_mode": "typescript", - "file_extension": ".ts", - "mimetype": "text/x.typescript", - "name": "typescript", - "nbconvert_exporter": "script", - "pygments_lexer": "typescript", - "version": "5.6.2" - } - }, - "nbformat": 4, - "nbformat_minor": 2 -} diff --git a/main.ts b/main.ts deleted file mode 100644 index 292ce5f..0000000 --- a/main.ts +++ /dev/null @@ -1,8 +0,0 @@ -export function add(a: number, b: number): number { - return a + b; -} - -// Learn more at https://docs.deno.com/runtime/manual/examples/module_metadata#concepts -if (import.meta.main) { - console.log("Add 2 + 3 =", add(2, 3)); -} diff --git a/main_test.ts b/main_test.ts deleted file mode 100644 index 3d981e9..0000000 --- a/main_test.ts +++ /dev/null @@ -1,6 +0,0 @@ -import { assertEquals } from "@std/assert"; -import { add } from "./main.ts"; - -Deno.test(function addTest() { - assertEquals(add(2, 3), 5); -}); diff --git a/mod.ts b/mod.ts new file mode 100644 index 0000000..f67b2c6 --- /dev/null +++ b/mod.ts @@ -0,0 +1 @@ +console.log("Hello via Bun!"); \ No newline at end of file diff --git a/assets/CarPrice_Assignment.csv b/notebooks/assets/CarPrice_Assignment.csv similarity index 100% rename from assets/CarPrice_Assignment.csv rename to notebooks/assets/CarPrice_Assignment.csv diff --git a/assets/cleaned_car_prices.csv b/notebooks/assets/cleaned_car_prices.csv similarity index 100% rename from assets/cleaned_car_prices.csv rename to notebooks/assets/cleaned_car_prices.csv diff --git a/assets/encoded_car_data.csv b/notebooks/assets/encoded_car_data.csv similarity index 100% rename from assets/encoded_car_data.csv rename to notebooks/assets/encoded_car_data.csv diff --git a/data_analytics_js.ipynb b/notebooks/data_analytics_js.ipynb similarity index 100% rename from data_analytics_js.ipynb rename to notebooks/data_analytics_js.ipynb diff --git a/deno_jupyter_bug.ipynb b/notebooks/deno_jupyter_bug.ipynb similarity index 98% rename from deno_jupyter_bug.ipynb rename to notebooks/deno_jupyter_bug.ipynb index 206445f..c24997d 100644 --- a/deno_jupyter_bug.ipynb +++ b/notebooks/deno_jupyter_bug.ipynb @@ -2,7 +2,7 @@ "cells": [ { "cell_type": "code", - "execution_count": 1, + "execution_count": 2, "metadata": {}, "outputs": [ { diff --git a/notebooks/deno_tinygo_wasm.ipynb b/notebooks/deno_tinygo_wasm.ipynb new file mode 100644 index 0000000..1db6ba5 --- /dev/null +++ b/notebooks/deno_tinygo_wasm.ipynb @@ -0,0 +1,59 @@ +{ + "cells": [ + { + "cell_type": "code", + "execution_count": 4, + "metadata": {}, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "\n", + "Linear Regression Line:\n", + "\tEstimated offset is: 1.480586\n", + "\tEstimated slope is: 2.999774\n", + "\tR^2 is: 0.999991\n" + ] + } + ], + "source": [ + "import stats from \"https://l12.xyz/x/shortcuts/raw/stat/mod.ts\";\n", + "\n", + "const xs = [];\n", + "const ys = [];\n", + "\n", + "for (let i = 0; i < 100; i++) {\n", + " xs.push(i);\n", + " ys.push((1 + 3 * i) + Math.random());\n", + "}\n", + "\n", + "const linreg = stats.LinearRegression(xs, ys, [], false);\n", + "const r = stats.RSquared(xs, ys, [], linreg.alpha, linreg.beta);\n", + "\n", + "console.log(\"\\nLinear Regression Line:\");\n", + "console.log(\"\\tEstimated offset is: \", linreg.alpha.toFixed(6));\n", + "console.log(\"\\tEstimated slope is: \", linreg.beta.toFixed(6));\n", + "console.log(\"\\tR^2 is: \", r.toFixed(6));\n" + ] + } + ], + "metadata": { + "kernelspec": { + "display_name": "Deno", + "language": "typescript", + "name": "deno" + }, + "language_info": { + "codemirror_mode": "typescript", + "file_extension": ".ts", + "mimetype": "text/x.typescript", + "name": "typescript", + "nbconvert_exporter": "script", + "pygments_lexer": "typescript", + "version": "5.6.2" + } + }, + "nbformat": 4, + "nbformat_minor": 2 +} diff --git a/package.json b/package.json new file mode 100644 index 0000000..b8d727c --- /dev/null +++ b/package.json @@ -0,0 +1,11 @@ +{ + "name": "@nesterow/shortcuts", + "module": "mod.ts", + "type": "module", + "devDependencies": { + "@types/bun": "latest" + }, + "peerDependencies": { + "typescript": "^5.0.0" + } +} \ No newline at end of file diff --git a/tsconfig.json b/tsconfig.json new file mode 100644 index 0000000..238655f --- /dev/null +++ b/tsconfig.json @@ -0,0 +1,27 @@ +{ + "compilerOptions": { + // Enable latest features + "lib": ["ESNext", "DOM"], + "target": "ESNext", + "module": "ESNext", + "moduleDetection": "force", + "jsx": "react-jsx", + "allowJs": true, + + // Bundler mode + "moduleResolution": "bundler", + "allowImportingTsExtensions": true, + "verbatimModuleSyntax": true, + "noEmit": true, + + // Best practices + "strict": true, + "skipLibCheck": true, + "noFallthroughCasesInSwitch": true, + + // Some stricter flags (disabled by default) + "noUnusedLocals": false, + "noUnusedParameters": false, + "noPropertyAccessFromIndexSignature": false + } +}