-
Notifications
You must be signed in to change notification settings - Fork 6
Expand file tree
/
Copy pathbooleanType.js
More file actions
36 lines (31 loc) · 885 Bytes
/
Copy pathbooleanType.js
File metadata and controls
36 lines (31 loc) · 885 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
var DataType = require("./common").DataType;
var chars = require("./common").chars;
var char = require("./common").char;
function BooleanType(fName, defaultVal){
this._name = fName;
this._type = DataType.BOOLEAN;
this._decodeChar = {};
this._decodeChar[char(175)] = null;
this._decodeChar[char(184)] = defaultVal;
this._decodeChar[char(181)] = true;
this._decodeChar[char(183)] = false;
}
BooleanType.prototype._encode = function(v){
if(v){
return chars.yes;
}else if(v === false){
return chars.no;
}else if(v === undefined){
return chars.missingPremitive;
}else if(v === null){
return chars.nilPremitive;
}
//return booleanValues[v];
};
BooleanType.prototype._decode = function(v,i){
return {
index: i+1,
value: this._decodeChar[ v[i] ]
}
};
module.exports = BooleanType;