diff --git a/lib/types.js b/lib/types.js index 832e7bfc..6f7d6b9a 100644 --- a/lib/types.js +++ b/lib/types.js @@ -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);