TodePond / Airspace

javascript library by the dreamberd foundation
MIT License
26 stars 2 forks source link

Add an Initial Implementation Matching the README Spec including a fully functioning Example Page. #3

Open danm36 opened 1 year ago

danm36 commented 1 year ago

Commit

Here's an initial version of the most perfect library known to berdkind - Airspace!

This commit includes a 99% functioning version of Airspace that matches the spec as detailed in README.md, as well as an example HTML page you can run locally to execute the code directly - covering everything listed in said README. Learnt a few...interesting design decisions about JS myself building this, something I'm sure I could use to greatly upset my colleagues.

Simply pull down the repo, drag the HTML file in the examples folder into your browser and give it a play! There's no need for any of that compiling fluff, no importing or exporting or requiring. All you need to do to include Airspace in your project is add a script tag pointing to the JS file like a good ol' 2006 JS library. It even polluts the global object and everything! I did include a package.json and a d.ts for completeness sake - the .d.ts simply adds the extra debug and execute literals to the primitive JS types - but it's all fully runnable by just importing airspace.js as-is.

Oh, only tested on Firefox, but I'd be shocked if Chromium browsers don't like it.

Bugs

print.x "abcde"
[3, 2].d

This prints out 'c' as the debug line is actually indexing the string "abcde" on the prior line. To fix this, you need to make sure either the prior line ends in a colon or half-colon, or the line with the array starts with a pre-colon.

print.x "abcde";;
[3, 2].d

and

print.x "abcde"
;;[3, 2].d

both work.

Compromises

1234.d

This doesn't work for JS syntax reasons, since 'd' isn't a valid numeric value. Do the following instead:

(1234).d

Note: Like the arrays issue above, you have to make sure the prior line ends in a colon or half-colon, or that this line starts with a pre-colon, otherwise it will try to execute the prior line as a function.

This code is ugly

Yep. I might neaten it up in the future, but for now I wanted to get the true early-JS feeling with no TypeScript, no modules, no build step, just a big chonky file of raw JS. I could definitely see Airspace get modularized, TypeScriptified and more in the future.

Also, using CSS to display the Githubissues.

  • Githubissues is a development platform for aggregating issues.