34255 lines · 1.2 MB · JavaScript
RawDownload
          dst[key] = src.cloneNode(true);        } else if (isElement(src)) {          dst[key] = src.clone();        } else {          if (!isObject(dst[key])) dst[key] = isArray(src) ? [] : {};          baseExtend(dst[key], [src], true);        }      } else {        dst[key] = src;      }    }  }   setHashKey(dst, h);  return dst;} /** * @ngdoc function * @name angular.extend * @module ng * @kind function * * @description * Extends the destination object `dst` by copying own enumerable properties from the `src` object(s) * to `dst`. You can specify multiple `src` objects. If you want to preserve original objects, you can do so * by passing an empty object as the target: `var object = angular.extend({}, object1, object2)`. * * **Note:** Keep in mind that `angular.extend` does not support recursive merge (deep copy). Use * {@link angular.merge} for this. * * @param {Object} dst Destination object. * @param {...Object} src Source object(s). * @returns {Object} Reference to `dst`. */function extend(dst) {  return baseExtend(dst, slice.call(arguments, 1), false);}  /*** @ngdoc function* @name angular.merge* @module ng* @kind function** @description* Deeply extends the destination object `dst` by copying own enumerable properties from the `src` object(s)* to `dst`. You can specify multiple `src` objects. If you want to preserve original objects, you can do so* by passing an empty object as the target: `var object = angular.merge({}, object1, object2)`.** Unlike {@link angular.extend extend()}, `merge()` recursively descends into object properties of source* objects, performing a deep copy.** @deprecated* sinceVersion="1.6.5"* This function is deprecated, but will not be removed in the 1.x lifecycle.* There are edge cases (see {@link angular.merge#known-issues known issues}) that are not* supported by this function. We suggest* using [lodash's merge()](https://lodash.com/docs/4.17.4#merge) instead.** @knownIssue* This is a list of (known) object types that are not handled correctly by this function:* - [`Blob`](https://developer.mozilla.org/docs/Web/API/Blob)* - [`MediaStream`](https://developer.mozilla.org/docs/Web/API/MediaStream)* - [`CanvasGradient`](https://developer.mozilla.org/docs/Web/API/CanvasGradient)* - AngularJS {@link $rootScope.Scope scopes};** @param {Object} dst Destination object.* @param {...Object} src Source object(s).* @returns {Object} Reference to `dst`.*/function merge(dst) {  return baseExtend(dst, slice.call(arguments, 1), true);}   function toInt(str) {  return parseInt(str, 10);} var isNumberNaN = Number.isNaN || function isNumberNaN(num) {  // eslint-disable-next-line no-self-compare  return num !== num;};  function inherit(parent, extra) {  return extend(Object.create(parent), extra);} /** * @ngdoc function * @name angular.noop * @module ng * @kind function * * @description * A function that performs no operations. This function can be useful when writing code in the * functional style.   ```js     function foo(callback) {       var result = calculateResult();       (callback || angular.noop)(result);     }   ``` */function noop() {}noop.$inject = [];  /** * @ngdoc function * @name angular.identity * @module ng * @kind function * * @description * A function that returns its first argument. This function is useful when writing code in the * functional style. *   ```js   function transformer(transformationFn, value) {     return (transformationFn || angular.identity)(value);   };    // E.g.   function getResult(fn, input) {     return (fn || angular.identity)(input);   };    getResult(function(n) { return n * 2; }, 21);   // returns 42   getResult(null, 21);                            // returns 21   getResult(undefined, 21);                       // returns 21   ``` * * @param {*} value to be returned. * @returns {*} the value passed in. */function identity($) {return $;}identity.$inject = [];  function valueFn(value) {return function valueRef() {return value;};} function hasCustomToString(obj) {  return isFunction(obj.toString) && obj.toString !== toString;}  /** * @ngdoc function * @name angular.isUndefined * @module ng * @kind function * * @description * Determines if a reference is undefined. * * @param {*} value Reference to check. * @returns {boolean} True if `value` is undefined. */function isUndefined(value) {return typeof value === 'undefined';}  /** * @ngdoc function * @name angular.isDefined * @module ng * @kind function * * @description * Determines if a reference is defined. * * @param {*} value Reference to check. * @returns {boolean} True if `value` is defined. */function isDefined(value) {return typeof value !== 'undefined';}  /** * @ngdoc function * @name angular.isObject * @module ng * @kind function * * @description * Determines if a reference is an `Object`. Unlike `typeof` in JavaScript, `null`s are not * considered to be objects. Note that JavaScript arrays are objects. * * @param {*} value Reference to check. * @returns {boolean} True if `value` is an `Object` but not `null`. */function isObject(value) {  // http://jsperf.com/isobject4  return value !== null && typeof value === 'object';}  /** * Determine if a value is an object with a null prototype * * @returns {boolean} True if `value` is an `Object` with a null prototype */function isBlankObject(value) {  return value !== null && typeof value === 'object' && !getPrototypeOf(value);}  /** * @ngdoc function * @name angular.isString * @module ng * @kind function * * @description * Determines if a reference is a `String`. * * @param {*} value Reference to check. * @returns {boolean} True if `value` is a `String`. */function isString(value) {return typeof value === 'string';}  /** * @ngdoc function * @name angular.isNumber * @module ng * @kind function * * @description * Determines if a reference is a `Number`. * * This includes the "special" numbers `NaN`, `+Infinity` and `-Infinity`. * * If you wish to exclude these then you can use the native * [`isFinite'](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/isFinite) * method. * * @param {*} value Reference to check. * @returns {boolean} True if `value` is a `Number`. */function isNumber(value) {return typeof value === 'number';}  /** * @ngdoc function * @name angular.isDate * @module ng * @kind function * * @description * Determines if a value is a date. * * @param {*} value Reference to check. * @returns {boolean} True if `value` is a `Date`. */function isDate(value) {  return toString.call(value) === '[object Date]';}  /** * @ngdoc function * @name angular.isArray * @module ng * @kind function * * @description * Determines if a reference is an `Array`. Alias of Array.isArray. * * @param {*} value Reference to check. * @returns {boolean} True if `value` is an `Array`. */var isArray = Array.isArray; /** * @description * Determines if a reference is an `Error`. * Loosely based on https://www.npmjs.com/package/iserror * * @param {*} value Reference to check. * @returns {boolean} True if `value` is an `Error`. */function isError(value) {  var tag = toString.call(value);  switch (tag) {    case '[object Error]': return true;    case '[object Exception]': return true;    case '[object DOMException]': return true;    default: return value instanceof Error;  }} /** * @ngdoc function * @name angular.isFunction * @module ng * @kind function * * @description * Determines if a reference is a `Function`. * * @param {*} value Reference to check. * @returns {boolean} True if `value` is a `Function`. */function isFunction(value) {return typeof value === 'function';}  /** * Determines if a value is a regular expression object. * * @private * @param {*} value Reference to check. * @returns {boolean} True if `value` is a `RegExp`. */function isRegExp(value) {  return toString.call(value) === '[object RegExp]';}  /** * Checks if `obj` is a window object. * * @private * @param {*} obj Object to check * @returns {boolean} True if `obj` is a window obj. */function isWindow(obj) {  return obj && obj.window === obj;}  function isScope(obj) {  return obj && obj.$evalAsync && obj.$watch;}  function isFile(obj) {  return toString.call(obj) === '[object File]';}  function isFormData(obj) {  return toString.call(obj) === '[object FormData]';}  function isBlob(obj) {  return toString.call(obj) === '[object Blob]';}  function isBoolean(value) {  return typeof value === 'boolean';}  function isPromiseLike(obj) {  return obj && isFunction(obj.then);}  var TYPED_ARRAY_REGEXP = /^\[object (?:Uint8|Uint8Clamped|Uint16|Uint32|Int8|Int16|Int32|Float32|Float64)Array]$/;function isTypedArray(value) {  return value && isNumber(value.length) && TYPED_ARRAY_REGEXP.test(toString.call(value));} function isArrayBuffer(obj) {  return toString.call(obj) === '[object ArrayBuffer]';}  var trim = function(value) {  return isString(value) ? value.trim() : value;}; // Copied from:// http://docs.closure-library.googlecode.com/git/local_closure_goog_string_string.js.source.html#line1021// Prereq: s is a string.var escapeForRegexp = function(s) {  return s    .replace(/([-()[\]{}+?*.$^|,:#<!\\])/g, '\\$1')    // eslint-disable-next-line no-control-regex    .replace(/\x08/g, '\\x08');};  /** * @ngdoc function * @name angular.isElement * @module ng * @kind function * * @description * Determines if a reference is a DOM element (or wrapped jQuery element). * * @param {*} value Reference to check. * @returns {boolean} True if `value` is a DOM element (or wrapped jQuery element). */function isElement(node) {  return !!(node &&    (node.nodeName  // We are a direct element.    || (node.prop && node.attr && node.find)));  // We have an on and find method part of jQuery API.} /** * @param str 'key1,key2,...' * @returns {object} in the form of {key1:true, key2:true, ...} */function makeMap(str) {  var obj = {}, items = str.split(','), i;  for (i = 0; i < items.length; i++) {    obj[items[i]] = true;  }  return obj;}  function nodeName_(element) {  return lowercase(element.nodeName || (element[0] && element[0].nodeName));} function includes(array, obj) {  return Array.prototype.indexOf.call(array, obj) !== -1;} function arrayRemove(array, value) {  var index = array.indexOf(value);  if (index >= 0) {    array.splice(index, 1);  }  return index;} /** * @ngdoc function * @name angular.copy * @module ng * @kind function * * @description * Creates a deep copy of `source`, which should be an object or an array. * * * If no destination is supplied, a copy of the object or array is created. * * If a destination is provided, all of its elements (for arrays) or properties (for objects) *   are deleted and then all elements/properties from the source are copied to it. * * If `source` is not an object or array (inc. `null` and `undefined`), `source` is returned. * * If `source` is identical to `destination` an exception will be thrown. * * <br /> * <div class="alert alert-warning"> *   Only enumerable properties are taken into account. Non-enumerable properties (both on `source` *   and on `destination`) will be ignored. * </div> * * @param {*} source The source that will be used to make a copy. *                   Can be any type, including primitives, `null`, and `undefined`. * @param {(Object|Array)=} destination Destination into which the source is copied. If *     provided, must be of the same type as `source`. * @returns {*} The copy or updated `destination`, if `destination` was specified. * * @example  <example module="copyExample" name="angular-copy">    <file name="index.html">      <div ng-controller="ExampleController">        <form novalidate class="simple-form">          <label>Name: <input type="text" ng-model="user.name" /></label><br />          <label>Age:  <input type="number" ng-model="user.age" /></label><br />          Gender: <label><input type="radio" ng-model="user.gender" value="male" />male</label>                  <label><input type="radio" ng-model="user.gender" value="female" />female</label><br />          <button ng-click="reset()">RESET</button>          <button ng-click="update(user)">SAVE</button>        </form>        <pre>form = {{user | json}}</pre>        <pre>leader = {{leader | json}}</pre>      </div>    </file>    <file name="script.js">      // Module: copyExample      angular.        module('copyExample', []).        controller('ExampleController', ['$scope', function($scope) {          $scope.leader = {};           $scope.reset = function() {            // Example with 1 argument            $scope.user = angular.copy($scope.leader);          };           $scope.update = function(user) {            // Example with 2 arguments            angular.copy(user, $scope.leader);          };           $scope.reset();        }]);    </file>  </example>

Lines 501–1000 of 34255. Previous lines

Keyboard shortcuts

General

Show keyboard shortcuts
?
Focus the current search
/

Issues and pull requests

Open filters
f

Issues, pull requests and Inbox

Select next item
j↓
Select previous item
k↑
Open selected item
Enter
Dismiss filters or clear selection
Esc

Repository code

Go to file
t