Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
DebugTarget.prototype.sendCommand = function(command, args) {
// Construct packet object.
var packet = {
'seq': ++this.nextTargetSeqId_,
'type': 'request',
'command': command
};
if (args) {
packet['arguments'] = args;
}
// Stash promise.
var promise = new Promise((function(resolve, reject) {
this.pendingTargetPromises_[packet['seq']] = {
resolve: resolve,
reject: reject
};
}).bind(this));
// Send the data.
var packetString = JSON.stringify(packet);
var packetLength = packetString.length;
this.targetSocket_.write(
'Content-Length: ' + packetLength + '\r\n\r\n' +
packetString);
if (this.argv_['log-network']) {
console.log('[->V8]', packetString);
}
function updateRuleFile(name: string, rule: IRule): Promise {
const baseUrl = 'https://github.com/buzinas/tslint-eslint-rules/blob/master';
const docFileName = `src/docs/rules/${name}Rule.md`;
return new Promise((fulfill, reject) => {
fs.readFile(docFileName, 'utf8', (readErr, data) => {
rule.tslintUrl = rule.tslintUrl || `${baseUrl}/${docFileName}`;
let content = readErr || !data ? '' : data;
content = content.replace(
/^$/gm,
[
'\n',
createRuleContent(rule),
'\n' + (readErr ? '\n' : '')
].join('')
);
fs.writeFile(docFileName, content, { encoding: 'utf8' }, (writeErr) => {
if (writeErr) {
return reject(writeErr);
}
console.log(` - ${name}`);
var readArticles = function(dir) {
return new Promise(function(resolve, reject) {
fs.readdir(dir, function(err, files) {
if (err) {
console.error('Error loading articles', err);
}
resolve(files.map(function (file) {
return {
path: dir,
filename: file
};
}));
});
});
};
public read():Promise {
if (!this.isEmpty) {
let content = this.content.shift();
this.emit('release', content);
if (this.isEmpty) {
this.emit('empty');
if (this.sealed) this.emit('end');
}
return Promise.resolve(content);
}
return new Promise(resolve => {
this.once('write', () => resolve(this.read()));
});
}
function getWhoisDomain(domain, server, port) {
if(!domain) throw new Error('`domain` is required');
if(!server) throw new Error('`server` is required');
const socket = new net.Socket();
const encoding = 'utf8'
if(!port) { port = 43 }
let responseText = '';
return new Promise((resolve, reject) => {
socket.setEncoding(encoding);
socket.connect(port, server, () => {
socket.end(domain + '\r\n', encoding);
});
socket.on('data', data => {
resolve(data);
});
socket.on('error', error => {
reject(error);
});
});
}
var getScreenDeviceId = function (constraints) {
return new Promise(function (resolve, reject) {
var o = {};
if (window.chrome) {
chrome.runtime.sendMessage(extensionId, {type: "isInstalled"}, function (response) {
if (response) {
o.maxWidth = constraints.video.width;
o.maxHeight = constraints.video.height;
o.maxFrameRate = constraints.video.frameRate.max;
o.chromeMediaSource = "desktop";
chrome.runtime.sendMessage(extensionId, {type: "getSourceId"}, function (response) {
if (response.error) {
reject(new Error("Screen access denied"));
} else {
o.chromeMediaSourceId = response.sourceId;
resolve({mandatory: o});
}
});
function invalidateCache (cacheId) {
return new Promise(function (resolve, reject) {
if (cacheId && typeof cacheId !== 'string') {
reject(Error('cacheId option of type string expected, got \'' + typeof cacheId + '\''))
} else {
var cachPath = cacheId ? path.join(options.cachePath, cacheId) : options.cachePath
rmdir(cachPath, function (err) {
if (err) {
reject(err)
} else {
resolve()
}
})
}
})
}
function askForGitRepo(gitRepo){
return new Promise(function(resolve){
if (gitRepo && gitRepo.length>0) resolve(gitRepo);
prompt.start();
prompt.get([{
description: 'GitHub Repository URL'.bgBlack.white + ' (leave blank if none)'.bgBlack.white.dim,
name: 'repo',
default: git.checkRemote() || ''
}], function(err, result) {
if (!result) return resolve('');
resolve(git.validRepo(result.repo));
});
});
}
app.get('/test/3', function(req, res){
var promise = res.pdf(path.resolve(__dirname, './fixture/test.pdf'));
expect(promise).not.toBeUndefined();
expect(promise).toEqual(jasmine.any(Promise));
promise.then(function(){
expect(true).toEqual(true);
finish();
}, function(){
expect('should not call catch').toBe(true);
finish();
});
});
server = app.listen(8888);
function compareToTSLint() {
return new es6_promise_1.Promise(function (fulfill) {
requestFromGithub('/repos/palantir/tslint/contents/src/rules', function (data) {
var rules = data
.filter(function (obj) { return obj.name.endsWith('.ts'); })
.map(function (obj) { return obj.name.substring(0, obj.name.length - 7); });
var notInUse = require('../../src/readme/unusedTSLintRules.json');
notInUse.forEach(function (name) {
var camel = rules_1.toCamelCase(name);
var index = rules.indexOf(camel);
if (index > -1) {
rules.splice(index, 1);
}
});
var tsRules = Object.keys(rules_1.ruleTSMap);
var missing = arrayDiff(rules, tsRules);
var buffer = [];
if (missing.length) {