Skip to content

Commit

Permalink
feat(api): add new/move type aliases into api.ts
Browse files Browse the repository at this point in the history
- Fn, FnAny, Pair, SEMAPHORE
  • Loading branch information
postspectacular committed Aug 9, 2018
1 parent c9ac981 commit cf30ba2
Showing 1 changed file with 17 additions and 0 deletions.
17 changes: 17 additions & 0 deletions packages/api/src/api.ts
Expand Up @@ -4,6 +4,8 @@ export const EVENT_ALL = "*";
export const EVENT_ENABLE = "enable";
export const EVENT_DISABLE = "disable";

export const SEMAPHORE = Symbol();

/**
* Generic 2-element comparator function type alias. Must follow this
* contract and return:
Expand All @@ -14,6 +16,16 @@ export const EVENT_DISABLE = "disable";
*/
export type Comparator<T> = (a: T, b: T) => number;

/**
* A single arg function from A => B.
*/
export type Fn<A, B> = (x: A) => B;

/**
* A vararg arg function to type T.
*/
export type FnAny<T> = (...xs: any[]) => T;

/**
* Event listener.
*/
Expand All @@ -24,6 +36,11 @@ export type Listener = (e: Event) => void;
*/
export type Path = PropertyKey | PropertyKey[];

/**
* A key-value pair / tuple.
*/
export type Pair<K, V> = [K, V];

/**
* Predicate function mapping given value to true/false.
*/
Expand Down

0 comments on commit cf30ba2

Please sign in to comment.