MCPcopy Index your code
hub / github.com/angular-ui/ui-router / serialize

Function serialize

test/angular/1.5/angular-mocks.js:955–986  ·  view source on GitHub ↗
(object)

Source from the content-addressed store, hash-verified

953 return serialize(object);
954
955 function serialize(object) {
956 var out;
957
958 if (angular.isElement(object)) {
959 object = angular.element(object);
960 out = angular.element('<div></div>');
961 angular.forEach(object, function(element) {
962 out.append(angular.element(element).clone());
963 });
964 out = out.html();
965 } else if (angular.isArray(object)) {
966 out = [];
967 angular.forEach(object, function(o) {
968 out.push(serialize(o));
969 });
970 out = '[ ' + out.join(', ') + ' ]';
971 } else if (angular.isObject(object)) {
972 if (angular.isFunction(object.$eval) && angular.isFunction(object.$apply)) {
973 out = serializeScope(object);
974 } else if (object instanceof Error) {
975 out = object.stack || ('' + object.name + ': ' + object.message);
976 } else {
977 // TODO(i): this prevents methods being logged,
978 // we should have a better way to serialize objects
979 out = angular.toJson(object, true);
980 }
981 } else {
982 out = String(object);
983 }
984
985 return out;
986 }
987
988 function serializeScope(scope, offset) {
989 offset = offset || ' ';

Callers 1

angular-mocks.jsFile · 0.70

Calls 1

serializeScopeFunction · 0.70

Tested by

no test coverage detected