id stringlengths 34 124 | type stringclasses 4
values | prompt stringlengths 0 4.95k | response stringlengths 21 4.89k | source_lang stringclasses 3
values | target_lang stringclasses 2
values | repo stringclasses 75
values | path stringlengths 10 88 | license stringclasses 1
value | commit stringlengths 40 40 | stars int64 431 18.7k | source_url stringlengths 86 176 | line_start int64 1 214 | line_end int64 3 253 |
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
elving/swag:test/comparisons_test.coffee:3:js_to_coffee | js_to_coffee | Convert this JavaScript to CoffeeScript.
```javascript
describe('or', function() {
return describe('{{#or great magnificent}} \n Kiss my perfect metal ass! \n {{else}} \n Never mind :( \n {{/or}}', function() {
return it('should render a block if one of the values is truthy.', function() {
var context, sour... | describe 'or', ->
describe '{{#or great magnificent}} \n
Kiss my perfect metal ass! \n
{{else}} \n
Never mind :( \n
{{/or}}', ->
it 'should render a block if one of the values is truthy.', ->
source = '{{#or great magnificent}}Kiss my perfect metal ass!{{else}}Never min... | JavaScript | CoffeeScript | elving/swag | test/comparisons_test.coffee | MIT | e9c8788dfc9f640038c00eaafe33f4137ff5f465 | 675 | https://github.com/elving/swag/blob/e9c8788dfc9f640038c00eaafe33f4137ff5f465/test/comparisons_test.coffee | 86 | 110 |
elving/swag:test/comparisons_test.coffee:3:completion | completion | describe 'or', ->
describe '{{#or great magnificent}} \n
Kiss my perfect metal ass! \n
{{else}} \n
Never mind :( \n
{{/or}}', ->
it 'should render a block if one of the values is truthy.', ->
source = '{{#or great magnificent}}Kiss my perfect metal ass!{{else}}Never min... | describe 'and', ->
describe '{{#and great magnificent}} \n
Kiss my glorious metal ass! \n
{{else}} \n
Never mind :( \n
{{/and}}', ->
it 'should render a block if both values are truthy.', ->
source = '{{#and great magnificent}}Kiss my glorious metal ass!{{else}}Never mi... | CoffeeScript | CoffeeScript | elving/swag | test/comparisons_test.coffee | MIT | e9c8788dfc9f640038c00eaafe33f4137ff5f465 | 675 | https://github.com/elving/swag/blob/e9c8788dfc9f640038c00eaafe33f4137ff5f465/test/comparisons_test.coffee | 86 | 110 |
elving/swag:test/comparisons_test.coffee:1:raw_corpus | raw_corpus | require 'should'
Handlebars = require 'handlebars'
Swag = require '../lib/swag'
describe 'is', ->
describe '{{#is bender "great"}} \n
Kiss my shiny metal ass! \n
{{else}} \n
Never mind :( \n
{{/is}}', ->
it 'should render a block if the condition is true.', ->
source ... | CoffeeScript | elving/swag | test/comparisons_test.coffee | MIT | ec99e1585bc96d513d3e6e77bd37a3738684836e | 675 | https://github.com/elving/swag/blob/ec99e1585bc96d513d3e6e77bd37a3738684836e/test/comparisons_test.coffee | 1 | 41 | ||
elving/swag:test/comparisons_test.coffee:1:coffee_to_js | coffee_to_js | Convert this CoffeeScript to JavaScript.
```coffeescript
require 'should'
Handlebars = require 'handlebars'
Swag = require '../lib/swag'
describe 'is', ->
describe '{{#is bender "great"}} \n
Kiss my shiny metal ass! \n
{{else}} \n
Never mind :( \n
{{/is}}', ->
it 'should render a b... | var Handlebars, Swag;
require('should');
Handlebars = require('handlebars');
Swag = require('../lib/swag');
describe('is', function() {
return describe('{{#is bender "great"}} \n Kiss my shiny metal ass! \n {{else}} \n Never mind :( \n {{/is}}', function() {
return it('should render a block if the condition i... | CoffeeScript | JavaScript | elving/swag | test/comparisons_test.coffee | MIT | ec99e1585bc96d513d3e6e77bd37a3738684836e | 675 | https://github.com/elving/swag/blob/ec99e1585bc96d513d3e6e77bd37a3738684836e/test/comparisons_test.coffee | 1 | 41 |
elving/swag:test/comparisons_test.coffee:1:js_to_coffee | js_to_coffee | Convert this JavaScript to CoffeeScript.
```javascript
var Handlebars, Swag;
require('should');
Handlebars = require('handlebars');
Swag = require('../lib/swag');
describe('is', function() {
return describe('{{#is bender "great"}} \n Kiss my shiny metal ass! \n {{else}} \n Never mind :( \n {{/is}}', function() {
... | require 'should'
Handlebars = require 'handlebars'
Swag = require '../lib/swag'
describe 'is', ->
describe '{{#is bender "great"}} \n
Kiss my shiny metal ass! \n
{{else}} \n
Never mind :( \n
{{/is}}', ->
it 'should render a block if the condition is true.', ->
source ... | JavaScript | CoffeeScript | elving/swag | test/comparisons_test.coffee | MIT | ec99e1585bc96d513d3e6e77bd37a3738684836e | 675 | https://github.com/elving/swag/blob/ec99e1585bc96d513d3e6e77bd37a3738684836e/test/comparisons_test.coffee | 1 | 41 |
elving/swag:test/comparisons_test.coffee:1:completion | completion | require 'should'
Handlebars = require 'handlebars'
Swag = require '../lib/swag'
describe 'is', ->
describe '{{#is bender "great"}} \n
Kiss my shiny metal ass! \n
{{else}} \n
Never mind :( \n
{{/is}}', ->
it 'should render a block if the condition is true.', ->
source ... | Kiss my great metal ass! \n
{{else}} \n
Never mind :( \n
{{/isnt}}', ->
it 'should render a block if the condition is not true.', ->
source = '{{#isnt number 2}}Kiss my great metal ass!{{else}}Never mind :({{/isnt}}'
template = Handlebars.compile(source)
con... | CoffeeScript | CoffeeScript | elving/swag | test/comparisons_test.coffee | MIT | ec99e1585bc96d513d3e6e77bd37a3738684836e | 675 | https://github.com/elving/swag/blob/ec99e1585bc96d513d3e6e77bd37a3738684836e/test/comparisons_test.coffee | 1 | 41 |
elving/swag:test/comparisons_test.coffee:1:raw_corpus | raw_corpus | require 'should'
Handlebars = require 'handlebars'
Swag = require '../lib/swag'
describe 'equal', ->
describe '{{#equal bender "great"}} \n
Kiss my shiny metal ass! \n
{{else}} \n
Never mind :( \n
{{/equal}}', ->
it 'should render a block if the condition is true.', ->
... | CoffeeScript | elving/swag | test/comparisons_test.coffee | MIT | b74033f61068855c91304cd8185ac5f7405c3169 | 675 | https://github.com/elving/swag/blob/b74033f61068855c91304cd8185ac5f7405c3169/test/comparisons_test.coffee | 1 | 41 | ||
elving/swag:test/comparisons_test.coffee:1:coffee_to_js | coffee_to_js | Convert this CoffeeScript to JavaScript.
```coffeescript
require 'should'
Handlebars = require 'handlebars'
Swag = require '../lib/swag'
describe 'equal', ->
describe '{{#equal bender "great"}} \n
Kiss my shiny metal ass! \n
{{else}} \n
Never mind :( \n
{{/equal}}', ->
it 'should r... | var Handlebars, Swag;
require('should');
Handlebars = require('handlebars');
Swag = require('../lib/swag');
describe('equal', function() {
return describe('{{#equal bender "great"}} \n Kiss my shiny metal ass! \n {{else}} \n Never mind :( \n {{/equal}}', function() {
return it('should render a block if the co... | CoffeeScript | JavaScript | elving/swag | test/comparisons_test.coffee | MIT | b74033f61068855c91304cd8185ac5f7405c3169 | 675 | https://github.com/elving/swag/blob/b74033f61068855c91304cd8185ac5f7405c3169/test/comparisons_test.coffee | 1 | 41 |
elving/swag:test/comparisons_test.coffee:1:js_to_coffee | js_to_coffee | Convert this JavaScript to CoffeeScript.
```javascript
var Handlebars, Swag;
require('should');
Handlebars = require('handlebars');
Swag = require('../lib/swag');
describe('equal', function() {
return describe('{{#equal bender "great"}} \n Kiss my shiny metal ass! \n {{else}} \n Never mind :( \n {{/equal}}', func... | require 'should'
Handlebars = require 'handlebars'
Swag = require '../lib/swag'
describe 'equal', ->
describe '{{#equal bender "great"}} \n
Kiss my shiny metal ass! \n
{{else}} \n
Never mind :( \n
{{/equal}}', ->
it 'should render a block if the condition is true.', ->
... | JavaScript | CoffeeScript | elving/swag | test/comparisons_test.coffee | MIT | b74033f61068855c91304cd8185ac5f7405c3169 | 675 | https://github.com/elving/swag/blob/b74033f61068855c91304cd8185ac5f7405c3169/test/comparisons_test.coffee | 1 | 41 |
elving/swag:test/comparisons_test.coffee:1:completion | completion | require 'should'
Handlebars = require 'handlebars'
Swag = require '../lib/swag'
describe 'equal', ->
describe '{{#equal bender "great"}} \n
Kiss my shiny metal ass! \n
{{else}} \n
Never mind :( \n
{{/equal}}', ->
it 'should render a block if the condition is true.', ->
... | Kiss my great metal ass! \n
{{else}} \n
Never mind :( \n
{{/notEqual}}', ->
it 'should render a block if the condition is not true.', ->
source = '{{#notEqual number 2}}Kiss my great metal ass!{{else}}Never mind :({{/notEqual}}'
template = Handlebars.compile(source)
... | CoffeeScript | CoffeeScript | elving/swag | test/comparisons_test.coffee | MIT | b74033f61068855c91304cd8185ac5f7405c3169 | 675 | https://github.com/elving/swag/blob/b74033f61068855c91304cd8185ac5f7405c3169/test/comparisons_test.coffee | 1 | 41 |
rs/pushd:lib/event.coffee:1:raw_corpus | raw_corpus | class Event
OPTION_IGNORE_MESSAGE: 1
name_format: /^[a-zA-Z0-9@:._-]{1,100}$/
unicast_format: /^unicast:(.+)$/
constructor: (@redis, @name) ->
throw new Error("Missing redis connection") if not @redis?
throw new Error('Invalid event name ' + @name) if not Event::name_format.test @name
... | CoffeeScript | rs/pushd | lib/event.coffee | MIT | 9dc56de9da2a64903cad510d22d4d0e078a8ba0a | 1,157 | https://github.com/rs/pushd/blob/9dc56de9da2a64903cad510d22d4d0e078a8ba0a/lib/event.coffee | 4 | 53 | ||
rs/pushd:lib/event.coffee:1:coffee_to_js | coffee_to_js | Convert this CoffeeScript to JavaScript.
```coffeescript
class Event
OPTION_IGNORE_MESSAGE: 1
name_format: /^[a-zA-Z0-9@:._-]{1,100}$/
unicast_format: /^unicast:(.+)$/
constructor: (@redis, @name) ->
throw new Error("Missing redis connection") if not @redis?
throw new Error('Invalid eve... | var Event,
hasProp = {}.hasOwnProperty;
Event = (function() {
class Event {
constructor(redis, name) {
this.redis = redis;
this.name = name;
if (this.redis == null) {
throw new Error("Missing redis connection");
}
if (!Event.prototype.name_format.test(this.name)) {
... | CoffeeScript | JavaScript | rs/pushd | lib/event.coffee | MIT | 9dc56de9da2a64903cad510d22d4d0e078a8ba0a | 1,157 | https://github.com/rs/pushd/blob/9dc56de9da2a64903cad510d22d4d0e078a8ba0a/lib/event.coffee | 4 | 53 |
rs/pushd:lib/event.coffee:1:js_to_coffee | js_to_coffee | Convert this JavaScript to CoffeeScript.
```javascript
var Event,
hasProp = {}.hasOwnProperty;
Event = (function() {
class Event {
constructor(redis, name) {
this.redis = redis;
this.name = name;
if (this.redis == null) {
throw new Error("Missing redis connection");
}
if (... | class Event
OPTION_IGNORE_MESSAGE: 1
name_format: /^[a-zA-Z0-9@:._-]{1,100}$/
unicast_format: /^unicast:(.+)$/
constructor: (@redis, @name) ->
throw new Error("Missing redis connection") if not @redis?
throw new Error('Invalid event name ' + @name) if not Event::name_format.test @name
... | JavaScript | CoffeeScript | rs/pushd | lib/event.coffee | MIT | 9dc56de9da2a64903cad510d22d4d0e078a8ba0a | 1,157 | https://github.com/rs/pushd/blob/9dc56de9da2a64903cad510d22d4d0e078a8ba0a/lib/event.coffee | 4 | 53 |
rs/pushd:lib/event.coffee:1:completion | completion | class Event
OPTION_IGNORE_MESSAGE: 1
name_format: /^[a-zA-Z0-9@:._-]{1,100}$/
unicast_format: /^unicast:(.+)$/
constructor: (@redis, @name) ->
throw new Error("Missing redis connection") if not @redis?
throw new Error('Invalid event name ' + @name) if not Event::name_format.test @name
... | else
cb(null)
unicastSubscriber: ->
Subscriber = require('./subscriber').Subscriber
if (matches = Event::unicast_format.exec @name)?
subscriberId = matches[1]
new Subscriber(@redis, subscriberId)
else
null
exists: (cb) ->
... | CoffeeScript | CoffeeScript | rs/pushd | lib/event.coffee | MIT | 9dc56de9da2a64903cad510d22d4d0e078a8ba0a | 1,157 | https://github.com/rs/pushd/blob/9dc56de9da2a64903cad510d22d4d0e078a8ba0a/lib/event.coffee | 4 | 53 |
rs/pushd:lib/event.coffee:2:raw_corpus | raw_corpus | @redis.multi()
# delete event's info hash
.del(@key)
# remove event from global event list
.srem("events", @name)
.exec (err, results) ->
cb(results[1] > 0) if cb
if @unicastSubscriber()?
performDel... | CoffeeScript | rs/pushd | lib/event.coffee | MIT | 9dc56de9da2a64903cad510d22d4d0e078a8ba0a | 1,157 | https://github.com/rs/pushd/blob/9dc56de9da2a64903cad510d22d4d0e078a8ba0a/lib/event.coffee | 54 | 103 | ||
rs/pushd:lib/event.coffee:2:coffee_to_js | coffee_to_js | Convert this CoffeeScript to JavaScript.
```coffeescript
@redis.multi()
# delete event's info hash
.del(@key)
# remove event from global event list
.srem("events", @name)
.exec (err, results) ->
cb(results[1] > 0) if cb
... | // delete event's info hash
// remove event from global event list
this.redis.multi().del(this.key).srem("events", this.name).exec(function(err, results) {
if (cb) {
return cb(results[1] > 0);
}
});
if (this.unicastSubscriber() != null) {
performDelete();
} else {
this.forEachSubscribers((subscriber, subOp... | CoffeeScript | JavaScript | rs/pushd | lib/event.coffee | MIT | 9dc56de9da2a64903cad510d22d4d0e078a8ba0a | 1,157 | https://github.com/rs/pushd/blob/9dc56de9da2a64903cad510d22d4d0e078a8ba0a/lib/event.coffee | 54 | 103 |
rs/pushd:lib/event.coffee:2:js_to_coffee | js_to_coffee | Convert this JavaScript to CoffeeScript.
```javascript
// delete event's info hash
// remove event from global event list
this.redis.multi().del(this.key).srem("events", this.name).exec(function(err, results) {
if (cb) {
return cb(results[1] > 0);
}
});
if (this.unicastSubscriber() != null) {
performDelete()... | @redis.multi()
# delete event's info hash
.del(@key)
# remove event from global event list
.srem("events", @name)
.exec (err, results) ->
cb(results[1] > 0) if cb
if @unicastSubscriber()?
performDel... | JavaScript | CoffeeScript | rs/pushd | lib/event.coffee | MIT | 9dc56de9da2a64903cad510d22d4d0e078a8ba0a | 1,157 | https://github.com/rs/pushd/blob/9dc56de9da2a64903cad510d22d4d0e078a8ba0a/lib/event.coffee | 54 | 103 |
rs/pushd:lib/event.coffee:2:completion | completion | @redis.multi()
# delete event's info hash
.del(@key)
# remove event from global event list
.srem("events", @name)
.exec (err, results) ->
cb(results[1] > 0) if cb
if @unicastSubscriber()?
performDel... | .hincrby(@key, "total", 1)
# store last notification date for this event
.hset(@key, "last", Math.round(new Date().getTime() / 1000))
.exec =>
cb() if cb
# Performs an action on each subscriber subscribed to this event
forEachSubscribers: (action, finished) -... | CoffeeScript | CoffeeScript | rs/pushd | lib/event.coffee | MIT | 9dc56de9da2a64903cad510d22d4d0e078a8ba0a | 1,157 | https://github.com/rs/pushd/blob/9dc56de9da2a64903cad510d22d4d0e078a8ba0a/lib/event.coffee | 54 | 103 |
rs/pushd:lib/event.coffee:3:raw_corpus | raw_corpus | perPage = 100
page = 0
@redis.zcard subscribersKey, (err, subcount) =>
total = subcount
totalPages = Math.ceil((subcount*1.0)/perPage)
async.whilst =>
return page < totalPages
, (chunkDone) =>
# treat s... | CoffeeScript | rs/pushd | lib/event.coffee | MIT | 9dc56de9da2a64903cad510d22d4d0e078a8ba0a | 1,157 | https://github.com/rs/pushd/blob/9dc56de9da2a64903cad510d22d4d0e078a8ba0a/lib/event.coffee | 104 | 127 | ||
rs/pushd:lib/event.coffee:3:completion | completion | perPage = 100
page = 0
@redis.zcard subscribersKey, (err, subcount) =>
total = subcount
totalPages = Math.ceil((subcount*1.0)/perPage)
async.whilst =>
return page < totalPages
, (chunkDone) =>
# treat s... | tasks = []
for id, i in subscriberIdsAndOptions by 2
tasks.push performAction(id, subscriberIdsAndOptions[i + 1])
async.series tasks, =>
#total += subscriberIdsAndOptions.length / 2
page++
... | CoffeeScript | CoffeeScript | rs/pushd | lib/event.coffee | MIT | 9dc56de9da2a64903cad510d22d4d0e078a8ba0a | 1,157 | https://github.com/rs/pushd/blob/9dc56de9da2a64903cad510d22d4d0e078a8ba0a/lib/event.coffee | 104 | 127 |
rs/pushd:lib/event.coffee:2:raw_corpus | raw_corpus | @redis.multi()
# delete event's info hash
.del(@key)
# remove event from global event list
.srem("events", @name)
.exec (err, results) ->
cb(results[1] > 0) if cb
if @unicastSubscriber()?
performDel... | CoffeeScript | rs/pushd | lib/event.coffee | MIT | 11413e63392a448ad201ce818c7ca853be36f25a | 1,157 | https://github.com/rs/pushd/blob/11413e63392a448ad201ce818c7ca853be36f25a/lib/event.coffee | 54 | 103 | ||
rs/pushd:lib/event.coffee:2:coffee_to_js | coffee_to_js | Convert this CoffeeScript to JavaScript.
```coffeescript
@redis.multi()
# delete event's info hash
.del(@key)
# remove event from global event list
.srem("events", @name)
.exec (err, results) ->
cb(results[1] > 0) if cb
... | var subscriberCount;
// delete event's info hash
// remove event from global event list
this.redis.multi().del(this.key).srem("events", this.name).exec(function(err, results) {
if (cb) {
return cb(results[1] > 0);
}
});
if (this.unicastSubscriber() != null) {
performDelete();
} else {
subscriberCount = 0;... | CoffeeScript | JavaScript | rs/pushd | lib/event.coffee | MIT | 11413e63392a448ad201ce818c7ca853be36f25a | 1,157 | https://github.com/rs/pushd/blob/11413e63392a448ad201ce818c7ca853be36f25a/lib/event.coffee | 54 | 103 |
rs/pushd:lib/event.coffee:2:js_to_coffee | js_to_coffee | Convert this JavaScript to CoffeeScript.
```javascript
var subscriberCount;
// delete event's info hash
// remove event from global event list
this.redis.multi().del(this.key).srem("events", this.name).exec(function(err, results) {
if (cb) {
return cb(results[1] > 0);
}
});
if (this.unicastSubscriber() != nul... | @redis.multi()
# delete event's info hash
.del(@key)
# remove event from global event list
.srem("events", @name)
.exec (err, results) ->
cb(results[1] > 0) if cb
if @unicastSubscriber()?
performDel... | JavaScript | CoffeeScript | rs/pushd | lib/event.coffee | MIT | 11413e63392a448ad201ce818c7ca853be36f25a | 1,157 | https://github.com/rs/pushd/blob/11413e63392a448ad201ce818c7ca853be36f25a/lib/event.coffee | 54 | 103 |
rs/pushd:lib/event.coffee:2:completion | completion | @redis.multi()
# delete event's info hash
.del(@key)
# remove event from global event list
.srem("events", @name)
.exec (err, results) ->
cb(results[1] > 0) if cb
if @unicastSubscriber()?
performDel... | .hincrby(@key, "total", 1)
# store last notification date for this event
.hset(@key, "last", Math.round(new Date().getTime() / 1000))
.exec =>
cb() if cb
# Performs an action on each subscriber subscribed to this event
forEachSubscribers: (action, finished) -... | CoffeeScript | CoffeeScript | rs/pushd | lib/event.coffee | MIT | 11413e63392a448ad201ce818c7ca853be36f25a | 1,157 | https://github.com/rs/pushd/blob/11413e63392a448ad201ce818c7ca853be36f25a/lib/event.coffee | 54 | 103 |
rs/pushd:lib/event.coffee:3:raw_corpus | raw_corpus | page = 0
perPage = 100
total = 0
async.whilst =>
# test if we got less items than requested during last request
# if so, we reached to end of the list
return page * perPage == total
, (done) =>
# treat subscr... | CoffeeScript | rs/pushd | lib/event.coffee | MIT | 11413e63392a448ad201ce818c7ca853be36f25a | 1,157 | https://github.com/rs/pushd/blob/11413e63392a448ad201ce818c7ca853be36f25a/lib/event.coffee | 104 | 126 | ||
rs/pushd:lib/event.coffee:3:completion | completion | page = 0
perPage = 100
total = 0
async.whilst =>
# test if we got less items than requested during last request
# if so, we reached to end of the list
return page * perPage == total
, (done) =>
# treat subscr... | tasks = []
for id, i in subscriberIdsAndOptions by 2
tasks.push performAction(id, subscriberIdsAndOptions[i + 1])
async.series tasks, =>
total += subscriberIdsAndOptions.length / 2
done()
page... | CoffeeScript | CoffeeScript | rs/pushd | lib/event.coffee | MIT | 11413e63392a448ad201ce818c7ca853be36f25a | 1,157 | https://github.com/rs/pushd/blob/11413e63392a448ad201ce818c7ca853be36f25a/lib/event.coffee | 104 | 126 |
rs/pushd:lib/event.coffee:1:raw_corpus | raw_corpus | class Event
OPTION_IGNORE_MESSAGE: 1
name_format: /^[a-zA-Z0-9@:._-]{1,100}$/
unicast_format: /^unicast:(.+)$/
constructor: (@redis, @name) ->
throw new Error("Missing redis connection") if not @redis?
throw new Error('Invalid event name ' + @name) if not Event::name_format.test @name
... | CoffeeScript | rs/pushd | lib/event.coffee | MIT | b41d14b4caace7c356f7ba057d649b6a525ac67d | 1,157 | https://github.com/rs/pushd/blob/b41d14b4caace7c356f7ba057d649b6a525ac67d/lib/event.coffee | 5 | 54 | ||
rs/pushd:lib/event.coffee:1:coffee_to_js | coffee_to_js | Convert this CoffeeScript to JavaScript.
```coffeescript
class Event
OPTION_IGNORE_MESSAGE: 1
name_format: /^[a-zA-Z0-9@:._-]{1,100}$/
unicast_format: /^unicast:(.+)$/
constructor: (@redis, @name) ->
throw new Error("Missing redis connection") if not @redis?
throw new Error('Invalid eve... | var Event,
hasProp = {}.hasOwnProperty;
Event = (function() {
class Event {
constructor(redis, name) {
this.redis = redis;
this.name = name;
if (this.redis == null) {
throw new Error("Missing redis connection");
}
if (!Event.prototype.name_format.test(this.name)) {
... | CoffeeScript | JavaScript | rs/pushd | lib/event.coffee | MIT | b41d14b4caace7c356f7ba057d649b6a525ac67d | 1,157 | https://github.com/rs/pushd/blob/b41d14b4caace7c356f7ba057d649b6a525ac67d/lib/event.coffee | 5 | 54 |
rs/pushd:lib/event.coffee:1:js_to_coffee | js_to_coffee | Convert this JavaScript to CoffeeScript.
```javascript
var Event,
hasProp = {}.hasOwnProperty;
Event = (function() {
class Event {
constructor(redis, name) {
this.redis = redis;
this.name = name;
if (this.redis == null) {
throw new Error("Missing redis connection");
}
if (... | class Event
OPTION_IGNORE_MESSAGE: 1
name_format: /^[a-zA-Z0-9@:._-]{1,100}$/
unicast_format: /^unicast:(.+)$/
constructor: (@redis, @name) ->
throw new Error("Missing redis connection") if not @redis?
throw new Error('Invalid event name ' + @name) if not Event::name_format.test @name
... | JavaScript | CoffeeScript | rs/pushd | lib/event.coffee | MIT | b41d14b4caace7c356f7ba057d649b6a525ac67d | 1,157 | https://github.com/rs/pushd/blob/b41d14b4caace7c356f7ba057d649b6a525ac67d/lib/event.coffee | 5 | 54 |
rs/pushd:lib/event.coffee:1:completion | completion | class Event
OPTION_IGNORE_MESSAGE: 1
name_format: /^[a-zA-Z0-9@:._-]{1,100}$/
unicast_format: /^unicast:(.+)$/
constructor: (@redis, @name) ->
throw new Error("Missing redis connection") if not @redis?
throw new Error('Invalid event name ' + @name) if not Event::name_format.test @name
... | else
cb(null)
unicastSubscriber: ->
if (matches = Event::unicast_format.exec @name)?
subscriberId = matches[1]
new Subscriber(@redis, subscriberId)
else
null
exists: (cb) ->
if @name is 'broadcast'
cb(true)
els... | CoffeeScript | CoffeeScript | rs/pushd | lib/event.coffee | MIT | b41d14b4caace7c356f7ba057d649b6a525ac67d | 1,157 | https://github.com/rs/pushd/blob/b41d14b4caace7c356f7ba057d649b6a525ac67d/lib/event.coffee | 5 | 54 |
rs/pushd:lib/event.coffee:2:raw_corpus | raw_corpus | # delete event's info hash
.del(@key)
# remove event from global event list
.srem("events", @name)
.exec (err, results) ->
cb(results[1] > 0) if cb
if @unicastSubscriber()?
performDelete()
else
... | CoffeeScript | rs/pushd | lib/event.coffee | MIT | b41d14b4caace7c356f7ba057d649b6a525ac67d | 1,157 | https://github.com/rs/pushd/blob/b41d14b4caace7c356f7ba057d649b6a525ac67d/lib/event.coffee | 55 | 104 | ||
rs/pushd:lib/event.coffee:2:completion | completion | # delete event's info hash
.del(@key)
# remove event from global event list
.srem("events", @name)
.exec (err, results) ->
cb(results[1] > 0) if cb
if @unicastSubscriber()?
performDelete()
else
... | # store last notification date for this event
.hset(@key, "last", Math.round(new Date().getTime() / 1000))
.exec =>
cb() if cb
# Performs an action on each subscriber subscribed to this event
forEachSubscribers: (action, finished) ->
Subscriber = require('./subsc... | CoffeeScript | CoffeeScript | rs/pushd | lib/event.coffee | MIT | b41d14b4caace7c356f7ba057d649b6a525ac67d | 1,157 | https://github.com/rs/pushd/blob/b41d14b4caace7c356f7ba057d649b6a525ac67d/lib/event.coffee | 55 | 104 |
rs/pushd:lib/event.coffee:3:raw_corpus | raw_corpus | perPage = 100
total = 0
async.whilst =>
# test if we got less items than requested during last request
# if so, we reached to end of the list
return page * perPage == total
, (done) =>
# treat subscribers by packs of 100... | CoffeeScript | rs/pushd | lib/event.coffee | MIT | b41d14b4caace7c356f7ba057d649b6a525ac67d | 1,157 | https://github.com/rs/pushd/blob/b41d14b4caace7c356f7ba057d649b6a525ac67d/lib/event.coffee | 105 | 126 | ||
rs/pushd:lib/event.coffee:3:completion | completion | perPage = 100
total = 0
async.whilst =>
# test if we got less items than requested during last request
# if so, we reached to end of the list
return page * perPage == total
, (done) =>
# treat subscribers by packs of 100... | for id, i in subscriberIdsAndOptions by 2
tasks.push performAction(id, subscriberIdsAndOptions[i + 1])
async.series tasks, =>
total += subscriberIdsAndOptions.length / 2
done()
page++
, =>
... | CoffeeScript | CoffeeScript | rs/pushd | lib/event.coffee | MIT | b41d14b4caace7c356f7ba057d649b6a525ac67d | 1,157 | https://github.com/rs/pushd/blob/b41d14b4caace7c356f7ba057d649b6a525ac67d/lib/event.coffee | 105 | 126 |
rs/pushd:lib/event.coffee:2:raw_corpus | raw_corpus | @redis.multi()
# delete event's info hash
.del(@key)
# remove event from global event list
.srem("events", @name)
.exec (err, results) ->
cb(results[1] > 0) if cb
if @unicastSubscriber()?
performDel... | CoffeeScript | rs/pushd | lib/event.coffee | MIT | 0216e29bc2c91df78af7b7301c5be6f969b80019 | 1,157 | https://github.com/rs/pushd/blob/0216e29bc2c91df78af7b7301c5be6f969b80019/lib/event.coffee | 54 | 103 | ||
rs/pushd:lib/event.coffee:2:coffee_to_js | coffee_to_js | Convert this CoffeeScript to JavaScript.
```coffeescript
@redis.multi()
# delete event's info hash
.del(@key)
# remove event from global event list
.srem("events", @name)
.exec (err, results) ->
cb(results[1] > 0) if cb
... | var subscriberCount;
// delete event's info hash
// remove event from global event list
this.redis.multi().del(this.key).srem("events", this.name).exec(function(err, results) {
if (cb) {
return cb(results[1] > 0);
}
});
if (this.unicastSubscriber() != null) {
performDelete();
} else {
subscriberCount = 0;... | CoffeeScript | JavaScript | rs/pushd | lib/event.coffee | MIT | 0216e29bc2c91df78af7b7301c5be6f969b80019 | 1,157 | https://github.com/rs/pushd/blob/0216e29bc2c91df78af7b7301c5be6f969b80019/lib/event.coffee | 54 | 103 |
rs/pushd:lib/event.coffee:2:js_to_coffee | js_to_coffee | Convert this JavaScript to CoffeeScript.
```javascript
var subscriberCount;
// delete event's info hash
// remove event from global event list
this.redis.multi().del(this.key).srem("events", this.name).exec(function(err, results) {
if (cb) {
return cb(results[1] > 0);
}
});
if (this.unicastSubscriber() != nul... | @redis.multi()
# delete event's info hash
.del(@key)
# remove event from global event list
.srem("events", @name)
.exec (err, results) ->
cb(results[1] > 0) if cb
if @unicastSubscriber()?
performDel... | JavaScript | CoffeeScript | rs/pushd | lib/event.coffee | MIT | 0216e29bc2c91df78af7b7301c5be6f969b80019 | 1,157 | https://github.com/rs/pushd/blob/0216e29bc2c91df78af7b7301c5be6f969b80019/lib/event.coffee | 54 | 103 |
rs/pushd:lib/event.coffee:2:completion | completion | @redis.multi()
# delete event's info hash
.del(@key)
# remove event from global event list
.srem("events", @name)
.exec (err, results) ->
cb(results[1] > 0) if cb
if @unicastSubscriber()?
performDel... | # account number of sent notification since event creation
.hincrby(@key, "total", 1)
# store last notification date for this event
.hset(@key, "last", Math.round(new Date().getTime() / 1000))
.exec =>
cb() if cb
# Performs an action on each subscribe... | CoffeeScript | CoffeeScript | rs/pushd | lib/event.coffee | MIT | 0216e29bc2c91df78af7b7301c5be6f969b80019 | 1,157 | https://github.com/rs/pushd/blob/0216e29bc2c91df78af7b7301c5be6f969b80019/lib/event.coffee | 54 | 103 |
rs/pushd:lib/event.coffee:3:raw_corpus | raw_corpus | subscribersKey = if @name is 'broadcast' then 'subscribers' else "#{@key}:subs"
page = 0
perPage = 100
total = 0
async.whilst =>
# test if we got less items than requested during last request
# if so, we reached to end of the list
... | CoffeeScript | rs/pushd | lib/event.coffee | MIT | 0216e29bc2c91df78af7b7301c5be6f969b80019 | 1,157 | https://github.com/rs/pushd/blob/0216e29bc2c91df78af7b7301c5be6f969b80019/lib/event.coffee | 104 | 127 | ||
rs/pushd:lib/event.coffee:3:completion | completion | subscribersKey = if @name is 'broadcast' then 'subscribers' else "#{@key}:subs"
page = 0
perPage = 100
total = 0
async.whilst =>
# test if we got less items than requested during last request
# if so, we reached to end of the list
... | tasks = []
for id, i in subscriberIdsAndOptions by 2
tasks.push performAction(id, subscriberIdsAndOptions[i + 1])
async.series tasks, =>
total += subscriberIdsAndOptions.length / 2
done()
page... | CoffeeScript | CoffeeScript | rs/pushd | lib/event.coffee | MIT | 0216e29bc2c91df78af7b7301c5be6f969b80019 | 1,157 | https://github.com/rs/pushd/blob/0216e29bc2c91df78af7b7301c5be6f969b80019/lib/event.coffee | 104 | 127 |
rs/pushd:lib/event.coffee:1:raw_corpus | raw_corpus | class Event
OPTION_IGNORE_MESSAGE: 1
name_format: /^[a-zA-Z0-9@:._-]{1,100}$/
constructor: (@redis, @name) ->
throw new Error("Missing redis connection") if not @redis?
throw new Error('Invalid event name ' + @name) if not Event::name_format.test @name
@key = "event:#{@name}"
i... | CoffeeScript | rs/pushd | lib/event.coffee | MIT | 33a494ab89385dd1944504989ad7bed69e80ba94 | 1,157 | https://github.com/rs/pushd/blob/33a494ab89385dd1944504989ad7bed69e80ba94/lib/event.coffee | 4 | 53 | ||
rs/pushd:lib/event.coffee:1:coffee_to_js | coffee_to_js | Convert this CoffeeScript to JavaScript.
```coffeescript
class Event
OPTION_IGNORE_MESSAGE: 1
name_format: /^[a-zA-Z0-9@:._-]{1,100}$/
constructor: (@redis, @name) ->
throw new Error("Missing redis connection") if not @redis?
throw new Error('Invalid event name ' + @name) if not Event::name... | var Event,
hasProp = {}.hasOwnProperty;
Event = (function() {
class Event {
constructor(redis, name) {
this.redis = redis;
this.name = name;
if (this.redis == null) {
throw new Error("Missing redis connection");
}
if (!Event.prototype.name_format.test(this.name)) {
... | CoffeeScript | JavaScript | rs/pushd | lib/event.coffee | MIT | 33a494ab89385dd1944504989ad7bed69e80ba94 | 1,157 | https://github.com/rs/pushd/blob/33a494ab89385dd1944504989ad7bed69e80ba94/lib/event.coffee | 4 | 53 |
rs/pushd:lib/event.coffee:1:js_to_coffee | js_to_coffee | Convert this JavaScript to CoffeeScript.
```javascript
var Event,
hasProp = {}.hasOwnProperty;
Event = (function() {
class Event {
constructor(redis, name) {
this.redis = redis;
this.name = name;
if (this.redis == null) {
throw new Error("Missing redis connection");
}
if (... | class Event
OPTION_IGNORE_MESSAGE: 1
name_format: /^[a-zA-Z0-9@:._-]{1,100}$/
constructor: (@redis, @name) ->
throw new Error("Missing redis connection") if not @redis?
throw new Error('Invalid event name ' + @name) if not Event::name_format.test @name
@key = "event:#{@name}"
i... | JavaScript | CoffeeScript | rs/pushd | lib/event.coffee | MIT | 33a494ab89385dd1944504989ad7bed69e80ba94 | 1,157 | https://github.com/rs/pushd/blob/33a494ab89385dd1944504989ad7bed69e80ba94/lib/event.coffee | 4 | 53 |
rs/pushd:lib/event.coffee:1:completion | completion | class Event
OPTION_IGNORE_MESSAGE: 1
name_format: /^[a-zA-Z0-9@:._-]{1,100}$/
constructor: (@redis, @name) ->
throw new Error("Missing redis connection") if not @redis?
throw new Error('Invalid event name ' + @name) if not Event::name_format.test @name
@key = "event:#{@name}"
i... | cb(null)
exists: (cb) ->
if @name is 'broadcast'
cb(true)
else
@redis.sismember "events", @name, (err, exists) =>
cb(exists)
delete: (cb) ->
logger.verbose "Deleting event #{@name}"
subscriberCount = 0
@forEachSubscribers (subscr... | CoffeeScript | CoffeeScript | rs/pushd | lib/event.coffee | MIT | 33a494ab89385dd1944504989ad7bed69e80ba94 | 1,157 | https://github.com/rs/pushd/blob/33a494ab89385dd1944504989ad7bed69e80ba94/lib/event.coffee | 4 | 53 |
rs/pushd:lib/event.coffee:2:raw_corpus | raw_corpus | .srem("events", @name)
.exec (err, results) ->
cb(results[1] > 0) if cb
log: (cb) ->
@redis.multi()
# account number of sent notification since event creation
.hincrby(@key, "total", 1)
# store last notification date for this event
... | CoffeeScript | rs/pushd | lib/event.coffee | MIT | 33a494ab89385dd1944504989ad7bed69e80ba94 | 1,157 | https://github.com/rs/pushd/blob/33a494ab89385dd1944504989ad7bed69e80ba94/lib/event.coffee | 54 | 103 | ||
rs/pushd:lib/event.coffee:2:completion | completion | .srem("events", @name)
.exec (err, results) ->
cb(results[1] > 0) if cb
log: (cb) ->
@redis.multi()
# account number of sent notification since event creation
.hincrby(@key, "total", 1)
# store last notification date for this event
... | return (done) =>
action(new Subscriber(@redis, subscriberId), options, done)
subscribersKey = if @name is 'broadcast' then 'subscribers' else "#{@key}:subs"
page = 0
perPage = 100
total = 0
async.whilst =>
# test if we got less items than requeste... | CoffeeScript | CoffeeScript | rs/pushd | lib/event.coffee | MIT | 33a494ab89385dd1944504989ad7bed69e80ba94 | 1,157 | https://github.com/rs/pushd/blob/33a494ab89385dd1944504989ad7bed69e80ba94/lib/event.coffee | 54 | 103 |
rs/pushd:lib/event.coffee:1:raw_corpus | raw_corpus | class Event
OPTION_IGNORE_MESSAGE: 1
name_format: /^[a-zA-Z0-9@:._-]{1,100}$/
constructor: (@redis, @name) ->
throw new Error("Missing redis connection") if not redis?
throw new Error('Invalid event name ' + @name) if not Event::name_format.test @name
@key = "event:#{@name}"
in... | CoffeeScript | rs/pushd | lib/event.coffee | MIT | 2b0c4d508a11e5ff7965de3deadc8e3309ea3990 | 1,157 | https://github.com/rs/pushd/blob/2b0c4d508a11e5ff7965de3deadc8e3309ea3990/lib/event.coffee | 4 | 53 | ||
rs/pushd:lib/event.coffee:1:coffee_to_js | coffee_to_js | Convert this CoffeeScript to JavaScript.
```coffeescript
class Event
OPTION_IGNORE_MESSAGE: 1
name_format: /^[a-zA-Z0-9@:._-]{1,100}$/
constructor: (@redis, @name) ->
throw new Error("Missing redis connection") if not redis?
throw new Error('Invalid event name ' + @name) if not Event::name_... | var Event,
hasProp = {}.hasOwnProperty;
Event = (function() {
class Event {
constructor(redis1, name) {
this.redis = redis1;
this.name = name;
if (typeof redis === "undefined" || redis === null) {
throw new Error("Missing redis connection");
}
if (!Event.prototype.name_for... | CoffeeScript | JavaScript | rs/pushd | lib/event.coffee | MIT | 2b0c4d508a11e5ff7965de3deadc8e3309ea3990 | 1,157 | https://github.com/rs/pushd/blob/2b0c4d508a11e5ff7965de3deadc8e3309ea3990/lib/event.coffee | 4 | 53 |
rs/pushd:lib/event.coffee:1:js_to_coffee | js_to_coffee | Convert this JavaScript to CoffeeScript.
```javascript
var Event,
hasProp = {}.hasOwnProperty;
Event = (function() {
class Event {
constructor(redis1, name) {
this.redis = redis1;
this.name = name;
if (typeof redis === "undefined" || redis === null) {
throw new Error("Missing redis co... | class Event
OPTION_IGNORE_MESSAGE: 1
name_format: /^[a-zA-Z0-9@:._-]{1,100}$/
constructor: (@redis, @name) ->
throw new Error("Missing redis connection") if not redis?
throw new Error('Invalid event name ' + @name) if not Event::name_format.test @name
@key = "event:#{@name}"
in... | JavaScript | CoffeeScript | rs/pushd | lib/event.coffee | MIT | 2b0c4d508a11e5ff7965de3deadc8e3309ea3990 | 1,157 | https://github.com/rs/pushd/blob/2b0c4d508a11e5ff7965de3deadc8e3309ea3990/lib/event.coffee | 4 | 53 |
rs/pushd:lib/event.coffee:1:completion | completion | class Event
OPTION_IGNORE_MESSAGE: 1
name_format: /^[a-zA-Z0-9@:._-]{1,100}$/
constructor: (@redis, @name) ->
throw new Error("Missing redis connection") if not redis?
throw new Error('Invalid event name ' + @name) if not Event::name_format.test @name
@key = "event:#{@name}"
in... | cb(null)
exists: (cb) ->
if @name is 'broadcast'
cb(true)
else
@redis.sismember "events", @name, (err, exists) =>
cb(exists)
delete: (cb) ->
logger.verbose "Deleting event #{@name}"
subscriberCount = 0
@forEachSubscribers (subscr... | CoffeeScript | CoffeeScript | rs/pushd | lib/event.coffee | MIT | 2b0c4d508a11e5ff7965de3deadc8e3309ea3990 | 1,157 | https://github.com/rs/pushd/blob/2b0c4d508a11e5ff7965de3deadc8e3309ea3990/lib/event.coffee | 4 | 53 |
rs/pushd:lib/event.coffee:1:raw_corpus | raw_corpus | class Event
OPTION_IGNORE_MESSAGE: 1
name_format: /^[a-zA-Z0-9:._-]{1,100}$/
constructor: (@redis, @name) ->
throw new Error("Missing redis connection") if not redis?
throw new Error('Invalid event name ' + @name) if not Event::name_format.test @name
@key = "event:#{@name}"
inf... | CoffeeScript | rs/pushd | lib/event.coffee | MIT | 394c3c913fa3b01dd539410e44ade84910d911eb | 1,157 | https://github.com/rs/pushd/blob/394c3c913fa3b01dd539410e44ade84910d911eb/lib/event.coffee | 4 | 53 | ||
rs/pushd:lib/event.coffee:1:coffee_to_js | coffee_to_js | Convert this CoffeeScript to JavaScript.
```coffeescript
class Event
OPTION_IGNORE_MESSAGE: 1
name_format: /^[a-zA-Z0-9:._-]{1,100}$/
constructor: (@redis, @name) ->
throw new Error("Missing redis connection") if not redis?
throw new Error('Invalid event name ' + @name) if not Event::name_f... | var Event,
hasProp = {}.hasOwnProperty;
Event = (function() {
class Event {
constructor(redis1, name) {
this.redis = redis1;
this.name = name;
if (typeof redis === "undefined" || redis === null) {
throw new Error("Missing redis connection");
}
if (!Event.prototype.name_for... | CoffeeScript | JavaScript | rs/pushd | lib/event.coffee | MIT | 394c3c913fa3b01dd539410e44ade84910d911eb | 1,157 | https://github.com/rs/pushd/blob/394c3c913fa3b01dd539410e44ade84910d911eb/lib/event.coffee | 4 | 53 |
rs/pushd:lib/event.coffee:1:js_to_coffee | js_to_coffee | Convert this JavaScript to CoffeeScript.
```javascript
var Event,
hasProp = {}.hasOwnProperty;
Event = (function() {
class Event {
constructor(redis1, name) {
this.redis = redis1;
this.name = name;
if (typeof redis === "undefined" || redis === null) {
throw new Error("Missing redis co... | class Event
OPTION_IGNORE_MESSAGE: 1
name_format: /^[a-zA-Z0-9:._-]{1,100}$/
constructor: (@redis, @name) ->
throw new Error("Missing redis connection") if not redis?
throw new Error('Invalid event name ' + @name) if not Event::name_format.test @name
@key = "event:#{@name}"
inf... | JavaScript | CoffeeScript | rs/pushd | lib/event.coffee | MIT | 394c3c913fa3b01dd539410e44ade84910d911eb | 1,157 | https://github.com/rs/pushd/blob/394c3c913fa3b01dd539410e44ade84910d911eb/lib/event.coffee | 4 | 53 |
rs/pushd:lib/event.coffee:1:completion | completion | class Event
OPTION_IGNORE_MESSAGE: 1
name_format: /^[a-zA-Z0-9:._-]{1,100}$/
constructor: (@redis, @name) ->
throw new Error("Missing redis connection") if not redis?
throw new Error('Invalid event name ' + @name) if not Event::name_format.test @name
@key = "event:#{@name}"
inf... | cb(null)
exists: (cb) ->
if @name is 'broadcast'
cb(true)
else
@redis.sismember "events", @name, (err, exists) =>
cb(exists)
delete: (cb) ->
logger.verbose "Deleting event #{@name}"
subscriberCount = 0
@forEachSubscribers (subscr... | CoffeeScript | CoffeeScript | rs/pushd | lib/event.coffee | MIT | 394c3c913fa3b01dd539410e44ade84910d911eb | 1,157 | https://github.com/rs/pushd/blob/394c3c913fa3b01dd539410e44ade84910d911eb/lib/event.coffee | 4 | 53 |
rs/pushd:lib/event.coffee:1:raw_corpus | raw_corpus | class Event
OPTION_IGNORE_MESSAGE: 1
name_format: /^[a-zA-Z0-9:._-]{1,100}$/
constructor: (@redis, @name) ->
throw new Error("Missing redis connection") if not redis?
throw new Error('Invalid event name ' + @name) if not Event::name_format.test @name
@key = "event:#{@name}"
inf... | CoffeeScript | rs/pushd | lib/event.coffee | MIT | ad18fda4fa48f8f99036b80a2cfe2df1acc1423a | 1,157 | https://github.com/rs/pushd/blob/ad18fda4fa48f8f99036b80a2cfe2df1acc1423a/lib/event.coffee | 3 | 52 | ||
rs/pushd:lib/event.coffee:1:coffee_to_js | coffee_to_js | Convert this CoffeeScript to JavaScript.
```coffeescript
class Event
OPTION_IGNORE_MESSAGE: 1
name_format: /^[a-zA-Z0-9:._-]{1,100}$/
constructor: (@redis, @name) ->
throw new Error("Missing redis connection") if not redis?
throw new Error('Invalid event name ' + @name) if not Event::name_f... | var Event,
hasProp = {}.hasOwnProperty;
Event = (function() {
class Event {
constructor(redis1, name) {
this.redis = redis1;
this.name = name;
if (typeof redis === "undefined" || redis === null) {
throw new Error("Missing redis connection");
}
if (!Event.prototype.name_for... | CoffeeScript | JavaScript | rs/pushd | lib/event.coffee | MIT | ad18fda4fa48f8f99036b80a2cfe2df1acc1423a | 1,157 | https://github.com/rs/pushd/blob/ad18fda4fa48f8f99036b80a2cfe2df1acc1423a/lib/event.coffee | 3 | 52 |
rs/pushd:lib/event.coffee:1:js_to_coffee | js_to_coffee | Convert this JavaScript to CoffeeScript.
```javascript
var Event,
hasProp = {}.hasOwnProperty;
Event = (function() {
class Event {
constructor(redis1, name) {
this.redis = redis1;
this.name = name;
if (typeof redis === "undefined" || redis === null) {
throw new Error("Missing redis co... | class Event
OPTION_IGNORE_MESSAGE: 1
name_format: /^[a-zA-Z0-9:._-]{1,100}$/
constructor: (@redis, @name) ->
throw new Error("Missing redis connection") if not redis?
throw new Error('Invalid event name ' + @name) if not Event::name_format.test @name
@key = "event:#{@name}"
inf... | JavaScript | CoffeeScript | rs/pushd | lib/event.coffee | MIT | ad18fda4fa48f8f99036b80a2cfe2df1acc1423a | 1,157 | https://github.com/rs/pushd/blob/ad18fda4fa48f8f99036b80a2cfe2df1acc1423a/lib/event.coffee | 3 | 52 |
rs/pushd:lib/event.coffee:1:completion | completion | class Event
OPTION_IGNORE_MESSAGE: 1
name_format: /^[a-zA-Z0-9:._-]{1,100}$/
constructor: (@redis, @name) ->
throw new Error("Missing redis connection") if not redis?
throw new Error('Invalid event name ' + @name) if not Event::name_format.test @name
@key = "event:#{@name}"
inf... | cb(null)
exists: (cb) ->
if @name is 'broadcast'
cb(true)
else
@redis.sismember "events", @name, (err, exists) =>
cb(exists)
delete: (cb) ->
@forEachSubscribers (subscriber, subOptions, done) =>
# action
subscriber.removeS... | CoffeeScript | CoffeeScript | rs/pushd | lib/event.coffee | MIT | ad18fda4fa48f8f99036b80a2cfe2df1acc1423a | 1,157 | https://github.com/rs/pushd/blob/ad18fda4fa48f8f99036b80a2cfe2df1acc1423a/lib/event.coffee | 3 | 52 |
rs/pushd:lib/event.coffee:2:raw_corpus | raw_corpus | # account number of sent notification since event creation
.hincrby(@key, "total", 1)
# store last notification date for this event
.hset(@key, "last", Math.round(new Date().getTime() / 1000))
.exec =>
cb() if cb
# Performs an action on each subscribe... | CoffeeScript | rs/pushd | lib/event.coffee | MIT | ad18fda4fa48f8f99036b80a2cfe2df1acc1423a | 1,157 | https://github.com/rs/pushd/blob/ad18fda4fa48f8f99036b80a2cfe2df1acc1423a/lib/event.coffee | 53 | 97 | ||
rs/pushd:lib/event.coffee:2:completion | completion | # account number of sent notification since event creation
.hincrby(@key, "total", 1)
# store last notification date for this event
.hset(@key, "last", Math.round(new Date().getTime() / 1000))
.exec =>
cb() if cb
# Performs an action on each subscribe... | page = 0
perPage = 100
total = 0
async.whilst =>
# test if we got less items than requested during last request
# if so, we reached to end of the list
return page * perPage == total
, (done) =>
# treat subscribers by packs of 100 with async... | CoffeeScript | CoffeeScript | rs/pushd | lib/event.coffee | MIT | ad18fda4fa48f8f99036b80a2cfe2df1acc1423a | 1,157 | https://github.com/rs/pushd/blob/ad18fda4fa48f8f99036b80a2cfe2df1acc1423a/lib/event.coffee | 53 | 97 |
rs/pushd:lib/event.coffee:1:raw_corpus | raw_corpus | class Event
OPTION_IGNORE_MESSAGE: 1
name_format: /^[a-zA-Z0-9:._-]{1,100}$/
constructor: (@redis, @name) ->
throw new Error("Missing redis connection") if not redis?
throw new Error('Invalid event name ' + @name) if not Event::name_format.test @name
@key = "event:#{@name}"
inf... | CoffeeScript | rs/pushd | lib/event.coffee | MIT | 40cc1594f102d10db35288825b86de42f9d2917c | 1,157 | https://github.com/rs/pushd/blob/40cc1594f102d10db35288825b86de42f9d2917c/lib/event.coffee | 3 | 52 | ||
rs/pushd:lib/event.coffee:1:coffee_to_js | coffee_to_js | Convert this CoffeeScript to JavaScript.
```coffeescript
class Event
OPTION_IGNORE_MESSAGE: 1
name_format: /^[a-zA-Z0-9:._-]{1,100}$/
constructor: (@redis, @name) ->
throw new Error("Missing redis connection") if not redis?
throw new Error('Invalid event name ' + @name) if not Event::name_f... | var Event,
hasProp = {}.hasOwnProperty;
Event = (function() {
class Event {
constructor(redis1, name) {
this.redis = redis1;
this.name = name;
if (typeof redis === "undefined" || redis === null) {
throw new Error("Missing redis connection");
}
if (!Event.prototype.name_for... | CoffeeScript | JavaScript | rs/pushd | lib/event.coffee | MIT | 40cc1594f102d10db35288825b86de42f9d2917c | 1,157 | https://github.com/rs/pushd/blob/40cc1594f102d10db35288825b86de42f9d2917c/lib/event.coffee | 3 | 52 |
rs/pushd:lib/event.coffee:1:js_to_coffee | js_to_coffee | Convert this JavaScript to CoffeeScript.
```javascript
var Event,
hasProp = {}.hasOwnProperty;
Event = (function() {
class Event {
constructor(redis1, name) {
this.redis = redis1;
this.name = name;
if (typeof redis === "undefined" || redis === null) {
throw new Error("Missing redis co... | class Event
OPTION_IGNORE_MESSAGE: 1
name_format: /^[a-zA-Z0-9:._-]{1,100}$/
constructor: (@redis, @name) ->
throw new Error("Missing redis connection") if not redis?
throw new Error('Invalid event name ' + @name) if not Event::name_format.test @name
@key = "event:#{@name}"
inf... | JavaScript | CoffeeScript | rs/pushd | lib/event.coffee | MIT | 40cc1594f102d10db35288825b86de42f9d2917c | 1,157 | https://github.com/rs/pushd/blob/40cc1594f102d10db35288825b86de42f9d2917c/lib/event.coffee | 3 | 52 |
rs/pushd:lib/event.coffee:1:completion | completion | class Event
OPTION_IGNORE_MESSAGE: 1
name_format: /^[a-zA-Z0-9:._-]{1,100}$/
constructor: (@redis, @name) ->
throw new Error("Missing redis connection") if not redis?
throw new Error('Invalid event name ' + @name) if not Event::name_format.test @name
@key = "event:#{@name}"
inf... | cb(null)
exists: (cb) ->
@redis.sismember "events", @name, (err, exists) =>
cb(exists)
delete: (cb) ->
@forEachSubscribers (subscriber, subOptions, done) =>
# action
subscriber.removeSubscription(@, done)
, =>
# finished
@redi... | CoffeeScript | CoffeeScript | rs/pushd | lib/event.coffee | MIT | 40cc1594f102d10db35288825b86de42f9d2917c | 1,157 | https://github.com/rs/pushd/blob/40cc1594f102d10db35288825b86de42f9d2917c/lib/event.coffee | 3 | 52 |
rs/pushd:lib/event.coffee:2:raw_corpus | raw_corpus | .hset(@key, "last", Math.round(new Date().getTime() / 1000))
.exec =>
cb() if cb
# Performs an action on each subscriber subsribed to this event
forEachSubscribers: (action, finished) ->
Subscriber = require('./subscriber').Subscriber
if @name is 'broadcast'
... | CoffeeScript | rs/pushd | lib/event.coffee | MIT | 40cc1594f102d10db35288825b86de42f9d2917c | 1,157 | https://github.com/rs/pushd/blob/40cc1594f102d10db35288825b86de42f9d2917c/lib/event.coffee | 53 | 94 | ||
rs/pushd:lib/event.coffee:2:completion | completion | .hset(@key, "last", Math.round(new Date().getTime() / 1000))
.exec =>
cb() if cb
# Performs an action on each subscriber subsribed to this event
forEachSubscribers: (action, finished) ->
Subscriber = require('./subscriber').Subscriber
if @name is 'broadcast'
... | total = 0
async.whilst =>
# test if we got less items than requested during last request
# if so, we reached to end of the list
return page * perPage == total
, (done) =>
# treat subscribers by packs of 100 with async to prevent from blocking the event loo... | CoffeeScript | CoffeeScript | rs/pushd | lib/event.coffee | MIT | 40cc1594f102d10db35288825b86de42f9d2917c | 1,157 | https://github.com/rs/pushd/blob/40cc1594f102d10db35288825b86de42f9d2917c/lib/event.coffee | 53 | 94 |
rs/pushd:lib/event.coffee:1:raw_corpus | raw_corpus | class Event
OPTION_IGNORE_MESSAGE: 1
name_format: /^[a-zA-Z0-9:._-]{1,100}$/
constructor: (@redis, @name) ->
throw new Error("Missing redis connection") if not redis?
throw new Error('Invalid event name ' + @name) if not Event::name_format.test @name
@key = "event:#{@name}"
inf... | CoffeeScript | rs/pushd | lib/event.coffee | MIT | 22821bc50da5b0923d81b3ee9e76c61181f32ee7 | 1,157 | https://github.com/rs/pushd/blob/22821bc50da5b0923d81b3ee9e76c61181f32ee7/lib/event.coffee | 3 | 52 | ||
rs/pushd:lib/event.coffee:1:coffee_to_js | coffee_to_js | Convert this CoffeeScript to JavaScript.
```coffeescript
class Event
OPTION_IGNORE_MESSAGE: 1
name_format: /^[a-zA-Z0-9:._-]{1,100}$/
constructor: (@redis, @name) ->
throw new Error("Missing redis connection") if not redis?
throw new Error('Invalid event name ' + @name) if not Event::name_f... | var Event,
hasProp = {}.hasOwnProperty;
Event = (function() {
class Event {
constructor(redis1, name) {
this.redis = redis1;
this.name = name;
if (typeof redis === "undefined" || redis === null) {
throw new Error("Missing redis connection");
}
if (!Event.prototype.name_for... | CoffeeScript | JavaScript | rs/pushd | lib/event.coffee | MIT | 22821bc50da5b0923d81b3ee9e76c61181f32ee7 | 1,157 | https://github.com/rs/pushd/blob/22821bc50da5b0923d81b3ee9e76c61181f32ee7/lib/event.coffee | 3 | 52 |
rs/pushd:lib/event.coffee:1:js_to_coffee | js_to_coffee | Convert this JavaScript to CoffeeScript.
```javascript
var Event,
hasProp = {}.hasOwnProperty;
Event = (function() {
class Event {
constructor(redis1, name) {
this.redis = redis1;
this.name = name;
if (typeof redis === "undefined" || redis === null) {
throw new Error("Missing redis co... | class Event
OPTION_IGNORE_MESSAGE: 1
name_format: /^[a-zA-Z0-9:._-]{1,100}$/
constructor: (@redis, @name) ->
throw new Error("Missing redis connection") if not redis?
throw new Error('Invalid event name ' + @name) if not Event::name_format.test @name
@key = "event:#{@name}"
inf... | JavaScript | CoffeeScript | rs/pushd | lib/event.coffee | MIT | 22821bc50da5b0923d81b3ee9e76c61181f32ee7 | 1,157 | https://github.com/rs/pushd/blob/22821bc50da5b0923d81b3ee9e76c61181f32ee7/lib/event.coffee | 3 | 52 |
rs/pushd:lib/event.coffee:1:completion | completion | class Event
OPTION_IGNORE_MESSAGE: 1
name_format: /^[a-zA-Z0-9:._-]{1,100}$/
constructor: (@redis, @name) ->
throw new Error("Missing redis connection") if not redis?
throw new Error('Invalid event name ' + @name) if not Event::name_format.test @name
@key = "event:#{@name}"
inf... | cb(null)
exists: (cb) ->
@redis.sismember "events", @name, (err, exists) =>
cb(exists)
delete: (cb) ->
@forEachSubscribers (subscriber, subOptions, done) =>
# action
subscriber.removeSubscription(@, done)
, =>
# finished
@redi... | CoffeeScript | CoffeeScript | rs/pushd | lib/event.coffee | MIT | 22821bc50da5b0923d81b3ee9e76c61181f32ee7 | 1,157 | https://github.com/rs/pushd/blob/22821bc50da5b0923d81b3ee9e76c61181f32ee7/lib/event.coffee | 3 | 52 |
rs/pushd:lib/event.coffee:2:raw_corpus | raw_corpus | .hset(@key, "last", Math.round(new Date().getTime() / 1000))
.exec =>
cb() if cb
# Performs an action on each subscriber subsribed to this event
forEachSubscribers: (action, finished) ->
Subscriber = require('./subscriber').Subscriber
if @name is 'broadcast'
... | CoffeeScript | rs/pushd | lib/event.coffee | MIT | 6c5a5cae436e00831c43b9acc2de48063f50b102 | 1,157 | https://github.com/rs/pushd/blob/6c5a5cae436e00831c43b9acc2de48063f50b102/lib/event.coffee | 53 | 94 | ||
rs/pushd:lib/event.coffee:2:completion | completion | .hset(@key, "last", Math.round(new Date().getTime() / 1000))
.exec =>
cb() if cb
# Performs an action on each subscriber subsribed to this event
forEachSubscribers: (action, finished) ->
Subscriber = require('./subscriber').Subscriber
if @name is 'broadcast'
... | total = 0
async.whilst =>
# test if we got less items than requested during last request
# if so, we reached to end of the list
return page * perPage == total
, (done) =>
# treat subscribers by packs of 100 with async to prevent from blocking the event loo... | CoffeeScript | CoffeeScript | rs/pushd | lib/event.coffee | MIT | 6c5a5cae436e00831c43b9acc2de48063f50b102 | 1,157 | https://github.com/rs/pushd/blob/6c5a5cae436e00831c43b9acc2de48063f50b102/lib/event.coffee | 53 | 94 |
rs/pushd:lib/event.coffee:1:raw_corpus | raw_corpus | class Event
OPTION_IGNORE_MESSAGE: 1
name_format: /^[a-zA-Z0-9:._-]{1,100}$/
constructor: (@redis, @pushservices, @name) ->
throw new Error("Missing redis connection") if not redis?
throw new Error('Invalid event name ' + @name) if not Event::name_format.test @name
@key = "event:#{@... | CoffeeScript | rs/pushd | lib/event.coffee | MIT | ecde74fac483e0de8302ee40b449752e8d4d966c | 1,157 | https://github.com/rs/pushd/blob/ecde74fac483e0de8302ee40b449752e8d4d966c/lib/event.coffee | 4 | 53 | ||
rs/pushd:lib/event.coffee:1:coffee_to_js | coffee_to_js | Convert this CoffeeScript to JavaScript.
```coffeescript
class Event
OPTION_IGNORE_MESSAGE: 1
name_format: /^[a-zA-Z0-9:._-]{1,100}$/
constructor: (@redis, @pushservices, @name) ->
throw new Error("Missing redis connection") if not redis?
throw new Error('Invalid event name ' + @name) if no... | var Event,
hasProp = {}.hasOwnProperty;
Event = (function() {
class Event {
constructor(redis1, pushservices, name) {
this.redis = redis1;
this.pushservices = pushservices;
this.name = name;
if (typeof redis === "undefined" || redis === null) {
throw new Error("Missing redis con... | CoffeeScript | JavaScript | rs/pushd | lib/event.coffee | MIT | ecde74fac483e0de8302ee40b449752e8d4d966c | 1,157 | https://github.com/rs/pushd/blob/ecde74fac483e0de8302ee40b449752e8d4d966c/lib/event.coffee | 4 | 53 |
rs/pushd:lib/event.coffee:1:js_to_coffee | js_to_coffee | Convert this JavaScript to CoffeeScript.
```javascript
var Event,
hasProp = {}.hasOwnProperty;
Event = (function() {
class Event {
constructor(redis1, pushservices, name) {
this.redis = redis1;
this.pushservices = pushservices;
this.name = name;
if (typeof redis === "undefined" || redis... | class Event
OPTION_IGNORE_MESSAGE: 1
name_format: /^[a-zA-Z0-9:._-]{1,100}$/
constructor: (@redis, @pushservices, @name) ->
throw new Error("Missing redis connection") if not redis?
throw new Error('Invalid event name ' + @name) if not Event::name_format.test @name
@key = "event:#{@... | JavaScript | CoffeeScript | rs/pushd | lib/event.coffee | MIT | ecde74fac483e0de8302ee40b449752e8d4d966c | 1,157 | https://github.com/rs/pushd/blob/ecde74fac483e0de8302ee40b449752e8d4d966c/lib/event.coffee | 4 | 53 |
rs/pushd:lib/event.coffee:1:completion | completion | class Event
OPTION_IGNORE_MESSAGE: 1
name_format: /^[a-zA-Z0-9:._-]{1,100}$/
constructor: (@redis, @pushservices, @name) ->
throw new Error("Missing redis connection") if not redis?
throw new Error('Invalid event name ' + @name) if not Event::name_format.test @name
@key = "event:#{@... | else
cb(null)
publish: (data, cb) ->
try
payload = new Payload(data)
payload.event = @
catch e
# Invalid payload (empty, missing key or invalid key format)
cb(-1) if cb
return
@redis.sismember "events", @name, ... | CoffeeScript | CoffeeScript | rs/pushd | lib/event.coffee | MIT | ecde74fac483e0de8302ee40b449752e8d4d966c | 1,157 | https://github.com/rs/pushd/blob/ecde74fac483e0de8302ee40b449752e8d4d966c/lib/event.coffee | 4 | 53 |
rs/pushd:lib/event.coffee:2:raw_corpus | raw_corpus | @forEachSubscribers (subscriber, subOptions, done) =>
# action
@pushservices.push(subscriber, subOptions, payload, done)
, (totalSubscribers) =>
# finished
if totalSubscribers > 0
# update some event' stats
... | CoffeeScript | rs/pushd | lib/event.coffee | MIT | ecde74fac483e0de8302ee40b449752e8d4d966c | 1,157 | https://github.com/rs/pushd/blob/ecde74fac483e0de8302ee40b449752e8d4d966c/lib/event.coffee | 54 | 103 | ||
rs/pushd:lib/event.coffee:2:coffee_to_js | coffee_to_js | Convert this CoffeeScript to JavaScript.
```coffeescript
@forEachSubscribers (subscriber, subOptions, done) =>
# action
@pushservices.push(subscriber, subOptions, payload, done)
, (totalSubscribers) =>
# finished
if totalSubscribers > 0
... | this.forEachSubscribers((subscriber, subOptions, done) => {
// action
return this.pushservices.push(subscriber, subOptions, payload, done);
}, (totalSubscribers) => {
// finished
if (totalSubscribers > 0) {
// update some event' stats
// account number of sent notification since event creation
// st... | CoffeeScript | JavaScript | rs/pushd | lib/event.coffee | MIT | ecde74fac483e0de8302ee40b449752e8d4d966c | 1,157 | https://github.com/rs/pushd/blob/ecde74fac483e0de8302ee40b449752e8d4d966c/lib/event.coffee | 54 | 103 |
rs/pushd:lib/event.coffee:2:js_to_coffee | js_to_coffee | Convert this JavaScript to CoffeeScript.
```javascript
this.forEachSubscribers((subscriber, subOptions, done) => {
// action
return this.pushservices.push(subscriber, subOptions, payload, done);
}, (totalSubscribers) => {
// finished
if (totalSubscribers > 0) {
// update some event' stats
// account num... | @forEachSubscribers (subscriber, subOptions, done) =>
# action
@pushservices.push(subscriber, subOptions, payload, done)
, (totalSubscribers) =>
# finished
if totalSubscribers > 0
# update some event' stats
... | JavaScript | CoffeeScript | rs/pushd | lib/event.coffee | MIT | ecde74fac483e0de8302ee40b449752e8d4d966c | 1,157 | https://github.com/rs/pushd/blob/ecde74fac483e0de8302ee40b449752e8d4d966c/lib/event.coffee | 54 | 103 |
rs/pushd:lib/event.coffee:2:completion | completion | @forEachSubscribers (subscriber, subOptions, done) =>
# action
@pushservices.push(subscriber, subOptions, payload, done)
, (totalSubscribers) =>
# finished
if totalSubscribers > 0
# update some event' stats
... | @redis.multi()
# delete event's info hash
.del(@key)
# remove event from global event list
.srem("events", @name)
.exec ->
cb() if cb
# Performs an action on each subscriber subsribed to this event
forEachSubscr... | CoffeeScript | CoffeeScript | rs/pushd | lib/event.coffee | MIT | ecde74fac483e0de8302ee40b449752e8d4d966c | 1,157 | https://github.com/rs/pushd/blob/ecde74fac483e0de8302ee40b449752e8d4d966c/lib/event.coffee | 54 | 103 |
rs/pushd:lib/event.coffee:3:raw_corpus | raw_corpus | total = 0
async.whilst =>
# test if we got less items than requested during last request
# if so, we reached to end of the list
return page * perPage == total
, (done) =>
# treat subscribers by packs of 100 with async to prevent from blocking the event loo... | CoffeeScript | rs/pushd | lib/event.coffee | MIT | ecde74fac483e0de8302ee40b449752e8d4d966c | 1,157 | https://github.com/rs/pushd/blob/ecde74fac483e0de8302ee40b449752e8d4d966c/lib/event.coffee | 104 | 124 | ||
rs/pushd:lib/event.coffee:3:completion | completion | total = 0
async.whilst =>
# test if we got less items than requested during last request
# if so, we reached to end of the list
return page * perPage == total
, (done) =>
# treat subscribers by packs of 100 with async to prevent from blocking the event loo... | for id, i in subscriberIdsAndOptions by 2
tasks.push performAction(id, subscriberIdsAndOptions[i + 1])
async.series tasks, =>
total += subscriberIdsAndOptions.length / 2
done()
page++
, =>
# all done
... | CoffeeScript | CoffeeScript | rs/pushd | lib/event.coffee | MIT | ecde74fac483e0de8302ee40b449752e8d4d966c | 1,157 | https://github.com/rs/pushd/blob/ecde74fac483e0de8302ee40b449752e8d4d966c/lib/event.coffee | 104 | 124 |
rs/pushd:lib/event.coffee:3:raw_corpus | raw_corpus | total = 0
async.whilst =>
# test if we got less items than requested during last request
# if so, we reached to end of the list
return page * perPage == total
, (done) =>
# treat subscribers by packs of 100 with async to prevent from blocking the event loo... | CoffeeScript | rs/pushd | lib/event.coffee | MIT | cb62436ea3f0c4b9d2c3bc0a5848571250ee6826 | 1,157 | https://github.com/rs/pushd/blob/cb62436ea3f0c4b9d2c3bc0a5848571250ee6826/lib/event.coffee | 104 | 123 | ||
rs/pushd:lib/event.coffee:3:completion | completion | total = 0
async.whilst =>
# test if we got less items than requested during last request
# if so, we reached to end of the list
return page * perPage == total
, (done) =>
# treat subscribers by packs of 100 with async to prevent from blocking the event loo... | for id, i in subscriberIdsAndOptions by 2
tasks.push performAction(id, subscriberIdsAndOptions[i + 1])
async.series tasks, =>
total += subscriberIdsAndOptions.length / 2
done()
, =>
# all done
finished(total) if ... | CoffeeScript | CoffeeScript | rs/pushd | lib/event.coffee | MIT | cb62436ea3f0c4b9d2c3bc0a5848571250ee6826 | 1,157 | https://github.com/rs/pushd/blob/cb62436ea3f0c4b9d2c3bc0a5848571250ee6826/lib/event.coffee | 104 | 123 |
rs/pushd:lib/event.coffee:1:raw_corpus | raw_corpus | class Event
OPTION_IGNORE_MESSAGE: 1
name_format: /^[a-zA-Z0-9:._-]{1,100}$/
constructor: (@redis, @pushservices, @name) ->
throw new Error("Missing redis connection") if not redis?
throw new Error('Invalid event name') if not Event::name_format.test @name
@key = "event:#{@name}"
... | CoffeeScript | rs/pushd | lib/event.coffee | MIT | a00ee14233b2798b03dc085cdce78a86076a9be8 | 1,157 | https://github.com/rs/pushd/blob/a00ee14233b2798b03dc085cdce78a86076a9be8/lib/event.coffee | 4 | 53 | ||
rs/pushd:lib/event.coffee:1:coffee_to_js | coffee_to_js | Convert this CoffeeScript to JavaScript.
```coffeescript
class Event
OPTION_IGNORE_MESSAGE: 1
name_format: /^[a-zA-Z0-9:._-]{1,100}$/
constructor: (@redis, @pushservices, @name) ->
throw new Error("Missing redis connection") if not redis?
throw new Error('Invalid event name') if not Event::... | var Event,
hasProp = {}.hasOwnProperty;
Event = (function() {
class Event {
constructor(redis1, pushservices, name) {
this.redis = redis1;
this.pushservices = pushservices;
this.name = name;
if (typeof redis === "undefined" || redis === null) {
throw new Error("Missing redis con... | CoffeeScript | JavaScript | rs/pushd | lib/event.coffee | MIT | a00ee14233b2798b03dc085cdce78a86076a9be8 | 1,157 | https://github.com/rs/pushd/blob/a00ee14233b2798b03dc085cdce78a86076a9be8/lib/event.coffee | 4 | 53 |
rs/pushd:lib/event.coffee:1:js_to_coffee | js_to_coffee | Convert this JavaScript to CoffeeScript.
```javascript
var Event,
hasProp = {}.hasOwnProperty;
Event = (function() {
class Event {
constructor(redis1, pushservices, name) {
this.redis = redis1;
this.pushservices = pushservices;
this.name = name;
if (typeof redis === "undefined" || redis... | class Event
OPTION_IGNORE_MESSAGE: 1
name_format: /^[a-zA-Z0-9:._-]{1,100}$/
constructor: (@redis, @pushservices, @name) ->
throw new Error("Missing redis connection") if not redis?
throw new Error('Invalid event name') if not Event::name_format.test @name
@key = "event:#{@name}"
... | JavaScript | CoffeeScript | rs/pushd | lib/event.coffee | MIT | a00ee14233b2798b03dc085cdce78a86076a9be8 | 1,157 | https://github.com/rs/pushd/blob/a00ee14233b2798b03dc085cdce78a86076a9be8/lib/event.coffee | 4 | 53 |
rs/pushd:lib/event.coffee:1:completion | completion | class Event
OPTION_IGNORE_MESSAGE: 1
name_format: /^[a-zA-Z0-9:._-]{1,100}$/
constructor: (@redis, @pushservices, @name) ->
throw new Error("Missing redis connection") if not redis?
throw new Error('Invalid event name') if not Event::name_format.test @name
@key = "event:#{@name}"
... | else
cb(null)
publish: (data, cb) ->
try
payload = new Payload(data)
payload.event = @
catch e
# Invalid payload (empty, missing key or invalid key format)
cb(-1) if cb
return
@redis.sismember "events", @name, ... | CoffeeScript | CoffeeScript | rs/pushd | lib/event.coffee | MIT | a00ee14233b2798b03dc085cdce78a86076a9be8 | 1,157 | https://github.com/rs/pushd/blob/a00ee14233b2798b03dc085cdce78a86076a9be8/lib/event.coffee | 4 | 53 |
rs/pushd:lib/event.coffee:2:raw_corpus | raw_corpus | @forEachSubscribers (subscriber, subOptions, done) =>
# action
@pushservices.push(subscriber, subOptions, payload, done)
, (totalSubscribers) =>
# finished
if totalSubscribers > 0
# update some event' stats
... | CoffeeScript | rs/pushd | lib/event.coffee | MIT | c0619e4ce06a98d60aea2b817a4a7dee4b0c24ff | 1,157 | https://github.com/rs/pushd/blob/c0619e4ce06a98d60aea2b817a4a7dee4b0c24ff/lib/event.coffee | 56 | 105 | ||
rs/pushd:lib/event.coffee:2:coffee_to_js | coffee_to_js | Convert this CoffeeScript to JavaScript.
```coffeescript
@forEachSubscribers (subscriber, subOptions, done) =>
# action
@pushservices.push(subscriber, subOptions, payload, done)
, (totalSubscribers) =>
# finished
if totalSubscribers > 0
... | this.forEachSubscribers((subscriber, subOptions, done) => {
// action
return this.pushservices.push(subscriber, subOptions, payload, done);
}, (totalSubscribers) => {
// finished
if (totalSubscribers > 0) {
// update some event' stats
// account number of sent notification since event creation
// st... | CoffeeScript | JavaScript | rs/pushd | lib/event.coffee | MIT | c0619e4ce06a98d60aea2b817a4a7dee4b0c24ff | 1,157 | https://github.com/rs/pushd/blob/c0619e4ce06a98d60aea2b817a4a7dee4b0c24ff/lib/event.coffee | 56 | 105 |
rs/pushd:lib/event.coffee:2:js_to_coffee | js_to_coffee | Convert this JavaScript to CoffeeScript.
```javascript
this.forEachSubscribers((subscriber, subOptions, done) => {
// action
return this.pushservices.push(subscriber, subOptions, payload, done);
}, (totalSubscribers) => {
// finished
if (totalSubscribers > 0) {
// update some event' stats
// account num... | @forEachSubscribers (subscriber, subOptions, done) =>
# action
@pushservices.push(subscriber, subOptions, payload, done)
, (totalSubscribers) =>
# finished
if totalSubscribers > 0
# update some event' stats
... | JavaScript | CoffeeScript | rs/pushd | lib/event.coffee | MIT | c0619e4ce06a98d60aea2b817a4a7dee4b0c24ff | 1,157 | https://github.com/rs/pushd/blob/c0619e4ce06a98d60aea2b817a4a7dee4b0c24ff/lib/event.coffee | 56 | 105 |
rs/pushd:lib/event.coffee:2:completion | completion | @forEachSubscribers (subscriber, subOptions, done) =>
# action
@pushservices.push(subscriber, subOptions, payload, done)
, (totalSubscribers) =>
# finished
if totalSubscribers > 0
# update some event' stats
... | @redis.multi()
# delete event's info hash
.del(@key)
# remove event from global event list
.srem("events", @name)
.exec ->
cb() if cb
# Performs an action on each subscriber subsribed to this event
forEachSubscr... | CoffeeScript | CoffeeScript | rs/pushd | lib/event.coffee | MIT | c0619e4ce06a98d60aea2b817a4a7dee4b0c24ff | 1,157 | https://github.com/rs/pushd/blob/c0619e4ce06a98d60aea2b817a4a7dee4b0c24ff/lib/event.coffee | 56 | 105 |
rs/pushd:lib/event.coffee:3:raw_corpus | raw_corpus | async.whilst =>
# test if we got less items than requested during last request
# if so, we reached to end of the list
return page * perPage == total
, (done) =>
# treat subscribers by packs of 100 with async to prevent from blocking the event loop
# fo... | CoffeeScript | rs/pushd | lib/event.coffee | MIT | c0619e4ce06a98d60aea2b817a4a7dee4b0c24ff | 1,157 | https://github.com/rs/pushd/blob/c0619e4ce06a98d60aea2b817a4a7dee4b0c24ff/lib/event.coffee | 106 | 122 | ||
rs/pushd:lib/event.coffee:3:coffee_to_js | coffee_to_js | Convert this CoffeeScript to JavaScript.
```coffeescript
async.whilst =>
# test if we got less items than requested during last request
# if so, we reached to end of the list
return page * perPage == total
, (done) =>
# treat subscribers by packs of 100 with async... | async.whilst(() => {
// test if we got less items than requested during last request
// if so, we reached to end of the list
return page * perPage === total;
}, (done) => {
// treat subscribers by packs of 100 with async to prevent from blocking the event loop
// for too long on large subscribers lists
retu... | CoffeeScript | JavaScript | rs/pushd | lib/event.coffee | MIT | c0619e4ce06a98d60aea2b817a4a7dee4b0c24ff | 1,157 | https://github.com/rs/pushd/blob/c0619e4ce06a98d60aea2b817a4a7dee4b0c24ff/lib/event.coffee | 106 | 122 |
rs/pushd:lib/event.coffee:3:js_to_coffee | js_to_coffee | Convert this JavaScript to CoffeeScript.
```javascript
async.whilst(() => {
// test if we got less items than requested during last request
// if so, we reached to end of the list
return page * perPage === total;
}, (done) => {
// treat subscribers by packs of 100 with async to prevent from blocking the event l... | async.whilst =>
# test if we got less items than requested during last request
# if so, we reached to end of the list
return page * perPage == total
, (done) =>
# treat subscribers by packs of 100 with async to prevent from blocking the event loop
# fo... | JavaScript | CoffeeScript | rs/pushd | lib/event.coffee | MIT | c0619e4ce06a98d60aea2b817a4a7dee4b0c24ff | 1,157 | https://github.com/rs/pushd/blob/c0619e4ce06a98d60aea2b817a4a7dee4b0c24ff/lib/event.coffee | 106 | 122 |
rs/pushd:lib/event.coffee:3:completion | completion | async.whilst =>
# test if we got less items than requested during last request
# if so, we reached to end of the list
return page * perPage == total
, (done) =>
# treat subscribers by packs of 100 with async to prevent from blocking the event loop
# fo... | tasks = []
for id, i in subscriberIdsAndOptions by 2
tasks.push performAction(id, subscriberIdsAndOptions[i + 1])
async.series tasks, =>
total += subscriberIdsAndOptions.length / 2
done()
, =>
# all done
... | CoffeeScript | CoffeeScript | rs/pushd | lib/event.coffee | MIT | c0619e4ce06a98d60aea2b817a4a7dee4b0c24ff | 1,157 | https://github.com/rs/pushd/blob/c0619e4ce06a98d60aea2b817a4a7dee4b0c24ff/lib/event.coffee | 106 | 122 |
rs/pushd:lib/event.coffee:2:raw_corpus | raw_corpus | @forEachSubscribers (subscriber, subOptions, done) =>
# action
@pushservices.push(subscriber, subOptions, payload, done)
, (totalSubscribers) =>
# finished
if totalSubscribers > 0
# update some event' stats
... | CoffeeScript | rs/pushd | lib/event.coffee | MIT | 348bd3e8a77369300c20775896045de9af11d8f3 | 1,157 | https://github.com/rs/pushd/blob/348bd3e8a77369300c20775896045de9af11d8f3/lib/event.coffee | 56 | 105 | ||
rs/pushd:lib/event.coffee:2:coffee_to_js | coffee_to_js | Convert this CoffeeScript to JavaScript.
```coffeescript
@forEachSubscribers (subscriber, subOptions, done) =>
# action
@pushservices.push(subscriber, subOptions, payload, done)
, (totalSubscribers) =>
# finished
if totalSubscribers > 0
... | this.forEachSubscribers((subscriber, subOptions, done) => {
// action
return this.pushservices.push(subscriber, subOptions, payload, done);
}, (totalSubscribers) => {
// finished
if (totalSubscribers > 0) {
// update some event' stats
// account number of sent notification since event creation
// st... | CoffeeScript | JavaScript | rs/pushd | lib/event.coffee | MIT | 348bd3e8a77369300c20775896045de9af11d8f3 | 1,157 | https://github.com/rs/pushd/blob/348bd3e8a77369300c20775896045de9af11d8f3/lib/event.coffee | 56 | 105 |
rs/pushd:lib/event.coffee:2:js_to_coffee | js_to_coffee | Convert this JavaScript to CoffeeScript.
```javascript
this.forEachSubscribers((subscriber, subOptions, done) => {
// action
return this.pushservices.push(subscriber, subOptions, payload, done);
}, (totalSubscribers) => {
// finished
if (totalSubscribers > 0) {
// update some event' stats
// account num... | @forEachSubscribers (subscriber, subOptions, done) =>
# action
@pushservices.push(subscriber, subOptions, payload, done)
, (totalSubscribers) =>
# finished
if totalSubscribers > 0
# update some event' stats
... | JavaScript | CoffeeScript | rs/pushd | lib/event.coffee | MIT | 348bd3e8a77369300c20775896045de9af11d8f3 | 1,157 | https://github.com/rs/pushd/blob/348bd3e8a77369300c20775896045de9af11d8f3/lib/event.coffee | 56 | 105 |
rs/pushd:lib/event.coffee:2:completion | completion | @forEachSubscribers (subscriber, subOptions, done) =>
# action
@pushservices.push(subscriber, subOptions, payload, done)
, (totalSubscribers) =>
# finished
if totalSubscribers > 0
# update some event' stats
... | @redis.multi()
# delete event's info hash
.del(@key)
# remove event from global event list
.srem("events", @name)
.exec ->
cb() if cb
# Performs an action on each subscriber subsribed to this event
forEachSubscr... | CoffeeScript | CoffeeScript | rs/pushd | lib/event.coffee | MIT | 348bd3e8a77369300c20775896045de9af11d8f3 | 1,157 | https://github.com/rs/pushd/blob/348bd3e8a77369300c20775896045de9af11d8f3/lib/event.coffee | 56 | 105 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.