| 1 | /* |
| 2 | * Copyright 2009 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 5. |
| 19 | * @see http://www.ecma-international.org/publications/files/drafts/tc39-2009-025.pdf |
| 20 | * @externs |
| 21 | */ |
| 22 | |
| 23 | |
| 24 | /** |
| 25 | * @param {Object} selfObj Specifies the object to which |this| should point |
| 26 | * when the function is run. If the value is null or undefined, it will |
| 27 | * default to the global object. |
| 28 | * @param {...*} var_args Additional arguments that are partially |
| 29 | * applied to fn. |
| 30 | * @return {!Function} A partially-applied form of the Function on which |
| 31 | * bind() was invoked as a method. |
| 32 | * @nosideeffects |
| 33 | * @see https://developer.mozilla.org/en/JavaScript/Reference/Global_Objects/Function/bind |
| 34 | */ |
| 35 | Function.prototype.bind = function(selfObj, var_args) {}; |
| 36 | |
| 37 | |
| 38 | /** |
| 39 | * @return {string} |
| 40 | * @nosideeffects |
| 41 | * @see http://developer.mozilla.org/en/JavaScript/Reference/Global_Objects/String/Trim |
| 42 | */ |
| 43 | String.prototype.trim = function() {}; |
| 44 | |
| 45 | |
| 46 | /** |
| 47 | * @return {string} |
| 48 | * @nosideeffects |
| 49 | * @see http://developer.mozilla.org/en/JavaScript/Reference/Global_Objects/String/TrimLeft |
| 50 | */ |
| 51 | String.prototype.trimLeft = function() {}; |
| 52 | |
| 53 | |
| 54 | /** |
| 55 | * @return {string} |
| 56 | * @nosideeffects |
| 57 | * @see http://developer.mozilla.org/en/JavaScript/Reference/Global_Objects/String/TrimRight |
| 58 | */ |
| 59 | String.prototype.trimRight = function() {}; |
| 60 | |
| 61 | |
| 62 | /** |
| 63 | * A object property descriptor used by Object.create, Object.defineProperty, |
| 64 | * Object.defineProperties, Object.getOwnPropertyDescriptor. |
| 65 | * |
| 66 | * Note: not a real constructor. |
| 67 | * @constructor |
| 68 | */ |
| 69 | var ObjectPropertyDescriptor = function(){}; |
| 70 | |
| 71 | /** @type {*} */ |
| 72 | ObjectPropertyDescriptor.prototype.value; |
| 73 | |
| 74 | /** @type {(function():?)||undefined} */ |
| 75 | ObjectPropertyDescriptor.prototype.get; |
| 76 | |
| 77 | /** @type {(function(?):void)||undefined} */ |
| 78 | ObjectPropertyDescriptor.prototype.set; |
| 79 | |
| 80 | /** @type {boolean|undefined} */ |
| 81 | ObjectPropertyDescriptor.prototype.writable; |
| 82 | |
| 83 | /** @type {boolean|undefined} */ |
| 84 | ObjectPropertyDescriptor.prototype.enumerable; |
| 85 | |
| 86 | /** @type {boolean|undefined} */ |
| 87 | ObjectPropertyDescriptor.prototype.configurable; |
| 88 | |
| 89 | |
| 90 | /** |
| 91 | * @param {Object} proto |
| 92 | * @param {Object=} opt_properties A map of ObjectPropertyDescriptors. |
| 93 | * @return {!Object} |
| 94 | * @nosideeffects |
| 95 | * @see https://developer.mozilla.org/en/JavaScript/Reference/Global_Objects/Object/create |
| 96 | */ |
| 97 | Object.create = function(proto, opt_properties) {}; |
| 98 | |
| 99 | |
| 100 | /** |
| 101 | * @param {!Object} obj |
| 102 | * @param {string} prop |
| 103 | * @param {!Object} descriptor A ObjectPropertyDescriptor. |
| 104 | * @return {!Object} |
| 105 | * @see https://developer.mozilla.org/en/JavaScript/Reference/Global_Objects/Object/defineProperty |
| 106 | */ |
| 107 | Object.defineProperty = function(obj, prop, descriptor) {}; |
| 108 | |
| 109 | |
| 110 | /** |
| 111 | * @param {!Object} obj |
| 112 | * @param {!Object} props A map of ObjectPropertyDescriptors. |
| 113 | * @return {!Object} |
| 114 | * @see https://developer.mozilla.org/en/JavaScript/Reference/Global_Objects/Object/defineProperties |
| 115 | */ |
| 116 | Object.defineProperties = function(obj, props) {}; |
| 117 | |
| 118 | |
| 119 | /** |
| 120 | * @param {!Object} obj |
| 121 | * @param {string} prop |
| 122 | * @return {Object.<ObjectPropertyDescriptor>} |
| 123 | * @nosideeffects |
| 124 | * @see https://developer.mozilla.org/en/JavaScript/Reference/Global_Objects/Object/getOwnPropertyDescriptor |
| 125 | */ |
| 126 | Object.getOwnPropertyDescriptor = function(obj, prop) {}; |
| 127 | |
| 128 | |
| 129 | /** |
| 130 | * @param {!Object} obj |
| 131 | * @return {Array.<string>} |
| 132 | * @nosideeffects |
| 133 | * @see https://developer.mozilla.org/en/JavaScript/Reference/Global_Objects/Object/keys |
| 134 | */ |
| 135 | Object.keys = function(obj) {}; |
| 136 | |
| 137 | |
| 138 | /** |
| 139 | * @param {!Object} obj |
| 140 | * @return {Array.<string>} |
| 141 | * @nosideeffects |
| 142 | * @see https://developer.mozilla.org/en/JavaScript/Reference/Global_Objects/Object/getOwnPropertyNames |
| 143 | */ |
| 144 | Object.getOwnPropertyNames = function(obj) {}; |
| 145 | |
| 146 | |
| 147 | /** |
| 148 | * @param {!Object} obj |
| 149 | * @return {Object} |
| 150 | * @nosideeffects |
| 151 | * @see https://developer.mozilla.org/en/JavaScript/Reference/Global_Objects/Object/GetPrototypeOf |
| 152 | */ |
| 153 | Object.getPrototypeOf = function(obj) {}; |
| 154 | |
| 155 | |
| 156 | /** |
| 157 | * @param {!T} obj |
| 158 | * @return {!T} |
| 159 | * @template T |
| 160 | * @see https://developer.mozilla.org/en/JavaScript/Reference/Global_Objects/Object/preventExtensions |
| 161 | */ |
| 162 | Object.preventExtensions = function(obj) {}; |
| 163 | |
| 164 | |
| 165 | /** |
| 166 | * @param {!T} obj |
| 167 | * @return {!T} |
| 168 | * @template T |
| 169 | * @see https://developer.mozilla.org/en/JavaScript/Reference/Global_Objects/Object/seal |
| 170 | */ |
| 171 | Object.seal = function(obj) {}; |
| 172 | |
| 173 | |
| 174 | /** |
| 175 | * @param {!T} obj |
| 176 | * @return {!T} |
| 177 | * @template T |
| 178 | * @see https://developer.mozilla.org/en/JavaScript/Reference/Global_Objects/Object/freeze |
| 179 | */ |
| 180 | Object.freeze = function(obj) {}; |
| 181 | |
| 182 | |
| 183 | /** |
| 184 | * @param {!Object} obj |
| 185 | * @return {boolean} |
| 186 | * @nosideeffects |
| 187 | * @see https://developer.mozilla.org/en/JavaScript/Reference/Global_Objects/Object/isExtensible |
| 188 | */ |
| 189 | Object.isExtensible = function(obj) {}; |
| 190 | |
| 191 | |
| 192 | /** |
| 193 | * @param {!Object} obj |
| 194 | * @return {boolean} |
| 195 | * @nosideeffects |
| 196 | * @see https://developer.mozilla.org/en/JavaScript/Reference/Global_Objects/Object/isSealed |
| 197 | */ |
| 198 | Object.isSealed = function(obj) {}; |
| 199 | |
| 200 | |
| 201 | /** |
| 202 | * @param {!Object} obj |
| 203 | * @return {boolean} |
| 204 | * @nosideeffects |
| 205 | * @see https://developer.mozilla.org/en/JavaScript/Reference/Global_Objects/Object/isFrozen |
| 206 | */ |
| 207 | Object.isFrozen = function(obj) {}; |
| 208 | |
| 209 | |
| 210 | /** |
| 211 | * As per ECMAScript 5, 15.12.3. |
| 212 | * @param {string=} opt_key The JSON key for this object. |
| 213 | * @return {*} The serializable representation of this object. Note that this |
| 214 | * need not be a string. See http://goo.gl/PEUvs. |
| 215 | */ |
| 216 | Object.prototype.toJSON = function(opt_key) {}; |
| 217 | |
| 218 | |
| 219 | /** |
| 220 | * @see https://developer.mozilla.org/en/JavaScript/Reference/Global_Objects/Date/toISOString |
| 221 | * @return {string} |
| 222 | */ |
| 223 | Date.prototype.toISOString = function() {}; |
| 224 | |
| 225 | |
| 226 | /** |
| 227 | * @param {*=} opt_ignoredKey |
| 228 | * @return {string} |
| 229 | * @override |
| 230 | */ |
| 231 | Date.prototype.toJSON = function(opt_ignoredKey) {}; |
| 232 | |
| 233 | |
| 234 | /** |
| 235 | * A fake type to model the JSON object. |
| 236 | * @constructor |
| 237 | */ |
| 238 | var JSONType = function() {}; |
| 239 | |
| 240 | |
| 241 | /** |
| 242 | * @param {string} jsonStr The string to parse. |
| 243 | * @param {(function(string, *) : *)=} opt_reviver |
| 244 | * @return {*} The JSON object. |
| 245 | * @throws {Error} |
| 246 | * @nosideeffects |
| 247 | */ |
| 248 | JSONType.prototype.parse = function(jsonStr, opt_reviver) {}; |
| 249 | |
| 250 | |
| 251 | /** |
| 252 | * @param {*} jsonObj Input object. |
| 253 | * @param {(Array.<string>|(function(string, *) : *)|null)=} opt_replacer |
| 254 | * @param {(number|string)=} opt_space |
| 255 | * @return {string} JSON string which represents jsonObj. |
| 256 | * @throws {Error} |
| 257 | * @nosideeffects |
| 258 | */ |
| 259 | JSONType.prototype.stringify = function(jsonObj, opt_replacer, opt_space) {}; |
| 260 | |
| 261 | |
| 262 | /** |
| 263 | * @type {!JSONType} |
| 264 | * @suppress {duplicate} |
| 265 | */ |
| 266 | var JSON; |