Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/w0rp/typescript-algorithms
Public domain TypeScript algorithms
https://github.com/w0rp/typescript-algorithms
Last synced: 3 months ago
JSON representation
Public domain TypeScript algorithms
- Host: GitHub
- URL: https://github.com/w0rp/typescript-algorithms
- Owner: w0rp
- License: unlicense
- Created: 2019-06-07T12:25:58.000Z (over 5 years ago)
- Default Branch: master
- Last Pushed: 2021-05-21T15:24:24.000Z (over 3 years ago)
- Last Synced: 2023-04-11T13:58:20.830Z (over 1 year ago)
- Language: TypeScript
- Size: 21.5 KB
- Stars: 8
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# TypeScript Algorithms
[![Travis CI Build Status](https://travis-ci.com/w0rp/typescript-algorithms.svg?branch=master)](https://travis-ci.com/w0rp/typescript-algorithms)
This repository hosts some TypeScript algorithms which are licensed under the
[Unlicense](https://unlicense.org/), 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](https://www.ecma-international.org/ecma-262/6.0/)
environment with a recent stable TypeScript compiler.## Algorithms
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.### notNull
[`notNull(x, message?)`](src/not-null.ts) [:wrench:](src/not-null.spec.ts)
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`.### orderBy
[`orderBy(cb)`](src/order-by.ts) [:wrench:](src/order-by.spec.ts)
Create a comparison function for sorting Arrays by particular keys.
### pick
[`pick(obj, ...keys)`](src/pick.ts) [:wrench:](src/pick.spec.ts)
Pick a subset of keys from an object.
### uniq
[`uniq(array, cmp)`](src/uniq.ts) [:wrench:](src/uniq.spec.ts)
Create an Array with repeated elements removed.
## Running tests
To run all of the tests on Unix, run `./run-tests`, and hopefully everything
should go well. You will need to have [yarn](https://yarnpkg.com) installed on
your system. You should see the results in your browser.