Skip to content

Commit feaa0dc

Browse files
committed
reformatting
1 parent a3fc6ce commit feaa0dc

35 files changed

Lines changed: 4560 additions & 4258 deletions

examples/delayed.js

Lines changed: 19 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
var kue = require( '../' );
1+
var kue = require('../');
22

33
// create our job queue
44

@@ -8,35 +8,35 @@ var jobs = kue.createQueue();
88

99
var minute = 60000;
1010

11-
var email = jobs.create( 'email', {
11+
var email = jobs.create('email', {
1212
title: 'Account renewal required', to: 'tj@learnboost.com', template: 'renewal-email'
13-
} ).delay( minute )
14-
.priority( 'high' )
13+
}).delay(minute)
14+
.priority('high')
1515
.save();
1616

1717

18-
email.on( 'promotion', function () {
19-
console.log( 'renewal job promoted' );
20-
} );
18+
email.on('promotion', function() {
19+
console.log('renewal job promoted');
20+
});
2121

22-
email.on( 'complete', function () {
23-
console.log( 'renewal job completed' );
24-
} );
22+
email.on('complete', function() {
23+
console.log('renewal job completed');
24+
});
2525

26-
jobs.create( 'email', {
26+
jobs.create('email', {
2727
title: 'Account expired', to: 'tj@learnboost.com', template: 'expired-email'
28-
} ).delay( minute * 10 )
29-
.priority( 'high' )
28+
}).delay(minute * 10)
29+
.priority('high')
3030
.save();
3131

3232
jobs.promote();
3333

34-
jobs.process( 'email', 10, function ( job, done ) {
35-
setTimeout( function () {
34+
jobs.process('email', 10, function( job, done ) {
35+
setTimeout(function() {
3636
done();
37-
}, Math.random() * 5000 );
38-
} );
37+
}, Math.random() * 5000);
38+
});
3939

4040
// start the UI
41-
kue.app.listen( 3000 );
42-
console.log( 'UI started on port 3000' );
41+
kue.app.listen(3000);
42+
console.log('UI started on port 3000');

examples/events.js

Lines changed: 23 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
var kue = require( '../' );
1+
var kue = require('../');
22

33
// create our job queue
44

@@ -13,48 +13,48 @@ var jobs = kue.createQueue();
1313

1414
function create() {
1515
var name = [ 'tobi', 'loki', 'jane', 'manny' ][ Math.random() * 4 | 0 ];
16-
var job = jobs.create( 'video conversion', {
16+
var job = jobs.create('video conversion', {
1717
title: 'converting ' + name + '\'s to avi', user: 1, frames: 200
18-
} );
18+
});
1919

20-
job.on( 'complete', function () {
21-
console.log( " Job complete" );
22-
} ).on( 'failed', function () {
23-
console.log( " Job failed" );
24-
} ).on( 'progress', function ( progress ) {
25-
process.stdout.write( '\r job #' + job.id + ' ' + progress + '% complete' );
26-
} );
20+
job.on('complete', function() {
21+
console.log(" Job complete");
22+
}).on('failed', function() {
23+
console.log(" Job failed");
24+
}).on('progress', function( progress ) {
25+
process.stdout.write('\r job #' + job.id + ' ' + progress + '% complete');
26+
});
2727

2828
job.save();
2929

30-
setTimeout( create, Math.random() * 2000 | 0 );
30+
setTimeout(create, Math.random() * 2000 | 0);
3131
}
3232

3333
create();
3434

3535
// process video conversion jobs, 1 at a time.
3636

