Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
fs.readFile("bitsy-with-arabic.ttx", "utf8", function(err, data) {
// console.log(data);
// console.log(xml2js);
xml2js.parseString(data, function(err, result) {
var bitsyFontData = "FONT arabic\n";
var font = result.ttFont;
var head = font.head[0];
function getHeadValue(id) {
return head[id][0]["$"]["value"];
}
var unitsPerEm = getHeadValue("unitsPerEm");
var pixelsPerEm = getHeadValue("lowestRecPPEM");
// 8 / 4096 = 0.001953125
// 4096 / 8 = 512
var pixelsPerUnit = pixelsPerEm / unitsPerEm; // pixelsPerUnit = 0.001953125
var unitsPerPixel = unitsPerEm / pixelsPerEm; // unitsPerPixel = 512
request.on('end', function () {
// Attempt to parse the XML
parseString(body, {trim: true}, function (err, result) {
// Log the body of the request
//var jsonResult = JSON.parse(result);
var fullResult = util.inspect(result, false, null);
if(err){
winston.error("Parse error" + err);
}
if(typeof result["JMF"]["Signal"][0]["DeviceInfo"] !== 'undefined'){
winston.info('Subscription Update', {
DeviceID: result["JMF"]["Signal"][0]["DeviceInfo"][0]["$"]["DeviceID"],
DeviceStatus: result["JMF"]["Signal"][0]["DeviceInfo"][0]["$"]["DeviceStatus"],
StatusDetails: result["JMF"]["Signal"][0]["DeviceInfo"][0]["$"]["StatusDetails"],
ProductionCounter: result["JMF"]["Signal"][0]["DeviceInfo"][0]["$"]["ProductionCounter"]
}
request.get(location.href, function(err, res, xml) {
if (!err) {
xml2js.parseString(xml, function(err, json) {
if (!err && json && json.root) {
var device = { ip: location.hostname, port: location.port };
for (var key in json.root.device[0]) {
device[key] = json.root.device[0][key][0];
}
if (device.deviceType == "urn:Belkin:device:bridge:1") {
//console.log( device.ip + ' -' + device.deviceType);
var ip = device.ip;
var port = device.port;
var udn = device.UDN;
var postoptions = {
host: ip,
port: port,
path: getenddevs.path,
method: 'POST',
headers: {
function onend() {
if (!to_s) {
var buf = Buffer.concat(bufs);
xml2js.parseString(buf, cb);
} else {
xml2js.parseString(data, cb);
}
}
}
function makeObjFromXml(xml, methodName, log, bc){
xml2js.parseString(xml, {explicitArray:false, ignoreAttrs:true}, function(err, result){
if(err){
return bc(err, null);
}
if(result === null || result === undefined){
if(log.isLevelEnabled('error')){
log.runLog('error', methodName, 'xml [' + xml + '] is not well-format');
}
return bc(new Error('xml is not well format'), null);
}
bc(null, result);
});
}
function parseAsXml(database, callback) {
database = xml2js.parseString(database, {explicitArray: false}, function(err, database) {
if(err) return callback(new Errors.Database('Could not parse database as XML: ' + err.toString()));
return callback(null, database);
});
}.$bind(this),
new Promise((resolve, reject) =>
parseString(i, (e, p) => (e ? reject(e) : resolve(p)))
);
return await new Promise((resolve, reject) => {
xml2js.parseString(buildXml, (err, buildObj) => {
if (err) {
reject(err);
}
const build: Build = Build.fromRestParcedObject(buildObj);
resolve(build);
});
});
}
return new Promise(function(resolve, reject) {
xml2js.parseString(xml, {trim: true}, function(err, content) {
if (err) {reject(err);}
else {resolve(content);}
});
});
};