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 |
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
meltingice/psd.js:lib/psd/layer/position_channels.coffee:1:raw_corpus | raw_corpus | module.exports =
# Every layer starts with the basics. Here we have the layer dimensions,
# the number of color channels for the image data, and information about
# the color channels.
parsePositionAndChannels: ->
@top = @file.readInt()
@left = @file.readInt()
@bottom = @file.readInt()
@right = ... | CoffeeScript | meltingice/psd.js | lib/psd/layer/position_channels.coffee | MIT | 7e8392d20fd5d66ad70ddda7309661b9a0ca67c8 | 2,846 | https://github.com/meltingice/psd.js/blob/7e8392d20fd5d66ad70ddda7309661b9a0ca67c8/lib/psd/layer/position_channels.coffee | 1 | 22 | ||
meltingice/psd.js:lib/psd/layer/position_channels.coffee:1:coffee_to_js | coffee_to_js | Convert this CoffeeScript to JavaScript.
```coffeescript
module.exports =
# Every layer starts with the basics. Here we have the layer dimensions,
# the number of color channels for the image data, and information about
# the color channels.
parsePositionAndChannels: ->
@top = @file.readInt()
@left = @f... | module.exports = {
// Every layer starts with the basics. Here we have the layer dimensions,
// the number of color channels for the image data, and information about
// the color channels.
parsePositionAndChannels: function() {
var i, id, j, length, ref, results;
this.top = this.file.readInt();
thi... | CoffeeScript | JavaScript | meltingice/psd.js | lib/psd/layer/position_channels.coffee | MIT | 7e8392d20fd5d66ad70ddda7309661b9a0ca67c8 | 2,846 | https://github.com/meltingice/psd.js/blob/7e8392d20fd5d66ad70ddda7309661b9a0ca67c8/lib/psd/layer/position_channels.coffee | 1 | 22 |
meltingice/psd.js:lib/psd/layer/position_channels.coffee:1:js_to_coffee | js_to_coffee | Convert this JavaScript to CoffeeScript.
```javascript
module.exports = {
// Every layer starts with the basics. Here we have the layer dimensions,
// the number of color channels for the image data, and information about
// the color channels.
parsePositionAndChannels: function() {
var i, id, j, length, re... | module.exports =
# Every layer starts with the basics. Here we have the layer dimensions,
# the number of color channels for the image data, and information about
# the color channels.
parsePositionAndChannels: ->
@top = @file.readInt()
@left = @file.readInt()
@bottom = @file.readInt()
@right = ... | JavaScript | CoffeeScript | meltingice/psd.js | lib/psd/layer/position_channels.coffee | MIT | 7e8392d20fd5d66ad70ddda7309661b9a0ca67c8 | 2,846 | https://github.com/meltingice/psd.js/blob/7e8392d20fd5d66ad70ddda7309661b9a0ca67c8/lib/psd/layer/position_channels.coffee | 1 | 22 |
meltingice/psd.js:lib/psd/layer/position_channels.coffee:1:completion | completion | module.exports =
# Every layer starts with the basics. Here we have the layer dimensions,
# the number of color channels for the image data, and information about
# the color channels.
parsePositionAndChannels: ->
@top = @file.readInt()
@left = @file.readInt()
@bottom = @file.readInt()
@right = ... | @rows = @height = @bottom - @top
@cols = @width = @right - @left
# Every color channel has both an ID and a length. The ID correlates to
# the color channel, e.g. 0 = R, 1 = G, 2 = B, -1 = A, and the length is
# the size of the data.
for i in [0...@channels]
id = @file.readShort()
lengt... | CoffeeScript | CoffeeScript | meltingice/psd.js | lib/psd/layer/position_channels.coffee | MIT | 7e8392d20fd5d66ad70ddda7309661b9a0ca67c8 | 2,846 | https://github.com/meltingice/psd.js/blob/7e8392d20fd5d66ad70ddda7309661b9a0ca67c8/lib/psd/layer/position_channels.coffee | 1 | 22 |
meltingice/psd.js:lib/psd/layer/position_channels.coffee:1:raw_corpus | raw_corpus | module.exports =
parsePositionAndChannels: ->
@top = @file.readInt()
@left = @file.readInt()
@bottom = @file.readInt()
@right = @file.readInt()
@channels = @file.readShort()
@rows = @height = @bottom - @top
@cols = @width = @right - @left
for i in [0...@channels]
id = @file.rea... | CoffeeScript | meltingice/psd.js | lib/psd/layer/position_channels.coffee | MIT | 565c4a6eef97b2ef26e76cd0910c3eb60b507434 | 2,846 | https://github.com/meltingice/psd.js/blob/565c4a6eef97b2ef26e76cd0910c3eb60b507434/lib/psd/layer/position_channels.coffee | 1 | 16 | ||
meltingice/psd.js:lib/psd/layer/position_channels.coffee:1:coffee_to_js | coffee_to_js | Convert this CoffeeScript to JavaScript.
```coffeescript
module.exports =
parsePositionAndChannels: ->
@top = @file.readInt()
@left = @file.readInt()
@bottom = @file.readInt()
@right = @file.readInt()
@channels = @file.readShort()
@rows = @height = @bottom - @top
@cols = @width = @right -... | module.exports = {
parsePositionAndChannels: function() {
var i, id, j, length, ref, results;
this.top = this.file.readInt();
this.left = this.file.readInt();
this.bottom = this.file.readInt();
this.right = this.file.readInt();
this.channels = this.file.readShort();
this.rows = this.height... | CoffeeScript | JavaScript | meltingice/psd.js | lib/psd/layer/position_channels.coffee | MIT | 565c4a6eef97b2ef26e76cd0910c3eb60b507434 | 2,846 | https://github.com/meltingice/psd.js/blob/565c4a6eef97b2ef26e76cd0910c3eb60b507434/lib/psd/layer/position_channels.coffee | 1 | 16 |
meltingice/psd.js:lib/psd/layer/position_channels.coffee:1:js_to_coffee | js_to_coffee | Convert this JavaScript to CoffeeScript.
```javascript
module.exports = {
parsePositionAndChannels: function() {
var i, id, j, length, ref, results;
this.top = this.file.readInt();
this.left = this.file.readInt();
this.bottom = this.file.readInt();
this.right = this.file.readInt();
this.channe... | module.exports =
parsePositionAndChannels: ->
@top = @file.readInt()
@left = @file.readInt()
@bottom = @file.readInt()
@right = @file.readInt()
@channels = @file.readShort()
@rows = @height = @bottom - @top
@cols = @width = @right - @left
for i in [0...@channels]
id = @file.rea... | JavaScript | CoffeeScript | meltingice/psd.js | lib/psd/layer/position_channels.coffee | MIT | 565c4a6eef97b2ef26e76cd0910c3eb60b507434 | 2,846 | https://github.com/meltingice/psd.js/blob/565c4a6eef97b2ef26e76cd0910c3eb60b507434/lib/psd/layer/position_channels.coffee | 1 | 16 |
meltingice/psd.js:lib/psd/layer/position_channels.coffee:1:completion | completion | module.exports =
parsePositionAndChannels: ->
@top = @file.readInt()
@left = @file.readInt()
@bottom = @file.readInt()
@right = @file.readInt()
@channels = @file.readShort() | @rows = @height = @bottom - @top
@cols = @width = @right - @left
for i in [0...@channels]
id = @file.readShort()
length = @file.readInt()
@channelsInfo.push id: id, length: length | CoffeeScript | CoffeeScript | meltingice/psd.js | lib/psd/layer/position_channels.coffee | MIT | 565c4a6eef97b2ef26e76cd0910c3eb60b507434 | 2,846 | https://github.com/meltingice/psd.js/blob/565c4a6eef97b2ef26e76cd0910c3eb60b507434/lib/psd/layer/position_channels.coffee | 1 | 16 |
CaryLandholt/AngularFun:tasks/requirejs.coffee:1:raw_corpus | raw_corpus | ###global module, require###
module.exports = (grunt) ->
requirejs = require 'requirejs'
grunt.registerMultiTask 'requirejs', 'Runs the RequireJS Optimizer', ->
config = @data
requirejs.optimize config, (buildResponse) ->
grunt.verbose.writeln buildResponse | CoffeeScript | CaryLandholt/AngularFun | tasks/requirejs.coffee | MIT | f2b41faa384d4ac2ceee72ae9134ad885ced0cb7 | 672 | https://github.com/CaryLandholt/AngularFun/blob/f2b41faa384d4ac2ceee72ae9134ad885ced0cb7/tasks/requirejs.coffee | 1 | 10 | ||
CaryLandholt/AngularFun:tasks/requirejs.coffee:1:coffee_to_js | coffee_to_js | Convert this CoffeeScript to JavaScript.
```coffeescript
###global module, require###
module.exports = (grunt) ->
requirejs = require 'requirejs'
grunt.registerMultiTask 'requirejs', 'Runs the RequireJS Optimizer', ->
config = @data
requirejs.optimize config, (buildResponse) ->
grunt.verbose.writeln buildRe... | /*global module, require*/
module.exports = function(grunt) {
var requirejs;
requirejs = require('requirejs');
return grunt.registerMultiTask('requirejs', 'Runs the RequireJS Optimizer', function() {
var config;
config = this.data;
return requirejs.optimize(config, function(buildResponse) {
retu... | CoffeeScript | JavaScript | CaryLandholt/AngularFun | tasks/requirejs.coffee | MIT | f2b41faa384d4ac2ceee72ae9134ad885ced0cb7 | 672 | https://github.com/CaryLandholt/AngularFun/blob/f2b41faa384d4ac2ceee72ae9134ad885ced0cb7/tasks/requirejs.coffee | 1 | 10 |
CaryLandholt/AngularFun:tasks/requirejs.coffee:1:js_to_coffee | js_to_coffee | Convert this JavaScript to CoffeeScript.
```javascript
/*global module, require*/
module.exports = function(grunt) {
var requirejs;
requirejs = require('requirejs');
return grunt.registerMultiTask('requirejs', 'Runs the RequireJS Optimizer', function() {
var config;
config = this.data;
return requirej... | ###global module, require###
module.exports = (grunt) ->
requirejs = require 'requirejs'
grunt.registerMultiTask 'requirejs', 'Runs the RequireJS Optimizer', ->
config = @data
requirejs.optimize config, (buildResponse) ->
grunt.verbose.writeln buildResponse | JavaScript | CoffeeScript | CaryLandholt/AngularFun | tasks/requirejs.coffee | MIT | f2b41faa384d4ac2ceee72ae9134ad885ced0cb7 | 672 | https://github.com/CaryLandholt/AngularFun/blob/f2b41faa384d4ac2ceee72ae9134ad885ced0cb7/tasks/requirejs.coffee | 1 | 10 |
CaryLandholt/AngularFun:tasks/requirejs.coffee:1:completion | completion | ###global module, require###
module.exports = (grunt) ->
requirejs = require 'requirejs' | grunt.registerMultiTask 'requirejs', 'Runs the RequireJS Optimizer', ->
config = @data
requirejs.optimize config, (buildResponse) ->
grunt.verbose.writeln buildResponse | CoffeeScript | CoffeeScript | CaryLandholt/AngularFun | tasks/requirejs.coffee | MIT | f2b41faa384d4ac2ceee72ae9134ad885ced0cb7 | 672 | https://github.com/CaryLandholt/AngularFun/blob/f2b41faa384d4ac2ceee72ae9134ad885ced0cb7/tasks/requirejs.coffee | 1 | 10 |
CaryLandholt/AngularFun:tasks/requirejs.coffee:1:raw_corpus | raw_corpus | ###global module, require###
module.exports = (grunt) ->
growl = require 'growl'
path = require 'path'
requirejs = require 'requirejs'
grunt.registerMultiTask 'requirejs', 'Runs the RequireJS Optimizer', ->
config = @data
dest = config.out
destFullPath = path.resolve dest
requirejs.optimize config, (buil... | CoffeeScript | CaryLandholt/AngularFun | tasks/requirejs.coffee | MIT | b51fa32a9d2a3556c592d2e033e8802bf40b3f97 | 672 | https://github.com/CaryLandholt/AngularFun/blob/b51fa32a9d2a3556c592d2e033e8802bf40b3f97/tasks/requirejs.coffee | 1 | 17 | ||
CaryLandholt/AngularFun:tasks/requirejs.coffee:1:coffee_to_js | coffee_to_js | Convert this CoffeeScript to JavaScript.
```coffeescript
###global module, require###
module.exports = (grunt) ->
growl = require 'growl'
path = require 'path'
requirejs = require 'requirejs'
grunt.registerMultiTask 'requirejs', 'Runs the RequireJS Optimizer', ->
config = @data
dest = config.out
destFullPat... | /*global module, require*/
module.exports = function(grunt) {
var growl, path, requirejs;
growl = require('growl');
path = require('path');
requirejs = require('requirejs');
return grunt.registerMultiTask('requirejs', 'Runs the RequireJS Optimizer', function() {
var config, dest, destFullPath;
config ... | CoffeeScript | JavaScript | CaryLandholt/AngularFun | tasks/requirejs.coffee | MIT | b51fa32a9d2a3556c592d2e033e8802bf40b3f97 | 672 | https://github.com/CaryLandholt/AngularFun/blob/b51fa32a9d2a3556c592d2e033e8802bf40b3f97/tasks/requirejs.coffee | 1 | 17 |
CaryLandholt/AngularFun:tasks/requirejs.coffee:1:js_to_coffee | js_to_coffee | Convert this JavaScript to CoffeeScript.
```javascript
/*global module, require*/
module.exports = function(grunt) {
var growl, path, requirejs;
growl = require('growl');
path = require('path');
requirejs = require('requirejs');
return grunt.registerMultiTask('requirejs', 'Runs the RequireJS Optimizer', funct... | ###global module, require###
module.exports = (grunt) ->
growl = require 'growl'
path = require 'path'
requirejs = require 'requirejs'
grunt.registerMultiTask 'requirejs', 'Runs the RequireJS Optimizer', ->
config = @data
dest = config.out
destFullPath = path.resolve dest
requirejs.optimize config, (buil... | JavaScript | CoffeeScript | CaryLandholt/AngularFun | tasks/requirejs.coffee | MIT | b51fa32a9d2a3556c592d2e033e8802bf40b3f97 | 672 | https://github.com/CaryLandholt/AngularFun/blob/b51fa32a9d2a3556c592d2e033e8802bf40b3f97/tasks/requirejs.coffee | 1 | 17 |
CaryLandholt/AngularFun:tasks/requirejs.coffee:1:completion | completion | ###global module, require###
module.exports = (grunt) ->
growl = require 'growl'
path = require 'path'
requirejs = require 'requirejs'
grunt.registerMultiTask 'requirejs', 'Runs the RequireJS Optimizer', -> | config = @data
dest = config.out
destFullPath = path.resolve dest
requirejs.optimize config, (buildResponse) ->
message = "Optimized #{buildResponse}"
#grunt.log.writeln message
growl message, title: 'Optimized JavaScript' | CoffeeScript | CoffeeScript | CaryLandholt/AngularFun | tasks/requirejs.coffee | MIT | b51fa32a9d2a3556c592d2e033e8802bf40b3f97 | 672 | https://github.com/CaryLandholt/AngularFun/blob/b51fa32a9d2a3556c592d2e033e8802bf40b3f97/tasks/requirejs.coffee | 1 | 17 |
CaryLandholt/AngularFun:tasks/requirejs.coffee:1:raw_corpus | raw_corpus | ###global module, require###
module.exports = (grunt) ->
growl = require 'growl'
path = require 'path'
requirejs = require 'requirejs'
grunt.registerMultiTask 'requirejs', 'Builds RequireJS modules via the RequireJS Optimizer', ->
config = @data
dest = config.out
destFullPath = path.resolve dest
requirej... | CoffeeScript | CaryLandholt/AngularFun | tasks/requirejs.coffee | MIT | 4d1f0e38f7f87729adcf7c80bc4242ce73098f46 | 672 | https://github.com/CaryLandholt/AngularFun/blob/4d1f0e38f7f87729adcf7c80bc4242ce73098f46/tasks/requirejs.coffee | 1 | 17 | ||
CaryLandholt/AngularFun:tasks/requirejs.coffee:1:coffee_to_js | coffee_to_js | Convert this CoffeeScript to JavaScript.
```coffeescript
###global module, require###
module.exports = (grunt) ->
growl = require 'growl'
path = require 'path'
requirejs = require 'requirejs'
grunt.registerMultiTask 'requirejs', 'Builds RequireJS modules via the RequireJS Optimizer', ->
config = @data
dest = ... | /*global module, require*/
module.exports = function(grunt) {
var growl, path, requirejs;
growl = require('growl');
path = require('path');
requirejs = require('requirejs');
return grunt.registerMultiTask('requirejs', 'Builds RequireJS modules via the RequireJS Optimizer', function() {
var config, dest, d... | CoffeeScript | JavaScript | CaryLandholt/AngularFun | tasks/requirejs.coffee | MIT | 4d1f0e38f7f87729adcf7c80bc4242ce73098f46 | 672 | https://github.com/CaryLandholt/AngularFun/blob/4d1f0e38f7f87729adcf7c80bc4242ce73098f46/tasks/requirejs.coffee | 1 | 17 |
CaryLandholt/AngularFun:tasks/requirejs.coffee:1:js_to_coffee | js_to_coffee | Convert this JavaScript to CoffeeScript.
```javascript
/*global module, require*/
module.exports = function(grunt) {
var growl, path, requirejs;
growl = require('growl');
path = require('path');
requirejs = require('requirejs');
return grunt.registerMultiTask('requirejs', 'Builds RequireJS modules via the Req... | ###global module, require###
module.exports = (grunt) ->
growl = require 'growl'
path = require 'path'
requirejs = require 'requirejs'
grunt.registerMultiTask 'requirejs', 'Builds RequireJS modules via the RequireJS Optimizer', ->
config = @data
dest = config.out
destFullPath = path.resolve dest
requirej... | JavaScript | CoffeeScript | CaryLandholt/AngularFun | tasks/requirejs.coffee | MIT | 4d1f0e38f7f87729adcf7c80bc4242ce73098f46 | 672 | https://github.com/CaryLandholt/AngularFun/blob/4d1f0e38f7f87729adcf7c80bc4242ce73098f46/tasks/requirejs.coffee | 1 | 17 |
CaryLandholt/AngularFun:tasks/requirejs.coffee:1:completion | completion | ###global module, require###
module.exports = (grunt) ->
growl = require 'growl'
path = require 'path'
requirejs = require 'requirejs'
grunt.registerMultiTask 'requirejs', 'Builds RequireJS modules via the RequireJS Optimizer', -> | config = @data
dest = config.out
destFullPath = path.resolve dest
requirejs.optimize config, (buildResponse) ->
message = "Optimized #{buildResponse}"
grunt.log.writeln message
growl message, title: 'Optimized JavaScript' | CoffeeScript | CoffeeScript | CaryLandholt/AngularFun | tasks/requirejs.coffee | MIT | 4d1f0e38f7f87729adcf7c80bc4242ce73098f46 | 672 | https://github.com/CaryLandholt/AngularFun/blob/4d1f0e38f7f87729adcf7c80bc4242ce73098f46/tasks/requirejs.coffee | 1 | 17 |
gterrono/houston:test/test_base.coffee:1:raw_corpus | raw_corpus | wait = (fn, ms=500) -> casper.wait ms, fn
PORT = 3500
test = (name, num_tests, path, fn, wait_time=500) ->
url = "http://localhost:#{PORT}#{path}"
casper.test.begin name, num_tests, (test) ->
casper.start url, (response) ->
fn.bind(@)
wait fn, wait_time
casper.run ->
test.done()
test 'Us... | CoffeeScript | gterrono/houston | test/test_base.coffee | MIT | b34f264085874f68eceb22d0f07a10250f3c11e0 | 802 | https://github.com/gterrono/houston/blob/b34f264085874f68eceb22d0f07a10250f3c11e0/test/test_base.coffee | 1 | 46 | ||
gterrono/houston:test/test_base.coffee:1:completion | completion | wait = (fn, ms=500) -> casper.wait ms, fn
PORT = 3500
test = (name, num_tests, path, fn, wait_time=500) ->
url = "http://localhost:#{PORT}#{path}"
casper.test.begin name, num_tests, (test) ->
casper.start url, (response) ->
fn.bind(@)
wait fn, wait_time
casper.run ->
test.done()
test 'Us... | test 'User can log out', 1, '/admin/login', ->
@click 'a.houston-logout'
wait ->
@test.assertEval (-> !Meteor.user()?), 'admin logged out successfully'
test 'User can log in', 3, '/admin', ->
@test.assertUrlMatch /\/admin\/login/, 'redirected to login'
@test.assertExists 'input[value="Sign in"]', 'sign in ... | CoffeeScript | CoffeeScript | gterrono/houston | test/test_base.coffee | MIT | b34f264085874f68eceb22d0f07a10250f3c11e0 | 802 | https://github.com/gterrono/houston/blob/b34f264085874f68eceb22d0f07a10250f3c11e0/test/test_base.coffee | 1 | 46 |
buttercoin/buttercoin:test/datastore/book_spec.coffee:1:raw_corpus | raw_corpus | sellBTC = (args...) ->
order = global.sellBTC(args...)
order.price = 1/order.price
return order
describe 'Book', ->
beforeEach ->
@book = new Book()
@account1 = {name: "acct1"}
@account2 = {name: "acct2"}
it 'should be able to add an order', ->
order = buyBTC(@account1, 1, 10)
@book.stor... | CoffeeScript | buttercoin/buttercoin | test/datastore/book_spec.coffee | MIT | 9132b62466965491ac27a0fd16328a4c2ac61eef | 663 | https://github.com/buttercoin/buttercoin/blob/9132b62466965491ac27a0fd16328a4c2ac61eef/test/datastore/book_spec.coffee | 4 | 53 | ||
buttercoin/buttercoin:test/datastore/book_spec.coffee:1:coffee_to_js | coffee_to_js | Convert this CoffeeScript to JavaScript.
```coffeescript
sellBTC = (args...) ->
order = global.sellBTC(args...)
order.price = 1/order.price
return order
describe 'Book', ->
beforeEach ->
@book = new Book()
@account1 = {name: "acct1"}
@account2 = {name: "acct2"}
it 'should be able to add an order... | var sellBTC;
sellBTC = function(...args) {
var order;
order = global.sellBTC(...args);
order.price = 1 / order.price;
return order;
};
describe('Book', function() {
beforeEach(function() {
this.book = new Book();
this.account1 = {
name: "acct1"
};
return this.account2 = {
name: "... | CoffeeScript | JavaScript | buttercoin/buttercoin | test/datastore/book_spec.coffee | MIT | 9132b62466965491ac27a0fd16328a4c2ac61eef | 663 | https://github.com/buttercoin/buttercoin/blob/9132b62466965491ac27a0fd16328a4c2ac61eef/test/datastore/book_spec.coffee | 4 | 53 |
buttercoin/buttercoin:test/datastore/book_spec.coffee:1:js_to_coffee | js_to_coffee | Convert this JavaScript to CoffeeScript.
```javascript
var sellBTC;
sellBTC = function(...args) {
var order;
order = global.sellBTC(...args);
order.price = 1 / order.price;
return order;
};
describe('Book', function() {
beforeEach(function() {
this.book = new Book();
this.account1 = {
name: "a... | sellBTC = (args...) ->
order = global.sellBTC(args...)
order.price = 1/order.price
return order
describe 'Book', ->
beforeEach ->
@book = new Book()
@account1 = {name: "acct1"}
@account2 = {name: "acct2"}
it 'should be able to add an order', ->
order = buyBTC(@account1, 1, 10)
@book.stor... | JavaScript | CoffeeScript | buttercoin/buttercoin | test/datastore/book_spec.coffee | MIT | 9132b62466965491ac27a0fd16328a4c2ac61eef | 663 | https://github.com/buttercoin/buttercoin/blob/9132b62466965491ac27a0fd16328a4c2ac61eef/test/datastore/book_spec.coffee | 4 | 53 |
buttercoin/buttercoin:test/datastore/book_spec.coffee:1:completion | completion | sellBTC = (args...) ->
order = global.sellBTC(args...)
order.price = 1/order.price
return order
describe 'Book', ->
beforeEach ->
@book = new Book()
@account1 = {name: "acct1"}
@account2 = {name: "acct2"}
it 'should be able to add an order', ->
order = buyBTC(@account1, 1, 10)
@book.stor... | expectedBTC = [2, 1]
expectedUSD = [20, 11]
expectedLevels = [10, 11]
# TODO sizes and prices should be inverse of one another?
expectedSizes = [20, 11]
@book.store.forEach (order_level, price) ->
price.should.equal expectedLevels.shift()
order_level.size.should.equal expectedSizes.shift... | CoffeeScript | CoffeeScript | buttercoin/buttercoin | test/datastore/book_spec.coffee | MIT | 9132b62466965491ac27a0fd16328a4c2ac61eef | 663 | https://github.com/buttercoin/buttercoin/blob/9132b62466965491ac27a0fd16328a4c2ac61eef/test/datastore/book_spec.coffee | 4 | 53 |
buttercoin/buttercoin:test/datastore/book_spec.coffee:2:raw_corpus | raw_corpus | it 'should preserve the order in which orders are received', ->
@book.add_order(sellBTC(@account1, 1, 10))
@book.add_order(sellBTC(@account2, 1, 10))
results = @book.fill_orders_with(buyBTC({name: 'acct3'}, 1, 10))
results.should.have.length(2)
sold = results.shift()
sold.should.succeed_with('o... | CoffeeScript | buttercoin/buttercoin | test/datastore/book_spec.coffee | MIT | 9132b62466965491ac27a0fd16328a4c2ac61eef | 663 | https://github.com/buttercoin/buttercoin/blob/9132b62466965491ac27a0fd16328a4c2ac61eef/test/datastore/book_spec.coffee | 54 | 103 | ||
buttercoin/buttercoin:test/datastore/book_spec.coffee:2:coffee_to_js | coffee_to_js | Convert this CoffeeScript to JavaScript.
```coffeescript
it 'should preserve the order in which orders are received', ->
@book.add_order(sellBTC(@account1, 1, 10))
@book.add_order(sellBTC(@account2, 1, 10))
results = @book.fill_orders_with(buyBTC({name: 'acct3'}, 1, 10))
results.should.have.length(2)
... | it('should preserve the order in which orders are received', function() {
var results, sold;
this.book.add_order(sellBTC(this.account1, 1, 10));
this.book.add_order(sellBTC(this.account2, 1, 10));
results = this.book.fill_orders_with(buyBTC({
name: 'acct3'
}, 1, 10));
results.should.have.length(2);
so... | CoffeeScript | JavaScript | buttercoin/buttercoin | test/datastore/book_spec.coffee | MIT | 9132b62466965491ac27a0fd16328a4c2ac61eef | 663 | https://github.com/buttercoin/buttercoin/blob/9132b62466965491ac27a0fd16328a4c2ac61eef/test/datastore/book_spec.coffee | 54 | 103 |
buttercoin/buttercoin:test/datastore/book_spec.coffee:2:js_to_coffee | js_to_coffee | Convert this JavaScript to CoffeeScript.
```javascript
it('should preserve the order in which orders are received', function() {
var results, sold;
this.book.add_order(sellBTC(this.account1, 1, 10));
this.book.add_order(sellBTC(this.account2, 1, 10));
results = this.book.fill_orders_with(buyBTC({
name: 'acc... | it 'should preserve the order in which orders are received', ->
@book.add_order(sellBTC(@account1, 1, 10))
@book.add_order(sellBTC(@account2, 1, 10))
results = @book.fill_orders_with(buyBTC({name: 'acct3'}, 1, 10))
results.should.have.length(2)
sold = results.shift()
sold.should.succeed_with('o... | JavaScript | CoffeeScript | buttercoin/buttercoin | test/datastore/book_spec.coffee | MIT | 9132b62466965491ac27a0fd16328a4c2ac61eef | 663 | https://github.com/buttercoin/buttercoin/blob/9132b62466965491ac27a0fd16328a4c2ac61eef/test/datastore/book_spec.coffee | 54 | 103 |
buttercoin/buttercoin:test/datastore/book_spec.coffee:2:completion | completion | it 'should preserve the order in which orders are received', ->
@book.add_order(sellBTC(@account1, 1, 10))
@book.add_order(sellBTC(@account2, 1, 10))
results = @book.fill_orders_with(buyBTC({name: 'acct3'}, 1, 10))
results.should.have.length(2)
sold = results.shift()
sold.should.succeed_with('o... | it 'should be able to partially close an open order', ->
@book.add_order(sellBTC(@account1, 2, 2))
results = @book.fill_orders_with(buyBTC(@account2, 1, 1))
@book.store.is_empty().should.be.false
results.should.have.length(2)
bought = results.shift()
bought.should.succeed_with('order_partially_... | CoffeeScript | CoffeeScript | buttercoin/buttercoin | test/datastore/book_spec.coffee | MIT | 9132b62466965491ac27a0fd16328a4c2ac61eef | 663 | https://github.com/buttercoin/buttercoin/blob/9132b62466965491ac27a0fd16328a4c2ac61eef/test/datastore/book_spec.coffee | 54 | 103 |
buttercoin/buttercoin:test/datastore/book_spec.coffee:3:raw_corpus | raw_corpus | it 'should be able to partially fill a new order', ->
# TODO - sell must always be first!
@book.add_order(buyBTC(@account1, 1, 1))
results = @book.fill_orders_with(sellBTC(@account2, 3, 3))
results.should.have.length(2)
filled = results.shift()
filled.should.succeed_with('order_filled')
fill... | CoffeeScript | buttercoin/buttercoin | test/datastore/book_spec.coffee | MIT | 9132b62466965491ac27a0fd16328a4c2ac61eef | 663 | https://github.com/buttercoin/buttercoin/blob/9132b62466965491ac27a0fd16328a4c2ac61eef/test/datastore/book_spec.coffee | 104 | 153 | ||
buttercoin/buttercoin:test/datastore/book_spec.coffee:3:coffee_to_js | coffee_to_js | Convert this CoffeeScript to JavaScript.
```coffeescript
it 'should be able to partially fill a new order', ->
# TODO - sell must always be first!
@book.add_order(buyBTC(@account1, 1, 1))
results = @book.fill_orders_with(sellBTC(@account2, 3, 3))
results.should.have.length(2)
filled = results.shift(... | it('should be able to partially fill a new order', function() {
var filled, partial, results;
// TODO - sell must always be first!
this.book.add_order(buyBTC(this.account1, 1, 1));
results = this.book.fill_orders_with(sellBTC(this.account2, 3, 3));
results.should.have.length(2);
filled = results.shift();
... | CoffeeScript | JavaScript | buttercoin/buttercoin | test/datastore/book_spec.coffee | MIT | 9132b62466965491ac27a0fd16328a4c2ac61eef | 663 | https://github.com/buttercoin/buttercoin/blob/9132b62466965491ac27a0fd16328a4c2ac61eef/test/datastore/book_spec.coffee | 104 | 153 |
buttercoin/buttercoin:test/datastore/book_spec.coffee:3:js_to_coffee | js_to_coffee | Convert this JavaScript to CoffeeScript.
```javascript
it('should be able to partially fill a new order', function() {
var filled, partial, results;
// TODO - sell must always be first!
this.book.add_order(buyBTC(this.account1, 1, 1));
results = this.book.fill_orders_with(sellBTC(this.account2, 3, 3));
result... | it 'should be able to partially fill a new order', ->
# TODO - sell must always be first!
@book.add_order(buyBTC(@account1, 1, 1))
results = @book.fill_orders_with(sellBTC(@account2, 3, 3))
results.should.have.length(2)
filled = results.shift()
filled.should.succeed_with('order_filled')
fill... | JavaScript | CoffeeScript | buttercoin/buttercoin | test/datastore/book_spec.coffee | MIT | 9132b62466965491ac27a0fd16328a4c2ac61eef | 663 | https://github.com/buttercoin/buttercoin/blob/9132b62466965491ac27a0fd16328a4c2ac61eef/test/datastore/book_spec.coffee | 104 | 153 |
buttercoin/buttercoin:test/datastore/book_spec.coffee:3:completion | completion | it 'should be able to partially fill a new order', ->
# TODO - sell must always be first!
@book.add_order(buyBTC(@account1, 1, 1))
results = @book.fill_orders_with(sellBTC(@account2, 3, 3))
results.should.have.length(2)
filled = results.shift()
filled.should.succeed_with('order_filled')
fill... | order1 = sellBTC(@account1, 1, 10)
@book.add_order(order1)
results = @book.fill_orders_with(buyBTC(@account2, 1, 11))
results.should.have.length(2)
original = results.shift()
original.should.succeed_with('order_filled')
original.order.account.should.equal(@account1)
original.order.price.shou... | CoffeeScript | CoffeeScript | buttercoin/buttercoin | test/datastore/book_spec.coffee | MIT | 9132b62466965491ac27a0fd16328a4c2ac61eef | 663 | https://github.com/buttercoin/buttercoin/blob/9132b62466965491ac27a0fd16328a4c2ac61eef/test/datastore/book_spec.coffee | 104 | 153 |
buttercoin/buttercoin:test/datastore/book_spec.coffee:4:raw_corpus | raw_corpus | closed = results.shift()
closed.should.succeed_with('order_filled')
closed.order.price.should.equal(11)
closed = results.shift()
closed.should.succeed_with('order_filled')
closed.order.price.should.equal(12)
closed = results.shift()
closed.should.succeed_with('order_filled')
closed.ord... | CoffeeScript | buttercoin/buttercoin | test/datastore/book_spec.coffee | MIT | 9132b62466965491ac27a0fd16328a4c2ac61eef | 663 | https://github.com/buttercoin/buttercoin/blob/9132b62466965491ac27a0fd16328a4c2ac61eef/test/datastore/book_spec.coffee | 154 | 178 | ||
buttercoin/buttercoin:test/datastore/book_spec.coffee:4:completion | completion | closed = results.shift()
closed.should.succeed_with('order_filled')
closed.order.price.should.equal(11)
closed = results.shift()
closed.should.succeed_with('order_filled')
closed.order.price.should.equal(12)
closed = results.shift()
closed.should.succeed_with('order_filled')
closed.ord... | partial = results.shift()
partial.should.succeed_with('order_partially_filled')
partial.filled_order.price.should.equal(12)
partial.filled_order.received_amount.should.equal(3)
partial.filled_order.offered_amount.should.equal(12*3)
partial.residual_order.price.should.equal(1/buy_price)
partial.... | CoffeeScript | CoffeeScript | buttercoin/buttercoin | test/datastore/book_spec.coffee | MIT | 9132b62466965491ac27a0fd16328a4c2ac61eef | 663 | https://github.com/buttercoin/buttercoin/blob/9132b62466965491ac27a0fd16328a4c2ac61eef/test/datastore/book_spec.coffee | 154 | 178 |
buttercoin/buttercoin:test/datastore/book_spec.coffee:2:raw_corpus | raw_corpus | xit 'should preserve the order in which orders are received'
it 'should be able to match an order', ->
@book.add_order(sellBTC(@account1, 1, 10))
results = @book.fill_orders_with(buyBTC(@account2, 1, 10))
@book.store.is_empty().should.be.true
results.should.have.length(2)
sold = results.shift()
... | CoffeeScript | buttercoin/buttercoin | test/datastore/book_spec.coffee | MIT | ab9f53ec6f19813648ed1045d67cbceff6ca5ab9 | 663 | https://github.com/buttercoin/buttercoin/blob/ab9f53ec6f19813648ed1045d67cbceff6ca5ab9/test/datastore/book_spec.coffee | 54 | 103 | ||
buttercoin/buttercoin:test/datastore/book_spec.coffee:2:completion | completion | xit 'should preserve the order in which orders are received'
it 'should be able to match an order', ->
@book.add_order(sellBTC(@account1, 1, 10))
results = @book.fill_orders_with(buyBTC(@account2, 1, 10))
@book.store.is_empty().should.be.true
results.should.have.length(2)
sold = results.shift()
... | bought.original_order.account.should.equal(@account1)
bought.filled_order.account.should.equal(@account1)
bought.residual_order.account.should.equal(@account1)
sold = results.shift()
sold.should.succeed_with('order_filled')
sold.order.account.should.equal(@account2)
# TODO - move sum checks to... | CoffeeScript | CoffeeScript | buttercoin/buttercoin | test/datastore/book_spec.coffee | MIT | ab9f53ec6f19813648ed1045d67cbceff6ca5ab9 | 663 | https://github.com/buttercoin/buttercoin/blob/ab9f53ec6f19813648ed1045d67cbceff6ca5ab9/test/datastore/book_spec.coffee | 54 | 103 |
buttercoin/buttercoin:test/datastore/book_spec.coffee:3:raw_corpus | raw_corpus | filled.order.account.should.equal(@account1)
partial = results.shift()
partial.should.succeed_with('order_partially_filled')
partial.original_order.account.should.equal(@account2)
partial.filled_order.account.should.equal(@account2)
partial.residual_order.account.should.equal(@account2)
it 'shou... | CoffeeScript | buttercoin/buttercoin | test/datastore/book_spec.coffee | MIT | ab9f53ec6f19813648ed1045d67cbceff6ca5ab9 | 663 | https://github.com/buttercoin/buttercoin/blob/ab9f53ec6f19813648ed1045d67cbceff6ca5ab9/test/datastore/book_spec.coffee | 104 | 153 | ||
buttercoin/buttercoin:test/datastore/book_spec.coffee:3:completion | completion | filled.order.account.should.equal(@account1)
partial = results.shift()
partial.should.succeed_with('order_partially_filled')
partial.original_order.account.should.equal(@account2)
partial.filled_order.account.should.equal(@account2)
partial.residual_order.account.should.equal(@account2)
it 'shou... | filling = results.shift()
filling.should.succeed_with('order_filled')
filling.order.account.should.equal(@account2)
filling.order.price.should.equal(order1.price)
it 'should partially fill across price levels and provide a correct residual order', ->
@book.add_order(sellBTC(@account1, 1, 11))
@b... | CoffeeScript | CoffeeScript | buttercoin/buttercoin | test/datastore/book_spec.coffee | MIT | ab9f53ec6f19813648ed1045d67cbceff6ca5ab9 | 663 | https://github.com/buttercoin/buttercoin/blob/ab9f53ec6f19813648ed1045d67cbceff6ca5ab9/test/datastore/book_spec.coffee | 104 | 153 |
buttercoin/buttercoin:test/datastore/book_spec.coffee:4:raw_corpus | raw_corpus | closed = results.shift()
closed.should.succeed_with('order_filled')
closed.order.price.should.equal(13)
partial = results.shift()
partial.should.succeed_with('order_partially_filled')
partial.filled_order.price.should.equal(12)
partial.filled_order.received_amount.should.equal(3)
partial.fi... | CoffeeScript | buttercoin/buttercoin | test/datastore/book_spec.coffee | MIT | ab9f53ec6f19813648ed1045d67cbceff6ca5ab9 | 663 | https://github.com/buttercoin/buttercoin/blob/ab9f53ec6f19813648ed1045d67cbceff6ca5ab9/test/datastore/book_spec.coffee | 154 | 180 | ||
buttercoin/buttercoin:test/datastore/book_spec.coffee:4:completion | completion | closed = results.shift()
closed.should.succeed_with('order_filled')
closed.order.price.should.equal(13)
partial = results.shift()
partial.should.succeed_with('order_partially_filled')
partial.filled_order.price.should.equal(12)
partial.filled_order.received_amount.should.equal(3)
partial.fi... | xit 'should do the right thing', ->
#@book.add_order(buyBTC(@account1, 1, 10))
#@book.add_order(buyBTC(@account1, 1, 9))
#@book.add_order(buyBTC(@account1, 1, 8))
#logResults @book.fill_orders_with(sellBTC(@account2, 1, 7*4))
@book.add_order(sellBTC(@account1, 1, 11))
@book.add_order(sellBTC(@a... | CoffeeScript | CoffeeScript | buttercoin/buttercoin | test/datastore/book_spec.coffee | MIT | ab9f53ec6f19813648ed1045d67cbceff6ca5ab9 | 663 | https://github.com/buttercoin/buttercoin/blob/ab9f53ec6f19813648ed1045d67cbceff6ca5ab9/test/datastore/book_spec.coffee | 154 | 180 |
buttercoin/buttercoin:test/datastore/book_spec.coffee:3:raw_corpus | raw_corpus | Number::leq = (y) -> @ <= y
describe 'Book', ->
beforeEach ->
@book = new Book()
@account1 = {name: "acct1"}
@account2 = {name: "acct2"}
it 'should be able to add an order', ->
order = buyBTC(@account1, 1, 10)
@book.store.is_empty().should.be.true
result = @book.add_order(order)
@book.... | CoffeeScript | buttercoin/buttercoin | test/datastore/book_spec.coffee | MIT | 7d44e1767c19e62d821fd3b69e6a772fa3fb68c3 | 663 | https://github.com/buttercoin/buttercoin/blob/7d44e1767c19e62d821fd3b69e6a772fa3fb68c3/test/datastore/book_spec.coffee | 12 | 61 | ||
buttercoin/buttercoin:test/datastore/book_spec.coffee:3:coffee_to_js | coffee_to_js | Convert this CoffeeScript to JavaScript.
```coffeescript
Number::leq = (y) -> @ <= y
describe 'Book', ->
beforeEach ->
@book = new Book()
@account1 = {name: "acct1"}
@account2 = {name: "acct2"}
it 'should be able to add an order', ->
order = buyBTC(@account1, 1, 10)
@book.store.is_empty().shou... | Number.prototype.leq = function(y) {
return this <= y;
};
describe('Book', function() {
beforeEach(function() {
this.book = new Book();
this.account1 = {
name: "acct1"
};
return this.account2 = {
name: "acct2"
};
});
it('should be able to add an order', function() {
var orde... | CoffeeScript | JavaScript | buttercoin/buttercoin | test/datastore/book_spec.coffee | MIT | 7d44e1767c19e62d821fd3b69e6a772fa3fb68c3 | 663 | https://github.com/buttercoin/buttercoin/blob/7d44e1767c19e62d821fd3b69e6a772fa3fb68c3/test/datastore/book_spec.coffee | 12 | 61 |
buttercoin/buttercoin:test/datastore/book_spec.coffee:3:js_to_coffee | js_to_coffee | Convert this JavaScript to CoffeeScript.
```javascript
Number.prototype.leq = function(y) {
return this <= y;
};
describe('Book', function() {
beforeEach(function() {
this.book = new Book();
this.account1 = {
name: "acct1"
};
return this.account2 = {
name: "acct2"
};
});
it('sho... | Number::leq = (y) -> @ <= y
describe 'Book', ->
beforeEach ->
@book = new Book()
@account1 = {name: "acct1"}
@account2 = {name: "acct2"}
it 'should be able to add an order', ->
order = buyBTC(@account1, 1, 10)
@book.store.is_empty().should.be.true
result = @book.add_order(order)
@book.... | JavaScript | CoffeeScript | buttercoin/buttercoin | test/datastore/book_spec.coffee | MIT | 7d44e1767c19e62d821fd3b69e6a772fa3fb68c3 | 663 | https://github.com/buttercoin/buttercoin/blob/7d44e1767c19e62d821fd3b69e6a772fa3fb68c3/test/datastore/book_spec.coffee | 12 | 61 |
buttercoin/buttercoin:test/datastore/book_spec.coffee:3:completion | completion | Number::leq = (y) -> @ <= y
describe 'Book', ->
beforeEach ->
@book = new Book()
@account1 = {name: "acct1"}
@account2 = {name: "acct2"}
it 'should be able to add an order', ->
order = buyBTC(@account1, 1, 10)
@book.store.is_empty().should.be.true
result = @book.add_order(order)
@book.... | expectedBTC = [2, 1]
expectedUSD = [20, 11]
expectedLevels = [10, 11]
# TODO sizes and prices should be inverse of one another?
expectedSizes = [20, 11]
@book.store.forEach (order_level, price) ->
price.should.equal expectedLevels.shift()
order_level.size.should.equal expectedSizes.shift... | CoffeeScript | CoffeeScript | buttercoin/buttercoin | test/datastore/book_spec.coffee | MIT | 7d44e1767c19e62d821fd3b69e6a772fa3fb68c3 | 663 | https://github.com/buttercoin/buttercoin/blob/7d44e1767c19e62d821fd3b69e6a772fa3fb68c3/test/datastore/book_spec.coffee | 12 | 61 |
buttercoin/buttercoin:test/datastore/book_spec.coffee:4:raw_corpus | raw_corpus | xit 'should preserve the order in which orders are received'
it 'should be able to match an order', ->
@book.add_order(sellBTC(@account1, 1, 10))
results = @book.fill_orders_with(buyBTC(@account2, 1, 10))
@book.store.is_empty().should.be.true
results.should.have.length(2)
sold = results.shift()
... | CoffeeScript | buttercoin/buttercoin | test/datastore/book_spec.coffee | MIT | 7d44e1767c19e62d821fd3b69e6a772fa3fb68c3 | 663 | https://github.com/buttercoin/buttercoin/blob/7d44e1767c19e62d821fd3b69e6a772fa3fb68c3/test/datastore/book_spec.coffee | 62 | 111 | ||
buttercoin/buttercoin:test/datastore/book_spec.coffee:4:completion | completion | xit 'should preserve the order in which orders are received'
it 'should be able to match an order', ->
@book.add_order(sellBTC(@account1, 1, 10))
results = @book.fill_orders_with(buyBTC(@account2, 1, 10))
@book.store.is_empty().should.be.true
results.should.have.length(2)
sold = results.shift()
... | bought = results.shift()
bought.status.should.equal('success')
bought.kind.should.equal('order_partially_filled')
bought.original_order.account.should.equal(@account1)
bought.filled_order.account.should.equal(@account1)
bought.residual_order.account.should.equal(@account1)
sold = results.shift(... | CoffeeScript | CoffeeScript | buttercoin/buttercoin | test/datastore/book_spec.coffee | MIT | 7d44e1767c19e62d821fd3b69e6a772fa3fb68c3 | 663 | https://github.com/buttercoin/buttercoin/blob/7d44e1767c19e62d821fd3b69e6a772fa3fb68c3/test/datastore/book_spec.coffee | 62 | 111 |
buttercoin/buttercoin:test/datastore/book_spec.coffee:5:raw_corpus | raw_corpus | results.should.have.length(2)
filled = results.shift()
filled.status.should.equal('success')
filled.kind.should.equal('order_filled')
filled.order.account.should.equal(@account1)
partial = results.shift()
partial.status.should.equal('success')
partial.kind.should.equal('order_partially_fill... | CoffeeScript | buttercoin/buttercoin | test/datastore/book_spec.coffee | MIT | 7d44e1767c19e62d821fd3b69e6a772fa3fb68c3 | 663 | https://github.com/buttercoin/buttercoin/blob/7d44e1767c19e62d821fd3b69e6a772fa3fb68c3/test/datastore/book_spec.coffee | 112 | 132 | ||
buttercoin/buttercoin:test/datastore/book_spec.coffee:5:completion | completion | results.should.have.length(2)
filled = results.shift()
filled.status.should.equal('success')
filled.kind.should.equal('order_filled')
filled.order.account.should.equal(@account1)
partial = results.shift()
partial.status.should.equal('success')
partial.kind.should.equal('order_partially_fill... | partial.filled_order.account.should.equal(@account2)
partial.residual_order.account.should.equal(@account2)
it 'should indicate that there are not matches when orders don\'t overlap', ->
@book.add_order(buyBTC(@account1, 1, 20))
result = @book.fill_orders_with(sellBTC(@account2, 1, 40).clone(true))
#... | CoffeeScript | CoffeeScript | buttercoin/buttercoin | test/datastore/book_spec.coffee | MIT | 7d44e1767c19e62d821fd3b69e6a772fa3fb68c3 | 663 | https://github.com/buttercoin/buttercoin/blob/7d44e1767c19e62d821fd3b69e6a772fa3fb68c3/test/datastore/book_spec.coffee | 112 | 132 |
buttercoin/buttercoin:test/datastore/book_spec.coffee:3:raw_corpus | raw_corpus | Number::leq = (y) -> @ <= y
describe 'Book', ->
beforeEach ->
@book = new Book()
@account1 = {name: "acct1"}
@account2 = {name: "acct2"}
it 'should be able to add an order', ->
order = buyBTC(@account1, 1, 10)
@book.store.is_empty().should.be.true
result = @book.add_order(order)
@book.... | CoffeeScript | buttercoin/buttercoin | test/datastore/book_spec.coffee | MIT | 52561a472f9db748bb5ad7eeaceaf6ea2e1e26c7 | 663 | https://github.com/buttercoin/buttercoin/blob/52561a472f9db748bb5ad7eeaceaf6ea2e1e26c7/test/datastore/book_spec.coffee | 11 | 60 | ||
buttercoin/buttercoin:test/datastore/book_spec.coffee:3:coffee_to_js | coffee_to_js | Convert this CoffeeScript to JavaScript.
```coffeescript
Number::leq = (y) -> @ <= y
describe 'Book', ->
beforeEach ->
@book = new Book()
@account1 = {name: "acct1"}
@account2 = {name: "acct2"}
it 'should be able to add an order', ->
order = buyBTC(@account1, 1, 10)
@book.store.is_empty().shou... | Number.prototype.leq = function(y) {
return this <= y;
};
describe('Book', function() {
beforeEach(function() {
this.book = new Book();
this.account1 = {
name: "acct1"
};
return this.account2 = {
name: "acct2"
};
});
it('should be able to add an order', function() {
var orde... | CoffeeScript | JavaScript | buttercoin/buttercoin | test/datastore/book_spec.coffee | MIT | 52561a472f9db748bb5ad7eeaceaf6ea2e1e26c7 | 663 | https://github.com/buttercoin/buttercoin/blob/52561a472f9db748bb5ad7eeaceaf6ea2e1e26c7/test/datastore/book_spec.coffee | 11 | 60 |
buttercoin/buttercoin:test/datastore/book_spec.coffee:3:js_to_coffee | js_to_coffee | Convert this JavaScript to CoffeeScript.
```javascript
Number.prototype.leq = function(y) {
return this <= y;
};
describe('Book', function() {
beforeEach(function() {
this.book = new Book();
this.account1 = {
name: "acct1"
};
return this.account2 = {
name: "acct2"
};
});
it('sho... | Number::leq = (y) -> @ <= y
describe 'Book', ->
beforeEach ->
@book = new Book()
@account1 = {name: "acct1"}
@account2 = {name: "acct2"}
it 'should be able to add an order', ->
order = buyBTC(@account1, 1, 10)
@book.store.is_empty().should.be.true
result = @book.add_order(order)
@book.... | JavaScript | CoffeeScript | buttercoin/buttercoin | test/datastore/book_spec.coffee | MIT | 52561a472f9db748bb5ad7eeaceaf6ea2e1e26c7 | 663 | https://github.com/buttercoin/buttercoin/blob/52561a472f9db748bb5ad7eeaceaf6ea2e1e26c7/test/datastore/book_spec.coffee | 11 | 60 |
buttercoin/buttercoin:test/datastore/book_spec.coffee:3:completion | completion | Number::leq = (y) -> @ <= y
describe 'Book', ->
beforeEach ->
@book = new Book()
@account1 = {name: "acct1"}
@account2 = {name: "acct2"}
it 'should be able to add an order', ->
order = buyBTC(@account1, 1, 10)
@book.store.is_empty().should.be.true
result = @book.add_order(order)
@book.... | sold = results.shift()
sold.status.should.equal('success')
sold.kind.should.equal('order_filled')
sold.order.account.should.equal(@account1)
bought = results.shift()
bought.status.should.equal('success')
bought.kind.should.equal('order_filled')
bought.order.account.should.equal(@account2)
... | CoffeeScript | CoffeeScript | buttercoin/buttercoin | test/datastore/book_spec.coffee | MIT | 52561a472f9db748bb5ad7eeaceaf6ea2e1e26c7 | 663 | https://github.com/buttercoin/buttercoin/blob/52561a472f9db748bb5ad7eeaceaf6ea2e1e26c7/test/datastore/book_spec.coffee | 11 | 60 |
buttercoin/buttercoin:test/datastore/book_spec.coffee:4:raw_corpus | raw_corpus | sold.kind.should.equal('order_filled')
sold.order.account.should.equal(@account2)
# TODO - move sum checks to spec for Order.split
sum = bought.filled_order.offered_amount + bought.remaining_order.offered_amount
sum.should.equal(bought.original_order.offered_amount)
sum = bought.filled_order.recei... | CoffeeScript | buttercoin/buttercoin | test/datastore/book_spec.coffee | MIT | 52561a472f9db748bb5ad7eeaceaf6ea2e1e26c7 | 663 | https://github.com/buttercoin/buttercoin/blob/52561a472f9db748bb5ad7eeaceaf6ea2e1e26c7/test/datastore/book_spec.coffee | 61 | 97 | ||
buttercoin/buttercoin:test/datastore/book_spec.coffee:4:completion | completion | sold.kind.should.equal('order_filled')
sold.order.account.should.equal(@account2)
# TODO - move sum checks to spec for Order.split
sum = bought.filled_order.offered_amount + bought.remaining_order.offered_amount
sum.should.equal(bought.original_order.offered_amount)
sum = bought.filled_order.recei... | filled.status.should.equal('success')
filled.kind.should.equal('order_filled')
filled.order.account.should.equal(@account1)
partial = results.shift()
partial.status.should.equal('success')
partial.kind.should.equal('order_partially_filled')
partial.original_order.account.should.equal(@account2)... | CoffeeScript | CoffeeScript | buttercoin/buttercoin | test/datastore/book_spec.coffee | MIT | 52561a472f9db748bb5ad7eeaceaf6ea2e1e26c7 | 663 | https://github.com/buttercoin/buttercoin/blob/52561a472f9db748bb5ad7eeaceaf6ea2e1e26c7/test/datastore/book_spec.coffee | 61 | 97 |
buttercoin/buttercoin:test/datastore/book_spec.coffee:1:raw_corpus | raw_corpus | Book = require('../../lib/datastore/book')
Order = require('../../lib/datastore/order')
buyBTC = (acct, numBtc, numDollars) ->
new Order(acct, 'USD', numDollars, 'BTC', numBtc)
sellBTC = (acct, numBtc, numDollars) ->
new Order(acct, 'BTC', numBtc, 'USD', numDollars)
Number::leq = (y) -> @ <= y
describe 'Book',... | CoffeeScript | buttercoin/buttercoin | test/datastore/book_spec.coffee | MIT | beb154c59115d3cef9eb69901c4b6630725cde44 | 663 | https://github.com/buttercoin/buttercoin/blob/beb154c59115d3cef9eb69901c4b6630725cde44/test/datastore/book_spec.coffee | 1 | 50 | ||
buttercoin/buttercoin:test/datastore/book_spec.coffee:1:coffee_to_js | coffee_to_js | Convert this CoffeeScript to JavaScript.
```coffeescript
Book = require('../../lib/datastore/book')
Order = require('../../lib/datastore/order')
buyBTC = (acct, numBtc, numDollars) ->
new Order(acct, 'USD', numDollars, 'BTC', numBtc)
sellBTC = (acct, numBtc, numDollars) ->
new Order(acct, 'BTC', numBtc, 'USD', n... | var Book, Order, buyBTC, sellBTC;
Book = require('../../lib/datastore/book');
Order = require('../../lib/datastore/order');
buyBTC = function(acct, numBtc, numDollars) {
return new Order(acct, 'USD', numDollars, 'BTC', numBtc);
};
sellBTC = function(acct, numBtc, numDollars) {
return new Order(acct, 'BTC', numB... | CoffeeScript | JavaScript | buttercoin/buttercoin | test/datastore/book_spec.coffee | MIT | beb154c59115d3cef9eb69901c4b6630725cde44 | 663 | https://github.com/buttercoin/buttercoin/blob/beb154c59115d3cef9eb69901c4b6630725cde44/test/datastore/book_spec.coffee | 1 | 50 |
buttercoin/buttercoin:test/datastore/book_spec.coffee:1:js_to_coffee | js_to_coffee | Convert this JavaScript to CoffeeScript.
```javascript
var Book, Order, buyBTC, sellBTC;
Book = require('../../lib/datastore/book');
Order = require('../../lib/datastore/order');
buyBTC = function(acct, numBtc, numDollars) {
return new Order(acct, 'USD', numDollars, 'BTC', numBtc);
};
sellBTC = function(acct, num... | Book = require('../../lib/datastore/book')
Order = require('../../lib/datastore/order')
buyBTC = (acct, numBtc, numDollars) ->
new Order(acct, 'USD', numDollars, 'BTC', numBtc)
sellBTC = (acct, numBtc, numDollars) ->
new Order(acct, 'BTC', numBtc, 'USD', numDollars)
Number::leq = (y) -> @ <= y
describe 'Book',... | JavaScript | CoffeeScript | buttercoin/buttercoin | test/datastore/book_spec.coffee | MIT | beb154c59115d3cef9eb69901c4b6630725cde44 | 663 | https://github.com/buttercoin/buttercoin/blob/beb154c59115d3cef9eb69901c4b6630725cde44/test/datastore/book_spec.coffee | 1 | 50 |
buttercoin/buttercoin:test/datastore/book_spec.coffee:1:completion | completion | Book = require('../../lib/datastore/book')
Order = require('../../lib/datastore/order')
buyBTC = (acct, numBtc, numDollars) ->
new Order(acct, 'USD', numDollars, 'BTC', numBtc)
sellBTC = (acct, numBtc, numDollars) ->
new Order(acct, 'BTC', numBtc, 'USD', numDollars)
Number::leq = (y) -> @ <= y
describe 'Book',... | expect(result).to.exist
result.status.should.equal('success')
result.kind.should.equal('order_opened')
result.order.should.equal(order)
it 'should be able to match an order', ->
@book.add_order(sellBTC(@account1, 1, 1))
results = @book.fill_orders_with(buyBTC(@account2, 1, 1))
@book.store.is_... | CoffeeScript | CoffeeScript | buttercoin/buttercoin | test/datastore/book_spec.coffee | MIT | beb154c59115d3cef9eb69901c4b6630725cde44 | 663 | https://github.com/buttercoin/buttercoin/blob/beb154c59115d3cef9eb69901c4b6630725cde44/test/datastore/book_spec.coffee | 1 | 50 |
buttercoin/buttercoin:test/datastore/book_spec.coffee:1:raw_corpus | raw_corpus | Book = require('../../lib/datastore/book')
Order = require('../../lib/datastore/order')
buyBTC = (acct, numBtc, numDollars) ->
new Order(acct, 'USD', numDollars, 'BTC', numBtc)
sellBTC = (acct, numBtc, numDollars) ->
new Order(acct, 'BTC', numBtc, 'USD', numDollars)
Number::leq = (y) -> @ <= y
describe 'Book',... | CoffeeScript | buttercoin/buttercoin | test/datastore/book_spec.coffee | MIT | 6b8057bca2866e8ea9401136c336ef25f188c47c | 663 | https://github.com/buttercoin/buttercoin/blob/6b8057bca2866e8ea9401136c336ef25f188c47c/test/datastore/book_spec.coffee | 1 | 36 | ||
buttercoin/buttercoin:test/datastore/book_spec.coffee:1:coffee_to_js | coffee_to_js | Convert this CoffeeScript to JavaScript.
```coffeescript
Book = require('../../lib/datastore/book')
Order = require('../../lib/datastore/order')
buyBTC = (acct, numBtc, numDollars) ->
new Order(acct, 'USD', numDollars, 'BTC', numBtc)
sellBTC = (acct, numBtc, numDollars) ->
new Order(acct, 'BTC', numBtc, 'USD', n... | var Book, Order, buyBTC, sellBTC;
Book = require('../../lib/datastore/book');
Order = require('../../lib/datastore/order');
buyBTC = function(acct, numBtc, numDollars) {
return new Order(acct, 'USD', numDollars, 'BTC', numBtc);
};
sellBTC = function(acct, numBtc, numDollars) {
return new Order(acct, 'BTC', numB... | CoffeeScript | JavaScript | buttercoin/buttercoin | test/datastore/book_spec.coffee | MIT | 6b8057bca2866e8ea9401136c336ef25f188c47c | 663 | https://github.com/buttercoin/buttercoin/blob/6b8057bca2866e8ea9401136c336ef25f188c47c/test/datastore/book_spec.coffee | 1 | 36 |
buttercoin/buttercoin:test/datastore/book_spec.coffee:1:js_to_coffee | js_to_coffee | Convert this JavaScript to CoffeeScript.
```javascript
var Book, Order, buyBTC, sellBTC;
Book = require('../../lib/datastore/book');
Order = require('../../lib/datastore/order');
buyBTC = function(acct, numBtc, numDollars) {
return new Order(acct, 'USD', numDollars, 'BTC', numBtc);
};
sellBTC = function(acct, num... | Book = require('../../lib/datastore/book')
Order = require('../../lib/datastore/order')
buyBTC = (acct, numBtc, numDollars) ->
new Order(acct, 'USD', numDollars, 'BTC', numBtc)
sellBTC = (acct, numBtc, numDollars) ->
new Order(acct, 'BTC', numBtc, 'USD', numDollars)
Number::leq = (y) -> @ <= y
describe 'Book',... | JavaScript | CoffeeScript | buttercoin/buttercoin | test/datastore/book_spec.coffee | MIT | 6b8057bca2866e8ea9401136c336ef25f188c47c | 663 | https://github.com/buttercoin/buttercoin/blob/6b8057bca2866e8ea9401136c336ef25f188c47c/test/datastore/book_spec.coffee | 1 | 36 |
buttercoin/buttercoin:test/datastore/book_spec.coffee:1:completion | completion | Book = require('../../lib/datastore/book')
Order = require('../../lib/datastore/order')
buyBTC = (acct, numBtc, numDollars) ->
new Order(acct, 'USD', numDollars, 'BTC', numBtc)
sellBTC = (acct, numBtc, numDollars) ->
new Order(acct, 'BTC', numBtc, 'USD', numDollars)
Number::leq = (y) -> @ <= y
describe 'Book',... | it 'should be able to add an order', ->
order = buyBTC(@account1, 1, 1)
@book.store.is_empty().should.be.true
@book.add_order(order)
@book.store.is_empty().should.be.false
it 'should be able to match an order', ->
@book.add_order(sellBTC(@account1, 1, 1))
@book.fill_orders_with(buyBTC(@accoun... | CoffeeScript | CoffeeScript | buttercoin/buttercoin | test/datastore/book_spec.coffee | MIT | 6b8057bca2866e8ea9401136c336ef25f188c47c | 663 | https://github.com/buttercoin/buttercoin/blob/6b8057bca2866e8ea9401136c336ef25f188c47c/test/datastore/book_spec.coffee | 1 | 36 |
Atraci/Atraci:coffee/_sidebar.coffee:1:raw_corpus | raw_corpus | class Sidebar
constructor: ->
@sidebarContainer = $('#SideBar')
@contentWrapper = $('#ContentWrapper')
@topSidebar = @sidebarContainer.find('.top-sidebar ul')
@middleSidebar = @sidebarContainer.find('.middle-sidebar ul')
@bottomSidebar = @sidebarContainer.find('.bottom-sidebar ul')
@bindEvent... | CoffeeScript | Atraci/Atraci | coffee/_sidebar.coffee | MIT | 4368080dc0fd1729c8ba16cd155edcd23662fbc6 | 800 | https://github.com/Atraci/Atraci/blob/4368080dc0fd1729c8ba16cd155edcd23662fbc6/coffee/_sidebar.coffee | 2 | 51 | ||
Atraci/Atraci:coffee/_sidebar.coffee:1:completion | completion | class Sidebar
constructor: ->
@sidebarContainer = $('#SideBar')
@contentWrapper = $('#ContentWrapper')
@topSidebar = @sidebarContainer.find('.top-sidebar ul')
@middleSidebar = @sidebarContainer.find('.middle-sidebar ul')
@bottomSidebar = @sidebarContainer.find('.bottom-sidebar ul')
@bindEvent... | @sidebarContainer.on('click', 'li', ->
if !$(@).hasClass('no-page')
self.contentWrapper.empty()
spinner = new Spinner(spinner_opts).spin(self.contentWrapper[0])
if $(@).hasClass('top')
TrackSource.topTracks((tracks) ->
spinner.stop()
window.tracklist.populate(tra... | CoffeeScript | CoffeeScript | Atraci/Atraci | coffee/_sidebar.coffee | MIT | 4368080dc0fd1729c8ba16cd155edcd23662fbc6 | 800 | https://github.com/Atraci/Atraci/blob/4368080dc0fd1729c8ba16cd155edcd23662fbc6/coffee/_sidebar.coffee | 2 | 51 |
Atraci/Atraci:coffee/_sidebar.coffee:2:raw_corpus | raw_corpus | )
else if $(@).hasClass('featured-artist')
TrackSource.featuredArtist((artist)->
doSearch artist.value, true, (tracks) ->
window.tracklist.populate(tracks, artist)
spinner.stop()
)
else if $(@).hasClass('donations')
gui.Shell.openExternal(
... | CoffeeScript | Atraci/Atraci | coffee/_sidebar.coffee | MIT | 4368080dc0fd1729c8ba16cd155edcd23662fbc6 | 800 | https://github.com/Atraci/Atraci/blob/4368080dc0fd1729c8ba16cd155edcd23662fbc6/coffee/_sidebar.coffee | 52 | 101 | ||
Atraci/Atraci:coffee/_sidebar.coffee:2:completion | completion | )
else if $(@).hasClass('featured-artist')
TrackSource.featuredArtist((artist)->
doSearch artist.value, true, (tracks) ->
window.tracklist.populate(tracks, artist)
spinner.stop()
)
else if $(@).hasClass('donations')
gui.Shell.openExternal(
... | @bottomSidebar.on 'contextmenu', 'li.playlist', (e) ->
e.stopPropagation()
playlistName = $(@).text()
menu = new gui.Menu()
menu.append self._createDeleteMenuItem(playlistName)
menu.append self._createRenameMenuItem(playlistName)
menu.popup e.clientX, e.clientY
getActiveItem: ->
... | CoffeeScript | CoffeeScript | Atraci/Atraci | coffee/_sidebar.coffee | MIT | 4368080dc0fd1729c8ba16cd155edcd23662fbc6 | 800 | https://github.com/Atraci/Atraci/blob/4368080dc0fd1729c8ba16cd155edcd23662fbc6/coffee/_sidebar.coffee | 52 | 101 |
Atraci/Atraci:coffee/_sidebar.coffee:3:raw_corpus | raw_corpus | playlists = data.playlists
$.each playlists, (index, playlist) ->
# We have to insert them below 'featured Artist'
self.topSidebar.append(self._createFeaturedMusicItem(
id: playlist.id
name: playlist.name
))
).fail(->
console.log 'failed to fet... | CoffeeScript | Atraci/Atraci | coffee/_sidebar.coffee | MIT | 4368080dc0fd1729c8ba16cd155edcd23662fbc6 | 800 | https://github.com/Atraci/Atraci/blob/4368080dc0fd1729c8ba16cd155edcd23662fbc6/coffee/_sidebar.coffee | 102 | 151 | ||
Atraci/Atraci:coffee/_sidebar.coffee:3:completion | completion | playlists = data.playlists
$.each playlists, (index, playlist) ->
# We have to insert them below 'featured Artist'
self.topSidebar.append(self._createFeaturedMusicItem(
id: playlist.id
name: playlist.name
))
).fail(->
console.log 'failed to fet... | <li class='playlist' data-name='#{playlistName}'>#{playlistName}</li>
")
_reactivePlaylistItem: (activePlaylistName) ->
@sidebarContainer.find('ul li').filter( ->
$(@).text() == activePlaylistName
).addClass('active')
_createFeaturedMusicItem: (options) ->
playlistId = options.id
playlis... | CoffeeScript | CoffeeScript | Atraci/Atraci | coffee/_sidebar.coffee | MIT | 4368080dc0fd1729c8ba16cd155edcd23662fbc6 | 800 | https://github.com/Atraci/Atraci/blob/4368080dc0fd1729c8ba16cd155edcd23662fbc6/coffee/_sidebar.coffee | 102 | 151 |
Atraci/Atraci:coffee/_sidebar.coffee:4:raw_corpus | raw_corpus | if e
self.sidebarContainer.find(
'[data-name="' + playlistName + '"]').remove()
Playlists.delete(playlistName)
Playlists.getAll((playlists) ->
self.populatePlaylists(playlists)
)
userTracking.event("Playlist", "Delete", playlistName... | CoffeeScript | Atraci/Atraci | coffee/_sidebar.coffee | MIT | 4368080dc0fd1729c8ba16cd155edcd23662fbc6 | 800 | https://github.com/Atraci/Atraci/blob/4368080dc0fd1729c8ba16cd155edcd23662fbc6/coffee/_sidebar.coffee | 152 | 178 | ||
Atraci/Atraci:coffee/_sidebar.coffee:4:completion | completion | if e
self.sidebarContainer.find(
'[data-name="' + playlistName + '"]').remove()
Playlists.delete(playlistName)
Playlists.getAll((playlists) ->
self.populatePlaylists(playlists)
)
userTracking.event("Playlist", "Delete", playlistName... | label: 'Rename ' + $(@).text(),
click: ->
alertify.prompt l10n.get('rename_playlist_popup'), (e, newName) ->
if e && newName
newName = Utils.filterSymbols(newName)
Playlists.rename(oldPlaylistName, newName)
Playlists.getAll((playlists) ->
self.po... | CoffeeScript | CoffeeScript | Atraci/Atraci | coffee/_sidebar.coffee | MIT | 4368080dc0fd1729c8ba16cd155edcd23662fbc6 | 800 | https://github.com/Atraci/Atraci/blob/4368080dc0fd1729c8ba16cd155edcd23662fbc6/coffee/_sidebar.coffee | 152 | 178 |
Atraci/Atraci:coffee/_sidebar.coffee:1:raw_corpus | raw_corpus | populateSidebar = (playlists) ->
currentlyActive = $('#SideBar ul li.active').text()
$('#SideBar ul').empty()
$('#SideBar ul').append(
"
<li class='top'>
<i class='fa fa-music'></i>
<span data-l10n-id='top_track'>Top Tracks</span>
</li>
"
)
$('#SideBar ul').append(
"
... | CoffeeScript | Atraci/Atraci | coffee/_sidebar.coffee | MIT | b7c388a6e82adeb5864d31a7df6120375ab3f727 | 800 | https://github.com/Atraci/Atraci/blob/b7c388a6e82adeb5864d31a7df6120375ab3f727/coffee/_sidebar.coffee | 1 | 50 | ||
Atraci/Atraci:coffee/_sidebar.coffee:1:completion | completion | populateSidebar = (playlists) ->
currentlyActive = $('#SideBar ul li.active').text()
$('#SideBar ul').empty()
$('#SideBar ul').append(
"
<li class='top'>
<i class='fa fa-music'></i>
<span data-l10n-id='top_track'>Top Tracks</span>
</li>
"
)
$('#SideBar ul').append(
"
... | <hr>
</li>
"
)
$('#SideBar ul').append(
"
<li class='history'>
<i class='fa fa-history'></i>
<span data-l10n-id='history'>History</span>
</li>
"
)
$('#SideBar ul').append(
"
<li class='sep'>
<hr>
</li>
"
)
$('#SideBar ul').append(
... | CoffeeScript | CoffeeScript | Atraci/Atraci | coffee/_sidebar.coffee | MIT | b7c388a6e82adeb5864d31a7df6120375ab3f727 | 800 | https://github.com/Atraci/Atraci/blob/b7c388a6e82adeb5864d31a7df6120375ab3f727/coffee/_sidebar.coffee | 1 | 50 |
Atraci/Atraci:coffee/_sidebar.coffee:2:raw_corpus | raw_corpus | <span data-l10n-id='new_playlist'>New playlist</span>
</li>
"
)
for playlist in playlists
$('#SideBar ul').append(
"
<li class='playlist' data-name='#{playlist.name}'>#{playlist.name}</li>
"
)
# Re-active context after repopulating
$('#SideBar ul li').filter(->
$(@).t... | CoffeeScript | Atraci/Atraci | coffee/_sidebar.coffee | MIT | b7c388a6e82adeb5864d31a7df6120375ab3f727 | 800 | https://github.com/Atraci/Atraci/blob/b7c388a6e82adeb5864d31a7df6120375ab3f727/coffee/_sidebar.coffee | 51 | 100 | ||
Atraci/Atraci:coffee/_sidebar.coffee:2:completion | completion | <span data-l10n-id='new_playlist'>New playlist</span>
</li>
"
)
for playlist in playlists
$('#SideBar ul').append(
"
<li class='playlist' data-name='#{playlist.name}'>#{playlist.name}</li>
"
)
# Re-active context after repopulating
$('#SideBar ul li').filter(->
$(@).t... | "
<li class='featured-music' data-id='#{playlist.id}'>
<i class='fa fa-music'></i>
<span>#{playlist.name}</span>
</li>
"
)
).fail(->
console.log 'failed to fetch ' + country + '.json'
)
)
$ ->
$('#SideBar').on(
'click',
'li.history... | CoffeeScript | CoffeeScript | Atraci/Atraci | coffee/_sidebar.coffee | MIT | b7c388a6e82adeb5864d31a7df6120375ab3f727 | 800 | https://github.com/Atraci/Atraci/blob/b7c388a6e82adeb5864d31a7df6120375ab3f727/coffee/_sidebar.coffee | 51 | 100 |
Atraci/Atraci:coffee/_sidebar.coffee:3:raw_corpus | raw_corpus | spinner.stop()
PopulateTrackList(tracks)
)
else if $(@).hasClass('history')
TrackSource.history((tracks) ->
spinner.stop()
PopulateTrackList(tracks)
)
else if $(@).hasClass('playlist')
TrackSource.playlist($(@).text(), ((tracks) ->
spinner.stop()
P... | CoffeeScript | Atraci/Atraci | coffee/_sidebar.coffee | MIT | b7c388a6e82adeb5864d31a7df6120375ab3f727 | 800 | https://github.com/Atraci/Atraci/blob/b7c388a6e82adeb5864d31a7df6120375ab3f727/coffee/_sidebar.coffee | 101 | 150 | ||
Atraci/Atraci:coffee/_sidebar.coffee:3:completion | completion | spinner.stop()
PopulateTrackList(tracks)
)
else if $(@).hasClass('history')
TrackSource.history((tracks) ->
spinner.stop()
PopulateTrackList(tracks)
)
else if $(@).hasClass('playlist')
TrackSource.playlist($(@).text(), ((tracks) ->
spinner.stop()
P... | if !e
return
else
Playlists.create(str)
Playlists.getAll((playlists) ->
populateSidebar(playlists)
)
userTracking.event("Playlist", "Create", str).send()
$('#SideBar ul').on 'contextmenu', 'li.playlist', (e) ->
playlist_name = $(@).text()
e.stopPropagat... | CoffeeScript | CoffeeScript | Atraci/Atraci | coffee/_sidebar.coffee | MIT | b7c388a6e82adeb5864d31a7df6120375ab3f727 | 800 | https://github.com/Atraci/Atraci/blob/b7c388a6e82adeb5864d31a7df6120375ab3f727/coffee/_sidebar.coffee | 101 | 150 |
Atraci/Atraci:coffee/_sidebar.coffee:4:raw_corpus | raw_corpus | menu.append new gui.MenuItem(
label: 'Rename ' + $(@).text(),
click: ->
alertify.prompt l10n.get('rename_playlist_popup'), (e, str) ->
if e && str
Playlists.rename(playlist_name, str)
Playlists.getAll((playlists) ->
populateSidebar(playlists)
... | CoffeeScript | Atraci/Atraci | coffee/_sidebar.coffee | MIT | b7c388a6e82adeb5864d31a7df6120375ab3f727 | 800 | https://github.com/Atraci/Atraci/blob/b7c388a6e82adeb5864d31a7df6120375ab3f727/coffee/_sidebar.coffee | 151 | 168 | ||
Atraci/Atraci:coffee/_sidebar.coffee:4:completion | completion | menu.append new gui.MenuItem(
label: 'Rename ' + $(@).text(),
click: ->
alertify.prompt l10n.get('rename_playlist_popup'), (e, str) ->
if e && str
Playlists.rename(playlist_name, str)
Playlists.getAll((playlists) ->
populateSidebar(playlists) | )
userTracking.event("Playlist", "Rename", str).send()
else
return
, playlist_name
)
menu.popup e.clientX, e.clientY
false | CoffeeScript | CoffeeScript | Atraci/Atraci | coffee/_sidebar.coffee | MIT | b7c388a6e82adeb5864d31a7df6120375ab3f727 | 800 | https://github.com/Atraci/Atraci/blob/b7c388a6e82adeb5864d31a7df6120375ab3f727/coffee/_sidebar.coffee | 151 | 168 |
Atraci/Atraci:coffee/_sidebar.coffee:5:raw_corpus | raw_corpus | loadFeaturedArtistPage = (callback) ->
$.getJSON("http://getatraci.net/featured.json", (artistObject) ->
doSearch artistObject.value, true, (tracks) ->
PopulateTrackList(tracks, artistObject)
callback()
)
true | CoffeeScript | Atraci/Atraci | coffee/_sidebar.coffee | MIT | b7c388a6e82adeb5864d31a7df6120375ab3f727 | 800 | https://github.com/Atraci/Atraci/blob/b7c388a6e82adeb5864d31a7df6120375ab3f727/coffee/_sidebar.coffee | 170 | 176 | ||
Atraci/Atraci:coffee/_sidebar.coffee:5:coffee_to_js | coffee_to_js | Convert this CoffeeScript to JavaScript.
```coffeescript
loadFeaturedArtistPage = (callback) ->
$.getJSON("http://getatraci.net/featured.json", (artistObject) ->
doSearch artistObject.value, true, (tracks) ->
PopulateTrackList(tracks, artistObject)
callback()
)
true
``` | var loadFeaturedArtistPage;
loadFeaturedArtistPage = function(callback) {
$.getJSON("http://getatraci.net/featured.json", function(artistObject) {
return doSearch(artistObject.value, true, function(tracks) {
PopulateTrackList(tracks, artistObject);
return callback();
});
});
return true;
}; | CoffeeScript | JavaScript | Atraci/Atraci | coffee/_sidebar.coffee | MIT | b7c388a6e82adeb5864d31a7df6120375ab3f727 | 800 | https://github.com/Atraci/Atraci/blob/b7c388a6e82adeb5864d31a7df6120375ab3f727/coffee/_sidebar.coffee | 170 | 176 |
Atraci/Atraci:coffee/_sidebar.coffee:5:js_to_coffee | js_to_coffee | Convert this JavaScript to CoffeeScript.
```javascript
var loadFeaturedArtistPage;
loadFeaturedArtistPage = function(callback) {
$.getJSON("http://getatraci.net/featured.json", function(artistObject) {
return doSearch(artistObject.value, true, function(tracks) {
PopulateTrackList(tracks, artistObject);
... | loadFeaturedArtistPage = (callback) ->
$.getJSON("http://getatraci.net/featured.json", (artistObject) ->
doSearch artistObject.value, true, (tracks) ->
PopulateTrackList(tracks, artistObject)
callback()
)
true | JavaScript | CoffeeScript | Atraci/Atraci | coffee/_sidebar.coffee | MIT | b7c388a6e82adeb5864d31a7df6120375ab3f727 | 800 | https://github.com/Atraci/Atraci/blob/b7c388a6e82adeb5864d31a7df6120375ab3f727/coffee/_sidebar.coffee | 170 | 176 |
Atraci/Atraci:coffee/_sidebar.coffee:2:raw_corpus | raw_corpus | <span data-l10n-id='new_playlist'>New playlist</span>
</li>
"
)
for playlist in playlists
$('#SideBar ul').append(
"
<li class='playlist' data-name='#{playlist.name}'>#{playlist.name}</li>
"
)
# Re-active context after repopulating
$('#SideBar ul li').filter(->
$(@).t... | CoffeeScript | Atraci/Atraci | coffee/_sidebar.coffee | MIT | 3531cba4082c000e4efafbbc6c0905d33485811c | 800 | https://github.com/Atraci/Atraci/blob/3531cba4082c000e4efafbbc6c0905d33485811c/coffee/_sidebar.coffee | 51 | 100 | ||
Atraci/Atraci:coffee/_sidebar.coffee:2:completion | completion | <span data-l10n-id='new_playlist'>New playlist</span>
</li>
"
)
for playlist in playlists
$('#SideBar ul').append(
"
<li class='playlist' data-name='#{playlist.name}'>#{playlist.name}</li>
"
)
# Re-active context after repopulating
$('#SideBar ul li').filter(->
$(@).t... | "
<li class='featured-music' data-id='#{playlist.id}'>
<i class='fa fa-music'></i>
<span>#{playlist.name}</span>
</li>
"
)
).fail(->
console.log 'failed to fetch ' + country + '.json'
)
)
$ ->
$('#SideBar').on(
'click',
'li.history... | CoffeeScript | CoffeeScript | Atraci/Atraci | coffee/_sidebar.coffee | MIT | 3531cba4082c000e4efafbbc6c0905d33485811c | 800 | https://github.com/Atraci/Atraci/blob/3531cba4082c000e4efafbbc6c0905d33485811c/coffee/_sidebar.coffee | 51 | 100 |
Atraci/Atraci:coffee/_sidebar.coffee:2:raw_corpus | raw_corpus | <span data-l10n-id='new_playlist'>New playlist</span>
</li>
"
)
for playlist in playlists
$('#SideBar ul').append(
"
<li class='playlist' data-name='#{playlist.name}'>#{playlist.name}</li>
"
)
# Re-active context after repopulating
$('#SideBar ul li').filter(->
$(@).t... | CoffeeScript | Atraci/Atraci | coffee/_sidebar.coffee | MIT | 711494b66ceb9d2a3ede3d50a538c46c1d8d9db3 | 800 | https://github.com/Atraci/Atraci/blob/711494b66ceb9d2a3ede3d50a538c46c1d8d9db3/coffee/_sidebar.coffee | 51 | 100 | ||
Atraci/Atraci:coffee/_sidebar.coffee:2:completion | completion | <span data-l10n-id='new_playlist'>New playlist</span>
</li>
"
)
for playlist in playlists
$('#SideBar ul').append(
"
<li class='playlist' data-name='#{playlist.name}'>#{playlist.name}</li>
"
)
# Re-active context after repopulating
$('#SideBar ul li').filter(->
$(@).t... | $('#SideBar ul li:eq(1)').after(
"
<li class='featured-music' data-id='#{playlist.id}'>
<i class='fa fa-music'></i>
<span>#{playlist.name}</span>
</li>
"
)
).fail(->
console.log 'failed to fetch ' + countryCode + '.json'
)
)
$ ->
... | CoffeeScript | CoffeeScript | Atraci/Atraci | coffee/_sidebar.coffee | MIT | 711494b66ceb9d2a3ede3d50a538c46c1d8d9db3 | 800 | https://github.com/Atraci/Atraci/blob/711494b66ceb9d2a3ede3d50a538c46c1d8d9db3/coffee/_sidebar.coffee | 51 | 100 |
Atraci/Atraci:coffee/_sidebar.coffee:3:raw_corpus | raw_corpus | TrackSource.topTracks((tracks) ->
spinner.stop()
PopulateTrackList(tracks)
)
else if $(@).hasClass('history')
TrackSource.history((tracks) ->
spinner.stop()
PopulateTrackList(tracks)
)
else if $(@).hasClass('playlist')
TrackSource.playlist($(@).text(), ((t... | CoffeeScript | Atraci/Atraci | coffee/_sidebar.coffee | MIT | 711494b66ceb9d2a3ede3d50a538c46c1d8d9db3 | 800 | https://github.com/Atraci/Atraci/blob/711494b66ceb9d2a3ede3d50a538c46c1d8d9db3/coffee/_sidebar.coffee | 101 | 150 | ||
Atraci/Atraci:coffee/_sidebar.coffee:3:completion | completion | TrackSource.topTracks((tracks) ->
spinner.stop()
PopulateTrackList(tracks)
)
else if $(@).hasClass('history')
TrackSource.history((tracks) ->
spinner.stop()
PopulateTrackList(tracks)
)
else if $(@).hasClass('playlist')
TrackSource.playlist($(@).text(), ((t... | alertify.prompt l10n.get('create_playlist_popup'), (e, str) ->
if !e
return
else
Playlists.create(str)
Playlists.getAll((playlists) ->
populateSidebar(playlists)
)
userTracking.event("Playlist", "Create", str).send()
$('#SideBar ul').on 'contextmenu', 'li... | CoffeeScript | CoffeeScript | Atraci/Atraci | coffee/_sidebar.coffee | MIT | 711494b66ceb9d2a3ede3d50a538c46c1d8d9db3 | 800 | https://github.com/Atraci/Atraci/blob/711494b66ceb9d2a3ede3d50a538c46c1d8d9db3/coffee/_sidebar.coffee | 101 | 150 |
Atraci/Atraci:coffee/_sidebar.coffee:4:raw_corpus | raw_corpus | )
menu.append new gui.MenuItem(
label: 'Rename ' + $(@).text(),
click: ->
alertify.prompt l10n.get('rename_playlist_popup'), (e, str) ->
if e && str
Playlists.rename(playlist_name, str)
Playlists.getAll((playlists) ->
populateSidebar(playlists)
... | CoffeeScript | Atraci/Atraci | coffee/_sidebar.coffee | MIT | 711494b66ceb9d2a3ede3d50a538c46c1d8d9db3 | 800 | https://github.com/Atraci/Atraci/blob/711494b66ceb9d2a3ede3d50a538c46c1d8d9db3/coffee/_sidebar.coffee | 151 | 169 | ||
Atraci/Atraci:coffee/_sidebar.coffee:4:completion | completion | )
menu.append new gui.MenuItem(
label: 'Rename ' + $(@).text(),
click: ->
alertify.prompt l10n.get('rename_playlist_popup'), (e, str) ->
if e && str
Playlists.rename(playlist_name, str)
Playlists.getAll((playlists) -> | populateSidebar(playlists)
)
userTracking.event("Playlist", "Rename", str).send()
else
return
, playlist_name
)
menu.popup e.clientX, e.clientY
false | CoffeeScript | CoffeeScript | Atraci/Atraci | coffee/_sidebar.coffee | MIT | 711494b66ceb9d2a3ede3d50a538c46c1d8d9db3 | 800 | https://github.com/Atraci/Atraci/blob/711494b66ceb9d2a3ede3d50a538c46c1d8d9db3/coffee/_sidebar.coffee | 151 | 169 |
Atraci/Atraci:coffee/_sidebar.coffee:1:raw_corpus | raw_corpus | populateSidebar = (playlists) ->
currentlyActive = $('#SideBar ul li.active').text()
$('#SideBar ul').empty()
$('#SideBar ul').append(
"
<li class='top'>
<i class='fa fa-music'></i>
<span data-l10n-id='top_track'>Top Tracks</span>
</li>
"
)
$('#SideBar ul').append(
"
... | CoffeeScript | Atraci/Atraci | coffee/_sidebar.coffee | MIT | a4e3a69e284a1ef05051d95c0dc9bbb90c15b74f | 800 | https://github.com/Atraci/Atraci/blob/a4e3a69e284a1ef05051d95c0dc9bbb90c15b74f/coffee/_sidebar.coffee | 1 | 50 | ||
Atraci/Atraci:coffee/_sidebar.coffee:1:completion | completion | populateSidebar = (playlists) ->
currentlyActive = $('#SideBar ul li.active').text()
$('#SideBar ul').empty()
$('#SideBar ul').append(
"
<li class='top'>
<i class='fa fa-music'></i>
<span data-l10n-id='top_track'>Top Tracks</span>
</li>
"
)
$('#SideBar ul').append(
"
... | <hr>
</li>
"
)
$('#SideBar ul').append(
"
<li class='history'>
<i class='fa fa-history'></i>
<span data-l10n-id='history'>History</span>
</li>
"
)
$('#SideBar ul').append(
"
<li class='sep'>
<hr>
</li>
"
)
$('#SideBar ul').append(
... | CoffeeScript | CoffeeScript | Atraci/Atraci | coffee/_sidebar.coffee | MIT | a4e3a69e284a1ef05051d95c0dc9bbb90c15b74f | 800 | https://github.com/Atraci/Atraci/blob/a4e3a69e284a1ef05051d95c0dc9bbb90c15b74f/coffee/_sidebar.coffee | 1 | 50 |
Atraci/Atraci:coffee/_sidebar.coffee:2:raw_corpus | raw_corpus | <span data-l10n-id='new_playlist'>New playlist</span>
</li>
"
)
for playlist in playlists
$('#SideBar ul').append(
"
<li class='playlist' data-name='#{playlist.name}'>#{playlist.name}</li>
"
)
# Re-active context after repopulating
$('#SideBar ul li').filter(->
$(@).t... | CoffeeScript | Atraci/Atraci | coffee/_sidebar.coffee | MIT | a4e3a69e284a1ef05051d95c0dc9bbb90c15b74f | 800 | https://github.com/Atraci/Atraci/blob/a4e3a69e284a1ef05051d95c0dc9bbb90c15b74f/coffee/_sidebar.coffee | 51 | 100 | ||
Atraci/Atraci:coffee/_sidebar.coffee:2:completion | completion | <span data-l10n-id='new_playlist'>New playlist</span>
</li>
"
)
for playlist in playlists
$('#SideBar ul').append(
"
<li class='playlist' data-name='#{playlist.name}'>#{playlist.name}</li>
"
)
# Re-active context after repopulating
$('#SideBar ul li').filter(->
$(@).t... | spinner = new Spinner(spinner_opts).spin($('#ContentWrapper')[0])
TrackSource.topTracks((tracks) ->
spinner.stop()
PopulateTrackList(tracks)
)
else if $(@).hasClass('history')
TrackSource.history((tracks) ->
PopulateTrackList(tracks)
)
else if $(@).hasClass('playl... | CoffeeScript | CoffeeScript | Atraci/Atraci | coffee/_sidebar.coffee | MIT | a4e3a69e284a1ef05051d95c0dc9bbb90c15b74f | 800 | https://github.com/Atraci/Atraci/blob/a4e3a69e284a1ef05051d95c0dc9bbb90c15b74f/coffee/_sidebar.coffee | 51 | 100 |
Atraci/Atraci:coffee/_sidebar.coffee:3:raw_corpus | raw_corpus | userTracking.event("Playlist", "Create", str).send()
$('#SideBar ul').on 'contextmenu', 'li.playlist', (e) ->
playlist_name = $(@).text()
e.stopPropagation()
menu = new gui.Menu()
menu.append new gui.MenuItem(
label: 'Delete ' + $(@).text(),
click: ->
alertify.confirm l10n.get('de... | CoffeeScript | Atraci/Atraci | coffee/_sidebar.coffee | MIT | a4e3a69e284a1ef05051d95c0dc9bbb90c15b74f | 800 | https://github.com/Atraci/Atraci/blob/a4e3a69e284a1ef05051d95c0dc9bbb90c15b74f/coffee/_sidebar.coffee | 101 | 136 | ||
Atraci/Atraci:coffee/_sidebar.coffee:3:completion | completion | userTracking.event("Playlist", "Create", str).send()
$('#SideBar ul').on 'contextmenu', 'li.playlist', (e) ->
playlist_name = $(@).text()
e.stopPropagation()
menu = new gui.Menu()
menu.append new gui.MenuItem(
label: 'Delete ' + $(@).text(),
click: ->
alertify.confirm l10n.get('de... | menu.append new gui.MenuItem(
label: 'Rename ' + $(@).text(),
click: ->
alertify.prompt l10n.get('rename_playlist_popup'), (e, str) ->
if e && str
Playlists.rename(playlist_name, str)
Playlists.getAll((playlists) ->
populateSidebar(playlists)
... | CoffeeScript | CoffeeScript | Atraci/Atraci | coffee/_sidebar.coffee | MIT | a4e3a69e284a1ef05051d95c0dc9bbb90c15b74f | 800 | https://github.com/Atraci/Atraci/blob/a4e3a69e284a1ef05051d95c0dc9bbb90c15b74f/coffee/_sidebar.coffee | 101 | 136 |
Atraci/Atraci:coffee/_sidebar.coffee:4:raw_corpus | raw_corpus | loadFeaturedArtistPage = ->
$.getJSON("http://getatraci.net/featured.json", (artistObject) ->
doSearch artistObject.value, true, (tracks) ->
PopulateTrackList(tracks, artistObject)
)
true | CoffeeScript | Atraci/Atraci | coffee/_sidebar.coffee | MIT | a4e3a69e284a1ef05051d95c0dc9bbb90c15b74f | 800 | https://github.com/Atraci/Atraci/blob/a4e3a69e284a1ef05051d95c0dc9bbb90c15b74f/coffee/_sidebar.coffee | 138 | 143 | ||
Atraci/Atraci:coffee/_sidebar.coffee:4:coffee_to_js | coffee_to_js | Convert this CoffeeScript to JavaScript.
```coffeescript
loadFeaturedArtistPage = ->
$.getJSON("http://getatraci.net/featured.json", (artistObject) ->
doSearch artistObject.value, true, (tracks) ->
PopulateTrackList(tracks, artistObject)
)
true
``` | var loadFeaturedArtistPage;
loadFeaturedArtistPage = function() {
$.getJSON("http://getatraci.net/featured.json", function(artistObject) {
return doSearch(artistObject.value, true, function(tracks) {
return PopulateTrackList(tracks, artistObject);
});
});
return true;
}; | CoffeeScript | JavaScript | Atraci/Atraci | coffee/_sidebar.coffee | MIT | a4e3a69e284a1ef05051d95c0dc9bbb90c15b74f | 800 | https://github.com/Atraci/Atraci/blob/a4e3a69e284a1ef05051d95c0dc9bbb90c15b74f/coffee/_sidebar.coffee | 138 | 143 |
Atraci/Atraci:coffee/_sidebar.coffee:4:js_to_coffee | js_to_coffee | Convert this JavaScript to CoffeeScript.
```javascript
var loadFeaturedArtistPage;
loadFeaturedArtistPage = function() {
$.getJSON("http://getatraci.net/featured.json", function(artistObject) {
return doSearch(artistObject.value, true, function(tracks) {
return PopulateTrackList(tracks, artistObject);
... | loadFeaturedArtistPage = ->
$.getJSON("http://getatraci.net/featured.json", (artistObject) ->
doSearch artistObject.value, true, (tracks) ->
PopulateTrackList(tracks, artistObject)
)
true | JavaScript | CoffeeScript | Atraci/Atraci | coffee/_sidebar.coffee | MIT | a4e3a69e284a1ef05051d95c0dc9bbb90c15b74f | 800 | https://github.com/Atraci/Atraci/blob/a4e3a69e284a1ef05051d95c0dc9bbb90c15b74f/coffee/_sidebar.coffee | 138 | 143 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.