From 7d44d7868db308e7d027da0daea19abc9adc02c3 Mon Sep 17 00:00:00 2001 From: brianc Date: Mon, 29 Aug 2011 22:52:16 -0500 Subject: [PATCH] move functions to increase readability --- lib/types.js | 27 +++++++++++++-------------- 1 file changed, 13 insertions(+), 14 deletions(-) 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);