Avatar

tmcw

👷 Building Val Town
Joined August 31, 2022
Public vals
167
tmcw avatar
tmcw
micromarkExample
Script
micromark micromark is a fantastic choice for formatting Markdown : it's tiny, safe, works great with Val Town.
0
tmcw avatar
tmcw
luxonExample
Script
luxon Luxon is, like date-fns , a good option for formatting, parsing, and manipulating dates. It's more of a direct successor to moment and has a similar method-chain-oriented API rather than function-call oriented API like date-fns.
0
tmcw avatar
tmcw
datefnsExample
Script
date-fns date-fns is a much better alternative to moment . It's much smaller, simpler, and easier to use. Plus, it supports ESM - notice how I can just import add and formatRelative here! Use it for all your date needs.
0
tmcw avatar
tmcw
nanoidExample
Script
nanoid nanoid is like a shorter, more fashionable alternative to UUIDs. Versus UUIDs: They're shorter, with a more customizable alphabet. They use more different characters by default. Unlike UUIDs, there aren't custom types for nanoids in databases Nanoids never contain information. UUIDs sometimes do: some UUIDs contain timestamps and MAC addresses.
0
tmcw avatar
tmcw
markedExample
Script
marked marked is a classic Markdown parser in JavaScript. I really don't like it! I don't recommend it! The people who made it and worked on it are great, but I think you really shouldn't use it. It supports a non-standard variation of Markdown, so you can't easily switch to another parser once you've encouraged people to write "in the marked style" It allows but doesn't sanitize HTML, which promotes a lot of XSS attacks It doesn't use an intermediate AST like remark or support plugins. Really it's a much better idea to use micromark or remark .
0
tmcw avatar
tmcw
ramdaExample
Script
ramda ramda is a module like lodash or underscore but with a much heavier emphasis on functional programming. It lets you do the same kind of things but in a much 🌶️ spicier, 💪 more macho, 🤔 sometimes confusing style. I was really into this module in my late 20s.
0
tmcw avatar
tmcw
handlebarsExample
Script
An interactive, runnable TypeScript val by tmcw
0
tmcw avatar
tmcw
semverExample
Script
semver The semver module is the most popular way to parse the Semantic Versioning style of versions. Semantic Versions attempt to convey a lot more information about a version than just a single number - each part of the version indicates breaking changes, features, or minor updates.
0
tmcw avatar
tmcw
jsYAMLExample
Script
js-yaml YAML is a popular format for data which is an alternative to JSON . In contrast to JSON, YAML can look more user-friendly: you can write text without worrying about quoting strings You can write comments in YAML But, on the other side, it's more possible to write YAML that is parsed in an unexpected way. JSON is more explicit and predictable. js-yaml is the most popular YAML parser for JavaScript.
0
tmcw avatar
tmcw
cheerioExample
Script
cheerio cheerio is a popular npm module that makes it easy to parse and manipulate HTML and XML. cheerio is modeled after a reduced version of jQuery . Note that it's pretty different than default browser DOM methods, so you can't call things like .appendChild or document.createElement when using cheerio: it's not based on a full-fledged DOM or browser implementation. But, in exchange it's a lot faster and simpler.
0
tmcw avatar
tmcw
uuidExample
Script
uuid The uuid module provides builders for different types of universally unique identifiers . These are kinds of identifiers that you can use instead of auto-incrementing integers. They're intended to contain so much randomness that the chances of a collision between two uuids is very low. There are different versions of uuids available: typically people use v4 UUIDs, which are fully random.
0
tmcw avatar
tmcw
underscoreExample
Script
underscore underscore is a module for functional programming and other utilities in JavaScript. It inspired lodash , which is what most people use now, because lodash is both faster, and provides an ESM version which is convenient to use in Val Town. Note that while we can import from lodash-es and use its named exports, underscore only provides a default export, so that's why we have the code { default: _ } below.
0
tmcw avatar
tmcw
momentExample
Script
moment moment is a module that helps you do math and formatting with dates and times in JavaScript. It's a pretty old and large module, though: if you're writing new code, you probably want to use luxon or date-fns instead!
0
tmcw avatar
tmcw
chalkExample
Script
chalk chalk is a very popular module for colorizing terminal output. In Val Town, it doesn't colorize the output of vals because it detects correctly that we don't support colorized logs yet. We've filed an issue internally to support colorized logs!
0
tmcw avatar
tmcw
lodashExample
Script
lodash Lodash is the most popular npm module. It provides helpers for functional programming, common algorithms, and a lot more. Before JavaScript had built-in methods for Array.map , lodash (and underscore before it) provided those methods.
0
tmcw avatar
tmcw
getTheTime
Script
An interactive, runnable TypeScript val by tmcw
0