GitHub Access Token became invalid

It seems like the GitHub access token used for retrieving details about this repository from GitHub became invalid. This might prevent certain types of inspections from being run (in particular, everything related to pull requests).
Please ask an admin of your repository to re-new the access token on this website.

Issues (3063)

angularjs/angular-1.6.5/angular-loader.js (2 issues)

Severity
1
/**
2
 * @license AngularJS v1.6.5
3
 * (c) 2010-2017 Google, Inc. http://angularjs.org
4
 * License: MIT
5
 */
6
7
(function() {'use strict';
8
    // NOTE:
9
    // These functions are copied here from `src/Angular.js`, because they are needed inside the
10
    // `angular-loader.js` closure and need to be available before the main `angular.js` script has
11
    // been loaded.
12
    function isFunction(value) {return typeof value === 'function';}
13
    function isDefined(value) {return typeof value !== 'undefined';}
14
    function isNumber(value) {return typeof value === 'number';}
15
    function isObject(value) {return value !== null && typeof value === 'object';}
16
    function isScope(obj) {return obj && obj.$evalAsync && obj.$watch;}
17
    function isUndefined(value) {return typeof value === 'undefined';}
18
    function isWindow(obj) {return obj && obj.window === obj;}
19
    function sliceArgs(args, startIndex) {return Array.prototype.slice.call(args, startIndex || 0);}
20
    function toJsonReplacer(key, value) {
21
      var val = value;
22
23
      if (typeof key === 'string' && key.charAt(0) === '$' && key.charAt(1) === '$') {
24
        val = undefined;
25
      } else if (isWindow(value)) {
26
        val = '$WINDOW';
27
      } else if (value &&  window.document === value) {
28
        val = '$DOCUMENT';
29
      } else if (isScope(value)) {
30
        val = '$SCOPE';
31
      }
32
33
      return val;
34
    }
35
36
/* exported toDebugString */
37
38
function serializeObject(obj, maxDepth) {
39
  var seen = [];
40
41
  // There is no direct way to stringify object until reaching a specific depth
42
  // and a very deep object can cause a performance issue, so we copy the object
43
  // based on this specific depth and then stringify it.
44
  if (isValidObjectMaxDepth(maxDepth)) {
45
    // This file is also included in `angular-loader`, so `copy()` might not always be available in
46
    // the closure. Therefore, it is lazily retrieved as `angular.copy()` when needed.
47
    obj = angular.copy(obj, null, maxDepth);
48
  }
49
  return JSON.stringify(obj, function(key, val) {
50
    val = toJsonReplacer(key, val);
51
    if (isObject(val)) {
52
53
      if (seen.indexOf(val) >= 0) return '...';
54
55
      seen.push(val);
56
    }
57
    return val;
58
  });
59
}
60
61
function toDebugString(obj, maxDepth) {
62
  if (typeof obj === 'function') {
63
    return obj.toString().replace(/ \{[\s\S]*$/, '');
64
  } else if (isUndefined(obj)) {
65
    return 'undefined';
66
  } else if (typeof obj !== 'string') {
67
    return serializeObject(obj, maxDepth);
68
  }
69
  return obj;
70
}
71
72
/* exported
73
  minErrConfig,
74
  errorHandlingConfig,
75
  isValidObjectMaxDepth
76
*/
77
78
var minErrConfig = {
79
  objectMaxDepth: 5
80
};
81
82
/**
83
 * @ngdoc function
84
 * @name angular.errorHandlingConfig
85
 * @module ng
86
 * @kind function
87
 *
88
 * @description
89
 * Configure several aspects of error handling in AngularJS if used as a setter or return the
90
 * current configuration if used as a getter. The following options are supported:
91
 *
92
 * - **objectMaxDepth**: The maximum depth to which objects are traversed when stringified for error messages.
93
 *
94
 * Omitted or undefined options will leave the corresponding configuration values unchanged.
95
 *
96
 * @param {Object=} config - The configuration object. May only contain the options that need to be
97
 *     updated. Supported keys:
98
 *
99
 * * `objectMaxDepth`  **{Number}** - The max depth for stringifying objects. Setting to a
100
 *   non-positive or non-numeric value, removes the max depth limit.
101
 *   Default: 5
102
 */
103
function errorHandlingConfig(config) {
0 ignored issues
show
The function errorHandlingConfig does not seem to be used and can be removed.
Loading history...
104
  if (isObject(config)) {
105
    if (isDefined(config.objectMaxDepth)) {
106
      minErrConfig.objectMaxDepth = isValidObjectMaxDepth(config.objectMaxDepth) ? config.objectMaxDepth : NaN;
107
    }
108
  } else {
109
    return minErrConfig;
110
  }
111
}
112
113
/**
114
 * @private
115
 * @param {Number} maxDepth
116
 * @return {boolean}
117
 */
118
function isValidObjectMaxDepth(maxDepth) {
119
  return isNumber(maxDepth) && maxDepth > 0;
120
}
121
122
/**
123
 * @description
124
 *
125
 * This object provides a utility for producing rich Error messages within
126
 * Angular. It can be called as follows:
127
 *
128
 * var exampleMinErr = minErr('example');
129
 * throw exampleMinErr('one', 'This {0} is {1}', foo, bar);
130
 *
131
 * The above creates an instance of minErr in the example namespace. The
132
 * resulting error will have a namespaced error code of example.one.  The
133
 * resulting error will replace {0} with the value of foo, and {1} with the
134
 * value of bar. The object is not restricted in the number of arguments it can
135
 * take.
136
 *
137
 * If fewer arguments are specified than necessary for interpolation, the extra
138
 * interpolation markers will be preserved in the final string.
139
 *
140
 * Since data will be parsed statically during a build step, some restrictions
141
 * are applied with respect to how minErr instances are created and called.
142
 * Instances should have names of the form namespaceMinErr for a minErr created
143
 * using minErr('namespace') . Error codes, namespaces and template strings
144
 * should all be static strings, not variables or general expressions.
145
 *
146
 * @param {string} module The namespace to use for the new minErr instance.
147
 * @param {function} ErrorConstructor Custom error constructor to be instantiated when returning
148
 *   error from returned function, for cases when a particular type of error is useful.
149
 * @returns {function(code:string, template:string, ...templateArgs): Error} minErr instance
150
 */
151
152 View Code Duplication
function minErr(module, ErrorConstructor) {
153
  ErrorConstructor = ErrorConstructor || Error;
154
  return function() {
155
    var code = arguments[0],
156
      template = arguments[1],
157
      message = '[' + (module ? module + ':' : '') + code + '] ',
158
      templateArgs = sliceArgs(arguments, 2).map(function(arg) {
159
        return toDebugString(arg, minErrConfig.objectMaxDepth);
160
      }),
161
      paramPrefix, i;
162
163
    message += template.replace(/\{\d+\}/g, function(match) {
164
      var index = +match.slice(1, -1);
165
166
      if (index < templateArgs.length) {
167
        return templateArgs[index];
168
      }
169
170
      return match;
171
    });
172
173
    message += '\nhttp://errors.angularjs.org/1.6.5/' +
174
      (module ? module + '/' : '') + code;
175
176
    for (i = 0, paramPrefix = '?'; i < templateArgs.length; i++, paramPrefix = '&') {
177
      message += paramPrefix + 'p' + i + '=' + encodeURIComponent(templateArgs[i]);
178
    }
179
180
    return new ErrorConstructor(message);
181
  };
182
}
183
184
/**
185
 * @ngdoc type
186
 * @name angular.Module
187
 * @module ng
188
 * @description
189
 *
190
 * Interface for configuring angular {@link angular.module modules}.
191
 */
192
193 View Code Duplication
function setupModuleLoader(window) {
194
195
  var $injectorMinErr = minErr('$injector');
196
  var ngMinErr = minErr('ng');
197
198
  function ensure(obj, name, factory) {
199
    return obj[name] || (obj[name] = factory());
200
  }
201
202
  var angular = ensure(window, 'angular', Object);
203
204
  // We need to expose `angular.$$minErr` to modules such as `ngResource` that reference it during bootstrap
205
  angular.$$minErr = angular.$$minErr || minErr;
206
207
  return ensure(angular, 'module', function() {
208
    /** @type {Object.<string, angular.Module>} */
209
    var modules = {};
210
211
    /**
212
     * @ngdoc function
213
     * @name angular.module
214
     * @module ng
215
     * @description
216
     *
217
     * The `angular.module` is a global place for creating, registering and retrieving Angular
218
     * modules.
219
     * All modules (angular core or 3rd party) that should be available to an application must be
220
     * registered using this mechanism.
221
     *
222
     * Passing one argument retrieves an existing {@link angular.Module},
223
     * whereas passing more than one argument creates a new {@link angular.Module}
224
     *
225
     *
226
     * # Module
227
     *
228
     * A module is a collection of services, directives, controllers, filters, and configuration information.
229
     * `angular.module` is used to configure the {@link auto.$injector $injector}.
230
     *
231
     * ```js
232
     * // Create a new module
233
     * var myModule = angular.module('myModule', []);
234
     *
235
     * // register a new service
236
     * myModule.value('appName', 'MyCoolApp');
237
     *
238
     * // configure existing services inside initialization blocks.
239
     * myModule.config(['$locationProvider', function($locationProvider) {
240
     *   // Configure existing providers
241
     *   $locationProvider.hashPrefix('!');
242
     * }]);
243
     * ```
244
     *
245
     * Then you can create an injector and load your modules like this:
246
     *
247
     * ```js
248
     * var injector = angular.injector(['ng', 'myModule'])
249
     * ```
250
     *
251
     * However it's more likely that you'll just use
252
     * {@link ng.directive:ngApp ngApp} or
253
     * {@link angular.bootstrap} to simplify this process for you.
254
     *
255
     * @param {!string} name The name of the module to create or retrieve.
256
     * @param {!Array.<string>=} requires If specified then new module is being created. If
257
     *        unspecified then the module is being retrieved for further configuration.
258
     * @param {Function=} configFn Optional configuration function for the module. Same as
259
     *        {@link angular.Module#config Module#config()}.
260
     * @returns {angular.Module} new module with the {@link angular.Module} api.
261
     */
262
    return function module(name, requires, configFn) {
263
264
      var info = {};
265
266
      var assertNotHasOwnProperty = function(name, context) {
267
        if (name === 'hasOwnProperty') {
268
          throw ngMinErr('badname', 'hasOwnProperty is not a valid {0} name', context);
269
        }
270
      };
271
272
      assertNotHasOwnProperty(name, 'module');
273
      if (requires && modules.hasOwnProperty(name)) {
274
        modules[name] = null;
275
      }
276
      return ensure(modules, name, function() {
277
        if (!requires) {
278
          throw $injectorMinErr('nomod', 'Module \'{0}\' is not available! You either misspelled ' +
279
             'the module name or forgot to load it. If registering a module ensure that you ' +
280
             'specify the dependencies as the second argument.', name);
281
        }
282
283
        /** @type {!Array.<Array.<*>>} */
284
        var invokeQueue = [];
285
286
        /** @type {!Array.<Function>} */
287
        var configBlocks = [];
288
289
        /** @type {!Array.<Function>} */
290
        var runBlocks = [];
291
292
        var config = invokeLater('$injector', 'invoke', 'push', configBlocks);
293
294
        /** @type {angular.Module} */
295
        var moduleInstance = {
296
          // Private state
297
          _invokeQueue: invokeQueue,
298
          _configBlocks: configBlocks,
299
          _runBlocks: runBlocks,
300
301
          /**
302
           * @ngdoc method
303
           * @name angular.Module#info
304
           * @module ng
305
           *
306
           * @param {Object=} info Information about the module
307
           * @returns {Object|Module} The current info object for this module if called as a getter,
308
           *                          or `this` if called as a setter.
309
           *
310
           * @description
311
           * Read and write custom information about this module.
312
           * For example you could put the version of the module in here.
313
           *
314
           * ```js
315
           * angular.module('myModule', []).info({ version: '1.0.0' });
316
           * ```
317
           *
318
           * The version could then be read back out by accessing the module elsewhere:
319
           *
320
           * ```
321
           * var version = angular.module('myModule').info().version;
322
           * ```
323
           *
324
           * You can also retrieve this information during runtime via the
325
           * {@link $injector#modules `$injector.modules`} property:
326
           *
327
           * ```js
328
           * var version = $injector.modules['myModule'].info().version;
329
           * ```
330
           */
331
          info: function(value) {
332
            if (isDefined(value)) {
333
              if (!isObject(value)) throw ngMinErr('aobj', 'Argument \'{0}\' must be an object', 'value');
334
              info = value;
335
              return this;
336
            }
337
            return info;
338
          },
339
340
          /**
341
           * @ngdoc property
342
           * @name angular.Module#requires
343
           * @module ng
344
           *
345
           * @description
346
           * Holds the list of modules which the injector will load before the current module is
347
           * loaded.
348
           */
349
          requires: requires,
350
351
          /**
352
           * @ngdoc property
353
           * @name angular.Module#name
354
           * @module ng
355
           *
356
           * @description
357
           * Name of the module.
358
           */
359
          name: name,
360
361
362
          /**
363
           * @ngdoc method
364
           * @name angular.Module#provider
365
           * @module ng
366
           * @param {string} name service name
367
           * @param {Function} providerType Construction function for creating new instance of the
368
           *                                service.
369
           * @description
370
           * See {@link auto.$provide#provider $provide.provider()}.
371
           */
372
          provider: invokeLaterAndSetModuleName('$provide', 'provider'),
373
374
          /**
375
           * @ngdoc method
376
           * @name angular.Module#factory
377
           * @module ng
378
           * @param {string} name service name
379
           * @param {Function} providerFunction Function for creating new instance of the service.
380
           * @description
381
           * See {@link auto.$provide#factory $provide.factory()}.
382
           */
383
          factory: invokeLaterAndSetModuleName('$provide', 'factory'),
384
385
          /**
386
           * @ngdoc method
387
           * @name angular.Module#service
388
           * @module ng
389
           * @param {string} name service name
390
           * @param {Function} constructor A constructor function that will be instantiated.
391
           * @description
392
           * See {@link auto.$provide#service $provide.service()}.
393
           */
394
          service: invokeLaterAndSetModuleName('$provide', 'service'),
395
396
          /**
397
           * @ngdoc method
398
           * @name angular.Module#value
399
           * @module ng
400
           * @param {string} name service name
401
           * @param {*} object Service instance object.
402
           * @description
403
           * See {@link auto.$provide#value $provide.value()}.
404
           */
405
          value: invokeLater('$provide', 'value'),
406
407
          /**
408
           * @ngdoc method
409
           * @name angular.Module#constant
410
           * @module ng
411
           * @param {string} name constant name
412
           * @param {*} object Constant value.
413
           * @description
414
           * Because the constants are fixed, they get applied before other provide methods.
415
           * See {@link auto.$provide#constant $provide.constant()}.
416
           */
417
          constant: invokeLater('$provide', 'constant', 'unshift'),
418
419
           /**
420
           * @ngdoc method
421
           * @name angular.Module#decorator
422
           * @module ng
423
           * @param {string} name The name of the service to decorate.
424
           * @param {Function} decorFn This function will be invoked when the service needs to be
425
           *                           instantiated and should return the decorated service instance.
426
           * @description
427
           * See {@link auto.$provide#decorator $provide.decorator()}.
428
           */
429
          decorator: invokeLaterAndSetModuleName('$provide', 'decorator', configBlocks),
430
431
          /**
432
           * @ngdoc method
433
           * @name angular.Module#animation
434
           * @module ng
435
           * @param {string} name animation name
436
           * @param {Function} animationFactory Factory function for creating new instance of an
437
           *                                    animation.
438
           * @description
439
           *
440
           * **NOTE**: animations take effect only if the **ngAnimate** module is loaded.
441
           *
442
           *
443
           * Defines an animation hook that can be later used with
444
           * {@link $animate $animate} service and directives that use this service.
445
           *
446
           * ```js
447
           * module.animation('.animation-name', function($inject1, $inject2) {
448
           *   return {
449
           *     eventName : function(element, done) {
450
           *       //code to run the animation
451
           *       //once complete, then run done()
452
           *       return function cancellationFunction(element) {
453
           *         //code to cancel the animation
454
           *       }
455
           *     }
456
           *   }
457
           * })
458
           * ```
459
           *
460
           * See {@link ng.$animateProvider#register $animateProvider.register()} and
461
           * {@link ngAnimate ngAnimate module} for more information.
462
           */
463
          animation: invokeLaterAndSetModuleName('$animateProvider', 'register'),
464
465
          /**
466
           * @ngdoc method
467
           * @name angular.Module#filter
468
           * @module ng
469
           * @param {string} name Filter name - this must be a valid angular expression identifier
470
           * @param {Function} filterFactory Factory function for creating new instance of filter.
471
           * @description
472
           * See {@link ng.$filterProvider#register $filterProvider.register()}.
473
           *
474
           * <div class="alert alert-warning">
475
           * **Note:** Filter names must be valid angular {@link expression} identifiers, such as `uppercase` or `orderBy`.
476
           * Names with special characters, such as hyphens and dots, are not allowed. If you wish to namespace
477
           * your filters, then you can use capitalization (`myappSubsectionFilterx`) or underscores
478
           * (`myapp_subsection_filterx`).
479
           * </div>
480
           */
481
          filter: invokeLaterAndSetModuleName('$filterProvider', 'register'),
482
483
          /**
484
           * @ngdoc method
485
           * @name angular.Module#controller
486
           * @module ng
487
           * @param {string|Object} name Controller name, or an object map of controllers where the
488
           *    keys are the names and the values are the constructors.
489
           * @param {Function} constructor Controller constructor function.
490
           * @description
491
           * See {@link ng.$controllerProvider#register $controllerProvider.register()}.
492
           */
493
          controller: invokeLaterAndSetModuleName('$controllerProvider', 'register'),
494
495
          /**
496
           * @ngdoc method
497
           * @name angular.Module#directive
498
           * @module ng
499
           * @param {string|Object} name Directive name, or an object map of directives where the
500
           *    keys are the names and the values are the factories.
501
           * @param {Function} directiveFactory Factory function for creating new instance of
502
           * directives.
503
           * @description
504
           * See {@link ng.$compileProvider#directive $compileProvider.directive()}.
505
           */
506
          directive: invokeLaterAndSetModuleName('$compileProvider', 'directive'),
507
508
          /**
509
           * @ngdoc method
510
           * @name angular.Module#component
511
           * @module ng
512
           * @param {string} name Name of the component in camel-case (i.e. myComp which will match as my-comp)
513
           * @param {Object} options Component definition object (a simplified
514
           *    {@link ng.$compile#directive-definition-object directive definition object})
515
           *
516
           * @description
517
           * See {@link ng.$compileProvider#component $compileProvider.component()}.
518
           */
519
          component: invokeLaterAndSetModuleName('$compileProvider', 'component'),
520
521
          /**
522
           * @ngdoc method
523
           * @name angular.Module#config
524
           * @module ng
525
           * @param {Function} configFn Execute this function on module load. Useful for service
526
           *    configuration.
527
           * @description
528
           * Use this method to register work which needs to be performed on module loading.
529
           * For more about how to configure services, see
530
           * {@link providers#provider-recipe Provider Recipe}.
531
           */
532
          config: config,
533
534
          /**
535
           * @ngdoc method
536
           * @name angular.Module#run
537
           * @module ng
538
           * @param {Function} initializationFn Execute this function after injector creation.
539
           *    Useful for application initialization.
540
           * @description
541
           * Use this method to register work which should be performed when the injector is done
542
           * loading all modules.
543
           */
544
          run: function(block) {
545
            runBlocks.push(block);
546
            return this;
547
          }
548
        };
549
550
        if (configFn) {
551
          config(configFn);
552
        }
553
554
        return moduleInstance;
555
556
        /**
557
         * @param {string} provider
558
         * @param {string} method
559
         * @param {String=} insertMethod
560
         * @returns {angular.Module}
561
         */
562
        function invokeLater(provider, method, insertMethod, queue) {
563
          if (!queue) queue = invokeQueue;
564
          return function() {
565
            queue[insertMethod || 'push']([provider, method, arguments]);
566
            return moduleInstance;
567
          };
568
        }
569
570
        /**
571
         * @param {string} provider
572
         * @param {string} method
573
         * @returns {angular.Module}
574
         */
575
        function invokeLaterAndSetModuleName(provider, method, queue) {
576
          if (!queue) queue = invokeQueue;
577
          return function(recipeName, factoryFunction) {
578
            if (factoryFunction && isFunction(factoryFunction)) factoryFunction.$$moduleName = name;
579
            queue.push([provider, method, arguments]);
580
            return moduleInstance;
581
          };
582
        }
583
      });
584
    };
585
  });
586
587
}
588
589
setupModuleLoader(window);
590
})(window);
591
592
/**
593
 * Closure compiler type information
594
 *
595
 * @typedef { {
596
 *   requires: !Array.<string>,
597
 *   invokeQueue: !Array.<Array.<*>>,
598
 *
599
 *   service: function(string, Function):angular.Module,
600
 *   factory: function(string, Function):angular.Module,
601
 *   value: function(string, *):angular.Module,
602
 *
603
 *   filter: function(string, Function):angular.Module,
604
 *
605
 *   init: function(Function):angular.Module
606
 * } }
607
 */
608
angular.Module;
0 ignored issues
show
The result of the property access to angular.Module is not used.
Loading history...
609
610