add some docstring

This commit is contained in:
Géry Debongnie
2019-03-06 14:52:31 +01:00
parent 7d317a3764
commit 4145a5ebac
3 changed files with 17 additions and 1 deletions
+3
View File
@@ -68,6 +68,9 @@ export class EventBus {
} }
} }
/**
* Remove all subscriptions.
*/
clear() { clear() {
this.subscriptions = {}; this.subscriptions = {};
} }
+10 -1
View File
@@ -27,7 +27,10 @@ export function htmlTrim(s: string): string {
return result; return result;
} }
export function idGenerator(): (() => number) { /**
* Create a function that will generate unique id numbers
*/
export function idGenerator(): () => number {
let nextID = 1; let nextID = 1;
return () => nextID++; return () => nextID++;
} }
@@ -88,6 +91,12 @@ interface Tree<T> {
children: T[]; children: T[];
} }
/**
* Find a node in a tree.
*
* This will traverse the tree (depth first) and return the first child that
* matches the predicate, if any
*/
export function findInTree<T extends Tree<T>>( export function findInTree<T extends Tree<T>>(
tree: T, tree: T,
predicate: (t: T) => boolean predicate: (t: T) => boolean
@@ -3,6 +3,10 @@ import { rpcMixin } from "./rpc_mixin";
import { Widget } from "../widget"; import { Widget } from "../widget";
import { View } from "../views/view"; import { View } from "../views/view";
//------------------------------------------------------------------------------
// Types
//------------------------------------------------------------------------------
export type Context = { [key: string]: any }; export type Context = { [key: string]: any };
export interface CommonActionInfo { export interface CommonActionInfo {