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:src/swag.numbers.coffee:1:raw_corpus | raw_corpus | Swag.addHelper 'toFixed', (number, digits) ->
number = parseFloat number
digits = if Utils.isUndefined digits then 0 else digits
number.toFixed digits
, 'number'
Swag.addHelper 'toPrecision', (number, precision) ->
number = parseFloat number
precision = if Utils.isUndefined precision then 1 else pr... | CoffeeScript | elving/swag | src/swag.numbers.coffee | MIT | e9c8788dfc9f640038c00eaafe33f4137ff5f465 | 675 | https://github.com/elving/swag/blob/e9c8788dfc9f640038c00eaafe33f4137ff5f465/src/swag.numbers.coffee | 1 | 31 | ||
elving/swag:src/swag.numbers.coffee:1:coffee_to_js | coffee_to_js | Convert this CoffeeScript to JavaScript.
```coffeescript
Swag.addHelper 'toFixed', (number, digits) ->
number = parseFloat number
digits = if Utils.isUndefined digits then 0 else digits
number.toFixed digits
, 'number'
Swag.addHelper 'toPrecision', (number, precision) ->
number = parseFloat number
... | Swag.addHelper('toFixed', function(number, digits) {
number = parseFloat(number);
digits = Utils.isUndefined(digits) ? 0 : digits;
return number.toFixed(digits);
}, 'number');
Swag.addHelper('toPrecision', function(number, precision) {
number = parseFloat(number);
precision = Utils.isUndefined(precision) ? 1... | CoffeeScript | JavaScript | elving/swag | src/swag.numbers.coffee | MIT | e9c8788dfc9f640038c00eaafe33f4137ff5f465 | 675 | https://github.com/elving/swag/blob/e9c8788dfc9f640038c00eaafe33f4137ff5f465/src/swag.numbers.coffee | 1 | 31 |
elving/swag:src/swag.numbers.coffee:1:js_to_coffee | js_to_coffee | Convert this JavaScript to CoffeeScript.
```javascript
Swag.addHelper('toFixed', function(number, digits) {
number = parseFloat(number);
digits = Utils.isUndefined(digits) ? 0 : digits;
return number.toFixed(digits);
}, 'number');
Swag.addHelper('toPrecision', function(number, precision) {
number = parseFloat(... | Swag.addHelper 'toFixed', (number, digits) ->
number = parseFloat number
digits = if Utils.isUndefined digits then 0 else digits
number.toFixed digits
, 'number'
Swag.addHelper 'toPrecision', (number, precision) ->
number = parseFloat number
precision = if Utils.isUndefined precision then 1 else pr... | JavaScript | CoffeeScript | elving/swag | src/swag.numbers.coffee | MIT | e9c8788dfc9f640038c00eaafe33f4137ff5f465 | 675 | https://github.com/elving/swag/blob/e9c8788dfc9f640038c00eaafe33f4137ff5f465/src/swag.numbers.coffee | 1 | 31 |
elving/swag:src/swag.numbers.coffee:1:completion | completion | Swag.addHelper 'toFixed', (number, digits) ->
number = parseFloat number
digits = if Utils.isUndefined digits then 0 else digits
number.toFixed digits
, 'number'
Swag.addHelper 'toPrecision', (number, precision) ->
number = parseFloat number
precision = if Utils.isUndefined precision then 1 else pr... | number.toExponential fractions
, 'number'
Swag.addHelper 'toInt', (number) ->
parseInt number, 10
, 'number'
Swag.addHelper 'toFloat', (number) ->
parseFloat number
, 'number'
Swag.addHelper 'digitGrouping', (number, separator) ->
number = parseFloat number
separator = if Utils.isUndefined separator ... | CoffeeScript | CoffeeScript | elving/swag | src/swag.numbers.coffee | MIT | e9c8788dfc9f640038c00eaafe33f4137ff5f465 | 675 | https://github.com/elving/swag/blob/e9c8788dfc9f640038c00eaafe33f4137ff5f465/src/swag.numbers.coffee | 1 | 31 |
elving/swag:src/swag.numbers.coffee:1:raw_corpus | raw_corpus | Swag.addHelper 'toFixed', (number, digits) ->
number = parseFloat Utils.result number
digits = if Utils.isUndefined digits then 0 else Utils.result digits
number.toFixed digits
, 'number'
Swag.addHelper 'toPrecision', (number, precision) ->
number = parseFloat Utils.result number
precision = if Uti... | CoffeeScript | elving/swag | src/swag.numbers.coffee | MIT | 1dab7399e1ac6127c7b2cde8d518f46c85838801 | 675 | https://github.com/elving/swag/blob/1dab7399e1ac6127c7b2cde8d518f46c85838801/src/swag.numbers.coffee | 1 | 33 | ||
elving/swag:src/swag.numbers.coffee:1:coffee_to_js | coffee_to_js | Convert this CoffeeScript to JavaScript.
```coffeescript
Swag.addHelper 'toFixed', (number, digits) ->
number = parseFloat Utils.result number
digits = if Utils.isUndefined digits then 0 else Utils.result digits
number.toFixed digits
, 'number'
Swag.addHelper 'toPrecision', (number, precision) ->
numbe... | Swag.addHelper('toFixed', function(number, digits) {
number = parseFloat(Utils.result(number));
digits = Utils.isUndefined(digits) ? 0 : Utils.result(digits);
return number.toFixed(digits);
}, 'number');
Swag.addHelper('toPrecision', function(number, precision) {
number = parseFloat(Utils.result(number));
pr... | CoffeeScript | JavaScript | elving/swag | src/swag.numbers.coffee | MIT | 1dab7399e1ac6127c7b2cde8d518f46c85838801 | 675 | https://github.com/elving/swag/blob/1dab7399e1ac6127c7b2cde8d518f46c85838801/src/swag.numbers.coffee | 1 | 33 |
elving/swag:src/swag.numbers.coffee:1:js_to_coffee | js_to_coffee | Convert this JavaScript to CoffeeScript.
```javascript
Swag.addHelper('toFixed', function(number, digits) {
number = parseFloat(Utils.result(number));
digits = Utils.isUndefined(digits) ? 0 : Utils.result(digits);
return number.toFixed(digits);
}, 'number');
Swag.addHelper('toPrecision', function(number, precisi... | Swag.addHelper 'toFixed', (number, digits) ->
number = parseFloat Utils.result number
digits = if Utils.isUndefined digits then 0 else Utils.result digits
number.toFixed digits
, 'number'
Swag.addHelper 'toPrecision', (number, precision) ->
number = parseFloat Utils.result number
precision = if Uti... | JavaScript | CoffeeScript | elving/swag | src/swag.numbers.coffee | MIT | 1dab7399e1ac6127c7b2cde8d518f46c85838801 | 675 | https://github.com/elving/swag/blob/1dab7399e1ac6127c7b2cde8d518f46c85838801/src/swag.numbers.coffee | 1 | 33 |
elving/swag:src/swag.numbers.coffee:1:completion | completion | Swag.addHelper 'toFixed', (number, digits) ->
number = parseFloat Utils.result number
digits = if Utils.isUndefined digits then 0 else Utils.result digits
number.toFixed digits
, 'number'
Swag.addHelper 'toPrecision', (number, precision) ->
number = parseFloat Utils.result number
precision = if Uti... | , 'number'
Swag.addHelper 'toInt', (number) ->
number = Utils.result number
parseInt number, 10
, 'number'
Swag.addHelper 'toFloat', (number) ->
number = Utils.result number
parseFloat number
, 'number'
Swag.addHelper 'digitGrouping', (number, separator) ->
number = parseFloat Utils.result number... | CoffeeScript | CoffeeScript | elving/swag | src/swag.numbers.coffee | MIT | 1dab7399e1ac6127c7b2cde8d518f46c85838801 | 675 | https://github.com/elving/swag/blob/1dab7399e1ac6127c7b2cde8d518f46c85838801/src/swag.numbers.coffee | 1 | 33 |
elving/swag:src/swag.numbers.coffee:1:raw_corpus | raw_corpus | Swag.addHelper 'toFixed', (number, digits) ->
unless Utils.isUndefined number
number = parseFloat Utils.result number
digits = if Utils.isUndefined digits then 0 else Utils.result digits
number.toFixed digits
else
Utils.err '{{toFixed}} takes at least one argument (number).'
Swa... | CoffeeScript | elving/swag | src/swag.numbers.coffee | MIT | 3a5249a04c2d7c27acb8834dc3e31ae0f56ccfd1 | 675 | https://github.com/elving/swag/blob/3a5249a04c2d7c27acb8834dc3e31ae0f56ccfd1/src/swag.numbers.coffee | 1 | 45 | ||
elving/swag:src/swag.numbers.coffee:1:coffee_to_js | coffee_to_js | Convert this CoffeeScript to JavaScript.
```coffeescript
Swag.addHelper 'toFixed', (number, digits) ->
unless Utils.isUndefined number
number = parseFloat Utils.result number
digits = if Utils.isUndefined digits then 0 else Utils.result digits
number.toFixed digits
else
Utils.err... | Swag.addHelper('toFixed', function(number, digits) {
if (!Utils.isUndefined(number)) {
number = parseFloat(Utils.result(number));
digits = Utils.isUndefined(digits) ? 0 : Utils.result(digits);
return number.toFixed(digits);
} else {
return Utils.err('{{toFixed}} takes at least one argument (number).... | CoffeeScript | JavaScript | elving/swag | src/swag.numbers.coffee | MIT | 3a5249a04c2d7c27acb8834dc3e31ae0f56ccfd1 | 675 | https://github.com/elving/swag/blob/3a5249a04c2d7c27acb8834dc3e31ae0f56ccfd1/src/swag.numbers.coffee | 1 | 45 |
elving/swag:src/swag.numbers.coffee:1:js_to_coffee | js_to_coffee | Convert this JavaScript to CoffeeScript.
```javascript
Swag.addHelper('toFixed', function(number, digits) {
if (!Utils.isUndefined(number)) {
number = parseFloat(Utils.result(number));
digits = Utils.isUndefined(digits) ? 0 : Utils.result(digits);
return number.toFixed(digits);
} else {
return Utils... | Swag.addHelper 'toFixed', (number, digits) ->
unless Utils.isUndefined number
number = parseFloat Utils.result number
digits = if Utils.isUndefined digits then 0 else Utils.result digits
number.toFixed digits
else
Utils.err '{{toFixed}} takes at least one argument (number).'
Swa... | JavaScript | CoffeeScript | elving/swag | src/swag.numbers.coffee | MIT | 3a5249a04c2d7c27acb8834dc3e31ae0f56ccfd1 | 675 | https://github.com/elving/swag/blob/3a5249a04c2d7c27acb8834dc3e31ae0f56ccfd1/src/swag.numbers.coffee | 1 | 45 |
elving/swag:src/swag.numbers.coffee:1:completion | completion | Swag.addHelper 'toFixed', (number, digits) ->
unless Utils.isUndefined number
number = parseFloat Utils.result number
digits = if Utils.isUndefined digits then 0 else Utils.result digits
number.toFixed digits
else
Utils.err '{{toFixed}} takes at least one argument (number).'
Swa... | Utils.err '{{toExponential}} takes at least one argument (number).'
Swag.addHelper 'toInt', (number) ->
unless Utils.isUndefined number
number = Utils.result number
parseInt number, 10
else
Utils.err '{{toInt}} takes one argument (number).'
Swag.addHelper 'toFloat', (number) ->
unl... | CoffeeScript | CoffeeScript | elving/swag | src/swag.numbers.coffee | MIT | 3a5249a04c2d7c27acb8834dc3e31ae0f56ccfd1 | 675 | https://github.com/elving/swag/blob/3a5249a04c2d7c27acb8834dc3e31ae0f56ccfd1/src/swag.numbers.coffee | 1 | 45 |
elving/swag:src/swag.numbers.coffee:1:raw_corpus | raw_corpus | Swag.addHelper 'toFixed', (number, digits) ->
digits = 0 if Utils.isUndefined(digits)
number.toFixed digits
Swag.addHelper 'toPrecision', (number, precision) ->
precision = 1 if Utils.isUndefined(precision)
number.toPrecision precision
Swag.addHelper 'toExponential', (number, fractions) ->
fractio... | CoffeeScript | elving/swag | src/swag.numbers.coffee | MIT | f17d2de491f4ec174ae77b59461eb8c9f823302c | 675 | https://github.com/elving/swag/blob/f17d2de491f4ec174ae77b59461eb8c9f823302c/src/swag.numbers.coffee | 1 | 21 | ||
elving/swag:src/swag.numbers.coffee:1:coffee_to_js | coffee_to_js | Convert this CoffeeScript to JavaScript.
```coffeescript
Swag.addHelper 'toFixed', (number, digits) ->
digits = 0 if Utils.isUndefined(digits)
number.toFixed digits
Swag.addHelper 'toPrecision', (number, precision) ->
precision = 1 if Utils.isUndefined(precision)
number.toPrecision precision
Swag.addH... | Swag.addHelper('toFixed', function(number, digits) {
if (Utils.isUndefined(digits)) {
digits = 0;
}
return number.toFixed(digits);
});
Swag.addHelper('toPrecision', function(number, precision) {
if (Utils.isUndefined(precision)) {
precision = 1;
}
return number.toPrecision(precision);
});
Swag.add... | CoffeeScript | JavaScript | elving/swag | src/swag.numbers.coffee | MIT | f17d2de491f4ec174ae77b59461eb8c9f823302c | 675 | https://github.com/elving/swag/blob/f17d2de491f4ec174ae77b59461eb8c9f823302c/src/swag.numbers.coffee | 1 | 21 |
elving/swag:src/swag.numbers.coffee:1:js_to_coffee | js_to_coffee | Convert this JavaScript to CoffeeScript.
```javascript
Swag.addHelper('toFixed', function(number, digits) {
if (Utils.isUndefined(digits)) {
digits = 0;
}
return number.toFixed(digits);
});
Swag.addHelper('toPrecision', function(number, precision) {
if (Utils.isUndefined(precision)) {
precision = 1;
... | Swag.addHelper 'toFixed', (number, digits) ->
digits = 0 if Utils.isUndefined(digits)
number.toFixed digits
Swag.addHelper 'toPrecision', (number, precision) ->
precision = 1 if Utils.isUndefined(precision)
number.toPrecision precision
Swag.addHelper 'toExponential', (number, fractions) ->
fractio... | JavaScript | CoffeeScript | elving/swag | src/swag.numbers.coffee | MIT | f17d2de491f4ec174ae77b59461eb8c9f823302c | 675 | https://github.com/elving/swag/blob/f17d2de491f4ec174ae77b59461eb8c9f823302c/src/swag.numbers.coffee | 1 | 21 |
elving/swag:src/swag.numbers.coffee:1:completion | completion | Swag.addHelper 'toFixed', (number, digits) ->
digits = 0 if Utils.isUndefined(digits)
number.toFixed digits
Swag.addHelper 'toPrecision', (number, precision) ->
precision = 1 if Utils.isUndefined(precision)
number.toPrecision precision
Swag.addHelper 'toExponential', (number, fractions) ->
fractio... | number.toExponential fractions
Swag.addHelper 'toInt', (number) ->
parseInt number, 10
Swag.addHelper 'toFloat', (number) ->
parseFloat number
Swag.addHelper 'digitGrouping', (number, separator) ->
separator = ',' if Utils.isUndefined(separator)
number.toString().replace /(\d)(?=(\d\d\d)+(?!\d))/g, "... | CoffeeScript | CoffeeScript | elving/swag | src/swag.numbers.coffee | MIT | f17d2de491f4ec174ae77b59461eb8c9f823302c | 675 | https://github.com/elving/swag/blob/f17d2de491f4ec174ae77b59461eb8c9f823302c/src/swag.numbers.coffee | 1 | 21 |
elving/swag:src/swag.numbers.coffee:1:raw_corpus | raw_corpus | Swag.registerHelper 'toFixed', (number, digits) ->
digits = 0 if Utils.isUndefined(digits)
number.toFixed digits
Swag.registerHelper 'toPrecision', (number, precision) ->
precision = 1 if Utils.isUndefined(precision)
number.toPrecision precision
Swag.registerHelper 'toExponential', (number, fractions)... | CoffeeScript | elving/swag | src/swag.numbers.coffee | MIT | 65fa361b1dbaa9c28ca8dbf5cad24d741f96ff17 | 675 | https://github.com/elving/swag/blob/65fa361b1dbaa9c28ca8dbf5cad24d741f96ff17/src/swag.numbers.coffee | 1 | 21 | ||
elving/swag:src/swag.numbers.coffee:1:coffee_to_js | coffee_to_js | Convert this CoffeeScript to JavaScript.
```coffeescript
Swag.registerHelper 'toFixed', (number, digits) ->
digits = 0 if Utils.isUndefined(digits)
number.toFixed digits
Swag.registerHelper 'toPrecision', (number, precision) ->
precision = 1 if Utils.isUndefined(precision)
number.toPrecision precision
... | Swag.registerHelper('toFixed', function(number, digits) {
if (Utils.isUndefined(digits)) {
digits = 0;
}
return number.toFixed(digits);
});
Swag.registerHelper('toPrecision', function(number, precision) {
if (Utils.isUndefined(precision)) {
precision = 1;
}
return number.toPrecision(precision);
});... | CoffeeScript | JavaScript | elving/swag | src/swag.numbers.coffee | MIT | 65fa361b1dbaa9c28ca8dbf5cad24d741f96ff17 | 675 | https://github.com/elving/swag/blob/65fa361b1dbaa9c28ca8dbf5cad24d741f96ff17/src/swag.numbers.coffee | 1 | 21 |
elving/swag:src/swag.numbers.coffee:1:js_to_coffee | js_to_coffee | Convert this JavaScript to CoffeeScript.
```javascript
Swag.registerHelper('toFixed', function(number, digits) {
if (Utils.isUndefined(digits)) {
digits = 0;
}
return number.toFixed(digits);
});
Swag.registerHelper('toPrecision', function(number, precision) {
if (Utils.isUndefined(precision)) {
precisi... | Swag.registerHelper 'toFixed', (number, digits) ->
digits = 0 if Utils.isUndefined(digits)
number.toFixed digits
Swag.registerHelper 'toPrecision', (number, precision) ->
precision = 1 if Utils.isUndefined(precision)
number.toPrecision precision
Swag.registerHelper 'toExponential', (number, fractions)... | JavaScript | CoffeeScript | elving/swag | src/swag.numbers.coffee | MIT | 65fa361b1dbaa9c28ca8dbf5cad24d741f96ff17 | 675 | https://github.com/elving/swag/blob/65fa361b1dbaa9c28ca8dbf5cad24d741f96ff17/src/swag.numbers.coffee | 1 | 21 |
elving/swag:src/swag.numbers.coffee:1:completion | completion | Swag.registerHelper 'toFixed', (number, digits) ->
digits = 0 if Utils.isUndefined(digits)
number.toFixed digits
Swag.registerHelper 'toPrecision', (number, precision) ->
precision = 1 if Utils.isUndefined(precision)
number.toPrecision precision
Swag.registerHelper 'toExponential', (number, fractions)... | number.toExponential fractions
Swag.registerHelper 'toInt', (number) ->
parseInt number, 10
Swag.registerHelper 'toFloat', (number) ->
parseFloat number
Swag.registerHelper 'digitGrouping', (number, separator) ->
separator = ',' if Utils.isUndefined(separator)
number.toString().replace /(\d)(?=(\d\d\... | CoffeeScript | CoffeeScript | elving/swag | src/swag.numbers.coffee | MIT | 65fa361b1dbaa9c28ca8dbf5cad24d741f96ff17 | 675 | https://github.com/elving/swag/blob/65fa361b1dbaa9c28ca8dbf5cad24d741f96ff17/src/swag.numbers.coffee | 1 | 21 |
elving/swag:src/swag.numbers.coffee:1:raw_corpus | raw_corpus | Handlebars.registerHelper 'toFixed', (number, digits) ->
digits = 0 if Utils.isUndefined(digits)
number.toFixed digits
Handlebars.registerHelper 'toPrecision', (number, precision) ->
precision = 1 if Utils.isUndefined(precision)
number.toPrecision precision
Handlebars.registerHelper 'toExponential', (... | CoffeeScript | elving/swag | src/swag.numbers.coffee | MIT | b691217045ff6f67119d54d3a9d346dca70d062a | 675 | https://github.com/elving/swag/blob/b691217045ff6f67119d54d3a9d346dca70d062a/src/swag.numbers.coffee | 1 | 21 | ||
elving/swag:src/swag.numbers.coffee:1:coffee_to_js | coffee_to_js | Convert this CoffeeScript to JavaScript.
```coffeescript
Handlebars.registerHelper 'toFixed', (number, digits) ->
digits = 0 if Utils.isUndefined(digits)
number.toFixed digits
Handlebars.registerHelper 'toPrecision', (number, precision) ->
precision = 1 if Utils.isUndefined(precision)
number.toPrecisio... | Handlebars.registerHelper('toFixed', function(number, digits) {
if (Utils.isUndefined(digits)) {
digits = 0;
}
return number.toFixed(digits);
});
Handlebars.registerHelper('toPrecision', function(number, precision) {
if (Utils.isUndefined(precision)) {
precision = 1;
}
return number.toPrecision(pre... | CoffeeScript | JavaScript | elving/swag | src/swag.numbers.coffee | MIT | b691217045ff6f67119d54d3a9d346dca70d062a | 675 | https://github.com/elving/swag/blob/b691217045ff6f67119d54d3a9d346dca70d062a/src/swag.numbers.coffee | 1 | 21 |
elving/swag:src/swag.numbers.coffee:1:js_to_coffee | js_to_coffee | Convert this JavaScript to CoffeeScript.
```javascript
Handlebars.registerHelper('toFixed', function(number, digits) {
if (Utils.isUndefined(digits)) {
digits = 0;
}
return number.toFixed(digits);
});
Handlebars.registerHelper('toPrecision', function(number, precision) {
if (Utils.isUndefined(precision)) {... | Handlebars.registerHelper 'toFixed', (number, digits) ->
digits = 0 if Utils.isUndefined(digits)
number.toFixed digits
Handlebars.registerHelper 'toPrecision', (number, precision) ->
precision = 1 if Utils.isUndefined(precision)
number.toPrecision precision
Handlebars.registerHelper 'toExponential', (... | JavaScript | CoffeeScript | elving/swag | src/swag.numbers.coffee | MIT | b691217045ff6f67119d54d3a9d346dca70d062a | 675 | https://github.com/elving/swag/blob/b691217045ff6f67119d54d3a9d346dca70d062a/src/swag.numbers.coffee | 1 | 21 |
elving/swag:src/swag.numbers.coffee:1:completion | completion | Handlebars.registerHelper 'toFixed', (number, digits) ->
digits = 0 if Utils.isUndefined(digits)
number.toFixed digits
Handlebars.registerHelper 'toPrecision', (number, precision) ->
precision = 1 if Utils.isUndefined(precision)
number.toPrecision precision
Handlebars.registerHelper 'toExponential', (... | number.toExponential fractions
Handlebars.registerHelper 'toInt', (number) ->
parseInt number, 10
Handlebars.registerHelper 'toFloat', (number) ->
parseFloat number
Handlebars.registerHelper 'digitGrouping', (number, separator) ->
separator = ',' if Utils.isUndefined(separator)
number.toString().repl... | CoffeeScript | CoffeeScript | elving/swag | src/swag.numbers.coffee | MIT | b691217045ff6f67119d54d3a9d346dca70d062a | 675 | https://github.com/elving/swag/blob/b691217045ff6f67119d54d3a9d346dca70d062a/src/swag.numbers.coffee | 1 | 21 |
elving/swag:src/swag.numbers.coffee:1:raw_corpus | raw_corpus | Handlebars.registerHelper 'toFixed', (number, digits) ->
digits = 0 if Utils.isUndefined(digits)
number.toFixed digits
Handlebars.registerHelper 'toPrecision', (number, precision) ->
precision = 1 if Utils.isUndefined(precision)
number.toPrecision precision
Handlebars.registerHelper 'toExponential', (... | CoffeeScript | elving/swag | src/swag.numbers.coffee | MIT | c644bfc29f1b2d21bed02a7c19c5c715439c5984 | 675 | https://github.com/elving/swag/blob/c644bfc29f1b2d21bed02a7c19c5c715439c5984/src/swag.numbers.coffee | 1 | 20 | ||
elving/swag:src/swag.numbers.coffee:1:coffee_to_js | coffee_to_js | Convert this CoffeeScript to JavaScript.
```coffeescript
Handlebars.registerHelper 'toFixed', (number, digits) ->
digits = 0 if Utils.isUndefined(digits)
number.toFixed digits
Handlebars.registerHelper 'toPrecision', (number, precision) ->
precision = 1 if Utils.isUndefined(precision)
number.toPrecisio... | Handlebars.registerHelper('toFixed', function(number, digits) {
if (Utils.isUndefined(digits)) {
digits = 0;
}
return number.toFixed(digits);
});
Handlebars.registerHelper('toPrecision', function(number, precision) {
if (Utils.isUndefined(precision)) {
precision = 1;
}
return number.toPrecision(pre... | CoffeeScript | JavaScript | elving/swag | src/swag.numbers.coffee | MIT | c644bfc29f1b2d21bed02a7c19c5c715439c5984 | 675 | https://github.com/elving/swag/blob/c644bfc29f1b2d21bed02a7c19c5c715439c5984/src/swag.numbers.coffee | 1 | 20 |
elving/swag:src/swag.numbers.coffee:1:js_to_coffee | js_to_coffee | Convert this JavaScript to CoffeeScript.
```javascript
Handlebars.registerHelper('toFixed', function(number, digits) {
if (Utils.isUndefined(digits)) {
digits = 0;
}
return number.toFixed(digits);
});
Handlebars.registerHelper('toPrecision', function(number, precision) {
if (Utils.isUndefined(precision)) {... | Handlebars.registerHelper 'toFixed', (number, digits) ->
digits = 0 if Utils.isUndefined(digits)
number.toFixed digits
Handlebars.registerHelper 'toPrecision', (number, precision) ->
precision = 1 if Utils.isUndefined(precision)
number.toPrecision precision
Handlebars.registerHelper 'toExponential', (... | JavaScript | CoffeeScript | elving/swag | src/swag.numbers.coffee | MIT | c644bfc29f1b2d21bed02a7c19c5c715439c5984 | 675 | https://github.com/elving/swag/blob/c644bfc29f1b2d21bed02a7c19c5c715439c5984/src/swag.numbers.coffee | 1 | 20 |
elving/swag:src/swag.numbers.coffee:1:completion | completion | Handlebars.registerHelper 'toFixed', (number, digits) ->
digits = 0 if Utils.isUndefined(digits)
number.toFixed digits
Handlebars.registerHelper 'toPrecision', (number, precision) ->
precision = 1 if Utils.isUndefined(precision)
number.toPrecision precision
Handlebars.registerHelper 'toExponential', (... | number.toExponential fractions
Handlebars.registerHelper 'toInt', (number) ->
parseInt number, 10
Handlebars.registerHelper 'toFloat', (number) ->
parseFloat number
Handlebars.registerHelper 'addCommas', (number) ->
number.toString().replace /(\d)(?=(\d\d\d)+(?!\d))/g, "$1," | CoffeeScript | CoffeeScript | elving/swag | src/swag.numbers.coffee | MIT | c644bfc29f1b2d21bed02a7c19c5c715439c5984 | 675 | https://github.com/elving/swag/blob/c644bfc29f1b2d21bed02a7c19c5c715439c5984/src/swag.numbers.coffee | 1 | 20 |
elving/swag:src/swag.numbers.coffee:1:raw_corpus | raw_corpus | Handlebars.registerHelper 'toFixed', (number, digits) ->
number.toFixed if Utils.isUndefined(digits) then digits
Handlebars.registerHelper 'toPrecision', (number, precision) ->
number.toPrecision if Utils.isUndefined(precision) then precision
Handlebars.registerHelper 'toExponential', (number, fractions) ->
... | CoffeeScript | elving/swag | src/swag.numbers.coffee | MIT | 00b3213de4811c0f27cb46c89b8ddae6b2e15702 | 675 | https://github.com/elving/swag/blob/00b3213de4811c0f27cb46c89b8ddae6b2e15702/src/swag.numbers.coffee | 1 | 17 | ||
elving/swag:src/swag.numbers.coffee:1:coffee_to_js | coffee_to_js | Convert this CoffeeScript to JavaScript.
```coffeescript
Handlebars.registerHelper 'toFixed', (number, digits) ->
number.toFixed if Utils.isUndefined(digits) then digits
Handlebars.registerHelper 'toPrecision', (number, precision) ->
number.toPrecision if Utils.isUndefined(precision) then precision
Handlebars... | Handlebars.registerHelper('toFixed', function(number, digits) {
return number.toFixed(Utils.isUndefined(digits) ? digits : void 0);
});
Handlebars.registerHelper('toPrecision', function(number, precision) {
return number.toPrecision(Utils.isUndefined(precision) ? precision : void 0);
});
Handlebars.registerHelper... | CoffeeScript | JavaScript | elving/swag | src/swag.numbers.coffee | MIT | 00b3213de4811c0f27cb46c89b8ddae6b2e15702 | 675 | https://github.com/elving/swag/blob/00b3213de4811c0f27cb46c89b8ddae6b2e15702/src/swag.numbers.coffee | 1 | 17 |
elving/swag:src/swag.numbers.coffee:1:js_to_coffee | js_to_coffee | Convert this JavaScript to CoffeeScript.
```javascript
Handlebars.registerHelper('toFixed', function(number, digits) {
return number.toFixed(Utils.isUndefined(digits) ? digits : void 0);
});
Handlebars.registerHelper('toPrecision', function(number, precision) {
return number.toPrecision(Utils.isUndefined(precision... | Handlebars.registerHelper 'toFixed', (number, digits) ->
number.toFixed if Utils.isUndefined(digits) then digits
Handlebars.registerHelper 'toPrecision', (number, precision) ->
number.toPrecision if Utils.isUndefined(precision) then precision
Handlebars.registerHelper 'toExponential', (number, fractions) ->
... | JavaScript | CoffeeScript | elving/swag | src/swag.numbers.coffee | MIT | 00b3213de4811c0f27cb46c89b8ddae6b2e15702 | 675 | https://github.com/elving/swag/blob/00b3213de4811c0f27cb46c89b8ddae6b2e15702/src/swag.numbers.coffee | 1 | 17 |
elving/swag:src/swag.numbers.coffee:1:completion | completion | Handlebars.registerHelper 'toFixed', (number, digits) ->
number.toFixed if Utils.isUndefined(digits) then digits
Handlebars.registerHelper 'toPrecision', (number, precision) ->
number.toPrecision if Utils.isUndefined(precision) then precision
Handlebars.registerHelper 'toExponential', (number, fractions) ->
... | Handlebars.registerHelper 'toInt', (number) ->
parseInt number, 10
Handlebars.registerHelper 'toFloat', (number) ->
parseFloat number
Handlebars.registerHelper 'addCommas', (number) ->
number.toString().replace /(\d)(?=(\d\d\d)+(?!\d))/g, "$1," | CoffeeScript | CoffeeScript | elving/swag | src/swag.numbers.coffee | MIT | 00b3213de4811c0f27cb46c89b8ddae6b2e15702 | 675 | https://github.com/elving/swag/blob/00b3213de4811c0f27cb46c89b8ddae6b2e15702/src/swag.numbers.coffee | 1 | 17 |
cdglabs/apparatus:src/Storage/Storage.coffee:1:raw_corpus | raw_corpus | module.exports = Storage = {}
Storage.Serializer = require "./Serializer"
# `text` should be a string of text that should be written to the file, `name`
# `the file name (e.g. `"hello.json"`), and `type` the content type (e.g.
# ``"application/json"`).
Storage.saveFile = (text, name, type) ->
dummyLink = document.... | CoffeeScript | cdglabs/apparatus | src/Storage/Storage.coffee | MIT | 107e0c2db5a0adf0f1c3b49f16f7625cff4e523b | 1,052 | https://github.com/cdglabs/apparatus/blob/107e0c2db5a0adf0f1c3b49f16f7625cff4e523b/src/Storage/Storage.coffee | 1 | 30 | ||
cdglabs/apparatus:src/Storage/Storage.coffee:1:coffee_to_js | coffee_to_js | Convert this CoffeeScript to JavaScript.
```coffeescript
module.exports = Storage = {}
Storage.Serializer = require "./Serializer"
# `text` should be a string of text that should be written to the file, `name`
# `the file name (e.g. `"hello.json"`), and `type` the content type (e.g.
# ``"application/json"`).
Storage... | var Storage;
module.exports = Storage = {};
Storage.Serializer = require("./Serializer");
// `text` should be a string of text that should be written to the file, `name`
// `the file name (e.g. `"hello.json"`), and `type` the content type (e.g.
// ``"application/json"`).
Storage.saveFile = function(text, name, type)... | CoffeeScript | JavaScript | cdglabs/apparatus | src/Storage/Storage.coffee | MIT | 107e0c2db5a0adf0f1c3b49f16f7625cff4e523b | 1,052 | https://github.com/cdglabs/apparatus/blob/107e0c2db5a0adf0f1c3b49f16f7625cff4e523b/src/Storage/Storage.coffee | 1 | 30 |
cdglabs/apparatus:src/Storage/Storage.coffee:1:js_to_coffee | js_to_coffee | Convert this JavaScript to CoffeeScript.
```javascript
var Storage;
module.exports = Storage = {};
Storage.Serializer = require("./Serializer");
// `text` should be a string of text that should be written to the file, `name`
// `the file name (e.g. `"hello.json"`), and `type` the content type (e.g.
// ``"application... | module.exports = Storage = {}
Storage.Serializer = require "./Serializer"
# `text` should be a string of text that should be written to the file, `name`
# `the file name (e.g. `"hello.json"`), and `type` the content type (e.g.
# ``"application/json"`).
Storage.saveFile = (text, name, type) ->
dummyLink = document.... | JavaScript | CoffeeScript | cdglabs/apparatus | src/Storage/Storage.coffee | MIT | 107e0c2db5a0adf0f1c3b49f16f7625cff4e523b | 1,052 | https://github.com/cdglabs/apparatus/blob/107e0c2db5a0adf0f1c3b49f16f7625cff4e523b/src/Storage/Storage.coffee | 1 | 30 |
cdglabs/apparatus:src/Storage/Storage.coffee:1:completion | completion | module.exports = Storage = {}
Storage.Serializer = require "./Serializer"
# `text` should be a string of text that should be written to the file, `name`
# `the file name (e.g. `"hello.json"`), and `type` the content type (e.g.
# ``"application/json"`).
Storage.saveFile = (text, name, type) ->
dummyLink = document.... | # This will pop open the file open dialog box. If a file is loaded
# successfully, callback will be called with a string that is the text of the
# file.
Storage.loadFile = (callback) ->
dummyInput = document.createElement("input")
dummyInput.setAttribute("type", "file")
dummyInput.addEventListener "change", (chan... | CoffeeScript | CoffeeScript | cdglabs/apparatus | src/Storage/Storage.coffee | MIT | 107e0c2db5a0adf0f1c3b49f16f7625cff4e523b | 1,052 | https://github.com/cdglabs/apparatus/blob/107e0c2db5a0adf0f1c3b49f16f7625cff4e523b/src/Storage/Storage.coffee | 1 | 30 |
cdglabs/apparatus:src/Storage/Storage.coffee:1:raw_corpus | raw_corpus | module.exports = Storage = {}
Storage.Serializer = require "./Serializer"
Storage.saveFile = (text, name, type) ->
dummyLink = document.createElement("a")
file = new Blob([text], {type})
dummyLink.href = URL.createObjectURL(file)
dummyLink.download = name
dummyLink.click()
Storage.loadFile = (callback) ->... | CoffeeScript | cdglabs/apparatus | src/Storage/Storage.coffee | MIT | 0bdf63f021ef20f44ff8e4a1b8f5831afddc06a2 | 1,052 | https://github.com/cdglabs/apparatus/blob/0bdf63f021ef20f44ff8e4a1b8f5831afddc06a2/src/Storage/Storage.coffee | 1 | 24 | ||
cdglabs/apparatus:src/Storage/Storage.coffee:1:coffee_to_js | coffee_to_js | Convert this CoffeeScript to JavaScript.
```coffeescript
module.exports = Storage = {}
Storage.Serializer = require "./Serializer"
Storage.saveFile = (text, name, type) ->
dummyLink = document.createElement("a")
file = new Blob([text], {type})
dummyLink.href = URL.createObjectURL(file)
dummyLink.download = n... | var Storage;
module.exports = Storage = {};
Storage.Serializer = require("./Serializer");
Storage.saveFile = function(text, name, type) {
var dummyLink, file;
dummyLink = document.createElement("a");
file = new Blob([text], {type});
dummyLink.href = URL.createObjectURL(file);
dummyLink.download = name;
r... | CoffeeScript | JavaScript | cdglabs/apparatus | src/Storage/Storage.coffee | MIT | 0bdf63f021ef20f44ff8e4a1b8f5831afddc06a2 | 1,052 | https://github.com/cdglabs/apparatus/blob/0bdf63f021ef20f44ff8e4a1b8f5831afddc06a2/src/Storage/Storage.coffee | 1 | 24 |
cdglabs/apparatus:src/Storage/Storage.coffee:1:js_to_coffee | js_to_coffee | Convert this JavaScript to CoffeeScript.
```javascript
var Storage;
module.exports = Storage = {};
Storage.Serializer = require("./Serializer");
Storage.saveFile = function(text, name, type) {
var dummyLink, file;
dummyLink = document.createElement("a");
file = new Blob([text], {type});
dummyLink.href = URL.... | module.exports = Storage = {}
Storage.Serializer = require "./Serializer"
Storage.saveFile = (text, name, type) ->
dummyLink = document.createElement("a")
file = new Blob([text], {type})
dummyLink.href = URL.createObjectURL(file)
dummyLink.download = name
dummyLink.click()
Storage.loadFile = (callback) ->... | JavaScript | CoffeeScript | cdglabs/apparatus | src/Storage/Storage.coffee | MIT | 0bdf63f021ef20f44ff8e4a1b8f5831afddc06a2 | 1,052 | https://github.com/cdglabs/apparatus/blob/0bdf63f021ef20f44ff8e4a1b8f5831afddc06a2/src/Storage/Storage.coffee | 1 | 24 |
cdglabs/apparatus:src/Storage/Storage.coffee:1:completion | completion | module.exports = Storage = {}
Storage.Serializer = require "./Serializer"
Storage.saveFile = (text, name, type) ->
dummyLink = document.createElement("a")
file = new Blob([text], {type})
dummyLink.href = URL.createObjectURL(file)
dummyLink.download = name
dummyLink.click() | Storage.loadFile = (callback) ->
dummyInput = document.createElement("input")
dummyInput.setAttribute("type", "file")
dummyInput.addEventListener "change", (changeEvent) ->
files = dummyInput.files
file = files[0]
return unless file
reader = new FileReader()
reader.onload = ->
callback(r... | CoffeeScript | CoffeeScript | cdglabs/apparatus | src/Storage/Storage.coffee | MIT | 0bdf63f021ef20f44ff8e4a1b8f5831afddc06a2 | 1,052 | https://github.com/cdglabs/apparatus/blob/0bdf63f021ef20f44ff8e4a1b8f5831afddc06a2/src/Storage/Storage.coffee | 1 | 24 |
cdglabs/apparatus:src/Storage/Storage.coffee:1:raw_corpus | raw_corpus | module.exports = Storage = {}
Storage.Serializer = require "./Serializer"
Storage.saveFile = (text, name, type) ->
dummyLink = document.createElement("a")
file = new Blob([text], {type})
dummyLink.href = URL.createObjectURL(file)
dummyLink.download = name
dummyLink.click() | CoffeeScript | cdglabs/apparatus | src/Storage/Storage.coffee | MIT | cf852f8f3204e99b0b82086a5e12c68ca40a225e | 1,052 | https://github.com/cdglabs/apparatus/blob/cf852f8f3204e99b0b82086a5e12c68ca40a225e/src/Storage/Storage.coffee | 1 | 11 | ||
cdglabs/apparatus:src/Storage/Storage.coffee:1:coffee_to_js | coffee_to_js | Convert this CoffeeScript to JavaScript.
```coffeescript
module.exports = Storage = {}
Storage.Serializer = require "./Serializer"
Storage.saveFile = (text, name, type) ->
dummyLink = document.createElement("a")
file = new Blob([text], {type})
dummyLink.href = URL.createObjectURL(file)
dummyLink.download = n... | var Storage;
module.exports = Storage = {};
Storage.Serializer = require("./Serializer");
Storage.saveFile = function(text, name, type) {
var dummyLink, file;
dummyLink = document.createElement("a");
file = new Blob([text], {type});
dummyLink.href = URL.createObjectURL(file);
dummyLink.download = name;
r... | CoffeeScript | JavaScript | cdglabs/apparatus | src/Storage/Storage.coffee | MIT | cf852f8f3204e99b0b82086a5e12c68ca40a225e | 1,052 | https://github.com/cdglabs/apparatus/blob/cf852f8f3204e99b0b82086a5e12c68ca40a225e/src/Storage/Storage.coffee | 1 | 11 |
cdglabs/apparatus:src/Storage/Storage.coffee:1:js_to_coffee | js_to_coffee | Convert this JavaScript to CoffeeScript.
```javascript
var Storage;
module.exports = Storage = {};
Storage.Serializer = require("./Serializer");
Storage.saveFile = function(text, name, type) {
var dummyLink, file;
dummyLink = document.createElement("a");
file = new Blob([text], {type});
dummyLink.href = URL.... | module.exports = Storage = {}
Storage.Serializer = require "./Serializer"
Storage.saveFile = (text, name, type) ->
dummyLink = document.createElement("a")
file = new Blob([text], {type})
dummyLink.href = URL.createObjectURL(file)
dummyLink.download = name
dummyLink.click() | JavaScript | CoffeeScript | cdglabs/apparatus | src/Storage/Storage.coffee | MIT | cf852f8f3204e99b0b82086a5e12c68ca40a225e | 1,052 | https://github.com/cdglabs/apparatus/blob/cf852f8f3204e99b0b82086a5e12c68ca40a225e/src/Storage/Storage.coffee | 1 | 11 |
cdglabs/apparatus:src/Storage/Storage.coffee:1:completion | completion | module.exports = Storage = {}
Storage.Serializer = require "./Serializer" | Storage.saveFile = (text, name, type) ->
dummyLink = document.createElement("a")
file = new Blob([text], {type})
dummyLink.href = URL.createObjectURL(file)
dummyLink.download = name
dummyLink.click() | CoffeeScript | CoffeeScript | cdglabs/apparatus | src/Storage/Storage.coffee | MIT | cf852f8f3204e99b0b82086a5e12c68ca40a225e | 1,052 | https://github.com/cdglabs/apparatus/blob/cf852f8f3204e99b0b82086a5e12c68ca40a225e/src/Storage/Storage.coffee | 1 | 11 |
kahmali/meteor-restivus:lib/endpoint.coffee:1:raw_corpus | raw_corpus | @Endpoint = (@api, @path, @options, @methods) ->
# Check if options were provided
if not @methods
@methods = @options
@options = null | CoffeeScript | kahmali/meteor-restivus | lib/endpoint.coffee | MIT | 07dd05317c512dc70cbca5c7080e4c9eadff986a | 541 | https://github.com/kahmali/meteor-restivus/blob/07dd05317c512dc70cbca5c7080e4c9eadff986a/lib/endpoint.coffee | 1 | 5 | ||
kahmali/meteor-restivus:lib/endpoint.coffee:1:coffee_to_js | coffee_to_js | Convert this CoffeeScript to JavaScript.
```coffeescript
@Endpoint = (@api, @path, @options, @methods) ->
# Check if options were provided
if not @methods
@methods = @options
@options = null
``` | this.Endpoint = function(api, path, options, methods) {
this.api = api;
this.path = path;
this.options = options;
this.methods = methods;
// Check if options were provided
if (!this.methods) {
this.methods = this.options;
return this.options = null;
}
}; | CoffeeScript | JavaScript | kahmali/meteor-restivus | lib/endpoint.coffee | MIT | 07dd05317c512dc70cbca5c7080e4c9eadff986a | 541 | https://github.com/kahmali/meteor-restivus/blob/07dd05317c512dc70cbca5c7080e4c9eadff986a/lib/endpoint.coffee | 1 | 5 |
kahmali/meteor-restivus:lib/endpoint.coffee:1:js_to_coffee | js_to_coffee | Convert this JavaScript to CoffeeScript.
```javascript
this.Endpoint = function(api, path, options, methods) {
this.api = api;
this.path = path;
this.options = options;
this.methods = methods;
// Check if options were provided
if (!this.methods) {
this.methods = this.options;
return this.options = n... | @Endpoint = (@api, @path, @options, @methods) ->
# Check if options were provided
if not @methods
@methods = @options
@options = null | JavaScript | CoffeeScript | kahmali/meteor-restivus | lib/endpoint.coffee | MIT | 07dd05317c512dc70cbca5c7080e4c9eadff986a | 541 | https://github.com/kahmali/meteor-restivus/blob/07dd05317c512dc70cbca5c7080e4c9eadff986a/lib/endpoint.coffee | 1 | 5 |
kahmali/meteor-restivus:lib/endpoint.coffee:1:completion | completion | @Endpoint = (@api, @path, @options, @methods) ->
# Check if options were provided | if not @methods
@methods = @options
@options = null | CoffeeScript | CoffeeScript | kahmali/meteor-restivus | lib/endpoint.coffee | MIT | 07dd05317c512dc70cbca5c7080e4c9eadff986a | 541 | https://github.com/kahmali/meteor-restivus/blob/07dd05317c512dc70cbca5c7080e4c9eadff986a/lib/endpoint.coffee | 1 | 5 |
kahmali/meteor-restivus:lib/endpoint.coffee:2:raw_corpus | raw_corpus | @Endpoint.prototype.addToApi = ->
self = this
# Throw an error if this endpoint has already been added
# TODO: Check for collisions with paths that follow same pattern with different parameter names
if _.contains @api.config.paths, @path
throw new Error "Cannot add endpoint at an existing path: #{@path}"
... | CoffeeScript | kahmali/meteor-restivus | lib/endpoint.coffee | MIT | 07dd05317c512dc70cbca5c7080e4c9eadff986a | 541 | https://github.com/kahmali/meteor-restivus/blob/07dd05317c512dc70cbca5c7080e4c9eadff986a/lib/endpoint.coffee | 7 | 56 | ||
kahmali/meteor-restivus:lib/endpoint.coffee:2:coffee_to_js | coffee_to_js | Convert this CoffeeScript to JavaScript.
```coffeescript
@Endpoint.prototype.addToApi = ->
self = this
# Throw an error if this endpoint has already been added
# TODO: Check for collisions with paths that follow same pattern with different parameter names
if _.contains @api.config.paths, @path
throw new E... | this.Endpoint.prototype.addToApi = function() {
var fullPath, self;
self = this;
// Throw an error if this endpoint has already been added
// TODO: Check for collisions with paths that follow same pattern with different parameter names
if (_.contains(this.api.config.paths, this.path)) {
throw new Error(`C... | CoffeeScript | JavaScript | kahmali/meteor-restivus | lib/endpoint.coffee | MIT | 07dd05317c512dc70cbca5c7080e4c9eadff986a | 541 | https://github.com/kahmali/meteor-restivus/blob/07dd05317c512dc70cbca5c7080e4c9eadff986a/lib/endpoint.coffee | 7 | 56 |
kahmali/meteor-restivus:lib/endpoint.coffee:2:js_to_coffee | js_to_coffee | Convert this JavaScript to CoffeeScript.
```javascript
this.Endpoint.prototype.addToApi = function() {
var fullPath, self;
self = this;
// Throw an error if this endpoint has already been added
// TODO: Check for collisions with paths that follow same pattern with different parameter names
if (_.contains(this... | @Endpoint.prototype.addToApi = ->
self = this
# Throw an error if this endpoint has already been added
# TODO: Check for collisions with paths that follow same pattern with different parameter names
if _.contains @api.config.paths, @path
throw new Error "Cannot add endpoint at an existing path: #{@path}"
... | JavaScript | CoffeeScript | kahmali/meteor-restivus | lib/endpoint.coffee | MIT | 07dd05317c512dc70cbca5c7080e4c9eadff986a | 541 | https://github.com/kahmali/meteor-restivus/blob/07dd05317c512dc70cbca5c7080e4c9eadff986a/lib/endpoint.coffee | 7 | 56 |
kahmali/meteor-restivus:lib/endpoint.coffee:2:completion | completion | @Endpoint.prototype.addToApi = ->
self = this
# Throw an error if this endpoint has already been added
# TODO: Check for collisions with paths that follow same pattern with different parameter names
if _.contains @api.config.paths, @path
throw new Error "Cannot add endpoint at an existing path: #{@path}"
... | # @params = @params.query = @request.body = null
# Respond to the requested HTTP method if an endpoint has been provided for it
if method is 'GET' and self.methods.get
responseData = callEndpoint.call(this, self, self.methods.get)
else if method is 'POST' and self.methods.post
re... | CoffeeScript | CoffeeScript | kahmali/meteor-restivus | lib/endpoint.coffee | MIT | 07dd05317c512dc70cbca5c7080e4c9eadff986a | 541 | https://github.com/kahmali/meteor-restivus/blob/07dd05317c512dc70cbca5c7080e4c9eadff986a/lib/endpoint.coffee | 7 | 56 |
kahmali/meteor-restivus:lib/endpoint.coffee:3:raw_corpus | raw_corpus | @api.config.paths.push @path
###
Authenticate an endpoint if required, and return the result of calling it
@context: IronRouter.Router.route()
### | CoffeeScript | kahmali/meteor-restivus | lib/endpoint.coffee | MIT | 07dd05317c512dc70cbca5c7080e4c9eadff986a | 541 | https://github.com/kahmali/meteor-restivus/blob/07dd05317c512dc70cbca5c7080e4c9eadff986a/lib/endpoint.coffee | 57 | 64 | ||
kahmali/meteor-restivus:lib/endpoint.coffee:3:coffee_to_js | coffee_to_js | Convert this CoffeeScript to JavaScript.
```coffeescript
@api.config.paths.push @path
###
Authenticate an endpoint if required, and return the result of calling it
@context: IronRouter.Router.route()
###
``` | this.api.config.paths.push(this.path);
/*
Authenticate an endpoint if required, and return the result of calling it
@context: IronRouter.Router.route()
*/ | CoffeeScript | JavaScript | kahmali/meteor-restivus | lib/endpoint.coffee | MIT | 07dd05317c512dc70cbca5c7080e4c9eadff986a | 541 | https://github.com/kahmali/meteor-restivus/blob/07dd05317c512dc70cbca5c7080e4c9eadff986a/lib/endpoint.coffee | 57 | 64 |
kahmali/meteor-restivus:lib/endpoint.coffee:3:js_to_coffee | js_to_coffee | Convert this JavaScript to CoffeeScript.
```javascript
this.api.config.paths.push(this.path);
/*
Authenticate an endpoint if required, and return the result of calling it
@context: IronRouter.Router.route()
*/
``` | @api.config.paths.push @path
###
Authenticate an endpoint if required, and return the result of calling it
@context: IronRouter.Router.route()
### | JavaScript | CoffeeScript | kahmali/meteor-restivus | lib/endpoint.coffee | MIT | 07dd05317c512dc70cbca5c7080e4c9eadff986a | 541 | https://github.com/kahmali/meteor-restivus/blob/07dd05317c512dc70cbca5c7080e4c9eadff986a/lib/endpoint.coffee | 57 | 64 |
kahmali/meteor-restivus:lib/endpoint.coffee:3:completion | completion | @api.config.paths.push @path
### | Authenticate an endpoint if required, and return the result of calling it
@context: IronRouter.Router.route()
### | CoffeeScript | CoffeeScript | kahmali/meteor-restivus | lib/endpoint.coffee | MIT | 07dd05317c512dc70cbca5c7080e4c9eadff986a | 541 | https://github.com/kahmali/meteor-restivus/blob/07dd05317c512dc70cbca5c7080e4c9eadff986a/lib/endpoint.coffee | 57 | 64 |
kahmali/meteor-restivus:lib/endpoint.coffee:4:raw_corpus | raw_corpus | callEndpoint = (endpoint, method) ->
method = resolveMethod method
authenticateIfRequired.call this, endpoint, method
method.action.call this
###
Convert the given endpoint method into our expected object if it is a bare function
### | CoffeeScript | kahmali/meteor-restivus | lib/endpoint.coffee | MIT | 07dd05317c512dc70cbca5c7080e4c9eadff986a | 541 | https://github.com/kahmali/meteor-restivus/blob/07dd05317c512dc70cbca5c7080e4c9eadff986a/lib/endpoint.coffee | 65 | 72 | ||
kahmali/meteor-restivus:lib/endpoint.coffee:4:coffee_to_js | coffee_to_js | Convert this CoffeeScript to JavaScript.
```coffeescript
callEndpoint = (endpoint, method) ->
method = resolveMethod method
authenticateIfRequired.call this, endpoint, method
method.action.call this
###
Convert the given endpoint method into our expected object if it is a bare function
###
``` | var callEndpoint;
callEndpoint = function(endpoint, method) {
method = resolveMethod(method);
authenticateIfRequired.call(this, endpoint, method);
return method.action.call(this);
};
/*
Convert the given endpoint method into our expected object if it is a bare function
*/ | CoffeeScript | JavaScript | kahmali/meteor-restivus | lib/endpoint.coffee | MIT | 07dd05317c512dc70cbca5c7080e4c9eadff986a | 541 | https://github.com/kahmali/meteor-restivus/blob/07dd05317c512dc70cbca5c7080e4c9eadff986a/lib/endpoint.coffee | 65 | 72 |
kahmali/meteor-restivus:lib/endpoint.coffee:4:js_to_coffee | js_to_coffee | Convert this JavaScript to CoffeeScript.
```javascript
var callEndpoint;
callEndpoint = function(endpoint, method) {
method = resolveMethod(method);
authenticateIfRequired.call(this, endpoint, method);
return method.action.call(this);
};
/*
Convert the given endpoint method into our expected object if it is a... | callEndpoint = (endpoint, method) ->
method = resolveMethod method
authenticateIfRequired.call this, endpoint, method
method.action.call this
###
Convert the given endpoint method into our expected object if it is a bare function
### | JavaScript | CoffeeScript | kahmali/meteor-restivus | lib/endpoint.coffee | MIT | 07dd05317c512dc70cbca5c7080e4c9eadff986a | 541 | https://github.com/kahmali/meteor-restivus/blob/07dd05317c512dc70cbca5c7080e4c9eadff986a/lib/endpoint.coffee | 65 | 72 |
kahmali/meteor-restivus:lib/endpoint.coffee:4:completion | completion | callEndpoint = (endpoint, method) ->
method = resolveMethod method
authenticateIfRequired.call this, endpoint, method
method.action.call this | ###
Convert the given endpoint method into our expected object if it is a bare function
### | CoffeeScript | CoffeeScript | kahmali/meteor-restivus | lib/endpoint.coffee | MIT | 07dd05317c512dc70cbca5c7080e4c9eadff986a | 541 | https://github.com/kahmali/meteor-restivus/blob/07dd05317c512dc70cbca5c7080e4c9eadff986a/lib/endpoint.coffee | 65 | 72 |
kahmali/meteor-restivus:lib/endpoint.coffee:5:raw_corpus | raw_corpus | resolveMethod = (method) ->
if _.isFunction(method)
method = {action: method}
method
###
Authenticate the given method if required
Once it's globally configured in the API, authentication can be required on an entire endpoint or individual
methods. If required on an entire endpoint, that serves as the d... | CoffeeScript | kahmali/meteor-restivus | lib/endpoint.coffee | MIT | 07dd05317c512dc70cbca5c7080e4c9eadff986a | 541 | https://github.com/kahmali/meteor-restivus/blob/07dd05317c512dc70cbca5c7080e4c9eadff986a/lib/endpoint.coffee | 73 | 86 | ||
kahmali/meteor-restivus:lib/endpoint.coffee:5:coffee_to_js | coffee_to_js | Convert this CoffeeScript to JavaScript.
```coffeescript
resolveMethod = (method) ->
if _.isFunction(method)
method = {action: method}
method
###
Authenticate the given method if required
Once it's globally configured in the API, authentication can be required on an entire endpoint or individual
methods... | var resolveMethod;
resolveMethod = function(method) {
if (_.isFunction(method)) {
method = {
action: method
};
}
return method;
};
/*
Authenticate the given method if required
Once it's globally configured in the API, authentication can be required on an entire endpoint or individual
method... | CoffeeScript | JavaScript | kahmali/meteor-restivus | lib/endpoint.coffee | MIT | 07dd05317c512dc70cbca5c7080e4c9eadff986a | 541 | https://github.com/kahmali/meteor-restivus/blob/07dd05317c512dc70cbca5c7080e4c9eadff986a/lib/endpoint.coffee | 73 | 86 |
kahmali/meteor-restivus:lib/endpoint.coffee:5:js_to_coffee | js_to_coffee | Convert this JavaScript to CoffeeScript.
```javascript
var resolveMethod;
resolveMethod = function(method) {
if (_.isFunction(method)) {
method = {
action: method
};
}
return method;
};
/*
Authenticate the given method if required
Once it's globally configured in the API, authentication can b... | resolveMethod = (method) ->
if _.isFunction(method)
method = {action: method}
method
###
Authenticate the given method if required
Once it's globally configured in the API, authentication can be required on an entire endpoint or individual
methods. If required on an entire endpoint, that serves as the d... | JavaScript | CoffeeScript | kahmali/meteor-restivus | lib/endpoint.coffee | MIT | 07dd05317c512dc70cbca5c7080e4c9eadff986a | 541 | https://github.com/kahmali/meteor-restivus/blob/07dd05317c512dc70cbca5c7080e4c9eadff986a/lib/endpoint.coffee | 73 | 86 |
kahmali/meteor-restivus:lib/endpoint.coffee:5:completion | completion | resolveMethod = (method) ->
if _.isFunction(method)
method = {action: method}
method
###
Authenticate the given method if required | Once it's globally configured in the API, authentication can be required on an entire endpoint or individual
methods. If required on an entire endpoint, that serves as the default. If required in any individual methods, that
will override the default.
@context: IronRouter.Router.route()
### | CoffeeScript | CoffeeScript | kahmali/meteor-restivus | lib/endpoint.coffee | MIT | 07dd05317c512dc70cbca5c7080e4c9eadff986a | 541 | https://github.com/kahmali/meteor-restivus/blob/07dd05317c512dc70cbca5c7080e4c9eadff986a/lib/endpoint.coffee | 73 | 86 |
kahmali/meteor-restivus:lib/endpoint.coffee:6:raw_corpus | raw_corpus | authenticateIfRequired = (endpoint, method) ->
# Authenticate the request if necessary
if endpoint.api.config.useAuth
if method.authRequired is undefined
authenticate.call(this) if endpoint.options?.authRequired
else if method.authRequired
authenticate.call this
###
Verify the request is bei... | CoffeeScript | kahmali/meteor-restivus | lib/endpoint.coffee | MIT | 07dd05317c512dc70cbca5c7080e4c9eadff986a | 541 | https://github.com/kahmali/meteor-restivus/blob/07dd05317c512dc70cbca5c7080e4c9eadff986a/lib/endpoint.coffee | 87 | 100 | ||
kahmali/meteor-restivus:lib/endpoint.coffee:6:coffee_to_js | coffee_to_js | Convert this CoffeeScript to JavaScript.
```coffeescript
authenticateIfRequired = (endpoint, method) ->
# Authenticate the request if necessary
if endpoint.api.config.useAuth
if method.authRequired is undefined
authenticate.call(this) if endpoint.options?.authRequired
else if method.authRequired
... | var authenticateIfRequired;
authenticateIfRequired = function(endpoint, method) {
var ref;
// Authenticate the request if necessary
if (endpoint.api.config.useAuth) {
if (method.authRequired === void 0) {
if ((ref = endpoint.options) != null ? ref.authRequired : void 0) {
return authenticate.ca... | CoffeeScript | JavaScript | kahmali/meteor-restivus | lib/endpoint.coffee | MIT | 07dd05317c512dc70cbca5c7080e4c9eadff986a | 541 | https://github.com/kahmali/meteor-restivus/blob/07dd05317c512dc70cbca5c7080e4c9eadff986a/lib/endpoint.coffee | 87 | 100 |
kahmali/meteor-restivus:lib/endpoint.coffee:6:js_to_coffee | js_to_coffee | Convert this JavaScript to CoffeeScript.
```javascript
var authenticateIfRequired;
authenticateIfRequired = function(endpoint, method) {
var ref;
// Authenticate the request if necessary
if (endpoint.api.config.useAuth) {
if (method.authRequired === void 0) {
if ((ref = endpoint.options) != null ? ref.... | authenticateIfRequired = (endpoint, method) ->
# Authenticate the request if necessary
if endpoint.api.config.useAuth
if method.authRequired is undefined
authenticate.call(this) if endpoint.options?.authRequired
else if method.authRequired
authenticate.call this
###
Verify the request is bei... | JavaScript | CoffeeScript | kahmali/meteor-restivus | lib/endpoint.coffee | MIT | 07dd05317c512dc70cbca5c7080e4c9eadff986a | 541 | https://github.com/kahmali/meteor-restivus/blob/07dd05317c512dc70cbca5c7080e4c9eadff986a/lib/endpoint.coffee | 87 | 100 |
kahmali/meteor-restivus:lib/endpoint.coffee:6:completion | completion | authenticateIfRequired = (endpoint, method) ->
# Authenticate the request if necessary
if endpoint.api.config.useAuth
if method.authRequired is undefined
authenticate.call(this) if endpoint.options?.authRequired
else if method.authRequired
authenticate.call this | ###
Verify the request is being made by an actively logged in user
@context: IronRouter.Router.route()
### | CoffeeScript | CoffeeScript | kahmali/meteor-restivus | lib/endpoint.coffee | MIT | 07dd05317c512dc70cbca5c7080e4c9eadff986a | 541 | https://github.com/kahmali/meteor-restivus/blob/07dd05317c512dc70cbca5c7080e4c9eadff986a/lib/endpoint.coffee | 87 | 100 |
kahmali/meteor-restivus:lib/endpoint.coffee:7:raw_corpus | raw_corpus | authenticate = ->
# Get the auth info from header
userId = @request.headers['x-user-id']
loginToken = @request.headers['x-auth-token']
# Get the user from the database
if userId and loginToken
user = Meteor.users.findOne {'_id': userId, 'services.resume.loginTokens.token': loginToken}
# Return an erro... | CoffeeScript | kahmali/meteor-restivus | lib/endpoint.coffee | MIT | 07dd05317c512dc70cbca5c7080e4c9eadff986a | 541 | https://github.com/kahmali/meteor-restivus/blob/07dd05317c512dc70cbca5c7080e4c9eadff986a/lib/endpoint.coffee | 101 | 121 | ||
kahmali/meteor-restivus:lib/endpoint.coffee:7:coffee_to_js | coffee_to_js | Convert this CoffeeScript to JavaScript.
```coffeescript
authenticate = ->
# Get the auth info from header
userId = @request.headers['x-user-id']
loginToken = @request.headers['x-auth-token']
# Get the user from the database
if userId and loginToken
user = Meteor.users.findOne {'_id': userId, 'services.r... | var authenticate;
authenticate = function() {
var loginToken, user, userId;
// Get the auth info from header
userId = this.request.headers['x-user-id'];
loginToken = this.request.headers['x-auth-token'];
// Get the user from the database
if (userId && loginToken) {
user = Meteor.users.findOne({
'... | CoffeeScript | JavaScript | kahmali/meteor-restivus | lib/endpoint.coffee | MIT | 07dd05317c512dc70cbca5c7080e4c9eadff986a | 541 | https://github.com/kahmali/meteor-restivus/blob/07dd05317c512dc70cbca5c7080e4c9eadff986a/lib/endpoint.coffee | 101 | 121 |
kahmali/meteor-restivus:lib/endpoint.coffee:7:js_to_coffee | js_to_coffee | Convert this JavaScript to CoffeeScript.
```javascript
var authenticate;
authenticate = function() {
var loginToken, user, userId;
// Get the auth info from header
userId = this.request.headers['x-user-id'];
loginToken = this.request.headers['x-auth-token'];
// Get the user from the database
if (userId && ... | authenticate = ->
# Get the auth info from header
userId = @request.headers['x-user-id']
loginToken = @request.headers['x-auth-token']
# Get the user from the database
if userId and loginToken
user = Meteor.users.findOne {'_id': userId, 'services.resume.loginTokens.token': loginToken}
# Return an erro... | JavaScript | CoffeeScript | kahmali/meteor-restivus | lib/endpoint.coffee | MIT | 07dd05317c512dc70cbca5c7080e4c9eadff986a | 541 | https://github.com/kahmali/meteor-restivus/blob/07dd05317c512dc70cbca5c7080e4c9eadff986a/lib/endpoint.coffee | 101 | 121 |
kahmali/meteor-restivus:lib/endpoint.coffee:7:completion | completion | authenticate = ->
# Get the auth info from header
userId = @request.headers['x-user-id']
loginToken = @request.headers['x-auth-token']
# Get the user from the database
if userId and loginToken
user = Meteor.users.findOne {'_id': userId, 'services.resume.loginTokens.token': loginToken}
# Return an erro... | if not user
respond.call this, {success: false, message: "You must be logged in to do this."}, 401
@user = user
###
Respond to an HTTP request
@context: IronRouter.Router.route()
### | CoffeeScript | CoffeeScript | kahmali/meteor-restivus | lib/endpoint.coffee | MIT | 07dd05317c512dc70cbca5c7080e4c9eadff986a | 541 | https://github.com/kahmali/meteor-restivus/blob/07dd05317c512dc70cbca5c7080e4c9eadff986a/lib/endpoint.coffee | 101 | 121 |
kahmali/meteor-restivus:lib/endpoint.coffee:8:raw_corpus | raw_corpus | respond = (body, statusCode=200, headers={'Content-Type':'text/json'}) ->
@response.writeHead statusCode, headers
@response.write JSON.stringify body
@response.end() | CoffeeScript | kahmali/meteor-restivus | lib/endpoint.coffee | MIT | 07dd05317c512dc70cbca5c7080e4c9eadff986a | 541 | https://github.com/kahmali/meteor-restivus/blob/07dd05317c512dc70cbca5c7080e4c9eadff986a/lib/endpoint.coffee | 122 | 125 | ||
kahmali/meteor-restivus:lib/endpoint.coffee:8:coffee_to_js | coffee_to_js | Convert this CoffeeScript to JavaScript.
```coffeescript
respond = (body, statusCode=200, headers={'Content-Type':'text/json'}) ->
@response.writeHead statusCode, headers
@response.write JSON.stringify body
@response.end()
``` | var respond;
respond = function(body, statusCode = 200, headers = {
'Content-Type': 'text/json'
}) {
this.response.writeHead(statusCode, headers);
this.response.write(JSON.stringify(body));
return this.response.end();
}; | CoffeeScript | JavaScript | kahmali/meteor-restivus | lib/endpoint.coffee | MIT | 07dd05317c512dc70cbca5c7080e4c9eadff986a | 541 | https://github.com/kahmali/meteor-restivus/blob/07dd05317c512dc70cbca5c7080e4c9eadff986a/lib/endpoint.coffee | 122 | 125 |
kahmali/meteor-restivus:lib/endpoint.coffee:8:js_to_coffee | js_to_coffee | Convert this JavaScript to CoffeeScript.
```javascript
var respond;
respond = function(body, statusCode = 200, headers = {
'Content-Type': 'text/json'
}) {
this.response.writeHead(statusCode, headers);
this.response.write(JSON.stringify(body));
return this.response.end();
};
``` | respond = (body, statusCode=200, headers={'Content-Type':'text/json'}) ->
@response.writeHead statusCode, headers
@response.write JSON.stringify body
@response.end() | JavaScript | CoffeeScript | kahmali/meteor-restivus | lib/endpoint.coffee | MIT | 07dd05317c512dc70cbca5c7080e4c9eadff986a | 541 | https://github.com/kahmali/meteor-restivus/blob/07dd05317c512dc70cbca5c7080e4c9eadff986a/lib/endpoint.coffee | 122 | 125 |
kahmali/meteor-restivus:lib/endpoint.coffee:8:completion | completion | respond = (body, statusCode=200, headers={'Content-Type':'text/json'}) ->
@response.writeHead statusCode, headers | @response.write JSON.stringify body
@response.end() | CoffeeScript | CoffeeScript | kahmali/meteor-restivus | lib/endpoint.coffee | MIT | 07dd05317c512dc70cbca5c7080e4c9eadff986a | 541 | https://github.com/kahmali/meteor-restivus/blob/07dd05317c512dc70cbca5c7080e4c9eadff986a/lib/endpoint.coffee | 122 | 125 |
kahmali/meteor-restivus:lib/endpoint.coffee:1:raw_corpus | raw_corpus | @Endpoint = (@api, @path, @options, @methods) ->
# TODO: Make the options...well...optional
@Endpoint.prototype.addToApi = ->
self = this
# Throw an error if this endpoint has already been added
# TODO: Check for collisions with paths that follow same pattern with different parameter names
if _.contains @a... | CoffeeScript | kahmali/meteor-restivus | lib/endpoint.coffee | MIT | 581e62c2112a9bc7d62ce70e073923fb843285fd | 541 | https://github.com/kahmali/meteor-restivus/blob/581e62c2112a9bc7d62ce70e073923fb843285fd/lib/endpoint.coffee | 1 | 50 | ||
kahmali/meteor-restivus:lib/endpoint.coffee:1:coffee_to_js | coffee_to_js | Convert this CoffeeScript to JavaScript.
```coffeescript
@Endpoint = (@api, @path, @options, @methods) ->
# TODO: Make the options...well...optional
@Endpoint.prototype.addToApi = ->
self = this
# Throw an error if this endpoint has already been added
# TODO: Check for collisions with paths that follow same ... | this.Endpoint = function(api, path, options, methods) {
this.api = api;
this.path = path;
this.options = options;
this.methods = methods;
};
// TODO: Make the options...well...optional
this.Endpoint.prototype.addToApi = function() {
var fullPath, self;
self = this;
// Throw an error if this endpoint has ... | CoffeeScript | JavaScript | kahmali/meteor-restivus | lib/endpoint.coffee | MIT | 581e62c2112a9bc7d62ce70e073923fb843285fd | 541 | https://github.com/kahmali/meteor-restivus/blob/581e62c2112a9bc7d62ce70e073923fb843285fd/lib/endpoint.coffee | 1 | 50 |
kahmali/meteor-restivus:lib/endpoint.coffee:1:js_to_coffee | js_to_coffee | Convert this JavaScript to CoffeeScript.
```javascript
this.Endpoint = function(api, path, options, methods) {
this.api = api;
this.path = path;
this.options = options;
this.methods = methods;
};
// TODO: Make the options...well...optional
this.Endpoint.prototype.addToApi = function() {
var fullPath, self;
... | @Endpoint = (@api, @path, @options, @methods) ->
# TODO: Make the options...well...optional
@Endpoint.prototype.addToApi = ->
self = this
# Throw an error if this endpoint has already been added
# TODO: Check for collisions with paths that follow same pattern with different parameter names
if _.contains @a... | JavaScript | CoffeeScript | kahmali/meteor-restivus | lib/endpoint.coffee | MIT | 581e62c2112a9bc7d62ce70e073923fb843285fd | 541 | https://github.com/kahmali/meteor-restivus/blob/581e62c2112a9bc7d62ce70e073923fb843285fd/lib/endpoint.coffee | 1 | 50 |
kahmali/meteor-restivus:lib/endpoint.coffee:1:completion | completion | @Endpoint = (@api, @path, @options, @methods) ->
# TODO: Make the options...well...optional
@Endpoint.prototype.addToApi = ->
self = this
# Throw an error if this endpoint has already been added
# TODO: Check for collisions with paths that follow same pattern with different parameter names
if _.contains @a... | # Respond to the requested HTTP method if an endpoint has been provided for it
method = @request.method
console.log "Handling #{method} request at #{self.path}"
# TODO: Handle the different method definition types (e.g., function, object) proposed in README
if method is 'GET' and self.methods.ge... | CoffeeScript | CoffeeScript | kahmali/meteor-restivus | lib/endpoint.coffee | MIT | 581e62c2112a9bc7d62ce70e073923fb843285fd | 541 | https://github.com/kahmali/meteor-restivus/blob/581e62c2112a9bc7d62ce70e073923fb843285fd/lib/endpoint.coffee | 1 | 50 |
kahmali/meteor-restivus:lib/endpoint.coffee:2:raw_corpus | raw_corpus | 'Content-Type': 'text/json'
@response.write JSON.stringify responseBody
@response.end()
# Add the path to our list of existing paths
@api.config.paths.push @path
###
Verify the request is being made by an actively logged in user
###
authenticate = ->
# Get the auth info from header
userId = @re... | CoffeeScript | kahmali/meteor-restivus | lib/endpoint.coffee | MIT | 581e62c2112a9bc7d62ce70e073923fb843285fd | 541 | https://github.com/kahmali/meteor-restivus/blob/581e62c2112a9bc7d62ce70e073923fb843285fd/lib/endpoint.coffee | 51 | 76 | ||
kahmali/meteor-restivus:lib/endpoint.coffee:2:completion | completion | 'Content-Type': 'text/json'
@response.write JSON.stringify responseBody
@response.end()
# Add the path to our list of existing paths
@api.config.paths.push @path
###
Verify the request is being made by an actively logged in user
###
authenticate = ->
# Get the auth info from header | userId = @request.headers['x-user-id']
loginToken = @request.headers['x-auth-token']
# Get the user from the database
if userId and loginToken
user = Meteor.users.findOne {'_id': userId, 'services.resume.loginTokens.token': loginToken}
# Return an error if the login token does not match any belonging to t... | CoffeeScript | CoffeeScript | kahmali/meteor-restivus | lib/endpoint.coffee | MIT | 581e62c2112a9bc7d62ce70e073923fb843285fd | 541 | https://github.com/kahmali/meteor-restivus/blob/581e62c2112a9bc7d62ce70e073923fb843285fd/lib/endpoint.coffee | 51 | 76 |
kahmali/meteor-restivus:lib/endpoint.coffee:1:raw_corpus | raw_corpus | @Endpoint = (@api, @path, @options, @methods) ->
# TODO: Make the options...well...optional
@Endpoint.prototype.addToApi = ->
self = this
# Throw an error if this endpoint has already been added
# TODO: Check for collisions with paths that follow same pattern with different parameter names
if _.contains @a... | CoffeeScript | kahmali/meteor-restivus | lib/endpoint.coffee | MIT | 9d959e0b9dd60398057724202c0e74e5785d7d3a | 541 | https://github.com/kahmali/meteor-restivus/blob/9d959e0b9dd60398057724202c0e74e5785d7d3a/lib/endpoint.coffee | 1 | 50 | ||
kahmali/meteor-restivus:lib/endpoint.coffee:1:coffee_to_js | coffee_to_js | Convert this CoffeeScript to JavaScript.
```coffeescript
@Endpoint = (@api, @path, @options, @methods) ->
# TODO: Make the options...well...optional
@Endpoint.prototype.addToApi = ->
self = this
# Throw an error if this endpoint has already been added
# TODO: Check for collisions with paths that follow same ... | this.Endpoint = function(api, path, options, methods) {
this.api = api;
this.path = path;
this.options = options;
this.methods = methods;
};
// TODO: Make the options...well...optional
this.Endpoint.prototype.addToApi = function() {
var fullPath, self;
self = this;
// Throw an error if this endpoint has ... | CoffeeScript | JavaScript | kahmali/meteor-restivus | lib/endpoint.coffee | MIT | 9d959e0b9dd60398057724202c0e74e5785d7d3a | 541 | https://github.com/kahmali/meteor-restivus/blob/9d959e0b9dd60398057724202c0e74e5785d7d3a/lib/endpoint.coffee | 1 | 50 |
kahmali/meteor-restivus:lib/endpoint.coffee:1:js_to_coffee | js_to_coffee | Convert this JavaScript to CoffeeScript.
```javascript
this.Endpoint = function(api, path, options, methods) {
this.api = api;
this.path = path;
this.options = options;
this.methods = methods;
};
// TODO: Make the options...well...optional
this.Endpoint.prototype.addToApi = function() {
var fullPath, self;
... | @Endpoint = (@api, @path, @options, @methods) ->
# TODO: Make the options...well...optional
@Endpoint.prototype.addToApi = ->
self = this
# Throw an error if this endpoint has already been added
# TODO: Check for collisions with paths that follow same pattern with different parameter names
if _.contains @a... | JavaScript | CoffeeScript | kahmali/meteor-restivus | lib/endpoint.coffee | MIT | 9d959e0b9dd60398057724202c0e74e5785d7d3a | 541 | https://github.com/kahmali/meteor-restivus/blob/9d959e0b9dd60398057724202c0e74e5785d7d3a/lib/endpoint.coffee | 1 | 50 |
kahmali/meteor-restivus:lib/endpoint.coffee:1:completion | completion | @Endpoint = (@api, @path, @options, @methods) ->
# TODO: Make the options...well...optional
@Endpoint.prototype.addToApi = ->
self = this
# Throw an error if this endpoint has already been added
# TODO: Check for collisions with paths that follow same pattern with different parameter names
if _.contains @a... | # Respond to the requested HTTP method if an endpoint has been provided for it
method = @request.method
console.log "Handling #{method} request at #{self.path}"
if method is 'GET' and self.methods.get
responseBody = self.methods.get.call this
else if method is 'POST' and self.methods.pos... | CoffeeScript | CoffeeScript | kahmali/meteor-restivus | lib/endpoint.coffee | MIT | 9d959e0b9dd60398057724202c0e74e5785d7d3a | 541 | https://github.com/kahmali/meteor-restivus/blob/9d959e0b9dd60398057724202c0e74e5785d7d3a/lib/endpoint.coffee | 1 | 50 |
kahmali/meteor-restivus:lib/endpoint.coffee:2:raw_corpus | raw_corpus | # Add the path to our list of existing paths
@api.config.paths.push @path
###
Verify the request is being made by an actively logged in user
###
authenticate = ->
# Get the auth info from header
userId = @request.headers['x-user-id']
loginToken = @request.headers['x-auth-token']
# Get the user from the d... | CoffeeScript | kahmali/meteor-restivus | lib/endpoint.coffee | MIT | 9d959e0b9dd60398057724202c0e74e5785d7d3a | 541 | https://github.com/kahmali/meteor-restivus/blob/9d959e0b9dd60398057724202c0e74e5785d7d3a/lib/endpoint.coffee | 51 | 72 | ||
kahmali/meteor-restivus:lib/endpoint.coffee:2:completion | completion | # Add the path to our list of existing paths
@api.config.paths.push @path
###
Verify the request is being made by an actively logged in user
###
authenticate = ->
# Get the auth info from header
userId = @request.headers['x-user-id']
loginToken = @request.headers['x-auth-token'] | # Get the user from the database
if userId and loginToken
user = Meteor.users.findOne {'_id': userId, 'services.resume.loginTokens.token': loginToken}
# Return an error if the login token does not match any belonging to the user
if not user
# TODO: Execute the http error response here
return [403, {s... | CoffeeScript | CoffeeScript | kahmali/meteor-restivus | lib/endpoint.coffee | MIT | 9d959e0b9dd60398057724202c0e74e5785d7d3a | 541 | https://github.com/kahmali/meteor-restivus/blob/9d959e0b9dd60398057724202c0e74e5785d7d3a/lib/endpoint.coffee | 51 | 72 |
kahmali/meteor-restivus:lib/endpoint.coffee:2:raw_corpus | raw_corpus | # Add the path to our list of existing paths
@api.config.paths.push @path
###
Verify the request is being made by an actively logged in user
###
authenticate = ->
# Get the auth info from header
userId = @request.headers['x-user-id']
loginToken = @request.headers['x-login-token']
# Get the user from the ... | CoffeeScript | kahmali/meteor-restivus | lib/endpoint.coffee | MIT | 52e3d9195a6d19afb4176cf82457b572ddd27951 | 541 | https://github.com/kahmali/meteor-restivus/blob/52e3d9195a6d19afb4176cf82457b572ddd27951/lib/endpoint.coffee | 51 | 72 | ||
kahmali/meteor-restivus:lib/endpoint.coffee:2:completion | completion | # Add the path to our list of existing paths
@api.config.paths.push @path
###
Verify the request is being made by an actively logged in user
###
authenticate = ->
# Get the auth info from header
userId = @request.headers['x-user-id']
loginToken = @request.headers['x-login-token'] | # Get the user from the database
if userId and loginToken
user = Meteor.users.findOne {'_id': userId, 'services.resume.loginTokens.token': loginToken}
# Return an error if the login token does not match any belonging to the user
if not user
# TODO: Execute the http error response here
return [403, {s... | CoffeeScript | CoffeeScript | kahmali/meteor-restivus | lib/endpoint.coffee | MIT | 52e3d9195a6d19afb4176cf82457b572ddd27951 | 541 | https://github.com/kahmali/meteor-restivus/blob/52e3d9195a6d19afb4176cf82457b572ddd27951/lib/endpoint.coffee | 51 | 72 |
meltingice/psd.js:lib/psd/image.coffee:1:raw_corpus | raw_corpus | module.exports = class Image extends Module
# Here we include all of our important mixins.
@includes ImageFormat.RAW
@includes ImageFormat.RLE
@includes ImageMode.Greyscale
@includes ImageMode.RGB
@includes ImageMode.CMYK
@includes Export.PNG
# Images can be 1 of 4 different compression types. RLE is t... | CoffeeScript | meltingice/psd.js | lib/psd/image.coffee | MIT | 7e8392d20fd5d66ad70ddda7309661b9a0ca67c8 | 2,846 | https://github.com/meltingice/psd.js/blob/7e8392d20fd5d66ad70ddda7309661b9a0ca67c8/lib/psd/image.coffee | 10 | 59 | ||
meltingice/psd.js:lib/psd/image.coffee:1:completion | completion | module.exports = class Image extends Module
# Here we include all of our important mixins.
@includes ImageFormat.RAW
@includes ImageFormat.RLE
@includes ImageMode.Greyscale
@includes ImageMode.RGB
@includes ImageMode.CMYK
@includes Export.PNG
# Images can be 1 of 4 different compression types. RLE is t... | # The resulting array that stores the pixel data, formatted in RGBA format.
@pixelData = new Uint8Array(@channelLength * 4)
@maskData = new Uint8Array(@maskLength * 4)
# This temporarily holds the raw channel data after it's been parsed, but not
# processed.
@channelData = new Uint8Array(@length +... | CoffeeScript | CoffeeScript | meltingice/psd.js | lib/psd/image.coffee | MIT | 7e8392d20fd5d66ad70ddda7309661b9a0ca67c8 | 2,846 | https://github.com/meltingice/psd.js/blob/7e8392d20fd5d66ad70ddda7309661b9a0ca67c8/lib/psd/image.coffee | 10 | 59 |
meltingice/psd.js:lib/psd/image.coffee:2:raw_corpus | raw_corpus | when 4 then @setCmykChannels()
# Calculates the length of the image data.
calculateLength: ->
@length = switch @depth()
when 1 then (@width() + 7) / 8 * @height()
when 16 then @width() * @height() * 2
else @width() * @height()
@channelLength = @length
@length *= @channels()
if @... | CoffeeScript | meltingice/psd.js | lib/psd/image.coffee | MIT | 7e8392d20fd5d66ad70ddda7309661b9a0ca67c8 | 2,846 | https://github.com/meltingice/psd.js/blob/7e8392d20fd5d66ad70ddda7309661b9a0ca67c8/lib/psd/image.coffee | 60 | 107 | ||
meltingice/psd.js:lib/psd/image.coffee:2:completion | completion | when 4 then @setCmykChannels()
# Calculates the length of the image data.
calculateLength: ->
@length = switch @depth()
when 1 then (@width() + 7) / 8 * @height()
when 16 then @width() * @height() * 2
else @width() * @height()
@channelLength = @length
@length *= @channels()
if @... | @parseImageData()
# Parses the compression mode.
parseCompression: -> @file.readShort()
# Parses the image data based on the compression mode.
parseImageData: ->
switch @compression
when 0 then @parseRaw()
when 1 then @parseRLE()
when 2, 3 then @parseZip()
else @file.seek(@endPos)
... | CoffeeScript | CoffeeScript | meltingice/psd.js | lib/psd/image.coffee | MIT | 7e8392d20fd5d66ad70ddda7309661b9a0ca67c8 | 2,846 | https://github.com/meltingice/psd.js/blob/7e8392d20fd5d66ad70ddda7309661b9a0ca67c8/lib/psd/image.coffee | 60 | 107 |
meltingice/psd.js:lib/psd/image.coffee:1:raw_corpus | raw_corpus | module.exports = class Image extends Module
# Here we include all of our important mixins.
@includes ImageFormat.RAW
@includes ImageFormat.RLE
@includes ImageMode.Greyscale
@includes ImageMode.RGB
@includes ImageMode.CMYK
@includes Export.PNG
# Images can be 1 of 4 different compression types. RLE is t... | CoffeeScript | meltingice/psd.js | lib/psd/image.coffee | MIT | b4031b340ad829a2275e7739f944139746b1df7f | 2,846 | https://github.com/meltingice/psd.js/blob/b4031b340ad829a2275e7739f944139746b1df7f/lib/psd/image.coffee | 10 | 59 | ||
meltingice/psd.js:lib/psd/image.coffee:1:completion | completion | module.exports = class Image extends Module
# Here we include all of our important mixins.
@includes ImageFormat.RAW
@includes ImageFormat.RLE
@includes ImageMode.Greyscale
@includes ImageMode.RGB
@includes ImageMode.CMYK
@includes Export.PNG
# Images can be 1 of 4 different compression types. RLE is t... | # The resulting array that stores the pixel data, formatted in RGBA format.
@pixelData = new Uint8Array(@length)
@maskData = new Uint8Array(@maskLength * 4)
# This temporarily holds the raw channel data after it's been parsed, but not
# processed.
@channelData = new Uint8Array(@length + @maskLengt... | CoffeeScript | CoffeeScript | meltingice/psd.js | lib/psd/image.coffee | MIT | b4031b340ad829a2275e7739f944139746b1df7f | 2,846 | https://github.com/meltingice/psd.js/blob/b4031b340ad829a2275e7739f944139746b1df7f/lib/psd/image.coffee | 10 | 59 |
meltingice/psd.js:lib/psd/image.coffee:1:raw_corpus | raw_corpus | module.exports = class Image extends Module
# Here we include all of our important mixins.
@includes ImageFormat.RAW
@includes ImageFormat.RLE
@includes ImageMode.Greyscale
@includes ImageMode.RGB
@includes ImageMode.CMYK
@includes Export.PNG
# Images can be 1 of 4 different compression types. RLE is t... | CoffeeScript | meltingice/psd.js | lib/psd/image.coffee | MIT | 1ccf630905de90ab1f5eedf8a9527491d6ac4ef1 | 2,846 | https://github.com/meltingice/psd.js/blob/1ccf630905de90ab1f5eedf8a9527491d6ac4ef1/lib/psd/image.coffee | 10 | 59 | ||
meltingice/psd.js:lib/psd/image.coffee:1:completion | completion | module.exports = class Image extends Module
# Here we include all of our important mixins.
@includes ImageFormat.RAW
@includes ImageFormat.RLE
@includes ImageMode.Greyscale
@includes ImageMode.RGB
@includes ImageMode.CMYK
@includes Export.PNG
# Images can be 1 of 4 different compression types. RLE is t... | # The resulting array that stores the pixel data, formatted in RGBA format.
@pixelData = []
# This temporarily holds the raw channel data after it's been parsed, but not
# processed.
@channelData = []
@opacity = 1.0
@hasMask = false
@startPos = @file.tell()
@endPos = @startPos + @lengt... | CoffeeScript | CoffeeScript | meltingice/psd.js | lib/psd/image.coffee | MIT | 1ccf630905de90ab1f5eedf8a9527491d6ac4ef1 | 2,846 | https://github.com/meltingice/psd.js/blob/1ccf630905de90ab1f5eedf8a9527491d6ac4ef1/lib/psd/image.coffee | 10 | 59 |
meltingice/psd.js:lib/psd/image.coffee:2:raw_corpus | raw_corpus | # Calculates the length of the image data.
calculateLength: ->
@length = switch @depth()
when 1 then (@width() + 7) / 8 * @height()
when 16 then @width() * @height() * 2
else @width() * @height()
@channelLength = @length
@length *= @channels()
# Parses the image and formats the image... | CoffeeScript | meltingice/psd.js | lib/psd/image.coffee | MIT | 1ccf630905de90ab1f5eedf8a9527491d6ac4ef1 | 2,846 | https://github.com/meltingice/psd.js/blob/1ccf630905de90ab1f5eedf8a9527491d6ac4ef1/lib/psd/image.coffee | 60 | 100 | ||
meltingice/psd.js:lib/psd/image.coffee:2:coffee_to_js | coffee_to_js | Convert this CoffeeScript to JavaScript.
```coffeescript
# Calculates the length of the image data.
calculateLength: ->
@length = switch @depth()
when 1 then (@width() + 7) / 8 * @height()
when 16 then @width() * @height() * 2
else @width() * @height()
@channelLength = @length
@length *... | // Calculates the length of the image data.
({
calculateLength: function() {
this.length = (function() {
switch (this.depth()) {
case 1:
return (this.width() + 7) / 8 * this.height();
case 16:
return this.width() * this.height() * 2;
default:
return this... | CoffeeScript | JavaScript | meltingice/psd.js | lib/psd/image.coffee | MIT | 1ccf630905de90ab1f5eedf8a9527491d6ac4ef1 | 2,846 | https://github.com/meltingice/psd.js/blob/1ccf630905de90ab1f5eedf8a9527491d6ac4ef1/lib/psd/image.coffee | 60 | 100 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.