MCPcopy Index your code
hub / github.com/JsAaron/jQuery / ajaxConvert

Function ajaxConvert

1.7/ajax.js:916–998  ·  view source on GitHub ↗
( s, response )

Source from the content-addressed store, hash-verified

914
915// Chain conversions given the request and the original response
916function ajaxConvert( s, response ) {
917
918 // Apply the dataFilter if provided
919 if ( s.dataFilter ) {
920 response = s.dataFilter( response, s.dataType );
921 }
922
923 var dataTypes = s.dataTypes,
924 converters = {},
925 i,
926 key,
927 length = dataTypes.length,
928 tmp,
929 // Current and previous dataTypes
930 current = dataTypes[ 0 ],
931 prev,
932 // Conversion expression
933 conversion,
934 // Conversion function
935 conv,
936 // Conversion functions (transitive conversion)
937 conv1,
938 conv2;
939
940 // For each dataType in the chain
941 for ( i = 1; i < length; i++ ) {
942
943 // Create converters map
944 // with lowercased keys
945 if ( i === 1 ) {
946 for ( key in s.converters ) {
947 if ( typeof key === "string" ) {
948 converters[ key.toLowerCase() ] = s.converters[ key ];
949 }
950 }
951 }
952
953 // Get the dataTypes
954 prev = current;
955 current = dataTypes[ i ];
956
957 // If current is auto dataType, update it to prev
958 if ( current === "*" ) {
959 current = prev;
960 // If no auto and dataTypes are actually different
961 } else if ( prev !== "*" && prev !== current ) {
962
963 // Get the converter
964 conversion = prev + " " + current;
965 conv = converters[ conversion ] || converters[ "* " + current ];
966
967 // If there is no direct converter, search transitively
968 if ( !conv ) {
969 conv2 = undefined;
970 for ( conv1 in converters ) {
971 tmp = conv1.split( " " );
972 if ( tmp[ 0 ] === prev || tmp[ 0 ] === "*" ) {
973 conv2 = converters[ tmp[1] + " " + current ];

Callers 1

doneFunction · 0.70

Calls

no outgoing calls

Tested by

no test coverage detected