Skip to content

Commit

Permalink
format + internal
Browse files Browse the repository at this point in the history
  • Loading branch information
sgratzl committed Dec 21, 2018
1 parent 9eb26b0 commit aa53413
Show file tree
Hide file tree
Showing 7 changed files with 166 additions and 19 deletions.
2 changes: 1 addition & 1 deletion src/internal/AEventDispatcher.ts
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ export default class AEventDispatcher implements IEventHandler {
this.listenersChanged(d, Boolean(listener!));
this.listeners.on(d, listener!);
} else if (__DEBUG__ && !d.includes('.')) {
console.warn(this, 'invalid event type', d);
console.warn(this, 'invalid event type', d);
}
});
} else if (this.listenerEvents.has((<string>type).split('.')[0])) {
Expand Down
6 changes: 3 additions & 3 deletions src/internal/dnd.ts
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ export function hasDnDType(e: DragEvent, ...typesToCheck: string[]) {
* helper storage for dnd in edge since edge doesn't support custom mime-types
* @type {Map<number, {[p: string]: string}>}
*/
const dndTransferStorage = new Map<number, { [key: string]: string }>();
const dndTransferStorage = new Map<number, {[key: string]: string}>();

function isEdgeDnD(e: DragEvent) {
return dndTransferStorage.size > 0 && hasDnDType(e, 'text/plain');
Expand Down Expand Up @@ -63,13 +63,13 @@ export type IDragEffect = 'none' | 'copy' | 'copyLink' | 'copyMove' | 'link' | '
/** @internal */
export interface IDragStartResult {
effectAllowed: IDragEffect;
data: { [mimeType: string]: string };
data: {[mimeType: string]: string};
}

/** @internal */
export interface IDropResult {
effect: IDragEffect;
data: { [mimeType: string]: string };
data: {[mimeType: string]: string};
}

let idCounter = 0;
Expand Down
12 changes: 6 additions & 6 deletions src/internal/drag.ts
Original file line number Diff line number Diff line change
@@ -1,19 +1,19 @@

/** @internal */
export interface IDragHandleOptions {
container: HTMLElement|SVGElement;
container: HTMLElement | SVGElement;
filter(evt: MouseEvent): boolean;
onStart(handle: HTMLElement|SVGElement, x: number, delta: number, evt: MouseEvent): void;
onDrag(handle: HTMLElement|SVGElement, x: number, delta: number, evt: MouseEvent): void;
onEnd(handle: HTMLElement|SVGElement, x: number, delta: number, evt: MouseEvent): void;
onStart(handle: HTMLElement | SVGElement, x: number, delta: number, evt: MouseEvent): void;
onDrag(handle: HTMLElement | SVGElement, x: number, delta: number, evt: MouseEvent): void;
onEnd(handle: HTMLElement | SVGElement, x: number, delta: number, evt: MouseEvent): void;
minDelta: number;
}

/**
* allow to change the width of a column using dragging the handle
* @internal
*/
export function dragHandle(handle: HTMLElement|SVGElement, options: Partial<IDragHandleOptions> = {}) {
export function dragHandle(handle: HTMLElement | SVGElement, options: Partial<IDragHandleOptions> = {}) {
const o: Readonly<IDragHandleOptions> = Object.assign({
container: handle.parentElement!,
filter: () => true,
Expand All @@ -23,7 +23,7 @@ export function dragHandle(handle: HTMLElement|SVGElement, options: Partial<IDra
minDelta: 2
}, options);

const toContainerRelative = (x: number, elem: HTMLElement|SVGElement) => {
const toContainerRelative = (x: number, elem: HTMLElement | SVGElement) => {
const rect = elem.getBoundingClientRect();
return x - rect.left - elem.clientLeft;
};
Expand Down
15 changes: 15 additions & 0 deletions src/internal/interable.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,9 @@ export interface IForEachAble<T> extends Iterable<T> {
forEach(callback: (v: T, i: number) => void): void;
}

/**
* @internal
*/
export function isForEachAble<T>(v: IForEachAble<T> | any): v is IForEachAble<T> {
return typeof v.forEach === 'function';
}
Expand All @@ -17,10 +20,16 @@ export interface ISequence<T> extends IForEachAble<T> {
reduce<U>(callback: (acc: U, v: T, i: number) => U, initial: U): U;
}

/**
* @internal
*/
export function isSeqEmpty(seq: ISequence<any>) {
return seq.every(() => false); // more efficent than counting length
}

/**
* @internal
*/
export function isIndicesAble<T>(it: Iterable<T>): it is ArrayLike<T> & Iterable<T> {
return Array.isArray(it) || it instanceof Uint8Array || it instanceof Uint16Array || it instanceof Uint32Array || it instanceof Float32Array || it instanceof Int8Array || it instanceof Int16Array || it instanceof Int32Array || it instanceof Float64Array;
}
Expand Down Expand Up @@ -482,6 +491,9 @@ class LazySeq<T> implements ISequence<T> {
}
}

/**
* @internal
*/
export function lazySeq<T>(iterable: Iterable<T>): ISequence<T> {
return new LazySeq(iterable);
}
Expand Down Expand Up @@ -540,6 +552,9 @@ class ConcatSequence<T> implements ISequence<T> {
}
}

/**
* @internal
*/
export function concatSeq<T>(seqs: ISequence<ISequence<T>>): ISequence<T>;
export function concatSeq<T>(seq1: ISequence<T>, seq2: ISequence<T>, ...seqs: ISequence<T>[]): ISequence<T>;
export function concatSeq<T>(seq1: ISequence<T>[] | ISequence<T>, seq2?: ISequence<T>, ...seqs: ISequence<T>[]): ISequence<T> {
Expand Down
Loading

0 comments on commit aa53413

Please sign in to comment.