move functions to increase readability

This commit is contained in:
brianc 2011-08-29 22:52:16 -05:00
parent f888f3b947
commit 7d44d7868d

View File

@ -1,24 +1,10 @@
//maps types from javascript to postgres and vise-versa
var typeParsers = {};
//registers a method used to parse a string representing a particular
//oid type into a javascript type
var registerStringTypeParser = function(oid, converter) {
typeParsers[oid] = converter;
};
//the empty parse function
var noParse = function(val) {
return val;
}
//returns a function used to convert a specific type (specified by
//oid) into a result javascript type
var getStringTypeParser = function(oid) {
return typeParsers[oid] || noParse;
};
//parses PostgreSQL server formatted date strings into javascript date objects
var parseDate = function(isoDate) {
//TODO this could do w/ a refactor
@ -128,6 +114,19 @@ var parseByteA = function(val) {
}).replace(/\\\\/g, "\\"), "binary");
}
var typeParsers = {};
//registers a method used to parse a string representing a particular
//oid type into a javascript type
var registerStringTypeParser = function(oid, converter) {
typeParsers[oid] = converter;
};
//returns a function used to convert a specific type (specified by
//oid) into a result javascript type
var getStringTypeParser = function(oid) {
return typeParsers[oid] || noParse;
};
//default string type parser registrations
registerStringTypeParser(20, parseInt);
registerStringTypeParser(21, parseInt);