37-
jobs.process( 'video conversion', 1, function ( job, done ) {
37+
jobs.process('video conversion', 1, function( job, done ) {
3838
var frames = job.data.frames;
3939

4040
function next( i ) {
4141
// pretend we are doing some work
42-
convertFrame( i, function ( err ) {
43-
if ( err ) return done( err );
42+
convertFrame(i, function( err ) {
43+
if( err ) return done(err);
4444
// report progress, i/frames complete
45-
job.progress( i, frames );
46-
if ( i >= frames ) done()
47-
else next( i + Math.random() * 10 );
48-
} );
45+
job.progress(i, frames);
46+
if( i >= frames ) done()
47+
else next(i + Math.random() * 10);
48+
});
4949
}
5050

51-
next( 0 );
52-
} );
51+
next(0);
52+
});
5353

5454
function convertFrame( i, fn ) {
55-
setTimeout( fn, Math.random() * 50 );
55+
setTimeout(fn, Math.random() * 50);
5656
}
5757

5858
// start the UI
59-
kue.app.listen( 3000 );
60-
console.log( 'UI started on port 3000' );
59+
kue.app.listen(3000);
60+
console.log('UI started on port 3000');

examples/many.js

Lines changed: 18 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -1,44 +1,44 @@
1-
var kue = require( '../' )
2-
, express = require( 'express' );
1+
var kue = require('../')
2+
, express = require('express');
33

44
// create our job queue
55

66
var jobs = kue.createQueue();
77

88
function create() {
99
var name = [ 'tobi', 'loki', 'jane', 'manny' ][ Math.random() * 4 | 0 ];
10-
jobs.create( 'video conversion', {
10+
jobs.create('video conversion', {
1111
title: 'converting ' + name + '\'s to avi', user: 1, frames: 200
12-
} ).save();
13-
setTimeout( create, Math.random() * 3000 | 0 );
12+
}).save();
13+
setTimeout(create, Math.random() * 3000 | 0);
1414
}
1515

1616
create();
1717

1818
function create2() {
1919
var name = [ 'tobi', 'loki', 'jane', 'manny' ][ Math.random() * 4 | 0 ];
20-
jobs.create( 'email', {
20+
jobs.create('email', {
2121
title: 'emailing ' + name + '', body: 'hello'
22-
} ).save();
23-
setTimeout( create2, Math.random() * 1000 | 0 );
22+
}).save();
23+
setTimeout(create2, Math.random() * 1000 | 0);
2424
}
2525

2626
create2();
2727

2828
// process video conversion jobs, 3 at a time.
2929

30-
jobs.process( 'video conversion', 2, function ( job, done ) {
31-
console.log( 'video' );
32-
setTimeout( done, Math.random() * 5000 );
33-
} );
30+
jobs.process('video conversion', 2, function( job, done ) {
31+
console.log('video');
32+
setTimeout(done, Math.random() * 5000);
33+
});
3434

3535
// process 10 emails at a time
3636

37-
jobs.process( 'email', 10, function ( job, done ) {
38-
console.log( 'email' );
39-
setTimeout( done, Math.random() * 2000 );
40-
} );
37+
jobs.process('email', 10, function( job, done ) {
38+
console.log('email');
39+
setTimeout(done, Math.random() * 2000);
40+
});
4141

4242
// start the UI
43-
kue.app.listen( 3000 );
44-
console.log( 'UI started on port 3000' );
43+
kue.app.listen(3000);
44+
console.log('UI started on port 3000');

examples/shutdown.js

Lines changed: 18 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -1,34 +1,34 @@
1-
var kue = require( '../' )
1+
var kue = require('../')
22

33
var jobs = kue.createQueue()
44

55

