es6_collections.js (4558B)
1 /* 2 * Copyright 2014 The Closure Compiler Authors 3 * 4 * Licensed under the Apache License, Version 2.0 (the "License"); 5 * you may not use this file except in compliance with the License. 6 * You may obtain a copy of the License at 7 * 8 * http://www.apache.org/licenses/LICENSE-2.0 9 * 10 * Unless required by applicable law or agreed to in writing, software 11 * distributed under the License is distributed on an "AS IS" BASIS, 12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 * See the License for the specific language governing permissions and 14 * limitations under the License. 15 */ 16 17 /** 18 * @fileoverview Definitions for ECMAScript 6. 19 * @see http://wiki.ecmascript.org/doku.php?id=harmony:specification_drafts 20 * @externs 21 */ 22 23 // TODO(johnlenz): Use Tuples for the Map and Set iterators where appropriate. 24 25 /** 26 * @constructor 27 * @param {Iterable.<!Array.<KEY|VALUE>>|!Array.<!Array.<KEY|VALUE>>=} opt_iterable 28 * @implements {Iterable.<!Array.<KEY|VALUE>>} 29 * @template KEY, VALUE 30 * @see https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Map 31 */ 32 function Map(opt_iterable) {} 33 34 /** @return {void} */ 35 Map.prototype.clear; 36 37 /** 38 * @param {KEY} key 39 * @return {boolean} 40 */ 41 Map.prototype.delete; 42 43 /** 44 * @return {!Iterator.<!Array.<KEY|VALUE>>} 45 * @nosideeffects 46 */ 47 Map.prototype.entries; 48 49 /** 50 * @param {function(this:THIS, VALUE, KEY, MAP):void} callback 51 * @param {THIS} thisArg 52 * @this {MAP} 53 * @template MAP,THIS 54 */ 55 Map.prototype.forEach; 56 57 /** 58 * @param {KEY} key 59 * @return {VALUE|undefined} 60 * @nosideeffects 61 */ 62 Map.prototype.get; 63 64 /** 65 * @param {KEY} key 66 * @return {boolean} 67 * @nosideeffects 68 */ 69 Map.prototype.has; 70 71 /** 72 * @return {!Iterator.<KEY>} 73 */ 74 Map.prototype.keys; 75 76 /** 77 * @param {KEY} key 78 * @param {VALUE} value 79 * @return {THIS} 80 * @this {THIS} 81 * @template THIS 82 */ 83 Map.prototype.set; 84 85 /** 86 * @type {number} 87 * (readonly) 88 */ 89 Map.prototype.size; 90 91 /** 92 * @return {!Iterator.<VALUE>} 93 * @nosideeffects 94 */ 95 Map.prototype.values; 96 97 /** 98 * @return {!Iterator.<!Array.<KEY|VALUE>>} 99 */ 100 Map.prototype[Symbol.iterator] = function() {}; 101 102 103 /** 104 * @constructor 105 * @param {Iterable.<!Array.<KEY|VALUE>>|!Array.<!Array.<KEY|VALUE>>=} opt_iterable 106 * @template KEY, VALUE 107 * @see https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/WeakMap 108 */ 109 function WeakMap(opt_iterable) {} 110 111 /** @return {void} */ 112 WeakMap.prototype.clear; 113 114 /** 115 * @param {KEY} key 116 * @return {boolean} 117 */ 118 WeakMap.prototype.delete; 119 120 /** 121 * @param {KEY} key 122 * @return {VALUE|undefined} 123 * @nosideeffects 124 */ 125 WeakMap.prototype.get; 126 127 /** 128 * @param {KEY} key 129 * @return {boolean} 130 * @nosideeffects 131 */ 132 WeakMap.prototype.has; 133 134 /** 135 * @param {KEY} key 136 * @param {VALUE} value 137 * @return {THIS} 138 * @this {THIS} 139 * @template THIS 140 */ 141 WeakMap.prototype.set; 142 143 144 145 /** 146 * @constructor 147 * @param {Iterable.<VALUE>|Array.<VALUE>=} opt_iterable 148 * @implements {Iterable.<VALUE>} 149 * @template VALUE 150 * @see https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Set 151 */ 152 function Set(opt_iterable) {} 153 154 /** 155 * @param {VALUE} value 156 * @return {THIS} 157 * @this {THIS} 158 * @template THIS 159 */ 160 Set.prototype.add; 161 162 /** 163 * @return {void} 164 */ 165 Set.prototype.clear; 166 167 /** 168 * @param {VALUE} value 169 * @return {boolean} 170 */ 171 Set.prototype.delete; 172 173 /** 174 * @return {!Iterator.<!Array.<VALUE>>} Where each array has two entries: 175 * [value, value] 176 * @nosideeffects 177 */ 178 Set.prototype.entries; 179 180 /** 181 * @param {function(VALUE, VALUE, SET)} callback 182 * @param {THIS} thisArg 183 * @this {SET} 184 * @template SET,THIS 185 */ 186 Set.prototype.forEach; 187 188 /** 189 * @param {VALUE} value 190 * @return {boolean} 191 * @nosideeffects 192 */ 193 Set.prototype.has; 194 195 /** 196 * @type {number} (readonly) 197 */ 198 Set.prototype.size; 199 200 /** 201 * @return {!Iterator.<VALUE>} 202 * @nosideeffects 203 */ 204 Set.prototype.keys; 205 206 /** 207 * @return {!Iterator.<VALUE>} 208 * @nosideeffects 209 */ 210 Set.prototype.values; 211 212 /** 213 * @return {!Iterator.<VALUE>} 214 */ 215 Set.prototype[Symbol.iterator] = function() {}; 216 217 218 219 /** 220 * @constructor 221 * @param {Iterable.<VALUE>|Array.<VALUE>=} opt_iterable 222 * @template VALUE 223 * @see https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Set 224 */ 225 function WeakSet(opt_iterable) {} 226 227 /** 228 * @param {VALUE} value 229 * @return {THIS} 230 * @this {THIS} 231 * @template THIS 232 */ 233 WeakSet.prototype.add; 234 235 /** 236 * @return {void} 237 */ 238 WeakSet.prototype.clear; 239 240 /** 241 * @param {VALUE} value 242 * @return {boolean} 243 */ 244 WeakSet.prototype.delete; 245 246 /** 247 * @param {VALUE} value 248 * @return {boolean} 249 * @nosideeffects 250 */ 251 WeakSet.prototype.has;