Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
test('emit on source before destination', t => {
t.plan(2)
const source = new EventEmitter()
const dest = new EventEmitter()
// Set up test case for "propagate all"
// `count` should have been incremented by handler on source when handler on dest is invoked
let count = 0
propagate(source, dest)
source.on('event', () => {
count++
})
dest.on('event', () => {
t.equal(count, 1, 'emit on source first')
})
// Emit the events for assertion
t.true(source.emit('event'))
})
require('./apps/dropub.json'),
require('./apps/stickers.json')
// require('./apps/pixel-pad.json')
]
const bongBongInput = require('./bong-bong-input')
const bongBongText = require('./bong-bong-text')
const bongBongSettings = require('./bong-bong-settings')
const bongBongImage = require('./bong-bong-image')
const bongBongMore = require('./bong-bong-more')
const bongBongApp = require('./bong-bong-app')
const bongLogin = require('./login')
const tick = require('./timers')
const defaultStorage = new EventEmitter()
defaultStorage.get = key => localStorage[key]
defaultStorage.set = (key, value) => {
localStorage[key] = value
defaultStorage.emit(key, value)
}
const uuid = a => {
return a ? (a ^ Math.random() * 16 >> a / 4).toString(16)
: ([1e7] + -1e3 + -4e3 + -8e3 + -1e11).replace(/[018]/g, uuid)
}
const instant = {behavior: 'instant'}
function findFrame (event) {
let frames = document.getElementsByTagName('iframe')
for (var i = 0; i < frames.length; i++) {
before: function() {
this.fakeFfmpeg = new EventEmitter();
this.fakeFfmpeg.stdin = new EventEmitter();
this.fakeFfmpeg.stdin.write = sinon.stub();
this.fakeFfmpeg.stdin.end = sinon.stub();
this.fakeFfmpeg.stdout = {pipe: sinon.spy()};
this.fakeFfmpeg.stderr = {pipe: sinon.spy()};
this.fakeSpawn = sinon.stub();
this.fakeSpawn.returns(this.fakeFfmpeg);
this.fakePngSplitter = new EventEmitter();
this.fakeFrameRate = 23;
this.fakeBuffer1 = new Buffer('123');
this.fakeBuffer2 = new Buffer('456');
this.fakeLog = {};
this.encoder = new PngEncoder({
spawn : this.fakeSpawn,
frameRate : this.fakeFrameRate,
pngSplitter : this.fakePngSplitter,
log : this.fakeLog,
});
},
it('should emit db Object with an EventEmitter', (done) => {
const mediator = new EventEmitter()
mediator.on('db.ready', (db) => {
db.admin().listDatabases((err, dbs) => {
test.equal(null, err)
test.ok(dbs.databases.length > 0)
console.log(dbs.databases)
db.close()
done()
})
})
mediator.on('db.error', (err) => {
console.log(err)
})
mongo.connect(dbSettings, mediator)
const events = require('events')
const emitter = new events.EventEmitter()
emitter.once('killall', signal =>
console.log('Killing all processes with signal ', signal)
)
emitter.setMaxListeners(50)
module.exports = emitter
if (typeof(options) === 'function') {
callback = options;
options = {};
}
var parser = new(less.Parser)(options),
ee;
if (callback) {
parser.parse(input, function (e, root) {
try { callback(e, root && root.toCSS && root.toCSS(options)); }
catch (err) { callback(err); }
});
} else {
ee = new (require('events').EventEmitter)();
process.nextTick(function () {
parser.parse(input, function (e, root) {
if (e) { return ee.emit('error', e); }
try { ee.emit('success', root.toCSS(options)); }
catch (err) { ee.emit('error', err); }
});
});
return ee;
}
},
formatError: function(ctx, options) {
const makeRequest = () => {
const ee: any = new events.EventEmitter();
ee.path = '/foo';
ee.method = 'post';
ee.queries = { foo: 'bar' };
ee.headers = {
foo: 'bar'
};
return ee;
};
xss.netcode.Server = function() {
this.emitter = new events.EventEmitter();
this.roomManager = new xss.room.ServerRoomManager(this);
this.ws = this.start();
};
this.services = function() {
var services = new EventEmitter()
, self = this
services.start = function() {
if (this.key) {
log.warn('services isn\'t available using the pro endpoints')
}
if (typeof(this._services) == 'undefined') {
var host = parse_host(self.host)
simple_request(host, 'GET'
, '/1/services/javascript'
, {'User-Agent': self.user_agent, 'Host': host.hostname}
, self.timeout )
.on('complete', function services_complete(response, data) {
try {
self._services = JSON.parse(data)