icssc / anteater-api

API that provides easy access to public data from UC Irvine. Developed for Anteaters, by Anteaters.
https://anteaterapi.com/reference
GNU Affero General Public License v3.0
3 stars 0 forks source link

Upgrade to Node 22 and clean up relevant code #32

Open ecxyzzy opened 1 week ago

ecxyzzy commented 1 week ago

Node.js 22 has just hit LTS, bringing with it some additional goodies like support for Iterator.toArray and Iterator.map.

We're also no longer constrained to Node 20, since Cloudflare has confirmed that using their codegen for types (which we are) means we do not need to pin the @types/node package to v20, so we can actually upgrade to Node 22.

Context

This will be useful in cleaning up components of our data pipelines, since we use the following pattern a lot:

const theMap = new Map<string, unknown>();

const res = Array.from(theMap.keys()).map((key) => { ... });

Which can then be converted into this pattern:

const theMap = new Map<string, unknown>();

// toArray can even be omitted in cases where the function consuming res accepts an Iterator
const res = theMap.keys().map((key) => { ... }).toArray();

Action Items