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)

  1. install nvm from your package manager
  2. add
     . /usr/share/nvm/init-nvm.sh
    

    to 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

  1. package the module into a .tgz:
    npm pack
    
  2. 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];
    
  • concat method:

     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 X
  • OBJ instanceof TYPE

Integer to string and vice versa

int.toString();
parseInt(str, base);