mirror of
https://github.com/wassname/DefinitelyTyped.git
synced 2026-09-05 16:10:11 +08:00
Added typings for es6-collections
This commit is contained in:
@@ -0,0 +1,59 @@
|
||||
/// <reference path="es6-collections.d.ts" />
|
||||
|
||||
interface Point { x: number; y: number; }
|
||||
let a: any;
|
||||
let s: string;
|
||||
let b: boolean;
|
||||
let i: number;
|
||||
let pt: Point;
|
||||
let arrayOfPoint: Point[];
|
||||
let arrayOfStringPoint: [string, Point][];
|
||||
let arrayOfPointString: [Point, string][];
|
||||
let map: Map<string, Point>;
|
||||
let set: Set<Point>;
|
||||
let weakMap: WeakMap<Point, string>;
|
||||
let weakSet: WeakSet<Point>;
|
||||
let iteratorOfString: Iterator<String>;
|
||||
let iteratorOfStringPoint: Iterator<[String, Point]>;
|
||||
let iteratorOfPoint: Iterator<Point>;
|
||||
let iteratorOfPointPoint: Iterator<[Point, Point]>;
|
||||
|
||||
map = new Map<string, Point>();
|
||||
map = new Map(arrayOfStringPoint);
|
||||
map.clear();
|
||||
b = map.delete(s);
|
||||
map.forEach((value: Point, key: string, map: Map<string, Point>) => { }, a);
|
||||
pt = map.get(s);
|
||||
b = map.has(s);
|
||||
map = map.set(s, pt);
|
||||
iteratorOfStringPoint = map.entries();
|
||||
iteratorOfString = map.keys();
|
||||
iteratorOfPoint = map.values();
|
||||
i = map.size;
|
||||
|
||||
set = new Set<Point>();
|
||||
set = new Set(arrayOfPoint);
|
||||
set.clear();
|
||||
b = set.delete(pt);
|
||||
set.forEach((value: Point, key: Point, set: Set<Point>) => { }, a);
|
||||
b = set.has(pt);
|
||||
set = set.add(pt);
|
||||
iteratorOfPointPoint = set.entries();
|
||||
iteratorOfPoint = set.keys();
|
||||
iteratorOfPoint = set.values();
|
||||
i = set.size;
|
||||
|
||||
weakMap = new WeakMap<Point, string>();
|
||||
weakMap = new WeakMap(arrayOfPointString);
|
||||
weakMap.clear();
|
||||
b = weakMap.delete(pt);
|
||||
s = weakMap.get(pt);
|
||||
b = weakMap.has(pt);
|
||||
weakMap = weakMap.set(pt, s);
|
||||
|
||||
weakSet = new WeakSet<Point>();
|
||||
weakSet = new WeakSet(arrayOfPoint);
|
||||
weakSet.clear();
|
||||
b = weakSet.delete(pt);
|
||||
b = weakSet.has(pt);
|
||||
weakSet = weakSet.add(pt);
|
||||
@@ -0,0 +1 @@
|
||||
--noImplicitAny --module commonjs --target es5
|
||||
Vendored
+113
@@ -0,0 +1,113 @@
|
||||
// Type definitions for es6-collections v0.5.1
|
||||
// Project: https://github.com/WebReflection/es6-collections/
|
||||
// Definitions by: Ron Buckton <http://github.com/rbuckton>
|
||||
// Definitions: https://github.com/borisyankov/DefinitelyTyped
|
||||
|
||||
/* *****************************************************************************
|
||||
Copyright (c) Microsoft Corporation. All rights reserved.
|
||||
Licensed under the Apache License, Version 2.0 (the "License"); you may not use
|
||||
this file except in compliance with the License. You may obtain a copy of the
|
||||
License at http://www.apache.org/licenses/LICENSE-2.0
|
||||
|
||||
THIS CODE IS PROVIDED *AS IS* BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
||||
KIND, EITHER EXPRESS OR IMPLIED, INCLUDING WITHOUT LIMITATION ANY IMPLIED
|
||||
WARRANTIES OR CONDITIONS OF TITLE, FITNESS FOR A PARTICULAR PURPOSE,
|
||||
MERCHANTABLITY OR NON-INFRINGEMENT.
|
||||
|
||||
See the Apache Version 2.0 License for specific language governing permissions
|
||||
and limitations under the License.
|
||||
***************************************************************************** */
|
||||
|
||||
interface IteratorResult<T> {
|
||||
done: boolean;
|
||||
value?: T;
|
||||
}
|
||||
|
||||
interface Iterator<T> {
|
||||
next(value?: any): IteratorResult<T>;
|
||||
return?(value?: any): IteratorResult<T>;
|
||||
throw?(e?: any): IteratorResult<T>;
|
||||
}
|
||||
|
||||
interface ForEachable<T> {
|
||||
forEach(callbackfn: (value: T) => void): void;
|
||||
}
|
||||
|
||||
interface Map<K, V> {
|
||||
clear(): void;
|
||||
delete(key: K): boolean;
|
||||
forEach(callbackfn: (value: V, index: K, map: Map<K, V>) => void, thisArg?: any): void;
|
||||
get(key: K): V;
|
||||
has(key: K): boolean;
|
||||
set(key: K, value?: V): Map<K, V>;
|
||||
entries(): Iterator<[K, V]>;
|
||||
keys(): Iterator<K>;
|
||||
values(): Iterator<V>;
|
||||
size: number;
|
||||
}
|
||||
|
||||
interface MapConstructor {
|
||||
new <K, V>(): Map<K, V>;
|
||||
new <K, V>(iterable: ForEachable<[K, V]>): Map<K, V>;
|
||||
prototype: Map<any, any>;
|
||||
}
|
||||
|
||||
declare var Map: MapConstructor;
|
||||
|
||||
interface Set<T> {
|
||||
add(value: T): Set<T>;
|
||||
clear(): void;
|
||||
delete(value: T): boolean;
|
||||
forEach(callbackfn: (value: T, index: T, set: Set<T>) => void, thisArg?: any): void;
|
||||
has(value: T): boolean;
|
||||
entries(): Iterator<[T, T]>;
|
||||
keys(): Iterator<T>;
|
||||
values(): Iterator<T>;
|
||||
size: number;
|
||||
}
|
||||
|
||||
interface SetConstructor {
|
||||
new <T>(): Set<T>;
|
||||
new <T>(iterable: ForEachable<T>): Set<T>;
|
||||
prototype: Set<any>;
|
||||
}
|
||||
|
||||
declare var Set: SetConstructor;
|
||||
|
||||
interface WeakMap<K, V> {
|
||||
delete(key: K): boolean;
|
||||
clear(): void;
|
||||
get(key: K): V;
|
||||
has(key: K): boolean;
|
||||
set(key: K, value?: V): WeakMap<K, V>;
|
||||
}
|
||||
|
||||
interface WeakMapConstructor {
|
||||
new <K, V>(): WeakMap<K, V>;
|
||||
new <K, V>(iterable: ForEachable<[K, V]>): WeakMap<K, V>;
|
||||
prototype: WeakMap<any, any>;
|
||||
}
|
||||
|
||||
declare var WeakMap: WeakMapConstructor;
|
||||
|
||||
interface WeakSet<T> {
|
||||
delete(value: T): boolean;
|
||||
clear(): void;
|
||||
add(value: T): WeakSet<T>;
|
||||
has(value: T): boolean;
|
||||
}
|
||||
|
||||
interface WeakSetConstructor {
|
||||
new <T>(): WeakSet<T>;
|
||||
new <T>(iterable: ForEachable<T>): WeakSet<T>;
|
||||
prototype: WeakSet<any>;
|
||||
}
|
||||
|
||||
declare var WeakSet: WeakSetConstructor;
|
||||
|
||||
declare module "es6-collections" {
|
||||
var Map: MapConstructor;
|
||||
var Set: SetConstructor;
|
||||
var WeakMap: WeakMapConstructor;
|
||||
var WeakSet: WeakSetConstructor;
|
||||
}
|
||||
Reference in New Issue
Block a user