const getEventForView = (event) => { const type = _ .chain(event) .get('event_type') .split('.') .last() .value(); const name = _.get(event, 'property_name'); const value = _.get(event, 'property_value'); return {type, name, value}; }
function replaceInterface(name, content, interfaceDescription) { var replaceFn = interfaceDescription.dhcp? formatDhcpConfig : formatConfig; return excludeInterface(name, content).trim() + '\n\n' + replaceFn(_.extend({ name: name }, interfaceDescription)) + '\n'; }
function excludeInterface(name, content) { var without = _.curry(function (name, content) { return !_.includes(content, name); }); return _.chain(content) .split('\n\n') .filter(without(name)) .join('\n\n').trim(); }
_ .chain(events) .map((event) => { const propertyName = getStringValueForSQL(event.propertyName); const propertyValue = getStringValueForSQL(event.propertyValue); return `(${event.eventId}, "${event.subscriptionType}", ${propertyName}, ${propertyValue}, ${event.objectId}, ${event.occurredAt})` }) .join(',') .value()
/** * extract broadcast addr * @param {string} line * @return {string,null} xxx.xxx.xxx.xxx */ function getBroadcastAddr(line) { if (!_.includes(line, BCAST)) { return null; } // inet adr:1.1.1.77 Bcast:1.1.1.255 Masque:1.1.1.0 // @todo oh boy. this is ugly. return _.chain(line) .split(BCAST) .slice(1) .first() .value() .substring(1) .split(' ')[0]; }
_.chain(os.networkInterfaces()) .values() .flatten() .filter(function(val) { return (val.family == 'IPv4' && val.internal == false) }) .map('address') .first() .value()