66
function generateJobs() {
7-
for ( var i = 0; i < 12; i++ ) {
8-
console.log( 'Creating Job #' + i );
9-
jobs.create( 'long render', {
7+
for( var i = 0; i < 12; i++ ) {
8+
console.log('Creating Job #' + i);
9+
jobs.create('long render', {
1010
title: 'rendering frame #' + i
11-
} ).save();
11+
}).save();
1212
}
1313
}
1414

1515

16-
jobs.process( 'long render', 4, function ( job, done ) {
17-
console.log( 'Starting ' + job.data.title );
18-
setTimeout( function () {
19-
console.log( 'Finished ' + job.data.title );
16+
jobs.process('long render', 4, function( job, done ) {
17+
console.log('Starting ' + job.data.title);
18+
setTimeout(function() {
19+
console.log('Finished ' + job.data.title);
2020
done();
21-
}, 3000 );
22-
} )
21+
}, 3000);
22+
})
2323

2424

2525
generateJobs();
2626

27-
setTimeout( function () {
28-
console.log( '[ Shutting down when all jobs finish... ]' );
29-
jobs.shutdown( function ( err ) {
30-
console.log( '[ All jobs finished. Kue is shut down. ]' );
31-
process.exit( 0 );
32-
} )
33-
}, 4200 )
27+
setTimeout(function() {
28+
console.log('[ Shutting down when all jobs finish... ]');
29+
jobs.shutdown(function( err ) {
30+
console.log('[ All jobs finished. Kue is shut down. ]');
31+
process.exit(0);
32+
})
33+
}, 4200)
3434

examples/stale.js

Lines changed: 29 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
1-
var kue = require( '../' )
2-
, express = require( 'express' );
1+
var kue = require('../')
2+
, express = require('express');
33

44
// create our job queue
55

@@ -15,51 +15,51 @@ var jobs = kue.createQueue()
1515

1616
function create() {
1717
var name = [ 'tobi', 'loki', 'jane', 'manny' ][ Math.random() * 4 | 0 ];
18-
console.log( '- creating job for %s', name );
19-
jobs.create( 'video conversion', {
18+
console.log('- creating job for %s', name);
19+
jobs.create('video conversion', {
2020
title: 'converting ' + name + '\'s to avi', user: 1, frames: 200
21-
} ).save();
22-
setTimeout( create, Math.random() * 3000 | 0 );
21+
}).save();
22+
setTimeout(create, Math.random() * 3000 | 0);
2323
}
2424

2525
create();
2626

2727
// process video conversion jobs, 3 at a time.
2828

29-
jobs.process( 'video conversion', 3, function ( job, done ) {
29+
jobs.process('video conversion', 3, function( job, done ) {
3030
var frames = job.data.frames;
31-
console.log( "job process %d", job.id );
31+
console.log("job process %d", job.id);
3232
function next( i ) {
3333
// pretend we are doing some work
34-
convertFrame( i, function ( err ) {
35-
if ( err ) return done( err );
34+
convertFrame(i, function( err ) {
35+
if( err ) return done(err);
3636
// report progress, i/frames complete
37-
job.progress( i, frames );
38-
if ( i == frames ) done()
39-
else next( i + 5 );
40-
} );
37+
job.progress(i, frames);
38+
if( i == frames ) done()
39+
else next(i + 5);
40+
});
4141
}
4242

43-
next( 0 );
44-
} );
43+
next(0);
44+
});
4545

4646
function convertFrame( i, fn ) {
47-
setTimeout( fn, Math.random() * 100 );
47+
setTimeout(fn, Math.random() * 100);
4848
}
4949

5050
// remove stale jobs
51-
jobs.on( 'job complete', function ( id ) {
52-
Job.get( id, function ( err, job ) {
53-
if ( err ) return;
54-
job.remove( function ( err ) {
55-
if ( err ) throw err;
56-
console.log( 'removed completed job #%d', job.id );
57-
} );
58-
} );
59-
} );
51+
jobs.on('job complete', function( id ) {
52+
Job.get(id, function( err, job ) {
53+
if( err ) return;
54+
job.remove(function( err ) {
55+
if( err ) throw err;
56+
console.log('removed completed job #%d', job.id);
57+
});
58+
});
59+
});
6060

6161
// start the UI
6262
var app = express.createServer();
63-
app.use( kue.app );
64-
app.listen( 3000 );
65-
console.log( 'UI started on port 3000' );
63+
app.use(kue.app);
64+
app.listen(3000);
65+
console.log('UI started on port 3000');

0 commit comments

Comments
 (0)