This repository was archived by the owner on Sep 29, 2025. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathbuffer.js
More file actions
57 lines (50 loc) · 1.5 KB
/
buffer.js
File metadata and controls
57 lines (50 loc) · 1.5 KB
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
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
var BufferField = require('./bufferfield.js'),
debug = require('debug'),
log = debug('n4p:buffer');
function Buffer(iTempTable,iMetaSchema,iDateFormat){
log( "Buffer create", iTempTable );
this.currentRecord = null;
this.tempTable = iTempTable;
this.metaSchema = iMetaSchema;
this.dateFormat = iDateFormat;
this.bufferField = new BufferField(this.dateFormat);
return this;
}
Buffer.prototype.setCurrentRecord = function(iCurrentRecord){
log( "Buffer:setCurrentRecord" );
this.currentRecord=iCurrentRecord;
};
Buffer.prototype.$ = function(fieldNm){
log( "Buffer:$", fieldNm );
var value = "";
var fieldMetaSchema = null;
for(var prop in this.currentRecord){
if(prop.toLowerCase() == fieldNm.toLowerCase()){
value=this.currentRecord[prop];
fieldMetaSchema=this.metaSchema[prop];
this.bufferField.setCurrenBufferField(prop,this.currentRecord,fieldMetaSchema);
break;
}
}
return this.bufferField;
};
Buffer.prototype.display = function(iFieldToDisplay){
log( "Buffer:display", iFieldToDisplay );
var fields = iFieldToDisplay.split(" ");
var fieldStr = "";
for(var i=0;i<fields.length;i++){
if(i>0){fieldStr+=" ";}
fieldStr+=this.$(fields[i]).$("screenValue");
}
return fieldStr;
};
Buffer.prototype.writeJson = function(){
var jsonStr="";
if(this.currentRecord){
jsonStr=JSON.stringify(this.currentRecord);
}
return jsonStr;
};
module.exports = function(iTempTable,iMetaSchema,iDateFormat) {
return new Buffer(iTempTable,iMetaSchema,iDateFormat);
};