Skip to content

Commit 7d44d78

Browse files
committed
move functions to increase readability
1 parent f888f3b commit 7d44d78

File tree

1 file changed

+13
-14
lines changed

1 file changed

+13
-14
lines changed

lib/types.js

Lines changed: 13 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,24 +1,10 @@
11
//maps types from javascript to postgres and vise-versa
22

3-
var typeParsers = {};
4-
//registers a method used to parse a string representing a particular
5-
//oid type into a javascript type
6-
var registerStringTypeParser = function(oid, converter) {
7-
typeParsers[oid] = converter;
8-
};
9-
103
//the empty parse function
114
var noParse = function(val) {
125
return val;
136
}
147

15-
//returns a function used to convert a specific type (specified by
16-
//oid) into a result javascript type
17-
var getStringTypeParser = function(oid) {
18-
return typeParsers[oid] || noParse;
19-
};
20-
21-
228
//parses PostgreSQL server formatted date strings into javascript date objects
239
var parseDate = function(isoDate) {
2410
//TODO this could do w/ a refactor
@@ -128,6 +114,19 @@ var parseByteA = function(val) {
128114
}).replace(/\\\\/g, "\\"), "binary");
129115
}
130116

117+
var typeParsers = {};
118+
//registers a method used to parse a string representing a particular
119+
//oid type into a javascript type
120+
var registerStringTypeParser = function(oid, converter) {
121+
typeParsers[oid] = converter;
122+
};
123+
124+
//returns a function used to convert a specific type (specified by
125+
//oid) into a result javascript type
126+
var getStringTypeParser = function(oid) {
127+
return typeParsers[oid] || noParse;
128+
};
129+
131130
//default string type parser registrations
132131
registerStringTypeParser(20, parseInt);
133132
registerStringTypeParser(21, parseInt);

0 commit comments

Comments
 (0)