Web development notes
Modern web dev stuff I am, after all, learning while working on a WYTIWYS (What You Tree Is What You Search) corpus query interface.
Nodenotes
Setting up nvm (Node Version Manager)
- install
nvmfrom your package manager - add
. /usr/share/nvm/init-nvm.shto the shell config file.
Installing version n of Node
nvm install n
Using version n of Node
nvm use n
Installing a TypeScript project
npm install
Using a local module in a TypeScript project
- package the module into a
.tgz:npm pack - move to the project folder and install the package:
npm install --save PATH-TO-TGZ
TypeScript
Array concatenation
Given
const a: number[] = [1, 2];
const b: number[] = [3, 4];
const c: number[] = [5];
-
spread operator:
const abc = [...a, ...b, ...c]; -
concatmethod:const abc = a.concat(b).concat(c);but also:
const abc = a.concat(b, c);and even:
const abc = a.concat(3, 4, 5); // wild!
Last element of an array
xs.slice(-1)[0]
Introspection
Two operators:
typeof XOBJ instanceof TYPE
Integer to string and vice versa
int.toString();
parseInt(str, base);