Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
require("v8").setFlagsFromString('--expose_gc');
var gc = require("vm").runInNewContext('gc');
var fs = require('fs')
, path = require('path')
, test = require('tape')
, cv = require('../lib/opencv');
var IMAGE_PATH = path.resolve(__dirname, '../examples/files', 'mona.png');
var VIDEO_PATH = path.resolve(__dirname, '../examples/files', 'motion.mov');
var TEMP_SAVE_PATH = path.resolve(__dirname, '../examples/tmp', 'out.jpg');
var TEMP_VIDEO_PATH = path.resolve(__dirname, '../examples/tmp', 'out.mp4');
// These tests check that every function that creates or modifies a Matrix handles its externally tracked memory correctly.
// Since the memory tracker uses OpenCV's reference counting to determine when to tell Node about memory changes,
// it is important that only Matrix objects that Javascript knows about retain references to internal OpenCV Mat objects.
// Reference counts for newly created objects should ususally therefore be 1, and releasing them should alter the
/* Tested to be working with the TPB dump at best. Extremely fast, zero Memory leaks and no garbage collection needed.
* Process exits immediately. Put together to work with papaparse */
const fs = require('fs');
const path = require('path');
const zlib = require('zlib');
require('v8').setFlagsFromString('--harmony'); //To fix the regex Lookbehind issue
// Keep the application from crashing on unexpected errors
process.on('uncaughtException', function (error) {
console.log(error);
process.send(['import-failed', 'general']); //mainWindow.webContents.send('import-failed', 'general');
});
let args = process.argv.slice(2);
let isUpd = (args[0] === 'true');
let filePath = args[1];
let timestamp = args[2];
let keepDL = (args[3] === 'true');
let stagePath = path.join(process.cwd(), 'data', 'stage.csv');
let extract = path.join(process.cwd(), 'data', 'downloads', 'torrent_dump_full.csv');
let totalLines = 0;
private _runGarbageCollector() {
const isGarbageCollectorHidden = !global.gc;
// GC is usually hidden, so we have to expose it before running.
setFlagsFromString('--expose-gc');
runInNewContext('gc')();
// The GC was not initially exposed, so let's hide it again.
if (isGarbageCollectorHidden) {
setFlagsFromString('--no-expose-gc');
}
}
}
};
}
return req_(id, cache)
}
var nm = {
exports: {},
loading: true,
loaded: false,
filename: id + '.js'
}
cache[id] = nm
var fn
var setV8Flags = false
try {
require('v8').setFlagsFromString('--allow_natives_syntax')
setV8Flags = true
} catch (e) {}
try {
/* istanbul ignore else */
if (ContextifyScript) {
fn = runInThisContext(source, {
filename: nm.filename,
lineOffset: 0,
displayErrors: true
});
} else {
fn = runInThisContext(source, nm.filename, true);
}
fn(nm.exports, cachingRequire, nm, nm.filename)
nm.loaded = true
} finally {
function useOld(n, input) {
// Force-optimize url.parse() so that the benchmark doesn't get
// disrupted by the optimizer kicking in halfway through.
url.parse(input);
v8.setFlagsFromString('--allow_natives_syntax');
eval('%OptimizeFunctionOnNextCall(url.parse)');
bench.start();
for (var i = 0; i < n; i += 1)
url.parse(input);
bench.end(n);
}
function main(conf) {
var n = conf.n | 0;
var href = hrefs[conf.href];
var path = paths[conf.path];
// Force-optimize url.resolve() so that the benchmark doesn't get
// disrupted by the optimizer kicking in halfway through.
url.resolve(href, path);
v8.setFlagsFromString('--allow_natives_syntax');
eval('%OptimizeFunctionOnNextCall(url.resolve)');
bench.start();
for (var i = 0; i < n; i += 1)
url.resolve(href, path);
bench.end(n);
}
var inputs = {
one: 'http://nodejs.org/docs/latest/api/url.html#url_url_format_urlobj',
two: 'http://blog.nodejs.org/',
three: 'https://encrypted.google.com/search?q=url&q=site:npmjs.org&hl=en',
four: 'javascript:alert("node is awesome");',
five: 'some.ran/dom/url.thing?oh=yes#whoo',
six: 'https://user:pass@example.com/',
};
var input = inputs[type] || '';
// Force-optimize url.parse() so that the benchmark doesn't get
// disrupted by the optimizer kicking in halfway through.
for (var name in inputs)
url.parse(inputs[name]);
v8.setFlagsFromString('--allow_natives_syntax');
eval('%OptimizeFunctionOnNextCall(url.parse)');
bench.start();
for (var i = 0; i < n; i += 1)
url.parse(input);
bench.end(n);
}
};
}
return req_(id, cache)
}
var nm = {
exports: {},
loading: true,
loaded: false,
filename: id + '.js'
}
cache[id] = nm
var fn
var setV8Flags = false
try {
require('v8').setFlagsFromString('--allow_natives_syntax')
setV8Flags = true
} catch (e) {}
try {
/* istanbul ignore else */
if (ContextifyScript) {
fn = runInThisContext(source, {
filename: nm.filename,
lineOffset: 0,
displayErrors: true
});
} else {
fn = runInThisContext(source, nm.filename, true);
}
fn(nm.exports, cachingRequire, nm, nm.filename)
nm.loaded = true
} finally {
assert.throws(function() { v8.setFlagsFromString(1); },
/^TypeError: v8 flag must be a string$/);
() => v8.setFlagsFromString(value),
{