Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
request(url, function (err, res, body) {
if (err) {
cb(err)
} else {
var res = []
var doc = new dom({errorHandler: function() {}}).parseFromString(body)
var tweets = xpath.select('//li[contains(@class, \'js-stream-item\')]', doc)
tweets.forEach(function (n) {
var tweet = xpath.select('./div[contains(@class, \'tweet\')]/div[contains(@class, \'content\')]', n)[0]
if (!tweet) {
// bad tweet?
return
}
var header = xpath.select('./div[contains(@class, \'stream-item-header\')]', tweet)[0]
var body = xpath.select('*/p[contains(@class, \'tweet-text\')]/text()', tweet)[0]
var fullname = xpath.select('.//strong[contains(@class, "fullname")]/text()', header)[0]
if (body) body = nodeToText(body)
var img = getImage(tweet)
function buildEntryFile(file) {
const contents = file.contents.toString();
const doc = new DOMParser().parseFromString(contents);
const select = xpath.useNamespaces({ 'proj': PROJ_NAMESPACE });
const items = select(XPATH_SELECTOR, doc).map(node => node.value);
const code = buildEntryCode(items);
// TODO wait for new version vinyl, see wearefractal/vinyl-fs#71
file.path = path.join(path.dirname(file.path), options.entryFileName);
file.contents = new Buffer(code);
return file;
}
function partitionData(ins, outs, config, cb) {
var xmlData = ins[0].data[0].value,
doc = new dom().parseFromString(xmlData),
xmlPath = "//Collection[@label='CollectionPoint']",
nodes = xpath.select(xmlPath, doc);
//onsole.log("DOC", doc);
//onsole.log("INS", JSON.stringify(ins, null, 2));
var timeWindowLength = 43200; // 12 hours
outs[0].data = [[]];
var t = 0, idx = 0, first = true;
var timestamp, humidity, tref;
nodes.forEach(function(node) {
if (t >= timeWindowLength) {
t -= timeWindowLength; idx += 1;
first = true;
}
var assert = require("assert");
var xmldom = require("xmldom");
var parser = new xmldom.DOMParser();
var domCompare = require("../");
var compare = domCompare.compare;
var reporter = domCompare.GroupingReporter;
describe("Differences reporting", function(){
describe("Grouping reporter", function(){
it("grouping differences by source node XPath", function(){
var doc = parser.parseFromString("");
var doc2 = parser.parseFromString("");
var failures = reporter.getDifferences(compare(doc, doc2));
assert.equal(3, Object.keys(failures).length);
this.send = function(ctx, response_callback) {
var doc = new Dom().parseFromString(ctx.request)
callback(ctx, doc, response_callback)
}
async function main() {
fontName = process.argv[2];
ligFontName = fontName.split('-').join('Lig-');
const srcFileName = `./original/${fontName}.ttx`;
const dstFileName = `./build/${ligFontName}.ttx`;
console.log(`Reading original font file ${srcFileName}`);
const xml = await fs.readFileAsync(srcFileName, 'utf-8');
const dom = new DOMParser().parseFromString(xml);
try {
await processPatch('names', patchNames, dom);
await processPatch('glyphs', patchGlyphs, dom);
await processPatch('gpos', patchGpos, dom);
await processPatch('gsub', patchGsub, dom);
await processPatch('hmtx', patchHmtx, dom);
//await processPatch('lookup', patchLookup, dom);
await processPatch('charstrings', patchCharStrings, dom);
} catch (err) {
console.log(err);
}
console.log(`Writing ligature font file ${dstFileName}`);
await fs.writeFileAsync(dstFileName, format(serialize(dom)));
console.log('Done');
async createDom() {
const xml = (await fs.readFile(this.girPath)).toString();
const parser = new DOMParser();
const doc = parser.parseFromString(xml, 'text/xml');
return doc.documentElement;
}
}
exports.normalizeSvg = function(svg, options) {
var svgDocNode = new DOMParser().parseFromString(svgPathify(svg), 'application/xml')
var svgNode = svgDocNode.getElementsByTagName('svg')[0]
//解决所有的变换,生成一个path
var path = Path.normalizePath(svgNode)
var trans = svgpath(path)
//根据目标viewbox进行变换
var targetHeight = options.targetHeight
if (targetHeight) {
var viewObj = Viewbox.generateAmendTrans(svgNode, targetHeight)
_.each(viewObj.transforms, function(viewTrans) {
trans[viewTrans[0]].apply(trans, viewTrans[1])
})
}
function initIosDir(){
if (!iosProjFolder || !iosPbxProjPath) {
var config = fs.readFileSync("config.xml").toString();
var configDoc = (new xmldom.DOMParser()).parseFromString(config, 'application/xml');
var name = getValue(configDoc, "name");
iosProjFolder = "platforms/ios/" + name;
iosPbxProjPath = "platforms/ios/" + name + ".xcodeproj/project.pbxproj";
}
}
async function loadConfigAsync(name) {
const fileName = `./ligature/${ligFontName}/${name}.xml`;
const xml = await fs.readFileAsync(fileName, 'utf-8');
return new DOMParser().parseFromString(xml);
}