This repository hosts some TypeScript algorithms which are licensed under the Unlicense, and therefore released into the public domain. This repository showcases how to write useful code in TypeScript, and the code can be used freely by anyone for any reason.
The NPM package has no dependences other than devDependences
, and the code is
designed to work in any
ECMAScript 2015
environment with a recent stable TypeScript compiler.
Code for all of the algorithms below can be viewed by clicking on them, and tests showing examples of how to use them can be viewed by clicking the wrenches.
Return x
, but throw if x
is null
or undefined
.
An optional message
can be provided for showing if x
turns out to be null
or undefined
.
Create a comparison function for sorting Arrays by particular keys.
Pick a subset of keys from an object.
Create an Array with repeated elements removed.
To run all of the tests on Unix, run ./run-tests
, and hopefully everything
should go well. You will need to have yarn installed on
your system. You should see the results in your browser.