mirror of
https://github.com/embarklabs/neo-blessed.git
synced 2025-02-02 14:14:41 +00:00
refactor. assert.
This commit is contained in:
parent
51bc7c388c
commit
f7a569c628
21
lib/tput.js
21
lib/tput.js
@ -132,7 +132,7 @@ Tput.prototype.parseTerminfo = function(data) {
|
||||
o = 0;
|
||||
for (; i < l; i++) {
|
||||
v = Tput.bools[o++];
|
||||
info.bools[v] = !!data[i];
|
||||
info.bools[v] = data[i] === 1;
|
||||
}
|
||||
|
||||
// Null byte in between to make sure numbers begin on an even byte.
|
||||
@ -179,9 +179,8 @@ Tput.prototype.parseTerminfo = function(data) {
|
||||
|
||||
while (data[j]) j++;
|
||||
|
||||
// assert.ok(j < data.length);
|
||||
// assert.ok(j < data.length, 'Expected ' + j + ' < ' + data.length);
|
||||
if (j >= data.length) {
|
||||
// throw new Error('Error parsing terminfo.');
|
||||
delete info.strings[key];
|
||||
return;
|
||||
}
|
||||
@ -284,7 +283,7 @@ Tput.prototype.parseExtended = function(data) {
|
||||
var _bools = [];
|
||||
l = i + h.boolCount;
|
||||
for (; i < l; i++) {
|
||||
_bools.push(!!data[i]);
|
||||
_bools.push(data[i] === 1);
|
||||
}
|
||||
|
||||
// Null byte in between to make sure numbers begin on an even byte.
|
||||
@ -333,9 +332,8 @@ Tput.prototype.parseExtended = function(data) {
|
||||
|
||||
while (data[j]) j++;
|
||||
|
||||
// assert.ok(j < data.length);
|
||||
// assert.ok(j < data.length, 'Expected ' + j + ' < ' + data.length);
|
||||
if (j >= data.length) {
|
||||
// throw new Error('Error parsing terminfo.');
|
||||
_strings[k] = '';
|
||||
return;
|
||||
}
|
||||
@ -365,21 +363,26 @@ Tput.prototype.parseExtended = function(data) {
|
||||
}
|
||||
|
||||
// Identify by name
|
||||
j = 0;
|
||||
|
||||
info.bools = {};
|
||||
_bools.forEach(function(bool) {
|
||||
info.bools[sym.shift()] = bool;
|
||||
info.bools[sym[j++]] = bool;
|
||||
});
|
||||
|
||||
info.numbers = {};
|
||||
_numbers.forEach(function(number) {
|
||||
info.numbers[sym.shift()] = number;
|
||||
info.numbers[sym[j++]] = number;
|
||||
});
|
||||
|
||||
info.strings = {};
|
||||
_strings.forEach(function(string) {
|
||||
info.strings[sym.shift()] = string;
|
||||
info.strings[sym[j++]] = string;
|
||||
});
|
||||
|
||||
// Should be the very last bit of data.
|
||||
assert.equal(i, data.length);
|
||||
|
||||
return info;
|
||||
};
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user