MCPcopy
hub / github.com/angular-ui/ui-router / serialize

Function serialize

test/angular/1.4/angular-mocks.js:948–979  ·  view source on GitHub ↗
(object)

Source from the content-addressed store, hash-verified

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

Callers 1

angular-mocks.jsFile · 0.70

Calls 1

serializeScopeFunction · 0.70

Tested by

no test coverage detected