Press n or j to go to the next uncovered block, b, p or k for the previous block.
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 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 | 1x 1x 1x 1x 1x 1x 1x 1x 1x 36x 36x 36x 36x 36x 36x 36x 36x 36x 551x 5096x 5096x 551x 36x 36x 36x 1676x 1676x 1676x 1676x 1676x 1676x 36x 9794x 9794x 118300x 118300x 118300x 118300x 118300x 118300x 118300x 118264x 118264x 118264x 118264x 106418x 106418x 118264x 118264x 118264x 118264x 118264x 118264x 118300x 9794x 7020x 108328x 108328x 7020x 18720x 18720x 18720x 18720x 18720x 7020x 9794x 9794x 36x 780x 1025x 1025x 1025x 780x 780x 36x 36x 3818x 3818x 3818x 3818x 3818x 3818x 3818x 3818x 3818x 3818x 36x 1548x 1548x 1548x 1548x 3348x 3348x 3348x 3348x 1548x 1548x 1548x 1548x 1548x 1548x 1548x 1548x 1548x 1548x 1548x 1548x 1548x 36x 36x 36x 36x 36x 574x 574x 574x 574x 574x 574x 574x 574x 36x 509x 509x 509x 36x 36x 146x 146x 36x 36x 36x 36x 36x 36x 36x 36x 18982x 18982x 18982x 36x 2969x 2969x 36x 103591x 103591x 36x 36x 1x | /** * straps.js - Class inheritance library with support for bean-style accessors * * Copyright (c) 2006 - 2016 Juerg Lehni * http://scratchdisk.com/ * * Distributed under the MIT license. * * straps.js was created by extracting and simplifying the inheritance framework * from boostrap.js, a JavaScript DOM library, also created by Juerg Lehni: * https://github.com/lehni/bootstrap.js * * Inspirations: * http://dean.edwards.name/weblog/2006/03/base/ * http://dev.helma.org/Wiki/JavaScript+Inheritance+Sugar/ */ // TODO: remove eslint-disable comment and deal with errors over time /* eslint-disable */ // import { HTMLCanvasElement_getContext_mock } from './canvas/canvas-mocks'; if (typeof globalThis.window === 'undefined') { // We know that we are NOT in browser context, we must be in NodeJs console.log('NOT in browser context, we must be in NodeJs with no global Window object'); if (typeof self !== 'undefined') { console.log('We are in a Web Worker context'); } } else { // We could be in browser OR in NodeJs with global WINDOW object (e.g. jsdom) // eslint-disable-next-line no-lonely-if if (typeof process !== 'undefined' && process?.release) { // We know we are in NodeJs console.log('NodeJs context, but we have a global Window (might be jsdom)'); const isJsdom = globalThis.window.navigator?.userAgent?.toLowerCase()?.includes('jsdom'); console.log('userAgentIncludesJsdom? = ', isJsdom); } else { // Here we know we are in a BROWSER context console.log('Browser context'); } } // @ts-expect-error = 'new' expression, whose target lacks a construct signature export const Base = new (function () { var hidden = /^(statics|enumerable|beans|preserve)$/, array = [], slice = array.slice, create = Object.create, describe = Object.getOwnPropertyDescriptor, define = Object.defineProperty, forEach = array.forEach || function (iter, bind) { // Poly-fill for forEach for (var i = 0, l = this.length; i < l; i++) { iter.call(bind, this[i], i, this); } }, forIn = function (iter, bind) { // Do not use Object.keys for iteration as iterators might modify // the object we're iterating over, making the hasOwnProperty still // necessary. for (var i in this) { if (this.hasOwnProperty(i)) iter.call(bind, this[i], i, this); } }, set = Object.assign || function (dst) { // Poly-fill for Object.assign for (var i = 1, l = arguments.length; i < l; i++) { var src = arguments[i]; for (var key in src) { if (src.hasOwnProperty(key)) dst[key] = src[key]; } } return dst; }, each = function (obj, iter, bind) { // Convention: Enumerate over the object using forEach if it defines // a value property named 'length' that contains an number value. // Everything else is enumerated using forIn. if (obj) { var desc = describe(obj, 'length'); (desc && typeof desc.value === 'number' ? forEach : forIn).call(obj, iter, (bind = bind || obj)); } return bind; }; /** * Private function that injects functions from src into dest, overriding * the previous definition, preserving a link to it through Function#base. */ function inject(dest, src, enumerable, beans, preserve) { var beansNames = {}; /** * Private function that injects one field with given name and checks if * the field is a function with a previous definition that we need to * link to through Function#base. */ function field(name, val) { // This does even work for prop: 0, as it will just be looked up // again through describe. val = val || ((val = describe(src, name)) && (val.get ? val : val.value)); // Allow aliases to properties with different names, by having // string values starting with '#' if (typeof val === 'string' && val[0] === '#') val = dest[val.substring(1)] || val; var isFunc = typeof val === 'function', res = val, // Only lookup previous value if we preserve existing entries or // define a function that might need it for Function#base. If // a getter is defined, don't lookup previous value, but look if // the property exists (name in dest) and store result in prev. // Also check if the function doesn't already have #base defined // in which case it shall not be overridden. This occurs when // injecting statics from one constructor function to the next // for inheritance. e.g. in Mootools' Function#extend would // falsely be preserved up the inheritance chain through #base. prev = preserve || (isFunc && !val.base) ? (val && val.get ? name in dest : dest[name]) : null, bean; if (!preserve || !prev) { // Expose the 'super' function (meaning the one this function is // overriding) through Function#base: if (isFunc && prev) val.base = prev; // Produce bean properties if getters or setters are specified. // Just collect potential beans for now, and look them up in // dest at the end of fields injection. This ensures base works // for beans too, and inherits setters for redefined getters in // subclasses. if (isFunc && beans !== false && (bean = name.match(/^([gs]et|is)(([A-Z])(.*))$/))) beansNames[bean[3].toLowerCase() + bean[4]] = bean[2]; // No need to create accessor description if it already is one. // It is considered a description if it is a plain object with a // get function. if (!res || isFunc || !res.get || typeof res.get !== 'function' || !(Base as any).isPlainObject(res)) { res = { value: res, writable: true }; } // Only set/change configurable and enumerable if this field is // configurable if ((describe(dest, name) || { configurable: true }).configurable) { res.configurable = true; // If no value is provided for enumerable, the default is to // allow any property to be enumerable except the functions // that create bean properties. res.enumerable = enumerable != null ? enumerable : !bean; } define(dest, name, res); } } // Iterate through all definitions in src now and call field() for each. if (src) { for (var name in src) { // @ts-expect-error = Expected 2 arguments, but got 1 if (src.hasOwnProperty(name) && !hidden.test(name)) field(name); } // Now process the beans as well. for (var name in beansNames) { // Simple Beans Convention: // - If `beans: false` is specified, no beans are injected. // - `isName()` is only considered a getter of a bean accessor // if there is also a setter for it. // - If a potential getter has no parameters, it forms a bean // accessor. // - If `beans: true` is specified, the parameter count of a // potential getter is ignored and the bean is always created. var part = beansNames[name], set = dest['set' + part], get = dest['get' + part] || (set && dest['is' + part]); if (get && (beans === true || get.length === 0)) field(name, { get: get, set: set }); } } return dest; } // The Base constructor function. function Base() { for (var i = 0, l = arguments.length; i < l; i++) { var src = arguments[i]; if (src) set(this, src); } return this; } // First inject static methods into Base function that is passed to inject() // and then returned as the Base class. // @ts-expect-error = Expected 5 arguments, but got 2 return inject(Base, { inject: function (src /*, ... */) { if (src) { // Allow the whole scope to just define statics by defining // `statics: true` var statics = src.statics === true ? src : src.statics, beans = src.beans, preserve = src.preserve; if (statics !== src) inject(this.prototype, src, src.enumerable, beans, preserve); // Use the preserve setting in src.preserve for statics too, not // their own. inject(this, statics, null, beans, preserve); } // If there are more than one argument, loop through them and call // inject again. Do not simple inline the above code in one loop, // since each of the passed objects might override this.inject. for (var i = 1, l = arguments.length; i < l; i++) this.inject(arguments[i]); return this; }, extend: function (/* src, ... */) { var base = this, ctor, proto; // Look for an initialize function in all injection objects and use // it directly as the actual constructor. Also look for prototype, // in case a class wants to override it (e.g. Array inheritance). for (var i = 0, obj, l = arguments.length; i < l && !(ctor && proto); i++) { obj = arguments[i]; ctor = ctor || obj.initialize; proto = proto || obj.prototype; } // If no initialize function is provided, create a constructor that // simply calls the base constructor. ctor = ctor || function () { base.apply(this, arguments); }; proto = ctor.prototype = proto || create(this.prototype); // The new prototype extends the constructor on which extend is // called. Fix constructor. define(proto, 'constructor', { value: ctor, writable: true, configurable: true, }); // Copy over static fields, as prototype-like inheritance // is not possible for static fields. // @ts-expect-error = Expected 5 arguments, but got 2 inject(ctor, this); // Inject all the definitions in src. Use the new inject instead of // the one in ctor, in case it was overridden. this is needed when // overriding the static .inject(). But only inject if there's // something to actually inject. if (arguments.length) this.inject.apply(ctor, arguments); // Expose base property on constructor functions as well. // Do this after everything else, to avoid incorrect overriding of // `base` in inject() when creating long super call chains in // constructors. ctor.base = base; return ctor; }, }).inject({ // Mark all properties in Base as not enumerable so that it can be used // as a basic hash-table class, e.g. `new Base(defaults, options); enumerable: false, /** * The Base constructor function. * * @param {...Object} objects one or multiple objects describing the * properties to set on the new created object. */ initialize: Base, /** * Sets properties on this object from one ore passed multiply objects. * * @param {...Object} objects one or multiple objects describing the * properties to set on this object. */ set: Base, /** * Injects the fields in this object from one ore passed multiply * objects. * * @param {...Object} objects one or multiple objects describing the * fields to be injected in this object. */ inject: function (/* src, ... */) { for (var i = 0, l = arguments.length; i < l; i++) { var src = arguments[i]; if (src) { inject(this, src, src.enumerable, src.beans, src.preserve); } } return this; }, /** * Returns a new object that inherits all properties from `this`, * through proper JS inheritance, without copying. * * Optionally, src parameters can be passed to inject into the newly * created object just like in {@link #inject()}, reflecting the * behavior of {@link Base.extend()}. * * @param {...Object} objects one or multiple objects describing the * fields to be injected in the newly created object. */ extend: function (/* src, ... */) { var res = create(this); return res.inject.apply(res, arguments); }, each: function (iter, bind) { return each(this, iter, bind); }, /** * General purpose clone function that delegates cloning to the * constructor that receives the object to be cloned as the first * argument. * NOTE: #clone() needs to be overridden in any class that requires * other cloning behavior. */ clone: function () { return new this.constructor(this); }, statics: { // Expose some local privates as static functions on Base. set: set, each: each, create: create, define: define, describe: describe, clone: function (obj) { return set(new obj.constructor(), obj); }, /** * Returns true if obj is a plain JavaScript object literal, or a * plain Base object, as produced by Base.merge(). */ isPlainObject: function (obj) { var ctor = obj != null && obj.constructor; // We also need to check for ctor.name === 'Object', in case // this is an object from another global scope (e.g. an iframe, // or another vm context in node.js). return ctor && (ctor === Object || ctor === Base || ctor.name === 'Object'); }, /** * Returns the 1st argument if it is defined, the 2nd otherwise. * `null` is counted as defined too, as !== undefined is used for * comparisons. */ pick: function (a, b) { return a !== undefined ? a : b; }, slice: function (list, begin, end) { return slice.call(list, begin, end); }, }, }); })(); // // Export Base class for node // if (typeof module !== 'undefined') // module.exports = Base; |