-
Notifications
You must be signed in to change notification settings - Fork 14
Expand file tree
/
Copy pathempty.ts
More file actions
27 lines (26 loc) · 1.47 KB
/
empty.ts
File metadata and controls
27 lines (26 loc) · 1.47 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
import { ComparatorFn, KeyedSelectorFn, MutationContext, isBoolean, isMutationContext } from '@collectable/core';
import { SortedMapEntry, SortedMapStructure, emptySortedMap } from '../internals';
export function empty<K, V> (compare?: ComparatorFn<SortedMapEntry<K, V, undefined>>): SortedMapStructure<K, V>;
export function empty<K, V, U> (compare: ComparatorFn<SortedMapEntry<K, V, U>>, select: KeyedSelectorFn<V, K, U>): SortedMapStructure<K, V>;
export function empty<K, V> (mutable: boolean|MutationContext, compare?: ComparatorFn<SortedMapEntry<K, V, undefined>>): SortedMapStructure<K, V>;
export function empty<K, V, U> (mutable: boolean|MutationContext, compare: ComparatorFn<SortedMapEntry<K, V, U>>, select: KeyedSelectorFn<V, K, U>): SortedMapStructure<K, V>;
export function empty<K, V, U> (
arg0?: boolean|MutationContext|ComparatorFn<SortedMapEntry<K, V, U>>,
arg1?: ComparatorFn<SortedMapEntry<K, V, U>>|KeyedSelectorFn<V, K, U>,
select?: KeyedSelectorFn<V, K, U>
): SortedMapStructure<K, V, U> {
var mutable: boolean|MutationContext;
var compare: ComparatorFn<SortedMapEntry<K, V, U>>|undefined;
if(typeof arg0 === 'function') {
compare = arg0;
if(typeof arg1 === 'function') {
select = <KeyedSelectorFn<V, K, U>>arg1;
}
mutable = false;
}
else {
compare = <ComparatorFn<SortedMapEntry<K, V, U>>>arg1;
mutable = isMutationContext(arg0) || isBoolean(arg0) ? arg0 : false;
}
return emptySortedMap<K, V, U>(compare, select, mutable);
}