Avatar

tmcw

👷 Building Val Town
Joined August 31, 2022
Public vals
167
tmcw avatar
tmcw
arenaApiExample
Script
Are.na API Example of using the are.na API to get the contents of an Are.na board - specifically my fun board that showcases websites with that "glossy black style." All you need is fetch to make this happen!
0
tmcw avatar
tmcw
joseExample
Script
JWTs with JOSE This is an example of using the jose module to generate a JSON Web Token . JSON web tokens you can use for authenticating requests and all kinds of unusual things.
0
tmcw avatar
tmcw
kyExample
Script
ky The ky module is a nice abstraction around the fetch API , which is easily compatible with Deno. It's by the same creator as got , which more explicitly targets Node.js. Most of the time, the fetch method is all you need! But in a pinch, you can use ky to make things a little fancier.
0
tmcw avatar
tmcw
evaluationFromValExample
Script
Val Town API: unauthenticated eval This val runs a val by using the Val Town API and returns the result of its evaluation.
0
tmcw avatar
tmcw
valTownApiExampleVal
Script
Val Town API: Find a val by handle and name This val fetches itself via the Val Town API ! Weird, right?
4
tmcw avatar
tmcw
valTownApiExampleUser
Script
Val Town API: Find a user by their handle This demonstrates how to use the Val Town API to find a user.
0
tmcw avatar
tmcw
valTownApiExampleSearch
Script
Val Town API Search This demonstrates how to use the Val Town API to search for vals that mention "lodash".
0
tmcw avatar
tmcw
sha256Example
Script
Creating a SHA-256 hash of a string This example shows how you can hash a string using SHA-256 without using any NPM modules – just web standards! Adapted from an example on MDN .
0
tmcw avatar
tmcw
randomUUIDExample
Script
Get a random UUID This val demonstrates how you can get a random UUID without even importing the uuid module .
0
tmcw avatar
tmcw
parseEnglishExample
Script
nclst The nclst tree format is an extremely useful tree structure used for natural language processing. This is an example of parsing a string of English text into a syntax tree.
0
tmcw avatar
tmcw
xastscriptExample
Script
xastscript xastscript is a great way to safely generate XML from within JavaScript - it provides a sort of 'Domain Specific Language' for building XML trees, and then you can encode that into XML using xast-util-to-xml . For example, we at Val Town use xastscript and these utilities to generate our sitemap.xml file for Google to discover vals.
0
tmcw avatar
tmcw
hastscriptExample
Script
hastscript hastscript is a way to create 'HTML trees' - then you can translate that tree into HTML using hast-util-to-html . It's pretty neat and straightforward to use in Val Town because it supports ESM exports.
0
tmcw avatar
tmcw
litExample
Script
lit Lit is kind of like Google's answer to React: it's a little more reliant on browser APIs like custom elements and the shadow DOM, a little less 'magic', like using JSX. This is an example of using Lit and rendering it straight to a string, which is something that's recently popular. It works pretty well, right off the bat: Lit provides nice ESM modules and a pretty smooth workflow!
0
tmcw avatar
tmcw
qsExample
Script
qs QS is a pretty old module that you probably shouldn't use but it's still pretty heavily used. In the very very early days there wasn't a built-in way in JavaScript to parse querystrings. So QS was born. But then, Node.js added a querystring module built-in. Then, JavaScript introduced URLSearchParams , which you should use whenever you want to parse or generate query strings.
0
tmcw avatar
tmcw
punycodeExample
Script
punycode punycode is so cool. It's esoteric, but like, it's amazing what ingenuity can do. It's an encoding of UTF-8 - the kind of text with easy representations for unicode sequences like ñ - in ASCII - the one that just supports English. It does this in a way that's reversible, and lets us use UTF8 text in ASCII places, because you can also detect when something is written in punycode. Do you need this, probably not – but someday you will, and you will remember.
0
tmcw avatar
tmcw
acornExample
Script
acorn Acorn is a JavaScript parser written in JavaScript! It's one of the most established, and best, options - written by the same main contributor as CodeMirror and ProseMirror. At Val Town, we use Acorn internally, as well as CodeMirror for the code editor. With Acorn, you can parse JavaScript, modify it, and generate strings from that parsed JavaScript. It's a lot more robust and productive than processing source code as strings.
0