mirror of
https://github.com/NuSkooler/enigma-bbs.git
synced 2025-06-06 12:47:13 +02:00
* New Address class for FTN addresses + experiment with ES6 classes
* Move a lot of address functionality/parsing/etc. to Address * WIP on ftn_bso scan/tosser * PATH and SEEN-BY creation, parsing, etc.
This commit is contained in:
parent
7b5ab029f9
commit
13d5c4d8f4
6 changed files with 605 additions and 139 deletions
|
@ -1,14 +1,16 @@
|
|||
/* jslint node: true */
|
||||
'use strict';
|
||||
|
||||
var miscUtil = require('./misc_util.js');
|
||||
let miscUtil = require('./misc_util.js');
|
||||
|
||||
let iconv = require('iconv-lite');
|
||||
|
||||
exports.stylizeString = stylizeString;
|
||||
exports.pad = pad;
|
||||
exports.replaceAt = replaceAt;
|
||||
exports.isPrintable = isPrintable;
|
||||
exports.debugEscapedString = debugEscapedString;
|
||||
exports.stylizeString = stylizeString;
|
||||
exports.pad = pad;
|
||||
exports.replaceAt = replaceAt;
|
||||
exports.isPrintable = isPrintable;
|
||||
exports.debugEscapedString = debugEscapedString;
|
||||
exports.stringFromNullTermBuffer = stringFromNullTermBuffer;
|
||||
|
||||
// :TODO: create Unicode verison of this
|
||||
var VOWELS = [ 'a', 'e', 'i', 'o', 'u' ];
|
||||
|
@ -176,6 +178,23 @@ function debugEscapedString(s) {
|
|||
return JSON.stringify(s).slice(1, -1);
|
||||
}
|
||||
|
||||
function stringFromNullTermBuffer(buf, encoding) {
|
||||
/*var nullPos = buf.length;
|
||||
for(var i = 0; i < buf.length; ++i) {
|
||||
if(0x00 === buf[i]) {
|
||||
nullPos = i;
|
||||
break;
|
||||
}
|
||||
}
|
||||
*/
|
||||
let nullPos = buf.indexOf(new Buffer( [ 0x00 ] ));
|
||||
if(-1 === nullPos) {
|
||||
nullPos = buf.length;
|
||||
}
|
||||
|
||||
return iconv.decode(buf.slice(0, nullPos), encoding || 'utf-8');
|
||||
}
|
||||
|
||||
//
|
||||
// Extend String.format's object syntax with some modifiers
|
||||
// e.g.: '{username!styleL33t}'.format( { username : 'Leet User' } ) -> "L33t U53r"
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue