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