NickIBrody/coffeescript-code-suite
CoffeeScript Code Suite CoffeeScript Code Suite is a public code dataset built from permissively licensed open-source CoffeeScript repositories. It is designed for three practical uses: CoffeeScript domain adaptation and continued pretraining through raw_corpus examples. CoffeeScript completion training through completion examples. CoffeeScript and JavaScript translation training through coffee_to_js and js_to_coffee examples. The dataset was assembled automatically from… See the full description on the dataset page: https://huggingface.co/datasets/NickIBrody/coffeescript-code-suite.
054
1{"id": "Atraci/Atraci:coffee/-Settings.class.coffee:1:raw_corpus", "type": "raw_corpus", "prompt": "", "response": "Settings =\n get: (variable) ->\n localStorage['settings_' + variable]\n set: (variable, newValue) ->\n localStorage.setItem 'settings_' + variable, newValue\n\n init: ->\n @set('updateUrl', 'http://getatraci.net/update.json') if not @get('updateUrl')\n\n\nSettings.init()", "source_lang": "", "target_lang": "CoffeeScript", "repo": "Atraci/Atraci", "path": "coffee/-Settings.class.coffee", "license": "MIT", "commit": "d4b7f952575352efeff69f232ab345bac48fe586", "stars": 800, "source_url": "https://github.com/Atraci/Atraci/blob/d4b7f952575352efeff69f232ab345bac48fe586/coffee/-Settings.class.coffee", "line_start": 1, "line_end": 11}2{"id": "Atraci/Atraci:coffee/-Settings.class.coffee:1:coffee_to_js", "type": "coffee_to_js", "prompt": "Convert this CoffeeScript to JavaScript.\n```coffeescript\nSettings =\n get: (variable) ->\n localStorage['settings_' + variable]\n set: (variable, newValue) ->\n localStorage.setItem 'settings_' + variable, newValue\n\n init: ->\n @set('updateUrl', 'http://getatraci.net/update.json') if not @get('updateUrl')\n\n\nSettings.init()\n```", "response": "var Settings;\n\nSettings = {\n get: function(variable) {\n return localStorage['settings_' + variable];\n },\n set: function(variable, newValue) {\n return localStorage.setItem('settings_' + variable, newValue);\n },\n init: function() {\n if (!this.get('updateUrl')) {\n return this.set('updateUrl', 'http://getatraci.net/update.json');\n }\n }\n};\n\nSettings.init();", "source_lang": "CoffeeScript", "target_lang": "JavaScript", "repo": "Atraci/Atraci", "path": "coffee/-Settings.class.coffee", "license": "MIT", "commit": "d4b7f952575352efeff69f232ab345bac48fe586", "stars": 800, "source_url": "https://github.com/Atraci/Atraci/blob/d4b7f952575352efeff69f232ab345bac48fe586/coffee/-Settings.class.coffee", "line_start": 1, "line_end": 11}3{"id": "Atraci/Atraci:coffee/-Settings.class.coffee:1:js_to_coffee", "type": "js_to_coffee", "prompt": "Convert this JavaScript to CoffeeScript.\n```javascript\nvar Settings;\n\nSettings = {\n get: function(variable) {\n return localStorage['settings_' + variable];\n },\n set: function(variable, newValue) {\n return localStorage.setItem('settings_' + variable, newValue);\n },\n init: function() {\n if (!this.get('updateUrl')) {\n return this.set('updateUrl', 'http://getatraci.net/update.json');\n }\n }\n};\n\nSettings.init();\n```", "response": "Settings =\n get: (variable) ->\n localStorage['settings_' + variable]\n set: (variable, newValue) ->\n localStorage.setItem 'settings_' + variable, newValue\n\n init: ->\n @set('updateUrl', 'http://getatraci.net/update.json') if not @get('updateUrl')\n\n\nSettings.init()", "source_lang": "JavaScript", "target_lang": "CoffeeScript", "repo": "Atraci/Atraci", "path": "coffee/-Settings.class.coffee", "license": "MIT", "commit": "d4b7f952575352efeff69f232ab345bac48fe586", "stars": 800, "source_url": "https://github.com/Atraci/Atraci/blob/d4b7f952575352efeff69f232ab345bac48fe586/coffee/-Settings.class.coffee", "line_start": 1, "line_end": 11}4{"id": "Atraci/Atraci:coffee/-Settings.class.coffee:1:completion", "type": "completion", "prompt": "Settings =\n get: (variable) ->\n localStorage['settings_' + variable]\n set: (variable, newValue) ->\n localStorage.setItem 'settings_' + variable, newValue", "response": "init: ->\n @set('updateUrl', 'http://getatraci.net/update.json') if not @get('updateUrl')\n\n\nSettings.init()", "source_lang": "CoffeeScript", "target_lang": "CoffeeScript", "repo": "Atraci/Atraci", "path": "coffee/-Settings.class.coffee", "license": "MIT", "commit": "d4b7f952575352efeff69f232ab345bac48fe586", "stars": 800, "source_url": "https://github.com/Atraci/Atraci/blob/d4b7f952575352efeff69f232ab345bac48fe586/coffee/-Settings.class.coffee", "line_start": 1, "line_end": 11}5{"id": "buttercoin/buttercoin:test/datastore/order_spec.coffee:1:raw_corpus", "type": "raw_corpus", "prompt": "", "response": "Order = require('../../lib/datastore/order')\n\ndescribe 'Order', ->\n beforeEach ->\n @account = {}\n @order = new Order({}, 'USD', 1, 'BTC', 10)\n\n it 'should be clonable', ->\n @order.clone.should.exist\n order2 = @order.clone()\n\n order2.account.should.equal(@order.account)\n @order.account = null\n order2.account.should.not.equal(@order.account)\n\n order2.offered_currency.should.equal(@order.offered_currency)\n @order.offered_currency = null\n order2.offered_currency.should.not.equal(@order.offered_currency)\n\n order2.offered_amount.should.equal(@order.offered_amount)\n @order.offered_amount = null\n order2.offered_amount.should.not.equal(@order.offered_amount)\n\n order2.received_currency.should.equal(@order.received_currency)\n @order.received_currency = null\n order2.received_currency.should.not.equal(@order.received_currency)\n\n order2.received_amount.should.equal(@order.received_amount)\n @order.received_amount = null\n order2.received_amount.should.not.equal(@order.received_amount)\n\n it 'should be able to produce a mirrored copy', ->\n order2 = @order.clone(true)\n order2.account.should.equal(@order.account)\n order2.offered_currency.should.equal(@order.received_currency)\n order2.offered_amount.should.equal(@order.received_amount)\n order2.received_currency.should.equal(@order.offered_currency)\n order2.received_amount.should.equal(@order.offered_amount)", "source_lang": "", "target_lang": "CoffeeScript", "repo": "buttercoin/buttercoin", "path": "test/datastore/order_spec.coffee", "license": "MIT", "commit": "52561a472f9db748bb5ad7eeaceaf6ea2e1e26c7", "stars": 663, "source_url": "https://github.com/buttercoin/buttercoin/blob/52561a472f9db748bb5ad7eeaceaf6ea2e1e26c7/test/datastore/order_spec.coffee", "line_start": 1, "line_end": 38}6{"id": "buttercoin/buttercoin:test/datastore/order_spec.coffee:1:coffee_to_js", "type": "coffee_to_js", "prompt": "Convert this CoffeeScript to JavaScript.\n```coffeescript\nOrder = require('../../lib/datastore/order')\n\ndescribe 'Order', ->\n beforeEach ->\n @account = {}\n @order = new Order({}, 'USD', 1, 'BTC', 10)\n\n it 'should be clonable', ->\n @order.clone.should.exist\n order2 = @order.clone()\n\n order2.account.should.equal(@order.account)\n @order.account = null\n order2.account.should.not.equal(@order.account)\n\n order2.offered_currency.should.equal(@order.offered_currency)\n @order.offered_currency = null\n order2.offered_currency.should.not.equal(@order.offered_currency)\n\n order2.offered_amount.should.equal(@order.offered_amount)\n @order.offered_amount = null\n order2.offered_amount.should.not.equal(@order.offered_amount)\n\n order2.received_currency.should.equal(@order.received_currency)\n @order.received_currency = null\n order2.received_currency.should.not.equal(@order.received_currency)\n\n order2.received_amount.should.equal(@order.received_amount)\n @order.received_amount = null\n order2.received_amount.should.not.equal(@order.received_amount)\n\n it 'should be able to produce a mirrored copy', ->\n order2 = @order.clone(true)\n order2.account.should.equal(@order.account)\n order2.offered_currency.should.equal(@order.received_currency)\n order2.offered_amount.should.equal(@order.received_amount)\n order2.received_currency.should.equal(@order.offered_currency)\n order2.received_amount.should.equal(@order.offered_amount)\n```", "response": "var Order;\n\nOrder = require('../../lib/datastore/order');\n\ndescribe('Order', function() {\n beforeEach(function() {\n this.account = {};\n return this.order = new Order({}, 'USD', 1, 'BTC', 10);\n });\n it('should be clonable', function() {\n var order2;\n this.order.clone.should.exist;\n order2 = this.order.clone();\n order2.account.should.equal(this.order.account);\n this.order.account = null;\n order2.account.should.not.equal(this.order.account);\n order2.offered_currency.should.equal(this.order.offered_currency);\n this.order.offered_currency = null;\n order2.offered_currency.should.not.equal(this.order.offered_currency);\n order2.offered_amount.should.equal(this.order.offered_amount);\n this.order.offered_amount = null;\n order2.offered_amount.should.not.equal(this.order.offered_amount);\n order2.received_currency.should.equal(this.order.received_currency);\n this.order.received_currency = null;\n order2.received_currency.should.not.equal(this.order.received_currency);\n order2.received_amount.should.equal(this.order.received_amount);\n this.order.received_amount = null;\n return order2.received_amount.should.not.equal(this.order.received_amount);\n });\n return it('should be able to produce a mirrored copy', function() {\n var order2;\n order2 = this.order.clone(true);\n order2.account.should.equal(this.order.account);\n order2.offered_currency.should.equal(this.order.received_currency);\n order2.offered_amount.should.equal(this.order.received_amount);\n order2.received_currency.should.equal(this.order.offered_currency);\n return order2.received_amount.should.equal(this.order.offered_amount);\n });\n});", "source_lang": "CoffeeScript", "target_lang": "JavaScript", "repo": "buttercoin/buttercoin", "path": "test/datastore/order_spec.coffee", "license": "MIT", "commit": "52561a472f9db748bb5ad7eeaceaf6ea2e1e26c7", "stars": 663, "source_url": "https://github.com/buttercoin/buttercoin/blob/52561a472f9db748bb5ad7eeaceaf6ea2e1e26c7/test/datastore/order_spec.coffee", "line_start": 1, "line_end": 38}7{"id": "buttercoin/buttercoin:test/datastore/order_spec.coffee:1:js_to_coffee", "type": "js_to_coffee", "prompt": "Convert this JavaScript to CoffeeScript.\n```javascript\nvar Order;\n\nOrder = require('../../lib/datastore/order');\n\ndescribe('Order', function() {\n beforeEach(function() {\n this.account = {};\n return this.order = new Order({}, 'USD', 1, 'BTC', 10);\n });\n it('should be clonable', function() {\n var order2;\n this.order.clone.should.exist;\n order2 = this.order.clone();\n order2.account.should.equal(this.order.account);\n this.order.account = null;\n order2.account.should.not.equal(this.order.account);\n order2.offered_currency.should.equal(this.order.offered_currency);\n this.order.offered_currency = null;\n order2.offered_currency.should.not.equal(this.order.offered_currency);\n order2.offered_amount.should.equal(this.order.offered_amount);\n this.order.offered_amount = null;\n order2.offered_amount.should.not.equal(this.order.offered_amount);\n order2.received_currency.should.equal(this.order.received_currency);\n this.order.received_currency = null;\n order2.received_currency.should.not.equal(this.order.received_currency);\n order2.received_amount.should.equal(this.order.received_amount);\n this.order.received_amount = null;\n return order2.received_amount.should.not.equal(this.order.received_amount);\n });\n return it('should be able to produce a mirrored copy', function() {\n var order2;\n order2 = this.order.clone(true);\n order2.account.should.equal(this.order.account);\n order2.offered_currency.should.equal(this.order.received_currency);\n order2.offered_amount.should.equal(this.order.received_amount);\n order2.received_currency.should.equal(this.order.offered_currency);\n return order2.received_amount.should.equal(this.order.offered_amount);\n });\n});\n```", "response": "Order = require('../../lib/datastore/order')\n\ndescribe 'Order', ->\n beforeEach ->\n @account = {}\n @order = new Order({}, 'USD', 1, 'BTC', 10)\n\n it 'should be clonable', ->\n @order.clone.should.exist\n order2 = @order.clone()\n\n order2.account.should.equal(@order.account)\n @order.account = null\n order2.account.should.not.equal(@order.account)\n\n order2.offered_currency.should.equal(@order.offered_currency)\n @order.offered_currency = null\n order2.offered_currency.should.not.equal(@order.offered_currency)\n\n order2.offered_amount.should.equal(@order.offered_amount)\n @order.offered_amount = null\n order2.offered_amount.should.not.equal(@order.offered_amount)\n\n order2.received_currency.should.equal(@order.received_currency)\n @order.received_currency = null\n order2.received_currency.should.not.equal(@order.received_currency)\n\n order2.received_amount.should.equal(@order.received_amount)\n @order.received_amount = null\n order2.received_amount.should.not.equal(@order.received_amount)\n\n it 'should be able to produce a mirrored copy', ->\n order2 = @order.clone(true)\n order2.account.should.equal(@order.account)\n order2.offered_currency.should.equal(@order.received_currency)\n order2.offered_amount.should.equal(@order.received_amount)\n order2.received_currency.should.equal(@order.offered_currency)\n order2.received_amount.should.equal(@order.offered_amount)", "source_lang": "JavaScript", "target_lang": "CoffeeScript", "repo": "buttercoin/buttercoin", "path": "test/datastore/order_spec.coffee", "license": "MIT", "commit": "52561a472f9db748bb5ad7eeaceaf6ea2e1e26c7", "stars": 663, "source_url": "https://github.com/buttercoin/buttercoin/blob/52561a472f9db748bb5ad7eeaceaf6ea2e1e26c7/test/datastore/order_spec.coffee", "line_start": 1, "line_end": 38}8{"id": "buttercoin/buttercoin:test/datastore/order_spec.coffee:1:completion", "type": "completion", "prompt": "Order = require('../../lib/datastore/order')\n\ndescribe 'Order', ->\n beforeEach ->\n @account = {}\n @order = new Order({}, 'USD', 1, 'BTC', 10)\n\n it 'should be clonable', ->\n @order.clone.should.exist\n order2 = @order.clone()\n\n order2.account.should.equal(@order.account)\n @order.account = null\n order2.account.should.not.equal(@order.account)\n\n order2.offered_currency.should.equal(@order.offered_currency)\n @order.offered_currency = null\n order2.offered_currency.should.not.equal(@order.offered_currency)", "response": "order2.offered_amount.should.equal(@order.offered_amount)\n @order.offered_amount = null\n order2.offered_amount.should.not.equal(@order.offered_amount)\n\n order2.received_currency.should.equal(@order.received_currency)\n @order.received_currency = null\n order2.received_currency.should.not.equal(@order.received_currency)\n\n order2.received_amount.should.equal(@order.received_amount)\n @order.received_amount = null\n order2.received_amount.should.not.equal(@order.received_amount)\n\n it 'should be able to produce a mirrored copy', ->\n order2 = @order.clone(true)\n order2.account.should.equal(@order.account)\n order2.offered_currency.should.equal(@order.received_currency)\n order2.offered_amount.should.equal(@order.received_amount)\n order2.received_currency.should.equal(@order.offered_currency)\n order2.received_amount.should.equal(@order.offered_amount)", "source_lang": "CoffeeScript", "target_lang": "CoffeeScript", "repo": "buttercoin/buttercoin", "path": "test/datastore/order_spec.coffee", "license": "MIT", "commit": "52561a472f9db748bb5ad7eeaceaf6ea2e1e26c7", "stars": 663, "source_url": "https://github.com/buttercoin/buttercoin/blob/52561a472f9db748bb5ad7eeaceaf6ea2e1e26c7/test/datastore/order_spec.coffee", "line_start": 1, "line_end": 38}9{"id": "jianliaoim/talk-os:talk-api2x/mshells/append-has-tag.coffee:1:raw_corpus", "type": "raw_corpus", "prompt": "", "response": "messages = db.messages.find({hasTag: null}, {tags: 1})\n\nnum = 0\n\nmessages.forEach (message) ->\n num += 1\n print \"Scan num\", num unless num % 10000\n hasTag = if message.tags?.length then true else false\n db.messages.update({_id: message._id}, {$set: {hasTag: hasTag}})\n\nprint \"Finish num\", num", "source_lang": "", "target_lang": "CoffeeScript", "repo": "jianliaoim/talk-os", "path": "talk-api2x/mshells/append-has-tag.coffee", "license": "MIT", "commit": "2545c4497865779a55762e03963a39237df9046b", "stars": 2703, "source_url": "https://github.com/jianliaoim/talk-os/blob/2545c4497865779a55762e03963a39237df9046b/talk-api2x/mshells/append-has-tag.coffee", "line_start": 1, "line_end": 11}10{"id": "jianliaoim/talk-os:talk-api2x/mshells/append-has-tag.coffee:1:coffee_to_js", "type": "coffee_to_js", "prompt": "Convert this CoffeeScript to JavaScript.\n```coffeescript\nmessages = db.messages.find({hasTag: null}, {tags: 1})\n\nnum = 0\n\nmessages.forEach (message) ->\n num += 1\n print \"Scan num\", num unless num % 10000\n hasTag = if message.tags?.length then true else false\n db.messages.update({_id: message._id}, {$set: {hasTag: hasTag}})\n\nprint \"Finish num\", num\n```", "response": "var messages, num;\n\nmessages = db.messages.find({\n hasTag: null\n}, {\n tags: 1\n});\n\nnum = 0;\n\nmessages.forEach(function(message) {\n var hasTag, ref;\n num += 1;\n if (!(num % 10000)) {\n print(\"Scan num\", num);\n }\n hasTag = ((ref = message.tags) != null ? ref.length : void 0) ? true : false;\n return db.messages.update({\n _id: message._id\n }, {\n $set: {\n hasTag: hasTag\n }\n });\n});\n\nprint(\"Finish num\", num);", "source_lang": "CoffeeScript", "target_lang": "JavaScript", "repo": "jianliaoim/talk-os", "path": "talk-api2x/mshells/append-has-tag.coffee", "license": "MIT", "commit": "2545c4497865779a55762e03963a39237df9046b", "stars": 2703, "source_url": "https://github.com/jianliaoim/talk-os/blob/2545c4497865779a55762e03963a39237df9046b/talk-api2x/mshells/append-has-tag.coffee", "line_start": 1, "line_end": 11}11{"id": "jianliaoim/talk-os:talk-api2x/mshells/append-has-tag.coffee:1:js_to_coffee", "type": "js_to_coffee", "prompt": "Convert this JavaScript to CoffeeScript.\n```javascript\nvar messages, num;\n\nmessages = db.messages.find({\n hasTag: null\n}, {\n tags: 1\n});\n\nnum = 0;\n\nmessages.forEach(function(message) {\n var hasTag, ref;\n num += 1;\n if (!(num % 10000)) {\n print(\"Scan num\", num);\n }\n hasTag = ((ref = message.tags) != null ? ref.length : void 0) ? true : false;\n return db.messages.update({\n _id: message._id\n }, {\n $set: {\n hasTag: hasTag\n }\n });\n});\n\nprint(\"Finish num\", num);\n```", "response": "messages = db.messages.find({hasTag: null}, {tags: 1})\n\nnum = 0\n\nmessages.forEach (message) ->\n num += 1\n print \"Scan num\", num unless num % 10000\n hasTag = if message.tags?.length then true else false\n db.messages.update({_id: message._id}, {$set: {hasTag: hasTag}})\n\nprint \"Finish num\", num", "source_lang": "JavaScript", "target_lang": "CoffeeScript", "repo": "jianliaoim/talk-os", "path": "talk-api2x/mshells/append-has-tag.coffee", "license": "MIT", "commit": "2545c4497865779a55762e03963a39237df9046b", "stars": 2703, "source_url": "https://github.com/jianliaoim/talk-os/blob/2545c4497865779a55762e03963a39237df9046b/talk-api2x/mshells/append-has-tag.coffee", "line_start": 1, "line_end": 11}12{"id": "jianliaoim/talk-os:talk-api2x/mshells/append-has-tag.coffee:1:completion", "type": "completion", "prompt": "messages = db.messages.find({hasTag: null}, {tags: 1})\n\nnum = 0\n\nmessages.forEach (message) ->", "response": "num += 1\n print \"Scan num\", num unless num % 10000\n hasTag = if message.tags?.length then true else false\n db.messages.update({_id: message._id}, {$set: {hasTag: hasTag}})\n\nprint \"Finish num\", num", "source_lang": "CoffeeScript", "target_lang": "CoffeeScript", "repo": "jianliaoim/talk-os", "path": "talk-api2x/mshells/append-has-tag.coffee", "license": "MIT", "commit": "2545c4497865779a55762e03963a39237df9046b", "stars": 2703, "source_url": "https://github.com/jianliaoim/talk-os/blob/2545c4497865779a55762e03963a39237df9046b/talk-api2x/mshells/append-has-tag.coffee", "line_start": 1, "line_end": 11}13{"id": "Glavin001/atom-beautify:src/beautifiers/fortran-beautifier/index.coffee:1:raw_corpus", "type": "raw_corpus", "prompt": "", "response": "###\nRequires https://www.gnu.org/software/emacs/\n###\n\n\"use strict\"\nBeautifier = require('../beautifier')\npath = require(\"path\")\n\nmodule.exports = class FortranBeautifier extends Beautifier\n name: \"Fortran Beautifier\"\n link: \"https://www.gnu.org/software/emacs/\"\n executables: [\n {\n name: \"Emacs\"\n cmd: \"emacs\"\n homepage: \"https://www.gnu.org/software/emacs/\"\n installation: \"https://www.gnu.org/software/emacs/\"\n version: {\n parse: (text) -> text.match(/Emacs (\\d+\\.\\d+\\.\\d+)/)[1]\n }\n }\n ]\n\n options: {\n Fortran: true\n }\n\n beautify: (text, language, options) ->\n @debug('fortran-beautifier', options)\n emacs = @exe(\"emacs\")\n\n emacs_path = options.emacs_path\n emacs_script_path = options.emacs_script_path\n\n if not emacs_script_path\n emacs_script_path = path.resolve(__dirname, \"emacs-fortran-formating-script.lisp\")\n\n @debug('fortran-beautifier', 'emacs script path: ' + emacs_script_path)\n\n args = [\n '--batch'\n '-l'\n emacs_script_path\n '-f'\n 'f90-batch-indent-region'\n tempFile = @tempFile(\"temp\", text)\n ]\n\n if emacs_path\n @deprecateOptionForExecutable(\"Emacs\", \"emacs_path\", \"Path\")", "source_lang": "", "target_lang": "CoffeeScript", "repo": "Glavin001/atom-beautify", "path": "src/beautifiers/fortran-beautifier/index.coffee", "license": "MIT", "commit": "41d5051b399f7fe11efd149504a232df16179d60", "stars": 1503, "source_url": "https://github.com/Glavin001/atom-beautify/blob/41d5051b399f7fe11efd149504a232df16179d60/src/beautifiers/fortran-beautifier/index.coffee", "line_start": 1, "line_end": 50}14{"id": "Glavin001/atom-beautify:src/beautifiers/fortran-beautifier/index.coffee:1:coffee_to_js", "type": "coffee_to_js", "prompt": "Convert this CoffeeScript to JavaScript.\n```coffeescript\n###\nRequires https://www.gnu.org/software/emacs/\n###\n\n\"use strict\"\nBeautifier = require('../beautifier')\npath = require(\"path\")\n\nmodule.exports = class FortranBeautifier extends Beautifier\n name: \"Fortran Beautifier\"\n link: \"https://www.gnu.org/software/emacs/\"\n executables: [\n {\n name: \"Emacs\"\n cmd: \"emacs\"\n homepage: \"https://www.gnu.org/software/emacs/\"\n installation: \"https://www.gnu.org/software/emacs/\"\n version: {\n parse: (text) -> text.match(/Emacs (\\d+\\.\\d+\\.\\d+)/)[1]\n }\n }\n ]\n\n options: {\n Fortran: true\n }\n\n beautify: (text, language, options) ->\n @debug('fortran-beautifier', options)\n emacs = @exe(\"emacs\")\n\n emacs_path = options.emacs_path\n emacs_script_path = options.emacs_script_path\n\n if not emacs_script_path\n emacs_script_path = path.resolve(__dirname, \"emacs-fortran-formating-script.lisp\")\n\n @debug('fortran-beautifier', 'emacs script path: ' + emacs_script_path)\n\n args = [\n '--batch'\n '-l'\n emacs_script_path\n '-f'\n 'f90-batch-indent-region'\n tempFile = @tempFile(\"temp\", text)\n ]\n\n if emacs_path\n @deprecateOptionForExecutable(\"Emacs\", \"emacs_path\", \"Path\")\n```", "response": "/*\nRequires https://www.gnu.org/software/emacs/\n*/\n\"use strict\";\nvar Beautifier, FortranBeautifier, path;\n\nBeautifier = require('../beautifier');\n\npath = require(\"path\");\n\nmodule.exports = FortranBeautifier = (function() {\n class FortranBeautifier extends Beautifier {\n beautify(text, language, options) {\n var args, emacs, emacs_path, emacs_script_path, tempFile;\n this.debug('fortran-beautifier', options);\n emacs = this.exe(\"emacs\");\n emacs_path = options.emacs_path;\n emacs_script_path = options.emacs_script_path;\n if (!emacs_script_path) {\n emacs_script_path = path.resolve(__dirname, \"emacs-fortran-formating-script.lisp\");\n }\n this.debug('fortran-beautifier', 'emacs script path: ' + emacs_script_path);\n args = ['--batch', '-l', emacs_script_path, '-f', 'f90-batch-indent-region', tempFile = this.tempFile(\"temp\", text)];\n if (emacs_path) {\n return this.deprecateOptionForExecutable(\"Emacs\", \"emacs_path\", \"Path\");\n }\n }\n\n };\n\n FortranBeautifier.prototype.name = \"Fortran Beautifier\";\n\n FortranBeautifier.prototype.link = \"https://www.gnu.org/software/emacs/\";\n\n FortranBeautifier.prototype.executables = [\n {\n name: \"Emacs\",\n cmd: \"emacs\",\n homepage: \"https://www.gnu.org/software/emacs/\",\n installation: \"https://www.gnu.org/software/emacs/\",\n version: {\n parse: function(text) {\n return text.match(/Emacs (\\d+\\.\\d+\\.\\d+)/)[1];\n }\n }\n }\n ];\n\n FortranBeautifier.prototype.options = {\n Fortran: true\n };\n\n return FortranBeautifier;\n\n}).call(this);", "source_lang": "CoffeeScript", "target_lang": "JavaScript", "repo": "Glavin001/atom-beautify", "path": "src/beautifiers/fortran-beautifier/index.coffee", "license": "MIT", "commit": "41d5051b399f7fe11efd149504a232df16179d60", "stars": 1503, "source_url": "https://github.com/Glavin001/atom-beautify/blob/41d5051b399f7fe11efd149504a232df16179d60/src/beautifiers/fortran-beautifier/index.coffee", "line_start": 1, "line_end": 50}15{"id": "Glavin001/atom-beautify:src/beautifiers/fortran-beautifier/index.coffee:1:js_to_coffee", "type": "js_to_coffee", "prompt": "Convert this JavaScript to CoffeeScript.\n```javascript\n/*\nRequires https://www.gnu.org/software/emacs/\n*/\n\"use strict\";\nvar Beautifier, FortranBeautifier, path;\n\nBeautifier = require('../beautifier');\n\npath = require(\"path\");\n\nmodule.exports = FortranBeautifier = (function() {\n class FortranBeautifier extends Beautifier {\n beautify(text, language, options) {\n var args, emacs, emacs_path, emacs_script_path, tempFile;\n this.debug('fortran-beautifier', options);\n emacs = this.exe(\"emacs\");\n emacs_path = options.emacs_path;\n emacs_script_path = options.emacs_script_path;\n if (!emacs_script_path) {\n emacs_script_path = path.resolve(__dirname, \"emacs-fortran-formating-script.lisp\");\n }\n this.debug('fortran-beautifier', 'emacs script path: ' + emacs_script_path);\n args = ['--batch', '-l', emacs_script_path, '-f', 'f90-batch-indent-region', tempFile = this.tempFile(\"temp\", text)];\n if (emacs_path) {\n return this.deprecateOptionForExecutable(\"Emacs\", \"emacs_path\", \"Path\");\n }\n }\n\n };\n\n FortranBeautifier.prototype.name = \"Fortran Beautifier\";\n\n FortranBeautifier.prototype.link = \"https://www.gnu.org/software/emacs/\";\n\n FortranBeautifier.prototype.executables = [\n {\n name: \"Emacs\",\n cmd: \"emacs\",\n homepage: \"https://www.gnu.org/software/emacs/\",\n installation: \"https://www.gnu.org/software/emacs/\",\n version: {\n parse: function(text) {\n return text.match(/Emacs (\\d+\\.\\d+\\.\\d+)/)[1];\n }\n }\n }\n ];\n\n FortranBeautifier.prototype.options = {\n Fortran: true\n };\n\n return FortranBeautifier;\n\n}).call(this);\n```", "response": "###\nRequires https://www.gnu.org/software/emacs/\n###\n\n\"use strict\"\nBeautifier = require('../beautifier')\npath = require(\"path\")\n\nmodule.exports = class FortranBeautifier extends Beautifier\n name: \"Fortran Beautifier\"\n link: \"https://www.gnu.org/software/emacs/\"\n executables: [\n {\n name: \"Emacs\"\n cmd: \"emacs\"\n homepage: \"https://www.gnu.org/software/emacs/\"\n installation: \"https://www.gnu.org/software/emacs/\"\n version: {\n parse: (text) -> text.match(/Emacs (\\d+\\.\\d+\\.\\d+)/)[1]\n }\n }\n ]\n\n options: {\n Fortran: true\n }\n\n beautify: (text, language, options) ->\n @debug('fortran-beautifier', options)\n emacs = @exe(\"emacs\")\n\n emacs_path = options.emacs_path\n emacs_script_path = options.emacs_script_path\n\n if not emacs_script_path\n emacs_script_path = path.resolve(__dirname, \"emacs-fortran-formating-script.lisp\")\n\n @debug('fortran-beautifier', 'emacs script path: ' + emacs_script_path)\n\n args = [\n '--batch'\n '-l'\n emacs_script_path\n '-f'\n 'f90-batch-indent-region'\n tempFile = @tempFile(\"temp\", text)\n ]\n\n if emacs_path\n @deprecateOptionForExecutable(\"Emacs\", \"emacs_path\", \"Path\")", "source_lang": "JavaScript", "target_lang": "CoffeeScript", "repo": "Glavin001/atom-beautify", "path": "src/beautifiers/fortran-beautifier/index.coffee", "license": "MIT", "commit": "41d5051b399f7fe11efd149504a232df16179d60", "stars": 1503, "source_url": "https://github.com/Glavin001/atom-beautify/blob/41d5051b399f7fe11efd149504a232df16179d60/src/beautifiers/fortran-beautifier/index.coffee", "line_start": 1, "line_end": 50}16{"id": "Glavin001/atom-beautify:src/beautifiers/fortran-beautifier/index.coffee:1:completion", "type": "completion", "prompt": "###\nRequires https://www.gnu.org/software/emacs/\n###\n\n\"use strict\"\nBeautifier = require('../beautifier')\npath = require(\"path\")\n\nmodule.exports = class FortranBeautifier extends Beautifier\n name: \"Fortran Beautifier\"\n link: \"https://www.gnu.org/software/emacs/\"\n executables: [\n {\n name: \"Emacs\"\n cmd: \"emacs\"\n homepage: \"https://www.gnu.org/software/emacs/\"\n installation: \"https://www.gnu.org/software/emacs/\"\n version: {\n parse: (text) -> text.match(/Emacs (\\d+\\.\\d+\\.\\d+)/)[1]\n }\n }\n ]\n\n options: {\n Fortran: true", "response": "}\n\n beautify: (text, language, options) ->\n @debug('fortran-beautifier', options)\n emacs = @exe(\"emacs\")\n\n emacs_path = options.emacs_path\n emacs_script_path = options.emacs_script_path\n\n if not emacs_script_path\n emacs_script_path = path.resolve(__dirname, \"emacs-fortran-formating-script.lisp\")\n\n @debug('fortran-beautifier', 'emacs script path: ' + emacs_script_path)\n\n args = [\n '--batch'\n '-l'\n emacs_script_path\n '-f'\n 'f90-batch-indent-region'\n tempFile = @tempFile(\"temp\", text)\n ]\n\n if emacs_path\n @deprecateOptionForExecutable(\"Emacs\", \"emacs_path\", \"Path\")", "source_lang": "CoffeeScript", "target_lang": "CoffeeScript", "repo": "Glavin001/atom-beautify", "path": "src/beautifiers/fortran-beautifier/index.coffee", "license": "MIT", "commit": "41d5051b399f7fe11efd149504a232df16179d60", "stars": 1503, "source_url": "https://github.com/Glavin001/atom-beautify/blob/41d5051b399f7fe11efd149504a232df16179d60/src/beautifiers/fortran-beautifier/index.coffee", "line_start": 1, "line_end": 50}17{"id": "Glavin001/atom-beautify:src/beautifiers/fortran-beautifier/index.coffee:2:raw_corpus", "type": "raw_corpus", "prompt": "", "response": "@run(emacs_path, args, {ignoreReturnCode: false})\n .then(=>\n @readFile(tempFile)\n )\n else\n emacs.run(args, {ignoreReturnCode: false})\n .then(=>\n @readFile(tempFile)\n )", "source_lang": "", "target_lang": "CoffeeScript", "repo": "Glavin001/atom-beautify", "path": "src/beautifiers/fortran-beautifier/index.coffee", "license": "MIT", "commit": "41d5051b399f7fe11efd149504a232df16179d60", "stars": 1503, "source_url": "https://github.com/Glavin001/atom-beautify/blob/41d5051b399f7fe11efd149504a232df16179d60/src/beautifiers/fortran-beautifier/index.coffee", "line_start": 51, "line_end": 59}18{"id": "Glavin001/atom-beautify:src/beautifiers/fortran-beautifier/index.coffee:2:completion", "type": "completion", "prompt": "@run(emacs_path, args, {ignoreReturnCode: false})\n .then(=>\n @readFile(tempFile)\n )", "response": "else\n emacs.run(args, {ignoreReturnCode: false})\n .then(=>\n @readFile(tempFile)\n )", "source_lang": "CoffeeScript", "target_lang": "CoffeeScript", "repo": "Glavin001/atom-beautify", "path": "src/beautifiers/fortran-beautifier/index.coffee", "license": "MIT", "commit": "41d5051b399f7fe11efd149504a232df16179d60", "stars": 1503, "source_url": "https://github.com/Glavin001/atom-beautify/blob/41d5051b399f7fe11efd149504a232df16179d60/src/beautifiers/fortran-beautifier/index.coffee", "line_start": 51, "line_end": 59}19{"id": "Glavin001/atom-beautify:src/beautifiers/fortran-beautifier/index.coffee:1:raw_corpus", "type": "raw_corpus", "prompt": "", "response": "###\nRequires https://www.gnu.org/software/emacs/\n###\n\n\"use strict\"\nBeautifier = require('../beautifier')\npath = require(\"path\")\n\nmodule.exports = class FortranBeautifier extends Beautifier\n name: \"Fortran Beautifier\"\n link: \"https://www.gnu.org/software/emacs/\"\n executables: [\n {\n name: \"Emacs\"\n cmd: \"emacs\"\n homepage: \"https://www.gnu.org/software/emacs/\"\n installation: \"https://www.gnu.org/software/emacs/\"\n version: {\n parse: (text) -> text.match(/Emacs (\\d+\\.\\d+\\.\\d+)/)[1]\n }\n }\n ]\n\n options: {\n Fortran: true\n }\n\n beautify: (text, language, options) ->\n @debug('fortran-beautifier', options)\n emacs = @exe(\"emacs\")\n\n emacs_path = options.emacs_path\n emacs_script_path = options.emacs_script_path\n\n if not emacs_script_path\n emacs_script_path = path.resolve(__dirname, \"emacs-fortran-formating-script.lisp\")\n\n @debug('fortran-beautifier', 'emacs script path: ' + emacs_script_path)\n\n args = [\n '--batch'\n '-l'\n emacs_script_path\n '-f'\n 'f90-batch-indent-region'\n tempFile = @tempFile(\"temp\", text)\n ]\n\n if emacs_path\n @deprecate(\"The \\\"emacs_path\\\" has been deprecated. Please switch to using the config with path \\\"Executables - Emacs - Path\\\" in Atom-Beautify package settings now.\")", "source_lang": "", "target_lang": "CoffeeScript", "repo": "Glavin001/atom-beautify", "path": "src/beautifiers/fortran-beautifier/index.coffee", "license": "MIT", "commit": "bee7b2573a5cdf4fdf2c93f76533d00a13336f42", "stars": 1503, "source_url": "https://github.com/Glavin001/atom-beautify/blob/bee7b2573a5cdf4fdf2c93f76533d00a13336f42/src/beautifiers/fortran-beautifier/index.coffee", "line_start": 1, "line_end": 50}20{"id": "Glavin001/atom-beautify:src/beautifiers/fortran-beautifier/index.coffee:1:coffee_to_js", "type": "coffee_to_js", "prompt": "Convert this CoffeeScript to JavaScript.\n```coffeescript\n###\nRequires https://www.gnu.org/software/emacs/\n###\n\n\"use strict\"\nBeautifier = require('../beautifier')\npath = require(\"path\")\n\nmodule.exports = class FortranBeautifier extends Beautifier\n name: \"Fortran Beautifier\"\n link: \"https://www.gnu.org/software/emacs/\"\n executables: [\n {\n name: \"Emacs\"\n cmd: \"emacs\"\n homepage: \"https://www.gnu.org/software/emacs/\"\n installation: \"https://www.gnu.org/software/emacs/\"\n version: {\n parse: (text) -> text.match(/Emacs (\\d+\\.\\d+\\.\\d+)/)[1]\n }\n }\n ]\n\n options: {\n Fortran: true\n }\n\n beautify: (text, language, options) ->\n @debug('fortran-beautifier', options)\n emacs = @exe(\"emacs\")\n\n emacs_path = options.emacs_path\n emacs_script_path = options.emacs_script_path\n\n if not emacs_script_path\n emacs_script_path = path.resolve(__dirname, \"emacs-fortran-formating-script.lisp\")\n\n @debug('fortran-beautifier', 'emacs script path: ' + emacs_script_path)\n\n args = [\n '--batch'\n '-l'\n emacs_script_path\n '-f'\n 'f90-batch-indent-region'\n tempFile = @tempFile(\"temp\", text)\n ]\n\n if emacs_path\n @deprecate(\"The \\\"emacs_path\\\" has been deprecated. Please switch to using the config with path \\\"Executables - Emacs - Path\\\" in Atom-Beautify package settings now.\")\n```", "response": "/*\nRequires https://www.gnu.org/software/emacs/\n*/\n\"use strict\";\nvar Beautifier, FortranBeautifier, path;\n\nBeautifier = require('../beautifier');\n\npath = require(\"path\");\n\nmodule.exports = FortranBeautifier = (function() {\n class FortranBeautifier extends Beautifier {\n beautify(text, language, options) {\n var args, emacs, emacs_path, emacs_script_path, tempFile;\n this.debug('fortran-beautifier', options);\n emacs = this.exe(\"emacs\");\n emacs_path = options.emacs_path;\n emacs_script_path = options.emacs_script_path;\n if (!emacs_script_path) {\n emacs_script_path = path.resolve(__dirname, \"emacs-fortran-formating-script.lisp\");\n }\n this.debug('fortran-beautifier', 'emacs script path: ' + emacs_script_path);\n args = ['--batch', '-l', emacs_script_path, '-f', 'f90-batch-indent-region', tempFile = this.tempFile(\"temp\", text)];\n if (emacs_path) {\n return this.deprecate(\"The \\\"emacs_path\\\" has been deprecated. Please switch to using the config with path \\\"Executables - Emacs - Path\\\" in Atom-Beautify package settings now.\");\n }\n }\n\n };\n\n FortranBeautifier.prototype.name = \"Fortran Beautifier\";\n\n FortranBeautifier.prototype.link = \"https://www.gnu.org/software/emacs/\";\n\n FortranBeautifier.prototype.executables = [\n {\n name: \"Emacs\",\n cmd: \"emacs\",\n homepage: \"https://www.gnu.org/software/emacs/\",\n installation: \"https://www.gnu.org/software/emacs/\",\n version: {\n parse: function(text) {\n return text.match(/Emacs (\\d+\\.\\d+\\.\\d+)/)[1];\n }\n }\n }\n ];\n\n FortranBeautifier.prototype.options = {\n Fortran: true\n };\n\n return FortranBeautifier;\n\n}).call(this);", "source_lang": "CoffeeScript", "target_lang": "JavaScript", "repo": "Glavin001/atom-beautify", "path": "src/beautifiers/fortran-beautifier/index.coffee", "license": "MIT", "commit": "bee7b2573a5cdf4fdf2c93f76533d00a13336f42", "stars": 1503, "source_url": "https://github.com/Glavin001/atom-beautify/blob/bee7b2573a5cdf4fdf2c93f76533d00a13336f42/src/beautifiers/fortran-beautifier/index.coffee", "line_start": 1, "line_end": 50}21{"id": "Glavin001/atom-beautify:src/beautifiers/fortran-beautifier/index.coffee:1:js_to_coffee", "type": "js_to_coffee", "prompt": "Convert this JavaScript to CoffeeScript.\n```javascript\n/*\nRequires https://www.gnu.org/software/emacs/\n*/\n\"use strict\";\nvar Beautifier, FortranBeautifier, path;\n\nBeautifier = require('../beautifier');\n\npath = require(\"path\");\n\nmodule.exports = FortranBeautifier = (function() {\n class FortranBeautifier extends Beautifier {\n beautify(text, language, options) {\n var args, emacs, emacs_path, emacs_script_path, tempFile;\n this.debug('fortran-beautifier', options);\n emacs = this.exe(\"emacs\");\n emacs_path = options.emacs_path;\n emacs_script_path = options.emacs_script_path;\n if (!emacs_script_path) {\n emacs_script_path = path.resolve(__dirname, \"emacs-fortran-formating-script.lisp\");\n }\n this.debug('fortran-beautifier', 'emacs script path: ' + emacs_script_path);\n args = ['--batch', '-l', emacs_script_path, '-f', 'f90-batch-indent-region', tempFile = this.tempFile(\"temp\", text)];\n if (emacs_path) {\n return this.deprecate(\"The \\\"emacs_path\\\" has been deprecated. Please switch to using the config with path \\\"Executables - Emacs - Path\\\" in Atom-Beautify package settings now.\");\n }\n }\n\n };\n\n FortranBeautifier.prototype.name = \"Fortran Beautifier\";\n\n FortranBeautifier.prototype.link = \"https://www.gnu.org/software/emacs/\";\n\n FortranBeautifier.prototype.executables = [\n {\n name: \"Emacs\",\n cmd: \"emacs\",\n homepage: \"https://www.gnu.org/software/emacs/\",\n installation: \"https://www.gnu.org/software/emacs/\",\n version: {\n parse: function(text) {\n return text.match(/Emacs (\\d+\\.\\d+\\.\\d+)/)[1];\n }\n }\n }\n ];\n\n FortranBeautifier.prototype.options = {\n Fortran: true\n };\n\n return FortranBeautifier;\n\n}).call(this);\n```", "response": "###\nRequires https://www.gnu.org/software/emacs/\n###\n\n\"use strict\"\nBeautifier = require('../beautifier')\npath = require(\"path\")\n\nmodule.exports = class FortranBeautifier extends Beautifier\n name: \"Fortran Beautifier\"\n link: \"https://www.gnu.org/software/emacs/\"\n executables: [\n {\n name: \"Emacs\"\n cmd: \"emacs\"\n homepage: \"https://www.gnu.org/software/emacs/\"\n installation: \"https://www.gnu.org/software/emacs/\"\n version: {\n parse: (text) -> text.match(/Emacs (\\d+\\.\\d+\\.\\d+)/)[1]\n }\n }\n ]\n\n options: {\n Fortran: true\n }\n\n beautify: (text, language, options) ->\n @debug('fortran-beautifier', options)\n emacs = @exe(\"emacs\")\n\n emacs_path = options.emacs_path\n emacs_script_path = options.emacs_script_path\n\n if not emacs_script_path\n emacs_script_path = path.resolve(__dirname, \"emacs-fortran-formating-script.lisp\")\n\n @debug('fortran-beautifier', 'emacs script path: ' + emacs_script_path)\n\n args = [\n '--batch'\n '-l'\n emacs_script_path\n '-f'\n 'f90-batch-indent-region'\n tempFile = @tempFile(\"temp\", text)\n ]\n\n if emacs_path\n @deprecate(\"The \\\"emacs_path\\\" has been deprecated. Please switch to using the config with path \\\"Executables - Emacs - Path\\\" in Atom-Beautify package settings now.\")", "source_lang": "JavaScript", "target_lang": "CoffeeScript", "repo": "Glavin001/atom-beautify", "path": "src/beautifiers/fortran-beautifier/index.coffee", "license": "MIT", "commit": "bee7b2573a5cdf4fdf2c93f76533d00a13336f42", "stars": 1503, "source_url": "https://github.com/Glavin001/atom-beautify/blob/bee7b2573a5cdf4fdf2c93f76533d00a13336f42/src/beautifiers/fortran-beautifier/index.coffee", "line_start": 1, "line_end": 50}22{"id": "Glavin001/atom-beautify:src/beautifiers/fortran-beautifier/index.coffee:1:completion", "type": "completion", "prompt": "###\nRequires https://www.gnu.org/software/emacs/\n###\n\n\"use strict\"\nBeautifier = require('../beautifier')\npath = require(\"path\")\n\nmodule.exports = class FortranBeautifier extends Beautifier\n name: \"Fortran Beautifier\"\n link: \"https://www.gnu.org/software/emacs/\"\n executables: [\n {\n name: \"Emacs\"\n cmd: \"emacs\"\n homepage: \"https://www.gnu.org/software/emacs/\"\n installation: \"https://www.gnu.org/software/emacs/\"\n version: {\n parse: (text) -> text.match(/Emacs (\\d+\\.\\d+\\.\\d+)/)[1]\n }\n }\n ]\n\n options: {\n Fortran: true", "response": "}\n\n beautify: (text, language, options) ->\n @debug('fortran-beautifier', options)\n emacs = @exe(\"emacs\")\n\n emacs_path = options.emacs_path\n emacs_script_path = options.emacs_script_path\n\n if not emacs_script_path\n emacs_script_path = path.resolve(__dirname, \"emacs-fortran-formating-script.lisp\")\n\n @debug('fortran-beautifier', 'emacs script path: ' + emacs_script_path)\n\n args = [\n '--batch'\n '-l'\n emacs_script_path\n '-f'\n 'f90-batch-indent-region'\n tempFile = @tempFile(\"temp\", text)\n ]\n\n if emacs_path\n @deprecate(\"The \\\"emacs_path\\\" has been deprecated. Please switch to using the config with path \\\"Executables - Emacs - Path\\\" in Atom-Beautify package settings now.\")", "source_lang": "CoffeeScript", "target_lang": "CoffeeScript", "repo": "Glavin001/atom-beautify", "path": "src/beautifiers/fortran-beautifier/index.coffee", "license": "MIT", "commit": "bee7b2573a5cdf4fdf2c93f76533d00a13336f42", "stars": 1503, "source_url": "https://github.com/Glavin001/atom-beautify/blob/bee7b2573a5cdf4fdf2c93f76533d00a13336f42/src/beautifiers/fortran-beautifier/index.coffee", "line_start": 1, "line_end": 50}23{"id": "Glavin001/atom-beautify:src/beautifiers/fortran-beautifier/index.coffee:1:raw_corpus", "type": "raw_corpus", "prompt": "", "response": "###\nRequires https://www.gnu.org/software/emacs/\n###\n\n\"use strict\"\nBeautifier = require('../beautifier')\npath = require(\"path\")\n\nmodule.exports = class FortranBeautifier extends Beautifier\n name: \"Fortran Beautifier\"\n link: \"https://www.gnu.org/software/emacs/\"\n isPreInstalled: false\n\n options: {\n Fortran: true\n }\n\n beautify: (text, language, options) ->\n @debug('fortran-beautifier', options)\n\n emacs_path = options.emacs_path\n emacs_script_path = options.emacs_script_path\n\n if not emacs_script_path\n emacs_script_path = path.resolve(__dirname, \"emacs-fortran-formating-script.lisp\")\n\n @debug('fortran-beautifier', 'emacs script path: ' + emacs_script_path)\n\n args = [\n '--batch'\n '-l'\n emacs_script_path\n '-f'\n 'f90-batch-indent-region'\n tempFile = @tempFile(\"temp\", text)\n ]\n\n if emacs_path\n @run(emacs_path, args, {ignoreReturnCode: false})\n .then(=>\n @readFile(tempFile)\n )\n else\n @run(\"emacs\", args, {ignoreReturnCode: false})\n .then(=>\n @readFile(tempFile)\n )", "source_lang": "", "target_lang": "CoffeeScript", "repo": "Glavin001/atom-beautify", "path": "src/beautifiers/fortran-beautifier/index.coffee", "license": "MIT", "commit": "ba2198675cbcc1ecd05f18e28e97133cdd2d5319", "stars": 1503, "source_url": "https://github.com/Glavin001/atom-beautify/blob/ba2198675cbcc1ecd05f18e28e97133cdd2d5319/src/beautifiers/fortran-beautifier/index.coffee", "line_start": 1, "line_end": 47}24{"id": "Glavin001/atom-beautify:src/beautifiers/fortran-beautifier/index.coffee:1:coffee_to_js", "type": "coffee_to_js", "prompt": "Convert this CoffeeScript to JavaScript.\n```coffeescript\n###\nRequires https://www.gnu.org/software/emacs/\n###\n\n\"use strict\"\nBeautifier = require('../beautifier')\npath = require(\"path\")\n\nmodule.exports = class FortranBeautifier extends Beautifier\n name: \"Fortran Beautifier\"\n link: \"https://www.gnu.org/software/emacs/\"\n isPreInstalled: false\n\n options: {\n Fortran: true\n }\n\n beautify: (text, language, options) ->\n @debug('fortran-beautifier', options)\n\n emacs_path = options.emacs_path\n emacs_script_path = options.emacs_script_path\n\n if not emacs_script_path\n emacs_script_path = path.resolve(__dirname, \"emacs-fortran-formating-script.lisp\")\n\n @debug('fortran-beautifier', 'emacs script path: ' + emacs_script_path)\n\n args = [\n '--batch'\n '-l'\n emacs_script_path\n '-f'\n 'f90-batch-indent-region'\n tempFile = @tempFile(\"temp\", text)\n ]\n\n if emacs_path\n @run(emacs_path, args, {ignoreReturnCode: false})\n .then(=>\n @readFile(tempFile)\n )\n else\n @run(\"emacs\", args, {ignoreReturnCode: false})\n .then(=>\n @readFile(tempFile)\n )\n```", "response": "/*\nRequires https://www.gnu.org/software/emacs/\n*/\n\"use strict\";\nvar Beautifier, FortranBeautifier, path;\n\nBeautifier = require('../beautifier');\n\npath = require(\"path\");\n\nmodule.exports = FortranBeautifier = (function() {\n class FortranBeautifier extends Beautifier {\n beautify(text, language, options) {\n var args, emacs_path, emacs_script_path, tempFile;\n this.debug('fortran-beautifier', options);\n emacs_path = options.emacs_path;\n emacs_script_path = options.emacs_script_path;\n if (!emacs_script_path) {\n emacs_script_path = path.resolve(__dirname, \"emacs-fortran-formating-script.lisp\");\n }\n this.debug('fortran-beautifier', 'emacs script path: ' + emacs_script_path);\n args = ['--batch', '-l', emacs_script_path, '-f', 'f90-batch-indent-region', tempFile = this.tempFile(\"temp\", text)];\n if (emacs_path) {\n return this.run(emacs_path, args, {\n ignoreReturnCode: false\n }).then(() => {\n return this.readFile(tempFile);\n });\n } else {\n return this.run(\"emacs\", args, {\n ignoreReturnCode: false\n }).then(() => {\n return this.readFile(tempFile);\n });\n }\n }\n\n };\n\n FortranBeautifier.prototype.name = \"Fortran Beautifier\";\n\n FortranBeautifier.prototype.link = \"https://www.gnu.org/software/emacs/\";\n\n FortranBeautifier.prototype.isPreInstalled = false;\n\n FortranBeautifier.prototype.options = {\n Fortran: true\n };\n\n return FortranBeautifier;\n\n}).call(this);", "source_lang": "CoffeeScript", "target_lang": "JavaScript", "repo": "Glavin001/atom-beautify", "path": "src/beautifiers/fortran-beautifier/index.coffee", "license": "MIT", "commit": "ba2198675cbcc1ecd05f18e28e97133cdd2d5319", "stars": 1503, "source_url": "https://github.com/Glavin001/atom-beautify/blob/ba2198675cbcc1ecd05f18e28e97133cdd2d5319/src/beautifiers/fortran-beautifier/index.coffee", "line_start": 1, "line_end": 47}25{"id": "Glavin001/atom-beautify:src/beautifiers/fortran-beautifier/index.coffee:1:js_to_coffee", "type": "js_to_coffee", "prompt": "Convert this JavaScript to CoffeeScript.\n```javascript\n/*\nRequires https://www.gnu.org/software/emacs/\n*/\n\"use strict\";\nvar Beautifier, FortranBeautifier, path;\n\nBeautifier = require('../beautifier');\n\npath = require(\"path\");\n\nmodule.exports = FortranBeautifier = (function() {\n class FortranBeautifier extends Beautifier {\n beautify(text, language, options) {\n var args, emacs_path, emacs_script_path, tempFile;\n this.debug('fortran-beautifier', options);\n emacs_path = options.emacs_path;\n emacs_script_path = options.emacs_script_path;\n if (!emacs_script_path) {\n emacs_script_path = path.resolve(__dirname, \"emacs-fortran-formating-script.lisp\");\n }\n this.debug('fortran-beautifier', 'emacs script path: ' + emacs_script_path);\n args = ['--batch', '-l', emacs_script_path, '-f', 'f90-batch-indent-region', tempFile = this.tempFile(\"temp\", text)];\n if (emacs_path) {\n return this.run(emacs_path, args, {\n ignoreReturnCode: false\n }).then(() => {\n return this.readFile(tempFile);\n });\n } else {\n return this.run(\"emacs\", args, {\n ignoreReturnCode: false\n }).then(() => {\n return this.readFile(tempFile);\n });\n }\n }\n\n };\n\n FortranBeautifier.prototype.name = \"Fortran Beautifier\";\n\n FortranBeautifier.prototype.link = \"https://www.gnu.org/software/emacs/\";\n\n FortranBeautifier.prototype.isPreInstalled = false;\n\n FortranBeautifier.prototype.options = {\n Fortran: true\n };\n\n return FortranBeautifier;\n\n}).call(this);\n```", "response": "###\nRequires https://www.gnu.org/software/emacs/\n###\n\n\"use strict\"\nBeautifier = require('../beautifier')\npath = require(\"path\")\n\nmodule.exports = class FortranBeautifier extends Beautifier\n name: \"Fortran Beautifier\"\n link: \"https://www.gnu.org/software/emacs/\"\n isPreInstalled: false\n\n options: {\n Fortran: true\n }\n\n beautify: (text, language, options) ->\n @debug('fortran-beautifier', options)\n\n emacs_path = options.emacs_path\n emacs_script_path = options.emacs_script_path\n\n if not emacs_script_path\n emacs_script_path = path.resolve(__dirname, \"emacs-fortran-formating-script.lisp\")\n\n @debug('fortran-beautifier', 'emacs script path: ' + emacs_script_path)\n\n args = [\n '--batch'\n '-l'\n emacs_script_path\n '-f'\n 'f90-batch-indent-region'\n tempFile = @tempFile(\"temp\", text)\n ]\n\n if emacs_path\n @run(emacs_path, args, {ignoreReturnCode: false})\n .then(=>\n @readFile(tempFile)\n )\n else\n @run(\"emacs\", args, {ignoreReturnCode: false})\n .then(=>\n @readFile(tempFile)\n )", "source_lang": "JavaScript", "target_lang": "CoffeeScript", "repo": "Glavin001/atom-beautify", "path": "src/beautifiers/fortran-beautifier/index.coffee", "license": "MIT", "commit": "ba2198675cbcc1ecd05f18e28e97133cdd2d5319", "stars": 1503, "source_url": "https://github.com/Glavin001/atom-beautify/blob/ba2198675cbcc1ecd05f18e28e97133cdd2d5319/src/beautifiers/fortran-beautifier/index.coffee", "line_start": 1, "line_end": 47}26{"id": "Glavin001/atom-beautify:src/beautifiers/fortran-beautifier/index.coffee:1:completion", "type": "completion", "prompt": "###\nRequires https://www.gnu.org/software/emacs/\n###\n\n\"use strict\"\nBeautifier = require('../beautifier')\npath = require(\"path\")\n\nmodule.exports = class FortranBeautifier extends Beautifier\n name: \"Fortran Beautifier\"\n link: \"https://www.gnu.org/software/emacs/\"\n isPreInstalled: false\n\n options: {\n Fortran: true\n }\n\n beautify: (text, language, options) ->\n @debug('fortran-beautifier', options)\n\n emacs_path = options.emacs_path\n emacs_script_path = options.emacs_script_path", "response": "if not emacs_script_path\n emacs_script_path = path.resolve(__dirname, \"emacs-fortran-formating-script.lisp\")\n\n @debug('fortran-beautifier', 'emacs script path: ' + emacs_script_path)\n\n args = [\n '--batch'\n '-l'\n emacs_script_path\n '-f'\n 'f90-batch-indent-region'\n tempFile = @tempFile(\"temp\", text)\n ]\n\n if emacs_path\n @run(emacs_path, args, {ignoreReturnCode: false})\n .then(=>\n @readFile(tempFile)\n )\n else\n @run(\"emacs\", args, {ignoreReturnCode: false})\n .then(=>\n @readFile(tempFile)\n )", "source_lang": "CoffeeScript", "target_lang": "CoffeeScript", "repo": "Glavin001/atom-beautify", "path": "src/beautifiers/fortran-beautifier/index.coffee", "license": "MIT", "commit": "ba2198675cbcc1ecd05f18e28e97133cdd2d5319", "stars": 1503, "source_url": "https://github.com/Glavin001/atom-beautify/blob/ba2198675cbcc1ecd05f18e28e97133cdd2d5319/src/beautifiers/fortran-beautifier/index.coffee", "line_start": 1, "line_end": 47}27{"id": "Leonidas-from-XIV/node-xml2js:src/xml2js.coffee:1:raw_corpus", "type": "raw_corpus", "prompt": "", "response": "\"use strict\"\n\ndefaults = require './defaults'\nbuilder = require './builder'\nparser = require './parser'\nprocessors = require './processors'\n\nexports.defaults = defaults.defaults\n\nexports.processors = processors\n\nclass exports.ValidationError extends Error\n constructor: (message) ->\n @message = message\n\nexports.Builder = builder.Builder\n\nexports.Parser = parser.Parser\n\nexports.parseString = parser.parseString\nexports.parseStringPromise = parser.parseStringPromise", "source_lang": "", "target_lang": "CoffeeScript", "repo": "Leonidas-from-XIV/node-xml2js", "path": "src/xml2js.coffee", "license": "MIT", "commit": "7173c245aab4c2b417cd4c24f0b54e697a369864", "stars": 4965, "source_url": "https://github.com/Leonidas-from-XIV/node-xml2js/blob/7173c245aab4c2b417cd4c24f0b54e697a369864/src/xml2js.coffee", "line_start": 1, "line_end": 21}28{"id": "Leonidas-from-XIV/node-xml2js:src/xml2js.coffee:1:completion", "type": "completion", "prompt": "\"use strict\"\n\ndefaults = require './defaults'\nbuilder = require './builder'\nparser = require './parser'\nprocessors = require './processors'\n\nexports.defaults = defaults.defaults\n\nexports.processors = processors", "response": "class exports.ValidationError extends Error\n constructor: (message) ->\n @message = message\n\nexports.Builder = builder.Builder\n\nexports.Parser = parser.Parser\n\nexports.parseString = parser.parseString\nexports.parseStringPromise = parser.parseStringPromise", "source_lang": "CoffeeScript", "target_lang": "CoffeeScript", "repo": "Leonidas-from-XIV/node-xml2js", "path": "src/xml2js.coffee", "license": "MIT", "commit": "7173c245aab4c2b417cd4c24f0b54e697a369864", "stars": 4965, "source_url": "https://github.com/Leonidas-from-XIV/node-xml2js/blob/7173c245aab4c2b417cd4c24f0b54e697a369864/src/xml2js.coffee", "line_start": 1, "line_end": 21}29{"id": "Leonidas-from-XIV/node-xml2js:src/xml2js.coffee:1:raw_corpus", "type": "raw_corpus", "prompt": "", "response": "\"use strict\"\n\ndefaults = require './defaults'\nbuilder = require './builder'\nparser = require './parser'\nprocessors = require './processors'\n\nexports.defaults = defaults.defaults\n\nexports.processors = processors\n\nclass exports.ValidationError extends Error\n constructor: (message) ->\n @message = message\n\nexports.Builder = builder.Builder\n\nexports.Parser = parser.Parser\n\nexports.parseString = parser.parseString", "source_lang": "", "target_lang": "CoffeeScript", "repo": "Leonidas-from-XIV/node-xml2js", "path": "src/xml2js.coffee", "license": "MIT", "commit": "57dca2f7fcf359d6505ce94d98921335935e83e7", "stars": 4965, "source_url": "https://github.com/Leonidas-from-XIV/node-xml2js/blob/57dca2f7fcf359d6505ce94d98921335935e83e7/src/xml2js.coffee", "line_start": 1, "line_end": 20}30{"id": "Leonidas-from-XIV/node-xml2js:src/xml2js.coffee:1:completion", "type": "completion", "prompt": "\"use strict\"\n\ndefaults = require './defaults'\nbuilder = require './builder'\nparser = require './parser'\nprocessors = require './processors'\n\nexports.defaults = defaults.defaults\n\nexports.processors = processors", "response": "class exports.ValidationError extends Error\n constructor: (message) ->\n @message = message\n\nexports.Builder = builder.Builder\n\nexports.Parser = parser.Parser\n\nexports.parseString = parser.parseString", "source_lang": "CoffeeScript", "target_lang": "CoffeeScript", "repo": "Leonidas-from-XIV/node-xml2js", "path": "src/xml2js.coffee", "license": "MIT", "commit": "57dca2f7fcf359d6505ce94d98921335935e83e7", "stars": 4965, "source_url": "https://github.com/Leonidas-from-XIV/node-xml2js/blob/57dca2f7fcf359d6505ce94d98921335935e83e7/src/xml2js.coffee", "line_start": 1, "line_end": 20}31{"id": "Leonidas-from-XIV/node-xml2js:src/xml2js.coffee:1:raw_corpus", "type": "raw_corpus", "prompt": "", "response": "isEmpty = (thing) ->\n return typeof thing is \"object\" && thing? && Object.keys(thing).length is 0\n\nexports.defaults =\n \"0.1\":\n explicitCharkey: false\n trim: true\n # normalize implicates trimming, just so you know\n normalize: true\n # normalize tag names to lower case\n normalizeTags: false\n # set default attribute object key\n attrkey: \"@\"\n # set default char object key\n charkey: \"#\"\n # always put child nodes in an array\n explicitArray: false\n # ignore all attributes regardless\n ignoreAttrs: false\n # merge attributes and child elements onto parent object. this may\n # cause collisions.\n mergeAttrs: false\n explicitRoot: false\n validator: null\n \"0.2\":\n explicitCharkey: false\n trim: false\n normalize: false\n normalizeTags: false\n attrkey: \"$\"\n charkey: \"_\"\n explicitArray: true\n ignoreAttrs: false\n mergeAttrs: false\n explicitRoot: true\n validator: null", "source_lang": "", "target_lang": "CoffeeScript", "repo": "Leonidas-from-XIV/node-xml2js", "path": "src/xml2js.coffee", "license": "MIT", "commit": "cd43a5ddaed4cd227561cab9a8c3fc7774f1d20d", "stars": 4965, "source_url": "https://github.com/Leonidas-from-XIV/node-xml2js/blob/cd43a5ddaed4cd227561cab9a8c3fc7774f1d20d/src/xml2js.coffee", "line_start": 5, "line_end": 40}32{"id": "Leonidas-from-XIV/node-xml2js:src/xml2js.coffee:1:coffee_to_js", "type": "coffee_to_js", "prompt": "Convert this CoffeeScript to JavaScript.\n```coffeescript\nisEmpty = (thing) ->\n return typeof thing is \"object\" && thing? && Object.keys(thing).length is 0\n\nexports.defaults =\n \"0.1\":\n explicitCharkey: false\n trim: true\n # normalize implicates trimming, just so you know\n normalize: true\n # normalize tag names to lower case\n normalizeTags: false\n # set default attribute object key\n attrkey: \"@\"\n # set default char object key\n charkey: \"#\"\n # always put child nodes in an array\n explicitArray: false\n # ignore all attributes regardless\n ignoreAttrs: false\n # merge attributes and child elements onto parent object. this may\n # cause collisions.\n mergeAttrs: false\n explicitRoot: false\n validator: null\n \"0.2\":\n explicitCharkey: false\n trim: false\n normalize: false\n normalizeTags: false\n attrkey: \"$\"\n charkey: \"_\"\n explicitArray: true\n ignoreAttrs: false\n mergeAttrs: false\n explicitRoot: true\n validator: null\n```", "response": "var isEmpty;\n\nisEmpty = function(thing) {\n return typeof thing === \"object\" && (thing != null) && Object.keys(thing).length === 0;\n};\n\nexports.defaults = {\n \"0.1\": {\n explicitCharkey: false,\n trim: true,\n // normalize implicates trimming, just so you know\n normalize: true,\n // normalize tag names to lower case\n normalizeTags: false,\n // set default attribute object key\n attrkey: \"@\",\n // set default char object key\n charkey: \"#\",\n // always put child nodes in an array\n explicitArray: false,\n // ignore all attributes regardless\n ignoreAttrs: false,\n // merge attributes and child elements onto parent object. this may\n // cause collisions.\n mergeAttrs: false,\n explicitRoot: false,\n validator: null\n },\n \"0.2\": {\n explicitCharkey: false,\n trim: false,\n normalize: false,\n normalizeTags: false,\n attrkey: \"$\",\n charkey: \"_\",\n explicitArray: true,\n ignoreAttrs: false,\n mergeAttrs: false,\n explicitRoot: true,\n validator: null\n }\n};", "source_lang": "CoffeeScript", "target_lang": "JavaScript", "repo": "Leonidas-from-XIV/node-xml2js", "path": "src/xml2js.coffee", "license": "MIT", "commit": "cd43a5ddaed4cd227561cab9a8c3fc7774f1d20d", "stars": 4965, "source_url": "https://github.com/Leonidas-from-XIV/node-xml2js/blob/cd43a5ddaed4cd227561cab9a8c3fc7774f1d20d/src/xml2js.coffee", "line_start": 5, "line_end": 40}33{"id": "Leonidas-from-XIV/node-xml2js:src/xml2js.coffee:1:js_to_coffee", "type": "js_to_coffee", "prompt": "Convert this JavaScript to CoffeeScript.\n```javascript\nvar isEmpty;\n\nisEmpty = function(thing) {\n return typeof thing === \"object\" && (thing != null) && Object.keys(thing).length === 0;\n};\n\nexports.defaults = {\n \"0.1\": {\n explicitCharkey: false,\n trim: true,\n // normalize implicates trimming, just so you know\n normalize: true,\n // normalize tag names to lower case\n normalizeTags: false,\n // set default attribute object key\n attrkey: \"@\",\n // set default char object key\n charkey: \"#\",\n // always put child nodes in an array\n explicitArray: false,\n // ignore all attributes regardless\n ignoreAttrs: false,\n // merge attributes and child elements onto parent object. this may\n // cause collisions.\n mergeAttrs: false,\n explicitRoot: false,\n validator: null\n },\n \"0.2\": {\n explicitCharkey: false,\n trim: false,\n normalize: false,\n normalizeTags: false,\n attrkey: \"$\",\n charkey: \"_\",\n explicitArray: true,\n ignoreAttrs: false,\n mergeAttrs: false,\n explicitRoot: true,\n validator: null\n }\n};\n```", "response": "isEmpty = (thing) ->\n return typeof thing is \"object\" && thing? && Object.keys(thing).length is 0\n\nexports.defaults =\n \"0.1\":\n explicitCharkey: false\n trim: true\n # normalize implicates trimming, just so you know\n normalize: true\n # normalize tag names to lower case\n normalizeTags: false\n # set default attribute object key\n attrkey: \"@\"\n # set default char object key\n charkey: \"#\"\n # always put child nodes in an array\n explicitArray: false\n # ignore all attributes regardless\n ignoreAttrs: false\n # merge attributes and child elements onto parent object. this may\n # cause collisions.\n mergeAttrs: false\n explicitRoot: false\n validator: null\n \"0.2\":\n explicitCharkey: false\n trim: false\n normalize: false\n normalizeTags: false\n attrkey: \"$\"\n charkey: \"_\"\n explicitArray: true\n ignoreAttrs: false\n mergeAttrs: false\n explicitRoot: true\n validator: null", "source_lang": "JavaScript", "target_lang": "CoffeeScript", "repo": "Leonidas-from-XIV/node-xml2js", "path": "src/xml2js.coffee", "license": "MIT", "commit": "cd43a5ddaed4cd227561cab9a8c3fc7774f1d20d", "stars": 4965, "source_url": "https://github.com/Leonidas-from-XIV/node-xml2js/blob/cd43a5ddaed4cd227561cab9a8c3fc7774f1d20d/src/xml2js.coffee", "line_start": 5, "line_end": 40}34{"id": "Leonidas-from-XIV/node-xml2js:src/xml2js.coffee:1:completion", "type": "completion", "prompt": "isEmpty = (thing) ->\n return typeof thing is \"object\" && thing? && Object.keys(thing).length is 0\n\nexports.defaults =\n \"0.1\":\n explicitCharkey: false\n trim: true\n # normalize implicates trimming, just so you know\n normalize: true\n # normalize tag names to lower case\n normalizeTags: false\n # set default attribute object key\n attrkey: \"@\"\n # set default char object key\n charkey: \"#\"\n # always put child nodes in an array\n explicitArray: false\n # ignore all attributes regardless", "response": "ignoreAttrs: false\n # merge attributes and child elements onto parent object. this may\n # cause collisions.\n mergeAttrs: false\n explicitRoot: false\n validator: null\n \"0.2\":\n explicitCharkey: false\n trim: false\n normalize: false\n normalizeTags: false\n attrkey: \"$\"\n charkey: \"_\"\n explicitArray: true\n ignoreAttrs: false\n mergeAttrs: false\n explicitRoot: true\n validator: null", "source_lang": "CoffeeScript", "target_lang": "CoffeeScript", "repo": "Leonidas-from-XIV/node-xml2js", "path": "src/xml2js.coffee", "license": "MIT", "commit": "cd43a5ddaed4cd227561cab9a8c3fc7774f1d20d", "stars": 4965, "source_url": "https://github.com/Leonidas-from-XIV/node-xml2js/blob/cd43a5ddaed4cd227561cab9a8c3fc7774f1d20d/src/xml2js.coffee", "line_start": 5, "line_end": 40}35{"id": "Leonidas-from-XIV/node-xml2js:src/xml2js.coffee:2:raw_corpus", "type": "raw_corpus", "prompt": "", "response": "class exports.ValidationError extends Error\n constructor: (message) ->\n @message = message", "source_lang": "", "target_lang": "CoffeeScript", "repo": "Leonidas-from-XIV/node-xml2js", "path": "src/xml2js.coffee", "license": "MIT", "commit": "cd43a5ddaed4cd227561cab9a8c3fc7774f1d20d", "stars": 4965, "source_url": "https://github.com/Leonidas-from-XIV/node-xml2js/blob/cd43a5ddaed4cd227561cab9a8c3fc7774f1d20d/src/xml2js.coffee", "line_start": 42, "line_end": 44}36{"id": "Leonidas-from-XIV/node-xml2js:src/xml2js.coffee:3:raw_corpus", "type": "raw_corpus", "prompt": "", "response": "class exports.Parser extends events.EventEmitter\n constructor: (opts) ->\n # copy this versions default options\n @options = {}\n @options[key] = value for own key, value of exports.defaults[\"0.2\"]\n # overwrite them with the specified options, if any\n @options[key] = value for own key, value of opts\n\n @reset()\n\n reset: =>\n # remove all previous listeners for events, to prevent event listener\n # accumulation\n @removeAllListeners()\n # make the SAX parser. tried trim and normalize, but they are not\n # very helpful\n @saxParser = sax.parser true, {\n trim: false,\n normalize: false\n }\n\n # emit one error event if the sax parser fails. this is mostly a hack, but\n # the sax parser isn't state of the art either.\n err = false\n @saxParser.onerror = (error) =>\n if ! err\n err = true\n @emit \"error\", error\n\n # always use the '#' key, even if there are no subkeys\n # setting this property by and is deprecated, yet still supported.\n # better pass it as explicitCharkey option to the constructor\n @EXPLICIT_CHARKEY = @options.explicitCharkey\n @resultObject = null\n stack = []\n # aliases, so we don't have to type so much\n attrkey = @options.attrkey\n charkey = @options.charkey\n\n @saxParser.onopentag = (node) =>\n obj = {}\n obj[charkey] = \"\"\n unless @options.ignoreAttrs\n for own key of node.attributes\n if attrkey not of obj and not @options.mergeAttrs\n obj[attrkey] = {}\n if @options.mergeAttrs\n obj[key] = node.attributes[key]\n else\n obj[attrkey][key] = node.attributes[key]", "source_lang": "", "target_lang": "CoffeeScript", "repo": "Leonidas-from-XIV/node-xml2js", "path": "src/xml2js.coffee", "license": "MIT", "commit": "cd43a5ddaed4cd227561cab9a8c3fc7774f1d20d", "stars": 4965, "source_url": "https://github.com/Leonidas-from-XIV/node-xml2js/blob/cd43a5ddaed4cd227561cab9a8c3fc7774f1d20d/src/xml2js.coffee", "line_start": 46, "line_end": 95}37{"id": "Leonidas-from-XIV/node-xml2js:src/xml2js.coffee:3:completion", "type": "completion", "prompt": "class exports.Parser extends events.EventEmitter\n constructor: (opts) ->\n # copy this versions default options\n @options = {}\n @options[key] = value for own key, value of exports.defaults[\"0.2\"]\n # overwrite them with the specified options, if any\n @options[key] = value for own key, value of opts\n\n @reset()\n\n reset: =>\n # remove all previous listeners for events, to prevent event listener\n # accumulation\n @removeAllListeners()\n # make the SAX parser. tried trim and normalize, but they are not\n # very helpful\n @saxParser = sax.parser true, {\n trim: false,\n normalize: false\n }\n\n # emit one error event if the sax parser fails. this is mostly a hack, but\n # the sax parser isn't state of the art either.\n err = false\n @saxParser.onerror = (error) =>", "response": "if ! err\n err = true\n @emit \"error\", error\n\n # always use the '#' key, even if there are no subkeys\n # setting this property by and is deprecated, yet still supported.\n # better pass it as explicitCharkey option to the constructor\n @EXPLICIT_CHARKEY = @options.explicitCharkey\n @resultObject = null\n stack = []\n # aliases, so we don't have to type so much\n attrkey = @options.attrkey\n charkey = @options.charkey\n\n @saxParser.onopentag = (node) =>\n obj = {}\n obj[charkey] = \"\"\n unless @options.ignoreAttrs\n for own key of node.attributes\n if attrkey not of obj and not @options.mergeAttrs\n obj[attrkey] = {}\n if @options.mergeAttrs\n obj[key] = node.attributes[key]\n else\n obj[attrkey][key] = node.attributes[key]", "source_lang": "CoffeeScript", "target_lang": "CoffeeScript", "repo": "Leonidas-from-XIV/node-xml2js", "path": "src/xml2js.coffee", "license": "MIT", "commit": "cd43a5ddaed4cd227561cab9a8c3fc7774f1d20d", "stars": 4965, "source_url": "https://github.com/Leonidas-from-XIV/node-xml2js/blob/cd43a5ddaed4cd227561cab9a8c3fc7774f1d20d/src/xml2js.coffee", "line_start": 46, "line_end": 95}38{"id": "Leonidas-from-XIV/node-xml2js:src/xml2js.coffee:4:raw_corpus", "type": "raw_corpus", "prompt": "", "response": "# need a place to store the node name\n obj[\"#name\"] = if @options.normalizeTags then node.name.toLowerCase() else node.name\n stack.push obj\n\n @saxParser.onclosetag = =>\n obj = stack.pop()\n nodeName = obj[\"#name\"]\n delete obj[\"#name\"]\n\n s = stack[stack.length - 1]\n # remove the '#' key altogether if it's blank\n if obj[charkey].match(/^\\s*$/)\n delete obj[charkey]\n else\n obj[charkey] = obj[charkey].trim() if @options.trim\n obj[charkey] = obj[charkey].replace(/\\s{2,}/g, \" \").trim() if @options.normalize\n # also do away with '#' key altogether, if there's no subkeys\n # unless EXPLICIT_CHARKEY is set\n if Object.keys(obj).length == 1 and charkey of obj and not @EXPLICIT_CHARKEY\n obj = obj[charkey]\n\n if @options.emptyTag != undefined && isEmpty obj\n obj = @options.emptyTag\n\n if @options.validator?\n xpath = \"/\" + (node[\"#name\"] for node in stack).concat(nodeName).join(\"/\")\n obj = @options.validator(xpath, s and s[nodeName], obj)\n\n # check whether we closed all the open tags\n if stack.length > 0\n if not @options.explicitArray\n if nodeName not of s\n s[nodeName] = obj\n else if s[nodeName] instanceof Array\n s[nodeName].push obj\n else\n old = s[nodeName]\n s[nodeName] = [old]\n s[nodeName].push obj\n else\n if not (s[nodeName] instanceof Array)\n s[nodeName] = []\n s[nodeName].push obj\n else\n # if explicitRoot was specified, wrap stuff in the root tag name\n if @options.explicitRoot\n # avoid circular references\n old = obj\n obj = {}", "source_lang": "", "target_lang": "CoffeeScript", "repo": "Leonidas-from-XIV/node-xml2js", "path": "src/xml2js.coffee", "license": "MIT", "commit": "cd43a5ddaed4cd227561cab9a8c3fc7774f1d20d", "stars": 4965, "source_url": "https://github.com/Leonidas-from-XIV/node-xml2js/blob/cd43a5ddaed4cd227561cab9a8c3fc7774f1d20d/src/xml2js.coffee", "line_start": 96, "line_end": 145}39{"id": "Leonidas-from-XIV/node-xml2js:src/xml2js.coffee:4:completion", "type": "completion", "prompt": "# need a place to store the node name\n obj[\"#name\"] = if @options.normalizeTags then node.name.toLowerCase() else node.name\n stack.push obj\n\n @saxParser.onclosetag = =>\n obj = stack.pop()\n nodeName = obj[\"#name\"]\n delete obj[\"#name\"]\n\n s = stack[stack.length - 1]\n # remove the '#' key altogether if it's blank\n if obj[charkey].match(/^\\s*$/)\n delete obj[charkey]\n else\n obj[charkey] = obj[charkey].trim() if @options.trim\n obj[charkey] = obj[charkey].replace(/\\s{2,}/g, \" \").trim() if @options.normalize\n # also do away with '#' key altogether, if there's no subkeys\n # unless EXPLICIT_CHARKEY is set\n if Object.keys(obj).length == 1 and charkey of obj and not @EXPLICIT_CHARKEY\n obj = obj[charkey]\n\n if @options.emptyTag != undefined && isEmpty obj\n obj = @options.emptyTag", "response": "if @options.validator?\n xpath = \"/\" + (node[\"#name\"] for node in stack).concat(nodeName).join(\"/\")\n obj = @options.validator(xpath, s and s[nodeName], obj)\n\n # check whether we closed all the open tags\n if stack.length > 0\n if not @options.explicitArray\n if nodeName not of s\n s[nodeName] = obj\n else if s[nodeName] instanceof Array\n s[nodeName].push obj\n else\n old = s[nodeName]\n s[nodeName] = [old]\n s[nodeName].push obj\n else\n if not (s[nodeName] instanceof Array)\n s[nodeName] = []\n s[nodeName].push obj\n else\n # if explicitRoot was specified, wrap stuff in the root tag name\n if @options.explicitRoot\n # avoid circular references\n old = obj\n obj = {}", "source_lang": "CoffeeScript", "target_lang": "CoffeeScript", "repo": "Leonidas-from-XIV/node-xml2js", "path": "src/xml2js.coffee", "license": "MIT", "commit": "cd43a5ddaed4cd227561cab9a8c3fc7774f1d20d", "stars": 4965, "source_url": "https://github.com/Leonidas-from-XIV/node-xml2js/blob/cd43a5ddaed4cd227561cab9a8c3fc7774f1d20d/src/xml2js.coffee", "line_start": 96, "line_end": 145}40{"id": "Leonidas-from-XIV/node-xml2js:src/xml2js.coffee:5:raw_corpus", "type": "raw_corpus", "prompt": "", "response": "obj[nodeName] = old\n\n @resultObject = obj\n @emit \"end\", @resultObject\n\n @saxParser.ontext = @saxParser.oncdata = (text) =>\n s = stack[stack.length - 1]\n if s\n s[charkey] += text\n\n parseString: (str, cb) =>\n if cb? and typeof cb is \"function\"\n @on \"end\", (result) ->\n @reset()\n cb null, result\n @on \"error\", (err) ->\n @reset()\n cb err\n\n if str.toString().trim() is ''\n @emit \"end\", null\n return true\n\n try\n @saxParser.write str.toString()\n catch ex\n if ex instanceof exports.ValidationError\n @emit(\"error\", ex.message)\n else\n throw ex", "source_lang": "", "target_lang": "CoffeeScript", "repo": "Leonidas-from-XIV/node-xml2js", "path": "src/xml2js.coffee", "license": "MIT", "commit": "cd43a5ddaed4cd227561cab9a8c3fc7774f1d20d", "stars": 4965, "source_url": "https://github.com/Leonidas-from-XIV/node-xml2js/blob/cd43a5ddaed4cd227561cab9a8c3fc7774f1d20d/src/xml2js.coffee", "line_start": 146, "line_end": 175}41{"id": "Leonidas-from-XIV/node-xml2js:src/xml2js.coffee:5:completion", "type": "completion", "prompt": "obj[nodeName] = old\n\n @resultObject = obj\n @emit \"end\", @resultObject\n\n @saxParser.ontext = @saxParser.oncdata = (text) =>\n s = stack[stack.length - 1]\n if s\n s[charkey] += text\n\n parseString: (str, cb) =>\n if cb? and typeof cb is \"function\"\n @on \"end\", (result) ->\n @reset()\n cb null, result", "response": "@on \"error\", (err) ->\n @reset()\n cb err\n\n if str.toString().trim() is ''\n @emit \"end\", null\n return true\n\n try\n @saxParser.write str.toString()\n catch ex\n if ex instanceof exports.ValidationError\n @emit(\"error\", ex.message)\n else\n throw ex", "source_lang": "CoffeeScript", "target_lang": "CoffeeScript", "repo": "Leonidas-from-XIV/node-xml2js", "path": "src/xml2js.coffee", "license": "MIT", "commit": "cd43a5ddaed4cd227561cab9a8c3fc7774f1d20d", "stars": 4965, "source_url": "https://github.com/Leonidas-from-XIV/node-xml2js/blob/cd43a5ddaed4cd227561cab9a8c3fc7774f1d20d/src/xml2js.coffee", "line_start": 146, "line_end": 175}42{"id": "Leonidas-from-XIV/node-xml2js:src/xml2js.coffee:1:raw_corpus", "type": "raw_corpus", "prompt": "", "response": "isEmpty = (thing) ->\n return typeof thing is \"object\" && thing? && Object.keys(thing).length is 0\n\nexports.defaults =\n \"0.1\":\n explicitCharkey: false\n trim: true\n # normalize implicates trimming, just so you know\n normalize: true\n # normalize tag names to lower case\n normalizeTags: false\n # set default attribute object key\n attrkey: \"@\"\n # set default char object key\n charkey: \"#\"\n # always put child nodes in an array\n explicitArray: false\n # ignore all attributes regardless\n ignoreAttrs: false\n # merge attributes and child elements onto parent object. this may\n # cause collisions.\n mergeAttrs: false\n explicitRoot: false\n validator: null\n \"0.2\":\n explicitCharkey: false\n trim: false\n normalize: false\n attrkey: \"$\"\n charkey: \"_\"\n explicitArray: true\n ignoreAttrs: false\n mergeAttrs: false\n explicitRoot: true\n validator: null", "source_lang": "", "target_lang": "CoffeeScript", "repo": "Leonidas-from-XIV/node-xml2js", "path": "src/xml2js.coffee", "license": "MIT", "commit": "048f20b78b4185adb2d4cd5a909e061a3ee882cd", "stars": 4965, "source_url": "https://github.com/Leonidas-from-XIV/node-xml2js/blob/048f20b78b4185adb2d4cd5a909e061a3ee882cd/src/xml2js.coffee", "line_start": 5, "line_end": 39}43{"id": "Leonidas-from-XIV/node-xml2js:src/xml2js.coffee:1:coffee_to_js", "type": "coffee_to_js", "prompt": "Convert this CoffeeScript to JavaScript.\n```coffeescript\nisEmpty = (thing) ->\n return typeof thing is \"object\" && thing? && Object.keys(thing).length is 0\n\nexports.defaults =\n \"0.1\":\n explicitCharkey: false\n trim: true\n # normalize implicates trimming, just so you know\n normalize: true\n # normalize tag names to lower case\n normalizeTags: false\n # set default attribute object key\n attrkey: \"@\"\n # set default char object key\n charkey: \"#\"\n # always put child nodes in an array\n explicitArray: false\n # ignore all attributes regardless\n ignoreAttrs: false\n # merge attributes and child elements onto parent object. this may\n # cause collisions.\n mergeAttrs: false\n explicitRoot: false\n validator: null\n \"0.2\":\n explicitCharkey: false\n trim: false\n normalize: false\n attrkey: \"$\"\n charkey: \"_\"\n explicitArray: true\n ignoreAttrs: false\n mergeAttrs: false\n explicitRoot: true\n validator: null\n```", "response": "var isEmpty;\n\nisEmpty = function(thing) {\n return typeof thing === \"object\" && (thing != null) && Object.keys(thing).length === 0;\n};\n\nexports.defaults = {\n \"0.1\": {\n explicitCharkey: false,\n trim: true,\n // normalize implicates trimming, just so you know\n normalize: true,\n // normalize tag names to lower case\n normalizeTags: false,\n // set default attribute object key\n attrkey: \"@\",\n // set default char object key\n charkey: \"#\",\n // always put child nodes in an array\n explicitArray: false,\n // ignore all attributes regardless\n ignoreAttrs: false,\n // merge attributes and child elements onto parent object. this may\n // cause collisions.\n mergeAttrs: false,\n explicitRoot: false,\n validator: null\n },\n \"0.2\": {\n explicitCharkey: false,\n trim: false,\n normalize: false,\n attrkey: \"$\",\n charkey: \"_\",\n explicitArray: true,\n ignoreAttrs: false,\n mergeAttrs: false,\n explicitRoot: true,\n validator: null\n }\n};", "source_lang": "CoffeeScript", "target_lang": "JavaScript", "repo": "Leonidas-from-XIV/node-xml2js", "path": "src/xml2js.coffee", "license": "MIT", "commit": "048f20b78b4185adb2d4cd5a909e061a3ee882cd", "stars": 4965, "source_url": "https://github.com/Leonidas-from-XIV/node-xml2js/blob/048f20b78b4185adb2d4cd5a909e061a3ee882cd/src/xml2js.coffee", "line_start": 5, "line_end": 39}44{"id": "Leonidas-from-XIV/node-xml2js:src/xml2js.coffee:1:js_to_coffee", "type": "js_to_coffee", "prompt": "Convert this JavaScript to CoffeeScript.\n```javascript\nvar isEmpty;\n\nisEmpty = function(thing) {\n return typeof thing === \"object\" && (thing != null) && Object.keys(thing).length === 0;\n};\n\nexports.defaults = {\n \"0.1\": {\n explicitCharkey: false,\n trim: true,\n // normalize implicates trimming, just so you know\n normalize: true,\n // normalize tag names to lower case\n normalizeTags: false,\n // set default attribute object key\n attrkey: \"@\",\n // set default char object key\n charkey: \"#\",\n // always put child nodes in an array\n explicitArray: false,\n // ignore all attributes regardless\n ignoreAttrs: false,\n // merge attributes and child elements onto parent object. this may\n // cause collisions.\n mergeAttrs: false,\n explicitRoot: false,\n validator: null\n },\n \"0.2\": {\n explicitCharkey: false,\n trim: false,\n normalize: false,\n attrkey: \"$\",\n charkey: \"_\",\n explicitArray: true,\n ignoreAttrs: false,\n mergeAttrs: false,\n explicitRoot: true,\n validator: null\n }\n};\n```", "response": "isEmpty = (thing) ->\n return typeof thing is \"object\" && thing? && Object.keys(thing).length is 0\n\nexports.defaults =\n \"0.1\":\n explicitCharkey: false\n trim: true\n # normalize implicates trimming, just so you know\n normalize: true\n # normalize tag names to lower case\n normalizeTags: false\n # set default attribute object key\n attrkey: \"@\"\n # set default char object key\n charkey: \"#\"\n # always put child nodes in an array\n explicitArray: false\n # ignore all attributes regardless\n ignoreAttrs: false\n # merge attributes and child elements onto parent object. this may\n # cause collisions.\n mergeAttrs: false\n explicitRoot: false\n validator: null\n \"0.2\":\n explicitCharkey: false\n trim: false\n normalize: false\n attrkey: \"$\"\n charkey: \"_\"\n explicitArray: true\n ignoreAttrs: false\n mergeAttrs: false\n explicitRoot: true\n validator: null", "source_lang": "JavaScript", "target_lang": "CoffeeScript", "repo": "Leonidas-from-XIV/node-xml2js", "path": "src/xml2js.coffee", "license": "MIT", "commit": "048f20b78b4185adb2d4cd5a909e061a3ee882cd", "stars": 4965, "source_url": "https://github.com/Leonidas-from-XIV/node-xml2js/blob/048f20b78b4185adb2d4cd5a909e061a3ee882cd/src/xml2js.coffee", "line_start": 5, "line_end": 39}45{"id": "Leonidas-from-XIV/node-xml2js:src/xml2js.coffee:1:completion", "type": "completion", "prompt": "isEmpty = (thing) ->\n return typeof thing is \"object\" && thing? && Object.keys(thing).length is 0\n\nexports.defaults =\n \"0.1\":\n explicitCharkey: false\n trim: true\n # normalize implicates trimming, just so you know\n normalize: true\n # normalize tag names to lower case\n normalizeTags: false\n # set default attribute object key\n attrkey: \"@\"\n # set default char object key\n charkey: \"#\"\n # always put child nodes in an array\n explicitArray: false", "response": "# ignore all attributes regardless\n ignoreAttrs: false\n # merge attributes and child elements onto parent object. this may\n # cause collisions.\n mergeAttrs: false\n explicitRoot: false\n validator: null\n \"0.2\":\n explicitCharkey: false\n trim: false\n normalize: false\n attrkey: \"$\"\n charkey: \"_\"\n explicitArray: true\n ignoreAttrs: false\n mergeAttrs: false\n explicitRoot: true\n validator: null", "source_lang": "CoffeeScript", "target_lang": "CoffeeScript", "repo": "Leonidas-from-XIV/node-xml2js", "path": "src/xml2js.coffee", "license": "MIT", "commit": "048f20b78b4185adb2d4cd5a909e061a3ee882cd", "stars": 4965, "source_url": "https://github.com/Leonidas-from-XIV/node-xml2js/blob/048f20b78b4185adb2d4cd5a909e061a3ee882cd/src/xml2js.coffee", "line_start": 5, "line_end": 39}46{"id": "Leonidas-from-XIV/node-xml2js:src/xml2js.coffee:4:raw_corpus", "type": "raw_corpus", "prompt": "", "response": "# need a place to store the node name\n obj[\"#name\"] = node.name\n stack.push obj\n\n @saxParser.onclosetag = =>\n obj = stack.pop()\n nodeName = obj[\"#name\"]\n delete obj[\"#name\"]\n\n if @options.normalizeTags\n nodeName = nodeName.toLowerCase()\n\n s = stack[stack.length - 1]\n # remove the '#' key altogether if it's blank\n if obj[charkey].match(/^\\s*$/)\n delete obj[charkey]\n else\n obj[charkey] = obj[charkey].trim() if @options.trim\n obj[charkey] = obj[charkey].replace(/\\s{2,}/g, \" \").trim() if @options.normalize\n # also do away with '#' key altogether, if there's no subkeys\n # unless EXPLICIT_CHARKEY is set\n if Object.keys(obj).length == 1 and charkey of obj and not @EXPLICIT_CHARKEY\n obj = obj[charkey]\n\n if @options.emptyTag != undefined && isEmpty obj\n obj = @options.emptyTag\n\n if @options.validator?\n xpath = \"/\" + (node[\"#name\"] for node in stack).concat(nodeName).join(\"/\")\n obj = @options.validator(xpath, s and s[nodeName], obj)\n\n # check whether we closed all the open tags\n if stack.length > 0\n if not @options.explicitArray\n if nodeName not of s\n s[nodeName] = obj\n else if s[nodeName] instanceof Array\n s[nodeName].push obj\n else\n old = s[nodeName]\n s[nodeName] = [old]\n s[nodeName].push obj\n else\n if not (s[nodeName] instanceof Array)\n s[nodeName] = []\n s[nodeName].push obj\n else\n # if explicitRoot was specified, wrap stuff in the root tag name\n if @options.explicitRoot", "source_lang": "", "target_lang": "CoffeeScript", "repo": "Leonidas-from-XIV/node-xml2js", "path": "src/xml2js.coffee", "license": "MIT", "commit": "048f20b78b4185adb2d4cd5a909e061a3ee882cd", "stars": 4965, "source_url": "https://github.com/Leonidas-from-XIV/node-xml2js/blob/048f20b78b4185adb2d4cd5a909e061a3ee882cd/src/xml2js.coffee", "line_start": 95, "line_end": 144}47{"id": "Leonidas-from-XIV/node-xml2js:src/xml2js.coffee:4:completion", "type": "completion", "prompt": "# need a place to store the node name\n obj[\"#name\"] = node.name\n stack.push obj\n\n @saxParser.onclosetag = =>\n obj = stack.pop()\n nodeName = obj[\"#name\"]\n delete obj[\"#name\"]\n\n if @options.normalizeTags\n nodeName = nodeName.toLowerCase()\n\n s = stack[stack.length - 1]\n # remove the '#' key altogether if it's blank\n if obj[charkey].match(/^\\s*$/)\n delete obj[charkey]\n else\n obj[charkey] = obj[charkey].trim() if @options.trim\n obj[charkey] = obj[charkey].replace(/\\s{2,}/g, \" \").trim() if @options.normalize\n # also do away with '#' key altogether, if there's no subkeys\n # unless EXPLICIT_CHARKEY is set\n if Object.keys(obj).length == 1 and charkey of obj and not @EXPLICIT_CHARKEY\n obj = obj[charkey]", "response": "if @options.emptyTag != undefined && isEmpty obj\n obj = @options.emptyTag\n\n if @options.validator?\n xpath = \"/\" + (node[\"#name\"] for node in stack).concat(nodeName).join(\"/\")\n obj = @options.validator(xpath, s and s[nodeName], obj)\n\n # check whether we closed all the open tags\n if stack.length > 0\n if not @options.explicitArray\n if nodeName not of s\n s[nodeName] = obj\n else if s[nodeName] instanceof Array\n s[nodeName].push obj\n else\n old = s[nodeName]\n s[nodeName] = [old]\n s[nodeName].push obj\n else\n if not (s[nodeName] instanceof Array)\n s[nodeName] = []\n s[nodeName].push obj\n else\n # if explicitRoot was specified, wrap stuff in the root tag name\n if @options.explicitRoot", "source_lang": "CoffeeScript", "target_lang": "CoffeeScript", "repo": "Leonidas-from-XIV/node-xml2js", "path": "src/xml2js.coffee", "license": "MIT", "commit": "048f20b78b4185adb2d4cd5a909e061a3ee882cd", "stars": 4965, "source_url": "https://github.com/Leonidas-from-XIV/node-xml2js/blob/048f20b78b4185adb2d4cd5a909e061a3ee882cd/src/xml2js.coffee", "line_start": 95, "line_end": 144}48{"id": "Leonidas-from-XIV/node-xml2js:src/xml2js.coffee:5:raw_corpus", "type": "raw_corpus", "prompt": "", "response": "# avoid circular references\n old = obj\n obj = {}\n obj[nodeName] = old\n\n @resultObject = obj\n @emit \"end\", @resultObject\n\n @saxParser.ontext = @saxParser.oncdata = (text) =>\n s = stack[stack.length - 1]\n if s\n s[charkey] += text\n\n parseString: (str, cb) =>\n if cb? and typeof cb is \"function\"\n @on \"end\", (result) ->\n @reset()\n cb null, result\n @on \"error\", (err) ->\n @reset()\n cb err\n\n if str.toString().trim() is ''\n @emit \"end\", null\n return true\n\n try\n @saxParser.write str.toString()\n catch ex\n if ex instanceof exports.ValidationError\n @emit(\"error\", ex.message)\n else\n throw ex", "source_lang": "", "target_lang": "CoffeeScript", "repo": "Leonidas-from-XIV/node-xml2js", "path": "src/xml2js.coffee", "license": "MIT", "commit": "048f20b78b4185adb2d4cd5a909e061a3ee882cd", "stars": 4965, "source_url": "https://github.com/Leonidas-from-XIV/node-xml2js/blob/048f20b78b4185adb2d4cd5a909e061a3ee882cd/src/xml2js.coffee", "line_start": 145, "line_end": 177}49{"id": "Leonidas-from-XIV/node-xml2js:src/xml2js.coffee:5:completion", "type": "completion", "prompt": "# avoid circular references\n old = obj\n obj = {}\n obj[nodeName] = old\n\n @resultObject = obj\n @emit \"end\", @resultObject\n\n @saxParser.ontext = @saxParser.oncdata = (text) =>\n s = stack[stack.length - 1]\n if s\n s[charkey] += text\n\n parseString: (str, cb) =>\n if cb? and typeof cb is \"function\"\n @on \"end\", (result) ->", "response": "@reset()\n cb null, result\n @on \"error\", (err) ->\n @reset()\n cb err\n\n if str.toString().trim() is ''\n @emit \"end\", null\n return true\n\n try\n @saxParser.write str.toString()\n catch ex\n if ex instanceof exports.ValidationError\n @emit(\"error\", ex.message)\n else\n throw ex", "source_lang": "CoffeeScript", "target_lang": "CoffeeScript", "repo": "Leonidas-from-XIV/node-xml2js", "path": "src/xml2js.coffee", "license": "MIT", "commit": "048f20b78b4185adb2d4cd5a909e061a3ee882cd", "stars": 4965, "source_url": "https://github.com/Leonidas-from-XIV/node-xml2js/blob/048f20b78b4185adb2d4cd5a909e061a3ee882cd/src/xml2js.coffee", "line_start": 145, "line_end": 177}50{"id": "Leonidas-from-XIV/node-xml2js:src/xml2js.coffee:1:raw_corpus", "type": "raw_corpus", "prompt": "", "response": "isEmpty = (thing) ->\n return typeof thing is \"object\" && thing? && Object.keys(thing).length is 0\n\nexports.defaults =\n \"0.1\":\n explicitCharkey: false\n trim: true\n # normalize implicates trimming, just so you know\n normalize: true\n # set default attribute object key\n attrkey: \"@\"\n # set default char object key\n charkey: \"#\"\n # always put child nodes in an array\n explicitArray: false\n # ignore all attributes regardless\n ignoreAttrs: false\n # merge attributes and child elements onto parent object. this may\n # cause collisions.\n mergeAttrs: false\n explicitRoot: false\n validator: null\n \"0.2\":\n explicitCharkey: false\n trim: false\n normalize: false\n attrkey: \"$\"\n charkey: \"_\"\n explicitArray: true\n ignoreAttrs: false\n mergeAttrs: false\n explicitRoot: true\n validator: null", "source_lang": "", "target_lang": "CoffeeScript", "repo": "Leonidas-from-XIV/node-xml2js", "path": "src/xml2js.coffee", "license": "MIT", "commit": "df32c2346bbdba268aa500643e484b3fbed71dc3", "stars": 4965, "source_url": "https://github.com/Leonidas-from-XIV/node-xml2js/blob/df32c2346bbdba268aa500643e484b3fbed71dc3/src/xml2js.coffee", "line_start": 5, "line_end": 37}51{"id": "Leonidas-from-XIV/node-xml2js:src/xml2js.coffee:1:coffee_to_js", "type": "coffee_to_js", "prompt": "Convert this CoffeeScript to JavaScript.\n```coffeescript\nisEmpty = (thing) ->\n return typeof thing is \"object\" && thing? && Object.keys(thing).length is 0\n\nexports.defaults =\n \"0.1\":\n explicitCharkey: false\n trim: true\n # normalize implicates trimming, just so you know\n normalize: true\n # set default attribute object key\n attrkey: \"@\"\n # set default char object key\n charkey: \"#\"\n # always put child nodes in an array\n explicitArray: false\n # ignore all attributes regardless\n ignoreAttrs: false\n # merge attributes and child elements onto parent object. this may\n # cause collisions.\n mergeAttrs: false\n explicitRoot: false\n validator: null\n \"0.2\":\n explicitCharkey: false\n trim: false\n normalize: false\n attrkey: \"$\"\n charkey: \"_\"\n explicitArray: true\n ignoreAttrs: false\n mergeAttrs: false\n explicitRoot: true\n validator: null\n```", "response": "var isEmpty;\n\nisEmpty = function(thing) {\n return typeof thing === \"object\" && (thing != null) && Object.keys(thing).length === 0;\n};\n\nexports.defaults = {\n \"0.1\": {\n explicitCharkey: false,\n trim: true,\n // normalize implicates trimming, just so you know\n normalize: true,\n // set default attribute object key\n attrkey: \"@\",\n // set default char object key\n charkey: \"#\",\n // always put child nodes in an array\n explicitArray: false,\n // ignore all attributes regardless\n ignoreAttrs: false,\n // merge attributes and child elements onto parent object. this may\n // cause collisions.\n mergeAttrs: false,\n explicitRoot: false,\n validator: null\n },\n \"0.2\": {\n explicitCharkey: false,\n trim: false,\n normalize: false,\n attrkey: \"$\",\n charkey: \"_\",\n explicitArray: true,\n ignoreAttrs: false,\n mergeAttrs: false,\n explicitRoot: true,\n validator: null\n }\n};", "source_lang": "CoffeeScript", "target_lang": "JavaScript", "repo": "Leonidas-from-XIV/node-xml2js", "path": "src/xml2js.coffee", "license": "MIT", "commit": "df32c2346bbdba268aa500643e484b3fbed71dc3", "stars": 4965, "source_url": "https://github.com/Leonidas-from-XIV/node-xml2js/blob/df32c2346bbdba268aa500643e484b3fbed71dc3/src/xml2js.coffee", "line_start": 5, "line_end": 37}52{"id": "Leonidas-from-XIV/node-xml2js:src/xml2js.coffee:1:js_to_coffee", "type": "js_to_coffee", "prompt": "Convert this JavaScript to CoffeeScript.\n```javascript\nvar isEmpty;\n\nisEmpty = function(thing) {\n return typeof thing === \"object\" && (thing != null) && Object.keys(thing).length === 0;\n};\n\nexports.defaults = {\n \"0.1\": {\n explicitCharkey: false,\n trim: true,\n // normalize implicates trimming, just so you know\n normalize: true,\n // set default attribute object key\n attrkey: \"@\",\n // set default char object key\n charkey: \"#\",\n // always put child nodes in an array\n explicitArray: false,\n // ignore all attributes regardless\n ignoreAttrs: false,\n // merge attributes and child elements onto parent object. this may\n // cause collisions.\n mergeAttrs: false,\n explicitRoot: false,\n validator: null\n },\n \"0.2\": {\n explicitCharkey: false,\n trim: false,\n normalize: false,\n attrkey: \"$\",\n charkey: \"_\",\n explicitArray: true,\n ignoreAttrs: false,\n mergeAttrs: false,\n explicitRoot: true,\n validator: null\n }\n};\n```", "response": "isEmpty = (thing) ->\n return typeof thing is \"object\" && thing? && Object.keys(thing).length is 0\n\nexports.defaults =\n \"0.1\":\n explicitCharkey: false\n trim: true\n # normalize implicates trimming, just so you know\n normalize: true\n # set default attribute object key\n attrkey: \"@\"\n # set default char object key\n charkey: \"#\"\n # always put child nodes in an array\n explicitArray: false\n # ignore all attributes regardless\n ignoreAttrs: false\n # merge attributes and child elements onto parent object. this may\n # cause collisions.\n mergeAttrs: false\n explicitRoot: false\n validator: null\n \"0.2\":\n explicitCharkey: false\n trim: false\n normalize: false\n attrkey: \"$\"\n charkey: \"_\"\n explicitArray: true\n ignoreAttrs: false\n mergeAttrs: false\n explicitRoot: true\n validator: null", "source_lang": "JavaScript", "target_lang": "CoffeeScript", "repo": "Leonidas-from-XIV/node-xml2js", "path": "src/xml2js.coffee", "license": "MIT", "commit": "df32c2346bbdba268aa500643e484b3fbed71dc3", "stars": 4965, "source_url": "https://github.com/Leonidas-from-XIV/node-xml2js/blob/df32c2346bbdba268aa500643e484b3fbed71dc3/src/xml2js.coffee", "line_start": 5, "line_end": 37}53{"id": "Leonidas-from-XIV/node-xml2js:src/xml2js.coffee:1:completion", "type": "completion", "prompt": "isEmpty = (thing) ->\n return typeof thing is \"object\" && thing? && Object.keys(thing).length is 0\n\nexports.defaults =\n \"0.1\":\n explicitCharkey: false\n trim: true\n # normalize implicates trimming, just so you know\n normalize: true\n # set default attribute object key\n attrkey: \"@\"\n # set default char object key\n charkey: \"#\"\n # always put child nodes in an array\n explicitArray: false\n # ignore all attributes regardless", "response": "ignoreAttrs: false\n # merge attributes and child elements onto parent object. this may\n # cause collisions.\n mergeAttrs: false\n explicitRoot: false\n validator: null\n \"0.2\":\n explicitCharkey: false\n trim: false\n normalize: false\n attrkey: \"$\"\n charkey: \"_\"\n explicitArray: true\n ignoreAttrs: false\n mergeAttrs: false\n explicitRoot: true\n validator: null", "source_lang": "CoffeeScript", "target_lang": "CoffeeScript", "repo": "Leonidas-from-XIV/node-xml2js", "path": "src/xml2js.coffee", "license": "MIT", "commit": "df32c2346bbdba268aa500643e484b3fbed71dc3", "stars": 4965, "source_url": "https://github.com/Leonidas-from-XIV/node-xml2js/blob/df32c2346bbdba268aa500643e484b3fbed71dc3/src/xml2js.coffee", "line_start": 5, "line_end": 37}54{"id": "Leonidas-from-XIV/node-xml2js:src/xml2js.coffee:4:raw_corpus", "type": "raw_corpus", "prompt": "", "response": "# need a place to store the node name\n obj[\"#name\"] = node.name\n stack.push obj\n\n @saxParser.onclosetag = =>\n obj = stack.pop()\n nodeName = obj[\"#name\"]\n delete obj[\"#name\"]\n\n s = stack[stack.length - 1]\n # remove the '#' key altogether if it's blank\n if obj[charkey].match(/^\\s*$/)\n delete obj[charkey]\n else\n obj[charkey] = obj[charkey].trim() if @options.trim\n obj[charkey] = obj[charkey].replace(/\\s{2,}/g, \" \").trim() if @options.normalize\n # also do away with '#' key altogether, if there's no subkeys\n # unless EXPLICIT_CHARKEY is set\n if Object.keys(obj).length == 1 and charkey of obj and not @EXPLICIT_CHARKEY\n obj = obj[charkey]\n\n if @options.emptyTag != undefined && isEmpty obj\n obj = @options.emptyTag\n\n if @options.validator?\n xpath = \"/\" + (node[\"#name\"] for node in stack).concat(nodeName).join(\"/\")\n obj = @options.validator(xpath, s and s[nodeName], obj)\n\n # check whether we closed all the open tags\n if stack.length > 0\n if not @options.explicitArray\n if nodeName not of s\n s[nodeName] = obj\n else if s[nodeName] instanceof Array\n s[nodeName].push obj\n else\n old = s[nodeName]\n s[nodeName] = [old]\n s[nodeName].push obj\n else\n if not (s[nodeName] instanceof Array)\n s[nodeName] = []\n s[nodeName].push obj\n else\n # if explicitRoot was specified, wrap stuff in the root tag name\n if @options.explicitRoot\n # avoid circular references\n old = obj\n obj = {}", "source_lang": "", "target_lang": "CoffeeScript", "repo": "Leonidas-from-XIV/node-xml2js", "path": "src/xml2js.coffee", "license": "MIT", "commit": "df32c2346bbdba268aa500643e484b3fbed71dc3", "stars": 4965, "source_url": "https://github.com/Leonidas-from-XIV/node-xml2js/blob/df32c2346bbdba268aa500643e484b3fbed71dc3/src/xml2js.coffee", "line_start": 93, "line_end": 142}55{"id": "Leonidas-from-XIV/node-xml2js:src/xml2js.coffee:4:completion", "type": "completion", "prompt": "# need a place to store the node name\n obj[\"#name\"] = node.name\n stack.push obj\n\n @saxParser.onclosetag = =>\n obj = stack.pop()\n nodeName = obj[\"#name\"]\n delete obj[\"#name\"]\n\n s = stack[stack.length - 1]\n # remove the '#' key altogether if it's blank\n if obj[charkey].match(/^\\s*$/)\n delete obj[charkey]\n else\n obj[charkey] = obj[charkey].trim() if @options.trim\n obj[charkey] = obj[charkey].replace(/\\s{2,}/g, \" \").trim() if @options.normalize\n # also do away with '#' key altogether, if there's no subkeys\n # unless EXPLICIT_CHARKEY is set\n if Object.keys(obj).length == 1 and charkey of obj and not @EXPLICIT_CHARKEY\n obj = obj[charkey]\n\n if @options.emptyTag != undefined && isEmpty obj\n obj = @options.emptyTag", "response": "if @options.validator?\n xpath = \"/\" + (node[\"#name\"] for node in stack).concat(nodeName).join(\"/\")\n obj = @options.validator(xpath, s and s[nodeName], obj)\n\n # check whether we closed all the open tags\n if stack.length > 0\n if not @options.explicitArray\n if nodeName not of s\n s[nodeName] = obj\n else if s[nodeName] instanceof Array\n s[nodeName].push obj\n else\n old = s[nodeName]\n s[nodeName] = [old]\n s[nodeName].push obj\n else\n if not (s[nodeName] instanceof Array)\n s[nodeName] = []\n s[nodeName].push obj\n else\n # if explicitRoot was specified, wrap stuff in the root tag name\n if @options.explicitRoot\n # avoid circular references\n old = obj\n obj = {}", "source_lang": "CoffeeScript", "target_lang": "CoffeeScript", "repo": "Leonidas-from-XIV/node-xml2js", "path": "src/xml2js.coffee", "license": "MIT", "commit": "df32c2346bbdba268aa500643e484b3fbed71dc3", "stars": 4965, "source_url": "https://github.com/Leonidas-from-XIV/node-xml2js/blob/df32c2346bbdba268aa500643e484b3fbed71dc3/src/xml2js.coffee", "line_start": 93, "line_end": 142}56{"id": "Leonidas-from-XIV/node-xml2js:src/xml2js.coffee:3:raw_corpus", "type": "raw_corpus", "prompt": "", "response": "class exports.Parser extends events.EventEmitter\n constructor: (opts) ->\n # copy this versions default options\n @options = {}\n @options[key] = value for own key, value of exports.defaults[\"0.1\"]\n # overwrite them with the specified options, if any\n @options[key] = value for own key, value of opts\n\n @reset()\n\n reset: =>\n # remove all previous listeners for events, to prevent event listener\n # accumulation\n @removeAllListeners()\n # make the SAX parser. tried trim and normalize, but they are not\n # very helpful\n @saxParser = sax.parser true, {\n trim: false,\n normalize: false\n }\n\n # emit one error event if the sax parser fails. this is mostly a hack, but\n # the sax parser isn't state of the art either.\n err = false\n @saxParser.onerror = (error) =>\n if ! err\n err = true\n @emit \"error\", error\n\n # always use the '#' key, even if there are no subkeys\n # setting this property by and is deprecated, yet still supported.\n # better pass it as explicitCharkey option to the constructor\n @EXPLICIT_CHARKEY = @options.explicitCharkey\n @resultObject = null\n stack = []\n # aliases, so we don't have to type so much\n attrkey = @options.attrkey\n charkey = @options.charkey\n\n @saxParser.onopentag = (node) =>\n obj = {}\n obj[charkey] = \"\"\n unless @options.ignoreAttrs\n for own key of node.attributes\n if attrkey not of obj and not @options.mergeAttrs\n obj[attrkey] = {}\n if @options.mergeAttrs\n obj[key] = node.attributes[key]\n else\n obj[attrkey][key] = node.attributes[key]", "source_lang": "", "target_lang": "CoffeeScript", "repo": "Leonidas-from-XIV/node-xml2js", "path": "src/xml2js.coffee", "license": "MIT", "commit": "1991d13c3a5308e7482ee1635aaa41c93ca05124", "stars": 4965, "source_url": "https://github.com/Leonidas-from-XIV/node-xml2js/blob/1991d13c3a5308e7482ee1635aaa41c93ca05124/src/xml2js.coffee", "line_start": 43, "line_end": 92}57{"id": "Leonidas-from-XIV/node-xml2js:src/xml2js.coffee:3:completion", "type": "completion", "prompt": "class exports.Parser extends events.EventEmitter\n constructor: (opts) ->\n # copy this versions default options\n @options = {}\n @options[key] = value for own key, value of exports.defaults[\"0.1\"]\n # overwrite them with the specified options, if any\n @options[key] = value for own key, value of opts\n\n @reset()\n\n reset: =>\n # remove all previous listeners for events, to prevent event listener\n # accumulation\n @removeAllListeners()\n # make the SAX parser. tried trim and normalize, but they are not\n # very helpful\n @saxParser = sax.parser true, {\n trim: false,\n normalize: false\n }\n\n # emit one error event if the sax parser fails. this is mostly a hack, but\n # the sax parser isn't state of the art either.\n err = false\n @saxParser.onerror = (error) =>", "response": "if ! err\n err = true\n @emit \"error\", error\n\n # always use the '#' key, even if there are no subkeys\n # setting this property by and is deprecated, yet still supported.\n # better pass it as explicitCharkey option to the constructor\n @EXPLICIT_CHARKEY = @options.explicitCharkey\n @resultObject = null\n stack = []\n # aliases, so we don't have to type so much\n attrkey = @options.attrkey\n charkey = @options.charkey\n\n @saxParser.onopentag = (node) =>\n obj = {}\n obj[charkey] = \"\"\n unless @options.ignoreAttrs\n for own key of node.attributes\n if attrkey not of obj and not @options.mergeAttrs\n obj[attrkey] = {}\n if @options.mergeAttrs\n obj[key] = node.attributes[key]\n else\n obj[attrkey][key] = node.attributes[key]", "source_lang": "CoffeeScript", "target_lang": "CoffeeScript", "repo": "Leonidas-from-XIV/node-xml2js", "path": "src/xml2js.coffee", "license": "MIT", "commit": "1991d13c3a5308e7482ee1635aaa41c93ca05124", "stars": 4965, "source_url": "https://github.com/Leonidas-from-XIV/node-xml2js/blob/1991d13c3a5308e7482ee1635aaa41c93ca05124/src/xml2js.coffee", "line_start": 43, "line_end": 92}58{"id": "Leonidas-from-XIV/node-xml2js:src/xml2js.coffee:1:raw_corpus", "type": "raw_corpus", "prompt": "", "response": "isEmpty = (thing) ->\n return typeof thing is \"object\" && thing? && Object.keys(thing).length is 0\n\nexports.defaults =\n \"0.1\":\n explicitCharkey: false\n trim: true\n # normalize implicates trimming, just so you know\n normalize: true\n # set default attribute object key\n attrkey: \"@\"\n # set default char object key\n charkey: \"#\"\n # always put child nodes in an array\n explicitArray: false\n # ignore all attributes regardless\n ignoreAttrs: false\n # merge attributes and child elements onto parent object. this may\n # cause collisions.\n mergeAttrs: false\n explicitRoot: false\n validator: null\n \"0.2\":\n explicitCharkey: false\n trim: false\n normalize: false\n attrkey: \"$\"\n # not sure if # is the best idea, will investigate\n charkey: \"#\"\n explicitArray: true\n ignoreAttrs: false\n mergeAttrs: false\n explicitRoot: true\n validator: null", "source_lang": "", "target_lang": "CoffeeScript", "repo": "Leonidas-from-XIV/node-xml2js", "path": "src/xml2js.coffee", "license": "MIT", "commit": "8de66fa66ac121915cfb64b65e16faaae55ca75a", "stars": 4965, "source_url": "https://github.com/Leonidas-from-XIV/node-xml2js/blob/8de66fa66ac121915cfb64b65e16faaae55ca75a/src/xml2js.coffee", "line_start": 5, "line_end": 38}59{"id": "Leonidas-from-XIV/node-xml2js:src/xml2js.coffee:1:coffee_to_js", "type": "coffee_to_js", "prompt": "Convert this CoffeeScript to JavaScript.\n```coffeescript\nisEmpty = (thing) ->\n return typeof thing is \"object\" && thing? && Object.keys(thing).length is 0\n\nexports.defaults =\n \"0.1\":\n explicitCharkey: false\n trim: true\n # normalize implicates trimming, just so you know\n normalize: true\n # set default attribute object key\n attrkey: \"@\"\n # set default char object key\n charkey: \"#\"\n # always put child nodes in an array\n explicitArray: false\n # ignore all attributes regardless\n ignoreAttrs: false\n # merge attributes and child elements onto parent object. this may\n # cause collisions.\n mergeAttrs: false\n explicitRoot: false\n validator: null\n \"0.2\":\n explicitCharkey: false\n trim: false\n normalize: false\n attrkey: \"$\"\n # not sure if # is the best idea, will investigate\n charkey: \"#\"\n explicitArray: true\n ignoreAttrs: false\n mergeAttrs: false\n explicitRoot: true\n validator: null\n```", "response": "var isEmpty;\n\nisEmpty = function(thing) {\n return typeof thing === \"object\" && (thing != null) && Object.keys(thing).length === 0;\n};\n\nexports.defaults = {\n \"0.1\": {\n explicitCharkey: false,\n trim: true,\n // normalize implicates trimming, just so you know\n normalize: true,\n // set default attribute object key\n attrkey: \"@\",\n // set default char object key\n charkey: \"#\",\n // always put child nodes in an array\n explicitArray: false,\n // ignore all attributes regardless\n ignoreAttrs: false,\n // merge attributes and child elements onto parent object. this may\n // cause collisions.\n mergeAttrs: false,\n explicitRoot: false,\n validator: null\n },\n \"0.2\": {\n explicitCharkey: false,\n trim: false,\n normalize: false,\n attrkey: \"$\",\n // not sure if # is the best idea, will investigate\n charkey: \"#\",\n explicitArray: true,\n ignoreAttrs: false,\n mergeAttrs: false,\n explicitRoot: true,\n validator: null\n }\n};", "source_lang": "CoffeeScript", "target_lang": "JavaScript", "repo": "Leonidas-from-XIV/node-xml2js", "path": "src/xml2js.coffee", "license": "MIT", "commit": "8de66fa66ac121915cfb64b65e16faaae55ca75a", "stars": 4965, "source_url": "https://github.com/Leonidas-from-XIV/node-xml2js/blob/8de66fa66ac121915cfb64b65e16faaae55ca75a/src/xml2js.coffee", "line_start": 5, "line_end": 38}60{"id": "Leonidas-from-XIV/node-xml2js:src/xml2js.coffee:1:js_to_coffee", "type": "js_to_coffee", "prompt": "Convert this JavaScript to CoffeeScript.\n```javascript\nvar isEmpty;\n\nisEmpty = function(thing) {\n return typeof thing === \"object\" && (thing != null) && Object.keys(thing).length === 0;\n};\n\nexports.defaults = {\n \"0.1\": {\n explicitCharkey: false,\n trim: true,\n // normalize implicates trimming, just so you know\n normalize: true,\n // set default attribute object key\n attrkey: \"@\",\n // set default char object key\n charkey: \"#\",\n // always put child nodes in an array\n explicitArray: false,\n // ignore all attributes regardless\n ignoreAttrs: false,\n // merge attributes and child elements onto parent object. this may\n // cause collisions.\n mergeAttrs: false,\n explicitRoot: false,\n validator: null\n },\n \"0.2\": {\n explicitCharkey: false,\n trim: false,\n normalize: false,\n attrkey: \"$\",\n // not sure if # is the best idea, will investigate\n charkey: \"#\",\n explicitArray: true,\n ignoreAttrs: false,\n mergeAttrs: false,\n explicitRoot: true,\n validator: null\n }\n};\n```", "response": "isEmpty = (thing) ->\n return typeof thing is \"object\" && thing? && Object.keys(thing).length is 0\n\nexports.defaults =\n \"0.1\":\n explicitCharkey: false\n trim: true\n # normalize implicates trimming, just so you know\n normalize: true\n # set default attribute object key\n attrkey: \"@\"\n # set default char object key\n charkey: \"#\"\n # always put child nodes in an array\n explicitArray: false\n # ignore all attributes regardless\n ignoreAttrs: false\n # merge attributes and child elements onto parent object. this may\n # cause collisions.\n mergeAttrs: false\n explicitRoot: false\n validator: null\n \"0.2\":\n explicitCharkey: false\n trim: false\n normalize: false\n attrkey: \"$\"\n # not sure if # is the best idea, will investigate\n charkey: \"#\"\n explicitArray: true\n ignoreAttrs: false\n mergeAttrs: false\n explicitRoot: true\n validator: null", "source_lang": "JavaScript", "target_lang": "CoffeeScript", "repo": "Leonidas-from-XIV/node-xml2js", "path": "src/xml2js.coffee", "license": "MIT", "commit": "8de66fa66ac121915cfb64b65e16faaae55ca75a", "stars": 4965, "source_url": "https://github.com/Leonidas-from-XIV/node-xml2js/blob/8de66fa66ac121915cfb64b65e16faaae55ca75a/src/xml2js.coffee", "line_start": 5, "line_end": 38}61{"id": "Leonidas-from-XIV/node-xml2js:src/xml2js.coffee:1:completion", "type": "completion", "prompt": "isEmpty = (thing) ->\n return typeof thing is \"object\" && thing? && Object.keys(thing).length is 0\n\nexports.defaults =\n \"0.1\":\n explicitCharkey: false\n trim: true\n # normalize implicates trimming, just so you know\n normalize: true\n # set default attribute object key\n attrkey: \"@\"\n # set default char object key\n charkey: \"#\"\n # always put child nodes in an array\n explicitArray: false\n # ignore all attributes regardless\n ignoreAttrs: false", "response": "# merge attributes and child elements onto parent object. this may\n # cause collisions.\n mergeAttrs: false\n explicitRoot: false\n validator: null\n \"0.2\":\n explicitCharkey: false\n trim: false\n normalize: false\n attrkey: \"$\"\n # not sure if # is the best idea, will investigate\n charkey: \"#\"\n explicitArray: true\n ignoreAttrs: false\n mergeAttrs: false\n explicitRoot: true\n validator: null", "source_lang": "CoffeeScript", "target_lang": "CoffeeScript", "repo": "Leonidas-from-XIV/node-xml2js", "path": "src/xml2js.coffee", "license": "MIT", "commit": "8de66fa66ac121915cfb64b65e16faaae55ca75a", "stars": 4965, "source_url": "https://github.com/Leonidas-from-XIV/node-xml2js/blob/8de66fa66ac121915cfb64b65e16faaae55ca75a/src/xml2js.coffee", "line_start": 5, "line_end": 38}62{"id": "Leonidas-from-XIV/node-xml2js:src/xml2js.coffee:1:raw_corpus", "type": "raw_corpus", "prompt": "", "response": "isEmpty = (thing) ->\n return typeof thing is \"object\" && thing? && Object.keys(thing).length is 0\n\nexports.defaults =\n \"0.1\":\n explicitCharkey: false\n trim: true\n # normalize implicates trimming, just so you know\n normalize: true\n # set default attribute object key\n attrkey: \"@\"\n # set default char object key\n charkey: \"#\"\n # always put child nodes in an array\n explicitArray: false\n # ignore all attributes regardless\n ignoreAttrs: false\n # merge attributes and child elements onto parent object. this may\n # cause collisions.\n mergeAttrs: false\n validator: null\n \"0.2\":\n explicitCharkey: false\n trim: false\n normalize: false\n attrkey: \"$\"\n # not sure if # is the best idea, will investigate\n charkey: \"#\"\n explicitArray: true\n ignoreAttrs: false\n mergeAttrs: false\n validator: null", "source_lang": "", "target_lang": "CoffeeScript", "repo": "Leonidas-from-XIV/node-xml2js", "path": "src/xml2js.coffee", "license": "MIT", "commit": "2164d82cf880871e0554c8dd8d1e39a7a7051002", "stars": 4965, "source_url": "https://github.com/Leonidas-from-XIV/node-xml2js/blob/2164d82cf880871e0554c8dd8d1e39a7a7051002/src/xml2js.coffee", "line_start": 5, "line_end": 36}63{"id": "Leonidas-from-XIV/node-xml2js:src/xml2js.coffee:1:coffee_to_js", "type": "coffee_to_js", "prompt": "Convert this CoffeeScript to JavaScript.\n```coffeescript\nisEmpty = (thing) ->\n return typeof thing is \"object\" && thing? && Object.keys(thing).length is 0\n\nexports.defaults =\n \"0.1\":\n explicitCharkey: false\n trim: true\n # normalize implicates trimming, just so you know\n normalize: true\n # set default attribute object key\n attrkey: \"@\"\n # set default char object key\n charkey: \"#\"\n # always put child nodes in an array\n explicitArray: false\n # ignore all attributes regardless\n ignoreAttrs: false\n # merge attributes and child elements onto parent object. this may\n # cause collisions.\n mergeAttrs: false\n validator: null\n \"0.2\":\n explicitCharkey: false\n trim: false\n normalize: false\n attrkey: \"$\"\n # not sure if # is the best idea, will investigate\n charkey: \"#\"\n explicitArray: true\n ignoreAttrs: false\n mergeAttrs: false\n validator: null\n```", "response": "var isEmpty;\n\nisEmpty = function(thing) {\n return typeof thing === \"object\" && (thing != null) && Object.keys(thing).length === 0;\n};\n\nexports.defaults = {\n \"0.1\": {\n explicitCharkey: false,\n trim: true,\n // normalize implicates trimming, just so you know\n normalize: true,\n // set default attribute object key\n attrkey: \"@\",\n // set default char object key\n charkey: \"#\",\n // always put child nodes in an array\n explicitArray: false,\n // ignore all attributes regardless\n ignoreAttrs: false,\n // merge attributes and child elements onto parent object. this may\n // cause collisions.\n mergeAttrs: false,\n validator: null\n },\n \"0.2\": {\n explicitCharkey: false,\n trim: false,\n normalize: false,\n attrkey: \"$\",\n // not sure if # is the best idea, will investigate\n charkey: \"#\",\n explicitArray: true,\n ignoreAttrs: false,\n mergeAttrs: false,\n validator: null\n }\n};", "source_lang": "CoffeeScript", "target_lang": "JavaScript", "repo": "Leonidas-from-XIV/node-xml2js", "path": "src/xml2js.coffee", "license": "MIT", "commit": "2164d82cf880871e0554c8dd8d1e39a7a7051002", "stars": 4965, "source_url": "https://github.com/Leonidas-from-XIV/node-xml2js/blob/2164d82cf880871e0554c8dd8d1e39a7a7051002/src/xml2js.coffee", "line_start": 5, "line_end": 36}64{"id": "Leonidas-from-XIV/node-xml2js:src/xml2js.coffee:1:js_to_coffee", "type": "js_to_coffee", "prompt": "Convert this JavaScript to CoffeeScript.\n```javascript\nvar isEmpty;\n\nisEmpty = function(thing) {\n return typeof thing === \"object\" && (thing != null) && Object.keys(thing).length === 0;\n};\n\nexports.defaults = {\n \"0.1\": {\n explicitCharkey: false,\n trim: true,\n // normalize implicates trimming, just so you know\n normalize: true,\n // set default attribute object key\n attrkey: \"@\",\n // set default char object key\n charkey: \"#\",\n // always put child nodes in an array\n explicitArray: false,\n // ignore all attributes regardless\n ignoreAttrs: false,\n // merge attributes and child elements onto parent object. this may\n // cause collisions.\n mergeAttrs: false,\n validator: null\n },\n \"0.2\": {\n explicitCharkey: false,\n trim: false,\n normalize: false,\n attrkey: \"$\",\n // not sure if # is the best idea, will investigate\n charkey: \"#\",\n explicitArray: true,\n ignoreAttrs: false,\n mergeAttrs: false,\n validator: null\n }\n};\n```", "response": "isEmpty = (thing) ->\n return typeof thing is \"object\" && thing? && Object.keys(thing).length is 0\n\nexports.defaults =\n \"0.1\":\n explicitCharkey: false\n trim: true\n # normalize implicates trimming, just so you know\n normalize: true\n # set default attribute object key\n attrkey: \"@\"\n # set default char object key\n charkey: \"#\"\n # always put child nodes in an array\n explicitArray: false\n # ignore all attributes regardless\n ignoreAttrs: false\n # merge attributes and child elements onto parent object. this may\n # cause collisions.\n mergeAttrs: false\n validator: null\n \"0.2\":\n explicitCharkey: false\n trim: false\n normalize: false\n attrkey: \"$\"\n # not sure if # is the best idea, will investigate\n charkey: \"#\"\n explicitArray: true\n ignoreAttrs: false\n mergeAttrs: false\n validator: null", "source_lang": "JavaScript", "target_lang": "CoffeeScript", "repo": "Leonidas-from-XIV/node-xml2js", "path": "src/xml2js.coffee", "license": "MIT", "commit": "2164d82cf880871e0554c8dd8d1e39a7a7051002", "stars": 4965, "source_url": "https://github.com/Leonidas-from-XIV/node-xml2js/blob/2164d82cf880871e0554c8dd8d1e39a7a7051002/src/xml2js.coffee", "line_start": 5, "line_end": 36}65{"id": "Leonidas-from-XIV/node-xml2js:src/xml2js.coffee:1:completion", "type": "completion", "prompt": "isEmpty = (thing) ->\n return typeof thing is \"object\" && thing? && Object.keys(thing).length is 0\n\nexports.defaults =\n \"0.1\":\n explicitCharkey: false\n trim: true\n # normalize implicates trimming, just so you know\n normalize: true\n # set default attribute object key\n attrkey: \"@\"\n # set default char object key\n charkey: \"#\"\n # always put child nodes in an array\n explicitArray: false\n # ignore all attributes regardless", "response": "ignoreAttrs: false\n # merge attributes and child elements onto parent object. this may\n # cause collisions.\n mergeAttrs: false\n validator: null\n \"0.2\":\n explicitCharkey: false\n trim: false\n normalize: false\n attrkey: \"$\"\n # not sure if # is the best idea, will investigate\n charkey: \"#\"\n explicitArray: true\n ignoreAttrs: false\n mergeAttrs: false\n validator: null", "source_lang": "CoffeeScript", "target_lang": "CoffeeScript", "repo": "Leonidas-from-XIV/node-xml2js", "path": "src/xml2js.coffee", "license": "MIT", "commit": "2164d82cf880871e0554c8dd8d1e39a7a7051002", "stars": 4965, "source_url": "https://github.com/Leonidas-from-XIV/node-xml2js/blob/2164d82cf880871e0554c8dd8d1e39a7a7051002/src/xml2js.coffee", "line_start": 5, "line_end": 36}66{"id": "Leonidas-from-XIV/node-xml2js:src/xml2js.coffee:1:raw_corpus", "type": "raw_corpus", "prompt": "", "response": "isEmpty = (thing) ->\n return typeof thing is \"object\" && thing? && Object.keys(thing).length is 0\n\nexports.defaults =\n \"0.1\":\n explicitCharkey: false\n trim: true\n # normalize implicates trimming, just so you know\n normalize: true\n # set default attribute object key\n attrkey: \"@\"\n # set default char object key\n charkey: \"#\"\n # always put child nodes in an array\n explicitArray: false\n # ignore all attributes regardless\n ignoreAttrs: false\n # merge attributes and child elements onto parent object. this may\n # cause collisions.\n mergeAttrs: false\n \"0.2\":\n explicitCharkey: false\n trim: false\n normalize: false\n attrkey: \"$\"\n # not sure if # is the best idea, will investigate\n charkey: \"#\"\n explicitArray: true\n ignoreAttrs: false\n mergeAttrs: false", "source_lang": "", "target_lang": "CoffeeScript", "repo": "Leonidas-from-XIV/node-xml2js", "path": "src/xml2js.coffee", "license": "MIT", "commit": "16084e47b0b13355828cac3503f43492a6d55581", "stars": 4965, "source_url": "https://github.com/Leonidas-from-XIV/node-xml2js/blob/16084e47b0b13355828cac3503f43492a6d55581/src/xml2js.coffee", "line_start": 5, "line_end": 34}67{"id": "Leonidas-from-XIV/node-xml2js:src/xml2js.coffee:1:coffee_to_js", "type": "coffee_to_js", "prompt": "Convert this CoffeeScript to JavaScript.\n```coffeescript\nisEmpty = (thing) ->\n return typeof thing is \"object\" && thing? && Object.keys(thing).length is 0\n\nexports.defaults =\n \"0.1\":\n explicitCharkey: false\n trim: true\n # normalize implicates trimming, just so you know\n normalize: true\n # set default attribute object key\n attrkey: \"@\"\n # set default char object key\n charkey: \"#\"\n # always put child nodes in an array\n explicitArray: false\n # ignore all attributes regardless\n ignoreAttrs: false\n # merge attributes and child elements onto parent object. this may\n # cause collisions.\n mergeAttrs: false\n \"0.2\":\n explicitCharkey: false\n trim: false\n normalize: false\n attrkey: \"$\"\n # not sure if # is the best idea, will investigate\n charkey: \"#\"\n explicitArray: true\n ignoreAttrs: false\n mergeAttrs: false\n```", "response": "var isEmpty;\n\nisEmpty = function(thing) {\n return typeof thing === \"object\" && (thing != null) && Object.keys(thing).length === 0;\n};\n\nexports.defaults = {\n \"0.1\": {\n explicitCharkey: false,\n trim: true,\n // normalize implicates trimming, just so you know\n normalize: true,\n // set default attribute object key\n attrkey: \"@\",\n // set default char object key\n charkey: \"#\",\n // always put child nodes in an array\n explicitArray: false,\n // ignore all attributes regardless\n ignoreAttrs: false,\n // merge attributes and child elements onto parent object. this may\n // cause collisions.\n mergeAttrs: false\n },\n \"0.2\": {\n explicitCharkey: false,\n trim: false,\n normalize: false,\n attrkey: \"$\",\n // not sure if # is the best idea, will investigate\n charkey: \"#\",\n explicitArray: true,\n ignoreAttrs: false,\n mergeAttrs: false\n }\n};", "source_lang": "CoffeeScript", "target_lang": "JavaScript", "repo": "Leonidas-from-XIV/node-xml2js", "path": "src/xml2js.coffee", "license": "MIT", "commit": "16084e47b0b13355828cac3503f43492a6d55581", "stars": 4965, "source_url": "https://github.com/Leonidas-from-XIV/node-xml2js/blob/16084e47b0b13355828cac3503f43492a6d55581/src/xml2js.coffee", "line_start": 5, "line_end": 34}68{"id": "Leonidas-from-XIV/node-xml2js:src/xml2js.coffee:1:js_to_coffee", "type": "js_to_coffee", "prompt": "Convert this JavaScript to CoffeeScript.\n```javascript\nvar isEmpty;\n\nisEmpty = function(thing) {\n return typeof thing === \"object\" && (thing != null) && Object.keys(thing).length === 0;\n};\n\nexports.defaults = {\n \"0.1\": {\n explicitCharkey: false,\n trim: true,\n // normalize implicates trimming, just so you know\n normalize: true,\n // set default attribute object key\n attrkey: \"@\",\n // set default char object key\n charkey: \"#\",\n // always put child nodes in an array\n explicitArray: false,\n // ignore all attributes regardless\n ignoreAttrs: false,\n // merge attributes and child elements onto parent object. this may\n // cause collisions.\n mergeAttrs: false\n },\n \"0.2\": {\n explicitCharkey: false,\n trim: false,\n normalize: false,\n attrkey: \"$\",\n // not sure if # is the best idea, will investigate\n charkey: \"#\",\n explicitArray: true,\n ignoreAttrs: false,\n mergeAttrs: false\n }\n};\n```", "response": "isEmpty = (thing) ->\n return typeof thing is \"object\" && thing? && Object.keys(thing).length is 0\n\nexports.defaults =\n \"0.1\":\n explicitCharkey: false\n trim: true\n # normalize implicates trimming, just so you know\n normalize: true\n # set default attribute object key\n attrkey: \"@\"\n # set default char object key\n charkey: \"#\"\n # always put child nodes in an array\n explicitArray: false\n # ignore all attributes regardless\n ignoreAttrs: false\n # merge attributes and child elements onto parent object. this may\n # cause collisions.\n mergeAttrs: false\n \"0.2\":\n explicitCharkey: false\n trim: false\n normalize: false\n attrkey: \"$\"\n # not sure if # is the best idea, will investigate\n charkey: \"#\"\n explicitArray: true\n ignoreAttrs: false\n mergeAttrs: false", "source_lang": "JavaScript", "target_lang": "CoffeeScript", "repo": "Leonidas-from-XIV/node-xml2js", "path": "src/xml2js.coffee", "license": "MIT", "commit": "16084e47b0b13355828cac3503f43492a6d55581", "stars": 4965, "source_url": "https://github.com/Leonidas-from-XIV/node-xml2js/blob/16084e47b0b13355828cac3503f43492a6d55581/src/xml2js.coffee", "line_start": 5, "line_end": 34}69{"id": "Leonidas-from-XIV/node-xml2js:src/xml2js.coffee:1:completion", "type": "completion", "prompt": "isEmpty = (thing) ->\n return typeof thing is \"object\" && thing? && Object.keys(thing).length is 0\n\nexports.defaults =\n \"0.1\":\n explicitCharkey: false\n trim: true\n # normalize implicates trimming, just so you know\n normalize: true\n # set default attribute object key\n attrkey: \"@\"\n # set default char object key\n charkey: \"#\"\n # always put child nodes in an array\n explicitArray: false", "response": "# ignore all attributes regardless\n ignoreAttrs: false\n # merge attributes and child elements onto parent object. this may\n # cause collisions.\n mergeAttrs: false\n \"0.2\":\n explicitCharkey: false\n trim: false\n normalize: false\n attrkey: \"$\"\n # not sure if # is the best idea, will investigate\n charkey: \"#\"\n explicitArray: true\n ignoreAttrs: false\n mergeAttrs: false", "source_lang": "CoffeeScript", "target_lang": "CoffeeScript", "repo": "Leonidas-from-XIV/node-xml2js", "path": "src/xml2js.coffee", "license": "MIT", "commit": "16084e47b0b13355828cac3503f43492a6d55581", "stars": 4965, "source_url": "https://github.com/Leonidas-from-XIV/node-xml2js/blob/16084e47b0b13355828cac3503f43492a6d55581/src/xml2js.coffee", "line_start": 5, "line_end": 34}70{"id": "Leonidas-from-XIV/node-xml2js:src/xml2js.coffee:2:raw_corpus", "type": "raw_corpus", "prompt": "", "response": "class exports.Parser extends events.EventEmitter\n constructor: (opts) ->\n # copy this versions default options\n @options = value for own key, value of exports.defaults[\"0.1\"]\n # overwrite them with the specified options, if any\n @options[key] = value for own key, value of opts\n\n @reset()\n\n reset: =>\n # remove all previous listeners for events, to prevent event listener\n # accumulation\n @removeAllListeners()\n # make the SAX parser. tried trim and normalize, but they are not\n # very helpful\n @saxParser = sax.parser true, {\n trim: false,\n normalize: false\n }\n\n # emit one error event if the sax parser fails. this is mostly a hack, but\n # the sax parser isn't state of the art either.\n err = false\n @saxParser.onerror = (error) =>\n if ! err\n err = true\n @emit \"error\", error\n\n # always use the '#' key, even if there are no subkeys\n # setting this property by and is deprecated, yet still supported.\n # better pass it as explicitCharkey option to the constructor\n @EXPLICIT_CHARKEY = @options.explicitCharkey\n @resultObject = null\n stack = []\n # aliases, so we don't have to type so much\n attrkey = @options.attrkey\n charkey = @options.charkey\n\n @saxParser.onopentag = (node) =>\n obj = {}\n obj[charkey] = \"\"\n unless @options.ignoreAttrs\n for own key of node.attributes\n if attrkey not of obj and not @options.mergeAttrs\n obj[attrkey] = {}\n if @options.mergeAttrs\n obj[key] = node.attributes[key]\n else\n obj[attrkey][key] = node.attributes[key]", "source_lang": "", "target_lang": "CoffeeScript", "repo": "Leonidas-from-XIV/node-xml2js", "path": "src/xml2js.coffee", "license": "MIT", "commit": "16084e47b0b13355828cac3503f43492a6d55581", "stars": 4965, "source_url": "https://github.com/Leonidas-from-XIV/node-xml2js/blob/16084e47b0b13355828cac3503f43492a6d55581/src/xml2js.coffee", "line_start": 36, "line_end": 85}71{"id": "Leonidas-from-XIV/node-xml2js:src/xml2js.coffee:2:completion", "type": "completion", "prompt": "class exports.Parser extends events.EventEmitter\n constructor: (opts) ->\n # copy this versions default options\n @options = value for own key, value of exports.defaults[\"0.1\"]\n # overwrite them with the specified options, if any\n @options[key] = value for own key, value of opts\n\n @reset()\n\n reset: =>\n # remove all previous listeners for events, to prevent event listener\n # accumulation\n @removeAllListeners()\n # make the SAX parser. tried trim and normalize, but they are not\n # very helpful\n @saxParser = sax.parser true, {\n trim: false,\n normalize: false\n }\n\n # emit one error event if the sax parser fails. this is mostly a hack, but\n # the sax parser isn't state of the art either.\n err = false\n @saxParser.onerror = (error) =>", "response": "if ! err\n err = true\n @emit \"error\", error\n\n # always use the '#' key, even if there are no subkeys\n # setting this property by and is deprecated, yet still supported.\n # better pass it as explicitCharkey option to the constructor\n @EXPLICIT_CHARKEY = @options.explicitCharkey\n @resultObject = null\n stack = []\n # aliases, so we don't have to type so much\n attrkey = @options.attrkey\n charkey = @options.charkey\n\n @saxParser.onopentag = (node) =>\n obj = {}\n obj[charkey] = \"\"\n unless @options.ignoreAttrs\n for own key of node.attributes\n if attrkey not of obj and not @options.mergeAttrs\n obj[attrkey] = {}\n if @options.mergeAttrs\n obj[key] = node.attributes[key]\n else\n obj[attrkey][key] = node.attributes[key]", "source_lang": "CoffeeScript", "target_lang": "CoffeeScript", "repo": "Leonidas-from-XIV/node-xml2js", "path": "src/xml2js.coffee", "license": "MIT", "commit": "16084e47b0b13355828cac3503f43492a6d55581", "stars": 4965, "source_url": "https://github.com/Leonidas-from-XIV/node-xml2js/blob/16084e47b0b13355828cac3503f43492a6d55581/src/xml2js.coffee", "line_start": 36, "line_end": 85}72{"id": "Leonidas-from-XIV/node-xml2js:src/xml2js.coffee:3:raw_corpus", "type": "raw_corpus", "prompt": "", "response": "# need a place to store the node name\n obj[\"#name\"] = node.name\n stack.push obj\n\n @saxParser.onclosetag = =>\n obj = stack.pop()\n nodeName = obj[\"#name\"]\n delete obj[\"#name\"]\n\n s = stack[stack.length - 1]\n # remove the '#' key altogether if it's blank\n if obj[charkey].match(/^\\s*$/)\n delete obj[charkey]\n else\n obj[charkey] = obj[charkey].trim() if @options.trim\n obj[charkey] = obj[charkey].replace(/\\s{2,}/g, \" \").trim() if @options.normalize\n # also do away with '#' key altogether, if there's no subkeys\n # unless EXPLICIT_CHARKEY is set\n if Object.keys(obj).length == 1 and charkey of obj and not @EXPLICIT_CHARKEY\n obj = obj[charkey]\n\n if @options.emptyTag != undefined && isEmpty obj\n obj = @options.emptyTag\n\n # check whether we closed all the open tags\n if stack.length > 0\n if not @options.explicitArray\n if nodeName not of s\n s[nodeName] = obj\n else if s[nodeName] instanceof Array\n s[nodeName].push obj\n else\n old = s[nodeName]\n s[nodeName] = [old]\n s[nodeName].push obj\n else\n if not (s[nodeName] instanceof Array)\n s[nodeName] = []\n s[nodeName].push obj\n else\n # if explicitRoot was specified, wrap stuff in the root tag name\n if @options.explicitRoot\n # avoid circular references\n old = obj\n obj = {}\n obj[nodeName] = old\n\n @resultObject = obj\n @emit \"end\", @resultObject", "source_lang": "", "target_lang": "CoffeeScript", "repo": "Leonidas-from-XIV/node-xml2js", "path": "src/xml2js.coffee", "license": "MIT", "commit": "16084e47b0b13355828cac3503f43492a6d55581", "stars": 4965, "source_url": "https://github.com/Leonidas-from-XIV/node-xml2js/blob/16084e47b0b13355828cac3503f43492a6d55581/src/xml2js.coffee", "line_start": 86, "line_end": 135}73{"id": "Leonidas-from-XIV/node-xml2js:src/xml2js.coffee:3:completion", "type": "completion", "prompt": "# need a place to store the node name\n obj[\"#name\"] = node.name\n stack.push obj\n\n @saxParser.onclosetag = =>\n obj = stack.pop()\n nodeName = obj[\"#name\"]\n delete obj[\"#name\"]\n\n s = stack[stack.length - 1]\n # remove the '#' key altogether if it's blank\n if obj[charkey].match(/^\\s*$/)\n delete obj[charkey]\n else\n obj[charkey] = obj[charkey].trim() if @options.trim\n obj[charkey] = obj[charkey].replace(/\\s{2,}/g, \" \").trim() if @options.normalize\n # also do away with '#' key altogether, if there's no subkeys\n # unless EXPLICIT_CHARKEY is set\n if Object.keys(obj).length == 1 and charkey of obj and not @EXPLICIT_CHARKEY\n obj = obj[charkey]\n\n if @options.emptyTag != undefined && isEmpty obj\n obj = @options.emptyTag", "response": "# check whether we closed all the open tags\n if stack.length > 0\n if not @options.explicitArray\n if nodeName not of s\n s[nodeName] = obj\n else if s[nodeName] instanceof Array\n s[nodeName].push obj\n else\n old = s[nodeName]\n s[nodeName] = [old]\n s[nodeName].push obj\n else\n if not (s[nodeName] instanceof Array)\n s[nodeName] = []\n s[nodeName].push obj\n else\n # if explicitRoot was specified, wrap stuff in the root tag name\n if @options.explicitRoot\n # avoid circular references\n old = obj\n obj = {}\n obj[nodeName] = old\n\n @resultObject = obj\n @emit \"end\", @resultObject", "source_lang": "CoffeeScript", "target_lang": "CoffeeScript", "repo": "Leonidas-from-XIV/node-xml2js", "path": "src/xml2js.coffee", "license": "MIT", "commit": "16084e47b0b13355828cac3503f43492a6d55581", "stars": 4965, "source_url": "https://github.com/Leonidas-from-XIV/node-xml2js/blob/16084e47b0b13355828cac3503f43492a6d55581/src/xml2js.coffee", "line_start": 86, "line_end": 135}74{"id": "Leonidas-from-XIV/node-xml2js:src/xml2js.coffee:4:raw_corpus", "type": "raw_corpus", "prompt": "", "response": "@saxParser.ontext = @saxParser.oncdata = (text) =>\n s = stack[stack.length - 1]\n if s\n s[charkey] += text\n\n parseString: (str, cb) =>\n if cb? and typeof cb is \"function\"\n @on \"end\", (result) ->\n @reset()\n cb null, result\n @on \"error\", (err) ->\n @reset()\n cb err\n\n if str.toString().trim() is ''\n @emit \"end\", null\n return true\n\n @saxParser.write str.toString()", "source_lang": "", "target_lang": "CoffeeScript", "repo": "Leonidas-from-XIV/node-xml2js", "path": "src/xml2js.coffee", "license": "MIT", "commit": "16084e47b0b13355828cac3503f43492a6d55581", "stars": 4965, "source_url": "https://github.com/Leonidas-from-XIV/node-xml2js/blob/16084e47b0b13355828cac3503f43492a6d55581/src/xml2js.coffee", "line_start": 136, "line_end": 154}75{"id": "Leonidas-from-XIV/node-xml2js:src/xml2js.coffee:4:coffee_to_js", "type": "coffee_to_js", "prompt": "Convert this CoffeeScript to JavaScript.\n```coffeescript\n@saxParser.ontext = @saxParser.oncdata = (text) =>\n s = stack[stack.length - 1]\n if s\n s[charkey] += text\n\n parseString: (str, cb) =>\n if cb? and typeof cb is \"function\"\n @on \"end\", (result) ->\n @reset()\n cb null, result\n @on \"error\", (err) ->\n @reset()\n cb err\n\n if str.toString().trim() is ''\n @emit \"end\", null\n return true\n\n @saxParser.write str.toString()\n```", "response": "this.saxParser.ontext = this.saxParser.oncdata = (text) => {\n var s;\n s = stack[stack.length - 1];\n if (s) {\n return s[charkey] += text;\n }\n};\n\n({\n parseString: (str, cb) => {\n if ((cb != null) && typeof cb === \"function\") {\n this.on(\"end\", function(result) {\n this.reset();\n return cb(null, result);\n });\n this.on(\"error\", function(err) {\n this.reset();\n return cb(err);\n });\n }\n if (str.toString().trim() === '') {\n this.emit(\"end\", null);\n return true;\n }\n return this.saxParser.write(str.toString());\n }\n});", "source_lang": "CoffeeScript", "target_lang": "JavaScript", "repo": "Leonidas-from-XIV/node-xml2js", "path": "src/xml2js.coffee", "license": "MIT", "commit": "16084e47b0b13355828cac3503f43492a6d55581", "stars": 4965, "source_url": "https://github.com/Leonidas-from-XIV/node-xml2js/blob/16084e47b0b13355828cac3503f43492a6d55581/src/xml2js.coffee", "line_start": 136, "line_end": 154}76{"id": "Leonidas-from-XIV/node-xml2js:src/xml2js.coffee:4:js_to_coffee", "type": "js_to_coffee", "prompt": "Convert this JavaScript to CoffeeScript.\n```javascript\nthis.saxParser.ontext = this.saxParser.oncdata = (text) => {\n var s;\n s = stack[stack.length - 1];\n if (s) {\n return s[charkey] += text;\n }\n};\n\n({\n parseString: (str, cb) => {\n if ((cb != null) && typeof cb === \"function\") {\n this.on(\"end\", function(result) {\n this.reset();\n return cb(null, result);\n });\n this.on(\"error\", function(err) {\n this.reset();\n return cb(err);\n });\n }\n if (str.toString().trim() === '') {\n this.emit(\"end\", null);\n return true;\n }\n return this.saxParser.write(str.toString());\n }\n});\n```", "response": "@saxParser.ontext = @saxParser.oncdata = (text) =>\n s = stack[stack.length - 1]\n if s\n s[charkey] += text\n\n parseString: (str, cb) =>\n if cb? and typeof cb is \"function\"\n @on \"end\", (result) ->\n @reset()\n cb null, result\n @on \"error\", (err) ->\n @reset()\n cb err\n\n if str.toString().trim() is ''\n @emit \"end\", null\n return true\n\n @saxParser.write str.toString()", "source_lang": "JavaScript", "target_lang": "CoffeeScript", "repo": "Leonidas-from-XIV/node-xml2js", "path": "src/xml2js.coffee", "license": "MIT", "commit": "16084e47b0b13355828cac3503f43492a6d55581", "stars": 4965, "source_url": "https://github.com/Leonidas-from-XIV/node-xml2js/blob/16084e47b0b13355828cac3503f43492a6d55581/src/xml2js.coffee", "line_start": 136, "line_end": 154}77{"id": "Leonidas-from-XIV/node-xml2js:src/xml2js.coffee:4:completion", "type": "completion", "prompt": "@saxParser.ontext = @saxParser.oncdata = (text) =>\n s = stack[stack.length - 1]\n if s\n s[charkey] += text\n\n parseString: (str, cb) =>\n if cb? and typeof cb is \"function\"\n @on \"end\", (result) ->\n @reset()", "response": "cb null, result\n @on \"error\", (err) ->\n @reset()\n cb err\n\n if str.toString().trim() is ''\n @emit \"end\", null\n return true\n\n @saxParser.write str.toString()", "source_lang": "CoffeeScript", "target_lang": "CoffeeScript", "repo": "Leonidas-from-XIV/node-xml2js", "path": "src/xml2js.coffee", "license": "MIT", "commit": "16084e47b0b13355828cac3503f43492a6d55581", "stars": 4965, "source_url": "https://github.com/Leonidas-from-XIV/node-xml2js/blob/16084e47b0b13355828cac3503f43492a6d55581/src/xml2js.coffee", "line_start": 136, "line_end": 154}78{"id": "Leonidas-from-XIV/node-xml2js:src/xml2js.coffee:2:raw_corpus", "type": "raw_corpus", "prompt": "", "response": "class exports.Parser extends events.EventEmitter\n constructor: (opts) ->\n # default options. for compatibility's sake set to some\n # sub-optimal settings. might change in the future.\n @options =\n explicitCharkey: false\n trim: true\n # normalize implicates trimming, just so you know\n normalize: true\n # set default attribute object key\n attrkey: \"@\"\n # set default char object key\n charkey: \"#\"\n # always put child nodes in an array\n explicitArray: false\n # ignore all attributes regardless\n ignoreAttrs: false\n # merge attributes and child elements onto parent object. this may\n # cause collisions.\n mergeAttrs: false\n # overwrite them with the specified options, if any\n @options[key] = value for own key, value of opts\n\n @reset()\n\n reset: =>\n # remove all previous listeners for events, to prevent event listener\n # accumulation\n @removeAllListeners()\n # make the SAX parser. tried trim and normalize, but they are not\n # very helpful\n @saxParser = sax.parser true, {\n trim: false,\n normalize: false\n }\n\n # emit one error event if the sax parser fails. this is mostly a hack, but\n # the sax parser isn't state of the art either.\n err = false\n @saxParser.onerror = (error) =>\n if ! err\n err = true\n @emit \"error\", error\n\n # always use the '#' key, even if there are no subkeys\n # setting this property by and is deprecated, yet still supported.\n # better pass it as explicitCharkey option to the constructor\n @EXPLICIT_CHARKEY = @options.explicitCharkey\n @resultObject = null\n stack = []", "source_lang": "", "target_lang": "CoffeeScript", "repo": "Leonidas-from-XIV/node-xml2js", "path": "src/xml2js.coffee", "license": "MIT", "commit": "de509d3e97b95c81ab5e3513fcabbf599986a6e3", "stars": 4965, "source_url": "https://github.com/Leonidas-from-XIV/node-xml2js/blob/de509d3e97b95c81ab5e3513fcabbf599986a6e3/src/xml2js.coffee", "line_start": 8, "line_end": 57}79{"id": "Leonidas-from-XIV/node-xml2js:src/xml2js.coffee:2:completion", "type": "completion", "prompt": "class exports.Parser extends events.EventEmitter\n constructor: (opts) ->\n # default options. for compatibility's sake set to some\n # sub-optimal settings. might change in the future.\n @options =\n explicitCharkey: false\n trim: true\n # normalize implicates trimming, just so you know\n normalize: true\n # set default attribute object key\n attrkey: \"@\"\n # set default char object key\n charkey: \"#\"\n # always put child nodes in an array\n explicitArray: false\n # ignore all attributes regardless\n ignoreAttrs: false\n # merge attributes and child elements onto parent object. this may\n # cause collisions.\n mergeAttrs: false\n # overwrite them with the specified options, if any\n @options[key] = value for own key, value of opts\n\n @reset()", "response": "reset: =>\n # remove all previous listeners for events, to prevent event listener\n # accumulation\n @removeAllListeners()\n # make the SAX parser. tried trim and normalize, but they are not\n # very helpful\n @saxParser = sax.parser true, {\n trim: false,\n normalize: false\n }\n\n # emit one error event if the sax parser fails. this is mostly a hack, but\n # the sax parser isn't state of the art either.\n err = false\n @saxParser.onerror = (error) =>\n if ! err\n err = true\n @emit \"error\", error\n\n # always use the '#' key, even if there are no subkeys\n # setting this property by and is deprecated, yet still supported.\n # better pass it as explicitCharkey option to the constructor\n @EXPLICIT_CHARKEY = @options.explicitCharkey\n @resultObject = null\n stack = []", "source_lang": "CoffeeScript", "target_lang": "CoffeeScript", "repo": "Leonidas-from-XIV/node-xml2js", "path": "src/xml2js.coffee", "license": "MIT", "commit": "de509d3e97b95c81ab5e3513fcabbf599986a6e3", "stars": 4965, "source_url": "https://github.com/Leonidas-from-XIV/node-xml2js/blob/de509d3e97b95c81ab5e3513fcabbf599986a6e3/src/xml2js.coffee", "line_start": 8, "line_end": 57}80{"id": "Leonidas-from-XIV/node-xml2js:src/xml2js.coffee:3:raw_corpus", "type": "raw_corpus", "prompt": "", "response": "# aliases, so we don't have to type so much\n attrkey = @options.attrkey\n charkey = @options.charkey\n\n @saxParser.onopentag = (node) =>\n obj = {}\n obj[charkey] = \"\"\n unless @options.ignoreAttrs\n for own key of node.attributes\n if attrkey not of obj and not @options.mergeAttrs\n obj[attrkey] = {}\n if @options.mergeAttrs\n obj[key] = node.attributes[key]\n else\n obj[attrkey][key] = node.attributes[key]\n\n # need a place to store the node name\n obj[\"#name\"] = node.name\n stack.push obj\n\n @saxParser.onclosetag = =>\n obj = stack.pop()\n nodeName = obj[\"#name\"]\n delete obj[\"#name\"]\n\n s = stack[stack.length - 1]\n # remove the '#' key altogether if it's blank\n if obj[charkey].match(/^\\s*$/)\n delete obj[charkey]\n else\n obj[charkey] = obj[charkey].trim() if @options.trim\n obj[charkey] = obj[charkey].replace(/\\s{2,}/g, \" \").trim() if @options.normalize\n # also do away with '#' key altogether, if there's no subkeys\n # unless EXPLICIT_CHARKEY is set\n if Object.keys(obj).length == 1 and charkey of obj and not @EXPLICIT_CHARKEY\n obj = obj[charkey]\n\n if @options.emptyTag != undefined && isEmpty obj\n obj = @options.emptyTag\n\n # check whether we closed all the open tags\n if stack.length > 0\n if not @options.explicitArray\n if nodeName not of s\n s[nodeName] = obj\n else if s[nodeName] instanceof Array\n s[nodeName].push obj\n else\n old = s[nodeName]\n s[nodeName] = [old]", "source_lang": "", "target_lang": "CoffeeScript", "repo": "Leonidas-from-XIV/node-xml2js", "path": "src/xml2js.coffee", "license": "MIT", "commit": "de509d3e97b95c81ab5e3513fcabbf599986a6e3", "stars": 4965, "source_url": "https://github.com/Leonidas-from-XIV/node-xml2js/blob/de509d3e97b95c81ab5e3513fcabbf599986a6e3/src/xml2js.coffee", "line_start": 58, "line_end": 107}81{"id": "Leonidas-from-XIV/node-xml2js:src/xml2js.coffee:3:coffee_to_js", "type": "coffee_to_js", "prompt": "Convert this CoffeeScript to JavaScript.\n```coffeescript\n# aliases, so we don't have to type so much\n attrkey = @options.attrkey\n charkey = @options.charkey\n\n @saxParser.onopentag = (node) =>\n obj = {}\n obj[charkey] = \"\"\n unless @options.ignoreAttrs\n for own key of node.attributes\n if attrkey not of obj and not @options.mergeAttrs\n obj[attrkey] = {}\n if @options.mergeAttrs\n obj[key] = node.attributes[key]\n else\n obj[attrkey][key] = node.attributes[key]\n\n # need a place to store the node name\n obj[\"#name\"] = node.name\n stack.push obj\n\n @saxParser.onclosetag = =>\n obj = stack.pop()\n nodeName = obj[\"#name\"]\n delete obj[\"#name\"]\n\n s = stack[stack.length - 1]\n # remove the '#' key altogether if it's blank\n if obj[charkey].match(/^\\s*$/)\n delete obj[charkey]\n else\n obj[charkey] = obj[charkey].trim() if @options.trim\n obj[charkey] = obj[charkey].replace(/\\s{2,}/g, \" \").trim() if @options.normalize\n # also do away with '#' key altogether, if there's no subkeys\n # unless EXPLICIT_CHARKEY is set\n if Object.keys(obj).length == 1 and charkey of obj and not @EXPLICIT_CHARKEY\n obj = obj[charkey]\n\n if @options.emptyTag != undefined && isEmpty obj\n obj = @options.emptyTag\n\n # check whether we closed all the open tags\n if stack.length > 0\n if not @options.explicitArray\n if nodeName not of s\n s[nodeName] = obj\n else if s[nodeName] instanceof Array\n s[nodeName].push obj\n else\n old = s[nodeName]\n s[nodeName] = [old]\n```", "response": "// aliases, so we don't have to type so much\nvar attrkey, charkey,\n hasProp = {}.hasOwnProperty;\n\nattrkey = this.options.attrkey;\n\ncharkey = this.options.charkey;\n\nthis.saxParser.onopentag = (node) => {\n var key, obj, ref;\n obj = {};\n obj[charkey] = \"\";\n if (!this.options.ignoreAttrs) {\n ref = node.attributes;\n for (key in ref) {\n if (!hasProp.call(ref, key)) continue;\n if (!(attrkey in obj) && !this.options.mergeAttrs) {\n obj[attrkey] = {};\n }\n if (this.options.mergeAttrs) {\n obj[key] = node.attributes[key];\n } else {\n obj[attrkey][key] = node.attributes[key];\n }\n }\n }\n // need a place to store the node name\n obj[\"#name\"] = node.name;\n return stack.push(obj);\n};\n\nthis.saxParser.onclosetag = () => {\n var nodeName, obj, old, s;\n obj = stack.pop();\n nodeName = obj[\"#name\"];\n delete obj[\"#name\"];\n s = stack[stack.length - 1];\n // remove the '#' key altogether if it's blank\n if (obj[charkey].match(/^\\s*$/)) {\n delete obj[charkey];\n } else {\n if (this.options.trim) {\n obj[charkey] = obj[charkey].trim();\n }\n if (this.options.normalize) {\n obj[charkey] = obj[charkey].replace(/\\s{2,}/g, \" \").trim();\n }\n // also do away with '#' key altogether, if there's no subkeys\n // unless EXPLICIT_CHARKEY is set\n if (Object.keys(obj).length === 1 && charkey in obj && !this.EXPLICIT_CHARKEY) {\n obj = obj[charkey];\n }\n }\n if (this.options.emptyTag !== void 0 && isEmpty(obj)) {\n obj = this.options.emptyTag;\n }\n // check whether we closed all the open tags\n if (stack.length > 0) {\n if (!this.options.explicitArray) {\n if (!(nodeName in s)) {\n return s[nodeName] = obj;\n } else if (s[nodeName] instanceof Array) {\n return s[nodeName].push(obj);\n } else {\n old = s[nodeName];\n return s[nodeName] = [old];\n }\n }\n }\n};", "source_lang": "CoffeeScript", "target_lang": "JavaScript", "repo": "Leonidas-from-XIV/node-xml2js", "path": "src/xml2js.coffee", "license": "MIT", "commit": "de509d3e97b95c81ab5e3513fcabbf599986a6e3", "stars": 4965, "source_url": "https://github.com/Leonidas-from-XIV/node-xml2js/blob/de509d3e97b95c81ab5e3513fcabbf599986a6e3/src/xml2js.coffee", "line_start": 58, "line_end": 107}82{"id": "Leonidas-from-XIV/node-xml2js:src/xml2js.coffee:3:js_to_coffee", "type": "js_to_coffee", "prompt": "Convert this JavaScript to CoffeeScript.\n```javascript\n// aliases, so we don't have to type so much\nvar attrkey, charkey,\n hasProp = {}.hasOwnProperty;\n\nattrkey = this.options.attrkey;\n\ncharkey = this.options.charkey;\n\nthis.saxParser.onopentag = (node) => {\n var key, obj, ref;\n obj = {};\n obj[charkey] = \"\";\n if (!this.options.ignoreAttrs) {\n ref = node.attributes;\n for (key in ref) {\n if (!hasProp.call(ref, key)) continue;\n if (!(attrkey in obj) && !this.options.mergeAttrs) {\n obj[attrkey] = {};\n }\n if (this.options.mergeAttrs) {\n obj[key] = node.attributes[key];\n } else {\n obj[attrkey][key] = node.attributes[key];\n }\n }\n }\n // need a place to store the node name\n obj[\"#name\"] = node.name;\n return stack.push(obj);\n};\n\nthis.saxParser.onclosetag = () => {\n var nodeName, obj, old, s;\n obj = stack.pop();\n nodeName = obj[\"#name\"];\n delete obj[\"#name\"];\n s = stack[stack.length - 1];\n // remove the '#' key altogether if it's blank\n if (obj[charkey].match(/^\\s*$/)) {\n delete obj[charkey];\n } else {\n if (this.options.trim) {\n obj[charkey] = obj[charkey].trim();\n }\n if (this.options.normalize) {\n obj[charkey] = obj[charkey].replace(/\\s{2,}/g, \" \").trim();\n }\n // also do away with '#' key altogether, if there's no subkeys\n // unless EXPLICIT_CHARKEY is set\n if (Object.keys(obj).length === 1 && charkey in obj && !this.EXPLICIT_CHARKEY) {\n obj = obj[charkey];\n }\n }\n if (this.options.emptyTag !== void 0 && isEmpty(obj)) {\n obj = this.options.emptyTag;\n }\n // check whether we closed all the open tags\n if (stack.length > 0) {\n if (!this.options.explicitArray) {\n if (!(nodeName in s)) {\n return s[nodeName] = obj;\n } else if (s[nodeName] instanceof Array) {\n return s[nodeName].push(obj);\n } else {\n old = s[nodeName];\n return s[nodeName] = [old];\n }\n }\n }\n};\n```", "response": "# aliases, so we don't have to type so much\n attrkey = @options.attrkey\n charkey = @options.charkey\n\n @saxParser.onopentag = (node) =>\n obj = {}\n obj[charkey] = \"\"\n unless @options.ignoreAttrs\n for own key of node.attributes\n if attrkey not of obj and not @options.mergeAttrs\n obj[attrkey] = {}\n if @options.mergeAttrs\n obj[key] = node.attributes[key]\n else\n obj[attrkey][key] = node.attributes[key]\n\n # need a place to store the node name\n obj[\"#name\"] = node.name\n stack.push obj\n\n @saxParser.onclosetag = =>\n obj = stack.pop()\n nodeName = obj[\"#name\"]\n delete obj[\"#name\"]\n\n s = stack[stack.length - 1]\n # remove the '#' key altogether if it's blank\n if obj[charkey].match(/^\\s*$/)\n delete obj[charkey]\n else\n obj[charkey] = obj[charkey].trim() if @options.trim\n obj[charkey] = obj[charkey].replace(/\\s{2,}/g, \" \").trim() if @options.normalize\n # also do away with '#' key altogether, if there's no subkeys\n # unless EXPLICIT_CHARKEY is set\n if Object.keys(obj).length == 1 and charkey of obj and not @EXPLICIT_CHARKEY\n obj = obj[charkey]\n\n if @options.emptyTag != undefined && isEmpty obj\n obj = @options.emptyTag\n\n # check whether we closed all the open tags\n if stack.length > 0\n if not @options.explicitArray\n if nodeName not of s\n s[nodeName] = obj\n else if s[nodeName] instanceof Array\n s[nodeName].push obj\n else\n old = s[nodeName]\n s[nodeName] = [old]", "source_lang": "JavaScript", "target_lang": "CoffeeScript", "repo": "Leonidas-from-XIV/node-xml2js", "path": "src/xml2js.coffee", "license": "MIT", "commit": "de509d3e97b95c81ab5e3513fcabbf599986a6e3", "stars": 4965, "source_url": "https://github.com/Leonidas-from-XIV/node-xml2js/blob/de509d3e97b95c81ab5e3513fcabbf599986a6e3/src/xml2js.coffee", "line_start": 58, "line_end": 107}83{"id": "Leonidas-from-XIV/node-xml2js:src/xml2js.coffee:3:completion", "type": "completion", "prompt": "# aliases, so we don't have to type so much\n attrkey = @options.attrkey\n charkey = @options.charkey\n\n @saxParser.onopentag = (node) =>\n obj = {}\n obj[charkey] = \"\"\n unless @options.ignoreAttrs\n for own key of node.attributes\n if attrkey not of obj and not @options.mergeAttrs\n obj[attrkey] = {}\n if @options.mergeAttrs\n obj[key] = node.attributes[key]\n else\n obj[attrkey][key] = node.attributes[key]\n\n # need a place to store the node name\n obj[\"#name\"] = node.name\n stack.push obj\n\n @saxParser.onclosetag = =>\n obj = stack.pop()\n nodeName = obj[\"#name\"]\n delete obj[\"#name\"]", "response": "s = stack[stack.length - 1]\n # remove the '#' key altogether if it's blank\n if obj[charkey].match(/^\\s*$/)\n delete obj[charkey]\n else\n obj[charkey] = obj[charkey].trim() if @options.trim\n obj[charkey] = obj[charkey].replace(/\\s{2,}/g, \" \").trim() if @options.normalize\n # also do away with '#' key altogether, if there's no subkeys\n # unless EXPLICIT_CHARKEY is set\n if Object.keys(obj).length == 1 and charkey of obj and not @EXPLICIT_CHARKEY\n obj = obj[charkey]\n\n if @options.emptyTag != undefined && isEmpty obj\n obj = @options.emptyTag\n\n # check whether we closed all the open tags\n if stack.length > 0\n if not @options.explicitArray\n if nodeName not of s\n s[nodeName] = obj\n else if s[nodeName] instanceof Array\n s[nodeName].push obj\n else\n old = s[nodeName]\n s[nodeName] = [old]", "source_lang": "CoffeeScript", "target_lang": "CoffeeScript", "repo": "Leonidas-from-XIV/node-xml2js", "path": "src/xml2js.coffee", "license": "MIT", "commit": "de509d3e97b95c81ab5e3513fcabbf599986a6e3", "stars": 4965, "source_url": "https://github.com/Leonidas-from-XIV/node-xml2js/blob/de509d3e97b95c81ab5e3513fcabbf599986a6e3/src/xml2js.coffee", "line_start": 58, "line_end": 107}84{"id": "Leonidas-from-XIV/node-xml2js:src/xml2js.coffee:4:raw_corpus", "type": "raw_corpus", "prompt": "", "response": "s[nodeName].push obj\n else\n if not (s[nodeName] instanceof Array)\n s[nodeName] = []\n s[nodeName].push obj\n else\n # if explicitRoot was specified, wrap stuff in the root tag name\n if @options.explicitRoot\n # avoid circular references\n old = obj\n obj = {}\n obj[nodeName] = old\n\n @resultObject = obj\n @emit \"end\", @resultObject\n\n @saxParser.ontext = @saxParser.oncdata = (text) =>\n s = stack[stack.length - 1]\n if s\n s[charkey] += text\n\n parseString: (str, cb) =>\n if cb? and typeof cb is \"function\"\n @on \"end\", (result) ->\n @reset()\n cb null, result\n @on \"error\", (err) ->\n @reset()\n cb err\n\n if str.toString().trim() is ''\n @emit \"end\", null\n return true\n\n @saxParser.write str.toString()", "source_lang": "", "target_lang": "CoffeeScript", "repo": "Leonidas-from-XIV/node-xml2js", "path": "src/xml2js.coffee", "license": "MIT", "commit": "de509d3e97b95c81ab5e3513fcabbf599986a6e3", "stars": 4965, "source_url": "https://github.com/Leonidas-from-XIV/node-xml2js/blob/de509d3e97b95c81ab5e3513fcabbf599986a6e3/src/xml2js.coffee", "line_start": 108, "line_end": 142}85{"id": "Leonidas-from-XIV/node-xml2js:src/xml2js.coffee:4:completion", "type": "completion", "prompt": "s[nodeName].push obj\n else\n if not (s[nodeName] instanceof Array)\n s[nodeName] = []\n s[nodeName].push obj\n else\n # if explicitRoot was specified, wrap stuff in the root tag name\n if @options.explicitRoot\n # avoid circular references\n old = obj\n obj = {}\n obj[nodeName] = old\n\n @resultObject = obj\n @emit \"end\", @resultObject\n\n @saxParser.ontext = @saxParser.oncdata = (text) =>", "response": "s = stack[stack.length - 1]\n if s\n s[charkey] += text\n\n parseString: (str, cb) =>\n if cb? and typeof cb is \"function\"\n @on \"end\", (result) ->\n @reset()\n cb null, result\n @on \"error\", (err) ->\n @reset()\n cb err\n\n if str.toString().trim() is ''\n @emit \"end\", null\n return true\n\n @saxParser.write str.toString()", "source_lang": "CoffeeScript", "target_lang": "CoffeeScript", "repo": "Leonidas-from-XIV/node-xml2js", "path": "src/xml2js.coffee", "license": "MIT", "commit": "de509d3e97b95c81ab5e3513fcabbf599986a6e3", "stars": 4965, "source_url": "https://github.com/Leonidas-from-XIV/node-xml2js/blob/de509d3e97b95c81ab5e3513fcabbf599986a6e3/src/xml2js.coffee", "line_start": 108, "line_end": 142}86{"id": "Leonidas-from-XIV/node-xml2js:src/xml2js.coffee:3:raw_corpus", "type": "raw_corpus", "prompt": "", "response": "class exports.Parser extends events.EventEmitter\n constructor: (opts) ->\n # default options. for compatibility's sake set to some\n # sub-optimal settings. might change in the future.\n @options =\n explicitCharkey: false\n trim: true\n # normalize implicates trimming, just so you know\n normalize: true\n # set default attribute object key\n attrkey: \"@\"\n # set default char object key\n charkey: \"#\"\n # always put child nodes in an array\n explicitArray: false\n # ignore all attributes regardless\n ignoreAttrs: false\n # merge attributes and child elements onto parent object. this may\n # cause collisions.\n mergeAttrs: false\n # optional validator for schema-driven generawtion\n validator: null\n # overwrite them with the specified options, if any\n @options[key] = value for own key, value of opts\n\n @reset()\n\n reset: =>\n # remove all previous listeners for events, to prevent event listener\n # accumulation\n @removeAllListeners()\n # make the SAX parser. tried trim and normalize, but they are not\n # very helpful\n @saxParser = sax.parser true, {\n trim: false,\n normalize: false\n }\n\n # emit one error event if the sax parser fails. this is mostly a hack, but\n # the sax parser isn't state of the art either.\n err = false\n @saxParser.onerror = (error) =>\n if ! err\n err = true\n @emit \"error\", error\n\n # always use the '#' key, even if there are no subkeys\n # setting this property by and is deprecated, yet still supported.\n # better pass it as explicitCharkey option to the constructor\n @EXPLICIT_CHARKEY = @options.explicitCharkey", "source_lang": "", "target_lang": "CoffeeScript", "repo": "Leonidas-from-XIV/node-xml2js", "path": "src/xml2js.coffee", "license": "MIT", "commit": "b023b382d12d72bf0a678fcd3b9f4e9f28fda928", "stars": 4965, "source_url": "https://github.com/Leonidas-from-XIV/node-xml2js/blob/b023b382d12d72bf0a678fcd3b9f4e9f28fda928/src/xml2js.coffee", "line_start": 12, "line_end": 61}87{"id": "Leonidas-from-XIV/node-xml2js:src/xml2js.coffee:3:completion", "type": "completion", "prompt": "class exports.Parser extends events.EventEmitter\n constructor: (opts) ->\n # default options. for compatibility's sake set to some\n # sub-optimal settings. might change in the future.\n @options =\n explicitCharkey: false\n trim: true\n # normalize implicates trimming, just so you know\n normalize: true\n # set default attribute object key\n attrkey: \"@\"\n # set default char object key\n charkey: \"#\"\n # always put child nodes in an array\n explicitArray: false\n # ignore all attributes regardless\n ignoreAttrs: false\n # merge attributes and child elements onto parent object. this may\n # cause collisions.\n mergeAttrs: false\n # optional validator for schema-driven generawtion\n validator: null\n # overwrite them with the specified options, if any\n @options[key] = value for own key, value of opts", "response": "@reset()\n\n reset: =>\n # remove all previous listeners for events, to prevent event listener\n # accumulation\n @removeAllListeners()\n # make the SAX parser. tried trim and normalize, but they are not\n # very helpful\n @saxParser = sax.parser true, {\n trim: false,\n normalize: false\n }\n\n # emit one error event if the sax parser fails. this is mostly a hack, but\n # the sax parser isn't state of the art either.\n err = false\n @saxParser.onerror = (error) =>\n if ! err\n err = true\n @emit \"error\", error\n\n # always use the '#' key, even if there are no subkeys\n # setting this property by and is deprecated, yet still supported.\n # better pass it as explicitCharkey option to the constructor\n @EXPLICIT_CHARKEY = @options.explicitCharkey", "source_lang": "CoffeeScript", "target_lang": "CoffeeScript", "repo": "Leonidas-from-XIV/node-xml2js", "path": "src/xml2js.coffee", "license": "MIT", "commit": "b023b382d12d72bf0a678fcd3b9f4e9f28fda928", "stars": 4965, "source_url": "https://github.com/Leonidas-from-XIV/node-xml2js/blob/b023b382d12d72bf0a678fcd3b9f4e9f28fda928/src/xml2js.coffee", "line_start": 12, "line_end": 61}88{"id": "Leonidas-from-XIV/node-xml2js:src/xml2js.coffee:4:raw_corpus", "type": "raw_corpus", "prompt": "", "response": "@resultObject = null\n stack = []\n # aliases, so we don't have to type so much\n attrkey = @options.attrkey\n charkey = @options.charkey\n\n @saxParser.onopentag = (node) =>\n obj = {}\n obj[charkey] = \"\"\n unless @options.ignoreAttrs\n for own key of node.attributes\n if attrkey not of obj and not @options.mergeAttrs\n obj[attrkey] = {}\n if @options.mergeAttrs\n obj[key] = node.attributes[key]\n else\n obj[attrkey][key] = node.attributes[key]\n\n # need a place to store the node name\n obj[\"#name\"] = node.name\n stack.push obj\n\n @saxParser.onclosetag = =>\n obj = stack.pop()\n nodeName = obj[\"#name\"]\n delete obj[\"#name\"]\n\n s = stack[stack.length - 1]\n # remove the '#' key altogether if it's blank\n if obj[charkey].match(/^\\s*$/)\n delete obj[charkey]\n else\n obj[charkey] = obj[charkey].trim() if @options.trim\n obj[charkey] = obj[charkey].replace(/\\s{2,}/g, \" \").trim() if @options.normalize\n # also do away with '#' key altogether, if there's no subkeys\n # unless EXPLICIT_CHARKEY is set\n if Object.keys(obj).length == 1 and charkey of obj and not @EXPLICIT_CHARKEY\n obj = obj[charkey]\n\n if @options.emptyTag != undefined && isEmpty obj\n obj = @options.emptyTag\n\n if @options.validator?\n xpath = \"/\" + (node[\"#name\"] for node in stack).concat(nodeName).join(\"/\")\n obj = @options.validator(xpath, s and s[nodeName], obj)\n\n # check whether we closed all the open tags\n if stack.length > 0\n if not @options.explicitArray\n if nodeName not of s", "source_lang": "", "target_lang": "CoffeeScript", "repo": "Leonidas-from-XIV/node-xml2js", "path": "src/xml2js.coffee", "license": "MIT", "commit": "b023b382d12d72bf0a678fcd3b9f4e9f28fda928", "stars": 4965, "source_url": "https://github.com/Leonidas-from-XIV/node-xml2js/blob/b023b382d12d72bf0a678fcd3b9f4e9f28fda928/src/xml2js.coffee", "line_start": 62, "line_end": 111}89{"id": "Leonidas-from-XIV/node-xml2js:src/xml2js.coffee:4:completion", "type": "completion", "prompt": "@resultObject = null\n stack = []\n # aliases, so we don't have to type so much\n attrkey = @options.attrkey\n charkey = @options.charkey\n\n @saxParser.onopentag = (node) =>\n obj = {}\n obj[charkey] = \"\"\n unless @options.ignoreAttrs\n for own key of node.attributes\n if attrkey not of obj and not @options.mergeAttrs\n obj[attrkey] = {}\n if @options.mergeAttrs\n obj[key] = node.attributes[key]\n else\n obj[attrkey][key] = node.attributes[key]\n\n # need a place to store the node name\n obj[\"#name\"] = node.name\n stack.push obj\n\n @saxParser.onclosetag = =>\n obj = stack.pop()\n nodeName = obj[\"#name\"]", "response": "delete obj[\"#name\"]\n\n s = stack[stack.length - 1]\n # remove the '#' key altogether if it's blank\n if obj[charkey].match(/^\\s*$/)\n delete obj[charkey]\n else\n obj[charkey] = obj[charkey].trim() if @options.trim\n obj[charkey] = obj[charkey].replace(/\\s{2,}/g, \" \").trim() if @options.normalize\n # also do away with '#' key altogether, if there's no subkeys\n # unless EXPLICIT_CHARKEY is set\n if Object.keys(obj).length == 1 and charkey of obj and not @EXPLICIT_CHARKEY\n obj = obj[charkey]\n\n if @options.emptyTag != undefined && isEmpty obj\n obj = @options.emptyTag\n\n if @options.validator?\n xpath = \"/\" + (node[\"#name\"] for node in stack).concat(nodeName).join(\"/\")\n obj = @options.validator(xpath, s and s[nodeName], obj)\n\n # check whether we closed all the open tags\n if stack.length > 0\n if not @options.explicitArray\n if nodeName not of s", "source_lang": "CoffeeScript", "target_lang": "CoffeeScript", "repo": "Leonidas-from-XIV/node-xml2js", "path": "src/xml2js.coffee", "license": "MIT", "commit": "b023b382d12d72bf0a678fcd3b9f4e9f28fda928", "stars": 4965, "source_url": "https://github.com/Leonidas-from-XIV/node-xml2js/blob/b023b382d12d72bf0a678fcd3b9f4e9f28fda928/src/xml2js.coffee", "line_start": 62, "line_end": 111}90{"id": "Leonidas-from-XIV/node-xml2js:src/xml2js.coffee:5:raw_corpus", "type": "raw_corpus", "prompt": "", "response": "s[nodeName] = obj\n else if s[nodeName] instanceof Array\n s[nodeName].push obj\n else\n old = s[nodeName]\n s[nodeName] = [old]\n s[nodeName].push obj\n else\n if not (s[nodeName] instanceof Array)\n s[nodeName] = []\n s[nodeName].push obj\n else\n # if explicitRoot was specified, wrap stuff in the root tag name\n if @options.explicitRoot\n # avoid circular references\n old = obj\n obj = {}\n obj[nodeName] = old\n\n @resultObject = obj\n @emit \"end\", @resultObject\n\n @saxParser.ontext = @saxParser.oncdata = (text) =>\n s = stack[stack.length - 1]\n if s\n s[charkey] += text\n\n parseString: (str, cb) =>\n if cb? and typeof cb is \"function\"\n @on \"end\", (result) ->\n @reset()\n cb null, result\n @on \"error\", (err) ->\n @reset()\n cb err\n\n if str.toString().trim() is ''\n @emit \"end\", null\n return true\n\n try\n @saxParser.write str.toString()\n catch ex\n if ex instanceof exports.ValidationError\n @emit(\"error\", ex.message)\n else\n throw ex", "source_lang": "", "target_lang": "CoffeeScript", "repo": "Leonidas-from-XIV/node-xml2js", "path": "src/xml2js.coffee", "license": "MIT", "commit": "b023b382d12d72bf0a678fcd3b9f4e9f28fda928", "stars": 4965, "source_url": "https://github.com/Leonidas-from-XIV/node-xml2js/blob/b023b382d12d72bf0a678fcd3b9f4e9f28fda928/src/xml2js.coffee", "line_start": 112, "line_end": 158}91{"id": "Leonidas-from-XIV/node-xml2js:src/xml2js.coffee:5:completion", "type": "completion", "prompt": "s[nodeName] = obj\n else if s[nodeName] instanceof Array\n s[nodeName].push obj\n else\n old = s[nodeName]\n s[nodeName] = [old]\n s[nodeName].push obj\n else\n if not (s[nodeName] instanceof Array)\n s[nodeName] = []\n s[nodeName].push obj\n else\n # if explicitRoot was specified, wrap stuff in the root tag name\n if @options.explicitRoot\n # avoid circular references\n old = obj\n obj = {}\n obj[nodeName] = old\n\n @resultObject = obj\n @emit \"end\", @resultObject\n\n @saxParser.ontext = @saxParser.oncdata = (text) =>", "response": "s = stack[stack.length - 1]\n if s\n s[charkey] += text\n\n parseString: (str, cb) =>\n if cb? and typeof cb is \"function\"\n @on \"end\", (result) ->\n @reset()\n cb null, result\n @on \"error\", (err) ->\n @reset()\n cb err\n\n if str.toString().trim() is ''\n @emit \"end\", null\n return true\n\n try\n @saxParser.write str.toString()\n catch ex\n if ex instanceof exports.ValidationError\n @emit(\"error\", ex.message)\n else\n throw ex", "source_lang": "CoffeeScript", "target_lang": "CoffeeScript", "repo": "Leonidas-from-XIV/node-xml2js", "path": "src/xml2js.coffee", "license": "MIT", "commit": "b023b382d12d72bf0a678fcd3b9f4e9f28fda928", "stars": 4965, "source_url": "https://github.com/Leonidas-from-XIV/node-xml2js/blob/b023b382d12d72bf0a678fcd3b9f4e9f28fda928/src/xml2js.coffee", "line_start": 112, "line_end": 158}92{"id": "Leonidas-from-XIV/node-xml2js:src/xml2js.coffee:4:raw_corpus", "type": "raw_corpus", "prompt": "", "response": "@resultObject = null\n stack = []\n # aliases, so we don't have to type so much\n attrkey = @options.attrkey\n charkey = @options.charkey\n\n @saxParser.onopentag = (node) =>\n obj = {}\n obj[charkey] = \"\"\n unless @options.ignoreAttrs\n for own key of node.attributes\n if attrkey not of obj and not @options.mergeAttrs\n obj[attrkey] = {}\n if @options.mergeAttrs\n obj[key] = node.attributes[key]\n else\n obj[attrkey][key] = node.attributes[key]\n\n # need a place to store the node name\n obj[\"#name\"] = node.name\n stack.push obj\n\n @saxParser.onclosetag = =>\n obj = stack.pop()\n nodeName = obj[\"#name\"]\n delete obj[\"#name\"]\n\n s = stack[stack.length - 1]\n # remove the '#' key altogether if it's blank\n if obj[charkey].match(/^\\s*$/)\n delete obj[charkey]\n else\n obj[charkey] = obj[charkey].trim() if @options.trim\n obj[charkey] = obj[charkey].replace(/\\s{2,}/g, \" \").trim() if @options.normalize\n # also do away with '#' key altogether, if there's no subkeys\n # unless EXPLICIT_CHARKEY is set\n if Object.keys(obj).length == 1 and charkey of obj and not @EXPLICIT_CHARKEY\n obj = obj[charkey]\n\n if @options.emptyTag != undefined && isEmpty obj\n obj = @options.emptyTag\n\n if @options.validator?\n obj = @options.validator(obj, stack, nodeName)\n\n # check whether we closed all the open tags\n if stack.length > 0\n if not @options.explicitArray\n if nodeName not of s\n s[nodeName] = obj", "source_lang": "", "target_lang": "CoffeeScript", "repo": "Leonidas-from-XIV/node-xml2js", "path": "src/xml2js.coffee", "license": "MIT", "commit": "a644bfdc8b9b7817144cdb8bf6a8a5eea7116254", "stars": 4965, "source_url": "https://github.com/Leonidas-from-XIV/node-xml2js/blob/a644bfdc8b9b7817144cdb8bf6a8a5eea7116254/src/xml2js.coffee", "line_start": 62, "line_end": 111}93{"id": "Leonidas-from-XIV/node-xml2js:src/xml2js.coffee:4:completion", "type": "completion", "prompt": "@resultObject = null\n stack = []\n # aliases, so we don't have to type so much\n attrkey = @options.attrkey\n charkey = @options.charkey\n\n @saxParser.onopentag = (node) =>\n obj = {}\n obj[charkey] = \"\"\n unless @options.ignoreAttrs\n for own key of node.attributes\n if attrkey not of obj and not @options.mergeAttrs\n obj[attrkey] = {}\n if @options.mergeAttrs\n obj[key] = node.attributes[key]\n else\n obj[attrkey][key] = node.attributes[key]\n\n # need a place to store the node name\n obj[\"#name\"] = node.name\n stack.push obj\n\n @saxParser.onclosetag = =>\n obj = stack.pop()\n nodeName = obj[\"#name\"]", "response": "delete obj[\"#name\"]\n\n s = stack[stack.length - 1]\n # remove the '#' key altogether if it's blank\n if obj[charkey].match(/^\\s*$/)\n delete obj[charkey]\n else\n obj[charkey] = obj[charkey].trim() if @options.trim\n obj[charkey] = obj[charkey].replace(/\\s{2,}/g, \" \").trim() if @options.normalize\n # also do away with '#' key altogether, if there's no subkeys\n # unless EXPLICIT_CHARKEY is set\n if Object.keys(obj).length == 1 and charkey of obj and not @EXPLICIT_CHARKEY\n obj = obj[charkey]\n\n if @options.emptyTag != undefined && isEmpty obj\n obj = @options.emptyTag\n\n if @options.validator?\n obj = @options.validator(obj, stack, nodeName)\n\n # check whether we closed all the open tags\n if stack.length > 0\n if not @options.explicitArray\n if nodeName not of s\n s[nodeName] = obj", "source_lang": "CoffeeScript", "target_lang": "CoffeeScript", "repo": "Leonidas-from-XIV/node-xml2js", "path": "src/xml2js.coffee", "license": "MIT", "commit": "a644bfdc8b9b7817144cdb8bf6a8a5eea7116254", "stars": 4965, "source_url": "https://github.com/Leonidas-from-XIV/node-xml2js/blob/a644bfdc8b9b7817144cdb8bf6a8a5eea7116254/src/xml2js.coffee", "line_start": 62, "line_end": 111}94{"id": "Leonidas-from-XIV/node-xml2js:src/xml2js.coffee:5:raw_corpus", "type": "raw_corpus", "prompt": "", "response": "else if s[nodeName] instanceof Array\n s[nodeName].push obj\n else\n old = s[nodeName]\n s[nodeName] = [old]\n s[nodeName].push obj\n else\n if not (s[nodeName] instanceof Array)\n s[nodeName] = []\n s[nodeName].push obj\n else\n # if explicitRoot was specified, wrap stuff in the root tag name\n if @options.explicitRoot\n # avoid circular references\n old = obj\n obj = {}\n obj[nodeName] = old\n\n @resultObject = obj\n @emit \"end\", @resultObject\n\n @saxParser.ontext = @saxParser.oncdata = (text) =>\n s = stack[stack.length - 1]\n if s\n s[charkey] += text\n\n parseString: (str, cb) =>\n if cb? and typeof cb is \"function\"\n @on \"end\", (result) ->\n @reset()\n cb null, result\n @on \"error\", (err) ->\n @reset()\n cb err\n\n if str.toString().trim() is ''\n @emit \"end\", null\n return true\n\n try\n @saxParser.write str.toString()\n catch ex\n if ex instanceof exports.ValidationError\n @emit(\"error\", ex.message)\n else\n throw ex", "source_lang": "", "target_lang": "CoffeeScript", "repo": "Leonidas-from-XIV/node-xml2js", "path": "src/xml2js.coffee", "license": "MIT", "commit": "a644bfdc8b9b7817144cdb8bf6a8a5eea7116254", "stars": 4965, "source_url": "https://github.com/Leonidas-from-XIV/node-xml2js/blob/a644bfdc8b9b7817144cdb8bf6a8a5eea7116254/src/xml2js.coffee", "line_start": 112, "line_end": 157}95{"id": "Leonidas-from-XIV/node-xml2js:src/xml2js.coffee:5:completion", "type": "completion", "prompt": "else if s[nodeName] instanceof Array\n s[nodeName].push obj\n else\n old = s[nodeName]\n s[nodeName] = [old]\n s[nodeName].push obj\n else\n if not (s[nodeName] instanceof Array)\n s[nodeName] = []\n s[nodeName].push obj\n else\n # if explicitRoot was specified, wrap stuff in the root tag name\n if @options.explicitRoot\n # avoid circular references\n old = obj\n obj = {}\n obj[nodeName] = old\n\n @resultObject = obj\n @emit \"end\", @resultObject\n\n @saxParser.ontext = @saxParser.oncdata = (text) =>\n s = stack[stack.length - 1]", "response": "if s\n s[charkey] += text\n\n parseString: (str, cb) =>\n if cb? and typeof cb is \"function\"\n @on \"end\", (result) ->\n @reset()\n cb null, result\n @on \"error\", (err) ->\n @reset()\n cb err\n\n if str.toString().trim() is ''\n @emit \"end\", null\n return true\n\n try\n @saxParser.write str.toString()\n catch ex\n if ex instanceof exports.ValidationError\n @emit(\"error\", ex.message)\n else\n throw ex", "source_lang": "CoffeeScript", "target_lang": "CoffeeScript", "repo": "Leonidas-from-XIV/node-xml2js", "path": "src/xml2js.coffee", "license": "MIT", "commit": "a644bfdc8b9b7817144cdb8bf6a8a5eea7116254", "stars": 4965, "source_url": "https://github.com/Leonidas-from-XIV/node-xml2js/blob/a644bfdc8b9b7817144cdb8bf6a8a5eea7116254/src/xml2js.coffee", "line_start": 112, "line_end": 157}96{"id": "Leonidas-from-XIV/node-xml2js:src/xml2js.coffee:3:raw_corpus", "type": "raw_corpus", "prompt": "", "response": "@resultObject = null\n stack = []\n # aliases, so we don't have to type so much\n attrkey = @options.attrkey\n charkey = @options.charkey\n\n @saxParser.onopentag = (node) =>\n obj = {}\n obj[charkey] = \"\"\n unless @options.ignoreAttrs\n for own key of node.attributes\n if attrkey not of obj and not @options.mergeAttrs\n obj[attrkey] = {}\n if @options.mergeAttrs\n obj[key] = node.attributes[key]\n else\n obj[attrkey][key] = node.attributes[key]\n\n # need a place to store the node name\n obj[\"#name\"] = node.name\n stack.push obj\n\n @saxParser.onclosetag = =>\n obj = stack.pop()\n nodeName = obj[\"#name\"]\n delete obj[\"#name\"]\n\n s = stack[stack.length - 1]\n # remove the '#' key altogether if it's blank\n if obj[charkey].match(/^\\s*$/)\n delete obj[charkey]\n else\n obj[charkey] = obj[charkey].trim() if @options.trim\n obj[charkey] = obj[charkey].replace(/\\s{2,}/g, \" \").trim() if @options.normalize\n # also do away with '#' key altogether, if there's no subkeys\n # unless EXPLICIT_CHARKEY is set\n if Object.keys(obj).length == 1 and charkey of obj and not @EXPLICIT_CHARKEY\n obj = obj[charkey]\n\n if @options.emptyTag != undefined && isEmpty obj\n obj = @options.emptyTag\n\n if @options.validator?\n obj = @options.validator.validate(obj, stack, nodeName)\n\n # check whether we closed all the open tags\n if stack.length > 0\n if not @options.explicitArray\n if nodeName not of s\n s[nodeName] = obj", "source_lang": "", "target_lang": "CoffeeScript", "repo": "Leonidas-from-XIV/node-xml2js", "path": "src/xml2js.coffee", "license": "MIT", "commit": "5cb2296cca1e76ea473553607791416dd656aa1b", "stars": 4965, "source_url": "https://github.com/Leonidas-from-XIV/node-xml2js/blob/5cb2296cca1e76ea473553607791416dd656aa1b/src/xml2js.coffee", "line_start": 58, "line_end": 107}97{"id": "Leonidas-from-XIV/node-xml2js:src/xml2js.coffee:3:completion", "type": "completion", "prompt": "@resultObject = null\n stack = []\n # aliases, so we don't have to type so much\n attrkey = @options.attrkey\n charkey = @options.charkey\n\n @saxParser.onopentag = (node) =>\n obj = {}\n obj[charkey] = \"\"\n unless @options.ignoreAttrs\n for own key of node.attributes\n if attrkey not of obj and not @options.mergeAttrs\n obj[attrkey] = {}\n if @options.mergeAttrs\n obj[key] = node.attributes[key]\n else\n obj[attrkey][key] = node.attributes[key]\n\n # need a place to store the node name\n obj[\"#name\"] = node.name\n stack.push obj\n\n @saxParser.onclosetag = =>\n obj = stack.pop()\n nodeName = obj[\"#name\"]", "response": "delete obj[\"#name\"]\n\n s = stack[stack.length - 1]\n # remove the '#' key altogether if it's blank\n if obj[charkey].match(/^\\s*$/)\n delete obj[charkey]\n else\n obj[charkey] = obj[charkey].trim() if @options.trim\n obj[charkey] = obj[charkey].replace(/\\s{2,}/g, \" \").trim() if @options.normalize\n # also do away with '#' key altogether, if there's no subkeys\n # unless EXPLICIT_CHARKEY is set\n if Object.keys(obj).length == 1 and charkey of obj and not @EXPLICIT_CHARKEY\n obj = obj[charkey]\n\n if @options.emptyTag != undefined && isEmpty obj\n obj = @options.emptyTag\n\n if @options.validator?\n obj = @options.validator.validate(obj, stack, nodeName)\n\n # check whether we closed all the open tags\n if stack.length > 0\n if not @options.explicitArray\n if nodeName not of s\n s[nodeName] = obj", "source_lang": "CoffeeScript", "target_lang": "CoffeeScript", "repo": "Leonidas-from-XIV/node-xml2js", "path": "src/xml2js.coffee", "license": "MIT", "commit": "5cb2296cca1e76ea473553607791416dd656aa1b", "stars": 4965, "source_url": "https://github.com/Leonidas-from-XIV/node-xml2js/blob/5cb2296cca1e76ea473553607791416dd656aa1b/src/xml2js.coffee", "line_start": 58, "line_end": 107}98{"id": "Leonidas-from-XIV/node-xml2js:src/xml2js.coffee:4:raw_corpus", "type": "raw_corpus", "prompt": "", "response": "else if s[nodeName] instanceof Array\n s[nodeName].push obj\n else\n old = s[nodeName]\n s[nodeName] = [old]\n s[nodeName].push obj\n else\n if not (s[nodeName] instanceof Array)\n s[nodeName] = []\n s[nodeName].push obj\n else\n # if explicitRoot was specified, wrap stuff in the root tag name\n if @options.explicitRoot\n # avoid circular references\n old = obj\n obj = {}\n obj[nodeName] = old\n\n @resultObject = obj\n @emit \"end\", @resultObject\n\n @saxParser.ontext = @saxParser.oncdata = (text) =>\n s = stack[stack.length - 1]\n if s\n s[charkey] += text\n\n parseString: (str, cb) =>\n if cb? and typeof cb is \"function\"\n @on \"end\", (result) ->\n @reset()\n cb null, result\n @on \"error\", (err) ->\n @reset()\n cb err\n\n if str.toString().trim() is ''\n @emit \"end\", null\n return true\n\n try\n @saxParser.write str.toString()\n catch ex\n @emit(\"error\", ex.message)\n return @saxParser", "source_lang": "", "target_lang": "CoffeeScript", "repo": "Leonidas-from-XIV/node-xml2js", "path": "src/xml2js.coffee", "license": "MIT", "commit": "5cb2296cca1e76ea473553607791416dd656aa1b", "stars": 4965, "source_url": "https://github.com/Leonidas-from-XIV/node-xml2js/blob/5cb2296cca1e76ea473553607791416dd656aa1b/src/xml2js.coffee", "line_start": 108, "line_end": 151}99{"id": "Leonidas-from-XIV/node-xml2js:src/xml2js.coffee:4:completion", "type": "completion", "prompt": "else if s[nodeName] instanceof Array\n s[nodeName].push obj\n else\n old = s[nodeName]\n s[nodeName] = [old]\n s[nodeName].push obj\n else\n if not (s[nodeName] instanceof Array)\n s[nodeName] = []\n s[nodeName].push obj\n else\n # if explicitRoot was specified, wrap stuff in the root tag name\n if @options.explicitRoot\n # avoid circular references\n old = obj\n obj = {}\n obj[nodeName] = old\n\n @resultObject = obj\n @emit \"end\", @resultObject\n\n @saxParser.ontext = @saxParser.oncdata = (text) =>", "response": "s = stack[stack.length - 1]\n if s\n s[charkey] += text\n\n parseString: (str, cb) =>\n if cb? and typeof cb is \"function\"\n @on \"end\", (result) ->\n @reset()\n cb null, result\n @on \"error\", (err) ->\n @reset()\n cb err\n\n if str.toString().trim() is ''\n @emit \"end\", null\n return true\n\n try\n @saxParser.write str.toString()\n catch ex\n @emit(\"error\", ex.message)\n return @saxParser", "source_lang": "CoffeeScript", "target_lang": "CoffeeScript", "repo": "Leonidas-from-XIV/node-xml2js", "path": "src/xml2js.coffee", "license": "MIT", "commit": "5cb2296cca1e76ea473553607791416dd656aa1b", "stars": 4965, "source_url": "https://github.com/Leonidas-from-XIV/node-xml2js/blob/5cb2296cca1e76ea473553607791416dd656aa1b/src/xml2js.coffee", "line_start": 108, "line_end": 151}100{"id": "Leonidas-from-XIV/node-xml2js:src/xml2js.coffee:2:raw_corpus", "type": "raw_corpus", "prompt": "", "response": "class exports.Parser extends events.EventEmitter\n constructor: (opts) ->\n # default options. for compatibility's sake set to some\n # sub-optimal settings. might change in the future.\n @options =\n explicitCharkey: false\n trim: true\n # normalize implicates trimming, just so you know\n normalize: true\n # set default attribute object key\n attrkey: \"@\"\n # set default char object key\n charkey: \"#\"\n # always put child nodes in an array\n explicitArray: false\n # ignore all attributes regardless\n ignoreAttrs: false\n # overwrite them with the specified options, if any\n @options[key] = value for own key, value of opts\n\n @reset()\n\n reset: =>\n # remove all previous listeners for events, to prevent event listener\n # accumulation\n @removeAllListeners()\n # make the SAX parser. tried trim and normalize, but they are not\n # very helpful\n @saxParser = sax.parser true, {\n trim: false,\n normalize: false\n }\n\n # emit one error event if the sax parser fails. this is mostly a hack, but\n # the sax parser isn't state of the art either.\n err = false\n @saxParser.onerror = (error) =>\n if ! err\n err = true\n @emit \"error\", error\n\n # always use the '#' key, even if there are no subkeys\n # setting this property by and is deprecated, yet still supported.\n # better pass it as explicitCharkey option to the constructor\n @EXPLICIT_CHARKEY = @options.explicitCharkey\n @resultObject = null\n stack = []\n # aliases, so we don't have to type so much\n attrkey = @options.attrkey\n charkey = @options.charkey", "source_lang": "", "target_lang": "CoffeeScript", "repo": "Leonidas-from-XIV/node-xml2js", "path": "src/xml2js.coffee", "license": "MIT", "commit": "b863ed92abfb92a9cb2cd82c636c492a13270327", "stars": 4965, "source_url": "https://github.com/Leonidas-from-XIV/node-xml2js/blob/b863ed92abfb92a9cb2cd82c636c492a13270327/src/xml2js.coffee", "line_start": 8, "line_end": 57}101{"id": "Leonidas-from-XIV/node-xml2js:src/xml2js.coffee:2:completion", "type": "completion", "prompt": "class exports.Parser extends events.EventEmitter\n constructor: (opts) ->\n # default options. for compatibility's sake set to some\n # sub-optimal settings. might change in the future.\n @options =\n explicitCharkey: false\n trim: true\n # normalize implicates trimming, just so you know\n normalize: true\n # set default attribute object key\n attrkey: \"@\"\n # set default char object key\n charkey: \"#\"\n # always put child nodes in an array\n explicitArray: false\n # ignore all attributes regardless\n ignoreAttrs: false\n # overwrite them with the specified options, if any\n @options[key] = value for own key, value of opts\n\n @reset()\n\n reset: =>\n # remove all previous listeners for events, to prevent event listener\n # accumulation", "response": "@removeAllListeners()\n # make the SAX parser. tried trim and normalize, but they are not\n # very helpful\n @saxParser = sax.parser true, {\n trim: false,\n normalize: false\n }\n\n # emit one error event if the sax parser fails. this is mostly a hack, but\n # the sax parser isn't state of the art either.\n err = false\n @saxParser.onerror = (error) =>\n if ! err\n err = true\n @emit \"error\", error\n\n # always use the '#' key, even if there are no subkeys\n # setting this property by and is deprecated, yet still supported.\n # better pass it as explicitCharkey option to the constructor\n @EXPLICIT_CHARKEY = @options.explicitCharkey\n @resultObject = null\n stack = []\n # aliases, so we don't have to type so much\n attrkey = @options.attrkey\n charkey = @options.charkey", "source_lang": "CoffeeScript", "target_lang": "CoffeeScript", "repo": "Leonidas-from-XIV/node-xml2js", "path": "src/xml2js.coffee", "license": "MIT", "commit": "b863ed92abfb92a9cb2cd82c636c492a13270327", "stars": 4965, "source_url": "https://github.com/Leonidas-from-XIV/node-xml2js/blob/b863ed92abfb92a9cb2cd82c636c492a13270327/src/xml2js.coffee", "line_start": 8, "line_end": 57}102{"id": "Leonidas-from-XIV/node-xml2js:src/xml2js.coffee:3:raw_corpus", "type": "raw_corpus", "prompt": "", "response": "@saxParser.onopentag = (node) =>\n obj = {}\n obj[charkey] = \"\"\n unless @options.ignoreAttrs\n for own key of node.attributes\n if attrkey not of obj\n obj[attrkey] = {}\n obj[attrkey][key] = node.attributes[key]\n\n # need a place to store the node name\n obj[\"#name\"] = node.name\n stack.push obj\n\n @saxParser.onclosetag = =>\n obj = stack.pop()\n nodeName = obj[\"#name\"]\n delete obj[\"#name\"]\n\n s = stack[stack.length - 1]\n # remove the '#' key altogether if it's blank\n if obj[charkey].match(/^\\s*$/)\n delete obj[charkey]\n else\n obj[charkey] = obj[charkey].trim() if @options.trim\n obj[charkey] = obj[charkey].replace(/\\s{2,}/g, \" \").trim() if @options.normalize\n # also do away with '#' key altogether, if there's no subkeys\n # unless EXPLICIT_CHARKEY is set\n if Object.keys(obj).length == 1 and charkey of obj and not @EXPLICIT_CHARKEY\n obj = obj[charkey]\n\n if @options.emptyTag != undefined && isEmpty obj\n obj = @options.emptyTag\n\n # check whether we closed all the open tags\n if stack.length > 0\n if not @options.explicitArray\n if nodeName not of s\n s[nodeName] = obj\n else if s[nodeName] instanceof Array\n s[nodeName].push obj\n else\n old = s[nodeName]\n s[nodeName] = [old]\n s[nodeName].push obj\n else\n if not (s[nodeName] instanceof Array)\n s[nodeName] = []\n s[nodeName].push obj\n else", "source_lang": "", "target_lang": "CoffeeScript", "repo": "Leonidas-from-XIV/node-xml2js", "path": "src/xml2js.coffee", "license": "MIT", "commit": "b863ed92abfb92a9cb2cd82c636c492a13270327", "stars": 4965, "source_url": "https://github.com/Leonidas-from-XIV/node-xml2js/blob/b863ed92abfb92a9cb2cd82c636c492a13270327/src/xml2js.coffee", "line_start": 58, "line_end": 107}103{"id": "Leonidas-from-XIV/node-xml2js:src/xml2js.coffee:3:coffee_to_js", "type": "coffee_to_js", "prompt": "Convert this CoffeeScript to JavaScript.\n```coffeescript\n@saxParser.onopentag = (node) =>\n obj = {}\n obj[charkey] = \"\"\n unless @options.ignoreAttrs\n for own key of node.attributes\n if attrkey not of obj\n obj[attrkey] = {}\n obj[attrkey][key] = node.attributes[key]\n\n # need a place to store the node name\n obj[\"#name\"] = node.name\n stack.push obj\n\n @saxParser.onclosetag = =>\n obj = stack.pop()\n nodeName = obj[\"#name\"]\n delete obj[\"#name\"]\n\n s = stack[stack.length - 1]\n # remove the '#' key altogether if it's blank\n if obj[charkey].match(/^\\s*$/)\n delete obj[charkey]\n else\n obj[charkey] = obj[charkey].trim() if @options.trim\n obj[charkey] = obj[charkey].replace(/\\s{2,}/g, \" \").trim() if @options.normalize\n # also do away with '#' key altogether, if there's no subkeys\n # unless EXPLICIT_CHARKEY is set\n if Object.keys(obj).length == 1 and charkey of obj and not @EXPLICIT_CHARKEY\n obj = obj[charkey]\n\n if @options.emptyTag != undefined && isEmpty obj\n obj = @options.emptyTag\n\n # check whether we closed all the open tags\n if stack.length > 0\n if not @options.explicitArray\n if nodeName not of s\n s[nodeName] = obj\n else if s[nodeName] instanceof Array\n s[nodeName].push obj\n else\n old = s[nodeName]\n s[nodeName] = [old]\n s[nodeName].push obj\n else\n if not (s[nodeName] instanceof Array)\n s[nodeName] = []\n s[nodeName].push obj\n else\n```", "response": "var hasProp = {}.hasOwnProperty;\n\nthis.saxParser.onopentag = (node) => {\n var key, obj, ref;\n obj = {};\n obj[charkey] = \"\";\n if (!this.options.ignoreAttrs) {\n ref = node.attributes;\n for (key in ref) {\n if (!hasProp.call(ref, key)) continue;\n if (!(attrkey in obj)) {\n obj[attrkey] = {};\n }\n obj[attrkey][key] = node.attributes[key];\n }\n }\n // need a place to store the node name\n obj[\"#name\"] = node.name;\n return stack.push(obj);\n};\n\nthis.saxParser.onclosetag = () => {\n var nodeName, obj, old, s;\n obj = stack.pop();\n nodeName = obj[\"#name\"];\n delete obj[\"#name\"];\n s = stack[stack.length - 1];\n // remove the '#' key altogether if it's blank\n if (obj[charkey].match(/^\\s*$/)) {\n delete obj[charkey];\n } else {\n if (this.options.trim) {\n obj[charkey] = obj[charkey].trim();\n }\n if (this.options.normalize) {\n obj[charkey] = obj[charkey].replace(/\\s{2,}/g, \" \").trim();\n }\n // also do away with '#' key altogether, if there's no subkeys\n // unless EXPLICIT_CHARKEY is set\n if (Object.keys(obj).length === 1 && charkey in obj && !this.EXPLICIT_CHARKEY) {\n obj = obj[charkey];\n }\n }\n if (this.options.emptyTag !== void 0 && isEmpty(obj)) {\n obj = this.options.emptyTag;\n }\n // check whether we closed all the open tags\n if (stack.length > 0) {\n if (!this.options.explicitArray) {\n if (!(nodeName in s)) {\n return s[nodeName] = obj;\n } else if (s[nodeName] instanceof Array) {\n return s[nodeName].push(obj);\n } else {\n old = s[nodeName];\n s[nodeName] = [old];\n return s[nodeName].push(obj);\n }\n } else {\n if (!(s[nodeName] instanceof Array)) {\n s[nodeName] = [];\n }\n return s[nodeName].push(obj);\n }\n } else {\n\n }\n};", "source_lang": "CoffeeScript", "target_lang": "JavaScript", "repo": "Leonidas-from-XIV/node-xml2js", "path": "src/xml2js.coffee", "license": "MIT", "commit": "b863ed92abfb92a9cb2cd82c636c492a13270327", "stars": 4965, "source_url": "https://github.com/Leonidas-from-XIV/node-xml2js/blob/b863ed92abfb92a9cb2cd82c636c492a13270327/src/xml2js.coffee", "line_start": 58, "line_end": 107}104{"id": "Leonidas-from-XIV/node-xml2js:src/xml2js.coffee:3:js_to_coffee", "type": "js_to_coffee", "prompt": "Convert this JavaScript to CoffeeScript.\n```javascript\nvar hasProp = {}.hasOwnProperty;\n\nthis.saxParser.onopentag = (node) => {\n var key, obj, ref;\n obj = {};\n obj[charkey] = \"\";\n if (!this.options.ignoreAttrs) {\n ref = node.attributes;\n for (key in ref) {\n if (!hasProp.call(ref, key)) continue;\n if (!(attrkey in obj)) {\n obj[attrkey] = {};\n }\n obj[attrkey][key] = node.attributes[key];\n }\n }\n // need a place to store the node name\n obj[\"#name\"] = node.name;\n return stack.push(obj);\n};\n\nthis.saxParser.onclosetag = () => {\n var nodeName, obj, old, s;\n obj = stack.pop();\n nodeName = obj[\"#name\"];\n delete obj[\"#name\"];\n s = stack[stack.length - 1];\n // remove the '#' key altogether if it's blank\n if (obj[charkey].match(/^\\s*$/)) {\n delete obj[charkey];\n } else {\n if (this.options.trim) {\n obj[charkey] = obj[charkey].trim();\n }\n if (this.options.normalize) {\n obj[charkey] = obj[charkey].replace(/\\s{2,}/g, \" \").trim();\n }\n // also do away with '#' key altogether, if there's no subkeys\n // unless EXPLICIT_CHARKEY is set\n if (Object.keys(obj).length === 1 && charkey in obj && !this.EXPLICIT_CHARKEY) {\n obj = obj[charkey];\n }\n }\n if (this.options.emptyTag !== void 0 && isEmpty(obj)) {\n obj = this.options.emptyTag;\n }\n // check whether we closed all the open tags\n if (stack.length > 0) {\n if (!this.options.explicitArray) {\n if (!(nodeName in s)) {\n return s[nodeName] = obj;\n } else if (s[nodeName] instanceof Array) {\n return s[nodeName].push(obj);\n } else {\n old = s[nodeName];\n s[nodeName] = [old];\n return s[nodeName].push(obj);\n }\n } else {\n if (!(s[nodeName] instanceof Array)) {\n s[nodeName] = [];\n }\n return s[nodeName].push(obj);\n }\n } else {\n\n }\n};\n```", "response": "@saxParser.onopentag = (node) =>\n obj = {}\n obj[charkey] = \"\"\n unless @options.ignoreAttrs\n for own key of node.attributes\n if attrkey not of obj\n obj[attrkey] = {}\n obj[attrkey][key] = node.attributes[key]\n\n # need a place to store the node name\n obj[\"#name\"] = node.name\n stack.push obj\n\n @saxParser.onclosetag = =>\n obj = stack.pop()\n nodeName = obj[\"#name\"]\n delete obj[\"#name\"]\n\n s = stack[stack.length - 1]\n # remove the '#' key altogether if it's blank\n if obj[charkey].match(/^\\s*$/)\n delete obj[charkey]\n else\n obj[charkey] = obj[charkey].trim() if @options.trim\n obj[charkey] = obj[charkey].replace(/\\s{2,}/g, \" \").trim() if @options.normalize\n # also do away with '#' key altogether, if there's no subkeys\n # unless EXPLICIT_CHARKEY is set\n if Object.keys(obj).length == 1 and charkey of obj and not @EXPLICIT_CHARKEY\n obj = obj[charkey]\n\n if @options.emptyTag != undefined && isEmpty obj\n obj = @options.emptyTag\n\n # check whether we closed all the open tags\n if stack.length > 0\n if not @options.explicitArray\n if nodeName not of s\n s[nodeName] = obj\n else if s[nodeName] instanceof Array\n s[nodeName].push obj\n else\n old = s[nodeName]\n s[nodeName] = [old]\n s[nodeName].push obj\n else\n if not (s[nodeName] instanceof Array)\n s[nodeName] = []\n s[nodeName].push obj\n else", "source_lang": "JavaScript", "target_lang": "CoffeeScript", "repo": "Leonidas-from-XIV/node-xml2js", "path": "src/xml2js.coffee", "license": "MIT", "commit": "b863ed92abfb92a9cb2cd82c636c492a13270327", "stars": 4965, "source_url": "https://github.com/Leonidas-from-XIV/node-xml2js/blob/b863ed92abfb92a9cb2cd82c636c492a13270327/src/xml2js.coffee", "line_start": 58, "line_end": 107}105{"id": "Leonidas-from-XIV/node-xml2js:src/xml2js.coffee:3:completion", "type": "completion", "prompt": "@saxParser.onopentag = (node) =>\n obj = {}\n obj[charkey] = \"\"\n unless @options.ignoreAttrs\n for own key of node.attributes\n if attrkey not of obj\n obj[attrkey] = {}\n obj[attrkey][key] = node.attributes[key]\n\n # need a place to store the node name\n obj[\"#name\"] = node.name\n stack.push obj\n\n @saxParser.onclosetag = =>\n obj = stack.pop()\n nodeName = obj[\"#name\"]\n delete obj[\"#name\"]\n\n s = stack[stack.length - 1]\n # remove the '#' key altogether if it's blank\n if obj[charkey].match(/^\\s*$/)\n delete obj[charkey]\n else\n obj[charkey] = obj[charkey].trim() if @options.trim", "response": "obj[charkey] = obj[charkey].replace(/\\s{2,}/g, \" \").trim() if @options.normalize\n # also do away with '#' key altogether, if there's no subkeys\n # unless EXPLICIT_CHARKEY is set\n if Object.keys(obj).length == 1 and charkey of obj and not @EXPLICIT_CHARKEY\n obj = obj[charkey]\n\n if @options.emptyTag != undefined && isEmpty obj\n obj = @options.emptyTag\n\n # check whether we closed all the open tags\n if stack.length > 0\n if not @options.explicitArray\n if nodeName not of s\n s[nodeName] = obj\n else if s[nodeName] instanceof Array\n s[nodeName].push obj\n else\n old = s[nodeName]\n s[nodeName] = [old]\n s[nodeName].push obj\n else\n if not (s[nodeName] instanceof Array)\n s[nodeName] = []\n s[nodeName].push obj\n else", "source_lang": "CoffeeScript", "target_lang": "CoffeeScript", "repo": "Leonidas-from-XIV/node-xml2js", "path": "src/xml2js.coffee", "license": "MIT", "commit": "b863ed92abfb92a9cb2cd82c636c492a13270327", "stars": 4965, "source_url": "https://github.com/Leonidas-from-XIV/node-xml2js/blob/b863ed92abfb92a9cb2cd82c636c492a13270327/src/xml2js.coffee", "line_start": 58, "line_end": 107}106{"id": "Leonidas-from-XIV/node-xml2js:src/xml2js.coffee:4:raw_corpus", "type": "raw_corpus", "prompt": "", "response": "# if explicitRoot was specified, wrap stuff in the root tag name\n if @options.explicitRoot\n # avoid circular references\n old = obj\n obj = {}\n obj[nodeName] = old\n\n @resultObject = obj\n @emit \"end\", @resultObject\n\n @saxParser.ontext = @saxParser.oncdata = (text) =>\n s = stack[stack.length - 1]\n if s\n s[charkey] += text\n\n parseString: (str, cb) =>\n if cb? and typeof cb is \"function\"\n @on \"end\", (result) ->\n @reset()\n cb null, result\n @on \"error\", (err) ->\n @reset()\n cb err\n\n if str.toString().trim() is ''\n @emit \"end\", null\n return true\n\n @saxParser.write str.toString()", "source_lang": "", "target_lang": "CoffeeScript", "repo": "Leonidas-from-XIV/node-xml2js", "path": "src/xml2js.coffee", "license": "MIT", "commit": "b863ed92abfb92a9cb2cd82c636c492a13270327", "stars": 4965, "source_url": "https://github.com/Leonidas-from-XIV/node-xml2js/blob/b863ed92abfb92a9cb2cd82c636c492a13270327/src/xml2js.coffee", "line_start": 108, "line_end": 136}107{"id": "Leonidas-from-XIV/node-xml2js:src/xml2js.coffee:4:completion", "type": "completion", "prompt": "# if explicitRoot was specified, wrap stuff in the root tag name\n if @options.explicitRoot\n # avoid circular references\n old = obj\n obj = {}\n obj[nodeName] = old\n\n @resultObject = obj\n @emit \"end\", @resultObject\n\n @saxParser.ontext = @saxParser.oncdata = (text) =>\n s = stack[stack.length - 1]\n if s\n s[charkey] += text", "response": "parseString: (str, cb) =>\n if cb? and typeof cb is \"function\"\n @on \"end\", (result) ->\n @reset()\n cb null, result\n @on \"error\", (err) ->\n @reset()\n cb err\n\n if str.toString().trim() is ''\n @emit \"end\", null\n return true\n\n @saxParser.write str.toString()", "source_lang": "CoffeeScript", "target_lang": "CoffeeScript", "repo": "Leonidas-from-XIV/node-xml2js", "path": "src/xml2js.coffee", "license": "MIT", "commit": "b863ed92abfb92a9cb2cd82c636c492a13270327", "stars": 4965, "source_url": "https://github.com/Leonidas-from-XIV/node-xml2js/blob/b863ed92abfb92a9cb2cd82c636c492a13270327/src/xml2js.coffee", "line_start": 108, "line_end": 136}108{"id": "Leonidas-from-XIV/node-xml2js:src/xml2js.coffee:2:raw_corpus", "type": "raw_corpus", "prompt": "", "response": "class exports.Parser extends events.EventEmitter\n constructor: (opts) ->\n # default options. for compatibility's sake set to some\n # sub-optimal settings. might change in the future.\n @options =\n explicitCharkey: false\n trim: true\n # normalize implicates trimming, just so you know\n normalize: true\n # set default attribute object key\n attrkey: \"@\"\n # set default char object key\n charkey: \"#\"\n # always put child nodes in an array\n explicitArray: false\n # ignore all attributes regardless\n ignoreAttrs: false\n # overwrite them with the specified options, if any\n @options[key] = value for own key, value of opts\n\n @reset()\n\n reset: =>\n # make the SAX parser. tried trim and normalize, but they are not\n # very helpful\n @saxParser = sax.parser true, {\n trim: false,\n normalize: false\n }\n\n # emit one error event if the sax parser fails. this is mostly a hack, but\n # the sax parser isn't state of the art either.\n err = false\n @saxParser.onerror = (error) =>\n if ! err\n err = true\n @emit \"error\", error\n\n # always use the '#' key, even if there are no subkeys\n # setting this property by and is deprecated, yet still supported.\n # better pass it as explicitCharkey option to the constructor\n @EXPLICIT_CHARKEY = @options.explicitCharkey\n @resultObject = null\n stack = []\n # aliases, so we don't have to type so much\n attrkey = @options.attrkey\n charkey = @options.charkey\n\n @saxParser.onopentag = (node) =>\n obj = {}", "source_lang": "", "target_lang": "CoffeeScript", "repo": "Leonidas-from-XIV/node-xml2js", "path": "src/xml2js.coffee", "license": "MIT", "commit": "c37c82a8b06fe2872f0d5d2334e78ff19aea7542", "stars": 4965, "source_url": "https://github.com/Leonidas-from-XIV/node-xml2js/blob/c37c82a8b06fe2872f0d5d2334e78ff19aea7542/src/xml2js.coffee", "line_start": 8, "line_end": 57}109{"id": "Leonidas-from-XIV/node-xml2js:src/xml2js.coffee:2:completion", "type": "completion", "prompt": "class exports.Parser extends events.EventEmitter\n constructor: (opts) ->\n # default options. for compatibility's sake set to some\n # sub-optimal settings. might change in the future.\n @options =\n explicitCharkey: false\n trim: true\n # normalize implicates trimming, just so you know\n normalize: true\n # set default attribute object key\n attrkey: \"@\"\n # set default char object key\n charkey: \"#\"\n # always put child nodes in an array\n explicitArray: false\n # ignore all attributes regardless\n ignoreAttrs: false\n # overwrite them with the specified options, if any\n @options[key] = value for own key, value of opts\n\n @reset()\n\n reset: =>\n # make the SAX parser. tried trim and normalize, but they are not\n # very helpful", "response": "@saxParser = sax.parser true, {\n trim: false,\n normalize: false\n }\n\n # emit one error event if the sax parser fails. this is mostly a hack, but\n # the sax parser isn't state of the art either.\n err = false\n @saxParser.onerror = (error) =>\n if ! err\n err = true\n @emit \"error\", error\n\n # always use the '#' key, even if there are no subkeys\n # setting this property by and is deprecated, yet still supported.\n # better pass it as explicitCharkey option to the constructor\n @EXPLICIT_CHARKEY = @options.explicitCharkey\n @resultObject = null\n stack = []\n # aliases, so we don't have to type so much\n attrkey = @options.attrkey\n charkey = @options.charkey\n\n @saxParser.onopentag = (node) =>\n obj = {}", "source_lang": "CoffeeScript", "target_lang": "CoffeeScript", "repo": "Leonidas-from-XIV/node-xml2js", "path": "src/xml2js.coffee", "license": "MIT", "commit": "c37c82a8b06fe2872f0d5d2334e78ff19aea7542", "stars": 4965, "source_url": "https://github.com/Leonidas-from-XIV/node-xml2js/blob/c37c82a8b06fe2872f0d5d2334e78ff19aea7542/src/xml2js.coffee", "line_start": 8, "line_end": 57}110{"id": "Leonidas-from-XIV/node-xml2js:src/xml2js.coffee:3:raw_corpus", "type": "raw_corpus", "prompt": "", "response": "obj[charkey] = \"\"\n unless @options.ignoreAttrs\n for own key of node.attributes\n if attrkey not of obj\n obj[attrkey] = {}\n obj[attrkey][key] = node.attributes[key]\n\n # need a place to store the node name\n obj[\"#name\"] = node.name\n stack.push obj\n\n @saxParser.onclosetag = =>\n obj = stack.pop()\n nodeName = obj[\"#name\"]\n delete obj[\"#name\"]\n\n s = stack[stack.length - 1]\n # remove the '#' key altogether if it's blank\n if obj[charkey].match(/^\\s*$/)\n delete obj[charkey]\n else\n obj[charkey] = obj[charkey].trim() if @options.trim\n obj[charkey] = obj[charkey].replace(/\\s{2,}/g, \" \").trim() if @options.normalize\n # also do away with '#' key altogether, if there's no subkeys\n # unless EXPLICIT_CHARKEY is set\n if Object.keys(obj).length == 1 and charkey of obj and not @EXPLICIT_CHARKEY\n obj = obj[charkey]\n\n if @options.emptyTag != undefined && isEmpty obj\n obj = @options.emptyTag\n\n # check whether we closed all the open tags\n if stack.length > 0\n if not @options.explicitArray\n if nodeName not of s\n s[nodeName] = obj\n else if s[nodeName] instanceof Array\n s[nodeName].push obj\n else\n old = s[nodeName]\n s[nodeName] = [old]\n s[nodeName].push obj\n else\n if not (s[nodeName] instanceof Array)\n s[nodeName] = []\n s[nodeName].push obj\n else\n # if explicitRoot was specified, wrap stuff in the root tag name\n if @options.explicitRoot\n # avoid circular references", "source_lang": "", "target_lang": "CoffeeScript", "repo": "Leonidas-from-XIV/node-xml2js", "path": "src/xml2js.coffee", "license": "MIT", "commit": "c37c82a8b06fe2872f0d5d2334e78ff19aea7542", "stars": 4965, "source_url": "https://github.com/Leonidas-from-XIV/node-xml2js/blob/c37c82a8b06fe2872f0d5d2334e78ff19aea7542/src/xml2js.coffee", "line_start": 58, "line_end": 107}111{"id": "Leonidas-from-XIV/node-xml2js:src/xml2js.coffee:3:completion", "type": "completion", "prompt": "obj[charkey] = \"\"\n unless @options.ignoreAttrs\n for own key of node.attributes\n if attrkey not of obj\n obj[attrkey] = {}\n obj[attrkey][key] = node.attributes[key]\n\n # need a place to store the node name\n obj[\"#name\"] = node.name\n stack.push obj\n\n @saxParser.onclosetag = =>\n obj = stack.pop()\n nodeName = obj[\"#name\"]\n delete obj[\"#name\"]\n\n s = stack[stack.length - 1]\n # remove the '#' key altogether if it's blank\n if obj[charkey].match(/^\\s*$/)\n delete obj[charkey]\n else\n obj[charkey] = obj[charkey].trim() if @options.trim\n obj[charkey] = obj[charkey].replace(/\\s{2,}/g, \" \").trim() if @options.normalize\n # also do away with '#' key altogether, if there's no subkeys\n # unless EXPLICIT_CHARKEY is set", "response": "if Object.keys(obj).length == 1 and charkey of obj and not @EXPLICIT_CHARKEY\n obj = obj[charkey]\n\n if @options.emptyTag != undefined && isEmpty obj\n obj = @options.emptyTag\n\n # check whether we closed all the open tags\n if stack.length > 0\n if not @options.explicitArray\n if nodeName not of s\n s[nodeName] = obj\n else if s[nodeName] instanceof Array\n s[nodeName].push obj\n else\n old = s[nodeName]\n s[nodeName] = [old]\n s[nodeName].push obj\n else\n if not (s[nodeName] instanceof Array)\n s[nodeName] = []\n s[nodeName].push obj\n else\n # if explicitRoot was specified, wrap stuff in the root tag name\n if @options.explicitRoot\n # avoid circular references", "source_lang": "CoffeeScript", "target_lang": "CoffeeScript", "repo": "Leonidas-from-XIV/node-xml2js", "path": "src/xml2js.coffee", "license": "MIT", "commit": "c37c82a8b06fe2872f0d5d2334e78ff19aea7542", "stars": 4965, "source_url": "https://github.com/Leonidas-from-XIV/node-xml2js/blob/c37c82a8b06fe2872f0d5d2334e78ff19aea7542/src/xml2js.coffee", "line_start": 58, "line_end": 107}112{"id": "Leonidas-from-XIV/node-xml2js:src/xml2js.coffee:4:raw_corpus", "type": "raw_corpus", "prompt": "", "response": "old = obj\n obj = {}\n obj[nodeName] = old\n\n @resultObject = obj\n @emit \"end\", @resultObject\n\n @saxParser.ontext = @saxParser.oncdata = (text) =>\n s = stack[stack.length - 1]\n if s\n s[charkey] += text\n\n parseString: (str, cb) =>\n if cb? and typeof cb is \"function\"\n @on \"end\", (result) ->\n @reset()\n cb null, result\n @on \"error\", (err) ->\n @reset()\n cb err\n\n if str.toString().trim() is ''\n @emit \"end\", null\n return true\n\n @saxParser.write str.toString()", "source_lang": "", "target_lang": "CoffeeScript", "repo": "Leonidas-from-XIV/node-xml2js", "path": "src/xml2js.coffee", "license": "MIT", "commit": "c37c82a8b06fe2872f0d5d2334e78ff19aea7542", "stars": 4965, "source_url": "https://github.com/Leonidas-from-XIV/node-xml2js/blob/c37c82a8b06fe2872f0d5d2334e78ff19aea7542/src/xml2js.coffee", "line_start": 108, "line_end": 133}113{"id": "Leonidas-from-XIV/node-xml2js:src/xml2js.coffee:4:completion", "type": "completion", "prompt": "old = obj\n obj = {}\n obj[nodeName] = old\n\n @resultObject = obj\n @emit \"end\", @resultObject\n\n @saxParser.ontext = @saxParser.oncdata = (text) =>\n s = stack[stack.length - 1]\n if s\n s[charkey] += text\n\n parseString: (str, cb) =>", "response": "if cb? and typeof cb is \"function\"\n @on \"end\", (result) ->\n @reset()\n cb null, result\n @on \"error\", (err) ->\n @reset()\n cb err\n\n if str.toString().trim() is ''\n @emit \"end\", null\n return true\n\n @saxParser.write str.toString()", "source_lang": "CoffeeScript", "target_lang": "CoffeeScript", "repo": "Leonidas-from-XIV/node-xml2js", "path": "src/xml2js.coffee", "license": "MIT", "commit": "c37c82a8b06fe2872f0d5d2334e78ff19aea7542", "stars": 4965, "source_url": "https://github.com/Leonidas-from-XIV/node-xml2js/blob/c37c82a8b06fe2872f0d5d2334e78ff19aea7542/src/xml2js.coffee", "line_start": 108, "line_end": 133}114{"id": "Leonidas-from-XIV/node-xml2js:src/xml2js.coffee:2:raw_corpus", "type": "raw_corpus", "prompt": "", "response": "class exports.Parser extends events.EventEmitter\n constructor: (opts) ->\n\n # default options. for compatibility's sake set to some\n # sub-optimal settings. might change in the future.\n options =\n explicitCharkey: false\n trim: true\n # normalize implicates trimming, just so you know\n normalize: true\n # set default attribute object key\n attrkey: \"@\"\n # set default char object key\n charkey: \"#\"\n # always put child nodes in an array\n explicitArray: false\n # ignore all attributes regardless\n ignoreAttrs: false\n # overwrite them with the specified options, if any\n options[key] = value for own key, value of opts\n\n # make the SAX parser. tried trim and normalize, but they are not\n # very helpful\n @saxParser = sax.parser true, {\n trim: false,\n normalize: false\n }\n\n # emit one error event if the sax parser fails. this is mostly a hack, but\n # the sax parser isn't state of the art either.\n err = false\n @saxParser.onerror = (error) =>\n if ! err\n err = true\n @emit \"error\", error\n\n # always use the '#' key, even if there are no subkeys\n # setting this property by and is deprecated, yet still supported.\n # better pass it as explicitCharkey option to the constructor\n @EXPLICIT_CHARKEY = options.explicitCharkey\n @resultObject = null\n stack = []\n # aliases, so we don't have to type so much\n attrkey = options.attrkey\n charkey = options.charkey\n\n @saxParser.onopentag = (node) =>\n obj = {}\n obj[charkey] = \"\"\n unless options.ignoreAttrs", "source_lang": "", "target_lang": "CoffeeScript", "repo": "Leonidas-from-XIV/node-xml2js", "path": "src/xml2js.coffee", "license": "MIT", "commit": "d41d510ce45211ed6cc9839c81c4a92e6a5e87cf", "stars": 4965, "source_url": "https://github.com/Leonidas-from-XIV/node-xml2js/blob/d41d510ce45211ed6cc9839c81c4a92e6a5e87cf/src/xml2js.coffee", "line_start": 8, "line_end": 57}115{"id": "Leonidas-from-XIV/node-xml2js:src/xml2js.coffee:2:completion", "type": "completion", "prompt": "class exports.Parser extends events.EventEmitter\n constructor: (opts) ->\n\n # default options. for compatibility's sake set to some\n # sub-optimal settings. might change in the future.\n options =\n explicitCharkey: false\n trim: true\n # normalize implicates trimming, just so you know\n normalize: true\n # set default attribute object key\n attrkey: \"@\"\n # set default char object key\n charkey: \"#\"\n # always put child nodes in an array\n explicitArray: false\n # ignore all attributes regardless\n ignoreAttrs: false\n # overwrite them with the specified options, if any\n options[key] = value for own key, value of opts\n\n # make the SAX parser. tried trim and normalize, but they are not\n # very helpful\n @saxParser = sax.parser true, {\n trim: false,", "response": "normalize: false\n }\n\n # emit one error event if the sax parser fails. this is mostly a hack, but\n # the sax parser isn't state of the art either.\n err = false\n @saxParser.onerror = (error) =>\n if ! err\n err = true\n @emit \"error\", error\n\n # always use the '#' key, even if there are no subkeys\n # setting this property by and is deprecated, yet still supported.\n # better pass it as explicitCharkey option to the constructor\n @EXPLICIT_CHARKEY = options.explicitCharkey\n @resultObject = null\n stack = []\n # aliases, so we don't have to type so much\n attrkey = options.attrkey\n charkey = options.charkey\n\n @saxParser.onopentag = (node) =>\n obj = {}\n obj[charkey] = \"\"\n unless options.ignoreAttrs", "source_lang": "CoffeeScript", "target_lang": "CoffeeScript", "repo": "Leonidas-from-XIV/node-xml2js", "path": "src/xml2js.coffee", "license": "MIT", "commit": "d41d510ce45211ed6cc9839c81c4a92e6a5e87cf", "stars": 4965, "source_url": "https://github.com/Leonidas-from-XIV/node-xml2js/blob/d41d510ce45211ed6cc9839c81c4a92e6a5e87cf/src/xml2js.coffee", "line_start": 8, "line_end": 57}116{"id": "Leonidas-from-XIV/node-xml2js:src/xml2js.coffee:3:raw_corpus", "type": "raw_corpus", "prompt": "", "response": "for own key of node.attributes\n if attrkey not of obj\n obj[attrkey] = {}\n obj[attrkey][key] = node.attributes[key]\n\n # need a place to store the node name\n obj[\"#name\"] = node.name\n stack.push obj\n\n @saxParser.onclosetag = =>\n obj = stack.pop()\n nodeName = obj[\"#name\"]\n delete obj[\"#name\"]\n\n s = stack[stack.length - 1]\n # remove the '#' key altogether if it's blank\n if obj[charkey].match(/^\\s*$/)\n delete obj[charkey]\n else\n obj[charkey] = obj[charkey].trim() if options.trim\n obj[charkey] = obj[charkey].replace(/\\s{2,}/g, \" \").trim() if options.normalize\n # also do away with '#' key altogether, if there's no subkeys\n # unless EXPLICIT_CHARKEY is set\n if Object.keys(obj).length == 1 and charkey of obj and not @EXPLICIT_CHARKEY\n obj = obj[charkey]\n\n if options.emptyTag != undefined && isEmpty obj\n obj = options.emptyTag\n\n # check whether we closed all the open tags\n if stack.length > 0\n if not options.explicitArray\n if nodeName not of s\n s[nodeName] = obj\n else if s[nodeName] instanceof Array\n s[nodeName].push obj\n else\n old = s[nodeName]\n s[nodeName] = [old]\n s[nodeName].push obj\n else\n if not (s[nodeName] instanceof Array)\n s[nodeName] = []\n s[nodeName].push obj\n else\n # if explicitRoot was specified, wrap stuff in the root tag name\n if options.explicitRoot\n # avoid circular references\n old = obj\n obj = {}", "source_lang": "", "target_lang": "CoffeeScript", "repo": "Leonidas-from-XIV/node-xml2js", "path": "src/xml2js.coffee", "license": "MIT", "commit": "d41d510ce45211ed6cc9839c81c4a92e6a5e87cf", "stars": 4965, "source_url": "https://github.com/Leonidas-from-XIV/node-xml2js/blob/d41d510ce45211ed6cc9839c81c4a92e6a5e87cf/src/xml2js.coffee", "line_start": 58, "line_end": 107}117{"id": "Leonidas-from-XIV/node-xml2js:src/xml2js.coffee:3:coffee_to_js", "type": "coffee_to_js", "prompt": "Convert this CoffeeScript to JavaScript.\n```coffeescript\nfor own key of node.attributes\n if attrkey not of obj\n obj[attrkey] = {}\n obj[attrkey][key] = node.attributes[key]\n\n # need a place to store the node name\n obj[\"#name\"] = node.name\n stack.push obj\n\n @saxParser.onclosetag = =>\n obj = stack.pop()\n nodeName = obj[\"#name\"]\n delete obj[\"#name\"]\n\n s = stack[stack.length - 1]\n # remove the '#' key altogether if it's blank\n if obj[charkey].match(/^\\s*$/)\n delete obj[charkey]\n else\n obj[charkey] = obj[charkey].trim() if options.trim\n obj[charkey] = obj[charkey].replace(/\\s{2,}/g, \" \").trim() if options.normalize\n # also do away with '#' key altogether, if there's no subkeys\n # unless EXPLICIT_CHARKEY is set\n if Object.keys(obj).length == 1 and charkey of obj and not @EXPLICIT_CHARKEY\n obj = obj[charkey]\n\n if options.emptyTag != undefined && isEmpty obj\n obj = options.emptyTag\n\n # check whether we closed all the open tags\n if stack.length > 0\n if not options.explicitArray\n if nodeName not of s\n s[nodeName] = obj\n else if s[nodeName] instanceof Array\n s[nodeName].push obj\n else\n old = s[nodeName]\n s[nodeName] = [old]\n s[nodeName].push obj\n else\n if not (s[nodeName] instanceof Array)\n s[nodeName] = []\n s[nodeName].push obj\n else\n # if explicitRoot was specified, wrap stuff in the root tag name\n if options.explicitRoot\n # avoid circular references\n old = obj\n obj = {}\n```", "response": "var key, ref,\n hasProp = {}.hasOwnProperty;\n\nref = node.attributes;\nfor (key in ref) {\n if (!hasProp.call(ref, key)) continue;\n if (!(attrkey in obj)) {\n obj[attrkey] = {};\n }\n obj[attrkey][key] = node.attributes[key];\n}\n\n// need a place to store the node name\nobj[\"#name\"] = node.name;\n\nstack.push(obj);\n\nthis.saxParser.onclosetag = () => {\n var nodeName, obj, old, s;\n obj = stack.pop();\n nodeName = obj[\"#name\"];\n delete obj[\"#name\"];\n s = stack[stack.length - 1];\n // remove the '#' key altogether if it's blank\n if (obj[charkey].match(/^\\s*$/)) {\n delete obj[charkey];\n } else {\n if (options.trim) {\n obj[charkey] = obj[charkey].trim();\n }\n if (options.normalize) {\n obj[charkey] = obj[charkey].replace(/\\s{2,}/g, \" \").trim();\n }\n // also do away with '#' key altogether, if there's no subkeys\n // unless EXPLICIT_CHARKEY is set\n if (Object.keys(obj).length === 1 && charkey in obj && !this.EXPLICIT_CHARKEY) {\n obj = obj[charkey];\n }\n }\n if (options.emptyTag !== void 0 && isEmpty(obj)) {\n obj = options.emptyTag;\n }\n // check whether we closed all the open tags\n if (stack.length > 0) {\n if (!options.explicitArray) {\n if (!(nodeName in s)) {\n return s[nodeName] = obj;\n } else if (s[nodeName] instanceof Array) {\n return s[nodeName].push(obj);\n } else {\n old = s[nodeName];\n s[nodeName] = [old];\n return s[nodeName].push(obj);\n }\n } else {\n if (!(s[nodeName] instanceof Array)) {\n s[nodeName] = [];\n }\n return s[nodeName].push(obj);\n }\n } else {\n // if explicitRoot was specified, wrap stuff in the root tag name\n if (options.explicitRoot) {\n // avoid circular references\n old = obj;\n return obj = {};\n }\n }\n};", "source_lang": "CoffeeScript", "target_lang": "JavaScript", "repo": "Leonidas-from-XIV/node-xml2js", "path": "src/xml2js.coffee", "license": "MIT", "commit": "d41d510ce45211ed6cc9839c81c4a92e6a5e87cf", "stars": 4965, "source_url": "https://github.com/Leonidas-from-XIV/node-xml2js/blob/d41d510ce45211ed6cc9839c81c4a92e6a5e87cf/src/xml2js.coffee", "line_start": 58, "line_end": 107}118{"id": "Leonidas-from-XIV/node-xml2js:src/xml2js.coffee:3:js_to_coffee", "type": "js_to_coffee", "prompt": "Convert this JavaScript to CoffeeScript.\n```javascript\nvar key, ref,\n hasProp = {}.hasOwnProperty;\n\nref = node.attributes;\nfor (key in ref) {\n if (!hasProp.call(ref, key)) continue;\n if (!(attrkey in obj)) {\n obj[attrkey] = {};\n }\n obj[attrkey][key] = node.attributes[key];\n}\n\n// need a place to store the node name\nobj[\"#name\"] = node.name;\n\nstack.push(obj);\n\nthis.saxParser.onclosetag = () => {\n var nodeName, obj, old, s;\n obj = stack.pop();\n nodeName = obj[\"#name\"];\n delete obj[\"#name\"];\n s = stack[stack.length - 1];\n // remove the '#' key altogether if it's blank\n if (obj[charkey].match(/^\\s*$/)) {\n delete obj[charkey];\n } else {\n if (options.trim) {\n obj[charkey] = obj[charkey].trim();\n }\n if (options.normalize) {\n obj[charkey] = obj[charkey].replace(/\\s{2,}/g, \" \").trim();\n }\n // also do away with '#' key altogether, if there's no subkeys\n // unless EXPLICIT_CHARKEY is set\n if (Object.keys(obj).length === 1 && charkey in obj && !this.EXPLICIT_CHARKEY) {\n obj = obj[charkey];\n }\n }\n if (options.emptyTag !== void 0 && isEmpty(obj)) {\n obj = options.emptyTag;\n }\n // check whether we closed all the open tags\n if (stack.length > 0) {\n if (!options.explicitArray) {\n if (!(nodeName in s)) {\n return s[nodeName] = obj;\n } else if (s[nodeName] instanceof Array) {\n return s[nodeName].push(obj);\n } else {\n old = s[nodeName];\n s[nodeName] = [old];\n return s[nodeName].push(obj);\n }\n } else {\n if (!(s[nodeName] instanceof Array)) {\n s[nodeName] = [];\n }\n return s[nodeName].push(obj);\n }\n } else {\n // if explicitRoot was specified, wrap stuff in the root tag name\n if (options.explicitRoot) {\n // avoid circular references\n old = obj;\n return obj = {};\n }\n }\n};\n```", "response": "for own key of node.attributes\n if attrkey not of obj\n obj[attrkey] = {}\n obj[attrkey][key] = node.attributes[key]\n\n # need a place to store the node name\n obj[\"#name\"] = node.name\n stack.push obj\n\n @saxParser.onclosetag = =>\n obj = stack.pop()\n nodeName = obj[\"#name\"]\n delete obj[\"#name\"]\n\n s = stack[stack.length - 1]\n # remove the '#' key altogether if it's blank\n if obj[charkey].match(/^\\s*$/)\n delete obj[charkey]\n else\n obj[charkey] = obj[charkey].trim() if options.trim\n obj[charkey] = obj[charkey].replace(/\\s{2,}/g, \" \").trim() if options.normalize\n # also do away with '#' key altogether, if there's no subkeys\n # unless EXPLICIT_CHARKEY is set\n if Object.keys(obj).length == 1 and charkey of obj and not @EXPLICIT_CHARKEY\n obj = obj[charkey]\n\n if options.emptyTag != undefined && isEmpty obj\n obj = options.emptyTag\n\n # check whether we closed all the open tags\n if stack.length > 0\n if not options.explicitArray\n if nodeName not of s\n s[nodeName] = obj\n else if s[nodeName] instanceof Array\n s[nodeName].push obj\n else\n old = s[nodeName]\n s[nodeName] = [old]\n s[nodeName].push obj\n else\n if not (s[nodeName] instanceof Array)\n s[nodeName] = []\n s[nodeName].push obj\n else\n # if explicitRoot was specified, wrap stuff in the root tag name\n if options.explicitRoot\n # avoid circular references\n old = obj\n obj = {}", "source_lang": "JavaScript", "target_lang": "CoffeeScript", "repo": "Leonidas-from-XIV/node-xml2js", "path": "src/xml2js.coffee", "license": "MIT", "commit": "d41d510ce45211ed6cc9839c81c4a92e6a5e87cf", "stars": 4965, "source_url": "https://github.com/Leonidas-from-XIV/node-xml2js/blob/d41d510ce45211ed6cc9839c81c4a92e6a5e87cf/src/xml2js.coffee", "line_start": 58, "line_end": 107}119{"id": "Leonidas-from-XIV/node-xml2js:src/xml2js.coffee:3:completion", "type": "completion", "prompt": "for own key of node.attributes\n if attrkey not of obj\n obj[attrkey] = {}\n obj[attrkey][key] = node.attributes[key]\n\n # need a place to store the node name\n obj[\"#name\"] = node.name\n stack.push obj\n\n @saxParser.onclosetag = =>\n obj = stack.pop()\n nodeName = obj[\"#name\"]\n delete obj[\"#name\"]\n\n s = stack[stack.length - 1]\n # remove the '#' key altogether if it's blank\n if obj[charkey].match(/^\\s*$/)\n delete obj[charkey]\n else\n obj[charkey] = obj[charkey].trim() if options.trim\n obj[charkey] = obj[charkey].replace(/\\s{2,}/g, \" \").trim() if options.normalize\n # also do away with '#' key altogether, if there's no subkeys\n # unless EXPLICIT_CHARKEY is set\n if Object.keys(obj).length == 1 and charkey of obj and not @EXPLICIT_CHARKEY\n obj = obj[charkey]", "response": "if options.emptyTag != undefined && isEmpty obj\n obj = options.emptyTag\n\n # check whether we closed all the open tags\n if stack.length > 0\n if not options.explicitArray\n if nodeName not of s\n s[nodeName] = obj\n else if s[nodeName] instanceof Array\n s[nodeName].push obj\n else\n old = s[nodeName]\n s[nodeName] = [old]\n s[nodeName].push obj\n else\n if not (s[nodeName] instanceof Array)\n s[nodeName] = []\n s[nodeName].push obj\n else\n # if explicitRoot was specified, wrap stuff in the root tag name\n if options.explicitRoot\n # avoid circular references\n old = obj\n obj = {}", "source_lang": "CoffeeScript", "target_lang": "CoffeeScript", "repo": "Leonidas-from-XIV/node-xml2js", "path": "src/xml2js.coffee", "license": "MIT", "commit": "d41d510ce45211ed6cc9839c81c4a92e6a5e87cf", "stars": 4965, "source_url": "https://github.com/Leonidas-from-XIV/node-xml2js/blob/d41d510ce45211ed6cc9839c81c4a92e6a5e87cf/src/xml2js.coffee", "line_start": 58, "line_end": 107}120{"id": "Leonidas-from-XIV/node-xml2js:src/xml2js.coffee:4:raw_corpus", "type": "raw_corpus", "prompt": "", "response": "obj[nodeName] = old\n\n @resultObject = obj\n @emit \"end\", @resultObject\n\n @saxParser.ontext = @saxParser.oncdata = (text) =>\n s = stack[stack.length - 1]\n if s\n s[charkey] += text\n\n parseString: (str, cb) =>\n if cb? and typeof cb is \"function\"\n @on \"end\", (result) ->\n cb null, result\n @on \"error\", (err) ->\n cb err\n\n if str.toString().trim() is ''\n @emit \"end\", null\n return true\n\n @saxParser.write str.toString()", "source_lang": "", "target_lang": "CoffeeScript", "repo": "Leonidas-from-XIV/node-xml2js", "path": "src/xml2js.coffee", "license": "MIT", "commit": "d41d510ce45211ed6cc9839c81c4a92e6a5e87cf", "stars": 4965, "source_url": "https://github.com/Leonidas-from-XIV/node-xml2js/blob/d41d510ce45211ed6cc9839c81c4a92e6a5e87cf/src/xml2js.coffee", "line_start": 108, "line_end": 129}121{"id": "Leonidas-from-XIV/node-xml2js:src/xml2js.coffee:4:completion", "type": "completion", "prompt": "obj[nodeName] = old\n\n @resultObject = obj\n @emit \"end\", @resultObject\n\n @saxParser.ontext = @saxParser.oncdata = (text) =>\n s = stack[stack.length - 1]\n if s\n s[charkey] += text\n\n parseString: (str, cb) =>", "response": "if cb? and typeof cb is \"function\"\n @on \"end\", (result) ->\n cb null, result\n @on \"error\", (err) ->\n cb err\n\n if str.toString().trim() is ''\n @emit \"end\", null\n return true\n\n @saxParser.write str.toString()", "source_lang": "CoffeeScript", "target_lang": "CoffeeScript", "repo": "Leonidas-from-XIV/node-xml2js", "path": "src/xml2js.coffee", "license": "MIT", "commit": "d41d510ce45211ed6cc9839c81c4a92e6a5e87cf", "stars": 4965, "source_url": "https://github.com/Leonidas-from-XIV/node-xml2js/blob/d41d510ce45211ed6cc9839c81c4a92e6a5e87cf/src/xml2js.coffee", "line_start": 108, "line_end": 129}122{"id": "Leonidas-from-XIV/node-xml2js:src/xml2js.coffee:2:raw_corpus", "type": "raw_corpus", "prompt": "", "response": "class exports.Parser extends events.EventEmitter\n constructor: (opts) ->\n\n # default options. for compatibility's sake set to some\n # sub-optimal settings. might change in the future.\n options =\n explicitCharkey: false\n trim: true\n # normalize implicates trimming, just so you know\n normalize: true\n # set default attribute object key\n attrkey: \"@\"\n # set default char object key\n charkey: \"#\"\n # always put child nodes in an array\n explicitArray: false\n # overwrite them with the specified options, if any\n options[key] = value for own key, value of opts\n\n # make the SAX parser. tried trim and normalize, but they are not\n # very helpful\n @saxParser = sax.parser true, {\n trim: false,\n normalize: false\n }\n\n # emit one error event if the sax parser fails. this is mostly a hack, but\n # the sax parser isn't state of the art either.\n err = false\n @saxParser.onerror = (error) =>\n if ! err\n err = true\n @emit \"error\", error\n\n # always use the '#' key, even if there are no subkeys\n # setting this property by and is deprecated, yet still supported.\n # better pass it as explicitCharkey option to the constructor\n @EXPLICIT_CHARKEY = options.explicitCharkey\n @resultObject = null\n stack = []\n # aliases, so we don't have to type so much\n attrkey = options.attrkey\n charkey = options.charkey\n\n @saxParser.onopentag = (node) =>\n obj = {}\n obj[charkey] = \"\"\n for own key of node.attributes\n if attrkey not of obj\n obj[attrkey] = {}", "source_lang": "", "target_lang": "CoffeeScript", "repo": "Leonidas-from-XIV/node-xml2js", "path": "src/xml2js.coffee", "license": "MIT", "commit": "c71e66c710ed98697e2079699c68589ea52c9595", "stars": 4965, "source_url": "https://github.com/Leonidas-from-XIV/node-xml2js/blob/c71e66c710ed98697e2079699c68589ea52c9595/src/xml2js.coffee", "line_start": 8, "line_end": 57}123{"id": "Leonidas-from-XIV/node-xml2js:src/xml2js.coffee:2:completion", "type": "completion", "prompt": "class exports.Parser extends events.EventEmitter\n constructor: (opts) ->\n\n # default options. for compatibility's sake set to some\n # sub-optimal settings. might change in the future.\n options =\n explicitCharkey: false\n trim: true\n # normalize implicates trimming, just so you know\n normalize: true\n # set default attribute object key\n attrkey: \"@\"\n # set default char object key\n charkey: \"#\"\n # always put child nodes in an array\n explicitArray: false\n # overwrite them with the specified options, if any\n options[key] = value for own key, value of opts\n\n # make the SAX parser. tried trim and normalize, but they are not\n # very helpful\n @saxParser = sax.parser true, {\n trim: false,\n normalize: false\n }", "response": "# emit one error event if the sax parser fails. this is mostly a hack, but\n # the sax parser isn't state of the art either.\n err = false\n @saxParser.onerror = (error) =>\n if ! err\n err = true\n @emit \"error\", error\n\n # always use the '#' key, even if there are no subkeys\n # setting this property by and is deprecated, yet still supported.\n # better pass it as explicitCharkey option to the constructor\n @EXPLICIT_CHARKEY = options.explicitCharkey\n @resultObject = null\n stack = []\n # aliases, so we don't have to type so much\n attrkey = options.attrkey\n charkey = options.charkey\n\n @saxParser.onopentag = (node) =>\n obj = {}\n obj[charkey] = \"\"\n for own key of node.attributes\n if attrkey not of obj\n obj[attrkey] = {}", "source_lang": "CoffeeScript", "target_lang": "CoffeeScript", "repo": "Leonidas-from-XIV/node-xml2js", "path": "src/xml2js.coffee", "license": "MIT", "commit": "c71e66c710ed98697e2079699c68589ea52c9595", "stars": 4965, "source_url": "https://github.com/Leonidas-from-XIV/node-xml2js/blob/c71e66c710ed98697e2079699c68589ea52c9595/src/xml2js.coffee", "line_start": 8, "line_end": 57}124{"id": "Leonidas-from-XIV/node-xml2js:src/xml2js.coffee:3:raw_corpus", "type": "raw_corpus", "prompt": "", "response": "obj[attrkey][key] = node.attributes[key]\n\n # need a place to store the node name\n obj[\"#name\"] = node.name\n stack.push obj\n\n @saxParser.onclosetag = =>\n obj = stack.pop()\n nodeName = obj[\"#name\"]\n delete obj[\"#name\"]\n\n s = stack[stack.length - 1]\n # remove the '#' key altogether if it's blank\n if obj[charkey].match(/^\\s*$/)\n delete obj[charkey]\n else\n obj[charkey] = obj[charkey].trim() if options.trim\n obj[charkey] = obj[charkey].replace(/\\s{2,}/g, \" \").trim() if options.normalize\n # also do away with '#' key altogether, if there's no subkeys\n # unless EXPLICIT_CHARKEY is set\n if Object.keys(obj).length == 1 and charkey of obj and not @EXPLICIT_CHARKEY\n obj = obj[charkey]\n\n if options.emptyTag != undefined && isEmpty obj\n obj = options.emptyTag\n\n # check whether we closed all the open tags\n if stack.length > 0\n if not options.explicitArray\n if nodeName not of s\n s[nodeName] = obj\n else if s[nodeName] instanceof Array\n s[nodeName].push obj\n else\n old = s[nodeName]\n s[nodeName] = [old]\n s[nodeName].push obj\n else\n if not (s[nodeName] instanceof Array)\n s[nodeName] = []\n s[nodeName].push obj\n else\n # if explicitRoot was specified, wrap stuff in the root tag name\n if options.explicitRoot\n # avoid circular references\n old = obj\n obj = {}\n obj[nodeName] = old\n\n @resultObject = obj", "source_lang": "", "target_lang": "CoffeeScript", "repo": "Leonidas-from-XIV/node-xml2js", "path": "src/xml2js.coffee", "license": "MIT", "commit": "c71e66c710ed98697e2079699c68589ea52c9595", "stars": 4965, "source_url": "https://github.com/Leonidas-from-XIV/node-xml2js/blob/c71e66c710ed98697e2079699c68589ea52c9595/src/xml2js.coffee", "line_start": 58, "line_end": 107}125{"id": "Leonidas-from-XIV/node-xml2js:src/xml2js.coffee:3:completion", "type": "completion", "prompt": "obj[attrkey][key] = node.attributes[key]\n\n # need a place to store the node name\n obj[\"#name\"] = node.name\n stack.push obj\n\n @saxParser.onclosetag = =>\n obj = stack.pop()\n nodeName = obj[\"#name\"]\n delete obj[\"#name\"]\n\n s = stack[stack.length - 1]\n # remove the '#' key altogether if it's blank\n if obj[charkey].match(/^\\s*$/)\n delete obj[charkey]\n else\n obj[charkey] = obj[charkey].trim() if options.trim\n obj[charkey] = obj[charkey].replace(/\\s{2,}/g, \" \").trim() if options.normalize\n # also do away with '#' key altogether, if there's no subkeys\n # unless EXPLICIT_CHARKEY is set\n if Object.keys(obj).length == 1 and charkey of obj and not @EXPLICIT_CHARKEY\n obj = obj[charkey]\n\n if options.emptyTag != undefined && isEmpty obj\n obj = options.emptyTag", "response": "# check whether we closed all the open tags\n if stack.length > 0\n if not options.explicitArray\n if nodeName not of s\n s[nodeName] = obj\n else if s[nodeName] instanceof Array\n s[nodeName].push obj\n else\n old = s[nodeName]\n s[nodeName] = [old]\n s[nodeName].push obj\n else\n if not (s[nodeName] instanceof Array)\n s[nodeName] = []\n s[nodeName].push obj\n else\n # if explicitRoot was specified, wrap stuff in the root tag name\n if options.explicitRoot\n # avoid circular references\n old = obj\n obj = {}\n obj[nodeName] = old\n\n @resultObject = obj", "source_lang": "CoffeeScript", "target_lang": "CoffeeScript", "repo": "Leonidas-from-XIV/node-xml2js", "path": "src/xml2js.coffee", "license": "MIT", "commit": "c71e66c710ed98697e2079699c68589ea52c9595", "stars": 4965, "source_url": "https://github.com/Leonidas-from-XIV/node-xml2js/blob/c71e66c710ed98697e2079699c68589ea52c9595/src/xml2js.coffee", "line_start": 58, "line_end": 107}126{"id": "Leonidas-from-XIV/node-xml2js:src/xml2js.coffee:4:raw_corpus", "type": "raw_corpus", "prompt": "", "response": "@emit \"end\", @resultObject\n\n @saxParser.ontext = @saxParser.oncdata = (text) =>\n s = stack[stack.length - 1]\n if s\n s[charkey] += text\n\n parseString: (str, cb) =>\n if cb? and typeof cb is \"function\"\n @on \"end\", (result) ->\n cb null, result\n @on \"error\", (err) ->\n cb err\n\n if str.toString().trim() is ''\n @emit \"end\", null\n return true\n\n @saxParser.write str.toString()", "source_lang": "", "target_lang": "CoffeeScript", "repo": "Leonidas-from-XIV/node-xml2js", "path": "src/xml2js.coffee", "license": "MIT", "commit": "c71e66c710ed98697e2079699c68589ea52c9595", "stars": 4965, "source_url": "https://github.com/Leonidas-from-XIV/node-xml2js/blob/c71e66c710ed98697e2079699c68589ea52c9595/src/xml2js.coffee", "line_start": 108, "line_end": 126}127{"id": "Leonidas-from-XIV/node-xml2js:src/xml2js.coffee:4:completion", "type": "completion", "prompt": "@emit \"end\", @resultObject\n\n @saxParser.ontext = @saxParser.oncdata = (text) =>\n s = stack[stack.length - 1]\n if s\n s[charkey] += text\n\n parseString: (str, cb) =>\n if cb? and typeof cb is \"function\"", "response": "@on \"end\", (result) ->\n cb null, result\n @on \"error\", (err) ->\n cb err\n\n if str.toString().trim() is ''\n @emit \"end\", null\n return true\n\n @saxParser.write str.toString()", "source_lang": "CoffeeScript", "target_lang": "CoffeeScript", "repo": "Leonidas-from-XIV/node-xml2js", "path": "src/xml2js.coffee", "license": "MIT", "commit": "c71e66c710ed98697e2079699c68589ea52c9595", "stars": 4965, "source_url": "https://github.com/Leonidas-from-XIV/node-xml2js/blob/c71e66c710ed98697e2079699c68589ea52c9595/src/xml2js.coffee", "line_start": 108, "line_end": 126}128{"id": "Leonidas-from-XIV/node-xml2js:src/xml2js.coffee:4:raw_corpus", "type": "raw_corpus", "prompt": "", "response": "@emit \"end\", @resultObject\n\n @saxParser.ontext = @saxParser.oncdata = (text) =>\n s = stack[stack.length - 1]\n if s\n s[charkey] += text\n\n parseString: (str, cb) =>\n if cb? and typeof cb is \"function\"\n @on \"end\", (result) ->\n cb null, result\n @on \"error\", (err) ->\n cb err\n\n @saxParser.write str.toString()", "source_lang": "", "target_lang": "CoffeeScript", "repo": "Leonidas-from-XIV/node-xml2js", "path": "src/xml2js.coffee", "license": "MIT", "commit": "6dff03b5e4c1f306bb286767061c6f296b6f761b", "stars": 4965, "source_url": "https://github.com/Leonidas-from-XIV/node-xml2js/blob/6dff03b5e4c1f306bb286767061c6f296b6f761b/src/xml2js.coffee", "line_start": 108, "line_end": 122}129{"id": "Leonidas-from-XIV/node-xml2js:src/xml2js.coffee:4:completion", "type": "completion", "prompt": "@emit \"end\", @resultObject\n\n @saxParser.ontext = @saxParser.oncdata = (text) =>\n s = stack[stack.length - 1]\n if s\n s[charkey] += text", "response": "parseString: (str, cb) =>\n if cb? and typeof cb is \"function\"\n @on \"end\", (result) ->\n cb null, result\n @on \"error\", (err) ->\n cb err\n\n @saxParser.write str.toString()", "source_lang": "CoffeeScript", "target_lang": "CoffeeScript", "repo": "Leonidas-from-XIV/node-xml2js", "path": "src/xml2js.coffee", "license": "MIT", "commit": "6dff03b5e4c1f306bb286767061c6f296b6f761b", "stars": 4965, "source_url": "https://github.com/Leonidas-from-XIV/node-xml2js/blob/6dff03b5e4c1f306bb286767061c6f296b6f761b/src/xml2js.coffee", "line_start": 108, "line_end": 122}130{"id": "Leonidas-from-XIV/node-xml2js:src/xml2js.coffee:4:raw_corpus", "type": "raw_corpus", "prompt": "", "response": "@emit \"end\", @resultObject\n\n @saxParser.ontext = @saxParser.oncdata = (text) =>\n s = stack[stack.length - 1]\n if s\n s[charkey] += text\n\n parseString: (str, cb) =>\n if cb? and typeof cb is 'function'\n @on 'end', (result) ->\n cb null, result\n @on 'error', (err) ->\n cb err\n\n @saxParser.write str.toString()", "source_lang": "", "target_lang": "CoffeeScript", "repo": "Leonidas-from-XIV/node-xml2js", "path": "src/xml2js.coffee", "license": "MIT", "commit": "f7436ce0eb0c876aa9b298413aa985b2040360d9", "stars": 4965, "source_url": "https://github.com/Leonidas-from-XIV/node-xml2js/blob/f7436ce0eb0c876aa9b298413aa985b2040360d9/src/xml2js.coffee", "line_start": 108, "line_end": 122}131{"id": "Leonidas-from-XIV/node-xml2js:src/xml2js.coffee:4:completion", "type": "completion", "prompt": "@emit \"end\", @resultObject\n\n @saxParser.ontext = @saxParser.oncdata = (text) =>\n s = stack[stack.length - 1]\n if s\n s[charkey] += text", "response": "parseString: (str, cb) =>\n if cb? and typeof cb is 'function'\n @on 'end', (result) ->\n cb null, result\n @on 'error', (err) ->\n cb err\n\n @saxParser.write str.toString()", "source_lang": "CoffeeScript", "target_lang": "CoffeeScript", "repo": "Leonidas-from-XIV/node-xml2js", "path": "src/xml2js.coffee", "license": "MIT", "commit": "f7436ce0eb0c876aa9b298413aa985b2040360d9", "stars": 4965, "source_url": "https://github.com/Leonidas-from-XIV/node-xml2js/blob/f7436ce0eb0c876aa9b298413aa985b2040360d9/src/xml2js.coffee", "line_start": 108, "line_end": 122}132{"id": "Leonidas-from-XIV/node-xml2js:src/xml2js.coffee:4:raw_corpus", "type": "raw_corpus", "prompt": "", "response": "@emit \"end\", @resultObject\n\n @saxParser.ontext = @saxParser.oncdata = (text) =>\n s = stack[stack.length - 1]\n if s\n s[charkey] += text\n\n parseString: (str) =>\n @saxParser.write str.toString()", "source_lang": "", "target_lang": "CoffeeScript", "repo": "Leonidas-from-XIV/node-xml2js", "path": "src/xml2js.coffee", "license": "MIT", "commit": "fd39560b891ad04b3d6b1086eb96e8b2e937288b", "stars": 4965, "source_url": "https://github.com/Leonidas-from-XIV/node-xml2js/blob/fd39560b891ad04b3d6b1086eb96e8b2e937288b/src/xml2js.coffee", "line_start": 108, "line_end": 116}133{"id": "Leonidas-from-XIV/node-xml2js:src/xml2js.coffee:4:completion", "type": "completion", "prompt": "@emit \"end\", @resultObject\n\n @saxParser.ontext = @saxParser.oncdata = (text) =>\n s = stack[stack.length - 1]", "response": "if s\n s[charkey] += text\n\n parseString: (str) =>\n @saxParser.write str.toString()", "source_lang": "CoffeeScript", "target_lang": "CoffeeScript", "repo": "Leonidas-from-XIV/node-xml2js", "path": "src/xml2js.coffee", "license": "MIT", "commit": "fd39560b891ad04b3d6b1086eb96e8b2e937288b", "stars": 4965, "source_url": "https://github.com/Leonidas-from-XIV/node-xml2js/blob/fd39560b891ad04b3d6b1086eb96e8b2e937288b/src/xml2js.coffee", "line_start": 108, "line_end": 116}134{"id": "Leonidas-from-XIV/node-xml2js:src/xml2js.coffee:2:raw_corpus", "type": "raw_corpus", "prompt": "", "response": "class exports.Parser extends events.EventEmitter\n constructor: (opts) ->\n\n # default options. for compatibility's sake set to some\n # sub-optimal settings. might change in the future.\n options =\n explicitCharkey: false\n trim: true\n # normalize implicates trimming, just so you know\n normalize: true\n # set default attribute object key\n attrkey: \"@\"\n # set default char object key\n charkey: \"#\"\n # overwrite them with the specified options, if any\n options[key] = value for own key, value of opts\n\n # make the SAX parser. tried trim and normalize, but they are not\n # very helpful\n @saxParser = sax.parser true, {\n trim: false,\n normalize: false\n }\n\n # emit one error event if the sax parser fails. this is mostly a hack, but\n # the sax parser isn't state of the art either.\n err = false\n @saxParser.onerror = (error) =>\n if ! err\n err = true\n @emit \"error\", error\n\n # always use the '#' key, even if there are no subkeys\n # setting this property by and is deprecated, yet still supported.\n # better pass it as explicitCharkey option to the constructor\n @EXPLICIT_CHARKEY = options.explicitCharkey\n @resultObject = null\n stack = []\n # aliases, so we don't have to type so much\n attrkey = options.attrkey\n charkey = options.charkey\n\n @saxParser.onopentag = (node) =>\n obj = {}\n obj[charkey] = \"\"\n for own key of node.attributes\n if attrkey not of obj\n obj[attrkey] = {}\n obj[attrkey][key] = node.attributes[key]", "source_lang": "", "target_lang": "CoffeeScript", "repo": "Leonidas-from-XIV/node-xml2js", "path": "src/xml2js.coffee", "license": "MIT", "commit": "94da6991f5649c9b84a758d6d15f29490bff4867", "stars": 4965, "source_url": "https://github.com/Leonidas-from-XIV/node-xml2js/blob/94da6991f5649c9b84a758d6d15f29490bff4867/src/xml2js.coffee", "line_start": 8, "line_end": 57}135{"id": "Leonidas-from-XIV/node-xml2js:src/xml2js.coffee:2:completion", "type": "completion", "prompt": "class exports.Parser extends events.EventEmitter\n constructor: (opts) ->\n\n # default options. for compatibility's sake set to some\n # sub-optimal settings. might change in the future.\n options =\n explicitCharkey: false\n trim: true\n # normalize implicates trimming, just so you know\n normalize: true\n # set default attribute object key\n attrkey: \"@\"\n # set default char object key\n charkey: \"#\"\n # overwrite them with the specified options, if any\n options[key] = value for own key, value of opts\n\n # make the SAX parser. tried trim and normalize, but they are not\n # very helpful\n @saxParser = sax.parser true, {\n trim: false,\n normalize: false\n }", "response": "# emit one error event if the sax parser fails. this is mostly a hack, but\n # the sax parser isn't state of the art either.\n err = false\n @saxParser.onerror = (error) =>\n if ! err\n err = true\n @emit \"error\", error\n\n # always use the '#' key, even if there are no subkeys\n # setting this property by and is deprecated, yet still supported.\n # better pass it as explicitCharkey option to the constructor\n @EXPLICIT_CHARKEY = options.explicitCharkey\n @resultObject = null\n stack = []\n # aliases, so we don't have to type so much\n attrkey = options.attrkey\n charkey = options.charkey\n\n @saxParser.onopentag = (node) =>\n obj = {}\n obj[charkey] = \"\"\n for own key of node.attributes\n if attrkey not of obj\n obj[attrkey] = {}\n obj[attrkey][key] = node.attributes[key]", "source_lang": "CoffeeScript", "target_lang": "CoffeeScript", "repo": "Leonidas-from-XIV/node-xml2js", "path": "src/xml2js.coffee", "license": "MIT", "commit": "94da6991f5649c9b84a758d6d15f29490bff4867", "stars": 4965, "source_url": "https://github.com/Leonidas-from-XIV/node-xml2js/blob/94da6991f5649c9b84a758d6d15f29490bff4867/src/xml2js.coffee", "line_start": 8, "line_end": 57}136{"id": "Leonidas-from-XIV/node-xml2js:src/xml2js.coffee:3:raw_corpus", "type": "raw_corpus", "prompt": "", "response": "# need a place to store the node name\n obj[\"#name\"] = node.name\n stack.push obj\n\n @saxParser.onclosetag = =>\n obj = stack.pop()\n nodeName = obj[\"#name\"]\n delete obj[\"#name\"]\n\n s = stack[stack.length - 1]\n # remove the '#' key altogether if it's blank\n if obj[charkey].match(/^\\s*$/)\n delete obj[charkey]\n else\n obj[charkey] = obj[charkey].trim() if options.trim\n obj[charkey] = obj[charkey].replace(/\\s{2,}/g, \" \").trim() if options.normalize\n # also do away with '#' key altogether, if there's no subkeys\n # unless EXPLICIT_CHARKEY is set\n if Object.keys(obj).length == 1 and charkey of obj and not @EXPLICIT_CHARKEY\n obj = obj[charkey]\n\n if options.emptyTag != undefined && isEmpty obj\n obj = options.emptyTag\n\n # check whether we closed all the open tags\n if stack.length > 0\n if nodeName not of s\n s[nodeName] = obj\n else if s[nodeName] instanceof Array\n s[nodeName].push obj\n else\n old = s[nodeName]\n s[nodeName] = [old]\n s[nodeName].push obj\n else\n # if explicitRoot was specified, wrap stuff in the root tag name\n if options.explicitRoot\n # avoid circular references\n old = obj\n obj = {}\n obj[nodeName] = old\n\n @resultObject = obj\n @emit \"end\", @resultObject\n\n @saxParser.ontext = @saxParser.oncdata = (text) =>\n s = stack[stack.length - 1]\n if s\n s[charkey] += text", "source_lang": "", "target_lang": "CoffeeScript", "repo": "Leonidas-from-XIV/node-xml2js", "path": "src/xml2js.coffee", "license": "MIT", "commit": "94da6991f5649c9b84a758d6d15f29490bff4867", "stars": 4965, "source_url": "https://github.com/Leonidas-from-XIV/node-xml2js/blob/94da6991f5649c9b84a758d6d15f29490bff4867/src/xml2js.coffee", "line_start": 58, "line_end": 107}137{"id": "Leonidas-from-XIV/node-xml2js:src/xml2js.coffee:3:completion", "type": "completion", "prompt": "# need a place to store the node name\n obj[\"#name\"] = node.name\n stack.push obj\n\n @saxParser.onclosetag = =>\n obj = stack.pop()\n nodeName = obj[\"#name\"]\n delete obj[\"#name\"]\n\n s = stack[stack.length - 1]\n # remove the '#' key altogether if it's blank\n if obj[charkey].match(/^\\s*$/)\n delete obj[charkey]\n else\n obj[charkey] = obj[charkey].trim() if options.trim\n obj[charkey] = obj[charkey].replace(/\\s{2,}/g, \" \").trim() if options.normalize\n # also do away with '#' key altogether, if there's no subkeys\n # unless EXPLICIT_CHARKEY is set\n if Object.keys(obj).length == 1 and charkey of obj and not @EXPLICIT_CHARKEY\n obj = obj[charkey]\n\n if options.emptyTag != undefined && isEmpty obj\n obj = options.emptyTag", "response": "# check whether we closed all the open tags\n if stack.length > 0\n if nodeName not of s\n s[nodeName] = obj\n else if s[nodeName] instanceof Array\n s[nodeName].push obj\n else\n old = s[nodeName]\n s[nodeName] = [old]\n s[nodeName].push obj\n else\n # if explicitRoot was specified, wrap stuff in the root tag name\n if options.explicitRoot\n # avoid circular references\n old = obj\n obj = {}\n obj[nodeName] = old\n\n @resultObject = obj\n @emit \"end\", @resultObject\n\n @saxParser.ontext = @saxParser.oncdata = (text) =>\n s = stack[stack.length - 1]\n if s\n s[charkey] += text", "source_lang": "CoffeeScript", "target_lang": "CoffeeScript", "repo": "Leonidas-from-XIV/node-xml2js", "path": "src/xml2js.coffee", "license": "MIT", "commit": "94da6991f5649c9b84a758d6d15f29490bff4867", "stars": 4965, "source_url": "https://github.com/Leonidas-from-XIV/node-xml2js/blob/94da6991f5649c9b84a758d6d15f29490bff4867/src/xml2js.coffee", "line_start": 58, "line_end": 107}138{"id": "Leonidas-from-XIV/node-xml2js:src/xml2js.coffee:2:raw_corpus", "type": "raw_corpus", "prompt": "", "response": "class exports.Parser extends events.EventEmitter\n constructor: (opts) ->\n\n # default options. for compatibility's sake set to some\n # sub-optimal settings. might change in the future.\n options =\n explicitCharkey: false\n trim: true\n # normalize implicates trimming, just so you know\n normalize: true\n # set default attribute object key\n attrkey: \"@\"\n # set default char object key\n charkey: \"#\"\n # overwrite them with the specified options, if any\n options[key] = value for own key, value of opts\n\n # make the SAX parser. tried trim and normalize, but they are not\n # very helpful\n @saxParser = sax.parser true, {\n trim: false,\n normalize: false\n }\n\n # emit one error event if the sax parser fails. this is mostly a hack, but\n # the sax parser isn't state of the art either.\n err = false\n @saxParser.onerror = (error) =>\n if ! err\n err = true\n @emit \"error\", error\n\n # always use the '#' key, even if there are no subkeys\n # setting this property by and is deprecated, yet still supported.\n # better pass it as explicitCharkey option to the constructor\n @EXPLICIT_CHARKEY = options.explicitCharkey\n @ATTRKEY = options.attrkey\n @CHARKEY = options.charkey\n @resultObject = null\n stack = []\n\n @saxParser.onopentag = (node) =>\n obj = {}\n obj[@CHARKEY] = \"\"\n for own key of node.attributes\n if @ATTRKEY not of obj\n obj[@ATTRKEY] = {}\n obj[@ATTRKEY][key] = node.attributes[key]\n\n # need a place to store the node name", "source_lang": "", "target_lang": "CoffeeScript", "repo": "Leonidas-from-XIV/node-xml2js", "path": "src/xml2js.coffee", "license": "MIT", "commit": "1a656087278c00cf9e206532e8c7ac08fab4620d", "stars": 4965, "source_url": "https://github.com/Leonidas-from-XIV/node-xml2js/blob/1a656087278c00cf9e206532e8c7ac08fab4620d/src/xml2js.coffee", "line_start": 8, "line_end": 57}139{"id": "Leonidas-from-XIV/node-xml2js:src/xml2js.coffee:2:completion", "type": "completion", "prompt": "class exports.Parser extends events.EventEmitter\n constructor: (opts) ->\n\n # default options. for compatibility's sake set to some\n # sub-optimal settings. might change in the future.\n options =\n explicitCharkey: false\n trim: true\n # normalize implicates trimming, just so you know\n normalize: true\n # set default attribute object key\n attrkey: \"@\"\n # set default char object key\n charkey: \"#\"\n # overwrite them with the specified options, if any\n options[key] = value for own key, value of opts\n\n # make the SAX parser. tried trim and normalize, but they are not\n # very helpful\n @saxParser = sax.parser true, {\n trim: false,\n normalize: false\n }\n\n # emit one error event if the sax parser fails. this is mostly a hack, but", "response": "# the sax parser isn't state of the art either.\n err = false\n @saxParser.onerror = (error) =>\n if ! err\n err = true\n @emit \"error\", error\n\n # always use the '#' key, even if there are no subkeys\n # setting this property by and is deprecated, yet still supported.\n # better pass it as explicitCharkey option to the constructor\n @EXPLICIT_CHARKEY = options.explicitCharkey\n @ATTRKEY = options.attrkey\n @CHARKEY = options.charkey\n @resultObject = null\n stack = []\n\n @saxParser.onopentag = (node) =>\n obj = {}\n obj[@CHARKEY] = \"\"\n for own key of node.attributes\n if @ATTRKEY not of obj\n obj[@ATTRKEY] = {}\n obj[@ATTRKEY][key] = node.attributes[key]\n\n # need a place to store the node name", "source_lang": "CoffeeScript", "target_lang": "CoffeeScript", "repo": "Leonidas-from-XIV/node-xml2js", "path": "src/xml2js.coffee", "license": "MIT", "commit": "1a656087278c00cf9e206532e8c7ac08fab4620d", "stars": 4965, "source_url": "https://github.com/Leonidas-from-XIV/node-xml2js/blob/1a656087278c00cf9e206532e8c7ac08fab4620d/src/xml2js.coffee", "line_start": 8, "line_end": 57}140{"id": "Leonidas-from-XIV/node-xml2js:src/xml2js.coffee:3:raw_corpus", "type": "raw_corpus", "prompt": "", "response": "obj[\"#name\"] = node.name\n stack.push obj\n\n @saxParser.onclosetag = =>\n obj = stack.pop()\n nodeName = obj[\"#name\"]\n delete obj[\"#name\"]\n\n s = stack[stack.length - 1]\n # remove the '#' key altogether if it's blank\n if obj[@CHARKEY].match(/^\\s*$/)\n delete obj[@CHARKEY]\n else\n obj[@CHARKEY] = obj[@CHARKEY].trim() if options.trim\n obj[@CHARKEY] = obj[@CHARKEY].replace(/\\s{2,}/g, \" \").trim() if options.normalize\n # also do away with '#' key altogether, if there's no subkeys\n # unless EXPLICIT_CHARKEY is set\n if Object.keys(obj).length == 1 and @CHARKEY of obj and not @EXPLICIT_CHARKEY\n obj = obj[@CHARKEY]\n\n if options.emptyTag != undefined && isEmpty obj\n obj = options.emptyTag\n\n # check whether we closed all the open tags\n if stack.length > 0\n if nodeName not of s\n s[nodeName] = obj\n else if s[nodeName] instanceof Array\n s[nodeName].push obj\n else\n old = s[nodeName]\n s[nodeName] = [old]\n s[nodeName].push obj\n else\n # if explicitRoot was specified, wrap stuff in the root tag name\n if options.explicitRoot\n # avoid circular references\n old = obj\n obj = {}\n obj[nodeName] = old\n\n @resultObject = obj\n @emit \"end\", @resultObject\n\n @saxParser.ontext = @saxParser.oncdata = (text) =>\n s = stack[stack.length - 1]\n if s\n s[@CHARKEY] += text\n\n parseString: (str) =>", "source_lang": "", "target_lang": "CoffeeScript", "repo": "Leonidas-from-XIV/node-xml2js", "path": "src/xml2js.coffee", "license": "MIT", "commit": "1a656087278c00cf9e206532e8c7ac08fab4620d", "stars": 4965, "source_url": "https://github.com/Leonidas-from-XIV/node-xml2js/blob/1a656087278c00cf9e206532e8c7ac08fab4620d/src/xml2js.coffee", "line_start": 58, "line_end": 107}141{"id": "Leonidas-from-XIV/node-xml2js:src/xml2js.coffee:3:completion", "type": "completion", "prompt": "obj[\"#name\"] = node.name\n stack.push obj\n\n @saxParser.onclosetag = =>\n obj = stack.pop()\n nodeName = obj[\"#name\"]\n delete obj[\"#name\"]\n\n s = stack[stack.length - 1]\n # remove the '#' key altogether if it's blank\n if obj[@CHARKEY].match(/^\\s*$/)\n delete obj[@CHARKEY]\n else\n obj[@CHARKEY] = obj[@CHARKEY].trim() if options.trim\n obj[@CHARKEY] = obj[@CHARKEY].replace(/\\s{2,}/g, \" \").trim() if options.normalize\n # also do away with '#' key altogether, if there's no subkeys\n # unless EXPLICIT_CHARKEY is set\n if Object.keys(obj).length == 1 and @CHARKEY of obj and not @EXPLICIT_CHARKEY\n obj = obj[@CHARKEY]\n\n if options.emptyTag != undefined && isEmpty obj\n obj = options.emptyTag\n\n # check whether we closed all the open tags\n if stack.length > 0", "response": "if nodeName not of s\n s[nodeName] = obj\n else if s[nodeName] instanceof Array\n s[nodeName].push obj\n else\n old = s[nodeName]\n s[nodeName] = [old]\n s[nodeName].push obj\n else\n # if explicitRoot was specified, wrap stuff in the root tag name\n if options.explicitRoot\n # avoid circular references\n old = obj\n obj = {}\n obj[nodeName] = old\n\n @resultObject = obj\n @emit \"end\", @resultObject\n\n @saxParser.ontext = @saxParser.oncdata = (text) =>\n s = stack[stack.length - 1]\n if s\n s[@CHARKEY] += text\n\n parseString: (str) =>", "source_lang": "CoffeeScript", "target_lang": "CoffeeScript", "repo": "Leonidas-from-XIV/node-xml2js", "path": "src/xml2js.coffee", "license": "MIT", "commit": "1a656087278c00cf9e206532e8c7ac08fab4620d", "stars": 4965, "source_url": "https://github.com/Leonidas-from-XIV/node-xml2js/blob/1a656087278c00cf9e206532e8c7ac08fab4620d/src/xml2js.coffee", "line_start": 58, "line_end": 107}142{"id": "Leonidas-from-XIV/node-xml2js:src/xml2js.coffee:2:raw_corpus", "type": "raw_corpus", "prompt": "", "response": "class exports.Parser extends events.EventEmitter\n constructor: (opts) ->\n\n # default options. for compatibility's sake set to some\n # sub-optimal settings. might change in the future.\n options =\n explicitCharkey: false\n trim: true\n # normalize implicates trimming, just so you know\n normalize: true\n # overwrite them with the specified options, if any\n options[key] = value for own key, value of opts\n\n # make the SAX parser. tried trim and normalize, but they are not\n # very helpful\n @saxParser = sax.parser true, {\n trim: false,\n normalize: false\n }\n\n # emit one error event if the sax parser fails. this is mostly a hack, but\n # the sax parser isn't state of the art either.\n err = false\n @saxParser.onerror = (error) =>\n if ! err\n err = true\n @emit \"error\", error\n\n # always use the '#' key, even if there are no subkeys\n # setting this property by and is deprecated, yet still supported.\n # better pass it as explicitCharkey option to the constructor\n @EXPLICIT_CHARKEY = options.explicitCharkey\n @resultObject = null\n stack = []\n\n @saxParser.onopentag = (node) =>\n obj = {}\n obj[\"#\"] = \"\"\n for own key of node.attributes\n if \"@\" not of obj\n obj[\"@\"] = {}\n obj[\"@\"][key] = node.attributes[key]\n\n # need a place to store the node name\n obj[\"#name\"] = node.name\n stack.push obj\n\n @saxParser.onclosetag = =>\n obj = stack.pop()\n nodeName = obj[\"#name\"]", "source_lang": "", "target_lang": "CoffeeScript", "repo": "Leonidas-from-XIV/node-xml2js", "path": "src/xml2js.coffee", "license": "MIT", "commit": "e024b03581b1a8cbe7772b71f328d66800b70d80", "stars": 4965, "source_url": "https://github.com/Leonidas-from-XIV/node-xml2js/blob/e024b03581b1a8cbe7772b71f328d66800b70d80/src/xml2js.coffee", "line_start": 8, "line_end": 57}143{"id": "Leonidas-from-XIV/node-xml2js:src/xml2js.coffee:2:completion", "type": "completion", "prompt": "class exports.Parser extends events.EventEmitter\n constructor: (opts) ->\n\n # default options. for compatibility's sake set to some\n # sub-optimal settings. might change in the future.\n options =\n explicitCharkey: false\n trim: true\n # normalize implicates trimming, just so you know\n normalize: true\n # overwrite them with the specified options, if any\n options[key] = value for own key, value of opts\n\n # make the SAX parser. tried trim and normalize, but they are not\n # very helpful\n @saxParser = sax.parser true, {\n trim: false,\n normalize: false\n }\n\n # emit one error event if the sax parser fails. this is mostly a hack, but\n # the sax parser isn't state of the art either.\n err = false\n @saxParser.onerror = (error) =>\n if ! err", "response": "err = true\n @emit \"error\", error\n\n # always use the '#' key, even if there are no subkeys\n # setting this property by and is deprecated, yet still supported.\n # better pass it as explicitCharkey option to the constructor\n @EXPLICIT_CHARKEY = options.explicitCharkey\n @resultObject = null\n stack = []\n\n @saxParser.onopentag = (node) =>\n obj = {}\n obj[\"#\"] = \"\"\n for own key of node.attributes\n if \"@\" not of obj\n obj[\"@\"] = {}\n obj[\"@\"][key] = node.attributes[key]\n\n # need a place to store the node name\n obj[\"#name\"] = node.name\n stack.push obj\n\n @saxParser.onclosetag = =>\n obj = stack.pop()\n nodeName = obj[\"#name\"]", "source_lang": "CoffeeScript", "target_lang": "CoffeeScript", "repo": "Leonidas-from-XIV/node-xml2js", "path": "src/xml2js.coffee", "license": "MIT", "commit": "e024b03581b1a8cbe7772b71f328d66800b70d80", "stars": 4965, "source_url": "https://github.com/Leonidas-from-XIV/node-xml2js/blob/e024b03581b1a8cbe7772b71f328d66800b70d80/src/xml2js.coffee", "line_start": 8, "line_end": 57}144{"id": "Leonidas-from-XIV/node-xml2js:src/xml2js.coffee:3:raw_corpus", "type": "raw_corpus", "prompt": "", "response": "delete obj[\"#name\"]\n\n s = stack[stack.length - 1]\n # remove the '#' key altogether if it's blank\n if obj[\"#\"].match(/^\\s*$/)\n delete obj[\"#\"]\n else\n obj[\"#\"] = obj[\"#\"].trim() if options.trim\n obj[\"#\"] = obj[\"#\"].replace(/\\s{2,}/g, \" \").trim() if options.normalize\n # also do away with '#' key altogether, if there's no subkeys\n # unless EXPLICIT_CHARKEY is set\n if Object.keys(obj).length == 1 and \"#\" of obj and not @EXPLICIT_CHARKEY\n obj = obj[\"#\"]\n\n if options.emptyTag != undefined && isEmpty obj\n obj = options.emptyTag\n\n # check whether we closed all the open tags\n if stack.length > 0\n if nodeName not of s\n s[nodeName] = obj\n else if s[nodeName] instanceof Array\n s[nodeName].push obj\n else\n old = s[nodeName]\n s[nodeName] = [old]\n s[nodeName].push obj\n else\n # if explicitRoot was specified, wrap stuff in the root tag name\n if options.explicitRoot\n # avoid circular references\n old = obj\n obj = {}\n obj[nodeName] = old\n\n @resultObject = obj\n @emit \"end\", @resultObject\n\n @saxParser.ontext = @saxParser.oncdata = (text) =>\n s = stack[stack.length - 1]\n if s\n s[\"#\"] += text\n\n parseString: (str) =>\n @saxParser.write str.toString()", "source_lang": "", "target_lang": "CoffeeScript", "repo": "Leonidas-from-XIV/node-xml2js", "path": "src/xml2js.coffee", "license": "MIT", "commit": "e024b03581b1a8cbe7772b71f328d66800b70d80", "stars": 4965, "source_url": "https://github.com/Leonidas-from-XIV/node-xml2js/blob/e024b03581b1a8cbe7772b71f328d66800b70d80/src/xml2js.coffee", "line_start": 58, "line_end": 102}145{"id": "Leonidas-from-XIV/node-xml2js:src/xml2js.coffee:3:completion", "type": "completion", "prompt": "delete obj[\"#name\"]\n\n s = stack[stack.length - 1]\n # remove the '#' key altogether if it's blank\n if obj[\"#\"].match(/^\\s*$/)\n delete obj[\"#\"]\n else\n obj[\"#\"] = obj[\"#\"].trim() if options.trim\n obj[\"#\"] = obj[\"#\"].replace(/\\s{2,}/g, \" \").trim() if options.normalize\n # also do away with '#' key altogether, if there's no subkeys\n # unless EXPLICIT_CHARKEY is set\n if Object.keys(obj).length == 1 and \"#\" of obj and not @EXPLICIT_CHARKEY\n obj = obj[\"#\"]\n\n if options.emptyTag != undefined && isEmpty obj\n obj = options.emptyTag\n\n # check whether we closed all the open tags\n if stack.length > 0\n if nodeName not of s\n s[nodeName] = obj\n else if s[nodeName] instanceof Array", "response": "s[nodeName].push obj\n else\n old = s[nodeName]\n s[nodeName] = [old]\n s[nodeName].push obj\n else\n # if explicitRoot was specified, wrap stuff in the root tag name\n if options.explicitRoot\n # avoid circular references\n old = obj\n obj = {}\n obj[nodeName] = old\n\n @resultObject = obj\n @emit \"end\", @resultObject\n\n @saxParser.ontext = @saxParser.oncdata = (text) =>\n s = stack[stack.length - 1]\n if s\n s[\"#\"] += text\n\n parseString: (str) =>\n @saxParser.write str.toString()", "source_lang": "CoffeeScript", "target_lang": "CoffeeScript", "repo": "Leonidas-from-XIV/node-xml2js", "path": "src/xml2js.coffee", "license": "MIT", "commit": "e024b03581b1a8cbe7772b71f328d66800b70d80", "stars": 4965, "source_url": "https://github.com/Leonidas-from-XIV/node-xml2js/blob/e024b03581b1a8cbe7772b71f328d66800b70d80/src/xml2js.coffee", "line_start": 58, "line_end": 102}146{"id": "Leonidas-from-XIV/node-xml2js:src/xml2js.coffee:3:raw_corpus", "type": "raw_corpus", "prompt": "", "response": "delete obj[\"#name\"]\n\n s = stack[stack.length - 1]\n # remove the '#' key altogether if it's blank\n if obj[\"#\"].match(/^\\s*$/)\n delete obj[\"#\"]\n else\n obj[\"#\"] = obj[\"#\"].trim() if options.trim\n obj[\"#\"] = obj[\"#\"].replace(/\\s{2,}/g, \" \").trim() if options.normalize\n # also do away with '#' key altogether, if there's no subkeys\n # unless EXPLICIT_CHARKEY is set\n if Object.keys(obj).length == 1 and \"#\" of obj and not @EXPLICIT_CHARKEY\n obj = obj[\"#\"]\n\n if options.emptyTag != undefined && isEmpty obj\n obj = options.emptyTag\n\n # check whether we closed all the open tags\n if stack.length > 0\n if nodeName not of s\n s[nodeName] = obj\n else if s[nodeName] instanceof Array\n s[nodeName].push obj\n else\n old = s[nodeName]\n s[nodeName] = [old]\n s[nodeName].push obj\n else\n @resultObject = obj\n @emit \"end\", @resultObject\n\n @saxParser.ontext = @saxParser.oncdata = (text) =>\n s = stack[stack.length - 1]\n if s\n s[\"#\"] += text\n\n parseString: (str) =>\n @saxParser.write str.toString()", "source_lang": "", "target_lang": "CoffeeScript", "repo": "Leonidas-from-XIV/node-xml2js", "path": "src/xml2js.coffee", "license": "MIT", "commit": "5f54d6963b8a8b57f28dd3a8db2a22a2105837b3", "stars": 4965, "source_url": "https://github.com/Leonidas-from-XIV/node-xml2js/blob/5f54d6963b8a8b57f28dd3a8db2a22a2105837b3/src/xml2js.coffee", "line_start": 58, "line_end": 95}147{"id": "Leonidas-from-XIV/node-xml2js:src/xml2js.coffee:3:completion", "type": "completion", "prompt": "delete obj[\"#name\"]\n\n s = stack[stack.length - 1]\n # remove the '#' key altogether if it's blank\n if obj[\"#\"].match(/^\\s*$/)\n delete obj[\"#\"]\n else\n obj[\"#\"] = obj[\"#\"].trim() if options.trim\n obj[\"#\"] = obj[\"#\"].replace(/\\s{2,}/g, \" \").trim() if options.normalize\n # also do away with '#' key altogether, if there's no subkeys\n # unless EXPLICIT_CHARKEY is set\n if Object.keys(obj).length == 1 and \"#\" of obj and not @EXPLICIT_CHARKEY\n obj = obj[\"#\"]\n\n if options.emptyTag != undefined && isEmpty obj\n obj = options.emptyTag\n\n # check whether we closed all the open tags\n if stack.length > 0", "response": "if nodeName not of s\n s[nodeName] = obj\n else if s[nodeName] instanceof Array\n s[nodeName].push obj\n else\n old = s[nodeName]\n s[nodeName] = [old]\n s[nodeName].push obj\n else\n @resultObject = obj\n @emit \"end\", @resultObject\n\n @saxParser.ontext = @saxParser.oncdata = (text) =>\n s = stack[stack.length - 1]\n if s\n s[\"#\"] += text\n\n parseString: (str) =>\n @saxParser.write str.toString()", "source_lang": "CoffeeScript", "target_lang": "CoffeeScript", "repo": "Leonidas-from-XIV/node-xml2js", "path": "src/xml2js.coffee", "license": "MIT", "commit": "5f54d6963b8a8b57f28dd3a8db2a22a2105837b3", "stars": 4965, "source_url": "https://github.com/Leonidas-from-XIV/node-xml2js/blob/5f54d6963b8a8b57f28dd3a8db2a22a2105837b3/src/xml2js.coffee", "line_start": 58, "line_end": 95}148{"id": "Leonidas-from-XIV/node-xml2js:src/xml2js.coffee:2:raw_corpus", "type": "raw_corpus", "prompt": "", "response": "delete obj[\"#name\"]\n\n s = stack[stack.length - 1]\n # remove the '#' key altogether if it's blank\n if obj[\"#\"].match(/^\\s*$/)\n delete obj[\"#\"]\n else\n obj[\"#\"] = obj[\"#\"].trim() if options.trim\n obj[\"#\"] = obj[\"#\"].replace(/\\s{2,}/g, \" \").trim() if options.normalize\n # also do away with '#' key altogether, if there's no subkeys\n # unless EXPLICIT_CHARKEY is set\n if Object.keys(obj).length == 1 and \"#\" of obj and not @EXPLICIT_CHARKEY\n obj = obj[\"#\"]\n\n if stack.length > 0\n if nodeName not of s\n s[nodeName] = obj\n else if s[nodeName] instanceof Array\n s[nodeName].push obj\n else\n old = s[nodeName]\n s[nodeName] = [old]\n s[nodeName].push obj\n else\n @resultObject = obj\n @emit \"end\", @resultObject\n\n @saxParser.ontext = @saxParser.oncdata = (text) =>\n s = stack[stack.length - 1]\n if s\n s[\"#\"] += text\n\n parseString: (str) =>\n @saxParser.write str.toString()", "source_lang": "", "target_lang": "CoffeeScript", "repo": "Leonidas-from-XIV/node-xml2js", "path": "src/xml2js.coffee", "license": "MIT", "commit": "a48e4a4bec2576e9b091c3210a5fe06ea99f538a", "stars": 4965, "source_url": "https://github.com/Leonidas-from-XIV/node-xml2js/blob/a48e4a4bec2576e9b091c3210a5fe06ea99f538a/src/xml2js.coffee", "line_start": 54, "line_end": 87}149{"id": "Leonidas-from-XIV/node-xml2js:src/xml2js.coffee:2:completion", "type": "completion", "prompt": "delete obj[\"#name\"]\n\n s = stack[stack.length - 1]\n # remove the '#' key altogether if it's blank\n if obj[\"#\"].match(/^\\s*$/)\n delete obj[\"#\"]\n else\n obj[\"#\"] = obj[\"#\"].trim() if options.trim\n obj[\"#\"] = obj[\"#\"].replace(/\\s{2,}/g, \" \").trim() if options.normalize\n # also do away with '#' key altogether, if there's no subkeys\n # unless EXPLICIT_CHARKEY is set\n if Object.keys(obj).length == 1 and \"#\" of obj and not @EXPLICIT_CHARKEY\n obj = obj[\"#\"]\n\n if stack.length > 0\n if nodeName not of s\n s[nodeName] = obj", "response": "else if s[nodeName] instanceof Array\n s[nodeName].push obj\n else\n old = s[nodeName]\n s[nodeName] = [old]\n s[nodeName].push obj\n else\n @resultObject = obj\n @emit \"end\", @resultObject\n\n @saxParser.ontext = @saxParser.oncdata = (text) =>\n s = stack[stack.length - 1]\n if s\n s[\"#\"] += text\n\n parseString: (str) =>\n @saxParser.write str.toString()", "source_lang": "CoffeeScript", "target_lang": "CoffeeScript", "repo": "Leonidas-from-XIV/node-xml2js", "path": "src/xml2js.coffee", "license": "MIT", "commit": "a48e4a4bec2576e9b091c3210a5fe06ea99f538a", "stars": 4965, "source_url": "https://github.com/Leonidas-from-XIV/node-xml2js/blob/a48e4a4bec2576e9b091c3210a5fe06ea99f538a/src/xml2js.coffee", "line_start": 54, "line_end": 87}150{"id": "Leonidas-from-XIV/node-xml2js:src/xml2js.coffee:1:raw_corpus", "type": "raw_corpus", "prompt": "", "response": "sax = require 'sax'\nevents = require 'events'\n\nclass exports.Parser extends events.EventEmitter\n constructor: (opts) ->\n\n # default options. for compatibility's sake set to some\n # sub-optimal settings. might change in the future.\n options =\n explicitCharkey: false\n trim: true\n # normalize implicates trimming, just so you know\n normalize: true\n # overwrite them with the specified options, if any\n options[key] = value for own key, value of opts\n\n # make the SAX parser. tried trim and normalize, but they are not\n # very helpful\n @saxParser = sax.parser true, {\n trim: false,\n normalize: false\n }\n # always use the '#' key, even if there are no subkeys\n # setting this property by and is deprecated, yet still supported.\n # better pass it as explicitCharkey option to the constructor\n @EXPLICIT_CHARKEY = options.explicitCharkey\n @resultObject = null\n stack = []\n\n @saxParser.onopentag = (node) =>\n obj = {}\n obj[\"#\"] = \"\"\n for own key of node.attributes\n if \"@\" not of obj\n obj[\"@\"] = {}\n obj[\"@\"][key] = node.attributes[key]\n\n # need a place to store the node name\n obj[\"#name\"] = node.name\n stack.push obj\n\n @saxParser.onclosetag = =>\n obj = stack.pop()\n nodeName = obj[\"#name\"]\n delete obj[\"#name\"]\n\n s = stack[stack.length - 1]\n # remove the '#' key altogether if it's blank\n if obj[\"#\"].match(/^\\s*$/)\n delete obj[\"#\"]", "source_lang": "", "target_lang": "CoffeeScript", "repo": "Leonidas-from-XIV/node-xml2js", "path": "src/xml2js.coffee", "license": "MIT", "commit": "7dddb3c5049f1b351824e993110569d77148ad2e", "stars": 4965, "source_url": "https://github.com/Leonidas-from-XIV/node-xml2js/blob/7dddb3c5049f1b351824e993110569d77148ad2e/src/xml2js.coffee", "line_start": 1, "line_end": 50}151{"id": "Leonidas-from-XIV/node-xml2js:src/xml2js.coffee:1:completion", "type": "completion", "prompt": "sax = require 'sax'\nevents = require 'events'\n\nclass exports.Parser extends events.EventEmitter\n constructor: (opts) ->\n\n # default options. for compatibility's sake set to some\n # sub-optimal settings. might change in the future.\n options =\n explicitCharkey: false\n trim: true\n # normalize implicates trimming, just so you know\n normalize: true\n # overwrite them with the specified options, if any\n options[key] = value for own key, value of opts\n\n # make the SAX parser. tried trim and normalize, but they are not\n # very helpful\n @saxParser = sax.parser true, {\n trim: false,\n normalize: false\n }\n # always use the '#' key, even if there are no subkeys\n # setting this property by and is deprecated, yet still supported.\n # better pass it as explicitCharkey option to the constructor", "response": "@EXPLICIT_CHARKEY = options.explicitCharkey\n @resultObject = null\n stack = []\n\n @saxParser.onopentag = (node) =>\n obj = {}\n obj[\"#\"] = \"\"\n for own key of node.attributes\n if \"@\" not of obj\n obj[\"@\"] = {}\n obj[\"@\"][key] = node.attributes[key]\n\n # need a place to store the node name\n obj[\"#name\"] = node.name\n stack.push obj\n\n @saxParser.onclosetag = =>\n obj = stack.pop()\n nodeName = obj[\"#name\"]\n delete obj[\"#name\"]\n\n s = stack[stack.length - 1]\n # remove the '#' key altogether if it's blank\n if obj[\"#\"].match(/^\\s*$/)\n delete obj[\"#\"]", "source_lang": "CoffeeScript", "target_lang": "CoffeeScript", "repo": "Leonidas-from-XIV/node-xml2js", "path": "src/xml2js.coffee", "license": "MIT", "commit": "7dddb3c5049f1b351824e993110569d77148ad2e", "stars": 4965, "source_url": "https://github.com/Leonidas-from-XIV/node-xml2js/blob/7dddb3c5049f1b351824e993110569d77148ad2e/src/xml2js.coffee", "line_start": 1, "line_end": 50}152{"id": "Leonidas-from-XIV/node-xml2js:src/xml2js.coffee:2:raw_corpus", "type": "raw_corpus", "prompt": "", "response": "else\n obj[\"#\"] = obj[\"#\"].trim() if options.trim\n obj[\"#\"] = obj[\"#\"].replace(/\\s{2,}/g, \" \").trim() if options.normalize\n # also do away with '#' key altogether, if there's no subkeys\n # unless EXPLICIT_CHARKEY is set\n if Object.keys(obj).length == 1 and \"#\" of obj and not @EXPLICIT_CHARKEY\n obj = obj[\"#\"]\n\n if stack.length > 0\n if nodeName not of s\n s[nodeName] = obj\n else if s[nodeName] instanceof Array\n s[nodeName].push obj\n else\n old = s[nodeName]\n s[nodeName] = [old]\n s[nodeName].push obj\n else\n @resultObject = obj\n @emit \"end\", @resultObject\n\n @saxParser.ontext = @saxParser.oncdata = (text) =>\n s = stack[stack.length - 1]\n if s\n s[\"#\"] += text\n\n parseString: (str) =>\n @saxParser.write str.toString()", "source_lang": "", "target_lang": "CoffeeScript", "repo": "Leonidas-from-XIV/node-xml2js", "path": "src/xml2js.coffee", "license": "MIT", "commit": "7dddb3c5049f1b351824e993110569d77148ad2e", "stars": 4965, "source_url": "https://github.com/Leonidas-from-XIV/node-xml2js/blob/7dddb3c5049f1b351824e993110569d77148ad2e/src/xml2js.coffee", "line_start": 51, "line_end": 78}153{"id": "Leonidas-from-XIV/node-xml2js:src/xml2js.coffee:2:completion", "type": "completion", "prompt": "else\n obj[\"#\"] = obj[\"#\"].trim() if options.trim\n obj[\"#\"] = obj[\"#\"].replace(/\\s{2,}/g, \" \").trim() if options.normalize\n # also do away with '#' key altogether, if there's no subkeys\n # unless EXPLICIT_CHARKEY is set\n if Object.keys(obj).length == 1 and \"#\" of obj and not @EXPLICIT_CHARKEY\n obj = obj[\"#\"]\n\n if stack.length > 0\n if nodeName not of s\n s[nodeName] = obj\n else if s[nodeName] instanceof Array\n s[nodeName].push obj\n else", "response": "old = s[nodeName]\n s[nodeName] = [old]\n s[nodeName].push obj\n else\n @resultObject = obj\n @emit \"end\", @resultObject\n\n @saxParser.ontext = @saxParser.oncdata = (text) =>\n s = stack[stack.length - 1]\n if s\n s[\"#\"] += text\n\n parseString: (str) =>\n @saxParser.write str.toString()", "source_lang": "CoffeeScript", "target_lang": "CoffeeScript", "repo": "Leonidas-from-XIV/node-xml2js", "path": "src/xml2js.coffee", "license": "MIT", "commit": "7dddb3c5049f1b351824e993110569d77148ad2e", "stars": 4965, "source_url": "https://github.com/Leonidas-from-XIV/node-xml2js/blob/7dddb3c5049f1b351824e993110569d77148ad2e/src/xml2js.coffee", "line_start": 51, "line_end": 78}154{"id": "Leonidas-from-XIV/node-xml2js:src/xml2js.coffee:1:raw_corpus", "type": "raw_corpus", "prompt": "", "response": "sax = require(\"sax\")\nevents = require(\"events\")\n\n\nclass exports.Parser extends events.EventEmitter\n constructor: (opts) ->\n\n # default options. for compatibility's sake set to some\n # sub-optimal settings. might change in the future.\n options =\n explicitCharkey: false\n trim: true\n # normalize implicates trimming, just so you know\n normalize: true\n # overwrite them with the specified options, if any\n options[key] = value for own key, value of opts\n\n # make the SAX parser. tried trim and normalize, but they are not\n # very helpful\n @saxParser = sax.parser true, {\n trim: false,\n normalize: false\n }\n # always use the '#' key, even if there are no subkeys\n # setting this property by and is deprecated, yet still supported.\n # better pass it as explicitCharkey option to the constructor\n @EXPLICIT_CHARKEY = options.explicitCharkey\n @resultObject = null\n stack = []\n\n @saxParser.onopentag = (node) =>\n obj = {}\n obj[\"#\"] = \"\"\n for own key of node.attributes\n if \"@\" not of obj\n obj[\"@\"] = {}\n obj[\"@\"][key] = node.attributes[key]\n\n # need a place to store the node name\n obj[\"#name\"] = node.name\n stack.push obj\n\n @saxParser.onclosetag = =>\n obj = stack.pop()\n nodeName = obj[\"#name\"]\n delete obj[\"#name\"]\n\n s = stack[stack.length - 1]\n # remove the '#' key altogether if it's blank\n if obj[\"#\"].match(/^\\s*$/)", "source_lang": "", "target_lang": "CoffeeScript", "repo": "Leonidas-from-XIV/node-xml2js", "path": "src/xml2js.coffee", "license": "MIT", "commit": "29a619b91708aebf6c78af885fb42dc0b2aad4db", "stars": 4965, "source_url": "https://github.com/Leonidas-from-XIV/node-xml2js/blob/29a619b91708aebf6c78af885fb42dc0b2aad4db/src/xml2js.coffee", "line_start": 1, "line_end": 50}155{"id": "Leonidas-from-XIV/node-xml2js:src/xml2js.coffee:1:completion", "type": "completion", "prompt": "sax = require(\"sax\")\nevents = require(\"events\")\n\n\nclass exports.Parser extends events.EventEmitter\n constructor: (opts) ->\n\n # default options. for compatibility's sake set to some\n # sub-optimal settings. might change in the future.\n options =\n explicitCharkey: false\n trim: true\n # normalize implicates trimming, just so you know\n normalize: true\n # overwrite them with the specified options, if any\n options[key] = value for own key, value of opts\n\n # make the SAX parser. tried trim and normalize, but they are not\n # very helpful\n @saxParser = sax.parser true, {\n trim: false,\n normalize: false\n }\n # always use the '#' key, even if there are no subkeys\n # setting this property by and is deprecated, yet still supported.", "response": "# better pass it as explicitCharkey option to the constructor\n @EXPLICIT_CHARKEY = options.explicitCharkey\n @resultObject = null\n stack = []\n\n @saxParser.onopentag = (node) =>\n obj = {}\n obj[\"#\"] = \"\"\n for own key of node.attributes\n if \"@\" not of obj\n obj[\"@\"] = {}\n obj[\"@\"][key] = node.attributes[key]\n\n # need a place to store the node name\n obj[\"#name\"] = node.name\n stack.push obj\n\n @saxParser.onclosetag = =>\n obj = stack.pop()\n nodeName = obj[\"#name\"]\n delete obj[\"#name\"]\n\n s = stack[stack.length - 1]\n # remove the '#' key altogether if it's blank\n if obj[\"#\"].match(/^\\s*$/)", "source_lang": "CoffeeScript", "target_lang": "CoffeeScript", "repo": "Leonidas-from-XIV/node-xml2js", "path": "src/xml2js.coffee", "license": "MIT", "commit": "29a619b91708aebf6c78af885fb42dc0b2aad4db", "stars": 4965, "source_url": "https://github.com/Leonidas-from-XIV/node-xml2js/blob/29a619b91708aebf6c78af885fb42dc0b2aad4db/src/xml2js.coffee", "line_start": 1, "line_end": 50}156{"id": "Leonidas-from-XIV/node-xml2js:src/xml2js.coffee:2:raw_corpus", "type": "raw_corpus", "prompt": "", "response": "delete obj[\"#\"]\n else\n obj[\"#\"] = obj[\"#\"].trim() if options.trim\n obj[\"#\"] = obj[\"#\"].replace(/\\s{2,}/g, \" \").trim() if options.normalize\n # also do away with '#' key altogether, if there's no subkeys\n # unless EXPLICIT_CHARKEY is set\n if Object.keys(obj).length == 1 and \"#\" of obj and not @EXPLICIT_CHARKEY\n obj = obj[\"#\"]\n\n if stack.length > 0\n if nodeName not of s\n s[nodeName] = obj\n else if s[nodeName] instanceof Array\n s[nodeName].push obj\n else\n old = s[nodeName]\n s[nodeName] = [old]\n s[nodeName].push obj\n else\n @resultObject = obj\n @emit \"end\", @resultObject\n\n @saxParser.ontext = @saxParser.oncdata = (text) =>\n s = stack[stack.length - 1]\n if s\n s[\"#\"] += text\n\n parseString: (str) =>\n @saxParser.write str.toString()", "source_lang": "", "target_lang": "CoffeeScript", "repo": "Leonidas-from-XIV/node-xml2js", "path": "src/xml2js.coffee", "license": "MIT", "commit": "29a619b91708aebf6c78af885fb42dc0b2aad4db", "stars": 4965, "source_url": "https://github.com/Leonidas-from-XIV/node-xml2js/blob/29a619b91708aebf6c78af885fb42dc0b2aad4db/src/xml2js.coffee", "line_start": 51, "line_end": 79}157{"id": "Leonidas-from-XIV/node-xml2js:src/xml2js.coffee:2:completion", "type": "completion", "prompt": "delete obj[\"#\"]\n else\n obj[\"#\"] = obj[\"#\"].trim() if options.trim\n obj[\"#\"] = obj[\"#\"].replace(/\\s{2,}/g, \" \").trim() if options.normalize\n # also do away with '#' key altogether, if there's no subkeys\n # unless EXPLICIT_CHARKEY is set\n if Object.keys(obj).length == 1 and \"#\" of obj and not @EXPLICIT_CHARKEY\n obj = obj[\"#\"]\n\n if stack.length > 0\n if nodeName not of s\n s[nodeName] = obj\n else if s[nodeName] instanceof Array\n s[nodeName].push obj", "response": "else\n old = s[nodeName]\n s[nodeName] = [old]\n s[nodeName].push obj\n else\n @resultObject = obj\n @emit \"end\", @resultObject\n\n @saxParser.ontext = @saxParser.oncdata = (text) =>\n s = stack[stack.length - 1]\n if s\n s[\"#\"] += text\n\n parseString: (str) =>\n @saxParser.write str.toString()", "source_lang": "CoffeeScript", "target_lang": "CoffeeScript", "repo": "Leonidas-from-XIV/node-xml2js", "path": "src/xml2js.coffee", "license": "MIT", "commit": "29a619b91708aebf6c78af885fb42dc0b2aad4db", "stars": 4965, "source_url": "https://github.com/Leonidas-from-XIV/node-xml2js/blob/29a619b91708aebf6c78af885fb42dc0b2aad4db/src/xml2js.coffee", "line_start": 51, "line_end": 79}158{"id": "Leonidas-from-XIV/node-xml2js:src/xml2js.coffee:1:raw_corpus", "type": "raw_corpus", "prompt": "", "response": "sax = require(\"sax\")\nevents = require(\"events\")\n\n\nclass exports.Parser extends events.EventEmitter\n constructor: (opts) ->\n\n # default options. for compatibility's sake set to some\n # sub-optimal settings. might change in the future.\n options =\n explicitCharkey: false\n trim: true\n # normalize implicates trimming, just so you know\n normalize: true\n # overwrite them with the specified options, if any\n options[key] = value for own key, value of opts\n\n # make the SAX parser. tried trim and normalize, but they are not\n # very helpful\n @saxParser = sax.parser true, {\n trim: false,\n normalize: false\n }\n # always use the '#' key, even if there are no subkeys\n @EXPLICIT_CHARKEY = options.explicitCharkey\n @resultObject = null\n stack = []\n\n @saxParser.onopentag = (node) =>\n obj = {}\n obj[\"#\"] = \"\"\n for own key of node.attributes\n if \"@\" not of obj\n obj[\"@\"] = {}\n obj[\"@\"][key] = node.attributes[key]\n\n # need a place to store the node name\n obj[\"#name\"] = node.name\n stack.push obj\n\n @saxParser.onclosetag = =>\n obj = stack.pop()\n nodeName = obj[\"#name\"]\n delete obj[\"#name\"]\n\n s = stack[stack.length - 1]\n # remove the '#' key altogether if it's blank\n if obj[\"#\"].match(/^\\s*$/)\n delete obj[\"#\"]\n else", "source_lang": "", "target_lang": "CoffeeScript", "repo": "Leonidas-from-XIV/node-xml2js", "path": "src/xml2js.coffee", "license": "MIT", "commit": "e1687bc96b0327db4aedaa136616790593724824", "stars": 4965, "source_url": "https://github.com/Leonidas-from-XIV/node-xml2js/blob/e1687bc96b0327db4aedaa136616790593724824/src/xml2js.coffee", "line_start": 1, "line_end": 50}159{"id": "Leonidas-from-XIV/node-xml2js:src/xml2js.coffee:1:completion", "type": "completion", "prompt": "sax = require(\"sax\")\nevents = require(\"events\")\n\n\nclass exports.Parser extends events.EventEmitter\n constructor: (opts) ->\n\n # default options. for compatibility's sake set to some\n # sub-optimal settings. might change in the future.\n options =\n explicitCharkey: false\n trim: true\n # normalize implicates trimming, just so you know\n normalize: true\n # overwrite them with the specified options, if any\n options[key] = value for own key, value of opts\n\n # make the SAX parser. tried trim and normalize, but they are not\n # very helpful\n @saxParser = sax.parser true, {\n trim: false,\n normalize: false\n }\n # always use the '#' key, even if there are no subkeys\n @EXPLICIT_CHARKEY = options.explicitCharkey", "response": "@resultObject = null\n stack = []\n\n @saxParser.onopentag = (node) =>\n obj = {}\n obj[\"#\"] = \"\"\n for own key of node.attributes\n if \"@\" not of obj\n obj[\"@\"] = {}\n obj[\"@\"][key] = node.attributes[key]\n\n # need a place to store the node name\n obj[\"#name\"] = node.name\n stack.push obj\n\n @saxParser.onclosetag = =>\n obj = stack.pop()\n nodeName = obj[\"#name\"]\n delete obj[\"#name\"]\n\n s = stack[stack.length - 1]\n # remove the '#' key altogether if it's blank\n if obj[\"#\"].match(/^\\s*$/)\n delete obj[\"#\"]\n else", "source_lang": "CoffeeScript", "target_lang": "CoffeeScript", "repo": "Leonidas-from-XIV/node-xml2js", "path": "src/xml2js.coffee", "license": "MIT", "commit": "e1687bc96b0327db4aedaa136616790593724824", "stars": 4965, "source_url": "https://github.com/Leonidas-from-XIV/node-xml2js/blob/e1687bc96b0327db4aedaa136616790593724824/src/xml2js.coffee", "line_start": 1, "line_end": 50}160{"id": "Leonidas-from-XIV/node-xml2js:src/xml2js.coffee:2:raw_corpus", "type": "raw_corpus", "prompt": "", "response": "obj[\"#\"] = obj[\"#\"].trim() if options.trim\n obj[\"#\"] = obj[\"#\"].replace(/\\s{2,}/g, \" \").trim() if options.normalize\n # also do away with '#' key altogether, if there's no subkeys\n # unless EXPLICIT_CHARKEY is set\n if Object.keys(obj).length == 1 and \"#\" of obj and not @EXPLICIT_CHARKEY\n obj = obj[\"#\"]\n\n if stack.length > 0\n if nodeName not of s\n s[nodeName] = obj\n else if s[nodeName] instanceof Array\n s[nodeName].push obj\n else\n old = s[nodeName]\n s[nodeName] = [old]\n s[nodeName].push obj\n else\n @resultObject = obj\n @emit \"end\", @resultObject\n\n @saxParser.ontext = @saxParser.oncdata = (text) =>\n s = stack[stack.length - 1]\n if s\n s[\"#\"] += text\n\n parseString: (str) =>\n @saxParser.write str.toString()", "source_lang": "", "target_lang": "CoffeeScript", "repo": "Leonidas-from-XIV/node-xml2js", "path": "src/xml2js.coffee", "license": "MIT", "commit": "e1687bc96b0327db4aedaa136616790593724824", "stars": 4965, "source_url": "https://github.com/Leonidas-from-XIV/node-xml2js/blob/e1687bc96b0327db4aedaa136616790593724824/src/xml2js.coffee", "line_start": 51, "line_end": 77}161{"id": "Leonidas-from-XIV/node-xml2js:src/xml2js.coffee:2:coffee_to_js", "type": "coffee_to_js", "prompt": "Convert this CoffeeScript to JavaScript.\n```coffeescript\nobj[\"#\"] = obj[\"#\"].trim() if options.trim\n obj[\"#\"] = obj[\"#\"].replace(/\\s{2,}/g, \" \").trim() if options.normalize\n # also do away with '#' key altogether, if there's no subkeys\n # unless EXPLICIT_CHARKEY is set\n if Object.keys(obj).length == 1 and \"#\" of obj and not @EXPLICIT_CHARKEY\n obj = obj[\"#\"]\n\n if stack.length > 0\n if nodeName not of s\n s[nodeName] = obj\n else if s[nodeName] instanceof Array\n s[nodeName].push obj\n else\n old = s[nodeName]\n s[nodeName] = [old]\n s[nodeName].push obj\n else\n @resultObject = obj\n @emit \"end\", @resultObject\n\n @saxParser.ontext = @saxParser.oncdata = (text) =>\n s = stack[stack.length - 1]\n if s\n s[\"#\"] += text\n\n parseString: (str) =>\n @saxParser.write str.toString()\n```", "response": "var obj, old;\n\n// also do away with '#' key altogether, if there's no subkeys\n// unless EXPLICIT_CHARKEY is set\nobj[\"#\"] = obj[\"#\"].trim()(options.trim ? (options.normalize ? obj[\"#\"] = obj[\"#\"].replace(/\\s{2,}/g, \" \").trim() : void 0, Object.keys(obj).length === 1 && \"#\" in obj && !this.EXPLICIT_CHARKEY ? obj = obj[\"#\"] : void 0) : void 0);\n\nif (stack.length > 0) {\n if (!(nodeName in s)) {\n s[nodeName] = obj;\n } else if (s[nodeName] instanceof Array) {\n s[nodeName].push(obj);\n } else {\n old = s[nodeName];\n s[nodeName] = [old];\n s[nodeName].push(obj);\n }\n} else {\n this.resultObject = obj;\n this.emit(\"end\", this.resultObject);\n}\n\nthis.saxParser.ontext = this.saxParser.oncdata = (text) => {\n var s;\n s = stack[stack.length - 1];\n if (s) {\n return s[\"#\"] += text;\n }\n};\n\n({\n parseString: (str) => {\n return this.saxParser.write(str.toString());\n }\n});", "source_lang": "CoffeeScript", "target_lang": "JavaScript", "repo": "Leonidas-from-XIV/node-xml2js", "path": "src/xml2js.coffee", "license": "MIT", "commit": "e1687bc96b0327db4aedaa136616790593724824", "stars": 4965, "source_url": "https://github.com/Leonidas-from-XIV/node-xml2js/blob/e1687bc96b0327db4aedaa136616790593724824/src/xml2js.coffee", "line_start": 51, "line_end": 77}162{"id": "Leonidas-from-XIV/node-xml2js:src/xml2js.coffee:2:js_to_coffee", "type": "js_to_coffee", "prompt": "Convert this JavaScript to CoffeeScript.\n```javascript\nvar obj, old;\n\n// also do away with '#' key altogether, if there's no subkeys\n// unless EXPLICIT_CHARKEY is set\nobj[\"#\"] = obj[\"#\"].trim()(options.trim ? (options.normalize ? obj[\"#\"] = obj[\"#\"].replace(/\\s{2,}/g, \" \").trim() : void 0, Object.keys(obj).length === 1 && \"#\" in obj && !this.EXPLICIT_CHARKEY ? obj = obj[\"#\"] : void 0) : void 0);\n\nif (stack.length > 0) {\n if (!(nodeName in s)) {\n s[nodeName] = obj;\n } else if (s[nodeName] instanceof Array) {\n s[nodeName].push(obj);\n } else {\n old = s[nodeName];\n s[nodeName] = [old];\n s[nodeName].push(obj);\n }\n} else {\n this.resultObject = obj;\n this.emit(\"end\", this.resultObject);\n}\n\nthis.saxParser.ontext = this.saxParser.oncdata = (text) => {\n var s;\n s = stack[stack.length - 1];\n if (s) {\n return s[\"#\"] += text;\n }\n};\n\n({\n parseString: (str) => {\n return this.saxParser.write(str.toString());\n }\n});\n```", "response": "obj[\"#\"] = obj[\"#\"].trim() if options.trim\n obj[\"#\"] = obj[\"#\"].replace(/\\s{2,}/g, \" \").trim() if options.normalize\n # also do away with '#' key altogether, if there's no subkeys\n # unless EXPLICIT_CHARKEY is set\n if Object.keys(obj).length == 1 and \"#\" of obj and not @EXPLICIT_CHARKEY\n obj = obj[\"#\"]\n\n if stack.length > 0\n if nodeName not of s\n s[nodeName] = obj\n else if s[nodeName] instanceof Array\n s[nodeName].push obj\n else\n old = s[nodeName]\n s[nodeName] = [old]\n s[nodeName].push obj\n else\n @resultObject = obj\n @emit \"end\", @resultObject\n\n @saxParser.ontext = @saxParser.oncdata = (text) =>\n s = stack[stack.length - 1]\n if s\n s[\"#\"] += text\n\n parseString: (str) =>\n @saxParser.write str.toString()", "source_lang": "JavaScript", "target_lang": "CoffeeScript", "repo": "Leonidas-from-XIV/node-xml2js", "path": "src/xml2js.coffee", "license": "MIT", "commit": "e1687bc96b0327db4aedaa136616790593724824", "stars": 4965, "source_url": "https://github.com/Leonidas-from-XIV/node-xml2js/blob/e1687bc96b0327db4aedaa136616790593724824/src/xml2js.coffee", "line_start": 51, "line_end": 77}163{"id": "Leonidas-from-XIV/node-xml2js:src/xml2js.coffee:2:completion", "type": "completion", "prompt": "obj[\"#\"] = obj[\"#\"].trim() if options.trim\n obj[\"#\"] = obj[\"#\"].replace(/\\s{2,}/g, \" \").trim() if options.normalize\n # also do away with '#' key altogether, if there's no subkeys\n # unless EXPLICIT_CHARKEY is set\n if Object.keys(obj).length == 1 and \"#\" of obj and not @EXPLICIT_CHARKEY\n obj = obj[\"#\"]\n\n if stack.length > 0\n if nodeName not of s\n s[nodeName] = obj\n else if s[nodeName] instanceof Array\n s[nodeName].push obj\n else", "response": "old = s[nodeName]\n s[nodeName] = [old]\n s[nodeName].push obj\n else\n @resultObject = obj\n @emit \"end\", @resultObject\n\n @saxParser.ontext = @saxParser.oncdata = (text) =>\n s = stack[stack.length - 1]\n if s\n s[\"#\"] += text\n\n parseString: (str) =>\n @saxParser.write str.toString()", "source_lang": "CoffeeScript", "target_lang": "CoffeeScript", "repo": "Leonidas-from-XIV/node-xml2js", "path": "src/xml2js.coffee", "license": "MIT", "commit": "e1687bc96b0327db4aedaa136616790593724824", "stars": 4965, "source_url": "https://github.com/Leonidas-from-XIV/node-xml2js/blob/e1687bc96b0327db4aedaa136616790593724824/src/xml2js.coffee", "line_start": 51, "line_end": 77}164{"id": "Leonidas-from-XIV/node-xml2js:src/xml2js.coffee:1:raw_corpus", "type": "raw_corpus", "prompt": "", "response": "sax = require(\"sax\")\nevents = require(\"events\")\n\n\nclass exports.Parser extends events.EventEmitter\n constructor: (opts) ->\n\n # default options\n options =\n explicitCharkey: false\n trim: false\n normalize: false\n # overwrite them with the specified options, if any\n options[key] = value for own key, value of opts\n\n # make the sax parser\n @saxParser = sax.parser true\n # always use the '#' key, even if there are no subkeys\n @EXPLICIT_CHARKEY = options.explicitCharkey\n @resultObject = null\n stack = []\n\n @saxParser.onopentag = (node) =>\n obj = {}\n obj[\"#\"] = \"\"\n for own key of node.attributes\n if \"@\" not of obj\n obj[\"@\"] = {}\n obj[\"@\"][key] = node.attributes[key]\n\n # need a place to store the node name\n obj[\"#name\"] = node.name\n stack.push obj\n\n @saxParser.onclosetag = =>\n obj = stack.pop()\n nodeName = obj[\"#name\"]\n delete obj[\"#name\"]\n\n s = stack[stack.length - 1]\n # remove the '#' key altogether if it's blank\n if obj[\"#\"].match(/^\\s*$/)\n delete obj[\"#\"]\n else\n # turn 2 or more spaces into one space\n obj[\"#\"] = obj[\"#\"].replace(/\\s{2,}/g, \" \").trim()\n # also do away with '#' key altogether, if there's no subkeys\n # unless EXPLICIT_CHARKEY is set\n if Object.keys(obj).length == 1 and \"#\" of obj and not @EXPLICIT_CHARKEY\n obj = obj[\"#\"]", "source_lang": "", "target_lang": "CoffeeScript", "repo": "Leonidas-from-XIV/node-xml2js", "path": "src/xml2js.coffee", "license": "MIT", "commit": "054b79f2eab8754284fac4260dd356a87ef83e84", "stars": 4965, "source_url": "https://github.com/Leonidas-from-XIV/node-xml2js/blob/054b79f2eab8754284fac4260dd356a87ef83e84/src/xml2js.coffee", "line_start": 1, "line_end": 50}165{"id": "Leonidas-from-XIV/node-xml2js:src/xml2js.coffee:1:completion", "type": "completion", "prompt": "sax = require(\"sax\")\nevents = require(\"events\")\n\n\nclass exports.Parser extends events.EventEmitter\n constructor: (opts) ->\n\n # default options\n options =\n explicitCharkey: false\n trim: false\n normalize: false\n # overwrite them with the specified options, if any\n options[key] = value for own key, value of opts\n\n # make the sax parser\n @saxParser = sax.parser true\n # always use the '#' key, even if there are no subkeys\n @EXPLICIT_CHARKEY = options.explicitCharkey\n @resultObject = null\n stack = []\n\n @saxParser.onopentag = (node) =>\n obj = {}\n obj[\"#\"] = \"\"", "response": "for own key of node.attributes\n if \"@\" not of obj\n obj[\"@\"] = {}\n obj[\"@\"][key] = node.attributes[key]\n\n # need a place to store the node name\n obj[\"#name\"] = node.name\n stack.push obj\n\n @saxParser.onclosetag = =>\n obj = stack.pop()\n nodeName = obj[\"#name\"]\n delete obj[\"#name\"]\n\n s = stack[stack.length - 1]\n # remove the '#' key altogether if it's blank\n if obj[\"#\"].match(/^\\s*$/)\n delete obj[\"#\"]\n else\n # turn 2 or more spaces into one space\n obj[\"#\"] = obj[\"#\"].replace(/\\s{2,}/g, \" \").trim()\n # also do away with '#' key altogether, if there's no subkeys\n # unless EXPLICIT_CHARKEY is set\n if Object.keys(obj).length == 1 and \"#\" of obj and not @EXPLICIT_CHARKEY\n obj = obj[\"#\"]", "source_lang": "CoffeeScript", "target_lang": "CoffeeScript", "repo": "Leonidas-from-XIV/node-xml2js", "path": "src/xml2js.coffee", "license": "MIT", "commit": "054b79f2eab8754284fac4260dd356a87ef83e84", "stars": 4965, "source_url": "https://github.com/Leonidas-from-XIV/node-xml2js/blob/054b79f2eab8754284fac4260dd356a87ef83e84/src/xml2js.coffee", "line_start": 1, "line_end": 50}166{"id": "Leonidas-from-XIV/node-xml2js:src/xml2js.coffee:2:raw_corpus", "type": "raw_corpus", "prompt": "", "response": "if stack.length > 0\n if nodeName not of s\n s[nodeName] = obj\n else if s[nodeName] instanceof Array\n s[nodeName].push obj\n else\n old = s[nodeName]\n s[nodeName] = [old]\n s[nodeName].push obj\n else\n @resultObject = obj\n @emit \"end\", @resultObject\n\n @saxParser.ontext = @saxParser.oncdata = (text) =>\n s = stack[stack.length - 1]\n if s\n s[\"#\"] += text\n\n parseString: (str) =>\n @saxParser.write str.toString()", "source_lang": "", "target_lang": "CoffeeScript", "repo": "Leonidas-from-XIV/node-xml2js", "path": "src/xml2js.coffee", "license": "MIT", "commit": "054b79f2eab8754284fac4260dd356a87ef83e84", "stars": 4965, "source_url": "https://github.com/Leonidas-from-XIV/node-xml2js/blob/054b79f2eab8754284fac4260dd356a87ef83e84/src/xml2js.coffee", "line_start": 51, "line_end": 71}167{"id": "Leonidas-from-XIV/node-xml2js:src/xml2js.coffee:2:coffee_to_js", "type": "coffee_to_js", "prompt": "Convert this CoffeeScript to JavaScript.\n```coffeescript\nif stack.length > 0\n if nodeName not of s\n s[nodeName] = obj\n else if s[nodeName] instanceof Array\n s[nodeName].push obj\n else\n old = s[nodeName]\n s[nodeName] = [old]\n s[nodeName].push obj\n else\n @resultObject = obj\n @emit \"end\", @resultObject\n\n @saxParser.ontext = @saxParser.oncdata = (text) =>\n s = stack[stack.length - 1]\n if s\n s[\"#\"] += text\n\n parseString: (str) =>\n @saxParser.write str.toString()\n```", "response": "var old;\n\nif (stack.length > 0) {\n if (!(nodeName in s)) {\n s[nodeName] = obj;\n } else if (s[nodeName] instanceof Array) {\n s[nodeName].push(obj);\n } else {\n old = s[nodeName];\n s[nodeName] = [old];\n s[nodeName].push(obj);\n }\n} else {\n this.resultObject = obj;\n this.emit(\"end\", this.resultObject);\n}\n\nthis.saxParser.ontext = this.saxParser.oncdata = (text) => {\n var s;\n s = stack[stack.length - 1];\n if (s) {\n return s[\"#\"] += text;\n }\n};\n\n({\n parseString: (str) => {\n return this.saxParser.write(str.toString());\n }\n});", "source_lang": "CoffeeScript", "target_lang": "JavaScript", "repo": "Leonidas-from-XIV/node-xml2js", "path": "src/xml2js.coffee", "license": "MIT", "commit": "054b79f2eab8754284fac4260dd356a87ef83e84", "stars": 4965, "source_url": "https://github.com/Leonidas-from-XIV/node-xml2js/blob/054b79f2eab8754284fac4260dd356a87ef83e84/src/xml2js.coffee", "line_start": 51, "line_end": 71}168{"id": "Leonidas-from-XIV/node-xml2js:src/xml2js.coffee:2:js_to_coffee", "type": "js_to_coffee", "prompt": "Convert this JavaScript to CoffeeScript.\n```javascript\nvar old;\n\nif (stack.length > 0) {\n if (!(nodeName in s)) {\n s[nodeName] = obj;\n } else if (s[nodeName] instanceof Array) {\n s[nodeName].push(obj);\n } else {\n old = s[nodeName];\n s[nodeName] = [old];\n s[nodeName].push(obj);\n }\n} else {\n this.resultObject = obj;\n this.emit(\"end\", this.resultObject);\n}\n\nthis.saxParser.ontext = this.saxParser.oncdata = (text) => {\n var s;\n s = stack[stack.length - 1];\n if (s) {\n return s[\"#\"] += text;\n }\n};\n\n({\n parseString: (str) => {\n return this.saxParser.write(str.toString());\n }\n});\n```", "response": "if stack.length > 0\n if nodeName not of s\n s[nodeName] = obj\n else if s[nodeName] instanceof Array\n s[nodeName].push obj\n else\n old = s[nodeName]\n s[nodeName] = [old]\n s[nodeName].push obj\n else\n @resultObject = obj\n @emit \"end\", @resultObject\n\n @saxParser.ontext = @saxParser.oncdata = (text) =>\n s = stack[stack.length - 1]\n if s\n s[\"#\"] += text\n\n parseString: (str) =>\n @saxParser.write str.toString()", "source_lang": "JavaScript", "target_lang": "CoffeeScript", "repo": "Leonidas-from-XIV/node-xml2js", "path": "src/xml2js.coffee", "license": "MIT", "commit": "054b79f2eab8754284fac4260dd356a87ef83e84", "stars": 4965, "source_url": "https://github.com/Leonidas-from-XIV/node-xml2js/blob/054b79f2eab8754284fac4260dd356a87ef83e84/src/xml2js.coffee", "line_start": 51, "line_end": 71}169{"id": "Leonidas-from-XIV/node-xml2js:src/xml2js.coffee:2:completion", "type": "completion", "prompt": "if stack.length > 0\n if nodeName not of s\n s[nodeName] = obj\n else if s[nodeName] instanceof Array\n s[nodeName].push obj\n else\n old = s[nodeName]\n s[nodeName] = [old]\n s[nodeName].push obj\n else", "response": "@resultObject = obj\n @emit \"end\", @resultObject\n\n @saxParser.ontext = @saxParser.oncdata = (text) =>\n s = stack[stack.length - 1]\n if s\n s[\"#\"] += text\n\n parseString: (str) =>\n @saxParser.write str.toString()", "source_lang": "CoffeeScript", "target_lang": "CoffeeScript", "repo": "Leonidas-from-XIV/node-xml2js", "path": "src/xml2js.coffee", "license": "MIT", "commit": "054b79f2eab8754284fac4260dd356a87ef83e84", "stars": 4965, "source_url": "https://github.com/Leonidas-from-XIV/node-xml2js/blob/054b79f2eab8754284fac4260dd356a87ef83e84/src/xml2js.coffee", "line_start": 51, "line_end": 71}170{"id": "Leonidas-from-XIV/node-xml2js:src/xml2js.coffee:1:raw_corpus", "type": "raw_corpus", "prompt": "", "response": "sax = require(\"sax\")\nevents = require(\"events\")\n\nclass exports.Parser extends events.EventEmitter\n constructor: ->\n # make the sax parser\n @saxParser = sax.parser(true)\n # always use the '#' key, even if there are no subkeys\n @EXPLICIT_CHARKEY = false\n @resultObject = null\n stack = []\n\n @saxParser.onopentag = (node) =>\n obj = {}\n obj[\"#\"] = \"\"\n for own key of node.attributes\n if \"@\" not of obj\n obj[\"@\"] = {}\n obj[\"@\"][key] = node.attributes[key]\n\n # need a place to store the node name\n obj[\"#name\"] = node.name\n stack.push obj\n\n @saxParser.onclosetag = =>\n obj = stack.pop()\n nodeName = obj[\"#name\"]\n delete obj[\"#name\"]\n\n s = stack[stack.length - 1]\n # remove the '#' key altogether if it's blank\n if obj[\"#\"].match(/^\\s*$/)\n delete obj[\"#\"]\n else\n # turn 2 or more spaces into one space\n obj[\"#\"] = obj[\"#\"].replace(/\\s{2,}/g, \" \").trim()\n # also do away with '#' key altogether, if there's no subkeys\n # unless EXPLICIT_CHARKEY is set\n if Object.keys(obj).length == 1 and \"#\" of obj and not @EXPLICIT_CHARKEY\n obj = obj[\"#\"]\n\n if stack.length > 0\n if nodeName not of s\n s[nodeName] = obj\n else if s[nodeName] instanceof Array\n s[nodeName].push obj\n else\n old = s[nodeName]\n s[nodeName] = [old]\n s[nodeName].push obj", "source_lang": "", "target_lang": "CoffeeScript", "repo": "Leonidas-from-XIV/node-xml2js", "path": "src/xml2js.coffee", "license": "MIT", "commit": "47fb32a5ebcda47d16800179e4c17a46825be5a4", "stars": 4965, "source_url": "https://github.com/Leonidas-from-XIV/node-xml2js/blob/47fb32a5ebcda47d16800179e4c17a46825be5a4/src/xml2js.coffee", "line_start": 1, "line_end": 50}171{"id": "Leonidas-from-XIV/node-xml2js:src/xml2js.coffee:1:completion", "type": "completion", "prompt": "sax = require(\"sax\")\nevents = require(\"events\")\n\nclass exports.Parser extends events.EventEmitter\n constructor: ->\n # make the sax parser\n @saxParser = sax.parser(true)\n # always use the '#' key, even if there are no subkeys\n @EXPLICIT_CHARKEY = false\n @resultObject = null\n stack = []\n\n @saxParser.onopentag = (node) =>\n obj = {}\n obj[\"#\"] = \"\"\n for own key of node.attributes\n if \"@\" not of obj\n obj[\"@\"] = {}\n obj[\"@\"][key] = node.attributes[key]\n\n # need a place to store the node name\n obj[\"#name\"] = node.name\n stack.push obj\n\n @saxParser.onclosetag = =>", "response": "obj = stack.pop()\n nodeName = obj[\"#name\"]\n delete obj[\"#name\"]\n\n s = stack[stack.length - 1]\n # remove the '#' key altogether if it's blank\n if obj[\"#\"].match(/^\\s*$/)\n delete obj[\"#\"]\n else\n # turn 2 or more spaces into one space\n obj[\"#\"] = obj[\"#\"].replace(/\\s{2,}/g, \" \").trim()\n # also do away with '#' key altogether, if there's no subkeys\n # unless EXPLICIT_CHARKEY is set\n if Object.keys(obj).length == 1 and \"#\" of obj and not @EXPLICIT_CHARKEY\n obj = obj[\"#\"]\n\n if stack.length > 0\n if nodeName not of s\n s[nodeName] = obj\n else if s[nodeName] instanceof Array\n s[nodeName].push obj\n else\n old = s[nodeName]\n s[nodeName] = [old]\n s[nodeName].push obj", "source_lang": "CoffeeScript", "target_lang": "CoffeeScript", "repo": "Leonidas-from-XIV/node-xml2js", "path": "src/xml2js.coffee", "license": "MIT", "commit": "47fb32a5ebcda47d16800179e4c17a46825be5a4", "stars": 4965, "source_url": "https://github.com/Leonidas-from-XIV/node-xml2js/blob/47fb32a5ebcda47d16800179e4c17a46825be5a4/src/xml2js.coffee", "line_start": 1, "line_end": 50}172{"id": "Leonidas-from-XIV/node-xml2js:src/xml2js.coffee:2:raw_corpus", "type": "raw_corpus", "prompt": "", "response": "else\n @resultObject = obj\n @emit \"end\", @resultObject\n\n @saxParser.ontext = @saxParser.oncdata = (text) =>\n s = stack[stack.length - 1]\n if s\n s[\"#\"] += text\n\n parseString: (str) =>\n @saxParser.write str.toString()", "source_lang": "", "target_lang": "CoffeeScript", "repo": "Leonidas-from-XIV/node-xml2js", "path": "src/xml2js.coffee", "license": "MIT", "commit": "47fb32a5ebcda47d16800179e4c17a46825be5a4", "stars": 4965, "source_url": "https://github.com/Leonidas-from-XIV/node-xml2js/blob/47fb32a5ebcda47d16800179e4c17a46825be5a4/src/xml2js.coffee", "line_start": 51, "line_end": 61}173{"id": "Leonidas-from-XIV/node-xml2js:src/xml2js.coffee:2:completion", "type": "completion", "prompt": "else\n @resultObject = obj\n @emit \"end\", @resultObject\n\n @saxParser.ontext = @saxParser.oncdata = (text) =>", "response": "s = stack[stack.length - 1]\n if s\n s[\"#\"] += text\n\n parseString: (str) =>\n @saxParser.write str.toString()", "source_lang": "CoffeeScript", "target_lang": "CoffeeScript", "repo": "Leonidas-from-XIV/node-xml2js", "path": "src/xml2js.coffee", "license": "MIT", "commit": "47fb32a5ebcda47d16800179e4c17a46825be5a4", "stars": 4965, "source_url": "https://github.com/Leonidas-from-XIV/node-xml2js/blob/47fb32a5ebcda47d16800179e4c17a46825be5a4/src/xml2js.coffee", "line_start": 51, "line_end": 61}174{"id": "Leonidas-from-XIV/node-xml2js:src/xml2js.coffee:1:raw_corpus", "type": "raw_corpus", "prompt": "", "response": "sax = require(\"sax\")\nevents = require(\"events\")\n\nclass exports.Parser extends events.EventEmitter\n constructor: ->\n # make the sax parser\n @saxParser = sax.parser(true)\n # always use the '#' key, even if there are no subkeys\n @EXPLICIT_CHARKEY = false\n @resultObject = null\n stack = []\n\n @saxParser.onopentag = (node) =>\n obj = {}\n obj[\"#\"] = \"\"\n for own key of node.attributes\n if not (\"@\" of obj)\n obj[\"@\"] = {}\n obj[\"@\"][key] = node.attributes[key]\n\n # need a place to store the node name\n obj[\"#name\"] = node.name\n stack.push obj\n\n @saxParser.onclosetag = =>\n obj = stack.pop()\n nodeName = obj[\"#name\"]\n delete obj[\"#name\"]\n\n s = stack[stack.length - 1]\n # remove the '#' key altogether if it's blank\n if obj[\"#\"].match(/^\\s*$/)\n delete obj[\"#\"]\n else\n # turn 2 or more spaces into one space\n obj[\"#\"] = obj[\"#\"].replace(/\\s{2,}/g, \" \").trim()\n # also do away with '#' key altogether, if there's no subkeys\n # unless EXPLICIT_CHARKEY is set\n if Object.keys(obj).length == 1 and \"#\" of obj and not @EXPLICIT_CHARKEY\n obj = obj[\"#\"]\n\n if stack.length > 0\n if typeof s[nodeName] == \"undefined\"\n s[nodeName] = obj\n else if s[nodeName] instanceof Array\n s[nodeName].push obj\n else\n old = s[nodeName]\n s[nodeName] = [ old ]\n s[nodeName].push obj", "source_lang": "", "target_lang": "CoffeeScript", "repo": "Leonidas-from-XIV/node-xml2js", "path": "src/xml2js.coffee", "license": "MIT", "commit": "a130536310e0cbc940a6ea69cb91c7b5cc2f6c9c", "stars": 4965, "source_url": "https://github.com/Leonidas-from-XIV/node-xml2js/blob/a130536310e0cbc940a6ea69cb91c7b5cc2f6c9c/src/xml2js.coffee", "line_start": 1, "line_end": 50}175{"id": "Leonidas-from-XIV/node-xml2js:src/xml2js.coffee:1:completion", "type": "completion", "prompt": "sax = require(\"sax\")\nevents = require(\"events\")\n\nclass exports.Parser extends events.EventEmitter\n constructor: ->\n # make the sax parser\n @saxParser = sax.parser(true)\n # always use the '#' key, even if there are no subkeys\n @EXPLICIT_CHARKEY = false\n @resultObject = null\n stack = []\n\n @saxParser.onopentag = (node) =>\n obj = {}\n obj[\"#\"] = \"\"\n for own key of node.attributes\n if not (\"@\" of obj)\n obj[\"@\"] = {}\n obj[\"@\"][key] = node.attributes[key]\n\n # need a place to store the node name\n obj[\"#name\"] = node.name\n stack.push obj\n\n @saxParser.onclosetag = =>", "response": "obj = stack.pop()\n nodeName = obj[\"#name\"]\n delete obj[\"#name\"]\n\n s = stack[stack.length - 1]\n # remove the '#' key altogether if it's blank\n if obj[\"#\"].match(/^\\s*$/)\n delete obj[\"#\"]\n else\n # turn 2 or more spaces into one space\n obj[\"#\"] = obj[\"#\"].replace(/\\s{2,}/g, \" \").trim()\n # also do away with '#' key altogether, if there's no subkeys\n # unless EXPLICIT_CHARKEY is set\n if Object.keys(obj).length == 1 and \"#\" of obj and not @EXPLICIT_CHARKEY\n obj = obj[\"#\"]\n\n if stack.length > 0\n if typeof s[nodeName] == \"undefined\"\n s[nodeName] = obj\n else if s[nodeName] instanceof Array\n s[nodeName].push obj\n else\n old = s[nodeName]\n s[nodeName] = [ old ]\n s[nodeName].push obj", "source_lang": "CoffeeScript", "target_lang": "CoffeeScript", "repo": "Leonidas-from-XIV/node-xml2js", "path": "src/xml2js.coffee", "license": "MIT", "commit": "a130536310e0cbc940a6ea69cb91c7b5cc2f6c9c", "stars": 4965, "source_url": "https://github.com/Leonidas-from-XIV/node-xml2js/blob/a130536310e0cbc940a6ea69cb91c7b5cc2f6c9c/src/xml2js.coffee", "line_start": 1, "line_end": 50}176{"id": "Leonidas-from-XIV/node-xml2js:src/xml2js.coffee:2:raw_corpus", "type": "raw_corpus", "prompt": "", "response": "else\n @resultObject = obj\n @emit \"end\", @resultObject\n\n @saxParser.ontext = @saxParser.oncdata = (t) ->\n s = stack[stack.length - 1]\n if s\n s[\"#\"] += t\n\n parseString: (str) =>\n @saxParser.write str.toString()", "source_lang": "", "target_lang": "CoffeeScript", "repo": "Leonidas-from-XIV/node-xml2js", "path": "src/xml2js.coffee", "license": "MIT", "commit": "a130536310e0cbc940a6ea69cb91c7b5cc2f6c9c", "stars": 4965, "source_url": "https://github.com/Leonidas-from-XIV/node-xml2js/blob/a130536310e0cbc940a6ea69cb91c7b5cc2f6c9c/src/xml2js.coffee", "line_start": 51, "line_end": 61}177{"id": "Leonidas-from-XIV/node-xml2js:src/xml2js.coffee:2:completion", "type": "completion", "prompt": "else\n @resultObject = obj\n @emit \"end\", @resultObject\n\n @saxParser.ontext = @saxParser.oncdata = (t) ->", "response": "s = stack[stack.length - 1]\n if s\n s[\"#\"] += t\n\n parseString: (str) =>\n @saxParser.write str.toString()", "source_lang": "CoffeeScript", "target_lang": "CoffeeScript", "repo": "Leonidas-from-XIV/node-xml2js", "path": "src/xml2js.coffee", "license": "MIT", "commit": "a130536310e0cbc940a6ea69cb91c7b5cc2f6c9c", "stars": 4965, "source_url": "https://github.com/Leonidas-from-XIV/node-xml2js/blob/a130536310e0cbc940a6ea69cb91c7b5cc2f6c9c/src/xml2js.coffee", "line_start": 51, "line_end": 61}178{"id": "Leonidas-from-XIV/node-xml2js:src/xml2js.coffee:1:raw_corpus", "type": "raw_corpus", "prompt": "", "response": "sax = require(\"sax\")\nsys = require(\"sys\")\nevents = require(\"events\")\n\nParser = ->\n that = this\n # make the sax parser\n @saxParser = sax.parser(true)\n # always use the '#' key, even if there are no subkeys\n @EXPLICIT_CHARKEY = false\n @resultObject = null\n stack = []\n @saxParser.onopentag = (node) ->\n obj = {}\n obj[\"#\"] = \"\"\n for own key of node.attributes\n if not (\"@\" of obj)\n obj[\"@\"] = {}\n obj[\"@\"][key] = node.attributes[key]\n\n # need a place to store the node name\n obj[\"#name\"] = node.name\n stack.push obj\n\n @saxParser.onclosetag = ->\n obj = stack.pop()\n nodeName = obj[\"#name\"]\n delete obj[\"#name\"]\n\n s = stack[stack.length - 1]\n # remove the '#' key altogether if it's blank\n if obj[\"#\"].match(/^\\s*$/)\n delete obj[\"#\"]\n else\n # turn 2 or more spaces into one space\n obj[\"#\"] = obj[\"#\"].replace(/\\s{2,}/g, \" \").trim()\n # also do away with '#' key altogether, if there's no subkeys\n # unless EXPLICIT_CHARKEY is set\n if Object.keys(obj).length == 1 and \"#\" of obj and not that.EXPLICIT_CHARKEY\n obj = obj[\"#\"]\n\n if stack.length > 0\n if typeof s[nodeName] == \"undefined\"\n s[nodeName] = obj\n else if s[nodeName] instanceof Array\n s[nodeName].push obj\n else\n old = s[nodeName]\n s[nodeName] = [ old ]\n s[nodeName].push obj", "source_lang": "", "target_lang": "CoffeeScript", "repo": "Leonidas-from-XIV/node-xml2js", "path": "src/xml2js.coffee", "license": "MIT", "commit": "69e74053987ad46a175c8b2f127ac246c374bbd1", "stars": 4965, "source_url": "https://github.com/Leonidas-from-XIV/node-xml2js/blob/69e74053987ad46a175c8b2f127ac246c374bbd1/src/xml2js.coffee", "line_start": 1, "line_end": 50}179{"id": "Leonidas-from-XIV/node-xml2js:src/xml2js.coffee:1:coffee_to_js", "type": "coffee_to_js", "prompt": "Convert this CoffeeScript to JavaScript.\n```coffeescript\nsax = require(\"sax\")\nsys = require(\"sys\")\nevents = require(\"events\")\n\nParser = ->\n that = this\n # make the sax parser\n @saxParser = sax.parser(true)\n # always use the '#' key, even if there are no subkeys\n @EXPLICIT_CHARKEY = false\n @resultObject = null\n stack = []\n @saxParser.onopentag = (node) ->\n obj = {}\n obj[\"#\"] = \"\"\n for own key of node.attributes\n if not (\"@\" of obj)\n obj[\"@\"] = {}\n obj[\"@\"][key] = node.attributes[key]\n\n # need a place to store the node name\n obj[\"#name\"] = node.name\n stack.push obj\n\n @saxParser.onclosetag = ->\n obj = stack.pop()\n nodeName = obj[\"#name\"]\n delete obj[\"#name\"]\n\n s = stack[stack.length - 1]\n # remove the '#' key altogether if it's blank\n if obj[\"#\"].match(/^\\s*$/)\n delete obj[\"#\"]\n else\n # turn 2 or more spaces into one space\n obj[\"#\"] = obj[\"#\"].replace(/\\s{2,}/g, \" \").trim()\n # also do away with '#' key altogether, if there's no subkeys\n # unless EXPLICIT_CHARKEY is set\n if Object.keys(obj).length == 1 and \"#\" of obj and not that.EXPLICIT_CHARKEY\n obj = obj[\"#\"]\n\n if stack.length > 0\n if typeof s[nodeName] == \"undefined\"\n s[nodeName] = obj\n else if s[nodeName] instanceof Array\n s[nodeName].push obj\n else\n old = s[nodeName]\n s[nodeName] = [ old ]\n s[nodeName].push obj\n```", "response": "var Parser, events, sax, sys,\n hasProp = {}.hasOwnProperty;\n\nsax = require(\"sax\");\n\nsys = require(\"sys\");\n\nevents = require(\"events\");\n\nParser = function() {\n var stack, that;\n that = this;\n // make the sax parser\n this.saxParser = sax.parser(true);\n // always use the '#' key, even if there are no subkeys\n this.EXPLICIT_CHARKEY = false;\n this.resultObject = null;\n stack = [];\n this.saxParser.onopentag = function(node) {\n var key, obj, ref;\n obj = {};\n obj[\"#\"] = \"\";\n ref = node.attributes;\n for (key in ref) {\n if (!hasProp.call(ref, key)) continue;\n if (!(\"@\" in obj)) {\n obj[\"@\"] = {};\n }\n obj[\"@\"][key] = node.attributes[key];\n }\n // need a place to store the node name\n obj[\"#name\"] = node.name;\n return stack.push(obj);\n };\n return this.saxParser.onclosetag = function() {\n var nodeName, obj, old, s;\n obj = stack.pop();\n nodeName = obj[\"#name\"];\n delete obj[\"#name\"];\n s = stack[stack.length - 1];\n // remove the '#' key altogether if it's blank\n if (obj[\"#\"].match(/^\\s*$/)) {\n delete obj[\"#\"];\n } else {\n // turn 2 or more spaces into one space\n obj[\"#\"] = obj[\"#\"].replace(/\\s{2,}/g, \" \").trim();\n // also do away with '#' key altogether, if there's no subkeys\n // unless EXPLICIT_CHARKEY is set\n if (Object.keys(obj).length === 1 && \"#\" in obj && !that.EXPLICIT_CHARKEY) {\n obj = obj[\"#\"];\n }\n }\n if (stack.length > 0) {\n if (typeof s[nodeName] === \"undefined\") {\n return s[nodeName] = obj;\n } else if (s[nodeName] instanceof Array) {\n return s[nodeName].push(obj);\n } else {\n old = s[nodeName];\n s[nodeName] = [old];\n return s[nodeName].push(obj);\n }\n }\n };\n};", "source_lang": "CoffeeScript", "target_lang": "JavaScript", "repo": "Leonidas-from-XIV/node-xml2js", "path": "src/xml2js.coffee", "license": "MIT", "commit": "69e74053987ad46a175c8b2f127ac246c374bbd1", "stars": 4965, "source_url": "https://github.com/Leonidas-from-XIV/node-xml2js/blob/69e74053987ad46a175c8b2f127ac246c374bbd1/src/xml2js.coffee", "line_start": 1, "line_end": 50}180{"id": "Leonidas-from-XIV/node-xml2js:src/xml2js.coffee:1:js_to_coffee", "type": "js_to_coffee", "prompt": "Convert this JavaScript to CoffeeScript.\n```javascript\nvar Parser, events, sax, sys,\n hasProp = {}.hasOwnProperty;\n\nsax = require(\"sax\");\n\nsys = require(\"sys\");\n\nevents = require(\"events\");\n\nParser = function() {\n var stack, that;\n that = this;\n // make the sax parser\n this.saxParser = sax.parser(true);\n // always use the '#' key, even if there are no subkeys\n this.EXPLICIT_CHARKEY = false;\n this.resultObject = null;\n stack = [];\n this.saxParser.onopentag = function(node) {\n var key, obj, ref;\n obj = {};\n obj[\"#\"] = \"\";\n ref = node.attributes;\n for (key in ref) {\n if (!hasProp.call(ref, key)) continue;\n if (!(\"@\" in obj)) {\n obj[\"@\"] = {};\n }\n obj[\"@\"][key] = node.attributes[key];\n }\n // need a place to store the node name\n obj[\"#name\"] = node.name;\n return stack.push(obj);\n };\n return this.saxParser.onclosetag = function() {\n var nodeName, obj, old, s;\n obj = stack.pop();\n nodeName = obj[\"#name\"];\n delete obj[\"#name\"];\n s = stack[stack.length - 1];\n // remove the '#' key altogether if it's blank\n if (obj[\"#\"].match(/^\\s*$/)) {\n delete obj[\"#\"];\n } else {\n // turn 2 or more spaces into one space\n obj[\"#\"] = obj[\"#\"].replace(/\\s{2,}/g, \" \").trim();\n // also do away with '#' key altogether, if there's no subkeys\n // unless EXPLICIT_CHARKEY is set\n if (Object.keys(obj).length === 1 && \"#\" in obj && !that.EXPLICIT_CHARKEY) {\n obj = obj[\"#\"];\n }\n }\n if (stack.length > 0) {\n if (typeof s[nodeName] === \"undefined\") {\n return s[nodeName] = obj;\n } else if (s[nodeName] instanceof Array) {\n return s[nodeName].push(obj);\n } else {\n old = s[nodeName];\n s[nodeName] = [old];\n return s[nodeName].push(obj);\n }\n }\n };\n};\n```", "response": "sax = require(\"sax\")\nsys = require(\"sys\")\nevents = require(\"events\")\n\nParser = ->\n that = this\n # make the sax parser\n @saxParser = sax.parser(true)\n # always use the '#' key, even if there are no subkeys\n @EXPLICIT_CHARKEY = false\n @resultObject = null\n stack = []\n @saxParser.onopentag = (node) ->\n obj = {}\n obj[\"#\"] = \"\"\n for own key of node.attributes\n if not (\"@\" of obj)\n obj[\"@\"] = {}\n obj[\"@\"][key] = node.attributes[key]\n\n # need a place to store the node name\n obj[\"#name\"] = node.name\n stack.push obj\n\n @saxParser.onclosetag = ->\n obj = stack.pop()\n nodeName = obj[\"#name\"]\n delete obj[\"#name\"]\n\n s = stack[stack.length - 1]\n # remove the '#' key altogether if it's blank\n if obj[\"#\"].match(/^\\s*$/)\n delete obj[\"#\"]\n else\n # turn 2 or more spaces into one space\n obj[\"#\"] = obj[\"#\"].replace(/\\s{2,}/g, \" \").trim()\n # also do away with '#' key altogether, if there's no subkeys\n # unless EXPLICIT_CHARKEY is set\n if Object.keys(obj).length == 1 and \"#\" of obj and not that.EXPLICIT_CHARKEY\n obj = obj[\"#\"]\n\n if stack.length > 0\n if typeof s[nodeName] == \"undefined\"\n s[nodeName] = obj\n else if s[nodeName] instanceof Array\n s[nodeName].push obj\n else\n old = s[nodeName]\n s[nodeName] = [ old ]\n s[nodeName].push obj", "source_lang": "JavaScript", "target_lang": "CoffeeScript", "repo": "Leonidas-from-XIV/node-xml2js", "path": "src/xml2js.coffee", "license": "MIT", "commit": "69e74053987ad46a175c8b2f127ac246c374bbd1", "stars": 4965, "source_url": "https://github.com/Leonidas-from-XIV/node-xml2js/blob/69e74053987ad46a175c8b2f127ac246c374bbd1/src/xml2js.coffee", "line_start": 1, "line_end": 50}181{"id": "Leonidas-from-XIV/node-xml2js:src/xml2js.coffee:1:completion", "type": "completion", "prompt": "sax = require(\"sax\")\nsys = require(\"sys\")\nevents = require(\"events\")\n\nParser = ->\n that = this\n # make the sax parser\n @saxParser = sax.parser(true)\n # always use the '#' key, even if there are no subkeys\n @EXPLICIT_CHARKEY = false\n @resultObject = null\n stack = []\n @saxParser.onopentag = (node) ->\n obj = {}\n obj[\"#\"] = \"\"\n for own key of node.attributes\n if not (\"@\" of obj)\n obj[\"@\"] = {}\n obj[\"@\"][key] = node.attributes[key]\n\n # need a place to store the node name\n obj[\"#name\"] = node.name\n stack.push obj\n\n @saxParser.onclosetag = ->", "response": "obj = stack.pop()\n nodeName = obj[\"#name\"]\n delete obj[\"#name\"]\n\n s = stack[stack.length - 1]\n # remove the '#' key altogether if it's blank\n if obj[\"#\"].match(/^\\s*$/)\n delete obj[\"#\"]\n else\n # turn 2 or more spaces into one space\n obj[\"#\"] = obj[\"#\"].replace(/\\s{2,}/g, \" \").trim()\n # also do away with '#' key altogether, if there's no subkeys\n # unless EXPLICIT_CHARKEY is set\n if Object.keys(obj).length == 1 and \"#\" of obj and not that.EXPLICIT_CHARKEY\n obj = obj[\"#\"]\n\n if stack.length > 0\n if typeof s[nodeName] == \"undefined\"\n s[nodeName] = obj\n else if s[nodeName] instanceof Array\n s[nodeName].push obj\n else\n old = s[nodeName]\n s[nodeName] = [ old ]\n s[nodeName].push obj", "source_lang": "CoffeeScript", "target_lang": "CoffeeScript", "repo": "Leonidas-from-XIV/node-xml2js", "path": "src/xml2js.coffee", "license": "MIT", "commit": "69e74053987ad46a175c8b2f127ac246c374bbd1", "stars": 4965, "source_url": "https://github.com/Leonidas-from-XIV/node-xml2js/blob/69e74053987ad46a175c8b2f127ac246c374bbd1/src/xml2js.coffee", "line_start": 1, "line_end": 50}182{"id": "Leonidas-from-XIV/node-xml2js:src/xml2js.coffee:2:raw_corpus", "type": "raw_corpus", "prompt": "", "response": "else\n that.resultObject = obj\n that.emit \"end\", that.resultObject\n\n @saxParser.ontext = @saxParser.oncdata = (t) ->\n s = stack[stack.length - 1]\n if s\n s[\"#\"] += t\n\n undefined\n\nsys.inherits Parser, events.EventEmitter\nParser::parseString = (str) ->\n @saxParser.write str.toString()\n\nexports.Parser = Parser", "source_lang": "", "target_lang": "CoffeeScript", "repo": "Leonidas-from-XIV/node-xml2js", "path": "src/xml2js.coffee", "license": "MIT", "commit": "69e74053987ad46a175c8b2f127ac246c374bbd1", "stars": 4965, "source_url": "https://github.com/Leonidas-from-XIV/node-xml2js/blob/69e74053987ad46a175c8b2f127ac246c374bbd1/src/xml2js.coffee", "line_start": 51, "line_end": 66}183{"id": "Leonidas-from-XIV/node-xml2js:src/xml2js.coffee:2:completion", "type": "completion", "prompt": "else\n that.resultObject = obj\n that.emit \"end\", that.resultObject\n\n @saxParser.ontext = @saxParser.oncdata = (t) ->\n s = stack[stack.length - 1]\n if s\n s[\"#\"] += t", "response": "undefined\n\nsys.inherits Parser, events.EventEmitter\nParser::parseString = (str) ->\n @saxParser.write str.toString()\n\nexports.Parser = Parser", "source_lang": "CoffeeScript", "target_lang": "CoffeeScript", "repo": "Leonidas-from-XIV/node-xml2js", "path": "src/xml2js.coffee", "license": "MIT", "commit": "69e74053987ad46a175c8b2f127ac246c374bbd1", "stars": 4965, "source_url": "https://github.com/Leonidas-from-XIV/node-xml2js/blob/69e74053987ad46a175c8b2f127ac246c374bbd1/src/xml2js.coffee", "line_start": 51, "line_end": 66}184{"id": "Leonidas-from-XIV/node-xml2js:src/xml2js.coffee:1:raw_corpus", "type": "raw_corpus", "prompt": "", "response": "sax = require(\"sax\")\nsys = require(\"sys\")\nevents = require(\"events\")\n\nParser = ->\n that = this\n @saxParser = sax.parser(true)\n @EXPLICIT_CHARKEY = false\n @resultObject = null\n stack = []\n @saxParser.onopentag = (node) ->\n obj = {}\n obj[\"#\"] = \"\"\n for own key of node.attributes\n if not (\"@\" of obj)\n obj[\"@\"] = {}\n obj[\"@\"][key] = node.attributes[key]\n\n obj[\"#name\"] = node.name\n stack.push obj\n\n @saxParser.onclosetag = ->\n obj = stack.pop()\n nodeName = obj[\"#name\"]\n delete obj[\"#name\"]\n\n s = stack[stack.length - 1]\n if obj[\"#\"].match(/^\\s*$/)\n delete obj[\"#\"]\n else\n obj[\"#\"] = obj[\"#\"].replace(/\\s{2,}/g, \" \").trim()\n if Object.keys(obj).length == 1 and \"#\" in obj and not (that.EXPLICIT_CHARKEY)\n obj = obj[\"#\"]\n if stack.length > 0\n if typeof s[nodeName] == \"undefined\"\n s[nodeName] = obj\n else if s[nodeName] instanceof Array\n s[nodeName].push obj\n else\n old = s[nodeName]\n s[nodeName] = [ old ]\n s[nodeName].push obj\n else\n that.resultObject = obj\n that.emit \"end\", that.resultObject\n\n @saxParser.ontext = @saxParser.oncdata = (t) ->\n s = stack[stack.length - 1]\n if s\n s[\"#\"] += t", "source_lang": "", "target_lang": "CoffeeScript", "repo": "Leonidas-from-XIV/node-xml2js", "path": "src/xml2js.coffee", "license": "MIT", "commit": "72e8fdc832471b4169c7f3982533e4439fad9b05", "stars": 4965, "source_url": "https://github.com/Leonidas-from-XIV/node-xml2js/blob/72e8fdc832471b4169c7f3982533e4439fad9b05/src/xml2js.coffee", "line_start": 1, "line_end": 50}185{"id": "Leonidas-from-XIV/node-xml2js:src/xml2js.coffee:1:coffee_to_js", "type": "coffee_to_js", "prompt": "Convert this CoffeeScript to JavaScript.\n```coffeescript\nsax = require(\"sax\")\nsys = require(\"sys\")\nevents = require(\"events\")\n\nParser = ->\n that = this\n @saxParser = sax.parser(true)\n @EXPLICIT_CHARKEY = false\n @resultObject = null\n stack = []\n @saxParser.onopentag = (node) ->\n obj = {}\n obj[\"#\"] = \"\"\n for own key of node.attributes\n if not (\"@\" of obj)\n obj[\"@\"] = {}\n obj[\"@\"][key] = node.attributes[key]\n\n obj[\"#name\"] = node.name\n stack.push obj\n\n @saxParser.onclosetag = ->\n obj = stack.pop()\n nodeName = obj[\"#name\"]\n delete obj[\"#name\"]\n\n s = stack[stack.length - 1]\n if obj[\"#\"].match(/^\\s*$/)\n delete obj[\"#\"]\n else\n obj[\"#\"] = obj[\"#\"].replace(/\\s{2,}/g, \" \").trim()\n if Object.keys(obj).length == 1 and \"#\" in obj and not (that.EXPLICIT_CHARKEY)\n obj = obj[\"#\"]\n if stack.length > 0\n if typeof s[nodeName] == \"undefined\"\n s[nodeName] = obj\n else if s[nodeName] instanceof Array\n s[nodeName].push obj\n else\n old = s[nodeName]\n s[nodeName] = [ old ]\n s[nodeName].push obj\n else\n that.resultObject = obj\n that.emit \"end\", that.resultObject\n\n @saxParser.ontext = @saxParser.oncdata = (t) ->\n s = stack[stack.length - 1]\n if s\n s[\"#\"] += t\n```", "response": "var Parser, events, sax, sys,\n hasProp = {}.hasOwnProperty,\n indexOf = [].indexOf;\n\nsax = require(\"sax\");\n\nsys = require(\"sys\");\n\nevents = require(\"events\");\n\nParser = function() {\n var stack, that;\n that = this;\n this.saxParser = sax.parser(true);\n this.EXPLICIT_CHARKEY = false;\n this.resultObject = null;\n stack = [];\n this.saxParser.onopentag = function(node) {\n var key, obj, ref;\n obj = {};\n obj[\"#\"] = \"\";\n ref = node.attributes;\n for (key in ref) {\n if (!hasProp.call(ref, key)) continue;\n if (!(\"@\" in obj)) {\n obj[\"@\"] = {};\n }\n obj[\"@\"][key] = node.attributes[key];\n }\n obj[\"#name\"] = node.name;\n return stack.push(obj);\n };\n this.saxParser.onclosetag = function() {\n var nodeName, obj, old, s;\n obj = stack.pop();\n nodeName = obj[\"#name\"];\n delete obj[\"#name\"];\n s = stack[stack.length - 1];\n if (obj[\"#\"].match(/^\\s*$/)) {\n delete obj[\"#\"];\n } else {\n obj[\"#\"] = obj[\"#\"].replace(/\\s{2,}/g, \" \").trim();\n if (Object.keys(obj).length === 1 && indexOf.call(obj, \"#\") >= 0 && !that.EXPLICIT_CHARKEY) {\n obj = obj[\"#\"];\n }\n }\n if (stack.length > 0) {\n if (typeof s[nodeName] === \"undefined\") {\n return s[nodeName] = obj;\n } else if (s[nodeName] instanceof Array) {\n return s[nodeName].push(obj);\n } else {\n old = s[nodeName];\n s[nodeName] = [old];\n return s[nodeName].push(obj);\n }\n } else {\n that.resultObject = obj;\n return that.emit(\"end\", that.resultObject);\n }\n };\n return this.saxParser.ontext = this.saxParser.oncdata = function(t) {\n var s;\n s = stack[stack.length - 1];\n if (s) {\n return s[\"#\"] += t;\n }\n };\n};", "source_lang": "CoffeeScript", "target_lang": "JavaScript", "repo": "Leonidas-from-XIV/node-xml2js", "path": "src/xml2js.coffee", "license": "MIT", "commit": "72e8fdc832471b4169c7f3982533e4439fad9b05", "stars": 4965, "source_url": "https://github.com/Leonidas-from-XIV/node-xml2js/blob/72e8fdc832471b4169c7f3982533e4439fad9b05/src/xml2js.coffee", "line_start": 1, "line_end": 50}186{"id": "Leonidas-from-XIV/node-xml2js:src/xml2js.coffee:1:js_to_coffee", "type": "js_to_coffee", "prompt": "Convert this JavaScript to CoffeeScript.\n```javascript\nvar Parser, events, sax, sys,\n hasProp = {}.hasOwnProperty,\n indexOf = [].indexOf;\n\nsax = require(\"sax\");\n\nsys = require(\"sys\");\n\nevents = require(\"events\");\n\nParser = function() {\n var stack, that;\n that = this;\n this.saxParser = sax.parser(true);\n this.EXPLICIT_CHARKEY = false;\n this.resultObject = null;\n stack = [];\n this.saxParser.onopentag = function(node) {\n var key, obj, ref;\n obj = {};\n obj[\"#\"] = \"\";\n ref = node.attributes;\n for (key in ref) {\n if (!hasProp.call(ref, key)) continue;\n if (!(\"@\" in obj)) {\n obj[\"@\"] = {};\n }\n obj[\"@\"][key] = node.attributes[key];\n }\n obj[\"#name\"] = node.name;\n return stack.push(obj);\n };\n this.saxParser.onclosetag = function() {\n var nodeName, obj, old, s;\n obj = stack.pop();\n nodeName = obj[\"#name\"];\n delete obj[\"#name\"];\n s = stack[stack.length - 1];\n if (obj[\"#\"].match(/^\\s*$/)) {\n delete obj[\"#\"];\n } else {\n obj[\"#\"] = obj[\"#\"].replace(/\\s{2,}/g, \" \").trim();\n if (Object.keys(obj).length === 1 && indexOf.call(obj, \"#\") >= 0 && !that.EXPLICIT_CHARKEY) {\n obj = obj[\"#\"];\n }\n }\n if (stack.length > 0) {\n if (typeof s[nodeName] === \"undefined\") {\n return s[nodeName] = obj;\n } else if (s[nodeName] instanceof Array) {\n return s[nodeName].push(obj);\n } else {\n old = s[nodeName];\n s[nodeName] = [old];\n return s[nodeName].push(obj);\n }\n } else {\n that.resultObject = obj;\n return that.emit(\"end\", that.resultObject);\n }\n };\n return this.saxParser.ontext = this.saxParser.oncdata = function(t) {\n var s;\n s = stack[stack.length - 1];\n if (s) {\n return s[\"#\"] += t;\n }\n };\n};\n```", "response": "sax = require(\"sax\")\nsys = require(\"sys\")\nevents = require(\"events\")\n\nParser = ->\n that = this\n @saxParser = sax.parser(true)\n @EXPLICIT_CHARKEY = false\n @resultObject = null\n stack = []\n @saxParser.onopentag = (node) ->\n obj = {}\n obj[\"#\"] = \"\"\n for own key of node.attributes\n if not (\"@\" of obj)\n obj[\"@\"] = {}\n obj[\"@\"][key] = node.attributes[key]\n\n obj[\"#name\"] = node.name\n stack.push obj\n\n @saxParser.onclosetag = ->\n obj = stack.pop()\n nodeName = obj[\"#name\"]\n delete obj[\"#name\"]\n\n s = stack[stack.length - 1]\n if obj[\"#\"].match(/^\\s*$/)\n delete obj[\"#\"]\n else\n obj[\"#\"] = obj[\"#\"].replace(/\\s{2,}/g, \" \").trim()\n if Object.keys(obj).length == 1 and \"#\" in obj and not (that.EXPLICIT_CHARKEY)\n obj = obj[\"#\"]\n if stack.length > 0\n if typeof s[nodeName] == \"undefined\"\n s[nodeName] = obj\n else if s[nodeName] instanceof Array\n s[nodeName].push obj\n else\n old = s[nodeName]\n s[nodeName] = [ old ]\n s[nodeName].push obj\n else\n that.resultObject = obj\n that.emit \"end\", that.resultObject\n\n @saxParser.ontext = @saxParser.oncdata = (t) ->\n s = stack[stack.length - 1]\n if s\n s[\"#\"] += t", "source_lang": "JavaScript", "target_lang": "CoffeeScript", "repo": "Leonidas-from-XIV/node-xml2js", "path": "src/xml2js.coffee", "license": "MIT", "commit": "72e8fdc832471b4169c7f3982533e4439fad9b05", "stars": 4965, "source_url": "https://github.com/Leonidas-from-XIV/node-xml2js/blob/72e8fdc832471b4169c7f3982533e4439fad9b05/src/xml2js.coffee", "line_start": 1, "line_end": 50}187{"id": "Leonidas-from-XIV/node-xml2js:src/xml2js.coffee:1:completion", "type": "completion", "prompt": "sax = require(\"sax\")\nsys = require(\"sys\")\nevents = require(\"events\")\n\nParser = ->\n that = this\n @saxParser = sax.parser(true)\n @EXPLICIT_CHARKEY = false\n @resultObject = null\n stack = []\n @saxParser.onopentag = (node) ->\n obj = {}\n obj[\"#\"] = \"\"\n for own key of node.attributes\n if not (\"@\" of obj)\n obj[\"@\"] = {}\n obj[\"@\"][key] = node.attributes[key]\n\n obj[\"#name\"] = node.name\n stack.push obj\n\n @saxParser.onclosetag = ->\n obj = stack.pop()\n nodeName = obj[\"#name\"]\n delete obj[\"#name\"]", "response": "s = stack[stack.length - 1]\n if obj[\"#\"].match(/^\\s*$/)\n delete obj[\"#\"]\n else\n obj[\"#\"] = obj[\"#\"].replace(/\\s{2,}/g, \" \").trim()\n if Object.keys(obj).length == 1 and \"#\" in obj and not (that.EXPLICIT_CHARKEY)\n obj = obj[\"#\"]\n if stack.length > 0\n if typeof s[nodeName] == \"undefined\"\n s[nodeName] = obj\n else if s[nodeName] instanceof Array\n s[nodeName].push obj\n else\n old = s[nodeName]\n s[nodeName] = [ old ]\n s[nodeName].push obj\n else\n that.resultObject = obj\n that.emit \"end\", that.resultObject\n\n @saxParser.ontext = @saxParser.oncdata = (t) ->\n s = stack[stack.length - 1]\n if s\n s[\"#\"] += t", "source_lang": "CoffeeScript", "target_lang": "CoffeeScript", "repo": "Leonidas-from-XIV/node-xml2js", "path": "src/xml2js.coffee", "license": "MIT", "commit": "72e8fdc832471b4169c7f3982533e4439fad9b05", "stars": 4965, "source_url": "https://github.com/Leonidas-from-XIV/node-xml2js/blob/72e8fdc832471b4169c7f3982533e4439fad9b05/src/xml2js.coffee", "line_start": 1, "line_end": 50}188{"id": "Leonidas-from-XIV/node-xml2js:src/xml2js.coffee:2:raw_corpus", "type": "raw_corpus", "prompt": "", "response": "undefined\n\nsys.inherits Parser, events.EventEmitter\nParser::parseString = (str) ->\n @saxParser.write str.toString()\n\nexports.Parser = Parser", "source_lang": "", "target_lang": "CoffeeScript", "repo": "Leonidas-from-XIV/node-xml2js", "path": "src/xml2js.coffee", "license": "MIT", "commit": "72e8fdc832471b4169c7f3982533e4439fad9b05", "stars": 4965, "source_url": "https://github.com/Leonidas-from-XIV/node-xml2js/blob/72e8fdc832471b4169c7f3982533e4439fad9b05/src/xml2js.coffee", "line_start": 51, "line_end": 58}189{"id": "Leonidas-from-XIV/node-xml2js:src/xml2js.coffee:2:coffee_to_js", "type": "coffee_to_js", "prompt": "Convert this CoffeeScript to JavaScript.\n```coffeescript\nundefined\n\nsys.inherits Parser, events.EventEmitter\nParser::parseString = (str) ->\n @saxParser.write str.toString()\n\nexports.Parser = Parser\n```", "response": "void 0;\nsys.inherits(Parser, events.EventEmitter);\n\nParser.prototype.parseString = function(str) {\n return this.saxParser.write(str.toString());\n};\n\nexports.Parser = Parser;", "source_lang": "CoffeeScript", "target_lang": "JavaScript", "repo": "Leonidas-from-XIV/node-xml2js", "path": "src/xml2js.coffee", "license": "MIT", "commit": "72e8fdc832471b4169c7f3982533e4439fad9b05", "stars": 4965, "source_url": "https://github.com/Leonidas-from-XIV/node-xml2js/blob/72e8fdc832471b4169c7f3982533e4439fad9b05/src/xml2js.coffee", "line_start": 51, "line_end": 58}190{"id": "Leonidas-from-XIV/node-xml2js:src/xml2js.coffee:2:js_to_coffee", "type": "js_to_coffee", "prompt": "Convert this JavaScript to CoffeeScript.\n```javascript\nvoid 0;\nsys.inherits(Parser, events.EventEmitter);\n\nParser.prototype.parseString = function(str) {\n return this.saxParser.write(str.toString());\n};\n\nexports.Parser = Parser;\n```", "response": "undefined\n\nsys.inherits Parser, events.EventEmitter\nParser::parseString = (str) ->\n @saxParser.write str.toString()\n\nexports.Parser = Parser", "source_lang": "JavaScript", "target_lang": "CoffeeScript", "repo": "Leonidas-from-XIV/node-xml2js", "path": "src/xml2js.coffee", "license": "MIT", "commit": "72e8fdc832471b4169c7f3982533e4439fad9b05", "stars": 4965, "source_url": "https://github.com/Leonidas-from-XIV/node-xml2js/blob/72e8fdc832471b4169c7f3982533e4439fad9b05/src/xml2js.coffee", "line_start": 51, "line_end": 58}191{"id": "Leonidas-from-XIV/node-xml2js:src/xml2js.coffee:2:completion", "type": "completion", "prompt": "undefined\n\nsys.inherits Parser, events.EventEmitter", "response": "Parser::parseString = (str) ->\n @saxParser.write str.toString()\n\nexports.Parser = Parser", "source_lang": "CoffeeScript", "target_lang": "CoffeeScript", "repo": "Leonidas-from-XIV/node-xml2js", "path": "src/xml2js.coffee", "license": "MIT", "commit": "72e8fdc832471b4169c7f3982533e4439fad9b05", "stars": 4965, "source_url": "https://github.com/Leonidas-from-XIV/node-xml2js/blob/72e8fdc832471b4169c7f3982533e4439fad9b05/src/xml2js.coffee", "line_start": 51, "line_end": 58}192{"id": "Leonidas-from-XIV/node-xml2js:src/xml2js.coffee:1:raw_corpus", "type": "raw_corpus", "prompt": "", "response": "sax = require(\"sax\")\nsys = require(\"sys\")\nevents = require(\"events\")\n\nParser = ->\n that = this\n @saxParser = sax.parser(true)\n @EXPLICIT_CHARKEY = false\n @resultObject = null\n stack = []\n @saxParser.onopentag = (node) ->\n obj = {}\n obj[\"#\"] = \"\"\n for own key of node.attributes\n if typeof obj[\"@\"] == \"undefined\"\n obj[\"@\"] = {}\n obj[\"@\"][key] = node.attributes[key]\n obj[\"#name\"] = node.name\n stack.push obj\n\n @saxParser.onclosetag = ->\n obj = stack.pop()\n nodeName = obj[\"#name\"]\n delete obj[\"#name\"]\n\n s = stack[stack.length - 1]\n if obj[\"#\"].match(/^\\s*$/)\n delete obj[\"#\"]\n else\n obj[\"#\"] = obj[\"#\"].replace(/\\s{2,}/g, \" \").trim()\n if Object.keys(obj).length == 1 and \"#\" in obj and not (that.EXPLICIT_CHARKEY)\n obj = obj[\"#\"]\n if stack.length > 0\n if typeof s[nodeName] == \"undefined\"\n s[nodeName] = obj\n else if s[nodeName] instanceof Array\n s[nodeName].push obj\n else\n old = s[nodeName]\n s[nodeName] = [ old ]\n s[nodeName].push obj\n else\n that.resultObject = obj\n that.emit \"end\", that.resultObject\n\n @saxParser.ontext = @saxParser.oncdata = (t) ->\n s = stack[stack.length - 1]\n if s\n s[\"#\"] += t", "source_lang": "", "target_lang": "CoffeeScript", "repo": "Leonidas-from-XIV/node-xml2js", "path": "src/xml2js.coffee", "license": "MIT", "commit": "8d18e8bb6c9e804e640da4a6dcf31e15c8c545f3", "stars": 4965, "source_url": "https://github.com/Leonidas-from-XIV/node-xml2js/blob/8d18e8bb6c9e804e640da4a6dcf31e15c8c545f3/src/xml2js.coffee", "line_start": 1, "line_end": 50}193{"id": "Leonidas-from-XIV/node-xml2js:src/xml2js.coffee:1:coffee_to_js", "type": "coffee_to_js", "prompt": "Convert this CoffeeScript to JavaScript.\n```coffeescript\nsax = require(\"sax\")\nsys = require(\"sys\")\nevents = require(\"events\")\n\nParser = ->\n that = this\n @saxParser = sax.parser(true)\n @EXPLICIT_CHARKEY = false\n @resultObject = null\n stack = []\n @saxParser.onopentag = (node) ->\n obj = {}\n obj[\"#\"] = \"\"\n for own key of node.attributes\n if typeof obj[\"@\"] == \"undefined\"\n obj[\"@\"] = {}\n obj[\"@\"][key] = node.attributes[key]\n obj[\"#name\"] = node.name\n stack.push obj\n\n @saxParser.onclosetag = ->\n obj = stack.pop()\n nodeName = obj[\"#name\"]\n delete obj[\"#name\"]\n\n s = stack[stack.length - 1]\n if obj[\"#\"].match(/^\\s*$/)\n delete obj[\"#\"]\n else\n obj[\"#\"] = obj[\"#\"].replace(/\\s{2,}/g, \" \").trim()\n if Object.keys(obj).length == 1 and \"#\" in obj and not (that.EXPLICIT_CHARKEY)\n obj = obj[\"#\"]\n if stack.length > 0\n if typeof s[nodeName] == \"undefined\"\n s[nodeName] = obj\n else if s[nodeName] instanceof Array\n s[nodeName].push obj\n else\n old = s[nodeName]\n s[nodeName] = [ old ]\n s[nodeName].push obj\n else\n that.resultObject = obj\n that.emit \"end\", that.resultObject\n\n @saxParser.ontext = @saxParser.oncdata = (t) ->\n s = stack[stack.length - 1]\n if s\n s[\"#\"] += t\n```", "response": "var Parser, events, sax, sys,\n hasProp = {}.hasOwnProperty,\n indexOf = [].indexOf;\n\nsax = require(\"sax\");\n\nsys = require(\"sys\");\n\nevents = require(\"events\");\n\nParser = function() {\n var stack, that;\n that = this;\n this.saxParser = sax.parser(true);\n this.EXPLICIT_CHARKEY = false;\n this.resultObject = null;\n stack = [];\n this.saxParser.onopentag = function(node) {\n var key, obj, ref;\n obj = {};\n obj[\"#\"] = \"\";\n ref = node.attributes;\n for (key in ref) {\n if (!hasProp.call(ref, key)) continue;\n if (typeof obj[\"@\"] === \"undefined\") {\n obj[\"@\"] = {};\n }\n obj[\"@\"][key] = node.attributes[key];\n }\n obj[\"#name\"] = node.name;\n return stack.push(obj);\n };\n this.saxParser.onclosetag = function() {\n var nodeName, obj, old, s;\n obj = stack.pop();\n nodeName = obj[\"#name\"];\n delete obj[\"#name\"];\n s = stack[stack.length - 1];\n if (obj[\"#\"].match(/^\\s*$/)) {\n delete obj[\"#\"];\n } else {\n obj[\"#\"] = obj[\"#\"].replace(/\\s{2,}/g, \" \").trim();\n if (Object.keys(obj).length === 1 && indexOf.call(obj, \"#\") >= 0 && !that.EXPLICIT_CHARKEY) {\n obj = obj[\"#\"];\n }\n }\n if (stack.length > 0) {\n if (typeof s[nodeName] === \"undefined\") {\n return s[nodeName] = obj;\n } else if (s[nodeName] instanceof Array) {\n return s[nodeName].push(obj);\n } else {\n old = s[nodeName];\n s[nodeName] = [old];\n return s[nodeName].push(obj);\n }\n } else {\n that.resultObject = obj;\n return that.emit(\"end\", that.resultObject);\n }\n };\n return this.saxParser.ontext = this.saxParser.oncdata = function(t) {\n var s;\n s = stack[stack.length - 1];\n if (s) {\n return s[\"#\"] += t;\n }\n };\n};", "source_lang": "CoffeeScript", "target_lang": "JavaScript", "repo": "Leonidas-from-XIV/node-xml2js", "path": "src/xml2js.coffee", "license": "MIT", "commit": "8d18e8bb6c9e804e640da4a6dcf31e15c8c545f3", "stars": 4965, "source_url": "https://github.com/Leonidas-from-XIV/node-xml2js/blob/8d18e8bb6c9e804e640da4a6dcf31e15c8c545f3/src/xml2js.coffee", "line_start": 1, "line_end": 50}194{"id": "Leonidas-from-XIV/node-xml2js:src/xml2js.coffee:1:js_to_coffee", "type": "js_to_coffee", "prompt": "Convert this JavaScript to CoffeeScript.\n```javascript\nvar Parser, events, sax, sys,\n hasProp = {}.hasOwnProperty,\n indexOf = [].indexOf;\n\nsax = require(\"sax\");\n\nsys = require(\"sys\");\n\nevents = require(\"events\");\n\nParser = function() {\n var stack, that;\n that = this;\n this.saxParser = sax.parser(true);\n this.EXPLICIT_CHARKEY = false;\n this.resultObject = null;\n stack = [];\n this.saxParser.onopentag = function(node) {\n var key, obj, ref;\n obj = {};\n obj[\"#\"] = \"\";\n ref = node.attributes;\n for (key in ref) {\n if (!hasProp.call(ref, key)) continue;\n if (typeof obj[\"@\"] === \"undefined\") {\n obj[\"@\"] = {};\n }\n obj[\"@\"][key] = node.attributes[key];\n }\n obj[\"#name\"] = node.name;\n return stack.push(obj);\n };\n this.saxParser.onclosetag = function() {\n var nodeName, obj, old, s;\n obj = stack.pop();\n nodeName = obj[\"#name\"];\n delete obj[\"#name\"];\n s = stack[stack.length - 1];\n if (obj[\"#\"].match(/^\\s*$/)) {\n delete obj[\"#\"];\n } else {\n obj[\"#\"] = obj[\"#\"].replace(/\\s{2,}/g, \" \").trim();\n if (Object.keys(obj).length === 1 && indexOf.call(obj, \"#\") >= 0 && !that.EXPLICIT_CHARKEY) {\n obj = obj[\"#\"];\n }\n }\n if (stack.length > 0) {\n if (typeof s[nodeName] === \"undefined\") {\n return s[nodeName] = obj;\n } else if (s[nodeName] instanceof Array) {\n return s[nodeName].push(obj);\n } else {\n old = s[nodeName];\n s[nodeName] = [old];\n return s[nodeName].push(obj);\n }\n } else {\n that.resultObject = obj;\n return that.emit(\"end\", that.resultObject);\n }\n };\n return this.saxParser.ontext = this.saxParser.oncdata = function(t) {\n var s;\n s = stack[stack.length - 1];\n if (s) {\n return s[\"#\"] += t;\n }\n };\n};\n```", "response": "sax = require(\"sax\")\nsys = require(\"sys\")\nevents = require(\"events\")\n\nParser = ->\n that = this\n @saxParser = sax.parser(true)\n @EXPLICIT_CHARKEY = false\n @resultObject = null\n stack = []\n @saxParser.onopentag = (node) ->\n obj = {}\n obj[\"#\"] = \"\"\n for own key of node.attributes\n if typeof obj[\"@\"] == \"undefined\"\n obj[\"@\"] = {}\n obj[\"@\"][key] = node.attributes[key]\n obj[\"#name\"] = node.name\n stack.push obj\n\n @saxParser.onclosetag = ->\n obj = stack.pop()\n nodeName = obj[\"#name\"]\n delete obj[\"#name\"]\n\n s = stack[stack.length - 1]\n if obj[\"#\"].match(/^\\s*$/)\n delete obj[\"#\"]\n else\n obj[\"#\"] = obj[\"#\"].replace(/\\s{2,}/g, \" \").trim()\n if Object.keys(obj).length == 1 and \"#\" in obj and not (that.EXPLICIT_CHARKEY)\n obj = obj[\"#\"]\n if stack.length > 0\n if typeof s[nodeName] == \"undefined\"\n s[nodeName] = obj\n else if s[nodeName] instanceof Array\n s[nodeName].push obj\n else\n old = s[nodeName]\n s[nodeName] = [ old ]\n s[nodeName].push obj\n else\n that.resultObject = obj\n that.emit \"end\", that.resultObject\n\n @saxParser.ontext = @saxParser.oncdata = (t) ->\n s = stack[stack.length - 1]\n if s\n s[\"#\"] += t", "source_lang": "JavaScript", "target_lang": "CoffeeScript", "repo": "Leonidas-from-XIV/node-xml2js", "path": "src/xml2js.coffee", "license": "MIT", "commit": "8d18e8bb6c9e804e640da4a6dcf31e15c8c545f3", "stars": 4965, "source_url": "https://github.com/Leonidas-from-XIV/node-xml2js/blob/8d18e8bb6c9e804e640da4a6dcf31e15c8c545f3/src/xml2js.coffee", "line_start": 1, "line_end": 50}195{"id": "Leonidas-from-XIV/node-xml2js:src/xml2js.coffee:1:completion", "type": "completion", "prompt": "sax = require(\"sax\")\nsys = require(\"sys\")\nevents = require(\"events\")\n\nParser = ->\n that = this\n @saxParser = sax.parser(true)\n @EXPLICIT_CHARKEY = false\n @resultObject = null\n stack = []\n @saxParser.onopentag = (node) ->\n obj = {}\n obj[\"#\"] = \"\"\n for own key of node.attributes\n if typeof obj[\"@\"] == \"undefined\"\n obj[\"@\"] = {}\n obj[\"@\"][key] = node.attributes[key]\n obj[\"#name\"] = node.name\n stack.push obj\n\n @saxParser.onclosetag = ->\n obj = stack.pop()\n nodeName = obj[\"#name\"]\n delete obj[\"#name\"]", "response": "s = stack[stack.length - 1]\n if obj[\"#\"].match(/^\\s*$/)\n delete obj[\"#\"]\n else\n obj[\"#\"] = obj[\"#\"].replace(/\\s{2,}/g, \" \").trim()\n if Object.keys(obj).length == 1 and \"#\" in obj and not (that.EXPLICIT_CHARKEY)\n obj = obj[\"#\"]\n if stack.length > 0\n if typeof s[nodeName] == \"undefined\"\n s[nodeName] = obj\n else if s[nodeName] instanceof Array\n s[nodeName].push obj\n else\n old = s[nodeName]\n s[nodeName] = [ old ]\n s[nodeName].push obj\n else\n that.resultObject = obj\n that.emit \"end\", that.resultObject\n\n @saxParser.ontext = @saxParser.oncdata = (t) ->\n s = stack[stack.length - 1]\n if s\n s[\"#\"] += t", "source_lang": "CoffeeScript", "target_lang": "CoffeeScript", "repo": "Leonidas-from-XIV/node-xml2js", "path": "src/xml2js.coffee", "license": "MIT", "commit": "8d18e8bb6c9e804e640da4a6dcf31e15c8c545f3", "stars": 4965, "source_url": "https://github.com/Leonidas-from-XIV/node-xml2js/blob/8d18e8bb6c9e804e640da4a6dcf31e15c8c545f3/src/xml2js.coffee", "line_start": 1, "line_end": 50}196{"id": "Leonidas-from-XIV/node-xml2js:src/xml2js.coffee:1:raw_corpus", "type": "raw_corpus", "prompt": "", "response": "sax = require(\"sax\")\nsys = require(\"sys\")\nevents = require(\"events\")\nParser = ->\n that = this\n @saxParser = sax.parser(true)\n @EXPLICIT_CHARKEY = false\n @resultObject = null\n stack = []\n @saxParser.onopentag = (node) ->\n obj = {}\n obj[\"#\"] = \"\"\n for key of node.attributes\n if node.attributes.hasOwnProperty(key)\n if typeof obj[\"@\"] == \"undefined\"\n obj[\"@\"] = {}\n obj[\"@\"][key] = node.attributes[key]\n obj[\"#name\"] = node.name\n stack.push obj\n\n @saxParser.onclosetag = ->\n obj = stack.pop()\n nodeName = obj[\"#name\"]\n delete obj[\"#name\"]\n\n s = stack[stack.length - 1]\n if obj[\"#\"].match(/^\\s*$/)\n delete obj[\"#\"]\n else\n obj[\"#\"] = obj[\"#\"].replace(/\\s{2,}/g, \" \").trim()\n if Object.keys(obj).length == 1 and \"#\" in obj and not (that.EXPLICIT_CHARKEY)\n obj = obj[\"#\"]\n if stack.length > 0\n if typeof s[nodeName] == \"undefined\"\n s[nodeName] = obj\n else if s[nodeName] instanceof Array\n s[nodeName].push obj\n else\n old = s[nodeName]\n s[nodeName] = [ old ]\n s[nodeName].push obj\n else\n that.resultObject = obj\n that.emit \"end\", that.resultObject\n\n @saxParser.ontext = @saxParser.oncdata = (t) ->\n s = stack[stack.length - 1]\n if s\n s[\"#\"] += t", "source_lang": "", "target_lang": "CoffeeScript", "repo": "Leonidas-from-XIV/node-xml2js", "path": "src/xml2js.coffee", "license": "MIT", "commit": "a33d8f2e18f9f60b2f9554ade4d794a62215ce3b", "stars": 4965, "source_url": "https://github.com/Leonidas-from-XIV/node-xml2js/blob/a33d8f2e18f9f60b2f9554ade4d794a62215ce3b/src/xml2js.coffee", "line_start": 1, "line_end": 50}197{"id": "Leonidas-from-XIV/node-xml2js:src/xml2js.coffee:1:coffee_to_js", "type": "coffee_to_js", "prompt": "Convert this CoffeeScript to JavaScript.\n```coffeescript\nsax = require(\"sax\")\nsys = require(\"sys\")\nevents = require(\"events\")\nParser = ->\n that = this\n @saxParser = sax.parser(true)\n @EXPLICIT_CHARKEY = false\n @resultObject = null\n stack = []\n @saxParser.onopentag = (node) ->\n obj = {}\n obj[\"#\"] = \"\"\n for key of node.attributes\n if node.attributes.hasOwnProperty(key)\n if typeof obj[\"@\"] == \"undefined\"\n obj[\"@\"] = {}\n obj[\"@\"][key] = node.attributes[key]\n obj[\"#name\"] = node.name\n stack.push obj\n\n @saxParser.onclosetag = ->\n obj = stack.pop()\n nodeName = obj[\"#name\"]\n delete obj[\"#name\"]\n\n s = stack[stack.length - 1]\n if obj[\"#\"].match(/^\\s*$/)\n delete obj[\"#\"]\n else\n obj[\"#\"] = obj[\"#\"].replace(/\\s{2,}/g, \" \").trim()\n if Object.keys(obj).length == 1 and \"#\" in obj and not (that.EXPLICIT_CHARKEY)\n obj = obj[\"#\"]\n if stack.length > 0\n if typeof s[nodeName] == \"undefined\"\n s[nodeName] = obj\n else if s[nodeName] instanceof Array\n s[nodeName].push obj\n else\n old = s[nodeName]\n s[nodeName] = [ old ]\n s[nodeName].push obj\n else\n that.resultObject = obj\n that.emit \"end\", that.resultObject\n\n @saxParser.ontext = @saxParser.oncdata = (t) ->\n s = stack[stack.length - 1]\n if s\n s[\"#\"] += t\n```", "response": "var Parser, events, sax, sys,\n indexOf = [].indexOf;\n\nsax = require(\"sax\");\n\nsys = require(\"sys\");\n\nevents = require(\"events\");\n\nParser = function() {\n var stack, that;\n that = this;\n this.saxParser = sax.parser(true);\n this.EXPLICIT_CHARKEY = false;\n this.resultObject = null;\n stack = [];\n this.saxParser.onopentag = function(node) {\n var key, obj;\n obj = {};\n obj[\"#\"] = \"\";\n for (key in node.attributes) {\n if (node.attributes.hasOwnProperty(key)) {\n if (typeof obj[\"@\"] === \"undefined\") {\n obj[\"@\"] = {};\n }\n obj[\"@\"][key] = node.attributes[key];\n }\n }\n obj[\"#name\"] = node.name;\n return stack.push(obj);\n };\n this.saxParser.onclosetag = function() {\n var nodeName, obj, old, s;\n obj = stack.pop();\n nodeName = obj[\"#name\"];\n delete obj[\"#name\"];\n s = stack[stack.length - 1];\n if (obj[\"#\"].match(/^\\s*$/)) {\n delete obj[\"#\"];\n } else {\n obj[\"#\"] = obj[\"#\"].replace(/\\s{2,}/g, \" \").trim();\n if (Object.keys(obj).length === 1 && indexOf.call(obj, \"#\") >= 0 && !that.EXPLICIT_CHARKEY) {\n obj = obj[\"#\"];\n }\n }\n if (stack.length > 0) {\n if (typeof s[nodeName] === \"undefined\") {\n return s[nodeName] = obj;\n } else if (s[nodeName] instanceof Array) {\n return s[nodeName].push(obj);\n } else {\n old = s[nodeName];\n s[nodeName] = [old];\n return s[nodeName].push(obj);\n }\n } else {\n that.resultObject = obj;\n return that.emit(\"end\", that.resultObject);\n }\n };\n return this.saxParser.ontext = this.saxParser.oncdata = function(t) {\n var s;\n s = stack[stack.length - 1];\n if (s) {\n return s[\"#\"] += t;\n }\n };\n};", "source_lang": "CoffeeScript", "target_lang": "JavaScript", "repo": "Leonidas-from-XIV/node-xml2js", "path": "src/xml2js.coffee", "license": "MIT", "commit": "a33d8f2e18f9f60b2f9554ade4d794a62215ce3b", "stars": 4965, "source_url": "https://github.com/Leonidas-from-XIV/node-xml2js/blob/a33d8f2e18f9f60b2f9554ade4d794a62215ce3b/src/xml2js.coffee", "line_start": 1, "line_end": 50}198{"id": "Leonidas-from-XIV/node-xml2js:src/xml2js.coffee:1:js_to_coffee", "type": "js_to_coffee", "prompt": "Convert this JavaScript to CoffeeScript.\n```javascript\nvar Parser, events, sax, sys,\n indexOf = [].indexOf;\n\nsax = require(\"sax\");\n\nsys = require(\"sys\");\n\nevents = require(\"events\");\n\nParser = function() {\n var stack, that;\n that = this;\n this.saxParser = sax.parser(true);\n this.EXPLICIT_CHARKEY = false;\n this.resultObject = null;\n stack = [];\n this.saxParser.onopentag = function(node) {\n var key, obj;\n obj = {};\n obj[\"#\"] = \"\";\n for (key in node.attributes) {\n if (node.attributes.hasOwnProperty(key)) {\n if (typeof obj[\"@\"] === \"undefined\") {\n obj[\"@\"] = {};\n }\n obj[\"@\"][key] = node.attributes[key];\n }\n }\n obj[\"#name\"] = node.name;\n return stack.push(obj);\n };\n this.saxParser.onclosetag = function() {\n var nodeName, obj, old, s;\n obj = stack.pop();\n nodeName = obj[\"#name\"];\n delete obj[\"#name\"];\n s = stack[stack.length - 1];\n if (obj[\"#\"].match(/^\\s*$/)) {\n delete obj[\"#\"];\n } else {\n obj[\"#\"] = obj[\"#\"].replace(/\\s{2,}/g, \" \").trim();\n if (Object.keys(obj).length === 1 && indexOf.call(obj, \"#\") >= 0 && !that.EXPLICIT_CHARKEY) {\n obj = obj[\"#\"];\n }\n }\n if (stack.length > 0) {\n if (typeof s[nodeName] === \"undefined\") {\n return s[nodeName] = obj;\n } else if (s[nodeName] instanceof Array) {\n return s[nodeName].push(obj);\n } else {\n old = s[nodeName];\n s[nodeName] = [old];\n return s[nodeName].push(obj);\n }\n } else {\n that.resultObject = obj;\n return that.emit(\"end\", that.resultObject);\n }\n };\n return this.saxParser.ontext = this.saxParser.oncdata = function(t) {\n var s;\n s = stack[stack.length - 1];\n if (s) {\n return s[\"#\"] += t;\n }\n };\n};\n```", "response": "sax = require(\"sax\")\nsys = require(\"sys\")\nevents = require(\"events\")\nParser = ->\n that = this\n @saxParser = sax.parser(true)\n @EXPLICIT_CHARKEY = false\n @resultObject = null\n stack = []\n @saxParser.onopentag = (node) ->\n obj = {}\n obj[\"#\"] = \"\"\n for key of node.attributes\n if node.attributes.hasOwnProperty(key)\n if typeof obj[\"@\"] == \"undefined\"\n obj[\"@\"] = {}\n obj[\"@\"][key] = node.attributes[key]\n obj[\"#name\"] = node.name\n stack.push obj\n\n @saxParser.onclosetag = ->\n obj = stack.pop()\n nodeName = obj[\"#name\"]\n delete obj[\"#name\"]\n\n s = stack[stack.length - 1]\n if obj[\"#\"].match(/^\\s*$/)\n delete obj[\"#\"]\n else\n obj[\"#\"] = obj[\"#\"].replace(/\\s{2,}/g, \" \").trim()\n if Object.keys(obj).length == 1 and \"#\" in obj and not (that.EXPLICIT_CHARKEY)\n obj = obj[\"#\"]\n if stack.length > 0\n if typeof s[nodeName] == \"undefined\"\n s[nodeName] = obj\n else if s[nodeName] instanceof Array\n s[nodeName].push obj\n else\n old = s[nodeName]\n s[nodeName] = [ old ]\n s[nodeName].push obj\n else\n that.resultObject = obj\n that.emit \"end\", that.resultObject\n\n @saxParser.ontext = @saxParser.oncdata = (t) ->\n s = stack[stack.length - 1]\n if s\n s[\"#\"] += t", "source_lang": "JavaScript", "target_lang": "CoffeeScript", "repo": "Leonidas-from-XIV/node-xml2js", "path": "src/xml2js.coffee", "license": "MIT", "commit": "a33d8f2e18f9f60b2f9554ade4d794a62215ce3b", "stars": 4965, "source_url": "https://github.com/Leonidas-from-XIV/node-xml2js/blob/a33d8f2e18f9f60b2f9554ade4d794a62215ce3b/src/xml2js.coffee", "line_start": 1, "line_end": 50}199{"id": "Leonidas-from-XIV/node-xml2js:src/xml2js.coffee:1:completion", "type": "completion", "prompt": "sax = require(\"sax\")\nsys = require(\"sys\")\nevents = require(\"events\")\nParser = ->\n that = this\n @saxParser = sax.parser(true)\n @EXPLICIT_CHARKEY = false\n @resultObject = null\n stack = []\n @saxParser.onopentag = (node) ->\n obj = {}\n obj[\"#\"] = \"\"\n for key of node.attributes\n if node.attributes.hasOwnProperty(key)\n if typeof obj[\"@\"] == \"undefined\"\n obj[\"@\"] = {}\n obj[\"@\"][key] = node.attributes[key]\n obj[\"#name\"] = node.name\n stack.push obj\n\n @saxParser.onclosetag = ->\n obj = stack.pop()\n nodeName = obj[\"#name\"]\n delete obj[\"#name\"]", "response": "s = stack[stack.length - 1]\n if obj[\"#\"].match(/^\\s*$/)\n delete obj[\"#\"]\n else\n obj[\"#\"] = obj[\"#\"].replace(/\\s{2,}/g, \" \").trim()\n if Object.keys(obj).length == 1 and \"#\" in obj and not (that.EXPLICIT_CHARKEY)\n obj = obj[\"#\"]\n if stack.length > 0\n if typeof s[nodeName] == \"undefined\"\n s[nodeName] = obj\n else if s[nodeName] instanceof Array\n s[nodeName].push obj\n else\n old = s[nodeName]\n s[nodeName] = [ old ]\n s[nodeName].push obj\n else\n that.resultObject = obj\n that.emit \"end\", that.resultObject\n\n @saxParser.ontext = @saxParser.oncdata = (t) ->\n s = stack[stack.length - 1]\n if s\n s[\"#\"] += t", "source_lang": "CoffeeScript", "target_lang": "CoffeeScript", "repo": "Leonidas-from-XIV/node-xml2js", "path": "src/xml2js.coffee", "license": "MIT", "commit": "a33d8f2e18f9f60b2f9554ade4d794a62215ce3b", "stars": 4965, "source_url": "https://github.com/Leonidas-from-XIV/node-xml2js/blob/a33d8f2e18f9f60b2f9554ade4d794a62215ce3b/src/xml2js.coffee", "line_start": 1, "line_end": 50}200{"id": "Leonidas-from-XIV/node-xml2js:src/xml2js.coffee:2:raw_corpus", "type": "raw_corpus", "prompt": "", "response": "sys.inherits Parser, events.EventEmitter\nParser::parseString = (str) ->\n @saxParser.write str.toString()\n\nexports.Parser = Parser", "source_lang": "", "target_lang": "CoffeeScript", "repo": "Leonidas-from-XIV/node-xml2js", "path": "src/xml2js.coffee", "license": "MIT", "commit": "a33d8f2e18f9f60b2f9554ade4d794a62215ce3b", "stars": 4965, "source_url": "https://github.com/Leonidas-from-XIV/node-xml2js/blob/a33d8f2e18f9f60b2f9554ade4d794a62215ce3b/src/xml2js.coffee", "line_start": 51, "line_end": 55}201{"id": "Leonidas-from-XIV/node-xml2js:src/xml2js.coffee:2:coffee_to_js", "type": "coffee_to_js", "prompt": "Convert this CoffeeScript to JavaScript.\n```coffeescript\nsys.inherits Parser, events.EventEmitter\nParser::parseString = (str) ->\n @saxParser.write str.toString()\n\nexports.Parser = Parser\n```", "response": "sys.inherits(Parser, events.EventEmitter);\n\nParser.prototype.parseString = function(str) {\n return this.saxParser.write(str.toString());\n};\n\nexports.Parser = Parser;", "source_lang": "CoffeeScript", "target_lang": "JavaScript", "repo": "Leonidas-from-XIV/node-xml2js", "path": "src/xml2js.coffee", "license": "MIT", "commit": "a33d8f2e18f9f60b2f9554ade4d794a62215ce3b", "stars": 4965, "source_url": "https://github.com/Leonidas-from-XIV/node-xml2js/blob/a33d8f2e18f9f60b2f9554ade4d794a62215ce3b/src/xml2js.coffee", "line_start": 51, "line_end": 55}202{"id": "Leonidas-from-XIV/node-xml2js:src/xml2js.coffee:2:js_to_coffee", "type": "js_to_coffee", "prompt": "Convert this JavaScript to CoffeeScript.\n```javascript\nsys.inherits(Parser, events.EventEmitter);\n\nParser.prototype.parseString = function(str) {\n return this.saxParser.write(str.toString());\n};\n\nexports.Parser = Parser;\n```", "response": "sys.inherits Parser, events.EventEmitter\nParser::parseString = (str) ->\n @saxParser.write str.toString()\n\nexports.Parser = Parser", "source_lang": "JavaScript", "target_lang": "CoffeeScript", "repo": "Leonidas-from-XIV/node-xml2js", "path": "src/xml2js.coffee", "license": "MIT", "commit": "a33d8f2e18f9f60b2f9554ade4d794a62215ce3b", "stars": 4965, "source_url": "https://github.com/Leonidas-from-XIV/node-xml2js/blob/a33d8f2e18f9f60b2f9554ade4d794a62215ce3b/src/xml2js.coffee", "line_start": 51, "line_end": 55}203{"id": "Leonidas-from-XIV/node-xml2js:src/xml2js.coffee:2:completion", "type": "completion", "prompt": "sys.inherits Parser, events.EventEmitter\nParser::parseString = (str) ->", "response": "@saxParser.write str.toString()\n\nexports.Parser = Parser", "source_lang": "CoffeeScript", "target_lang": "CoffeeScript", "repo": "Leonidas-from-XIV/node-xml2js", "path": "src/xml2js.coffee", "license": "MIT", "commit": "a33d8f2e18f9f60b2f9554ade4d794a62215ce3b", "stars": 4965, "source_url": "https://github.com/Leonidas-from-XIV/node-xml2js/blob/a33d8f2e18f9f60b2f9554ade4d794a62215ce3b/src/xml2js.coffee", "line_start": 51, "line_end": 55}204{"id": "abe33/atom-pigments:lib/sticky-title.coffee:1:raw_corpus", "type": "raw_corpus", "prompt": "", "response": "{EventsDelegation} = require 'atom-utils'\nCompositeDisposable = null\n\nmodule.exports =\nclass StickyTitle\n EventsDelegation.includeInto(this)\n\n constructor: (@stickies, @scrollContainer) ->\n CompositeDisposable ?= require('atom').CompositeDisposable\n\n @subscriptions = new CompositeDisposable\n Array::forEach.call @stickies, (sticky) ->\n sticky.parentNode.style.height = sticky.offsetHeight + 'px'\n sticky.style.width = sticky.offsetWidth + 'px'\n\n @subscriptions.add @subscribeTo @scrollContainer, 'scroll': (e) =>\n @scroll(e)\n\n dispose: ->\n @subscriptions.dispose()\n @stickies = null\n @scrollContainer = null\n\n scroll: (e) ->\n delta = if @lastScrollTop\n @lastScrollTop - @scrollContainer.scrollTop\n else\n 0\n\n Array::forEach.call @stickies, (sticky, i) =>\n nextSticky = @stickies[i + 1]\n prevSticky = @stickies[i - 1]\n scrollTop = @scrollContainer.getBoundingClientRect().top\n parentTop = sticky.parentNode.getBoundingClientRect().top\n {top} = sticky.getBoundingClientRect()\n\n if parentTop < scrollTop\n unless sticky.classList.contains('absolute')\n sticky.classList.add 'fixed'\n sticky.style.top = scrollTop + 'px'\n\n if nextSticky?\n nextTop = nextSticky.parentNode.getBoundingClientRect().top\n if top + sticky.offsetHeight >= nextTop\n sticky.classList.add('absolute')\n sticky.style.top = @scrollContainer.scrollTop + 'px'\n\n else\n sticky.classList.remove 'fixed'", "source_lang": "", "target_lang": "CoffeeScript", "repo": "abe33/atom-pigments", "path": "lib/sticky-title.coffee", "license": "MIT", "commit": "4bdef2e1ebeaa492a6c353c2fd9e7adecdebadf4", "stars": 518, "source_url": "https://github.com/abe33/atom-pigments/blob/4bdef2e1ebeaa492a6c353c2fd9e7adecdebadf4/lib/sticky-title.coffee", "line_start": 1, "line_end": 50}205{"id": "abe33/atom-pigments:lib/sticky-title.coffee:1:coffee_to_js", "type": "coffee_to_js", "prompt": "Convert this CoffeeScript to JavaScript.\n```coffeescript\n{EventsDelegation} = require 'atom-utils'\nCompositeDisposable = null\n\nmodule.exports =\nclass StickyTitle\n EventsDelegation.includeInto(this)\n\n constructor: (@stickies, @scrollContainer) ->\n CompositeDisposable ?= require('atom').CompositeDisposable\n\n @subscriptions = new CompositeDisposable\n Array::forEach.call @stickies, (sticky) ->\n sticky.parentNode.style.height = sticky.offsetHeight + 'px'\n sticky.style.width = sticky.offsetWidth + 'px'\n\n @subscriptions.add @subscribeTo @scrollContainer, 'scroll': (e) =>\n @scroll(e)\n\n dispose: ->\n @subscriptions.dispose()\n @stickies = null\n @scrollContainer = null\n\n scroll: (e) ->\n delta = if @lastScrollTop\n @lastScrollTop - @scrollContainer.scrollTop\n else\n 0\n\n Array::forEach.call @stickies, (sticky, i) =>\n nextSticky = @stickies[i + 1]\n prevSticky = @stickies[i - 1]\n scrollTop = @scrollContainer.getBoundingClientRect().top\n parentTop = sticky.parentNode.getBoundingClientRect().top\n {top} = sticky.getBoundingClientRect()\n\n if parentTop < scrollTop\n unless sticky.classList.contains('absolute')\n sticky.classList.add 'fixed'\n sticky.style.top = scrollTop + 'px'\n\n if nextSticky?\n nextTop = nextSticky.parentNode.getBoundingClientRect().top\n if top + sticky.offsetHeight >= nextTop\n sticky.classList.add('absolute')\n sticky.style.top = @scrollContainer.scrollTop + 'px'\n\n else\n sticky.classList.remove 'fixed'\n```", "response": "var CompositeDisposable, EventsDelegation, StickyTitle;\n\n({EventsDelegation} = require('atom-utils'));\n\nCompositeDisposable = null;\n\nmodule.exports = StickyTitle = (function() {\n class StickyTitle {\n constructor(stickies, scrollContainer) {\n this.stickies = stickies;\n this.scrollContainer = scrollContainer;\n if (CompositeDisposable == null) {\n CompositeDisposable = require('atom').CompositeDisposable;\n }\n this.subscriptions = new CompositeDisposable();\n Array.prototype.forEach.call(this.stickies, function(sticky) {\n sticky.parentNode.style.height = sticky.offsetHeight + 'px';\n return sticky.style.width = sticky.offsetWidth + 'px';\n });\n this.subscriptions.add(this.subscribeTo(this.scrollContainer, {\n 'scroll': (e) => {\n return this.scroll(e);\n }\n }));\n }\n\n dispose() {\n this.subscriptions.dispose();\n this.stickies = null;\n return this.scrollContainer = null;\n }\n\n scroll(e) {\n var delta;\n delta = this.lastScrollTop ? this.lastScrollTop - this.scrollContainer.scrollTop : 0;\n return Array.prototype.forEach.call(this.stickies, (sticky, i) => {\n var nextSticky, nextTop, parentTop, prevSticky, scrollTop, top;\n nextSticky = this.stickies[i + 1];\n prevSticky = this.stickies[i - 1];\n scrollTop = this.scrollContainer.getBoundingClientRect().top;\n parentTop = sticky.parentNode.getBoundingClientRect().top;\n ({top} = sticky.getBoundingClientRect());\n if (parentTop < scrollTop) {\n if (!sticky.classList.contains('absolute')) {\n sticky.classList.add('fixed');\n sticky.style.top = scrollTop + 'px';\n if (nextSticky != null) {\n nextTop = nextSticky.parentNode.getBoundingClientRect().top;\n if (top + sticky.offsetHeight >= nextTop) {\n sticky.classList.add('absolute');\n return sticky.style.top = this.scrollContainer.scrollTop + 'px';\n }\n }\n }\n } else {\n return sticky.classList.remove('fixed');\n }\n });\n }\n\n };\n\n EventsDelegation.includeInto(StickyTitle);\n\n return StickyTitle;\n\n}).call(this);", "source_lang": "CoffeeScript", "target_lang": "JavaScript", "repo": "abe33/atom-pigments", "path": "lib/sticky-title.coffee", "license": "MIT", "commit": "4bdef2e1ebeaa492a6c353c2fd9e7adecdebadf4", "stars": 518, "source_url": "https://github.com/abe33/atom-pigments/blob/4bdef2e1ebeaa492a6c353c2fd9e7adecdebadf4/lib/sticky-title.coffee", "line_start": 1, "line_end": 50}206{"id": "abe33/atom-pigments:lib/sticky-title.coffee:1:js_to_coffee", "type": "js_to_coffee", "prompt": "Convert this JavaScript to CoffeeScript.\n```javascript\nvar CompositeDisposable, EventsDelegation, StickyTitle;\n\n({EventsDelegation} = require('atom-utils'));\n\nCompositeDisposable = null;\n\nmodule.exports = StickyTitle = (function() {\n class StickyTitle {\n constructor(stickies, scrollContainer) {\n this.stickies = stickies;\n this.scrollContainer = scrollContainer;\n if (CompositeDisposable == null) {\n CompositeDisposable = require('atom').CompositeDisposable;\n }\n this.subscriptions = new CompositeDisposable();\n Array.prototype.forEach.call(this.stickies, function(sticky) {\n sticky.parentNode.style.height = sticky.offsetHeight + 'px';\n return sticky.style.width = sticky.offsetWidth + 'px';\n });\n this.subscriptions.add(this.subscribeTo(this.scrollContainer, {\n 'scroll': (e) => {\n return this.scroll(e);\n }\n }));\n }\n\n dispose() {\n this.subscriptions.dispose();\n this.stickies = null;\n return this.scrollContainer = null;\n }\n\n scroll(e) {\n var delta;\n delta = this.lastScrollTop ? this.lastScrollTop - this.scrollContainer.scrollTop : 0;\n return Array.prototype.forEach.call(this.stickies, (sticky, i) => {\n var nextSticky, nextTop, parentTop, prevSticky, scrollTop, top;\n nextSticky = this.stickies[i + 1];\n prevSticky = this.stickies[i - 1];\n scrollTop = this.scrollContainer.getBoundingClientRect().top;\n parentTop = sticky.parentNode.getBoundingClientRect().top;\n ({top} = sticky.getBoundingClientRect());\n if (parentTop < scrollTop) {\n if (!sticky.classList.contains('absolute')) {\n sticky.classList.add('fixed');\n sticky.style.top = scrollTop + 'px';\n if (nextSticky != null) {\n nextTop = nextSticky.parentNode.getBoundingClientRect().top;\n if (top + sticky.offsetHeight >= nextTop) {\n sticky.classList.add('absolute');\n return sticky.style.top = this.scrollContainer.scrollTop + 'px';\n }\n }\n }\n } else {\n return sticky.classList.remove('fixed');\n }\n });\n }\n\n };\n\n EventsDelegation.includeInto(StickyTitle);\n\n return StickyTitle;\n\n}).call(this);\n```", "response": "{EventsDelegation} = require 'atom-utils'\nCompositeDisposable = null\n\nmodule.exports =\nclass StickyTitle\n EventsDelegation.includeInto(this)\n\n constructor: (@stickies, @scrollContainer) ->\n CompositeDisposable ?= require('atom').CompositeDisposable\n\n @subscriptions = new CompositeDisposable\n Array::forEach.call @stickies, (sticky) ->\n sticky.parentNode.style.height = sticky.offsetHeight + 'px'\n sticky.style.width = sticky.offsetWidth + 'px'\n\n @subscriptions.add @subscribeTo @scrollContainer, 'scroll': (e) =>\n @scroll(e)\n\n dispose: ->\n @subscriptions.dispose()\n @stickies = null\n @scrollContainer = null\n\n scroll: (e) ->\n delta = if @lastScrollTop\n @lastScrollTop - @scrollContainer.scrollTop\n else\n 0\n\n Array::forEach.call @stickies, (sticky, i) =>\n nextSticky = @stickies[i + 1]\n prevSticky = @stickies[i - 1]\n scrollTop = @scrollContainer.getBoundingClientRect().top\n parentTop = sticky.parentNode.getBoundingClientRect().top\n {top} = sticky.getBoundingClientRect()\n\n if parentTop < scrollTop\n unless sticky.classList.contains('absolute')\n sticky.classList.add 'fixed'\n sticky.style.top = scrollTop + 'px'\n\n if nextSticky?\n nextTop = nextSticky.parentNode.getBoundingClientRect().top\n if top + sticky.offsetHeight >= nextTop\n sticky.classList.add('absolute')\n sticky.style.top = @scrollContainer.scrollTop + 'px'\n\n else\n sticky.classList.remove 'fixed'", "source_lang": "JavaScript", "target_lang": "CoffeeScript", "repo": "abe33/atom-pigments", "path": "lib/sticky-title.coffee", "license": "MIT", "commit": "4bdef2e1ebeaa492a6c353c2fd9e7adecdebadf4", "stars": 518, "source_url": "https://github.com/abe33/atom-pigments/blob/4bdef2e1ebeaa492a6c353c2fd9e7adecdebadf4/lib/sticky-title.coffee", "line_start": 1, "line_end": 50}207{"id": "abe33/atom-pigments:lib/sticky-title.coffee:1:completion", "type": "completion", "prompt": "{EventsDelegation} = require 'atom-utils'\nCompositeDisposable = null\n\nmodule.exports =\nclass StickyTitle\n EventsDelegation.includeInto(this)\n\n constructor: (@stickies, @scrollContainer) ->\n CompositeDisposable ?= require('atom').CompositeDisposable\n\n @subscriptions = new CompositeDisposable\n Array::forEach.call @stickies, (sticky) ->\n sticky.parentNode.style.height = sticky.offsetHeight + 'px'\n sticky.style.width = sticky.offsetWidth + 'px'\n\n @subscriptions.add @subscribeTo @scrollContainer, 'scroll': (e) =>\n @scroll(e)\n\n dispose: ->\n @subscriptions.dispose()\n @stickies = null\n @scrollContainer = null\n\n scroll: (e) ->", "response": "delta = if @lastScrollTop\n @lastScrollTop - @scrollContainer.scrollTop\n else\n 0\n\n Array::forEach.call @stickies, (sticky, i) =>\n nextSticky = @stickies[i + 1]\n prevSticky = @stickies[i - 1]\n scrollTop = @scrollContainer.getBoundingClientRect().top\n parentTop = sticky.parentNode.getBoundingClientRect().top\n {top} = sticky.getBoundingClientRect()\n\n if parentTop < scrollTop\n unless sticky.classList.contains('absolute')\n sticky.classList.add 'fixed'\n sticky.style.top = scrollTop + 'px'\n\n if nextSticky?\n nextTop = nextSticky.parentNode.getBoundingClientRect().top\n if top + sticky.offsetHeight >= nextTop\n sticky.classList.add('absolute')\n sticky.style.top = @scrollContainer.scrollTop + 'px'\n\n else\n sticky.classList.remove 'fixed'", "source_lang": "CoffeeScript", "target_lang": "CoffeeScript", "repo": "abe33/atom-pigments", "path": "lib/sticky-title.coffee", "license": "MIT", "commit": "4bdef2e1ebeaa492a6c353c2fd9e7adecdebadf4", "stars": 518, "source_url": "https://github.com/abe33/atom-pigments/blob/4bdef2e1ebeaa492a6c353c2fd9e7adecdebadf4/lib/sticky-title.coffee", "line_start": 1, "line_end": 50}208{"id": "abe33/atom-pigments:lib/sticky-title.coffee:2:raw_corpus", "type": "raw_corpus", "prompt": "", "response": "if prevSticky? and prevSticky.classList.contains('absolute')\n prevTop = prevSticky.getBoundingClientRect().top\n prevTop -= prevSticky.offsetHeight if delta < 0\n\n if scrollTop <= prevTop\n prevSticky.classList.remove('absolute')\n prevSticky.style.top = scrollTop + 'px'\n\n @lastScrollTop = @scrollContainer.scrollTop", "source_lang": "", "target_lang": "CoffeeScript", "repo": "abe33/atom-pigments", "path": "lib/sticky-title.coffee", "license": "MIT", "commit": "4bdef2e1ebeaa492a6c353c2fd9e7adecdebadf4", "stars": 518, "source_url": "https://github.com/abe33/atom-pigments/blob/4bdef2e1ebeaa492a6c353c2fd9e7adecdebadf4/lib/sticky-title.coffee", "line_start": 51, "line_end": 59}209{"id": "abe33/atom-pigments:lib/sticky-title.coffee:2:coffee_to_js", "type": "coffee_to_js", "prompt": "Convert this CoffeeScript to JavaScript.\n```coffeescript\nif prevSticky? and prevSticky.classList.contains('absolute')\n prevTop = prevSticky.getBoundingClientRect().top\n prevTop -= prevSticky.offsetHeight if delta < 0\n\n if scrollTop <= prevTop\n prevSticky.classList.remove('absolute')\n prevSticky.style.top = scrollTop + 'px'\n\n @lastScrollTop = @scrollContainer.scrollTop\n```", "response": "var prevTop;\n\nif ((typeof prevSticky !== \"undefined\" && prevSticky !== null) && prevSticky.classList.contains('absolute')) {\n prevTop = prevSticky.getBoundingClientRect().top;\n if (delta < 0) {\n prevTop -= prevSticky.offsetHeight;\n }\n if (scrollTop <= prevTop) {\n prevSticky.classList.remove('absolute');\n prevSticky.style.top = scrollTop + 'px';\n }\n}\n\nthis.lastScrollTop = this.scrollContainer.scrollTop;", "source_lang": "CoffeeScript", "target_lang": "JavaScript", "repo": "abe33/atom-pigments", "path": "lib/sticky-title.coffee", "license": "MIT", "commit": "4bdef2e1ebeaa492a6c353c2fd9e7adecdebadf4", "stars": 518, "source_url": "https://github.com/abe33/atom-pigments/blob/4bdef2e1ebeaa492a6c353c2fd9e7adecdebadf4/lib/sticky-title.coffee", "line_start": 51, "line_end": 59}210{"id": "abe33/atom-pigments:lib/sticky-title.coffee:2:js_to_coffee", "type": "js_to_coffee", "prompt": "Convert this JavaScript to CoffeeScript.\n```javascript\nvar prevTop;\n\nif ((typeof prevSticky !== \"undefined\" && prevSticky !== null) && prevSticky.classList.contains('absolute')) {\n prevTop = prevSticky.getBoundingClientRect().top;\n if (delta < 0) {\n prevTop -= prevSticky.offsetHeight;\n }\n if (scrollTop <= prevTop) {\n prevSticky.classList.remove('absolute');\n prevSticky.style.top = scrollTop + 'px';\n }\n}\n\nthis.lastScrollTop = this.scrollContainer.scrollTop;\n```", "response": "if prevSticky? and prevSticky.classList.contains('absolute')\n prevTop = prevSticky.getBoundingClientRect().top\n prevTop -= prevSticky.offsetHeight if delta < 0\n\n if scrollTop <= prevTop\n prevSticky.classList.remove('absolute')\n prevSticky.style.top = scrollTop + 'px'\n\n @lastScrollTop = @scrollContainer.scrollTop", "source_lang": "JavaScript", "target_lang": "CoffeeScript", "repo": "abe33/atom-pigments", "path": "lib/sticky-title.coffee", "license": "MIT", "commit": "4bdef2e1ebeaa492a6c353c2fd9e7adecdebadf4", "stars": 518, "source_url": "https://github.com/abe33/atom-pigments/blob/4bdef2e1ebeaa492a6c353c2fd9e7adecdebadf4/lib/sticky-title.coffee", "line_start": 51, "line_end": 59}211{"id": "abe33/atom-pigments:lib/sticky-title.coffee:2:completion", "type": "completion", "prompt": "if prevSticky? and prevSticky.classList.contains('absolute')\n prevTop = prevSticky.getBoundingClientRect().top\n prevTop -= prevSticky.offsetHeight if delta < 0", "response": "if scrollTop <= prevTop\n prevSticky.classList.remove('absolute')\n prevSticky.style.top = scrollTop + 'px'\n\n @lastScrollTop = @scrollContainer.scrollTop", "source_lang": "CoffeeScript", "target_lang": "CoffeeScript", "repo": "abe33/atom-pigments", "path": "lib/sticky-title.coffee", "license": "MIT", "commit": "4bdef2e1ebeaa492a6c353c2fd9e7adecdebadf4", "stars": 518, "source_url": "https://github.com/abe33/atom-pigments/blob/4bdef2e1ebeaa492a6c353c2fd9e7adecdebadf4/lib/sticky-title.coffee", "line_start": 51, "line_end": 59}212{"id": "abe33/atom-pigments:lib/sticky-title.coffee:1:raw_corpus", "type": "raw_corpus", "prompt": "", "response": "{CompositeDisposable} = require 'atom'\n{EventsDelegation} = require 'atom-utils'\n\nmodule.exports =\n\nclass StickyTitle\n EventsDelegation.includeInto(this)\n\n constructor: (@stickies, @scrollContainer) ->\n @subscriptions = new CompositeDisposable\n Array::forEach.call @stickies, (sticky) ->\n sticky.parentNode.style.height = sticky.offsetHeight + 'px'\n sticky.style.width = sticky.offsetWidth + 'px'\n\n @subscriptions.add @subscribeTo @scrollContainer, 'scroll': (e) =>\n @scroll(e)\n\n dispose: ->\n @subscriptions.dispose()\n @stickies = null\n @scrollContainer = null\n\n scroll: (e) ->\n delta = if @lastScrollTop\n @lastScrollTop - @scrollContainer.scrollTop\n else\n 0\n\n Array::forEach.call @stickies, (sticky, i) =>\n nextSticky = @stickies[i + 1]\n prevSticky = @stickies[i - 1]\n scrollTop = @scrollContainer.getBoundingClientRect().top\n parentTop = sticky.parentNode.getBoundingClientRect().top\n {top} = sticky.getBoundingClientRect()\n\n if parentTop < scrollTop\n unless sticky.classList.contains('absolute')\n sticky.classList.add 'fixed'\n sticky.style.top = scrollTop + 'px'\n\n if nextSticky?\n nextTop = nextSticky.parentNode.getBoundingClientRect().top\n if top + sticky.offsetHeight >= nextTop\n sticky.classList.add('absolute')\n sticky.style.top = @scrollContainer.scrollTop + 'px'\n\n else\n sticky.classList.remove 'fixed'\n\n if prevSticky? and prevSticky.classList.contains('absolute')", "source_lang": "", "target_lang": "CoffeeScript", "repo": "abe33/atom-pigments", "path": "lib/sticky-title.coffee", "license": "MIT", "commit": "6b9b5368e8a617bbb73ccdb1da96350aba9fd444", "stars": 518, "source_url": "https://github.com/abe33/atom-pigments/blob/6b9b5368e8a617bbb73ccdb1da96350aba9fd444/lib/sticky-title.coffee", "line_start": 1, "line_end": 50}213{"id": "abe33/atom-pigments:lib/sticky-title.coffee:1:completion", "type": "completion", "prompt": "{CompositeDisposable} = require 'atom'\n{EventsDelegation} = require 'atom-utils'\n\nmodule.exports =\n\nclass StickyTitle\n EventsDelegation.includeInto(this)\n\n constructor: (@stickies, @scrollContainer) ->\n @subscriptions = new CompositeDisposable\n Array::forEach.call @stickies, (sticky) ->\n sticky.parentNode.style.height = sticky.offsetHeight + 'px'\n sticky.style.width = sticky.offsetWidth + 'px'\n\n @subscriptions.add @subscribeTo @scrollContainer, 'scroll': (e) =>\n @scroll(e)\n\n dispose: ->\n @subscriptions.dispose()\n @stickies = null\n @scrollContainer = null\n\n scroll: (e) ->\n delta = if @lastScrollTop\n @lastScrollTop - @scrollContainer.scrollTop", "response": "else\n 0\n\n Array::forEach.call @stickies, (sticky, i) =>\n nextSticky = @stickies[i + 1]\n prevSticky = @stickies[i - 1]\n scrollTop = @scrollContainer.getBoundingClientRect().top\n parentTop = sticky.parentNode.getBoundingClientRect().top\n {top} = sticky.getBoundingClientRect()\n\n if parentTop < scrollTop\n unless sticky.classList.contains('absolute')\n sticky.classList.add 'fixed'\n sticky.style.top = scrollTop + 'px'\n\n if nextSticky?\n nextTop = nextSticky.parentNode.getBoundingClientRect().top\n if top + sticky.offsetHeight >= nextTop\n sticky.classList.add('absolute')\n sticky.style.top = @scrollContainer.scrollTop + 'px'\n\n else\n sticky.classList.remove 'fixed'\n\n if prevSticky? and prevSticky.classList.contains('absolute')", "source_lang": "CoffeeScript", "target_lang": "CoffeeScript", "repo": "abe33/atom-pigments", "path": "lib/sticky-title.coffee", "license": "MIT", "commit": "6b9b5368e8a617bbb73ccdb1da96350aba9fd444", "stars": 518, "source_url": "https://github.com/abe33/atom-pigments/blob/6b9b5368e8a617bbb73ccdb1da96350aba9fd444/lib/sticky-title.coffee", "line_start": 1, "line_end": 50}214{"id": "abe33/atom-pigments:lib/sticky-title.coffee:2:raw_corpus", "type": "raw_corpus", "prompt": "", "response": "prevTop = prevSticky.getBoundingClientRect().top\n prevTop -= prevSticky.offsetHeight if delta < 0\n\n if scrollTop <= prevTop\n prevSticky.classList.remove('absolute')\n prevSticky.style.top = scrollTop + 'px'\n\n @lastScrollTop = @scrollContainer.scrollTop", "source_lang": "", "target_lang": "CoffeeScript", "repo": "abe33/atom-pigments", "path": "lib/sticky-title.coffee", "license": "MIT", "commit": "6b9b5368e8a617bbb73ccdb1da96350aba9fd444", "stars": 518, "source_url": "https://github.com/abe33/atom-pigments/blob/6b9b5368e8a617bbb73ccdb1da96350aba9fd444/lib/sticky-title.coffee", "line_start": 51, "line_end": 58}215{"id": "abe33/atom-pigments:lib/sticky-title.coffee:2:completion", "type": "completion", "prompt": "prevTop = prevSticky.getBoundingClientRect().top\n prevTop -= prevSticky.offsetHeight if delta < 0\n\n if scrollTop <= prevTop", "response": "prevSticky.classList.remove('absolute')\n prevSticky.style.top = scrollTop + 'px'\n\n @lastScrollTop = @scrollContainer.scrollTop", "source_lang": "CoffeeScript", "target_lang": "CoffeeScript", "repo": "abe33/atom-pigments", "path": "lib/sticky-title.coffee", "license": "MIT", "commit": "6b9b5368e8a617bbb73ccdb1da96350aba9fd444", "stars": 518, "source_url": "https://github.com/abe33/atom-pigments/blob/6b9b5368e8a617bbb73ccdb1da96350aba9fd444/lib/sticky-title.coffee", "line_start": 51, "line_end": 58}216{"id": "jianliaoim/talk-os:talk-web/client/app/snippet-editor.coffee:1:raw_corpus", "type": "raw_corpus", "prompt": "", "response": "module.exports = React.createClass\n displayName: 'snippet-editor'\n mixins: [ PureRenderMixin ]\n\n propTypes:\n _toId: T.string\n _roomId: T.string\n _teamId: T.string\n _storyId: T.string\n draftMode: T.bool\n onClose: T.func.isRequired\n onSubmit: T.func.isRequired\n attachment: T.object\n\n getInitialState: ->\n data: Immutable.fromJS\n text: @props.attachment?.text or ''\n title: @props.attachment?.title or ''\n codeType: @props.attachment?.codeType or 'txt'\n\n componentDidMount: ->\n lazyModules.ensureCodeEditor =>\n isLoadedCodeEditor = true\n @debounceSaveDraft = debounce @saveDraft, 500\n @forceUpdate()\n\n componentWillUnmount: ->\n @debounceSaveDraft = null\n\n saveDraft: (snippetDraft) ->\n _channelId = @props._roomId or @props._toId or @props._storyId\n hasDraft = @state.data.get('text').length or @state.data.get('title').length\n\n if _channelId?\n if hasDraft\n draftActions.saveSnippet @props._teamId, _channelId, snippetDraft.toJS()\n else\n draftActions.clearSnippet @props._teamId, _channelId\n\n saveState: (data) ->\n @setState\n data: data\n , =>\n @debounceSaveDraft data\n\n handleEditorChange: (text) ->\n data = @state.data.set 'text', text\n @saveState data\n\n handleSelectorChange: (codeType) ->", "source_lang": "", "target_lang": "CoffeeScript", "repo": "jianliaoim/talk-os", "path": "talk-web/client/app/snippet-editor.coffee", "license": "MIT", "commit": "2545c4497865779a55762e03963a39237df9046b", "stars": 2703, "source_url": "https://github.com/jianliaoim/talk-os/blob/2545c4497865779a55762e03963a39237df9046b/talk-web/client/app/snippet-editor.coffee", "line_start": 23, "line_end": 72}217{"id": "jianliaoim/talk-os:talk-web/client/app/snippet-editor.coffee:1:coffee_to_js", "type": "coffee_to_js", "prompt": "Convert this CoffeeScript to JavaScript.\n```coffeescript\nmodule.exports = React.createClass\n displayName: 'snippet-editor'\n mixins: [ PureRenderMixin ]\n\n propTypes:\n _toId: T.string\n _roomId: T.string\n _teamId: T.string\n _storyId: T.string\n draftMode: T.bool\n onClose: T.func.isRequired\n onSubmit: T.func.isRequired\n attachment: T.object\n\n getInitialState: ->\n data: Immutable.fromJS\n text: @props.attachment?.text or ''\n title: @props.attachment?.title or ''\n codeType: @props.attachment?.codeType or 'txt'\n\n componentDidMount: ->\n lazyModules.ensureCodeEditor =>\n isLoadedCodeEditor = true\n @debounceSaveDraft = debounce @saveDraft, 500\n @forceUpdate()\n\n componentWillUnmount: ->\n @debounceSaveDraft = null\n\n saveDraft: (snippetDraft) ->\n _channelId = @props._roomId or @props._toId or @props._storyId\n hasDraft = @state.data.get('text').length or @state.data.get('title').length\n\n if _channelId?\n if hasDraft\n draftActions.saveSnippet @props._teamId, _channelId, snippetDraft.toJS()\n else\n draftActions.clearSnippet @props._teamId, _channelId\n\n saveState: (data) ->\n @setState\n data: data\n , =>\n @debounceSaveDraft data\n\n handleEditorChange: (text) ->\n data = @state.data.set 'text', text\n @saveState data\n\n handleSelectorChange: (codeType) ->\n```", "response": "module.exports = React.createClass({\n displayName: 'snippet-editor',\n mixins: [PureRenderMixin],\n propTypes: {\n _toId: T.string,\n _roomId: T.string,\n _teamId: T.string,\n _storyId: T.string,\n draftMode: T.bool,\n onClose: T.func.isRequired,\n onSubmit: T.func.isRequired,\n attachment: T.object\n },\n getInitialState: function() {\n var ref, ref1, ref2;\n return {\n data: Immutable.fromJS({\n text: ((ref = this.props.attachment) != null ? ref.text : void 0) || '',\n title: ((ref1 = this.props.attachment) != null ? ref1.title : void 0) || '',\n codeType: ((ref2 = this.props.attachment) != null ? ref2.codeType : void 0) || 'txt'\n })\n };\n },\n componentDidMount: function() {\n return lazyModules.ensureCodeEditor(() => {\n var isLoadedCodeEditor;\n isLoadedCodeEditor = true;\n this.debounceSaveDraft = debounce(this.saveDraft, 500);\n return this.forceUpdate();\n });\n },\n componentWillUnmount: function() {\n return this.debounceSaveDraft = null;\n },\n saveDraft: function(snippetDraft) {\n var _channelId, hasDraft;\n _channelId = this.props._roomId || this.props._toId || this.props._storyId;\n hasDraft = this.state.data.get('text').length || this.state.data.get('title').length;\n if (_channelId != null) {\n if (hasDraft) {\n return draftActions.saveSnippet(this.props._teamId, _channelId, snippetDraft.toJS());\n } else {\n return draftActions.clearSnippet(this.props._teamId, _channelId);\n }\n }\n },\n saveState: function(data) {\n return this.setState({\n data: data\n }, () => {\n return this.debounceSaveDraft(data);\n });\n },\n handleEditorChange: function(text) {\n var data;\n data = this.state.data.set('text', text);\n return this.saveState(data);\n },\n handleSelectorChange: function(codeType) {}\n});", "source_lang": "CoffeeScript", "target_lang": "JavaScript", "repo": "jianliaoim/talk-os", "path": "talk-web/client/app/snippet-editor.coffee", "license": "MIT", "commit": "2545c4497865779a55762e03963a39237df9046b", "stars": 2703, "source_url": "https://github.com/jianliaoim/talk-os/blob/2545c4497865779a55762e03963a39237df9046b/talk-web/client/app/snippet-editor.coffee", "line_start": 23, "line_end": 72}218{"id": "jianliaoim/talk-os:talk-web/client/app/snippet-editor.coffee:1:js_to_coffee", "type": "js_to_coffee", "prompt": "Convert this JavaScript to CoffeeScript.\n```javascript\nmodule.exports = React.createClass({\n displayName: 'snippet-editor',\n mixins: [PureRenderMixin],\n propTypes: {\n _toId: T.string,\n _roomId: T.string,\n _teamId: T.string,\n _storyId: T.string,\n draftMode: T.bool,\n onClose: T.func.isRequired,\n onSubmit: T.func.isRequired,\n attachment: T.object\n },\n getInitialState: function() {\n var ref, ref1, ref2;\n return {\n data: Immutable.fromJS({\n text: ((ref = this.props.attachment) != null ? ref.text : void 0) || '',\n title: ((ref1 = this.props.attachment) != null ? ref1.title : void 0) || '',\n codeType: ((ref2 = this.props.attachment) != null ? ref2.codeType : void 0) || 'txt'\n })\n };\n },\n componentDidMount: function() {\n return lazyModules.ensureCodeEditor(() => {\n var isLoadedCodeEditor;\n isLoadedCodeEditor = true;\n this.debounceSaveDraft = debounce(this.saveDraft, 500);\n return this.forceUpdate();\n });\n },\n componentWillUnmount: function() {\n return this.debounceSaveDraft = null;\n },\n saveDraft: function(snippetDraft) {\n var _channelId, hasDraft;\n _channelId = this.props._roomId || this.props._toId || this.props._storyId;\n hasDraft = this.state.data.get('text').length || this.state.data.get('title').length;\n if (_channelId != null) {\n if (hasDraft) {\n return draftActions.saveSnippet(this.props._teamId, _channelId, snippetDraft.toJS());\n } else {\n return draftActions.clearSnippet(this.props._teamId, _channelId);\n }\n }\n },\n saveState: function(data) {\n return this.setState({\n data: data\n }, () => {\n return this.debounceSaveDraft(data);\n });\n },\n handleEditorChange: function(text) {\n var data;\n data = this.state.data.set('text', text);\n return this.saveState(data);\n },\n handleSelectorChange: function(codeType) {}\n});\n```", "response": "module.exports = React.createClass\n displayName: 'snippet-editor'\n mixins: [ PureRenderMixin ]\n\n propTypes:\n _toId: T.string\n _roomId: T.string\n _teamId: T.string\n _storyId: T.string\n draftMode: T.bool\n onClose: T.func.isRequired\n onSubmit: T.func.isRequired\n attachment: T.object\n\n getInitialState: ->\n data: Immutable.fromJS\n text: @props.attachment?.text or ''\n title: @props.attachment?.title or ''\n codeType: @props.attachment?.codeType or 'txt'\n\n componentDidMount: ->\n lazyModules.ensureCodeEditor =>\n isLoadedCodeEditor = true\n @debounceSaveDraft = debounce @saveDraft, 500\n @forceUpdate()\n\n componentWillUnmount: ->\n @debounceSaveDraft = null\n\n saveDraft: (snippetDraft) ->\n _channelId = @props._roomId or @props._toId or @props._storyId\n hasDraft = @state.data.get('text').length or @state.data.get('title').length\n\n if _channelId?\n if hasDraft\n draftActions.saveSnippet @props._teamId, _channelId, snippetDraft.toJS()\n else\n draftActions.clearSnippet @props._teamId, _channelId\n\n saveState: (data) ->\n @setState\n data: data\n , =>\n @debounceSaveDraft data\n\n handleEditorChange: (text) ->\n data = @state.data.set 'text', text\n @saveState data\n\n handleSelectorChange: (codeType) ->", "source_lang": "JavaScript", "target_lang": "CoffeeScript", "repo": "jianliaoim/talk-os", "path": "talk-web/client/app/snippet-editor.coffee", "license": "MIT", "commit": "2545c4497865779a55762e03963a39237df9046b", "stars": 2703, "source_url": "https://github.com/jianliaoim/talk-os/blob/2545c4497865779a55762e03963a39237df9046b/talk-web/client/app/snippet-editor.coffee", "line_start": 23, "line_end": 72}219{"id": "jianliaoim/talk-os:talk-web/client/app/snippet-editor.coffee:1:completion", "type": "completion", "prompt": "module.exports = React.createClass\n displayName: 'snippet-editor'\n mixins: [ PureRenderMixin ]\n\n propTypes:\n _toId: T.string\n _roomId: T.string\n _teamId: T.string\n _storyId: T.string\n draftMode: T.bool\n onClose: T.func.isRequired\n onSubmit: T.func.isRequired\n attachment: T.object\n\n getInitialState: ->\n data: Immutable.fromJS\n text: @props.attachment?.text or ''\n title: @props.attachment?.title or ''\n codeType: @props.attachment?.codeType or 'txt'\n\n componentDidMount: ->\n lazyModules.ensureCodeEditor =>\n isLoadedCodeEditor = true\n @debounceSaveDraft = debounce @saveDraft, 500\n @forceUpdate()", "response": "componentWillUnmount: ->\n @debounceSaveDraft = null\n\n saveDraft: (snippetDraft) ->\n _channelId = @props._roomId or @props._toId or @props._storyId\n hasDraft = @state.data.get('text').length or @state.data.get('title').length\n\n if _channelId?\n if hasDraft\n draftActions.saveSnippet @props._teamId, _channelId, snippetDraft.toJS()\n else\n draftActions.clearSnippet @props._teamId, _channelId\n\n saveState: (data) ->\n @setState\n data: data\n , =>\n @debounceSaveDraft data\n\n handleEditorChange: (text) ->\n data = @state.data.set 'text', text\n @saveState data\n\n handleSelectorChange: (codeType) ->", "source_lang": "CoffeeScript", "target_lang": "CoffeeScript", "repo": "jianliaoim/talk-os", "path": "talk-web/client/app/snippet-editor.coffee", "license": "MIT", "commit": "2545c4497865779a55762e03963a39237df9046b", "stars": 2703, "source_url": "https://github.com/jianliaoim/talk-os/blob/2545c4497865779a55762e03963a39237df9046b/talk-web/client/app/snippet-editor.coffee", "line_start": 23, "line_end": 72}220{"id": "jianliaoim/talk-os:talk-web/client/app/snippet-editor.coffee:2:raw_corpus", "type": "raw_corpus", "prompt": "", "response": "data = @state.data.set 'codeType', codeType\n @saveState data\n\n handleTitleChange: (event) ->\n data = @state.data.set 'title', event.target.value\n @saveState data\n\n onSubmit: ->\n isEmpty = @state.data.get('text')?.trim().length is 0\n\n if isEmpty\n notifyActions.error lang.getText 'snippet-send-empty'\n return\n\n @props.onSubmit @state.data.toJS()\n\n renderCodeEditor: ->\n codeEditor = lazyModules.load 'code-editor'\n\n codeEditor\n text: @state.data.get 'text'\n codeType: snippetUtil.getCodemirror @state.data.get 'codeType'\n onChange: @handleEditorChange\n placeholder: lang.getText 'snippet-editor-placeholder'\n\n renderSelector: ->\n snippetSelector = lazyModules.load 'snippet-selector'\n\n snippetSelector\n onClick: @handleSelectorChange\n codeType: @state.data.get 'codeType'\n codeAssets: snippetUtil.getAssets()\n\n renderTitle: ->\n div className: 'title',\n input\n type: 'text', className: 'input'\n onChange: @handleTitleChange\n placeholder: lang.getText 'snippet-editor-title-placeholder'\n defaultValue: @state.data.get 'title'\n\n render: ->\n return null if not isLoadedCodeEditor\n\n isEmpty = @state.data.get('text')?.trim().length is 0\n buttonClassName = cx 'button',\n 'is-primary': not isEmpty\n 'is-disabled': isEmpty\n\n div className: 'snippet-editor', onClick: @onClick,", "source_lang": "", "target_lang": "CoffeeScript", "repo": "jianliaoim/talk-os", "path": "talk-web/client/app/snippet-editor.coffee", "license": "MIT", "commit": "2545c4497865779a55762e03963a39237df9046b", "stars": 2703, "source_url": "https://github.com/jianliaoim/talk-os/blob/2545c4497865779a55762e03963a39237df9046b/talk-web/client/app/snippet-editor.coffee", "line_start": 73, "line_end": 122}221{"id": "jianliaoim/talk-os:talk-web/client/app/snippet-editor.coffee:2:completion", "type": "completion", "prompt": "data = @state.data.set 'codeType', codeType\n @saveState data\n\n handleTitleChange: (event) ->\n data = @state.data.set 'title', event.target.value\n @saveState data\n\n onSubmit: ->\n isEmpty = @state.data.get('text')?.trim().length is 0\n\n if isEmpty\n notifyActions.error lang.getText 'snippet-send-empty'\n return\n\n @props.onSubmit @state.data.toJS()\n\n renderCodeEditor: ->\n codeEditor = lazyModules.load 'code-editor'\n\n codeEditor\n text: @state.data.get 'text'\n codeType: snippetUtil.getCodemirror @state.data.get 'codeType'\n onChange: @handleEditorChange\n placeholder: lang.getText 'snippet-editor-placeholder'", "response": "renderSelector: ->\n snippetSelector = lazyModules.load 'snippet-selector'\n\n snippetSelector\n onClick: @handleSelectorChange\n codeType: @state.data.get 'codeType'\n codeAssets: snippetUtil.getAssets()\n\n renderTitle: ->\n div className: 'title',\n input\n type: 'text', className: 'input'\n onChange: @handleTitleChange\n placeholder: lang.getText 'snippet-editor-title-placeholder'\n defaultValue: @state.data.get 'title'\n\n render: ->\n return null if not isLoadedCodeEditor\n\n isEmpty = @state.data.get('text')?.trim().length is 0\n buttonClassName = cx 'button',\n 'is-primary': not isEmpty\n 'is-disabled': isEmpty\n\n div className: 'snippet-editor', onClick: @onClick,", "source_lang": "CoffeeScript", "target_lang": "CoffeeScript", "repo": "jianliaoim/talk-os", "path": "talk-web/client/app/snippet-editor.coffee", "license": "MIT", "commit": "2545c4497865779a55762e03963a39237df9046b", "stars": 2703, "source_url": "https://github.com/jianliaoim/talk-os/blob/2545c4497865779a55762e03963a39237df9046b/talk-web/client/app/snippet-editor.coffee", "line_start": 73, "line_end": 122}222{"id": "jianliaoim/talk-os:talk-web/client/app/snippet-editor.coffee:3:raw_corpus", "type": "raw_corpus", "prompt": "", "response": "div className: 'header line',\n lang.getText 'snippet-editor'\n Icon name: 'remove', className: 'button-close', size: 20, onClick: @props.onClose\n div className: 'body',\n @renderTitle()\n @renderCodeEditor()\n div ref: 'footer', className: 'footer',\n @renderSelector()\n div className: 'buttons line',\n button className: buttonClassName, onClick: @onSubmit, disabled: isEmpty,\n if @props.draftMode\n lang.getText 'send'\n else\n lang.getText 'save'", "source_lang": "", "target_lang": "CoffeeScript", "repo": "jianliaoim/talk-os", "path": "talk-web/client/app/snippet-editor.coffee", "license": "MIT", "commit": "2545c4497865779a55762e03963a39237df9046b", "stars": 2703, "source_url": "https://github.com/jianliaoim/talk-os/blob/2545c4497865779a55762e03963a39237df9046b/talk-web/client/app/snippet-editor.coffee", "line_start": 123, "line_end": 136}223{"id": "jianliaoim/talk-os:talk-web/client/app/snippet-editor.coffee:3:coffee_to_js", "type": "coffee_to_js", "prompt": "Convert this CoffeeScript to JavaScript.\n```coffeescript\ndiv className: 'header line',\n lang.getText 'snippet-editor'\n Icon name: 'remove', className: 'button-close', size: 20, onClick: @props.onClose\n div className: 'body',\n @renderTitle()\n @renderCodeEditor()\n div ref: 'footer', className: 'footer',\n @renderSelector()\n div className: 'buttons line',\n button className: buttonClassName, onClick: @onSubmit, disabled: isEmpty,\n if @props.draftMode\n lang.getText 'send'\n else\n lang.getText 'save'\n```", "response": "div({\n className: 'header line'\n}, lang.getText('snippet-editor'), Icon({\n name: 'remove',\n className: 'button-close',\n size: 20,\n onClick: this.props.onClose\n}));\n\ndiv({\n className: 'body'\n}, this.renderTitle(), this.renderCodeEditor());\n\ndiv({\n ref: 'footer',\n className: 'footer'\n}, this.renderSelector(), div({\n className: 'buttons line'\n}, button({\n className: buttonClassName,\n onClick: this.onSubmit,\n disabled: isEmpty\n}, this.props.draftMode ? lang.getText('send') : lang.getText('save'))));", "source_lang": "CoffeeScript", "target_lang": "JavaScript", "repo": "jianliaoim/talk-os", "path": "talk-web/client/app/snippet-editor.coffee", "license": "MIT", "commit": "2545c4497865779a55762e03963a39237df9046b", "stars": 2703, "source_url": "https://github.com/jianliaoim/talk-os/blob/2545c4497865779a55762e03963a39237df9046b/talk-web/client/app/snippet-editor.coffee", "line_start": 123, "line_end": 136}224{"id": "jianliaoim/talk-os:talk-web/client/app/snippet-editor.coffee:3:js_to_coffee", "type": "js_to_coffee", "prompt": "Convert this JavaScript to CoffeeScript.\n```javascript\ndiv({\n className: 'header line'\n}, lang.getText('snippet-editor'), Icon({\n name: 'remove',\n className: 'button-close',\n size: 20,\n onClick: this.props.onClose\n}));\n\ndiv({\n className: 'body'\n}, this.renderTitle(), this.renderCodeEditor());\n\ndiv({\n ref: 'footer',\n className: 'footer'\n}, this.renderSelector(), div({\n className: 'buttons line'\n}, button({\n className: buttonClassName,\n onClick: this.onSubmit,\n disabled: isEmpty\n}, this.props.draftMode ? lang.getText('send') : lang.getText('save'))));\n```", "response": "div className: 'header line',\n lang.getText 'snippet-editor'\n Icon name: 'remove', className: 'button-close', size: 20, onClick: @props.onClose\n div className: 'body',\n @renderTitle()\n @renderCodeEditor()\n div ref: 'footer', className: 'footer',\n @renderSelector()\n div className: 'buttons line',\n button className: buttonClassName, onClick: @onSubmit, disabled: isEmpty,\n if @props.draftMode\n lang.getText 'send'\n else\n lang.getText 'save'", "source_lang": "JavaScript", "target_lang": "CoffeeScript", "repo": "jianliaoim/talk-os", "path": "talk-web/client/app/snippet-editor.coffee", "license": "MIT", "commit": "2545c4497865779a55762e03963a39237df9046b", "stars": 2703, "source_url": "https://github.com/jianliaoim/talk-os/blob/2545c4497865779a55762e03963a39237df9046b/talk-web/client/app/snippet-editor.coffee", "line_start": 123, "line_end": 136}225{"id": "jianliaoim/talk-os:talk-web/client/app/snippet-editor.coffee:3:completion", "type": "completion", "prompt": "div className: 'header line',\n lang.getText 'snippet-editor'\n Icon name: 'remove', className: 'button-close', size: 20, onClick: @props.onClose\n div className: 'body',\n @renderTitle()\n @renderCodeEditor()\n div ref: 'footer', className: 'footer',", "response": "@renderSelector()\n div className: 'buttons line',\n button className: buttonClassName, onClick: @onSubmit, disabled: isEmpty,\n if @props.draftMode\n lang.getText 'send'\n else\n lang.getText 'save'", "source_lang": "CoffeeScript", "target_lang": "CoffeeScript", "repo": "jianliaoim/talk-os", "path": "talk-web/client/app/snippet-editor.coffee", "license": "MIT", "commit": "2545c4497865779a55762e03963a39237df9046b", "stars": 2703, "source_url": "https://github.com/jianliaoim/talk-os/blob/2545c4497865779a55762e03963a39237df9046b/talk-web/client/app/snippet-editor.coffee", "line_start": 123, "line_end": 136}226{"id": "soulwire/Coffee-Physics:source/engine/integrator/ImprovedEuler.coffee:1:raw_corpus", "type": "raw_corpus", "prompt": "", "response": "### Improved Euler Integrator ###\n\nclass ImprovedEuler extends Integrator\n\n # x += (v * dt) + (a * 0.5 * dt * dt)\n # v += a * dt\n\n integrate: (particles, dt, drag) ->\n\n acc = new Vector()\n vel = new Vector()\n\n dtSq = dt * dt\n\n for p in particles when not p.fixed\n\n # Store previous location.\n p.old.pos.copy p.pos\n\n # Scale force to mass.\n p.acc.scale p.massInv\n\n # Duplicate velocity to preserve momentum.\n vel.copy p.vel\n\n # Duplicate force.\n acc.copy p.acc\n\n # Update position.\n p.pos.add (vel.scale dt).add (acc.scale 0.5 * dtSq)\n\n # Update velocity.\n p.vel.add p.acc.scale dt\n\n # Apply friction.\n if drag then p.vel.scale drag\n\n # Reset forces.\n p.acc.clear()", "source_lang": "", "target_lang": "CoffeeScript", "repo": "soulwire/Coffee-Physics", "path": "source/engine/integrator/ImprovedEuler.coffee", "license": "MIT", "commit": "df9d43d3153dfc6a734fef1b24eb5a90c2c61e4d", "stars": 1053, "source_url": "https://github.com/soulwire/Coffee-Physics/blob/df9d43d3153dfc6a734fef1b24eb5a90c2c61e4d/source/engine/integrator/ImprovedEuler.coffee", "line_start": 1, "line_end": 39}227{"id": "soulwire/Coffee-Physics:source/engine/integrator/ImprovedEuler.coffee:1:coffee_to_js", "type": "coffee_to_js", "prompt": "Convert this CoffeeScript to JavaScript.\n```coffeescript\n### Improved Euler Integrator ###\n\nclass ImprovedEuler extends Integrator\n\n # x += (v * dt) + (a * 0.5 * dt * dt)\n # v += a * dt\n\n integrate: (particles, dt, drag) ->\n\n acc = new Vector()\n vel = new Vector()\n\n dtSq = dt * dt\n\n for p in particles when not p.fixed\n\n # Store previous location.\n p.old.pos.copy p.pos\n\n # Scale force to mass.\n p.acc.scale p.massInv\n\n # Duplicate velocity to preserve momentum.\n vel.copy p.vel\n\n # Duplicate force.\n acc.copy p.acc\n\n # Update position.\n p.pos.add (vel.scale dt).add (acc.scale 0.5 * dtSq)\n\n # Update velocity.\n p.vel.add p.acc.scale dt\n\n # Apply friction.\n if drag then p.vel.scale drag\n\n # Reset forces.\n p.acc.clear()\n```", "response": "/* Improved Euler Integrator */\nvar ImprovedEuler;\n\nImprovedEuler = class ImprovedEuler extends Integrator {\n // x += (v * dt) + (a * 0.5 * dt * dt)\n // v += a * dt\n integrate(particles, dt, drag) {\n var acc, dtSq, i, len, p, results, vel;\n acc = new Vector();\n vel = new Vector();\n dtSq = dt * dt;\n results = [];\n for (i = 0, len = particles.length; i < len; i++) {\n p = particles[i];\n if (!(!p.fixed)) {\n continue;\n }\n // Store previous location.\n p.old.pos.copy(p.pos);\n // Scale force to mass.\n p.acc.scale(p.massInv);\n // Duplicate velocity to preserve momentum.\n vel.copy(p.vel);\n // Duplicate force.\n acc.copy(p.acc);\n // Update position.\n p.pos.add((vel.scale(dt)).add(acc.scale(0.5 * dtSq)));\n // Update velocity.\n p.vel.add(p.acc.scale(dt));\n // Apply friction.\n if (drag) {\n p.vel.scale(drag);\n }\n // Reset forces.\n results.push(p.acc.clear());\n }\n return results;\n }\n\n};", "source_lang": "CoffeeScript", "target_lang": "JavaScript", "repo": "soulwire/Coffee-Physics", "path": "source/engine/integrator/ImprovedEuler.coffee", "license": "MIT", "commit": "df9d43d3153dfc6a734fef1b24eb5a90c2c61e4d", "stars": 1053, "source_url": "https://github.com/soulwire/Coffee-Physics/blob/df9d43d3153dfc6a734fef1b24eb5a90c2c61e4d/source/engine/integrator/ImprovedEuler.coffee", "line_start": 1, "line_end": 39}228{"id": "soulwire/Coffee-Physics:source/engine/integrator/ImprovedEuler.coffee:1:js_to_coffee", "type": "js_to_coffee", "prompt": "Convert this JavaScript to CoffeeScript.\n```javascript\n/* Improved Euler Integrator */\nvar ImprovedEuler;\n\nImprovedEuler = class ImprovedEuler extends Integrator {\n // x += (v * dt) + (a * 0.5 * dt * dt)\n // v += a * dt\n integrate(particles, dt, drag) {\n var acc, dtSq, i, len, p, results, vel;\n acc = new Vector();\n vel = new Vector();\n dtSq = dt * dt;\n results = [];\n for (i = 0, len = particles.length; i < len; i++) {\n p = particles[i];\n if (!(!p.fixed)) {\n continue;\n }\n // Store previous location.\n p.old.pos.copy(p.pos);\n // Scale force to mass.\n p.acc.scale(p.massInv);\n // Duplicate velocity to preserve momentum.\n vel.copy(p.vel);\n // Duplicate force.\n acc.copy(p.acc);\n // Update position.\n p.pos.add((vel.scale(dt)).add(acc.scale(0.5 * dtSq)));\n // Update velocity.\n p.vel.add(p.acc.scale(dt));\n // Apply friction.\n if (drag) {\n p.vel.scale(drag);\n }\n // Reset forces.\n results.push(p.acc.clear());\n }\n return results;\n }\n\n};\n```", "response": "### Improved Euler Integrator ###\n\nclass ImprovedEuler extends Integrator\n\n # x += (v * dt) + (a * 0.5 * dt * dt)\n # v += a * dt\n\n integrate: (particles, dt, drag) ->\n\n acc = new Vector()\n vel = new Vector()\n\n dtSq = dt * dt\n\n for p in particles when not p.fixed\n\n # Store previous location.\n p.old.pos.copy p.pos\n\n # Scale force to mass.\n p.acc.scale p.massInv\n\n # Duplicate velocity to preserve momentum.\n vel.copy p.vel\n\n # Duplicate force.\n acc.copy p.acc\n\n # Update position.\n p.pos.add (vel.scale dt).add (acc.scale 0.5 * dtSq)\n\n # Update velocity.\n p.vel.add p.acc.scale dt\n\n # Apply friction.\n if drag then p.vel.scale drag\n\n # Reset forces.\n p.acc.clear()", "source_lang": "JavaScript", "target_lang": "CoffeeScript", "repo": "soulwire/Coffee-Physics", "path": "source/engine/integrator/ImprovedEuler.coffee", "license": "MIT", "commit": "df9d43d3153dfc6a734fef1b24eb5a90c2c61e4d", "stars": 1053, "source_url": "https://github.com/soulwire/Coffee-Physics/blob/df9d43d3153dfc6a734fef1b24eb5a90c2c61e4d/source/engine/integrator/ImprovedEuler.coffee", "line_start": 1, "line_end": 39}229{"id": "soulwire/Coffee-Physics:source/engine/integrator/ImprovedEuler.coffee:1:completion", "type": "completion", "prompt": "### Improved Euler Integrator ###\n\nclass ImprovedEuler extends Integrator\n\n # x += (v * dt) + (a * 0.5 * dt * dt)\n # v += a * dt\n\n integrate: (particles, dt, drag) ->\n\n acc = new Vector()\n vel = new Vector()\n\n dtSq = dt * dt\n\n for p in particles when not p.fixed\n\n # Store previous location.\n p.old.pos.copy p.pos", "response": "# Scale force to mass.\n p.acc.scale p.massInv\n\n # Duplicate velocity to preserve momentum.\n vel.copy p.vel\n\n # Duplicate force.\n acc.copy p.acc\n\n # Update position.\n p.pos.add (vel.scale dt).add (acc.scale 0.5 * dtSq)\n\n # Update velocity.\n p.vel.add p.acc.scale dt\n\n # Apply friction.\n if drag then p.vel.scale drag\n\n # Reset forces.\n p.acc.clear()", "source_lang": "CoffeeScript", "target_lang": "CoffeeScript", "repo": "soulwire/Coffee-Physics", "path": "source/engine/integrator/ImprovedEuler.coffee", "license": "MIT", "commit": "df9d43d3153dfc6a734fef1b24eb5a90c2c61e4d", "stars": 1053, "source_url": "https://github.com/soulwire/Coffee-Physics/blob/df9d43d3153dfc6a734fef1b24eb5a90c2c61e4d/source/engine/integrator/ImprovedEuler.coffee", "line_start": 1, "line_end": 39}230{"id": "jianliaoim/talk-os:talk-account/client/entry/renderer.coffee:1:raw_corpus", "type": "raw_corpus", "prompt": "", "response": "Err = require 'err1st'\nconfig = require 'config'\nlogger = require 'graceful-logger'\nrecorder = require 'actions-recorder'\nImmutable = require 'immutable'\n\nroutes = require '../routes'\nschema = require '../schema'\nlocales = require '../locales'\ntemplate = require './template'\n\nrouterUtil = require 'router-view/lib/path'\n\nmodule.exports = (req, res) ->\n router = routerUtil.getCurrentInfo routes, req.originalUrl\n next_url = req.cookies?.next_url\n\n {accounts, user} = req.get()\n\n store = schema.store\n # 设置用户信息\n .set 'user', Immutable.fromJS user\n # 设置路由\n .set 'router', router\n # configured siteUrl for redirecting\n .setIn ['client', 'siteUrl'], config.siteUrl\n .setIn ['config', 'siteUrl'], config.siteUrl\n .setIn ['config', 'accountUrl'], config.accountUrl\n .setIn ['config', 'cookieDomain'], config.cookieDomain\n .setIn ['config', 'weiboLogin'], config.weiboLogin\n .setIn ['config', 'firimLogin'], config.firimLogin\n .setIn ['config', 'githubLogin'], config.githubLogin\n .setIn ['config', 'trelloLogin'], config.trelloLogin\n .setIn ['config', 'teambitionLogin'], config.teambitionLogin\n # language detected from cookie and headers\n .setIn ['client', 'language'], req.getLocale()\n # /bind-thirdparty need an `method` for further behaviors\n .setIn ['client', 'serverAction'], (req.cookies?.method or null)\n # remember refer, client router will probably rewrite `query`\n .setIn ['client', 'referer'], router.getIn(['query', 'next_url']) or next_url\n # page of /accounts renders a list of accounts\n .setIn ['page', 'accounts'], Immutable.fromJS(accounts)\n .setIn ['client', 'captchaService'], config.captchaService\n\n if res.err?\n if res.err.code is 404\n res.status res.err.status\n store = store.set 'serverError', Immutable.fromJS\n status: 404\n message: locales.get('pageNotFound', req.getLocale())", "source_lang": "", "target_lang": "CoffeeScript", "repo": "jianliaoim/talk-os", "path": "talk-account/client/entry/renderer.coffee", "license": "MIT", "commit": "2545c4497865779a55762e03963a39237df9046b", "stars": 2703, "source_url": "https://github.com/jianliaoim/talk-os/blob/2545c4497865779a55762e03963a39237df9046b/talk-account/client/entry/renderer.coffee", "line_start": 1, "line_end": 50}231{"id": "jianliaoim/talk-os:talk-account/client/entry/renderer.coffee:1:coffee_to_js", "type": "coffee_to_js", "prompt": "Convert this CoffeeScript to JavaScript.\n```coffeescript\nErr = require 'err1st'\nconfig = require 'config'\nlogger = require 'graceful-logger'\nrecorder = require 'actions-recorder'\nImmutable = require 'immutable'\n\nroutes = require '../routes'\nschema = require '../schema'\nlocales = require '../locales'\ntemplate = require './template'\n\nrouterUtil = require 'router-view/lib/path'\n\nmodule.exports = (req, res) ->\n router = routerUtil.getCurrentInfo routes, req.originalUrl\n next_url = req.cookies?.next_url\n\n {accounts, user} = req.get()\n\n store = schema.store\n # 设置用户信息\n .set 'user', Immutable.fromJS user\n # 设置路由\n .set 'router', router\n # configured siteUrl for redirecting\n .setIn ['client', 'siteUrl'], config.siteUrl\n .setIn ['config', 'siteUrl'], config.siteUrl\n .setIn ['config', 'accountUrl'], config.accountUrl\n .setIn ['config', 'cookieDomain'], config.cookieDomain\n .setIn ['config', 'weiboLogin'], config.weiboLogin\n .setIn ['config', 'firimLogin'], config.firimLogin\n .setIn ['config', 'githubLogin'], config.githubLogin\n .setIn ['config', 'trelloLogin'], config.trelloLogin\n .setIn ['config', 'teambitionLogin'], config.teambitionLogin\n # language detected from cookie and headers\n .setIn ['client', 'language'], req.getLocale()\n # /bind-thirdparty need an `method` for further behaviors\n .setIn ['client', 'serverAction'], (req.cookies?.method or null)\n # remember refer, client router will probably rewrite `query`\n .setIn ['client', 'referer'], router.getIn(['query', 'next_url']) or next_url\n # page of /accounts renders a list of accounts\n .setIn ['page', 'accounts'], Immutable.fromJS(accounts)\n .setIn ['client', 'captchaService'], config.captchaService\n\n if res.err?\n if res.err.code is 404\n res.status res.err.status\n store = store.set 'serverError', Immutable.fromJS\n status: 404\n message: locales.get('pageNotFound', req.getLocale())\n```", "response": "var Err, Immutable, config, locales, logger, recorder, routerUtil, routes, schema, template;\n\nErr = require('err1st');\n\nconfig = require('config');\n\nlogger = require('graceful-logger');\n\nrecorder = require('actions-recorder');\n\nImmutable = require('immutable');\n\nroutes = require('../routes');\n\nschema = require('../schema');\n\nlocales = require('../locales');\n\ntemplate = require('./template');\n\nrouterUtil = require('router-view/lib/path');\n\nmodule.exports = function(req, res) {\n var accounts, next_url, ref, ref1, router, store, user;\n router = routerUtil.getCurrentInfo(routes, req.originalUrl);\n next_url = (ref = req.cookies) != null ? ref.next_url : void 0;\n ({accounts, user} = req.get());\n // 设置用户信息\n // 设置路由\n // configured siteUrl for redirecting\n // language detected from cookie and headers\n // /bind-thirdparty need an `method` for further behaviors\n // remember refer, client router will probably rewrite `query`\n // page of /accounts renders a list of accounts\n store = schema.store.set('user', Immutable.fromJS(user)).set('router', router).setIn(['client', 'siteUrl'], config.siteUrl).setIn(['config', 'siteUrl'], config.siteUrl).setIn(['config', 'accountUrl'], config.accountUrl).setIn(['config', 'cookieDomain'], config.cookieDomain).setIn(['config', 'weiboLogin'], config.weiboLogin).setIn(['config', 'firimLogin'], config.firimLogin).setIn(['config', 'githubLogin'], config.githubLogin).setIn(['config', 'trelloLogin'], config.trelloLogin).setIn(['config', 'teambitionLogin'], config.teambitionLogin).setIn(['client', 'language'], req.getLocale()).setIn(['client', 'serverAction'], ((ref1 = req.cookies) != null ? ref1.method : void 0) || null).setIn(['client', 'referer'], router.getIn(['query', 'next_url']) || next_url).setIn(['page', 'accounts'], Immutable.fromJS(accounts)).setIn(['client', 'captchaService'], config.captchaService);\n if (res.err != null) {\n if (res.err.code === 404) {\n res.status(res.err.status);\n return store = store.set('serverError', Immutable.fromJS({\n status: 404,\n message: locales.get('pageNotFound', req.getLocale())\n }));\n }\n }\n};", "source_lang": "CoffeeScript", "target_lang": "JavaScript", "repo": "jianliaoim/talk-os", "path": "talk-account/client/entry/renderer.coffee", "license": "MIT", "commit": "2545c4497865779a55762e03963a39237df9046b", "stars": 2703, "source_url": "https://github.com/jianliaoim/talk-os/blob/2545c4497865779a55762e03963a39237df9046b/talk-account/client/entry/renderer.coffee", "line_start": 1, "line_end": 50}232{"id": "jianliaoim/talk-os:talk-account/client/entry/renderer.coffee:1:js_to_coffee", "type": "js_to_coffee", "prompt": "Convert this JavaScript to CoffeeScript.\n```javascript\nvar Err, Immutable, config, locales, logger, recorder, routerUtil, routes, schema, template;\n\nErr = require('err1st');\n\nconfig = require('config');\n\nlogger = require('graceful-logger');\n\nrecorder = require('actions-recorder');\n\nImmutable = require('immutable');\n\nroutes = require('../routes');\n\nschema = require('../schema');\n\nlocales = require('../locales');\n\ntemplate = require('./template');\n\nrouterUtil = require('router-view/lib/path');\n\nmodule.exports = function(req, res) {\n var accounts, next_url, ref, ref1, router, store, user;\n router = routerUtil.getCurrentInfo(routes, req.originalUrl);\n next_url = (ref = req.cookies) != null ? ref.next_url : void 0;\n ({accounts, user} = req.get());\n // 设置用户信息\n // 设置路由\n // configured siteUrl for redirecting\n // language detected from cookie and headers\n // /bind-thirdparty need an `method` for further behaviors\n // remember refer, client router will probably rewrite `query`\n // page of /accounts renders a list of accounts\n store = schema.store.set('user', Immutable.fromJS(user)).set('router', router).setIn(['client', 'siteUrl'], config.siteUrl).setIn(['config', 'siteUrl'], config.siteUrl).setIn(['config', 'accountUrl'], config.accountUrl).setIn(['config', 'cookieDomain'], config.cookieDomain).setIn(['config', 'weiboLogin'], config.weiboLogin).setIn(['config', 'firimLogin'], config.firimLogin).setIn(['config', 'githubLogin'], config.githubLogin).setIn(['config', 'trelloLogin'], config.trelloLogin).setIn(['config', 'teambitionLogin'], config.teambitionLogin).setIn(['client', 'language'], req.getLocale()).setIn(['client', 'serverAction'], ((ref1 = req.cookies) != null ? ref1.method : void 0) || null).setIn(['client', 'referer'], router.getIn(['query', 'next_url']) || next_url).setIn(['page', 'accounts'], Immutable.fromJS(accounts)).setIn(['client', 'captchaService'], config.captchaService);\n if (res.err != null) {\n if (res.err.code === 404) {\n res.status(res.err.status);\n return store = store.set('serverError', Immutable.fromJS({\n status: 404,\n message: locales.get('pageNotFound', req.getLocale())\n }));\n }\n }\n};\n```", "response": "Err = require 'err1st'\nconfig = require 'config'\nlogger = require 'graceful-logger'\nrecorder = require 'actions-recorder'\nImmutable = require 'immutable'\n\nroutes = require '../routes'\nschema = require '../schema'\nlocales = require '../locales'\ntemplate = require './template'\n\nrouterUtil = require 'router-view/lib/path'\n\nmodule.exports = (req, res) ->\n router = routerUtil.getCurrentInfo routes, req.originalUrl\n next_url = req.cookies?.next_url\n\n {accounts, user} = req.get()\n\n store = schema.store\n # 设置用户信息\n .set 'user', Immutable.fromJS user\n # 设置路由\n .set 'router', router\n # configured siteUrl for redirecting\n .setIn ['client', 'siteUrl'], config.siteUrl\n .setIn ['config', 'siteUrl'], config.siteUrl\n .setIn ['config', 'accountUrl'], config.accountUrl\n .setIn ['config', 'cookieDomain'], config.cookieDomain\n .setIn ['config', 'weiboLogin'], config.weiboLogin\n .setIn ['config', 'firimLogin'], config.firimLogin\n .setIn ['config', 'githubLogin'], config.githubLogin\n .setIn ['config', 'trelloLogin'], config.trelloLogin\n .setIn ['config', 'teambitionLogin'], config.teambitionLogin\n # language detected from cookie and headers\n .setIn ['client', 'language'], req.getLocale()\n # /bind-thirdparty need an `method` for further behaviors\n .setIn ['client', 'serverAction'], (req.cookies?.method or null)\n # remember refer, client router will probably rewrite `query`\n .setIn ['client', 'referer'], router.getIn(['query', 'next_url']) or next_url\n # page of /accounts renders a list of accounts\n .setIn ['page', 'accounts'], Immutable.fromJS(accounts)\n .setIn ['client', 'captchaService'], config.captchaService\n\n if res.err?\n if res.err.code is 404\n res.status res.err.status\n store = store.set 'serverError', Immutable.fromJS\n status: 404\n message: locales.get('pageNotFound', req.getLocale())", "source_lang": "JavaScript", "target_lang": "CoffeeScript", "repo": "jianliaoim/talk-os", "path": "talk-account/client/entry/renderer.coffee", "license": "MIT", "commit": "2545c4497865779a55762e03963a39237df9046b", "stars": 2703, "source_url": "https://github.com/jianliaoim/talk-os/blob/2545c4497865779a55762e03963a39237df9046b/talk-account/client/entry/renderer.coffee", "line_start": 1, "line_end": 50}233{"id": "jianliaoim/talk-os:talk-account/client/entry/renderer.coffee:1:completion", "type": "completion", "prompt": "Err = require 'err1st'\nconfig = require 'config'\nlogger = require 'graceful-logger'\nrecorder = require 'actions-recorder'\nImmutable = require 'immutable'\n\nroutes = require '../routes'\nschema = require '../schema'\nlocales = require '../locales'\ntemplate = require './template'\n\nrouterUtil = require 'router-view/lib/path'\n\nmodule.exports = (req, res) ->\n router = routerUtil.getCurrentInfo routes, req.originalUrl\n next_url = req.cookies?.next_url\n\n {accounts, user} = req.get()\n\n store = schema.store\n # 设置用户信息\n .set 'user', Immutable.fromJS user\n # 设置路由\n .set 'router', router\n # configured siteUrl for redirecting", "response": ".setIn ['client', 'siteUrl'], config.siteUrl\n .setIn ['config', 'siteUrl'], config.siteUrl\n .setIn ['config', 'accountUrl'], config.accountUrl\n .setIn ['config', 'cookieDomain'], config.cookieDomain\n .setIn ['config', 'weiboLogin'], config.weiboLogin\n .setIn ['config', 'firimLogin'], config.firimLogin\n .setIn ['config', 'githubLogin'], config.githubLogin\n .setIn ['config', 'trelloLogin'], config.trelloLogin\n .setIn ['config', 'teambitionLogin'], config.teambitionLogin\n # language detected from cookie and headers\n .setIn ['client', 'language'], req.getLocale()\n # /bind-thirdparty need an `method` for further behaviors\n .setIn ['client', 'serverAction'], (req.cookies?.method or null)\n # remember refer, client router will probably rewrite `query`\n .setIn ['client', 'referer'], router.getIn(['query', 'next_url']) or next_url\n # page of /accounts renders a list of accounts\n .setIn ['page', 'accounts'], Immutable.fromJS(accounts)\n .setIn ['client', 'captchaService'], config.captchaService\n\n if res.err?\n if res.err.code is 404\n res.status res.err.status\n store = store.set 'serverError', Immutable.fromJS\n status: 404\n message: locales.get('pageNotFound', req.getLocale())", "source_lang": "CoffeeScript", "target_lang": "CoffeeScript", "repo": "jianliaoim/talk-os", "path": "talk-account/client/entry/renderer.coffee", "license": "MIT", "commit": "2545c4497865779a55762e03963a39237df9046b", "stars": 2703, "source_url": "https://github.com/jianliaoim/talk-os/blob/2545c4497865779a55762e03963a39237df9046b/talk-account/client/entry/renderer.coffee", "line_start": 1, "line_end": 50}234{"id": "jianliaoim/talk-os:talk-account/client/entry/renderer.coffee:2:raw_corpus", "type": "raw_corpus", "prompt": "", "response": "else\n err = new Err(res.err) unless res.err instanceof Err\n # copied logics to write status code\n logger.warn err.stack if config.debug or err.code is 100\n res.status err.status\n store = store.set 'serverError', Immutable.fromJS\n status: err.status\n message: err.message\n\n recorder.setup initial: store\n res.end template.render(recorder.getCore())", "source_lang": "", "target_lang": "CoffeeScript", "repo": "jianliaoim/talk-os", "path": "talk-account/client/entry/renderer.coffee", "license": "MIT", "commit": "2545c4497865779a55762e03963a39237df9046b", "stars": 2703, "source_url": "https://github.com/jianliaoim/talk-os/blob/2545c4497865779a55762e03963a39237df9046b/talk-account/client/entry/renderer.coffee", "line_start": 51, "line_end": 61}235{"id": "jianliaoim/talk-os:talk-account/client/entry/renderer.coffee:2:completion", "type": "completion", "prompt": "else\n err = new Err(res.err) unless res.err instanceof Err\n # copied logics to write status code\n logger.warn err.stack if config.debug or err.code is 100\n res.status err.status", "response": "store = store.set 'serverError', Immutable.fromJS\n status: err.status\n message: err.message\n\n recorder.setup initial: store\n res.end template.render(recorder.getCore())", "source_lang": "CoffeeScript", "target_lang": "CoffeeScript", "repo": "jianliaoim/talk-os", "path": "talk-account/client/entry/renderer.coffee", "license": "MIT", "commit": "2545c4497865779a55762e03963a39237df9046b", "stars": 2703, "source_url": "https://github.com/jianliaoim/talk-os/blob/2545c4497865779a55762e03963a39237df9046b/talk-account/client/entry/renderer.coffee", "line_start": 51, "line_end": 61}236{"id": "Glavin001/atom-beautify:src/beautifiers/uncrustify/index.coffee:1:raw_corpus", "type": "raw_corpus", "prompt": "", "response": "module.exports = class Uncrustify extends Beautifier\n name: \"Uncrustify\"\n link: \"https://github.com/uncrustify/uncrustify\"\n executables: [\n {\n name: \"Uncrustify\"\n cmd: \"uncrustify\"\n homepage: \"http://uncrustify.sourceforge.net/\"\n installation: \"https://github.com/uncrustify/uncrustify\"\n version: {\n parse: (text) ->\n try\n v = text.match(/uncrustify (\\d+\\.\\d+)/)[1]\n catch error\n @error(error)\n v = text.match(/Uncrustify-(\\d+\\.\\d+)/)[1] if not v?\n if v\n return v + \".0\"\n }\n docker: {\n image: \"unibeautify/uncrustify\"\n }\n }\n ]\n\n options: {\n Apex: true\n C: true\n \"C++\": true\n \"C#\": true\n \"Objective-C\": true\n D: true\n Pawn: true\n Vala: true\n Java: true\n Arduino: true\n }\n\n beautify: (text, language, options, context) ->\n fileExtension = context.fileExtension\n\n uncrustify = @exe(\"uncrustify\")\n # console.log('uncrustify.beautify', language, options)\n return new @Promise((resolve, reject) ->\n configPath = options.configPath\n unless configPath\n # No custom config path\n cfg options, (error, cPath) ->\n throw error if error\n resolve cPath", "source_lang": "", "target_lang": "CoffeeScript", "repo": "Glavin001/atom-beautify", "path": "src/beautifiers/uncrustify/index.coffee", "license": "MIT", "commit": "41d5051b399f7fe11efd149504a232df16179d60", "stars": 1503, "source_url": "https://github.com/Glavin001/atom-beautify/blob/41d5051b399f7fe11efd149504a232df16179d60/src/beautifiers/uncrustify/index.coffee", "line_start": 11, "line_end": 60}237{"id": "Glavin001/atom-beautify:src/beautifiers/uncrustify/index.coffee:1:completion", "type": "completion", "prompt": "module.exports = class Uncrustify extends Beautifier\n name: \"Uncrustify\"\n link: \"https://github.com/uncrustify/uncrustify\"\n executables: [\n {\n name: \"Uncrustify\"\n cmd: \"uncrustify\"\n homepage: \"http://uncrustify.sourceforge.net/\"\n installation: \"https://github.com/uncrustify/uncrustify\"\n version: {\n parse: (text) ->\n try\n v = text.match(/uncrustify (\\d+\\.\\d+)/)[1]\n catch error\n @error(error)\n v = text.match(/Uncrustify-(\\d+\\.\\d+)/)[1] if not v?\n if v\n return v + \".0\"\n }\n docker: {\n image: \"unibeautify/uncrustify\"\n }\n }\n ]", "response": "options: {\n Apex: true\n C: true\n \"C++\": true\n \"C#\": true\n \"Objective-C\": true\n D: true\n Pawn: true\n Vala: true\n Java: true\n Arduino: true\n }\n\n beautify: (text, language, options, context) ->\n fileExtension = context.fileExtension\n\n uncrustify = @exe(\"uncrustify\")\n # console.log('uncrustify.beautify', language, options)\n return new @Promise((resolve, reject) ->\n configPath = options.configPath\n unless configPath\n # No custom config path\n cfg options, (error, cPath) ->\n throw error if error\n resolve cPath", "source_lang": "CoffeeScript", "target_lang": "CoffeeScript", "repo": "Glavin001/atom-beautify", "path": "src/beautifiers/uncrustify/index.coffee", "license": "MIT", "commit": "41d5051b399f7fe11efd149504a232df16179d60", "stars": 1503, "source_url": "https://github.com/Glavin001/atom-beautify/blob/41d5051b399f7fe11efd149504a232df16179d60/src/beautifiers/uncrustify/index.coffee", "line_start": 11, "line_end": 60}238{"id": "Glavin001/atom-beautify:src/beautifiers/uncrustify/index.coffee:2:raw_corpus", "type": "raw_corpus", "prompt": "", "response": "else\n # Has custom config path\n editor = atom.workspace.getActiveTextEditor()\n if editor?\n basePath = path.dirname(editor.getPath())\n projectPath = atom.workspace.project.getPaths()[0]\n # console.log(basePath);\n # Expand Home Directory in Config Path\n expandedConfigPath = expandHomeDir(configPath)\n configPath = path.resolve(projectPath, expandedConfigPath)\n resolve configPath\n else\n reject(new Error(\"No Uncrustify Config Path set! Please configure Uncrustify with Atom Beautify.\"))\n )\n .then((configPath) =>\n # Select Uncrustify language\n lang = \"C\" # Default is C\n switch language\n when \"Apex\"\n lang = \"Apex\"\n when \"C\"\n lang = \"C\"\n when \"C++\"\n lang = \"CPP\"\n when \"C#\"\n lang = \"CS\"\n when \"Objective-C\", \"Objective-C++\"\n lang = \"OC+\"\n when \"D\"\n lang = \"D\"\n when \"Pawn\"\n lang = \"PAWN\"\n when \"Vala\"\n lang = \"VALA\"\n when \"Java\"\n lang = \"JAVA\"\n when \"Arduino\"\n lang = \"CPP\"\n\n uncrustify.run([\n \"-c\"\n configPath\n \"-f\"\n @tempFile(\"input\", text, fileExtension and \".#{fileExtension}\")\n \"-o\"\n outputFile = @tempFile(\"output\", text, fileExtension and \".#{fileExtension}\")\n \"-l\"\n lang\n ])\n .then(=>", "source_lang": "", "target_lang": "CoffeeScript", "repo": "Glavin001/atom-beautify", "path": "src/beautifiers/uncrustify/index.coffee", "license": "MIT", "commit": "41d5051b399f7fe11efd149504a232df16179d60", "stars": 1503, "source_url": "https://github.com/Glavin001/atom-beautify/blob/41d5051b399f7fe11efd149504a232df16179d60/src/beautifiers/uncrustify/index.coffee", "line_start": 61, "line_end": 110}239{"id": "Glavin001/atom-beautify:src/beautifiers/uncrustify/index.coffee:2:completion", "type": "completion", "prompt": "else\n # Has custom config path\n editor = atom.workspace.getActiveTextEditor()\n if editor?\n basePath = path.dirname(editor.getPath())\n projectPath = atom.workspace.project.getPaths()[0]\n # console.log(basePath);\n # Expand Home Directory in Config Path\n expandedConfigPath = expandHomeDir(configPath)\n configPath = path.resolve(projectPath, expandedConfigPath)\n resolve configPath\n else\n reject(new Error(\"No Uncrustify Config Path set! Please configure Uncrustify with Atom Beautify.\"))\n )\n .then((configPath) =>\n # Select Uncrustify language\n lang = \"C\" # Default is C\n switch language\n when \"Apex\"\n lang = \"Apex\"\n when \"C\"\n lang = \"C\"\n when \"C++\"\n lang = \"CPP\"\n when \"C#\"", "response": "lang = \"CS\"\n when \"Objective-C\", \"Objective-C++\"\n lang = \"OC+\"\n when \"D\"\n lang = \"D\"\n when \"Pawn\"\n lang = \"PAWN\"\n when \"Vala\"\n lang = \"VALA\"\n when \"Java\"\n lang = \"JAVA\"\n when \"Arduino\"\n lang = \"CPP\"\n\n uncrustify.run([\n \"-c\"\n configPath\n \"-f\"\n @tempFile(\"input\", text, fileExtension and \".#{fileExtension}\")\n \"-o\"\n outputFile = @tempFile(\"output\", text, fileExtension and \".#{fileExtension}\")\n \"-l\"\n lang\n ])\n .then(=>", "source_lang": "CoffeeScript", "target_lang": "CoffeeScript", "repo": "Glavin001/atom-beautify", "path": "src/beautifiers/uncrustify/index.coffee", "license": "MIT", "commit": "41d5051b399f7fe11efd149504a232df16179d60", "stars": 1503, "source_url": "https://github.com/Glavin001/atom-beautify/blob/41d5051b399f7fe11efd149504a232df16179d60/src/beautifiers/uncrustify/index.coffee", "line_start": 61, "line_end": 110}240{"id": "Glavin001/atom-beautify:src/beautifiers/uncrustify/index.coffee:1:raw_corpus", "type": "raw_corpus", "prompt": "", "response": "module.exports = class Uncrustify extends Beautifier\n name: \"Uncrustify\"\n link: \"https://github.com/uncrustify/uncrustify\"\n executables: [\n {\n name: \"Uncrustify\"\n cmd: \"uncrustify\"\n homepage: \"http://uncrustify.sourceforge.net/\"\n installation: \"https://github.com/uncrustify/uncrustify\"\n version: {\n parse: (text) ->\n try\n v = text.match(/uncrustify (\\d+\\.\\d+)/)[1]\n catch error\n @error(error)\n v = text.match(/Uncrustify-(\\d+\\.\\d+)/)[1] if not v?\n if v\n return v + \".0\"\n }\n docker: {\n image: \"unibeautify/uncrustify\"\n }\n }\n ]\n\n options: {\n Apex: true\n C: true\n \"C++\": true\n \"C#\": true\n \"Objective-C\": true\n D: true\n Pawn: true\n Vala: true\n Java: true\n Arduino: true\n }\n\n beautify: (text, language, options) ->\n uncrustify = @exe(\"uncrustify\")\n # console.log('uncrustify.beautify', language, options)\n return new @Promise((resolve, reject) ->\n configPath = options.configPath\n unless configPath\n # No custom config path\n cfg options, (error, cPath) ->\n throw error if error\n resolve cPath\n else\n # Has custom config path", "source_lang": "", "target_lang": "CoffeeScript", "repo": "Glavin001/atom-beautify", "path": "src/beautifiers/uncrustify/index.coffee", "license": "MIT", "commit": "baca098a91c33e1bbc39fe7f78c27db2c36ba3b3", "stars": 1503, "source_url": "https://github.com/Glavin001/atom-beautify/blob/baca098a91c33e1bbc39fe7f78c27db2c36ba3b3/src/beautifiers/uncrustify/index.coffee", "line_start": 11, "line_end": 60}241{"id": "Glavin001/atom-beautify:src/beautifiers/uncrustify/index.coffee:1:completion", "type": "completion", "prompt": "module.exports = class Uncrustify extends Beautifier\n name: \"Uncrustify\"\n link: \"https://github.com/uncrustify/uncrustify\"\n executables: [\n {\n name: \"Uncrustify\"\n cmd: \"uncrustify\"\n homepage: \"http://uncrustify.sourceforge.net/\"\n installation: \"https://github.com/uncrustify/uncrustify\"\n version: {\n parse: (text) ->\n try\n v = text.match(/uncrustify (\\d+\\.\\d+)/)[1]\n catch error\n @error(error)\n v = text.match(/Uncrustify-(\\d+\\.\\d+)/)[1] if not v?\n if v\n return v + \".0\"\n }\n docker: {\n image: \"unibeautify/uncrustify\"\n }\n }\n ]", "response": "options: {\n Apex: true\n C: true\n \"C++\": true\n \"C#\": true\n \"Objective-C\": true\n D: true\n Pawn: true\n Vala: true\n Java: true\n Arduino: true\n }\n\n beautify: (text, language, options) ->\n uncrustify = @exe(\"uncrustify\")\n # console.log('uncrustify.beautify', language, options)\n return new @Promise((resolve, reject) ->\n configPath = options.configPath\n unless configPath\n # No custom config path\n cfg options, (error, cPath) ->\n throw error if error\n resolve cPath\n else\n # Has custom config path", "source_lang": "CoffeeScript", "target_lang": "CoffeeScript", "repo": "Glavin001/atom-beautify", "path": "src/beautifiers/uncrustify/index.coffee", "license": "MIT", "commit": "baca098a91c33e1bbc39fe7f78c27db2c36ba3b3", "stars": 1503, "source_url": "https://github.com/Glavin001/atom-beautify/blob/baca098a91c33e1bbc39fe7f78c27db2c36ba3b3/src/beautifiers/uncrustify/index.coffee", "line_start": 11, "line_end": 60}242{"id": "Glavin001/atom-beautify:src/beautifiers/uncrustify/index.coffee:2:raw_corpus", "type": "raw_corpus", "prompt": "", "response": "editor = atom.workspace.getActiveTextEditor()\n if editor?\n basePath = path.dirname(editor.getPath())\n projectPath = atom.workspace.project.getPaths()[0]\n # console.log(basePath);\n # Expand Home Directory in Config Path\n expandedConfigPath = expandHomeDir(configPath)\n configPath = path.resolve(projectPath, expandedConfigPath)\n resolve configPath\n else\n reject(new Error(\"No Uncrustify Config Path set! Please configure Uncrustify with Atom Beautify.\"))\n )\n .then((configPath) =>\n # Select Uncrustify language\n lang = \"C\" # Default is C\n switch language\n when \"Apex\"\n lang = \"Apex\"\n when \"C\"\n lang = \"C\"\n when \"C++\"\n lang = \"CPP\"\n when \"C#\"\n lang = \"CS\"\n when \"Objective-C\", \"Objective-C++\"\n lang = \"OC+\"\n when \"D\"\n lang = \"D\"\n when \"Pawn\"\n lang = \"PAWN\"\n when \"Vala\"\n lang = \"VALA\"\n when \"Java\"\n lang = \"JAVA\"\n when \"Arduino\"\n lang = \"CPP\"\n\n uncrustify.run([\n \"-c\"\n configPath\n \"-f\"\n @tempFile(\"input\", text)\n \"-o\"\n outputFile = @tempFile(\"output\", text)\n \"-l\"\n lang\n ])\n .then(=>\n @readFile(outputFile)\n )", "source_lang": "", "target_lang": "CoffeeScript", "repo": "Glavin001/atom-beautify", "path": "src/beautifiers/uncrustify/index.coffee", "license": "MIT", "commit": "baca098a91c33e1bbc39fe7f78c27db2c36ba3b3", "stars": 1503, "source_url": "https://github.com/Glavin001/atom-beautify/blob/baca098a91c33e1bbc39fe7f78c27db2c36ba3b3/src/beautifiers/uncrustify/index.coffee", "line_start": 61, "line_end": 110}243{"id": "Glavin001/atom-beautify:src/beautifiers/uncrustify/index.coffee:2:completion", "type": "completion", "prompt": "editor = atom.workspace.getActiveTextEditor()\n if editor?\n basePath = path.dirname(editor.getPath())\n projectPath = atom.workspace.project.getPaths()[0]\n # console.log(basePath);\n # Expand Home Directory in Config Path\n expandedConfigPath = expandHomeDir(configPath)\n configPath = path.resolve(projectPath, expandedConfigPath)\n resolve configPath\n else\n reject(new Error(\"No Uncrustify Config Path set! Please configure Uncrustify with Atom Beautify.\"))\n )\n .then((configPath) =>\n # Select Uncrustify language\n lang = \"C\" # Default is C\n switch language\n when \"Apex\"\n lang = \"Apex\"\n when \"C\"\n lang = \"C\"\n when \"C++\"\n lang = \"CPP\"\n when \"C#\"\n lang = \"CS\"\n when \"Objective-C\", \"Objective-C++\"", "response": "lang = \"OC+\"\n when \"D\"\n lang = \"D\"\n when \"Pawn\"\n lang = \"PAWN\"\n when \"Vala\"\n lang = \"VALA\"\n when \"Java\"\n lang = \"JAVA\"\n when \"Arduino\"\n lang = \"CPP\"\n\n uncrustify.run([\n \"-c\"\n configPath\n \"-f\"\n @tempFile(\"input\", text)\n \"-o\"\n outputFile = @tempFile(\"output\", text)\n \"-l\"\n lang\n ])\n .then(=>\n @readFile(outputFile)\n )", "source_lang": "CoffeeScript", "target_lang": "CoffeeScript", "repo": "Glavin001/atom-beautify", "path": "src/beautifiers/uncrustify/index.coffee", "license": "MIT", "commit": "baca098a91c33e1bbc39fe7f78c27db2c36ba3b3", "stars": 1503, "source_url": "https://github.com/Glavin001/atom-beautify/blob/baca098a91c33e1bbc39fe7f78c27db2c36ba3b3/src/beautifiers/uncrustify/index.coffee", "line_start": 61, "line_end": 110}244{"id": "Glavin001/atom-beautify:src/beautifiers/uncrustify/index.coffee:1:raw_corpus", "type": "raw_corpus", "prompt": "", "response": "module.exports = class Uncrustify extends Beautifier\n name: \"Uncrustify\"\n link: \"https://github.com/uncrustify/uncrustify\"\n executables: [\n {\n name: \"Uncrustify\"\n cmd: \"uncrustify\"\n homepage: \"http://uncrustify.sourceforge.net/\"\n installation: \"https://github.com/uncrustify/uncrustify\"\n version: {\n parse: (text) ->\n try\n v = text.match(/uncrustify (\\d+\\.\\d+)/)[1]\n catch error\n @error(error)\n v = text.match(/Uncrustify-(\\d+\\.\\d+)/)[1] if not v?\n if v\n return v + \".0\"\n }\n }\n ]\n\n options: {\n Apex: true\n C: true\n \"C++\": true\n \"C#\": true\n \"Objective-C\": true\n D: true\n Pawn: true\n Vala: true\n Java: true\n Arduino: true\n }\n\n beautify: (text, language, options) ->\n uncrustify = @exe(\"uncrustify\")\n # console.log('uncrustify.beautify', language, options)\n return new @Promise((resolve, reject) ->\n configPath = options.configPath\n unless configPath\n # No custom config path\n cfg options, (error, cPath) ->\n throw error if error\n resolve cPath\n else\n # Has custom config path\n editor = atom.workspace.getActiveTextEditor()\n if editor?\n basePath = path.dirname(editor.getPath())", "source_lang": "", "target_lang": "CoffeeScript", "repo": "Glavin001/atom-beautify", "path": "src/beautifiers/uncrustify/index.coffee", "license": "MIT", "commit": "d99b43cb16175a39dac05442cd7dcb43836a70a6", "stars": 1503, "source_url": "https://github.com/Glavin001/atom-beautify/blob/d99b43cb16175a39dac05442cd7dcb43836a70a6/src/beautifiers/uncrustify/index.coffee", "line_start": 11, "line_end": 60}245{"id": "Glavin001/atom-beautify:src/beautifiers/uncrustify/index.coffee:1:completion", "type": "completion", "prompt": "module.exports = class Uncrustify extends Beautifier\n name: \"Uncrustify\"\n link: \"https://github.com/uncrustify/uncrustify\"\n executables: [\n {\n name: \"Uncrustify\"\n cmd: \"uncrustify\"\n homepage: \"http://uncrustify.sourceforge.net/\"\n installation: \"https://github.com/uncrustify/uncrustify\"\n version: {\n parse: (text) ->\n try\n v = text.match(/uncrustify (\\d+\\.\\d+)/)[1]\n catch error\n @error(error)\n v = text.match(/Uncrustify-(\\d+\\.\\d+)/)[1] if not v?\n if v\n return v + \".0\"\n }\n }\n ]\n\n options: {\n Apex: true\n C: true", "response": "\"C++\": true\n \"C#\": true\n \"Objective-C\": true\n D: true\n Pawn: true\n Vala: true\n Java: true\n Arduino: true\n }\n\n beautify: (text, language, options) ->\n uncrustify = @exe(\"uncrustify\")\n # console.log('uncrustify.beautify', language, options)\n return new @Promise((resolve, reject) ->\n configPath = options.configPath\n unless configPath\n # No custom config path\n cfg options, (error, cPath) ->\n throw error if error\n resolve cPath\n else\n # Has custom config path\n editor = atom.workspace.getActiveTextEditor()\n if editor?\n basePath = path.dirname(editor.getPath())", "source_lang": "CoffeeScript", "target_lang": "CoffeeScript", "repo": "Glavin001/atom-beautify", "path": "src/beautifiers/uncrustify/index.coffee", "license": "MIT", "commit": "d99b43cb16175a39dac05442cd7dcb43836a70a6", "stars": 1503, "source_url": "https://github.com/Glavin001/atom-beautify/blob/d99b43cb16175a39dac05442cd7dcb43836a70a6/src/beautifiers/uncrustify/index.coffee", "line_start": 11, "line_end": 60}246{"id": "Glavin001/atom-beautify:src/beautifiers/uncrustify/index.coffee:2:raw_corpus", "type": "raw_corpus", "prompt": "", "response": "projectPath = atom.workspace.project.getPaths()[0]\n # console.log(basePath);\n # Expand Home Directory in Config Path\n expandedConfigPath = expandHomeDir(configPath)\n configPath = path.resolve(projectPath, expandedConfigPath)\n resolve configPath\n else\n reject(new Error(\"No Uncrustify Config Path set! Please configure Uncrustify with Atom Beautify.\"))\n )\n .then((configPath) =>\n # Select Uncrustify language\n lang = \"C\" # Default is C\n switch language\n when \"Apex\"\n lang = \"Apex\"\n when \"C\"\n lang = \"C\"\n when \"C++\"\n lang = \"CPP\"\n when \"C#\"\n lang = \"CS\"\n when \"Objective-C\", \"Objective-C++\"\n lang = \"OC+\"\n when \"D\"\n lang = \"D\"\n when \"Pawn\"\n lang = \"PAWN\"\n when \"Vala\"\n lang = \"VALA\"\n when \"Java\"\n lang = \"JAVA\"\n when \"Arduino\"\n lang = \"CPP\"\n\n uncrustify.run([\n \"-c\"\n configPath\n \"-f\"\n @tempFile(\"input\", text)\n \"-o\"\n outputFile = @tempFile(\"output\", text)\n \"-l\"\n lang\n ])\n .then(=>\n @readFile(outputFile)\n )\n )", "source_lang": "", "target_lang": "CoffeeScript", "repo": "Glavin001/atom-beautify", "path": "src/beautifiers/uncrustify/index.coffee", "license": "MIT", "commit": "d99b43cb16175a39dac05442cd7dcb43836a70a6", "stars": 1503, "source_url": "https://github.com/Glavin001/atom-beautify/blob/d99b43cb16175a39dac05442cd7dcb43836a70a6/src/beautifiers/uncrustify/index.coffee", "line_start": 61, "line_end": 108}247{"id": "Glavin001/atom-beautify:src/beautifiers/uncrustify/index.coffee:2:completion", "type": "completion", "prompt": "projectPath = atom.workspace.project.getPaths()[0]\n # console.log(basePath);\n # Expand Home Directory in Config Path\n expandedConfigPath = expandHomeDir(configPath)\n configPath = path.resolve(projectPath, expandedConfigPath)\n resolve configPath\n else\n reject(new Error(\"No Uncrustify Config Path set! Please configure Uncrustify with Atom Beautify.\"))\n )\n .then((configPath) =>\n # Select Uncrustify language\n lang = \"C\" # Default is C\n switch language\n when \"Apex\"\n lang = \"Apex\"\n when \"C\"\n lang = \"C\"\n when \"C++\"\n lang = \"CPP\"\n when \"C#\"\n lang = \"CS\"\n when \"Objective-C\", \"Objective-C++\"\n lang = \"OC+\"\n when \"D\"", "response": "lang = \"D\"\n when \"Pawn\"\n lang = \"PAWN\"\n when \"Vala\"\n lang = \"VALA\"\n when \"Java\"\n lang = \"JAVA\"\n when \"Arduino\"\n lang = \"CPP\"\n\n uncrustify.run([\n \"-c\"\n configPath\n \"-f\"\n @tempFile(\"input\", text)\n \"-o\"\n outputFile = @tempFile(\"output\", text)\n \"-l\"\n lang\n ])\n .then(=>\n @readFile(outputFile)\n )\n )", "source_lang": "CoffeeScript", "target_lang": "CoffeeScript", "repo": "Glavin001/atom-beautify", "path": "src/beautifiers/uncrustify/index.coffee", "license": "MIT", "commit": "d99b43cb16175a39dac05442cd7dcb43836a70a6", "stars": 1503, "source_url": "https://github.com/Glavin001/atom-beautify/blob/d99b43cb16175a39dac05442cd7dcb43836a70a6/src/beautifiers/uncrustify/index.coffee", "line_start": 61, "line_end": 108}248{"id": "Glavin001/atom-beautify:src/beautifiers/uncrustify/index.coffee:1:raw_corpus", "type": "raw_corpus", "prompt": "", "response": "module.exports = class Uncrustify extends Beautifier\n name: \"Uncrustify\"\n link: \"https://github.com/uncrustify/uncrustify\"\n executables: [\n {\n name: \"Uncrustify\"\n cmd: \"uncrustify\"\n homepage: \"http://uncrustify.sourceforge.net/\"\n installation: \"https://github.com/uncrustify/uncrustify\"\n version: {\n parse: (text) -> text.match(/uncrustify (\\d+\\.\\d+)/)[1] + \".0\"\n }\n }\n ]\n\n options: {\n Apex: true\n C: true\n \"C++\": true\n \"C#\": true\n \"Objective-C\": true\n D: true\n Pawn: true\n Vala: true\n Java: true\n Arduino: true\n }\n\n beautify: (text, language, options) ->\n uncrustify = @exe(\"uncrustify\")\n # console.log('uncrustify.beautify', language, options)\n return new @Promise((resolve, reject) ->\n configPath = options.configPath\n unless configPath\n # No custom config path\n cfg options, (error, cPath) ->\n throw error if error\n resolve cPath\n else\n # Has custom config path\n editor = atom.workspace.getActiveTextEditor()\n if editor?\n basePath = path.dirname(editor.getPath())\n projectPath = atom.workspace.project.getPaths()[0]\n # console.log(basePath);\n # Expand Home Directory in Config Path\n expandedConfigPath = expandHomeDir(configPath)\n configPath = path.resolve(projectPath, expandedConfigPath)\n resolve configPath\n else", "source_lang": "", "target_lang": "CoffeeScript", "repo": "Glavin001/atom-beautify", "path": "src/beautifiers/uncrustify/index.coffee", "license": "MIT", "commit": "9144df29a194ee2cb24a242818b77341a0051bbf", "stars": 1503, "source_url": "https://github.com/Glavin001/atom-beautify/blob/9144df29a194ee2cb24a242818b77341a0051bbf/src/beautifiers/uncrustify/index.coffee", "line_start": 11, "line_end": 60}249{"id": "Glavin001/atom-beautify:src/beautifiers/uncrustify/index.coffee:1:completion", "type": "completion", "prompt": "module.exports = class Uncrustify extends Beautifier\n name: \"Uncrustify\"\n link: \"https://github.com/uncrustify/uncrustify\"\n executables: [\n {\n name: \"Uncrustify\"\n cmd: \"uncrustify\"\n homepage: \"http://uncrustify.sourceforge.net/\"\n installation: \"https://github.com/uncrustify/uncrustify\"\n version: {\n parse: (text) -> text.match(/uncrustify (\\d+\\.\\d+)/)[1] + \".0\"\n }\n }\n ]\n\n options: {\n Apex: true\n C: true\n \"C++\": true\n \"C#\": true\n \"Objective-C\": true\n D: true\n Pawn: true\n Vala: true\n Java: true", "response": "Arduino: true\n }\n\n beautify: (text, language, options) ->\n uncrustify = @exe(\"uncrustify\")\n # console.log('uncrustify.beautify', language, options)\n return new @Promise((resolve, reject) ->\n configPath = options.configPath\n unless configPath\n # No custom config path\n cfg options, (error, cPath) ->\n throw error if error\n resolve cPath\n else\n # Has custom config path\n editor = atom.workspace.getActiveTextEditor()\n if editor?\n basePath = path.dirname(editor.getPath())\n projectPath = atom.workspace.project.getPaths()[0]\n # console.log(basePath);\n # Expand Home Directory in Config Path\n expandedConfigPath = expandHomeDir(configPath)\n configPath = path.resolve(projectPath, expandedConfigPath)\n resolve configPath\n else", "source_lang": "CoffeeScript", "target_lang": "CoffeeScript", "repo": "Glavin001/atom-beautify", "path": "src/beautifiers/uncrustify/index.coffee", "license": "MIT", "commit": "9144df29a194ee2cb24a242818b77341a0051bbf", "stars": 1503, "source_url": "https://github.com/Glavin001/atom-beautify/blob/9144df29a194ee2cb24a242818b77341a0051bbf/src/beautifiers/uncrustify/index.coffee", "line_start": 11, "line_end": 60}250{"id": "Glavin001/atom-beautify:src/beautifiers/uncrustify/index.coffee:2:raw_corpus", "type": "raw_corpus", "prompt": "", "response": "reject(new Error(\"No Uncrustify Config Path set! Please configure Uncrustify with Atom Beautify.\"))\n )\n .then((configPath) =>\n # Select Uncrustify language\n lang = \"C\" # Default is C\n switch language\n when \"Apex\"\n lang = \"Apex\"\n when \"C\"\n lang = \"C\"\n when \"C++\"\n lang = \"CPP\"\n when \"C#\"\n lang = \"CS\"\n when \"Objective-C\", \"Objective-C++\"\n lang = \"OC+\"\n when \"D\"\n lang = \"D\"\n when \"Pawn\"\n lang = \"PAWN\"\n when \"Vala\"\n lang = \"VALA\"\n when \"Java\"\n lang = \"JAVA\"\n when \"Arduino\"\n lang = \"CPP\"\n\n uncrustify.run([\n \"-c\"\n configPath\n \"-f\"\n @tempFile(\"input\", text)\n \"-o\"\n outputFile = @tempFile(\"output\", text)\n \"-l\"\n lang\n ], help: {\n link: \"http://sourceforge.net/projects/uncrustify/\"\n })\n .then(=>\n @readFile(outputFile)\n )\n )", "source_lang": "", "target_lang": "CoffeeScript", "repo": "Glavin001/atom-beautify", "path": "src/beautifiers/uncrustify/index.coffee", "license": "MIT", "commit": "9144df29a194ee2cb24a242818b77341a0051bbf", "stars": 1503, "source_url": "https://github.com/Glavin001/atom-beautify/blob/9144df29a194ee2cb24a242818b77341a0051bbf/src/beautifiers/uncrustify/index.coffee", "line_start": 61, "line_end": 103}251{"id": "Glavin001/atom-beautify:src/beautifiers/uncrustify/index.coffee:2:completion", "type": "completion", "prompt": "reject(new Error(\"No Uncrustify Config Path set! Please configure Uncrustify with Atom Beautify.\"))\n )\n .then((configPath) =>\n # Select Uncrustify language\n lang = \"C\" # Default is C\n switch language\n when \"Apex\"\n lang = \"Apex\"\n when \"C\"\n lang = \"C\"\n when \"C++\"\n lang = \"CPP\"\n when \"C#\"\n lang = \"CS\"\n when \"Objective-C\", \"Objective-C++\"\n lang = \"OC+\"\n when \"D\"\n lang = \"D\"\n when \"Pawn\"\n lang = \"PAWN\"\n when \"Vala\"", "response": "lang = \"VALA\"\n when \"Java\"\n lang = \"JAVA\"\n when \"Arduino\"\n lang = \"CPP\"\n\n uncrustify.run([\n \"-c\"\n configPath\n \"-f\"\n @tempFile(\"input\", text)\n \"-o\"\n outputFile = @tempFile(\"output\", text)\n \"-l\"\n lang\n ], help: {\n link: \"http://sourceforge.net/projects/uncrustify/\"\n })\n .then(=>\n @readFile(outputFile)\n )\n )", "source_lang": "CoffeeScript", "target_lang": "CoffeeScript", "repo": "Glavin001/atom-beautify", "path": "src/beautifiers/uncrustify/index.coffee", "license": "MIT", "commit": "9144df29a194ee2cb24a242818b77341a0051bbf", "stars": 1503, "source_url": "https://github.com/Glavin001/atom-beautify/blob/9144df29a194ee2cb24a242818b77341a0051bbf/src/beautifiers/uncrustify/index.coffee", "line_start": 61, "line_end": 103}252{"id": "Glavin001/atom-beautify:src/beautifiers/uncrustify/index.coffee:1:raw_corpus", "type": "raw_corpus", "prompt": "", "response": "module.exports = class Uncrustify extends Beautifier\n name: \"Uncrustify\"\n link: \"https://github.com/uncrustify/uncrustify\"\n isPreInstalled: false\n\n options: {\n Apex: true\n C: true\n \"C++\": true\n \"C#\": true\n \"Objective-C\": true\n D: true\n Pawn: true\n Vala: true\n Java: true\n Arduino: true\n }\n\n beautify: (text, language, options) ->\n # console.log('uncrustify.beautify', language, options)\n return new @Promise((resolve, reject) ->\n configPath = options.configPath\n unless configPath\n # No custom config path\n cfg options, (error, cPath) ->\n throw error if error\n resolve cPath\n else\n # Has custom config path\n editor = atom.workspace.getActiveTextEditor()\n if editor?\n basePath = path.dirname(editor.getPath())\n projectPath = atom.workspace.project.getPaths()[0]\n # console.log(basePath);\n # Expand Home Directory in Config Path\n expandedConfigPath = expandHomeDir(configPath)\n configPath = path.resolve(projectPath, expandedConfigPath)\n resolve configPath\n else\n reject(new Error(\"No Uncrustify Config Path set! Please configure Uncrustify with Atom Beautify.\"))\n )\n .then((configPath) =>\n\n\n # Select Uncrustify language\n lang = \"C\" # Default is C\n switch language\n when \"Apex\"\n lang = \"Apex\"\n when \"C\"", "source_lang": "", "target_lang": "CoffeeScript", "repo": "Glavin001/atom-beautify", "path": "src/beautifiers/uncrustify/index.coffee", "license": "MIT", "commit": "ba2198675cbcc1ecd05f18e28e97133cdd2d5319", "stars": 1503, "source_url": "https://github.com/Glavin001/atom-beautify/blob/ba2198675cbcc1ecd05f18e28e97133cdd2d5319/src/beautifiers/uncrustify/index.coffee", "line_start": 11, "line_end": 60}253{"id": "Glavin001/atom-beautify:src/beautifiers/uncrustify/index.coffee:1:completion", "type": "completion", "prompt": "module.exports = class Uncrustify extends Beautifier\n name: \"Uncrustify\"\n link: \"https://github.com/uncrustify/uncrustify\"\n isPreInstalled: false\n\n options: {\n Apex: true\n C: true\n \"C++\": true\n \"C#\": true\n \"Objective-C\": true\n D: true\n Pawn: true\n Vala: true\n Java: true\n Arduino: true\n }\n\n beautify: (text, language, options) ->\n # console.log('uncrustify.beautify', language, options)\n return new @Promise((resolve, reject) ->\n configPath = options.configPath\n unless configPath\n # No custom config path\n cfg options, (error, cPath) ->", "response": "throw error if error\n resolve cPath\n else\n # Has custom config path\n editor = atom.workspace.getActiveTextEditor()\n if editor?\n basePath = path.dirname(editor.getPath())\n projectPath = atom.workspace.project.getPaths()[0]\n # console.log(basePath);\n # Expand Home Directory in Config Path\n expandedConfigPath = expandHomeDir(configPath)\n configPath = path.resolve(projectPath, expandedConfigPath)\n resolve configPath\n else\n reject(new Error(\"No Uncrustify Config Path set! Please configure Uncrustify with Atom Beautify.\"))\n )\n .then((configPath) =>\n\n\n # Select Uncrustify language\n lang = \"C\" # Default is C\n switch language\n when \"Apex\"\n lang = \"Apex\"\n when \"C\"", "source_lang": "CoffeeScript", "target_lang": "CoffeeScript", "repo": "Glavin001/atom-beautify", "path": "src/beautifiers/uncrustify/index.coffee", "license": "MIT", "commit": "ba2198675cbcc1ecd05f18e28e97133cdd2d5319", "stars": 1503, "source_url": "https://github.com/Glavin001/atom-beautify/blob/ba2198675cbcc1ecd05f18e28e97133cdd2d5319/src/beautifiers/uncrustify/index.coffee", "line_start": 11, "line_end": 60}254{"id": "Glavin001/atom-beautify:src/beautifiers/uncrustify/index.coffee:2:raw_corpus", "type": "raw_corpus", "prompt": "", "response": "lang = \"C\"\n when \"C++\"\n lang = \"CPP\"\n when \"C#\"\n lang = \"CS\"\n when \"Objective-C\", \"Objective-C++\"\n lang = \"OC+\"\n when \"D\"\n lang = \"D\"\n when \"Pawn\"\n lang = \"PAWN\"\n when \"Vala\"\n lang = \"VALA\"\n when \"Java\"\n lang = \"JAVA\"\n when \"Arduino\"\n lang = \"CPP\"\n\n @run(\"uncrustify\", [\n \"-c\"\n configPath\n \"-f\"\n @tempFile(\"input\", text)\n \"-o\"\n outputFile = @tempFile(\"output\", text)\n \"-l\"\n lang\n ], help: {\n link: \"http://sourceforge.net/projects/uncrustify/\"\n })\n .then(=>\n @readFile(outputFile)\n )\n )", "source_lang": "", "target_lang": "CoffeeScript", "repo": "Glavin001/atom-beautify", "path": "src/beautifiers/uncrustify/index.coffee", "license": "MIT", "commit": "ba2198675cbcc1ecd05f18e28e97133cdd2d5319", "stars": 1503, "source_url": "https://github.com/Glavin001/atom-beautify/blob/ba2198675cbcc1ecd05f18e28e97133cdd2d5319/src/beautifiers/uncrustify/index.coffee", "line_start": 61, "line_end": 94}255{"id": "Glavin001/atom-beautify:src/beautifiers/uncrustify/index.coffee:2:completion", "type": "completion", "prompt": "lang = \"C\"\n when \"C++\"\n lang = \"CPP\"\n when \"C#\"\n lang = \"CS\"\n when \"Objective-C\", \"Objective-C++\"\n lang = \"OC+\"\n when \"D\"\n lang = \"D\"\n when \"Pawn\"\n lang = \"PAWN\"\n when \"Vala\"\n lang = \"VALA\"\n when \"Java\"\n lang = \"JAVA\"\n when \"Arduino\"\n lang = \"CPP\"", "response": "@run(\"uncrustify\", [\n \"-c\"\n configPath\n \"-f\"\n @tempFile(\"input\", text)\n \"-o\"\n outputFile = @tempFile(\"output\", text)\n \"-l\"\n lang\n ], help: {\n link: \"http://sourceforge.net/projects/uncrustify/\"\n })\n .then(=>\n @readFile(outputFile)\n )\n )", "source_lang": "CoffeeScript", "target_lang": "CoffeeScript", "repo": "Glavin001/atom-beautify", "path": "src/beautifiers/uncrustify/index.coffee", "license": "MIT", "commit": "ba2198675cbcc1ecd05f18e28e97133cdd2d5319", "stars": 1503, "source_url": "https://github.com/Glavin001/atom-beautify/blob/ba2198675cbcc1ecd05f18e28e97133cdd2d5319/src/beautifiers/uncrustify/index.coffee", "line_start": 61, "line_end": 94}256{"id": "Glavin001/atom-beautify:src/beautifiers/uncrustify/index.coffee:1:raw_corpus", "type": "raw_corpus", "prompt": "", "response": "module.exports = class Uncrustify extends Beautifier\n name: \"Uncrustify\"\n link: \"https://github.com/uncrustify/uncrustify\"\n options: {\n Apex: true\n C: true\n \"C++\": true\n \"C#\": true\n \"Objective-C\": true\n D: true\n Pawn: true\n Vala: true\n Java: true\n Arduino: true\n }\n\n beautify: (text, language, options) ->\n # console.log('uncrustify.beautify', language, options)\n return new @Promise((resolve, reject) ->\n configPath = options.configPath\n unless configPath\n # No custom config path\n cfg options, (error, cPath) ->\n throw error if error\n resolve cPath\n else\n # Has custom config path\n editor = atom.workspace.getActiveTextEditor()\n if editor?\n basePath = path.dirname(editor.getPath())\n projectPath = atom.workspace.project.getPaths()[0]\n # console.log(basePath);\n # Expand Home Directory in Config Path\n expandedConfigPath = expandHomeDir(configPath)\n configPath = path.resolve(projectPath, expandedConfigPath)\n resolve configPath\n else\n reject(new Error(\"No Uncrustify Config Path set! Please configure Uncrustify with Atom Beautify.\"))\n )\n .then((configPath) =>\n\n\n # Select Uncrustify language\n lang = \"C\" # Default is C\n switch language\n when \"Apex\"\n lang = \"Apex\"\n when \"C\"\n lang = \"C\"\n when \"C++\"", "source_lang": "", "target_lang": "CoffeeScript", "repo": "Glavin001/atom-beautify", "path": "src/beautifiers/uncrustify/index.coffee", "license": "MIT", "commit": "88305ae1c6df043d9bc3ed8ec50dfc6faca38403", "stars": 1503, "source_url": "https://github.com/Glavin001/atom-beautify/blob/88305ae1c6df043d9bc3ed8ec50dfc6faca38403/src/beautifiers/uncrustify/index.coffee", "line_start": 11, "line_end": 60}257{"id": "Glavin001/atom-beautify:src/beautifiers/uncrustify/index.coffee:1:completion", "type": "completion", "prompt": "module.exports = class Uncrustify extends Beautifier\n name: \"Uncrustify\"\n link: \"https://github.com/uncrustify/uncrustify\"\n options: {\n Apex: true\n C: true\n \"C++\": true\n \"C#\": true\n \"Objective-C\": true\n D: true\n Pawn: true\n Vala: true\n Java: true\n Arduino: true\n }\n\n beautify: (text, language, options) ->\n # console.log('uncrustify.beautify', language, options)\n return new @Promise((resolve, reject) ->\n configPath = options.configPath\n unless configPath\n # No custom config path\n cfg options, (error, cPath) ->\n throw error if error\n resolve cPath", "response": "else\n # Has custom config path\n editor = atom.workspace.getActiveTextEditor()\n if editor?\n basePath = path.dirname(editor.getPath())\n projectPath = atom.workspace.project.getPaths()[0]\n # console.log(basePath);\n # Expand Home Directory in Config Path\n expandedConfigPath = expandHomeDir(configPath)\n configPath = path.resolve(projectPath, expandedConfigPath)\n resolve configPath\n else\n reject(new Error(\"No Uncrustify Config Path set! Please configure Uncrustify with Atom Beautify.\"))\n )\n .then((configPath) =>\n\n\n # Select Uncrustify language\n lang = \"C\" # Default is C\n switch language\n when \"Apex\"\n lang = \"Apex\"\n when \"C\"\n lang = \"C\"\n when \"C++\"", "source_lang": "CoffeeScript", "target_lang": "CoffeeScript", "repo": "Glavin001/atom-beautify", "path": "src/beautifiers/uncrustify/index.coffee", "license": "MIT", "commit": "88305ae1c6df043d9bc3ed8ec50dfc6faca38403", "stars": 1503, "source_url": "https://github.com/Glavin001/atom-beautify/blob/88305ae1c6df043d9bc3ed8ec50dfc6faca38403/src/beautifiers/uncrustify/index.coffee", "line_start": 11, "line_end": 60}258{"id": "Glavin001/atom-beautify:src/beautifiers/uncrustify/index.coffee:2:raw_corpus", "type": "raw_corpus", "prompt": "", "response": "lang = \"CPP\"\n when \"C#\"\n lang = \"CS\"\n when \"Objective-C\", \"Objective-C++\"\n lang = \"OC+\"\n when \"D\"\n lang = \"D\"\n when \"Pawn\"\n lang = \"PAWN\"\n when \"Vala\"\n lang = \"VALA\"\n when \"Java\"\n lang = \"JAVA\"\n when \"Arduino\"\n lang = \"CPP\"\n\n @run(\"uncrustify\", [\n \"-c\"\n configPath\n \"-f\"\n @tempFile(\"input\", text)\n \"-o\"\n outputFile = @tempFile(\"output\", text)\n \"-l\"\n lang\n ], help: {\n link: \"http://sourceforge.net/projects/uncrustify/\"\n })\n .then(=>\n @readFile(outputFile)\n )\n )", "source_lang": "", "target_lang": "CoffeeScript", "repo": "Glavin001/atom-beautify", "path": "src/beautifiers/uncrustify/index.coffee", "license": "MIT", "commit": "88305ae1c6df043d9bc3ed8ec50dfc6faca38403", "stars": 1503, "source_url": "https://github.com/Glavin001/atom-beautify/blob/88305ae1c6df043d9bc3ed8ec50dfc6faca38403/src/beautifiers/uncrustify/index.coffee", "line_start": 61, "line_end": 92}259{"id": "Glavin001/atom-beautify:src/beautifiers/uncrustify/index.coffee:2:completion", "type": "completion", "prompt": "lang = \"CPP\"\n when \"C#\"\n lang = \"CS\"\n when \"Objective-C\", \"Objective-C++\"\n lang = \"OC+\"\n when \"D\"\n lang = \"D\"\n when \"Pawn\"\n lang = \"PAWN\"\n when \"Vala\"\n lang = \"VALA\"\n when \"Java\"\n lang = \"JAVA\"\n when \"Arduino\"\n lang = \"CPP\"", "response": "@run(\"uncrustify\", [\n \"-c\"\n configPath\n \"-f\"\n @tempFile(\"input\", text)\n \"-o\"\n outputFile = @tempFile(\"output\", text)\n \"-l\"\n lang\n ], help: {\n link: \"http://sourceforge.net/projects/uncrustify/\"\n })\n .then(=>\n @readFile(outputFile)\n )\n )", "source_lang": "CoffeeScript", "target_lang": "CoffeeScript", "repo": "Glavin001/atom-beautify", "path": "src/beautifiers/uncrustify/index.coffee", "license": "MIT", "commit": "88305ae1c6df043d9bc3ed8ec50dfc6faca38403", "stars": 1503, "source_url": "https://github.com/Glavin001/atom-beautify/blob/88305ae1c6df043d9bc3ed8ec50dfc6faca38403/src/beautifiers/uncrustify/index.coffee", "line_start": 61, "line_end": 92}260{"id": "Glavin001/atom-beautify:src/beautifiers/uncrustify/index.coffee:1:raw_corpus", "type": "raw_corpus", "prompt": "", "response": "module.exports = class Uncrustify extends Beautifier\n name: \"Uncrustify\"\n options: {\n Apex: true\n C: true\n \"C++\": true\n \"C#\": true\n \"Objective-C\": true\n D: true\n Pawn: true\n Vala: true\n Java: true\n Arduino: true\n }\n\n beautify: (text, language, options) ->\n # console.log('uncrustify.beautify', language, options)\n return new @Promise((resolve, reject) ->\n configPath = options.configPath\n unless configPath\n # No custom config path\n cfg options, (error, cPath) ->\n throw error if error\n resolve cPath\n else\n # Has custom config path\n editor = atom.workspace.getActiveTextEditor()\n if editor?\n basePath = path.dirname(editor.getPath())\n projectPath = atom.workspace.project.getPaths()[0]\n # console.log(basePath);\n # Expand Home Directory in Config Path\n expandedConfigPath = expandHomeDir(configPath)\n configPath = path.resolve(projectPath, expandedConfigPath)\n resolve configPath\n else\n reject(new Error(\"No Uncrustify Config Path set! Please configure Uncrustify with Atom Beautify.\"))\n )\n .then((configPath) =>\n\n\n # Select Uncrustify language\n lang = \"C\" # Default is C\n switch language\n when \"Apex\"\n lang = \"Apex\"\n when \"C\"\n lang = \"C\"\n when \"C++\"\n lang = \"CPP\"", "source_lang": "", "target_lang": "CoffeeScript", "repo": "Glavin001/atom-beautify", "path": "src/beautifiers/uncrustify/index.coffee", "license": "MIT", "commit": "9ff43dafcc25f5486bc595b58e77d085277b4fb2", "stars": 1503, "source_url": "https://github.com/Glavin001/atom-beautify/blob/9ff43dafcc25f5486bc595b58e77d085277b4fb2/src/beautifiers/uncrustify/index.coffee", "line_start": 11, "line_end": 60}261{"id": "Glavin001/atom-beautify:src/beautifiers/uncrustify/index.coffee:1:completion", "type": "completion", "prompt": "module.exports = class Uncrustify extends Beautifier\n name: \"Uncrustify\"\n options: {\n Apex: true\n C: true\n \"C++\": true\n \"C#\": true\n \"Objective-C\": true\n D: true\n Pawn: true\n Vala: true\n Java: true\n Arduino: true\n }\n\n beautify: (text, language, options) ->\n # console.log('uncrustify.beautify', language, options)\n return new @Promise((resolve, reject) ->\n configPath = options.configPath\n unless configPath\n # No custom config path\n cfg options, (error, cPath) ->\n throw error if error\n resolve cPath\n else", "response": "# Has custom config path\n editor = atom.workspace.getActiveTextEditor()\n if editor?\n basePath = path.dirname(editor.getPath())\n projectPath = atom.workspace.project.getPaths()[0]\n # console.log(basePath);\n # Expand Home Directory in Config Path\n expandedConfigPath = expandHomeDir(configPath)\n configPath = path.resolve(projectPath, expandedConfigPath)\n resolve configPath\n else\n reject(new Error(\"No Uncrustify Config Path set! Please configure Uncrustify with Atom Beautify.\"))\n )\n .then((configPath) =>\n\n\n # Select Uncrustify language\n lang = \"C\" # Default is C\n switch language\n when \"Apex\"\n lang = \"Apex\"\n when \"C\"\n lang = \"C\"\n when \"C++\"\n lang = \"CPP\"", "source_lang": "CoffeeScript", "target_lang": "CoffeeScript", "repo": "Glavin001/atom-beautify", "path": "src/beautifiers/uncrustify/index.coffee", "license": "MIT", "commit": "9ff43dafcc25f5486bc595b58e77d085277b4fb2", "stars": 1503, "source_url": "https://github.com/Glavin001/atom-beautify/blob/9ff43dafcc25f5486bc595b58e77d085277b4fb2/src/beautifiers/uncrustify/index.coffee", "line_start": 11, "line_end": 60}262{"id": "Glavin001/atom-beautify:src/beautifiers/uncrustify/index.coffee:2:raw_corpus", "type": "raw_corpus", "prompt": "", "response": "when \"C#\"\n lang = \"CS\"\n when \"Objective-C\", \"Objective-C++\"\n lang = \"OC+\"\n when \"D\"\n lang = \"D\"\n when \"Pawn\"\n lang = \"PAWN\"\n when \"Vala\"\n lang = \"VALA\"\n when \"Java\"\n lang = \"JAVA\"\n when \"Arduino\"\n lang = \"CPP\"\n\n @run(\"uncrustify\", [\n \"-c\"\n configPath\n \"-f\"\n @tempFile(\"input\", text)\n \"-o\"\n outputFile = @tempFile(\"output\", text)\n \"-l\"\n lang\n ], help: {\n link: \"http://sourceforge.net/projects/uncrustify/\"\n })\n .then(=>\n @readFile(outputFile)\n )\n )", "source_lang": "", "target_lang": "CoffeeScript", "repo": "Glavin001/atom-beautify", "path": "src/beautifiers/uncrustify/index.coffee", "license": "MIT", "commit": "9ff43dafcc25f5486bc595b58e77d085277b4fb2", "stars": 1503, "source_url": "https://github.com/Glavin001/atom-beautify/blob/9ff43dafcc25f5486bc595b58e77d085277b4fb2/src/beautifiers/uncrustify/index.coffee", "line_start": 61, "line_end": 91}263{"id": "Glavin001/atom-beautify:src/beautifiers/uncrustify/index.coffee:2:completion", "type": "completion", "prompt": "when \"C#\"\n lang = \"CS\"\n when \"Objective-C\", \"Objective-C++\"\n lang = \"OC+\"\n when \"D\"\n lang = \"D\"\n when \"Pawn\"\n lang = \"PAWN\"\n when \"Vala\"\n lang = \"VALA\"\n when \"Java\"\n lang = \"JAVA\"\n when \"Arduino\"\n lang = \"CPP\"", "response": "@run(\"uncrustify\", [\n \"-c\"\n configPath\n \"-f\"\n @tempFile(\"input\", text)\n \"-o\"\n outputFile = @tempFile(\"output\", text)\n \"-l\"\n lang\n ], help: {\n link: \"http://sourceforge.net/projects/uncrustify/\"\n })\n .then(=>\n @readFile(outputFile)\n )\n )", "source_lang": "CoffeeScript", "target_lang": "CoffeeScript", "repo": "Glavin001/atom-beautify", "path": "src/beautifiers/uncrustify/index.coffee", "license": "MIT", "commit": "9ff43dafcc25f5486bc595b58e77d085277b4fb2", "stars": 1503, "source_url": "https://github.com/Glavin001/atom-beautify/blob/9ff43dafcc25f5486bc595b58e77d085277b4fb2/src/beautifiers/uncrustify/index.coffee", "line_start": 61, "line_end": 91}264{"id": "iizukanao/node-rtsp-rtmp-server:rtsp.coffee:1:raw_corpus", "type": "raw_corpus", "prompt": "", "response": "# RTSP spec:\n# RFC 2326 http://www.ietf.org/rfc/rfc2326.txt\n\napi =\n INTERLEAVED_SIGN: 0x24 # '$' (dollar sign)\n INTERLEAVED_HEADER_LEN: 4\n\n # Creates an interleaved header and returns the buffer.\n #\n # opts:\n # channel: <number> channel identifier\n # payloadLength: <number> payload length\n createInterleavedHeader: (opts) ->\n if not opts?.channel?\n throw new Error \"createInterleavedHeader: channel is required\"\n if not opts?.payloadLength?\n throw new Error \"createInterleavedHeader: payloadLength is required\"\n\n return new Buffer [\n api.INTERLEAVED_SIGN,\n opts.channel,\n opts.payloadLength >> 8, opts.payloadLength & 0xff,\n ]\n\n # Parses and returns an interleaved header.\n #\n # If the buffer doesn't have enough length for an interleaved header,\n # returns null.\n parseInterleavedHeader: (buf) ->\n if buf.length < api.INTERLEAVED_HEADER_LEN\n # not enough buffer\n return null\n\n if buf[0] isnt api.INTERLEAVED_SIGN\n throw new Error \"The buffer is not an interleaved data\"\n\n info = {}\n info.channel = buf[1]\n info.payloadLength = (buf[2] << 8) | buf[3]\n info.totalLength = api.INTERLEAVED_HEADER_LEN + info.payloadLength\n return info\n\n # Parses and returns the information of complete interleaved data.\n #\n # If parsing failed or buf doesn't have enough length for\n # the payload, returns null.\n getInterleavedData: (buf) ->\n info = api.parseInterleavedHeader buf\n if not info?\n return null", "source_lang": "", "target_lang": "CoffeeScript", "repo": "iizukanao/node-rtsp-rtmp-server", "path": "rtsp.coffee", "license": "MIT", "commit": "af6524dda361dd6dd193d2f66b289e0b65a48b89", "stars": 1100, "source_url": "https://github.com/iizukanao/node-rtsp-rtmp-server/blob/af6524dda361dd6dd193d2f66b289e0b65a48b89/rtsp.coffee", "line_start": 1, "line_end": 50}265{"id": "iizukanao/node-rtsp-rtmp-server:rtsp.coffee:1:coffee_to_js", "type": "coffee_to_js", "prompt": "Convert this CoffeeScript to JavaScript.\n```coffeescript\n# RTSP spec:\n# RFC 2326 http://www.ietf.org/rfc/rfc2326.txt\n\napi =\n INTERLEAVED_SIGN: 0x24 # '$' (dollar sign)\n INTERLEAVED_HEADER_LEN: 4\n\n # Creates an interleaved header and returns the buffer.\n #\n # opts:\n # channel: <number> channel identifier\n # payloadLength: <number> payload length\n createInterleavedHeader: (opts) ->\n if not opts?.channel?\n throw new Error \"createInterleavedHeader: channel is required\"\n if not opts?.payloadLength?\n throw new Error \"createInterleavedHeader: payloadLength is required\"\n\n return new Buffer [\n api.INTERLEAVED_SIGN,\n opts.channel,\n opts.payloadLength >> 8, opts.payloadLength & 0xff,\n ]\n\n # Parses and returns an interleaved header.\n #\n # If the buffer doesn't have enough length for an interleaved header,\n # returns null.\n parseInterleavedHeader: (buf) ->\n if buf.length < api.INTERLEAVED_HEADER_LEN\n # not enough buffer\n return null\n\n if buf[0] isnt api.INTERLEAVED_SIGN\n throw new Error \"The buffer is not an interleaved data\"\n\n info = {}\n info.channel = buf[1]\n info.payloadLength = (buf[2] << 8) | buf[3]\n info.totalLength = api.INTERLEAVED_HEADER_LEN + info.payloadLength\n return info\n\n # Parses and returns the information of complete interleaved data.\n #\n # If parsing failed or buf doesn't have enough length for\n # the payload, returns null.\n getInterleavedData: (buf) ->\n info = api.parseInterleavedHeader buf\n if not info?\n return null\n```", "response": "// RTSP spec:\n// RFC 2326 http://www.ietf.org/rfc/rfc2326.txt\nvar api;\n\napi = {\n INTERLEAVED_SIGN: 0x24, // '$' (dollar sign)\n INTERLEAVED_HEADER_LEN: 4,\n // Creates an interleaved header and returns the buffer.\n\n // opts:\n // channel: <number> channel identifier\n // payloadLength: <number> payload length\n createInterleavedHeader: function(opts) {\n if ((opts != null ? opts.channel : void 0) == null) {\n throw new Error(\"createInterleavedHeader: channel is required\");\n }\n if ((opts != null ? opts.payloadLength : void 0) == null) {\n throw new Error(\"createInterleavedHeader: payloadLength is required\");\n }\n return new Buffer([api.INTERLEAVED_SIGN, opts.channel, opts.payloadLength >> 8, opts.payloadLength & 0xff]);\n },\n // Parses and returns an interleaved header.\n\n // If the buffer doesn't have enough length for an interleaved header,\n // returns null.\n parseInterleavedHeader: function(buf) {\n var info;\n if (buf.length < api.INTERLEAVED_HEADER_LEN) {\n // not enough buffer\n return null;\n }\n if (buf[0] !== api.INTERLEAVED_SIGN) {\n throw new Error(\"The buffer is not an interleaved data\");\n }\n info = {};\n info.channel = buf[1];\n info.payloadLength = (buf[2] << 8) | buf[3];\n info.totalLength = api.INTERLEAVED_HEADER_LEN + info.payloadLength;\n return info;\n },\n // Parses and returns the information of complete interleaved data.\n\n // If parsing failed or buf doesn't have enough length for\n // the payload, returns null.\n getInterleavedData: function(buf) {\n var info;\n info = api.parseInterleavedHeader(buf);\n if (info == null) {\n return null;\n }\n }\n};", "source_lang": "CoffeeScript", "target_lang": "JavaScript", "repo": "iizukanao/node-rtsp-rtmp-server", "path": "rtsp.coffee", "license": "MIT", "commit": "af6524dda361dd6dd193d2f66b289e0b65a48b89", "stars": 1100, "source_url": "https://github.com/iizukanao/node-rtsp-rtmp-server/blob/af6524dda361dd6dd193d2f66b289e0b65a48b89/rtsp.coffee", "line_start": 1, "line_end": 50}266{"id": "iizukanao/node-rtsp-rtmp-server:rtsp.coffee:1:js_to_coffee", "type": "js_to_coffee", "prompt": "Convert this JavaScript to CoffeeScript.\n```javascript\n// RTSP spec:\n// RFC 2326 http://www.ietf.org/rfc/rfc2326.txt\nvar api;\n\napi = {\n INTERLEAVED_SIGN: 0x24, // '$' (dollar sign)\n INTERLEAVED_HEADER_LEN: 4,\n // Creates an interleaved header and returns the buffer.\n\n // opts:\n // channel: <number> channel identifier\n // payloadLength: <number> payload length\n createInterleavedHeader: function(opts) {\n if ((opts != null ? opts.channel : void 0) == null) {\n throw new Error(\"createInterleavedHeader: channel is required\");\n }\n if ((opts != null ? opts.payloadLength : void 0) == null) {\n throw new Error(\"createInterleavedHeader: payloadLength is required\");\n }\n return new Buffer([api.INTERLEAVED_SIGN, opts.channel, opts.payloadLength >> 8, opts.payloadLength & 0xff]);\n },\n // Parses and returns an interleaved header.\n\n // If the buffer doesn't have enough length for an interleaved header,\n // returns null.\n parseInterleavedHeader: function(buf) {\n var info;\n if (buf.length < api.INTERLEAVED_HEADER_LEN) {\n // not enough buffer\n return null;\n }\n if (buf[0] !== api.INTERLEAVED_SIGN) {\n throw new Error(\"The buffer is not an interleaved data\");\n }\n info = {};\n info.channel = buf[1];\n info.payloadLength = (buf[2] << 8) | buf[3];\n info.totalLength = api.INTERLEAVED_HEADER_LEN + info.payloadLength;\n return info;\n },\n // Parses and returns the information of complete interleaved data.\n\n // If parsing failed or buf doesn't have enough length for\n // the payload, returns null.\n getInterleavedData: function(buf) {\n var info;\n info = api.parseInterleavedHeader(buf);\n if (info == null) {\n return null;\n }\n }\n};\n```", "response": "# RTSP spec:\n# RFC 2326 http://www.ietf.org/rfc/rfc2326.txt\n\napi =\n INTERLEAVED_SIGN: 0x24 # '$' (dollar sign)\n INTERLEAVED_HEADER_LEN: 4\n\n # Creates an interleaved header and returns the buffer.\n #\n # opts:\n # channel: <number> channel identifier\n # payloadLength: <number> payload length\n createInterleavedHeader: (opts) ->\n if not opts?.channel?\n throw new Error \"createInterleavedHeader: channel is required\"\n if not opts?.payloadLength?\n throw new Error \"createInterleavedHeader: payloadLength is required\"\n\n return new Buffer [\n api.INTERLEAVED_SIGN,\n opts.channel,\n opts.payloadLength >> 8, opts.payloadLength & 0xff,\n ]\n\n # Parses and returns an interleaved header.\n #\n # If the buffer doesn't have enough length for an interleaved header,\n # returns null.\n parseInterleavedHeader: (buf) ->\n if buf.length < api.INTERLEAVED_HEADER_LEN\n # not enough buffer\n return null\n\n if buf[0] isnt api.INTERLEAVED_SIGN\n throw new Error \"The buffer is not an interleaved data\"\n\n info = {}\n info.channel = buf[1]\n info.payloadLength = (buf[2] << 8) | buf[3]\n info.totalLength = api.INTERLEAVED_HEADER_LEN + info.payloadLength\n return info\n\n # Parses and returns the information of complete interleaved data.\n #\n # If parsing failed or buf doesn't have enough length for\n # the payload, returns null.\n getInterleavedData: (buf) ->\n info = api.parseInterleavedHeader buf\n if not info?\n return null", "source_lang": "JavaScript", "target_lang": "CoffeeScript", "repo": "iizukanao/node-rtsp-rtmp-server", "path": "rtsp.coffee", "license": "MIT", "commit": "af6524dda361dd6dd193d2f66b289e0b65a48b89", "stars": 1100, "source_url": "https://github.com/iizukanao/node-rtsp-rtmp-server/blob/af6524dda361dd6dd193d2f66b289e0b65a48b89/rtsp.coffee", "line_start": 1, "line_end": 50}267{"id": "iizukanao/node-rtsp-rtmp-server:rtsp.coffee:1:completion", "type": "completion", "prompt": "# RTSP spec:\n# RFC 2326 http://www.ietf.org/rfc/rfc2326.txt\n\napi =\n INTERLEAVED_SIGN: 0x24 # '$' (dollar sign)\n INTERLEAVED_HEADER_LEN: 4\n\n # Creates an interleaved header and returns the buffer.\n #\n # opts:\n # channel: <number> channel identifier\n # payloadLength: <number> payload length\n createInterleavedHeader: (opts) ->\n if not opts?.channel?\n throw new Error \"createInterleavedHeader: channel is required\"\n if not opts?.payloadLength?\n throw new Error \"createInterleavedHeader: payloadLength is required\"\n\n return new Buffer [\n api.INTERLEAVED_SIGN,\n opts.channel,\n opts.payloadLength >> 8, opts.payloadLength & 0xff,\n ]\n\n # Parses and returns an interleaved header.", "response": "#\n # If the buffer doesn't have enough length for an interleaved header,\n # returns null.\n parseInterleavedHeader: (buf) ->\n if buf.length < api.INTERLEAVED_HEADER_LEN\n # not enough buffer\n return null\n\n if buf[0] isnt api.INTERLEAVED_SIGN\n throw new Error \"The buffer is not an interleaved data\"\n\n info = {}\n info.channel = buf[1]\n info.payloadLength = (buf[2] << 8) | buf[3]\n info.totalLength = api.INTERLEAVED_HEADER_LEN + info.payloadLength\n return info\n\n # Parses and returns the information of complete interleaved data.\n #\n # If parsing failed or buf doesn't have enough length for\n # the payload, returns null.\n getInterleavedData: (buf) ->\n info = api.parseInterleavedHeader buf\n if not info?\n return null", "source_lang": "CoffeeScript", "target_lang": "CoffeeScript", "repo": "iizukanao/node-rtsp-rtmp-server", "path": "rtsp.coffee", "license": "MIT", "commit": "af6524dda361dd6dd193d2f66b289e0b65a48b89", "stars": 1100, "source_url": "https://github.com/iizukanao/node-rtsp-rtmp-server/blob/af6524dda361dd6dd193d2f66b289e0b65a48b89/rtsp.coffee", "line_start": 1, "line_end": 50}268{"id": "iizukanao/node-rtsp-rtmp-server:rtsp.coffee:2:raw_corpus", "type": "raw_corpus", "prompt": "", "response": "if buf.length < info.totalLength\n # not enough buffer\n return null\n\n info.data = buf[api.INTERLEAVED_HEADER_LEN...info.totalLength]\n\n return info\n\nmodule.exports = api", "source_lang": "", "target_lang": "CoffeeScript", "repo": "iizukanao/node-rtsp-rtmp-server", "path": "rtsp.coffee", "license": "MIT", "commit": "af6524dda361dd6dd193d2f66b289e0b65a48b89", "stars": 1100, "source_url": "https://github.com/iizukanao/node-rtsp-rtmp-server/blob/af6524dda361dd6dd193d2f66b289e0b65a48b89/rtsp.coffee", "line_start": 51, "line_end": 60}269{"id": "iizukanao/node-rtsp-rtmp-server:rtsp.coffee:2:coffee_to_js", "type": "coffee_to_js", "prompt": "Convert this CoffeeScript to JavaScript.\n```coffeescript\nif buf.length < info.totalLength\n # not enough buffer\n return null\n\n info.data = buf[api.INTERLEAVED_HEADER_LEN...info.totalLength]\n\n return info\n\nmodule.exports = api\n```", "response": "if (buf.length < info.totalLength) {\n // not enough buffer\n return null;\n}\n\ninfo.data = buf.slice(api.INTERLEAVED_HEADER_LEN, info.totalLength);\n\nreturn info;\n\nmodule.exports = api;", "source_lang": "CoffeeScript", "target_lang": "JavaScript", "repo": "iizukanao/node-rtsp-rtmp-server", "path": "rtsp.coffee", "license": "MIT", "commit": "af6524dda361dd6dd193d2f66b289e0b65a48b89", "stars": 1100, "source_url": "https://github.com/iizukanao/node-rtsp-rtmp-server/blob/af6524dda361dd6dd193d2f66b289e0b65a48b89/rtsp.coffee", "line_start": 51, "line_end": 60}270{"id": "iizukanao/node-rtsp-rtmp-server:rtsp.coffee:2:js_to_coffee", "type": "js_to_coffee", "prompt": "Convert this JavaScript to CoffeeScript.\n```javascript\nif (buf.length < info.totalLength) {\n // not enough buffer\n return null;\n}\n\ninfo.data = buf.slice(api.INTERLEAVED_HEADER_LEN, info.totalLength);\n\nreturn info;\n\nmodule.exports = api;\n```", "response": "if buf.length < info.totalLength\n # not enough buffer\n return null\n\n info.data = buf[api.INTERLEAVED_HEADER_LEN...info.totalLength]\n\n return info\n\nmodule.exports = api", "source_lang": "JavaScript", "target_lang": "CoffeeScript", "repo": "iizukanao/node-rtsp-rtmp-server", "path": "rtsp.coffee", "license": "MIT", "commit": "af6524dda361dd6dd193d2f66b289e0b65a48b89", "stars": 1100, "source_url": "https://github.com/iizukanao/node-rtsp-rtmp-server/blob/af6524dda361dd6dd193d2f66b289e0b65a48b89/rtsp.coffee", "line_start": 51, "line_end": 60}271{"id": "iizukanao/node-rtsp-rtmp-server:rtsp.coffee:2:completion", "type": "completion", "prompt": "if buf.length < info.totalLength\n # not enough buffer\n return null", "response": "info.data = buf[api.INTERLEAVED_HEADER_LEN...info.totalLength]\n\n return info\n\nmodule.exports = api", "source_lang": "CoffeeScript", "target_lang": "CoffeeScript", "repo": "iizukanao/node-rtsp-rtmp-server", "path": "rtsp.coffee", "license": "MIT", "commit": "af6524dda361dd6dd193d2f66b289e0b65a48b89", "stars": 1100, "source_url": "https://github.com/iizukanao/node-rtsp-rtmp-server/blob/af6524dda361dd6dd193d2f66b289e0b65a48b89/rtsp.coffee", "line_start": 51, "line_end": 60}272{"id": "jianliaoim/talk-os:talk-web/client/app/team-invite-batch.coffee:1:raw_corpus", "type": "raw_corpus", "prompt": "", "response": "module.exports = React.createClass\n displayName: 'team-invite-batch'\n mixins: [ PureRenderMixin ]\n\n propTypes:\n _teamId: T.string.isRequired\n contacts: T.instanceOf(Immutable.List).isRequired\n onClose: T.func.isRequired\n\n getInitialState: ->\n invitees: ''\n\n makeInvitees: (data) ->\n arr = []\n data = data.split /\\s|,|;/\n data.forEach (el) ->\n if el.length > 0\n arr.push el\n arr\n\n makeData: (data) ->\n data = Immutable.fromJS data\n data\n .groupBy (el) ->\n if util.isEmail el\n 'emails'\n else if util.isMobile el\n 'mobiles'\n .toJS()\n\n validInvitees: (data) ->\n data.every (el) ->\n util.isMobile(el) or util.isEmail(el)\n\n onBatchInvite: ->\n if @state.invitees.trim().length isnt 0\n invitees = @makeInvitees @state.invitees\n inviteesNew = []\n max = 100\n\n if (invitees.length is 0) or not @validInvitees invitees\n notifyActions.error l('room-members-invalid')\n else\n invitees.forEach (invitee) =>\n if not @props.contacts.some((x) -> invitee in [x.get('email'), x.get('phoneForLogin')])\n inviteesNew.push invitee\n\n if inviteesNew.length > 0 and inviteesNew.length < max\n inviteesNew = @makeData inviteesNew\n teamActions.batchInvite @props._teamId, inviteesNew,", "source_lang": "", "target_lang": "CoffeeScript", "repo": "jianliaoim/talk-os", "path": "talk-web/client/app/team-invite-batch.coffee", "license": "MIT", "commit": "2545c4497865779a55762e03963a39237df9046b", "stars": 2703, "source_url": "https://github.com/jianliaoim/talk-os/blob/2545c4497865779a55762e03963a39237df9046b/talk-web/client/app/team-invite-batch.coffee", "line_start": 17, "line_end": 66}273{"id": "jianliaoim/talk-os:talk-web/client/app/team-invite-batch.coffee:1:coffee_to_js", "type": "coffee_to_js", "prompt": "Convert this CoffeeScript to JavaScript.\n```coffeescript\nmodule.exports = React.createClass\n displayName: 'team-invite-batch'\n mixins: [ PureRenderMixin ]\n\n propTypes:\n _teamId: T.string.isRequired\n contacts: T.instanceOf(Immutable.List).isRequired\n onClose: T.func.isRequired\n\n getInitialState: ->\n invitees: ''\n\n makeInvitees: (data) ->\n arr = []\n data = data.split /\\s|,|;/\n data.forEach (el) ->\n if el.length > 0\n arr.push el\n arr\n\n makeData: (data) ->\n data = Immutable.fromJS data\n data\n .groupBy (el) ->\n if util.isEmail el\n 'emails'\n else if util.isMobile el\n 'mobiles'\n .toJS()\n\n validInvitees: (data) ->\n data.every (el) ->\n util.isMobile(el) or util.isEmail(el)\n\n onBatchInvite: ->\n if @state.invitees.trim().length isnt 0\n invitees = @makeInvitees @state.invitees\n inviteesNew = []\n max = 100\n\n if (invitees.length is 0) or not @validInvitees invitees\n notifyActions.error l('room-members-invalid')\n else\n invitees.forEach (invitee) =>\n if not @props.contacts.some((x) -> invitee in [x.get('email'), x.get('phoneForLogin')])\n inviteesNew.push invitee\n\n if inviteesNew.length > 0 and inviteesNew.length < max\n inviteesNew = @makeData inviteesNew\n teamActions.batchInvite @props._teamId, inviteesNew,\n```", "response": "module.exports = React.createClass({\n displayName: 'team-invite-batch',\n mixins: [PureRenderMixin],\n propTypes: {\n _teamId: T.string.isRequired,\n contacts: T.instanceOf(Immutable.List).isRequired,\n onClose: T.func.isRequired\n },\n getInitialState: function() {\n return {\n invitees: ''\n };\n },\n makeInvitees: function(data) {\n var arr;\n arr = [];\n data = data.split(/\\s|,|;/);\n data.forEach(function(el) {\n if (el.length > 0) {\n return arr.push(el);\n }\n });\n return arr;\n },\n makeData: function(data) {\n data = Immutable.fromJS(data);\n return data.groupBy(function(el) {\n if (util.isEmail(el)) {\n return 'emails';\n } else if (util.isMobile(el)) {\n return 'mobiles';\n }\n }).toJS();\n },\n validInvitees: function(data) {\n return data.every(function(el) {\n return util.isMobile(el) || util.isEmail(el);\n });\n },\n onBatchInvite: function() {\n var invitees, inviteesNew, max;\n if (this.state.invitees.trim().length !== 0) {\n invitees = this.makeInvitees(this.state.invitees);\n inviteesNew = [];\n max = 100;\n if ((invitees.length === 0) || !this.validInvitees(invitees)) {\n return notifyActions.error(l('room-members-invalid'));\n } else {\n invitees.forEach((invitee) => {\n if (!this.props.contacts.some(function(x) {\n return invitee === x.get('email') || invitee === x.get('phoneForLogin');\n })) {\n return inviteesNew.push(invitee);\n }\n });\n if (inviteesNew.length > 0 && inviteesNew.length < max) {\n inviteesNew = this.makeData(inviteesNew);\n return teamActions.batchInvite(this.props._teamId, inviteesNew);\n }\n }\n }\n }\n});", "source_lang": "CoffeeScript", "target_lang": "JavaScript", "repo": "jianliaoim/talk-os", "path": "talk-web/client/app/team-invite-batch.coffee", "license": "MIT", "commit": "2545c4497865779a55762e03963a39237df9046b", "stars": 2703, "source_url": "https://github.com/jianliaoim/talk-os/blob/2545c4497865779a55762e03963a39237df9046b/talk-web/client/app/team-invite-batch.coffee", "line_start": 17, "line_end": 66}274{"id": "jianliaoim/talk-os:talk-web/client/app/team-invite-batch.coffee:1:js_to_coffee", "type": "js_to_coffee", "prompt": "Convert this JavaScript to CoffeeScript.\n```javascript\nmodule.exports = React.createClass({\n displayName: 'team-invite-batch',\n mixins: [PureRenderMixin],\n propTypes: {\n _teamId: T.string.isRequired,\n contacts: T.instanceOf(Immutable.List).isRequired,\n onClose: T.func.isRequired\n },\n getInitialState: function() {\n return {\n invitees: ''\n };\n },\n makeInvitees: function(data) {\n var arr;\n arr = [];\n data = data.split(/\\s|,|;/);\n data.forEach(function(el) {\n if (el.length > 0) {\n return arr.push(el);\n }\n });\n return arr;\n },\n makeData: function(data) {\n data = Immutable.fromJS(data);\n return data.groupBy(function(el) {\n if (util.isEmail(el)) {\n return 'emails';\n } else if (util.isMobile(el)) {\n return 'mobiles';\n }\n }).toJS();\n },\n validInvitees: function(data) {\n return data.every(function(el) {\n return util.isMobile(el) || util.isEmail(el);\n });\n },\n onBatchInvite: function() {\n var invitees, inviteesNew, max;\n if (this.state.invitees.trim().length !== 0) {\n invitees = this.makeInvitees(this.state.invitees);\n inviteesNew = [];\n max = 100;\n if ((invitees.length === 0) || !this.validInvitees(invitees)) {\n return notifyActions.error(l('room-members-invalid'));\n } else {\n invitees.forEach((invitee) => {\n if (!this.props.contacts.some(function(x) {\n return invitee === x.get('email') || invitee === x.get('phoneForLogin');\n })) {\n return inviteesNew.push(invitee);\n }\n });\n if (inviteesNew.length > 0 && inviteesNew.length < max) {\n inviteesNew = this.makeData(inviteesNew);\n return teamActions.batchInvite(this.props._teamId, inviteesNew);\n }\n }\n }\n }\n});\n```", "response": "module.exports = React.createClass\n displayName: 'team-invite-batch'\n mixins: [ PureRenderMixin ]\n\n propTypes:\n _teamId: T.string.isRequired\n contacts: T.instanceOf(Immutable.List).isRequired\n onClose: T.func.isRequired\n\n getInitialState: ->\n invitees: ''\n\n makeInvitees: (data) ->\n arr = []\n data = data.split /\\s|,|;/\n data.forEach (el) ->\n if el.length > 0\n arr.push el\n arr\n\n makeData: (data) ->\n data = Immutable.fromJS data\n data\n .groupBy (el) ->\n if util.isEmail el\n 'emails'\n else if util.isMobile el\n 'mobiles'\n .toJS()\n\n validInvitees: (data) ->\n data.every (el) ->\n util.isMobile(el) or util.isEmail(el)\n\n onBatchInvite: ->\n if @state.invitees.trim().length isnt 0\n invitees = @makeInvitees @state.invitees\n inviteesNew = []\n max = 100\n\n if (invitees.length is 0) or not @validInvitees invitees\n notifyActions.error l('room-members-invalid')\n else\n invitees.forEach (invitee) =>\n if not @props.contacts.some((x) -> invitee in [x.get('email'), x.get('phoneForLogin')])\n inviteesNew.push invitee\n\n if inviteesNew.length > 0 and inviteesNew.length < max\n inviteesNew = @makeData inviteesNew\n teamActions.batchInvite @props._teamId, inviteesNew,", "source_lang": "JavaScript", "target_lang": "CoffeeScript", "repo": "jianliaoim/talk-os", "path": "talk-web/client/app/team-invite-batch.coffee", "license": "MIT", "commit": "2545c4497865779a55762e03963a39237df9046b", "stars": 2703, "source_url": "https://github.com/jianliaoim/talk-os/blob/2545c4497865779a55762e03963a39237df9046b/talk-web/client/app/team-invite-batch.coffee", "line_start": 17, "line_end": 66}275{"id": "jianliaoim/talk-os:talk-web/client/app/team-invite-batch.coffee:1:completion", "type": "completion", "prompt": "module.exports = React.createClass\n displayName: 'team-invite-batch'\n mixins: [ PureRenderMixin ]\n\n propTypes:\n _teamId: T.string.isRequired\n contacts: T.instanceOf(Immutable.List).isRequired\n onClose: T.func.isRequired\n\n getInitialState: ->\n invitees: ''\n\n makeInvitees: (data) ->\n arr = []\n data = data.split /\\s|,|;/\n data.forEach (el) ->\n if el.length > 0\n arr.push el\n arr\n\n makeData: (data) ->\n data = Immutable.fromJS data\n data\n .groupBy (el) ->\n if util.isEmail el", "response": "'emails'\n else if util.isMobile el\n 'mobiles'\n .toJS()\n\n validInvitees: (data) ->\n data.every (el) ->\n util.isMobile(el) or util.isEmail(el)\n\n onBatchInvite: ->\n if @state.invitees.trim().length isnt 0\n invitees = @makeInvitees @state.invitees\n inviteesNew = []\n max = 100\n\n if (invitees.length is 0) or not @validInvitees invitees\n notifyActions.error l('room-members-invalid')\n else\n invitees.forEach (invitee) =>\n if not @props.contacts.some((x) -> invitee in [x.get('email'), x.get('phoneForLogin')])\n inviteesNew.push invitee\n\n if inviteesNew.length > 0 and inviteesNew.length < max\n inviteesNew = @makeData inviteesNew\n teamActions.batchInvite @props._teamId, inviteesNew,", "source_lang": "CoffeeScript", "target_lang": "CoffeeScript", "repo": "jianliaoim/talk-os", "path": "talk-web/client/app/team-invite-batch.coffee", "license": "MIT", "commit": "2545c4497865779a55762e03963a39237df9046b", "stars": 2703, "source_url": "https://github.com/jianliaoim/talk-os/blob/2545c4497865779a55762e03963a39237df9046b/talk-web/client/app/team-invite-batch.coffee", "line_start": 17, "line_end": 66}276{"id": "jianliaoim/talk-os:talk-web/client/app/team-invite-batch.coffee:2:raw_corpus", "type": "raw_corpus", "prompt": "", "response": "=>\n @setState invitees: ''\n @props.onClose()\n notifyActions.success l('room-members-success')\n ->\n notifyActions.error l('room-members-error')\n else if inviteesNew.length >= max\n notifyActions.error l('room-members-exceed-maximum').replace '%s', max\n else if invitees.length isnt inviteesNew.length\n notifyActions.error l('room-members-exists')\n\n onTextareaChange: (event) ->\n @setState invitees: event.target.value\n\n renderFooter: ->\n div className: 'footer',\n span className: 'button', onClick: @onBatchInvite, l('team-contacts-batch-invite-link')\n\n render: ->\n div className: 'team-invite-batch',\n div className: 'section',\n l('team-contacts-batch-invite')\n textarea\n autoFocus: true\n className: 'form-control is-static'\n placeholder: l('batch-invite-textarea')\n onChange: @onTextareaChange\n @renderFooter()", "source_lang": "", "target_lang": "CoffeeScript", "repo": "jianliaoim/talk-os", "path": "talk-web/client/app/team-invite-batch.coffee", "license": "MIT", "commit": "2545c4497865779a55762e03963a39237df9046b", "stars": 2703, "source_url": "https://github.com/jianliaoim/talk-os/blob/2545c4497865779a55762e03963a39237df9046b/talk-web/client/app/team-invite-batch.coffee", "line_start": 67, "line_end": 94}277{"id": "jianliaoim/talk-os:talk-web/client/app/team-invite-batch.coffee:2:completion", "type": "completion", "prompt": "=>\n @setState invitees: ''\n @props.onClose()\n notifyActions.success l('room-members-success')\n ->\n notifyActions.error l('room-members-error')\n else if inviteesNew.length >= max\n notifyActions.error l('room-members-exceed-maximum').replace '%s', max\n else if invitees.length isnt inviteesNew.length\n notifyActions.error l('room-members-exists')\n\n onTextareaChange: (event) ->\n @setState invitees: event.target.value", "response": "renderFooter: ->\n div className: 'footer',\n span className: 'button', onClick: @onBatchInvite, l('team-contacts-batch-invite-link')\n\n render: ->\n div className: 'team-invite-batch',\n div className: 'section',\n l('team-contacts-batch-invite')\n textarea\n autoFocus: true\n className: 'form-control is-static'\n placeholder: l('batch-invite-textarea')\n onChange: @onTextareaChange\n @renderFooter()", "source_lang": "CoffeeScript", "target_lang": "CoffeeScript", "repo": "jianliaoim/talk-os", "path": "talk-web/client/app/team-invite-batch.coffee", "license": "MIT", "commit": "2545c4497865779a55762e03963a39237df9046b", "stars": 2703, "source_url": "https://github.com/jianliaoim/talk-os/blob/2545c4497865779a55762e03963a39237df9046b/talk-web/client/app/team-invite-batch.coffee", "line_start": 67, "line_end": 94}278{"id": "jianliaoim/talk-os:talk-api2x/server/util/sms.coffee:1:raw_corpus", "type": "raw_corpus", "prompt": "", "response": "Err = require 'err1st'\nPromise = require 'bluebird'\nrequestAsync = Promise.promisify(require 'request')\nconfig = require 'config'\nmoment = require 'moment'\n\nmodule.exports =\n sendSMS: (mobile, text, options = {}, callback = ->) ->\n # @osv\n return callback(null, ok: 1)\n {redis} = require '../components'\n endOfToday = moment().endOf('day').valueOf()\n rateKey = \"sms:#{mobile}:#{endOfToday}\"\n\n if options.dailyRate\n $overRate = redis.getAsync rateKey\n\n .then (rateNum) ->\n return unless rateNum\n if Number(rateNum) > options.dailyRate\n throw new Err 'MOBILE_RATE_EXCEEDED'\n return\n\n else $overRate = Promise.resolve()\n\n $sendSMS = $overRate.then ->\n _options =\n method: 'POST'\n url: config.sms.host + '/send'\n json: true\n body:\n key: config.sms.key\n secret: config.sms.secret\n phone: mobile\n ip: options.ip\n _userId: options._userId\n refer: options.refer\n msg: text\n uid: options.uid or options._userId\n requestAsync _options\n .spread (res) ->\n throw new Err('SEND_SMS_ERROR') unless res?.statusCode is 200\n res.body\n\n $setRate = $sendSMS.then ->\n remainSeconds = Math.floor((endOfToday - Date.now())/1000)\n redis\n .multi()\n .incr rateKey\n .expire rateKey, remainSeconds", "source_lang": "", "target_lang": "CoffeeScript", "repo": "jianliaoim/talk-os", "path": "talk-api2x/server/util/sms.coffee", "license": "MIT", "commit": "2545c4497865779a55762e03963a39237df9046b", "stars": 2703, "source_url": "https://github.com/jianliaoim/talk-os/blob/2545c4497865779a55762e03963a39237df9046b/talk-api2x/server/util/sms.coffee", "line_start": 1, "line_end": 50}279{"id": "jianliaoim/talk-os:talk-api2x/server/util/sms.coffee:1:coffee_to_js", "type": "coffee_to_js", "prompt": "Convert this CoffeeScript to JavaScript.\n```coffeescript\nErr = require 'err1st'\nPromise = require 'bluebird'\nrequestAsync = Promise.promisify(require 'request')\nconfig = require 'config'\nmoment = require 'moment'\n\nmodule.exports =\n sendSMS: (mobile, text, options = {}, callback = ->) ->\n # @osv\n return callback(null, ok: 1)\n {redis} = require '../components'\n endOfToday = moment().endOf('day').valueOf()\n rateKey = \"sms:#{mobile}:#{endOfToday}\"\n\n if options.dailyRate\n $overRate = redis.getAsync rateKey\n\n .then (rateNum) ->\n return unless rateNum\n if Number(rateNum) > options.dailyRate\n throw new Err 'MOBILE_RATE_EXCEEDED'\n return\n\n else $overRate = Promise.resolve()\n\n $sendSMS = $overRate.then ->\n _options =\n method: 'POST'\n url: config.sms.host + '/send'\n json: true\n body:\n key: config.sms.key\n secret: config.sms.secret\n phone: mobile\n ip: options.ip\n _userId: options._userId\n refer: options.refer\n msg: text\n uid: options.uid or options._userId\n requestAsync _options\n .spread (res) ->\n throw new Err('SEND_SMS_ERROR') unless res?.statusCode is 200\n res.body\n\n $setRate = $sendSMS.then ->\n remainSeconds = Math.floor((endOfToday - Date.now())/1000)\n redis\n .multi()\n .incr rateKey\n .expire rateKey, remainSeconds\n```", "response": "var Err, Promise, config, moment, requestAsync;\n\nErr = require('err1st');\n\nPromise = require('bluebird');\n\nrequestAsync = Promise.promisify(require('request'));\n\nconfig = require('config');\n\nmoment = require('moment');\n\nmodule.exports = {\n sendSMS: function(mobile, text, options = {}, callback = function() {}) {\n var $overRate, $sendSMS, $setRate, endOfToday, rateKey, redis;\n // @osv\n return callback(null, {\n ok: 1\n });\n ({redis} = require('../components'));\n endOfToday = moment().endOf('day').valueOf();\n rateKey = `sms:${mobile}:${endOfToday}`;\n if (options.dailyRate) {\n $overRate = redis.getAsync(rateKey).then(function(rateNum) {\n if (!rateNum) {\n return;\n }\n if (Number(rateNum) > options.dailyRate) {\n throw new Err('MOBILE_RATE_EXCEEDED');\n }\n });\n } else {\n $overRate = Promise.resolve();\n }\n $sendSMS = $overRate.then(function() {\n var _options;\n _options = {\n method: 'POST',\n url: config.sms.host + '/send',\n json: true,\n body: {\n key: config.sms.key,\n secret: config.sms.secret,\n phone: mobile,\n ip: options.ip,\n _userId: options._userId,\n refer: options.refer,\n msg: text,\n uid: options.uid || options._userId\n }\n };\n return requestAsync(_options).spread(function(res) {\n if ((res != null ? res.statusCode : void 0) !== 200) {\n throw new Err('SEND_SMS_ERROR');\n }\n return res.body;\n });\n });\n return $setRate = $sendSMS.then(function() {\n var remainSeconds;\n remainSeconds = Math.floor((endOfToday - Date.now()) / 1000);\n return redis.multi().incr(rateKey).expire(rateKey, remainSeconds);\n });\n }\n};", "source_lang": "CoffeeScript", "target_lang": "JavaScript", "repo": "jianliaoim/talk-os", "path": "talk-api2x/server/util/sms.coffee", "license": "MIT", "commit": "2545c4497865779a55762e03963a39237df9046b", "stars": 2703, "source_url": "https://github.com/jianliaoim/talk-os/blob/2545c4497865779a55762e03963a39237df9046b/talk-api2x/server/util/sms.coffee", "line_start": 1, "line_end": 50}280{"id": "jianliaoim/talk-os:talk-api2x/server/util/sms.coffee:1:js_to_coffee", "type": "js_to_coffee", "prompt": "Convert this JavaScript to CoffeeScript.\n```javascript\nvar Err, Promise, config, moment, requestAsync;\n\nErr = require('err1st');\n\nPromise = require('bluebird');\n\nrequestAsync = Promise.promisify(require('request'));\n\nconfig = require('config');\n\nmoment = require('moment');\n\nmodule.exports = {\n sendSMS: function(mobile, text, options = {}, callback = function() {}) {\n var $overRate, $sendSMS, $setRate, endOfToday, rateKey, redis;\n // @osv\n return callback(null, {\n ok: 1\n });\n ({redis} = require('../components'));\n endOfToday = moment().endOf('day').valueOf();\n rateKey = `sms:${mobile}:${endOfToday}`;\n if (options.dailyRate) {\n $overRate = redis.getAsync(rateKey).then(function(rateNum) {\n if (!rateNum) {\n return;\n }\n if (Number(rateNum) > options.dailyRate) {\n throw new Err('MOBILE_RATE_EXCEEDED');\n }\n });\n } else {\n $overRate = Promise.resolve();\n }\n $sendSMS = $overRate.then(function() {\n var _options;\n _options = {\n method: 'POST',\n url: config.sms.host + '/send',\n json: true,\n body: {\n key: config.sms.key,\n secret: config.sms.secret,\n phone: mobile,\n ip: options.ip,\n _userId: options._userId,\n refer: options.refer,\n msg: text,\n uid: options.uid || options._userId\n }\n };\n return requestAsync(_options).spread(function(res) {\n if ((res != null ? res.statusCode : void 0) !== 200) {\n throw new Err('SEND_SMS_ERROR');\n }\n return res.body;\n });\n });\n return $setRate = $sendSMS.then(function() {\n var remainSeconds;\n remainSeconds = Math.floor((endOfToday - Date.now()) / 1000);\n return redis.multi().incr(rateKey).expire(rateKey, remainSeconds);\n });\n }\n};\n```", "response": "Err = require 'err1st'\nPromise = require 'bluebird'\nrequestAsync = Promise.promisify(require 'request')\nconfig = require 'config'\nmoment = require 'moment'\n\nmodule.exports =\n sendSMS: (mobile, text, options = {}, callback = ->) ->\n # @osv\n return callback(null, ok: 1)\n {redis} = require '../components'\n endOfToday = moment().endOf('day').valueOf()\n rateKey = \"sms:#{mobile}:#{endOfToday}\"\n\n if options.dailyRate\n $overRate = redis.getAsync rateKey\n\n .then (rateNum) ->\n return unless rateNum\n if Number(rateNum) > options.dailyRate\n throw new Err 'MOBILE_RATE_EXCEEDED'\n return\n\n else $overRate = Promise.resolve()\n\n $sendSMS = $overRate.then ->\n _options =\n method: 'POST'\n url: config.sms.host + '/send'\n json: true\n body:\n key: config.sms.key\n secret: config.sms.secret\n phone: mobile\n ip: options.ip\n _userId: options._userId\n refer: options.refer\n msg: text\n uid: options.uid or options._userId\n requestAsync _options\n .spread (res) ->\n throw new Err('SEND_SMS_ERROR') unless res?.statusCode is 200\n res.body\n\n $setRate = $sendSMS.then ->\n remainSeconds = Math.floor((endOfToday - Date.now())/1000)\n redis\n .multi()\n .incr rateKey\n .expire rateKey, remainSeconds", "source_lang": "JavaScript", "target_lang": "CoffeeScript", "repo": "jianliaoim/talk-os", "path": "talk-api2x/server/util/sms.coffee", "license": "MIT", "commit": "2545c4497865779a55762e03963a39237df9046b", "stars": 2703, "source_url": "https://github.com/jianliaoim/talk-os/blob/2545c4497865779a55762e03963a39237df9046b/talk-api2x/server/util/sms.coffee", "line_start": 1, "line_end": 50}281{"id": "jianliaoim/talk-os:talk-api2x/server/util/sms.coffee:1:completion", "type": "completion", "prompt": "Err = require 'err1st'\nPromise = require 'bluebird'\nrequestAsync = Promise.promisify(require 'request')\nconfig = require 'config'\nmoment = require 'moment'\n\nmodule.exports =\n sendSMS: (mobile, text, options = {}, callback = ->) ->\n # @osv\n return callback(null, ok: 1)\n {redis} = require '../components'\n endOfToday = moment().endOf('day').valueOf()\n rateKey = \"sms:#{mobile}:#{endOfToday}\"\n\n if options.dailyRate\n $overRate = redis.getAsync rateKey\n\n .then (rateNum) ->\n return unless rateNum\n if Number(rateNum) > options.dailyRate\n throw new Err 'MOBILE_RATE_EXCEEDED'\n return\n\n else $overRate = Promise.resolve()", "response": "$sendSMS = $overRate.then ->\n _options =\n method: 'POST'\n url: config.sms.host + '/send'\n json: true\n body:\n key: config.sms.key\n secret: config.sms.secret\n phone: mobile\n ip: options.ip\n _userId: options._userId\n refer: options.refer\n msg: text\n uid: options.uid or options._userId\n requestAsync _options\n .spread (res) ->\n throw new Err('SEND_SMS_ERROR') unless res?.statusCode is 200\n res.body\n\n $setRate = $sendSMS.then ->\n remainSeconds = Math.floor((endOfToday - Date.now())/1000)\n redis\n .multi()\n .incr rateKey\n .expire rateKey, remainSeconds", "source_lang": "CoffeeScript", "target_lang": "CoffeeScript", "repo": "jianliaoim/talk-os", "path": "talk-api2x/server/util/sms.coffee", "license": "MIT", "commit": "2545c4497865779a55762e03963a39237df9046b", "stars": 2703, "source_url": "https://github.com/jianliaoim/talk-os/blob/2545c4497865779a55762e03963a39237df9046b/talk-api2x/server/util/sms.coffee", "line_start": 1, "line_end": 50}282{"id": "jianliaoim/talk-os:talk-api2x/server/util/sms.coffee:2:raw_corpus", "type": "raw_corpus", "prompt": "", "response": ".execAsync()\n\n Promise.all [$sendSMS, $setRate]\n .spread (body) -> body\n .nodeify callback", "source_lang": "", "target_lang": "CoffeeScript", "repo": "jianliaoim/talk-os", "path": "talk-api2x/server/util/sms.coffee", "license": "MIT", "commit": "2545c4497865779a55762e03963a39237df9046b", "stars": 2703, "source_url": "https://github.com/jianliaoim/talk-os/blob/2545c4497865779a55762e03963a39237df9046b/talk-api2x/server/util/sms.coffee", "line_start": 51, "line_end": 55}283{"id": "mauricemach/zappa:tests/assets.coffee:1:raw_corpus", "type": "raw_corpus", "prompt": "", "response": "@tests =\n client: (t) ->\n t.expect 1, 2\n t.wait 3000\n\n zapp = zappa port++, ->\n @client '/index.js': ->\n @get '#/': -> alert 'hi'\n\n c = t.client(zapp.app)\n c.get '/index.js', (err, res) ->\n t.equal 1, res.body, ';zappa.run(function () {\\n return this.get({\\n \\'#/\\': function() {\\n return alert(\\'hi\\');\\n }\\n });\\n });'\n t.equal 2, res.headers['content-type'], 'application/javascript'\n\n coffee: (t) ->\n t.expect 1, 2\n t.wait 3000\n\n zapp = zappa port++, ->\n @coffee '/coffee.js': ->\n alert 'hi'\n\n c = t.client(zapp.app)\n c.get '/coffee.js', (err, res) ->\n t.equal 1, res.body, ';var __slice = Array.prototype.slice;var __hasProp = Object.prototype.hasOwnProperty;var __bind = function(fn, me){ return function(){ return fn.apply(me, arguments); }; };var __extends = function(child, parent) { for (var key in parent) { if (__hasProp.call(parent, key)) child[key] = parent[key]; } function ctor() { this.constructor = child; } ctor.prototype = parent.prototype; child.prototype = new ctor; child.__super__ = parent.prototype; return child; };var __indexOf = Array.prototype.indexOf || function(item) { for (var i = 0, l = this.length; i < l; i++) { if (this[i] === item) return i; } return -1; };(function () {\\n return alert(\\'hi\\');\\n })();'\n t.equal 2, res.headers['content-type'], 'application/javascript'\n\n js: (t) ->\n t.expect 1, 2\n t.wait 3000\n\n zapp = zappa port++, ->\n @js '/js.js': '''\n alert('hi');\n '''\n\n c = t.client(zapp.app)\n c.get '/js.js', (err, res) ->\n t.equal 1, res.body, \"alert('hi');\"\n t.equal 2, res.headers['content-type'], 'application/javascript'\n\n css: (t) ->\n t.expect 1, 2\n t.wait 3000\n\n zapp = zappa port++, ->\n @css '/index.css': '''\n font-family: sans-serif;\n '''", "source_lang": "", "target_lang": "CoffeeScript", "repo": "mauricemach/zappa", "path": "tests/assets.coffee", "license": "MIT", "commit": "725e0103755c9a92fe84de06cee82db00e51a1f8", "stars": 943, "source_url": "https://github.com/mauricemach/zappa/blob/725e0103755c9a92fe84de06cee82db00e51a1f8/tests/assets.coffee", "line_start": 4, "line_end": 53}284{"id": "mauricemach/zappa:tests/assets.coffee:1:coffee_to_js", "type": "coffee_to_js", "prompt": "Convert this CoffeeScript to JavaScript.\n```coffeescript\n@tests =\n client: (t) ->\n t.expect 1, 2\n t.wait 3000\n\n zapp = zappa port++, ->\n @client '/index.js': ->\n @get '#/': -> alert 'hi'\n\n c = t.client(zapp.app)\n c.get '/index.js', (err, res) ->\n t.equal 1, res.body, ';zappa.run(function () {\\n return this.get({\\n \\'#/\\': function() {\\n return alert(\\'hi\\');\\n }\\n });\\n });'\n t.equal 2, res.headers['content-type'], 'application/javascript'\n\n coffee: (t) ->\n t.expect 1, 2\n t.wait 3000\n\n zapp = zappa port++, ->\n @coffee '/coffee.js': ->\n alert 'hi'\n\n c = t.client(zapp.app)\n c.get '/coffee.js', (err, res) ->\n t.equal 1, res.body, ';var __slice = Array.prototype.slice;var __hasProp = Object.prototype.hasOwnProperty;var __bind = function(fn, me){ return function(){ return fn.apply(me, arguments); }; };var __extends = function(child, parent) { for (var key in parent) { if (__hasProp.call(parent, key)) child[key] = parent[key]; } function ctor() { this.constructor = child; } ctor.prototype = parent.prototype; child.prototype = new ctor; child.__super__ = parent.prototype; return child; };var __indexOf = Array.prototype.indexOf || function(item) { for (var i = 0, l = this.length; i < l; i++) { if (this[i] === item) return i; } return -1; };(function () {\\n return alert(\\'hi\\');\\n })();'\n t.equal 2, res.headers['content-type'], 'application/javascript'\n\n js: (t) ->\n t.expect 1, 2\n t.wait 3000\n\n zapp = zappa port++, ->\n @js '/js.js': '''\n alert('hi');\n '''\n\n c = t.client(zapp.app)\n c.get '/js.js', (err, res) ->\n t.equal 1, res.body, \"alert('hi');\"\n t.equal 2, res.headers['content-type'], 'application/javascript'\n\n css: (t) ->\n t.expect 1, 2\n t.wait 3000\n\n zapp = zappa port++, ->\n @css '/index.css': '''\n font-family: sans-serif;\n '''\n```", "response": "this.tests = {\n client: function(t) {\n var c, zapp;\n t.expect(1, 2);\n t.wait(3000);\n zapp = zappa(port++, function() {\n return this.client({\n '/index.js': function() {\n return this.get({\n '#/': function() {\n return alert('hi');\n }\n });\n }\n });\n });\n c = t.client(zapp.app);\n return c.get('/index.js', function(err, res) {\n t.equal(1, res.body, ';zappa.run(function () {\\n return this.get({\\n \\'#/\\': function() {\\n return alert(\\'hi\\');\\n }\\n });\\n });');\n return t.equal(2, res.headers['content-type'], 'application/javascript');\n });\n },\n coffee: function(t) {\n var c, zapp;\n t.expect(1, 2);\n t.wait(3000);\n zapp = zappa(port++, function() {\n return this.coffee({\n '/coffee.js': function() {\n return alert('hi');\n }\n });\n });\n c = t.client(zapp.app);\n return c.get('/coffee.js', function(err, res) {\n t.equal(1, res.body, ';var __slice = Array.prototype.slice;var __hasProp = Object.prototype.hasOwnProperty;var __bind = function(fn, me){ return function(){ return fn.apply(me, arguments); }; };var __extends = function(child, parent) { for (var key in parent) { if (__hasProp.call(parent, key)) child[key] = parent[key]; } function ctor() { this.constructor = child; } ctor.prototype = parent.prototype; child.prototype = new ctor; child.__super__ = parent.prototype; return child; };var __indexOf = Array.prototype.indexOf || function(item) { for (var i = 0, l = this.length; i < l; i++) { if (this[i] === item) return i; } return -1; };(function () {\\n return alert(\\'hi\\');\\n })();');\n return t.equal(2, res.headers['content-type'], 'application/javascript');\n });\n },\n js: function(t) {\n var c, zapp;\n t.expect(1, 2);\n t.wait(3000);\n zapp = zappa(port++, function() {\n return this.js({\n '/js.js': `alert('hi');`\n });\n });\n c = t.client(zapp.app);\n return c.get('/js.js', function(err, res) {\n t.equal(1, res.body, \"alert('hi');\");\n return t.equal(2, res.headers['content-type'], 'application/javascript');\n });\n },\n css: function(t) {\n var zapp;\n t.expect(1, 2);\n t.wait(3000);\n return zapp = zappa(port++, function() {\n return this.css({\n '/index.css': `font-family: sans-serif;`\n });\n });\n }\n};", "source_lang": "CoffeeScript", "target_lang": "JavaScript", "repo": "mauricemach/zappa", "path": "tests/assets.coffee", "license": "MIT", "commit": "725e0103755c9a92fe84de06cee82db00e51a1f8", "stars": 943, "source_url": "https://github.com/mauricemach/zappa/blob/725e0103755c9a92fe84de06cee82db00e51a1f8/tests/assets.coffee", "line_start": 4, "line_end": 53}285{"id": "mauricemach/zappa:tests/assets.coffee:1:js_to_coffee", "type": "js_to_coffee", "prompt": "Convert this JavaScript to CoffeeScript.\n```javascript\nthis.tests = {\n client: function(t) {\n var c, zapp;\n t.expect(1, 2);\n t.wait(3000);\n zapp = zappa(port++, function() {\n return this.client({\n '/index.js': function() {\n return this.get({\n '#/': function() {\n return alert('hi');\n }\n });\n }\n });\n });\n c = t.client(zapp.app);\n return c.get('/index.js', function(err, res) {\n t.equal(1, res.body, ';zappa.run(function () {\\n return this.get({\\n \\'#/\\': function() {\\n return alert(\\'hi\\');\\n }\\n });\\n });');\n return t.equal(2, res.headers['content-type'], 'application/javascript');\n });\n },\n coffee: function(t) {\n var c, zapp;\n t.expect(1, 2);\n t.wait(3000);\n zapp = zappa(port++, function() {\n return this.coffee({\n '/coffee.js': function() {\n return alert('hi');\n }\n });\n });\n c = t.client(zapp.app);\n return c.get('/coffee.js', function(err, res) {\n t.equal(1, res.body, ';var __slice = Array.prototype.slice;var __hasProp = Object.prototype.hasOwnProperty;var __bind = function(fn, me){ return function(){ return fn.apply(me, arguments); }; };var __extends = function(child, parent) { for (var key in parent) { if (__hasProp.call(parent, key)) child[key] = parent[key]; } function ctor() { this.constructor = child; } ctor.prototype = parent.prototype; child.prototype = new ctor; child.__super__ = parent.prototype; return child; };var __indexOf = Array.prototype.indexOf || function(item) { for (var i = 0, l = this.length; i < l; i++) { if (this[i] === item) return i; } return -1; };(function () {\\n return alert(\\'hi\\');\\n })();');\n return t.equal(2, res.headers['content-type'], 'application/javascript');\n });\n },\n js: function(t) {\n var c, zapp;\n t.expect(1, 2);\n t.wait(3000);\n zapp = zappa(port++, function() {\n return this.js({\n '/js.js': `alert('hi');`\n });\n });\n c = t.client(zapp.app);\n return c.get('/js.js', function(err, res) {\n t.equal(1, res.body, \"alert('hi');\");\n return t.equal(2, res.headers['content-type'], 'application/javascript');\n });\n },\n css: function(t) {\n var zapp;\n t.expect(1, 2);\n t.wait(3000);\n return zapp = zappa(port++, function() {\n return this.css({\n '/index.css': `font-family: sans-serif;`\n });\n });\n }\n};\n```", "response": "@tests =\n client: (t) ->\n t.expect 1, 2\n t.wait 3000\n\n zapp = zappa port++, ->\n @client '/index.js': ->\n @get '#/': -> alert 'hi'\n\n c = t.client(zapp.app)\n c.get '/index.js', (err, res) ->\n t.equal 1, res.body, ';zappa.run(function () {\\n return this.get({\\n \\'#/\\': function() {\\n return alert(\\'hi\\');\\n }\\n });\\n });'\n t.equal 2, res.headers['content-type'], 'application/javascript'\n\n coffee: (t) ->\n t.expect 1, 2\n t.wait 3000\n\n zapp = zappa port++, ->\n @coffee '/coffee.js': ->\n alert 'hi'\n\n c = t.client(zapp.app)\n c.get '/coffee.js', (err, res) ->\n t.equal 1, res.body, ';var __slice = Array.prototype.slice;var __hasProp = Object.prototype.hasOwnProperty;var __bind = function(fn, me){ return function(){ return fn.apply(me, arguments); }; };var __extends = function(child, parent) { for (var key in parent) { if (__hasProp.call(parent, key)) child[key] = parent[key]; } function ctor() { this.constructor = child; } ctor.prototype = parent.prototype; child.prototype = new ctor; child.__super__ = parent.prototype; return child; };var __indexOf = Array.prototype.indexOf || function(item) { for (var i = 0, l = this.length; i < l; i++) { if (this[i] === item) return i; } return -1; };(function () {\\n return alert(\\'hi\\');\\n })();'\n t.equal 2, res.headers['content-type'], 'application/javascript'\n\n js: (t) ->\n t.expect 1, 2\n t.wait 3000\n\n zapp = zappa port++, ->\n @js '/js.js': '''\n alert('hi');\n '''\n\n c = t.client(zapp.app)\n c.get '/js.js', (err, res) ->\n t.equal 1, res.body, \"alert('hi');\"\n t.equal 2, res.headers['content-type'], 'application/javascript'\n\n css: (t) ->\n t.expect 1, 2\n t.wait 3000\n\n zapp = zappa port++, ->\n @css '/index.css': '''\n font-family: sans-serif;\n '''", "source_lang": "JavaScript", "target_lang": "CoffeeScript", "repo": "mauricemach/zappa", "path": "tests/assets.coffee", "license": "MIT", "commit": "725e0103755c9a92fe84de06cee82db00e51a1f8", "stars": 943, "source_url": "https://github.com/mauricemach/zappa/blob/725e0103755c9a92fe84de06cee82db00e51a1f8/tests/assets.coffee", "line_start": 4, "line_end": 53}286{"id": "mauricemach/zappa:tests/assets.coffee:1:completion", "type": "completion", "prompt": "@tests =\n client: (t) ->\n t.expect 1, 2\n t.wait 3000\n\n zapp = zappa port++, ->\n @client '/index.js': ->\n @get '#/': -> alert 'hi'\n\n c = t.client(zapp.app)\n c.get '/index.js', (err, res) ->\n t.equal 1, res.body, ';zappa.run(function () {\\n return this.get({\\n \\'#/\\': function() {\\n return alert(\\'hi\\');\\n }\\n });\\n });'\n t.equal 2, res.headers['content-type'], 'application/javascript'\n\n coffee: (t) ->\n t.expect 1, 2\n t.wait 3000\n\n zapp = zappa port++, ->\n @coffee '/coffee.js': ->\n alert 'hi'\n\n c = t.client(zapp.app)\n c.get '/coffee.js', (err, res) ->", "response": "t.equal 1, res.body, ';var __slice = Array.prototype.slice;var __hasProp = Object.prototype.hasOwnProperty;var __bind = function(fn, me){ return function(){ return fn.apply(me, arguments); }; };var __extends = function(child, parent) { for (var key in parent) { if (__hasProp.call(parent, key)) child[key] = parent[key]; } function ctor() { this.constructor = child; } ctor.prototype = parent.prototype; child.prototype = new ctor; child.__super__ = parent.prototype; return child; };var __indexOf = Array.prototype.indexOf || function(item) { for (var i = 0, l = this.length; i < l; i++) { if (this[i] === item) return i; } return -1; };(function () {\\n return alert(\\'hi\\');\\n })();'\n t.equal 2, res.headers['content-type'], 'application/javascript'\n\n js: (t) ->\n t.expect 1, 2\n t.wait 3000\n\n zapp = zappa port++, ->\n @js '/js.js': '''\n alert('hi');\n '''\n\n c = t.client(zapp.app)\n c.get '/js.js', (err, res) ->\n t.equal 1, res.body, \"alert('hi');\"\n t.equal 2, res.headers['content-type'], 'application/javascript'\n\n css: (t) ->\n t.expect 1, 2\n t.wait 3000\n\n zapp = zappa port++, ->\n @css '/index.css': '''\n font-family: sans-serif;\n '''", "source_lang": "CoffeeScript", "target_lang": "CoffeeScript", "repo": "mauricemach/zappa", "path": "tests/assets.coffee", "license": "MIT", "commit": "725e0103755c9a92fe84de06cee82db00e51a1f8", "stars": 943, "source_url": "https://github.com/mauricemach/zappa/blob/725e0103755c9a92fe84de06cee82db00e51a1f8/tests/assets.coffee", "line_start": 4, "line_end": 53}287{"id": "mauricemach/zappa:tests/assets.coffee:2:raw_corpus", "type": "raw_corpus", "prompt": "", "response": "c = t.client(zapp.app)\n c.get '/index.css', (err, res) ->\n t.equal 1, res.body, 'font-family: sans-serif;'\n t.equal 2, res.headers['content-type'], 'text/css'\n\n stylus: (t) ->\n t.expect 'header', 'body'\n t.wait 3000\n\n zapp = zappa port++, ->\n @stylus '/index.css': '''\n border-radius()\n -webkit-border-radius arguments\n -moz-border-radius arguments\n border-radius arguments\n\n body\n font 12px Helvetica, Arial, sans-serif\n\n a.button\n border-radius 5px\n '''\n\n c = t.client(zapp.app)\n c.get '/index.css', (err, res) ->\n t.equal 'header', res.headers['content-type'], 'text/css'\n t.equal 'body', res.body, '''\n body {\n font: 12px Helvetica, Arial, sans-serif;\n }\n a.button {\n -webkit-border-radius: 5px;\n -moz-border-radius: 5px;\n border-radius: 5px;\n }\n\n '''\n\n jquery: (t) ->\n t.expect 'content-type', 'length'\n t.wait 3000\n\n zapp = zappa port++, ->\n @use 'zappa'\n\n c = t.client(zapp.app)\n c.get '/zappa/jquery.js', (err, res) ->\n t.equal 'content-type', res.headers['content-type'], 'application/javascript'\n t.equal 'length', res.headers['content-length'], '91669'", "source_lang": "", "target_lang": "CoffeeScript", "repo": "mauricemach/zappa", "path": "tests/assets.coffee", "license": "MIT", "commit": "725e0103755c9a92fe84de06cee82db00e51a1f8", "stars": 943, "source_url": "https://github.com/mauricemach/zappa/blob/725e0103755c9a92fe84de06cee82db00e51a1f8/tests/assets.coffee", "line_start": 54, "line_end": 103}288{"id": "mauricemach/zappa:tests/assets.coffee:2:completion", "type": "completion", "prompt": "c = t.client(zapp.app)\n c.get '/index.css', (err, res) ->\n t.equal 1, res.body, 'font-family: sans-serif;'\n t.equal 2, res.headers['content-type'], 'text/css'\n\n stylus: (t) ->\n t.expect 'header', 'body'\n t.wait 3000\n\n zapp = zappa port++, ->\n @stylus '/index.css': '''\n border-radius()\n -webkit-border-radius arguments\n -moz-border-radius arguments\n border-radius arguments\n\n body\n font 12px Helvetica, Arial, sans-serif\n\n a.button\n border-radius 5px\n '''\n\n c = t.client(zapp.app)", "response": "c.get '/index.css', (err, res) ->\n t.equal 'header', res.headers['content-type'], 'text/css'\n t.equal 'body', res.body, '''\n body {\n font: 12px Helvetica, Arial, sans-serif;\n }\n a.button {\n -webkit-border-radius: 5px;\n -moz-border-radius: 5px;\n border-radius: 5px;\n }\n\n '''\n\n jquery: (t) ->\n t.expect 'content-type', 'length'\n t.wait 3000\n\n zapp = zappa port++, ->\n @use 'zappa'\n\n c = t.client(zapp.app)\n c.get '/zappa/jquery.js', (err, res) ->\n t.equal 'content-type', res.headers['content-type'], 'application/javascript'\n t.equal 'length', res.headers['content-length'], '91669'", "source_lang": "CoffeeScript", "target_lang": "CoffeeScript", "repo": "mauricemach/zappa", "path": "tests/assets.coffee", "license": "MIT", "commit": "725e0103755c9a92fe84de06cee82db00e51a1f8", "stars": 943, "source_url": "https://github.com/mauricemach/zappa/blob/725e0103755c9a92fe84de06cee82db00e51a1f8/tests/assets.coffee", "line_start": 54, "line_end": 103}289{"id": "mauricemach/zappa:tests/assets.coffee:3:raw_corpus", "type": "raw_corpus", "prompt": "", "response": "sammy: (t) ->\n t.expect 'content-type', 'length'\n t.wait 3000\n\n zapp = zappa port++, ->\n @use 'zappa'\n\n c = t.client(zapp.app)\n c.get '/zappa/sammy.js', (err, res) ->\n t.equal 'content-type', res.headers['content-type'], 'application/javascript'\n t.equal 'length', res.headers['content-length'], '18059'\n\n zappa: (t) ->\n t.expect 'content-type', 'snippet'\n t.wait 3000\n\n zapp = zappa port++, ->\n @use 'zappa'\n\n c = t.client(zapp.app)\n c.get '/zappa/zappa.js', (err, res) ->\n t.equal 'content-type', res.headers['content-type'], 'application/javascript'\n t.ok 'snippet', res.body.indexOf('window.zappa = {};') > -1\n\n 'zappa (automatic)': (t) ->\n t.expect 'content-type', 'snippet'\n t.wait 3000\n\n zapp = zappa port++, ->\n @client '/index.js': ->\n\n c = t.client(zapp.app)\n c.get '/zappa/zappa.js', (err, res) ->\n t.equal 'content-type', res.headers['content-type'], 'application/javascript'\n t.ok 'snippet', res.body.indexOf('window.zappa = {};') > -1\n\n minify: (t) ->\n t.expect 'zappa', 'client', 'shared', 'coffee', 'js'\n t.wait 3000\n\n zapp = zappa port++, ->\n @enable 'minify'\n @client '/client.js': -> alert 'foo'\n @shared '/shared.js': -> alert 'foo' if window?\n @coffee '/coffee.js': -> alert 'foo'\n @js '/js.js': \"alert('foo');\"\n\n c = t.client(zapp.app)\n c.get '/zappa/zappa.js', (err, res) ->\n t.ok 'zappa', res.body.indexOf('window.zappa={},') > -1", "source_lang": "", "target_lang": "CoffeeScript", "repo": "mauricemach/zappa", "path": "tests/assets.coffee", "license": "MIT", "commit": "725e0103755c9a92fe84de06cee82db00e51a1f8", "stars": 943, "source_url": "https://github.com/mauricemach/zappa/blob/725e0103755c9a92fe84de06cee82db00e51a1f8/tests/assets.coffee", "line_start": 104, "line_end": 153}290{"id": "mauricemach/zappa:tests/assets.coffee:3:coffee_to_js", "type": "coffee_to_js", "prompt": "Convert this CoffeeScript to JavaScript.\n```coffeescript\nsammy: (t) ->\n t.expect 'content-type', 'length'\n t.wait 3000\n\n zapp = zappa port++, ->\n @use 'zappa'\n\n c = t.client(zapp.app)\n c.get '/zappa/sammy.js', (err, res) ->\n t.equal 'content-type', res.headers['content-type'], 'application/javascript'\n t.equal 'length', res.headers['content-length'], '18059'\n\n zappa: (t) ->\n t.expect 'content-type', 'snippet'\n t.wait 3000\n\n zapp = zappa port++, ->\n @use 'zappa'\n\n c = t.client(zapp.app)\n c.get '/zappa/zappa.js', (err, res) ->\n t.equal 'content-type', res.headers['content-type'], 'application/javascript'\n t.ok 'snippet', res.body.indexOf('window.zappa = {};') > -1\n\n 'zappa (automatic)': (t) ->\n t.expect 'content-type', 'snippet'\n t.wait 3000\n\n zapp = zappa port++, ->\n @client '/index.js': ->\n\n c = t.client(zapp.app)\n c.get '/zappa/zappa.js', (err, res) ->\n t.equal 'content-type', res.headers['content-type'], 'application/javascript'\n t.ok 'snippet', res.body.indexOf('window.zappa = {};') > -1\n\n minify: (t) ->\n t.expect 'zappa', 'client', 'shared', 'coffee', 'js'\n t.wait 3000\n\n zapp = zappa port++, ->\n @enable 'minify'\n @client '/client.js': -> alert 'foo'\n @shared '/shared.js': -> alert 'foo' if window?\n @coffee '/coffee.js': -> alert 'foo'\n @js '/js.js': \"alert('foo');\"\n\n c = t.client(zapp.app)\n c.get '/zappa/zappa.js', (err, res) ->\n t.ok 'zappa', res.body.indexOf('window.zappa={},') > -1\n```", "response": "({\n sammy: function(t) {\n var c, zapp;\n t.expect('content-type', 'length');\n t.wait(3000);\n zapp = zappa(port++, function() {\n return this.use('zappa');\n });\n c = t.client(zapp.app);\n return c.get('/zappa/sammy.js', function(err, res) {\n t.equal('content-type', res.headers['content-type'], 'application/javascript');\n return t.equal('length', res.headers['content-length'], '18059');\n });\n },\n zappa: function(t) {\n var c, zapp;\n t.expect('content-type', 'snippet');\n t.wait(3000);\n zapp = zappa(port++, function() {\n return this.use('zappa');\n });\n c = t.client(zapp.app);\n return c.get('/zappa/zappa.js', function(err, res) {\n t.equal('content-type', res.headers['content-type'], 'application/javascript');\n return t.ok('snippet', res.body.indexOf('window.zappa = {};') > -1);\n });\n },\n 'zappa (automatic)': function(t) {\n var c, zapp;\n t.expect('content-type', 'snippet');\n t.wait(3000);\n zapp = zappa(port++, function() {\n return this.client({\n '/index.js': function() {}\n });\n });\n c = t.client(zapp.app);\n return c.get('/zappa/zappa.js', function(err, res) {\n t.equal('content-type', res.headers['content-type'], 'application/javascript');\n return t.ok('snippet', res.body.indexOf('window.zappa = {};') > -1);\n });\n },\n minify: function(t) {\n var c, zapp;\n t.expect('zappa', 'client', 'shared', 'coffee', 'js');\n t.wait(3000);\n zapp = zappa(port++, function() {\n this.enable('minify');\n this.client({\n '/client.js': function() {\n return alert('foo');\n }\n });\n this.shared({\n '/shared.js': function() {\n if (typeof window !== \"undefined\" && window !== null) {\n return alert('foo');\n }\n }\n });\n this.coffee({\n '/coffee.js': function() {\n return alert('foo');\n }\n });\n return this.js({\n '/js.js': \"alert('foo');\"\n });\n });\n c = t.client(zapp.app);\n return c.get('/zappa/zappa.js', function(err, res) {\n return t.ok('zappa', res.body.indexOf('window.zappa={},') > -1);\n });\n }\n});", "source_lang": "CoffeeScript", "target_lang": "JavaScript", "repo": "mauricemach/zappa", "path": "tests/assets.coffee", "license": "MIT", "commit": "725e0103755c9a92fe84de06cee82db00e51a1f8", "stars": 943, "source_url": "https://github.com/mauricemach/zappa/blob/725e0103755c9a92fe84de06cee82db00e51a1f8/tests/assets.coffee", "line_start": 104, "line_end": 153}291{"id": "mauricemach/zappa:tests/assets.coffee:3:js_to_coffee", "type": "js_to_coffee", "prompt": "Convert this JavaScript to CoffeeScript.\n```javascript\n({\n sammy: function(t) {\n var c, zapp;\n t.expect('content-type', 'length');\n t.wait(3000);\n zapp = zappa(port++, function() {\n return this.use('zappa');\n });\n c = t.client(zapp.app);\n return c.get('/zappa/sammy.js', function(err, res) {\n t.equal('content-type', res.headers['content-type'], 'application/javascript');\n return t.equal('length', res.headers['content-length'], '18059');\n });\n },\n zappa: function(t) {\n var c, zapp;\n t.expect('content-type', 'snippet');\n t.wait(3000);\n zapp = zappa(port++, function() {\n return this.use('zappa');\n });\n c = t.client(zapp.app);\n return c.get('/zappa/zappa.js', function(err, res) {\n t.equal('content-type', res.headers['content-type'], 'application/javascript');\n return t.ok('snippet', res.body.indexOf('window.zappa = {};') > -1);\n });\n },\n 'zappa (automatic)': function(t) {\n var c, zapp;\n t.expect('content-type', 'snippet');\n t.wait(3000);\n zapp = zappa(port++, function() {\n return this.client({\n '/index.js': function() {}\n });\n });\n c = t.client(zapp.app);\n return c.get('/zappa/zappa.js', function(err, res) {\n t.equal('content-type', res.headers['content-type'], 'application/javascript');\n return t.ok('snippet', res.body.indexOf('window.zappa = {};') > -1);\n });\n },\n minify: function(t) {\n var c, zapp;\n t.expect('zappa', 'client', 'shared', 'coffee', 'js');\n t.wait(3000);\n zapp = zappa(port++, function() {\n this.enable('minify');\n this.client({\n '/client.js': function() {\n return alert('foo');\n }\n });\n this.shared({\n '/shared.js': function() {\n if (typeof window !== \"undefined\" && window !== null) {\n return alert('foo');\n }\n }\n });\n this.coffee({\n '/coffee.js': function() {\n return alert('foo');\n }\n });\n return this.js({\n '/js.js': \"alert('foo');\"\n });\n });\n c = t.client(zapp.app);\n return c.get('/zappa/zappa.js', function(err, res) {\n return t.ok('zappa', res.body.indexOf('window.zappa={},') > -1);\n });\n }\n});\n```", "response": "sammy: (t) ->\n t.expect 'content-type', 'length'\n t.wait 3000\n\n zapp = zappa port++, ->\n @use 'zappa'\n\n c = t.client(zapp.app)\n c.get '/zappa/sammy.js', (err, res) ->\n t.equal 'content-type', res.headers['content-type'], 'application/javascript'\n t.equal 'length', res.headers['content-length'], '18059'\n\n zappa: (t) ->\n t.expect 'content-type', 'snippet'\n t.wait 3000\n\n zapp = zappa port++, ->\n @use 'zappa'\n\n c = t.client(zapp.app)\n c.get '/zappa/zappa.js', (err, res) ->\n t.equal 'content-type', res.headers['content-type'], 'application/javascript'\n t.ok 'snippet', res.body.indexOf('window.zappa = {};') > -1\n\n 'zappa (automatic)': (t) ->\n t.expect 'content-type', 'snippet'\n t.wait 3000\n\n zapp = zappa port++, ->\n @client '/index.js': ->\n\n c = t.client(zapp.app)\n c.get '/zappa/zappa.js', (err, res) ->\n t.equal 'content-type', res.headers['content-type'], 'application/javascript'\n t.ok 'snippet', res.body.indexOf('window.zappa = {};') > -1\n\n minify: (t) ->\n t.expect 'zappa', 'client', 'shared', 'coffee', 'js'\n t.wait 3000\n\n zapp = zappa port++, ->\n @enable 'minify'\n @client '/client.js': -> alert 'foo'\n @shared '/shared.js': -> alert 'foo' if window?\n @coffee '/coffee.js': -> alert 'foo'\n @js '/js.js': \"alert('foo');\"\n\n c = t.client(zapp.app)\n c.get '/zappa/zappa.js', (err, res) ->\n t.ok 'zappa', res.body.indexOf('window.zappa={},') > -1", "source_lang": "JavaScript", "target_lang": "CoffeeScript", "repo": "mauricemach/zappa", "path": "tests/assets.coffee", "license": "MIT", "commit": "725e0103755c9a92fe84de06cee82db00e51a1f8", "stars": 943, "source_url": "https://github.com/mauricemach/zappa/blob/725e0103755c9a92fe84de06cee82db00e51a1f8/tests/assets.coffee", "line_start": 104, "line_end": 153}292{"id": "mauricemach/zappa:tests/assets.coffee:3:completion", "type": "completion", "prompt": "sammy: (t) ->\n t.expect 'content-type', 'length'\n t.wait 3000\n\n zapp = zappa port++, ->\n @use 'zappa'\n\n c = t.client(zapp.app)\n c.get '/zappa/sammy.js', (err, res) ->\n t.equal 'content-type', res.headers['content-type'], 'application/javascript'\n t.equal 'length', res.headers['content-length'], '18059'\n\n zappa: (t) ->\n t.expect 'content-type', 'snippet'\n t.wait 3000\n\n zapp = zappa port++, ->\n @use 'zappa'\n\n c = t.client(zapp.app)\n c.get '/zappa/zappa.js', (err, res) ->\n t.equal 'content-type', res.headers['content-type'], 'application/javascript'\n t.ok 'snippet', res.body.indexOf('window.zappa = {};') > -1\n\n 'zappa (automatic)': (t) ->", "response": "t.expect 'content-type', 'snippet'\n t.wait 3000\n\n zapp = zappa port++, ->\n @client '/index.js': ->\n\n c = t.client(zapp.app)\n c.get '/zappa/zappa.js', (err, res) ->\n t.equal 'content-type', res.headers['content-type'], 'application/javascript'\n t.ok 'snippet', res.body.indexOf('window.zappa = {};') > -1\n\n minify: (t) ->\n t.expect 'zappa', 'client', 'shared', 'coffee', 'js'\n t.wait 3000\n\n zapp = zappa port++, ->\n @enable 'minify'\n @client '/client.js': -> alert 'foo'\n @shared '/shared.js': -> alert 'foo' if window?\n @coffee '/coffee.js': -> alert 'foo'\n @js '/js.js': \"alert('foo');\"\n\n c = t.client(zapp.app)\n c.get '/zappa/zappa.js', (err, res) ->\n t.ok 'zappa', res.body.indexOf('window.zappa={},') > -1", "source_lang": "CoffeeScript", "target_lang": "CoffeeScript", "repo": "mauricemach/zappa", "path": "tests/assets.coffee", "license": "MIT", "commit": "725e0103755c9a92fe84de06cee82db00e51a1f8", "stars": 943, "source_url": "https://github.com/mauricemach/zappa/blob/725e0103755c9a92fe84de06cee82db00e51a1f8/tests/assets.coffee", "line_start": 104, "line_end": 153}293{"id": "mauricemach/zappa:tests/assets.coffee:4:raw_corpus", "type": "raw_corpus", "prompt": "", "response": "c.get '/client.js', (err, res) ->\n t.equal 'client', res.headers['content-length'], '42'\n c.get '/shared.js', (err, res) ->\n t.equal 'shared', res.headers['content-length'], '87'\n c.get '/coffee.js', (err, res) ->\n t.equal 'coffee', res.headers['content-length'], '475'\n c.get '/js.js', (err, res) ->\n t.equal 'js', res.headers['content-length'], '12'", "source_lang": "", "target_lang": "CoffeeScript", "repo": "mauricemach/zappa", "path": "tests/assets.coffee", "license": "MIT", "commit": "725e0103755c9a92fe84de06cee82db00e51a1f8", "stars": 943, "source_url": "https://github.com/mauricemach/zappa/blob/725e0103755c9a92fe84de06cee82db00e51a1f8/tests/assets.coffee", "line_start": 154, "line_end": 161}294{"id": "mauricemach/zappa:tests/assets.coffee:4:coffee_to_js", "type": "coffee_to_js", "prompt": "Convert this CoffeeScript to JavaScript.\n```coffeescript\nc.get '/client.js', (err, res) ->\n t.equal 'client', res.headers['content-length'], '42'\n c.get '/shared.js', (err, res) ->\n t.equal 'shared', res.headers['content-length'], '87'\n c.get '/coffee.js', (err, res) ->\n t.equal 'coffee', res.headers['content-length'], '475'\n c.get '/js.js', (err, res) ->\n t.equal 'js', res.headers['content-length'], '12'\n```", "response": "c.get('/client.js', function(err, res) {\n return t.equal('client', res.headers['content-length'], '42');\n});\n\nc.get('/shared.js', function(err, res) {\n return t.equal('shared', res.headers['content-length'], '87');\n});\n\nc.get('/coffee.js', function(err, res) {\n return t.equal('coffee', res.headers['content-length'], '475');\n});\n\nc.get('/js.js', function(err, res) {\n return t.equal('js', res.headers['content-length'], '12');\n});", "source_lang": "CoffeeScript", "target_lang": "JavaScript", "repo": "mauricemach/zappa", "path": "tests/assets.coffee", "license": "MIT", "commit": "725e0103755c9a92fe84de06cee82db00e51a1f8", "stars": 943, "source_url": "https://github.com/mauricemach/zappa/blob/725e0103755c9a92fe84de06cee82db00e51a1f8/tests/assets.coffee", "line_start": 154, "line_end": 161}295{"id": "mauricemach/zappa:tests/assets.coffee:4:js_to_coffee", "type": "js_to_coffee", "prompt": "Convert this JavaScript to CoffeeScript.\n```javascript\nc.get('/client.js', function(err, res) {\n return t.equal('client', res.headers['content-length'], '42');\n});\n\nc.get('/shared.js', function(err, res) {\n return t.equal('shared', res.headers['content-length'], '87');\n});\n\nc.get('/coffee.js', function(err, res) {\n return t.equal('coffee', res.headers['content-length'], '475');\n});\n\nc.get('/js.js', function(err, res) {\n return t.equal('js', res.headers['content-length'], '12');\n});\n```", "response": "c.get '/client.js', (err, res) ->\n t.equal 'client', res.headers['content-length'], '42'\n c.get '/shared.js', (err, res) ->\n t.equal 'shared', res.headers['content-length'], '87'\n c.get '/coffee.js', (err, res) ->\n t.equal 'coffee', res.headers['content-length'], '475'\n c.get '/js.js', (err, res) ->\n t.equal 'js', res.headers['content-length'], '12'", "source_lang": "JavaScript", "target_lang": "CoffeeScript", "repo": "mauricemach/zappa", "path": "tests/assets.coffee", "license": "MIT", "commit": "725e0103755c9a92fe84de06cee82db00e51a1f8", "stars": 943, "source_url": "https://github.com/mauricemach/zappa/blob/725e0103755c9a92fe84de06cee82db00e51a1f8/tests/assets.coffee", "line_start": 154, "line_end": 161}296{"id": "mauricemach/zappa:tests/assets.coffee:4:completion", "type": "completion", "prompt": "c.get '/client.js', (err, res) ->\n t.equal 'client', res.headers['content-length'], '42'\n c.get '/shared.js', (err, res) ->\n t.equal 'shared', res.headers['content-length'], '87'", "response": "c.get '/coffee.js', (err, res) ->\n t.equal 'coffee', res.headers['content-length'], '475'\n c.get '/js.js', (err, res) ->\n t.equal 'js', res.headers['content-length'], '12'", "source_lang": "CoffeeScript", "target_lang": "CoffeeScript", "repo": "mauricemach/zappa", "path": "tests/assets.coffee", "license": "MIT", "commit": "725e0103755c9a92fe84de06cee82db00e51a1f8", "stars": 943, "source_url": "https://github.com/mauricemach/zappa/blob/725e0103755c9a92fe84de06cee82db00e51a1f8/tests/assets.coffee", "line_start": 154, "line_end": 161}297{"id": "mauricemach/zappa:tests/assets.coffee:2:raw_corpus", "type": "raw_corpus", "prompt": "", "response": "c = t.client(zapp.app)\n c.get '/index.css', (err, res) ->\n t.equal 1, res.body, 'font-family: sans-serif;'\n t.equal 2, res.headers['content-type'], 'text/css'\n\n stylus: (t) ->\n t.expect 'header', 'body'\n t.wait 3000\n\n zapp = zappa port++, ->\n @stylus '/index.css': '''\n border-radius()\n -webkit-border-radius arguments\n -moz-border-radius arguments\n border-radius arguments\n\n body\n font 12px Helvetica, Arial, sans-serif\n\n a.button\n border-radius 5px\n '''\n\n c = t.client(zapp.app)\n c.get '/index.css', (err, res) ->\n t.equal 'header', res.headers['content-type'], 'text/css'\n t.equal 'body', res.body, '''\n body {\n font: 12px Helvetica, Arial, sans-serif;\n }\n a.button {\n -webkit-border-radius: 5px;\n -moz-border-radius: 5px;\n border-radius: 5px;\n }\n\n '''\n\n jquery: (t) ->\n t.expect 'content-type', 'length'\n t.wait 3000\n\n zapp = zappa port++, ->\n @enable 'serve jquery'\n\n c = t.client(zapp.app)\n c.get '/zappa/jquery.js', (err, res) ->\n t.equal 'content-type', res.headers['content-type'], 'application/javascript'\n t.equal 'length', res.headers['content-length'], '91669'", "source_lang": "", "target_lang": "CoffeeScript", "repo": "mauricemach/zappa", "path": "tests/assets.coffee", "license": "MIT", "commit": "44808669dcc48e436237fa0fcb7645d36f367ce7", "stars": 943, "source_url": "https://github.com/mauricemach/zappa/blob/44808669dcc48e436237fa0fcb7645d36f367ce7/tests/assets.coffee", "line_start": 54, "line_end": 103}298{"id": "mauricemach/zappa:tests/assets.coffee:2:completion", "type": "completion", "prompt": "c = t.client(zapp.app)\n c.get '/index.css', (err, res) ->\n t.equal 1, res.body, 'font-family: sans-serif;'\n t.equal 2, res.headers['content-type'], 'text/css'\n\n stylus: (t) ->\n t.expect 'header', 'body'\n t.wait 3000\n\n zapp = zappa port++, ->\n @stylus '/index.css': '''\n border-radius()\n -webkit-border-radius arguments\n -moz-border-radius arguments\n border-radius arguments\n\n body\n font 12px Helvetica, Arial, sans-serif\n\n a.button\n border-radius 5px\n '''\n\n c = t.client(zapp.app)", "response": "c.get '/index.css', (err, res) ->\n t.equal 'header', res.headers['content-type'], 'text/css'\n t.equal 'body', res.body, '''\n body {\n font: 12px Helvetica, Arial, sans-serif;\n }\n a.button {\n -webkit-border-radius: 5px;\n -moz-border-radius: 5px;\n border-radius: 5px;\n }\n\n '''\n\n jquery: (t) ->\n t.expect 'content-type', 'length'\n t.wait 3000\n\n zapp = zappa port++, ->\n @enable 'serve jquery'\n\n c = t.client(zapp.app)\n c.get '/zappa/jquery.js', (err, res) ->\n t.equal 'content-type', res.headers['content-type'], 'application/javascript'\n t.equal 'length', res.headers['content-length'], '91669'", "source_lang": "CoffeeScript", "target_lang": "CoffeeScript", "repo": "mauricemach/zappa", "path": "tests/assets.coffee", "license": "MIT", "commit": "44808669dcc48e436237fa0fcb7645d36f367ce7", "stars": 943, "source_url": "https://github.com/mauricemach/zappa/blob/44808669dcc48e436237fa0fcb7645d36f367ce7/tests/assets.coffee", "line_start": 54, "line_end": 103}299{"id": "mauricemach/zappa:tests/assets.coffee:3:raw_corpus", "type": "raw_corpus", "prompt": "", "response": "sammy: (t) ->\n t.expect 'content-type', 'length'\n t.wait 3000\n\n zapp = zappa port++, ->\n @enable 'serve sammy'\n\n c = t.client(zapp.app)\n c.get '/zappa/sammy.js', (err, res) ->\n t.equal 'content-type', res.headers['content-type'], 'application/javascript'\n t.equal 'length', res.headers['content-length'], '18059'\n\n zappa: (t) ->\n t.expect 'content-type', 'snippet'\n t.wait 3000\n\n zapp = zappa port++, ->\n @enable 'serve zappa'\n\n c = t.client(zapp.app)\n c.get '/zappa/zappa.js', (err, res) ->\n t.equal 'content-type', res.headers['content-type'], 'application/javascript'\n t.ok 'snippet', res.body.indexOf('window.zappa = {};') > -1\n\n 'zappa (automatic)': (t) ->\n t.expect 'content-type', 'snippet'\n t.wait 3000\n\n zapp = zappa port++, ->\n @client '/index.js': ->\n\n c = t.client(zapp.app)\n c.get '/zappa/zappa.js', (err, res) ->\n t.equal 'content-type', res.headers['content-type'], 'application/javascript'\n t.ok 'snippet', res.body.indexOf('window.zappa = {};') > -1\n\n minify: (t) ->\n t.expect 'zappa', 'client', 'shared', 'coffee', 'js'\n t.wait 3000\n\n zapp = zappa port++, ->\n @enable 'serve zappa', 'minify'\n @client '/client.js': -> alert 'foo'\n @shared '/shared.js': -> alert 'foo' if window?\n @coffee '/coffee.js': -> alert 'foo'\n @js '/js.js': \"alert('foo');\"\n\n c = t.client(zapp.app)\n c.get '/zappa/zappa.js', (err, res) ->\n t.ok 'zappa', res.body.indexOf('window.zappa={},') > -1", "source_lang": "", "target_lang": "CoffeeScript", "repo": "mauricemach/zappa", "path": "tests/assets.coffee", "license": "MIT", "commit": "44808669dcc48e436237fa0fcb7645d36f367ce7", "stars": 943, "source_url": "https://github.com/mauricemach/zappa/blob/44808669dcc48e436237fa0fcb7645d36f367ce7/tests/assets.coffee", "line_start": 104, "line_end": 153}300{"id": "mauricemach/zappa:tests/assets.coffee:3:coffee_to_js", "type": "coffee_to_js", "prompt": "Convert this CoffeeScript to JavaScript.\n```coffeescript\nsammy: (t) ->\n t.expect 'content-type', 'length'\n t.wait 3000\n\n zapp = zappa port++, ->\n @enable 'serve sammy'\n\n c = t.client(zapp.app)\n c.get '/zappa/sammy.js', (err, res) ->\n t.equal 'content-type', res.headers['content-type'], 'application/javascript'\n t.equal 'length', res.headers['content-length'], '18059'\n\n zappa: (t) ->\n t.expect 'content-type', 'snippet'\n t.wait 3000\n\n zapp = zappa port++, ->\n @enable 'serve zappa'\n\n c = t.client(zapp.app)\n c.get '/zappa/zappa.js', (err, res) ->\n t.equal 'content-type', res.headers['content-type'], 'application/javascript'\n t.ok 'snippet', res.body.indexOf('window.zappa = {};') > -1\n\n 'zappa (automatic)': (t) ->\n t.expect 'content-type', 'snippet'\n t.wait 3000\n\n zapp = zappa port++, ->\n @client '/index.js': ->\n\n c = t.client(zapp.app)\n c.get '/zappa/zappa.js', (err, res) ->\n t.equal 'content-type', res.headers['content-type'], 'application/javascript'\n t.ok 'snippet', res.body.indexOf('window.zappa = {};') > -1\n\n minify: (t) ->\n t.expect 'zappa', 'client', 'shared', 'coffee', 'js'\n t.wait 3000\n\n zapp = zappa port++, ->\n @enable 'serve zappa', 'minify'\n @client '/client.js': -> alert 'foo'\n @shared '/shared.js': -> alert 'foo' if window?\n @coffee '/coffee.js': -> alert 'foo'\n @js '/js.js': \"alert('foo');\"\n\n c = t.client(zapp.app)\n c.get '/zappa/zappa.js', (err, res) ->\n t.ok 'zappa', res.body.indexOf('window.zappa={},') > -1\n```", "response": "({\n sammy: function(t) {\n var c, zapp;\n t.expect('content-type', 'length');\n t.wait(3000);\n zapp = zappa(port++, function() {\n return this.enable('serve sammy');\n });\n c = t.client(zapp.app);\n return c.get('/zappa/sammy.js', function(err, res) {\n t.equal('content-type', res.headers['content-type'], 'application/javascript');\n return t.equal('length', res.headers['content-length'], '18059');\n });\n },\n zappa: function(t) {\n var c, zapp;\n t.expect('content-type', 'snippet');\n t.wait(3000);\n zapp = zappa(port++, function() {\n return this.enable('serve zappa');\n });\n c = t.client(zapp.app);\n return c.get('/zappa/zappa.js', function(err, res) {\n t.equal('content-type', res.headers['content-type'], 'application/javascript');\n return t.ok('snippet', res.body.indexOf('window.zappa = {};') > -1);\n });\n },\n 'zappa (automatic)': function(t) {\n var c, zapp;\n t.expect('content-type', 'snippet');\n t.wait(3000);\n zapp = zappa(port++, function() {\n return this.client({\n '/index.js': function() {}\n });\n });\n c = t.client(zapp.app);\n return c.get('/zappa/zappa.js', function(err, res) {\n t.equal('content-type', res.headers['content-type'], 'application/javascript');\n return t.ok('snippet', res.body.indexOf('window.zappa = {};') > -1);\n });\n },\n minify: function(t) {\n var c, zapp;\n t.expect('zappa', 'client', 'shared', 'coffee', 'js');\n t.wait(3000);\n zapp = zappa(port++, function() {\n this.enable('serve zappa', 'minify');\n this.client({\n '/client.js': function() {\n return alert('foo');\n }\n });\n this.shared({\n '/shared.js': function() {\n if (typeof window !== \"undefined\" && window !== null) {\n return alert('foo');\n }\n }\n });\n this.coffee({\n '/coffee.js': function() {\n return alert('foo');\n }\n });\n return this.js({\n '/js.js': \"alert('foo');\"\n });\n });\n c = t.client(zapp.app);\n return c.get('/zappa/zappa.js', function(err, res) {\n return t.ok('zappa', res.body.indexOf('window.zappa={},') > -1);\n });\n }\n});", "source_lang": "CoffeeScript", "target_lang": "JavaScript", "repo": "mauricemach/zappa", "path": "tests/assets.coffee", "license": "MIT", "commit": "44808669dcc48e436237fa0fcb7645d36f367ce7", "stars": 943, "source_url": "https://github.com/mauricemach/zappa/blob/44808669dcc48e436237fa0fcb7645d36f367ce7/tests/assets.coffee", "line_start": 104, "line_end": 153}301{"id": "mauricemach/zappa:tests/assets.coffee:3:js_to_coffee", "type": "js_to_coffee", "prompt": "Convert this JavaScript to CoffeeScript.\n```javascript\n({\n sammy: function(t) {\n var c, zapp;\n t.expect('content-type', 'length');\n t.wait(3000);\n zapp = zappa(port++, function() {\n return this.enable('serve sammy');\n });\n c = t.client(zapp.app);\n return c.get('/zappa/sammy.js', function(err, res) {\n t.equal('content-type', res.headers['content-type'], 'application/javascript');\n return t.equal('length', res.headers['content-length'], '18059');\n });\n },\n zappa: function(t) {\n var c, zapp;\n t.expect('content-type', 'snippet');\n t.wait(3000);\n zapp = zappa(port++, function() {\n return this.enable('serve zappa');\n });\n c = t.client(zapp.app);\n return c.get('/zappa/zappa.js', function(err, res) {\n t.equal('content-type', res.headers['content-type'], 'application/javascript');\n return t.ok('snippet', res.body.indexOf('window.zappa = {};') > -1);\n });\n },\n 'zappa (automatic)': function(t) {\n var c, zapp;\n t.expect('content-type', 'snippet');\n t.wait(3000);\n zapp = zappa(port++, function() {\n return this.client({\n '/index.js': function() {}\n });\n });\n c = t.client(zapp.app);\n return c.get('/zappa/zappa.js', function(err, res) {\n t.equal('content-type', res.headers['content-type'], 'application/javascript');\n return t.ok('snippet', res.body.indexOf('window.zappa = {};') > -1);\n });\n },\n minify: function(t) {\n var c, zapp;\n t.expect('zappa', 'client', 'shared', 'coffee', 'js');\n t.wait(3000);\n zapp = zappa(port++, function() {\n this.enable('serve zappa', 'minify');\n this.client({\n '/client.js': function() {\n return alert('foo');\n }\n });\n this.shared({\n '/shared.js': function() {\n if (typeof window !== \"undefined\" && window !== null) {\n return alert('foo');\n }\n }\n });\n this.coffee({\n '/coffee.js': function() {\n return alert('foo');\n }\n });\n return this.js({\n '/js.js': \"alert('foo');\"\n });\n });\n c = t.client(zapp.app);\n return c.get('/zappa/zappa.js', function(err, res) {\n return t.ok('zappa', res.body.indexOf('window.zappa={},') > -1);\n });\n }\n});\n```", "response": "sammy: (t) ->\n t.expect 'content-type', 'length'\n t.wait 3000\n\n zapp = zappa port++, ->\n @enable 'serve sammy'\n\n c = t.client(zapp.app)\n c.get '/zappa/sammy.js', (err, res) ->\n t.equal 'content-type', res.headers['content-type'], 'application/javascript'\n t.equal 'length', res.headers['content-length'], '18059'\n\n zappa: (t) ->\n t.expect 'content-type', 'snippet'\n t.wait 3000\n\n zapp = zappa port++, ->\n @enable 'serve zappa'\n\n c = t.client(zapp.app)\n c.get '/zappa/zappa.js', (err, res) ->\n t.equal 'content-type', res.headers['content-type'], 'application/javascript'\n t.ok 'snippet', res.body.indexOf('window.zappa = {};') > -1\n\n 'zappa (automatic)': (t) ->\n t.expect 'content-type', 'snippet'\n t.wait 3000\n\n zapp = zappa port++, ->\n @client '/index.js': ->\n\n c = t.client(zapp.app)\n c.get '/zappa/zappa.js', (err, res) ->\n t.equal 'content-type', res.headers['content-type'], 'application/javascript'\n t.ok 'snippet', res.body.indexOf('window.zappa = {};') > -1\n\n minify: (t) ->\n t.expect 'zappa', 'client', 'shared', 'coffee', 'js'\n t.wait 3000\n\n zapp = zappa port++, ->\n @enable 'serve zappa', 'minify'\n @client '/client.js': -> alert 'foo'\n @shared '/shared.js': -> alert 'foo' if window?\n @coffee '/coffee.js': -> alert 'foo'\n @js '/js.js': \"alert('foo');\"\n\n c = t.client(zapp.app)\n c.get '/zappa/zappa.js', (err, res) ->\n t.ok 'zappa', res.body.indexOf('window.zappa={},') > -1", "source_lang": "JavaScript", "target_lang": "CoffeeScript", "repo": "mauricemach/zappa", "path": "tests/assets.coffee", "license": "MIT", "commit": "44808669dcc48e436237fa0fcb7645d36f367ce7", "stars": 943, "source_url": "https://github.com/mauricemach/zappa/blob/44808669dcc48e436237fa0fcb7645d36f367ce7/tests/assets.coffee", "line_start": 104, "line_end": 153}302{"id": "mauricemach/zappa:tests/assets.coffee:3:completion", "type": "completion", "prompt": "sammy: (t) ->\n t.expect 'content-type', 'length'\n t.wait 3000\n\n zapp = zappa port++, ->\n @enable 'serve sammy'\n\n c = t.client(zapp.app)\n c.get '/zappa/sammy.js', (err, res) ->\n t.equal 'content-type', res.headers['content-type'], 'application/javascript'\n t.equal 'length', res.headers['content-length'], '18059'\n\n zappa: (t) ->\n t.expect 'content-type', 'snippet'\n t.wait 3000\n\n zapp = zappa port++, ->\n @enable 'serve zappa'\n\n c = t.client(zapp.app)\n c.get '/zappa/zappa.js', (err, res) ->\n t.equal 'content-type', res.headers['content-type'], 'application/javascript'\n t.ok 'snippet', res.body.indexOf('window.zappa = {};') > -1\n\n 'zappa (automatic)': (t) ->", "response": "t.expect 'content-type', 'snippet'\n t.wait 3000\n\n zapp = zappa port++, ->\n @client '/index.js': ->\n\n c = t.client(zapp.app)\n c.get '/zappa/zappa.js', (err, res) ->\n t.equal 'content-type', res.headers['content-type'], 'application/javascript'\n t.ok 'snippet', res.body.indexOf('window.zappa = {};') > -1\n\n minify: (t) ->\n t.expect 'zappa', 'client', 'shared', 'coffee', 'js'\n t.wait 3000\n\n zapp = zappa port++, ->\n @enable 'serve zappa', 'minify'\n @client '/client.js': -> alert 'foo'\n @shared '/shared.js': -> alert 'foo' if window?\n @coffee '/coffee.js': -> alert 'foo'\n @js '/js.js': \"alert('foo');\"\n\n c = t.client(zapp.app)\n c.get '/zappa/zappa.js', (err, res) ->\n t.ok 'zappa', res.body.indexOf('window.zappa={},') > -1", "source_lang": "CoffeeScript", "target_lang": "CoffeeScript", "repo": "mauricemach/zappa", "path": "tests/assets.coffee", "license": "MIT", "commit": "44808669dcc48e436237fa0fcb7645d36f367ce7", "stars": 943, "source_url": "https://github.com/mauricemach/zappa/blob/44808669dcc48e436237fa0fcb7645d36f367ce7/tests/assets.coffee", "line_start": 104, "line_end": 153}303{"id": "mauricemach/zappa:tests/assets.coffee:3:raw_corpus", "type": "raw_corpus", "prompt": "", "response": "sammy: (t) ->\n t.expect 'content-type', 'length'\n t.wait 3000\n\n zapp = zappa port++, ->\n @enable 'serve sammy'\n\n c = t.client(zapp.app)\n c.get '/zappa/sammy.js', (err, res) ->\n t.equal 'content-type', res.headers['content-type'], 'application/javascript'\n t.equal 'length', res.headers['content-length'], '18059'\n\n zappa: (t) ->\n t.expect 'content-type', 'length'\n t.wait 3000\n\n zapp = zappa port++, ->\n @enable 'serve zappa'\n\n c = t.client(zapp.app)\n c.get '/zappa/zappa.js', (err, res) ->\n t.equal 'content-type', res.headers['content-type'], 'application/javascript'\n t.equal 'length', res.headers['content-length'], '5574'\n\n 'zappa (automatic)': (t) ->\n t.expect 'content-type', 'length'\n t.wait 3000\n\n zapp = zappa port++, ->\n @client '/index.js': ->\n\n c = t.client(zapp.app)\n c.get '/zappa/zappa.js', (err, res) ->\n t.equal 'content-type', res.headers['content-type'], 'application/javascript'\n t.equal 'length', res.headers['content-length'], '5574'\n\n minify: (t) ->\n t.expect 'zappa', 'client', 'shared', 'coffee', 'js'\n t.wait 3000\n\n zapp = zappa port++, ->\n @enable 'serve zappa', 'minify'\n @client '/client.js': -> alert 'foo'\n @shared '/shared.js': -> alert 'foo' if window?\n @coffee '/coffee.js': -> alert 'foo'\n @js '/js.js': \"alert('foo');\"\n\n c = t.client(zapp.app)\n c.get '/zappa/zappa.js', (err, res) ->\n t.equal 'zappa', res.headers['content-length'], '2894'", "source_lang": "", "target_lang": "CoffeeScript", "repo": "mauricemach/zappa", "path": "tests/assets.coffee", "license": "MIT", "commit": "97c7ba23356254d5006e2cb8cb2c0012b05553ac", "stars": 943, "source_url": "https://github.com/mauricemach/zappa/blob/97c7ba23356254d5006e2cb8cb2c0012b05553ac/tests/assets.coffee", "line_start": 104, "line_end": 153}304{"id": "mauricemach/zappa:tests/assets.coffee:3:coffee_to_js", "type": "coffee_to_js", "prompt": "Convert this CoffeeScript to JavaScript.\n```coffeescript\nsammy: (t) ->\n t.expect 'content-type', 'length'\n t.wait 3000\n\n zapp = zappa port++, ->\n @enable 'serve sammy'\n\n c = t.client(zapp.app)\n c.get '/zappa/sammy.js', (err, res) ->\n t.equal 'content-type', res.headers['content-type'], 'application/javascript'\n t.equal 'length', res.headers['content-length'], '18059'\n\n zappa: (t) ->\n t.expect 'content-type', 'length'\n t.wait 3000\n\n zapp = zappa port++, ->\n @enable 'serve zappa'\n\n c = t.client(zapp.app)\n c.get '/zappa/zappa.js', (err, res) ->\n t.equal 'content-type', res.headers['content-type'], 'application/javascript'\n t.equal 'length', res.headers['content-length'], '5574'\n\n 'zappa (automatic)': (t) ->\n t.expect 'content-type', 'length'\n t.wait 3000\n\n zapp = zappa port++, ->\n @client '/index.js': ->\n\n c = t.client(zapp.app)\n c.get '/zappa/zappa.js', (err, res) ->\n t.equal 'content-type', res.headers['content-type'], 'application/javascript'\n t.equal 'length', res.headers['content-length'], '5574'\n\n minify: (t) ->\n t.expect 'zappa', 'client', 'shared', 'coffee', 'js'\n t.wait 3000\n\n zapp = zappa port++, ->\n @enable 'serve zappa', 'minify'\n @client '/client.js': -> alert 'foo'\n @shared '/shared.js': -> alert 'foo' if window?\n @coffee '/coffee.js': -> alert 'foo'\n @js '/js.js': \"alert('foo');\"\n\n c = t.client(zapp.app)\n c.get '/zappa/zappa.js', (err, res) ->\n t.equal 'zappa', res.headers['content-length'], '2894'\n```", "response": "({\n sammy: function(t) {\n var c, zapp;\n t.expect('content-type', 'length');\n t.wait(3000);\n zapp = zappa(port++, function() {\n return this.enable('serve sammy');\n });\n c = t.client(zapp.app);\n return c.get('/zappa/sammy.js', function(err, res) {\n t.equal('content-type', res.headers['content-type'], 'application/javascript');\n return t.equal('length', res.headers['content-length'], '18059');\n });\n },\n zappa: function(t) {\n var c, zapp;\n t.expect('content-type', 'length');\n t.wait(3000);\n zapp = zappa(port++, function() {\n return this.enable('serve zappa');\n });\n c = t.client(zapp.app);\n return c.get('/zappa/zappa.js', function(err, res) {\n t.equal('content-type', res.headers['content-type'], 'application/javascript');\n return t.equal('length', res.headers['content-length'], '5574');\n });\n },\n 'zappa (automatic)': function(t) {\n var c, zapp;\n t.expect('content-type', 'length');\n t.wait(3000);\n zapp = zappa(port++, function() {\n return this.client({\n '/index.js': function() {}\n });\n });\n c = t.client(zapp.app);\n return c.get('/zappa/zappa.js', function(err, res) {\n t.equal('content-type', res.headers['content-type'], 'application/javascript');\n return t.equal('length', res.headers['content-length'], '5574');\n });\n },\n minify: function(t) {\n var c, zapp;\n t.expect('zappa', 'client', 'shared', 'coffee', 'js');\n t.wait(3000);\n zapp = zappa(port++, function() {\n this.enable('serve zappa', 'minify');\n this.client({\n '/client.js': function() {\n return alert('foo');\n }\n });\n this.shared({\n '/shared.js': function() {\n if (typeof window !== \"undefined\" && window !== null) {\n return alert('foo');\n }\n }\n });\n this.coffee({\n '/coffee.js': function() {\n return alert('foo');\n }\n });\n return this.js({\n '/js.js': \"alert('foo');\"\n });\n });\n c = t.client(zapp.app);\n return c.get('/zappa/zappa.js', function(err, res) {\n return t.equal('zappa', res.headers['content-length'], '2894');\n });\n }\n});", "source_lang": "CoffeeScript", "target_lang": "JavaScript", "repo": "mauricemach/zappa", "path": "tests/assets.coffee", "license": "MIT", "commit": "97c7ba23356254d5006e2cb8cb2c0012b05553ac", "stars": 943, "source_url": "https://github.com/mauricemach/zappa/blob/97c7ba23356254d5006e2cb8cb2c0012b05553ac/tests/assets.coffee", "line_start": 104, "line_end": 153}305{"id": "mauricemach/zappa:tests/assets.coffee:3:js_to_coffee", "type": "js_to_coffee", "prompt": "Convert this JavaScript to CoffeeScript.\n```javascript\n({\n sammy: function(t) {\n var c, zapp;\n t.expect('content-type', 'length');\n t.wait(3000);\n zapp = zappa(port++, function() {\n return this.enable('serve sammy');\n });\n c = t.client(zapp.app);\n return c.get('/zappa/sammy.js', function(err, res) {\n t.equal('content-type', res.headers['content-type'], 'application/javascript');\n return t.equal('length', res.headers['content-length'], '18059');\n });\n },\n zappa: function(t) {\n var c, zapp;\n t.expect('content-type', 'length');\n t.wait(3000);\n zapp = zappa(port++, function() {\n return this.enable('serve zappa');\n });\n c = t.client(zapp.app);\n return c.get('/zappa/zappa.js', function(err, res) {\n t.equal('content-type', res.headers['content-type'], 'application/javascript');\n return t.equal('length', res.headers['content-length'], '5574');\n });\n },\n 'zappa (automatic)': function(t) {\n var c, zapp;\n t.expect('content-type', 'length');\n t.wait(3000);\n zapp = zappa(port++, function() {\n return this.client({\n '/index.js': function() {}\n });\n });\n c = t.client(zapp.app);\n return c.get('/zappa/zappa.js', function(err, res) {\n t.equal('content-type', res.headers['content-type'], 'application/javascript');\n return t.equal('length', res.headers['content-length'], '5574');\n });\n },\n minify: function(t) {\n var c, zapp;\n t.expect('zappa', 'client', 'shared', 'coffee', 'js');\n t.wait(3000);\n zapp = zappa(port++, function() {\n this.enable('serve zappa', 'minify');\n this.client({\n '/client.js': function() {\n return alert('foo');\n }\n });\n this.shared({\n '/shared.js': function() {\n if (typeof window !== \"undefined\" && window !== null) {\n return alert('foo');\n }\n }\n });\n this.coffee({\n '/coffee.js': function() {\n return alert('foo');\n }\n });\n return this.js({\n '/js.js': \"alert('foo');\"\n });\n });\n c = t.client(zapp.app);\n return c.get('/zappa/zappa.js', function(err, res) {\n return t.equal('zappa', res.headers['content-length'], '2894');\n });\n }\n});\n```", "response": "sammy: (t) ->\n t.expect 'content-type', 'length'\n t.wait 3000\n\n zapp = zappa port++, ->\n @enable 'serve sammy'\n\n c = t.client(zapp.app)\n c.get '/zappa/sammy.js', (err, res) ->\n t.equal 'content-type', res.headers['content-type'], 'application/javascript'\n t.equal 'length', res.headers['content-length'], '18059'\n\n zappa: (t) ->\n t.expect 'content-type', 'length'\n t.wait 3000\n\n zapp = zappa port++, ->\n @enable 'serve zappa'\n\n c = t.client(zapp.app)\n c.get '/zappa/zappa.js', (err, res) ->\n t.equal 'content-type', res.headers['content-type'], 'application/javascript'\n t.equal 'length', res.headers['content-length'], '5574'\n\n 'zappa (automatic)': (t) ->\n t.expect 'content-type', 'length'\n t.wait 3000\n\n zapp = zappa port++, ->\n @client '/index.js': ->\n\n c = t.client(zapp.app)\n c.get '/zappa/zappa.js', (err, res) ->\n t.equal 'content-type', res.headers['content-type'], 'application/javascript'\n t.equal 'length', res.headers['content-length'], '5574'\n\n minify: (t) ->\n t.expect 'zappa', 'client', 'shared', 'coffee', 'js'\n t.wait 3000\n\n zapp = zappa port++, ->\n @enable 'serve zappa', 'minify'\n @client '/client.js': -> alert 'foo'\n @shared '/shared.js': -> alert 'foo' if window?\n @coffee '/coffee.js': -> alert 'foo'\n @js '/js.js': \"alert('foo');\"\n\n c = t.client(zapp.app)\n c.get '/zappa/zappa.js', (err, res) ->\n t.equal 'zappa', res.headers['content-length'], '2894'", "source_lang": "JavaScript", "target_lang": "CoffeeScript", "repo": "mauricemach/zappa", "path": "tests/assets.coffee", "license": "MIT", "commit": "97c7ba23356254d5006e2cb8cb2c0012b05553ac", "stars": 943, "source_url": "https://github.com/mauricemach/zappa/blob/97c7ba23356254d5006e2cb8cb2c0012b05553ac/tests/assets.coffee", "line_start": 104, "line_end": 153}306{"id": "mauricemach/zappa:tests/assets.coffee:3:completion", "type": "completion", "prompt": "sammy: (t) ->\n t.expect 'content-type', 'length'\n t.wait 3000\n\n zapp = zappa port++, ->\n @enable 'serve sammy'\n\n c = t.client(zapp.app)\n c.get '/zappa/sammy.js', (err, res) ->\n t.equal 'content-type', res.headers['content-type'], 'application/javascript'\n t.equal 'length', res.headers['content-length'], '18059'\n\n zappa: (t) ->\n t.expect 'content-type', 'length'\n t.wait 3000\n\n zapp = zappa port++, ->\n @enable 'serve zappa'\n\n c = t.client(zapp.app)\n c.get '/zappa/zappa.js', (err, res) ->\n t.equal 'content-type', res.headers['content-type'], 'application/javascript'\n t.equal 'length', res.headers['content-length'], '5574'\n\n 'zappa (automatic)': (t) ->", "response": "t.expect 'content-type', 'length'\n t.wait 3000\n\n zapp = zappa port++, ->\n @client '/index.js': ->\n\n c = t.client(zapp.app)\n c.get '/zappa/zappa.js', (err, res) ->\n t.equal 'content-type', res.headers['content-type'], 'application/javascript'\n t.equal 'length', res.headers['content-length'], '5574'\n\n minify: (t) ->\n t.expect 'zappa', 'client', 'shared', 'coffee', 'js'\n t.wait 3000\n\n zapp = zappa port++, ->\n @enable 'serve zappa', 'minify'\n @client '/client.js': -> alert 'foo'\n @shared '/shared.js': -> alert 'foo' if window?\n @coffee '/coffee.js': -> alert 'foo'\n @js '/js.js': \"alert('foo');\"\n\n c = t.client(zapp.app)\n c.get '/zappa/zappa.js', (err, res) ->\n t.equal 'zappa', res.headers['content-length'], '2894'", "source_lang": "CoffeeScript", "target_lang": "CoffeeScript", "repo": "mauricemach/zappa", "path": "tests/assets.coffee", "license": "MIT", "commit": "97c7ba23356254d5006e2cb8cb2c0012b05553ac", "stars": 943, "source_url": "https://github.com/mauricemach/zappa/blob/97c7ba23356254d5006e2cb8cb2c0012b05553ac/tests/assets.coffee", "line_start": 104, "line_end": 153}307{"id": "mauricemach/zappa:tests/assets.coffee:3:raw_corpus", "type": "raw_corpus", "prompt": "", "response": "sammy: (t) ->\n t.expect 'content-type', 'length'\n t.wait 3000\n\n zapp = zappa port++, ->\n @enable 'serve sammy'\n\n c = t.client(zapp.app)\n c.get '/zappa/sammy.js', (err, res) ->\n t.equal 'content-type', res.headers['content-type'], 'application/javascript'\n t.equal 'length', res.headers['content-length'], '18059'\n\n zappa: (t) ->\n t.expect 'content-type', 'length'\n t.wait 3000\n\n zapp = zappa port++, ->\n @enable 'serve zappa'\n\n c = t.client(zapp.app)\n c.get '/zappa/zappa.js', (err, res) ->\n t.equal 'content-type', res.headers['content-type'], 'application/javascript'\n t.equal 'length', res.headers['content-length'], '5525'\n\n 'zappa (automatic)': (t) ->\n t.expect 'content-type', 'length'\n t.wait 3000\n\n zapp = zappa port++, ->\n @client '/index.js': ->\n\n c = t.client(zapp.app)\n c.get '/zappa/zappa.js', (err, res) ->\n t.equal 'content-type', res.headers['content-type'], 'application/javascript'\n t.equal 'length', res.headers['content-length'], '5525'\n\n minify: (t) ->\n t.expect 'zappa', 'client', 'shared', 'coffee', 'js'\n t.wait 3000\n\n zapp = zappa port++, ->\n @enable 'serve zappa', 'minify'\n @client '/client.js': -> alert 'foo'\n @shared '/shared.js': -> alert 'foo' if window?\n @coffee '/coffee.js': -> alert 'foo'\n @js '/js.js': \"alert('foo');\"\n\n c = t.client(zapp.app)\n c.get '/zappa/zappa.js', (err, res) ->\n t.equal 'zappa', res.headers['content-length'], '2809'", "source_lang": "", "target_lang": "CoffeeScript", "repo": "mauricemach/zappa", "path": "tests/assets.coffee", "license": "MIT", "commit": "e2df1016e4d0cd8360bb0ae5f96da48d8f6723b7", "stars": 943, "source_url": "https://github.com/mauricemach/zappa/blob/e2df1016e4d0cd8360bb0ae5f96da48d8f6723b7/tests/assets.coffee", "line_start": 104, "line_end": 153}308{"id": "mauricemach/zappa:tests/assets.coffee:3:coffee_to_js", "type": "coffee_to_js", "prompt": "Convert this CoffeeScript to JavaScript.\n```coffeescript\nsammy: (t) ->\n t.expect 'content-type', 'length'\n t.wait 3000\n\n zapp = zappa port++, ->\n @enable 'serve sammy'\n\n c = t.client(zapp.app)\n c.get '/zappa/sammy.js', (err, res) ->\n t.equal 'content-type', res.headers['content-type'], 'application/javascript'\n t.equal 'length', res.headers['content-length'], '18059'\n\n zappa: (t) ->\n t.expect 'content-type', 'length'\n t.wait 3000\n\n zapp = zappa port++, ->\n @enable 'serve zappa'\n\n c = t.client(zapp.app)\n c.get '/zappa/zappa.js', (err, res) ->\n t.equal 'content-type', res.headers['content-type'], 'application/javascript'\n t.equal 'length', res.headers['content-length'], '5525'\n\n 'zappa (automatic)': (t) ->\n t.expect 'content-type', 'length'\n t.wait 3000\n\n zapp = zappa port++, ->\n @client '/index.js': ->\n\n c = t.client(zapp.app)\n c.get '/zappa/zappa.js', (err, res) ->\n t.equal 'content-type', res.headers['content-type'], 'application/javascript'\n t.equal 'length', res.headers['content-length'], '5525'\n\n minify: (t) ->\n t.expect 'zappa', 'client', 'shared', 'coffee', 'js'\n t.wait 3000\n\n zapp = zappa port++, ->\n @enable 'serve zappa', 'minify'\n @client '/client.js': -> alert 'foo'\n @shared '/shared.js': -> alert 'foo' if window?\n @coffee '/coffee.js': -> alert 'foo'\n @js '/js.js': \"alert('foo');\"\n\n c = t.client(zapp.app)\n c.get '/zappa/zappa.js', (err, res) ->\n t.equal 'zappa', res.headers['content-length'], '2809'\n```", "response": "({\n sammy: function(t) {\n var c, zapp;\n t.expect('content-type', 'length');\n t.wait(3000);\n zapp = zappa(port++, function() {\n return this.enable('serve sammy');\n });\n c = t.client(zapp.app);\n return c.get('/zappa/sammy.js', function(err, res) {\n t.equal('content-type', res.headers['content-type'], 'application/javascript');\n return t.equal('length', res.headers['content-length'], '18059');\n });\n },\n zappa: function(t) {\n var c, zapp;\n t.expect('content-type', 'length');\n t.wait(3000);\n zapp = zappa(port++, function() {\n return this.enable('serve zappa');\n });\n c = t.client(zapp.app);\n return c.get('/zappa/zappa.js', function(err, res) {\n t.equal('content-type', res.headers['content-type'], 'application/javascript');\n return t.equal('length', res.headers['content-length'], '5525');\n });\n },\n 'zappa (automatic)': function(t) {\n var c, zapp;\n t.expect('content-type', 'length');\n t.wait(3000);\n zapp = zappa(port++, function() {\n return this.client({\n '/index.js': function() {}\n });\n });\n c = t.client(zapp.app);\n return c.get('/zappa/zappa.js', function(err, res) {\n t.equal('content-type', res.headers['content-type'], 'application/javascript');\n return t.equal('length', res.headers['content-length'], '5525');\n });\n },\n minify: function(t) {\n var c, zapp;\n t.expect('zappa', 'client', 'shared', 'coffee', 'js');\n t.wait(3000);\n zapp = zappa(port++, function() {\n this.enable('serve zappa', 'minify');\n this.client({\n '/client.js': function() {\n return alert('foo');\n }\n });\n this.shared({\n '/shared.js': function() {\n if (typeof window !== \"undefined\" && window !== null) {\n return alert('foo');\n }\n }\n });\n this.coffee({\n '/coffee.js': function() {\n return alert('foo');\n }\n });\n return this.js({\n '/js.js': \"alert('foo');\"\n });\n });\n c = t.client(zapp.app);\n return c.get('/zappa/zappa.js', function(err, res) {\n return t.equal('zappa', res.headers['content-length'], '2809');\n });\n }\n});", "source_lang": "CoffeeScript", "target_lang": "JavaScript", "repo": "mauricemach/zappa", "path": "tests/assets.coffee", "license": "MIT", "commit": "e2df1016e4d0cd8360bb0ae5f96da48d8f6723b7", "stars": 943, "source_url": "https://github.com/mauricemach/zappa/blob/e2df1016e4d0cd8360bb0ae5f96da48d8f6723b7/tests/assets.coffee", "line_start": 104, "line_end": 153}309{"id": "mauricemach/zappa:tests/assets.coffee:3:js_to_coffee", "type": "js_to_coffee", "prompt": "Convert this JavaScript to CoffeeScript.\n```javascript\n({\n sammy: function(t) {\n var c, zapp;\n t.expect('content-type', 'length');\n t.wait(3000);\n zapp = zappa(port++, function() {\n return this.enable('serve sammy');\n });\n c = t.client(zapp.app);\n return c.get('/zappa/sammy.js', function(err, res) {\n t.equal('content-type', res.headers['content-type'], 'application/javascript');\n return t.equal('length', res.headers['content-length'], '18059');\n });\n },\n zappa: function(t) {\n var c, zapp;\n t.expect('content-type', 'length');\n t.wait(3000);\n zapp = zappa(port++, function() {\n return this.enable('serve zappa');\n });\n c = t.client(zapp.app);\n return c.get('/zappa/zappa.js', function(err, res) {\n t.equal('content-type', res.headers['content-type'], 'application/javascript');\n return t.equal('length', res.headers['content-length'], '5525');\n });\n },\n 'zappa (automatic)': function(t) {\n var c, zapp;\n t.expect('content-type', 'length');\n t.wait(3000);\n zapp = zappa(port++, function() {\n return this.client({\n '/index.js': function() {}\n });\n });\n c = t.client(zapp.app);\n return c.get('/zappa/zappa.js', function(err, res) {\n t.equal('content-type', res.headers['content-type'], 'application/javascript');\n return t.equal('length', res.headers['content-length'], '5525');\n });\n },\n minify: function(t) {\n var c, zapp;\n t.expect('zappa', 'client', 'shared', 'coffee', 'js');\n t.wait(3000);\n zapp = zappa(port++, function() {\n this.enable('serve zappa', 'minify');\n this.client({\n '/client.js': function() {\n return alert('foo');\n }\n });\n this.shared({\n '/shared.js': function() {\n if (typeof window !== \"undefined\" && window !== null) {\n return alert('foo');\n }\n }\n });\n this.coffee({\n '/coffee.js': function() {\n return alert('foo');\n }\n });\n return this.js({\n '/js.js': \"alert('foo');\"\n });\n });\n c = t.client(zapp.app);\n return c.get('/zappa/zappa.js', function(err, res) {\n return t.equal('zappa', res.headers['content-length'], '2809');\n });\n }\n});\n```", "response": "sammy: (t) ->\n t.expect 'content-type', 'length'\n t.wait 3000\n\n zapp = zappa port++, ->\n @enable 'serve sammy'\n\n c = t.client(zapp.app)\n c.get '/zappa/sammy.js', (err, res) ->\n t.equal 'content-type', res.headers['content-type'], 'application/javascript'\n t.equal 'length', res.headers['content-length'], '18059'\n\n zappa: (t) ->\n t.expect 'content-type', 'length'\n t.wait 3000\n\n zapp = zappa port++, ->\n @enable 'serve zappa'\n\n c = t.client(zapp.app)\n c.get '/zappa/zappa.js', (err, res) ->\n t.equal 'content-type', res.headers['content-type'], 'application/javascript'\n t.equal 'length', res.headers['content-length'], '5525'\n\n 'zappa (automatic)': (t) ->\n t.expect 'content-type', 'length'\n t.wait 3000\n\n zapp = zappa port++, ->\n @client '/index.js': ->\n\n c = t.client(zapp.app)\n c.get '/zappa/zappa.js', (err, res) ->\n t.equal 'content-type', res.headers['content-type'], 'application/javascript'\n t.equal 'length', res.headers['content-length'], '5525'\n\n minify: (t) ->\n t.expect 'zappa', 'client', 'shared', 'coffee', 'js'\n t.wait 3000\n\n zapp = zappa port++, ->\n @enable 'serve zappa', 'minify'\n @client '/client.js': -> alert 'foo'\n @shared '/shared.js': -> alert 'foo' if window?\n @coffee '/coffee.js': -> alert 'foo'\n @js '/js.js': \"alert('foo');\"\n\n c = t.client(zapp.app)\n c.get '/zappa/zappa.js', (err, res) ->\n t.equal 'zappa', res.headers['content-length'], '2809'", "source_lang": "JavaScript", "target_lang": "CoffeeScript", "repo": "mauricemach/zappa", "path": "tests/assets.coffee", "license": "MIT", "commit": "e2df1016e4d0cd8360bb0ae5f96da48d8f6723b7", "stars": 943, "source_url": "https://github.com/mauricemach/zappa/blob/e2df1016e4d0cd8360bb0ae5f96da48d8f6723b7/tests/assets.coffee", "line_start": 104, "line_end": 153}310{"id": "mauricemach/zappa:tests/assets.coffee:3:completion", "type": "completion", "prompt": "sammy: (t) ->\n t.expect 'content-type', 'length'\n t.wait 3000\n\n zapp = zappa port++, ->\n @enable 'serve sammy'\n\n c = t.client(zapp.app)\n c.get '/zappa/sammy.js', (err, res) ->\n t.equal 'content-type', res.headers['content-type'], 'application/javascript'\n t.equal 'length', res.headers['content-length'], '18059'\n\n zappa: (t) ->\n t.expect 'content-type', 'length'\n t.wait 3000\n\n zapp = zappa port++, ->\n @enable 'serve zappa'\n\n c = t.client(zapp.app)\n c.get '/zappa/zappa.js', (err, res) ->\n t.equal 'content-type', res.headers['content-type'], 'application/javascript'\n t.equal 'length', res.headers['content-length'], '5525'\n\n 'zappa (automatic)': (t) ->", "response": "t.expect 'content-type', 'length'\n t.wait 3000\n\n zapp = zappa port++, ->\n @client '/index.js': ->\n\n c = t.client(zapp.app)\n c.get '/zappa/zappa.js', (err, res) ->\n t.equal 'content-type', res.headers['content-type'], 'application/javascript'\n t.equal 'length', res.headers['content-length'], '5525'\n\n minify: (t) ->\n t.expect 'zappa', 'client', 'shared', 'coffee', 'js'\n t.wait 3000\n\n zapp = zappa port++, ->\n @enable 'serve zappa', 'minify'\n @client '/client.js': -> alert 'foo'\n @shared '/shared.js': -> alert 'foo' if window?\n @coffee '/coffee.js': -> alert 'foo'\n @js '/js.js': \"alert('foo');\"\n\n c = t.client(zapp.app)\n c.get '/zappa/zappa.js', (err, res) ->\n t.equal 'zappa', res.headers['content-length'], '2809'", "source_lang": "CoffeeScript", "target_lang": "CoffeeScript", "repo": "mauricemach/zappa", "path": "tests/assets.coffee", "license": "MIT", "commit": "e2df1016e4d0cd8360bb0ae5f96da48d8f6723b7", "stars": 943, "source_url": "https://github.com/mauricemach/zappa/blob/e2df1016e4d0cd8360bb0ae5f96da48d8f6723b7/tests/assets.coffee", "line_start": 104, "line_end": 153}311{"id": "mauricemach/zappa:tests/assets.coffee:3:raw_corpus", "type": "raw_corpus", "prompt": "", "response": "sammy: (t) ->\n t.expect 'content-type', 'length'\n t.wait 3000\n\n zapp = zappa port++, ->\n @enable 'serve sammy'\n\n c = t.client(zapp.app)\n c.get '/zappa/sammy.js', (err, res) ->\n t.equal 'content-type', res.headers['content-type'], 'application/javascript'\n t.equal 'length', res.headers['content-length'], '18059'\n\n zappa: (t) ->\n t.expect 'content-type', 'length'\n t.wait 3000\n\n zapp = zappa port++, ->\n @enable 'serve zappa'\n\n c = t.client(zapp.app)\n c.get '/zappa/zappa.js', (err, res) ->\n t.equal 'content-type', res.headers['content-type'], 'application/javascript'\n t.equal 'length', res.headers['content-length'], '5049'\n\n 'zappa (automatic)': (t) ->\n t.expect 'content-type', 'length'\n t.wait 3000\n\n zapp = zappa port++, ->\n @client '/index.js': ->\n\n c = t.client(zapp.app)\n c.get '/zappa/zappa.js', (err, res) ->\n t.equal 'content-type', res.headers['content-type'], 'application/javascript'\n t.equal 'length', res.headers['content-length'], '5049'\n\n minify: (t) ->\n t.expect 'zappa', 'client', 'shared', 'coffee', 'js'\n t.wait 3000\n\n zapp = zappa port++, ->\n @enable 'serve zappa', 'minify'\n @client '/client.js': -> alert 'foo'\n @shared '/shared.js': -> alert 'foo' if window?\n @coffee '/coffee.js': -> alert 'foo'\n @js '/js.js': \"alert('foo');\"\n\n c = t.client(zapp.app)\n c.get '/zappa/zappa.js', (err, res) ->\n t.equal 'zappa', res.headers['content-length'], '2623'", "source_lang": "", "target_lang": "CoffeeScript", "repo": "mauricemach/zappa", "path": "tests/assets.coffee", "license": "MIT", "commit": "2f373ce1622801e11822adff5138103887427b62", "stars": 943, "source_url": "https://github.com/mauricemach/zappa/blob/2f373ce1622801e11822adff5138103887427b62/tests/assets.coffee", "line_start": 104, "line_end": 153}312{"id": "mauricemach/zappa:tests/assets.coffee:3:coffee_to_js", "type": "coffee_to_js", "prompt": "Convert this CoffeeScript to JavaScript.\n```coffeescript\nsammy: (t) ->\n t.expect 'content-type', 'length'\n t.wait 3000\n\n zapp = zappa port++, ->\n @enable 'serve sammy'\n\n c = t.client(zapp.app)\n c.get '/zappa/sammy.js', (err, res) ->\n t.equal 'content-type', res.headers['content-type'], 'application/javascript'\n t.equal 'length', res.headers['content-length'], '18059'\n\n zappa: (t) ->\n t.expect 'content-type', 'length'\n t.wait 3000\n\n zapp = zappa port++, ->\n @enable 'serve zappa'\n\n c = t.client(zapp.app)\n c.get '/zappa/zappa.js', (err, res) ->\n t.equal 'content-type', res.headers['content-type'], 'application/javascript'\n t.equal 'length', res.headers['content-length'], '5049'\n\n 'zappa (automatic)': (t) ->\n t.expect 'content-type', 'length'\n t.wait 3000\n\n zapp = zappa port++, ->\n @client '/index.js': ->\n\n c = t.client(zapp.app)\n c.get '/zappa/zappa.js', (err, res) ->\n t.equal 'content-type', res.headers['content-type'], 'application/javascript'\n t.equal 'length', res.headers['content-length'], '5049'\n\n minify: (t) ->\n t.expect 'zappa', 'client', 'shared', 'coffee', 'js'\n t.wait 3000\n\n zapp = zappa port++, ->\n @enable 'serve zappa', 'minify'\n @client '/client.js': -> alert 'foo'\n @shared '/shared.js': -> alert 'foo' if window?\n @coffee '/coffee.js': -> alert 'foo'\n @js '/js.js': \"alert('foo');\"\n\n c = t.client(zapp.app)\n c.get '/zappa/zappa.js', (err, res) ->\n t.equal 'zappa', res.headers['content-length'], '2623'\n```", "response": "({\n sammy: function(t) {\n var c, zapp;\n t.expect('content-type', 'length');\n t.wait(3000);\n zapp = zappa(port++, function() {\n return this.enable('serve sammy');\n });\n c = t.client(zapp.app);\n return c.get('/zappa/sammy.js', function(err, res) {\n t.equal('content-type', res.headers['content-type'], 'application/javascript');\n return t.equal('length', res.headers['content-length'], '18059');\n });\n },\n zappa: function(t) {\n var c, zapp;\n t.expect('content-type', 'length');\n t.wait(3000);\n zapp = zappa(port++, function() {\n return this.enable('serve zappa');\n });\n c = t.client(zapp.app);\n return c.get('/zappa/zappa.js', function(err, res) {\n t.equal('content-type', res.headers['content-type'], 'application/javascript');\n return t.equal('length', res.headers['content-length'], '5049');\n });\n },\n 'zappa (automatic)': function(t) {\n var c, zapp;\n t.expect('content-type', 'length');\n t.wait(3000);\n zapp = zappa(port++, function() {\n return this.client({\n '/index.js': function() {}\n });\n });\n c = t.client(zapp.app);\n return c.get('/zappa/zappa.js', function(err, res) {\n t.equal('content-type', res.headers['content-type'], 'application/javascript');\n return t.equal('length', res.headers['content-length'], '5049');\n });\n },\n minify: function(t) {\n var c, zapp;\n t.expect('zappa', 'client', 'shared', 'coffee', 'js');\n t.wait(3000);\n zapp = zappa(port++, function() {\n this.enable('serve zappa', 'minify');\n this.client({\n '/client.js': function() {\n return alert('foo');\n }\n });\n this.shared({\n '/shared.js': function() {\n if (typeof window !== \"undefined\" && window !== null) {\n return alert('foo');\n }\n }\n });\n this.coffee({\n '/coffee.js': function() {\n return alert('foo');\n }\n });\n return this.js({\n '/js.js': \"alert('foo');\"\n });\n });\n c = t.client(zapp.app);\n return c.get('/zappa/zappa.js', function(err, res) {\n return t.equal('zappa', res.headers['content-length'], '2623');\n });\n }\n});", "source_lang": "CoffeeScript", "target_lang": "JavaScript", "repo": "mauricemach/zappa", "path": "tests/assets.coffee", "license": "MIT", "commit": "2f373ce1622801e11822adff5138103887427b62", "stars": 943, "source_url": "https://github.com/mauricemach/zappa/blob/2f373ce1622801e11822adff5138103887427b62/tests/assets.coffee", "line_start": 104, "line_end": 153}313{"id": "mauricemach/zappa:tests/assets.coffee:3:js_to_coffee", "type": "js_to_coffee", "prompt": "Convert this JavaScript to CoffeeScript.\n```javascript\n({\n sammy: function(t) {\n var c, zapp;\n t.expect('content-type', 'length');\n t.wait(3000);\n zapp = zappa(port++, function() {\n return this.enable('serve sammy');\n });\n c = t.client(zapp.app);\n return c.get('/zappa/sammy.js', function(err, res) {\n t.equal('content-type', res.headers['content-type'], 'application/javascript');\n return t.equal('length', res.headers['content-length'], '18059');\n });\n },\n zappa: function(t) {\n var c, zapp;\n t.expect('content-type', 'length');\n t.wait(3000);\n zapp = zappa(port++, function() {\n return this.enable('serve zappa');\n });\n c = t.client(zapp.app);\n return c.get('/zappa/zappa.js', function(err, res) {\n t.equal('content-type', res.headers['content-type'], 'application/javascript');\n return t.equal('length', res.headers['content-length'], '5049');\n });\n },\n 'zappa (automatic)': function(t) {\n var c, zapp;\n t.expect('content-type', 'length');\n t.wait(3000);\n zapp = zappa(port++, function() {\n return this.client({\n '/index.js': function() {}\n });\n });\n c = t.client(zapp.app);\n return c.get('/zappa/zappa.js', function(err, res) {\n t.equal('content-type', res.headers['content-type'], 'application/javascript');\n return t.equal('length', res.headers['content-length'], '5049');\n });\n },\n minify: function(t) {\n var c, zapp;\n t.expect('zappa', 'client', 'shared', 'coffee', 'js');\n t.wait(3000);\n zapp = zappa(port++, function() {\n this.enable('serve zappa', 'minify');\n this.client({\n '/client.js': function() {\n return alert('foo');\n }\n });\n this.shared({\n '/shared.js': function() {\n if (typeof window !== \"undefined\" && window !== null) {\n return alert('foo');\n }\n }\n });\n this.coffee({\n '/coffee.js': function() {\n return alert('foo');\n }\n });\n return this.js({\n '/js.js': \"alert('foo');\"\n });\n });\n c = t.client(zapp.app);\n return c.get('/zappa/zappa.js', function(err, res) {\n return t.equal('zappa', res.headers['content-length'], '2623');\n });\n }\n});\n```", "response": "sammy: (t) ->\n t.expect 'content-type', 'length'\n t.wait 3000\n\n zapp = zappa port++, ->\n @enable 'serve sammy'\n\n c = t.client(zapp.app)\n c.get '/zappa/sammy.js', (err, res) ->\n t.equal 'content-type', res.headers['content-type'], 'application/javascript'\n t.equal 'length', res.headers['content-length'], '18059'\n\n zappa: (t) ->\n t.expect 'content-type', 'length'\n t.wait 3000\n\n zapp = zappa port++, ->\n @enable 'serve zappa'\n\n c = t.client(zapp.app)\n c.get '/zappa/zappa.js', (err, res) ->\n t.equal 'content-type', res.headers['content-type'], 'application/javascript'\n t.equal 'length', res.headers['content-length'], '5049'\n\n 'zappa (automatic)': (t) ->\n t.expect 'content-type', 'length'\n t.wait 3000\n\n zapp = zappa port++, ->\n @client '/index.js': ->\n\n c = t.client(zapp.app)\n c.get '/zappa/zappa.js', (err, res) ->\n t.equal 'content-type', res.headers['content-type'], 'application/javascript'\n t.equal 'length', res.headers['content-length'], '5049'\n\n minify: (t) ->\n t.expect 'zappa', 'client', 'shared', 'coffee', 'js'\n t.wait 3000\n\n zapp = zappa port++, ->\n @enable 'serve zappa', 'minify'\n @client '/client.js': -> alert 'foo'\n @shared '/shared.js': -> alert 'foo' if window?\n @coffee '/coffee.js': -> alert 'foo'\n @js '/js.js': \"alert('foo');\"\n\n c = t.client(zapp.app)\n c.get '/zappa/zappa.js', (err, res) ->\n t.equal 'zappa', res.headers['content-length'], '2623'", "source_lang": "JavaScript", "target_lang": "CoffeeScript", "repo": "mauricemach/zappa", "path": "tests/assets.coffee", "license": "MIT", "commit": "2f373ce1622801e11822adff5138103887427b62", "stars": 943, "source_url": "https://github.com/mauricemach/zappa/blob/2f373ce1622801e11822adff5138103887427b62/tests/assets.coffee", "line_start": 104, "line_end": 153}314{"id": "mauricemach/zappa:tests/assets.coffee:3:completion", "type": "completion", "prompt": "sammy: (t) ->\n t.expect 'content-type', 'length'\n t.wait 3000\n\n zapp = zappa port++, ->\n @enable 'serve sammy'\n\n c = t.client(zapp.app)\n c.get '/zappa/sammy.js', (err, res) ->\n t.equal 'content-type', res.headers['content-type'], 'application/javascript'\n t.equal 'length', res.headers['content-length'], '18059'\n\n zappa: (t) ->\n t.expect 'content-type', 'length'\n t.wait 3000\n\n zapp = zappa port++, ->\n @enable 'serve zappa'\n\n c = t.client(zapp.app)\n c.get '/zappa/zappa.js', (err, res) ->\n t.equal 'content-type', res.headers['content-type'], 'application/javascript'\n t.equal 'length', res.headers['content-length'], '5049'\n\n 'zappa (automatic)': (t) ->", "response": "t.expect 'content-type', 'length'\n t.wait 3000\n\n zapp = zappa port++, ->\n @client '/index.js': ->\n\n c = t.client(zapp.app)\n c.get '/zappa/zappa.js', (err, res) ->\n t.equal 'content-type', res.headers['content-type'], 'application/javascript'\n t.equal 'length', res.headers['content-length'], '5049'\n\n minify: (t) ->\n t.expect 'zappa', 'client', 'shared', 'coffee', 'js'\n t.wait 3000\n\n zapp = zappa port++, ->\n @enable 'serve zappa', 'minify'\n @client '/client.js': -> alert 'foo'\n @shared '/shared.js': -> alert 'foo' if window?\n @coffee '/coffee.js': -> alert 'foo'\n @js '/js.js': \"alert('foo');\"\n\n c = t.client(zapp.app)\n c.get '/zappa/zappa.js', (err, res) ->\n t.equal 'zappa', res.headers['content-length'], '2623'", "source_lang": "CoffeeScript", "target_lang": "CoffeeScript", "repo": "mauricemach/zappa", "path": "tests/assets.coffee", "license": "MIT", "commit": "2f373ce1622801e11822adff5138103887427b62", "stars": 943, "source_url": "https://github.com/mauricemach/zappa/blob/2f373ce1622801e11822adff5138103887427b62/tests/assets.coffee", "line_start": 104, "line_end": 153}315{"id": "mauricemach/zappa:tests/assets.coffee:3:raw_corpus", "type": "raw_corpus", "prompt": "", "response": "sammy: (t) ->\n t.expect 'content-type', 'length'\n t.wait 3000\n\n zapp = zappa port++, ->\n @enable 'serve sammy'\n\n c = t.client(zapp.app)\n c.get '/zappa/sammy.js', (err, res) ->\n t.equal 'content-type', res.headers['content-type'], 'application/javascript'\n t.equal 'length', res.headers['content-length'], '18059'\n\n zappa: (t) ->\n t.expect 'content-type', 'length'\n t.wait 3000\n\n zapp = zappa port++, ->\n @enable 'serve zappa'\n\n c = t.client(zapp.app)\n c.get '/zappa/zappa.js', (err, res) ->\n t.equal 'content-type', res.headers['content-type'], 'application/javascript'\n t.equal 'length', res.headers['content-length'], '5160'\n\n 'zappa (automatic)': (t) ->\n t.expect 'content-type', 'length'\n t.wait 3000\n\n zapp = zappa port++, ->\n @client '/index.js': ->\n\n c = t.client(zapp.app)\n c.get '/zappa/zappa.js', (err, res) ->\n t.equal 'content-type', res.headers['content-type'], 'application/javascript'\n t.equal 'length', res.headers['content-length'], '5160'\n\n minify: (t) ->\n t.expect 'zappa', 'client', 'shared', 'coffee', 'js'\n t.wait 3000\n\n zapp = zappa port++, ->\n @enable 'serve zappa', 'minify'\n @client '/client.js': -> alert 'foo'\n @shared '/shared.js': -> alert 'foo' if window?\n @coffee '/coffee.js': -> alert 'foo'\n @js '/js.js': \"alert('foo');\"\n\n c = t.client(zapp.app)\n c.get '/zappa/zappa.js', (err, res) ->\n t.equal 'zappa', res.headers['content-length'], '2667'", "source_lang": "", "target_lang": "CoffeeScript", "repo": "mauricemach/zappa", "path": "tests/assets.coffee", "license": "MIT", "commit": "92f6f994e18cf11bd33881c68bbe0f5c846d24b2", "stars": 943, "source_url": "https://github.com/mauricemach/zappa/blob/92f6f994e18cf11bd33881c68bbe0f5c846d24b2/tests/assets.coffee", "line_start": 104, "line_end": 153}316{"id": "mauricemach/zappa:tests/assets.coffee:3:coffee_to_js", "type": "coffee_to_js", "prompt": "Convert this CoffeeScript to JavaScript.\n```coffeescript\nsammy: (t) ->\n t.expect 'content-type', 'length'\n t.wait 3000\n\n zapp = zappa port++, ->\n @enable 'serve sammy'\n\n c = t.client(zapp.app)\n c.get '/zappa/sammy.js', (err, res) ->\n t.equal 'content-type', res.headers['content-type'], 'application/javascript'\n t.equal 'length', res.headers['content-length'], '18059'\n\n zappa: (t) ->\n t.expect 'content-type', 'length'\n t.wait 3000\n\n zapp = zappa port++, ->\n @enable 'serve zappa'\n\n c = t.client(zapp.app)\n c.get '/zappa/zappa.js', (err, res) ->\n t.equal 'content-type', res.headers['content-type'], 'application/javascript'\n t.equal 'length', res.headers['content-length'], '5160'\n\n 'zappa (automatic)': (t) ->\n t.expect 'content-type', 'length'\n t.wait 3000\n\n zapp = zappa port++, ->\n @client '/index.js': ->\n\n c = t.client(zapp.app)\n c.get '/zappa/zappa.js', (err, res) ->\n t.equal 'content-type', res.headers['content-type'], 'application/javascript'\n t.equal 'length', res.headers['content-length'], '5160'\n\n minify: (t) ->\n t.expect 'zappa', 'client', 'shared', 'coffee', 'js'\n t.wait 3000\n\n zapp = zappa port++, ->\n @enable 'serve zappa', 'minify'\n @client '/client.js': -> alert 'foo'\n @shared '/shared.js': -> alert 'foo' if window?\n @coffee '/coffee.js': -> alert 'foo'\n @js '/js.js': \"alert('foo');\"\n\n c = t.client(zapp.app)\n c.get '/zappa/zappa.js', (err, res) ->\n t.equal 'zappa', res.headers['content-length'], '2667'\n```", "response": "({\n sammy: function(t) {\n var c, zapp;\n t.expect('content-type', 'length');\n t.wait(3000);\n zapp = zappa(port++, function() {\n return this.enable('serve sammy');\n });\n c = t.client(zapp.app);\n return c.get('/zappa/sammy.js', function(err, res) {\n t.equal('content-type', res.headers['content-type'], 'application/javascript');\n return t.equal('length', res.headers['content-length'], '18059');\n });\n },\n zappa: function(t) {\n var c, zapp;\n t.expect('content-type', 'length');\n t.wait(3000);\n zapp = zappa(port++, function() {\n return this.enable('serve zappa');\n });\n c = t.client(zapp.app);\n return c.get('/zappa/zappa.js', function(err, res) {\n t.equal('content-type', res.headers['content-type'], 'application/javascript');\n return t.equal('length', res.headers['content-length'], '5160');\n });\n },\n 'zappa (automatic)': function(t) {\n var c, zapp;\n t.expect('content-type', 'length');\n t.wait(3000);\n zapp = zappa(port++, function() {\n return this.client({\n '/index.js': function() {}\n });\n });\n c = t.client(zapp.app);\n return c.get('/zappa/zappa.js', function(err, res) {\n t.equal('content-type', res.headers['content-type'], 'application/javascript');\n return t.equal('length', res.headers['content-length'], '5160');\n });\n },\n minify: function(t) {\n var c, zapp;\n t.expect('zappa', 'client', 'shared', 'coffee', 'js');\n t.wait(3000);\n zapp = zappa(port++, function() {\n this.enable('serve zappa', 'minify');\n this.client({\n '/client.js': function() {\n return alert('foo');\n }\n });\n this.shared({\n '/shared.js': function() {\n if (typeof window !== \"undefined\" && window !== null) {\n return alert('foo');\n }\n }\n });\n this.coffee({\n '/coffee.js': function() {\n return alert('foo');\n }\n });\n return this.js({\n '/js.js': \"alert('foo');\"\n });\n });\n c = t.client(zapp.app);\n return c.get('/zappa/zappa.js', function(err, res) {\n return t.equal('zappa', res.headers['content-length'], '2667');\n });\n }\n});", "source_lang": "CoffeeScript", "target_lang": "JavaScript", "repo": "mauricemach/zappa", "path": "tests/assets.coffee", "license": "MIT", "commit": "92f6f994e18cf11bd33881c68bbe0f5c846d24b2", "stars": 943, "source_url": "https://github.com/mauricemach/zappa/blob/92f6f994e18cf11bd33881c68bbe0f5c846d24b2/tests/assets.coffee", "line_start": 104, "line_end": 153}317{"id": "mauricemach/zappa:tests/assets.coffee:3:js_to_coffee", "type": "js_to_coffee", "prompt": "Convert this JavaScript to CoffeeScript.\n```javascript\n({\n sammy: function(t) {\n var c, zapp;\n t.expect('content-type', 'length');\n t.wait(3000);\n zapp = zappa(port++, function() {\n return this.enable('serve sammy');\n });\n c = t.client(zapp.app);\n return c.get('/zappa/sammy.js', function(err, res) {\n t.equal('content-type', res.headers['content-type'], 'application/javascript');\n return t.equal('length', res.headers['content-length'], '18059');\n });\n },\n zappa: function(t) {\n var c, zapp;\n t.expect('content-type', 'length');\n t.wait(3000);\n zapp = zappa(port++, function() {\n return this.enable('serve zappa');\n });\n c = t.client(zapp.app);\n return c.get('/zappa/zappa.js', function(err, res) {\n t.equal('content-type', res.headers['content-type'], 'application/javascript');\n return t.equal('length', res.headers['content-length'], '5160');\n });\n },\n 'zappa (automatic)': function(t) {\n var c, zapp;\n t.expect('content-type', 'length');\n t.wait(3000);\n zapp = zappa(port++, function() {\n return this.client({\n '/index.js': function() {}\n });\n });\n c = t.client(zapp.app);\n return c.get('/zappa/zappa.js', function(err, res) {\n t.equal('content-type', res.headers['content-type'], 'application/javascript');\n return t.equal('length', res.headers['content-length'], '5160');\n });\n },\n minify: function(t) {\n var c, zapp;\n t.expect('zappa', 'client', 'shared', 'coffee', 'js');\n t.wait(3000);\n zapp = zappa(port++, function() {\n this.enable('serve zappa', 'minify');\n this.client({\n '/client.js': function() {\n return alert('foo');\n }\n });\n this.shared({\n '/shared.js': function() {\n if (typeof window !== \"undefined\" && window !== null) {\n return alert('foo');\n }\n }\n });\n this.coffee({\n '/coffee.js': function() {\n return alert('foo');\n }\n });\n return this.js({\n '/js.js': \"alert('foo');\"\n });\n });\n c = t.client(zapp.app);\n return c.get('/zappa/zappa.js', function(err, res) {\n return t.equal('zappa', res.headers['content-length'], '2667');\n });\n }\n});\n```", "response": "sammy: (t) ->\n t.expect 'content-type', 'length'\n t.wait 3000\n\n zapp = zappa port++, ->\n @enable 'serve sammy'\n\n c = t.client(zapp.app)\n c.get '/zappa/sammy.js', (err, res) ->\n t.equal 'content-type', res.headers['content-type'], 'application/javascript'\n t.equal 'length', res.headers['content-length'], '18059'\n\n zappa: (t) ->\n t.expect 'content-type', 'length'\n t.wait 3000\n\n zapp = zappa port++, ->\n @enable 'serve zappa'\n\n c = t.client(zapp.app)\n c.get '/zappa/zappa.js', (err, res) ->\n t.equal 'content-type', res.headers['content-type'], 'application/javascript'\n t.equal 'length', res.headers['content-length'], '5160'\n\n 'zappa (automatic)': (t) ->\n t.expect 'content-type', 'length'\n t.wait 3000\n\n zapp = zappa port++, ->\n @client '/index.js': ->\n\n c = t.client(zapp.app)\n c.get '/zappa/zappa.js', (err, res) ->\n t.equal 'content-type', res.headers['content-type'], 'application/javascript'\n t.equal 'length', res.headers['content-length'], '5160'\n\n minify: (t) ->\n t.expect 'zappa', 'client', 'shared', 'coffee', 'js'\n t.wait 3000\n\n zapp = zappa port++, ->\n @enable 'serve zappa', 'minify'\n @client '/client.js': -> alert 'foo'\n @shared '/shared.js': -> alert 'foo' if window?\n @coffee '/coffee.js': -> alert 'foo'\n @js '/js.js': \"alert('foo');\"\n\n c = t.client(zapp.app)\n c.get '/zappa/zappa.js', (err, res) ->\n t.equal 'zappa', res.headers['content-length'], '2667'", "source_lang": "JavaScript", "target_lang": "CoffeeScript", "repo": "mauricemach/zappa", "path": "tests/assets.coffee", "license": "MIT", "commit": "92f6f994e18cf11bd33881c68bbe0f5c846d24b2", "stars": 943, "source_url": "https://github.com/mauricemach/zappa/blob/92f6f994e18cf11bd33881c68bbe0f5c846d24b2/tests/assets.coffee", "line_start": 104, "line_end": 153}318{"id": "mauricemach/zappa:tests/assets.coffee:3:completion", "type": "completion", "prompt": "sammy: (t) ->\n t.expect 'content-type', 'length'\n t.wait 3000\n\n zapp = zappa port++, ->\n @enable 'serve sammy'\n\n c = t.client(zapp.app)\n c.get '/zappa/sammy.js', (err, res) ->\n t.equal 'content-type', res.headers['content-type'], 'application/javascript'\n t.equal 'length', res.headers['content-length'], '18059'\n\n zappa: (t) ->\n t.expect 'content-type', 'length'\n t.wait 3000\n\n zapp = zappa port++, ->\n @enable 'serve zappa'\n\n c = t.client(zapp.app)\n c.get '/zappa/zappa.js', (err, res) ->\n t.equal 'content-type', res.headers['content-type'], 'application/javascript'\n t.equal 'length', res.headers['content-length'], '5160'\n\n 'zappa (automatic)': (t) ->", "response": "t.expect 'content-type', 'length'\n t.wait 3000\n\n zapp = zappa port++, ->\n @client '/index.js': ->\n\n c = t.client(zapp.app)\n c.get '/zappa/zappa.js', (err, res) ->\n t.equal 'content-type', res.headers['content-type'], 'application/javascript'\n t.equal 'length', res.headers['content-length'], '5160'\n\n minify: (t) ->\n t.expect 'zappa', 'client', 'shared', 'coffee', 'js'\n t.wait 3000\n\n zapp = zappa port++, ->\n @enable 'serve zappa', 'minify'\n @client '/client.js': -> alert 'foo'\n @shared '/shared.js': -> alert 'foo' if window?\n @coffee '/coffee.js': -> alert 'foo'\n @js '/js.js': \"alert('foo');\"\n\n c = t.client(zapp.app)\n c.get '/zappa/zappa.js', (err, res) ->\n t.equal 'zappa', res.headers['content-length'], '2667'", "source_lang": "CoffeeScript", "target_lang": "CoffeeScript", "repo": "mauricemach/zappa", "path": "tests/assets.coffee", "license": "MIT", "commit": "92f6f994e18cf11bd33881c68bbe0f5c846d24b2", "stars": 943, "source_url": "https://github.com/mauricemach/zappa/blob/92f6f994e18cf11bd33881c68bbe0f5c846d24b2/tests/assets.coffee", "line_start": 104, "line_end": 153}319{"id": "mauricemach/zappa:tests/assets.coffee:2:raw_corpus", "type": "raw_corpus", "prompt": "", "response": "c = t.client(zapp.app)\n c.get '/index.css', (err, res) ->\n t.equal 1, res.body, 'font-family: sans-serif;'\n t.equal 2, res.headers['content-type'], 'text/css'\n\n stylus: (t) ->\n t.expect 'header', 'body'\n t.wait 3000\n\n zapp = zappa port++, ->\n @stylus '/index.css': '''\n border-radius()\n -webkit-border-radius arguments\n -moz-border-radius arguments\n border-radius arguments\n\n body\n font 12px Helvetica, Arial, sans-serif\n\n a.button\n border-radius 5px\n '''\n\n c = t.client(zapp.app)\n c.get '/index.css', (err, res) ->\n t.equal 'header', res.headers['content-type'], 'text/css'\n t.equal 'body', res.body, '''\n body {\n font: 12px Helvetica, Arial, sans-serif;\n }\n a.button {\n -webkit-border-radius: 5px;\n -moz-border-radius: 5px;\n border-radius: 5px;\n }\n\n '''\n\n jquery: (t) ->\n t.expect 'content-type', 'length'\n t.wait 3000\n\n zapp = zappa port++, ->\n @enable 'serve jquery'\n\n c = t.client(zapp.app)\n c.get '/zappa/jquery.js', (err, res) ->\n t.equal 'content-type', res.headers['content-type'], 'application/javascript'\n t.equal 'length', res.headers['content-length'], '92334'", "source_lang": "", "target_lang": "CoffeeScript", "repo": "mauricemach/zappa", "path": "tests/assets.coffee", "license": "MIT", "commit": "13361ea724375f6dd3e85118df6cd62145ef7ab0", "stars": 943, "source_url": "https://github.com/mauricemach/zappa/blob/13361ea724375f6dd3e85118df6cd62145ef7ab0/tests/assets.coffee", "line_start": 54, "line_end": 103}320{"id": "mauricemach/zappa:tests/assets.coffee:2:completion", "type": "completion", "prompt": "c = t.client(zapp.app)\n c.get '/index.css', (err, res) ->\n t.equal 1, res.body, 'font-family: sans-serif;'\n t.equal 2, res.headers['content-type'], 'text/css'\n\n stylus: (t) ->\n t.expect 'header', 'body'\n t.wait 3000\n\n zapp = zappa port++, ->\n @stylus '/index.css': '''\n border-radius()\n -webkit-border-radius arguments\n -moz-border-radius arguments\n border-radius arguments\n\n body\n font 12px Helvetica, Arial, sans-serif\n\n a.button\n border-radius 5px\n '''\n\n c = t.client(zapp.app)", "response": "c.get '/index.css', (err, res) ->\n t.equal 'header', res.headers['content-type'], 'text/css'\n t.equal 'body', res.body, '''\n body {\n font: 12px Helvetica, Arial, sans-serif;\n }\n a.button {\n -webkit-border-radius: 5px;\n -moz-border-radius: 5px;\n border-radius: 5px;\n }\n\n '''\n\n jquery: (t) ->\n t.expect 'content-type', 'length'\n t.wait 3000\n\n zapp = zappa port++, ->\n @enable 'serve jquery'\n\n c = t.client(zapp.app)\n c.get '/zappa/jquery.js', (err, res) ->\n t.equal 'content-type', res.headers['content-type'], 'application/javascript'\n t.equal 'length', res.headers['content-length'], '92334'", "source_lang": "CoffeeScript", "target_lang": "CoffeeScript", "repo": "mauricemach/zappa", "path": "tests/assets.coffee", "license": "MIT", "commit": "13361ea724375f6dd3e85118df6cd62145ef7ab0", "stars": 943, "source_url": "https://github.com/mauricemach/zappa/blob/13361ea724375f6dd3e85118df6cd62145ef7ab0/tests/assets.coffee", "line_start": 54, "line_end": 103}321{"id": "mauricemach/zappa:tests/assets.coffee:3:raw_corpus", "type": "raw_corpus", "prompt": "", "response": "sammy: (t) ->\n t.expect 'content-type', 'length'\n t.wait 3000\n\n zapp = zappa port++, ->\n @enable 'serve sammy'\n\n c = t.client(zapp.app)\n c.get '/zappa/sammy.js', (err, res) ->\n t.equal 'content-type', res.headers['content-type'], 'application/javascript'\n t.equal 'length', res.headers['content-length'], '16854'\n\n zappa: (t) ->\n t.expect 'content-type', 'length'\n t.wait 3000\n\n zapp = zappa port++, ->\n @enable 'serve zappa'\n\n c = t.client(zapp.app)\n c.get '/zappa/zappa.js', (err, res) ->\n t.equal 'content-type', res.headers['content-type'], 'application/javascript'\n t.equal 'length', res.headers['content-length'], '5156'\n\n 'zappa (automatic)': (t) ->\n t.expect 'content-type', 'length'\n t.wait 3000\n\n zapp = zappa port++, ->\n @client '/index.js': ->\n\n c = t.client(zapp.app)\n c.get '/zappa/zappa.js', (err, res) ->\n t.equal 'content-type', res.headers['content-type'], 'application/javascript'\n t.equal 'length', res.headers['content-length'], '5156'\n\n minify: (t) ->\n t.expect 'zappa', 'client', 'shared', 'coffee', 'js'\n t.wait 3000\n\n zapp = zappa port++, ->\n @enable 'serve zappa', 'minify'\n @client '/client.js': -> alert 'foo'\n @shared '/shared.js': -> alert 'foo' if window?\n @coffee '/coffee.js': -> alert 'foo'\n @js '/js.js': \"alert('foo');\"\n\n c = t.client(zapp.app)\n c.get '/zappa/zappa.js', (err, res) ->\n t.equal 'zappa', res.headers['content-length'], '2663'", "source_lang": "", "target_lang": "CoffeeScript", "repo": "mauricemach/zappa", "path": "tests/assets.coffee", "license": "MIT", "commit": "13361ea724375f6dd3e85118df6cd62145ef7ab0", "stars": 943, "source_url": "https://github.com/mauricemach/zappa/blob/13361ea724375f6dd3e85118df6cd62145ef7ab0/tests/assets.coffee", "line_start": 104, "line_end": 153}322{"id": "mauricemach/zappa:tests/assets.coffee:3:coffee_to_js", "type": "coffee_to_js", "prompt": "Convert this CoffeeScript to JavaScript.\n```coffeescript\nsammy: (t) ->\n t.expect 'content-type', 'length'\n t.wait 3000\n\n zapp = zappa port++, ->\n @enable 'serve sammy'\n\n c = t.client(zapp.app)\n c.get '/zappa/sammy.js', (err, res) ->\n t.equal 'content-type', res.headers['content-type'], 'application/javascript'\n t.equal 'length', res.headers['content-length'], '16854'\n\n zappa: (t) ->\n t.expect 'content-type', 'length'\n t.wait 3000\n\n zapp = zappa port++, ->\n @enable 'serve zappa'\n\n c = t.client(zapp.app)\n c.get '/zappa/zappa.js', (err, res) ->\n t.equal 'content-type', res.headers['content-type'], 'application/javascript'\n t.equal 'length', res.headers['content-length'], '5156'\n\n 'zappa (automatic)': (t) ->\n t.expect 'content-type', 'length'\n t.wait 3000\n\n zapp = zappa port++, ->\n @client '/index.js': ->\n\n c = t.client(zapp.app)\n c.get '/zappa/zappa.js', (err, res) ->\n t.equal 'content-type', res.headers['content-type'], 'application/javascript'\n t.equal 'length', res.headers['content-length'], '5156'\n\n minify: (t) ->\n t.expect 'zappa', 'client', 'shared', 'coffee', 'js'\n t.wait 3000\n\n zapp = zappa port++, ->\n @enable 'serve zappa', 'minify'\n @client '/client.js': -> alert 'foo'\n @shared '/shared.js': -> alert 'foo' if window?\n @coffee '/coffee.js': -> alert 'foo'\n @js '/js.js': \"alert('foo');\"\n\n c = t.client(zapp.app)\n c.get '/zappa/zappa.js', (err, res) ->\n t.equal 'zappa', res.headers['content-length'], '2663'\n```", "response": "({\n sammy: function(t) {\n var c, zapp;\n t.expect('content-type', 'length');\n t.wait(3000);\n zapp = zappa(port++, function() {\n return this.enable('serve sammy');\n });\n c = t.client(zapp.app);\n return c.get('/zappa/sammy.js', function(err, res) {\n t.equal('content-type', res.headers['content-type'], 'application/javascript');\n return t.equal('length', res.headers['content-length'], '16854');\n });\n },\n zappa: function(t) {\n var c, zapp;\n t.expect('content-type', 'length');\n t.wait(3000);\n zapp = zappa(port++, function() {\n return this.enable('serve zappa');\n });\n c = t.client(zapp.app);\n return c.get('/zappa/zappa.js', function(err, res) {\n t.equal('content-type', res.headers['content-type'], 'application/javascript');\n return t.equal('length', res.headers['content-length'], '5156');\n });\n },\n 'zappa (automatic)': function(t) {\n var c, zapp;\n t.expect('content-type', 'length');\n t.wait(3000);\n zapp = zappa(port++, function() {\n return this.client({\n '/index.js': function() {}\n });\n });\n c = t.client(zapp.app);\n return c.get('/zappa/zappa.js', function(err, res) {\n t.equal('content-type', res.headers['content-type'], 'application/javascript');\n return t.equal('length', res.headers['content-length'], '5156');\n });\n },\n minify: function(t) {\n var c, zapp;\n t.expect('zappa', 'client', 'shared', 'coffee', 'js');\n t.wait(3000);\n zapp = zappa(port++, function() {\n this.enable('serve zappa', 'minify');\n this.client({\n '/client.js': function() {\n return alert('foo');\n }\n });\n this.shared({\n '/shared.js': function() {\n if (typeof window !== \"undefined\" && window !== null) {\n return alert('foo');\n }\n }\n });\n this.coffee({\n '/coffee.js': function() {\n return alert('foo');\n }\n });\n return this.js({\n '/js.js': \"alert('foo');\"\n });\n });\n c = t.client(zapp.app);\n return c.get('/zappa/zappa.js', function(err, res) {\n return t.equal('zappa', res.headers['content-length'], '2663');\n });\n }\n});", "source_lang": "CoffeeScript", "target_lang": "JavaScript", "repo": "mauricemach/zappa", "path": "tests/assets.coffee", "license": "MIT", "commit": "13361ea724375f6dd3e85118df6cd62145ef7ab0", "stars": 943, "source_url": "https://github.com/mauricemach/zappa/blob/13361ea724375f6dd3e85118df6cd62145ef7ab0/tests/assets.coffee", "line_start": 104, "line_end": 153}323{"id": "mauricemach/zappa:tests/assets.coffee:3:js_to_coffee", "type": "js_to_coffee", "prompt": "Convert this JavaScript to CoffeeScript.\n```javascript\n({\n sammy: function(t) {\n var c, zapp;\n t.expect('content-type', 'length');\n t.wait(3000);\n zapp = zappa(port++, function() {\n return this.enable('serve sammy');\n });\n c = t.client(zapp.app);\n return c.get('/zappa/sammy.js', function(err, res) {\n t.equal('content-type', res.headers['content-type'], 'application/javascript');\n return t.equal('length', res.headers['content-length'], '16854');\n });\n },\n zappa: function(t) {\n var c, zapp;\n t.expect('content-type', 'length');\n t.wait(3000);\n zapp = zappa(port++, function() {\n return this.enable('serve zappa');\n });\n c = t.client(zapp.app);\n return c.get('/zappa/zappa.js', function(err, res) {\n t.equal('content-type', res.headers['content-type'], 'application/javascript');\n return t.equal('length', res.headers['content-length'], '5156');\n });\n },\n 'zappa (automatic)': function(t) {\n var c, zapp;\n t.expect('content-type', 'length');\n t.wait(3000);\n zapp = zappa(port++, function() {\n return this.client({\n '/index.js': function() {}\n });\n });\n c = t.client(zapp.app);\n return c.get('/zappa/zappa.js', function(err, res) {\n t.equal('content-type', res.headers['content-type'], 'application/javascript');\n return t.equal('length', res.headers['content-length'], '5156');\n });\n },\n minify: function(t) {\n var c, zapp;\n t.expect('zappa', 'client', 'shared', 'coffee', 'js');\n t.wait(3000);\n zapp = zappa(port++, function() {\n this.enable('serve zappa', 'minify');\n this.client({\n '/client.js': function() {\n return alert('foo');\n }\n });\n this.shared({\n '/shared.js': function() {\n if (typeof window !== \"undefined\" && window !== null) {\n return alert('foo');\n }\n }\n });\n this.coffee({\n '/coffee.js': function() {\n return alert('foo');\n }\n });\n return this.js({\n '/js.js': \"alert('foo');\"\n });\n });\n c = t.client(zapp.app);\n return c.get('/zappa/zappa.js', function(err, res) {\n return t.equal('zappa', res.headers['content-length'], '2663');\n });\n }\n});\n```", "response": "sammy: (t) ->\n t.expect 'content-type', 'length'\n t.wait 3000\n\n zapp = zappa port++, ->\n @enable 'serve sammy'\n\n c = t.client(zapp.app)\n c.get '/zappa/sammy.js', (err, res) ->\n t.equal 'content-type', res.headers['content-type'], 'application/javascript'\n t.equal 'length', res.headers['content-length'], '16854'\n\n zappa: (t) ->\n t.expect 'content-type', 'length'\n t.wait 3000\n\n zapp = zappa port++, ->\n @enable 'serve zappa'\n\n c = t.client(zapp.app)\n c.get '/zappa/zappa.js', (err, res) ->\n t.equal 'content-type', res.headers['content-type'], 'application/javascript'\n t.equal 'length', res.headers['content-length'], '5156'\n\n 'zappa (automatic)': (t) ->\n t.expect 'content-type', 'length'\n t.wait 3000\n\n zapp = zappa port++, ->\n @client '/index.js': ->\n\n c = t.client(zapp.app)\n c.get '/zappa/zappa.js', (err, res) ->\n t.equal 'content-type', res.headers['content-type'], 'application/javascript'\n t.equal 'length', res.headers['content-length'], '5156'\n\n minify: (t) ->\n t.expect 'zappa', 'client', 'shared', 'coffee', 'js'\n t.wait 3000\n\n zapp = zappa port++, ->\n @enable 'serve zappa', 'minify'\n @client '/client.js': -> alert 'foo'\n @shared '/shared.js': -> alert 'foo' if window?\n @coffee '/coffee.js': -> alert 'foo'\n @js '/js.js': \"alert('foo');\"\n\n c = t.client(zapp.app)\n c.get '/zappa/zappa.js', (err, res) ->\n t.equal 'zappa', res.headers['content-length'], '2663'", "source_lang": "JavaScript", "target_lang": "CoffeeScript", "repo": "mauricemach/zappa", "path": "tests/assets.coffee", "license": "MIT", "commit": "13361ea724375f6dd3e85118df6cd62145ef7ab0", "stars": 943, "source_url": "https://github.com/mauricemach/zappa/blob/13361ea724375f6dd3e85118df6cd62145ef7ab0/tests/assets.coffee", "line_start": 104, "line_end": 153}324{"id": "mauricemach/zappa:tests/assets.coffee:3:completion", "type": "completion", "prompt": "sammy: (t) ->\n t.expect 'content-type', 'length'\n t.wait 3000\n\n zapp = zappa port++, ->\n @enable 'serve sammy'\n\n c = t.client(zapp.app)\n c.get '/zappa/sammy.js', (err, res) ->\n t.equal 'content-type', res.headers['content-type'], 'application/javascript'\n t.equal 'length', res.headers['content-length'], '16854'\n\n zappa: (t) ->\n t.expect 'content-type', 'length'\n t.wait 3000\n\n zapp = zappa port++, ->\n @enable 'serve zappa'\n\n c = t.client(zapp.app)\n c.get '/zappa/zappa.js', (err, res) ->\n t.equal 'content-type', res.headers['content-type'], 'application/javascript'\n t.equal 'length', res.headers['content-length'], '5156'\n\n 'zappa (automatic)': (t) ->", "response": "t.expect 'content-type', 'length'\n t.wait 3000\n\n zapp = zappa port++, ->\n @client '/index.js': ->\n\n c = t.client(zapp.app)\n c.get '/zappa/zappa.js', (err, res) ->\n t.equal 'content-type', res.headers['content-type'], 'application/javascript'\n t.equal 'length', res.headers['content-length'], '5156'\n\n minify: (t) ->\n t.expect 'zappa', 'client', 'shared', 'coffee', 'js'\n t.wait 3000\n\n zapp = zappa port++, ->\n @enable 'serve zappa', 'minify'\n @client '/client.js': -> alert 'foo'\n @shared '/shared.js': -> alert 'foo' if window?\n @coffee '/coffee.js': -> alert 'foo'\n @js '/js.js': \"alert('foo');\"\n\n c = t.client(zapp.app)\n c.get '/zappa/zappa.js', (err, res) ->\n t.equal 'zappa', res.headers['content-length'], '2663'", "source_lang": "CoffeeScript", "target_lang": "CoffeeScript", "repo": "mauricemach/zappa", "path": "tests/assets.coffee", "license": "MIT", "commit": "13361ea724375f6dd3e85118df6cd62145ef7ab0", "stars": 943, "source_url": "https://github.com/mauricemach/zappa/blob/13361ea724375f6dd3e85118df6cd62145ef7ab0/tests/assets.coffee", "line_start": 104, "line_end": 153}325{"id": "mauricemach/zappa:tests/assets.coffee:3:raw_corpus", "type": "raw_corpus", "prompt": "", "response": "sammy: (t) ->\n t.expect 'content-type', 'length'\n t.wait 3000\n\n zapp = zappa port++, ->\n @enable 'serve sammy'\n\n c = t.client(zapp.app)\n c.get '/zappa/sammy.js', (err, res) ->\n t.equal 'content-type', res.headers['content-type'], 'application/javascript'\n t.equal 'length', res.headers['content-length'], '16854'\n\n zappa: (t) ->\n t.expect 'content-type', 'length'\n t.wait 3000\n\n zapp = zappa port++, ->\n @enable 'serve zappa'\n\n c = t.client(zapp.app)\n c.get '/zappa/zappa.js', (err, res) ->\n t.equal 'content-type', res.headers['content-type'], 'application/javascript'\n t.equal 'length', res.headers['content-length'], '4685'\n\n 'zappa (automatic)': (t) ->\n t.expect 'content-type', 'length'\n t.wait 3000\n\n zapp = zappa port++, ->\n @client '/index.js': ->\n\n c = t.client(zapp.app)\n c.get '/zappa/zappa.js', (err, res) ->\n t.equal 'content-type', res.headers['content-type'], 'application/javascript'\n t.equal 'length', res.headers['content-length'], '4685'\n\n minify: (t) ->\n t.expect 'zappa', 'client', 'shared', 'coffee', 'js'\n t.wait 3000\n\n zapp = zappa port++, ->\n @enable 'serve zappa', 'minify'\n @client '/client.js': -> alert 'foo'\n @shared '/shared.js': -> alert 'foo' if window?\n @coffee '/coffee.js': -> alert 'foo'\n @js '/js.js': \"alert('foo');\"\n\n c = t.client(zapp.app)\n c.get '/zappa/zappa.js', (err, res) ->\n t.equal 'zappa', res.headers['content-length'], '2492'", "source_lang": "", "target_lang": "CoffeeScript", "repo": "mauricemach/zappa", "path": "tests/assets.coffee", "license": "MIT", "commit": "e5d10aedecdd70b2c81c6923a746fb7d2f9eeafd", "stars": 943, "source_url": "https://github.com/mauricemach/zappa/blob/e5d10aedecdd70b2c81c6923a746fb7d2f9eeafd/tests/assets.coffee", "line_start": 104, "line_end": 153}326{"id": "mauricemach/zappa:tests/assets.coffee:3:coffee_to_js", "type": "coffee_to_js", "prompt": "Convert this CoffeeScript to JavaScript.\n```coffeescript\nsammy: (t) ->\n t.expect 'content-type', 'length'\n t.wait 3000\n\n zapp = zappa port++, ->\n @enable 'serve sammy'\n\n c = t.client(zapp.app)\n c.get '/zappa/sammy.js', (err, res) ->\n t.equal 'content-type', res.headers['content-type'], 'application/javascript'\n t.equal 'length', res.headers['content-length'], '16854'\n\n zappa: (t) ->\n t.expect 'content-type', 'length'\n t.wait 3000\n\n zapp = zappa port++, ->\n @enable 'serve zappa'\n\n c = t.client(zapp.app)\n c.get '/zappa/zappa.js', (err, res) ->\n t.equal 'content-type', res.headers['content-type'], 'application/javascript'\n t.equal 'length', res.headers['content-length'], '4685'\n\n 'zappa (automatic)': (t) ->\n t.expect 'content-type', 'length'\n t.wait 3000\n\n zapp = zappa port++, ->\n @client '/index.js': ->\n\n c = t.client(zapp.app)\n c.get '/zappa/zappa.js', (err, res) ->\n t.equal 'content-type', res.headers['content-type'], 'application/javascript'\n t.equal 'length', res.headers['content-length'], '4685'\n\n minify: (t) ->\n t.expect 'zappa', 'client', 'shared', 'coffee', 'js'\n t.wait 3000\n\n zapp = zappa port++, ->\n @enable 'serve zappa', 'minify'\n @client '/client.js': -> alert 'foo'\n @shared '/shared.js': -> alert 'foo' if window?\n @coffee '/coffee.js': -> alert 'foo'\n @js '/js.js': \"alert('foo');\"\n\n c = t.client(zapp.app)\n c.get '/zappa/zappa.js', (err, res) ->\n t.equal 'zappa', res.headers['content-length'], '2492'\n```", "response": "({\n sammy: function(t) {\n var c, zapp;\n t.expect('content-type', 'length');\n t.wait(3000);\n zapp = zappa(port++, function() {\n return this.enable('serve sammy');\n });\n c = t.client(zapp.app);\n return c.get('/zappa/sammy.js', function(err, res) {\n t.equal('content-type', res.headers['content-type'], 'application/javascript');\n return t.equal('length', res.headers['content-length'], '16854');\n });\n },\n zappa: function(t) {\n var c, zapp;\n t.expect('content-type', 'length');\n t.wait(3000);\n zapp = zappa(port++, function() {\n return this.enable('serve zappa');\n });\n c = t.client(zapp.app);\n return c.get('/zappa/zappa.js', function(err, res) {\n t.equal('content-type', res.headers['content-type'], 'application/javascript');\n return t.equal('length', res.headers['content-length'], '4685');\n });\n },\n 'zappa (automatic)': function(t) {\n var c, zapp;\n t.expect('content-type', 'length');\n t.wait(3000);\n zapp = zappa(port++, function() {\n return this.client({\n '/index.js': function() {}\n });\n });\n c = t.client(zapp.app);\n return c.get('/zappa/zappa.js', function(err, res) {\n t.equal('content-type', res.headers['content-type'], 'application/javascript');\n return t.equal('length', res.headers['content-length'], '4685');\n });\n },\n minify: function(t) {\n var c, zapp;\n t.expect('zappa', 'client', 'shared', 'coffee', 'js');\n t.wait(3000);\n zapp = zappa(port++, function() {\n this.enable('serve zappa', 'minify');\n this.client({\n '/client.js': function() {\n return alert('foo');\n }\n });\n this.shared({\n '/shared.js': function() {\n if (typeof window !== \"undefined\" && window !== null) {\n return alert('foo');\n }\n }\n });\n this.coffee({\n '/coffee.js': function() {\n return alert('foo');\n }\n });\n return this.js({\n '/js.js': \"alert('foo');\"\n });\n });\n c = t.client(zapp.app);\n return c.get('/zappa/zappa.js', function(err, res) {\n return t.equal('zappa', res.headers['content-length'], '2492');\n });\n }\n});", "source_lang": "CoffeeScript", "target_lang": "JavaScript", "repo": "mauricemach/zappa", "path": "tests/assets.coffee", "license": "MIT", "commit": "e5d10aedecdd70b2c81c6923a746fb7d2f9eeafd", "stars": 943, "source_url": "https://github.com/mauricemach/zappa/blob/e5d10aedecdd70b2c81c6923a746fb7d2f9eeafd/tests/assets.coffee", "line_start": 104, "line_end": 153}327{"id": "mauricemach/zappa:tests/assets.coffee:3:js_to_coffee", "type": "js_to_coffee", "prompt": "Convert this JavaScript to CoffeeScript.\n```javascript\n({\n sammy: function(t) {\n var c, zapp;\n t.expect('content-type', 'length');\n t.wait(3000);\n zapp = zappa(port++, function() {\n return this.enable('serve sammy');\n });\n c = t.client(zapp.app);\n return c.get('/zappa/sammy.js', function(err, res) {\n t.equal('content-type', res.headers['content-type'], 'application/javascript');\n return t.equal('length', res.headers['content-length'], '16854');\n });\n },\n zappa: function(t) {\n var c, zapp;\n t.expect('content-type', 'length');\n t.wait(3000);\n zapp = zappa(port++, function() {\n return this.enable('serve zappa');\n });\n c = t.client(zapp.app);\n return c.get('/zappa/zappa.js', function(err, res) {\n t.equal('content-type', res.headers['content-type'], 'application/javascript');\n return t.equal('length', res.headers['content-length'], '4685');\n });\n },\n 'zappa (automatic)': function(t) {\n var c, zapp;\n t.expect('content-type', 'length');\n t.wait(3000);\n zapp = zappa(port++, function() {\n return this.client({\n '/index.js': function() {}\n });\n });\n c = t.client(zapp.app);\n return c.get('/zappa/zappa.js', function(err, res) {\n t.equal('content-type', res.headers['content-type'], 'application/javascript');\n return t.equal('length', res.headers['content-length'], '4685');\n });\n },\n minify: function(t) {\n var c, zapp;\n t.expect('zappa', 'client', 'shared', 'coffee', 'js');\n t.wait(3000);\n zapp = zappa(port++, function() {\n this.enable('serve zappa', 'minify');\n this.client({\n '/client.js': function() {\n return alert('foo');\n }\n });\n this.shared({\n '/shared.js': function() {\n if (typeof window !== \"undefined\" && window !== null) {\n return alert('foo');\n }\n }\n });\n this.coffee({\n '/coffee.js': function() {\n return alert('foo');\n }\n });\n return this.js({\n '/js.js': \"alert('foo');\"\n });\n });\n c = t.client(zapp.app);\n return c.get('/zappa/zappa.js', function(err, res) {\n return t.equal('zappa', res.headers['content-length'], '2492');\n });\n }\n});\n```", "response": "sammy: (t) ->\n t.expect 'content-type', 'length'\n t.wait 3000\n\n zapp = zappa port++, ->\n @enable 'serve sammy'\n\n c = t.client(zapp.app)\n c.get '/zappa/sammy.js', (err, res) ->\n t.equal 'content-type', res.headers['content-type'], 'application/javascript'\n t.equal 'length', res.headers['content-length'], '16854'\n\n zappa: (t) ->\n t.expect 'content-type', 'length'\n t.wait 3000\n\n zapp = zappa port++, ->\n @enable 'serve zappa'\n\n c = t.client(zapp.app)\n c.get '/zappa/zappa.js', (err, res) ->\n t.equal 'content-type', res.headers['content-type'], 'application/javascript'\n t.equal 'length', res.headers['content-length'], '4685'\n\n 'zappa (automatic)': (t) ->\n t.expect 'content-type', 'length'\n t.wait 3000\n\n zapp = zappa port++, ->\n @client '/index.js': ->\n\n c = t.client(zapp.app)\n c.get '/zappa/zappa.js', (err, res) ->\n t.equal 'content-type', res.headers['content-type'], 'application/javascript'\n t.equal 'length', res.headers['content-length'], '4685'\n\n minify: (t) ->\n t.expect 'zappa', 'client', 'shared', 'coffee', 'js'\n t.wait 3000\n\n zapp = zappa port++, ->\n @enable 'serve zappa', 'minify'\n @client '/client.js': -> alert 'foo'\n @shared '/shared.js': -> alert 'foo' if window?\n @coffee '/coffee.js': -> alert 'foo'\n @js '/js.js': \"alert('foo');\"\n\n c = t.client(zapp.app)\n c.get '/zappa/zappa.js', (err, res) ->\n t.equal 'zappa', res.headers['content-length'], '2492'", "source_lang": "JavaScript", "target_lang": "CoffeeScript", "repo": "mauricemach/zappa", "path": "tests/assets.coffee", "license": "MIT", "commit": "e5d10aedecdd70b2c81c6923a746fb7d2f9eeafd", "stars": 943, "source_url": "https://github.com/mauricemach/zappa/blob/e5d10aedecdd70b2c81c6923a746fb7d2f9eeafd/tests/assets.coffee", "line_start": 104, "line_end": 153}328{"id": "mauricemach/zappa:tests/assets.coffee:3:completion", "type": "completion", "prompt": "sammy: (t) ->\n t.expect 'content-type', 'length'\n t.wait 3000\n\n zapp = zappa port++, ->\n @enable 'serve sammy'\n\n c = t.client(zapp.app)\n c.get '/zappa/sammy.js', (err, res) ->\n t.equal 'content-type', res.headers['content-type'], 'application/javascript'\n t.equal 'length', res.headers['content-length'], '16854'\n\n zappa: (t) ->\n t.expect 'content-type', 'length'\n t.wait 3000\n\n zapp = zappa port++, ->\n @enable 'serve zappa'\n\n c = t.client(zapp.app)\n c.get '/zappa/zappa.js', (err, res) ->\n t.equal 'content-type', res.headers['content-type'], 'application/javascript'\n t.equal 'length', res.headers['content-length'], '4685'\n\n 'zappa (automatic)': (t) ->", "response": "t.expect 'content-type', 'length'\n t.wait 3000\n\n zapp = zappa port++, ->\n @client '/index.js': ->\n\n c = t.client(zapp.app)\n c.get '/zappa/zappa.js', (err, res) ->\n t.equal 'content-type', res.headers['content-type'], 'application/javascript'\n t.equal 'length', res.headers['content-length'], '4685'\n\n minify: (t) ->\n t.expect 'zappa', 'client', 'shared', 'coffee', 'js'\n t.wait 3000\n\n zapp = zappa port++, ->\n @enable 'serve zappa', 'minify'\n @client '/client.js': -> alert 'foo'\n @shared '/shared.js': -> alert 'foo' if window?\n @coffee '/coffee.js': -> alert 'foo'\n @js '/js.js': \"alert('foo');\"\n\n c = t.client(zapp.app)\n c.get '/zappa/zappa.js', (err, res) ->\n t.equal 'zappa', res.headers['content-length'], '2492'", "source_lang": "CoffeeScript", "target_lang": "CoffeeScript", "repo": "mauricemach/zappa", "path": "tests/assets.coffee", "license": "MIT", "commit": "e5d10aedecdd70b2c81c6923a746fb7d2f9eeafd", "stars": 943, "source_url": "https://github.com/mauricemach/zappa/blob/e5d10aedecdd70b2c81c6923a746fb7d2f9eeafd/tests/assets.coffee", "line_start": 104, "line_end": 153}329{"id": "mauricemach/zappa:tests/assets.coffee:3:raw_corpus", "type": "raw_corpus", "prompt": "", "response": "sammy: (t) ->\n t.expect 'content-type', 'length'\n t.wait 3000\n\n zapp = zappa port++, ->\n @enable 'serve sammy'\n\n c = t.client(zapp.app)\n c.get '/zappa/sammy.js', (err, res) ->\n t.equal 'content-type', res.headers['content-type'], 'application/javascript'\n t.equal 'length', res.headers['content-length'], '16854'\n\n zappa: (t) ->\n t.expect 'content-type', 'length'\n t.wait 3000\n\n zapp = zappa port++, ->\n @enable 'serve zappa'\n\n c = t.client(zapp.app)\n c.get '/zappa/zappa.js', (err, res) ->\n t.equal 'content-type', res.headers['content-type'], 'application/javascript'\n t.equal 'length', res.headers['content-length'], '4685'\n\n 'zappa (automatic)': (t) ->\n t.expect 'content-type', 'length'\n t.wait 3000\n\n zapp = zappa port++, ->\n @client '/index.js': ->\n\n c = t.client(zapp.app)\n c.get '/zappa/zappa.js', (err, res) ->\n t.equal 'content-type', res.headers['content-type'], 'application/javascript'\n t.equal 'length', res.headers['content-length'], '4685'", "source_lang": "", "target_lang": "CoffeeScript", "repo": "mauricemach/zappa", "path": "tests/assets.coffee", "license": "MIT", "commit": "a991eab803a76ebc3156095775a13b376176e341", "stars": 943, "source_url": "https://github.com/mauricemach/zappa/blob/a991eab803a76ebc3156095775a13b376176e341/tests/assets.coffee", "line_start": 104, "line_end": 138}330{"id": "mauricemach/zappa:tests/assets.coffee:3:coffee_to_js", "type": "coffee_to_js", "prompt": "Convert this CoffeeScript to JavaScript.\n```coffeescript\nsammy: (t) ->\n t.expect 'content-type', 'length'\n t.wait 3000\n\n zapp = zappa port++, ->\n @enable 'serve sammy'\n\n c = t.client(zapp.app)\n c.get '/zappa/sammy.js', (err, res) ->\n t.equal 'content-type', res.headers['content-type'], 'application/javascript'\n t.equal 'length', res.headers['content-length'], '16854'\n\n zappa: (t) ->\n t.expect 'content-type', 'length'\n t.wait 3000\n\n zapp = zappa port++, ->\n @enable 'serve zappa'\n\n c = t.client(zapp.app)\n c.get '/zappa/zappa.js', (err, res) ->\n t.equal 'content-type', res.headers['content-type'], 'application/javascript'\n t.equal 'length', res.headers['content-length'], '4685'\n\n 'zappa (automatic)': (t) ->\n t.expect 'content-type', 'length'\n t.wait 3000\n\n zapp = zappa port++, ->\n @client '/index.js': ->\n\n c = t.client(zapp.app)\n c.get '/zappa/zappa.js', (err, res) ->\n t.equal 'content-type', res.headers['content-type'], 'application/javascript'\n t.equal 'length', res.headers['content-length'], '4685'\n```", "response": "({\n sammy: function(t) {\n var c, zapp;\n t.expect('content-type', 'length');\n t.wait(3000);\n zapp = zappa(port++, function() {\n return this.enable('serve sammy');\n });\n c = t.client(zapp.app);\n return c.get('/zappa/sammy.js', function(err, res) {\n t.equal('content-type', res.headers['content-type'], 'application/javascript');\n return t.equal('length', res.headers['content-length'], '16854');\n });\n },\n zappa: function(t) {\n var c, zapp;\n t.expect('content-type', 'length');\n t.wait(3000);\n zapp = zappa(port++, function() {\n return this.enable('serve zappa');\n });\n c = t.client(zapp.app);\n return c.get('/zappa/zappa.js', function(err, res) {\n t.equal('content-type', res.headers['content-type'], 'application/javascript');\n return t.equal('length', res.headers['content-length'], '4685');\n });\n },\n 'zappa (automatic)': function(t) {\n var c, zapp;\n t.expect('content-type', 'length');\n t.wait(3000);\n zapp = zappa(port++, function() {\n return this.client({\n '/index.js': function() {}\n });\n });\n c = t.client(zapp.app);\n return c.get('/zappa/zappa.js', function(err, res) {\n t.equal('content-type', res.headers['content-type'], 'application/javascript');\n return t.equal('length', res.headers['content-length'], '4685');\n });\n }\n});", "source_lang": "CoffeeScript", "target_lang": "JavaScript", "repo": "mauricemach/zappa", "path": "tests/assets.coffee", "license": "MIT", "commit": "a991eab803a76ebc3156095775a13b376176e341", "stars": 943, "source_url": "https://github.com/mauricemach/zappa/blob/a991eab803a76ebc3156095775a13b376176e341/tests/assets.coffee", "line_start": 104, "line_end": 138}331{"id": "mauricemach/zappa:tests/assets.coffee:3:js_to_coffee", "type": "js_to_coffee", "prompt": "Convert this JavaScript to CoffeeScript.\n```javascript\n({\n sammy: function(t) {\n var c, zapp;\n t.expect('content-type', 'length');\n t.wait(3000);\n zapp = zappa(port++, function() {\n return this.enable('serve sammy');\n });\n c = t.client(zapp.app);\n return c.get('/zappa/sammy.js', function(err, res) {\n t.equal('content-type', res.headers['content-type'], 'application/javascript');\n return t.equal('length', res.headers['content-length'], '16854');\n });\n },\n zappa: function(t) {\n var c, zapp;\n t.expect('content-type', 'length');\n t.wait(3000);\n zapp = zappa(port++, function() {\n return this.enable('serve zappa');\n });\n c = t.client(zapp.app);\n return c.get('/zappa/zappa.js', function(err, res) {\n t.equal('content-type', res.headers['content-type'], 'application/javascript');\n return t.equal('length', res.headers['content-length'], '4685');\n });\n },\n 'zappa (automatic)': function(t) {\n var c, zapp;\n t.expect('content-type', 'length');\n t.wait(3000);\n zapp = zappa(port++, function() {\n return this.client({\n '/index.js': function() {}\n });\n });\n c = t.client(zapp.app);\n return c.get('/zappa/zappa.js', function(err, res) {\n t.equal('content-type', res.headers['content-type'], 'application/javascript');\n return t.equal('length', res.headers['content-length'], '4685');\n });\n }\n});\n```", "response": "sammy: (t) ->\n t.expect 'content-type', 'length'\n t.wait 3000\n\n zapp = zappa port++, ->\n @enable 'serve sammy'\n\n c = t.client(zapp.app)\n c.get '/zappa/sammy.js', (err, res) ->\n t.equal 'content-type', res.headers['content-type'], 'application/javascript'\n t.equal 'length', res.headers['content-length'], '16854'\n\n zappa: (t) ->\n t.expect 'content-type', 'length'\n t.wait 3000\n\n zapp = zappa port++, ->\n @enable 'serve zappa'\n\n c = t.client(zapp.app)\n c.get '/zappa/zappa.js', (err, res) ->\n t.equal 'content-type', res.headers['content-type'], 'application/javascript'\n t.equal 'length', res.headers['content-length'], '4685'\n\n 'zappa (automatic)': (t) ->\n t.expect 'content-type', 'length'\n t.wait 3000\n\n zapp = zappa port++, ->\n @client '/index.js': ->\n\n c = t.client(zapp.app)\n c.get '/zappa/zappa.js', (err, res) ->\n t.equal 'content-type', res.headers['content-type'], 'application/javascript'\n t.equal 'length', res.headers['content-length'], '4685'", "source_lang": "JavaScript", "target_lang": "CoffeeScript", "repo": "mauricemach/zappa", "path": "tests/assets.coffee", "license": "MIT", "commit": "a991eab803a76ebc3156095775a13b376176e341", "stars": 943, "source_url": "https://github.com/mauricemach/zappa/blob/a991eab803a76ebc3156095775a13b376176e341/tests/assets.coffee", "line_start": 104, "line_end": 138}332{"id": "mauricemach/zappa:tests/assets.coffee:3:completion", "type": "completion", "prompt": "sammy: (t) ->\n t.expect 'content-type', 'length'\n t.wait 3000\n\n zapp = zappa port++, ->\n @enable 'serve sammy'\n\n c = t.client(zapp.app)\n c.get '/zappa/sammy.js', (err, res) ->\n t.equal 'content-type', res.headers['content-type'], 'application/javascript'\n t.equal 'length', res.headers['content-length'], '16854'\n\n zappa: (t) ->\n t.expect 'content-type', 'length'\n t.wait 3000\n\n zapp = zappa port++, ->", "response": "@enable 'serve zappa'\n\n c = t.client(zapp.app)\n c.get '/zappa/zappa.js', (err, res) ->\n t.equal 'content-type', res.headers['content-type'], 'application/javascript'\n t.equal 'length', res.headers['content-length'], '4685'\n\n 'zappa (automatic)': (t) ->\n t.expect 'content-type', 'length'\n t.wait 3000\n\n zapp = zappa port++, ->\n @client '/index.js': ->\n\n c = t.client(zapp.app)\n c.get '/zappa/zappa.js', (err, res) ->\n t.equal 'content-type', res.headers['content-type'], 'application/javascript'\n t.equal 'length', res.headers['content-length'], '4685'", "source_lang": "CoffeeScript", "target_lang": "CoffeeScript", "repo": "mauricemach/zappa", "path": "tests/assets.coffee", "license": "MIT", "commit": "a991eab803a76ebc3156095775a13b376176e341", "stars": 943, "source_url": "https://github.com/mauricemach/zappa/blob/a991eab803a76ebc3156095775a13b376176e341/tests/assets.coffee", "line_start": 104, "line_end": 138}333{"id": "mauricemach/zappa:tests/assets.coffee:1:raw_corpus", "type": "raw_corpus", "prompt": "", "response": "@tests =\n client: (t) ->\n t.expect 1, 2\n t.wait 3000\n\n zapp = zappa port++, ->\n client '/index.js': ->\n get '#/': -> alert 'hi'\n\n c = t.client(zapp.app)\n c.get '/index.js', (err, res) ->\n t.equal 1, res.body, ';zappa.run(function () {\\n return get({\\n \\'#/\\': function() {\\n return alert(\\'hi\\');\\n }\\n });\\n });'\n t.equal 2, res.headers['content-type'], 'application/javascript'\n\n coffee: (t) ->\n t.expect 1, 2\n t.wait 3000\n\n zapp = zappa port++, ->\n coffee '/coffee.js': ->\n alert 'hi'\n\n c = t.client(zapp.app)\n c.get '/coffee.js', (err, res) ->\n t.equal 1, res.body, ';var __slice = Array.prototype.slice;var __hasProp = Object.prototype.hasOwnProperty;var __bind = function(fn, me){ return function(){ return fn.apply(me, arguments); }; };var __extends = function(child, parent) { for (var key in parent) { if (__hasProp.call(parent, key)) child[key] = parent[key]; } function ctor() { this.constructor = child; } ctor.prototype = parent.prototype; child.prototype = new ctor; child.__super__ = parent.prototype; return child; };var __indexOf = Array.prototype.indexOf || function(item) { for (var i = 0, l = this.length; i < l; i++) { if (this[i] === item) return i; } return -1; };(function () {\\n return alert(\\'hi\\');\\n })();'\n t.equal 2, res.headers['content-type'], 'application/javascript'\n\n js: (t) ->\n t.expect 1, 2\n t.wait 3000\n\n zapp = zappa port++, ->\n js '/js.js': '''\n alert('hi');\n '''\n\n c = t.client(zapp.app)\n c.get '/js.js', (err, res) ->\n t.equal 1, res.body, \"alert('hi');\"\n t.equal 2, res.headers['content-type'], 'application/javascript'\n\n css: (t) ->\n t.expect 1, 2\n t.wait 3000\n\n zapp = zappa port++, ->\n css '/index.css': '''\n font-family: sans-serif;\n '''", "source_lang": "", "target_lang": "CoffeeScript", "repo": "mauricemach/zappa", "path": "tests/assets.coffee", "license": "MIT", "commit": "d2bfe3e0b4920f99699ca1c730cc40bbde565850", "stars": 943, "source_url": "https://github.com/mauricemach/zappa/blob/d2bfe3e0b4920f99699ca1c730cc40bbde565850/tests/assets.coffee", "line_start": 4, "line_end": 53}334{"id": "mauricemach/zappa:tests/assets.coffee:1:coffee_to_js", "type": "coffee_to_js", "prompt": "Convert this CoffeeScript to JavaScript.\n```coffeescript\n@tests =\n client: (t) ->\n t.expect 1, 2\n t.wait 3000\n\n zapp = zappa port++, ->\n client '/index.js': ->\n get '#/': -> alert 'hi'\n\n c = t.client(zapp.app)\n c.get '/index.js', (err, res) ->\n t.equal 1, res.body, ';zappa.run(function () {\\n return get({\\n \\'#/\\': function() {\\n return alert(\\'hi\\');\\n }\\n });\\n });'\n t.equal 2, res.headers['content-type'], 'application/javascript'\n\n coffee: (t) ->\n t.expect 1, 2\n t.wait 3000\n\n zapp = zappa port++, ->\n coffee '/coffee.js': ->\n alert 'hi'\n\n c = t.client(zapp.app)\n c.get '/coffee.js', (err, res) ->\n t.equal 1, res.body, ';var __slice = Array.prototype.slice;var __hasProp = Object.prototype.hasOwnProperty;var __bind = function(fn, me){ return function(){ return fn.apply(me, arguments); }; };var __extends = function(child, parent) { for (var key in parent) { if (__hasProp.call(parent, key)) child[key] = parent[key]; } function ctor() { this.constructor = child; } ctor.prototype = parent.prototype; child.prototype = new ctor; child.__super__ = parent.prototype; return child; };var __indexOf = Array.prototype.indexOf || function(item) { for (var i = 0, l = this.length; i < l; i++) { if (this[i] === item) return i; } return -1; };(function () {\\n return alert(\\'hi\\');\\n })();'\n t.equal 2, res.headers['content-type'], 'application/javascript'\n\n js: (t) ->\n t.expect 1, 2\n t.wait 3000\n\n zapp = zappa port++, ->\n js '/js.js': '''\n alert('hi');\n '''\n\n c = t.client(zapp.app)\n c.get '/js.js', (err, res) ->\n t.equal 1, res.body, \"alert('hi');\"\n t.equal 2, res.headers['content-type'], 'application/javascript'\n\n css: (t) ->\n t.expect 1, 2\n t.wait 3000\n\n zapp = zappa port++, ->\n css '/index.css': '''\n font-family: sans-serif;\n '''\n```", "response": "this.tests = {\n client: function(t) {\n var c, zapp;\n t.expect(1, 2);\n t.wait(3000);\n zapp = zappa(port++, function() {\n return client({\n '/index.js': function() {\n return get({\n '#/': function() {\n return alert('hi');\n }\n });\n }\n });\n });\n c = t.client(zapp.app);\n return c.get('/index.js', function(err, res) {\n t.equal(1, res.body, ';zappa.run(function () {\\n return get({\\n \\'#/\\': function() {\\n return alert(\\'hi\\');\\n }\\n });\\n });');\n return t.equal(2, res.headers['content-type'], 'application/javascript');\n });\n },\n coffee: function(t) {\n var c, zapp;\n t.expect(1, 2);\n t.wait(3000);\n zapp = zappa(port++, function() {\n return coffee({\n '/coffee.js': function() {\n return alert('hi');\n }\n });\n });\n c = t.client(zapp.app);\n return c.get('/coffee.js', function(err, res) {\n t.equal(1, res.body, ';var __slice = Array.prototype.slice;var __hasProp = Object.prototype.hasOwnProperty;var __bind = function(fn, me){ return function(){ return fn.apply(me, arguments); }; };var __extends = function(child, parent) { for (var key in parent) { if (__hasProp.call(parent, key)) child[key] = parent[key]; } function ctor() { this.constructor = child; } ctor.prototype = parent.prototype; child.prototype = new ctor; child.__super__ = parent.prototype; return child; };var __indexOf = Array.prototype.indexOf || function(item) { for (var i = 0, l = this.length; i < l; i++) { if (this[i] === item) return i; } return -1; };(function () {\\n return alert(\\'hi\\');\\n })();');\n return t.equal(2, res.headers['content-type'], 'application/javascript');\n });\n },\n js: function(t) {\n var c, zapp;\n t.expect(1, 2);\n t.wait(3000);\n zapp = zappa(port++, function() {\n return js({\n '/js.js': `alert('hi');`\n });\n });\n c = t.client(zapp.app);\n return c.get('/js.js', function(err, res) {\n t.equal(1, res.body, \"alert('hi');\");\n return t.equal(2, res.headers['content-type'], 'application/javascript');\n });\n },\n css: function(t) {\n var zapp;\n t.expect(1, 2);\n t.wait(3000);\n return zapp = zappa(port++, function() {\n return css({\n '/index.css': `font-family: sans-serif;`\n });\n });\n }\n};", "source_lang": "CoffeeScript", "target_lang": "JavaScript", "repo": "mauricemach/zappa", "path": "tests/assets.coffee", "license": "MIT", "commit": "d2bfe3e0b4920f99699ca1c730cc40bbde565850", "stars": 943, "source_url": "https://github.com/mauricemach/zappa/blob/d2bfe3e0b4920f99699ca1c730cc40bbde565850/tests/assets.coffee", "line_start": 4, "line_end": 53}335{"id": "mauricemach/zappa:tests/assets.coffee:1:js_to_coffee", "type": "js_to_coffee", "prompt": "Convert this JavaScript to CoffeeScript.\n```javascript\nthis.tests = {\n client: function(t) {\n var c, zapp;\n t.expect(1, 2);\n t.wait(3000);\n zapp = zappa(port++, function() {\n return client({\n '/index.js': function() {\n return get({\n '#/': function() {\n return alert('hi');\n }\n });\n }\n });\n });\n c = t.client(zapp.app);\n return c.get('/index.js', function(err, res) {\n t.equal(1, res.body, ';zappa.run(function () {\\n return get({\\n \\'#/\\': function() {\\n return alert(\\'hi\\');\\n }\\n });\\n });');\n return t.equal(2, res.headers['content-type'], 'application/javascript');\n });\n },\n coffee: function(t) {\n var c, zapp;\n t.expect(1, 2);\n t.wait(3000);\n zapp = zappa(port++, function() {\n return coffee({\n '/coffee.js': function() {\n return alert('hi');\n }\n });\n });\n c = t.client(zapp.app);\n return c.get('/coffee.js', function(err, res) {\n t.equal(1, res.body, ';var __slice = Array.prototype.slice;var __hasProp = Object.prototype.hasOwnProperty;var __bind = function(fn, me){ return function(){ return fn.apply(me, arguments); }; };var __extends = function(child, parent) { for (var key in parent) { if (__hasProp.call(parent, key)) child[key] = parent[key]; } function ctor() { this.constructor = child; } ctor.prototype = parent.prototype; child.prototype = new ctor; child.__super__ = parent.prototype; return child; };var __indexOf = Array.prototype.indexOf || function(item) { for (var i = 0, l = this.length; i < l; i++) { if (this[i] === item) return i; } return -1; };(function () {\\n return alert(\\'hi\\');\\n })();');\n return t.equal(2, res.headers['content-type'], 'application/javascript');\n });\n },\n js: function(t) {\n var c, zapp;\n t.expect(1, 2);\n t.wait(3000);\n zapp = zappa(port++, function() {\n return js({\n '/js.js': `alert('hi');`\n });\n });\n c = t.client(zapp.app);\n return c.get('/js.js', function(err, res) {\n t.equal(1, res.body, \"alert('hi');\");\n return t.equal(2, res.headers['content-type'], 'application/javascript');\n });\n },\n css: function(t) {\n var zapp;\n t.expect(1, 2);\n t.wait(3000);\n return zapp = zappa(port++, function() {\n return css({\n '/index.css': `font-family: sans-serif;`\n });\n });\n }\n};\n```", "response": "@tests =\n client: (t) ->\n t.expect 1, 2\n t.wait 3000\n\n zapp = zappa port++, ->\n client '/index.js': ->\n get '#/': -> alert 'hi'\n\n c = t.client(zapp.app)\n c.get '/index.js', (err, res) ->\n t.equal 1, res.body, ';zappa.run(function () {\\n return get({\\n \\'#/\\': function() {\\n return alert(\\'hi\\');\\n }\\n });\\n });'\n t.equal 2, res.headers['content-type'], 'application/javascript'\n\n coffee: (t) ->\n t.expect 1, 2\n t.wait 3000\n\n zapp = zappa port++, ->\n coffee '/coffee.js': ->\n alert 'hi'\n\n c = t.client(zapp.app)\n c.get '/coffee.js', (err, res) ->\n t.equal 1, res.body, ';var __slice = Array.prototype.slice;var __hasProp = Object.prototype.hasOwnProperty;var __bind = function(fn, me){ return function(){ return fn.apply(me, arguments); }; };var __extends = function(child, parent) { for (var key in parent) { if (__hasProp.call(parent, key)) child[key] = parent[key]; } function ctor() { this.constructor = child; } ctor.prototype = parent.prototype; child.prototype = new ctor; child.__super__ = parent.prototype; return child; };var __indexOf = Array.prototype.indexOf || function(item) { for (var i = 0, l = this.length; i < l; i++) { if (this[i] === item) return i; } return -1; };(function () {\\n return alert(\\'hi\\');\\n })();'\n t.equal 2, res.headers['content-type'], 'application/javascript'\n\n js: (t) ->\n t.expect 1, 2\n t.wait 3000\n\n zapp = zappa port++, ->\n js '/js.js': '''\n alert('hi');\n '''\n\n c = t.client(zapp.app)\n c.get '/js.js', (err, res) ->\n t.equal 1, res.body, \"alert('hi');\"\n t.equal 2, res.headers['content-type'], 'application/javascript'\n\n css: (t) ->\n t.expect 1, 2\n t.wait 3000\n\n zapp = zappa port++, ->\n css '/index.css': '''\n font-family: sans-serif;\n '''", "source_lang": "JavaScript", "target_lang": "CoffeeScript", "repo": "mauricemach/zappa", "path": "tests/assets.coffee", "license": "MIT", "commit": "d2bfe3e0b4920f99699ca1c730cc40bbde565850", "stars": 943, "source_url": "https://github.com/mauricemach/zappa/blob/d2bfe3e0b4920f99699ca1c730cc40bbde565850/tests/assets.coffee", "line_start": 4, "line_end": 53}336{"id": "mauricemach/zappa:tests/assets.coffee:1:completion", "type": "completion", "prompt": "@tests =\n client: (t) ->\n t.expect 1, 2\n t.wait 3000\n\n zapp = zappa port++, ->\n client '/index.js': ->\n get '#/': -> alert 'hi'\n\n c = t.client(zapp.app)\n c.get '/index.js', (err, res) ->\n t.equal 1, res.body, ';zappa.run(function () {\\n return get({\\n \\'#/\\': function() {\\n return alert(\\'hi\\');\\n }\\n });\\n });'\n t.equal 2, res.headers['content-type'], 'application/javascript'\n\n coffee: (t) ->\n t.expect 1, 2\n t.wait 3000\n\n zapp = zappa port++, ->\n coffee '/coffee.js': ->\n alert 'hi'\n\n c = t.client(zapp.app)\n c.get '/coffee.js', (err, res) ->", "response": "t.equal 1, res.body, ';var __slice = Array.prototype.slice;var __hasProp = Object.prototype.hasOwnProperty;var __bind = function(fn, me){ return function(){ return fn.apply(me, arguments); }; };var __extends = function(child, parent) { for (var key in parent) { if (__hasProp.call(parent, key)) child[key] = parent[key]; } function ctor() { this.constructor = child; } ctor.prototype = parent.prototype; child.prototype = new ctor; child.__super__ = parent.prototype; return child; };var __indexOf = Array.prototype.indexOf || function(item) { for (var i = 0, l = this.length; i < l; i++) { if (this[i] === item) return i; } return -1; };(function () {\\n return alert(\\'hi\\');\\n })();'\n t.equal 2, res.headers['content-type'], 'application/javascript'\n\n js: (t) ->\n t.expect 1, 2\n t.wait 3000\n\n zapp = zappa port++, ->\n js '/js.js': '''\n alert('hi');\n '''\n\n c = t.client(zapp.app)\n c.get '/js.js', (err, res) ->\n t.equal 1, res.body, \"alert('hi');\"\n t.equal 2, res.headers['content-type'], 'application/javascript'\n\n css: (t) ->\n t.expect 1, 2\n t.wait 3000\n\n zapp = zappa port++, ->\n css '/index.css': '''\n font-family: sans-serif;\n '''", "source_lang": "CoffeeScript", "target_lang": "CoffeeScript", "repo": "mauricemach/zappa", "path": "tests/assets.coffee", "license": "MIT", "commit": "d2bfe3e0b4920f99699ca1c730cc40bbde565850", "stars": 943, "source_url": "https://github.com/mauricemach/zappa/blob/d2bfe3e0b4920f99699ca1c730cc40bbde565850/tests/assets.coffee", "line_start": 4, "line_end": 53}337{"id": "mauricemach/zappa:tests/assets.coffee:2:raw_corpus", "type": "raw_corpus", "prompt": "", "response": "c = t.client(zapp.app)\n c.get '/index.css', (err, res) ->\n t.equal 1, res.body, 'font-family: sans-serif;'\n t.equal 2, res.headers['content-type'], 'text/css'\n\n stylus: (t) ->\n t.expect 'header', 'body'\n t.wait 3000\n\n zapp = zappa port++, ->\n stylus '/index.css': '''\n border-radius()\n -webkit-border-radius arguments\n -moz-border-radius arguments\n border-radius arguments\n\n body\n font 12px Helvetica, Arial, sans-serif\n\n a.button\n border-radius 5px\n '''\n\n c = t.client(zapp.app)\n c.get '/index.css', (err, res) ->\n t.equal 'header', res.headers['content-type'], 'text/css'\n t.equal 'body', res.body, '''\n body {\n font: 12px Helvetica, Arial, sans-serif;\n }\n a.button {\n -webkit-border-radius: 5px;\n -moz-border-radius: 5px;\n border-radius: 5px;\n }\n\n '''\n\n jquery: (t) ->\n t.expect 'content-type', 'length'\n t.wait 3000\n\n zapp = zappa port++, ->\n enable 'serve jquery'\n\n c = t.client(zapp.app)\n c.get '/zappa/jquery.js', (err, res) ->\n t.equal 'content-type', res.headers['content-type'], 'application/javascript'\n t.equal 'length', res.headers['content-length'], '92334'", "source_lang": "", "target_lang": "CoffeeScript", "repo": "mauricemach/zappa", "path": "tests/assets.coffee", "license": "MIT", "commit": "d2bfe3e0b4920f99699ca1c730cc40bbde565850", "stars": 943, "source_url": "https://github.com/mauricemach/zappa/blob/d2bfe3e0b4920f99699ca1c730cc40bbde565850/tests/assets.coffee", "line_start": 54, "line_end": 103}338{"id": "mauricemach/zappa:tests/assets.coffee:2:completion", "type": "completion", "prompt": "c = t.client(zapp.app)\n c.get '/index.css', (err, res) ->\n t.equal 1, res.body, 'font-family: sans-serif;'\n t.equal 2, res.headers['content-type'], 'text/css'\n\n stylus: (t) ->\n t.expect 'header', 'body'\n t.wait 3000\n\n zapp = zappa port++, ->\n stylus '/index.css': '''\n border-radius()\n -webkit-border-radius arguments\n -moz-border-radius arguments\n border-radius arguments\n\n body\n font 12px Helvetica, Arial, sans-serif\n\n a.button\n border-radius 5px\n '''\n\n c = t.client(zapp.app)", "response": "c.get '/index.css', (err, res) ->\n t.equal 'header', res.headers['content-type'], 'text/css'\n t.equal 'body', res.body, '''\n body {\n font: 12px Helvetica, Arial, sans-serif;\n }\n a.button {\n -webkit-border-radius: 5px;\n -moz-border-radius: 5px;\n border-radius: 5px;\n }\n\n '''\n\n jquery: (t) ->\n t.expect 'content-type', 'length'\n t.wait 3000\n\n zapp = zappa port++, ->\n enable 'serve jquery'\n\n c = t.client(zapp.app)\n c.get '/zappa/jquery.js', (err, res) ->\n t.equal 'content-type', res.headers['content-type'], 'application/javascript'\n t.equal 'length', res.headers['content-length'], '92334'", "source_lang": "CoffeeScript", "target_lang": "CoffeeScript", "repo": "mauricemach/zappa", "path": "tests/assets.coffee", "license": "MIT", "commit": "d2bfe3e0b4920f99699ca1c730cc40bbde565850", "stars": 943, "source_url": "https://github.com/mauricemach/zappa/blob/d2bfe3e0b4920f99699ca1c730cc40bbde565850/tests/assets.coffee", "line_start": 54, "line_end": 103}339{"id": "mauricemach/zappa:tests/assets.coffee:3:raw_corpus", "type": "raw_corpus", "prompt": "", "response": "sammy: (t) ->\n t.expect 'content-type', 'length'\n t.wait 3000\n\n zapp = zappa port++, ->\n enable 'serve sammy'\n\n c = t.client(zapp.app)\n c.get '/zappa/sammy.js', (err, res) ->\n t.equal 'content-type', res.headers['content-type'], 'application/javascript'\n t.equal 'length', res.headers['content-length'], '16854'\n\n zappa: (t) ->\n t.expect 'content-type', 'length'\n t.wait 3000\n\n zapp = zappa port++, ->\n enable 'serve zappa'\n\n c = t.client(zapp.app)\n c.get '/zappa/zappa.js', (err, res) ->\n t.equal 'content-type', res.headers['content-type'], 'application/javascript'\n t.equal 'length', res.headers['content-length'], '7037'\n\n 'zappa (automatic)': (t) ->\n t.expect 'content-type', 'length'\n t.wait 3000\n\n zapp = zappa port++, ->\n client '/index.js': ->\n\n c = t.client(zapp.app)\n c.get '/zappa/zappa.js', (err, res) ->\n t.equal 'content-type', res.headers['content-type'], 'application/javascript'\n t.equal 'length', res.headers['content-length'], '7037'", "source_lang": "", "target_lang": "CoffeeScript", "repo": "mauricemach/zappa", "path": "tests/assets.coffee", "license": "MIT", "commit": "d2bfe3e0b4920f99699ca1c730cc40bbde565850", "stars": 943, "source_url": "https://github.com/mauricemach/zappa/blob/d2bfe3e0b4920f99699ca1c730cc40bbde565850/tests/assets.coffee", "line_start": 104, "line_end": 138}340{"id": "mauricemach/zappa:tests/assets.coffee:3:coffee_to_js", "type": "coffee_to_js", "prompt": "Convert this CoffeeScript to JavaScript.\n```coffeescript\nsammy: (t) ->\n t.expect 'content-type', 'length'\n t.wait 3000\n\n zapp = zappa port++, ->\n enable 'serve sammy'\n\n c = t.client(zapp.app)\n c.get '/zappa/sammy.js', (err, res) ->\n t.equal 'content-type', res.headers['content-type'], 'application/javascript'\n t.equal 'length', res.headers['content-length'], '16854'\n\n zappa: (t) ->\n t.expect 'content-type', 'length'\n t.wait 3000\n\n zapp = zappa port++, ->\n enable 'serve zappa'\n\n c = t.client(zapp.app)\n c.get '/zappa/zappa.js', (err, res) ->\n t.equal 'content-type', res.headers['content-type'], 'application/javascript'\n t.equal 'length', res.headers['content-length'], '7037'\n\n 'zappa (automatic)': (t) ->\n t.expect 'content-type', 'length'\n t.wait 3000\n\n zapp = zappa port++, ->\n client '/index.js': ->\n\n c = t.client(zapp.app)\n c.get '/zappa/zappa.js', (err, res) ->\n t.equal 'content-type', res.headers['content-type'], 'application/javascript'\n t.equal 'length', res.headers['content-length'], '7037'\n```", "response": "({\n sammy: function(t) {\n var c, zapp;\n t.expect('content-type', 'length');\n t.wait(3000);\n zapp = zappa(port++, function() {\n return enable('serve sammy');\n });\n c = t.client(zapp.app);\n return c.get('/zappa/sammy.js', function(err, res) {\n t.equal('content-type', res.headers['content-type'], 'application/javascript');\n return t.equal('length', res.headers['content-length'], '16854');\n });\n },\n zappa: function(t) {\n var c, zapp;\n t.expect('content-type', 'length');\n t.wait(3000);\n zapp = zappa(port++, function() {\n return enable('serve zappa');\n });\n c = t.client(zapp.app);\n return c.get('/zappa/zappa.js', function(err, res) {\n t.equal('content-type', res.headers['content-type'], 'application/javascript');\n return t.equal('length', res.headers['content-length'], '7037');\n });\n },\n 'zappa (automatic)': function(t) {\n var c, zapp;\n t.expect('content-type', 'length');\n t.wait(3000);\n zapp = zappa(port++, function() {\n return client({\n '/index.js': function() {}\n });\n });\n c = t.client(zapp.app);\n return c.get('/zappa/zappa.js', function(err, res) {\n t.equal('content-type', res.headers['content-type'], 'application/javascript');\n return t.equal('length', res.headers['content-length'], '7037');\n });\n }\n});", "source_lang": "CoffeeScript", "target_lang": "JavaScript", "repo": "mauricemach/zappa", "path": "tests/assets.coffee", "license": "MIT", "commit": "d2bfe3e0b4920f99699ca1c730cc40bbde565850", "stars": 943, "source_url": "https://github.com/mauricemach/zappa/blob/d2bfe3e0b4920f99699ca1c730cc40bbde565850/tests/assets.coffee", "line_start": 104, "line_end": 138}341{"id": "mauricemach/zappa:tests/assets.coffee:3:js_to_coffee", "type": "js_to_coffee", "prompt": "Convert this JavaScript to CoffeeScript.\n```javascript\n({\n sammy: function(t) {\n var c, zapp;\n t.expect('content-type', 'length');\n t.wait(3000);\n zapp = zappa(port++, function() {\n return enable('serve sammy');\n });\n c = t.client(zapp.app);\n return c.get('/zappa/sammy.js', function(err, res) {\n t.equal('content-type', res.headers['content-type'], 'application/javascript');\n return t.equal('length', res.headers['content-length'], '16854');\n });\n },\n zappa: function(t) {\n var c, zapp;\n t.expect('content-type', 'length');\n t.wait(3000);\n zapp = zappa(port++, function() {\n return enable('serve zappa');\n });\n c = t.client(zapp.app);\n return c.get('/zappa/zappa.js', function(err, res) {\n t.equal('content-type', res.headers['content-type'], 'application/javascript');\n return t.equal('length', res.headers['content-length'], '7037');\n });\n },\n 'zappa (automatic)': function(t) {\n var c, zapp;\n t.expect('content-type', 'length');\n t.wait(3000);\n zapp = zappa(port++, function() {\n return client({\n '/index.js': function() {}\n });\n });\n c = t.client(zapp.app);\n return c.get('/zappa/zappa.js', function(err, res) {\n t.equal('content-type', res.headers['content-type'], 'application/javascript');\n return t.equal('length', res.headers['content-length'], '7037');\n });\n }\n});\n```", "response": "sammy: (t) ->\n t.expect 'content-type', 'length'\n t.wait 3000\n\n zapp = zappa port++, ->\n enable 'serve sammy'\n\n c = t.client(zapp.app)\n c.get '/zappa/sammy.js', (err, res) ->\n t.equal 'content-type', res.headers['content-type'], 'application/javascript'\n t.equal 'length', res.headers['content-length'], '16854'\n\n zappa: (t) ->\n t.expect 'content-type', 'length'\n t.wait 3000\n\n zapp = zappa port++, ->\n enable 'serve zappa'\n\n c = t.client(zapp.app)\n c.get '/zappa/zappa.js', (err, res) ->\n t.equal 'content-type', res.headers['content-type'], 'application/javascript'\n t.equal 'length', res.headers['content-length'], '7037'\n\n 'zappa (automatic)': (t) ->\n t.expect 'content-type', 'length'\n t.wait 3000\n\n zapp = zappa port++, ->\n client '/index.js': ->\n\n c = t.client(zapp.app)\n c.get '/zappa/zappa.js', (err, res) ->\n t.equal 'content-type', res.headers['content-type'], 'application/javascript'\n t.equal 'length', res.headers['content-length'], '7037'", "source_lang": "JavaScript", "target_lang": "CoffeeScript", "repo": "mauricemach/zappa", "path": "tests/assets.coffee", "license": "MIT", "commit": "d2bfe3e0b4920f99699ca1c730cc40bbde565850", "stars": 943, "source_url": "https://github.com/mauricemach/zappa/blob/d2bfe3e0b4920f99699ca1c730cc40bbde565850/tests/assets.coffee", "line_start": 104, "line_end": 138}342{"id": "mauricemach/zappa:tests/assets.coffee:3:completion", "type": "completion", "prompt": "sammy: (t) ->\n t.expect 'content-type', 'length'\n t.wait 3000\n\n zapp = zappa port++, ->\n enable 'serve sammy'\n\n c = t.client(zapp.app)\n c.get '/zappa/sammy.js', (err, res) ->\n t.equal 'content-type', res.headers['content-type'], 'application/javascript'\n t.equal 'length', res.headers['content-length'], '16854'\n\n zappa: (t) ->\n t.expect 'content-type', 'length'\n t.wait 3000\n\n zapp = zappa port++, ->", "response": "enable 'serve zappa'\n\n c = t.client(zapp.app)\n c.get '/zappa/zappa.js', (err, res) ->\n t.equal 'content-type', res.headers['content-type'], 'application/javascript'\n t.equal 'length', res.headers['content-length'], '7037'\n\n 'zappa (automatic)': (t) ->\n t.expect 'content-type', 'length'\n t.wait 3000\n\n zapp = zappa port++, ->\n client '/index.js': ->\n\n c = t.client(zapp.app)\n c.get '/zappa/zappa.js', (err, res) ->\n t.equal 'content-type', res.headers['content-type'], 'application/javascript'\n t.equal 'length', res.headers['content-length'], '7037'", "source_lang": "CoffeeScript", "target_lang": "CoffeeScript", "repo": "mauricemach/zappa", "path": "tests/assets.coffee", "license": "MIT", "commit": "d2bfe3e0b4920f99699ca1c730cc40bbde565850", "stars": 943, "source_url": "https://github.com/mauricemach/zappa/blob/d2bfe3e0b4920f99699ca1c730cc40bbde565850/tests/assets.coffee", "line_start": 104, "line_end": 138}343{"id": "mauricemach/zappa:tests/assets.coffee:3:raw_corpus", "type": "raw_corpus", "prompt": "", "response": "sammy: (t) ->\n t.expect 'content-type', 'length'\n t.wait 3000\n\n zapp = zappa port++, ->\n enable 'serve sammy'\n\n c = t.client(zapp.app)\n c.get '/zappa/sammy.js', (err, res) ->\n t.equal 'content-type', res.headers['content-type'], 'application/javascript'\n t.equal 'length', res.headers['content-length'], '16854'\n\n zappa: (t) ->\n t.expect 'content-type', 'length'\n t.wait 3000\n\n zapp = zappa port++, ->\n enable 'serve zappa'\n\n c = t.client(zapp.app)\n c.get '/zappa/zappa.js', (err, res) ->\n t.equal 'content-type', res.headers['content-type'], 'application/javascript'\n t.equal 'length', res.headers['content-length'], '6865'\n\n 'zappa (automatic)': (t) ->\n t.expect 'content-type', 'length'\n t.wait 3000\n\n zapp = zappa port++, ->\n client '/index.js': ->\n\n c = t.client(zapp.app)\n c.get '/zappa/zappa.js', (err, res) ->\n t.equal 'content-type', res.headers['content-type'], 'application/javascript'\n t.equal 'length', res.headers['content-length'], '6865'", "source_lang": "", "target_lang": "CoffeeScript", "repo": "mauricemach/zappa", "path": "tests/assets.coffee", "license": "MIT", "commit": "974f5b26e61fedc740a305bc5d21606a77af840e", "stars": 943, "source_url": "https://github.com/mauricemach/zappa/blob/974f5b26e61fedc740a305bc5d21606a77af840e/tests/assets.coffee", "line_start": 104, "line_end": 138}344{"id": "mauricemach/zappa:tests/assets.coffee:3:coffee_to_js", "type": "coffee_to_js", "prompt": "Convert this CoffeeScript to JavaScript.\n```coffeescript\nsammy: (t) ->\n t.expect 'content-type', 'length'\n t.wait 3000\n\n zapp = zappa port++, ->\n enable 'serve sammy'\n\n c = t.client(zapp.app)\n c.get '/zappa/sammy.js', (err, res) ->\n t.equal 'content-type', res.headers['content-type'], 'application/javascript'\n t.equal 'length', res.headers['content-length'], '16854'\n\n zappa: (t) ->\n t.expect 'content-type', 'length'\n t.wait 3000\n\n zapp = zappa port++, ->\n enable 'serve zappa'\n\n c = t.client(zapp.app)\n c.get '/zappa/zappa.js', (err, res) ->\n t.equal 'content-type', res.headers['content-type'], 'application/javascript'\n t.equal 'length', res.headers['content-length'], '6865'\n\n 'zappa (automatic)': (t) ->\n t.expect 'content-type', 'length'\n t.wait 3000\n\n zapp = zappa port++, ->\n client '/index.js': ->\n\n c = t.client(zapp.app)\n c.get '/zappa/zappa.js', (err, res) ->\n t.equal 'content-type', res.headers['content-type'], 'application/javascript'\n t.equal 'length', res.headers['content-length'], '6865'\n```", "response": "({\n sammy: function(t) {\n var c, zapp;\n t.expect('content-type', 'length');\n t.wait(3000);\n zapp = zappa(port++, function() {\n return enable('serve sammy');\n });\n c = t.client(zapp.app);\n return c.get('/zappa/sammy.js', function(err, res) {\n t.equal('content-type', res.headers['content-type'], 'application/javascript');\n return t.equal('length', res.headers['content-length'], '16854');\n });\n },\n zappa: function(t) {\n var c, zapp;\n t.expect('content-type', 'length');\n t.wait(3000);\n zapp = zappa(port++, function() {\n return enable('serve zappa');\n });\n c = t.client(zapp.app);\n return c.get('/zappa/zappa.js', function(err, res) {\n t.equal('content-type', res.headers['content-type'], 'application/javascript');\n return t.equal('length', res.headers['content-length'], '6865');\n });\n },\n 'zappa (automatic)': function(t) {\n var c, zapp;\n t.expect('content-type', 'length');\n t.wait(3000);\n zapp = zappa(port++, function() {\n return client({\n '/index.js': function() {}\n });\n });\n c = t.client(zapp.app);\n return c.get('/zappa/zappa.js', function(err, res) {\n t.equal('content-type', res.headers['content-type'], 'application/javascript');\n return t.equal('length', res.headers['content-length'], '6865');\n });\n }\n});", "source_lang": "CoffeeScript", "target_lang": "JavaScript", "repo": "mauricemach/zappa", "path": "tests/assets.coffee", "license": "MIT", "commit": "974f5b26e61fedc740a305bc5d21606a77af840e", "stars": 943, "source_url": "https://github.com/mauricemach/zappa/blob/974f5b26e61fedc740a305bc5d21606a77af840e/tests/assets.coffee", "line_start": 104, "line_end": 138}345{"id": "mauricemach/zappa:tests/assets.coffee:3:js_to_coffee", "type": "js_to_coffee", "prompt": "Convert this JavaScript to CoffeeScript.\n```javascript\n({\n sammy: function(t) {\n var c, zapp;\n t.expect('content-type', 'length');\n t.wait(3000);\n zapp = zappa(port++, function() {\n return enable('serve sammy');\n });\n c = t.client(zapp.app);\n return c.get('/zappa/sammy.js', function(err, res) {\n t.equal('content-type', res.headers['content-type'], 'application/javascript');\n return t.equal('length', res.headers['content-length'], '16854');\n });\n },\n zappa: function(t) {\n var c, zapp;\n t.expect('content-type', 'length');\n t.wait(3000);\n zapp = zappa(port++, function() {\n return enable('serve zappa');\n });\n c = t.client(zapp.app);\n return c.get('/zappa/zappa.js', function(err, res) {\n t.equal('content-type', res.headers['content-type'], 'application/javascript');\n return t.equal('length', res.headers['content-length'], '6865');\n });\n },\n 'zappa (automatic)': function(t) {\n var c, zapp;\n t.expect('content-type', 'length');\n t.wait(3000);\n zapp = zappa(port++, function() {\n return client({\n '/index.js': function() {}\n });\n });\n c = t.client(zapp.app);\n return c.get('/zappa/zappa.js', function(err, res) {\n t.equal('content-type', res.headers['content-type'], 'application/javascript');\n return t.equal('length', res.headers['content-length'], '6865');\n });\n }\n});\n```", "response": "sammy: (t) ->\n t.expect 'content-type', 'length'\n t.wait 3000\n\n zapp = zappa port++, ->\n enable 'serve sammy'\n\n c = t.client(zapp.app)\n c.get '/zappa/sammy.js', (err, res) ->\n t.equal 'content-type', res.headers['content-type'], 'application/javascript'\n t.equal 'length', res.headers['content-length'], '16854'\n\n zappa: (t) ->\n t.expect 'content-type', 'length'\n t.wait 3000\n\n zapp = zappa port++, ->\n enable 'serve zappa'\n\n c = t.client(zapp.app)\n c.get '/zappa/zappa.js', (err, res) ->\n t.equal 'content-type', res.headers['content-type'], 'application/javascript'\n t.equal 'length', res.headers['content-length'], '6865'\n\n 'zappa (automatic)': (t) ->\n t.expect 'content-type', 'length'\n t.wait 3000\n\n zapp = zappa port++, ->\n client '/index.js': ->\n\n c = t.client(zapp.app)\n c.get '/zappa/zappa.js', (err, res) ->\n t.equal 'content-type', res.headers['content-type'], 'application/javascript'\n t.equal 'length', res.headers['content-length'], '6865'", "source_lang": "JavaScript", "target_lang": "CoffeeScript", "repo": "mauricemach/zappa", "path": "tests/assets.coffee", "license": "MIT", "commit": "974f5b26e61fedc740a305bc5d21606a77af840e", "stars": 943, "source_url": "https://github.com/mauricemach/zappa/blob/974f5b26e61fedc740a305bc5d21606a77af840e/tests/assets.coffee", "line_start": 104, "line_end": 138}346{"id": "mauricemach/zappa:tests/assets.coffee:3:completion", "type": "completion", "prompt": "sammy: (t) ->\n t.expect 'content-type', 'length'\n t.wait 3000\n\n zapp = zappa port++, ->\n enable 'serve sammy'\n\n c = t.client(zapp.app)\n c.get '/zappa/sammy.js', (err, res) ->\n t.equal 'content-type', res.headers['content-type'], 'application/javascript'\n t.equal 'length', res.headers['content-length'], '16854'\n\n zappa: (t) ->\n t.expect 'content-type', 'length'\n t.wait 3000\n\n zapp = zappa port++, ->", "response": "enable 'serve zappa'\n\n c = t.client(zapp.app)\n c.get '/zappa/zappa.js', (err, res) ->\n t.equal 'content-type', res.headers['content-type'], 'application/javascript'\n t.equal 'length', res.headers['content-length'], '6865'\n\n 'zappa (automatic)': (t) ->\n t.expect 'content-type', 'length'\n t.wait 3000\n\n zapp = zappa port++, ->\n client '/index.js': ->\n\n c = t.client(zapp.app)\n c.get '/zappa/zappa.js', (err, res) ->\n t.equal 'content-type', res.headers['content-type'], 'application/javascript'\n t.equal 'length', res.headers['content-length'], '6865'", "source_lang": "CoffeeScript", "target_lang": "CoffeeScript", "repo": "mauricemach/zappa", "path": "tests/assets.coffee", "license": "MIT", "commit": "974f5b26e61fedc740a305bc5d21606a77af840e", "stars": 943, "source_url": "https://github.com/mauricemach/zappa/blob/974f5b26e61fedc740a305bc5d21606a77af840e/tests/assets.coffee", "line_start": 104, "line_end": 138}347{"id": "mauricemach/zappa:tests/assets.coffee:3:raw_corpus", "type": "raw_corpus", "prompt": "", "response": "sammy: (t) ->\n t.expect 'content-type', 'length'\n t.wait 3000\n\n zapp = zappa port++, ->\n enable 'serve sammy'\n\n c = t.client(zapp.app)\n c.get '/zappa/sammy.js', (err, res) ->\n t.equal 'content-type', res.headers['content-type'], 'application/javascript'\n t.equal 'length', res.headers['content-length'], '16854'\n\n zappa: (t) ->\n t.expect 'content-type', 'length'\n t.wait 3000\n\n zapp = zappa port++, ->\n enable 'serve zappa'\n\n c = t.client(zapp.app)\n c.get '/zappa/zappa.js', (err, res) ->\n t.equal 'content-type', res.headers['content-type'], 'application/javascript'\n t.equal 'length', res.headers['content-length'], '6864'\n\n 'zappa (automatic)': (t) ->\n t.expect 'content-type', 'length'\n t.wait 3000\n\n zapp = zappa port++, ->\n client '/index.js': ->\n\n c = t.client(zapp.app)\n c.get '/zappa/zappa.js', (err, res) ->\n t.equal 'content-type', res.headers['content-type'], 'application/javascript'\n t.equal 'length', res.headers['content-length'], '6864'", "source_lang": "", "target_lang": "CoffeeScript", "repo": "mauricemach/zappa", "path": "tests/assets.coffee", "license": "MIT", "commit": "6a0bf34282a3db50b307b1319d30ff227d4277a9", "stars": 943, "source_url": "https://github.com/mauricemach/zappa/blob/6a0bf34282a3db50b307b1319d30ff227d4277a9/tests/assets.coffee", "line_start": 104, "line_end": 138}348{"id": "mauricemach/zappa:tests/assets.coffee:3:coffee_to_js", "type": "coffee_to_js", "prompt": "Convert this CoffeeScript to JavaScript.\n```coffeescript\nsammy: (t) ->\n t.expect 'content-type', 'length'\n t.wait 3000\n\n zapp = zappa port++, ->\n enable 'serve sammy'\n\n c = t.client(zapp.app)\n c.get '/zappa/sammy.js', (err, res) ->\n t.equal 'content-type', res.headers['content-type'], 'application/javascript'\n t.equal 'length', res.headers['content-length'], '16854'\n\n zappa: (t) ->\n t.expect 'content-type', 'length'\n t.wait 3000\n\n zapp = zappa port++, ->\n enable 'serve zappa'\n\n c = t.client(zapp.app)\n c.get '/zappa/zappa.js', (err, res) ->\n t.equal 'content-type', res.headers['content-type'], 'application/javascript'\n t.equal 'length', res.headers['content-length'], '6864'\n\n 'zappa (automatic)': (t) ->\n t.expect 'content-type', 'length'\n t.wait 3000\n\n zapp = zappa port++, ->\n client '/index.js': ->\n\n c = t.client(zapp.app)\n c.get '/zappa/zappa.js', (err, res) ->\n t.equal 'content-type', res.headers['content-type'], 'application/javascript'\n t.equal 'length', res.headers['content-length'], '6864'\n```", "response": "({\n sammy: function(t) {\n var c, zapp;\n t.expect('content-type', 'length');\n t.wait(3000);\n zapp = zappa(port++, function() {\n return enable('serve sammy');\n });\n c = t.client(zapp.app);\n return c.get('/zappa/sammy.js', function(err, res) {\n t.equal('content-type', res.headers['content-type'], 'application/javascript');\n return t.equal('length', res.headers['content-length'], '16854');\n });\n },\n zappa: function(t) {\n var c, zapp;\n t.expect('content-type', 'length');\n t.wait(3000);\n zapp = zappa(port++, function() {\n return enable('serve zappa');\n });\n c = t.client(zapp.app);\n return c.get('/zappa/zappa.js', function(err, res) {\n t.equal('content-type', res.headers['content-type'], 'application/javascript');\n return t.equal('length', res.headers['content-length'], '6864');\n });\n },\n 'zappa (automatic)': function(t) {\n var c, zapp;\n t.expect('content-type', 'length');\n t.wait(3000);\n zapp = zappa(port++, function() {\n return client({\n '/index.js': function() {}\n });\n });\n c = t.client(zapp.app);\n return c.get('/zappa/zappa.js', function(err, res) {\n t.equal('content-type', res.headers['content-type'], 'application/javascript');\n return t.equal('length', res.headers['content-length'], '6864');\n });\n }\n});", "source_lang": "CoffeeScript", "target_lang": "JavaScript", "repo": "mauricemach/zappa", "path": "tests/assets.coffee", "license": "MIT", "commit": "6a0bf34282a3db50b307b1319d30ff227d4277a9", "stars": 943, "source_url": "https://github.com/mauricemach/zappa/blob/6a0bf34282a3db50b307b1319d30ff227d4277a9/tests/assets.coffee", "line_start": 104, "line_end": 138}349{"id": "mauricemach/zappa:tests/assets.coffee:3:js_to_coffee", "type": "js_to_coffee", "prompt": "Convert this JavaScript to CoffeeScript.\n```javascript\n({\n sammy: function(t) {\n var c, zapp;\n t.expect('content-type', 'length');\n t.wait(3000);\n zapp = zappa(port++, function() {\n return enable('serve sammy');\n });\n c = t.client(zapp.app);\n return c.get('/zappa/sammy.js', function(err, res) {\n t.equal('content-type', res.headers['content-type'], 'application/javascript');\n return t.equal('length', res.headers['content-length'], '16854');\n });\n },\n zappa: function(t) {\n var c, zapp;\n t.expect('content-type', 'length');\n t.wait(3000);\n zapp = zappa(port++, function() {\n return enable('serve zappa');\n });\n c = t.client(zapp.app);\n return c.get('/zappa/zappa.js', function(err, res) {\n t.equal('content-type', res.headers['content-type'], 'application/javascript');\n return t.equal('length', res.headers['content-length'], '6864');\n });\n },\n 'zappa (automatic)': function(t) {\n var c, zapp;\n t.expect('content-type', 'length');\n t.wait(3000);\n zapp = zappa(port++, function() {\n return client({\n '/index.js': function() {}\n });\n });\n c = t.client(zapp.app);\n return c.get('/zappa/zappa.js', function(err, res) {\n t.equal('content-type', res.headers['content-type'], 'application/javascript');\n return t.equal('length', res.headers['content-length'], '6864');\n });\n }\n});\n```", "response": "sammy: (t) ->\n t.expect 'content-type', 'length'\n t.wait 3000\n\n zapp = zappa port++, ->\n enable 'serve sammy'\n\n c = t.client(zapp.app)\n c.get '/zappa/sammy.js', (err, res) ->\n t.equal 'content-type', res.headers['content-type'], 'application/javascript'\n t.equal 'length', res.headers['content-length'], '16854'\n\n zappa: (t) ->\n t.expect 'content-type', 'length'\n t.wait 3000\n\n zapp = zappa port++, ->\n enable 'serve zappa'\n\n c = t.client(zapp.app)\n c.get '/zappa/zappa.js', (err, res) ->\n t.equal 'content-type', res.headers['content-type'], 'application/javascript'\n t.equal 'length', res.headers['content-length'], '6864'\n\n 'zappa (automatic)': (t) ->\n t.expect 'content-type', 'length'\n t.wait 3000\n\n zapp = zappa port++, ->\n client '/index.js': ->\n\n c = t.client(zapp.app)\n c.get '/zappa/zappa.js', (err, res) ->\n t.equal 'content-type', res.headers['content-type'], 'application/javascript'\n t.equal 'length', res.headers['content-length'], '6864'", "source_lang": "JavaScript", "target_lang": "CoffeeScript", "repo": "mauricemach/zappa", "path": "tests/assets.coffee", "license": "MIT", "commit": "6a0bf34282a3db50b307b1319d30ff227d4277a9", "stars": 943, "source_url": "https://github.com/mauricemach/zappa/blob/6a0bf34282a3db50b307b1319d30ff227d4277a9/tests/assets.coffee", "line_start": 104, "line_end": 138}350{"id": "mauricemach/zappa:tests/assets.coffee:3:completion", "type": "completion", "prompt": "sammy: (t) ->\n t.expect 'content-type', 'length'\n t.wait 3000\n\n zapp = zappa port++, ->\n enable 'serve sammy'\n\n c = t.client(zapp.app)\n c.get '/zappa/sammy.js', (err, res) ->\n t.equal 'content-type', res.headers['content-type'], 'application/javascript'\n t.equal 'length', res.headers['content-length'], '16854'\n\n zappa: (t) ->\n t.expect 'content-type', 'length'\n t.wait 3000\n\n zapp = zappa port++, ->", "response": "enable 'serve zappa'\n\n c = t.client(zapp.app)\n c.get '/zappa/zappa.js', (err, res) ->\n t.equal 'content-type', res.headers['content-type'], 'application/javascript'\n t.equal 'length', res.headers['content-length'], '6864'\n\n 'zappa (automatic)': (t) ->\n t.expect 'content-type', 'length'\n t.wait 3000\n\n zapp = zappa port++, ->\n client '/index.js': ->\n\n c = t.client(zapp.app)\n c.get '/zappa/zappa.js', (err, res) ->\n t.equal 'content-type', res.headers['content-type'], 'application/javascript'\n t.equal 'length', res.headers['content-length'], '6864'", "source_lang": "CoffeeScript", "target_lang": "CoffeeScript", "repo": "mauricemach/zappa", "path": "tests/assets.coffee", "license": "MIT", "commit": "6a0bf34282a3db50b307b1319d30ff227d4277a9", "stars": 943, "source_url": "https://github.com/mauricemach/zappa/blob/6a0bf34282a3db50b307b1319d30ff227d4277a9/tests/assets.coffee", "line_start": 104, "line_end": 138}351{"id": "mauricemach/zappa:tests/assets.coffee:1:raw_corpus", "type": "raw_corpus", "prompt": "", "response": "module.exports =\n client: ->\n t = zappa ->\n client '/index.js': ->\n get '#/': -> alert 'hi'\n headers = 'Content-Type': 'application/javascript'\n body = ';zappa.run(function () {\\n return get({\\n \\'#/\\': function() {\\n return alert(\\'hi\\');\\n }\\n });\\n });'\n t.response {url: '/index.js'}, {headers, body}\n\n coffee: ->\n t = zappa ->\n coffee '/coffee.js': ->\n alert 'hi'\n headers = 'Content-Type': 'application/javascript'\n body = ';var __slice = Array.prototype.slice;var __hasProp = Object.prototype.hasOwnProperty;var __bind = function(fn, me){ return function(){ return fn.apply(me, arguments); }; };var __extends = function(child, parent) { for (var key in parent) { if (__hasProp.call(parent, key)) child[key] = parent[key]; } function ctor() { this.constructor = child; } ctor.prototype = parent.prototype; child.prototype = new ctor; child.__super__ = parent.prototype; return child; };var __indexOf = Array.prototype.indexOf || function(item) { for (var i = 0, l = this.length; i < l; i++) { if (this[i] === item) return i; } return -1; };(function () {\\n return alert(\\'hi\\');\\n })();'\n t.response {url: '/coffee.js'}, {headers, body}\n\n js: ->\n t = zappa ->\n js '/js.js': '''\n alert('hi');\n '''\n headers = 'Content-Type': 'application/javascript'\n body = \"alert('hi');\"\n t.response {url: '/js.js'}, {headers, body}\n\n css: ->\n t = zappa ->\n css '/index.css': '''\n font-family: sans-serif;\n '''\n headers = 'Content-Type': 'text/css'\n body = 'font-family: sans-serif;'\n t.response {url: '/index.css'}, {headers, body}\n\n stylus: ->\n t = zappa ->\n stylus '/index.css': '''\n border-radius()\n -webkit-border-radius arguments\n -moz-border-radius arguments\n border-radius arguments\n\n body\n font 12px Helvetica, Arial, sans-serif\n\n a.button\n border-radius 5px\n '''\n headers = 'Content-Type': 'text/css'", "source_lang": "", "target_lang": "CoffeeScript", "repo": "mauricemach/zappa", "path": "tests/assets.coffee", "license": "MIT", "commit": "3c5114ebe4b768e7266ad497703eff62404efac3", "stars": 943, "source_url": "https://github.com/mauricemach/zappa/blob/3c5114ebe4b768e7266ad497703eff62404efac3/tests/assets.coffee", "line_start": 3, "line_end": 52}352{"id": "mauricemach/zappa:tests/assets.coffee:1:coffee_to_js", "type": "coffee_to_js", "prompt": "Convert this CoffeeScript to JavaScript.\n```coffeescript\nmodule.exports =\n client: ->\n t = zappa ->\n client '/index.js': ->\n get '#/': -> alert 'hi'\n headers = 'Content-Type': 'application/javascript'\n body = ';zappa.run(function () {\\n return get({\\n \\'#/\\': function() {\\n return alert(\\'hi\\');\\n }\\n });\\n });'\n t.response {url: '/index.js'}, {headers, body}\n\n coffee: ->\n t = zappa ->\n coffee '/coffee.js': ->\n alert 'hi'\n headers = 'Content-Type': 'application/javascript'\n body = ';var __slice = Array.prototype.slice;var __hasProp = Object.prototype.hasOwnProperty;var __bind = function(fn, me){ return function(){ return fn.apply(me, arguments); }; };var __extends = function(child, parent) { for (var key in parent) { if (__hasProp.call(parent, key)) child[key] = parent[key]; } function ctor() { this.constructor = child; } ctor.prototype = parent.prototype; child.prototype = new ctor; child.__super__ = parent.prototype; return child; };var __indexOf = Array.prototype.indexOf || function(item) { for (var i = 0, l = this.length; i < l; i++) { if (this[i] === item) return i; } return -1; };(function () {\\n return alert(\\'hi\\');\\n })();'\n t.response {url: '/coffee.js'}, {headers, body}\n\n js: ->\n t = zappa ->\n js '/js.js': '''\n alert('hi');\n '''\n headers = 'Content-Type': 'application/javascript'\n body = \"alert('hi');\"\n t.response {url: '/js.js'}, {headers, body}\n\n css: ->\n t = zappa ->\n css '/index.css': '''\n font-family: sans-serif;\n '''\n headers = 'Content-Type': 'text/css'\n body = 'font-family: sans-serif;'\n t.response {url: '/index.css'}, {headers, body}\n\n stylus: ->\n t = zappa ->\n stylus '/index.css': '''\n border-radius()\n -webkit-border-radius arguments\n -moz-border-radius arguments\n border-radius arguments\n\n body\n font 12px Helvetica, Arial, sans-serif\n\n a.button\n border-radius 5px\n '''\n headers = 'Content-Type': 'text/css'\n```", "response": "module.exports = {\n client: function() {\n var body, headers, t;\n t = zappa(function() {\n return client({\n '/index.js': function() {\n return get({\n '#/': function() {\n return alert('hi');\n }\n });\n }\n });\n });\n headers = {\n 'Content-Type': 'application/javascript'\n };\n body = ';zappa.run(function () {\\n return get({\\n \\'#/\\': function() {\\n return alert(\\'hi\\');\\n }\\n });\\n });';\n return t.response({\n url: '/index.js'\n }, {headers, body});\n },\n coffee: function() {\n var body, headers, t;\n t = zappa(function() {\n return coffee({\n '/coffee.js': function() {\n return alert('hi');\n }\n });\n });\n headers = {\n 'Content-Type': 'application/javascript'\n };\n body = ';var __slice = Array.prototype.slice;var __hasProp = Object.prototype.hasOwnProperty;var __bind = function(fn, me){ return function(){ return fn.apply(me, arguments); }; };var __extends = function(child, parent) { for (var key in parent) { if (__hasProp.call(parent, key)) child[key] = parent[key]; } function ctor() { this.constructor = child; } ctor.prototype = parent.prototype; child.prototype = new ctor; child.__super__ = parent.prototype; return child; };var __indexOf = Array.prototype.indexOf || function(item) { for (var i = 0, l = this.length; i < l; i++) { if (this[i] === item) return i; } return -1; };(function () {\\n return alert(\\'hi\\');\\n })();';\n return t.response({\n url: '/coffee.js'\n }, {headers, body});\n },\n js: function() {\n var body, headers, t;\n t = zappa(function() {\n return js({\n '/js.js': `alert('hi');`\n });\n });\n headers = {\n 'Content-Type': 'application/javascript'\n };\n body = \"alert('hi');\";\n return t.response({\n url: '/js.js'\n }, {headers, body});\n },\n css: function() {\n var body, headers, t;\n t = zappa(function() {\n return css({\n '/index.css': `font-family: sans-serif;`\n });\n });\n headers = {\n 'Content-Type': 'text/css'\n };\n body = 'font-family: sans-serif;';\n return t.response({\n url: '/index.css'\n }, {headers, body});\n },\n stylus: function() {\n var headers, t;\n t = zappa(function() {\n return stylus({\n '/index.css': `border-radius()\n -webkit-border-radius arguments\n -moz-border-radius arguments\n border-radius arguments\n\nbody\n font 12px Helvetica, Arial, sans-serif\n\na.button\n border-radius 5px`\n });\n });\n return headers = {\n 'Content-Type': 'text/css'\n };\n }\n};", "source_lang": "CoffeeScript", "target_lang": "JavaScript", "repo": "mauricemach/zappa", "path": "tests/assets.coffee", "license": "MIT", "commit": "3c5114ebe4b768e7266ad497703eff62404efac3", "stars": 943, "source_url": "https://github.com/mauricemach/zappa/blob/3c5114ebe4b768e7266ad497703eff62404efac3/tests/assets.coffee", "line_start": 3, "line_end": 52}353{"id": "mauricemach/zappa:tests/assets.coffee:1:js_to_coffee", "type": "js_to_coffee", "prompt": "Convert this JavaScript to CoffeeScript.\n```javascript\nmodule.exports = {\n client: function() {\n var body, headers, t;\n t = zappa(function() {\n return client({\n '/index.js': function() {\n return get({\n '#/': function() {\n return alert('hi');\n }\n });\n }\n });\n });\n headers = {\n 'Content-Type': 'application/javascript'\n };\n body = ';zappa.run(function () {\\n return get({\\n \\'#/\\': function() {\\n return alert(\\'hi\\');\\n }\\n });\\n });';\n return t.response({\n url: '/index.js'\n }, {headers, body});\n },\n coffee: function() {\n var body, headers, t;\n t = zappa(function() {\n return coffee({\n '/coffee.js': function() {\n return alert('hi');\n }\n });\n });\n headers = {\n 'Content-Type': 'application/javascript'\n };\n body = ';var __slice = Array.prototype.slice;var __hasProp = Object.prototype.hasOwnProperty;var __bind = function(fn, me){ return function(){ return fn.apply(me, arguments); }; };var __extends = function(child, parent) { for (var key in parent) { if (__hasProp.call(parent, key)) child[key] = parent[key]; } function ctor() { this.constructor = child; } ctor.prototype = parent.prototype; child.prototype = new ctor; child.__super__ = parent.prototype; return child; };var __indexOf = Array.prototype.indexOf || function(item) { for (var i = 0, l = this.length; i < l; i++) { if (this[i] === item) return i; } return -1; };(function () {\\n return alert(\\'hi\\');\\n })();';\n return t.response({\n url: '/coffee.js'\n }, {headers, body});\n },\n js: function() {\n var body, headers, t;\n t = zappa(function() {\n return js({\n '/js.js': `alert('hi');`\n });\n });\n headers = {\n 'Content-Type': 'application/javascript'\n };\n body = \"alert('hi');\";\n return t.response({\n url: '/js.js'\n }, {headers, body});\n },\n css: function() {\n var body, headers, t;\n t = zappa(function() {\n return css({\n '/index.css': `font-family: sans-serif;`\n });\n });\n headers = {\n 'Content-Type': 'text/css'\n };\n body = 'font-family: sans-serif;';\n return t.response({\n url: '/index.css'\n }, {headers, body});\n },\n stylus: function() {\n var headers, t;\n t = zappa(function() {\n return stylus({\n '/index.css': `border-radius()\n -webkit-border-radius arguments\n -moz-border-radius arguments\n border-radius arguments\n\nbody\n font 12px Helvetica, Arial, sans-serif\n\na.button\n border-radius 5px`\n });\n });\n return headers = {\n 'Content-Type': 'text/css'\n };\n }\n};\n```", "response": "module.exports =\n client: ->\n t = zappa ->\n client '/index.js': ->\n get '#/': -> alert 'hi'\n headers = 'Content-Type': 'application/javascript'\n body = ';zappa.run(function () {\\n return get({\\n \\'#/\\': function() {\\n return alert(\\'hi\\');\\n }\\n });\\n });'\n t.response {url: '/index.js'}, {headers, body}\n\n coffee: ->\n t = zappa ->\n coffee '/coffee.js': ->\n alert 'hi'\n headers = 'Content-Type': 'application/javascript'\n body = ';var __slice = Array.prototype.slice;var __hasProp = Object.prototype.hasOwnProperty;var __bind = function(fn, me){ return function(){ return fn.apply(me, arguments); }; };var __extends = function(child, parent) { for (var key in parent) { if (__hasProp.call(parent, key)) child[key] = parent[key]; } function ctor() { this.constructor = child; } ctor.prototype = parent.prototype; child.prototype = new ctor; child.__super__ = parent.prototype; return child; };var __indexOf = Array.prototype.indexOf || function(item) { for (var i = 0, l = this.length; i < l; i++) { if (this[i] === item) return i; } return -1; };(function () {\\n return alert(\\'hi\\');\\n })();'\n t.response {url: '/coffee.js'}, {headers, body}\n\n js: ->\n t = zappa ->\n js '/js.js': '''\n alert('hi');\n '''\n headers = 'Content-Type': 'application/javascript'\n body = \"alert('hi');\"\n t.response {url: '/js.js'}, {headers, body}\n\n css: ->\n t = zappa ->\n css '/index.css': '''\n font-family: sans-serif;\n '''\n headers = 'Content-Type': 'text/css'\n body = 'font-family: sans-serif;'\n t.response {url: '/index.css'}, {headers, body}\n\n stylus: ->\n t = zappa ->\n stylus '/index.css': '''\n border-radius()\n -webkit-border-radius arguments\n -moz-border-radius arguments\n border-radius arguments\n\n body\n font 12px Helvetica, Arial, sans-serif\n\n a.button\n border-radius 5px\n '''\n headers = 'Content-Type': 'text/css'", "source_lang": "JavaScript", "target_lang": "CoffeeScript", "repo": "mauricemach/zappa", "path": "tests/assets.coffee", "license": "MIT", "commit": "3c5114ebe4b768e7266ad497703eff62404efac3", "stars": 943, "source_url": "https://github.com/mauricemach/zappa/blob/3c5114ebe4b768e7266ad497703eff62404efac3/tests/assets.coffee", "line_start": 3, "line_end": 52}354{"id": "mauricemach/zappa:tests/assets.coffee:1:completion", "type": "completion", "prompt": "module.exports =\n client: ->\n t = zappa ->\n client '/index.js': ->\n get '#/': -> alert 'hi'\n headers = 'Content-Type': 'application/javascript'\n body = ';zappa.run(function () {\\n return get({\\n \\'#/\\': function() {\\n return alert(\\'hi\\');\\n }\\n });\\n });'\n t.response {url: '/index.js'}, {headers, body}\n\n coffee: ->\n t = zappa ->\n coffee '/coffee.js': ->\n alert 'hi'\n headers = 'Content-Type': 'application/javascript'\n body = ';var __slice = Array.prototype.slice;var __hasProp = Object.prototype.hasOwnProperty;var __bind = function(fn, me){ return function(){ return fn.apply(me, arguments); }; };var __extends = function(child, parent) { for (var key in parent) { if (__hasProp.call(parent, key)) child[key] = parent[key]; } function ctor() { this.constructor = child; } ctor.prototype = parent.prototype; child.prototype = new ctor; child.__super__ = parent.prototype; return child; };var __indexOf = Array.prototype.indexOf || function(item) { for (var i = 0, l = this.length; i < l; i++) { if (this[i] === item) return i; } return -1; };(function () {\\n return alert(\\'hi\\');\\n })();'\n t.response {url: '/coffee.js'}, {headers, body}\n\n js: ->\n t = zappa ->\n js '/js.js': '''\n alert('hi');\n '''\n headers = 'Content-Type': 'application/javascript'\n body = \"alert('hi');\"\n t.response {url: '/js.js'}, {headers, body}", "response": "css: ->\n t = zappa ->\n css '/index.css': '''\n font-family: sans-serif;\n '''\n headers = 'Content-Type': 'text/css'\n body = 'font-family: sans-serif;'\n t.response {url: '/index.css'}, {headers, body}\n\n stylus: ->\n t = zappa ->\n stylus '/index.css': '''\n border-radius()\n -webkit-border-radius arguments\n -moz-border-radius arguments\n border-radius arguments\n\n body\n font 12px Helvetica, Arial, sans-serif\n\n a.button\n border-radius 5px\n '''\n headers = 'Content-Type': 'text/css'", "source_lang": "CoffeeScript", "target_lang": "CoffeeScript", "repo": "mauricemach/zappa", "path": "tests/assets.coffee", "license": "MIT", "commit": "3c5114ebe4b768e7266ad497703eff62404efac3", "stars": 943, "source_url": "https://github.com/mauricemach/zappa/blob/3c5114ebe4b768e7266ad497703eff62404efac3/tests/assets.coffee", "line_start": 3, "line_end": 52}355{"id": "mauricemach/zappa:tests/assets.coffee:2:raw_corpus", "type": "raw_corpus", "prompt": "", "response": "body = '''\n body {\n font: 12px Helvetica, Arial, sans-serif;\n }\n a.button {\n -webkit-border-radius: 5px;\n -moz-border-radius: 5px;\n border-radius: 5px;\n }\n\n '''\n t.response {url: '/index.css'}, {headers, body}\n\n jquery: ->\n t = zappa ->\n enable 'serve jquery'\n status = 200\n headers =\n 'Content-Type': 'application/javascript'\n 'Content-Length': '92334'\n t.response {url: '/zappa/jquery.js'}, {status, headers}\n\n sammy: ->\n t = zappa ->\n enable 'serve sammy'\n status = 200\n headers =\n 'Content-Type': 'application/javascript'\n 'Content-Length': '16854'\n t.response {url: '/zappa/sammy.js'}, {status, headers}\n\n zappa: ->\n t = zappa ->\n enable 'serve zappa'\n status = 200\n headers =\n 'Content-Type': 'application/javascript'\n 'Content-Length': '6864'\n t.response {url: '/zappa/zappa.js'}, {status, headers}\n\n 'zappa (automatic)': ->\n t = zappa ->\n client '/index.js': ->\n status = 200\n headers =\n 'Content-Type': 'application/javascript'\n 'Content-Length': '6864'\n t.response {url: '/zappa/zappa.js'}, {status, headers}", "source_lang": "", "target_lang": "CoffeeScript", "repo": "mauricemach/zappa", "path": "tests/assets.coffee", "license": "MIT", "commit": "3c5114ebe4b768e7266ad497703eff62404efac3", "stars": 943, "source_url": "https://github.com/mauricemach/zappa/blob/3c5114ebe4b768e7266ad497703eff62404efac3/tests/assets.coffee", "line_start": 53, "line_end": 100}356{"id": "mauricemach/zappa:tests/assets.coffee:2:completion", "type": "completion", "prompt": "body = '''\n body {\n font: 12px Helvetica, Arial, sans-serif;\n }\n a.button {\n -webkit-border-radius: 5px;\n -moz-border-radius: 5px;\n border-radius: 5px;\n }\n\n '''\n t.response {url: '/index.css'}, {headers, body}\n\n jquery: ->\n t = zappa ->\n enable 'serve jquery'\n status = 200\n headers =\n 'Content-Type': 'application/javascript'\n 'Content-Length': '92334'\n t.response {url: '/zappa/jquery.js'}, {status, headers}\n\n sammy: ->\n t = zappa ->", "response": "enable 'serve sammy'\n status = 200\n headers =\n 'Content-Type': 'application/javascript'\n 'Content-Length': '16854'\n t.response {url: '/zappa/sammy.js'}, {status, headers}\n\n zappa: ->\n t = zappa ->\n enable 'serve zappa'\n status = 200\n headers =\n 'Content-Type': 'application/javascript'\n 'Content-Length': '6864'\n t.response {url: '/zappa/zappa.js'}, {status, headers}\n\n 'zappa (automatic)': ->\n t = zappa ->\n client '/index.js': ->\n status = 200\n headers =\n 'Content-Type': 'application/javascript'\n 'Content-Length': '6864'\n t.response {url: '/zappa/zappa.js'}, {status, headers}", "source_lang": "CoffeeScript", "target_lang": "CoffeeScript", "repo": "mauricemach/zappa", "path": "tests/assets.coffee", "license": "MIT", "commit": "3c5114ebe4b768e7266ad497703eff62404efac3", "stars": 943, "source_url": "https://github.com/mauricemach/zappa/blob/3c5114ebe4b768e7266ad497703eff62404efac3/tests/assets.coffee", "line_start": 53, "line_end": 100}357{"id": "mauricemach/zappa:tests/assets.coffee:1:raw_corpus", "type": "raw_corpus", "prompt": "", "response": "zappa = require('./support/tester') require('../src/zappa')\n\nmodule.exports =\n coffee: ->\n t = zappa ->\n coffee '/coffee.js': ->\n alert 'hi'\n headers = 'Content-Type': 'application/javascript'\n body = ';var __slice = Array.prototype.slice;var __hasProp = Object.prototype.hasOwnProperty;var __bind = function(fn, me){ return function(){ return fn.apply(me, arguments); }; };var __extends = function(child, parent) { for (var key in parent) { if (__hasProp.call(parent, key)) child[key] = parent[key]; } function ctor() { this.constructor = child; } ctor.prototype = parent.prototype; child.prototype = new ctor; child.__super__ = parent.prototype; return child; };var __indexOf = Array.prototype.indexOf || function(item) { for (var i = 0, l = this.length; i < l; i++) { if (this[i] === item) return i; } return -1; };(function () {\\n return alert(\\'hi\\');\\n })();'\n t.response {url: '/coffee.js'}, {headers, body}\n\n js: ->\n t = zappa ->\n js '/js.js': '''\n alert('hi');\n '''\n headers = 'Content-Type': 'application/javascript'\n body = \"alert('hi');\"\n t.response {url: '/js.js'}, {headers, body}\n\n css: ->\n t = zappa ->\n css '/index.css': '''\n font-family: sans-serif;\n '''\n headers = 'Content-Type': 'text/css'\n body = 'font-family: sans-serif;'\n t.response {url: '/index.css'}, {headers, body}\n\n stylus: ->\n t = zappa ->\n stylus '/index.css': '''\n border-radius()\n -webkit-border-radius arguments\n -moz-border-radius arguments\n border-radius arguments\n\n body\n font 12px Helvetica, Arial, sans-serif\n\n a.button\n border-radius 5px\n '''\n headers = 'Content-Type': 'text/css'\n body = '''\n body {\n font: 12px Helvetica, Arial, sans-serif;\n }\n a.button {\n -webkit-border-radius: 5px;", "source_lang": "", "target_lang": "CoffeeScript", "repo": "mauricemach/zappa", "path": "tests/assets.coffee", "license": "MIT", "commit": "e338cf805cb6b68ea06957166238560063d1f1e4", "stars": 943, "source_url": "https://github.com/mauricemach/zappa/blob/e338cf805cb6b68ea06957166238560063d1f1e4/tests/assets.coffee", "line_start": 1, "line_end": 50}358{"id": "mauricemach/zappa:tests/assets.coffee:1:completion", "type": "completion", "prompt": "zappa = require('./support/tester') require('../src/zappa')\n\nmodule.exports =\n coffee: ->\n t = zappa ->\n coffee '/coffee.js': ->\n alert 'hi'\n headers = 'Content-Type': 'application/javascript'\n body = ';var __slice = Array.prototype.slice;var __hasProp = Object.prototype.hasOwnProperty;var __bind = function(fn, me){ return function(){ return fn.apply(me, arguments); }; };var __extends = function(child, parent) { for (var key in parent) { if (__hasProp.call(parent, key)) child[key] = parent[key]; } function ctor() { this.constructor = child; } ctor.prototype = parent.prototype; child.prototype = new ctor; child.__super__ = parent.prototype; return child; };var __indexOf = Array.prototype.indexOf || function(item) { for (var i = 0, l = this.length; i < l; i++) { if (this[i] === item) return i; } return -1; };(function () {\\n return alert(\\'hi\\');\\n })();'\n t.response {url: '/coffee.js'}, {headers, body}\n\n js: ->\n t = zappa ->\n js '/js.js': '''\n alert('hi');\n '''\n headers = 'Content-Type': 'application/javascript'\n body = \"alert('hi');\"\n t.response {url: '/js.js'}, {headers, body}\n\n css: ->\n t = zappa ->\n css '/index.css': '''\n font-family: sans-serif;\n '''", "response": "headers = 'Content-Type': 'text/css'\n body = 'font-family: sans-serif;'\n t.response {url: '/index.css'}, {headers, body}\n\n stylus: ->\n t = zappa ->\n stylus '/index.css': '''\n border-radius()\n -webkit-border-radius arguments\n -moz-border-radius arguments\n border-radius arguments\n\n body\n font 12px Helvetica, Arial, sans-serif\n\n a.button\n border-radius 5px\n '''\n headers = 'Content-Type': 'text/css'\n body = '''\n body {\n font: 12px Helvetica, Arial, sans-serif;\n }\n a.button {\n -webkit-border-radius: 5px;", "source_lang": "CoffeeScript", "target_lang": "CoffeeScript", "repo": "mauricemach/zappa", "path": "tests/assets.coffee", "license": "MIT", "commit": "e338cf805cb6b68ea06957166238560063d1f1e4", "stars": 943, "source_url": "https://github.com/mauricemach/zappa/blob/e338cf805cb6b68ea06957166238560063d1f1e4/tests/assets.coffee", "line_start": 1, "line_end": 50}359{"id": "jianliaoim/talk-os:talk-web/client/util/url.coffee:1:raw_corpus", "type": "raw_corpus", "prompt": "", "response": "detect = require './detect'\n\nexports.issueUrl = 'http://tburl.in/3e8ad2b0'\nexports.feedbackUrl = 'https://jianliao.com/page/invite/e840f0402t'\nexports.xiaoaiAvatar = 'https://dn-talk.oss.aliyuncs.com/images/icons/talkai@2x.png'\nexports.emailIcon = 'https://dn-talk.oss.aliyuncs.com/icons/email@2x.png'\n\nexports.iosAppUrl = 'https://itunes.apple.com/cn/app/talk-by-teambition/id922425179?mt=8'\nexports.macAppUrl = 'https://dn-talk.oss.aliyuncs.com/app-downloads/talk.dmg'\nexports.androidAppUrl = 'https://dn-talk.oss.aliyuncs.com/downloads/talk-teambition-release.apk'\nexports.windows32AppUrl = 'https://dn-talk.oss.aliyuncs.com/app-downloads/talk-win32-ia32.zip'\nexports.windows64AppUrl = 'https://dn-talk.oss.aliyuncs.com/app-downloads/talk-win32-x64.zip'\nexports.linux32AppUrl = 'https://dn-talk.oss.aliyuncs.com/app-downloads/talk-linux-ia32.tar.gz'\nexports.linux64AppUrl = 'https://dn-talk.oss.aliyuncs.com/app-downloads/talk-linux-x64.tar.gz'\n\njianliaoPages = [\n /^\\/site/\n /^\\/blog/\n /^\\/doc/\n /^\\/page/\n /^\\/v\\d/\n /^\\/t\\//\n]\n\nexports.isInRoutes = (locationOrigin, href) ->\n isOrigin = href.indexOf(locationOrigin) is 0\n\n routePath = href.substr(locationOrigin.length)\n isException = jianliaoPages.some (route) ->\n routePath.match(route)?\n\n isOrigin and not isException", "source_lang": "", "target_lang": "CoffeeScript", "repo": "jianliaoim/talk-os", "path": "talk-web/client/util/url.coffee", "license": "MIT", "commit": "2545c4497865779a55762e03963a39237df9046b", "stars": 2703, "source_url": "https://github.com/jianliaoim/talk-os/blob/2545c4497865779a55762e03963a39237df9046b/talk-web/client/util/url.coffee", "line_start": 1, "line_end": 32}360{"id": "jianliaoim/talk-os:talk-web/client/util/url.coffee:1:coffee_to_js", "type": "coffee_to_js", "prompt": "Convert this CoffeeScript to JavaScript.\n```coffeescript\ndetect = require './detect'\n\nexports.issueUrl = 'http://tburl.in/3e8ad2b0'\nexports.feedbackUrl = 'https://jianliao.com/page/invite/e840f0402t'\nexports.xiaoaiAvatar = 'https://dn-talk.oss.aliyuncs.com/images/icons/talkai@2x.png'\nexports.emailIcon = 'https://dn-talk.oss.aliyuncs.com/icons/email@2x.png'\n\nexports.iosAppUrl = 'https://itunes.apple.com/cn/app/talk-by-teambition/id922425179?mt=8'\nexports.macAppUrl = 'https://dn-talk.oss.aliyuncs.com/app-downloads/talk.dmg'\nexports.androidAppUrl = 'https://dn-talk.oss.aliyuncs.com/downloads/talk-teambition-release.apk'\nexports.windows32AppUrl = 'https://dn-talk.oss.aliyuncs.com/app-downloads/talk-win32-ia32.zip'\nexports.windows64AppUrl = 'https://dn-talk.oss.aliyuncs.com/app-downloads/talk-win32-x64.zip'\nexports.linux32AppUrl = 'https://dn-talk.oss.aliyuncs.com/app-downloads/talk-linux-ia32.tar.gz'\nexports.linux64AppUrl = 'https://dn-talk.oss.aliyuncs.com/app-downloads/talk-linux-x64.tar.gz'\n\njianliaoPages = [\n /^\\/site/\n /^\\/blog/\n /^\\/doc/\n /^\\/page/\n /^\\/v\\d/\n /^\\/t\\//\n]\n\nexports.isInRoutes = (locationOrigin, href) ->\n isOrigin = href.indexOf(locationOrigin) is 0\n\n routePath = href.substr(locationOrigin.length)\n isException = jianliaoPages.some (route) ->\n routePath.match(route)?\n\n isOrigin and not isException\n```", "response": "var detect, jianliaoPages;\n\ndetect = require('./detect');\n\nexports.issueUrl = 'http://tburl.in/3e8ad2b0';\n\nexports.feedbackUrl = 'https://jianliao.com/page/invite/e840f0402t';\n\nexports.xiaoaiAvatar = 'https://dn-talk.oss.aliyuncs.com/images/icons/talkai@2x.png';\n\nexports.emailIcon = 'https://dn-talk.oss.aliyuncs.com/icons/email@2x.png';\n\nexports.iosAppUrl = 'https://itunes.apple.com/cn/app/talk-by-teambition/id922425179?mt=8';\n\nexports.macAppUrl = 'https://dn-talk.oss.aliyuncs.com/app-downloads/talk.dmg';\n\nexports.androidAppUrl = 'https://dn-talk.oss.aliyuncs.com/downloads/talk-teambition-release.apk';\n\nexports.windows32AppUrl = 'https://dn-talk.oss.aliyuncs.com/app-downloads/talk-win32-ia32.zip';\n\nexports.windows64AppUrl = 'https://dn-talk.oss.aliyuncs.com/app-downloads/talk-win32-x64.zip';\n\nexports.linux32AppUrl = 'https://dn-talk.oss.aliyuncs.com/app-downloads/talk-linux-ia32.tar.gz';\n\nexports.linux64AppUrl = 'https://dn-talk.oss.aliyuncs.com/app-downloads/talk-linux-x64.tar.gz';\n\njianliaoPages = [/^\\/site/, /^\\/blog/, /^\\/doc/, /^\\/page/, /^\\/v\\d/, /^\\/t\\//];\n\nexports.isInRoutes = function(locationOrigin, href) {\n var isException, isOrigin, routePath;\n isOrigin = href.indexOf(locationOrigin) === 0;\n routePath = href.substr(locationOrigin.length);\n isException = jianliaoPages.some(function(route) {\n return routePath.match(route) != null;\n });\n return isOrigin && !isException;\n};", "source_lang": "CoffeeScript", "target_lang": "JavaScript", "repo": "jianliaoim/talk-os", "path": "talk-web/client/util/url.coffee", "license": "MIT", "commit": "2545c4497865779a55762e03963a39237df9046b", "stars": 2703, "source_url": "https://github.com/jianliaoim/talk-os/blob/2545c4497865779a55762e03963a39237df9046b/talk-web/client/util/url.coffee", "line_start": 1, "line_end": 32}361{"id": "jianliaoim/talk-os:talk-web/client/util/url.coffee:1:js_to_coffee", "type": "js_to_coffee", "prompt": "Convert this JavaScript to CoffeeScript.\n```javascript\nvar detect, jianliaoPages;\n\ndetect = require('./detect');\n\nexports.issueUrl = 'http://tburl.in/3e8ad2b0';\n\nexports.feedbackUrl = 'https://jianliao.com/page/invite/e840f0402t';\n\nexports.xiaoaiAvatar = 'https://dn-talk.oss.aliyuncs.com/images/icons/talkai@2x.png';\n\nexports.emailIcon = 'https://dn-talk.oss.aliyuncs.com/icons/email@2x.png';\n\nexports.iosAppUrl = 'https://itunes.apple.com/cn/app/talk-by-teambition/id922425179?mt=8';\n\nexports.macAppUrl = 'https://dn-talk.oss.aliyuncs.com/app-downloads/talk.dmg';\n\nexports.androidAppUrl = 'https://dn-talk.oss.aliyuncs.com/downloads/talk-teambition-release.apk';\n\nexports.windows32AppUrl = 'https://dn-talk.oss.aliyuncs.com/app-downloads/talk-win32-ia32.zip';\n\nexports.windows64AppUrl = 'https://dn-talk.oss.aliyuncs.com/app-downloads/talk-win32-x64.zip';\n\nexports.linux32AppUrl = 'https://dn-talk.oss.aliyuncs.com/app-downloads/talk-linux-ia32.tar.gz';\n\nexports.linux64AppUrl = 'https://dn-talk.oss.aliyuncs.com/app-downloads/talk-linux-x64.tar.gz';\n\njianliaoPages = [/^\\/site/, /^\\/blog/, /^\\/doc/, /^\\/page/, /^\\/v\\d/, /^\\/t\\//];\n\nexports.isInRoutes = function(locationOrigin, href) {\n var isException, isOrigin, routePath;\n isOrigin = href.indexOf(locationOrigin) === 0;\n routePath = href.substr(locationOrigin.length);\n isException = jianliaoPages.some(function(route) {\n return routePath.match(route) != null;\n });\n return isOrigin && !isException;\n};\n```", "response": "detect = require './detect'\n\nexports.issueUrl = 'http://tburl.in/3e8ad2b0'\nexports.feedbackUrl = 'https://jianliao.com/page/invite/e840f0402t'\nexports.xiaoaiAvatar = 'https://dn-talk.oss.aliyuncs.com/images/icons/talkai@2x.png'\nexports.emailIcon = 'https://dn-talk.oss.aliyuncs.com/icons/email@2x.png'\n\nexports.iosAppUrl = 'https://itunes.apple.com/cn/app/talk-by-teambition/id922425179?mt=8'\nexports.macAppUrl = 'https://dn-talk.oss.aliyuncs.com/app-downloads/talk.dmg'\nexports.androidAppUrl = 'https://dn-talk.oss.aliyuncs.com/downloads/talk-teambition-release.apk'\nexports.windows32AppUrl = 'https://dn-talk.oss.aliyuncs.com/app-downloads/talk-win32-ia32.zip'\nexports.windows64AppUrl = 'https://dn-talk.oss.aliyuncs.com/app-downloads/talk-win32-x64.zip'\nexports.linux32AppUrl = 'https://dn-talk.oss.aliyuncs.com/app-downloads/talk-linux-ia32.tar.gz'\nexports.linux64AppUrl = 'https://dn-talk.oss.aliyuncs.com/app-downloads/talk-linux-x64.tar.gz'\n\njianliaoPages = [\n /^\\/site/\n /^\\/blog/\n /^\\/doc/\n /^\\/page/\n /^\\/v\\d/\n /^\\/t\\//\n]\n\nexports.isInRoutes = (locationOrigin, href) ->\n isOrigin = href.indexOf(locationOrigin) is 0\n\n routePath = href.substr(locationOrigin.length)\n isException = jianliaoPages.some (route) ->\n routePath.match(route)?\n\n isOrigin and not isException", "source_lang": "JavaScript", "target_lang": "CoffeeScript", "repo": "jianliaoim/talk-os", "path": "talk-web/client/util/url.coffee", "license": "MIT", "commit": "2545c4497865779a55762e03963a39237df9046b", "stars": 2703, "source_url": "https://github.com/jianliaoim/talk-os/blob/2545c4497865779a55762e03963a39237df9046b/talk-web/client/util/url.coffee", "line_start": 1, "line_end": 32}362{"id": "jianliaoim/talk-os:talk-web/client/util/url.coffee:1:completion", "type": "completion", "prompt": "detect = require './detect'\n\nexports.issueUrl = 'http://tburl.in/3e8ad2b0'\nexports.feedbackUrl = 'https://jianliao.com/page/invite/e840f0402t'\nexports.xiaoaiAvatar = 'https://dn-talk.oss.aliyuncs.com/images/icons/talkai@2x.png'\nexports.emailIcon = 'https://dn-talk.oss.aliyuncs.com/icons/email@2x.png'\n\nexports.iosAppUrl = 'https://itunes.apple.com/cn/app/talk-by-teambition/id922425179?mt=8'\nexports.macAppUrl = 'https://dn-talk.oss.aliyuncs.com/app-downloads/talk.dmg'\nexports.androidAppUrl = 'https://dn-talk.oss.aliyuncs.com/downloads/talk-teambition-release.apk'\nexports.windows32AppUrl = 'https://dn-talk.oss.aliyuncs.com/app-downloads/talk-win32-ia32.zip'\nexports.windows64AppUrl = 'https://dn-talk.oss.aliyuncs.com/app-downloads/talk-win32-x64.zip'\nexports.linux32AppUrl = 'https://dn-talk.oss.aliyuncs.com/app-downloads/talk-linux-ia32.tar.gz'\nexports.linux64AppUrl = 'https://dn-talk.oss.aliyuncs.com/app-downloads/talk-linux-x64.tar.gz'\n\njianliaoPages = [", "response": "/^\\/site/\n /^\\/blog/\n /^\\/doc/\n /^\\/page/\n /^\\/v\\d/\n /^\\/t\\//\n]\n\nexports.isInRoutes = (locationOrigin, href) ->\n isOrigin = href.indexOf(locationOrigin) is 0\n\n routePath = href.substr(locationOrigin.length)\n isException = jianliaoPages.some (route) ->\n routePath.match(route)?\n\n isOrigin and not isException", "source_lang": "CoffeeScript", "target_lang": "CoffeeScript", "repo": "jianliaoim/talk-os", "path": "talk-web/client/util/url.coffee", "license": "MIT", "commit": "2545c4497865779a55762e03963a39237df9046b", "stars": 2703, "source_url": "https://github.com/jianliaoim/talk-os/blob/2545c4497865779a55762e03963a39237df9046b/talk-web/client/util/url.coffee", "line_start": 1, "line_end": 32}363{"id": "cdglabs/apparatus:src/Model/Editor.coffee:1:raw_corpus", "type": "raw_corpus", "prompt": "", "response": "module.exports = class Editor\n constructor: ->\n @_setupLayout()\n @_setupSerializer()\n @_setupProject()\n @_setupRevision()\n @_parseQueryString()\n\n _setupLayout: ->\n @layout = new Model.Layout()\n\n _setupProject: ->\n @loadFromLocalStorage()\n if !@project\n @createNewProject()\n\n _setupSerializer: ->\n builtInObjects = []\n for own name, object of @_builtIn()\n if _.isFunction(object)\n object = object.prototype\n Util.assignId(object, name)\n builtInObjects.push(object)\n @serializer = new Storage.Serializer(builtInObjects)\n\n # Checks if we should load an external JSON file based on the query string\n # (the ?stuff at the end of the URL).\n _parseQueryString: ->\n parsed = queryString.parse(location.search)\n if parsed.experimental == '1'\n @experimental = true\n if parsed.load\n @loadFromURL(parsed.load)\n\n # builtIn returns all of the built in classes and objects that are used as\n # the \"anchors\" for serialization and deserialization. That is, all of the\n # objects and classes which should not themselves be serialized but instead\n # be *referenced* from a serialization. When deserialized, these references\n # are then bound appropriately.\n _builtIn: ->\n builtIn = _.clone(Model)\n builtIn[\"SpreadEnv\"] = Dataflow.SpreadEnv\n builtIn[\"Matrix\"] = Util.Matrix\n return builtIn\n\n # TODO: get version via build process / ENV variable?\n version: \"0.4.1\"\n\n loadJsonStringIntoProject: (jsonString) ->\n json = JSON.parse(jsonString)", "source_lang": "", "target_lang": "CoffeeScript", "repo": "cdglabs/apparatus", "path": "src/Model/Editor.coffee", "license": "MIT", "commit": "a9c998cb75d6726b1cf5eb5b059f2c7b6d1e11a2", "stars": 1052, "source_url": "https://github.com/cdglabs/apparatus/blob/a9c998cb75d6726b1cf5eb5b059f2c7b6d1e11a2/src/Model/Editor.coffee", "line_start": 9, "line_end": 58}364{"id": "cdglabs/apparatus:src/Model/Editor.coffee:1:coffee_to_js", "type": "coffee_to_js", "prompt": "Convert this CoffeeScript to JavaScript.\n```coffeescript\nmodule.exports = class Editor\n constructor: ->\n @_setupLayout()\n @_setupSerializer()\n @_setupProject()\n @_setupRevision()\n @_parseQueryString()\n\n _setupLayout: ->\n @layout = new Model.Layout()\n\n _setupProject: ->\n @loadFromLocalStorage()\n if !@project\n @createNewProject()\n\n _setupSerializer: ->\n builtInObjects = []\n for own name, object of @_builtIn()\n if _.isFunction(object)\n object = object.prototype\n Util.assignId(object, name)\n builtInObjects.push(object)\n @serializer = new Storage.Serializer(builtInObjects)\n\n # Checks if we should load an external JSON file based on the query string\n # (the ?stuff at the end of the URL).\n _parseQueryString: ->\n parsed = queryString.parse(location.search)\n if parsed.experimental == '1'\n @experimental = true\n if parsed.load\n @loadFromURL(parsed.load)\n\n # builtIn returns all of the built in classes and objects that are used as\n # the \"anchors\" for serialization and deserialization. That is, all of the\n # objects and classes which should not themselves be serialized but instead\n # be *referenced* from a serialization. When deserialized, these references\n # are then bound appropriately.\n _builtIn: ->\n builtIn = _.clone(Model)\n builtIn[\"SpreadEnv\"] = Dataflow.SpreadEnv\n builtIn[\"Matrix\"] = Util.Matrix\n return builtIn\n\n # TODO: get version via build process / ENV variable?\n version: \"0.4.1\"\n\n loadJsonStringIntoProject: (jsonString) ->\n json = JSON.parse(jsonString)\n```", "response": "var Editor,\n hasProp = {}.hasOwnProperty;\n\nmodule.exports = Editor = (function() {\n class Editor {\n constructor() {\n this._setupLayout();\n this._setupSerializer();\n this._setupProject();\n this._setupRevision();\n this._parseQueryString();\n }\n\n _setupLayout() {\n return this.layout = new Model.Layout();\n }\n\n _setupProject() {\n this.loadFromLocalStorage();\n if (!this.project) {\n return this.createNewProject();\n }\n }\n\n _setupSerializer() {\n var builtInObjects, name, object, ref;\n builtInObjects = [];\n ref = this._builtIn();\n for (name in ref) {\n if (!hasProp.call(ref, name)) continue;\n object = ref[name];\n if (_.isFunction(object)) {\n object = object.prototype;\n }\n Util.assignId(object, name);\n builtInObjects.push(object);\n }\n return this.serializer = new Storage.Serializer(builtInObjects);\n }\n\n // Checks if we should load an external JSON file based on the query string\n // (the ?stuff at the end of the URL).\n _parseQueryString() {\n var parsed;\n parsed = queryString.parse(location.search);\n if (parsed.experimental === '1') {\n this.experimental = true;\n }\n if (parsed.load) {\n return this.loadFromURL(parsed.load);\n }\n }\n\n // builtIn returns all of the built in classes and objects that are used as\n // the \"anchors\" for serialization and deserialization. That is, all of the\n // objects and classes which should not themselves be serialized but instead\n // be *referenced* from a serialization. When deserialized, these references\n // are then bound appropriately.\n _builtIn() {\n var builtIn;\n builtIn = _.clone(Model);\n builtIn[\"SpreadEnv\"] = Dataflow.SpreadEnv;\n builtIn[\"Matrix\"] = Util.Matrix;\n return builtIn;\n }\n\n loadJsonStringIntoProject(jsonString) {\n var json;\n return json = JSON.parse(jsonString);\n }\n\n };\n\n // TODO: get version via build process / ENV variable?\n Editor.prototype.version = \"0.4.1\";\n\n return Editor;\n\n}).call(this);", "source_lang": "CoffeeScript", "target_lang": "JavaScript", "repo": "cdglabs/apparatus", "path": "src/Model/Editor.coffee", "license": "MIT", "commit": "a9c998cb75d6726b1cf5eb5b059f2c7b6d1e11a2", "stars": 1052, "source_url": "https://github.com/cdglabs/apparatus/blob/a9c998cb75d6726b1cf5eb5b059f2c7b6d1e11a2/src/Model/Editor.coffee", "line_start": 9, "line_end": 58}365{"id": "cdglabs/apparatus:src/Model/Editor.coffee:1:js_to_coffee", "type": "js_to_coffee", "prompt": "Convert this JavaScript to CoffeeScript.\n```javascript\nvar Editor,\n hasProp = {}.hasOwnProperty;\n\nmodule.exports = Editor = (function() {\n class Editor {\n constructor() {\n this._setupLayout();\n this._setupSerializer();\n this._setupProject();\n this._setupRevision();\n this._parseQueryString();\n }\n\n _setupLayout() {\n return this.layout = new Model.Layout();\n }\n\n _setupProject() {\n this.loadFromLocalStorage();\n if (!this.project) {\n return this.createNewProject();\n }\n }\n\n _setupSerializer() {\n var builtInObjects, name, object, ref;\n builtInObjects = [];\n ref = this._builtIn();\n for (name in ref) {\n if (!hasProp.call(ref, name)) continue;\n object = ref[name];\n if (_.isFunction(object)) {\n object = object.prototype;\n }\n Util.assignId(object, name);\n builtInObjects.push(object);\n }\n return this.serializer = new Storage.Serializer(builtInObjects);\n }\n\n // Checks if we should load an external JSON file based on the query string\n // (the ?stuff at the end of the URL).\n _parseQueryString() {\n var parsed;\n parsed = queryString.parse(location.search);\n if (parsed.experimental === '1') {\n this.experimental = true;\n }\n if (parsed.load) {\n return this.loadFromURL(parsed.load);\n }\n }\n\n // builtIn returns all of the built in classes and objects that are used as\n // the \"anchors\" for serialization and deserialization. That is, all of the\n // objects and classes which should not themselves be serialized but instead\n // be *referenced* from a serialization. When deserialized, these references\n // are then bound appropriately.\n _builtIn() {\n var builtIn;\n builtIn = _.clone(Model);\n builtIn[\"SpreadEnv\"] = Dataflow.SpreadEnv;\n builtIn[\"Matrix\"] = Util.Matrix;\n return builtIn;\n }\n\n loadJsonStringIntoProject(jsonString) {\n var json;\n return json = JSON.parse(jsonString);\n }\n\n };\n\n // TODO: get version via build process / ENV variable?\n Editor.prototype.version = \"0.4.1\";\n\n return Editor;\n\n}).call(this);\n```", "response": "module.exports = class Editor\n constructor: ->\n @_setupLayout()\n @_setupSerializer()\n @_setupProject()\n @_setupRevision()\n @_parseQueryString()\n\n _setupLayout: ->\n @layout = new Model.Layout()\n\n _setupProject: ->\n @loadFromLocalStorage()\n if !@project\n @createNewProject()\n\n _setupSerializer: ->\n builtInObjects = []\n for own name, object of @_builtIn()\n if _.isFunction(object)\n object = object.prototype\n Util.assignId(object, name)\n builtInObjects.push(object)\n @serializer = new Storage.Serializer(builtInObjects)\n\n # Checks if we should load an external JSON file based on the query string\n # (the ?stuff at the end of the URL).\n _parseQueryString: ->\n parsed = queryString.parse(location.search)\n if parsed.experimental == '1'\n @experimental = true\n if parsed.load\n @loadFromURL(parsed.load)\n\n # builtIn returns all of the built in classes and objects that are used as\n # the \"anchors\" for serialization and deserialization. That is, all of the\n # objects and classes which should not themselves be serialized but instead\n # be *referenced* from a serialization. When deserialized, these references\n # are then bound appropriately.\n _builtIn: ->\n builtIn = _.clone(Model)\n builtIn[\"SpreadEnv\"] = Dataflow.SpreadEnv\n builtIn[\"Matrix\"] = Util.Matrix\n return builtIn\n\n # TODO: get version via build process / ENV variable?\n version: \"0.4.1\"\n\n loadJsonStringIntoProject: (jsonString) ->\n json = JSON.parse(jsonString)", "source_lang": "JavaScript", "target_lang": "CoffeeScript", "repo": "cdglabs/apparatus", "path": "src/Model/Editor.coffee", "license": "MIT", "commit": "a9c998cb75d6726b1cf5eb5b059f2c7b6d1e11a2", "stars": 1052, "source_url": "https://github.com/cdglabs/apparatus/blob/a9c998cb75d6726b1cf5eb5b059f2c7b6d1e11a2/src/Model/Editor.coffee", "line_start": 9, "line_end": 58}366{"id": "cdglabs/apparatus:src/Model/Editor.coffee:1:completion", "type": "completion", "prompt": "module.exports = class Editor\n constructor: ->\n @_setupLayout()\n @_setupSerializer()\n @_setupProject()\n @_setupRevision()\n @_parseQueryString()\n\n _setupLayout: ->\n @layout = new Model.Layout()\n\n _setupProject: ->\n @loadFromLocalStorage()\n if !@project\n @createNewProject()\n\n _setupSerializer: ->\n builtInObjects = []\n for own name, object of @_builtIn()\n if _.isFunction(object)\n object = object.prototype\n Util.assignId(object, name)\n builtInObjects.push(object)\n @serializer = new Storage.Serializer(builtInObjects)", "response": "# Checks if we should load an external JSON file based on the query string\n # (the ?stuff at the end of the URL).\n _parseQueryString: ->\n parsed = queryString.parse(location.search)\n if parsed.experimental == '1'\n @experimental = true\n if parsed.load\n @loadFromURL(parsed.load)\n\n # builtIn returns all of the built in classes and objects that are used as\n # the \"anchors\" for serialization and deserialization. That is, all of the\n # objects and classes which should not themselves be serialized but instead\n # be *referenced* from a serialization. When deserialized, these references\n # are then bound appropriately.\n _builtIn: ->\n builtIn = _.clone(Model)\n builtIn[\"SpreadEnv\"] = Dataflow.SpreadEnv\n builtIn[\"Matrix\"] = Util.Matrix\n return builtIn\n\n # TODO: get version via build process / ENV variable?\n version: \"0.4.1\"\n\n loadJsonStringIntoProject: (jsonString) ->\n json = JSON.parse(jsonString)", "source_lang": "CoffeeScript", "target_lang": "CoffeeScript", "repo": "cdglabs/apparatus", "path": "src/Model/Editor.coffee", "license": "MIT", "commit": "a9c998cb75d6726b1cf5eb5b059f2c7b6d1e11a2", "stars": 1052, "source_url": "https://github.com/cdglabs/apparatus/blob/a9c998cb75d6726b1cf5eb5b059f2c7b6d1e11a2/src/Model/Editor.coffee", "line_start": 9, "line_end": 58}367{"id": "cdglabs/apparatus:src/Model/Editor.coffee:2:raw_corpus", "type": "raw_corpus", "prompt": "", "response": "# TODO: If the file format changes, this will need to check the version\n # and convert or fail appropriately.\n if json.type == \"Apparatus\"\n @project = @serializer.dejsonify(json)\n\n loadJsonStringIntoProjectFromExternalSource: (jsonString) ->\n @loadJsonStringIntoProject(jsonString)\n @checkpoint()\n Apparatus.refresh() # HACK: calling Apparatus seems funky here.\n\n getJsonStringOfProject: ->\n json = @serializer.jsonify(@project)\n json.type = \"Apparatus\"\n json.version = @version\n jsonString = JSON.stringify(json)\n return jsonString\n\n createNewProject: ->\n @project = new Model.Project()\n\n\n # ===========================================================================\n # Local Storage\n # ===========================================================================\n\n localStorageName: \"apparatus\"\n\n saveToLocalStorage: ->\n jsonString = @getJsonStringOfProject()\n window.localStorage[@localStorageName] = jsonString\n return jsonString\n\n loadFromLocalStorage: ->\n jsonString = window.localStorage[@localStorageName]\n if jsonString\n @loadJsonStringIntoProject(jsonString)\n\n resetLocalStorage: ->\n delete window.localStorage[@localStorageName]\n\n\n # ===========================================================================\n # File System\n # ===========================================================================\n\n saveToFile: ->\n jsonString = @getJsonStringOfProject()\n fileName = @project.editingElement.label + \".json\"\n Storage.saveFile(jsonString, fileName, \"application/json;charset=utf-8\")", "source_lang": "", "target_lang": "CoffeeScript", "repo": "cdglabs/apparatus", "path": "src/Model/Editor.coffee", "license": "MIT", "commit": "a9c998cb75d6726b1cf5eb5b059f2c7b6d1e11a2", "stars": 1052, "source_url": "https://github.com/cdglabs/apparatus/blob/a9c998cb75d6726b1cf5eb5b059f2c7b6d1e11a2/src/Model/Editor.coffee", "line_start": 59, "line_end": 108}368{"id": "cdglabs/apparatus:src/Model/Editor.coffee:2:completion", "type": "completion", "prompt": "# TODO: If the file format changes, this will need to check the version\n # and convert or fail appropriately.\n if json.type == \"Apparatus\"\n @project = @serializer.dejsonify(json)\n\n loadJsonStringIntoProjectFromExternalSource: (jsonString) ->\n @loadJsonStringIntoProject(jsonString)\n @checkpoint()\n Apparatus.refresh() # HACK: calling Apparatus seems funky here.\n\n getJsonStringOfProject: ->\n json = @serializer.jsonify(@project)\n json.type = \"Apparatus\"\n json.version = @version\n jsonString = JSON.stringify(json)\n return jsonString\n\n createNewProject: ->\n @project = new Model.Project()\n\n\n # ===========================================================================\n # Local Storage\n # ===========================================================================", "response": "localStorageName: \"apparatus\"\n\n saveToLocalStorage: ->\n jsonString = @getJsonStringOfProject()\n window.localStorage[@localStorageName] = jsonString\n return jsonString\n\n loadFromLocalStorage: ->\n jsonString = window.localStorage[@localStorageName]\n if jsonString\n @loadJsonStringIntoProject(jsonString)\n\n resetLocalStorage: ->\n delete window.localStorage[@localStorageName]\n\n\n # ===========================================================================\n # File System\n # ===========================================================================\n\n saveToFile: ->\n jsonString = @getJsonStringOfProject()\n fileName = @project.editingElement.label + \".json\"\n Storage.saveFile(jsonString, fileName, \"application/json;charset=utf-8\")", "source_lang": "CoffeeScript", "target_lang": "CoffeeScript", "repo": "cdglabs/apparatus", "path": "src/Model/Editor.coffee", "license": "MIT", "commit": "a9c998cb75d6726b1cf5eb5b059f2c7b6d1e11a2", "stars": 1052, "source_url": "https://github.com/cdglabs/apparatus/blob/a9c998cb75d6726b1cf5eb5b059f2c7b6d1e11a2/src/Model/Editor.coffee", "line_start": 59, "line_end": 108}369{"id": "cdglabs/apparatus:src/Model/Editor.coffee:3:raw_corpus", "type": "raw_corpus", "prompt": "", "response": "loadFromFile: ->\n Storage.loadFile (jsonString) =>\n @loadJsonStringIntoProjectFromExternalSource(jsonString)\n\n\n # ===========================================================================\n # External URL\n # ===========================================================================\n\n # TODO: Deal with error conditions, timeout, etc.\n # TODO: Maybe move xhr stuff to Util.\n # TODO: Show some sort of loading indicator.\n loadFromURL: (url) ->\n xhr = new XMLHttpRequest()\n xhr.onreadystatechange = =>\n return unless xhr.readyState == 4\n return unless xhr.status == 200\n jsonString = xhr.responseText\n @loadJsonStringIntoProjectFromExternalSource(jsonString)\n xhr.open(\"GET\", url, true)\n xhr.send()\n\n\n # ===========================================================================\n # Revision History\n # ===========================================================================\n\n _setupRevision: ->\n # @current is a JSON string representing the current state. @undoStack and\n # @redoStack are arrays of such JSON strings.\n @current = @getJsonStringOfProject()\n @undoStack = []\n @redoStack = []\n @maxUndoStackSize = 100\n\n checkpoint: ->\n jsonString = @saveToLocalStorage()\n return if @current == jsonString\n @undoStack.push(@current)\n if @undoStack.length > @maxUndoStackSize\n @undoStack.shift()\n @redoStack = []\n @current = jsonString\n\n undo: ->\n return unless @isUndoable()\n @redoStack.push(@current)\n @current = @undoStack.pop()\n @loadJsonStringIntoProject(@current)\n @saveToLocalStorage()", "source_lang": "", "target_lang": "CoffeeScript", "repo": "cdglabs/apparatus", "path": "src/Model/Editor.coffee", "license": "MIT", "commit": "a9c998cb75d6726b1cf5eb5b059f2c7b6d1e11a2", "stars": 1052, "source_url": "https://github.com/cdglabs/apparatus/blob/a9c998cb75d6726b1cf5eb5b059f2c7b6d1e11a2/src/Model/Editor.coffee", "line_start": 109, "line_end": 158}370{"id": "cdglabs/apparatus:src/Model/Editor.coffee:3:coffee_to_js", "type": "coffee_to_js", "prompt": "Convert this CoffeeScript to JavaScript.\n```coffeescript\nloadFromFile: ->\n Storage.loadFile (jsonString) =>\n @loadJsonStringIntoProjectFromExternalSource(jsonString)\n\n\n # ===========================================================================\n # External URL\n # ===========================================================================\n\n # TODO: Deal with error conditions, timeout, etc.\n # TODO: Maybe move xhr stuff to Util.\n # TODO: Show some sort of loading indicator.\n loadFromURL: (url) ->\n xhr = new XMLHttpRequest()\n xhr.onreadystatechange = =>\n return unless xhr.readyState == 4\n return unless xhr.status == 200\n jsonString = xhr.responseText\n @loadJsonStringIntoProjectFromExternalSource(jsonString)\n xhr.open(\"GET\", url, true)\n xhr.send()\n\n\n # ===========================================================================\n # Revision History\n # ===========================================================================\n\n _setupRevision: ->\n # @current is a JSON string representing the current state. @undoStack and\n # @redoStack are arrays of such JSON strings.\n @current = @getJsonStringOfProject()\n @undoStack = []\n @redoStack = []\n @maxUndoStackSize = 100\n\n checkpoint: ->\n jsonString = @saveToLocalStorage()\n return if @current == jsonString\n @undoStack.push(@current)\n if @undoStack.length > @maxUndoStackSize\n @undoStack.shift()\n @redoStack = []\n @current = jsonString\n\n undo: ->\n return unless @isUndoable()\n @redoStack.push(@current)\n @current = @undoStack.pop()\n @loadJsonStringIntoProject(@current)\n @saveToLocalStorage()\n```", "response": "({\n loadFromFile: function() {\n return Storage.loadFile((jsonString) => {\n return this.loadJsonStringIntoProjectFromExternalSource(jsonString);\n });\n },\n // ===========================================================================\n // External URL\n // ===========================================================================\n\n // TODO: Deal with error conditions, timeout, etc.\n // TODO: Maybe move xhr stuff to Util.\n // TODO: Show some sort of loading indicator.\n loadFromURL: function(url) {\n var xhr;\n xhr = new XMLHttpRequest();\n xhr.onreadystatechange = () => {\n var jsonString;\n if (xhr.readyState !== 4) {\n return;\n }\n if (xhr.status !== 200) {\n return;\n }\n jsonString = xhr.responseText;\n return this.loadJsonStringIntoProjectFromExternalSource(jsonString);\n };\n xhr.open(\"GET\", url, true);\n return xhr.send();\n },\n // ===========================================================================\n // Revision History\n // ===========================================================================\n _setupRevision: function() {\n // @current is a JSON string representing the current state. @undoStack and\n // @redoStack are arrays of such JSON strings.\n this.current = this.getJsonStringOfProject();\n this.undoStack = [];\n this.redoStack = [];\n return this.maxUndoStackSize = 100;\n },\n checkpoint: function() {\n var jsonString;\n jsonString = this.saveToLocalStorage();\n if (this.current === jsonString) {\n return;\n }\n this.undoStack.push(this.current);\n if (this.undoStack.length > this.maxUndoStackSize) {\n this.undoStack.shift();\n }\n this.redoStack = [];\n return this.current = jsonString;\n },\n undo: function() {\n if (!this.isUndoable()) {\n return;\n }\n this.redoStack.push(this.current);\n this.current = this.undoStack.pop();\n this.loadJsonStringIntoProject(this.current);\n return this.saveToLocalStorage();\n }\n});", "source_lang": "CoffeeScript", "target_lang": "JavaScript", "repo": "cdglabs/apparatus", "path": "src/Model/Editor.coffee", "license": "MIT", "commit": "a9c998cb75d6726b1cf5eb5b059f2c7b6d1e11a2", "stars": 1052, "source_url": "https://github.com/cdglabs/apparatus/blob/a9c998cb75d6726b1cf5eb5b059f2c7b6d1e11a2/src/Model/Editor.coffee", "line_start": 109, "line_end": 158}371{"id": "cdglabs/apparatus:src/Model/Editor.coffee:3:js_to_coffee", "type": "js_to_coffee", "prompt": "Convert this JavaScript to CoffeeScript.\n```javascript\n({\n loadFromFile: function() {\n return Storage.loadFile((jsonString) => {\n return this.loadJsonStringIntoProjectFromExternalSource(jsonString);\n });\n },\n // ===========================================================================\n // External URL\n // ===========================================================================\n\n // TODO: Deal with error conditions, timeout, etc.\n // TODO: Maybe move xhr stuff to Util.\n // TODO: Show some sort of loading indicator.\n loadFromURL: function(url) {\n var xhr;\n xhr = new XMLHttpRequest();\n xhr.onreadystatechange = () => {\n var jsonString;\n if (xhr.readyState !== 4) {\n return;\n }\n if (xhr.status !== 200) {\n return;\n }\n jsonString = xhr.responseText;\n return this.loadJsonStringIntoProjectFromExternalSource(jsonString);\n };\n xhr.open(\"GET\", url, true);\n return xhr.send();\n },\n // ===========================================================================\n // Revision History\n // ===========================================================================\n _setupRevision: function() {\n // @current is a JSON string representing the current state. @undoStack and\n // @redoStack are arrays of such JSON strings.\n this.current = this.getJsonStringOfProject();\n this.undoStack = [];\n this.redoStack = [];\n return this.maxUndoStackSize = 100;\n },\n checkpoint: function() {\n var jsonString;\n jsonString = this.saveToLocalStorage();\n if (this.current === jsonString) {\n return;\n }\n this.undoStack.push(this.current);\n if (this.undoStack.length > this.maxUndoStackSize) {\n this.undoStack.shift();\n }\n this.redoStack = [];\n return this.current = jsonString;\n },\n undo: function() {\n if (!this.isUndoable()) {\n return;\n }\n this.redoStack.push(this.current);\n this.current = this.undoStack.pop();\n this.loadJsonStringIntoProject(this.current);\n return this.saveToLocalStorage();\n }\n});\n```", "response": "loadFromFile: ->\n Storage.loadFile (jsonString) =>\n @loadJsonStringIntoProjectFromExternalSource(jsonString)\n\n\n # ===========================================================================\n # External URL\n # ===========================================================================\n\n # TODO: Deal with error conditions, timeout, etc.\n # TODO: Maybe move xhr stuff to Util.\n # TODO: Show some sort of loading indicator.\n loadFromURL: (url) ->\n xhr = new XMLHttpRequest()\n xhr.onreadystatechange = =>\n return unless xhr.readyState == 4\n return unless xhr.status == 200\n jsonString = xhr.responseText\n @loadJsonStringIntoProjectFromExternalSource(jsonString)\n xhr.open(\"GET\", url, true)\n xhr.send()\n\n\n # ===========================================================================\n # Revision History\n # ===========================================================================\n\n _setupRevision: ->\n # @current is a JSON string representing the current state. @undoStack and\n # @redoStack are arrays of such JSON strings.\n @current = @getJsonStringOfProject()\n @undoStack = []\n @redoStack = []\n @maxUndoStackSize = 100\n\n checkpoint: ->\n jsonString = @saveToLocalStorage()\n return if @current == jsonString\n @undoStack.push(@current)\n if @undoStack.length > @maxUndoStackSize\n @undoStack.shift()\n @redoStack = []\n @current = jsonString\n\n undo: ->\n return unless @isUndoable()\n @redoStack.push(@current)\n @current = @undoStack.pop()\n @loadJsonStringIntoProject(@current)\n @saveToLocalStorage()", "source_lang": "JavaScript", "target_lang": "CoffeeScript", "repo": "cdglabs/apparatus", "path": "src/Model/Editor.coffee", "license": "MIT", "commit": "a9c998cb75d6726b1cf5eb5b059f2c7b6d1e11a2", "stars": 1052, "source_url": "https://github.com/cdglabs/apparatus/blob/a9c998cb75d6726b1cf5eb5b059f2c7b6d1e11a2/src/Model/Editor.coffee", "line_start": 109, "line_end": 158}372{"id": "cdglabs/apparatus:src/Model/Editor.coffee:3:completion", "type": "completion", "prompt": "loadFromFile: ->\n Storage.loadFile (jsonString) =>\n @loadJsonStringIntoProjectFromExternalSource(jsonString)\n\n\n # ===========================================================================\n # External URL\n # ===========================================================================\n\n # TODO: Deal with error conditions, timeout, etc.\n # TODO: Maybe move xhr stuff to Util.\n # TODO: Show some sort of loading indicator.\n loadFromURL: (url) ->\n xhr = new XMLHttpRequest()\n xhr.onreadystatechange = =>\n return unless xhr.readyState == 4\n return unless xhr.status == 200\n jsonString = xhr.responseText\n @loadJsonStringIntoProjectFromExternalSource(jsonString)\n xhr.open(\"GET\", url, true)\n xhr.send()\n\n\n # ===========================================================================\n # Revision History", "response": "# ===========================================================================\n\n _setupRevision: ->\n # @current is a JSON string representing the current state. @undoStack and\n # @redoStack are arrays of such JSON strings.\n @current = @getJsonStringOfProject()\n @undoStack = []\n @redoStack = []\n @maxUndoStackSize = 100\n\n checkpoint: ->\n jsonString = @saveToLocalStorage()\n return if @current == jsonString\n @undoStack.push(@current)\n if @undoStack.length > @maxUndoStackSize\n @undoStack.shift()\n @redoStack = []\n @current = jsonString\n\n undo: ->\n return unless @isUndoable()\n @redoStack.push(@current)\n @current = @undoStack.pop()\n @loadJsonStringIntoProject(@current)\n @saveToLocalStorage()", "source_lang": "CoffeeScript", "target_lang": "CoffeeScript", "repo": "cdglabs/apparatus", "path": "src/Model/Editor.coffee", "license": "MIT", "commit": "a9c998cb75d6726b1cf5eb5b059f2c7b6d1e11a2", "stars": 1052, "source_url": "https://github.com/cdglabs/apparatus/blob/a9c998cb75d6726b1cf5eb5b059f2c7b6d1e11a2/src/Model/Editor.coffee", "line_start": 109, "line_end": 158}373{"id": "cdglabs/apparatus:src/Model/Editor.coffee:4:raw_corpus", "type": "raw_corpus", "prompt": "", "response": "redo: ->\n return unless @isRedoable()\n @undoStack.push(@current)\n @current = @redoStack.pop()\n @loadJsonStringIntoProject(@current)\n @saveToLocalStorage()\n\n isUndoable: ->\n return @undoStack.length > 0\n\n isRedoable: ->\n return @redoStack.length > 0", "source_lang": "", "target_lang": "CoffeeScript", "repo": "cdglabs/apparatus", "path": "src/Model/Editor.coffee", "license": "MIT", "commit": "a9c998cb75d6726b1cf5eb5b059f2c7b6d1e11a2", "stars": 1052, "source_url": "https://github.com/cdglabs/apparatus/blob/a9c998cb75d6726b1cf5eb5b059f2c7b6d1e11a2/src/Model/Editor.coffee", "line_start": 159, "line_end": 171}374{"id": "cdglabs/apparatus:src/Model/Editor.coffee:4:coffee_to_js", "type": "coffee_to_js", "prompt": "Convert this CoffeeScript to JavaScript.\n```coffeescript\nredo: ->\n return unless @isRedoable()\n @undoStack.push(@current)\n @current = @redoStack.pop()\n @loadJsonStringIntoProject(@current)\n @saveToLocalStorage()\n\n isUndoable: ->\n return @undoStack.length > 0\n\n isRedoable: ->\n return @redoStack.length > 0\n```", "response": "({\n redo: function() {\n if (!this.isRedoable()) {\n return;\n }\n this.undoStack.push(this.current);\n this.current = this.redoStack.pop();\n this.loadJsonStringIntoProject(this.current);\n return this.saveToLocalStorage();\n },\n isUndoable: function() {\n return this.undoStack.length > 0;\n },\n isRedoable: function() {\n return this.redoStack.length > 0;\n }\n});", "source_lang": "CoffeeScript", "target_lang": "JavaScript", "repo": "cdglabs/apparatus", "path": "src/Model/Editor.coffee", "license": "MIT", "commit": "a9c998cb75d6726b1cf5eb5b059f2c7b6d1e11a2", "stars": 1052, "source_url": "https://github.com/cdglabs/apparatus/blob/a9c998cb75d6726b1cf5eb5b059f2c7b6d1e11a2/src/Model/Editor.coffee", "line_start": 159, "line_end": 171}375{"id": "cdglabs/apparatus:src/Model/Editor.coffee:4:js_to_coffee", "type": "js_to_coffee", "prompt": "Convert this JavaScript to CoffeeScript.\n```javascript\n({\n redo: function() {\n if (!this.isRedoable()) {\n return;\n }\n this.undoStack.push(this.current);\n this.current = this.redoStack.pop();\n this.loadJsonStringIntoProject(this.current);\n return this.saveToLocalStorage();\n },\n isUndoable: function() {\n return this.undoStack.length > 0;\n },\n isRedoable: function() {\n return this.redoStack.length > 0;\n }\n});\n```", "response": "redo: ->\n return unless @isRedoable()\n @undoStack.push(@current)\n @current = @redoStack.pop()\n @loadJsonStringIntoProject(@current)\n @saveToLocalStorage()\n\n isUndoable: ->\n return @undoStack.length > 0\n\n isRedoable: ->\n return @redoStack.length > 0", "source_lang": "JavaScript", "target_lang": "CoffeeScript", "repo": "cdglabs/apparatus", "path": "src/Model/Editor.coffee", "license": "MIT", "commit": "a9c998cb75d6726b1cf5eb5b059f2c7b6d1e11a2", "stars": 1052, "source_url": "https://github.com/cdglabs/apparatus/blob/a9c998cb75d6726b1cf5eb5b059f2c7b6d1e11a2/src/Model/Editor.coffee", "line_start": 159, "line_end": 171}376{"id": "cdglabs/apparatus:src/Model/Editor.coffee:4:completion", "type": "completion", "prompt": "redo: ->\n return unless @isRedoable()\n @undoStack.push(@current)\n @current = @redoStack.pop()\n @loadJsonStringIntoProject(@current)\n @saveToLocalStorage()", "response": "isUndoable: ->\n return @undoStack.length > 0\n\n isRedoable: ->\n return @redoStack.length > 0", "source_lang": "CoffeeScript", "target_lang": "CoffeeScript", "repo": "cdglabs/apparatus", "path": "src/Model/Editor.coffee", "license": "MIT", "commit": "a9c998cb75d6726b1cf5eb5b059f2c7b6d1e11a2", "stars": 1052, "source_url": "https://github.com/cdglabs/apparatus/blob/a9c998cb75d6726b1cf5eb5b059f2c7b6d1e11a2/src/Model/Editor.coffee", "line_start": 159, "line_end": 171}377{"id": "cdglabs/apparatus:src/Model/Editor.coffee:1:raw_corpus", "type": "raw_corpus", "prompt": "", "response": "module.exports = class Editor\n constructor: ->\n @_setupLayout()\n @_setupSerializer()\n @_setupProject()\n @_setupRevision()\n @_parseQueryString()\n\n _setupLayout: ->\n @layout = new Model.Layout()\n\n _setupProject: ->\n @loadFromLocalStorage()\n if !@project\n @createNewProject()\n\n _setupSerializer: ->\n builtInObjects = []\n for own name, object of @_builtIn()\n if _.isFunction(object)\n object = object.prototype\n Util.assignId(object, name)\n builtInObjects.push(object)\n @serializer = new Storage.Serializer(builtInObjects)\n\n # Checks if we should load an external JSON file based on the query string\n # (the ?stuff at the end of the URL).\n _parseQueryString: ->\n parsed = queryString.parse(location.search)\n if parsed.load\n @loadFromURL(parsed.load)\n\n # builtIn returns all of the built in classes and objects that are used as\n # the \"anchors\" for serialization and deserialization. That is, all of the\n # objects and classes which should not themselves be serialized but instead\n # be *referenced* from a serialization. When deserialized, these references\n # are then bound appropriately.\n _builtIn: ->\n builtIn = _.clone(Model)\n builtIn[\"SpreadEnv\"] = Dataflow.SpreadEnv\n builtIn[\"Matrix\"] = Util.Matrix\n return builtIn\n\n # TODO: get version via build process / ENV variable?\n version: \"0.4.1\"\n\n loadJsonStringIntoProject: (jsonString) ->\n json = JSON.parse(jsonString)\n # TODO: If the file format changes, this will need to check the version\n # and convert or fail appropriately.", "source_lang": "", "target_lang": "CoffeeScript", "repo": "cdglabs/apparatus", "path": "src/Model/Editor.coffee", "license": "MIT", "commit": "7e4cb8771426288afdc4758d7c6208cc233018c5", "stars": 1052, "source_url": "https://github.com/cdglabs/apparatus/blob/7e4cb8771426288afdc4758d7c6208cc233018c5/src/Model/Editor.coffee", "line_start": 9, "line_end": 58}378{"id": "cdglabs/apparatus:src/Model/Editor.coffee:1:coffee_to_js", "type": "coffee_to_js", "prompt": "Convert this CoffeeScript to JavaScript.\n```coffeescript\nmodule.exports = class Editor\n constructor: ->\n @_setupLayout()\n @_setupSerializer()\n @_setupProject()\n @_setupRevision()\n @_parseQueryString()\n\n _setupLayout: ->\n @layout = new Model.Layout()\n\n _setupProject: ->\n @loadFromLocalStorage()\n if !@project\n @createNewProject()\n\n _setupSerializer: ->\n builtInObjects = []\n for own name, object of @_builtIn()\n if _.isFunction(object)\n object = object.prototype\n Util.assignId(object, name)\n builtInObjects.push(object)\n @serializer = new Storage.Serializer(builtInObjects)\n\n # Checks if we should load an external JSON file based on the query string\n # (the ?stuff at the end of the URL).\n _parseQueryString: ->\n parsed = queryString.parse(location.search)\n if parsed.load\n @loadFromURL(parsed.load)\n\n # builtIn returns all of the built in classes and objects that are used as\n # the \"anchors\" for serialization and deserialization. That is, all of the\n # objects and classes which should not themselves be serialized but instead\n # be *referenced* from a serialization. When deserialized, these references\n # are then bound appropriately.\n _builtIn: ->\n builtIn = _.clone(Model)\n builtIn[\"SpreadEnv\"] = Dataflow.SpreadEnv\n builtIn[\"Matrix\"] = Util.Matrix\n return builtIn\n\n # TODO: get version via build process / ENV variable?\n version: \"0.4.1\"\n\n loadJsonStringIntoProject: (jsonString) ->\n json = JSON.parse(jsonString)\n # TODO: If the file format changes, this will need to check the version\n # and convert or fail appropriately.\n```", "response": "var Editor,\n hasProp = {}.hasOwnProperty;\n\nmodule.exports = Editor = (function() {\n class Editor {\n constructor() {\n this._setupLayout();\n this._setupSerializer();\n this._setupProject();\n this._setupRevision();\n this._parseQueryString();\n }\n\n _setupLayout() {\n return this.layout = new Model.Layout();\n }\n\n _setupProject() {\n this.loadFromLocalStorage();\n if (!this.project) {\n return this.createNewProject();\n }\n }\n\n _setupSerializer() {\n var builtInObjects, name, object, ref;\n builtInObjects = [];\n ref = this._builtIn();\n for (name in ref) {\n if (!hasProp.call(ref, name)) continue;\n object = ref[name];\n if (_.isFunction(object)) {\n object = object.prototype;\n }\n Util.assignId(object, name);\n builtInObjects.push(object);\n }\n return this.serializer = new Storage.Serializer(builtInObjects);\n }\n\n // Checks if we should load an external JSON file based on the query string\n // (the ?stuff at the end of the URL).\n _parseQueryString() {\n var parsed;\n parsed = queryString.parse(location.search);\n if (parsed.load) {\n return this.loadFromURL(parsed.load);\n }\n }\n\n // builtIn returns all of the built in classes and objects that are used as\n // the \"anchors\" for serialization and deserialization. That is, all of the\n // objects and classes which should not themselves be serialized but instead\n // be *referenced* from a serialization. When deserialized, these references\n // are then bound appropriately.\n _builtIn() {\n var builtIn;\n builtIn = _.clone(Model);\n builtIn[\"SpreadEnv\"] = Dataflow.SpreadEnv;\n builtIn[\"Matrix\"] = Util.Matrix;\n return builtIn;\n }\n\n loadJsonStringIntoProject(jsonString) {\n var json;\n return json = JSON.parse(jsonString);\n }\n\n };\n\n // TODO: get version via build process / ENV variable?\n Editor.prototype.version = \"0.4.1\";\n\n return Editor;\n\n}).call(this);\n\n// TODO: If the file format changes, this will need to check the version\n// and convert or fail appropriately.", "source_lang": "CoffeeScript", "target_lang": "JavaScript", "repo": "cdglabs/apparatus", "path": "src/Model/Editor.coffee", "license": "MIT", "commit": "7e4cb8771426288afdc4758d7c6208cc233018c5", "stars": 1052, "source_url": "https://github.com/cdglabs/apparatus/blob/7e4cb8771426288afdc4758d7c6208cc233018c5/src/Model/Editor.coffee", "line_start": 9, "line_end": 58}379{"id": "cdglabs/apparatus:src/Model/Editor.coffee:1:js_to_coffee", "type": "js_to_coffee", "prompt": "Convert this JavaScript to CoffeeScript.\n```javascript\nvar Editor,\n hasProp = {}.hasOwnProperty;\n\nmodule.exports = Editor = (function() {\n class Editor {\n constructor() {\n this._setupLayout();\n this._setupSerializer();\n this._setupProject();\n this._setupRevision();\n this._parseQueryString();\n }\n\n _setupLayout() {\n return this.layout = new Model.Layout();\n }\n\n _setupProject() {\n this.loadFromLocalStorage();\n if (!this.project) {\n return this.createNewProject();\n }\n }\n\n _setupSerializer() {\n var builtInObjects, name, object, ref;\n builtInObjects = [];\n ref = this._builtIn();\n for (name in ref) {\n if (!hasProp.call(ref, name)) continue;\n object = ref[name];\n if (_.isFunction(object)) {\n object = object.prototype;\n }\n Util.assignId(object, name);\n builtInObjects.push(object);\n }\n return this.serializer = new Storage.Serializer(builtInObjects);\n }\n\n // Checks if we should load an external JSON file based on the query string\n // (the ?stuff at the end of the URL).\n _parseQueryString() {\n var parsed;\n parsed = queryString.parse(location.search);\n if (parsed.load) {\n return this.loadFromURL(parsed.load);\n }\n }\n\n // builtIn returns all of the built in classes and objects that are used as\n // the \"anchors\" for serialization and deserialization. That is, all of the\n // objects and classes which should not themselves be serialized but instead\n // be *referenced* from a serialization. When deserialized, these references\n // are then bound appropriately.\n _builtIn() {\n var builtIn;\n builtIn = _.clone(Model);\n builtIn[\"SpreadEnv\"] = Dataflow.SpreadEnv;\n builtIn[\"Matrix\"] = Util.Matrix;\n return builtIn;\n }\n\n loadJsonStringIntoProject(jsonString) {\n var json;\n return json = JSON.parse(jsonString);\n }\n\n };\n\n // TODO: get version via build process / ENV variable?\n Editor.prototype.version = \"0.4.1\";\n\n return Editor;\n\n}).call(this);\n\n// TODO: If the file format changes, this will need to check the version\n// and convert or fail appropriately.\n```", "response": "module.exports = class Editor\n constructor: ->\n @_setupLayout()\n @_setupSerializer()\n @_setupProject()\n @_setupRevision()\n @_parseQueryString()\n\n _setupLayout: ->\n @layout = new Model.Layout()\n\n _setupProject: ->\n @loadFromLocalStorage()\n if !@project\n @createNewProject()\n\n _setupSerializer: ->\n builtInObjects = []\n for own name, object of @_builtIn()\n if _.isFunction(object)\n object = object.prototype\n Util.assignId(object, name)\n builtInObjects.push(object)\n @serializer = new Storage.Serializer(builtInObjects)\n\n # Checks if we should load an external JSON file based on the query string\n # (the ?stuff at the end of the URL).\n _parseQueryString: ->\n parsed = queryString.parse(location.search)\n if parsed.load\n @loadFromURL(parsed.load)\n\n # builtIn returns all of the built in classes and objects that are used as\n # the \"anchors\" for serialization and deserialization. That is, all of the\n # objects and classes which should not themselves be serialized but instead\n # be *referenced* from a serialization. When deserialized, these references\n # are then bound appropriately.\n _builtIn: ->\n builtIn = _.clone(Model)\n builtIn[\"SpreadEnv\"] = Dataflow.SpreadEnv\n builtIn[\"Matrix\"] = Util.Matrix\n return builtIn\n\n # TODO: get version via build process / ENV variable?\n version: \"0.4.1\"\n\n loadJsonStringIntoProject: (jsonString) ->\n json = JSON.parse(jsonString)\n # TODO: If the file format changes, this will need to check the version\n # and convert or fail appropriately.", "source_lang": "JavaScript", "target_lang": "CoffeeScript", "repo": "cdglabs/apparatus", "path": "src/Model/Editor.coffee", "license": "MIT", "commit": "7e4cb8771426288afdc4758d7c6208cc233018c5", "stars": 1052, "source_url": "https://github.com/cdglabs/apparatus/blob/7e4cb8771426288afdc4758d7c6208cc233018c5/src/Model/Editor.coffee", "line_start": 9, "line_end": 58}380{"id": "cdglabs/apparatus:src/Model/Editor.coffee:1:completion", "type": "completion", "prompt": "module.exports = class Editor\n constructor: ->\n @_setupLayout()\n @_setupSerializer()\n @_setupProject()\n @_setupRevision()\n @_parseQueryString()\n\n _setupLayout: ->\n @layout = new Model.Layout()\n\n _setupProject: ->\n @loadFromLocalStorage()\n if !@project\n @createNewProject()\n\n _setupSerializer: ->\n builtInObjects = []\n for own name, object of @_builtIn()\n if _.isFunction(object)\n object = object.prototype\n Util.assignId(object, name)\n builtInObjects.push(object)\n @serializer = new Storage.Serializer(builtInObjects)", "response": "# Checks if we should load an external JSON file based on the query string\n # (the ?stuff at the end of the URL).\n _parseQueryString: ->\n parsed = queryString.parse(location.search)\n if parsed.load\n @loadFromURL(parsed.load)\n\n # builtIn returns all of the built in classes and objects that are used as\n # the \"anchors\" for serialization and deserialization. That is, all of the\n # objects and classes which should not themselves be serialized but instead\n # be *referenced* from a serialization. When deserialized, these references\n # are then bound appropriately.\n _builtIn: ->\n builtIn = _.clone(Model)\n builtIn[\"SpreadEnv\"] = Dataflow.SpreadEnv\n builtIn[\"Matrix\"] = Util.Matrix\n return builtIn\n\n # TODO: get version via build process / ENV variable?\n version: \"0.4.1\"\n\n loadJsonStringIntoProject: (jsonString) ->\n json = JSON.parse(jsonString)\n # TODO: If the file format changes, this will need to check the version\n # and convert or fail appropriately.", "source_lang": "CoffeeScript", "target_lang": "CoffeeScript", "repo": "cdglabs/apparatus", "path": "src/Model/Editor.coffee", "license": "MIT", "commit": "7e4cb8771426288afdc4758d7c6208cc233018c5", "stars": 1052, "source_url": "https://github.com/cdglabs/apparatus/blob/7e4cb8771426288afdc4758d7c6208cc233018c5/src/Model/Editor.coffee", "line_start": 9, "line_end": 58}381{"id": "cdglabs/apparatus:src/Model/Editor.coffee:2:raw_corpus", "type": "raw_corpus", "prompt": "", "response": "if json.type == \"Apparatus\"\n @project = @serializer.dejsonify(json)\n\n loadJsonStringIntoProjectFromExternalSource: (jsonString) ->\n @loadJsonStringIntoProject(jsonString)\n @checkpoint()\n Apparatus.refresh() # HACK: calling Apparatus seems funky here.\n\n getJsonStringOfProject: ->\n json = @serializer.jsonify(@project)\n json.type = \"Apparatus\"\n json.version = @version\n jsonString = JSON.stringify(json)\n return jsonString\n\n createNewProject: ->\n @project = new Model.Project()\n\n\n # ===========================================================================\n # Local Storage\n # ===========================================================================\n\n localStorageName: \"apparatus\"\n\n saveToLocalStorage: ->\n jsonString = @getJsonStringOfProject()\n window.localStorage[@localStorageName] = jsonString\n return jsonString\n\n loadFromLocalStorage: ->\n jsonString = window.localStorage[@localStorageName]\n if jsonString\n @loadJsonStringIntoProject(jsonString)\n\n resetLocalStorage: ->\n delete window.localStorage[@localStorageName]\n\n\n # ===========================================================================\n # File System\n # ===========================================================================\n\n saveToFile: ->\n jsonString = @getJsonStringOfProject()\n fileName = @project.editingElement.label + \".json\"\n Storage.saveFile(jsonString, fileName, \"application/json;charset=utf-8\")\n\n loadFromFile: ->\n Storage.loadFile (jsonString) =>", "source_lang": "", "target_lang": "CoffeeScript", "repo": "cdglabs/apparatus", "path": "src/Model/Editor.coffee", "license": "MIT", "commit": "7e4cb8771426288afdc4758d7c6208cc233018c5", "stars": 1052, "source_url": "https://github.com/cdglabs/apparatus/blob/7e4cb8771426288afdc4758d7c6208cc233018c5/src/Model/Editor.coffee", "line_start": 59, "line_end": 108}382{"id": "cdglabs/apparatus:src/Model/Editor.coffee:2:coffee_to_js", "type": "coffee_to_js", "prompt": "Convert this CoffeeScript to JavaScript.\n```coffeescript\nif json.type == \"Apparatus\"\n @project = @serializer.dejsonify(json)\n\n loadJsonStringIntoProjectFromExternalSource: (jsonString) ->\n @loadJsonStringIntoProject(jsonString)\n @checkpoint()\n Apparatus.refresh() # HACK: calling Apparatus seems funky here.\n\n getJsonStringOfProject: ->\n json = @serializer.jsonify(@project)\n json.type = \"Apparatus\"\n json.version = @version\n jsonString = JSON.stringify(json)\n return jsonString\n\n createNewProject: ->\n @project = new Model.Project()\n\n\n # ===========================================================================\n # Local Storage\n # ===========================================================================\n\n localStorageName: \"apparatus\"\n\n saveToLocalStorage: ->\n jsonString = @getJsonStringOfProject()\n window.localStorage[@localStorageName] = jsonString\n return jsonString\n\n loadFromLocalStorage: ->\n jsonString = window.localStorage[@localStorageName]\n if jsonString\n @loadJsonStringIntoProject(jsonString)\n\n resetLocalStorage: ->\n delete window.localStorage[@localStorageName]\n\n\n # ===========================================================================\n # File System\n # ===========================================================================\n\n saveToFile: ->\n jsonString = @getJsonStringOfProject()\n fileName = @project.editingElement.label + \".json\"\n Storage.saveFile(jsonString, fileName, \"application/json;charset=utf-8\")\n\n loadFromFile: ->\n Storage.loadFile (jsonString) =>\n```", "response": "if (json.type === \"Apparatus\") {\n this.project = this.serializer.dejsonify(json);\n}\n\n({\n loadJsonStringIntoProjectFromExternalSource: function(jsonString) {\n this.loadJsonStringIntoProject(jsonString);\n this.checkpoint();\n return Apparatus.refresh(); // HACK: calling Apparatus seems funky here.\n },\n getJsonStringOfProject: function() {\n var json, jsonString;\n json = this.serializer.jsonify(this.project);\n json.type = \"Apparatus\";\n json.version = this.version;\n jsonString = JSON.stringify(json);\n return jsonString;\n },\n createNewProject: function() {\n return this.project = new Model.Project();\n },\n // ===========================================================================\n // Local Storage\n // ===========================================================================\n localStorageName: \"apparatus\",\n saveToLocalStorage: function() {\n var jsonString;\n jsonString = this.getJsonStringOfProject();\n window.localStorage[this.localStorageName] = jsonString;\n return jsonString;\n },\n loadFromLocalStorage: function() {\n var jsonString;\n jsonString = window.localStorage[this.localStorageName];\n if (jsonString) {\n return this.loadJsonStringIntoProject(jsonString);\n }\n },\n resetLocalStorage: function() {\n return delete window.localStorage[this.localStorageName];\n },\n // ===========================================================================\n // File System\n // ===========================================================================\n saveToFile: function() {\n var fileName, jsonString;\n jsonString = this.getJsonStringOfProject();\n fileName = this.project.editingElement.label + \".json\";\n return Storage.saveFile(jsonString, fileName, \"application/json;charset=utf-8\");\n },\n loadFromFile: function() {\n return Storage.loadFile((jsonString) => {});\n }\n});", "source_lang": "CoffeeScript", "target_lang": "JavaScript", "repo": "cdglabs/apparatus", "path": "src/Model/Editor.coffee", "license": "MIT", "commit": "7e4cb8771426288afdc4758d7c6208cc233018c5", "stars": 1052, "source_url": "https://github.com/cdglabs/apparatus/blob/7e4cb8771426288afdc4758d7c6208cc233018c5/src/Model/Editor.coffee", "line_start": 59, "line_end": 108}383{"id": "cdglabs/apparatus:src/Model/Editor.coffee:2:js_to_coffee", "type": "js_to_coffee", "prompt": "Convert this JavaScript to CoffeeScript.\n```javascript\nif (json.type === \"Apparatus\") {\n this.project = this.serializer.dejsonify(json);\n}\n\n({\n loadJsonStringIntoProjectFromExternalSource: function(jsonString) {\n this.loadJsonStringIntoProject(jsonString);\n this.checkpoint();\n return Apparatus.refresh(); // HACK: calling Apparatus seems funky here.\n },\n getJsonStringOfProject: function() {\n var json, jsonString;\n json = this.serializer.jsonify(this.project);\n json.type = \"Apparatus\";\n json.version = this.version;\n jsonString = JSON.stringify(json);\n return jsonString;\n },\n createNewProject: function() {\n return this.project = new Model.Project();\n },\n // ===========================================================================\n // Local Storage\n // ===========================================================================\n localStorageName: \"apparatus\",\n saveToLocalStorage: function() {\n var jsonString;\n jsonString = this.getJsonStringOfProject();\n window.localStorage[this.localStorageName] = jsonString;\n return jsonString;\n },\n loadFromLocalStorage: function() {\n var jsonString;\n jsonString = window.localStorage[this.localStorageName];\n if (jsonString) {\n return this.loadJsonStringIntoProject(jsonString);\n }\n },\n resetLocalStorage: function() {\n return delete window.localStorage[this.localStorageName];\n },\n // ===========================================================================\n // File System\n // ===========================================================================\n saveToFile: function() {\n var fileName, jsonString;\n jsonString = this.getJsonStringOfProject();\n fileName = this.project.editingElement.label + \".json\";\n return Storage.saveFile(jsonString, fileName, \"application/json;charset=utf-8\");\n },\n loadFromFile: function() {\n return Storage.loadFile((jsonString) => {});\n }\n});\n```", "response": "if json.type == \"Apparatus\"\n @project = @serializer.dejsonify(json)\n\n loadJsonStringIntoProjectFromExternalSource: (jsonString) ->\n @loadJsonStringIntoProject(jsonString)\n @checkpoint()\n Apparatus.refresh() # HACK: calling Apparatus seems funky here.\n\n getJsonStringOfProject: ->\n json = @serializer.jsonify(@project)\n json.type = \"Apparatus\"\n json.version = @version\n jsonString = JSON.stringify(json)\n return jsonString\n\n createNewProject: ->\n @project = new Model.Project()\n\n\n # ===========================================================================\n # Local Storage\n # ===========================================================================\n\n localStorageName: \"apparatus\"\n\n saveToLocalStorage: ->\n jsonString = @getJsonStringOfProject()\n window.localStorage[@localStorageName] = jsonString\n return jsonString\n\n loadFromLocalStorage: ->\n jsonString = window.localStorage[@localStorageName]\n if jsonString\n @loadJsonStringIntoProject(jsonString)\n\n resetLocalStorage: ->\n delete window.localStorage[@localStorageName]\n\n\n # ===========================================================================\n # File System\n # ===========================================================================\n\n saveToFile: ->\n jsonString = @getJsonStringOfProject()\n fileName = @project.editingElement.label + \".json\"\n Storage.saveFile(jsonString, fileName, \"application/json;charset=utf-8\")\n\n loadFromFile: ->\n Storage.loadFile (jsonString) =>", "source_lang": "JavaScript", "target_lang": "CoffeeScript", "repo": "cdglabs/apparatus", "path": "src/Model/Editor.coffee", "license": "MIT", "commit": "7e4cb8771426288afdc4758d7c6208cc233018c5", "stars": 1052, "source_url": "https://github.com/cdglabs/apparatus/blob/7e4cb8771426288afdc4758d7c6208cc233018c5/src/Model/Editor.coffee", "line_start": 59, "line_end": 108}384{"id": "cdglabs/apparatus:src/Model/Editor.coffee:2:completion", "type": "completion", "prompt": "if json.type == \"Apparatus\"\n @project = @serializer.dejsonify(json)\n\n loadJsonStringIntoProjectFromExternalSource: (jsonString) ->\n @loadJsonStringIntoProject(jsonString)\n @checkpoint()\n Apparatus.refresh() # HACK: calling Apparatus seems funky here.\n\n getJsonStringOfProject: ->\n json = @serializer.jsonify(@project)\n json.type = \"Apparatus\"\n json.version = @version\n jsonString = JSON.stringify(json)\n return jsonString\n\n createNewProject: ->\n @project = new Model.Project()\n\n\n # ===========================================================================\n # Local Storage\n # ===========================================================================\n\n localStorageName: \"apparatus\"", "response": "saveToLocalStorage: ->\n jsonString = @getJsonStringOfProject()\n window.localStorage[@localStorageName] = jsonString\n return jsonString\n\n loadFromLocalStorage: ->\n jsonString = window.localStorage[@localStorageName]\n if jsonString\n @loadJsonStringIntoProject(jsonString)\n\n resetLocalStorage: ->\n delete window.localStorage[@localStorageName]\n\n\n # ===========================================================================\n # File System\n # ===========================================================================\n\n saveToFile: ->\n jsonString = @getJsonStringOfProject()\n fileName = @project.editingElement.label + \".json\"\n Storage.saveFile(jsonString, fileName, \"application/json;charset=utf-8\")\n\n loadFromFile: ->\n Storage.loadFile (jsonString) =>", "source_lang": "CoffeeScript", "target_lang": "CoffeeScript", "repo": "cdglabs/apparatus", "path": "src/Model/Editor.coffee", "license": "MIT", "commit": "7e4cb8771426288afdc4758d7c6208cc233018c5", "stars": 1052, "source_url": "https://github.com/cdglabs/apparatus/blob/7e4cb8771426288afdc4758d7c6208cc233018c5/src/Model/Editor.coffee", "line_start": 59, "line_end": 108}385{"id": "cdglabs/apparatus:src/Model/Editor.coffee:3:raw_corpus", "type": "raw_corpus", "prompt": "", "response": "@loadJsonStringIntoProjectFromExternalSource(jsonString)\n\n\n # ===========================================================================\n # External URL\n # ===========================================================================\n\n # TODO: Deal with error conditions, timeout, etc.\n # TODO: Maybe move xhr stuff to Util.\n # TODO: Show some sort of loading indicator.\n loadFromURL: (url) ->\n xhr = new XMLHttpRequest()\n xhr.onreadystatechange = =>\n return unless xhr.readyState == 4\n return unless xhr.status == 200\n jsonString = xhr.responseText\n @loadJsonStringIntoProjectFromExternalSource(jsonString)\n xhr.open(\"GET\", url, true)\n xhr.send()\n\n\n # ===========================================================================\n # Revision History\n # ===========================================================================\n\n _setupRevision: ->\n # @current is a JSON string representing the current state. @undoStack and\n # @redoStack are arrays of such JSON strings.\n @current = @getJsonStringOfProject()\n @undoStack = []\n @redoStack = []\n @maxUndoStackSize = 100\n\n checkpoint: ->\n jsonString = @saveToLocalStorage()\n return if @current == jsonString\n @undoStack.push(@current)\n if @undoStack.length > @maxUndoStackSize\n @undoStack.shift()\n @redoStack = []\n @current = jsonString\n\n undo: ->\n return unless @isUndoable()\n @redoStack.push(@current)\n @current = @undoStack.pop()\n @loadJsonStringIntoProject(@current)\n @saveToLocalStorage()\n\n redo: ->", "source_lang": "", "target_lang": "CoffeeScript", "repo": "cdglabs/apparatus", "path": "src/Model/Editor.coffee", "license": "MIT", "commit": "7e4cb8771426288afdc4758d7c6208cc233018c5", "stars": 1052, "source_url": "https://github.com/cdglabs/apparatus/blob/7e4cb8771426288afdc4758d7c6208cc233018c5/src/Model/Editor.coffee", "line_start": 109, "line_end": 158}386{"id": "cdglabs/apparatus:src/Model/Editor.coffee:3:coffee_to_js", "type": "coffee_to_js", "prompt": "Convert this CoffeeScript to JavaScript.\n```coffeescript\n@loadJsonStringIntoProjectFromExternalSource(jsonString)\n\n\n # ===========================================================================\n # External URL\n # ===========================================================================\n\n # TODO: Deal with error conditions, timeout, etc.\n # TODO: Maybe move xhr stuff to Util.\n # TODO: Show some sort of loading indicator.\n loadFromURL: (url) ->\n xhr = new XMLHttpRequest()\n xhr.onreadystatechange = =>\n return unless xhr.readyState == 4\n return unless xhr.status == 200\n jsonString = xhr.responseText\n @loadJsonStringIntoProjectFromExternalSource(jsonString)\n xhr.open(\"GET\", url, true)\n xhr.send()\n\n\n # ===========================================================================\n # Revision History\n # ===========================================================================\n\n _setupRevision: ->\n # @current is a JSON string representing the current state. @undoStack and\n # @redoStack are arrays of such JSON strings.\n @current = @getJsonStringOfProject()\n @undoStack = []\n @redoStack = []\n @maxUndoStackSize = 100\n\n checkpoint: ->\n jsonString = @saveToLocalStorage()\n return if @current == jsonString\n @undoStack.push(@current)\n if @undoStack.length > @maxUndoStackSize\n @undoStack.shift()\n @redoStack = []\n @current = jsonString\n\n undo: ->\n return unless @isUndoable()\n @redoStack.push(@current)\n @current = @undoStack.pop()\n @loadJsonStringIntoProject(@current)\n @saveToLocalStorage()\n\n redo: ->\n```", "response": "this.loadJsonStringIntoProjectFromExternalSource(jsonString)({\n // ===========================================================================\n // External URL\n // ===========================================================================\n\n // TODO: Deal with error conditions, timeout, etc.\n // TODO: Maybe move xhr stuff to Util.\n // TODO: Show some sort of loading indicator.\n loadFromURL: function(url) {\n var xhr;\n xhr = new XMLHttpRequest();\n xhr.onreadystatechange = () => {\n var jsonString;\n if (xhr.readyState !== 4) {\n return;\n }\n if (xhr.status !== 200) {\n return;\n }\n jsonString = xhr.responseText;\n return this.loadJsonStringIntoProjectFromExternalSource(jsonString);\n };\n xhr.open(\"GET\", url, true);\n return xhr.send();\n },\n // ===========================================================================\n // Revision History\n // ===========================================================================\n _setupRevision: function() {\n // @current is a JSON string representing the current state. @undoStack and\n // @redoStack are arrays of such JSON strings.\n this.current = this.getJsonStringOfProject();\n this.undoStack = [];\n this.redoStack = [];\n return this.maxUndoStackSize = 100;\n },\n checkpoint: function() {\n var jsonString;\n jsonString = this.saveToLocalStorage();\n if (this.current === jsonString) {\n return;\n }\n this.undoStack.push(this.current);\n if (this.undoStack.length > this.maxUndoStackSize) {\n this.undoStack.shift();\n }\n this.redoStack = [];\n return this.current = jsonString;\n },\n undo: function() {\n if (!this.isUndoable()) {\n return;\n }\n this.redoStack.push(this.current);\n this.current = this.undoStack.pop();\n this.loadJsonStringIntoProject(this.current);\n return this.saveToLocalStorage();\n },\n redo: function() {}\n});", "source_lang": "CoffeeScript", "target_lang": "JavaScript", "repo": "cdglabs/apparatus", "path": "src/Model/Editor.coffee", "license": "MIT", "commit": "7e4cb8771426288afdc4758d7c6208cc233018c5", "stars": 1052, "source_url": "https://github.com/cdglabs/apparatus/blob/7e4cb8771426288afdc4758d7c6208cc233018c5/src/Model/Editor.coffee", "line_start": 109, "line_end": 158}387{"id": "cdglabs/apparatus:src/Model/Editor.coffee:3:js_to_coffee", "type": "js_to_coffee", "prompt": "Convert this JavaScript to CoffeeScript.\n```javascript\nthis.loadJsonStringIntoProjectFromExternalSource(jsonString)({\n // ===========================================================================\n // External URL\n // ===========================================================================\n\n // TODO: Deal with error conditions, timeout, etc.\n // TODO: Maybe move xhr stuff to Util.\n // TODO: Show some sort of loading indicator.\n loadFromURL: function(url) {\n var xhr;\n xhr = new XMLHttpRequest();\n xhr.onreadystatechange = () => {\n var jsonString;\n if (xhr.readyState !== 4) {\n return;\n }\n if (xhr.status !== 200) {\n return;\n }\n jsonString = xhr.responseText;\n return this.loadJsonStringIntoProjectFromExternalSource(jsonString);\n };\n xhr.open(\"GET\", url, true);\n return xhr.send();\n },\n // ===========================================================================\n // Revision History\n // ===========================================================================\n _setupRevision: function() {\n // @current is a JSON string representing the current state. @undoStack and\n // @redoStack are arrays of such JSON strings.\n this.current = this.getJsonStringOfProject();\n this.undoStack = [];\n this.redoStack = [];\n return this.maxUndoStackSize = 100;\n },\n checkpoint: function() {\n var jsonString;\n jsonString = this.saveToLocalStorage();\n if (this.current === jsonString) {\n return;\n }\n this.undoStack.push(this.current);\n if (this.undoStack.length > this.maxUndoStackSize) {\n this.undoStack.shift();\n }\n this.redoStack = [];\n return this.current = jsonString;\n },\n undo: function() {\n if (!this.isUndoable()) {\n return;\n }\n this.redoStack.push(this.current);\n this.current = this.undoStack.pop();\n this.loadJsonStringIntoProject(this.current);\n return this.saveToLocalStorage();\n },\n redo: function() {}\n});\n```", "response": "@loadJsonStringIntoProjectFromExternalSource(jsonString)\n\n\n # ===========================================================================\n # External URL\n # ===========================================================================\n\n # TODO: Deal with error conditions, timeout, etc.\n # TODO: Maybe move xhr stuff to Util.\n # TODO: Show some sort of loading indicator.\n loadFromURL: (url) ->\n xhr = new XMLHttpRequest()\n xhr.onreadystatechange = =>\n return unless xhr.readyState == 4\n return unless xhr.status == 200\n jsonString = xhr.responseText\n @loadJsonStringIntoProjectFromExternalSource(jsonString)\n xhr.open(\"GET\", url, true)\n xhr.send()\n\n\n # ===========================================================================\n # Revision History\n # ===========================================================================\n\n _setupRevision: ->\n # @current is a JSON string representing the current state. @undoStack and\n # @redoStack are arrays of such JSON strings.\n @current = @getJsonStringOfProject()\n @undoStack = []\n @redoStack = []\n @maxUndoStackSize = 100\n\n checkpoint: ->\n jsonString = @saveToLocalStorage()\n return if @current == jsonString\n @undoStack.push(@current)\n if @undoStack.length > @maxUndoStackSize\n @undoStack.shift()\n @redoStack = []\n @current = jsonString\n\n undo: ->\n return unless @isUndoable()\n @redoStack.push(@current)\n @current = @undoStack.pop()\n @loadJsonStringIntoProject(@current)\n @saveToLocalStorage()\n\n redo: ->", "source_lang": "JavaScript", "target_lang": "CoffeeScript", "repo": "cdglabs/apparatus", "path": "src/Model/Editor.coffee", "license": "MIT", "commit": "7e4cb8771426288afdc4758d7c6208cc233018c5", "stars": 1052, "source_url": "https://github.com/cdglabs/apparatus/blob/7e4cb8771426288afdc4758d7c6208cc233018c5/src/Model/Editor.coffee", "line_start": 109, "line_end": 158}388{"id": "cdglabs/apparatus:src/Model/Editor.coffee:3:completion", "type": "completion", "prompt": "@loadJsonStringIntoProjectFromExternalSource(jsonString)\n\n\n # ===========================================================================\n # External URL\n # ===========================================================================\n\n # TODO: Deal with error conditions, timeout, etc.\n # TODO: Maybe move xhr stuff to Util.\n # TODO: Show some sort of loading indicator.\n loadFromURL: (url) ->\n xhr = new XMLHttpRequest()\n xhr.onreadystatechange = =>\n return unless xhr.readyState == 4\n return unless xhr.status == 200\n jsonString = xhr.responseText\n @loadJsonStringIntoProjectFromExternalSource(jsonString)\n xhr.open(\"GET\", url, true)\n xhr.send()\n\n\n # ===========================================================================\n # Revision History\n # ===========================================================================", "response": "_setupRevision: ->\n # @current is a JSON string representing the current state. @undoStack and\n # @redoStack are arrays of such JSON strings.\n @current = @getJsonStringOfProject()\n @undoStack = []\n @redoStack = []\n @maxUndoStackSize = 100\n\n checkpoint: ->\n jsonString = @saveToLocalStorage()\n return if @current == jsonString\n @undoStack.push(@current)\n if @undoStack.length > @maxUndoStackSize\n @undoStack.shift()\n @redoStack = []\n @current = jsonString\n\n undo: ->\n return unless @isUndoable()\n @redoStack.push(@current)\n @current = @undoStack.pop()\n @loadJsonStringIntoProject(@current)\n @saveToLocalStorage()\n\n redo: ->", "source_lang": "CoffeeScript", "target_lang": "CoffeeScript", "repo": "cdglabs/apparatus", "path": "src/Model/Editor.coffee", "license": "MIT", "commit": "7e4cb8771426288afdc4758d7c6208cc233018c5", "stars": 1052, "source_url": "https://github.com/cdglabs/apparatus/blob/7e4cb8771426288afdc4758d7c6208cc233018c5/src/Model/Editor.coffee", "line_start": 109, "line_end": 158}389{"id": "cdglabs/apparatus:src/Model/Editor.coffee:4:raw_corpus", "type": "raw_corpus", "prompt": "", "response": "return unless @isRedoable()\n @undoStack.push(@current)\n @current = @redoStack.pop()\n @loadJsonStringIntoProject(@current)\n @saveToLocalStorage()\n\n isUndoable: ->\n return @undoStack.length > 0\n\n isRedoable: ->\n return @redoStack.length > 0", "source_lang": "", "target_lang": "CoffeeScript", "repo": "cdglabs/apparatus", "path": "src/Model/Editor.coffee", "license": "MIT", "commit": "7e4cb8771426288afdc4758d7c6208cc233018c5", "stars": 1052, "source_url": "https://github.com/cdglabs/apparatus/blob/7e4cb8771426288afdc4758d7c6208cc233018c5/src/Model/Editor.coffee", "line_start": 159, "line_end": 169}390{"id": "cdglabs/apparatus:src/Model/Editor.coffee:4:coffee_to_js", "type": "coffee_to_js", "prompt": "Convert this CoffeeScript to JavaScript.\n```coffeescript\nreturn unless @isRedoable()\n @undoStack.push(@current)\n @current = @redoStack.pop()\n @loadJsonStringIntoProject(@current)\n @saveToLocalStorage()\n\n isUndoable: ->\n return @undoStack.length > 0\n\n isRedoable: ->\n return @redoStack.length > 0\n```", "response": "if (!this.isRedoable()) {\n this.undoStack.push(this.current);\n this.current = this.redoStack.pop();\n this.loadJsonStringIntoProject(this.current);\n return this.saveToLocalStorage();\n}\n\n({\n isUndoable: function() {\n return this.undoStack.length > 0;\n },\n isRedoable: function() {\n return this.redoStack.length > 0;\n }\n});", "source_lang": "CoffeeScript", "target_lang": "JavaScript", "repo": "cdglabs/apparatus", "path": "src/Model/Editor.coffee", "license": "MIT", "commit": "7e4cb8771426288afdc4758d7c6208cc233018c5", "stars": 1052, "source_url": "https://github.com/cdglabs/apparatus/blob/7e4cb8771426288afdc4758d7c6208cc233018c5/src/Model/Editor.coffee", "line_start": 159, "line_end": 169}391{"id": "cdglabs/apparatus:src/Model/Editor.coffee:4:js_to_coffee", "type": "js_to_coffee", "prompt": "Convert this JavaScript to CoffeeScript.\n```javascript\nif (!this.isRedoable()) {\n this.undoStack.push(this.current);\n this.current = this.redoStack.pop();\n this.loadJsonStringIntoProject(this.current);\n return this.saveToLocalStorage();\n}\n\n({\n isUndoable: function() {\n return this.undoStack.length > 0;\n },\n isRedoable: function() {\n return this.redoStack.length > 0;\n }\n});\n```", "response": "return unless @isRedoable()\n @undoStack.push(@current)\n @current = @redoStack.pop()\n @loadJsonStringIntoProject(@current)\n @saveToLocalStorage()\n\n isUndoable: ->\n return @undoStack.length > 0\n\n isRedoable: ->\n return @redoStack.length > 0", "source_lang": "JavaScript", "target_lang": "CoffeeScript", "repo": "cdglabs/apparatus", "path": "src/Model/Editor.coffee", "license": "MIT", "commit": "7e4cb8771426288afdc4758d7c6208cc233018c5", "stars": 1052, "source_url": "https://github.com/cdglabs/apparatus/blob/7e4cb8771426288afdc4758d7c6208cc233018c5/src/Model/Editor.coffee", "line_start": 159, "line_end": 169}392{"id": "cdglabs/apparatus:src/Model/Editor.coffee:4:completion", "type": "completion", "prompt": "return unless @isRedoable()\n @undoStack.push(@current)\n @current = @redoStack.pop()\n @loadJsonStringIntoProject(@current)\n @saveToLocalStorage()", "response": "isUndoable: ->\n return @undoStack.length > 0\n\n isRedoable: ->\n return @redoStack.length > 0", "source_lang": "CoffeeScript", "target_lang": "CoffeeScript", "repo": "cdglabs/apparatus", "path": "src/Model/Editor.coffee", "license": "MIT", "commit": "7e4cb8771426288afdc4758d7c6208cc233018c5", "stars": 1052, "source_url": "https://github.com/cdglabs/apparatus/blob/7e4cb8771426288afdc4758d7c6208cc233018c5/src/Model/Editor.coffee", "line_start": 159, "line_end": 169}393{"id": "cdglabs/apparatus:src/Model/Editor.coffee:1:raw_corpus", "type": "raw_corpus", "prompt": "", "response": "module.exports = class Editor\n constructor: ->\n @_setupLayout()\n @_setupSerializer()\n @_setupProject()\n @_setupRevision()\n @_parseQueryString()\n\n _setupLayout: ->\n @layout = new Model.Layout()\n\n _setupProject: ->\n @loadFromLocalStorage()\n if !@project\n @createNewProject()\n\n _setupSerializer: ->\n builtInObjects = []\n for own name, object of @_builtIn()\n if _.isFunction(object)\n object = object.prototype\n Util.assignId(object, name)\n builtInObjects.push(object)\n @serializer = new Storage.Serializer(builtInObjects)\n\n # Checks if we should load an external JSON file based on the query string\n # (the ?stuff at the end of the URL).\n _parseQueryString: ->\n parsed = queryString.parse(location.search)\n if parsed.load\n @loadFromURL(parsed.load)\n\n # builtIn returns all of the built in classes and objects that are used as\n # the \"anchors\" for serialization and deserialization. That is, all of the\n # objects and classes which should not themselves be serialized but instead\n # be *referenced* from a serialization. When deserialized, these references\n # are then bound appropriately.\n _builtIn: ->\n builtIn = _.clone(Model)\n builtIn[\"SpreadEnv\"] = Dataflow.SpreadEnv\n builtIn[\"Matrix\"] = Util.Matrix\n return builtIn\n\n # TODO: get version via build process / ENV variable?\n version: \"0.4.1\"\n\n load: (jsonString) ->\n json = JSON.parse(jsonString)\n # TODO: If the file format changes, this will need to check the version\n # and convert or fail appropriately.", "source_lang": "", "target_lang": "CoffeeScript", "repo": "cdglabs/apparatus", "path": "src/Model/Editor.coffee", "license": "MIT", "commit": "0d3acbcbe264f318b00e15e2dd1b9eff2e929203", "stars": 1052, "source_url": "https://github.com/cdglabs/apparatus/blob/0d3acbcbe264f318b00e15e2dd1b9eff2e929203/src/Model/Editor.coffee", "line_start": 9, "line_end": 58}394{"id": "cdglabs/apparatus:src/Model/Editor.coffee:1:coffee_to_js", "type": "coffee_to_js", "prompt": "Convert this CoffeeScript to JavaScript.\n```coffeescript\nmodule.exports = class Editor\n constructor: ->\n @_setupLayout()\n @_setupSerializer()\n @_setupProject()\n @_setupRevision()\n @_parseQueryString()\n\n _setupLayout: ->\n @layout = new Model.Layout()\n\n _setupProject: ->\n @loadFromLocalStorage()\n if !@project\n @createNewProject()\n\n _setupSerializer: ->\n builtInObjects = []\n for own name, object of @_builtIn()\n if _.isFunction(object)\n object = object.prototype\n Util.assignId(object, name)\n builtInObjects.push(object)\n @serializer = new Storage.Serializer(builtInObjects)\n\n # Checks if we should load an external JSON file based on the query string\n # (the ?stuff at the end of the URL).\n _parseQueryString: ->\n parsed = queryString.parse(location.search)\n if parsed.load\n @loadFromURL(parsed.load)\n\n # builtIn returns all of the built in classes and objects that are used as\n # the \"anchors\" for serialization and deserialization. That is, all of the\n # objects and classes which should not themselves be serialized but instead\n # be *referenced* from a serialization. When deserialized, these references\n # are then bound appropriately.\n _builtIn: ->\n builtIn = _.clone(Model)\n builtIn[\"SpreadEnv\"] = Dataflow.SpreadEnv\n builtIn[\"Matrix\"] = Util.Matrix\n return builtIn\n\n # TODO: get version via build process / ENV variable?\n version: \"0.4.1\"\n\n load: (jsonString) ->\n json = JSON.parse(jsonString)\n # TODO: If the file format changes, this will need to check the version\n # and convert or fail appropriately.\n```", "response": "var Editor,\n hasProp = {}.hasOwnProperty;\n\nmodule.exports = Editor = (function() {\n class Editor {\n constructor() {\n this._setupLayout();\n this._setupSerializer();\n this._setupProject();\n this._setupRevision();\n this._parseQueryString();\n }\n\n _setupLayout() {\n return this.layout = new Model.Layout();\n }\n\n _setupProject() {\n this.loadFromLocalStorage();\n if (!this.project) {\n return this.createNewProject();\n }\n }\n\n _setupSerializer() {\n var builtInObjects, name, object, ref;\n builtInObjects = [];\n ref = this._builtIn();\n for (name in ref) {\n if (!hasProp.call(ref, name)) continue;\n object = ref[name];\n if (_.isFunction(object)) {\n object = object.prototype;\n }\n Util.assignId(object, name);\n builtInObjects.push(object);\n }\n return this.serializer = new Storage.Serializer(builtInObjects);\n }\n\n // Checks if we should load an external JSON file based on the query string\n // (the ?stuff at the end of the URL).\n _parseQueryString() {\n var parsed;\n parsed = queryString.parse(location.search);\n if (parsed.load) {\n return this.loadFromURL(parsed.load);\n }\n }\n\n // builtIn returns all of the built in classes and objects that are used as\n // the \"anchors\" for serialization and deserialization. That is, all of the\n // objects and classes which should not themselves be serialized but instead\n // be *referenced* from a serialization. When deserialized, these references\n // are then bound appropriately.\n _builtIn() {\n var builtIn;\n builtIn = _.clone(Model);\n builtIn[\"SpreadEnv\"] = Dataflow.SpreadEnv;\n builtIn[\"Matrix\"] = Util.Matrix;\n return builtIn;\n }\n\n load(jsonString) {\n var json;\n return json = JSON.parse(jsonString);\n }\n\n };\n\n // TODO: get version via build process / ENV variable?\n Editor.prototype.version = \"0.4.1\";\n\n return Editor;\n\n}).call(this);\n\n// TODO: If the file format changes, this will need to check the version\n// and convert or fail appropriately.", "source_lang": "CoffeeScript", "target_lang": "JavaScript", "repo": "cdglabs/apparatus", "path": "src/Model/Editor.coffee", "license": "MIT", "commit": "0d3acbcbe264f318b00e15e2dd1b9eff2e929203", "stars": 1052, "source_url": "https://github.com/cdglabs/apparatus/blob/0d3acbcbe264f318b00e15e2dd1b9eff2e929203/src/Model/Editor.coffee", "line_start": 9, "line_end": 58}395{"id": "cdglabs/apparatus:src/Model/Editor.coffee:1:js_to_coffee", "type": "js_to_coffee", "prompt": "Convert this JavaScript to CoffeeScript.\n```javascript\nvar Editor,\n hasProp = {}.hasOwnProperty;\n\nmodule.exports = Editor = (function() {\n class Editor {\n constructor() {\n this._setupLayout();\n this._setupSerializer();\n this._setupProject();\n this._setupRevision();\n this._parseQueryString();\n }\n\n _setupLayout() {\n return this.layout = new Model.Layout();\n }\n\n _setupProject() {\n this.loadFromLocalStorage();\n if (!this.project) {\n return this.createNewProject();\n }\n }\n\n _setupSerializer() {\n var builtInObjects, name, object, ref;\n builtInObjects = [];\n ref = this._builtIn();\n for (name in ref) {\n if (!hasProp.call(ref, name)) continue;\n object = ref[name];\n if (_.isFunction(object)) {\n object = object.prototype;\n }\n Util.assignId(object, name);\n builtInObjects.push(object);\n }\n return this.serializer = new Storage.Serializer(builtInObjects);\n }\n\n // Checks if we should load an external JSON file based on the query string\n // (the ?stuff at the end of the URL).\n _parseQueryString() {\n var parsed;\n parsed = queryString.parse(location.search);\n if (parsed.load) {\n return this.loadFromURL(parsed.load);\n }\n }\n\n // builtIn returns all of the built in classes and objects that are used as\n // the \"anchors\" for serialization and deserialization. That is, all of the\n // objects and classes which should not themselves be serialized but instead\n // be *referenced* from a serialization. When deserialized, these references\n // are then bound appropriately.\n _builtIn() {\n var builtIn;\n builtIn = _.clone(Model);\n builtIn[\"SpreadEnv\"] = Dataflow.SpreadEnv;\n builtIn[\"Matrix\"] = Util.Matrix;\n return builtIn;\n }\n\n load(jsonString) {\n var json;\n return json = JSON.parse(jsonString);\n }\n\n };\n\n // TODO: get version via build process / ENV variable?\n Editor.prototype.version = \"0.4.1\";\n\n return Editor;\n\n}).call(this);\n\n// TODO: If the file format changes, this will need to check the version\n// and convert or fail appropriately.\n```", "response": "module.exports = class Editor\n constructor: ->\n @_setupLayout()\n @_setupSerializer()\n @_setupProject()\n @_setupRevision()\n @_parseQueryString()\n\n _setupLayout: ->\n @layout = new Model.Layout()\n\n _setupProject: ->\n @loadFromLocalStorage()\n if !@project\n @createNewProject()\n\n _setupSerializer: ->\n builtInObjects = []\n for own name, object of @_builtIn()\n if _.isFunction(object)\n object = object.prototype\n Util.assignId(object, name)\n builtInObjects.push(object)\n @serializer = new Storage.Serializer(builtInObjects)\n\n # Checks if we should load an external JSON file based on the query string\n # (the ?stuff at the end of the URL).\n _parseQueryString: ->\n parsed = queryString.parse(location.search)\n if parsed.load\n @loadFromURL(parsed.load)\n\n # builtIn returns all of the built in classes and objects that are used as\n # the \"anchors\" for serialization and deserialization. That is, all of the\n # objects and classes which should not themselves be serialized but instead\n # be *referenced* from a serialization. When deserialized, these references\n # are then bound appropriately.\n _builtIn: ->\n builtIn = _.clone(Model)\n builtIn[\"SpreadEnv\"] = Dataflow.SpreadEnv\n builtIn[\"Matrix\"] = Util.Matrix\n return builtIn\n\n # TODO: get version via build process / ENV variable?\n version: \"0.4.1\"\n\n load: (jsonString) ->\n json = JSON.parse(jsonString)\n # TODO: If the file format changes, this will need to check the version\n # and convert or fail appropriately.", "source_lang": "JavaScript", "target_lang": "CoffeeScript", "repo": "cdglabs/apparatus", "path": "src/Model/Editor.coffee", "license": "MIT", "commit": "0d3acbcbe264f318b00e15e2dd1b9eff2e929203", "stars": 1052, "source_url": "https://github.com/cdglabs/apparatus/blob/0d3acbcbe264f318b00e15e2dd1b9eff2e929203/src/Model/Editor.coffee", "line_start": 9, "line_end": 58}396{"id": "cdglabs/apparatus:src/Model/Editor.coffee:1:completion", "type": "completion", "prompt": "module.exports = class Editor\n constructor: ->\n @_setupLayout()\n @_setupSerializer()\n @_setupProject()\n @_setupRevision()\n @_parseQueryString()\n\n _setupLayout: ->\n @layout = new Model.Layout()\n\n _setupProject: ->\n @loadFromLocalStorage()\n if !@project\n @createNewProject()\n\n _setupSerializer: ->\n builtInObjects = []\n for own name, object of @_builtIn()\n if _.isFunction(object)\n object = object.prototype\n Util.assignId(object, name)\n builtInObjects.push(object)\n @serializer = new Storage.Serializer(builtInObjects)", "response": "# Checks if we should load an external JSON file based on the query string\n # (the ?stuff at the end of the URL).\n _parseQueryString: ->\n parsed = queryString.parse(location.search)\n if parsed.load\n @loadFromURL(parsed.load)\n\n # builtIn returns all of the built in classes and objects that are used as\n # the \"anchors\" for serialization and deserialization. That is, all of the\n # objects and classes which should not themselves be serialized but instead\n # be *referenced* from a serialization. When deserialized, these references\n # are then bound appropriately.\n _builtIn: ->\n builtIn = _.clone(Model)\n builtIn[\"SpreadEnv\"] = Dataflow.SpreadEnv\n builtIn[\"Matrix\"] = Util.Matrix\n return builtIn\n\n # TODO: get version via build process / ENV variable?\n version: \"0.4.1\"\n\n load: (jsonString) ->\n json = JSON.parse(jsonString)\n # TODO: If the file format changes, this will need to check the version\n # and convert or fail appropriately.", "source_lang": "CoffeeScript", "target_lang": "CoffeeScript", "repo": "cdglabs/apparatus", "path": "src/Model/Editor.coffee", "license": "MIT", "commit": "0d3acbcbe264f318b00e15e2dd1b9eff2e929203", "stars": 1052, "source_url": "https://github.com/cdglabs/apparatus/blob/0d3acbcbe264f318b00e15e2dd1b9eff2e929203/src/Model/Editor.coffee", "line_start": 9, "line_end": 58}397{"id": "cdglabs/apparatus:src/Model/Editor.coffee:2:raw_corpus", "type": "raw_corpus", "prompt": "", "response": "if json.type == \"Apparatus\"\n @project = @serializer.dejsonify(json)\n\n save: ->\n json = @serializer.jsonify(@project)\n json.type = \"Apparatus\"\n json.version = @version\n jsonString = JSON.stringify(json)\n return jsonString\n\n createNewProject: ->\n @project = new Model.Project()\n\n\n # ===========================================================================\n # Local Storage\n # ===========================================================================\n\n localStorageName: \"apparatus\"\n\n saveToLocalStorage: ->\n jsonString = @save()\n window.localStorage[@localStorageName] = jsonString\n return jsonString\n\n loadFromLocalStorage: ->\n jsonString = window.localStorage[@localStorageName]\n if jsonString\n @load(jsonString)\n\n resetLocalStorage: ->\n delete window.localStorage[@localStorageName]\n\n\n # ===========================================================================\n # File System\n # ===========================================================================\n\n saveToFile: ->\n jsonString = @save()\n fileName = @project.editingElement.label + \".json\"\n Storage.saveFile(jsonString, fileName, \"application/json;charset=utf-8\")\n\n loadFromFile: ->\n Storage.loadFile (jsonString) =>\n @load(jsonString)\n\n\n # ===========================================================================\n # External URL", "source_lang": "", "target_lang": "CoffeeScript", "repo": "cdglabs/apparatus", "path": "src/Model/Editor.coffee", "license": "MIT", "commit": "0d3acbcbe264f318b00e15e2dd1b9eff2e929203", "stars": 1052, "source_url": "https://github.com/cdglabs/apparatus/blob/0d3acbcbe264f318b00e15e2dd1b9eff2e929203/src/Model/Editor.coffee", "line_start": 59, "line_end": 108}398{"id": "cdglabs/apparatus:src/Model/Editor.coffee:2:coffee_to_js", "type": "coffee_to_js", "prompt": "Convert this CoffeeScript to JavaScript.\n```coffeescript\nif json.type == \"Apparatus\"\n @project = @serializer.dejsonify(json)\n\n save: ->\n json = @serializer.jsonify(@project)\n json.type = \"Apparatus\"\n json.version = @version\n jsonString = JSON.stringify(json)\n return jsonString\n\n createNewProject: ->\n @project = new Model.Project()\n\n\n # ===========================================================================\n # Local Storage\n # ===========================================================================\n\n localStorageName: \"apparatus\"\n\n saveToLocalStorage: ->\n jsonString = @save()\n window.localStorage[@localStorageName] = jsonString\n return jsonString\n\n loadFromLocalStorage: ->\n jsonString = window.localStorage[@localStorageName]\n if jsonString\n @load(jsonString)\n\n resetLocalStorage: ->\n delete window.localStorage[@localStorageName]\n\n\n # ===========================================================================\n # File System\n # ===========================================================================\n\n saveToFile: ->\n jsonString = @save()\n fileName = @project.editingElement.label + \".json\"\n Storage.saveFile(jsonString, fileName, \"application/json;charset=utf-8\")\n\n loadFromFile: ->\n Storage.loadFile (jsonString) =>\n @load(jsonString)\n\n\n # ===========================================================================\n # External URL\n```", "response": "if (json.type === \"Apparatus\") {\n this.project = this.serializer.dejsonify(json);\n}\n\n({\n save: function() {\n var json, jsonString;\n json = this.serializer.jsonify(this.project);\n json.type = \"Apparatus\";\n json.version = this.version;\n jsonString = JSON.stringify(json);\n return jsonString;\n },\n createNewProject: function() {\n return this.project = new Model.Project();\n },\n // ===========================================================================\n // Local Storage\n // ===========================================================================\n localStorageName: \"apparatus\",\n saveToLocalStorage: function() {\n var jsonString;\n jsonString = this.save();\n window.localStorage[this.localStorageName] = jsonString;\n return jsonString;\n },\n loadFromLocalStorage: function() {\n var jsonString;\n jsonString = window.localStorage[this.localStorageName];\n if (jsonString) {\n return this.load(jsonString);\n }\n },\n resetLocalStorage: function() {\n return delete window.localStorage[this.localStorageName];\n },\n // ===========================================================================\n // File System\n // ===========================================================================\n saveToFile: function() {\n var fileName, jsonString;\n jsonString = this.save();\n fileName = this.project.editingElement.label + \".json\";\n return Storage.saveFile(jsonString, fileName, \"application/json;charset=utf-8\");\n },\n loadFromFile: function() {\n return Storage.loadFile((jsonString) => {\n return this.load(jsonString);\n });\n }\n});\n\n// ===========================================================================\n// External URL", "source_lang": "CoffeeScript", "target_lang": "JavaScript", "repo": "cdglabs/apparatus", "path": "src/Model/Editor.coffee", "license": "MIT", "commit": "0d3acbcbe264f318b00e15e2dd1b9eff2e929203", "stars": 1052, "source_url": "https://github.com/cdglabs/apparatus/blob/0d3acbcbe264f318b00e15e2dd1b9eff2e929203/src/Model/Editor.coffee", "line_start": 59, "line_end": 108}399{"id": "cdglabs/apparatus:src/Model/Editor.coffee:2:js_to_coffee", "type": "js_to_coffee", "prompt": "Convert this JavaScript to CoffeeScript.\n```javascript\nif (json.type === \"Apparatus\") {\n this.project = this.serializer.dejsonify(json);\n}\n\n({\n save: function() {\n var json, jsonString;\n json = this.serializer.jsonify(this.project);\n json.type = \"Apparatus\";\n json.version = this.version;\n jsonString = JSON.stringify(json);\n return jsonString;\n },\n createNewProject: function() {\n return this.project = new Model.Project();\n },\n // ===========================================================================\n // Local Storage\n // ===========================================================================\n localStorageName: \"apparatus\",\n saveToLocalStorage: function() {\n var jsonString;\n jsonString = this.save();\n window.localStorage[this.localStorageName] = jsonString;\n return jsonString;\n },\n loadFromLocalStorage: function() {\n var jsonString;\n jsonString = window.localStorage[this.localStorageName];\n if (jsonString) {\n return this.load(jsonString);\n }\n },\n resetLocalStorage: function() {\n return delete window.localStorage[this.localStorageName];\n },\n // ===========================================================================\n // File System\n // ===========================================================================\n saveToFile: function() {\n var fileName, jsonString;\n jsonString = this.save();\n fileName = this.project.editingElement.label + \".json\";\n return Storage.saveFile(jsonString, fileName, \"application/json;charset=utf-8\");\n },\n loadFromFile: function() {\n return Storage.loadFile((jsonString) => {\n return this.load(jsonString);\n });\n }\n});\n\n// ===========================================================================\n// External URL\n```", "response": "if json.type == \"Apparatus\"\n @project = @serializer.dejsonify(json)\n\n save: ->\n json = @serializer.jsonify(@project)\n json.type = \"Apparatus\"\n json.version = @version\n jsonString = JSON.stringify(json)\n return jsonString\n\n createNewProject: ->\n @project = new Model.Project()\n\n\n # ===========================================================================\n # Local Storage\n # ===========================================================================\n\n localStorageName: \"apparatus\"\n\n saveToLocalStorage: ->\n jsonString = @save()\n window.localStorage[@localStorageName] = jsonString\n return jsonString\n\n loadFromLocalStorage: ->\n jsonString = window.localStorage[@localStorageName]\n if jsonString\n @load(jsonString)\n\n resetLocalStorage: ->\n delete window.localStorage[@localStorageName]\n\n\n # ===========================================================================\n # File System\n # ===========================================================================\n\n saveToFile: ->\n jsonString = @save()\n fileName = @project.editingElement.label + \".json\"\n Storage.saveFile(jsonString, fileName, \"application/json;charset=utf-8\")\n\n loadFromFile: ->\n Storage.loadFile (jsonString) =>\n @load(jsonString)\n\n\n # ===========================================================================\n # External URL", "source_lang": "JavaScript", "target_lang": "CoffeeScript", "repo": "cdglabs/apparatus", "path": "src/Model/Editor.coffee", "license": "MIT", "commit": "0d3acbcbe264f318b00e15e2dd1b9eff2e929203", "stars": 1052, "source_url": "https://github.com/cdglabs/apparatus/blob/0d3acbcbe264f318b00e15e2dd1b9eff2e929203/src/Model/Editor.coffee", "line_start": 59, "line_end": 108}400{"id": "cdglabs/apparatus:src/Model/Editor.coffee:2:completion", "type": "completion", "prompt": "if json.type == \"Apparatus\"\n @project = @serializer.dejsonify(json)\n\n save: ->\n json = @serializer.jsonify(@project)\n json.type = \"Apparatus\"\n json.version = @version\n jsonString = JSON.stringify(json)\n return jsonString\n\n createNewProject: ->\n @project = new Model.Project()\n\n\n # ===========================================================================\n # Local Storage\n # ===========================================================================\n\n localStorageName: \"apparatus\"\n\n saveToLocalStorage: ->\n jsonString = @save()\n window.localStorage[@localStorageName] = jsonString\n return jsonString", "response": "loadFromLocalStorage: ->\n jsonString = window.localStorage[@localStorageName]\n if jsonString\n @load(jsonString)\n\n resetLocalStorage: ->\n delete window.localStorage[@localStorageName]\n\n\n # ===========================================================================\n # File System\n # ===========================================================================\n\n saveToFile: ->\n jsonString = @save()\n fileName = @project.editingElement.label + \".json\"\n Storage.saveFile(jsonString, fileName, \"application/json;charset=utf-8\")\n\n loadFromFile: ->\n Storage.loadFile (jsonString) =>\n @load(jsonString)\n\n\n # ===========================================================================\n # External URL", "source_lang": "CoffeeScript", "target_lang": "CoffeeScript", "repo": "cdglabs/apparatus", "path": "src/Model/Editor.coffee", "license": "MIT", "commit": "0d3acbcbe264f318b00e15e2dd1b9eff2e929203", "stars": 1052, "source_url": "https://github.com/cdglabs/apparatus/blob/0d3acbcbe264f318b00e15e2dd1b9eff2e929203/src/Model/Editor.coffee", "line_start": 59, "line_end": 108}401{"id": "cdglabs/apparatus:src/Model/Editor.coffee:3:raw_corpus", "type": "raw_corpus", "prompt": "", "response": "# ===========================================================================\n\n # TODO: Deal with error conditions, timeout, etc.\n # TODO: Maybe move xhr stuff to Util.\n # TODO: Show some sort of loading indicator.\n loadFromURL: (url) ->\n xhr = new XMLHttpRequest()\n xhr.onreadystatechange = =>\n return unless xhr.readyState == 4\n return unless xhr.status == 200\n jsonString = xhr.responseText\n @load(jsonString)\n @checkpoint()\n Apparatus.refresh() # HACK: calling Apparatus seems funky here.\n xhr.open(\"GET\", url, true)\n xhr.send()\n\n\n # ===========================================================================\n # Revision History\n # ===========================================================================\n\n _setupRevision: ->\n # @current is a JSON string representing the current state. @undoStack and\n # @redoStack are arrays of such JSON strings.\n @current = @save()\n @undoStack = []\n @redoStack = []\n @maxUndoStackSize = 100\n\n checkpoint: ->\n jsonString = @saveToLocalStorage()\n return if @current == jsonString\n @undoStack.push(@current)\n if @undoStack.length > @maxUndoStackSize\n @undoStack.shift()\n @redoStack = []\n @current = jsonString\n\n undo: ->\n return unless @isUndoable()\n @redoStack.push(@current)\n @current = @undoStack.pop()\n @load(@current)\n @saveToLocalStorage()\n\n redo: ->\n return unless @isRedoable()\n @undoStack.push(@current)\n @current = @redoStack.pop()", "source_lang": "", "target_lang": "CoffeeScript", "repo": "cdglabs/apparatus", "path": "src/Model/Editor.coffee", "license": "MIT", "commit": "0d3acbcbe264f318b00e15e2dd1b9eff2e929203", "stars": 1052, "source_url": "https://github.com/cdglabs/apparatus/blob/0d3acbcbe264f318b00e15e2dd1b9eff2e929203/src/Model/Editor.coffee", "line_start": 109, "line_end": 158}402{"id": "cdglabs/apparatus:src/Model/Editor.coffee:3:coffee_to_js", "type": "coffee_to_js", "prompt": "Convert this CoffeeScript to JavaScript.\n```coffeescript\n# ===========================================================================\n\n # TODO: Deal with error conditions, timeout, etc.\n # TODO: Maybe move xhr stuff to Util.\n # TODO: Show some sort of loading indicator.\n loadFromURL: (url) ->\n xhr = new XMLHttpRequest()\n xhr.onreadystatechange = =>\n return unless xhr.readyState == 4\n return unless xhr.status == 200\n jsonString = xhr.responseText\n @load(jsonString)\n @checkpoint()\n Apparatus.refresh() # HACK: calling Apparatus seems funky here.\n xhr.open(\"GET\", url, true)\n xhr.send()\n\n\n # ===========================================================================\n # Revision History\n # ===========================================================================\n\n _setupRevision: ->\n # @current is a JSON string representing the current state. @undoStack and\n # @redoStack are arrays of such JSON strings.\n @current = @save()\n @undoStack = []\n @redoStack = []\n @maxUndoStackSize = 100\n\n checkpoint: ->\n jsonString = @saveToLocalStorage()\n return if @current == jsonString\n @undoStack.push(@current)\n if @undoStack.length > @maxUndoStackSize\n @undoStack.shift()\n @redoStack = []\n @current = jsonString\n\n undo: ->\n return unless @isUndoable()\n @redoStack.push(@current)\n @current = @undoStack.pop()\n @load(@current)\n @saveToLocalStorage()\n\n redo: ->\n return unless @isRedoable()\n @undoStack.push(@current)\n @current = @redoStack.pop()\n```", "response": "// ===========================================================================\n\n// TODO: Deal with error conditions, timeout, etc.\n// TODO: Maybe move xhr stuff to Util.\n// TODO: Show some sort of loading indicator.\n({\n loadFromURL: function(url) {\n var xhr;\n xhr = new XMLHttpRequest();\n xhr.onreadystatechange = () => {\n var jsonString;\n if (xhr.readyState !== 4) {\n return;\n }\n if (xhr.status !== 200) {\n return;\n }\n jsonString = xhr.responseText;\n this.load(jsonString);\n this.checkpoint();\n return Apparatus.refresh(); // HACK: calling Apparatus seems funky here.\n };\n xhr.open(\"GET\", url, true);\n return xhr.send();\n },\n // ===========================================================================\n // Revision History\n // ===========================================================================\n _setupRevision: function() {\n // @current is a JSON string representing the current state. @undoStack and\n // @redoStack are arrays of such JSON strings.\n this.current = this.save();\n this.undoStack = [];\n this.redoStack = [];\n return this.maxUndoStackSize = 100;\n },\n checkpoint: function() {\n var jsonString;\n jsonString = this.saveToLocalStorage();\n if (this.current === jsonString) {\n return;\n }\n this.undoStack.push(this.current);\n if (this.undoStack.length > this.maxUndoStackSize) {\n this.undoStack.shift();\n }\n this.redoStack = [];\n return this.current = jsonString;\n },\n undo: function() {\n if (!this.isUndoable()) {\n return;\n }\n this.redoStack.push(this.current);\n this.current = this.undoStack.pop();\n this.load(this.current);\n return this.saveToLocalStorage();\n },\n redo: function() {\n if (!this.isRedoable()) {\n return;\n }\n this.undoStack.push(this.current);\n return this.current = this.redoStack.pop();\n }\n});", "source_lang": "CoffeeScript", "target_lang": "JavaScript", "repo": "cdglabs/apparatus", "path": "src/Model/Editor.coffee", "license": "MIT", "commit": "0d3acbcbe264f318b00e15e2dd1b9eff2e929203", "stars": 1052, "source_url": "https://github.com/cdglabs/apparatus/blob/0d3acbcbe264f318b00e15e2dd1b9eff2e929203/src/Model/Editor.coffee", "line_start": 109, "line_end": 158}403{"id": "cdglabs/apparatus:src/Model/Editor.coffee:3:js_to_coffee", "type": "js_to_coffee", "prompt": "Convert this JavaScript to CoffeeScript.\n```javascript\n// ===========================================================================\n\n// TODO: Deal with error conditions, timeout, etc.\n// TODO: Maybe move xhr stuff to Util.\n// TODO: Show some sort of loading indicator.\n({\n loadFromURL: function(url) {\n var xhr;\n xhr = new XMLHttpRequest();\n xhr.onreadystatechange = () => {\n var jsonString;\n if (xhr.readyState !== 4) {\n return;\n }\n if (xhr.status !== 200) {\n return;\n }\n jsonString = xhr.responseText;\n this.load(jsonString);\n this.checkpoint();\n return Apparatus.refresh(); // HACK: calling Apparatus seems funky here.\n };\n xhr.open(\"GET\", url, true);\n return xhr.send();\n },\n // ===========================================================================\n // Revision History\n // ===========================================================================\n _setupRevision: function() {\n // @current is a JSON string representing the current state. @undoStack and\n // @redoStack are arrays of such JSON strings.\n this.current = this.save();\n this.undoStack = [];\n this.redoStack = [];\n return this.maxUndoStackSize = 100;\n },\n checkpoint: function() {\n var jsonString;\n jsonString = this.saveToLocalStorage();\n if (this.current === jsonString) {\n return;\n }\n this.undoStack.push(this.current);\n if (this.undoStack.length > this.maxUndoStackSize) {\n this.undoStack.shift();\n }\n this.redoStack = [];\n return this.current = jsonString;\n },\n undo: function() {\n if (!this.isUndoable()) {\n return;\n }\n this.redoStack.push(this.current);\n this.current = this.undoStack.pop();\n this.load(this.current);\n return this.saveToLocalStorage();\n },\n redo: function() {\n if (!this.isRedoable()) {\n return;\n }\n this.undoStack.push(this.current);\n return this.current = this.redoStack.pop();\n }\n});\n```", "response": "# ===========================================================================\n\n # TODO: Deal with error conditions, timeout, etc.\n # TODO: Maybe move xhr stuff to Util.\n # TODO: Show some sort of loading indicator.\n loadFromURL: (url) ->\n xhr = new XMLHttpRequest()\n xhr.onreadystatechange = =>\n return unless xhr.readyState == 4\n return unless xhr.status == 200\n jsonString = xhr.responseText\n @load(jsonString)\n @checkpoint()\n Apparatus.refresh() # HACK: calling Apparatus seems funky here.\n xhr.open(\"GET\", url, true)\n xhr.send()\n\n\n # ===========================================================================\n # Revision History\n # ===========================================================================\n\n _setupRevision: ->\n # @current is a JSON string representing the current state. @undoStack and\n # @redoStack are arrays of such JSON strings.\n @current = @save()\n @undoStack = []\n @redoStack = []\n @maxUndoStackSize = 100\n\n checkpoint: ->\n jsonString = @saveToLocalStorage()\n return if @current == jsonString\n @undoStack.push(@current)\n if @undoStack.length > @maxUndoStackSize\n @undoStack.shift()\n @redoStack = []\n @current = jsonString\n\n undo: ->\n return unless @isUndoable()\n @redoStack.push(@current)\n @current = @undoStack.pop()\n @load(@current)\n @saveToLocalStorage()\n\n redo: ->\n return unless @isRedoable()\n @undoStack.push(@current)\n @current = @redoStack.pop()", "source_lang": "JavaScript", "target_lang": "CoffeeScript", "repo": "cdglabs/apparatus", "path": "src/Model/Editor.coffee", "license": "MIT", "commit": "0d3acbcbe264f318b00e15e2dd1b9eff2e929203", "stars": 1052, "source_url": "https://github.com/cdglabs/apparatus/blob/0d3acbcbe264f318b00e15e2dd1b9eff2e929203/src/Model/Editor.coffee", "line_start": 109, "line_end": 158}404{"id": "cdglabs/apparatus:src/Model/Editor.coffee:3:completion", "type": "completion", "prompt": "# ===========================================================================\n\n # TODO: Deal with error conditions, timeout, etc.\n # TODO: Maybe move xhr stuff to Util.\n # TODO: Show some sort of loading indicator.\n loadFromURL: (url) ->\n xhr = new XMLHttpRequest()\n xhr.onreadystatechange = =>\n return unless xhr.readyState == 4\n return unless xhr.status == 200\n jsonString = xhr.responseText\n @load(jsonString)\n @checkpoint()\n Apparatus.refresh() # HACK: calling Apparatus seems funky here.\n xhr.open(\"GET\", url, true)\n xhr.send()\n\n\n # ===========================================================================\n # Revision History\n # ===========================================================================\n\n _setupRevision: ->\n # @current is a JSON string representing the current state. @undoStack and\n # @redoStack are arrays of such JSON strings.", "response": "@current = @save()\n @undoStack = []\n @redoStack = []\n @maxUndoStackSize = 100\n\n checkpoint: ->\n jsonString = @saveToLocalStorage()\n return if @current == jsonString\n @undoStack.push(@current)\n if @undoStack.length > @maxUndoStackSize\n @undoStack.shift()\n @redoStack = []\n @current = jsonString\n\n undo: ->\n return unless @isUndoable()\n @redoStack.push(@current)\n @current = @undoStack.pop()\n @load(@current)\n @saveToLocalStorage()\n\n redo: ->\n return unless @isRedoable()\n @undoStack.push(@current)\n @current = @redoStack.pop()", "source_lang": "CoffeeScript", "target_lang": "CoffeeScript", "repo": "cdglabs/apparatus", "path": "src/Model/Editor.coffee", "license": "MIT", "commit": "0d3acbcbe264f318b00e15e2dd1b9eff2e929203", "stars": 1052, "source_url": "https://github.com/cdglabs/apparatus/blob/0d3acbcbe264f318b00e15e2dd1b9eff2e929203/src/Model/Editor.coffee", "line_start": 109, "line_end": 158}405{"id": "cdglabs/apparatus:src/Model/Editor.coffee:4:raw_corpus", "type": "raw_corpus", "prompt": "", "response": "@load(@current)\n @saveToLocalStorage()\n\n isUndoable: ->\n return @undoStack.length > 0\n\n isRedoable: ->\n return @redoStack.length > 0", "source_lang": "", "target_lang": "CoffeeScript", "repo": "cdglabs/apparatus", "path": "src/Model/Editor.coffee", "license": "MIT", "commit": "0d3acbcbe264f318b00e15e2dd1b9eff2e929203", "stars": 1052, "source_url": "https://github.com/cdglabs/apparatus/blob/0d3acbcbe264f318b00e15e2dd1b9eff2e929203/src/Model/Editor.coffee", "line_start": 159, "line_end": 166}406{"id": "cdglabs/apparatus:src/Model/Editor.coffee:4:completion", "type": "completion", "prompt": "@load(@current)\n @saveToLocalStorage()\n\n isUndoable: ->", "response": "return @undoStack.length > 0\n\n isRedoable: ->\n return @redoStack.length > 0", "source_lang": "CoffeeScript", "target_lang": "CoffeeScript", "repo": "cdglabs/apparatus", "path": "src/Model/Editor.coffee", "license": "MIT", "commit": "0d3acbcbe264f318b00e15e2dd1b9eff2e929203", "stars": 1052, "source_url": "https://github.com/cdglabs/apparatus/blob/0d3acbcbe264f318b00e15e2dd1b9eff2e929203/src/Model/Editor.coffee", "line_start": 159, "line_end": 166}407{"id": "cdglabs/apparatus:src/Model/Editor.coffee:1:raw_corpus", "type": "raw_corpus", "prompt": "", "response": "module.exports = class Editor\n constructor: ->\n @_setupLayout()\n @_setupSerializer()\n @_setupProject()\n @_setupRevision()\n @_parseQueryString()\n\n _setupLayout: ->\n @layout = new Model.Layout()\n\n _setupProject: ->\n @loadFromLocalStorage()\n if !@project\n @createNewProject()\n\n _setupSerializer: ->\n builtInObjects = []\n for own name, object of @_builtIn()\n if _.isFunction(object)\n object = object.prototype\n Util.assignId(object, name)\n builtInObjects.push(object)\n @serializer = new Storage.Serializer(builtInObjects)\n\n # Checks if we should load an external JSON file based on the query string\n # (the ?stuff at the end of the URL).\n _parseQueryString: ->\n parsed = queryString.parse(location.search)\n if parsed.load\n @loadFromURL(parsed.load)\n\n # builtIn returns all of the built in classes and objects that are used as\n # the \"anchors\" for serialization and deserialization. That is, all of the\n # objects and classes which should not themselves be serialized but instead\n # be *referenced* from a serialization. When deserialized, these references\n # are then bound appropriately.\n _builtIn: ->\n builtIn = _.clone(Model)\n builtIn[\"SpreadEnv\"] = Dataflow.SpreadEnv\n builtIn[\"Matrix\"] = Util.Matrix\n return builtIn\n\n # TODO: get version via build process / ENV variable?\n version: \"0.4.0\"\n\n load: (jsonString) ->\n json = JSON.parse(jsonString)\n if json.type == \"Apparatus\" and json.version == @version\n @project = @serializer.dejsonify(json)", "source_lang": "", "target_lang": "CoffeeScript", "repo": "cdglabs/apparatus", "path": "src/Model/Editor.coffee", "license": "MIT", "commit": "197f7a87562a6de36185a768b3627749831d5c75", "stars": 1052, "source_url": "https://github.com/cdglabs/apparatus/blob/197f7a87562a6de36185a768b3627749831d5c75/src/Model/Editor.coffee", "line_start": 9, "line_end": 58}408{"id": "cdglabs/apparatus:src/Model/Editor.coffee:1:coffee_to_js", "type": "coffee_to_js", "prompt": "Convert this CoffeeScript to JavaScript.\n```coffeescript\nmodule.exports = class Editor\n constructor: ->\n @_setupLayout()\n @_setupSerializer()\n @_setupProject()\n @_setupRevision()\n @_parseQueryString()\n\n _setupLayout: ->\n @layout = new Model.Layout()\n\n _setupProject: ->\n @loadFromLocalStorage()\n if !@project\n @createNewProject()\n\n _setupSerializer: ->\n builtInObjects = []\n for own name, object of @_builtIn()\n if _.isFunction(object)\n object = object.prototype\n Util.assignId(object, name)\n builtInObjects.push(object)\n @serializer = new Storage.Serializer(builtInObjects)\n\n # Checks if we should load an external JSON file based on the query string\n # (the ?stuff at the end of the URL).\n _parseQueryString: ->\n parsed = queryString.parse(location.search)\n if parsed.load\n @loadFromURL(parsed.load)\n\n # builtIn returns all of the built in classes and objects that are used as\n # the \"anchors\" for serialization and deserialization. That is, all of the\n # objects and classes which should not themselves be serialized but instead\n # be *referenced* from a serialization. When deserialized, these references\n # are then bound appropriately.\n _builtIn: ->\n builtIn = _.clone(Model)\n builtIn[\"SpreadEnv\"] = Dataflow.SpreadEnv\n builtIn[\"Matrix\"] = Util.Matrix\n return builtIn\n\n # TODO: get version via build process / ENV variable?\n version: \"0.4.0\"\n\n load: (jsonString) ->\n json = JSON.parse(jsonString)\n if json.type == \"Apparatus\" and json.version == @version\n @project = @serializer.dejsonify(json)\n```", "response": "var Editor,\n hasProp = {}.hasOwnProperty;\n\nmodule.exports = Editor = (function() {\n class Editor {\n constructor() {\n this._setupLayout();\n this._setupSerializer();\n this._setupProject();\n this._setupRevision();\n this._parseQueryString();\n }\n\n _setupLayout() {\n return this.layout = new Model.Layout();\n }\n\n _setupProject() {\n this.loadFromLocalStorage();\n if (!this.project) {\n return this.createNewProject();\n }\n }\n\n _setupSerializer() {\n var builtInObjects, name, object, ref;\n builtInObjects = [];\n ref = this._builtIn();\n for (name in ref) {\n if (!hasProp.call(ref, name)) continue;\n object = ref[name];\n if (_.isFunction(object)) {\n object = object.prototype;\n }\n Util.assignId(object, name);\n builtInObjects.push(object);\n }\n return this.serializer = new Storage.Serializer(builtInObjects);\n }\n\n // Checks if we should load an external JSON file based on the query string\n // (the ?stuff at the end of the URL).\n _parseQueryString() {\n var parsed;\n parsed = queryString.parse(location.search);\n if (parsed.load) {\n return this.loadFromURL(parsed.load);\n }\n }\n\n // builtIn returns all of the built in classes and objects that are used as\n // the \"anchors\" for serialization and deserialization. That is, all of the\n // objects and classes which should not themselves be serialized but instead\n // be *referenced* from a serialization. When deserialized, these references\n // are then bound appropriately.\n _builtIn() {\n var builtIn;\n builtIn = _.clone(Model);\n builtIn[\"SpreadEnv\"] = Dataflow.SpreadEnv;\n builtIn[\"Matrix\"] = Util.Matrix;\n return builtIn;\n }\n\n load(jsonString) {\n var json;\n json = JSON.parse(jsonString);\n if (json.type === \"Apparatus\" && json.version === this.version) {\n return this.project = this.serializer.dejsonify(json);\n }\n }\n\n };\n\n // TODO: get version via build process / ENV variable?\n Editor.prototype.version = \"0.4.0\";\n\n return Editor;\n\n}).call(this);", "source_lang": "CoffeeScript", "target_lang": "JavaScript", "repo": "cdglabs/apparatus", "path": "src/Model/Editor.coffee", "license": "MIT", "commit": "197f7a87562a6de36185a768b3627749831d5c75", "stars": 1052, "source_url": "https://github.com/cdglabs/apparatus/blob/197f7a87562a6de36185a768b3627749831d5c75/src/Model/Editor.coffee", "line_start": 9, "line_end": 58}409{"id": "cdglabs/apparatus:src/Model/Editor.coffee:1:js_to_coffee", "type": "js_to_coffee", "prompt": "Convert this JavaScript to CoffeeScript.\n```javascript\nvar Editor,\n hasProp = {}.hasOwnProperty;\n\nmodule.exports = Editor = (function() {\n class Editor {\n constructor() {\n this._setupLayout();\n this._setupSerializer();\n this._setupProject();\n this._setupRevision();\n this._parseQueryString();\n }\n\n _setupLayout() {\n return this.layout = new Model.Layout();\n }\n\n _setupProject() {\n this.loadFromLocalStorage();\n if (!this.project) {\n return this.createNewProject();\n }\n }\n\n _setupSerializer() {\n var builtInObjects, name, object, ref;\n builtInObjects = [];\n ref = this._builtIn();\n for (name in ref) {\n if (!hasProp.call(ref, name)) continue;\n object = ref[name];\n if (_.isFunction(object)) {\n object = object.prototype;\n }\n Util.assignId(object, name);\n builtInObjects.push(object);\n }\n return this.serializer = new Storage.Serializer(builtInObjects);\n }\n\n // Checks if we should load an external JSON file based on the query string\n // (the ?stuff at the end of the URL).\n _parseQueryString() {\n var parsed;\n parsed = queryString.parse(location.search);\n if (parsed.load) {\n return this.loadFromURL(parsed.load);\n }\n }\n\n // builtIn returns all of the built in classes and objects that are used as\n // the \"anchors\" for serialization and deserialization. That is, all of the\n // objects and classes which should not themselves be serialized but instead\n // be *referenced* from a serialization. When deserialized, these references\n // are then bound appropriately.\n _builtIn() {\n var builtIn;\n builtIn = _.clone(Model);\n builtIn[\"SpreadEnv\"] = Dataflow.SpreadEnv;\n builtIn[\"Matrix\"] = Util.Matrix;\n return builtIn;\n }\n\n load(jsonString) {\n var json;\n json = JSON.parse(jsonString);\n if (json.type === \"Apparatus\" && json.version === this.version) {\n return this.project = this.serializer.dejsonify(json);\n }\n }\n\n };\n\n // TODO: get version via build process / ENV variable?\n Editor.prototype.version = \"0.4.0\";\n\n return Editor;\n\n}).call(this);\n```", "response": "module.exports = class Editor\n constructor: ->\n @_setupLayout()\n @_setupSerializer()\n @_setupProject()\n @_setupRevision()\n @_parseQueryString()\n\n _setupLayout: ->\n @layout = new Model.Layout()\n\n _setupProject: ->\n @loadFromLocalStorage()\n if !@project\n @createNewProject()\n\n _setupSerializer: ->\n builtInObjects = []\n for own name, object of @_builtIn()\n if _.isFunction(object)\n object = object.prototype\n Util.assignId(object, name)\n builtInObjects.push(object)\n @serializer = new Storage.Serializer(builtInObjects)\n\n # Checks if we should load an external JSON file based on the query string\n # (the ?stuff at the end of the URL).\n _parseQueryString: ->\n parsed = queryString.parse(location.search)\n if parsed.load\n @loadFromURL(parsed.load)\n\n # builtIn returns all of the built in classes and objects that are used as\n # the \"anchors\" for serialization and deserialization. That is, all of the\n # objects and classes which should not themselves be serialized but instead\n # be *referenced* from a serialization. When deserialized, these references\n # are then bound appropriately.\n _builtIn: ->\n builtIn = _.clone(Model)\n builtIn[\"SpreadEnv\"] = Dataflow.SpreadEnv\n builtIn[\"Matrix\"] = Util.Matrix\n return builtIn\n\n # TODO: get version via build process / ENV variable?\n version: \"0.4.0\"\n\n load: (jsonString) ->\n json = JSON.parse(jsonString)\n if json.type == \"Apparatus\" and json.version == @version\n @project = @serializer.dejsonify(json)", "source_lang": "JavaScript", "target_lang": "CoffeeScript", "repo": "cdglabs/apparatus", "path": "src/Model/Editor.coffee", "license": "MIT", "commit": "197f7a87562a6de36185a768b3627749831d5c75", "stars": 1052, "source_url": "https://github.com/cdglabs/apparatus/blob/197f7a87562a6de36185a768b3627749831d5c75/src/Model/Editor.coffee", "line_start": 9, "line_end": 58}410{"id": "cdglabs/apparatus:src/Model/Editor.coffee:1:completion", "type": "completion", "prompt": "module.exports = class Editor\n constructor: ->\n @_setupLayout()\n @_setupSerializer()\n @_setupProject()\n @_setupRevision()\n @_parseQueryString()\n\n _setupLayout: ->\n @layout = new Model.Layout()\n\n _setupProject: ->\n @loadFromLocalStorage()\n if !@project\n @createNewProject()\n\n _setupSerializer: ->\n builtInObjects = []\n for own name, object of @_builtIn()\n if _.isFunction(object)\n object = object.prototype\n Util.assignId(object, name)\n builtInObjects.push(object)\n @serializer = new Storage.Serializer(builtInObjects)", "response": "# Checks if we should load an external JSON file based on the query string\n # (the ?stuff at the end of the URL).\n _parseQueryString: ->\n parsed = queryString.parse(location.search)\n if parsed.load\n @loadFromURL(parsed.load)\n\n # builtIn returns all of the built in classes and objects that are used as\n # the \"anchors\" for serialization and deserialization. That is, all of the\n # objects and classes which should not themselves be serialized but instead\n # be *referenced* from a serialization. When deserialized, these references\n # are then bound appropriately.\n _builtIn: ->\n builtIn = _.clone(Model)\n builtIn[\"SpreadEnv\"] = Dataflow.SpreadEnv\n builtIn[\"Matrix\"] = Util.Matrix\n return builtIn\n\n # TODO: get version via build process / ENV variable?\n version: \"0.4.0\"\n\n load: (jsonString) ->\n json = JSON.parse(jsonString)\n if json.type == \"Apparatus\" and json.version == @version\n @project = @serializer.dejsonify(json)", "source_lang": "CoffeeScript", "target_lang": "CoffeeScript", "repo": "cdglabs/apparatus", "path": "src/Model/Editor.coffee", "license": "MIT", "commit": "197f7a87562a6de36185a768b3627749831d5c75", "stars": 1052, "source_url": "https://github.com/cdglabs/apparatus/blob/197f7a87562a6de36185a768b3627749831d5c75/src/Model/Editor.coffee", "line_start": 9, "line_end": 58}411{"id": "cdglabs/apparatus:src/Model/Editor.coffee:2:raw_corpus", "type": "raw_corpus", "prompt": "", "response": "save: ->\n json = @serializer.jsonify(@project)\n json.type = \"Apparatus\"\n json.version = @version\n jsonString = JSON.stringify(json)\n return jsonString\n\n createNewProject: ->\n @project = new Model.Project()\n\n\n # ===========================================================================\n # Local Storage\n # ===========================================================================\n\n localStorageName: \"apparatus\"\n\n saveToLocalStorage: ->\n jsonString = @save()\n window.localStorage[@localStorageName] = jsonString\n return jsonString\n\n loadFromLocalStorage: ->\n jsonString = window.localStorage[@localStorageName]\n if jsonString\n @load(jsonString)\n\n resetLocalStorage: ->\n delete window.localStorage[@localStorageName]\n\n\n # ===========================================================================\n # File System\n # ===========================================================================\n\n saveToFile: ->\n jsonString = @save()\n fileName = @project.editingElement.label + \".json\"\n Storage.saveFile(jsonString, fileName, \"application/json;charset=utf-8\")\n\n loadFromFile: ->\n Storage.loadFile (jsonString) =>\n @load(jsonString)\n\n\n # ===========================================================================\n # External URL\n # ===========================================================================", "source_lang": "", "target_lang": "CoffeeScript", "repo": "cdglabs/apparatus", "path": "src/Model/Editor.coffee", "license": "MIT", "commit": "197f7a87562a6de36185a768b3627749831d5c75", "stars": 1052, "source_url": "https://github.com/cdglabs/apparatus/blob/197f7a87562a6de36185a768b3627749831d5c75/src/Model/Editor.coffee", "line_start": 59, "line_end": 108}412{"id": "cdglabs/apparatus:src/Model/Editor.coffee:2:coffee_to_js", "type": "coffee_to_js", "prompt": "Convert this CoffeeScript to JavaScript.\n```coffeescript\nsave: ->\n json = @serializer.jsonify(@project)\n json.type = \"Apparatus\"\n json.version = @version\n jsonString = JSON.stringify(json)\n return jsonString\n\n createNewProject: ->\n @project = new Model.Project()\n\n\n # ===========================================================================\n # Local Storage\n # ===========================================================================\n\n localStorageName: \"apparatus\"\n\n saveToLocalStorage: ->\n jsonString = @save()\n window.localStorage[@localStorageName] = jsonString\n return jsonString\n\n loadFromLocalStorage: ->\n jsonString = window.localStorage[@localStorageName]\n if jsonString\n @load(jsonString)\n\n resetLocalStorage: ->\n delete window.localStorage[@localStorageName]\n\n\n # ===========================================================================\n # File System\n # ===========================================================================\n\n saveToFile: ->\n jsonString = @save()\n fileName = @project.editingElement.label + \".json\"\n Storage.saveFile(jsonString, fileName, \"application/json;charset=utf-8\")\n\n loadFromFile: ->\n Storage.loadFile (jsonString) =>\n @load(jsonString)\n\n\n # ===========================================================================\n # External URL\n # ===========================================================================\n```", "response": "({\n save: function() {\n var json, jsonString;\n json = this.serializer.jsonify(this.project);\n json.type = \"Apparatus\";\n json.version = this.version;\n jsonString = JSON.stringify(json);\n return jsonString;\n },\n createNewProject: function() {\n return this.project = new Model.Project();\n },\n // ===========================================================================\n // Local Storage\n // ===========================================================================\n localStorageName: \"apparatus\",\n saveToLocalStorage: function() {\n var jsonString;\n jsonString = this.save();\n window.localStorage[this.localStorageName] = jsonString;\n return jsonString;\n },\n loadFromLocalStorage: function() {\n var jsonString;\n jsonString = window.localStorage[this.localStorageName];\n if (jsonString) {\n return this.load(jsonString);\n }\n },\n resetLocalStorage: function() {\n return delete window.localStorage[this.localStorageName];\n },\n // ===========================================================================\n // File System\n // ===========================================================================\n saveToFile: function() {\n var fileName, jsonString;\n jsonString = this.save();\n fileName = this.project.editingElement.label + \".json\";\n return Storage.saveFile(jsonString, fileName, \"application/json;charset=utf-8\");\n },\n loadFromFile: function() {\n return Storage.loadFile((jsonString) => {\n return this.load(jsonString);\n });\n }\n});\n\n// ===========================================================================\n// External URL\n// ===========================================================================", "source_lang": "CoffeeScript", "target_lang": "JavaScript", "repo": "cdglabs/apparatus", "path": "src/Model/Editor.coffee", "license": "MIT", "commit": "197f7a87562a6de36185a768b3627749831d5c75", "stars": 1052, "source_url": "https://github.com/cdglabs/apparatus/blob/197f7a87562a6de36185a768b3627749831d5c75/src/Model/Editor.coffee", "line_start": 59, "line_end": 108}413{"id": "cdglabs/apparatus:src/Model/Editor.coffee:2:js_to_coffee", "type": "js_to_coffee", "prompt": "Convert this JavaScript to CoffeeScript.\n```javascript\n({\n save: function() {\n var json, jsonString;\n json = this.serializer.jsonify(this.project);\n json.type = \"Apparatus\";\n json.version = this.version;\n jsonString = JSON.stringify(json);\n return jsonString;\n },\n createNewProject: function() {\n return this.project = new Model.Project();\n },\n // ===========================================================================\n // Local Storage\n // ===========================================================================\n localStorageName: \"apparatus\",\n saveToLocalStorage: function() {\n var jsonString;\n jsonString = this.save();\n window.localStorage[this.localStorageName] = jsonString;\n return jsonString;\n },\n loadFromLocalStorage: function() {\n var jsonString;\n jsonString = window.localStorage[this.localStorageName];\n if (jsonString) {\n return this.load(jsonString);\n }\n },\n resetLocalStorage: function() {\n return delete window.localStorage[this.localStorageName];\n },\n // ===========================================================================\n // File System\n // ===========================================================================\n saveToFile: function() {\n var fileName, jsonString;\n jsonString = this.save();\n fileName = this.project.editingElement.label + \".json\";\n return Storage.saveFile(jsonString, fileName, \"application/json;charset=utf-8\");\n },\n loadFromFile: function() {\n return Storage.loadFile((jsonString) => {\n return this.load(jsonString);\n });\n }\n});\n\n// ===========================================================================\n// External URL\n// ===========================================================================\n```", "response": "save: ->\n json = @serializer.jsonify(@project)\n json.type = \"Apparatus\"\n json.version = @version\n jsonString = JSON.stringify(json)\n return jsonString\n\n createNewProject: ->\n @project = new Model.Project()\n\n\n # ===========================================================================\n # Local Storage\n # ===========================================================================\n\n localStorageName: \"apparatus\"\n\n saveToLocalStorage: ->\n jsonString = @save()\n window.localStorage[@localStorageName] = jsonString\n return jsonString\n\n loadFromLocalStorage: ->\n jsonString = window.localStorage[@localStorageName]\n if jsonString\n @load(jsonString)\n\n resetLocalStorage: ->\n delete window.localStorage[@localStorageName]\n\n\n # ===========================================================================\n # File System\n # ===========================================================================\n\n saveToFile: ->\n jsonString = @save()\n fileName = @project.editingElement.label + \".json\"\n Storage.saveFile(jsonString, fileName, \"application/json;charset=utf-8\")\n\n loadFromFile: ->\n Storage.loadFile (jsonString) =>\n @load(jsonString)\n\n\n # ===========================================================================\n # External URL\n # ===========================================================================", "source_lang": "JavaScript", "target_lang": "CoffeeScript", "repo": "cdglabs/apparatus", "path": "src/Model/Editor.coffee", "license": "MIT", "commit": "197f7a87562a6de36185a768b3627749831d5c75", "stars": 1052, "source_url": "https://github.com/cdglabs/apparatus/blob/197f7a87562a6de36185a768b3627749831d5c75/src/Model/Editor.coffee", "line_start": 59, "line_end": 108}414{"id": "cdglabs/apparatus:src/Model/Editor.coffee:2:completion", "type": "completion", "prompt": "save: ->\n json = @serializer.jsonify(@project)\n json.type = \"Apparatus\"\n json.version = @version\n jsonString = JSON.stringify(json)\n return jsonString\n\n createNewProject: ->\n @project = new Model.Project()\n\n\n # ===========================================================================\n # Local Storage\n # ===========================================================================\n\n localStorageName: \"apparatus\"\n\n saveToLocalStorage: ->\n jsonString = @save()\n window.localStorage[@localStorageName] = jsonString\n return jsonString\n\n loadFromLocalStorage: ->\n jsonString = window.localStorage[@localStorageName]", "response": "if jsonString\n @load(jsonString)\n\n resetLocalStorage: ->\n delete window.localStorage[@localStorageName]\n\n\n # ===========================================================================\n # File System\n # ===========================================================================\n\n saveToFile: ->\n jsonString = @save()\n fileName = @project.editingElement.label + \".json\"\n Storage.saveFile(jsonString, fileName, \"application/json;charset=utf-8\")\n\n loadFromFile: ->\n Storage.loadFile (jsonString) =>\n @load(jsonString)\n\n\n # ===========================================================================\n # External URL\n # ===========================================================================", "source_lang": "CoffeeScript", "target_lang": "CoffeeScript", "repo": "cdglabs/apparatus", "path": "src/Model/Editor.coffee", "license": "MIT", "commit": "197f7a87562a6de36185a768b3627749831d5c75", "stars": 1052, "source_url": "https://github.com/cdglabs/apparatus/blob/197f7a87562a6de36185a768b3627749831d5c75/src/Model/Editor.coffee", "line_start": 59, "line_end": 108}415{"id": "cdglabs/apparatus:src/Model/Editor.coffee:3:raw_corpus", "type": "raw_corpus", "prompt": "", "response": "# TODO: Deal with error conditions, timeout, etc.\n # TODO: Maybe move xhr stuff to Util.\n # TODO: Show some sort of loading indicator.\n loadFromURL: (url) ->\n xhr = new XMLHttpRequest()\n xhr.onreadystatechange = =>\n return unless xhr.readyState == 4\n return unless xhr.status == 200\n jsonString = xhr.responseText\n @load(jsonString)\n @checkpoint()\n Apparatus.refresh() # HACK: calling Apparatus seems funky here.\n xhr.open(\"GET\", url, true)\n xhr.send()\n\n\n # ===========================================================================\n # Revision History\n # ===========================================================================\n\n _setupRevision: ->\n # @current is a JSON string representing the current state. @undoStack and\n # @redoStack are arrays of such JSON strings.\n @current = @save()\n @undoStack = []\n @redoStack = []\n @maxUndoStackSize = 100\n\n checkpoint: ->\n jsonString = @saveToLocalStorage()\n return if @current == jsonString\n @undoStack.push(@current)\n if @undoStack.length > @maxUndoStackSize\n @undoStack.shift()\n @redoStack = []\n @current = jsonString\n\n undo: ->\n return unless @isUndoable()\n @redoStack.push(@current)\n @current = @undoStack.pop()\n @load(@current)\n @saveToLocalStorage()\n\n redo: ->\n return unless @isRedoable()\n @undoStack.push(@current)\n @current = @redoStack.pop()\n @load(@current)\n @saveToLocalStorage()", "source_lang": "", "target_lang": "CoffeeScript", "repo": "cdglabs/apparatus", "path": "src/Model/Editor.coffee", "license": "MIT", "commit": "197f7a87562a6de36185a768b3627749831d5c75", "stars": 1052, "source_url": "https://github.com/cdglabs/apparatus/blob/197f7a87562a6de36185a768b3627749831d5c75/src/Model/Editor.coffee", "line_start": 109, "line_end": 158}416{"id": "cdglabs/apparatus:src/Model/Editor.coffee:3:coffee_to_js", "type": "coffee_to_js", "prompt": "Convert this CoffeeScript to JavaScript.\n```coffeescript\n# TODO: Deal with error conditions, timeout, etc.\n # TODO: Maybe move xhr stuff to Util.\n # TODO: Show some sort of loading indicator.\n loadFromURL: (url) ->\n xhr = new XMLHttpRequest()\n xhr.onreadystatechange = =>\n return unless xhr.readyState == 4\n return unless xhr.status == 200\n jsonString = xhr.responseText\n @load(jsonString)\n @checkpoint()\n Apparatus.refresh() # HACK: calling Apparatus seems funky here.\n xhr.open(\"GET\", url, true)\n xhr.send()\n\n\n # ===========================================================================\n # Revision History\n # ===========================================================================\n\n _setupRevision: ->\n # @current is a JSON string representing the current state. @undoStack and\n # @redoStack are arrays of such JSON strings.\n @current = @save()\n @undoStack = []\n @redoStack = []\n @maxUndoStackSize = 100\n\n checkpoint: ->\n jsonString = @saveToLocalStorage()\n return if @current == jsonString\n @undoStack.push(@current)\n if @undoStack.length > @maxUndoStackSize\n @undoStack.shift()\n @redoStack = []\n @current = jsonString\n\n undo: ->\n return unless @isUndoable()\n @redoStack.push(@current)\n @current = @undoStack.pop()\n @load(@current)\n @saveToLocalStorage()\n\n redo: ->\n return unless @isRedoable()\n @undoStack.push(@current)\n @current = @redoStack.pop()\n @load(@current)\n @saveToLocalStorage()\n```", "response": "// TODO: Deal with error conditions, timeout, etc.\n// TODO: Maybe move xhr stuff to Util.\n// TODO: Show some sort of loading indicator.\n({\n loadFromURL: function(url) {\n var xhr;\n xhr = new XMLHttpRequest();\n xhr.onreadystatechange = () => {\n var jsonString;\n if (xhr.readyState !== 4) {\n return;\n }\n if (xhr.status !== 200) {\n return;\n }\n jsonString = xhr.responseText;\n this.load(jsonString);\n this.checkpoint();\n return Apparatus.refresh(); // HACK: calling Apparatus seems funky here.\n };\n xhr.open(\"GET\", url, true);\n return xhr.send();\n },\n // ===========================================================================\n // Revision History\n // ===========================================================================\n _setupRevision: function() {\n // @current is a JSON string representing the current state. @undoStack and\n // @redoStack are arrays of such JSON strings.\n this.current = this.save();\n this.undoStack = [];\n this.redoStack = [];\n return this.maxUndoStackSize = 100;\n },\n checkpoint: function() {\n var jsonString;\n jsonString = this.saveToLocalStorage();\n if (this.current === jsonString) {\n return;\n }\n this.undoStack.push(this.current);\n if (this.undoStack.length > this.maxUndoStackSize) {\n this.undoStack.shift();\n }\n this.redoStack = [];\n return this.current = jsonString;\n },\n undo: function() {\n if (!this.isUndoable()) {\n return;\n }\n this.redoStack.push(this.current);\n this.current = this.undoStack.pop();\n this.load(this.current);\n return this.saveToLocalStorage();\n },\n redo: function() {\n if (!this.isRedoable()) {\n return;\n }\n this.undoStack.push(this.current);\n this.current = this.redoStack.pop();\n this.load(this.current);\n return this.saveToLocalStorage();\n }\n});", "source_lang": "CoffeeScript", "target_lang": "JavaScript", "repo": "cdglabs/apparatus", "path": "src/Model/Editor.coffee", "license": "MIT", "commit": "197f7a87562a6de36185a768b3627749831d5c75", "stars": 1052, "source_url": "https://github.com/cdglabs/apparatus/blob/197f7a87562a6de36185a768b3627749831d5c75/src/Model/Editor.coffee", "line_start": 109, "line_end": 158}417{"id": "cdglabs/apparatus:src/Model/Editor.coffee:3:js_to_coffee", "type": "js_to_coffee", "prompt": "Convert this JavaScript to CoffeeScript.\n```javascript\n// TODO: Deal with error conditions, timeout, etc.\n// TODO: Maybe move xhr stuff to Util.\n// TODO: Show some sort of loading indicator.\n({\n loadFromURL: function(url) {\n var xhr;\n xhr = new XMLHttpRequest();\n xhr.onreadystatechange = () => {\n var jsonString;\n if (xhr.readyState !== 4) {\n return;\n }\n if (xhr.status !== 200) {\n return;\n }\n jsonString = xhr.responseText;\n this.load(jsonString);\n this.checkpoint();\n return Apparatus.refresh(); // HACK: calling Apparatus seems funky here.\n };\n xhr.open(\"GET\", url, true);\n return xhr.send();\n },\n // ===========================================================================\n // Revision History\n // ===========================================================================\n _setupRevision: function() {\n // @current is a JSON string representing the current state. @undoStack and\n // @redoStack are arrays of such JSON strings.\n this.current = this.save();\n this.undoStack = [];\n this.redoStack = [];\n return this.maxUndoStackSize = 100;\n },\n checkpoint: function() {\n var jsonString;\n jsonString = this.saveToLocalStorage();\n if (this.current === jsonString) {\n return;\n }\n this.undoStack.push(this.current);\n if (this.undoStack.length > this.maxUndoStackSize) {\n this.undoStack.shift();\n }\n this.redoStack = [];\n return this.current = jsonString;\n },\n undo: function() {\n if (!this.isUndoable()) {\n return;\n }\n this.redoStack.push(this.current);\n this.current = this.undoStack.pop();\n this.load(this.current);\n return this.saveToLocalStorage();\n },\n redo: function() {\n if (!this.isRedoable()) {\n return;\n }\n this.undoStack.push(this.current);\n this.current = this.redoStack.pop();\n this.load(this.current);\n return this.saveToLocalStorage();\n }\n});\n```", "response": "# TODO: Deal with error conditions, timeout, etc.\n # TODO: Maybe move xhr stuff to Util.\n # TODO: Show some sort of loading indicator.\n loadFromURL: (url) ->\n xhr = new XMLHttpRequest()\n xhr.onreadystatechange = =>\n return unless xhr.readyState == 4\n return unless xhr.status == 200\n jsonString = xhr.responseText\n @load(jsonString)\n @checkpoint()\n Apparatus.refresh() # HACK: calling Apparatus seems funky here.\n xhr.open(\"GET\", url, true)\n xhr.send()\n\n\n # ===========================================================================\n # Revision History\n # ===========================================================================\n\n _setupRevision: ->\n # @current is a JSON string representing the current state. @undoStack and\n # @redoStack are arrays of such JSON strings.\n @current = @save()\n @undoStack = []\n @redoStack = []\n @maxUndoStackSize = 100\n\n checkpoint: ->\n jsonString = @saveToLocalStorage()\n return if @current == jsonString\n @undoStack.push(@current)\n if @undoStack.length > @maxUndoStackSize\n @undoStack.shift()\n @redoStack = []\n @current = jsonString\n\n undo: ->\n return unless @isUndoable()\n @redoStack.push(@current)\n @current = @undoStack.pop()\n @load(@current)\n @saveToLocalStorage()\n\n redo: ->\n return unless @isRedoable()\n @undoStack.push(@current)\n @current = @redoStack.pop()\n @load(@current)\n @saveToLocalStorage()", "source_lang": "JavaScript", "target_lang": "CoffeeScript", "repo": "cdglabs/apparatus", "path": "src/Model/Editor.coffee", "license": "MIT", "commit": "197f7a87562a6de36185a768b3627749831d5c75", "stars": 1052, "source_url": "https://github.com/cdglabs/apparatus/blob/197f7a87562a6de36185a768b3627749831d5c75/src/Model/Editor.coffee", "line_start": 109, "line_end": 158}418{"id": "cdglabs/apparatus:src/Model/Editor.coffee:3:completion", "type": "completion", "prompt": "# TODO: Deal with error conditions, timeout, etc.\n # TODO: Maybe move xhr stuff to Util.\n # TODO: Show some sort of loading indicator.\n loadFromURL: (url) ->\n xhr = new XMLHttpRequest()\n xhr.onreadystatechange = =>\n return unless xhr.readyState == 4\n return unless xhr.status == 200\n jsonString = xhr.responseText\n @load(jsonString)\n @checkpoint()\n Apparatus.refresh() # HACK: calling Apparatus seems funky here.\n xhr.open(\"GET\", url, true)\n xhr.send()\n\n\n # ===========================================================================\n # Revision History\n # ===========================================================================\n\n _setupRevision: ->\n # @current is a JSON string representing the current state. @undoStack and\n # @redoStack are arrays of such JSON strings.\n @current = @save()\n @undoStack = []", "response": "@redoStack = []\n @maxUndoStackSize = 100\n\n checkpoint: ->\n jsonString = @saveToLocalStorage()\n return if @current == jsonString\n @undoStack.push(@current)\n if @undoStack.length > @maxUndoStackSize\n @undoStack.shift()\n @redoStack = []\n @current = jsonString\n\n undo: ->\n return unless @isUndoable()\n @redoStack.push(@current)\n @current = @undoStack.pop()\n @load(@current)\n @saveToLocalStorage()\n\n redo: ->\n return unless @isRedoable()\n @undoStack.push(@current)\n @current = @redoStack.pop()\n @load(@current)\n @saveToLocalStorage()", "source_lang": "CoffeeScript", "target_lang": "CoffeeScript", "repo": "cdglabs/apparatus", "path": "src/Model/Editor.coffee", "license": "MIT", "commit": "197f7a87562a6de36185a768b3627749831d5c75", "stars": 1052, "source_url": "https://github.com/cdglabs/apparatus/blob/197f7a87562a6de36185a768b3627749831d5c75/src/Model/Editor.coffee", "line_start": 109, "line_end": 158}419{"id": "cdglabs/apparatus:src/Model/Editor.coffee:4:raw_corpus", "type": "raw_corpus", "prompt": "", "response": "isUndoable: ->\n return @undoStack.length > 0\n\n isRedoable: ->\n return @redoStack.length > 0", "source_lang": "", "target_lang": "CoffeeScript", "repo": "cdglabs/apparatus", "path": "src/Model/Editor.coffee", "license": "MIT", "commit": "197f7a87562a6de36185a768b3627749831d5c75", "stars": 1052, "source_url": "https://github.com/cdglabs/apparatus/blob/197f7a87562a6de36185a768b3627749831d5c75/src/Model/Editor.coffee", "line_start": 159, "line_end": 164}420{"id": "cdglabs/apparatus:src/Model/Editor.coffee:4:coffee_to_js", "type": "coffee_to_js", "prompt": "Convert this CoffeeScript to JavaScript.\n```coffeescript\nisUndoable: ->\n return @undoStack.length > 0\n\n isRedoable: ->\n return @redoStack.length > 0\n```", "response": "({\n isUndoable: function() {\n return this.undoStack.length > 0;\n },\n isRedoable: function() {\n return this.redoStack.length > 0;\n }\n});", "source_lang": "CoffeeScript", "target_lang": "JavaScript", "repo": "cdglabs/apparatus", "path": "src/Model/Editor.coffee", "license": "MIT", "commit": "197f7a87562a6de36185a768b3627749831d5c75", "stars": 1052, "source_url": "https://github.com/cdglabs/apparatus/blob/197f7a87562a6de36185a768b3627749831d5c75/src/Model/Editor.coffee", "line_start": 159, "line_end": 164}421{"id": "cdglabs/apparatus:src/Model/Editor.coffee:4:js_to_coffee", "type": "js_to_coffee", "prompt": "Convert this JavaScript to CoffeeScript.\n```javascript\n({\n isUndoable: function() {\n return this.undoStack.length > 0;\n },\n isRedoable: function() {\n return this.redoStack.length > 0;\n }\n});\n```", "response": "isUndoable: ->\n return @undoStack.length > 0\n\n isRedoable: ->\n return @redoStack.length > 0", "source_lang": "JavaScript", "target_lang": "CoffeeScript", "repo": "cdglabs/apparatus", "path": "src/Model/Editor.coffee", "license": "MIT", "commit": "197f7a87562a6de36185a768b3627749831d5c75", "stars": 1052, "source_url": "https://github.com/cdglabs/apparatus/blob/197f7a87562a6de36185a768b3627749831d5c75/src/Model/Editor.coffee", "line_start": 159, "line_end": 164}422{"id": "cdglabs/apparatus:src/Model/Editor.coffee:4:completion", "type": "completion", "prompt": "isUndoable: ->\n return @undoStack.length > 0", "response": "isRedoable: ->\n return @redoStack.length > 0", "source_lang": "CoffeeScript", "target_lang": "CoffeeScript", "repo": "cdglabs/apparatus", "path": "src/Model/Editor.coffee", "license": "MIT", "commit": "197f7a87562a6de36185a768b3627749831d5c75", "stars": 1052, "source_url": "https://github.com/cdglabs/apparatus/blob/197f7a87562a6de36185a768b3627749831d5c75/src/Model/Editor.coffee", "line_start": 159, "line_end": 164}423{"id": "cdglabs/apparatus:src/Model/Editor.coffee:1:raw_corpus", "type": "raw_corpus", "prompt": "", "response": "module.exports = class Editor\n constructor: ->\n @_setupLayout()\n @_setupSerializer()\n @_setupProject()\n @_setupRevision()\n @_parseQueryString()\n\n _setupLayout: ->\n @layout = { rightPanelWidth: 400 }\n\n _setupProject: ->\n @loadFromLocalStorage()\n if !@project\n @createNewProject()\n\n _setupSerializer: ->\n builtInObjects = []\n for own name, object of @_builtIn()\n if _.isFunction(object)\n object = object.prototype\n Util.assignId(object, name)\n builtInObjects.push(object)\n @serializer = new Storage.Serializer(builtInObjects)\n\n # Checks if we should load an external JSON file based on the query string\n # (the ?stuff at the end of the URL).\n _parseQueryString: ->\n parsed = queryString.parse(location.search)\n if parsed.load\n @loadFromURL(parsed.load)\n\n # builtIn returns all of the built in classes and objects that are used as\n # the \"anchors\" for serialization and deserialization. That is, all of the\n # objects and classes which should not themselves be serialized but instead\n # be *referenced* from a serialization. When deserialized, these references\n # are then bound appropriately.\n _builtIn: ->\n builtIn = _.clone(Model)\n builtIn[\"SpreadEnv\"] = Dataflow.SpreadEnv\n builtIn[\"Matrix\"] = Util.Matrix\n return builtIn\n\n # TODO: get version via build process / ENV variable?\n version: \"0.4.0\"\n\n load: (jsonString) ->\n json = JSON.parse(jsonString)\n if json.type == \"Apparatus\" and json.version == @version\n @project = @serializer.dejsonify(json)", "source_lang": "", "target_lang": "CoffeeScript", "repo": "cdglabs/apparatus", "path": "src/Model/Editor.coffee", "license": "MIT", "commit": "c07e280ab05c9576a00549820e25b0f8383f0024", "stars": 1052, "source_url": "https://github.com/cdglabs/apparatus/blob/c07e280ab05c9576a00549820e25b0f8383f0024/src/Model/Editor.coffee", "line_start": 9, "line_end": 58}424{"id": "cdglabs/apparatus:src/Model/Editor.coffee:1:coffee_to_js", "type": "coffee_to_js", "prompt": "Convert this CoffeeScript to JavaScript.\n```coffeescript\nmodule.exports = class Editor\n constructor: ->\n @_setupLayout()\n @_setupSerializer()\n @_setupProject()\n @_setupRevision()\n @_parseQueryString()\n\n _setupLayout: ->\n @layout = { rightPanelWidth: 400 }\n\n _setupProject: ->\n @loadFromLocalStorage()\n if !@project\n @createNewProject()\n\n _setupSerializer: ->\n builtInObjects = []\n for own name, object of @_builtIn()\n if _.isFunction(object)\n object = object.prototype\n Util.assignId(object, name)\n builtInObjects.push(object)\n @serializer = new Storage.Serializer(builtInObjects)\n\n # Checks if we should load an external JSON file based on the query string\n # (the ?stuff at the end of the URL).\n _parseQueryString: ->\n parsed = queryString.parse(location.search)\n if parsed.load\n @loadFromURL(parsed.load)\n\n # builtIn returns all of the built in classes and objects that are used as\n # the \"anchors\" for serialization and deserialization. That is, all of the\n # objects and classes which should not themselves be serialized but instead\n # be *referenced* from a serialization. When deserialized, these references\n # are then bound appropriately.\n _builtIn: ->\n builtIn = _.clone(Model)\n builtIn[\"SpreadEnv\"] = Dataflow.SpreadEnv\n builtIn[\"Matrix\"] = Util.Matrix\n return builtIn\n\n # TODO: get version via build process / ENV variable?\n version: \"0.4.0\"\n\n load: (jsonString) ->\n json = JSON.parse(jsonString)\n if json.type == \"Apparatus\" and json.version == @version\n @project = @serializer.dejsonify(json)\n```", "response": "var Editor,\n hasProp = {}.hasOwnProperty;\n\nmodule.exports = Editor = (function() {\n class Editor {\n constructor() {\n this._setupLayout();\n this._setupSerializer();\n this._setupProject();\n this._setupRevision();\n this._parseQueryString();\n }\n\n _setupLayout() {\n return this.layout = {\n rightPanelWidth: 400\n };\n }\n\n _setupProject() {\n this.loadFromLocalStorage();\n if (!this.project) {\n return this.createNewProject();\n }\n }\n\n _setupSerializer() {\n var builtInObjects, name, object, ref;\n builtInObjects = [];\n ref = this._builtIn();\n for (name in ref) {\n if (!hasProp.call(ref, name)) continue;\n object = ref[name];\n if (_.isFunction(object)) {\n object = object.prototype;\n }\n Util.assignId(object, name);\n builtInObjects.push(object);\n }\n return this.serializer = new Storage.Serializer(builtInObjects);\n }\n\n // Checks if we should load an external JSON file based on the query string\n // (the ?stuff at the end of the URL).\n _parseQueryString() {\n var parsed;\n parsed = queryString.parse(location.search);\n if (parsed.load) {\n return this.loadFromURL(parsed.load);\n }\n }\n\n // builtIn returns all of the built in classes and objects that are used as\n // the \"anchors\" for serialization and deserialization. That is, all of the\n // objects and classes which should not themselves be serialized but instead\n // be *referenced* from a serialization. When deserialized, these references\n // are then bound appropriately.\n _builtIn() {\n var builtIn;\n builtIn = _.clone(Model);\n builtIn[\"SpreadEnv\"] = Dataflow.SpreadEnv;\n builtIn[\"Matrix\"] = Util.Matrix;\n return builtIn;\n }\n\n load(jsonString) {\n var json;\n json = JSON.parse(jsonString);\n if (json.type === \"Apparatus\" && json.version === this.version) {\n return this.project = this.serializer.dejsonify(json);\n }\n }\n\n };\n\n // TODO: get version via build process / ENV variable?\n Editor.prototype.version = \"0.4.0\";\n\n return Editor;\n\n}).call(this);", "source_lang": "CoffeeScript", "target_lang": "JavaScript", "repo": "cdglabs/apparatus", "path": "src/Model/Editor.coffee", "license": "MIT", "commit": "c07e280ab05c9576a00549820e25b0f8383f0024", "stars": 1052, "source_url": "https://github.com/cdglabs/apparatus/blob/c07e280ab05c9576a00549820e25b0f8383f0024/src/Model/Editor.coffee", "line_start": 9, "line_end": 58}425{"id": "cdglabs/apparatus:src/Model/Editor.coffee:1:js_to_coffee", "type": "js_to_coffee", "prompt": "Convert this JavaScript to CoffeeScript.\n```javascript\nvar Editor,\n hasProp = {}.hasOwnProperty;\n\nmodule.exports = Editor = (function() {\n class Editor {\n constructor() {\n this._setupLayout();\n this._setupSerializer();\n this._setupProject();\n this._setupRevision();\n this._parseQueryString();\n }\n\n _setupLayout() {\n return this.layout = {\n rightPanelWidth: 400\n };\n }\n\n _setupProject() {\n this.loadFromLocalStorage();\n if (!this.project) {\n return this.createNewProject();\n }\n }\n\n _setupSerializer() {\n var builtInObjects, name, object, ref;\n builtInObjects = [];\n ref = this._builtIn();\n for (name in ref) {\n if (!hasProp.call(ref, name)) continue;\n object = ref[name];\n if (_.isFunction(object)) {\n object = object.prototype;\n }\n Util.assignId(object, name);\n builtInObjects.push(object);\n }\n return this.serializer = new Storage.Serializer(builtInObjects);\n }\n\n // Checks if we should load an external JSON file based on the query string\n // (the ?stuff at the end of the URL).\n _parseQueryString() {\n var parsed;\n parsed = queryString.parse(location.search);\n if (parsed.load) {\n return this.loadFromURL(parsed.load);\n }\n }\n\n // builtIn returns all of the built in classes and objects that are used as\n // the \"anchors\" for serialization and deserialization. That is, all of the\n // objects and classes which should not themselves be serialized but instead\n // be *referenced* from a serialization. When deserialized, these references\n // are then bound appropriately.\n _builtIn() {\n var builtIn;\n builtIn = _.clone(Model);\n builtIn[\"SpreadEnv\"] = Dataflow.SpreadEnv;\n builtIn[\"Matrix\"] = Util.Matrix;\n return builtIn;\n }\n\n load(jsonString) {\n var json;\n json = JSON.parse(jsonString);\n if (json.type === \"Apparatus\" && json.version === this.version) {\n return this.project = this.serializer.dejsonify(json);\n }\n }\n\n };\n\n // TODO: get version via build process / ENV variable?\n Editor.prototype.version = \"0.4.0\";\n\n return Editor;\n\n}).call(this);\n```", "response": "module.exports = class Editor\n constructor: ->\n @_setupLayout()\n @_setupSerializer()\n @_setupProject()\n @_setupRevision()\n @_parseQueryString()\n\n _setupLayout: ->\n @layout = { rightPanelWidth: 400 }\n\n _setupProject: ->\n @loadFromLocalStorage()\n if !@project\n @createNewProject()\n\n _setupSerializer: ->\n builtInObjects = []\n for own name, object of @_builtIn()\n if _.isFunction(object)\n object = object.prototype\n Util.assignId(object, name)\n builtInObjects.push(object)\n @serializer = new Storage.Serializer(builtInObjects)\n\n # Checks if we should load an external JSON file based on the query string\n # (the ?stuff at the end of the URL).\n _parseQueryString: ->\n parsed = queryString.parse(location.search)\n if parsed.load\n @loadFromURL(parsed.load)\n\n # builtIn returns all of the built in classes and objects that are used as\n # the \"anchors\" for serialization and deserialization. That is, all of the\n # objects and classes which should not themselves be serialized but instead\n # be *referenced* from a serialization. When deserialized, these references\n # are then bound appropriately.\n _builtIn: ->\n builtIn = _.clone(Model)\n builtIn[\"SpreadEnv\"] = Dataflow.SpreadEnv\n builtIn[\"Matrix\"] = Util.Matrix\n return builtIn\n\n # TODO: get version via build process / ENV variable?\n version: \"0.4.0\"\n\n load: (jsonString) ->\n json = JSON.parse(jsonString)\n if json.type == \"Apparatus\" and json.version == @version\n @project = @serializer.dejsonify(json)", "source_lang": "JavaScript", "target_lang": "CoffeeScript", "repo": "cdglabs/apparatus", "path": "src/Model/Editor.coffee", "license": "MIT", "commit": "c07e280ab05c9576a00549820e25b0f8383f0024", "stars": 1052, "source_url": "https://github.com/cdglabs/apparatus/blob/c07e280ab05c9576a00549820e25b0f8383f0024/src/Model/Editor.coffee", "line_start": 9, "line_end": 58}426{"id": "cdglabs/apparatus:src/Model/Editor.coffee:1:completion", "type": "completion", "prompt": "module.exports = class Editor\n constructor: ->\n @_setupLayout()\n @_setupSerializer()\n @_setupProject()\n @_setupRevision()\n @_parseQueryString()\n\n _setupLayout: ->\n @layout = { rightPanelWidth: 400 }\n\n _setupProject: ->\n @loadFromLocalStorage()\n if !@project\n @createNewProject()\n\n _setupSerializer: ->\n builtInObjects = []\n for own name, object of @_builtIn()\n if _.isFunction(object)\n object = object.prototype\n Util.assignId(object, name)\n builtInObjects.push(object)\n @serializer = new Storage.Serializer(builtInObjects)", "response": "# Checks if we should load an external JSON file based on the query string\n # (the ?stuff at the end of the URL).\n _parseQueryString: ->\n parsed = queryString.parse(location.search)\n if parsed.load\n @loadFromURL(parsed.load)\n\n # builtIn returns all of the built in classes and objects that are used as\n # the \"anchors\" for serialization and deserialization. That is, all of the\n # objects and classes which should not themselves be serialized but instead\n # be *referenced* from a serialization. When deserialized, these references\n # are then bound appropriately.\n _builtIn: ->\n builtIn = _.clone(Model)\n builtIn[\"SpreadEnv\"] = Dataflow.SpreadEnv\n builtIn[\"Matrix\"] = Util.Matrix\n return builtIn\n\n # TODO: get version via build process / ENV variable?\n version: \"0.4.0\"\n\n load: (jsonString) ->\n json = JSON.parse(jsonString)\n if json.type == \"Apparatus\" and json.version == @version\n @project = @serializer.dejsonify(json)", "source_lang": "CoffeeScript", "target_lang": "CoffeeScript", "repo": "cdglabs/apparatus", "path": "src/Model/Editor.coffee", "license": "MIT", "commit": "c07e280ab05c9576a00549820e25b0f8383f0024", "stars": 1052, "source_url": "https://github.com/cdglabs/apparatus/blob/c07e280ab05c9576a00549820e25b0f8383f0024/src/Model/Editor.coffee", "line_start": 9, "line_end": 58}427{"id": "cdglabs/apparatus:src/Model/Editor.coffee:1:raw_corpus", "type": "raw_corpus", "prompt": "", "response": "module.exports = class Editor\n constructor: ->\n @_setupSerializer()\n @_setupProject()\n @_setupRevision()\n @_parseQueryString()\n\n _setupProject: ->\n @loadFromLocalStorage()\n if !@project\n @createNewProject()\n\n _setupSerializer: ->\n builtInObjects = []\n for own name, object of @_builtIn()\n if _.isFunction(object)\n object = object.prototype\n Util.assignId(object, name)\n builtInObjects.push(object)\n @serializer = new Storage.Serializer(builtInObjects)\n\n # Checks if we should load an external JSON file based on the query string\n # (the ?stuff at the end of the URL).\n _parseQueryString: ->\n parsed = queryString.parse(location.search)\n if parsed.load\n @loadFromURL(parsed.load)\n\n # builtIn returns all of the built in classes and objects that are used as\n # the \"anchors\" for serialization and deserialization. That is, all of the\n # objects and classes which should not themselves be serialized but instead\n # be *referenced* from a serialization. When deserialized, these references\n # are then bound appropriately.\n _builtIn: ->\n builtIn = _.clone(Model)\n builtIn[\"SpreadEnv\"] = Dataflow.SpreadEnv\n builtIn[\"Matrix\"] = Util.Matrix\n return builtIn\n\n # TODO: get version via build process / ENV variable?\n version: \"0.4.0\"\n\n load: (jsonString) ->\n json = JSON.parse(jsonString)\n if json.type == \"Apparatus\" and json.version == @version\n @project = @serializer.dejsonify(json)\n\n save: ->\n json = @serializer.jsonify(@project)\n json.type = \"Apparatus\"", "source_lang": "", "target_lang": "CoffeeScript", "repo": "cdglabs/apparatus", "path": "src/Model/Editor.coffee", "license": "MIT", "commit": "78d3d0bd60324c54fb3594489ce6317ca27081a2", "stars": 1052, "source_url": "https://github.com/cdglabs/apparatus/blob/78d3d0bd60324c54fb3594489ce6317ca27081a2/src/Model/Editor.coffee", "line_start": 9, "line_end": 58}428{"id": "cdglabs/apparatus:src/Model/Editor.coffee:1:coffee_to_js", "type": "coffee_to_js", "prompt": "Convert this CoffeeScript to JavaScript.\n```coffeescript\nmodule.exports = class Editor\n constructor: ->\n @_setupSerializer()\n @_setupProject()\n @_setupRevision()\n @_parseQueryString()\n\n _setupProject: ->\n @loadFromLocalStorage()\n if !@project\n @createNewProject()\n\n _setupSerializer: ->\n builtInObjects = []\n for own name, object of @_builtIn()\n if _.isFunction(object)\n object = object.prototype\n Util.assignId(object, name)\n builtInObjects.push(object)\n @serializer = new Storage.Serializer(builtInObjects)\n\n # Checks if we should load an external JSON file based on the query string\n # (the ?stuff at the end of the URL).\n _parseQueryString: ->\n parsed = queryString.parse(location.search)\n if parsed.load\n @loadFromURL(parsed.load)\n\n # builtIn returns all of the built in classes and objects that are used as\n # the \"anchors\" for serialization and deserialization. That is, all of the\n # objects and classes which should not themselves be serialized but instead\n # be *referenced* from a serialization. When deserialized, these references\n # are then bound appropriately.\n _builtIn: ->\n builtIn = _.clone(Model)\n builtIn[\"SpreadEnv\"] = Dataflow.SpreadEnv\n builtIn[\"Matrix\"] = Util.Matrix\n return builtIn\n\n # TODO: get version via build process / ENV variable?\n version: \"0.4.0\"\n\n load: (jsonString) ->\n json = JSON.parse(jsonString)\n if json.type == \"Apparatus\" and json.version == @version\n @project = @serializer.dejsonify(json)\n\n save: ->\n json = @serializer.jsonify(@project)\n json.type = \"Apparatus\"\n```", "response": "var Editor,\n hasProp = {}.hasOwnProperty;\n\nmodule.exports = Editor = (function() {\n class Editor {\n constructor() {\n this._setupSerializer();\n this._setupProject();\n this._setupRevision();\n this._parseQueryString();\n }\n\n _setupProject() {\n this.loadFromLocalStorage();\n if (!this.project) {\n return this.createNewProject();\n }\n }\n\n _setupSerializer() {\n var builtInObjects, name, object, ref;\n builtInObjects = [];\n ref = this._builtIn();\n for (name in ref) {\n if (!hasProp.call(ref, name)) continue;\n object = ref[name];\n if (_.isFunction(object)) {\n object = object.prototype;\n }\n Util.assignId(object, name);\n builtInObjects.push(object);\n }\n return this.serializer = new Storage.Serializer(builtInObjects);\n }\n\n // Checks if we should load an external JSON file based on the query string\n // (the ?stuff at the end of the URL).\n _parseQueryString() {\n var parsed;\n parsed = queryString.parse(location.search);\n if (parsed.load) {\n return this.loadFromURL(parsed.load);\n }\n }\n\n // builtIn returns all of the built in classes and objects that are used as\n // the \"anchors\" for serialization and deserialization. That is, all of the\n // objects and classes which should not themselves be serialized but instead\n // be *referenced* from a serialization. When deserialized, these references\n // are then bound appropriately.\n _builtIn() {\n var builtIn;\n builtIn = _.clone(Model);\n builtIn[\"SpreadEnv\"] = Dataflow.SpreadEnv;\n builtIn[\"Matrix\"] = Util.Matrix;\n return builtIn;\n }\n\n load(jsonString) {\n var json;\n json = JSON.parse(jsonString);\n if (json.type === \"Apparatus\" && json.version === this.version) {\n return this.project = this.serializer.dejsonify(json);\n }\n }\n\n save() {\n var json;\n json = this.serializer.jsonify(this.project);\n return json.type = \"Apparatus\";\n }\n\n };\n\n // TODO: get version via build process / ENV variable?\n Editor.prototype.version = \"0.4.0\";\n\n return Editor;\n\n}).call(this);", "source_lang": "CoffeeScript", "target_lang": "JavaScript", "repo": "cdglabs/apparatus", "path": "src/Model/Editor.coffee", "license": "MIT", "commit": "78d3d0bd60324c54fb3594489ce6317ca27081a2", "stars": 1052, "source_url": "https://github.com/cdglabs/apparatus/blob/78d3d0bd60324c54fb3594489ce6317ca27081a2/src/Model/Editor.coffee", "line_start": 9, "line_end": 58}429{"id": "cdglabs/apparatus:src/Model/Editor.coffee:1:js_to_coffee", "type": "js_to_coffee", "prompt": "Convert this JavaScript to CoffeeScript.\n```javascript\nvar Editor,\n hasProp = {}.hasOwnProperty;\n\nmodule.exports = Editor = (function() {\n class Editor {\n constructor() {\n this._setupSerializer();\n this._setupProject();\n this._setupRevision();\n this._parseQueryString();\n }\n\n _setupProject() {\n this.loadFromLocalStorage();\n if (!this.project) {\n return this.createNewProject();\n }\n }\n\n _setupSerializer() {\n var builtInObjects, name, object, ref;\n builtInObjects = [];\n ref = this._builtIn();\n for (name in ref) {\n if (!hasProp.call(ref, name)) continue;\n object = ref[name];\n if (_.isFunction(object)) {\n object = object.prototype;\n }\n Util.assignId(object, name);\n builtInObjects.push(object);\n }\n return this.serializer = new Storage.Serializer(builtInObjects);\n }\n\n // Checks if we should load an external JSON file based on the query string\n // (the ?stuff at the end of the URL).\n _parseQueryString() {\n var parsed;\n parsed = queryString.parse(location.search);\n if (parsed.load) {\n return this.loadFromURL(parsed.load);\n }\n }\n\n // builtIn returns all of the built in classes and objects that are used as\n // the \"anchors\" for serialization and deserialization. That is, all of the\n // objects and classes which should not themselves be serialized but instead\n // be *referenced* from a serialization. When deserialized, these references\n // are then bound appropriately.\n _builtIn() {\n var builtIn;\n builtIn = _.clone(Model);\n builtIn[\"SpreadEnv\"] = Dataflow.SpreadEnv;\n builtIn[\"Matrix\"] = Util.Matrix;\n return builtIn;\n }\n\n load(jsonString) {\n var json;\n json = JSON.parse(jsonString);\n if (json.type === \"Apparatus\" && json.version === this.version) {\n return this.project = this.serializer.dejsonify(json);\n }\n }\n\n save() {\n var json;\n json = this.serializer.jsonify(this.project);\n return json.type = \"Apparatus\";\n }\n\n };\n\n // TODO: get version via build process / ENV variable?\n Editor.prototype.version = \"0.4.0\";\n\n return Editor;\n\n}).call(this);\n```", "response": "module.exports = class Editor\n constructor: ->\n @_setupSerializer()\n @_setupProject()\n @_setupRevision()\n @_parseQueryString()\n\n _setupProject: ->\n @loadFromLocalStorage()\n if !@project\n @createNewProject()\n\n _setupSerializer: ->\n builtInObjects = []\n for own name, object of @_builtIn()\n if _.isFunction(object)\n object = object.prototype\n Util.assignId(object, name)\n builtInObjects.push(object)\n @serializer = new Storage.Serializer(builtInObjects)\n\n # Checks if we should load an external JSON file based on the query string\n # (the ?stuff at the end of the URL).\n _parseQueryString: ->\n parsed = queryString.parse(location.search)\n if parsed.load\n @loadFromURL(parsed.load)\n\n # builtIn returns all of the built in classes and objects that are used as\n # the \"anchors\" for serialization and deserialization. That is, all of the\n # objects and classes which should not themselves be serialized but instead\n # be *referenced* from a serialization. When deserialized, these references\n # are then bound appropriately.\n _builtIn: ->\n builtIn = _.clone(Model)\n builtIn[\"SpreadEnv\"] = Dataflow.SpreadEnv\n builtIn[\"Matrix\"] = Util.Matrix\n return builtIn\n\n # TODO: get version via build process / ENV variable?\n version: \"0.4.0\"\n\n load: (jsonString) ->\n json = JSON.parse(jsonString)\n if json.type == \"Apparatus\" and json.version == @version\n @project = @serializer.dejsonify(json)\n\n save: ->\n json = @serializer.jsonify(@project)\n json.type = \"Apparatus\"", "source_lang": "JavaScript", "target_lang": "CoffeeScript", "repo": "cdglabs/apparatus", "path": "src/Model/Editor.coffee", "license": "MIT", "commit": "78d3d0bd60324c54fb3594489ce6317ca27081a2", "stars": 1052, "source_url": "https://github.com/cdglabs/apparatus/blob/78d3d0bd60324c54fb3594489ce6317ca27081a2/src/Model/Editor.coffee", "line_start": 9, "line_end": 58}430{"id": "cdglabs/apparatus:src/Model/Editor.coffee:1:completion", "type": "completion", "prompt": "module.exports = class Editor\n constructor: ->\n @_setupSerializer()\n @_setupProject()\n @_setupRevision()\n @_parseQueryString()\n\n _setupProject: ->\n @loadFromLocalStorage()\n if !@project\n @createNewProject()\n\n _setupSerializer: ->\n builtInObjects = []\n for own name, object of @_builtIn()\n if _.isFunction(object)\n object = object.prototype\n Util.assignId(object, name)\n builtInObjects.push(object)\n @serializer = new Storage.Serializer(builtInObjects)\n\n # Checks if we should load an external JSON file based on the query string\n # (the ?stuff at the end of the URL).\n _parseQueryString: ->\n parsed = queryString.parse(location.search)", "response": "if parsed.load\n @loadFromURL(parsed.load)\n\n # builtIn returns all of the built in classes and objects that are used as\n # the \"anchors\" for serialization and deserialization. That is, all of the\n # objects and classes which should not themselves be serialized but instead\n # be *referenced* from a serialization. When deserialized, these references\n # are then bound appropriately.\n _builtIn: ->\n builtIn = _.clone(Model)\n builtIn[\"SpreadEnv\"] = Dataflow.SpreadEnv\n builtIn[\"Matrix\"] = Util.Matrix\n return builtIn\n\n # TODO: get version via build process / ENV variable?\n version: \"0.4.0\"\n\n load: (jsonString) ->\n json = JSON.parse(jsonString)\n if json.type == \"Apparatus\" and json.version == @version\n @project = @serializer.dejsonify(json)\n\n save: ->\n json = @serializer.jsonify(@project)\n json.type = \"Apparatus\"", "source_lang": "CoffeeScript", "target_lang": "CoffeeScript", "repo": "cdglabs/apparatus", "path": "src/Model/Editor.coffee", "license": "MIT", "commit": "78d3d0bd60324c54fb3594489ce6317ca27081a2", "stars": 1052, "source_url": "https://github.com/cdglabs/apparatus/blob/78d3d0bd60324c54fb3594489ce6317ca27081a2/src/Model/Editor.coffee", "line_start": 9, "line_end": 58}431{"id": "cdglabs/apparatus:src/Model/Editor.coffee:2:raw_corpus", "type": "raw_corpus", "prompt": "", "response": "json.version = @version\n jsonString = JSON.stringify(json)\n return jsonString\n\n createNewProject: ->\n @project = new Model.Project()\n\n\n # ===========================================================================\n # Local Storage\n # ===========================================================================\n\n localStorageName: \"apparatus\"\n\n saveToLocalStorage: ->\n jsonString = @save()\n window.localStorage[@localStorageName] = jsonString\n return jsonString\n\n loadFromLocalStorage: ->\n jsonString = window.localStorage[@localStorageName]\n if jsonString\n @load(jsonString)\n\n resetLocalStorage: ->\n delete window.localStorage[@localStorageName]\n\n\n # ===========================================================================\n # File System\n # ===========================================================================\n\n saveToFile: ->\n jsonString = @save()\n fileName = @project.editingElement.label + \".json\"\n Storage.saveFile(jsonString, fileName, \"application/json;charset=utf-8\")\n\n loadFromFile: ->\n Storage.loadFile (jsonString) =>\n @load(jsonString)\n\n\n # ===========================================================================\n # External URL\n # ===========================================================================\n\n # TODO: Deal with error conditions, timeout, etc.\n # TODO: Maybe move xhr stuff to Util.\n # TODO: Show some sort of loading indicator.\n loadFromURL: (url) ->", "source_lang": "", "target_lang": "CoffeeScript", "repo": "cdglabs/apparatus", "path": "src/Model/Editor.coffee", "license": "MIT", "commit": "78d3d0bd60324c54fb3594489ce6317ca27081a2", "stars": 1052, "source_url": "https://github.com/cdglabs/apparatus/blob/78d3d0bd60324c54fb3594489ce6317ca27081a2/src/Model/Editor.coffee", "line_start": 59, "line_end": 108}432{"id": "cdglabs/apparatus:src/Model/Editor.coffee:2:completion", "type": "completion", "prompt": "json.version = @version\n jsonString = JSON.stringify(json)\n return jsonString\n\n createNewProject: ->\n @project = new Model.Project()\n\n\n # ===========================================================================\n # Local Storage\n # ===========================================================================\n\n localStorageName: \"apparatus\"\n\n saveToLocalStorage: ->\n jsonString = @save()\n window.localStorage[@localStorageName] = jsonString\n return jsonString\n\n loadFromLocalStorage: ->\n jsonString = window.localStorage[@localStorageName]\n if jsonString\n @load(jsonString)\n\n resetLocalStorage: ->", "response": "delete window.localStorage[@localStorageName]\n\n\n # ===========================================================================\n # File System\n # ===========================================================================\n\n saveToFile: ->\n jsonString = @save()\n fileName = @project.editingElement.label + \".json\"\n Storage.saveFile(jsonString, fileName, \"application/json;charset=utf-8\")\n\n loadFromFile: ->\n Storage.loadFile (jsonString) =>\n @load(jsonString)\n\n\n # ===========================================================================\n # External URL\n # ===========================================================================\n\n # TODO: Deal with error conditions, timeout, etc.\n # TODO: Maybe move xhr stuff to Util.\n # TODO: Show some sort of loading indicator.\n loadFromURL: (url) ->", "source_lang": "CoffeeScript", "target_lang": "CoffeeScript", "repo": "cdglabs/apparatus", "path": "src/Model/Editor.coffee", "license": "MIT", "commit": "78d3d0bd60324c54fb3594489ce6317ca27081a2", "stars": 1052, "source_url": "https://github.com/cdglabs/apparatus/blob/78d3d0bd60324c54fb3594489ce6317ca27081a2/src/Model/Editor.coffee", "line_start": 59, "line_end": 108}433{"id": "cdglabs/apparatus:src/Model/Editor.coffee:3:raw_corpus", "type": "raw_corpus", "prompt": "", "response": "xhr = new XMLHttpRequest()\n xhr.onreadystatechange = =>\n return unless xhr.readyState == 4\n return unless xhr.status == 200\n jsonString = xhr.responseText\n @load(jsonString)\n @checkpoint()\n Apparatus.refresh() # HACK: calling Apparatus seems funky here.\n xhr.open(\"GET\", url, true)\n xhr.send()\n\n\n # ===========================================================================\n # Revision History\n # ===========================================================================\n\n _setupRevision: ->\n # @current is a JSON string representing the current state. @undoStack and\n # @redoStack are arrays of such JSON strings.\n @current = @save()\n @undoStack = []\n @redoStack = []\n @maxUndoStackSize = 100\n\n checkpoint: ->\n jsonString = @saveToLocalStorage()\n return if @current == jsonString\n @undoStack.push(@current)\n if @undoStack.length > @maxUndoStackSize\n @undoStack.shift()\n @redoStack = []\n @current = jsonString\n\n undo: ->\n return unless @isUndoable()\n @redoStack.push(@current)\n @current = @undoStack.pop()\n @load(@current)\n @saveToLocalStorage()\n\n redo: ->\n return unless @isRedoable()\n @undoStack.push(@current)\n @current = @redoStack.pop()\n @load(@current)\n @saveToLocalStorage()\n\n isUndoable: ->\n return @undoStack.length > 0", "source_lang": "", "target_lang": "CoffeeScript", "repo": "cdglabs/apparatus", "path": "src/Model/Editor.coffee", "license": "MIT", "commit": "78d3d0bd60324c54fb3594489ce6317ca27081a2", "stars": 1052, "source_url": "https://github.com/cdglabs/apparatus/blob/78d3d0bd60324c54fb3594489ce6317ca27081a2/src/Model/Editor.coffee", "line_start": 109, "line_end": 158}434{"id": "cdglabs/apparatus:src/Model/Editor.coffee:3:completion", "type": "completion", "prompt": "xhr = new XMLHttpRequest()\n xhr.onreadystatechange = =>\n return unless xhr.readyState == 4\n return unless xhr.status == 200\n jsonString = xhr.responseText\n @load(jsonString)\n @checkpoint()\n Apparatus.refresh() # HACK: calling Apparatus seems funky here.\n xhr.open(\"GET\", url, true)\n xhr.send()\n\n\n # ===========================================================================\n # Revision History\n # ===========================================================================\n\n _setupRevision: ->\n # @current is a JSON string representing the current state. @undoStack and\n # @redoStack are arrays of such JSON strings.\n @current = @save()\n @undoStack = []\n @redoStack = []\n @maxUndoStackSize = 100", "response": "checkpoint: ->\n jsonString = @saveToLocalStorage()\n return if @current == jsonString\n @undoStack.push(@current)\n if @undoStack.length > @maxUndoStackSize\n @undoStack.shift()\n @redoStack = []\n @current = jsonString\n\n undo: ->\n return unless @isUndoable()\n @redoStack.push(@current)\n @current = @undoStack.pop()\n @load(@current)\n @saveToLocalStorage()\n\n redo: ->\n return unless @isRedoable()\n @undoStack.push(@current)\n @current = @redoStack.pop()\n @load(@current)\n @saveToLocalStorage()\n\n isUndoable: ->\n return @undoStack.length > 0", "source_lang": "CoffeeScript", "target_lang": "CoffeeScript", "repo": "cdglabs/apparatus", "path": "src/Model/Editor.coffee", "license": "MIT", "commit": "78d3d0bd60324c54fb3594489ce6317ca27081a2", "stars": 1052, "source_url": "https://github.com/cdglabs/apparatus/blob/78d3d0bd60324c54fb3594489ce6317ca27081a2/src/Model/Editor.coffee", "line_start": 109, "line_end": 158}435{"id": "cdglabs/apparatus:src/Model/Editor.coffee:1:raw_corpus", "type": "raw_corpus", "prompt": "", "response": "module.exports = class Editor\n constructor: ->\n @_setupSerializer()\n @_setupProject()\n @_setupRevision()\n\n _setupProject: ->\n @loadFromLocalStorage()\n if !@project\n @createNewProject()\n\n _setupSerializer: ->\n builtInObjects = []\n for own name, object of @_builtIn()\n if _.isFunction(object)\n object = object.prototype\n Util.assignId(object, name)\n builtInObjects.push(object)\n @serializer = new Storage.Serializer(builtInObjects)\n\n # builtIn returns all of the built in classes and objects that are used as\n # the \"anchors\" for serialization and deserialization. That is, all of the\n # objects and classes which should not themselves be serialized but instead\n # be *referenced* from a serialization. When deserialized, these references\n # are then bound appropriately.\n _builtIn: ->\n builtIn = _.clone(Model)\n builtIn[\"SpreadEnv\"] = Dataflow.SpreadEnv\n builtIn[\"Matrix\"] = Util.Matrix\n return builtIn\n\n # TODO: get version via build process / ENV variable?\n version: \"0.4.0\"\n\n load: (jsonString) ->\n json = JSON.parse(jsonString)\n if json.type == \"Apparatus\" and json.version == @version\n @project = @serializer.dejsonify(json)\n\n save: ->\n json = @serializer.jsonify(@project)\n json.type = \"Apparatus\"\n json.version = @version\n jsonString = JSON.stringify(json)\n return jsonString\n\n createNewProject: ->\n @project = new Model.Project()", "source_lang": "", "target_lang": "CoffeeScript", "repo": "cdglabs/apparatus", "path": "src/Model/Editor.coffee", "license": "MIT", "commit": "a5d0fda468599b02ead67939236e58b5e5f7133e", "stars": 1052, "source_url": "https://github.com/cdglabs/apparatus/blob/a5d0fda468599b02ead67939236e58b5e5f7133e/src/Model/Editor.coffee", "line_start": 8, "line_end": 57}436{"id": "cdglabs/apparatus:src/Model/Editor.coffee:1:coffee_to_js", "type": "coffee_to_js", "prompt": "Convert this CoffeeScript to JavaScript.\n```coffeescript\nmodule.exports = class Editor\n constructor: ->\n @_setupSerializer()\n @_setupProject()\n @_setupRevision()\n\n _setupProject: ->\n @loadFromLocalStorage()\n if !@project\n @createNewProject()\n\n _setupSerializer: ->\n builtInObjects = []\n for own name, object of @_builtIn()\n if _.isFunction(object)\n object = object.prototype\n Util.assignId(object, name)\n builtInObjects.push(object)\n @serializer = new Storage.Serializer(builtInObjects)\n\n # builtIn returns all of the built in classes and objects that are used as\n # the \"anchors\" for serialization and deserialization. That is, all of the\n # objects and classes which should not themselves be serialized but instead\n # be *referenced* from a serialization. When deserialized, these references\n # are then bound appropriately.\n _builtIn: ->\n builtIn = _.clone(Model)\n builtIn[\"SpreadEnv\"] = Dataflow.SpreadEnv\n builtIn[\"Matrix\"] = Util.Matrix\n return builtIn\n\n # TODO: get version via build process / ENV variable?\n version: \"0.4.0\"\n\n load: (jsonString) ->\n json = JSON.parse(jsonString)\n if json.type == \"Apparatus\" and json.version == @version\n @project = @serializer.dejsonify(json)\n\n save: ->\n json = @serializer.jsonify(@project)\n json.type = \"Apparatus\"\n json.version = @version\n jsonString = JSON.stringify(json)\n return jsonString\n\n createNewProject: ->\n @project = new Model.Project()\n```", "response": "var Editor,\n hasProp = {}.hasOwnProperty;\n\nmodule.exports = Editor = (function() {\n class Editor {\n constructor() {\n this._setupSerializer();\n this._setupProject();\n this._setupRevision();\n }\n\n _setupProject() {\n this.loadFromLocalStorage();\n if (!this.project) {\n return this.createNewProject();\n }\n }\n\n _setupSerializer() {\n var builtInObjects, name, object, ref;\n builtInObjects = [];\n ref = this._builtIn();\n for (name in ref) {\n if (!hasProp.call(ref, name)) continue;\n object = ref[name];\n if (_.isFunction(object)) {\n object = object.prototype;\n }\n Util.assignId(object, name);\n builtInObjects.push(object);\n }\n return this.serializer = new Storage.Serializer(builtInObjects);\n }\n\n // builtIn returns all of the built in classes and objects that are used as\n // the \"anchors\" for serialization and deserialization. That is, all of the\n // objects and classes which should not themselves be serialized but instead\n // be *referenced* from a serialization. When deserialized, these references\n // are then bound appropriately.\n _builtIn() {\n var builtIn;\n builtIn = _.clone(Model);\n builtIn[\"SpreadEnv\"] = Dataflow.SpreadEnv;\n builtIn[\"Matrix\"] = Util.Matrix;\n return builtIn;\n }\n\n load(jsonString) {\n var json;\n json = JSON.parse(jsonString);\n if (json.type === \"Apparatus\" && json.version === this.version) {\n return this.project = this.serializer.dejsonify(json);\n }\n }\n\n save() {\n var json, jsonString;\n json = this.serializer.jsonify(this.project);\n json.type = \"Apparatus\";\n json.version = this.version;\n jsonString = JSON.stringify(json);\n return jsonString;\n }\n\n createNewProject() {\n return this.project = new Model.Project();\n }\n\n };\n\n // TODO: get version via build process / ENV variable?\n Editor.prototype.version = \"0.4.0\";\n\n return Editor;\n\n}).call(this);", "source_lang": "CoffeeScript", "target_lang": "JavaScript", "repo": "cdglabs/apparatus", "path": "src/Model/Editor.coffee", "license": "MIT", "commit": "a5d0fda468599b02ead67939236e58b5e5f7133e", "stars": 1052, "source_url": "https://github.com/cdglabs/apparatus/blob/a5d0fda468599b02ead67939236e58b5e5f7133e/src/Model/Editor.coffee", "line_start": 8, "line_end": 57}437{"id": "cdglabs/apparatus:src/Model/Editor.coffee:1:js_to_coffee", "type": "js_to_coffee", "prompt": "Convert this JavaScript to CoffeeScript.\n```javascript\nvar Editor,\n hasProp = {}.hasOwnProperty;\n\nmodule.exports = Editor = (function() {\n class Editor {\n constructor() {\n this._setupSerializer();\n this._setupProject();\n this._setupRevision();\n }\n\n _setupProject() {\n this.loadFromLocalStorage();\n if (!this.project) {\n return this.createNewProject();\n }\n }\n\n _setupSerializer() {\n var builtInObjects, name, object, ref;\n builtInObjects = [];\n ref = this._builtIn();\n for (name in ref) {\n if (!hasProp.call(ref, name)) continue;\n object = ref[name];\n if (_.isFunction(object)) {\n object = object.prototype;\n }\n Util.assignId(object, name);\n builtInObjects.push(object);\n }\n return this.serializer = new Storage.Serializer(builtInObjects);\n }\n\n // builtIn returns all of the built in classes and objects that are used as\n // the \"anchors\" for serialization and deserialization. That is, all of the\n // objects and classes which should not themselves be serialized but instead\n // be *referenced* from a serialization. When deserialized, these references\n // are then bound appropriately.\n _builtIn() {\n var builtIn;\n builtIn = _.clone(Model);\n builtIn[\"SpreadEnv\"] = Dataflow.SpreadEnv;\n builtIn[\"Matrix\"] = Util.Matrix;\n return builtIn;\n }\n\n load(jsonString) {\n var json;\n json = JSON.parse(jsonString);\n if (json.type === \"Apparatus\" && json.version === this.version) {\n return this.project = this.serializer.dejsonify(json);\n }\n }\n\n save() {\n var json, jsonString;\n json = this.serializer.jsonify(this.project);\n json.type = \"Apparatus\";\n json.version = this.version;\n jsonString = JSON.stringify(json);\n return jsonString;\n }\n\n createNewProject() {\n return this.project = new Model.Project();\n }\n\n };\n\n // TODO: get version via build process / ENV variable?\n Editor.prototype.version = \"0.4.0\";\n\n return Editor;\n\n}).call(this);\n```", "response": "module.exports = class Editor\n constructor: ->\n @_setupSerializer()\n @_setupProject()\n @_setupRevision()\n\n _setupProject: ->\n @loadFromLocalStorage()\n if !@project\n @createNewProject()\n\n _setupSerializer: ->\n builtInObjects = []\n for own name, object of @_builtIn()\n if _.isFunction(object)\n object = object.prototype\n Util.assignId(object, name)\n builtInObjects.push(object)\n @serializer = new Storage.Serializer(builtInObjects)\n\n # builtIn returns all of the built in classes and objects that are used as\n # the \"anchors\" for serialization and deserialization. That is, all of the\n # objects and classes which should not themselves be serialized but instead\n # be *referenced* from a serialization. When deserialized, these references\n # are then bound appropriately.\n _builtIn: ->\n builtIn = _.clone(Model)\n builtIn[\"SpreadEnv\"] = Dataflow.SpreadEnv\n builtIn[\"Matrix\"] = Util.Matrix\n return builtIn\n\n # TODO: get version via build process / ENV variable?\n version: \"0.4.0\"\n\n load: (jsonString) ->\n json = JSON.parse(jsonString)\n if json.type == \"Apparatus\" and json.version == @version\n @project = @serializer.dejsonify(json)\n\n save: ->\n json = @serializer.jsonify(@project)\n json.type = \"Apparatus\"\n json.version = @version\n jsonString = JSON.stringify(json)\n return jsonString\n\n createNewProject: ->\n @project = new Model.Project()", "source_lang": "JavaScript", "target_lang": "CoffeeScript", "repo": "cdglabs/apparatus", "path": "src/Model/Editor.coffee", "license": "MIT", "commit": "a5d0fda468599b02ead67939236e58b5e5f7133e", "stars": 1052, "source_url": "https://github.com/cdglabs/apparatus/blob/a5d0fda468599b02ead67939236e58b5e5f7133e/src/Model/Editor.coffee", "line_start": 8, "line_end": 57}438{"id": "cdglabs/apparatus:src/Model/Editor.coffee:1:completion", "type": "completion", "prompt": "module.exports = class Editor\n constructor: ->\n @_setupSerializer()\n @_setupProject()\n @_setupRevision()\n\n _setupProject: ->\n @loadFromLocalStorage()\n if !@project\n @createNewProject()\n\n _setupSerializer: ->\n builtInObjects = []\n for own name, object of @_builtIn()\n if _.isFunction(object)\n object = object.prototype\n Util.assignId(object, name)\n builtInObjects.push(object)\n @serializer = new Storage.Serializer(builtInObjects)\n\n # builtIn returns all of the built in classes and objects that are used as\n # the \"anchors\" for serialization and deserialization. That is, all of the\n # objects and classes which should not themselves be serialized but instead\n # be *referenced* from a serialization. When deserialized, these references", "response": "# are then bound appropriately.\n _builtIn: ->\n builtIn = _.clone(Model)\n builtIn[\"SpreadEnv\"] = Dataflow.SpreadEnv\n builtIn[\"Matrix\"] = Util.Matrix\n return builtIn\n\n # TODO: get version via build process / ENV variable?\n version: \"0.4.0\"\n\n load: (jsonString) ->\n json = JSON.parse(jsonString)\n if json.type == \"Apparatus\" and json.version == @version\n @project = @serializer.dejsonify(json)\n\n save: ->\n json = @serializer.jsonify(@project)\n json.type = \"Apparatus\"\n json.version = @version\n jsonString = JSON.stringify(json)\n return jsonString\n\n createNewProject: ->\n @project = new Model.Project()", "source_lang": "CoffeeScript", "target_lang": "CoffeeScript", "repo": "cdglabs/apparatus", "path": "src/Model/Editor.coffee", "license": "MIT", "commit": "a5d0fda468599b02ead67939236e58b5e5f7133e", "stars": 1052, "source_url": "https://github.com/cdglabs/apparatus/blob/a5d0fda468599b02ead67939236e58b5e5f7133e/src/Model/Editor.coffee", "line_start": 8, "line_end": 57}439{"id": "cdglabs/apparatus:src/Model/Editor.coffee:2:raw_corpus", "type": "raw_corpus", "prompt": "", "response": "# ===========================================================================\n # Local Storage\n # ===========================================================================\n\n localStorageName: \"apparatus\"\n\n saveToLocalStorage: ->\n jsonString = @save()\n window.localStorage[@localStorageName] = jsonString\n return jsonString\n\n loadFromLocalStorage: ->\n jsonString = window.localStorage[@localStorageName]\n if jsonString\n @load(jsonString)\n\n resetLocalStorage: ->\n delete window.localStorage[@localStorageName]\n\n\n # ===========================================================================\n # File System\n # ===========================================================================\n\n saveToFile: ->\n jsonString = @save()\n fileName = @project.editingElement.label + \".json\"\n Storage.saveFile(jsonString, fileName, \"application/json;charset=utf-8\")\n\n loadFromFile: ->\n Storage.loadFile (jsonString) =>\n @load(jsonString)\n\n\n # ===========================================================================\n # Revision History\n # ===========================================================================\n\n _setupRevision: ->\n # @current is a JSON string representing the current state. @undoStack and\n # @redoStack are arrays of such JSON strings.\n @current = @save()\n @undoStack = []\n @redoStack = []\n @maxUndoStackSize = 100\n\n checkpoint: ->\n jsonString = @saveToLocalStorage()\n return if @current == jsonString\n @undoStack.push(@current)", "source_lang": "", "target_lang": "CoffeeScript", "repo": "cdglabs/apparatus", "path": "src/Model/Editor.coffee", "license": "MIT", "commit": "a5d0fda468599b02ead67939236e58b5e5f7133e", "stars": 1052, "source_url": "https://github.com/cdglabs/apparatus/blob/a5d0fda468599b02ead67939236e58b5e5f7133e/src/Model/Editor.coffee", "line_start": 58, "line_end": 107}440{"id": "cdglabs/apparatus:src/Model/Editor.coffee:2:coffee_to_js", "type": "coffee_to_js", "prompt": "Convert this CoffeeScript to JavaScript.\n```coffeescript\n# ===========================================================================\n # Local Storage\n # ===========================================================================\n\n localStorageName: \"apparatus\"\n\n saveToLocalStorage: ->\n jsonString = @save()\n window.localStorage[@localStorageName] = jsonString\n return jsonString\n\n loadFromLocalStorage: ->\n jsonString = window.localStorage[@localStorageName]\n if jsonString\n @load(jsonString)\n\n resetLocalStorage: ->\n delete window.localStorage[@localStorageName]\n\n\n # ===========================================================================\n # File System\n # ===========================================================================\n\n saveToFile: ->\n jsonString = @save()\n fileName = @project.editingElement.label + \".json\"\n Storage.saveFile(jsonString, fileName, \"application/json;charset=utf-8\")\n\n loadFromFile: ->\n Storage.loadFile (jsonString) =>\n @load(jsonString)\n\n\n # ===========================================================================\n # Revision History\n # ===========================================================================\n\n _setupRevision: ->\n # @current is a JSON string representing the current state. @undoStack and\n # @redoStack are arrays of such JSON strings.\n @current = @save()\n @undoStack = []\n @redoStack = []\n @maxUndoStackSize = 100\n\n checkpoint: ->\n jsonString = @saveToLocalStorage()\n return if @current == jsonString\n @undoStack.push(@current)\n```", "response": "// ===========================================================================\n// Local Storage\n// ===========================================================================\n({\n localStorageName: \"apparatus\",\n saveToLocalStorage: function() {\n var jsonString;\n jsonString = this.save();\n window.localStorage[this.localStorageName] = jsonString;\n return jsonString;\n },\n loadFromLocalStorage: function() {\n var jsonString;\n jsonString = window.localStorage[this.localStorageName];\n if (jsonString) {\n return this.load(jsonString);\n }\n },\n resetLocalStorage: function() {\n return delete window.localStorage[this.localStorageName];\n },\n // ===========================================================================\n // File System\n // ===========================================================================\n saveToFile: function() {\n var fileName, jsonString;\n jsonString = this.save();\n fileName = this.project.editingElement.label + \".json\";\n return Storage.saveFile(jsonString, fileName, \"application/json;charset=utf-8\");\n },\n loadFromFile: function() {\n return Storage.loadFile((jsonString) => {\n return this.load(jsonString);\n });\n },\n // ===========================================================================\n // Revision History\n // ===========================================================================\n _setupRevision: function() {\n // @current is a JSON string representing the current state. @undoStack and\n // @redoStack are arrays of such JSON strings.\n this.current = this.save();\n this.undoStack = [];\n this.redoStack = [];\n return this.maxUndoStackSize = 100;\n },\n checkpoint: function() {\n var jsonString;\n jsonString = this.saveToLocalStorage();\n if (this.current === jsonString) {\n return;\n }\n return this.undoStack.push(this.current);\n }\n});", "source_lang": "CoffeeScript", "target_lang": "JavaScript", "repo": "cdglabs/apparatus", "path": "src/Model/Editor.coffee", "license": "MIT", "commit": "a5d0fda468599b02ead67939236e58b5e5f7133e", "stars": 1052, "source_url": "https://github.com/cdglabs/apparatus/blob/a5d0fda468599b02ead67939236e58b5e5f7133e/src/Model/Editor.coffee", "line_start": 58, "line_end": 107}441{"id": "cdglabs/apparatus:src/Model/Editor.coffee:2:js_to_coffee", "type": "js_to_coffee", "prompt": "Convert this JavaScript to CoffeeScript.\n```javascript\n// ===========================================================================\n// Local Storage\n// ===========================================================================\n({\n localStorageName: \"apparatus\",\n saveToLocalStorage: function() {\n var jsonString;\n jsonString = this.save();\n window.localStorage[this.localStorageName] = jsonString;\n return jsonString;\n },\n loadFromLocalStorage: function() {\n var jsonString;\n jsonString = window.localStorage[this.localStorageName];\n if (jsonString) {\n return this.load(jsonString);\n }\n },\n resetLocalStorage: function() {\n return delete window.localStorage[this.localStorageName];\n },\n // ===========================================================================\n // File System\n // ===========================================================================\n saveToFile: function() {\n var fileName, jsonString;\n jsonString = this.save();\n fileName = this.project.editingElement.label + \".json\";\n return Storage.saveFile(jsonString, fileName, \"application/json;charset=utf-8\");\n },\n loadFromFile: function() {\n return Storage.loadFile((jsonString) => {\n return this.load(jsonString);\n });\n },\n // ===========================================================================\n // Revision History\n // ===========================================================================\n _setupRevision: function() {\n // @current is a JSON string representing the current state. @undoStack and\n // @redoStack are arrays of such JSON strings.\n this.current = this.save();\n this.undoStack = [];\n this.redoStack = [];\n return this.maxUndoStackSize = 100;\n },\n checkpoint: function() {\n var jsonString;\n jsonString = this.saveToLocalStorage();\n if (this.current === jsonString) {\n return;\n }\n return this.undoStack.push(this.current);\n }\n});\n```", "response": "# ===========================================================================\n # Local Storage\n # ===========================================================================\n\n localStorageName: \"apparatus\"\n\n saveToLocalStorage: ->\n jsonString = @save()\n window.localStorage[@localStorageName] = jsonString\n return jsonString\n\n loadFromLocalStorage: ->\n jsonString = window.localStorage[@localStorageName]\n if jsonString\n @load(jsonString)\n\n resetLocalStorage: ->\n delete window.localStorage[@localStorageName]\n\n\n # ===========================================================================\n # File System\n # ===========================================================================\n\n saveToFile: ->\n jsonString = @save()\n fileName = @project.editingElement.label + \".json\"\n Storage.saveFile(jsonString, fileName, \"application/json;charset=utf-8\")\n\n loadFromFile: ->\n Storage.loadFile (jsonString) =>\n @load(jsonString)\n\n\n # ===========================================================================\n # Revision History\n # ===========================================================================\n\n _setupRevision: ->\n # @current is a JSON string representing the current state. @undoStack and\n # @redoStack are arrays of such JSON strings.\n @current = @save()\n @undoStack = []\n @redoStack = []\n @maxUndoStackSize = 100\n\n checkpoint: ->\n jsonString = @saveToLocalStorage()\n return if @current == jsonString\n @undoStack.push(@current)", "source_lang": "JavaScript", "target_lang": "CoffeeScript", "repo": "cdglabs/apparatus", "path": "src/Model/Editor.coffee", "license": "MIT", "commit": "a5d0fda468599b02ead67939236e58b5e5f7133e", "stars": 1052, "source_url": "https://github.com/cdglabs/apparatus/blob/a5d0fda468599b02ead67939236e58b5e5f7133e/src/Model/Editor.coffee", "line_start": 58, "line_end": 107}442{"id": "cdglabs/apparatus:src/Model/Editor.coffee:2:completion", "type": "completion", "prompt": "# ===========================================================================\n # Local Storage\n # ===========================================================================\n\n localStorageName: \"apparatus\"\n\n saveToLocalStorage: ->\n jsonString = @save()\n window.localStorage[@localStorageName] = jsonString\n return jsonString\n\n loadFromLocalStorage: ->\n jsonString = window.localStorage[@localStorageName]\n if jsonString\n @load(jsonString)\n\n resetLocalStorage: ->\n delete window.localStorage[@localStorageName]\n\n\n # ===========================================================================\n # File System\n # ===========================================================================\n\n saveToFile: ->", "response": "jsonString = @save()\n fileName = @project.editingElement.label + \".json\"\n Storage.saveFile(jsonString, fileName, \"application/json;charset=utf-8\")\n\n loadFromFile: ->\n Storage.loadFile (jsonString) =>\n @load(jsonString)\n\n\n # ===========================================================================\n # Revision History\n # ===========================================================================\n\n _setupRevision: ->\n # @current is a JSON string representing the current state. @undoStack and\n # @redoStack are arrays of such JSON strings.\n @current = @save()\n @undoStack = []\n @redoStack = []\n @maxUndoStackSize = 100\n\n checkpoint: ->\n jsonString = @saveToLocalStorage()\n return if @current == jsonString\n @undoStack.push(@current)", "source_lang": "CoffeeScript", "target_lang": "CoffeeScript", "repo": "cdglabs/apparatus", "path": "src/Model/Editor.coffee", "license": "MIT", "commit": "a5d0fda468599b02ead67939236e58b5e5f7133e", "stars": 1052, "source_url": "https://github.com/cdglabs/apparatus/blob/a5d0fda468599b02ead67939236e58b5e5f7133e/src/Model/Editor.coffee", "line_start": 58, "line_end": 107}443{"id": "cdglabs/apparatus:src/Model/Editor.coffee:3:raw_corpus", "type": "raw_corpus", "prompt": "", "response": "if @undoStack.length > @maxUndoStackSize\n @undoStack.shift()\n @redoStack = []\n @current = jsonString\n\n undo: ->\n return unless @isUndoable()\n @redoStack.push(@current)\n @current = @undoStack.pop()\n @load(@current)\n @saveToLocalStorage()\n\n redo: ->\n return unless @isRedoable()\n @undoStack.push(@current)\n @current = @redoStack.pop()\n @load(@current)\n @saveToLocalStorage()\n\n isUndoable: ->\n return @undoStack.length > 0\n\n isRedoable: ->\n return @redoStack.length > 0", "source_lang": "", "target_lang": "CoffeeScript", "repo": "cdglabs/apparatus", "path": "src/Model/Editor.coffee", "license": "MIT", "commit": "a5d0fda468599b02ead67939236e58b5e5f7133e", "stars": 1052, "source_url": "https://github.com/cdglabs/apparatus/blob/a5d0fda468599b02ead67939236e58b5e5f7133e/src/Model/Editor.coffee", "line_start": 108, "line_end": 131}444{"id": "cdglabs/apparatus:src/Model/Editor.coffee:3:coffee_to_js", "type": "coffee_to_js", "prompt": "Convert this CoffeeScript to JavaScript.\n```coffeescript\nif @undoStack.length > @maxUndoStackSize\n @undoStack.shift()\n @redoStack = []\n @current = jsonString\n\n undo: ->\n return unless @isUndoable()\n @redoStack.push(@current)\n @current = @undoStack.pop()\n @load(@current)\n @saveToLocalStorage()\n\n redo: ->\n return unless @isRedoable()\n @undoStack.push(@current)\n @current = @redoStack.pop()\n @load(@current)\n @saveToLocalStorage()\n\n isUndoable: ->\n return @undoStack.length > 0\n\n isRedoable: ->\n return @redoStack.length > 0\n```", "response": "if (this.undoStack.length > this.maxUndoStackSize) {\n this.undoStack.shift();\n}\n\nthis.redoStack = [];\n\nthis.current = jsonString;\n\n({\n undo: function() {\n if (!this.isUndoable()) {\n return;\n }\n this.redoStack.push(this.current);\n this.current = this.undoStack.pop();\n this.load(this.current);\n return this.saveToLocalStorage();\n },\n redo: function() {\n if (!this.isRedoable()) {\n return;\n }\n this.undoStack.push(this.current);\n this.current = this.redoStack.pop();\n this.load(this.current);\n return this.saveToLocalStorage();\n },\n isUndoable: function() {\n return this.undoStack.length > 0;\n },\n isRedoable: function() {\n return this.redoStack.length > 0;\n }\n});", "source_lang": "CoffeeScript", "target_lang": "JavaScript", "repo": "cdglabs/apparatus", "path": "src/Model/Editor.coffee", "license": "MIT", "commit": "a5d0fda468599b02ead67939236e58b5e5f7133e", "stars": 1052, "source_url": "https://github.com/cdglabs/apparatus/blob/a5d0fda468599b02ead67939236e58b5e5f7133e/src/Model/Editor.coffee", "line_start": 108, "line_end": 131}445{"id": "cdglabs/apparatus:src/Model/Editor.coffee:3:js_to_coffee", "type": "js_to_coffee", "prompt": "Convert this JavaScript to CoffeeScript.\n```javascript\nif (this.undoStack.length > this.maxUndoStackSize) {\n this.undoStack.shift();\n}\n\nthis.redoStack = [];\n\nthis.current = jsonString;\n\n({\n undo: function() {\n if (!this.isUndoable()) {\n return;\n }\n this.redoStack.push(this.current);\n this.current = this.undoStack.pop();\n this.load(this.current);\n return this.saveToLocalStorage();\n },\n redo: function() {\n if (!this.isRedoable()) {\n return;\n }\n this.undoStack.push(this.current);\n this.current = this.redoStack.pop();\n this.load(this.current);\n return this.saveToLocalStorage();\n },\n isUndoable: function() {\n return this.undoStack.length > 0;\n },\n isRedoable: function() {\n return this.redoStack.length > 0;\n }\n});\n```", "response": "if @undoStack.length > @maxUndoStackSize\n @undoStack.shift()\n @redoStack = []\n @current = jsonString\n\n undo: ->\n return unless @isUndoable()\n @redoStack.push(@current)\n @current = @undoStack.pop()\n @load(@current)\n @saveToLocalStorage()\n\n redo: ->\n return unless @isRedoable()\n @undoStack.push(@current)\n @current = @redoStack.pop()\n @load(@current)\n @saveToLocalStorage()\n\n isUndoable: ->\n return @undoStack.length > 0\n\n isRedoable: ->\n return @redoStack.length > 0", "source_lang": "JavaScript", "target_lang": "CoffeeScript", "repo": "cdglabs/apparatus", "path": "src/Model/Editor.coffee", "license": "MIT", "commit": "a5d0fda468599b02ead67939236e58b5e5f7133e", "stars": 1052, "source_url": "https://github.com/cdglabs/apparatus/blob/a5d0fda468599b02ead67939236e58b5e5f7133e/src/Model/Editor.coffee", "line_start": 108, "line_end": 131}446{"id": "cdglabs/apparatus:src/Model/Editor.coffee:3:completion", "type": "completion", "prompt": "if @undoStack.length > @maxUndoStackSize\n @undoStack.shift()\n @redoStack = []\n @current = jsonString\n\n undo: ->\n return unless @isUndoable()\n @redoStack.push(@current)\n @current = @undoStack.pop()\n @load(@current)\n @saveToLocalStorage()", "response": "redo: ->\n return unless @isRedoable()\n @undoStack.push(@current)\n @current = @redoStack.pop()\n @load(@current)\n @saveToLocalStorage()\n\n isUndoable: ->\n return @undoStack.length > 0\n\n isRedoable: ->\n return @redoStack.length > 0", "source_lang": "CoffeeScript", "target_lang": "CoffeeScript", "repo": "cdglabs/apparatus", "path": "src/Model/Editor.coffee", "license": "MIT", "commit": "a5d0fda468599b02ead67939236e58b5e5f7133e", "stars": 1052, "source_url": "https://github.com/cdglabs/apparatus/blob/a5d0fda468599b02ead67939236e58b5e5f7133e/src/Model/Editor.coffee", "line_start": 108, "line_end": 131}447{"id": "cdglabs/apparatus:src/Model/Editor.coffee:1:raw_corpus", "type": "raw_corpus", "prompt": "", "response": "module.exports = class Editor\n constructor: ->\n @_setupSerializer()\n @_setupProject()\n\n _setupProject: ->\n @loadFromLocalStorage()\n if !@project\n @createNewProject()\n\n _setupSerializer: ->\n builtInObjects = []\n for own name, object of @_builtIn()\n if _.isFunction(object)\n object = object.prototype\n Util.assignId(object, name)\n builtInObjects.push(object)\n @serializer = new Storage.Serializer(builtInObjects)\n\n # builtIn returns all of the built in classes and objects that are used as\n # the \"anchors\" for serialization and deserialization. That is, all of the\n # objects and classes which should not themselves be serialized but instead\n # be *referenced* from a serialization. When deserialized, these references\n # are then bound appropriately.\n _builtIn: ->\n builtIn = _.clone(Model)\n builtIn[\"SpreadEnv\"] = Dataflow.SpreadEnv\n builtIn[\"Matrix\"] = Util.Matrix\n return builtIn\n\n # TODO: get version via build process / ENV variable?\n version: \"0.4.0\"\n\n load: (jsonString) ->\n json = JSON.parse(jsonString)\n if json.type == \"Apparatus\" and json.version == @version\n @project = @serializer.dejsonify(json)\n\n save: ->\n json = @serializer.jsonify(@project)\n json.type = \"Apparatus\"\n json.version = @version\n jsonString = JSON.stringify(json)\n return jsonString\n\n createNewProject: ->\n @project = new Model.Project()\n\n\n # ===========================================================================", "source_lang": "", "target_lang": "CoffeeScript", "repo": "cdglabs/apparatus", "path": "src/Model/Editor.coffee", "license": "MIT", "commit": "0bdf63f021ef20f44ff8e4a1b8f5831afddc06a2", "stars": 1052, "source_url": "https://github.com/cdglabs/apparatus/blob/0bdf63f021ef20f44ff8e4a1b8f5831afddc06a2/src/Model/Editor.coffee", "line_start": 8, "line_end": 57}448{"id": "cdglabs/apparatus:src/Model/Editor.coffee:1:coffee_to_js", "type": "coffee_to_js", "prompt": "Convert this CoffeeScript to JavaScript.\n```coffeescript\nmodule.exports = class Editor\n constructor: ->\n @_setupSerializer()\n @_setupProject()\n\n _setupProject: ->\n @loadFromLocalStorage()\n if !@project\n @createNewProject()\n\n _setupSerializer: ->\n builtInObjects = []\n for own name, object of @_builtIn()\n if _.isFunction(object)\n object = object.prototype\n Util.assignId(object, name)\n builtInObjects.push(object)\n @serializer = new Storage.Serializer(builtInObjects)\n\n # builtIn returns all of the built in classes and objects that are used as\n # the \"anchors\" for serialization and deserialization. That is, all of the\n # objects and classes which should not themselves be serialized but instead\n # be *referenced* from a serialization. When deserialized, these references\n # are then bound appropriately.\n _builtIn: ->\n builtIn = _.clone(Model)\n builtIn[\"SpreadEnv\"] = Dataflow.SpreadEnv\n builtIn[\"Matrix\"] = Util.Matrix\n return builtIn\n\n # TODO: get version via build process / ENV variable?\n version: \"0.4.0\"\n\n load: (jsonString) ->\n json = JSON.parse(jsonString)\n if json.type == \"Apparatus\" and json.version == @version\n @project = @serializer.dejsonify(json)\n\n save: ->\n json = @serializer.jsonify(@project)\n json.type = \"Apparatus\"\n json.version = @version\n jsonString = JSON.stringify(json)\n return jsonString\n\n createNewProject: ->\n @project = new Model.Project()\n\n\n # ===========================================================================\n```", "response": "var Editor,\n hasProp = {}.hasOwnProperty;\n\nmodule.exports = Editor = (function() {\n class Editor {\n constructor() {\n this._setupSerializer();\n this._setupProject();\n }\n\n _setupProject() {\n this.loadFromLocalStorage();\n if (!this.project) {\n return this.createNewProject();\n }\n }\n\n _setupSerializer() {\n var builtInObjects, name, object, ref;\n builtInObjects = [];\n ref = this._builtIn();\n for (name in ref) {\n if (!hasProp.call(ref, name)) continue;\n object = ref[name];\n if (_.isFunction(object)) {\n object = object.prototype;\n }\n Util.assignId(object, name);\n builtInObjects.push(object);\n }\n return this.serializer = new Storage.Serializer(builtInObjects);\n }\n\n // builtIn returns all of the built in classes and objects that are used as\n // the \"anchors\" for serialization and deserialization. That is, all of the\n // objects and classes which should not themselves be serialized but instead\n // be *referenced* from a serialization. When deserialized, these references\n // are then bound appropriately.\n _builtIn() {\n var builtIn;\n builtIn = _.clone(Model);\n builtIn[\"SpreadEnv\"] = Dataflow.SpreadEnv;\n builtIn[\"Matrix\"] = Util.Matrix;\n return builtIn;\n }\n\n load(jsonString) {\n var json;\n json = JSON.parse(jsonString);\n if (json.type === \"Apparatus\" && json.version === this.version) {\n return this.project = this.serializer.dejsonify(json);\n }\n }\n\n save() {\n var json, jsonString;\n json = this.serializer.jsonify(this.project);\n json.type = \"Apparatus\";\n json.version = this.version;\n jsonString = JSON.stringify(json);\n return jsonString;\n }\n\n createNewProject() {\n return this.project = new Model.Project();\n }\n\n };\n\n // TODO: get version via build process / ENV variable?\n Editor.prototype.version = \"0.4.0\";\n\n return Editor;\n\n}).call(this);\n\n// ===========================================================================", "source_lang": "CoffeeScript", "target_lang": "JavaScript", "repo": "cdglabs/apparatus", "path": "src/Model/Editor.coffee", "license": "MIT", "commit": "0bdf63f021ef20f44ff8e4a1b8f5831afddc06a2", "stars": 1052, "source_url": "https://github.com/cdglabs/apparatus/blob/0bdf63f021ef20f44ff8e4a1b8f5831afddc06a2/src/Model/Editor.coffee", "line_start": 8, "line_end": 57}449{"id": "cdglabs/apparatus:src/Model/Editor.coffee:1:js_to_coffee", "type": "js_to_coffee", "prompt": "Convert this JavaScript to CoffeeScript.\n```javascript\nvar Editor,\n hasProp = {}.hasOwnProperty;\n\nmodule.exports = Editor = (function() {\n class Editor {\n constructor() {\n this._setupSerializer();\n this._setupProject();\n }\n\n _setupProject() {\n this.loadFromLocalStorage();\n if (!this.project) {\n return this.createNewProject();\n }\n }\n\n _setupSerializer() {\n var builtInObjects, name, object, ref;\n builtInObjects = [];\n ref = this._builtIn();\n for (name in ref) {\n if (!hasProp.call(ref, name)) continue;\n object = ref[name];\n if (_.isFunction(object)) {\n object = object.prototype;\n }\n Util.assignId(object, name);\n builtInObjects.push(object);\n }\n return this.serializer = new Storage.Serializer(builtInObjects);\n }\n\n // builtIn returns all of the built in classes and objects that are used as\n // the \"anchors\" for serialization and deserialization. That is, all of the\n // objects and classes which should not themselves be serialized but instead\n // be *referenced* from a serialization. When deserialized, these references\n // are then bound appropriately.\n _builtIn() {\n var builtIn;\n builtIn = _.clone(Model);\n builtIn[\"SpreadEnv\"] = Dataflow.SpreadEnv;\n builtIn[\"Matrix\"] = Util.Matrix;\n return builtIn;\n }\n\n load(jsonString) {\n var json;\n json = JSON.parse(jsonString);\n if (json.type === \"Apparatus\" && json.version === this.version) {\n return this.project = this.serializer.dejsonify(json);\n }\n }\n\n save() {\n var json, jsonString;\n json = this.serializer.jsonify(this.project);\n json.type = \"Apparatus\";\n json.version = this.version;\n jsonString = JSON.stringify(json);\n return jsonString;\n }\n\n createNewProject() {\n return this.project = new Model.Project();\n }\n\n };\n\n // TODO: get version via build process / ENV variable?\n Editor.prototype.version = \"0.4.0\";\n\n return Editor;\n\n}).call(this);\n\n// ===========================================================================\n```", "response": "module.exports = class Editor\n constructor: ->\n @_setupSerializer()\n @_setupProject()\n\n _setupProject: ->\n @loadFromLocalStorage()\n if !@project\n @createNewProject()\n\n _setupSerializer: ->\n builtInObjects = []\n for own name, object of @_builtIn()\n if _.isFunction(object)\n object = object.prototype\n Util.assignId(object, name)\n builtInObjects.push(object)\n @serializer = new Storage.Serializer(builtInObjects)\n\n # builtIn returns all of the built in classes and objects that are used as\n # the \"anchors\" for serialization and deserialization. That is, all of the\n # objects and classes which should not themselves be serialized but instead\n # be *referenced* from a serialization. When deserialized, these references\n # are then bound appropriately.\n _builtIn: ->\n builtIn = _.clone(Model)\n builtIn[\"SpreadEnv\"] = Dataflow.SpreadEnv\n builtIn[\"Matrix\"] = Util.Matrix\n return builtIn\n\n # TODO: get version via build process / ENV variable?\n version: \"0.4.0\"\n\n load: (jsonString) ->\n json = JSON.parse(jsonString)\n if json.type == \"Apparatus\" and json.version == @version\n @project = @serializer.dejsonify(json)\n\n save: ->\n json = @serializer.jsonify(@project)\n json.type = \"Apparatus\"\n json.version = @version\n jsonString = JSON.stringify(json)\n return jsonString\n\n createNewProject: ->\n @project = new Model.Project()\n\n\n # ===========================================================================", "source_lang": "JavaScript", "target_lang": "CoffeeScript", "repo": "cdglabs/apparatus", "path": "src/Model/Editor.coffee", "license": "MIT", "commit": "0bdf63f021ef20f44ff8e4a1b8f5831afddc06a2", "stars": 1052, "source_url": "https://github.com/cdglabs/apparatus/blob/0bdf63f021ef20f44ff8e4a1b8f5831afddc06a2/src/Model/Editor.coffee", "line_start": 8, "line_end": 57}450{"id": "cdglabs/apparatus:src/Model/Editor.coffee:1:completion", "type": "completion", "prompt": "module.exports = class Editor\n constructor: ->\n @_setupSerializer()\n @_setupProject()\n\n _setupProject: ->\n @loadFromLocalStorage()\n if !@project\n @createNewProject()\n\n _setupSerializer: ->\n builtInObjects = []\n for own name, object of @_builtIn()\n if _.isFunction(object)\n object = object.prototype\n Util.assignId(object, name)\n builtInObjects.push(object)\n @serializer = new Storage.Serializer(builtInObjects)\n\n # builtIn returns all of the built in classes and objects that are used as\n # the \"anchors\" for serialization and deserialization. That is, all of the\n # objects and classes which should not themselves be serialized but instead\n # be *referenced* from a serialization. When deserialized, these references\n # are then bound appropriately.\n _builtIn: ->", "response": "builtIn = _.clone(Model)\n builtIn[\"SpreadEnv\"] = Dataflow.SpreadEnv\n builtIn[\"Matrix\"] = Util.Matrix\n return builtIn\n\n # TODO: get version via build process / ENV variable?\n version: \"0.4.0\"\n\n load: (jsonString) ->\n json = JSON.parse(jsonString)\n if json.type == \"Apparatus\" and json.version == @version\n @project = @serializer.dejsonify(json)\n\n save: ->\n json = @serializer.jsonify(@project)\n json.type = \"Apparatus\"\n json.version = @version\n jsonString = JSON.stringify(json)\n return jsonString\n\n createNewProject: ->\n @project = new Model.Project()\n\n\n # ===========================================================================", "source_lang": "CoffeeScript", "target_lang": "CoffeeScript", "repo": "cdglabs/apparatus", "path": "src/Model/Editor.coffee", "license": "MIT", "commit": "0bdf63f021ef20f44ff8e4a1b8f5831afddc06a2", "stars": 1052, "source_url": "https://github.com/cdglabs/apparatus/blob/0bdf63f021ef20f44ff8e4a1b8f5831afddc06a2/src/Model/Editor.coffee", "line_start": 8, "line_end": 57}451{"id": "cdglabs/apparatus:src/Model/Editor.coffee:2:raw_corpus", "type": "raw_corpus", "prompt": "", "response": "# Local Storage\n # ===========================================================================\n\n localStorageName: \"apparatus\"\n\n saveToLocalStorage: ->\n jsonString = @save()\n window.localStorage[@localStorageName] = jsonString\n\n loadFromLocalStorage: ->\n jsonString = window.localStorage[@localStorageName]\n if jsonString\n @load(jsonString)\n\n resetLocalStorage: ->\n delete window.localStorage[@localStorageName]\n\n\n # ===========================================================================\n # File System\n # ===========================================================================\n\n saveToFile: ->\n jsonString = @save()\n fileName = @project.editingElement.label + \".json\"\n Storage.saveFile(jsonString, fileName, \"application/json;charset=utf-8\")\n\n loadFromFile: ->\n Storage.loadFile (jsonString) =>\n @load(jsonString)\n\n\n # ===========================================================================\n # Revision History\n # ===========================================================================\n\n checkpoint: ->\n @saveToLocalStorage()\n\n # TODO: undo, redo", "source_lang": "", "target_lang": "CoffeeScript", "repo": "cdglabs/apparatus", "path": "src/Model/Editor.coffee", "license": "MIT", "commit": "0bdf63f021ef20f44ff8e4a1b8f5831afddc06a2", "stars": 1052, "source_url": "https://github.com/cdglabs/apparatus/blob/0bdf63f021ef20f44ff8e4a1b8f5831afddc06a2/src/Model/Editor.coffee", "line_start": 58, "line_end": 97}452{"id": "cdglabs/apparatus:src/Model/Editor.coffee:2:coffee_to_js", "type": "coffee_to_js", "prompt": "Convert this CoffeeScript to JavaScript.\n```coffeescript\n# Local Storage\n # ===========================================================================\n\n localStorageName: \"apparatus\"\n\n saveToLocalStorage: ->\n jsonString = @save()\n window.localStorage[@localStorageName] = jsonString\n\n loadFromLocalStorage: ->\n jsonString = window.localStorage[@localStorageName]\n if jsonString\n @load(jsonString)\n\n resetLocalStorage: ->\n delete window.localStorage[@localStorageName]\n\n\n # ===========================================================================\n # File System\n # ===========================================================================\n\n saveToFile: ->\n jsonString = @save()\n fileName = @project.editingElement.label + \".json\"\n Storage.saveFile(jsonString, fileName, \"application/json;charset=utf-8\")\n\n loadFromFile: ->\n Storage.loadFile (jsonString) =>\n @load(jsonString)\n\n\n # ===========================================================================\n # Revision History\n # ===========================================================================\n\n checkpoint: ->\n @saveToLocalStorage()\n\n # TODO: undo, redo\n```", "response": "// Local Storage\n// ===========================================================================\n({\n localStorageName: \"apparatus\",\n saveToLocalStorage: function() {\n var jsonString;\n jsonString = this.save();\n return window.localStorage[this.localStorageName] = jsonString;\n },\n loadFromLocalStorage: function() {\n var jsonString;\n jsonString = window.localStorage[this.localStorageName];\n if (jsonString) {\n return this.load(jsonString);\n }\n },\n resetLocalStorage: function() {\n return delete window.localStorage[this.localStorageName];\n },\n // ===========================================================================\n // File System\n // ===========================================================================\n saveToFile: function() {\n var fileName, jsonString;\n jsonString = this.save();\n fileName = this.project.editingElement.label + \".json\";\n return Storage.saveFile(jsonString, fileName, \"application/json;charset=utf-8\");\n },\n loadFromFile: function() {\n return Storage.loadFile((jsonString) => {\n return this.load(jsonString);\n });\n },\n // ===========================================================================\n // Revision History\n // ===========================================================================\n checkpoint: function() {\n return this.saveToLocalStorage();\n }\n});\n\n// TODO: undo, redo", "source_lang": "CoffeeScript", "target_lang": "JavaScript", "repo": "cdglabs/apparatus", "path": "src/Model/Editor.coffee", "license": "MIT", "commit": "0bdf63f021ef20f44ff8e4a1b8f5831afddc06a2", "stars": 1052, "source_url": "https://github.com/cdglabs/apparatus/blob/0bdf63f021ef20f44ff8e4a1b8f5831afddc06a2/src/Model/Editor.coffee", "line_start": 58, "line_end": 97}453{"id": "cdglabs/apparatus:src/Model/Editor.coffee:2:js_to_coffee", "type": "js_to_coffee", "prompt": "Convert this JavaScript to CoffeeScript.\n```javascript\n// Local Storage\n// ===========================================================================\n({\n localStorageName: \"apparatus\",\n saveToLocalStorage: function() {\n var jsonString;\n jsonString = this.save();\n return window.localStorage[this.localStorageName] = jsonString;\n },\n loadFromLocalStorage: function() {\n var jsonString;\n jsonString = window.localStorage[this.localStorageName];\n if (jsonString) {\n return this.load(jsonString);\n }\n },\n resetLocalStorage: function() {\n return delete window.localStorage[this.localStorageName];\n },\n // ===========================================================================\n // File System\n // ===========================================================================\n saveToFile: function() {\n var fileName, jsonString;\n jsonString = this.save();\n fileName = this.project.editingElement.label + \".json\";\n return Storage.saveFile(jsonString, fileName, \"application/json;charset=utf-8\");\n },\n loadFromFile: function() {\n return Storage.loadFile((jsonString) => {\n return this.load(jsonString);\n });\n },\n // ===========================================================================\n // Revision History\n // ===========================================================================\n checkpoint: function() {\n return this.saveToLocalStorage();\n }\n});\n\n// TODO: undo, redo\n```", "response": "# Local Storage\n # ===========================================================================\n\n localStorageName: \"apparatus\"\n\n saveToLocalStorage: ->\n jsonString = @save()\n window.localStorage[@localStorageName] = jsonString\n\n loadFromLocalStorage: ->\n jsonString = window.localStorage[@localStorageName]\n if jsonString\n @load(jsonString)\n\n resetLocalStorage: ->\n delete window.localStorage[@localStorageName]\n\n\n # ===========================================================================\n # File System\n # ===========================================================================\n\n saveToFile: ->\n jsonString = @save()\n fileName = @project.editingElement.label + \".json\"\n Storage.saveFile(jsonString, fileName, \"application/json;charset=utf-8\")\n\n loadFromFile: ->\n Storage.loadFile (jsonString) =>\n @load(jsonString)\n\n\n # ===========================================================================\n # Revision History\n # ===========================================================================\n\n checkpoint: ->\n @saveToLocalStorage()\n\n # TODO: undo, redo", "source_lang": "JavaScript", "target_lang": "CoffeeScript", "repo": "cdglabs/apparatus", "path": "src/Model/Editor.coffee", "license": "MIT", "commit": "0bdf63f021ef20f44ff8e4a1b8f5831afddc06a2", "stars": 1052, "source_url": "https://github.com/cdglabs/apparatus/blob/0bdf63f021ef20f44ff8e4a1b8f5831afddc06a2/src/Model/Editor.coffee", "line_start": 58, "line_end": 97}454{"id": "cdglabs/apparatus:src/Model/Editor.coffee:2:completion", "type": "completion", "prompt": "# Local Storage\n # ===========================================================================\n\n localStorageName: \"apparatus\"\n\n saveToLocalStorage: ->\n jsonString = @save()\n window.localStorage[@localStorageName] = jsonString\n\n loadFromLocalStorage: ->\n jsonString = window.localStorage[@localStorageName]\n if jsonString\n @load(jsonString)\n\n resetLocalStorage: ->\n delete window.localStorage[@localStorageName]\n\n\n # ===========================================================================\n # File System", "response": "# ===========================================================================\n\n saveToFile: ->\n jsonString = @save()\n fileName = @project.editingElement.label + \".json\"\n Storage.saveFile(jsonString, fileName, \"application/json;charset=utf-8\")\n\n loadFromFile: ->\n Storage.loadFile (jsonString) =>\n @load(jsonString)\n\n\n # ===========================================================================\n # Revision History\n # ===========================================================================\n\n checkpoint: ->\n @saveToLocalStorage()\n\n # TODO: undo, redo", "source_lang": "CoffeeScript", "target_lang": "CoffeeScript", "repo": "cdglabs/apparatus", "path": "src/Model/Editor.coffee", "license": "MIT", "commit": "0bdf63f021ef20f44ff8e4a1b8f5831afddc06a2", "stars": 1052, "source_url": "https://github.com/cdglabs/apparatus/blob/0bdf63f021ef20f44ff8e4a1b8f5831afddc06a2/src/Model/Editor.coffee", "line_start": 58, "line_end": 97}455{"id": "cdglabs/apparatus:src/Model/Editor.coffee:2:raw_corpus", "type": "raw_corpus", "prompt": "", "response": "# Local Storage\n # ===========================================================================\n\n localStorageName: \"apparatus\"\n\n saveToLocalStorage: ->\n jsonString = @save()\n window.localStorage[@localStorageName] = jsonString\n\n loadFromLocalStorage: ->\n jsonString = window.localStorage[@localStorageName]\n if jsonString\n @load(jsonString)\n\n resetLocalStorage: ->\n delete window.localStorage[@localStorageName]\n\n\n # ===========================================================================\n # File System\n # ===========================================================================\n\n saveToFile: ->\n jsonString = @save()\n fileName = @project.editingElement.label + \".json\"\n Storage.saveFile(jsonString, fileName, \"application/json;charset=utf-8\")\n\n\n # ===========================================================================\n # Revision History\n # ===========================================================================\n\n checkpoint: ->\n @saveToLocalStorage()\n\n # TODO: undo, redo", "source_lang": "", "target_lang": "CoffeeScript", "repo": "cdglabs/apparatus", "path": "src/Model/Editor.coffee", "license": "MIT", "commit": "9f376cbe85686e8b2d6e773ae7acb849d664d605", "stars": 1052, "source_url": "https://github.com/cdglabs/apparatus/blob/9f376cbe85686e8b2d6e773ae7acb849d664d605/src/Model/Editor.coffee", "line_start": 58, "line_end": 93}456{"id": "cdglabs/apparatus:src/Model/Editor.coffee:2:coffee_to_js", "type": "coffee_to_js", "prompt": "Convert this CoffeeScript to JavaScript.\n```coffeescript\n# Local Storage\n # ===========================================================================\n\n localStorageName: \"apparatus\"\n\n saveToLocalStorage: ->\n jsonString = @save()\n window.localStorage[@localStorageName] = jsonString\n\n loadFromLocalStorage: ->\n jsonString = window.localStorage[@localStorageName]\n if jsonString\n @load(jsonString)\n\n resetLocalStorage: ->\n delete window.localStorage[@localStorageName]\n\n\n # ===========================================================================\n # File System\n # ===========================================================================\n\n saveToFile: ->\n jsonString = @save()\n fileName = @project.editingElement.label + \".json\"\n Storage.saveFile(jsonString, fileName, \"application/json;charset=utf-8\")\n\n\n # ===========================================================================\n # Revision History\n # ===========================================================================\n\n checkpoint: ->\n @saveToLocalStorage()\n\n # TODO: undo, redo\n```", "response": "// Local Storage\n// ===========================================================================\n({\n localStorageName: \"apparatus\",\n saveToLocalStorage: function() {\n var jsonString;\n jsonString = this.save();\n return window.localStorage[this.localStorageName] = jsonString;\n },\n loadFromLocalStorage: function() {\n var jsonString;\n jsonString = window.localStorage[this.localStorageName];\n if (jsonString) {\n return this.load(jsonString);\n }\n },\n resetLocalStorage: function() {\n return delete window.localStorage[this.localStorageName];\n },\n // ===========================================================================\n // File System\n // ===========================================================================\n saveToFile: function() {\n var fileName, jsonString;\n jsonString = this.save();\n fileName = this.project.editingElement.label + \".json\";\n return Storage.saveFile(jsonString, fileName, \"application/json;charset=utf-8\");\n },\n // ===========================================================================\n // Revision History\n // ===========================================================================\n checkpoint: function() {\n return this.saveToLocalStorage();\n }\n});\n\n// TODO: undo, redo", "source_lang": "CoffeeScript", "target_lang": "JavaScript", "repo": "cdglabs/apparatus", "path": "src/Model/Editor.coffee", "license": "MIT", "commit": "9f376cbe85686e8b2d6e773ae7acb849d664d605", "stars": 1052, "source_url": "https://github.com/cdglabs/apparatus/blob/9f376cbe85686e8b2d6e773ae7acb849d664d605/src/Model/Editor.coffee", "line_start": 58, "line_end": 93}457{"id": "cdglabs/apparatus:src/Model/Editor.coffee:2:js_to_coffee", "type": "js_to_coffee", "prompt": "Convert this JavaScript to CoffeeScript.\n```javascript\n// Local Storage\n// ===========================================================================\n({\n localStorageName: \"apparatus\",\n saveToLocalStorage: function() {\n var jsonString;\n jsonString = this.save();\n return window.localStorage[this.localStorageName] = jsonString;\n },\n loadFromLocalStorage: function() {\n var jsonString;\n jsonString = window.localStorage[this.localStorageName];\n if (jsonString) {\n return this.load(jsonString);\n }\n },\n resetLocalStorage: function() {\n return delete window.localStorage[this.localStorageName];\n },\n // ===========================================================================\n // File System\n // ===========================================================================\n saveToFile: function() {\n var fileName, jsonString;\n jsonString = this.save();\n fileName = this.project.editingElement.label + \".json\";\n return Storage.saveFile(jsonString, fileName, \"application/json;charset=utf-8\");\n },\n // ===========================================================================\n // Revision History\n // ===========================================================================\n checkpoint: function() {\n return this.saveToLocalStorage();\n }\n});\n\n// TODO: undo, redo\n```", "response": "# Local Storage\n # ===========================================================================\n\n localStorageName: \"apparatus\"\n\n saveToLocalStorage: ->\n jsonString = @save()\n window.localStorage[@localStorageName] = jsonString\n\n loadFromLocalStorage: ->\n jsonString = window.localStorage[@localStorageName]\n if jsonString\n @load(jsonString)\n\n resetLocalStorage: ->\n delete window.localStorage[@localStorageName]\n\n\n # ===========================================================================\n # File System\n # ===========================================================================\n\n saveToFile: ->\n jsonString = @save()\n fileName = @project.editingElement.label + \".json\"\n Storage.saveFile(jsonString, fileName, \"application/json;charset=utf-8\")\n\n\n # ===========================================================================\n # Revision History\n # ===========================================================================\n\n checkpoint: ->\n @saveToLocalStorage()\n\n # TODO: undo, redo", "source_lang": "JavaScript", "target_lang": "CoffeeScript", "repo": "cdglabs/apparatus", "path": "src/Model/Editor.coffee", "license": "MIT", "commit": "9f376cbe85686e8b2d6e773ae7acb849d664d605", "stars": 1052, "source_url": "https://github.com/cdglabs/apparatus/blob/9f376cbe85686e8b2d6e773ae7acb849d664d605/src/Model/Editor.coffee", "line_start": 58, "line_end": 93}458{"id": "cdglabs/apparatus:src/Model/Editor.coffee:2:completion", "type": "completion", "prompt": "# Local Storage\n # ===========================================================================\n\n localStorageName: \"apparatus\"\n\n saveToLocalStorage: ->\n jsonString = @save()\n window.localStorage[@localStorageName] = jsonString\n\n loadFromLocalStorage: ->\n jsonString = window.localStorage[@localStorageName]\n if jsonString\n @load(jsonString)\n\n resetLocalStorage: ->\n delete window.localStorage[@localStorageName]", "response": "# ===========================================================================\n # File System\n # ===========================================================================\n\n saveToFile: ->\n jsonString = @save()\n fileName = @project.editingElement.label + \".json\"\n Storage.saveFile(jsonString, fileName, \"application/json;charset=utf-8\")\n\n\n # ===========================================================================\n # Revision History\n # ===========================================================================\n\n checkpoint: ->\n @saveToLocalStorage()\n\n # TODO: undo, redo", "source_lang": "CoffeeScript", "target_lang": "CoffeeScript", "repo": "cdglabs/apparatus", "path": "src/Model/Editor.coffee", "license": "MIT", "commit": "9f376cbe85686e8b2d6e773ae7acb849d664d605", "stars": 1052, "source_url": "https://github.com/cdglabs/apparatus/blob/9f376cbe85686e8b2d6e773ae7acb849d664d605/src/Model/Editor.coffee", "line_start": 58, "line_end": 93}459{"id": "cdglabs/apparatus:src/Model/Editor.coffee:1:raw_corpus", "type": "raw_corpus", "prompt": "", "response": "module.exports = class Editor\n constructor: ->\n @_setupSerializer()\n @_setupProject()\n\n _setupProject: ->\n @loadFromLocalStorage()\n if !@project\n @project = new Model.Project()\n\n _setupSerializer: ->\n builtInObjects = []\n for own name, object of @_builtIn()\n if _.isFunction(object)\n object = object.prototype\n Util.assignId(object, name)\n builtInObjects.push(object)\n @serializer = new Storage.Serializer(builtInObjects)\n\n # builtIn returns all of the built in classes and objects that are used as\n # the \"anchors\" for serialization and deserialization. That is, all of the\n # objects and classes which should not themselves be serialized but instead\n # be *referenced* from a serialization. When deserialized, these references\n # are then bound appropriately.\n _builtIn: ->\n builtIn = _.clone(Model)\n builtIn[\"SpreadEnv\"] = Dataflow.SpreadEnv\n builtIn[\"Matrix\"] = Util.Matrix\n return builtIn\n\n # TODO: get version via build process / ENV variable?\n version: \"0.4.0\"\n\n load: (jsonString) ->\n json = JSON.parse(jsonString)\n if json.type == \"Apparatus\" and json.version == @version\n @project = @serializer.dejsonify(json)\n\n save: ->\n json = @serializer.jsonify(@project)\n json.type = \"Apparatus\"\n json.version = @version\n jsonString = JSON.stringify(json)\n return jsonString\n\n\n # ===========================================================================\n # Local Storage\n # ===========================================================================", "source_lang": "", "target_lang": "CoffeeScript", "repo": "cdglabs/apparatus", "path": "src/Model/Editor.coffee", "license": "MIT", "commit": "cf852f8f3204e99b0b82086a5e12c68ca40a225e", "stars": 1052, "source_url": "https://github.com/cdglabs/apparatus/blob/cf852f8f3204e99b0b82086a5e12c68ca40a225e/src/Model/Editor.coffee", "line_start": 8, "line_end": 57}460{"id": "cdglabs/apparatus:src/Model/Editor.coffee:1:coffee_to_js", "type": "coffee_to_js", "prompt": "Convert this CoffeeScript to JavaScript.\n```coffeescript\nmodule.exports = class Editor\n constructor: ->\n @_setupSerializer()\n @_setupProject()\n\n _setupProject: ->\n @loadFromLocalStorage()\n if !@project\n @project = new Model.Project()\n\n _setupSerializer: ->\n builtInObjects = []\n for own name, object of @_builtIn()\n if _.isFunction(object)\n object = object.prototype\n Util.assignId(object, name)\n builtInObjects.push(object)\n @serializer = new Storage.Serializer(builtInObjects)\n\n # builtIn returns all of the built in classes and objects that are used as\n # the \"anchors\" for serialization and deserialization. That is, all of the\n # objects and classes which should not themselves be serialized but instead\n # be *referenced* from a serialization. When deserialized, these references\n # are then bound appropriately.\n _builtIn: ->\n builtIn = _.clone(Model)\n builtIn[\"SpreadEnv\"] = Dataflow.SpreadEnv\n builtIn[\"Matrix\"] = Util.Matrix\n return builtIn\n\n # TODO: get version via build process / ENV variable?\n version: \"0.4.0\"\n\n load: (jsonString) ->\n json = JSON.parse(jsonString)\n if json.type == \"Apparatus\" and json.version == @version\n @project = @serializer.dejsonify(json)\n\n save: ->\n json = @serializer.jsonify(@project)\n json.type = \"Apparatus\"\n json.version = @version\n jsonString = JSON.stringify(json)\n return jsonString\n\n\n # ===========================================================================\n # Local Storage\n # ===========================================================================\n```", "response": "var Editor,\n hasProp = {}.hasOwnProperty;\n\nmodule.exports = Editor = (function() {\n class Editor {\n constructor() {\n this._setupSerializer();\n this._setupProject();\n }\n\n _setupProject() {\n this.loadFromLocalStorage();\n if (!this.project) {\n return this.project = new Model.Project();\n }\n }\n\n _setupSerializer() {\n var builtInObjects, name, object, ref;\n builtInObjects = [];\n ref = this._builtIn();\n for (name in ref) {\n if (!hasProp.call(ref, name)) continue;\n object = ref[name];\n if (_.isFunction(object)) {\n object = object.prototype;\n }\n Util.assignId(object, name);\n builtInObjects.push(object);\n }\n return this.serializer = new Storage.Serializer(builtInObjects);\n }\n\n // builtIn returns all of the built in classes and objects that are used as\n // the \"anchors\" for serialization and deserialization. That is, all of the\n // objects and classes which should not themselves be serialized but instead\n // be *referenced* from a serialization. When deserialized, these references\n // are then bound appropriately.\n _builtIn() {\n var builtIn;\n builtIn = _.clone(Model);\n builtIn[\"SpreadEnv\"] = Dataflow.SpreadEnv;\n builtIn[\"Matrix\"] = Util.Matrix;\n return builtIn;\n }\n\n load(jsonString) {\n var json;\n json = JSON.parse(jsonString);\n if (json.type === \"Apparatus\" && json.version === this.version) {\n return this.project = this.serializer.dejsonify(json);\n }\n }\n\n save() {\n var json, jsonString;\n json = this.serializer.jsonify(this.project);\n json.type = \"Apparatus\";\n json.version = this.version;\n jsonString = JSON.stringify(json);\n return jsonString;\n }\n\n };\n\n // TODO: get version via build process / ENV variable?\n Editor.prototype.version = \"0.4.0\";\n\n return Editor;\n\n}).call(this);\n\n// ===========================================================================\n// Local Storage\n// ===========================================================================", "source_lang": "CoffeeScript", "target_lang": "JavaScript", "repo": "cdglabs/apparatus", "path": "src/Model/Editor.coffee", "license": "MIT", "commit": "cf852f8f3204e99b0b82086a5e12c68ca40a225e", "stars": 1052, "source_url": "https://github.com/cdglabs/apparatus/blob/cf852f8f3204e99b0b82086a5e12c68ca40a225e/src/Model/Editor.coffee", "line_start": 8, "line_end": 57}461{"id": "cdglabs/apparatus:src/Model/Editor.coffee:1:js_to_coffee", "type": "js_to_coffee", "prompt": "Convert this JavaScript to CoffeeScript.\n```javascript\nvar Editor,\n hasProp = {}.hasOwnProperty;\n\nmodule.exports = Editor = (function() {\n class Editor {\n constructor() {\n this._setupSerializer();\n this._setupProject();\n }\n\n _setupProject() {\n this.loadFromLocalStorage();\n if (!this.project) {\n return this.project = new Model.Project();\n }\n }\n\n _setupSerializer() {\n var builtInObjects, name, object, ref;\n builtInObjects = [];\n ref = this._builtIn();\n for (name in ref) {\n if (!hasProp.call(ref, name)) continue;\n object = ref[name];\n if (_.isFunction(object)) {\n object = object.prototype;\n }\n Util.assignId(object, name);\n builtInObjects.push(object);\n }\n return this.serializer = new Storage.Serializer(builtInObjects);\n }\n\n // builtIn returns all of the built in classes and objects that are used as\n // the \"anchors\" for serialization and deserialization. That is, all of the\n // objects and classes which should not themselves be serialized but instead\n // be *referenced* from a serialization. When deserialized, these references\n // are then bound appropriately.\n _builtIn() {\n var builtIn;\n builtIn = _.clone(Model);\n builtIn[\"SpreadEnv\"] = Dataflow.SpreadEnv;\n builtIn[\"Matrix\"] = Util.Matrix;\n return builtIn;\n }\n\n load(jsonString) {\n var json;\n json = JSON.parse(jsonString);\n if (json.type === \"Apparatus\" && json.version === this.version) {\n return this.project = this.serializer.dejsonify(json);\n }\n }\n\n save() {\n var json, jsonString;\n json = this.serializer.jsonify(this.project);\n json.type = \"Apparatus\";\n json.version = this.version;\n jsonString = JSON.stringify(json);\n return jsonString;\n }\n\n };\n\n // TODO: get version via build process / ENV variable?\n Editor.prototype.version = \"0.4.0\";\n\n return Editor;\n\n}).call(this);\n\n// ===========================================================================\n// Local Storage\n// ===========================================================================\n```", "response": "module.exports = class Editor\n constructor: ->\n @_setupSerializer()\n @_setupProject()\n\n _setupProject: ->\n @loadFromLocalStorage()\n if !@project\n @project = new Model.Project()\n\n _setupSerializer: ->\n builtInObjects = []\n for own name, object of @_builtIn()\n if _.isFunction(object)\n object = object.prototype\n Util.assignId(object, name)\n builtInObjects.push(object)\n @serializer = new Storage.Serializer(builtInObjects)\n\n # builtIn returns all of the built in classes and objects that are used as\n # the \"anchors\" for serialization and deserialization. That is, all of the\n # objects and classes which should not themselves be serialized but instead\n # be *referenced* from a serialization. When deserialized, these references\n # are then bound appropriately.\n _builtIn: ->\n builtIn = _.clone(Model)\n builtIn[\"SpreadEnv\"] = Dataflow.SpreadEnv\n builtIn[\"Matrix\"] = Util.Matrix\n return builtIn\n\n # TODO: get version via build process / ENV variable?\n version: \"0.4.0\"\n\n load: (jsonString) ->\n json = JSON.parse(jsonString)\n if json.type == \"Apparatus\" and json.version == @version\n @project = @serializer.dejsonify(json)\n\n save: ->\n json = @serializer.jsonify(@project)\n json.type = \"Apparatus\"\n json.version = @version\n jsonString = JSON.stringify(json)\n return jsonString\n\n\n # ===========================================================================\n # Local Storage\n # ===========================================================================", "source_lang": "JavaScript", "target_lang": "CoffeeScript", "repo": "cdglabs/apparatus", "path": "src/Model/Editor.coffee", "license": "MIT", "commit": "cf852f8f3204e99b0b82086a5e12c68ca40a225e", "stars": 1052, "source_url": "https://github.com/cdglabs/apparatus/blob/cf852f8f3204e99b0b82086a5e12c68ca40a225e/src/Model/Editor.coffee", "line_start": 8, "line_end": 57}462{"id": "cdglabs/apparatus:src/Model/Editor.coffee:1:completion", "type": "completion", "prompt": "module.exports = class Editor\n constructor: ->\n @_setupSerializer()\n @_setupProject()\n\n _setupProject: ->\n @loadFromLocalStorage()\n if !@project\n @project = new Model.Project()\n\n _setupSerializer: ->\n builtInObjects = []\n for own name, object of @_builtIn()\n if _.isFunction(object)\n object = object.prototype\n Util.assignId(object, name)\n builtInObjects.push(object)\n @serializer = new Storage.Serializer(builtInObjects)\n\n # builtIn returns all of the built in classes and objects that are used as\n # the \"anchors\" for serialization and deserialization. That is, all of the\n # objects and classes which should not themselves be serialized but instead\n # be *referenced* from a serialization. When deserialized, these references\n # are then bound appropriately.", "response": "_builtIn: ->\n builtIn = _.clone(Model)\n builtIn[\"SpreadEnv\"] = Dataflow.SpreadEnv\n builtIn[\"Matrix\"] = Util.Matrix\n return builtIn\n\n # TODO: get version via build process / ENV variable?\n version: \"0.4.0\"\n\n load: (jsonString) ->\n json = JSON.parse(jsonString)\n if json.type == \"Apparatus\" and json.version == @version\n @project = @serializer.dejsonify(json)\n\n save: ->\n json = @serializer.jsonify(@project)\n json.type = \"Apparatus\"\n json.version = @version\n jsonString = JSON.stringify(json)\n return jsonString\n\n\n # ===========================================================================\n # Local Storage\n # ===========================================================================", "source_lang": "CoffeeScript", "target_lang": "CoffeeScript", "repo": "cdglabs/apparatus", "path": "src/Model/Editor.coffee", "license": "MIT", "commit": "cf852f8f3204e99b0b82086a5e12c68ca40a225e", "stars": 1052, "source_url": "https://github.com/cdglabs/apparatus/blob/cf852f8f3204e99b0b82086a5e12c68ca40a225e/src/Model/Editor.coffee", "line_start": 8, "line_end": 57}463{"id": "cdglabs/apparatus:src/Model/Editor.coffee:2:raw_corpus", "type": "raw_corpus", "prompt": "", "response": "localStorageName: \"apparatus\"\n\n saveToLocalStorage: ->\n jsonString = @save()\n window.localStorage[@localStorageName] = jsonString\n\n loadFromLocalStorage: ->\n jsonString = window.localStorage[@localStorageName]\n if jsonString\n @load(jsonString)\n\n resetLocalStorage: ->\n delete window.localStorage[@localStorageName]\n\n\n # ===========================================================================\n # File System\n # ===========================================================================\n\n saveToFile: ->\n jsonString = @save()\n fileName = @project.editingElement.label + \".json\"\n Storage.saveFile(jsonString, fileName, \"application/json;charset=utf-8\")\n\n\n # ===========================================================================\n # Revision History\n # ===========================================================================\n\n checkpoint: ->\n @saveToLocalStorage()\n\n # TODO: undo, redo", "source_lang": "", "target_lang": "CoffeeScript", "repo": "cdglabs/apparatus", "path": "src/Model/Editor.coffee", "license": "MIT", "commit": "cf852f8f3204e99b0b82086a5e12c68ca40a225e", "stars": 1052, "source_url": "https://github.com/cdglabs/apparatus/blob/cf852f8f3204e99b0b82086a5e12c68ca40a225e/src/Model/Editor.coffee", "line_start": 58, "line_end": 90}464{"id": "cdglabs/apparatus:src/Model/Editor.coffee:2:completion", "type": "completion", "prompt": "localStorageName: \"apparatus\"\n\n saveToLocalStorage: ->\n jsonString = @save()\n window.localStorage[@localStorageName] = jsonString\n\n loadFromLocalStorage: ->\n jsonString = window.localStorage[@localStorageName]\n if jsonString\n @load(jsonString)\n\n resetLocalStorage: ->\n delete window.localStorage[@localStorageName]\n\n\n # ===========================================================================", "response": "# File System\n # ===========================================================================\n\n saveToFile: ->\n jsonString = @save()\n fileName = @project.editingElement.label + \".json\"\n Storage.saveFile(jsonString, fileName, \"application/json;charset=utf-8\")\n\n\n # ===========================================================================\n # Revision History\n # ===========================================================================\n\n checkpoint: ->\n @saveToLocalStorage()\n\n # TODO: undo, redo", "source_lang": "CoffeeScript", "target_lang": "CoffeeScript", "repo": "cdglabs/apparatus", "path": "src/Model/Editor.coffee", "license": "MIT", "commit": "cf852f8f3204e99b0b82086a5e12c68ca40a225e", "stars": 1052, "source_url": "https://github.com/cdglabs/apparatus/blob/cf852f8f3204e99b0b82086a5e12c68ca40a225e/src/Model/Editor.coffee", "line_start": 58, "line_end": 90}465{"id": "cdglabs/apparatus:src/Model/Editor.coffee:1:raw_corpus", "type": "raw_corpus", "prompt": "", "response": "_ = require \"underscore\"\nDataflow = require \"../Dataflow/Dataflow\"\nModel = require \"./Model\"\nUtil = require \"../Util/Util\"\nStorage = require \"../Storage/Storage\"\n\n\nmodule.exports = class Editor\n constructor: ->\n @_setupSerializer()\n @_setupProject()\n\n _setupProject: ->\n @loadFromLocalStorage()\n if !@project\n @project = new Model.Project()\n\n _setupSerializer: ->\n builtInObjects = []\n for own name, object of @_builtIn()\n if _.isFunction(object)\n object = object.prototype\n Util.assignId(object, name)\n builtInObjects.push(object)\n @serializer = new Storage.Serializer(builtInObjects)\n\n # builtIn returns all of the built in classes and objects that are used as\n # the \"anchors\" for serialization and deserialization. That is, all of the\n # objects and classes which should not themselves be serialized but instead\n # be *referenced* from a serialization. When deserialized, these references\n # are then bound appropriately.\n _builtIn: ->\n builtIn = _.clone(Model)\n builtIn[\"SpreadEnv\"] = Dataflow.SpreadEnv\n builtIn[\"Matrix\"] = Util.Matrix\n return builtIn\n\n # TODO: get version via build process / ENV variable?\n version: \"0.4.0\"\n\n load: (jsonString) ->\n json = JSON.parse(jsonString)\n if json.type == \"Apparatus\" and json.version == @version\n @project = @serializer.dejsonify(json)\n\n save: ->\n json = @serializer.jsonify(@project)\n json.type = \"Apparatus\"\n json.version = @version\n jsonString = JSON.stringify(json)", "source_lang": "", "target_lang": "CoffeeScript", "repo": "cdglabs/apparatus", "path": "src/Model/Editor.coffee", "license": "MIT", "commit": "8488c61d326045c635d28cfa1580a37deeb7fecc", "stars": 1052, "source_url": "https://github.com/cdglabs/apparatus/blob/8488c61d326045c635d28cfa1580a37deeb7fecc/src/Model/Editor.coffee", "line_start": 1, "line_end": 50}466{"id": "cdglabs/apparatus:src/Model/Editor.coffee:1:coffee_to_js", "type": "coffee_to_js", "prompt": "Convert this CoffeeScript to JavaScript.\n```coffeescript\n_ = require \"underscore\"\nDataflow = require \"../Dataflow/Dataflow\"\nModel = require \"./Model\"\nUtil = require \"../Util/Util\"\nStorage = require \"../Storage/Storage\"\n\n\nmodule.exports = class Editor\n constructor: ->\n @_setupSerializer()\n @_setupProject()\n\n _setupProject: ->\n @loadFromLocalStorage()\n if !@project\n @project = new Model.Project()\n\n _setupSerializer: ->\n builtInObjects = []\n for own name, object of @_builtIn()\n if _.isFunction(object)\n object = object.prototype\n Util.assignId(object, name)\n builtInObjects.push(object)\n @serializer = new Storage.Serializer(builtInObjects)\n\n # builtIn returns all of the built in classes and objects that are used as\n # the \"anchors\" for serialization and deserialization. That is, all of the\n # objects and classes which should not themselves be serialized but instead\n # be *referenced* from a serialization. When deserialized, these references\n # are then bound appropriately.\n _builtIn: ->\n builtIn = _.clone(Model)\n builtIn[\"SpreadEnv\"] = Dataflow.SpreadEnv\n builtIn[\"Matrix\"] = Util.Matrix\n return builtIn\n\n # TODO: get version via build process / ENV variable?\n version: \"0.4.0\"\n\n load: (jsonString) ->\n json = JSON.parse(jsonString)\n if json.type == \"Apparatus\" and json.version == @version\n @project = @serializer.dejsonify(json)\n\n save: ->\n json = @serializer.jsonify(@project)\n json.type = \"Apparatus\"\n json.version = @version\n jsonString = JSON.stringify(json)\n```", "response": "var Dataflow, Editor, Model, Storage, Util, _,\n hasProp = {}.hasOwnProperty;\n\n_ = require(\"underscore\");\n\nDataflow = require(\"../Dataflow/Dataflow\");\n\nModel = require(\"./Model\");\n\nUtil = require(\"../Util/Util\");\n\nStorage = require(\"../Storage/Storage\");\n\nmodule.exports = Editor = (function() {\n class Editor {\n constructor() {\n this._setupSerializer();\n this._setupProject();\n }\n\n _setupProject() {\n this.loadFromLocalStorage();\n if (!this.project) {\n return this.project = new Model.Project();\n }\n }\n\n _setupSerializer() {\n var builtInObjects, name, object, ref;\n builtInObjects = [];\n ref = this._builtIn();\n for (name in ref) {\n if (!hasProp.call(ref, name)) continue;\n object = ref[name];\n if (_.isFunction(object)) {\n object = object.prototype;\n }\n Util.assignId(object, name);\n builtInObjects.push(object);\n }\n return this.serializer = new Storage.Serializer(builtInObjects);\n }\n\n // builtIn returns all of the built in classes and objects that are used as\n // the \"anchors\" for serialization and deserialization. That is, all of the\n // objects and classes which should not themselves be serialized but instead\n // be *referenced* from a serialization. When deserialized, these references\n // are then bound appropriately.\n _builtIn() {\n var builtIn;\n builtIn = _.clone(Model);\n builtIn[\"SpreadEnv\"] = Dataflow.SpreadEnv;\n builtIn[\"Matrix\"] = Util.Matrix;\n return builtIn;\n }\n\n load(jsonString) {\n var json;\n json = JSON.parse(jsonString);\n if (json.type === \"Apparatus\" && json.version === this.version) {\n return this.project = this.serializer.dejsonify(json);\n }\n }\n\n save() {\n var json, jsonString;\n json = this.serializer.jsonify(this.project);\n json.type = \"Apparatus\";\n json.version = this.version;\n return jsonString = JSON.stringify(json);\n }\n\n };\n\n // TODO: get version via build process / ENV variable?\n Editor.prototype.version = \"0.4.0\";\n\n return Editor;\n\n}).call(this);", "source_lang": "CoffeeScript", "target_lang": "JavaScript", "repo": "cdglabs/apparatus", "path": "src/Model/Editor.coffee", "license": "MIT", "commit": "8488c61d326045c635d28cfa1580a37deeb7fecc", "stars": 1052, "source_url": "https://github.com/cdglabs/apparatus/blob/8488c61d326045c635d28cfa1580a37deeb7fecc/src/Model/Editor.coffee", "line_start": 1, "line_end": 50}467{"id": "cdglabs/apparatus:src/Model/Editor.coffee:1:js_to_coffee", "type": "js_to_coffee", "prompt": "Convert this JavaScript to CoffeeScript.\n```javascript\nvar Dataflow, Editor, Model, Storage, Util, _,\n hasProp = {}.hasOwnProperty;\n\n_ = require(\"underscore\");\n\nDataflow = require(\"../Dataflow/Dataflow\");\n\nModel = require(\"./Model\");\n\nUtil = require(\"../Util/Util\");\n\nStorage = require(\"../Storage/Storage\");\n\nmodule.exports = Editor = (function() {\n class Editor {\n constructor() {\n this._setupSerializer();\n this._setupProject();\n }\n\n _setupProject() {\n this.loadFromLocalStorage();\n if (!this.project) {\n return this.project = new Model.Project();\n }\n }\n\n _setupSerializer() {\n var builtInObjects, name, object, ref;\n builtInObjects = [];\n ref = this._builtIn();\n for (name in ref) {\n if (!hasProp.call(ref, name)) continue;\n object = ref[name];\n if (_.isFunction(object)) {\n object = object.prototype;\n }\n Util.assignId(object, name);\n builtInObjects.push(object);\n }\n return this.serializer = new Storage.Serializer(builtInObjects);\n }\n\n // builtIn returns all of the built in classes and objects that are used as\n // the \"anchors\" for serialization and deserialization. That is, all of the\n // objects and classes which should not themselves be serialized but instead\n // be *referenced* from a serialization. When deserialized, these references\n // are then bound appropriately.\n _builtIn() {\n var builtIn;\n builtIn = _.clone(Model);\n builtIn[\"SpreadEnv\"] = Dataflow.SpreadEnv;\n builtIn[\"Matrix\"] = Util.Matrix;\n return builtIn;\n }\n\n load(jsonString) {\n var json;\n json = JSON.parse(jsonString);\n if (json.type === \"Apparatus\" && json.version === this.version) {\n return this.project = this.serializer.dejsonify(json);\n }\n }\n\n save() {\n var json, jsonString;\n json = this.serializer.jsonify(this.project);\n json.type = \"Apparatus\";\n json.version = this.version;\n return jsonString = JSON.stringify(json);\n }\n\n };\n\n // TODO: get version via build process / ENV variable?\n Editor.prototype.version = \"0.4.0\";\n\n return Editor;\n\n}).call(this);\n```", "response": "_ = require \"underscore\"\nDataflow = require \"../Dataflow/Dataflow\"\nModel = require \"./Model\"\nUtil = require \"../Util/Util\"\nStorage = require \"../Storage/Storage\"\n\n\nmodule.exports = class Editor\n constructor: ->\n @_setupSerializer()\n @_setupProject()\n\n _setupProject: ->\n @loadFromLocalStorage()\n if !@project\n @project = new Model.Project()\n\n _setupSerializer: ->\n builtInObjects = []\n for own name, object of @_builtIn()\n if _.isFunction(object)\n object = object.prototype\n Util.assignId(object, name)\n builtInObjects.push(object)\n @serializer = new Storage.Serializer(builtInObjects)\n\n # builtIn returns all of the built in classes and objects that are used as\n # the \"anchors\" for serialization and deserialization. That is, all of the\n # objects and classes which should not themselves be serialized but instead\n # be *referenced* from a serialization. When deserialized, these references\n # are then bound appropriately.\n _builtIn: ->\n builtIn = _.clone(Model)\n builtIn[\"SpreadEnv\"] = Dataflow.SpreadEnv\n builtIn[\"Matrix\"] = Util.Matrix\n return builtIn\n\n # TODO: get version via build process / ENV variable?\n version: \"0.4.0\"\n\n load: (jsonString) ->\n json = JSON.parse(jsonString)\n if json.type == \"Apparatus\" and json.version == @version\n @project = @serializer.dejsonify(json)\n\n save: ->\n json = @serializer.jsonify(@project)\n json.type = \"Apparatus\"\n json.version = @version\n jsonString = JSON.stringify(json)", "source_lang": "JavaScript", "target_lang": "CoffeeScript", "repo": "cdglabs/apparatus", "path": "src/Model/Editor.coffee", "license": "MIT", "commit": "8488c61d326045c635d28cfa1580a37deeb7fecc", "stars": 1052, "source_url": "https://github.com/cdglabs/apparatus/blob/8488c61d326045c635d28cfa1580a37deeb7fecc/src/Model/Editor.coffee", "line_start": 1, "line_end": 50}468{"id": "cdglabs/apparatus:src/Model/Editor.coffee:1:completion", "type": "completion", "prompt": "_ = require \"underscore\"\nDataflow = require \"../Dataflow/Dataflow\"\nModel = require \"./Model\"\nUtil = require \"../Util/Util\"\nStorage = require \"../Storage/Storage\"\n\n\nmodule.exports = class Editor\n constructor: ->\n @_setupSerializer()\n @_setupProject()\n\n _setupProject: ->\n @loadFromLocalStorage()\n if !@project\n @project = new Model.Project()\n\n _setupSerializer: ->\n builtInObjects = []\n for own name, object of @_builtIn()\n if _.isFunction(object)\n object = object.prototype\n Util.assignId(object, name)\n builtInObjects.push(object)\n @serializer = new Storage.Serializer(builtInObjects)", "response": "# builtIn returns all of the built in classes and objects that are used as\n # the \"anchors\" for serialization and deserialization. That is, all of the\n # objects and classes which should not themselves be serialized but instead\n # be *referenced* from a serialization. When deserialized, these references\n # are then bound appropriately.\n _builtIn: ->\n builtIn = _.clone(Model)\n builtIn[\"SpreadEnv\"] = Dataflow.SpreadEnv\n builtIn[\"Matrix\"] = Util.Matrix\n return builtIn\n\n # TODO: get version via build process / ENV variable?\n version: \"0.4.0\"\n\n load: (jsonString) ->\n json = JSON.parse(jsonString)\n if json.type == \"Apparatus\" and json.version == @version\n @project = @serializer.dejsonify(json)\n\n save: ->\n json = @serializer.jsonify(@project)\n json.type = \"Apparatus\"\n json.version = @version\n jsonString = JSON.stringify(json)", "source_lang": "CoffeeScript", "target_lang": "CoffeeScript", "repo": "cdglabs/apparatus", "path": "src/Model/Editor.coffee", "license": "MIT", "commit": "8488c61d326045c635d28cfa1580a37deeb7fecc", "stars": 1052, "source_url": "https://github.com/cdglabs/apparatus/blob/8488c61d326045c635d28cfa1580a37deeb7fecc/src/Model/Editor.coffee", "line_start": 1, "line_end": 50}469{"id": "cdglabs/apparatus:src/Model/Editor.coffee:2:raw_corpus", "type": "raw_corpus", "prompt": "", "response": "return jsonString\n\n\n # ===========================================================================\n # Local Storage\n # ===========================================================================\n\n localStorageName: \"apparatus\"\n\n saveToLocalStorage: ->\n jsonString = @save()\n window.localStorage[@localStorageName] = jsonString\n\n loadFromLocalStorage: ->\n jsonString = window.localStorage[@localStorageName]\n if jsonString\n @load(jsonString)\n\n resetLocalStorage: ->\n delete window.localStorage[@localStorageName]\n\n\n # ===========================================================================\n # Revision History\n # ===========================================================================\n\n checkpoint: ->\n @saveToLocalStorage()\n\n # TODO: undo, redo", "source_lang": "", "target_lang": "CoffeeScript", "repo": "cdglabs/apparatus", "path": "src/Model/Editor.coffee", "license": "MIT", "commit": "8488c61d326045c635d28cfa1580a37deeb7fecc", "stars": 1052, "source_url": "https://github.com/cdglabs/apparatus/blob/8488c61d326045c635d28cfa1580a37deeb7fecc/src/Model/Editor.coffee", "line_start": 51, "line_end": 80}470{"id": "cdglabs/apparatus:src/Model/Editor.coffee:2:coffee_to_js", "type": "coffee_to_js", "prompt": "Convert this CoffeeScript to JavaScript.\n```coffeescript\nreturn jsonString\n\n\n # ===========================================================================\n # Local Storage\n # ===========================================================================\n\n localStorageName: \"apparatus\"\n\n saveToLocalStorage: ->\n jsonString = @save()\n window.localStorage[@localStorageName] = jsonString\n\n loadFromLocalStorage: ->\n jsonString = window.localStorage[@localStorageName]\n if jsonString\n @load(jsonString)\n\n resetLocalStorage: ->\n delete window.localStorage[@localStorageName]\n\n\n # ===========================================================================\n # Revision History\n # ===========================================================================\n\n checkpoint: ->\n @saveToLocalStorage()\n\n # TODO: undo, redo\n```", "response": "return jsonString({\n // ===========================================================================\n // Local Storage\n // ===========================================================================\n localStorageName: \"apparatus\",\n saveToLocalStorage: function() {\n var jsonString;\n jsonString = this.save();\n return window.localStorage[this.localStorageName] = jsonString;\n },\n loadFromLocalStorage: function() {\n var jsonString;\n jsonString = window.localStorage[this.localStorageName];\n if (jsonString) {\n return this.load(jsonString);\n }\n },\n resetLocalStorage: function() {\n return delete window.localStorage[this.localStorageName];\n },\n // ===========================================================================\n // Revision History\n // ===========================================================================\n checkpoint: function() {\n return this.saveToLocalStorage();\n }\n});\n\n// TODO: undo, redo", "source_lang": "CoffeeScript", "target_lang": "JavaScript", "repo": "cdglabs/apparatus", "path": "src/Model/Editor.coffee", "license": "MIT", "commit": "8488c61d326045c635d28cfa1580a37deeb7fecc", "stars": 1052, "source_url": "https://github.com/cdglabs/apparatus/blob/8488c61d326045c635d28cfa1580a37deeb7fecc/src/Model/Editor.coffee", "line_start": 51, "line_end": 80}471{"id": "cdglabs/apparatus:src/Model/Editor.coffee:2:js_to_coffee", "type": "js_to_coffee", "prompt": "Convert this JavaScript to CoffeeScript.\n```javascript\nreturn jsonString({\n // ===========================================================================\n // Local Storage\n // ===========================================================================\n localStorageName: \"apparatus\",\n saveToLocalStorage: function() {\n var jsonString;\n jsonString = this.save();\n return window.localStorage[this.localStorageName] = jsonString;\n },\n loadFromLocalStorage: function() {\n var jsonString;\n jsonString = window.localStorage[this.localStorageName];\n if (jsonString) {\n return this.load(jsonString);\n }\n },\n resetLocalStorage: function() {\n return delete window.localStorage[this.localStorageName];\n },\n // ===========================================================================\n // Revision History\n // ===========================================================================\n checkpoint: function() {\n return this.saveToLocalStorage();\n }\n});\n\n// TODO: undo, redo\n```", "response": "return jsonString\n\n\n # ===========================================================================\n # Local Storage\n # ===========================================================================\n\n localStorageName: \"apparatus\"\n\n saveToLocalStorage: ->\n jsonString = @save()\n window.localStorage[@localStorageName] = jsonString\n\n loadFromLocalStorage: ->\n jsonString = window.localStorage[@localStorageName]\n if jsonString\n @load(jsonString)\n\n resetLocalStorage: ->\n delete window.localStorage[@localStorageName]\n\n\n # ===========================================================================\n # Revision History\n # ===========================================================================\n\n checkpoint: ->\n @saveToLocalStorage()\n\n # TODO: undo, redo", "source_lang": "JavaScript", "target_lang": "CoffeeScript", "repo": "cdglabs/apparatus", "path": "src/Model/Editor.coffee", "license": "MIT", "commit": "8488c61d326045c635d28cfa1580a37deeb7fecc", "stars": 1052, "source_url": "https://github.com/cdglabs/apparatus/blob/8488c61d326045c635d28cfa1580a37deeb7fecc/src/Model/Editor.coffee", "line_start": 51, "line_end": 80}472{"id": "cdglabs/apparatus:src/Model/Editor.coffee:2:completion", "type": "completion", "prompt": "return jsonString\n\n\n # ===========================================================================\n # Local Storage\n # ===========================================================================\n\n localStorageName: \"apparatus\"\n\n saveToLocalStorage: ->\n jsonString = @save()\n window.localStorage[@localStorageName] = jsonString\n\n loadFromLocalStorage: ->\n jsonString = window.localStorage[@localStorageName]", "response": "if jsonString\n @load(jsonString)\n\n resetLocalStorage: ->\n delete window.localStorage[@localStorageName]\n\n\n # ===========================================================================\n # Revision History\n # ===========================================================================\n\n checkpoint: ->\n @saveToLocalStorage()\n\n # TODO: undo, redo", "source_lang": "CoffeeScript", "target_lang": "CoffeeScript", "repo": "cdglabs/apparatus", "path": "src/Model/Editor.coffee", "license": "MIT", "commit": "8488c61d326045c635d28cfa1580a37deeb7fecc", "stars": 1052, "source_url": "https://github.com/cdglabs/apparatus/blob/8488c61d326045c635d28cfa1580a37deeb7fecc/src/Model/Editor.coffee", "line_start": 51, "line_end": 80}473{"id": "cdglabs/apparatus:src/Model/Editor.coffee:1:raw_corpus", "type": "raw_corpus", "prompt": "", "response": "_ = require \"underscore\"\nModel = require \"./Model\"\nUtil = require \"../Util/Util\"\nStorage = require \"../Storage/Storage\"\n\n\nmodule.exports = class Editor\n constructor: ->\n @_setupSerializer()\n @_setupProject()\n\n _setupProject: ->\n @loadFromLocalStorage()\n if !@project\n @project = new Model.Project()\n\n _setupSerializer: ->\n builtInObjects = []\n for own name, object of Model\n if _.isFunction(object)\n object = object.prototype\n Util.assignId(object, name)\n builtInObjects.push(object)\n @serializer = new Storage.Serializer(builtInObjects)\n\n # TODO: get version via build process / ENV variable?\n version: \"0.4.0\"\n\n load: (jsonString) ->\n json = JSON.parse(jsonString)\n if json.type == \"Apparatus\" and json.version == @version\n @project = @serializer.dejsonify(json)\n\n save: ->\n json = @serializer.jsonify(@project)\n json.type = \"Apparatus\"\n json.version = @version\n jsonString = JSON.stringify(json)\n return jsonString\n\n\n # ===========================================================================\n # Local Storage\n # ===========================================================================\n\n localStorageName: \"apparatus\"\n\n saveToLocalStorage: ->\n jsonString = @save()\n window.localStorage[@localStorageName] = jsonString", "source_lang": "", "target_lang": "CoffeeScript", "repo": "cdglabs/apparatus", "path": "src/Model/Editor.coffee", "license": "MIT", "commit": "73bc1a6fafa26fa85ccb696fb08702a23eefa7b8", "stars": 1052, "source_url": "https://github.com/cdglabs/apparatus/blob/73bc1a6fafa26fa85ccb696fb08702a23eefa7b8/src/Model/Editor.coffee", "line_start": 1, "line_end": 50}474{"id": "cdglabs/apparatus:src/Model/Editor.coffee:1:coffee_to_js", "type": "coffee_to_js", "prompt": "Convert this CoffeeScript to JavaScript.\n```coffeescript\n_ = require \"underscore\"\nModel = require \"./Model\"\nUtil = require \"../Util/Util\"\nStorage = require \"../Storage/Storage\"\n\n\nmodule.exports = class Editor\n constructor: ->\n @_setupSerializer()\n @_setupProject()\n\n _setupProject: ->\n @loadFromLocalStorage()\n if !@project\n @project = new Model.Project()\n\n _setupSerializer: ->\n builtInObjects = []\n for own name, object of Model\n if _.isFunction(object)\n object = object.prototype\n Util.assignId(object, name)\n builtInObjects.push(object)\n @serializer = new Storage.Serializer(builtInObjects)\n\n # TODO: get version via build process / ENV variable?\n version: \"0.4.0\"\n\n load: (jsonString) ->\n json = JSON.parse(jsonString)\n if json.type == \"Apparatus\" and json.version == @version\n @project = @serializer.dejsonify(json)\n\n save: ->\n json = @serializer.jsonify(@project)\n json.type = \"Apparatus\"\n json.version = @version\n jsonString = JSON.stringify(json)\n return jsonString\n\n\n # ===========================================================================\n # Local Storage\n # ===========================================================================\n\n localStorageName: \"apparatus\"\n\n saveToLocalStorage: ->\n jsonString = @save()\n window.localStorage[@localStorageName] = jsonString\n```", "response": "var Editor, Model, Storage, Util, _,\n hasProp = {}.hasOwnProperty;\n\n_ = require(\"underscore\");\n\nModel = require(\"./Model\");\n\nUtil = require(\"../Util/Util\");\n\nStorage = require(\"../Storage/Storage\");\n\nmodule.exports = Editor = (function() {\n class Editor {\n constructor() {\n this._setupSerializer();\n this._setupProject();\n }\n\n _setupProject() {\n this.loadFromLocalStorage();\n if (!this.project) {\n return this.project = new Model.Project();\n }\n }\n\n _setupSerializer() {\n var builtInObjects, name, object;\n builtInObjects = [];\n for (name in Model) {\n if (!hasProp.call(Model, name)) continue;\n object = Model[name];\n if (_.isFunction(object)) {\n object = object.prototype;\n }\n Util.assignId(object, name);\n builtInObjects.push(object);\n }\n return this.serializer = new Storage.Serializer(builtInObjects);\n }\n\n load(jsonString) {\n var json;\n json = JSON.parse(jsonString);\n if (json.type === \"Apparatus\" && json.version === this.version) {\n return this.project = this.serializer.dejsonify(json);\n }\n }\n\n save() {\n var json, jsonString;\n json = this.serializer.jsonify(this.project);\n json.type = \"Apparatus\";\n json.version = this.version;\n jsonString = JSON.stringify(json);\n return jsonString;\n }\n\n saveToLocalStorage() {\n var jsonString;\n jsonString = this.save();\n return window.localStorage[this.localStorageName] = jsonString;\n }\n\n };\n\n // TODO: get version via build process / ENV variable?\n Editor.prototype.version = \"0.4.0\";\n\n // ===========================================================================\n // Local Storage\n // ===========================================================================\n Editor.prototype.localStorageName = \"apparatus\";\n\n return Editor;\n\n}).call(this);", "source_lang": "CoffeeScript", "target_lang": "JavaScript", "repo": "cdglabs/apparatus", "path": "src/Model/Editor.coffee", "license": "MIT", "commit": "73bc1a6fafa26fa85ccb696fb08702a23eefa7b8", "stars": 1052, "source_url": "https://github.com/cdglabs/apparatus/blob/73bc1a6fafa26fa85ccb696fb08702a23eefa7b8/src/Model/Editor.coffee", "line_start": 1, "line_end": 50}475{"id": "cdglabs/apparatus:src/Model/Editor.coffee:1:js_to_coffee", "type": "js_to_coffee", "prompt": "Convert this JavaScript to CoffeeScript.\n```javascript\nvar Editor, Model, Storage, Util, _,\n hasProp = {}.hasOwnProperty;\n\n_ = require(\"underscore\");\n\nModel = require(\"./Model\");\n\nUtil = require(\"../Util/Util\");\n\nStorage = require(\"../Storage/Storage\");\n\nmodule.exports = Editor = (function() {\n class Editor {\n constructor() {\n this._setupSerializer();\n this._setupProject();\n }\n\n _setupProject() {\n this.loadFromLocalStorage();\n if (!this.project) {\n return this.project = new Model.Project();\n }\n }\n\n _setupSerializer() {\n var builtInObjects, name, object;\n builtInObjects = [];\n for (name in Model) {\n if (!hasProp.call(Model, name)) continue;\n object = Model[name];\n if (_.isFunction(object)) {\n object = object.prototype;\n }\n Util.assignId(object, name);\n builtInObjects.push(object);\n }\n return this.serializer = new Storage.Serializer(builtInObjects);\n }\n\n load(jsonString) {\n var json;\n json = JSON.parse(jsonString);\n if (json.type === \"Apparatus\" && json.version === this.version) {\n return this.project = this.serializer.dejsonify(json);\n }\n }\n\n save() {\n var json, jsonString;\n json = this.serializer.jsonify(this.project);\n json.type = \"Apparatus\";\n json.version = this.version;\n jsonString = JSON.stringify(json);\n return jsonString;\n }\n\n saveToLocalStorage() {\n var jsonString;\n jsonString = this.save();\n return window.localStorage[this.localStorageName] = jsonString;\n }\n\n };\n\n // TODO: get version via build process / ENV variable?\n Editor.prototype.version = \"0.4.0\";\n\n // ===========================================================================\n // Local Storage\n // ===========================================================================\n Editor.prototype.localStorageName = \"apparatus\";\n\n return Editor;\n\n}).call(this);\n```", "response": "_ = require \"underscore\"\nModel = require \"./Model\"\nUtil = require \"../Util/Util\"\nStorage = require \"../Storage/Storage\"\n\n\nmodule.exports = class Editor\n constructor: ->\n @_setupSerializer()\n @_setupProject()\n\n _setupProject: ->\n @loadFromLocalStorage()\n if !@project\n @project = new Model.Project()\n\n _setupSerializer: ->\n builtInObjects = []\n for own name, object of Model\n if _.isFunction(object)\n object = object.prototype\n Util.assignId(object, name)\n builtInObjects.push(object)\n @serializer = new Storage.Serializer(builtInObjects)\n\n # TODO: get version via build process / ENV variable?\n version: \"0.4.0\"\n\n load: (jsonString) ->\n json = JSON.parse(jsonString)\n if json.type == \"Apparatus\" and json.version == @version\n @project = @serializer.dejsonify(json)\n\n save: ->\n json = @serializer.jsonify(@project)\n json.type = \"Apparatus\"\n json.version = @version\n jsonString = JSON.stringify(json)\n return jsonString\n\n\n # ===========================================================================\n # Local Storage\n # ===========================================================================\n\n localStorageName: \"apparatus\"\n\n saveToLocalStorage: ->\n jsonString = @save()\n window.localStorage[@localStorageName] = jsonString", "source_lang": "JavaScript", "target_lang": "CoffeeScript", "repo": "cdglabs/apparatus", "path": "src/Model/Editor.coffee", "license": "MIT", "commit": "73bc1a6fafa26fa85ccb696fb08702a23eefa7b8", "stars": 1052, "source_url": "https://github.com/cdglabs/apparatus/blob/73bc1a6fafa26fa85ccb696fb08702a23eefa7b8/src/Model/Editor.coffee", "line_start": 1, "line_end": 50}476{"id": "cdglabs/apparatus:src/Model/Editor.coffee:1:completion", "type": "completion", "prompt": "_ = require \"underscore\"\nModel = require \"./Model\"\nUtil = require \"../Util/Util\"\nStorage = require \"../Storage/Storage\"\n\n\nmodule.exports = class Editor\n constructor: ->\n @_setupSerializer()\n @_setupProject()\n\n _setupProject: ->\n @loadFromLocalStorage()\n if !@project\n @project = new Model.Project()\n\n _setupSerializer: ->\n builtInObjects = []\n for own name, object of Model\n if _.isFunction(object)\n object = object.prototype\n Util.assignId(object, name)\n builtInObjects.push(object)\n @serializer = new Storage.Serializer(builtInObjects)", "response": "# TODO: get version via build process / ENV variable?\n version: \"0.4.0\"\n\n load: (jsonString) ->\n json = JSON.parse(jsonString)\n if json.type == \"Apparatus\" and json.version == @version\n @project = @serializer.dejsonify(json)\n\n save: ->\n json = @serializer.jsonify(@project)\n json.type = \"Apparatus\"\n json.version = @version\n jsonString = JSON.stringify(json)\n return jsonString\n\n\n # ===========================================================================\n # Local Storage\n # ===========================================================================\n\n localStorageName: \"apparatus\"\n\n saveToLocalStorage: ->\n jsonString = @save()\n window.localStorage[@localStorageName] = jsonString", "source_lang": "CoffeeScript", "target_lang": "CoffeeScript", "repo": "cdglabs/apparatus", "path": "src/Model/Editor.coffee", "license": "MIT", "commit": "73bc1a6fafa26fa85ccb696fb08702a23eefa7b8", "stars": 1052, "source_url": "https://github.com/cdglabs/apparatus/blob/73bc1a6fafa26fa85ccb696fb08702a23eefa7b8/src/Model/Editor.coffee", "line_start": 1, "line_end": 50}477{"id": "cdglabs/apparatus:src/Model/Editor.coffee:2:raw_corpus", "type": "raw_corpus", "prompt": "", "response": "loadFromLocalStorage: ->\n jsonString = window.localStorage[@localStorageName]\n if jsonString\n @load(jsonString)\n\n resetLocalStorage: ->\n delete window.localStorage[@localStorageName]\n\n\n # ===========================================================================\n # Revision History\n # ===========================================================================\n\n checkpoint: ->\n @saveToLocalStorage()\n\n # TODO: undo, redo", "source_lang": "", "target_lang": "CoffeeScript", "repo": "cdglabs/apparatus", "path": "src/Model/Editor.coffee", "license": "MIT", "commit": "73bc1a6fafa26fa85ccb696fb08702a23eefa7b8", "stars": 1052, "source_url": "https://github.com/cdglabs/apparatus/blob/73bc1a6fafa26fa85ccb696fb08702a23eefa7b8/src/Model/Editor.coffee", "line_start": 51, "line_end": 68}478{"id": "cdglabs/apparatus:src/Model/Editor.coffee:2:coffee_to_js", "type": "coffee_to_js", "prompt": "Convert this CoffeeScript to JavaScript.\n```coffeescript\nloadFromLocalStorage: ->\n jsonString = window.localStorage[@localStorageName]\n if jsonString\n @load(jsonString)\n\n resetLocalStorage: ->\n delete window.localStorage[@localStorageName]\n\n\n # ===========================================================================\n # Revision History\n # ===========================================================================\n\n checkpoint: ->\n @saveToLocalStorage()\n\n # TODO: undo, redo\n```", "response": "({\n loadFromLocalStorage: function() {\n var jsonString;\n jsonString = window.localStorage[this.localStorageName];\n if (jsonString) {\n return this.load(jsonString);\n }\n },\n resetLocalStorage: function() {\n return delete window.localStorage[this.localStorageName];\n },\n // ===========================================================================\n // Revision History\n // ===========================================================================\n checkpoint: function() {\n return this.saveToLocalStorage();\n }\n});\n\n// TODO: undo, redo", "source_lang": "CoffeeScript", "target_lang": "JavaScript", "repo": "cdglabs/apparatus", "path": "src/Model/Editor.coffee", "license": "MIT", "commit": "73bc1a6fafa26fa85ccb696fb08702a23eefa7b8", "stars": 1052, "source_url": "https://github.com/cdglabs/apparatus/blob/73bc1a6fafa26fa85ccb696fb08702a23eefa7b8/src/Model/Editor.coffee", "line_start": 51, "line_end": 68}479{"id": "cdglabs/apparatus:src/Model/Editor.coffee:2:js_to_coffee", "type": "js_to_coffee", "prompt": "Convert this JavaScript to CoffeeScript.\n```javascript\n({\n loadFromLocalStorage: function() {\n var jsonString;\n jsonString = window.localStorage[this.localStorageName];\n if (jsonString) {\n return this.load(jsonString);\n }\n },\n resetLocalStorage: function() {\n return delete window.localStorage[this.localStorageName];\n },\n // ===========================================================================\n // Revision History\n // ===========================================================================\n checkpoint: function() {\n return this.saveToLocalStorage();\n }\n});\n\n// TODO: undo, redo\n```", "response": "loadFromLocalStorage: ->\n jsonString = window.localStorage[@localStorageName]\n if jsonString\n @load(jsonString)\n\n resetLocalStorage: ->\n delete window.localStorage[@localStorageName]\n\n\n # ===========================================================================\n # Revision History\n # ===========================================================================\n\n checkpoint: ->\n @saveToLocalStorage()\n\n # TODO: undo, redo", "source_lang": "JavaScript", "target_lang": "CoffeeScript", "repo": "cdglabs/apparatus", "path": "src/Model/Editor.coffee", "license": "MIT", "commit": "73bc1a6fafa26fa85ccb696fb08702a23eefa7b8", "stars": 1052, "source_url": "https://github.com/cdglabs/apparatus/blob/73bc1a6fafa26fa85ccb696fb08702a23eefa7b8/src/Model/Editor.coffee", "line_start": 51, "line_end": 68}480{"id": "cdglabs/apparatus:src/Model/Editor.coffee:2:completion", "type": "completion", "prompt": "loadFromLocalStorage: ->\n jsonString = window.localStorage[@localStorageName]\n if jsonString\n @load(jsonString)\n\n resetLocalStorage: ->\n delete window.localStorage[@localStorageName]", "response": "# ===========================================================================\n # Revision History\n # ===========================================================================\n\n checkpoint: ->\n @saveToLocalStorage()\n\n # TODO: undo, redo", "source_lang": "CoffeeScript", "target_lang": "CoffeeScript", "repo": "cdglabs/apparatus", "path": "src/Model/Editor.coffee", "license": "MIT", "commit": "73bc1a6fafa26fa85ccb696fb08702a23eefa7b8", "stars": 1052, "source_url": "https://github.com/cdglabs/apparatus/blob/73bc1a6fafa26fa85ccb696fb08702a23eefa7b8/src/Model/Editor.coffee", "line_start": 51, "line_end": 68}481{"id": "cdglabs/apparatus:src/Model/Editor.coffee:1:raw_corpus", "type": "raw_corpus", "prompt": "", "response": "_ = require \"underscore\"\nModel = require \"./Model\"\nUtil = require \"../Util/Util\"\nStorage = require \"../Storage/Storage\"\n\n\nmodule.exports = class Editor\n constructor: ->\n @project = new Model.Project()\n @_setupSerializer()\n\n _setupSerializer: ->\n builtInObjects = []\n for own name, object of Model\n if _.isFunction(object)\n object = object.prototype\n Util.assignId(object, name)\n builtInObjects.push(object)\n @serializer = new Storage.Serializer(builtInObjects)\n\n\n load: (jsonString) ->\n # TODO: check type and version to ensure it's a valid jsonString.\n json = JSON.parse(jsonString)\n @project = @serializer.dejsonify(json)\n\n save: ->\n json = @serializer.jsonify(@project)\n json.type = \"Apparatus\"\n # TODO: get version via build process / ENV variable?\n json.version = \"0.4.0\"\n jsonString = JSON.stringify(json)\n return jsonString", "source_lang": "", "target_lang": "CoffeeScript", "repo": "cdglabs/apparatus", "path": "src/Model/Editor.coffee", "license": "MIT", "commit": "01d0628f253632c227bb0a7fc7afac851870213f", "stars": 1052, "source_url": "https://github.com/cdglabs/apparatus/blob/01d0628f253632c227bb0a7fc7afac851870213f/src/Model/Editor.coffee", "line_start": 1, "line_end": 33}482{"id": "cdglabs/apparatus:src/Model/Editor.coffee:1:coffee_to_js", "type": "coffee_to_js", "prompt": "Convert this CoffeeScript to JavaScript.\n```coffeescript\n_ = require \"underscore\"\nModel = require \"./Model\"\nUtil = require \"../Util/Util\"\nStorage = require \"../Storage/Storage\"\n\n\nmodule.exports = class Editor\n constructor: ->\n @project = new Model.Project()\n @_setupSerializer()\n\n _setupSerializer: ->\n builtInObjects = []\n for own name, object of Model\n if _.isFunction(object)\n object = object.prototype\n Util.assignId(object, name)\n builtInObjects.push(object)\n @serializer = new Storage.Serializer(builtInObjects)\n\n\n load: (jsonString) ->\n # TODO: check type and version to ensure it's a valid jsonString.\n json = JSON.parse(jsonString)\n @project = @serializer.dejsonify(json)\n\n save: ->\n json = @serializer.jsonify(@project)\n json.type = \"Apparatus\"\n # TODO: get version via build process / ENV variable?\n json.version = \"0.4.0\"\n jsonString = JSON.stringify(json)\n return jsonString\n```", "response": "var Editor, Model, Storage, Util, _,\n hasProp = {}.hasOwnProperty;\n\n_ = require(\"underscore\");\n\nModel = require(\"./Model\");\n\nUtil = require(\"../Util/Util\");\n\nStorage = require(\"../Storage/Storage\");\n\nmodule.exports = Editor = class Editor {\n constructor() {\n this.project = new Model.Project();\n this._setupSerializer();\n }\n\n _setupSerializer() {\n var builtInObjects, name, object;\n builtInObjects = [];\n for (name in Model) {\n if (!hasProp.call(Model, name)) continue;\n object = Model[name];\n if (_.isFunction(object)) {\n object = object.prototype;\n }\n Util.assignId(object, name);\n builtInObjects.push(object);\n }\n return this.serializer = new Storage.Serializer(builtInObjects);\n }\n\n load(jsonString) {\n var json;\n // TODO: check type and version to ensure it's a valid jsonString.\n json = JSON.parse(jsonString);\n return this.project = this.serializer.dejsonify(json);\n }\n\n save() {\n var json, jsonString;\n json = this.serializer.jsonify(this.project);\n json.type = \"Apparatus\";\n // TODO: get version via build process / ENV variable?\n json.version = \"0.4.0\";\n jsonString = JSON.stringify(json);\n return jsonString;\n }\n\n};", "source_lang": "CoffeeScript", "target_lang": "JavaScript", "repo": "cdglabs/apparatus", "path": "src/Model/Editor.coffee", "license": "MIT", "commit": "01d0628f253632c227bb0a7fc7afac851870213f", "stars": 1052, "source_url": "https://github.com/cdglabs/apparatus/blob/01d0628f253632c227bb0a7fc7afac851870213f/src/Model/Editor.coffee", "line_start": 1, "line_end": 33}483{"id": "cdglabs/apparatus:src/Model/Editor.coffee:1:js_to_coffee", "type": "js_to_coffee", "prompt": "Convert this JavaScript to CoffeeScript.\n```javascript\nvar Editor, Model, Storage, Util, _,\n hasProp = {}.hasOwnProperty;\n\n_ = require(\"underscore\");\n\nModel = require(\"./Model\");\n\nUtil = require(\"../Util/Util\");\n\nStorage = require(\"../Storage/Storage\");\n\nmodule.exports = Editor = class Editor {\n constructor() {\n this.project = new Model.Project();\n this._setupSerializer();\n }\n\n _setupSerializer() {\n var builtInObjects, name, object;\n builtInObjects = [];\n for (name in Model) {\n if (!hasProp.call(Model, name)) continue;\n object = Model[name];\n if (_.isFunction(object)) {\n object = object.prototype;\n }\n Util.assignId(object, name);\n builtInObjects.push(object);\n }\n return this.serializer = new Storage.Serializer(builtInObjects);\n }\n\n load(jsonString) {\n var json;\n // TODO: check type and version to ensure it's a valid jsonString.\n json = JSON.parse(jsonString);\n return this.project = this.serializer.dejsonify(json);\n }\n\n save() {\n var json, jsonString;\n json = this.serializer.jsonify(this.project);\n json.type = \"Apparatus\";\n // TODO: get version via build process / ENV variable?\n json.version = \"0.4.0\";\n jsonString = JSON.stringify(json);\n return jsonString;\n }\n\n};\n```", "response": "_ = require \"underscore\"\nModel = require \"./Model\"\nUtil = require \"../Util/Util\"\nStorage = require \"../Storage/Storage\"\n\n\nmodule.exports = class Editor\n constructor: ->\n @project = new Model.Project()\n @_setupSerializer()\n\n _setupSerializer: ->\n builtInObjects = []\n for own name, object of Model\n if _.isFunction(object)\n object = object.prototype\n Util.assignId(object, name)\n builtInObjects.push(object)\n @serializer = new Storage.Serializer(builtInObjects)\n\n\n load: (jsonString) ->\n # TODO: check type and version to ensure it's a valid jsonString.\n json = JSON.parse(jsonString)\n @project = @serializer.dejsonify(json)\n\n save: ->\n json = @serializer.jsonify(@project)\n json.type = \"Apparatus\"\n # TODO: get version via build process / ENV variable?\n json.version = \"0.4.0\"\n jsonString = JSON.stringify(json)\n return jsonString", "source_lang": "JavaScript", "target_lang": "CoffeeScript", "repo": "cdglabs/apparatus", "path": "src/Model/Editor.coffee", "license": "MIT", "commit": "01d0628f253632c227bb0a7fc7afac851870213f", "stars": 1052, "source_url": "https://github.com/cdglabs/apparatus/blob/01d0628f253632c227bb0a7fc7afac851870213f/src/Model/Editor.coffee", "line_start": 1, "line_end": 33}484{"id": "cdglabs/apparatus:src/Model/Editor.coffee:1:completion", "type": "completion", "prompt": "_ = require \"underscore\"\nModel = require \"./Model\"\nUtil = require \"../Util/Util\"\nStorage = require \"../Storage/Storage\"\n\n\nmodule.exports = class Editor\n constructor: ->\n @project = new Model.Project()\n @_setupSerializer()\n\n _setupSerializer: ->\n builtInObjects = []\n for own name, object of Model\n if _.isFunction(object)\n object = object.prototype", "response": "Util.assignId(object, name)\n builtInObjects.push(object)\n @serializer = new Storage.Serializer(builtInObjects)\n\n\n load: (jsonString) ->\n # TODO: check type and version to ensure it's a valid jsonString.\n json = JSON.parse(jsonString)\n @project = @serializer.dejsonify(json)\n\n save: ->\n json = @serializer.jsonify(@project)\n json.type = \"Apparatus\"\n # TODO: get version via build process / ENV variable?\n json.version = \"0.4.0\"\n jsonString = JSON.stringify(json)\n return jsonString", "source_lang": "CoffeeScript", "target_lang": "CoffeeScript", "repo": "cdglabs/apparatus", "path": "src/Model/Editor.coffee", "license": "MIT", "commit": "01d0628f253632c227bb0a7fc7afac851870213f", "stars": 1052, "source_url": "https://github.com/cdglabs/apparatus/blob/01d0628f253632c227bb0a7fc7afac851870213f/src/Model/Editor.coffee", "line_start": 1, "line_end": 33}485{"id": "jianliaoim/talk-os:talk-web/client/util/reqwest.coffee:1:raw_corpus", "type": "raw_corpus", "prompt": "", "response": "if typeof window is 'undefined'\n module.exports = {}\nelse\n module.exports = require 'reqwest'", "source_lang": "", "target_lang": "CoffeeScript", "repo": "jianliaoim/talk-os", "path": "talk-web/client/util/reqwest.coffee", "license": "MIT", "commit": "2545c4497865779a55762e03963a39237df9046b", "stars": 2703, "source_url": "https://github.com/jianliaoim/talk-os/blob/2545c4497865779a55762e03963a39237df9046b/talk-web/client/util/reqwest.coffee", "line_start": 1, "line_end": 4}486{"id": "jianliaoim/talk-os:talk-web/client/util/reqwest.coffee:1:coffee_to_js", "type": "coffee_to_js", "prompt": "Convert this CoffeeScript to JavaScript.\n```coffeescript\nif typeof window is 'undefined'\n module.exports = {}\nelse\n module.exports = require 'reqwest'\n```", "response": "if (typeof window === 'undefined') {\n module.exports = {};\n} else {\n module.exports = require('reqwest');\n}", "source_lang": "CoffeeScript", "target_lang": "JavaScript", "repo": "jianliaoim/talk-os", "path": "talk-web/client/util/reqwest.coffee", "license": "MIT", "commit": "2545c4497865779a55762e03963a39237df9046b", "stars": 2703, "source_url": "https://github.com/jianliaoim/talk-os/blob/2545c4497865779a55762e03963a39237df9046b/talk-web/client/util/reqwest.coffee", "line_start": 1, "line_end": 4}487{"id": "jianliaoim/talk-os:talk-web/client/util/reqwest.coffee:1:js_to_coffee", "type": "js_to_coffee", "prompt": "Convert this JavaScript to CoffeeScript.\n```javascript\nif (typeof window === 'undefined') {\n module.exports = {};\n} else {\n module.exports = require('reqwest');\n}\n```", "response": "if typeof window is 'undefined'\n module.exports = {}\nelse\n module.exports = require 'reqwest'", "source_lang": "JavaScript", "target_lang": "CoffeeScript", "repo": "jianliaoim/talk-os", "path": "talk-web/client/util/reqwest.coffee", "license": "MIT", "commit": "2545c4497865779a55762e03963a39237df9046b", "stars": 2703, "source_url": "https://github.com/jianliaoim/talk-os/blob/2545c4497865779a55762e03963a39237df9046b/talk-web/client/util/reqwest.coffee", "line_start": 1, "line_end": 4}488{"id": "jianliaoim/talk-os:talk-web/client/util/reqwest.coffee:1:completion", "type": "completion", "prompt": "if typeof window is 'undefined'\n module.exports = {}", "response": "else\n module.exports = require 'reqwest'", "source_lang": "CoffeeScript", "target_lang": "CoffeeScript", "repo": "jianliaoim/talk-os", "path": "talk-web/client/util/reqwest.coffee", "license": "MIT", "commit": "2545c4497865779a55762e03963a39237df9046b", "stars": 2703, "source_url": "https://github.com/jianliaoim/talk-os/blob/2545c4497865779a55762e03963a39237df9046b/talk-web/client/util/reqwest.coffee", "line_start": 1, "line_end": 4}489{"id": "ExpediaGroup/cyclotron:cyclotron-site/app/scripts/mgmt/directives/directives.metricsGraphics.coffee:1:raw_corpus", "type": "raw_corpus", "prompt": "", "response": "###\n# Copyright (c) 2013-2018 the original author or authors.\n#\n# Licensed under the MIT License (the \"License\");\n# you may not use this file except in compliance with the License.\n# You may obtain a copy of the License at\n#\n# http://www.opensource.org/licenses/mit-license.php\n#\n# Unless required by applicable law or agreed to in writing,\n# software distributed under the License is distributed on an\n# \"AS IS\" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND,\n# either express or implied. See the License for the specific\n# language governing permissions and limitations under the License.\n###\n\ncyclotronDirectives.directive 'metricsGraphics', ->\n {\n restrict: 'EAC'\n scope:\n data: '='\n options: '='\n\n link: (scope, element) ->\n\n $element = $(element)\n chartWidth = $element.width()\n\n # Generate random element ID\n if _.isEmpty $element.prop('id')\n scope.id = 'mg-' + uuid.v4()\n $element.prop 'id', scope.id\n\n redraw = ->\n return unless scope.data?\n\n options =\n title: null\n height: 200\n width: chartWidth\n target: '#' + scope.id\n data: scope.data\n interpolate: 'cardinal'\n interpolate_tension: 0.95\n\n # Apply passed options\n _.assign options, scope.options\n\n # Wrap mouseover\n if options.mouseover?", "source_lang": "", "target_lang": "CoffeeScript", "repo": "ExpediaGroup/cyclotron", "path": "cyclotron-site/app/scripts/mgmt/directives/directives.metricsGraphics.coffee", "license": "MIT", "commit": "0228db71d84a3138a9ffddb50d8f4f8ff37cc5ab", "stars": 1544, "source_url": "https://github.com/ExpediaGroup/cyclotron/blob/0228db71d84a3138a9ffddb50d8f4f8ff37cc5ab/cyclotron-site/app/scripts/mgmt/directives/directives.metricsGraphics.coffee", "line_start": 1, "line_end": 50}490{"id": "ExpediaGroup/cyclotron:cyclotron-site/app/scripts/mgmt/directives/directives.metricsGraphics.coffee:1:completion", "type": "completion", "prompt": "###\n# Copyright (c) 2013-2018 the original author or authors.\n#\n# Licensed under the MIT License (the \"License\");\n# you may not use this file except in compliance with the License.\n# You may obtain a copy of the License at\n#\n# http://www.opensource.org/licenses/mit-license.php\n#\n# Unless required by applicable law or agreed to in writing,\n# software distributed under the License is distributed on an\n# \"AS IS\" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND,\n# either express or implied. See the License for the specific\n# language governing permissions and limitations under the License.\n###\n\ncyclotronDirectives.directive 'metricsGraphics', ->\n {\n restrict: 'EAC'\n scope:\n data: '='\n options: '='\n\n link: (scope, element) ->", "response": "$element = $(element)\n chartWidth = $element.width()\n\n # Generate random element ID\n if _.isEmpty $element.prop('id')\n scope.id = 'mg-' + uuid.v4()\n $element.prop 'id', scope.id\n\n redraw = ->\n return unless scope.data?\n\n options =\n title: null\n height: 200\n width: chartWidth\n target: '#' + scope.id\n data: scope.data\n interpolate: 'cardinal'\n interpolate_tension: 0.95\n\n # Apply passed options\n _.assign options, scope.options\n\n # Wrap mouseover\n if options.mouseover?", "source_lang": "CoffeeScript", "target_lang": "CoffeeScript", "repo": "ExpediaGroup/cyclotron", "path": "cyclotron-site/app/scripts/mgmt/directives/directives.metricsGraphics.coffee", "license": "MIT", "commit": "0228db71d84a3138a9ffddb50d8f4f8ff37cc5ab", "stars": 1544, "source_url": "https://github.com/ExpediaGroup/cyclotron/blob/0228db71d84a3138a9ffddb50d8f4f8ff37cc5ab/cyclotron-site/app/scripts/mgmt/directives/directives.metricsGraphics.coffee", "line_start": 1, "line_end": 50}491{"id": "ExpediaGroup/cyclotron:cyclotron-site/app/scripts/mgmt/directives/directives.metricsGraphics.coffee:2:raw_corpus", "type": "raw_corpus", "prompt": "", "response": "getMouseoverText = options.mouseover\n options.mouseover = (d, i) ->\n text = getMouseoverText(d, i)\n d3.select('#' + scope.id + ' svg .mg-active-datapoint').text(text)\n\n MG.data_graphic options\n\n scope.$watch 'data', (newData) ->\n redraw()\n\n $element.resize _.debounce ->\n chartWidth = $element.width()\n redraw()\n , 100, { leading: false, maxWait: 300 }\n }", "source_lang": "", "target_lang": "CoffeeScript", "repo": "ExpediaGroup/cyclotron", "path": "cyclotron-site/app/scripts/mgmt/directives/directives.metricsGraphics.coffee", "license": "MIT", "commit": "0228db71d84a3138a9ffddb50d8f4f8ff37cc5ab", "stars": 1544, "source_url": "https://github.com/ExpediaGroup/cyclotron/blob/0228db71d84a3138a9ffddb50d8f4f8ff37cc5ab/cyclotron-site/app/scripts/mgmt/directives/directives.metricsGraphics.coffee", "line_start": 51, "line_end": 65}492{"id": "ExpediaGroup/cyclotron:cyclotron-site/app/scripts/mgmt/directives/directives.metricsGraphics.coffee:2:completion", "type": "completion", "prompt": "getMouseoverText = options.mouseover\n options.mouseover = (d, i) ->\n text = getMouseoverText(d, i)\n d3.select('#' + scope.id + ' svg .mg-active-datapoint').text(text)\n\n MG.data_graphic options", "response": "scope.$watch 'data', (newData) ->\n redraw()\n\n $element.resize _.debounce ->\n chartWidth = $element.width()\n redraw()\n , 100, { leading: false, maxWait: 300 }\n }", "source_lang": "CoffeeScript", "target_lang": "CoffeeScript", "repo": "ExpediaGroup/cyclotron", "path": "cyclotron-site/app/scripts/mgmt/directives/directives.metricsGraphics.coffee", "license": "MIT", "commit": "0228db71d84a3138a9ffddb50d8f4f8ff37cc5ab", "stars": 1544, "source_url": "https://github.com/ExpediaGroup/cyclotron/blob/0228db71d84a3138a9ffddb50d8f4f8ff37cc5ab/cyclotron-site/app/scripts/mgmt/directives/directives.metricsGraphics.coffee", "line_start": 51, "line_end": 65}493{"id": "ExpediaGroup/cyclotron:cyclotron-site/app/scripts/mgmt/directives/directives.metricsGraphics.coffee:1:raw_corpus", "type": "raw_corpus", "prompt": "", "response": "###\n# Copyright (c) 2013-2015 the original author or authors.\n#\n# Licensed under the MIT License (the \"License\");\n# you may not use this file except in compliance with the License.\n# You may obtain a copy of the License at\n#\n# http://www.opensource.org/licenses/mit-license.php\n#\n# Unless required by applicable law or agreed to in writing,\n# software distributed under the License is distributed on an\n# \"AS IS\" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND,\n# either express or implied. See the License for the specific\n# language governing permissions and limitations under the License.\n###\n\ncyclotronDirectives.directive 'metricsGraphics', ->\n {\n restrict: 'EAC'\n scope:\n data: '='\n options: '='\n\n link: (scope, element) ->\n\n $element = $(element)\n chartWidth = $element.width()\n\n # Generate random element ID\n if _.isEmpty $element.prop('id')\n scope.id = 'mg-' + uuid.v4()\n $element.prop 'id', scope.id\n\n redraw = ->\n return unless scope.data?\n\n options =\n title: null\n height: 200\n width: chartWidth\n target: '#' + scope.id\n data: scope.data\n interpolate: 'cardinal'\n interpolate_tension: 0.95\n\n # Apply passed options\n _.assign options, scope.options\n\n # Wrap mouseover\n if options.mouseover?", "source_lang": "", "target_lang": "CoffeeScript", "repo": "ExpediaGroup/cyclotron", "path": "cyclotron-site/app/scripts/mgmt/directives/directives.metricsGraphics.coffee", "license": "MIT", "commit": "aa249eacd2cdb7409ce6c4581e1cedf99c9471b7", "stars": 1544, "source_url": "https://github.com/ExpediaGroup/cyclotron/blob/aa249eacd2cdb7409ce6c4581e1cedf99c9471b7/cyclotron-site/app/scripts/mgmt/directives/directives.metricsGraphics.coffee", "line_start": 1, "line_end": 50}494{"id": "ExpediaGroup/cyclotron:cyclotron-site/app/scripts/mgmt/directives/directives.metricsGraphics.coffee:1:completion", "type": "completion", "prompt": "###\n# Copyright (c) 2013-2015 the original author or authors.\n#\n# Licensed under the MIT License (the \"License\");\n# you may not use this file except in compliance with the License.\n# You may obtain a copy of the License at\n#\n# http://www.opensource.org/licenses/mit-license.php\n#\n# Unless required by applicable law or agreed to in writing,\n# software distributed under the License is distributed on an\n# \"AS IS\" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND,\n# either express or implied. See the License for the specific\n# language governing permissions and limitations under the License.\n###\n\ncyclotronDirectives.directive 'metricsGraphics', ->\n {\n restrict: 'EAC'\n scope:\n data: '='\n options: '='\n\n link: (scope, element) ->", "response": "$element = $(element)\n chartWidth = $element.width()\n\n # Generate random element ID\n if _.isEmpty $element.prop('id')\n scope.id = 'mg-' + uuid.v4()\n $element.prop 'id', scope.id\n\n redraw = ->\n return unless scope.data?\n\n options =\n title: null\n height: 200\n width: chartWidth\n target: '#' + scope.id\n data: scope.data\n interpolate: 'cardinal'\n interpolate_tension: 0.95\n\n # Apply passed options\n _.assign options, scope.options\n\n # Wrap mouseover\n if options.mouseover?", "source_lang": "CoffeeScript", "target_lang": "CoffeeScript", "repo": "ExpediaGroup/cyclotron", "path": "cyclotron-site/app/scripts/mgmt/directives/directives.metricsGraphics.coffee", "license": "MIT", "commit": "aa249eacd2cdb7409ce6c4581e1cedf99c9471b7", "stars": 1544, "source_url": "https://github.com/ExpediaGroup/cyclotron/blob/aa249eacd2cdb7409ce6c4581e1cedf99c9471b7/cyclotron-site/app/scripts/mgmt/directives/directives.metricsGraphics.coffee", "line_start": 1, "line_end": 50}495{"id": "ExpediaGroup/cyclotron:cyclotron-site/app/scripts/mgmt/directives/directives.metricsGraphics.coffee:1:raw_corpus", "type": "raw_corpus", "prompt": "", "response": "###\n# Copyright (c) 2013-2015 the original author or authors.\n#\n# Licensed under the MIT License (the \"License\");\n# you may not use this file except in compliance with the License.\n# You may obtain a copy of the License at\n#\n# http://www.opensource.org/licenses/mit-license.php\n#\n# Unless required by applicable law or agreed to in writing,\n# software distributed under the License is distributed on an\n# \"AS IS\" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND,\n# either express or implied. See the License for the specific\n# language governing permissions and limitations under the License.\n###\n\ncyclotronDirectives.directive 'metricsGraphics', ->\n {\n restrict: 'EAC'\n scope:\n data: '='\n options: '='\n\n link: (scope, element) ->\n\n $element = $(element)\n scope.width = $element.width()\n\n # Generate random element ID\n if _.isEmpty $element.prop('id')\n scope.id = 'mg-' + uuid.v4()\n $element.prop 'id', scope.id\n\n redraw = ->\n return unless scope.data?\n\n options =\n title: null\n height: 200\n width: scope.width\n target: '#' + scope.id\n data: scope.data\n interpolate: 'cardinal'\n interpolate_tension: 0.95\n\n # Apply passed options\n _.assign options, scope.options\n\n # Wrap mouseover\n if options.mouseover?", "source_lang": "", "target_lang": "CoffeeScript", "repo": "ExpediaGroup/cyclotron", "path": "cyclotron-site/app/scripts/mgmt/directives/directives.metricsGraphics.coffee", "license": "MIT", "commit": "08680403c1ab72b7789517426293681c2224eada", "stars": 1544, "source_url": "https://github.com/ExpediaGroup/cyclotron/blob/08680403c1ab72b7789517426293681c2224eada/cyclotron-site/app/scripts/mgmt/directives/directives.metricsGraphics.coffee", "line_start": 1, "line_end": 50}496{"id": "ExpediaGroup/cyclotron:cyclotron-site/app/scripts/mgmt/directives/directives.metricsGraphics.coffee:1:completion", "type": "completion", "prompt": "###\n# Copyright (c) 2013-2015 the original author or authors.\n#\n# Licensed under the MIT License (the \"License\");\n# you may not use this file except in compliance with the License.\n# You may obtain a copy of the License at\n#\n# http://www.opensource.org/licenses/mit-license.php\n#\n# Unless required by applicable law or agreed to in writing,\n# software distributed under the License is distributed on an\n# \"AS IS\" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND,\n# either express or implied. See the License for the specific\n# language governing permissions and limitations under the License.\n###\n\ncyclotronDirectives.directive 'metricsGraphics', ->\n {\n restrict: 'EAC'\n scope:\n data: '='\n options: '='\n\n link: (scope, element) ->", "response": "$element = $(element)\n scope.width = $element.width()\n\n # Generate random element ID\n if _.isEmpty $element.prop('id')\n scope.id = 'mg-' + uuid.v4()\n $element.prop 'id', scope.id\n\n redraw = ->\n return unless scope.data?\n\n options =\n title: null\n height: 200\n width: scope.width\n target: '#' + scope.id\n data: scope.data\n interpolate: 'cardinal'\n interpolate_tension: 0.95\n\n # Apply passed options\n _.assign options, scope.options\n\n # Wrap mouseover\n if options.mouseover?", "source_lang": "CoffeeScript", "target_lang": "CoffeeScript", "repo": "ExpediaGroup/cyclotron", "path": "cyclotron-site/app/scripts/mgmt/directives/directives.metricsGraphics.coffee", "license": "MIT", "commit": "08680403c1ab72b7789517426293681c2224eada", "stars": 1544, "source_url": "https://github.com/ExpediaGroup/cyclotron/blob/08680403c1ab72b7789517426293681c2224eada/cyclotron-site/app/scripts/mgmt/directives/directives.metricsGraphics.coffee", "line_start": 1, "line_end": 50}497{"id": "ExpediaGroup/cyclotron:cyclotron-site/app/scripts/mgmt/directives/directives.metricsGraphics.coffee:2:raw_corpus", "type": "raw_corpus", "prompt": "", "response": "getMouseoverText = options.mouseover\n options.mouseover = (d, i) ->\n text = getMouseoverText(d, i)\n d3.select('#' + scope.id + ' svg .mg-active-datapoint').text(text)\n\n MG.data_graphic options\n\n scope.$watch 'data', (newData) ->\n redraw()\n\n $element.resize _.debounce ->\n scope.$apply ->\n scope.width = $element.width()\n redraw()\n , 90, { leading: false, maxWait: 200 }\n }", "source_lang": "", "target_lang": "CoffeeScript", "repo": "ExpediaGroup/cyclotron", "path": "cyclotron-site/app/scripts/mgmt/directives/directives.metricsGraphics.coffee", "license": "MIT", "commit": "08680403c1ab72b7789517426293681c2224eada", "stars": 1544, "source_url": "https://github.com/ExpediaGroup/cyclotron/blob/08680403c1ab72b7789517426293681c2224eada/cyclotron-site/app/scripts/mgmt/directives/directives.metricsGraphics.coffee", "line_start": 51, "line_end": 66}498{"id": "ExpediaGroup/cyclotron:cyclotron-site/app/scripts/mgmt/directives/directives.metricsGraphics.coffee:2:completion", "type": "completion", "prompt": "getMouseoverText = options.mouseover\n options.mouseover = (d, i) ->\n text = getMouseoverText(d, i)\n d3.select('#' + scope.id + ' svg .mg-active-datapoint').text(text)\n\n MG.data_graphic options\n\n scope.$watch 'data', (newData) ->", "response": "redraw()\n\n $element.resize _.debounce ->\n scope.$apply ->\n scope.width = $element.width()\n redraw()\n , 90, { leading: false, maxWait: 200 }\n }", "source_lang": "CoffeeScript", "target_lang": "CoffeeScript", "repo": "ExpediaGroup/cyclotron", "path": "cyclotron-site/app/scripts/mgmt/directives/directives.metricsGraphics.coffee", "license": "MIT", "commit": "08680403c1ab72b7789517426293681c2224eada", "stars": 1544, "source_url": "https://github.com/ExpediaGroup/cyclotron/blob/08680403c1ab72b7789517426293681c2224eada/cyclotron-site/app/scripts/mgmt/directives/directives.metricsGraphics.coffee", "line_start": 51, "line_end": 66}499{"id": "ExpediaGroup/cyclotron:cyclotron-site/app/scripts/mgmt/directives/directives.metricsGraphics.coffee:2:raw_corpus", "type": "raw_corpus", "prompt": "", "response": "getMouseoverText = options.mouseover\n options.mouseover = (d, i) ->\n text = getMouseoverText(d, i)\n d3.select('#' + scope.id + ' svg .mg-active-datapoint').text(text)\n\n MG.data_graphic options\n\n scope.$watch 'data', (newData) ->\n redraw()\n\n $element.resize(_.throttle(->\n scope.$apply ->\n scope.width = $element.width()\n redraw()\n , 65))\n }", "source_lang": "", "target_lang": "CoffeeScript", "repo": "ExpediaGroup/cyclotron", "path": "cyclotron-site/app/scripts/mgmt/directives/directives.metricsGraphics.coffee", "license": "MIT", "commit": "14b0e411415be801f94fe13ea6f63d5ad957c2ed", "stars": 1544, "source_url": "https://github.com/ExpediaGroup/cyclotron/blob/14b0e411415be801f94fe13ea6f63d5ad957c2ed/cyclotron-site/app/scripts/mgmt/directives/directives.metricsGraphics.coffee", "line_start": 51, "line_end": 66}500{"id": "ExpediaGroup/cyclotron:cyclotron-site/app/scripts/mgmt/directives/directives.metricsGraphics.coffee:2:completion", "type": "completion", "prompt": "getMouseoverText = options.mouseover\n options.mouseover = (d, i) ->\n text = getMouseoverText(d, i)\n d3.select('#' + scope.id + ' svg .mg-active-datapoint').text(text)\n\n MG.data_graphic options\n\n scope.$watch 'data', (newData) ->", "response": "redraw()\n\n $element.resize(_.throttle(->\n scope.$apply ->\n scope.width = $element.width()\n redraw()\n , 65))\n }", "source_lang": "CoffeeScript", "target_lang": "CoffeeScript", "repo": "ExpediaGroup/cyclotron", "path": "cyclotron-site/app/scripts/mgmt/directives/directives.metricsGraphics.coffee", "license": "MIT", "commit": "14b0e411415be801f94fe13ea6f63d5ad957c2ed", "stars": 1544, "source_url": "https://github.com/ExpediaGroup/cyclotron/blob/14b0e411415be801f94fe13ea6f63d5ad957c2ed/cyclotron-site/app/scripts/mgmt/directives/directives.metricsGraphics.coffee", "line_start": 51, "line_end": 66}501{"id": "jianliaoim/talk-os:talk-web/client/updater/search-message.coffee:1:raw_corpus", "type": "raw_corpus", "prompt": "", "response": "exports.after = (store, messagesList) ->\n store.update 'searchMessages', (messages) ->\n messages.concat messagesList\n\nexports.before = (store, messagesList) ->\n store.update 'searchMessages', (messages) ->\n messagesList.concat messages\n\nexports.search = (store, messagesList) ->\n store.set 'searchMessages', messagesList", "source_lang": "", "target_lang": "CoffeeScript", "repo": "jianliaoim/talk-os", "path": "talk-web/client/updater/search-message.coffee", "license": "MIT", "commit": "2545c4497865779a55762e03963a39237df9046b", "stars": 2703, "source_url": "https://github.com/jianliaoim/talk-os/blob/2545c4497865779a55762e03963a39237df9046b/talk-web/client/updater/search-message.coffee", "line_start": 1, "line_end": 10}502{"id": "jianliaoim/talk-os:talk-web/client/updater/search-message.coffee:1:coffee_to_js", "type": "coffee_to_js", "prompt": "Convert this CoffeeScript to JavaScript.\n```coffeescript\nexports.after = (store, messagesList) ->\n store.update 'searchMessages', (messages) ->\n messages.concat messagesList\n\nexports.before = (store, messagesList) ->\n store.update 'searchMessages', (messages) ->\n messagesList.concat messages\n\nexports.search = (store, messagesList) ->\n store.set 'searchMessages', messagesList\n```", "response": "exports.after = function(store, messagesList) {\n return store.update('searchMessages', function(messages) {\n return messages.concat(messagesList);\n });\n};\n\nexports.before = function(store, messagesList) {\n return store.update('searchMessages', function(messages) {\n return messagesList.concat(messages);\n });\n};\n\nexports.search = function(store, messagesList) {\n return store.set('searchMessages', messagesList);\n};", "source_lang": "CoffeeScript", "target_lang": "JavaScript", "repo": "jianliaoim/talk-os", "path": "talk-web/client/updater/search-message.coffee", "license": "MIT", "commit": "2545c4497865779a55762e03963a39237df9046b", "stars": 2703, "source_url": "https://github.com/jianliaoim/talk-os/blob/2545c4497865779a55762e03963a39237df9046b/talk-web/client/updater/search-message.coffee", "line_start": 1, "line_end": 10}503{"id": "jianliaoim/talk-os:talk-web/client/updater/search-message.coffee:1:js_to_coffee", "type": "js_to_coffee", "prompt": "Convert this JavaScript to CoffeeScript.\n```javascript\nexports.after = function(store, messagesList) {\n return store.update('searchMessages', function(messages) {\n return messages.concat(messagesList);\n });\n};\n\nexports.before = function(store, messagesList) {\n return store.update('searchMessages', function(messages) {\n return messagesList.concat(messages);\n });\n};\n\nexports.search = function(store, messagesList) {\n return store.set('searchMessages', messagesList);\n};\n```", "response": "exports.after = (store, messagesList) ->\n store.update 'searchMessages', (messages) ->\n messages.concat messagesList\n\nexports.before = (store, messagesList) ->\n store.update 'searchMessages', (messages) ->\n messagesList.concat messages\n\nexports.search = (store, messagesList) ->\n store.set 'searchMessages', messagesList", "source_lang": "JavaScript", "target_lang": "CoffeeScript", "repo": "jianliaoim/talk-os", "path": "talk-web/client/updater/search-message.coffee", "license": "MIT", "commit": "2545c4497865779a55762e03963a39237df9046b", "stars": 2703, "source_url": "https://github.com/jianliaoim/talk-os/blob/2545c4497865779a55762e03963a39237df9046b/talk-web/client/updater/search-message.coffee", "line_start": 1, "line_end": 10}504{"id": "jianliaoim/talk-os:talk-web/client/updater/search-message.coffee:1:completion", "type": "completion", "prompt": "exports.after = (store, messagesList) ->\n store.update 'searchMessages', (messages) ->\n messages.concat messagesList\n\nexports.before = (store, messagesList) ->", "response": "store.update 'searchMessages', (messages) ->\n messagesList.concat messages\n\nexports.search = (store, messagesList) ->\n store.set 'searchMessages', messagesList", "source_lang": "CoffeeScript", "target_lang": "CoffeeScript", "repo": "jianliaoim/talk-os", "path": "talk-web/client/updater/search-message.coffee", "license": "MIT", "commit": "2545c4497865779a55762e03963a39237df9046b", "stars": 2703, "source_url": "https://github.com/jianliaoim/talk-os/blob/2545c4497865779a55762e03963a39237df9046b/talk-web/client/updater/search-message.coffee", "line_start": 1, "line_end": 10}505{"id": "jrcryer/grunt-pagespeed:tasks/pagespeed.coffee:1:raw_corpus", "type": "raw_corpus", "prompt": "", "response": "#\n# grunt-pagespeed\n# http://www.jamescryer.com/grunt-pagespeed\n#\n# Copyright (c) 2013 James Cryer\n# http://www.jamescryer.com\n# Licensed under the MIT license.\n#\n'use strict'\n\nmodule.exports = (grunt) ->\n\n config = require('./lib/config').init grunt\n psi = require('psi')\n\n grunt.registerMultiTask 'pagespeed', 'Run Pagespeed Insights', ->\n done = this.async()\n params = config.params this.options(this.data)\n numOfTests = params.length\n current = 0\n\n for index, options of params\n psi.output(options.url, options).then (response) ->\n current++\n done() if numOfTests == current\n .catch (err) ->\n current++\n done(err) if numOfTests == current", "source_lang": "", "target_lang": "CoffeeScript", "repo": "jrcryer/grunt-pagespeed", "path": "tasks/pagespeed.coffee", "license": "MIT", "commit": "89804738ab895209b737fdc8a336e502b36aea6b", "stars": 459, "source_url": "https://github.com/jrcryer/grunt-pagespeed/blob/89804738ab895209b737fdc8a336e502b36aea6b/tasks/pagespeed.coffee", "line_start": 1, "line_end": 28}506{"id": "jrcryer/grunt-pagespeed:tasks/pagespeed.coffee:1:coffee_to_js", "type": "coffee_to_js", "prompt": "Convert this CoffeeScript to JavaScript.\n```coffeescript\n#\n# grunt-pagespeed\n# http://www.jamescryer.com/grunt-pagespeed\n#\n# Copyright (c) 2013 James Cryer\n# http://www.jamescryer.com\n# Licensed under the MIT license.\n#\n'use strict'\n\nmodule.exports = (grunt) ->\n\n config = require('./lib/config').init grunt\n psi = require('psi')\n\n grunt.registerMultiTask 'pagespeed', 'Run Pagespeed Insights', ->\n done = this.async()\n params = config.params this.options(this.data)\n numOfTests = params.length\n current = 0\n\n for index, options of params\n psi.output(options.url, options).then (response) ->\n current++\n done() if numOfTests == current\n .catch (err) ->\n current++\n done(err) if numOfTests == current\n```", "response": "// grunt-pagespeed\n// http://www.jamescryer.com/grunt-pagespeed\n\n// Copyright (c) 2013 James Cryer\n// http://www.jamescryer.com\n// Licensed under the MIT license.\n\n'use strict';\nmodule.exports = function(grunt) {\n var config, psi;\n config = require('./lib/config').init(grunt);\n psi = require('psi');\n return grunt.registerMultiTask('pagespeed', 'Run Pagespeed Insights', function() {\n var current, done, index, numOfTests, options, params, results;\n done = this.async();\n params = config.params(this.options(this.data));\n numOfTests = params.length;\n current = 0;\n results = [];\n for (index in params) {\n options = params[index];\n results.push(psi.output(options.url, options).then(function(response) {\n current++;\n if (numOfTests === current) {\n return done();\n }\n }).catch(function(err) {\n current++;\n if (numOfTests === current) {\n return done(err);\n }\n }));\n }\n return results;\n });\n};", "source_lang": "CoffeeScript", "target_lang": "JavaScript", "repo": "jrcryer/grunt-pagespeed", "path": "tasks/pagespeed.coffee", "license": "MIT", "commit": "89804738ab895209b737fdc8a336e502b36aea6b", "stars": 459, "source_url": "https://github.com/jrcryer/grunt-pagespeed/blob/89804738ab895209b737fdc8a336e502b36aea6b/tasks/pagespeed.coffee", "line_start": 1, "line_end": 28}507{"id": "jrcryer/grunt-pagespeed:tasks/pagespeed.coffee:1:js_to_coffee", "type": "js_to_coffee", "prompt": "Convert this JavaScript to CoffeeScript.\n```javascript\n// grunt-pagespeed\n// http://www.jamescryer.com/grunt-pagespeed\n\n// Copyright (c) 2013 James Cryer\n// http://www.jamescryer.com\n// Licensed under the MIT license.\n\n'use strict';\nmodule.exports = function(grunt) {\n var config, psi;\n config = require('./lib/config').init(grunt);\n psi = require('psi');\n return grunt.registerMultiTask('pagespeed', 'Run Pagespeed Insights', function() {\n var current, done, index, numOfTests, options, params, results;\n done = this.async();\n params = config.params(this.options(this.data));\n numOfTests = params.length;\n current = 0;\n results = [];\n for (index in params) {\n options = params[index];\n results.push(psi.output(options.url, options).then(function(response) {\n current++;\n if (numOfTests === current) {\n return done();\n }\n }).catch(function(err) {\n current++;\n if (numOfTests === current) {\n return done(err);\n }\n }));\n }\n return results;\n });\n};\n```", "response": "#\n# grunt-pagespeed\n# http://www.jamescryer.com/grunt-pagespeed\n#\n# Copyright (c) 2013 James Cryer\n# http://www.jamescryer.com\n# Licensed under the MIT license.\n#\n'use strict'\n\nmodule.exports = (grunt) ->\n\n config = require('./lib/config').init grunt\n psi = require('psi')\n\n grunt.registerMultiTask 'pagespeed', 'Run Pagespeed Insights', ->\n done = this.async()\n params = config.params this.options(this.data)\n numOfTests = params.length\n current = 0\n\n for index, options of params\n psi.output(options.url, options).then (response) ->\n current++\n done() if numOfTests == current\n .catch (err) ->\n current++\n done(err) if numOfTests == current", "source_lang": "JavaScript", "target_lang": "CoffeeScript", "repo": "jrcryer/grunt-pagespeed", "path": "tasks/pagespeed.coffee", "license": "MIT", "commit": "89804738ab895209b737fdc8a336e502b36aea6b", "stars": 459, "source_url": "https://github.com/jrcryer/grunt-pagespeed/blob/89804738ab895209b737fdc8a336e502b36aea6b/tasks/pagespeed.coffee", "line_start": 1, "line_end": 28}508{"id": "jrcryer/grunt-pagespeed:tasks/pagespeed.coffee:1:completion", "type": "completion", "prompt": "#\n# grunt-pagespeed\n# http://www.jamescryer.com/grunt-pagespeed\n#\n# Copyright (c) 2013 James Cryer\n# http://www.jamescryer.com\n# Licensed under the MIT license.\n#\n'use strict'\n\nmodule.exports = (grunt) ->\n\n config = require('./lib/config').init grunt\n psi = require('psi')", "response": "grunt.registerMultiTask 'pagespeed', 'Run Pagespeed Insights', ->\n done = this.async()\n params = config.params this.options(this.data)\n numOfTests = params.length\n current = 0\n\n for index, options of params\n psi.output(options.url, options).then (response) ->\n current++\n done() if numOfTests == current\n .catch (err) ->\n current++\n done(err) if numOfTests == current", "source_lang": "CoffeeScript", "target_lang": "CoffeeScript", "repo": "jrcryer/grunt-pagespeed", "path": "tasks/pagespeed.coffee", "license": "MIT", "commit": "89804738ab895209b737fdc8a336e502b36aea6b", "stars": 459, "source_url": "https://github.com/jrcryer/grunt-pagespeed/blob/89804738ab895209b737fdc8a336e502b36aea6b/tasks/pagespeed.coffee", "line_start": 1, "line_end": 28}509{"id": "jrcryer/grunt-pagespeed:tasks/pagespeed.coffee:1:raw_corpus", "type": "raw_corpus", "prompt": "", "response": "#\n# grunt-pagespeed\n# http://www.jamescryer.com/grunt-pagespeed\n#\n# Copyright (c) 2013 James Cryer\n# http://www.jamescryer.com\n# Licensed under the MIT license.\n#\n'use strict'\n\nmodule.exports = (grunt) ->\n\n config = require('./lib/config').init grunt\n psi = require('psi')\n\n grunt.registerMultiTask 'pagespeed', 'Run Pagespeed Insights', ->\n done = this.async()\n params = config.params this.options(this.data)\n numOfTests = params.length\n current = 0\n\n for index, options of params\n psi.output(options.url, options).then (response) ->\n current++\n done() if numOfTests == current\n .catch (err) ->\n done(err) if numOfTests == current", "source_lang": "", "target_lang": "CoffeeScript", "repo": "jrcryer/grunt-pagespeed", "path": "tasks/pagespeed.coffee", "license": "MIT", "commit": "f984c431aefc0bb938b8c6e8e97a9d782d17018c", "stars": 459, "source_url": "https://github.com/jrcryer/grunt-pagespeed/blob/f984c431aefc0bb938b8c6e8e97a9d782d17018c/tasks/pagespeed.coffee", "line_start": 1, "line_end": 27}510{"id": "jrcryer/grunt-pagespeed:tasks/pagespeed.coffee:1:coffee_to_js", "type": "coffee_to_js", "prompt": "Convert this CoffeeScript to JavaScript.\n```coffeescript\n#\n# grunt-pagespeed\n# http://www.jamescryer.com/grunt-pagespeed\n#\n# Copyright (c) 2013 James Cryer\n# http://www.jamescryer.com\n# Licensed under the MIT license.\n#\n'use strict'\n\nmodule.exports = (grunt) ->\n\n config = require('./lib/config').init grunt\n psi = require('psi')\n\n grunt.registerMultiTask 'pagespeed', 'Run Pagespeed Insights', ->\n done = this.async()\n params = config.params this.options(this.data)\n numOfTests = params.length\n current = 0\n\n for index, options of params\n psi.output(options.url, options).then (response) ->\n current++\n done() if numOfTests == current\n .catch (err) ->\n done(err) if numOfTests == current\n```", "response": "// grunt-pagespeed\n// http://www.jamescryer.com/grunt-pagespeed\n\n// Copyright (c) 2013 James Cryer\n// http://www.jamescryer.com\n// Licensed under the MIT license.\n\n'use strict';\nmodule.exports = function(grunt) {\n var config, psi;\n config = require('./lib/config').init(grunt);\n psi = require('psi');\n return grunt.registerMultiTask('pagespeed', 'Run Pagespeed Insights', function() {\n var current, done, index, numOfTests, options, params, results;\n done = this.async();\n params = config.params(this.options(this.data));\n numOfTests = params.length;\n current = 0;\n results = [];\n for (index in params) {\n options = params[index];\n results.push(psi.output(options.url, options).then(function(response) {\n current++;\n if (numOfTests === current) {\n return done();\n }\n }).catch(function(err) {\n if (numOfTests === current) {\n return done(err);\n }\n }));\n }\n return results;\n });\n};", "source_lang": "CoffeeScript", "target_lang": "JavaScript", "repo": "jrcryer/grunt-pagespeed", "path": "tasks/pagespeed.coffee", "license": "MIT", "commit": "f984c431aefc0bb938b8c6e8e97a9d782d17018c", "stars": 459, "source_url": "https://github.com/jrcryer/grunt-pagespeed/blob/f984c431aefc0bb938b8c6e8e97a9d782d17018c/tasks/pagespeed.coffee", "line_start": 1, "line_end": 27}511{"id": "jrcryer/grunt-pagespeed:tasks/pagespeed.coffee:1:js_to_coffee", "type": "js_to_coffee", "prompt": "Convert this JavaScript to CoffeeScript.\n```javascript\n// grunt-pagespeed\n// http://www.jamescryer.com/grunt-pagespeed\n\n// Copyright (c) 2013 James Cryer\n// http://www.jamescryer.com\n// Licensed under the MIT license.\n\n'use strict';\nmodule.exports = function(grunt) {\n var config, psi;\n config = require('./lib/config').init(grunt);\n psi = require('psi');\n return grunt.registerMultiTask('pagespeed', 'Run Pagespeed Insights', function() {\n var current, done, index, numOfTests, options, params, results;\n done = this.async();\n params = config.params(this.options(this.data));\n numOfTests = params.length;\n current = 0;\n results = [];\n for (index in params) {\n options = params[index];\n results.push(psi.output(options.url, options).then(function(response) {\n current++;\n if (numOfTests === current) {\n return done();\n }\n }).catch(function(err) {\n if (numOfTests === current) {\n return done(err);\n }\n }));\n }\n return results;\n });\n};\n```", "response": "#\n# grunt-pagespeed\n# http://www.jamescryer.com/grunt-pagespeed\n#\n# Copyright (c) 2013 James Cryer\n# http://www.jamescryer.com\n# Licensed under the MIT license.\n#\n'use strict'\n\nmodule.exports = (grunt) ->\n\n config = require('./lib/config').init grunt\n psi = require('psi')\n\n grunt.registerMultiTask 'pagespeed', 'Run Pagespeed Insights', ->\n done = this.async()\n params = config.params this.options(this.data)\n numOfTests = params.length\n current = 0\n\n for index, options of params\n psi.output(options.url, options).then (response) ->\n current++\n done() if numOfTests == current\n .catch (err) ->\n done(err) if numOfTests == current", "source_lang": "JavaScript", "target_lang": "CoffeeScript", "repo": "jrcryer/grunt-pagespeed", "path": "tasks/pagespeed.coffee", "license": "MIT", "commit": "f984c431aefc0bb938b8c6e8e97a9d782d17018c", "stars": 459, "source_url": "https://github.com/jrcryer/grunt-pagespeed/blob/f984c431aefc0bb938b8c6e8e97a9d782d17018c/tasks/pagespeed.coffee", "line_start": 1, "line_end": 27}512{"id": "jrcryer/grunt-pagespeed:tasks/pagespeed.coffee:1:completion", "type": "completion", "prompt": "#\n# grunt-pagespeed\n# http://www.jamescryer.com/grunt-pagespeed\n#\n# Copyright (c) 2013 James Cryer\n# http://www.jamescryer.com\n# Licensed under the MIT license.\n#\n'use strict'\n\nmodule.exports = (grunt) ->\n\n config = require('./lib/config').init grunt", "response": "psi = require('psi')\n\n grunt.registerMultiTask 'pagespeed', 'Run Pagespeed Insights', ->\n done = this.async()\n params = config.params this.options(this.data)\n numOfTests = params.length\n current = 0\n\n for index, options of params\n psi.output(options.url, options).then (response) ->\n current++\n done() if numOfTests == current\n .catch (err) ->\n done(err) if numOfTests == current", "source_lang": "CoffeeScript", "target_lang": "CoffeeScript", "repo": "jrcryer/grunt-pagespeed", "path": "tasks/pagespeed.coffee", "license": "MIT", "commit": "f984c431aefc0bb938b8c6e8e97a9d782d17018c", "stars": 459, "source_url": "https://github.com/jrcryer/grunt-pagespeed/blob/f984c431aefc0bb938b8c6e8e97a9d782d17018c/tasks/pagespeed.coffee", "line_start": 1, "line_end": 27}513{"id": "jrcryer/grunt-pagespeed:tasks/pagespeed.coffee:1:raw_corpus", "type": "raw_corpus", "prompt": "", "response": "#\n# grunt-pagespeed\n# http://www.jamescryer.com/grunt-pagespeed\n#\n# Copyright (c) 2013 James Cryer\n# http://www.jamescryer.com\n# Licensed under the MIT license.\n#\n'use strict'\n\nmodule.exports = (grunt) ->\n\n config = require('./lib/config').init grunt\n psi = require('psi')\n\n grunt.registerMultiTask 'pagespeed', 'Run Pagespeed Insights', ->\n done = this.async()\n params = config.params this.options(this.data)\n numOfTests = params.length\n current = 0\n\n for index, options of params\n psi.output(options.url, options, (err, response) ->\n current++\n done(err) if numOfTests == current\n )", "source_lang": "", "target_lang": "CoffeeScript", "repo": "jrcryer/grunt-pagespeed", "path": "tasks/pagespeed.coffee", "license": "MIT", "commit": "eb8f0df22039c83887e984ae22c93079550fd958", "stars": 459, "source_url": "https://github.com/jrcryer/grunt-pagespeed/blob/eb8f0df22039c83887e984ae22c93079550fd958/tasks/pagespeed.coffee", "line_start": 1, "line_end": 26}514{"id": "jrcryer/grunt-pagespeed:tasks/pagespeed.coffee:1:coffee_to_js", "type": "coffee_to_js", "prompt": "Convert this CoffeeScript to JavaScript.\n```coffeescript\n#\n# grunt-pagespeed\n# http://www.jamescryer.com/grunt-pagespeed\n#\n# Copyright (c) 2013 James Cryer\n# http://www.jamescryer.com\n# Licensed under the MIT license.\n#\n'use strict'\n\nmodule.exports = (grunt) ->\n\n config = require('./lib/config').init grunt\n psi = require('psi')\n\n grunt.registerMultiTask 'pagespeed', 'Run Pagespeed Insights', ->\n done = this.async()\n params = config.params this.options(this.data)\n numOfTests = params.length\n current = 0\n\n for index, options of params\n psi.output(options.url, options, (err, response) ->\n current++\n done(err) if numOfTests == current\n )\n```", "response": "// grunt-pagespeed\n// http://www.jamescryer.com/grunt-pagespeed\n\n// Copyright (c) 2013 James Cryer\n// http://www.jamescryer.com\n// Licensed under the MIT license.\n\n'use strict';\nmodule.exports = function(grunt) {\n var config, psi;\n config = require('./lib/config').init(grunt);\n psi = require('psi');\n return grunt.registerMultiTask('pagespeed', 'Run Pagespeed Insights', function() {\n var current, done, index, numOfTests, options, params, results;\n done = this.async();\n params = config.params(this.options(this.data));\n numOfTests = params.length;\n current = 0;\n results = [];\n for (index in params) {\n options = params[index];\n results.push(psi.output(options.url, options, function(err, response) {\n current++;\n if (numOfTests === current) {\n return done(err);\n }\n }));\n }\n return results;\n });\n};", "source_lang": "CoffeeScript", "target_lang": "JavaScript", "repo": "jrcryer/grunt-pagespeed", "path": "tasks/pagespeed.coffee", "license": "MIT", "commit": "eb8f0df22039c83887e984ae22c93079550fd958", "stars": 459, "source_url": "https://github.com/jrcryer/grunt-pagespeed/blob/eb8f0df22039c83887e984ae22c93079550fd958/tasks/pagespeed.coffee", "line_start": 1, "line_end": 26}515{"id": "jrcryer/grunt-pagespeed:tasks/pagespeed.coffee:1:js_to_coffee", "type": "js_to_coffee", "prompt": "Convert this JavaScript to CoffeeScript.\n```javascript\n// grunt-pagespeed\n// http://www.jamescryer.com/grunt-pagespeed\n\n// Copyright (c) 2013 James Cryer\n// http://www.jamescryer.com\n// Licensed under the MIT license.\n\n'use strict';\nmodule.exports = function(grunt) {\n var config, psi;\n config = require('./lib/config').init(grunt);\n psi = require('psi');\n return grunt.registerMultiTask('pagespeed', 'Run Pagespeed Insights', function() {\n var current, done, index, numOfTests, options, params, results;\n done = this.async();\n params = config.params(this.options(this.data));\n numOfTests = params.length;\n current = 0;\n results = [];\n for (index in params) {\n options = params[index];\n results.push(psi.output(options.url, options, function(err, response) {\n current++;\n if (numOfTests === current) {\n return done(err);\n }\n }));\n }\n return results;\n });\n};\n```", "response": "#\n# grunt-pagespeed\n# http://www.jamescryer.com/grunt-pagespeed\n#\n# Copyright (c) 2013 James Cryer\n# http://www.jamescryer.com\n# Licensed under the MIT license.\n#\n'use strict'\n\nmodule.exports = (grunt) ->\n\n config = require('./lib/config').init grunt\n psi = require('psi')\n\n grunt.registerMultiTask 'pagespeed', 'Run Pagespeed Insights', ->\n done = this.async()\n params = config.params this.options(this.data)\n numOfTests = params.length\n current = 0\n\n for index, options of params\n psi.output(options.url, options, (err, response) ->\n current++\n done(err) if numOfTests == current\n )", "source_lang": "JavaScript", "target_lang": "CoffeeScript", "repo": "jrcryer/grunt-pagespeed", "path": "tasks/pagespeed.coffee", "license": "MIT", "commit": "eb8f0df22039c83887e984ae22c93079550fd958", "stars": 459, "source_url": "https://github.com/jrcryer/grunt-pagespeed/blob/eb8f0df22039c83887e984ae22c93079550fd958/tasks/pagespeed.coffee", "line_start": 1, "line_end": 26}516{"id": "jrcryer/grunt-pagespeed:tasks/pagespeed.coffee:1:completion", "type": "completion", "prompt": "#\n# grunt-pagespeed\n# http://www.jamescryer.com/grunt-pagespeed\n#\n# Copyright (c) 2013 James Cryer\n# http://www.jamescryer.com\n# Licensed under the MIT license.\n#\n'use strict'\n\nmodule.exports = (grunt) ->\n\n config = require('./lib/config').init grunt", "response": "psi = require('psi')\n\n grunt.registerMultiTask 'pagespeed', 'Run Pagespeed Insights', ->\n done = this.async()\n params = config.params this.options(this.data)\n numOfTests = params.length\n current = 0\n\n for index, options of params\n psi.output(options.url, options, (err, response) ->\n current++\n done(err) if numOfTests == current\n )", "source_lang": "CoffeeScript", "target_lang": "CoffeeScript", "repo": "jrcryer/grunt-pagespeed", "path": "tasks/pagespeed.coffee", "license": "MIT", "commit": "eb8f0df22039c83887e984ae22c93079550fd958", "stars": 459, "source_url": "https://github.com/jrcryer/grunt-pagespeed/blob/eb8f0df22039c83887e984ae22c93079550fd958/tasks/pagespeed.coffee", "line_start": 1, "line_end": 26}517{"id": "jrcryer/grunt-pagespeed:tasks/pagespeed.coffee:1:raw_corpus", "type": "raw_corpus", "prompt": "", "response": "#\n# grunt-pagespeed\n# http://www.jamescryer.com/grunt-pagespeed\n#\n# Copyright (c) 2013 James Cryer\n# http://www.jamescryer.com\n# Licensed under the MIT license.\n#\n'use strict'\n\nmodule.exports = (grunt) ->\n\n config = require('./lib/config').init grunt\n psi = require('psi')\n\n grunt.registerMultiTask 'pagespeed', 'Run Pagespeed Insights', ->\n done = this.async()\n params = config.params this.options(this.data)\n numOfTests = params.length\n current = 0\n\n for index, options of params\n psi(options, (err, response) ->\n current++\n done(err) if numOfTests == current\n )", "source_lang": "", "target_lang": "CoffeeScript", "repo": "jrcryer/grunt-pagespeed", "path": "tasks/pagespeed.coffee", "license": "MIT", "commit": "674417c12c51d08f011ed0b45287c68c2555516f", "stars": 459, "source_url": "https://github.com/jrcryer/grunt-pagespeed/blob/674417c12c51d08f011ed0b45287c68c2555516f/tasks/pagespeed.coffee", "line_start": 1, "line_end": 26}518{"id": "jrcryer/grunt-pagespeed:tasks/pagespeed.coffee:1:coffee_to_js", "type": "coffee_to_js", "prompt": "Convert this CoffeeScript to JavaScript.\n```coffeescript\n#\n# grunt-pagespeed\n# http://www.jamescryer.com/grunt-pagespeed\n#\n# Copyright (c) 2013 James Cryer\n# http://www.jamescryer.com\n# Licensed under the MIT license.\n#\n'use strict'\n\nmodule.exports = (grunt) ->\n\n config = require('./lib/config').init grunt\n psi = require('psi')\n\n grunt.registerMultiTask 'pagespeed', 'Run Pagespeed Insights', ->\n done = this.async()\n params = config.params this.options(this.data)\n numOfTests = params.length\n current = 0\n\n for index, options of params\n psi(options, (err, response) ->\n current++\n done(err) if numOfTests == current\n )\n```", "response": "// grunt-pagespeed\n// http://www.jamescryer.com/grunt-pagespeed\n\n// Copyright (c) 2013 James Cryer\n// http://www.jamescryer.com\n// Licensed under the MIT license.\n\n'use strict';\nmodule.exports = function(grunt) {\n var config, psi;\n config = require('./lib/config').init(grunt);\n psi = require('psi');\n return grunt.registerMultiTask('pagespeed', 'Run Pagespeed Insights', function() {\n var current, done, index, numOfTests, options, params, results;\n done = this.async();\n params = config.params(this.options(this.data));\n numOfTests = params.length;\n current = 0;\n results = [];\n for (index in params) {\n options = params[index];\n results.push(psi(options, function(err, response) {\n current++;\n if (numOfTests === current) {\n return done(err);\n }\n }));\n }\n return results;\n });\n};", "source_lang": "CoffeeScript", "target_lang": "JavaScript", "repo": "jrcryer/grunt-pagespeed", "path": "tasks/pagespeed.coffee", "license": "MIT", "commit": "674417c12c51d08f011ed0b45287c68c2555516f", "stars": 459, "source_url": "https://github.com/jrcryer/grunt-pagespeed/blob/674417c12c51d08f011ed0b45287c68c2555516f/tasks/pagespeed.coffee", "line_start": 1, "line_end": 26}519{"id": "jrcryer/grunt-pagespeed:tasks/pagespeed.coffee:1:js_to_coffee", "type": "js_to_coffee", "prompt": "Convert this JavaScript to CoffeeScript.\n```javascript\n// grunt-pagespeed\n// http://www.jamescryer.com/grunt-pagespeed\n\n// Copyright (c) 2013 James Cryer\n// http://www.jamescryer.com\n// Licensed under the MIT license.\n\n'use strict';\nmodule.exports = function(grunt) {\n var config, psi;\n config = require('./lib/config').init(grunt);\n psi = require('psi');\n return grunt.registerMultiTask('pagespeed', 'Run Pagespeed Insights', function() {\n var current, done, index, numOfTests, options, params, results;\n done = this.async();\n params = config.params(this.options(this.data));\n numOfTests = params.length;\n current = 0;\n results = [];\n for (index in params) {\n options = params[index];\n results.push(psi(options, function(err, response) {\n current++;\n if (numOfTests === current) {\n return done(err);\n }\n }));\n }\n return results;\n });\n};\n```", "response": "#\n# grunt-pagespeed\n# http://www.jamescryer.com/grunt-pagespeed\n#\n# Copyright (c) 2013 James Cryer\n# http://www.jamescryer.com\n# Licensed under the MIT license.\n#\n'use strict'\n\nmodule.exports = (grunt) ->\n\n config = require('./lib/config').init grunt\n psi = require('psi')\n\n grunt.registerMultiTask 'pagespeed', 'Run Pagespeed Insights', ->\n done = this.async()\n params = config.params this.options(this.data)\n numOfTests = params.length\n current = 0\n\n for index, options of params\n psi(options, (err, response) ->\n current++\n done(err) if numOfTests == current\n )", "source_lang": "JavaScript", "target_lang": "CoffeeScript", "repo": "jrcryer/grunt-pagespeed", "path": "tasks/pagespeed.coffee", "license": "MIT", "commit": "674417c12c51d08f011ed0b45287c68c2555516f", "stars": 459, "source_url": "https://github.com/jrcryer/grunt-pagespeed/blob/674417c12c51d08f011ed0b45287c68c2555516f/tasks/pagespeed.coffee", "line_start": 1, "line_end": 26}520{"id": "jrcryer/grunt-pagespeed:tasks/pagespeed.coffee:1:completion", "type": "completion", "prompt": "#\n# grunt-pagespeed\n# http://www.jamescryer.com/grunt-pagespeed\n#\n# Copyright (c) 2013 James Cryer\n# http://www.jamescryer.com\n# Licensed under the MIT license.\n#\n'use strict'\n\nmodule.exports = (grunt) ->\n\n config = require('./lib/config').init grunt", "response": "psi = require('psi')\n\n grunt.registerMultiTask 'pagespeed', 'Run Pagespeed Insights', ->\n done = this.async()\n params = config.params this.options(this.data)\n numOfTests = params.length\n current = 0\n\n for index, options of params\n psi(options, (err, response) ->\n current++\n done(err) if numOfTests == current\n )", "source_lang": "CoffeeScript", "target_lang": "CoffeeScript", "repo": "jrcryer/grunt-pagespeed", "path": "tasks/pagespeed.coffee", "license": "MIT", "commit": "674417c12c51d08f011ed0b45287c68c2555516f", "stars": 459, "source_url": "https://github.com/jrcryer/grunt-pagespeed/blob/674417c12c51d08f011ed0b45287c68c2555516f/tasks/pagespeed.coffee", "line_start": 1, "line_end": 26}521{"id": "jrcryer/grunt-pagespeed:tasks/pagespeed.coffee:1:raw_corpus", "type": "raw_corpus", "prompt": "", "response": "#\n# grunt-pagespeed\n# http://www.jamescryer.com/grunt-pagespeed\n#\n# Copyright (c) 2013 James Cryer\n# http://www.jamescryer.com\n# Licensed under the MIT license.\n#\n'use strict'\n\nmodule.exports = (grunt) ->\n\n config = require('./lib/config').init grunt\n psi = require('psi')\n\n grunt.registerMultiTask 'pagespeed', 'Run Pagespeed Insights', ->\n done = this.async()\n params = config.params this.options(this.data)\n numOfTests = params.length\n index = 0\n\n for index, options of params\n psi(options, (err, response) ->\n index++\n done(err) if numOfTests == index\n )", "source_lang": "", "target_lang": "CoffeeScript", "repo": "jrcryer/grunt-pagespeed", "path": "tasks/pagespeed.coffee", "license": "MIT", "commit": "beaf05085baedaeb45d6900ed4e23a88a4e4c57a", "stars": 459, "source_url": "https://github.com/jrcryer/grunt-pagespeed/blob/beaf05085baedaeb45d6900ed4e23a88a4e4c57a/tasks/pagespeed.coffee", "line_start": 1, "line_end": 26}522{"id": "jrcryer/grunt-pagespeed:tasks/pagespeed.coffee:1:coffee_to_js", "type": "coffee_to_js", "prompt": "Convert this CoffeeScript to JavaScript.\n```coffeescript\n#\n# grunt-pagespeed\n# http://www.jamescryer.com/grunt-pagespeed\n#\n# Copyright (c) 2013 James Cryer\n# http://www.jamescryer.com\n# Licensed under the MIT license.\n#\n'use strict'\n\nmodule.exports = (grunt) ->\n\n config = require('./lib/config').init grunt\n psi = require('psi')\n\n grunt.registerMultiTask 'pagespeed', 'Run Pagespeed Insights', ->\n done = this.async()\n params = config.params this.options(this.data)\n numOfTests = params.length\n index = 0\n\n for index, options of params\n psi(options, (err, response) ->\n index++\n done(err) if numOfTests == index\n )\n```", "response": "// grunt-pagespeed\n// http://www.jamescryer.com/grunt-pagespeed\n\n// Copyright (c) 2013 James Cryer\n// http://www.jamescryer.com\n// Licensed under the MIT license.\n\n'use strict';\nmodule.exports = function(grunt) {\n var config, psi;\n config = require('./lib/config').init(grunt);\n psi = require('psi');\n return grunt.registerMultiTask('pagespeed', 'Run Pagespeed Insights', function() {\n var done, index, numOfTests, options, params, results;\n done = this.async();\n params = config.params(this.options(this.data));\n numOfTests = params.length;\n index = 0;\n results = [];\n for (index in params) {\n options = params[index];\n results.push(psi(options, function(err, response) {\n index++;\n if (numOfTests === index) {\n return done(err);\n }\n }));\n }\n return results;\n });\n};", "source_lang": "CoffeeScript", "target_lang": "JavaScript", "repo": "jrcryer/grunt-pagespeed", "path": "tasks/pagespeed.coffee", "license": "MIT", "commit": "beaf05085baedaeb45d6900ed4e23a88a4e4c57a", "stars": 459, "source_url": "https://github.com/jrcryer/grunt-pagespeed/blob/beaf05085baedaeb45d6900ed4e23a88a4e4c57a/tasks/pagespeed.coffee", "line_start": 1, "line_end": 26}523{"id": "jrcryer/grunt-pagespeed:tasks/pagespeed.coffee:1:js_to_coffee", "type": "js_to_coffee", "prompt": "Convert this JavaScript to CoffeeScript.\n```javascript\n// grunt-pagespeed\n// http://www.jamescryer.com/grunt-pagespeed\n\n// Copyright (c) 2013 James Cryer\n// http://www.jamescryer.com\n// Licensed under the MIT license.\n\n'use strict';\nmodule.exports = function(grunt) {\n var config, psi;\n config = require('./lib/config').init(grunt);\n psi = require('psi');\n return grunt.registerMultiTask('pagespeed', 'Run Pagespeed Insights', function() {\n var done, index, numOfTests, options, params, results;\n done = this.async();\n params = config.params(this.options(this.data));\n numOfTests = params.length;\n index = 0;\n results = [];\n for (index in params) {\n options = params[index];\n results.push(psi(options, function(err, response) {\n index++;\n if (numOfTests === index) {\n return done(err);\n }\n }));\n }\n return results;\n });\n};\n```", "response": "#\n# grunt-pagespeed\n# http://www.jamescryer.com/grunt-pagespeed\n#\n# Copyright (c) 2013 James Cryer\n# http://www.jamescryer.com\n# Licensed under the MIT license.\n#\n'use strict'\n\nmodule.exports = (grunt) ->\n\n config = require('./lib/config').init grunt\n psi = require('psi')\n\n grunt.registerMultiTask 'pagespeed', 'Run Pagespeed Insights', ->\n done = this.async()\n params = config.params this.options(this.data)\n numOfTests = params.length\n index = 0\n\n for index, options of params\n psi(options, (err, response) ->\n index++\n done(err) if numOfTests == index\n )", "source_lang": "JavaScript", "target_lang": "CoffeeScript", "repo": "jrcryer/grunt-pagespeed", "path": "tasks/pagespeed.coffee", "license": "MIT", "commit": "beaf05085baedaeb45d6900ed4e23a88a4e4c57a", "stars": 459, "source_url": "https://github.com/jrcryer/grunt-pagespeed/blob/beaf05085baedaeb45d6900ed4e23a88a4e4c57a/tasks/pagespeed.coffee", "line_start": 1, "line_end": 26}524{"id": "jrcryer/grunt-pagespeed:tasks/pagespeed.coffee:1:completion", "type": "completion", "prompt": "#\n# grunt-pagespeed\n# http://www.jamescryer.com/grunt-pagespeed\n#\n# Copyright (c) 2013 James Cryer\n# http://www.jamescryer.com\n# Licensed under the MIT license.\n#\n'use strict'\n\nmodule.exports = (grunt) ->\n\n config = require('./lib/config').init grunt", "response": "psi = require('psi')\n\n grunt.registerMultiTask 'pagespeed', 'Run Pagespeed Insights', ->\n done = this.async()\n params = config.params this.options(this.data)\n numOfTests = params.length\n index = 0\n\n for index, options of params\n psi(options, (err, response) ->\n index++\n done(err) if numOfTests == index\n )", "source_lang": "CoffeeScript", "target_lang": "CoffeeScript", "repo": "jrcryer/grunt-pagespeed", "path": "tasks/pagespeed.coffee", "license": "MIT", "commit": "beaf05085baedaeb45d6900ed4e23a88a4e4c57a", "stars": 459, "source_url": "https://github.com/jrcryer/grunt-pagespeed/blob/beaf05085baedaeb45d6900ed4e23a88a4e4c57a/tasks/pagespeed.coffee", "line_start": 1, "line_end": 26}525{"id": "jrcryer/grunt-pagespeed:tasks/pagespeed.coffee:1:raw_corpus", "type": "raw_corpus", "prompt": "", "response": "#\n# grunt-pagespeed\n# http://www.jamescryer.com/grunt-pagespeed\n#\n# Copyright (c) 2013 James Cryer\n# http://www.jamescryer.com\n# Licensed under the MIT license.\n#\n'use strict'\n\nmodule.exports = (grunt) ->\n\n config = require('./lib/config').init grunt\n psi = require('psi')\n\n grunt.registerMultiTask 'pagespeed', 'Run Pagespeed Insights', ->\n done = this.async()\n params = config.params this.options(this.data)\n numOfTests = params.length\n index = 0\n\n for index, options of params\n psi(options, (err, response) ->\n index++\n done() if numOfTests == index\n )", "source_lang": "", "target_lang": "CoffeeScript", "repo": "jrcryer/grunt-pagespeed", "path": "tasks/pagespeed.coffee", "license": "MIT", "commit": "0656f7f816984227f3fa13002d5e47ca2e92bf02", "stars": 459, "source_url": "https://github.com/jrcryer/grunt-pagespeed/blob/0656f7f816984227f3fa13002d5e47ca2e92bf02/tasks/pagespeed.coffee", "line_start": 1, "line_end": 26}526{"id": "jrcryer/grunt-pagespeed:tasks/pagespeed.coffee:1:coffee_to_js", "type": "coffee_to_js", "prompt": "Convert this CoffeeScript to JavaScript.\n```coffeescript\n#\n# grunt-pagespeed\n# http://www.jamescryer.com/grunt-pagespeed\n#\n# Copyright (c) 2013 James Cryer\n# http://www.jamescryer.com\n# Licensed under the MIT license.\n#\n'use strict'\n\nmodule.exports = (grunt) ->\n\n config = require('./lib/config').init grunt\n psi = require('psi')\n\n grunt.registerMultiTask 'pagespeed', 'Run Pagespeed Insights', ->\n done = this.async()\n params = config.params this.options(this.data)\n numOfTests = params.length\n index = 0\n\n for index, options of params\n psi(options, (err, response) ->\n index++\n done() if numOfTests == index\n )\n```", "response": "// grunt-pagespeed\n// http://www.jamescryer.com/grunt-pagespeed\n\n// Copyright (c) 2013 James Cryer\n// http://www.jamescryer.com\n// Licensed under the MIT license.\n\n'use strict';\nmodule.exports = function(grunt) {\n var config, psi;\n config = require('./lib/config').init(grunt);\n psi = require('psi');\n return grunt.registerMultiTask('pagespeed', 'Run Pagespeed Insights', function() {\n var done, index, numOfTests, options, params, results;\n done = this.async();\n params = config.params(this.options(this.data));\n numOfTests = params.length;\n index = 0;\n results = [];\n for (index in params) {\n options = params[index];\n results.push(psi(options, function(err, response) {\n index++;\n if (numOfTests === index) {\n return done();\n }\n }));\n }\n return results;\n });\n};", "source_lang": "CoffeeScript", "target_lang": "JavaScript", "repo": "jrcryer/grunt-pagespeed", "path": "tasks/pagespeed.coffee", "license": "MIT", "commit": "0656f7f816984227f3fa13002d5e47ca2e92bf02", "stars": 459, "source_url": "https://github.com/jrcryer/grunt-pagespeed/blob/0656f7f816984227f3fa13002d5e47ca2e92bf02/tasks/pagespeed.coffee", "line_start": 1, "line_end": 26}527{"id": "jrcryer/grunt-pagespeed:tasks/pagespeed.coffee:1:js_to_coffee", "type": "js_to_coffee", "prompt": "Convert this JavaScript to CoffeeScript.\n```javascript\n// grunt-pagespeed\n// http://www.jamescryer.com/grunt-pagespeed\n\n// Copyright (c) 2013 James Cryer\n// http://www.jamescryer.com\n// Licensed under the MIT license.\n\n'use strict';\nmodule.exports = function(grunt) {\n var config, psi;\n config = require('./lib/config').init(grunt);\n psi = require('psi');\n return grunt.registerMultiTask('pagespeed', 'Run Pagespeed Insights', function() {\n var done, index, numOfTests, options, params, results;\n done = this.async();\n params = config.params(this.options(this.data));\n numOfTests = params.length;\n index = 0;\n results = [];\n for (index in params) {\n options = params[index];\n results.push(psi(options, function(err, response) {\n index++;\n if (numOfTests === index) {\n return done();\n }\n }));\n }\n return results;\n });\n};\n```", "response": "#\n# grunt-pagespeed\n# http://www.jamescryer.com/grunt-pagespeed\n#\n# Copyright (c) 2013 James Cryer\n# http://www.jamescryer.com\n# Licensed under the MIT license.\n#\n'use strict'\n\nmodule.exports = (grunt) ->\n\n config = require('./lib/config').init grunt\n psi = require('psi')\n\n grunt.registerMultiTask 'pagespeed', 'Run Pagespeed Insights', ->\n done = this.async()\n params = config.params this.options(this.data)\n numOfTests = params.length\n index = 0\n\n for index, options of params\n psi(options, (err, response) ->\n index++\n done() if numOfTests == index\n )", "source_lang": "JavaScript", "target_lang": "CoffeeScript", "repo": "jrcryer/grunt-pagespeed", "path": "tasks/pagespeed.coffee", "license": "MIT", "commit": "0656f7f816984227f3fa13002d5e47ca2e92bf02", "stars": 459, "source_url": "https://github.com/jrcryer/grunt-pagespeed/blob/0656f7f816984227f3fa13002d5e47ca2e92bf02/tasks/pagespeed.coffee", "line_start": 1, "line_end": 26}528{"id": "jrcryer/grunt-pagespeed:tasks/pagespeed.coffee:1:completion", "type": "completion", "prompt": "#\n# grunt-pagespeed\n# http://www.jamescryer.com/grunt-pagespeed\n#\n# Copyright (c) 2013 James Cryer\n# http://www.jamescryer.com\n# Licensed under the MIT license.\n#\n'use strict'\n\nmodule.exports = (grunt) ->\n\n config = require('./lib/config').init grunt", "response": "psi = require('psi')\n\n grunt.registerMultiTask 'pagespeed', 'Run Pagespeed Insights', ->\n done = this.async()\n params = config.params this.options(this.data)\n numOfTests = params.length\n index = 0\n\n for index, options of params\n psi(options, (err, response) ->\n index++\n done() if numOfTests == index\n )", "source_lang": "CoffeeScript", "target_lang": "CoffeeScript", "repo": "jrcryer/grunt-pagespeed", "path": "tasks/pagespeed.coffee", "license": "MIT", "commit": "0656f7f816984227f3fa13002d5e47ca2e92bf02", "stars": 459, "source_url": "https://github.com/jrcryer/grunt-pagespeed/blob/0656f7f816984227f3fa13002d5e47ca2e92bf02/tasks/pagespeed.coffee", "line_start": 1, "line_end": 26}529{"id": "jrcryer/grunt-pagespeed:tasks/pagespeed.coffee:1:raw_corpus", "type": "raw_corpus", "prompt": "", "response": "#\n# grunt-pagespeed\n# http://www.jamescryer.com/grunt-pagespeed\n#\n# Copyright (c) 2013 James Cryer\n# http://www.jamescryer.com\n# Licensed under the MIT license.\n#\n'use strict'\n\nmodule.exports = (grunt) ->\n\n config = require('./lib/config').init grunt\n pagespeed = require('./lib/pagespeed').init grunt\n output = require('./lib/output').init grunt\n\n grunt.registerMultiTask 'pagespeed', 'Run Pagespeed Insights', ->\n\n grunt.verbose.writeln 'Running Pagespeed Insights'\n done = this.async()\n\n params = config.params this.options(this.data)\n output.threshold(config.threshold()) if config.threshold()\n pagespeed.run(params, output.process, done)", "source_lang": "", "target_lang": "CoffeeScript", "repo": "jrcryer/grunt-pagespeed", "path": "tasks/pagespeed.coffee", "license": "MIT", "commit": "8717917f807bdee6719ddc55c69a0e580b9cb6d6", "stars": 459, "source_url": "https://github.com/jrcryer/grunt-pagespeed/blob/8717917f807bdee6719ddc55c69a0e580b9cb6d6/tasks/pagespeed.coffee", "line_start": 1, "line_end": 24}530{"id": "jrcryer/grunt-pagespeed:tasks/pagespeed.coffee:1:coffee_to_js", "type": "coffee_to_js", "prompt": "Convert this CoffeeScript to JavaScript.\n```coffeescript\n#\n# grunt-pagespeed\n# http://www.jamescryer.com/grunt-pagespeed\n#\n# Copyright (c) 2013 James Cryer\n# http://www.jamescryer.com\n# Licensed under the MIT license.\n#\n'use strict'\n\nmodule.exports = (grunt) ->\n\n config = require('./lib/config').init grunt\n pagespeed = require('./lib/pagespeed').init grunt\n output = require('./lib/output').init grunt\n\n grunt.registerMultiTask 'pagespeed', 'Run Pagespeed Insights', ->\n\n grunt.verbose.writeln 'Running Pagespeed Insights'\n done = this.async()\n\n params = config.params this.options(this.data)\n output.threshold(config.threshold()) if config.threshold()\n pagespeed.run(params, output.process, done)\n```", "response": "// grunt-pagespeed\n// http://www.jamescryer.com/grunt-pagespeed\n\n// Copyright (c) 2013 James Cryer\n// http://www.jamescryer.com\n// Licensed under the MIT license.\n\n'use strict';\nmodule.exports = function(grunt) {\n var config, output, pagespeed;\n config = require('./lib/config').init(grunt);\n pagespeed = require('./lib/pagespeed').init(grunt);\n output = require('./lib/output').init(grunt);\n return grunt.registerMultiTask('pagespeed', 'Run Pagespeed Insights', function() {\n var done, params;\n grunt.verbose.writeln('Running Pagespeed Insights');\n done = this.async();\n params = config.params(this.options(this.data));\n if (config.threshold()) {\n output.threshold(config.threshold());\n }\n return pagespeed.run(params, output.process, done);\n });\n};", "source_lang": "CoffeeScript", "target_lang": "JavaScript", "repo": "jrcryer/grunt-pagespeed", "path": "tasks/pagespeed.coffee", "license": "MIT", "commit": "8717917f807bdee6719ddc55c69a0e580b9cb6d6", "stars": 459, "source_url": "https://github.com/jrcryer/grunt-pagespeed/blob/8717917f807bdee6719ddc55c69a0e580b9cb6d6/tasks/pagespeed.coffee", "line_start": 1, "line_end": 24}531{"id": "jrcryer/grunt-pagespeed:tasks/pagespeed.coffee:1:js_to_coffee", "type": "js_to_coffee", "prompt": "Convert this JavaScript to CoffeeScript.\n```javascript\n// grunt-pagespeed\n// http://www.jamescryer.com/grunt-pagespeed\n\n// Copyright (c) 2013 James Cryer\n// http://www.jamescryer.com\n// Licensed under the MIT license.\n\n'use strict';\nmodule.exports = function(grunt) {\n var config, output, pagespeed;\n config = require('./lib/config').init(grunt);\n pagespeed = require('./lib/pagespeed').init(grunt);\n output = require('./lib/output').init(grunt);\n return grunt.registerMultiTask('pagespeed', 'Run Pagespeed Insights', function() {\n var done, params;\n grunt.verbose.writeln('Running Pagespeed Insights');\n done = this.async();\n params = config.params(this.options(this.data));\n if (config.threshold()) {\n output.threshold(config.threshold());\n }\n return pagespeed.run(params, output.process, done);\n });\n};\n```", "response": "#\n# grunt-pagespeed\n# http://www.jamescryer.com/grunt-pagespeed\n#\n# Copyright (c) 2013 James Cryer\n# http://www.jamescryer.com\n# Licensed under the MIT license.\n#\n'use strict'\n\nmodule.exports = (grunt) ->\n\n config = require('./lib/config').init grunt\n pagespeed = require('./lib/pagespeed').init grunt\n output = require('./lib/output').init grunt\n\n grunt.registerMultiTask 'pagespeed', 'Run Pagespeed Insights', ->\n\n grunt.verbose.writeln 'Running Pagespeed Insights'\n done = this.async()\n\n params = config.params this.options(this.data)\n output.threshold(config.threshold()) if config.threshold()\n pagespeed.run(params, output.process, done)", "source_lang": "JavaScript", "target_lang": "CoffeeScript", "repo": "jrcryer/grunt-pagespeed", "path": "tasks/pagespeed.coffee", "license": "MIT", "commit": "8717917f807bdee6719ddc55c69a0e580b9cb6d6", "stars": 459, "source_url": "https://github.com/jrcryer/grunt-pagespeed/blob/8717917f807bdee6719ddc55c69a0e580b9cb6d6/tasks/pagespeed.coffee", "line_start": 1, "line_end": 24}532{"id": "jrcryer/grunt-pagespeed:tasks/pagespeed.coffee:1:completion", "type": "completion", "prompt": "#\n# grunt-pagespeed\n# http://www.jamescryer.com/grunt-pagespeed\n#\n# Copyright (c) 2013 James Cryer\n# http://www.jamescryer.com\n# Licensed under the MIT license.\n#\n'use strict'\n\nmodule.exports = (grunt) ->", "response": "config = require('./lib/config').init grunt\n pagespeed = require('./lib/pagespeed').init grunt\n output = require('./lib/output').init grunt\n\n grunt.registerMultiTask 'pagespeed', 'Run Pagespeed Insights', ->\n\n grunt.verbose.writeln 'Running Pagespeed Insights'\n done = this.async()\n\n params = config.params this.options(this.data)\n output.threshold(config.threshold()) if config.threshold()\n pagespeed.run(params, output.process, done)", "source_lang": "CoffeeScript", "target_lang": "CoffeeScript", "repo": "jrcryer/grunt-pagespeed", "path": "tasks/pagespeed.coffee", "license": "MIT", "commit": "8717917f807bdee6719ddc55c69a0e580b9cb6d6", "stars": 459, "source_url": "https://github.com/jrcryer/grunt-pagespeed/blob/8717917f807bdee6719ddc55c69a0e580b9cb6d6/tasks/pagespeed.coffee", "line_start": 1, "line_end": 24}533{"id": "jrcryer/grunt-pagespeed:tasks/pagespeed.coffee:1:raw_corpus", "type": "raw_corpus", "prompt": "", "response": "#\n# grunt-pagespeed\n# http://www.jamescryer.com/grunt-pagespeed\n#\n# Copyright (c) 2013 James Cryer\n# http://www.jamescryer.com\n# Licensed under the MIT license.\n#\n'use strict'\n\nmodule.exports = (grunt) ->\n\n config = require('./lib/config').init grunt\n pagespeed = require('./lib/pagespeed').init grunt\n output = require('./lib/output').init grunt\n\n grunt.registerMultiTask 'pagespeed', 'Run Pagespeed Insights', ->\n\n grunt.verbose.writeln 'Running Pagespeed Insights'\n this.async()\n\n params = config.params this.options(this.data)\n output.threshold(config.threshold()) if config.threshold()\n\n pagespeed.run(params, output.process)", "source_lang": "", "target_lang": "CoffeeScript", "repo": "jrcryer/grunt-pagespeed", "path": "tasks/pagespeed.coffee", "license": "MIT", "commit": "0fd25dcc4148f4e235fdaca820faf0e6a185faa8", "stars": 459, "source_url": "https://github.com/jrcryer/grunt-pagespeed/blob/0fd25dcc4148f4e235fdaca820faf0e6a185faa8/tasks/pagespeed.coffee", "line_start": 1, "line_end": 25}534{"id": "jrcryer/grunt-pagespeed:tasks/pagespeed.coffee:1:coffee_to_js", "type": "coffee_to_js", "prompt": "Convert this CoffeeScript to JavaScript.\n```coffeescript\n#\n# grunt-pagespeed\n# http://www.jamescryer.com/grunt-pagespeed\n#\n# Copyright (c) 2013 James Cryer\n# http://www.jamescryer.com\n# Licensed under the MIT license.\n#\n'use strict'\n\nmodule.exports = (grunt) ->\n\n config = require('./lib/config').init grunt\n pagespeed = require('./lib/pagespeed').init grunt\n output = require('./lib/output').init grunt\n\n grunt.registerMultiTask 'pagespeed', 'Run Pagespeed Insights', ->\n\n grunt.verbose.writeln 'Running Pagespeed Insights'\n this.async()\n\n params = config.params this.options(this.data)\n output.threshold(config.threshold()) if config.threshold()\n\n pagespeed.run(params, output.process)\n```", "response": "// grunt-pagespeed\n// http://www.jamescryer.com/grunt-pagespeed\n\n// Copyright (c) 2013 James Cryer\n// http://www.jamescryer.com\n// Licensed under the MIT license.\n\n'use strict';\nmodule.exports = function(grunt) {\n var config, output, pagespeed;\n config = require('./lib/config').init(grunt);\n pagespeed = require('./lib/pagespeed').init(grunt);\n output = require('./lib/output').init(grunt);\n return grunt.registerMultiTask('pagespeed', 'Run Pagespeed Insights', function() {\n var params;\n grunt.verbose.writeln('Running Pagespeed Insights');\n this.async();\n params = config.params(this.options(this.data));\n if (config.threshold()) {\n output.threshold(config.threshold());\n }\n return pagespeed.run(params, output.process);\n });\n};", "source_lang": "CoffeeScript", "target_lang": "JavaScript", "repo": "jrcryer/grunt-pagespeed", "path": "tasks/pagespeed.coffee", "license": "MIT", "commit": "0fd25dcc4148f4e235fdaca820faf0e6a185faa8", "stars": 459, "source_url": "https://github.com/jrcryer/grunt-pagespeed/blob/0fd25dcc4148f4e235fdaca820faf0e6a185faa8/tasks/pagespeed.coffee", "line_start": 1, "line_end": 25}535{"id": "jrcryer/grunt-pagespeed:tasks/pagespeed.coffee:1:js_to_coffee", "type": "js_to_coffee", "prompt": "Convert this JavaScript to CoffeeScript.\n```javascript\n// grunt-pagespeed\n// http://www.jamescryer.com/grunt-pagespeed\n\n// Copyright (c) 2013 James Cryer\n// http://www.jamescryer.com\n// Licensed under the MIT license.\n\n'use strict';\nmodule.exports = function(grunt) {\n var config, output, pagespeed;\n config = require('./lib/config').init(grunt);\n pagespeed = require('./lib/pagespeed').init(grunt);\n output = require('./lib/output').init(grunt);\n return grunt.registerMultiTask('pagespeed', 'Run Pagespeed Insights', function() {\n var params;\n grunt.verbose.writeln('Running Pagespeed Insights');\n this.async();\n params = config.params(this.options(this.data));\n if (config.threshold()) {\n output.threshold(config.threshold());\n }\n return pagespeed.run(params, output.process);\n });\n};\n```", "response": "#\n# grunt-pagespeed\n# http://www.jamescryer.com/grunt-pagespeed\n#\n# Copyright (c) 2013 James Cryer\n# http://www.jamescryer.com\n# Licensed under the MIT license.\n#\n'use strict'\n\nmodule.exports = (grunt) ->\n\n config = require('./lib/config').init grunt\n pagespeed = require('./lib/pagespeed').init grunt\n output = require('./lib/output').init grunt\n\n grunt.registerMultiTask 'pagespeed', 'Run Pagespeed Insights', ->\n\n grunt.verbose.writeln 'Running Pagespeed Insights'\n this.async()\n\n params = config.params this.options(this.data)\n output.threshold(config.threshold()) if config.threshold()\n\n pagespeed.run(params, output.process)", "source_lang": "JavaScript", "target_lang": "CoffeeScript", "repo": "jrcryer/grunt-pagespeed", "path": "tasks/pagespeed.coffee", "license": "MIT", "commit": "0fd25dcc4148f4e235fdaca820faf0e6a185faa8", "stars": 459, "source_url": "https://github.com/jrcryer/grunt-pagespeed/blob/0fd25dcc4148f4e235fdaca820faf0e6a185faa8/tasks/pagespeed.coffee", "line_start": 1, "line_end": 25}536{"id": "jrcryer/grunt-pagespeed:tasks/pagespeed.coffee:1:completion", "type": "completion", "prompt": "#\n# grunt-pagespeed\n# http://www.jamescryer.com/grunt-pagespeed\n#\n# Copyright (c) 2013 James Cryer\n# http://www.jamescryer.com\n# Licensed under the MIT license.\n#\n'use strict'\n\nmodule.exports = (grunt) ->", "response": "config = require('./lib/config').init grunt\n pagespeed = require('./lib/pagespeed').init grunt\n output = require('./lib/output').init grunt\n\n grunt.registerMultiTask 'pagespeed', 'Run Pagespeed Insights', ->\n\n grunt.verbose.writeln 'Running Pagespeed Insights'\n this.async()\n\n params = config.params this.options(this.data)\n output.threshold(config.threshold()) if config.threshold()\n\n pagespeed.run(params, output.process)", "source_lang": "CoffeeScript", "target_lang": "CoffeeScript", "repo": "jrcryer/grunt-pagespeed", "path": "tasks/pagespeed.coffee", "license": "MIT", "commit": "0fd25dcc4148f4e235fdaca820faf0e6a185faa8", "stars": 459, "source_url": "https://github.com/jrcryer/grunt-pagespeed/blob/0fd25dcc4148f4e235fdaca820faf0e6a185faa8/tasks/pagespeed.coffee", "line_start": 1, "line_end": 25}537{"id": "jrcryer/grunt-pagespeed:tasks/pagespeed.coffee:1:raw_corpus", "type": "raw_corpus", "prompt": "", "response": "#\n# grunt-pagespeed\n# http://www.jamescryer.com/grunt-pagespeed\n#\n# Copyright (c) 2013 James Cryer\n# http://www.jamescryer.com\n# Licensed under the MIT license.\n#\n'use strict'\n\nmodule.exports = (grunt) ->\n\n config = require('./lib/config').init grunt\n pagespeed = require('./lib/pagespeed').init grunt\n output = require('./lib/output').init grunt\n\n grunt.registerMultiTask 'pagespeed', 'Run Pagespeed Insights', ->\n\n grunt.verbose.writeln 'Running Pagespeed Insights'\n this.async()\n\n params = config.params this.options(this.data)\n pagespeed.run(params, output.process)", "source_lang": "", "target_lang": "CoffeeScript", "repo": "jrcryer/grunt-pagespeed", "path": "tasks/pagespeed.coffee", "license": "MIT", "commit": "5664361dc05def5a0710604858244e4a8ab62d70", "stars": 459, "source_url": "https://github.com/jrcryer/grunt-pagespeed/blob/5664361dc05def5a0710604858244e4a8ab62d70/tasks/pagespeed.coffee", "line_start": 1, "line_end": 23}538{"id": "jrcryer/grunt-pagespeed:tasks/pagespeed.coffee:1:coffee_to_js", "type": "coffee_to_js", "prompt": "Convert this CoffeeScript to JavaScript.\n```coffeescript\n#\n# grunt-pagespeed\n# http://www.jamescryer.com/grunt-pagespeed\n#\n# Copyright (c) 2013 James Cryer\n# http://www.jamescryer.com\n# Licensed under the MIT license.\n#\n'use strict'\n\nmodule.exports = (grunt) ->\n\n config = require('./lib/config').init grunt\n pagespeed = require('./lib/pagespeed').init grunt\n output = require('./lib/output').init grunt\n\n grunt.registerMultiTask 'pagespeed', 'Run Pagespeed Insights', ->\n\n grunt.verbose.writeln 'Running Pagespeed Insights'\n this.async()\n\n params = config.params this.options(this.data)\n pagespeed.run(params, output.process)\n```", "response": "// grunt-pagespeed\n// http://www.jamescryer.com/grunt-pagespeed\n\n// Copyright (c) 2013 James Cryer\n// http://www.jamescryer.com\n// Licensed under the MIT license.\n\n'use strict';\nmodule.exports = function(grunt) {\n var config, output, pagespeed;\n config = require('./lib/config').init(grunt);\n pagespeed = require('./lib/pagespeed').init(grunt);\n output = require('./lib/output').init(grunt);\n return grunt.registerMultiTask('pagespeed', 'Run Pagespeed Insights', function() {\n var params;\n grunt.verbose.writeln('Running Pagespeed Insights');\n this.async();\n params = config.params(this.options(this.data));\n return pagespeed.run(params, output.process);\n });\n};", "source_lang": "CoffeeScript", "target_lang": "JavaScript", "repo": "jrcryer/grunt-pagespeed", "path": "tasks/pagespeed.coffee", "license": "MIT", "commit": "5664361dc05def5a0710604858244e4a8ab62d70", "stars": 459, "source_url": "https://github.com/jrcryer/grunt-pagespeed/blob/5664361dc05def5a0710604858244e4a8ab62d70/tasks/pagespeed.coffee", "line_start": 1, "line_end": 23}539{"id": "jrcryer/grunt-pagespeed:tasks/pagespeed.coffee:1:js_to_coffee", "type": "js_to_coffee", "prompt": "Convert this JavaScript to CoffeeScript.\n```javascript\n// grunt-pagespeed\n// http://www.jamescryer.com/grunt-pagespeed\n\n// Copyright (c) 2013 James Cryer\n// http://www.jamescryer.com\n// Licensed under the MIT license.\n\n'use strict';\nmodule.exports = function(grunt) {\n var config, output, pagespeed;\n config = require('./lib/config').init(grunt);\n pagespeed = require('./lib/pagespeed').init(grunt);\n output = require('./lib/output').init(grunt);\n return grunt.registerMultiTask('pagespeed', 'Run Pagespeed Insights', function() {\n var params;\n grunt.verbose.writeln('Running Pagespeed Insights');\n this.async();\n params = config.params(this.options(this.data));\n return pagespeed.run(params, output.process);\n });\n};\n```", "response": "#\n# grunt-pagespeed\n# http://www.jamescryer.com/grunt-pagespeed\n#\n# Copyright (c) 2013 James Cryer\n# http://www.jamescryer.com\n# Licensed under the MIT license.\n#\n'use strict'\n\nmodule.exports = (grunt) ->\n\n config = require('./lib/config').init grunt\n pagespeed = require('./lib/pagespeed').init grunt\n output = require('./lib/output').init grunt\n\n grunt.registerMultiTask 'pagespeed', 'Run Pagespeed Insights', ->\n\n grunt.verbose.writeln 'Running Pagespeed Insights'\n this.async()\n\n params = config.params this.options(this.data)\n pagespeed.run(params, output.process)", "source_lang": "JavaScript", "target_lang": "CoffeeScript", "repo": "jrcryer/grunt-pagespeed", "path": "tasks/pagespeed.coffee", "license": "MIT", "commit": "5664361dc05def5a0710604858244e4a8ab62d70", "stars": 459, "source_url": "https://github.com/jrcryer/grunt-pagespeed/blob/5664361dc05def5a0710604858244e4a8ab62d70/tasks/pagespeed.coffee", "line_start": 1, "line_end": 23}540{"id": "jrcryer/grunt-pagespeed:tasks/pagespeed.coffee:1:completion", "type": "completion", "prompt": "#\n# grunt-pagespeed\n# http://www.jamescryer.com/grunt-pagespeed\n#\n# Copyright (c) 2013 James Cryer\n# http://www.jamescryer.com\n# Licensed under the MIT license.\n#\n'use strict'\n\nmodule.exports = (grunt) ->", "response": "config = require('./lib/config').init grunt\n pagespeed = require('./lib/pagespeed').init grunt\n output = require('./lib/output').init grunt\n\n grunt.registerMultiTask 'pagespeed', 'Run Pagespeed Insights', ->\n\n grunt.verbose.writeln 'Running Pagespeed Insights'\n this.async()\n\n params = config.params this.options(this.data)\n pagespeed.run(params, output.process)", "source_lang": "CoffeeScript", "target_lang": "CoffeeScript", "repo": "jrcryer/grunt-pagespeed", "path": "tasks/pagespeed.coffee", "license": "MIT", "commit": "5664361dc05def5a0710604858244e4a8ab62d70", "stars": 459, "source_url": "https://github.com/jrcryer/grunt-pagespeed/blob/5664361dc05def5a0710604858244e4a8ab62d70/tasks/pagespeed.coffee", "line_start": 1, "line_end": 23}541{"id": "jrcryer/grunt-pagespeed:tasks/pagespeed.coffee:1:raw_corpus", "type": "raw_corpus", "prompt": "", "response": "#\n# grunt-pagespeed\n# http://www.jamescryer.com/grunt-pagespeed\n#\n# Copyright (c) 2013 James Cryer\n# http://www.jamescryer.com\n# Licensed under the MIT license.\n#\n'use strict'\n\nmodule.exports = (grunt) ->\n\n config = require('./lib/config').init grunt\n pagespeed = require('./lib/pagespeed').init grunt\n output = require('./lib/output').init grunt\n\n grunt.registerMultiTask 'pagespeed', 'Run Pagespeed Insights', ->\n\n grunt.verbose.writeln 'Running Pagespeed Insights'\n this.async()\n\n pagespeed.run(config.params(this.options(this.data)), output.process)", "source_lang": "", "target_lang": "CoffeeScript", "repo": "jrcryer/grunt-pagespeed", "path": "tasks/pagespeed.coffee", "license": "MIT", "commit": "47d3fa0347b3babdbc341bac60370578add8d204", "stars": 459, "source_url": "https://github.com/jrcryer/grunt-pagespeed/blob/47d3fa0347b3babdbc341bac60370578add8d204/tasks/pagespeed.coffee", "line_start": 1, "line_end": 22}542{"id": "jrcryer/grunt-pagespeed:tasks/pagespeed.coffee:1:coffee_to_js", "type": "coffee_to_js", "prompt": "Convert this CoffeeScript to JavaScript.\n```coffeescript\n#\n# grunt-pagespeed\n# http://www.jamescryer.com/grunt-pagespeed\n#\n# Copyright (c) 2013 James Cryer\n# http://www.jamescryer.com\n# Licensed under the MIT license.\n#\n'use strict'\n\nmodule.exports = (grunt) ->\n\n config = require('./lib/config').init grunt\n pagespeed = require('./lib/pagespeed').init grunt\n output = require('./lib/output').init grunt\n\n grunt.registerMultiTask 'pagespeed', 'Run Pagespeed Insights', ->\n\n grunt.verbose.writeln 'Running Pagespeed Insights'\n this.async()\n\n pagespeed.run(config.params(this.options(this.data)), output.process)\n```", "response": "// grunt-pagespeed\n// http://www.jamescryer.com/grunt-pagespeed\n\n// Copyright (c) 2013 James Cryer\n// http://www.jamescryer.com\n// Licensed under the MIT license.\n\n'use strict';\nmodule.exports = function(grunt) {\n var config, output, pagespeed;\n config = require('./lib/config').init(grunt);\n pagespeed = require('./lib/pagespeed').init(grunt);\n output = require('./lib/output').init(grunt);\n return grunt.registerMultiTask('pagespeed', 'Run Pagespeed Insights', function() {\n grunt.verbose.writeln('Running Pagespeed Insights');\n this.async();\n return pagespeed.run(config.params(this.options(this.data)), output.process);\n });\n};", "source_lang": "CoffeeScript", "target_lang": "JavaScript", "repo": "jrcryer/grunt-pagespeed", "path": "tasks/pagespeed.coffee", "license": "MIT", "commit": "47d3fa0347b3babdbc341bac60370578add8d204", "stars": 459, "source_url": "https://github.com/jrcryer/grunt-pagespeed/blob/47d3fa0347b3babdbc341bac60370578add8d204/tasks/pagespeed.coffee", "line_start": 1, "line_end": 22}543{"id": "jrcryer/grunt-pagespeed:tasks/pagespeed.coffee:1:js_to_coffee", "type": "js_to_coffee", "prompt": "Convert this JavaScript to CoffeeScript.\n```javascript\n// grunt-pagespeed\n// http://www.jamescryer.com/grunt-pagespeed\n\n// Copyright (c) 2013 James Cryer\n// http://www.jamescryer.com\n// Licensed under the MIT license.\n\n'use strict';\nmodule.exports = function(grunt) {\n var config, output, pagespeed;\n config = require('./lib/config').init(grunt);\n pagespeed = require('./lib/pagespeed').init(grunt);\n output = require('./lib/output').init(grunt);\n return grunt.registerMultiTask('pagespeed', 'Run Pagespeed Insights', function() {\n grunt.verbose.writeln('Running Pagespeed Insights');\n this.async();\n return pagespeed.run(config.params(this.options(this.data)), output.process);\n });\n};\n```", "response": "#\n# grunt-pagespeed\n# http://www.jamescryer.com/grunt-pagespeed\n#\n# Copyright (c) 2013 James Cryer\n# http://www.jamescryer.com\n# Licensed under the MIT license.\n#\n'use strict'\n\nmodule.exports = (grunt) ->\n\n config = require('./lib/config').init grunt\n pagespeed = require('./lib/pagespeed').init grunt\n output = require('./lib/output').init grunt\n\n grunt.registerMultiTask 'pagespeed', 'Run Pagespeed Insights', ->\n\n grunt.verbose.writeln 'Running Pagespeed Insights'\n this.async()\n\n pagespeed.run(config.params(this.options(this.data)), output.process)", "source_lang": "JavaScript", "target_lang": "CoffeeScript", "repo": "jrcryer/grunt-pagespeed", "path": "tasks/pagespeed.coffee", "license": "MIT", "commit": "47d3fa0347b3babdbc341bac60370578add8d204", "stars": 459, "source_url": "https://github.com/jrcryer/grunt-pagespeed/blob/47d3fa0347b3babdbc341bac60370578add8d204/tasks/pagespeed.coffee", "line_start": 1, "line_end": 22}544{"id": "jrcryer/grunt-pagespeed:tasks/pagespeed.coffee:1:completion", "type": "completion", "prompt": "#\n# grunt-pagespeed\n# http://www.jamescryer.com/grunt-pagespeed\n#\n# Copyright (c) 2013 James Cryer\n# http://www.jamescryer.com\n# Licensed under the MIT license.\n#\n'use strict'\n\nmodule.exports = (grunt) ->", "response": "config = require('./lib/config').init grunt\n pagespeed = require('./lib/pagespeed').init grunt\n output = require('./lib/output').init grunt\n\n grunt.registerMultiTask 'pagespeed', 'Run Pagespeed Insights', ->\n\n grunt.verbose.writeln 'Running Pagespeed Insights'\n this.async()\n\n pagespeed.run(config.params(this.options(this.data)), output.process)", "source_lang": "CoffeeScript", "target_lang": "CoffeeScript", "repo": "jrcryer/grunt-pagespeed", "path": "tasks/pagespeed.coffee", "license": "MIT", "commit": "47d3fa0347b3babdbc341bac60370578add8d204", "stars": 459, "source_url": "https://github.com/jrcryer/grunt-pagespeed/blob/47d3fa0347b3babdbc341bac60370578add8d204/tasks/pagespeed.coffee", "line_start": 1, "line_end": 22}545{"id": "jianliaoim/talk-os:talk-web/client/util/notify.coffee:1:raw_corpus", "type": "raw_corpus", "prompt": "", "response": "if window.nwDispatcher?.requireNwGui\n nwGui = window.nwDispatcher.requireNwGui()\n nwWin = nwGui.Window.get()\n\n\nformat = require './format'\ntime = require './time'\ntypeUtil = require './type'\n\nif typeof window isnt 'undefined'\n Favico = require 'favico.js'\n favicon = new Favico\n animation: 'none'\n\nexports.desktop = (data, cb) ->\n data.body = data.body.replace /[\\n\\r]+/g, ' '\n if window.MacGap?\n window.MacGap.notify\n title: data.title\n content: data.body or ''\n else if window.macgap?\n window.macgap.growl.notify\n title: data.title\n content: data.body or ''\n else if window.Notification?\n message = new window.Notification data.title, data\n message.onclick = -> cb?()\n time.delay 3000, ->\n message.close()\n\nexports.favicon = (number) ->\n return if typeof window is 'undefined'\n number = Number(number) unless typeUtil.isNumber(number)\n number = format.escape100 number\n if number is @oldNumber\n return\n @oldNumber = number\n\n if window.MacGap?\n window.MacGap.Dock.addBadge number\n else if window.macgap?\n window.macgap.dock.badge = number\n else if nwWin\n nwWin.setBadgeLabel number\n else if window.badge? # private API targeting Electron\n window.badge number\n else\n favicon.badge number", "source_lang": "", "target_lang": "CoffeeScript", "repo": "jianliaoim/talk-os", "path": "talk-web/client/util/notify.coffee", "license": "MIT", "commit": "2545c4497865779a55762e03963a39237df9046b", "stars": 2703, "source_url": "https://github.com/jianliaoim/talk-os/blob/2545c4497865779a55762e03963a39237df9046b/talk-web/client/util/notify.coffee", "line_start": 1, "line_end": 48}546{"id": "jianliaoim/talk-os:talk-web/client/util/notify.coffee:1:coffee_to_js", "type": "coffee_to_js", "prompt": "Convert this CoffeeScript to JavaScript.\n```coffeescript\nif window.nwDispatcher?.requireNwGui\n nwGui = window.nwDispatcher.requireNwGui()\n nwWin = nwGui.Window.get()\n\n\nformat = require './format'\ntime = require './time'\ntypeUtil = require './type'\n\nif typeof window isnt 'undefined'\n Favico = require 'favico.js'\n favicon = new Favico\n animation: 'none'\n\nexports.desktop = (data, cb) ->\n data.body = data.body.replace /[\\n\\r]+/g, ' '\n if window.MacGap?\n window.MacGap.notify\n title: data.title\n content: data.body or ''\n else if window.macgap?\n window.macgap.growl.notify\n title: data.title\n content: data.body or ''\n else if window.Notification?\n message = new window.Notification data.title, data\n message.onclick = -> cb?()\n time.delay 3000, ->\n message.close()\n\nexports.favicon = (number) ->\n return if typeof window is 'undefined'\n number = Number(number) unless typeUtil.isNumber(number)\n number = format.escape100 number\n if number is @oldNumber\n return\n @oldNumber = number\n\n if window.MacGap?\n window.MacGap.Dock.addBadge number\n else if window.macgap?\n window.macgap.dock.badge = number\n else if nwWin\n nwWin.setBadgeLabel number\n else if window.badge? # private API targeting Electron\n window.badge number\n else\n favicon.badge number\n```", "response": "var Favico, favicon, format, nwGui, nwWin, ref, time, typeUtil;\n\nif ((ref = window.nwDispatcher) != null ? ref.requireNwGui : void 0) {\n nwGui = window.nwDispatcher.requireNwGui();\n nwWin = nwGui.Window.get();\n}\n\nformat = require('./format');\n\ntime = require('./time');\n\ntypeUtil = require('./type');\n\nif (typeof window !== 'undefined') {\n Favico = require('favico.js');\n favicon = new Favico({\n animation: 'none'\n });\n}\n\nexports.desktop = function(data, cb) {\n var message;\n data.body = data.body.replace(/[\\n\\r]+/g, ' ');\n if (window.MacGap != null) {\n return window.MacGap.notify({\n title: data.title,\n content: data.body || ''\n });\n } else if (window.macgap != null) {\n return window.macgap.growl.notify({\n title: data.title,\n content: data.body || ''\n });\n } else if (window.Notification != null) {\n message = new window.Notification(data.title, data);\n message.onclick = function() {\n return typeof cb === \"function\" ? cb() : void 0;\n };\n return time.delay(3000, function() {\n return message.close();\n });\n }\n};\n\nexports.favicon = function(number) {\n if (typeof window === 'undefined') {\n return;\n }\n if (!typeUtil.isNumber(number)) {\n number = Number(number);\n }\n number = format.escape100(number);\n if (number === this.oldNumber) {\n return;\n }\n this.oldNumber = number;\n if (window.MacGap != null) {\n return window.MacGap.Dock.addBadge(number);\n } else if (window.macgap != null) {\n return window.macgap.dock.badge = number;\n } else if (nwWin) {\n return nwWin.setBadgeLabel(number);\n } else if (window.badge != null) {\n return window.badge(number);\n } else {\n return favicon.badge(number); // private API targeting Electron\n }\n};", "source_lang": "CoffeeScript", "target_lang": "JavaScript", "repo": "jianliaoim/talk-os", "path": "talk-web/client/util/notify.coffee", "license": "MIT", "commit": "2545c4497865779a55762e03963a39237df9046b", "stars": 2703, "source_url": "https://github.com/jianliaoim/talk-os/blob/2545c4497865779a55762e03963a39237df9046b/talk-web/client/util/notify.coffee", "line_start": 1, "line_end": 48}547{"id": "jianliaoim/talk-os:talk-web/client/util/notify.coffee:1:js_to_coffee", "type": "js_to_coffee", "prompt": "Convert this JavaScript to CoffeeScript.\n```javascript\nvar Favico, favicon, format, nwGui, nwWin, ref, time, typeUtil;\n\nif ((ref = window.nwDispatcher) != null ? ref.requireNwGui : void 0) {\n nwGui = window.nwDispatcher.requireNwGui();\n nwWin = nwGui.Window.get();\n}\n\nformat = require('./format');\n\ntime = require('./time');\n\ntypeUtil = require('./type');\n\nif (typeof window !== 'undefined') {\n Favico = require('favico.js');\n favicon = new Favico({\n animation: 'none'\n });\n}\n\nexports.desktop = function(data, cb) {\n var message;\n data.body = data.body.replace(/[\\n\\r]+/g, ' ');\n if (window.MacGap != null) {\n return window.MacGap.notify({\n title: data.title,\n content: data.body || ''\n });\n } else if (window.macgap != null) {\n return window.macgap.growl.notify({\n title: data.title,\n content: data.body || ''\n });\n } else if (window.Notification != null) {\n message = new window.Notification(data.title, data);\n message.onclick = function() {\n return typeof cb === \"function\" ? cb() : void 0;\n };\n return time.delay(3000, function() {\n return message.close();\n });\n }\n};\n\nexports.favicon = function(number) {\n if (typeof window === 'undefined') {\n return;\n }\n if (!typeUtil.isNumber(number)) {\n number = Number(number);\n }\n number = format.escape100(number);\n if (number === this.oldNumber) {\n return;\n }\n this.oldNumber = number;\n if (window.MacGap != null) {\n return window.MacGap.Dock.addBadge(number);\n } else if (window.macgap != null) {\n return window.macgap.dock.badge = number;\n } else if (nwWin) {\n return nwWin.setBadgeLabel(number);\n } else if (window.badge != null) {\n return window.badge(number);\n } else {\n return favicon.badge(number); // private API targeting Electron\n }\n};\n```", "response": "if window.nwDispatcher?.requireNwGui\n nwGui = window.nwDispatcher.requireNwGui()\n nwWin = nwGui.Window.get()\n\n\nformat = require './format'\ntime = require './time'\ntypeUtil = require './type'\n\nif typeof window isnt 'undefined'\n Favico = require 'favico.js'\n favicon = new Favico\n animation: 'none'\n\nexports.desktop = (data, cb) ->\n data.body = data.body.replace /[\\n\\r]+/g, ' '\n if window.MacGap?\n window.MacGap.notify\n title: data.title\n content: data.body or ''\n else if window.macgap?\n window.macgap.growl.notify\n title: data.title\n content: data.body or ''\n else if window.Notification?\n message = new window.Notification data.title, data\n message.onclick = -> cb?()\n time.delay 3000, ->\n message.close()\n\nexports.favicon = (number) ->\n return if typeof window is 'undefined'\n number = Number(number) unless typeUtil.isNumber(number)\n number = format.escape100 number\n if number is @oldNumber\n return\n @oldNumber = number\n\n if window.MacGap?\n window.MacGap.Dock.addBadge number\n else if window.macgap?\n window.macgap.dock.badge = number\n else if nwWin\n nwWin.setBadgeLabel number\n else if window.badge? # private API targeting Electron\n window.badge number\n else\n favicon.badge number", "source_lang": "JavaScript", "target_lang": "CoffeeScript", "repo": "jianliaoim/talk-os", "path": "talk-web/client/util/notify.coffee", "license": "MIT", "commit": "2545c4497865779a55762e03963a39237df9046b", "stars": 2703, "source_url": "https://github.com/jianliaoim/talk-os/blob/2545c4497865779a55762e03963a39237df9046b/talk-web/client/util/notify.coffee", "line_start": 1, "line_end": 48}548{"id": "jianliaoim/talk-os:talk-web/client/util/notify.coffee:1:completion", "type": "completion", "prompt": "if window.nwDispatcher?.requireNwGui\n nwGui = window.nwDispatcher.requireNwGui()\n nwWin = nwGui.Window.get()\n\n\nformat = require './format'\ntime = require './time'\ntypeUtil = require './type'\n\nif typeof window isnt 'undefined'\n Favico = require 'favico.js'\n favicon = new Favico\n animation: 'none'\n\nexports.desktop = (data, cb) ->\n data.body = data.body.replace /[\\n\\r]+/g, ' '\n if window.MacGap?\n window.MacGap.notify\n title: data.title\n content: data.body or ''\n else if window.macgap?\n window.macgap.growl.notify\n title: data.title\n content: data.body or ''", "response": "else if window.Notification?\n message = new window.Notification data.title, data\n message.onclick = -> cb?()\n time.delay 3000, ->\n message.close()\n\nexports.favicon = (number) ->\n return if typeof window is 'undefined'\n number = Number(number) unless typeUtil.isNumber(number)\n number = format.escape100 number\n if number is @oldNumber\n return\n @oldNumber = number\n\n if window.MacGap?\n window.MacGap.Dock.addBadge number\n else if window.macgap?\n window.macgap.dock.badge = number\n else if nwWin\n nwWin.setBadgeLabel number\n else if window.badge? # private API targeting Electron\n window.badge number\n else\n favicon.badge number", "source_lang": "CoffeeScript", "target_lang": "CoffeeScript", "repo": "jianliaoim/talk-os", "path": "talk-web/client/util/notify.coffee", "license": "MIT", "commit": "2545c4497865779a55762e03963a39237df9046b", "stars": 2703, "source_url": "https://github.com/jianliaoim/talk-os/blob/2545c4497865779a55762e03963a39237df9046b/talk-web/client/util/notify.coffee", "line_start": 1, "line_end": 48}549{"id": "CaryLandholt/AngularFun:scripts/controllers/people.coffee:1:raw_corpus", "type": "raw_corpus", "prompt": "", "response": "###global define###\n\ndefine ['controllers/controllers', 'services/people'], (controllers) ->\n\t'use strict'\n\n\tcontrollers.controller 'people', ['$scope', 'people', ($scope, service) ->\n\t\t$scope.error = ''\n\t\t$scope.name = ''\n\t\t$scope.people = service.people\n\n\t\t$scope.insertPerson = (name) ->\n\t\t\tservice.post name\n\t\t\t, (Resource, getResponseHeaders) ->\n\t\t\t\t$scope.error = ''\n\t\t\t\t$scope.name = ''\n\t\t\t, (obj) ->\n\t\t\t\t($scope.error = obj.data) if obj.status is 403\n\n\t\tservice.get()\n\t]", "source_lang": "", "target_lang": "CoffeeScript", "repo": "CaryLandholt/AngularFun", "path": "scripts/controllers/people.coffee", "license": "MIT", "commit": "a0fe3a453e28b488b6b711d2110bb1eeb574c8eb", "stars": 672, "source_url": "https://github.com/CaryLandholt/AngularFun/blob/a0fe3a453e28b488b6b711d2110bb1eeb574c8eb/scripts/controllers/people.coffee", "line_start": 1, "line_end": 20}550{"id": "CaryLandholt/AngularFun:scripts/controllers/people.coffee:1:coffee_to_js", "type": "coffee_to_js", "prompt": "Convert this CoffeeScript to JavaScript.\n```coffeescript\n###global define###\n\ndefine ['controllers/controllers', 'services/people'], (controllers) ->\n\t'use strict'\n\n\tcontrollers.controller 'people', ['$scope', 'people', ($scope, service) ->\n\t\t$scope.error = ''\n\t\t$scope.name = ''\n\t\t$scope.people = service.people\n\n\t\t$scope.insertPerson = (name) ->\n\t\t\tservice.post name\n\t\t\t, (Resource, getResponseHeaders) ->\n\t\t\t\t$scope.error = ''\n\t\t\t\t$scope.name = ''\n\t\t\t, (obj) ->\n\t\t\t\t($scope.error = obj.data) if obj.status is 403\n\n\t\tservice.get()\n\t]\n```", "response": "/*global define*/\ndefine(['controllers/controllers', 'services/people'], function(controllers) {\n 'use strict';\n return controllers.controller('people', [\n '$scope',\n 'people',\n function($scope,\n service) {\n $scope.error = '';\n $scope.name = '';\n $scope.people = service.people;\n $scope.insertPerson = function(name) {\n return service.post(name,\n function(Resource,\n getResponseHeaders) {\n $scope.error = '';\n return $scope.name = '';\n },\n function(obj) {\n if (obj.status === 403) {\n return $scope.error = obj.data;\n }\n });\n };\n return service.get();\n }\n ]);\n});", "source_lang": "CoffeeScript", "target_lang": "JavaScript", "repo": "CaryLandholt/AngularFun", "path": "scripts/controllers/people.coffee", "license": "MIT", "commit": "a0fe3a453e28b488b6b711d2110bb1eeb574c8eb", "stars": 672, "source_url": "https://github.com/CaryLandholt/AngularFun/blob/a0fe3a453e28b488b6b711d2110bb1eeb574c8eb/scripts/controllers/people.coffee", "line_start": 1, "line_end": 20}551{"id": "CaryLandholt/AngularFun:scripts/controllers/people.coffee:1:js_to_coffee", "type": "js_to_coffee", "prompt": "Convert this JavaScript to CoffeeScript.\n```javascript\n/*global define*/\ndefine(['controllers/controllers', 'services/people'], function(controllers) {\n 'use strict';\n return controllers.controller('people', [\n '$scope',\n 'people',\n function($scope,\n service) {\n $scope.error = '';\n $scope.name = '';\n $scope.people = service.people;\n $scope.insertPerson = function(name) {\n return service.post(name,\n function(Resource,\n getResponseHeaders) {\n $scope.error = '';\n return $scope.name = '';\n },\n function(obj) {\n if (obj.status === 403) {\n return $scope.error = obj.data;\n }\n });\n };\n return service.get();\n }\n ]);\n});\n```", "response": "###global define###\n\ndefine ['controllers/controllers', 'services/people'], (controllers) ->\n\t'use strict'\n\n\tcontrollers.controller 'people', ['$scope', 'people', ($scope, service) ->\n\t\t$scope.error = ''\n\t\t$scope.name = ''\n\t\t$scope.people = service.people\n\n\t\t$scope.insertPerson = (name) ->\n\t\t\tservice.post name\n\t\t\t, (Resource, getResponseHeaders) ->\n\t\t\t\t$scope.error = ''\n\t\t\t\t$scope.name = ''\n\t\t\t, (obj) ->\n\t\t\t\t($scope.error = obj.data) if obj.status is 403\n\n\t\tservice.get()\n\t]", "source_lang": "JavaScript", "target_lang": "CoffeeScript", "repo": "CaryLandholt/AngularFun", "path": "scripts/controllers/people.coffee", "license": "MIT", "commit": "a0fe3a453e28b488b6b711d2110bb1eeb574c8eb", "stars": 672, "source_url": "https://github.com/CaryLandholt/AngularFun/blob/a0fe3a453e28b488b6b711d2110bb1eeb574c8eb/scripts/controllers/people.coffee", "line_start": 1, "line_end": 20}552{"id": "CaryLandholt/AngularFun:scripts/controllers/people.coffee:1:completion", "type": "completion", "prompt": "###global define###\n\ndefine ['controllers/controllers', 'services/people'], (controllers) ->\n\t'use strict'\n\n\tcontrollers.controller 'people', ['$scope', 'people', ($scope, service) ->\n\t\t$scope.error = ''\n\t\t$scope.name = ''\n\t\t$scope.people = service.people", "response": "$scope.insertPerson = (name) ->\n\t\t\tservice.post name\n\t\t\t, (Resource, getResponseHeaders) ->\n\t\t\t\t$scope.error = ''\n\t\t\t\t$scope.name = ''\n\t\t\t, (obj) ->\n\t\t\t\t($scope.error = obj.data) if obj.status is 403\n\n\t\tservice.get()\n\t]", "source_lang": "CoffeeScript", "target_lang": "CoffeeScript", "repo": "CaryLandholt/AngularFun", "path": "scripts/controllers/people.coffee", "license": "MIT", "commit": "a0fe3a453e28b488b6b711d2110bb1eeb574c8eb", "stars": 672, "source_url": "https://github.com/CaryLandholt/AngularFun/blob/a0fe3a453e28b488b6b711d2110bb1eeb574c8eb/scripts/controllers/people.coffee", "line_start": 1, "line_end": 20}553{"id": "CaryLandholt/AngularFun:scripts/controllers/people.coffee:1:raw_corpus", "type": "raw_corpus", "prompt": "", "response": "###global define###\n\ndefine ['controllers/controllers', 'services/people'], (controllers) ->\n\t'use strict'\n\n\tcontrollers.controller 'people', ['$scope', 'people', ($scope, service) ->\n\t\t$scope.people = service.people\n\n\t\t$scope.insertPerson = ->\n\t\t\tservice.post()\n\n\t\tservice.get()\n\t]", "source_lang": "", "target_lang": "CoffeeScript", "repo": "CaryLandholt/AngularFun", "path": "scripts/controllers/people.coffee", "license": "MIT", "commit": "83e68a53d7c24f7d417b494e4fef7451cf0e3d9b", "stars": 672, "source_url": "https://github.com/CaryLandholt/AngularFun/blob/83e68a53d7c24f7d417b494e4fef7451cf0e3d9b/scripts/controllers/people.coffee", "line_start": 1, "line_end": 13}554{"id": "CaryLandholt/AngularFun:scripts/controllers/people.coffee:1:coffee_to_js", "type": "coffee_to_js", "prompt": "Convert this CoffeeScript to JavaScript.\n```coffeescript\n###global define###\n\ndefine ['controllers/controllers', 'services/people'], (controllers) ->\n\t'use strict'\n\n\tcontrollers.controller 'people', ['$scope', 'people', ($scope, service) ->\n\t\t$scope.people = service.people\n\n\t\t$scope.insertPerson = ->\n\t\t\tservice.post()\n\n\t\tservice.get()\n\t]\n```", "response": "/*global define*/\ndefine(['controllers/controllers', 'services/people'], function(controllers) {\n 'use strict';\n return controllers.controller('people', [\n '$scope',\n 'people',\n function($scope,\n service) {\n $scope.people = service.people;\n $scope.insertPerson = function() {\n return service.post();\n };\n return service.get();\n }\n ]);\n});", "source_lang": "CoffeeScript", "target_lang": "JavaScript", "repo": "CaryLandholt/AngularFun", "path": "scripts/controllers/people.coffee", "license": "MIT", "commit": "83e68a53d7c24f7d417b494e4fef7451cf0e3d9b", "stars": 672, "source_url": "https://github.com/CaryLandholt/AngularFun/blob/83e68a53d7c24f7d417b494e4fef7451cf0e3d9b/scripts/controllers/people.coffee", "line_start": 1, "line_end": 13}555{"id": "CaryLandholt/AngularFun:scripts/controllers/people.coffee:1:js_to_coffee", "type": "js_to_coffee", "prompt": "Convert this JavaScript to CoffeeScript.\n```javascript\n/*global define*/\ndefine(['controllers/controllers', 'services/people'], function(controllers) {\n 'use strict';\n return controllers.controller('people', [\n '$scope',\n 'people',\n function($scope,\n service) {\n $scope.people = service.people;\n $scope.insertPerson = function() {\n return service.post();\n };\n return service.get();\n }\n ]);\n});\n```", "response": "###global define###\n\ndefine ['controllers/controllers', 'services/people'], (controllers) ->\n\t'use strict'\n\n\tcontrollers.controller 'people', ['$scope', 'people', ($scope, service) ->\n\t\t$scope.people = service.people\n\n\t\t$scope.insertPerson = ->\n\t\t\tservice.post()\n\n\t\tservice.get()\n\t]", "source_lang": "JavaScript", "target_lang": "CoffeeScript", "repo": "CaryLandholt/AngularFun", "path": "scripts/controllers/people.coffee", "license": "MIT", "commit": "83e68a53d7c24f7d417b494e4fef7451cf0e3d9b", "stars": 672, "source_url": "https://github.com/CaryLandholt/AngularFun/blob/83e68a53d7c24f7d417b494e4fef7451cf0e3d9b/scripts/controllers/people.coffee", "line_start": 1, "line_end": 13}556{"id": "CaryLandholt/AngularFun:scripts/controllers/people.coffee:1:completion", "type": "completion", "prompt": "###global define###\n\ndefine ['controllers/controllers', 'services/people'], (controllers) ->\n\t'use strict'\n\n\tcontrollers.controller 'people', ['$scope', 'people', ($scope, service) ->", "response": "$scope.people = service.people\n\n\t\t$scope.insertPerson = ->\n\t\t\tservice.post()\n\n\t\tservice.get()\n\t]", "source_lang": "CoffeeScript", "target_lang": "CoffeeScript", "repo": "CaryLandholt/AngularFun", "path": "scripts/controllers/people.coffee", "license": "MIT", "commit": "83e68a53d7c24f7d417b494e4fef7451cf0e3d9b", "stars": 672, "source_url": "https://github.com/CaryLandholt/AngularFun/blob/83e68a53d7c24f7d417b494e4fef7451cf0e3d9b/scripts/controllers/people.coffee", "line_start": 1, "line_end": 13}557{"id": "CaryLandholt/AngularFun:scripts/controllers/people.coffee:1:raw_corpus", "type": "raw_corpus", "prompt": "", "response": "###global define###\n\ndefine ['controllers/controllers', 'services/people'], (controllers) ->\n\t'use strict'\n\n\tcontrollers.controller 'people', ['$scope', 'people', '$log', ($scope, service, $log) ->\n\t\t$scope.people = service.people\n\n\t\t$scope.insertPerson = ->\n\t\t\tservice.post()\n\n\t\tservice.get (Resource, getResponseHeaders) ->\n\t\t\treturn\n\t\t\t#$log.info 'people.get success', Resource, getResponseHeaders()\n\t\t, (obj) ->\n\t\t\treturn\n\t\t\t#$log.error 'people.get error', obj.config, obj.headers(), obj.status, obj.data\n\t]", "source_lang": "", "target_lang": "CoffeeScript", "repo": "CaryLandholt/AngularFun", "path": "scripts/controllers/people.coffee", "license": "MIT", "commit": "0ae299ec8a05ddbfb2e26f04898245b95f7ab37c", "stars": 672, "source_url": "https://github.com/CaryLandholt/AngularFun/blob/0ae299ec8a05ddbfb2e26f04898245b95f7ab37c/scripts/controllers/people.coffee", "line_start": 1, "line_end": 18}558{"id": "CaryLandholt/AngularFun:scripts/controllers/people.coffee:1:coffee_to_js", "type": "coffee_to_js", "prompt": "Convert this CoffeeScript to JavaScript.\n```coffeescript\n###global define###\n\ndefine ['controllers/controllers', 'services/people'], (controllers) ->\n\t'use strict'\n\n\tcontrollers.controller 'people', ['$scope', 'people', '$log', ($scope, service, $log) ->\n\t\t$scope.people = service.people\n\n\t\t$scope.insertPerson = ->\n\t\t\tservice.post()\n\n\t\tservice.get (Resource, getResponseHeaders) ->\n\t\t\treturn\n\t\t\t#$log.info 'people.get success', Resource, getResponseHeaders()\n\t\t, (obj) ->\n\t\t\treturn\n\t\t\t#$log.error 'people.get error', obj.config, obj.headers(), obj.status, obj.data\n\t]\n```", "response": "/*global define*/\ndefine(['controllers/controllers', 'services/people'], function(controllers) {\n 'use strict';\n return controllers.controller('people', [\n '$scope',\n 'people',\n '$log',\n function($scope,\n service,\n $log) {\n $scope.people = service.people;\n $scope.insertPerson = function() {\n return service.post();\n };\n return service.get(function(Resource,\n getResponseHeaders) {},\n //$log.info 'people.get success', Resource, getResponseHeaders()\n function(obj) {});\n }\n ]);\n});\n\n//$log.error 'people.get error', obj.config, obj.headers(), obj.status, obj.data", "source_lang": "CoffeeScript", "target_lang": "JavaScript", "repo": "CaryLandholt/AngularFun", "path": "scripts/controllers/people.coffee", "license": "MIT", "commit": "0ae299ec8a05ddbfb2e26f04898245b95f7ab37c", "stars": 672, "source_url": "https://github.com/CaryLandholt/AngularFun/blob/0ae299ec8a05ddbfb2e26f04898245b95f7ab37c/scripts/controllers/people.coffee", "line_start": 1, "line_end": 18}559{"id": "CaryLandholt/AngularFun:scripts/controllers/people.coffee:1:js_to_coffee", "type": "js_to_coffee", "prompt": "Convert this JavaScript to CoffeeScript.\n```javascript\n/*global define*/\ndefine(['controllers/controllers', 'services/people'], function(controllers) {\n 'use strict';\n return controllers.controller('people', [\n '$scope',\n 'people',\n '$log',\n function($scope,\n service,\n $log) {\n $scope.people = service.people;\n $scope.insertPerson = function() {\n return service.post();\n };\n return service.get(function(Resource,\n getResponseHeaders) {},\n //$log.info 'people.get success', Resource, getResponseHeaders()\n function(obj) {});\n }\n ]);\n});\n\n//$log.error 'people.get error', obj.config, obj.headers(), obj.status, obj.data\n```", "response": "###global define###\n\ndefine ['controllers/controllers', 'services/people'], (controllers) ->\n\t'use strict'\n\n\tcontrollers.controller 'people', ['$scope', 'people', '$log', ($scope, service, $log) ->\n\t\t$scope.people = service.people\n\n\t\t$scope.insertPerson = ->\n\t\t\tservice.post()\n\n\t\tservice.get (Resource, getResponseHeaders) ->\n\t\t\treturn\n\t\t\t#$log.info 'people.get success', Resource, getResponseHeaders()\n\t\t, (obj) ->\n\t\t\treturn\n\t\t\t#$log.error 'people.get error', obj.config, obj.headers(), obj.status, obj.data\n\t]", "source_lang": "JavaScript", "target_lang": "CoffeeScript", "repo": "CaryLandholt/AngularFun", "path": "scripts/controllers/people.coffee", "license": "MIT", "commit": "0ae299ec8a05ddbfb2e26f04898245b95f7ab37c", "stars": 672, "source_url": "https://github.com/CaryLandholt/AngularFun/blob/0ae299ec8a05ddbfb2e26f04898245b95f7ab37c/scripts/controllers/people.coffee", "line_start": 1, "line_end": 18}560{"id": "CaryLandholt/AngularFun:scripts/controllers/people.coffee:1:completion", "type": "completion", "prompt": "###global define###\n\ndefine ['controllers/controllers', 'services/people'], (controllers) ->\n\t'use strict'\n\n\tcontrollers.controller 'people', ['$scope', 'people', '$log', ($scope, service, $log) ->\n\t\t$scope.people = service.people\n\n\t\t$scope.insertPerson = ->", "response": "service.post()\n\n\t\tservice.get (Resource, getResponseHeaders) ->\n\t\t\treturn\n\t\t\t#$log.info 'people.get success', Resource, getResponseHeaders()\n\t\t, (obj) ->\n\t\t\treturn\n\t\t\t#$log.error 'people.get error', obj.config, obj.headers(), obj.status, obj.data\n\t]", "source_lang": "CoffeeScript", "target_lang": "CoffeeScript", "repo": "CaryLandholt/AngularFun", "path": "scripts/controllers/people.coffee", "license": "MIT", "commit": "0ae299ec8a05ddbfb2e26f04898245b95f7ab37c", "stars": 672, "source_url": "https://github.com/CaryLandholt/AngularFun/blob/0ae299ec8a05ddbfb2e26f04898245b95f7ab37c/scripts/controllers/people.coffee", "line_start": 1, "line_end": 18}561{"id": "Pagedraw/pagedraw:html-importer/chrome-plugin/popup.coffee:1:raw_corpus", "type": "raw_corpus", "prompt": "", "response": "getCurrentTabUrl = (callback) ->\n # Query filter to be passed to chrome.tabs.query - see\n # https://developer.chrome.com/extensions/tabs#method-query\n chrome.tabs.query {active: true, currentWindow: true}, (tabs) ->\n url = tabs[0].url\n console.assert(typeof url == 'string', 'tab.url should be a string')\n callback(url)\n\ndocument.addEventListener 'DOMContentLoaded', ->\n # make page DEFAULT_PAGE_WIDTH wide\n chrome.windows.update(chrome.windows.WINDOW_ID_CURRENT, {width: 970})\n\n # load scripts into page\n chrome.tabs.executeScript null, { file: \"vendor/jquery-2.1.4.js\" }, ->\n chrome.tabs.executeScript null, { file: \"vendor/underscore-min.js\" }, ->\n chrome.tabs.executeScript null, { file: \"reader.js\" }\n\n\n$('.output').text(\"loading...\")\n\nchrome.extension.onMessage.addListener (request, sender, response) ->\n $('#url').val(request.url)\n $('.output').text(JSON.stringify(request, null, 2))\n $.ajax {\n method: \"POST\",\n url: \"http://localhost:9000/pages\",\n data: JSON.stringify(request),\n contentType: \"application/json\"\n }", "source_lang": "", "target_lang": "CoffeeScript", "repo": "Pagedraw/pagedraw", "path": "html-importer/chrome-plugin/popup.coffee", "license": "MIT", "commit": "aba1bd1b8ef6bb7f58866a9d11ebb7f1e0e18a8e", "stars": 3558, "source_url": "https://github.com/Pagedraw/pagedraw/blob/aba1bd1b8ef6bb7f58866a9d11ebb7f1e0e18a8e/html-importer/chrome-plugin/popup.coffee", "line_start": 1, "line_end": 29}562{"id": "Pagedraw/pagedraw:html-importer/chrome-plugin/popup.coffee:1:coffee_to_js", "type": "coffee_to_js", "prompt": "Convert this CoffeeScript to JavaScript.\n```coffeescript\ngetCurrentTabUrl = (callback) ->\n # Query filter to be passed to chrome.tabs.query - see\n # https://developer.chrome.com/extensions/tabs#method-query\n chrome.tabs.query {active: true, currentWindow: true}, (tabs) ->\n url = tabs[0].url\n console.assert(typeof url == 'string', 'tab.url should be a string')\n callback(url)\n\ndocument.addEventListener 'DOMContentLoaded', ->\n # make page DEFAULT_PAGE_WIDTH wide\n chrome.windows.update(chrome.windows.WINDOW_ID_CURRENT, {width: 970})\n\n # load scripts into page\n chrome.tabs.executeScript null, { file: \"vendor/jquery-2.1.4.js\" }, ->\n chrome.tabs.executeScript null, { file: \"vendor/underscore-min.js\" }, ->\n chrome.tabs.executeScript null, { file: \"reader.js\" }\n\n\n$('.output').text(\"loading...\")\n\nchrome.extension.onMessage.addListener (request, sender, response) ->\n $('#url').val(request.url)\n $('.output').text(JSON.stringify(request, null, 2))\n $.ajax {\n method: \"POST\",\n url: \"http://localhost:9000/pages\",\n data: JSON.stringify(request),\n contentType: \"application/json\"\n }\n```", "response": "var getCurrentTabUrl;\n\ngetCurrentTabUrl = function(callback) {\n // Query filter to be passed to chrome.tabs.query - see\n // https://developer.chrome.com/extensions/tabs#method-query\n return chrome.tabs.query({\n active: true,\n currentWindow: true\n }, function(tabs) {\n var url;\n url = tabs[0].url;\n console.assert(typeof url === 'string', 'tab.url should be a string');\n return callback(url);\n });\n};\n\ndocument.addEventListener('DOMContentLoaded', function() {\n // make page DEFAULT_PAGE_WIDTH wide\n chrome.windows.update(chrome.windows.WINDOW_ID_CURRENT, {\n width: 970\n });\n // load scripts into page\n return chrome.tabs.executeScript(null, {\n file: \"vendor/jquery-2.1.4.js\"\n }, function() {\n return chrome.tabs.executeScript(null, {\n file: \"vendor/underscore-min.js\"\n }, function() {\n return chrome.tabs.executeScript(null, {\n file: \"reader.js\"\n });\n });\n });\n});\n\n$('.output').text(\"loading...\");\n\nchrome.extension.onMessage.addListener(function(request, sender, response) {\n $('#url').val(request.url);\n $('.output').text(JSON.stringify(request, null, 2));\n return $.ajax({\n method: \"POST\",\n url: \"http://localhost:9000/pages\",\n data: JSON.stringify(request),\n contentType: \"application/json\"\n });\n});", "source_lang": "CoffeeScript", "target_lang": "JavaScript", "repo": "Pagedraw/pagedraw", "path": "html-importer/chrome-plugin/popup.coffee", "license": "MIT", "commit": "aba1bd1b8ef6bb7f58866a9d11ebb7f1e0e18a8e", "stars": 3558, "source_url": "https://github.com/Pagedraw/pagedraw/blob/aba1bd1b8ef6bb7f58866a9d11ebb7f1e0e18a8e/html-importer/chrome-plugin/popup.coffee", "line_start": 1, "line_end": 29}563{"id": "Pagedraw/pagedraw:html-importer/chrome-plugin/popup.coffee:1:js_to_coffee", "type": "js_to_coffee", "prompt": "Convert this JavaScript to CoffeeScript.\n```javascript\nvar getCurrentTabUrl;\n\ngetCurrentTabUrl = function(callback) {\n // Query filter to be passed to chrome.tabs.query - see\n // https://developer.chrome.com/extensions/tabs#method-query\n return chrome.tabs.query({\n active: true,\n currentWindow: true\n }, function(tabs) {\n var url;\n url = tabs[0].url;\n console.assert(typeof url === 'string', 'tab.url should be a string');\n return callback(url);\n });\n};\n\ndocument.addEventListener('DOMContentLoaded', function() {\n // make page DEFAULT_PAGE_WIDTH wide\n chrome.windows.update(chrome.windows.WINDOW_ID_CURRENT, {\n width: 970\n });\n // load scripts into page\n return chrome.tabs.executeScript(null, {\n file: \"vendor/jquery-2.1.4.js\"\n }, function() {\n return chrome.tabs.executeScript(null, {\n file: \"vendor/underscore-min.js\"\n }, function() {\n return chrome.tabs.executeScript(null, {\n file: \"reader.js\"\n });\n });\n });\n});\n\n$('.output').text(\"loading...\");\n\nchrome.extension.onMessage.addListener(function(request, sender, response) {\n $('#url').val(request.url);\n $('.output').text(JSON.stringify(request, null, 2));\n return $.ajax({\n method: \"POST\",\n url: \"http://localhost:9000/pages\",\n data: JSON.stringify(request),\n contentType: \"application/json\"\n });\n});\n```", "response": "getCurrentTabUrl = (callback) ->\n # Query filter to be passed to chrome.tabs.query - see\n # https://developer.chrome.com/extensions/tabs#method-query\n chrome.tabs.query {active: true, currentWindow: true}, (tabs) ->\n url = tabs[0].url\n console.assert(typeof url == 'string', 'tab.url should be a string')\n callback(url)\n\ndocument.addEventListener 'DOMContentLoaded', ->\n # make page DEFAULT_PAGE_WIDTH wide\n chrome.windows.update(chrome.windows.WINDOW_ID_CURRENT, {width: 970})\n\n # load scripts into page\n chrome.tabs.executeScript null, { file: \"vendor/jquery-2.1.4.js\" }, ->\n chrome.tabs.executeScript null, { file: \"vendor/underscore-min.js\" }, ->\n chrome.tabs.executeScript null, { file: \"reader.js\" }\n\n\n$('.output').text(\"loading...\")\n\nchrome.extension.onMessage.addListener (request, sender, response) ->\n $('#url').val(request.url)\n $('.output').text(JSON.stringify(request, null, 2))\n $.ajax {\n method: \"POST\",\n url: \"http://localhost:9000/pages\",\n data: JSON.stringify(request),\n contentType: \"application/json\"\n }", "source_lang": "JavaScript", "target_lang": "CoffeeScript", "repo": "Pagedraw/pagedraw", "path": "html-importer/chrome-plugin/popup.coffee", "license": "MIT", "commit": "aba1bd1b8ef6bb7f58866a9d11ebb7f1e0e18a8e", "stars": 3558, "source_url": "https://github.com/Pagedraw/pagedraw/blob/aba1bd1b8ef6bb7f58866a9d11ebb7f1e0e18a8e/html-importer/chrome-plugin/popup.coffee", "line_start": 1, "line_end": 29}564{"id": "Pagedraw/pagedraw:html-importer/chrome-plugin/popup.coffee:1:completion", "type": "completion", "prompt": "getCurrentTabUrl = (callback) ->\n # Query filter to be passed to chrome.tabs.query - see\n # https://developer.chrome.com/extensions/tabs#method-query\n chrome.tabs.query {active: true, currentWindow: true}, (tabs) ->\n url = tabs[0].url\n console.assert(typeof url == 'string', 'tab.url should be a string')\n callback(url)\n\ndocument.addEventListener 'DOMContentLoaded', ->\n # make page DEFAULT_PAGE_WIDTH wide\n chrome.windows.update(chrome.windows.WINDOW_ID_CURRENT, {width: 970})\n\n # load scripts into page\n chrome.tabs.executeScript null, { file: \"vendor/jquery-2.1.4.js\" }, ->", "response": "chrome.tabs.executeScript null, { file: \"vendor/underscore-min.js\" }, ->\n chrome.tabs.executeScript null, { file: \"reader.js\" }\n\n\n$('.output').text(\"loading...\")\n\nchrome.extension.onMessage.addListener (request, sender, response) ->\n $('#url').val(request.url)\n $('.output').text(JSON.stringify(request, null, 2))\n $.ajax {\n method: \"POST\",\n url: \"http://localhost:9000/pages\",\n data: JSON.stringify(request),\n contentType: \"application/json\"\n }", "source_lang": "CoffeeScript", "target_lang": "CoffeeScript", "repo": "Pagedraw/pagedraw", "path": "html-importer/chrome-plugin/popup.coffee", "license": "MIT", "commit": "aba1bd1b8ef6bb7f58866a9d11ebb7f1e0e18a8e", "stars": 3558, "source_url": "https://github.com/Pagedraw/pagedraw/blob/aba1bd1b8ef6bb7f58866a9d11ebb7f1e0e18a8e/html-importer/chrome-plugin/popup.coffee", "line_start": 1, "line_end": 29}565{"id": "Glavin001/atom-beautify:src/beautifiers/jscs.coffee:1:raw_corpus", "type": "raw_corpus", "prompt": "", "response": "\"use strict\"\nBeautifier = require('./beautifier')\n\nChecker = null\ncliConfig = null\nchecker = null\n\nmodule.exports = class JSCSFixer extends Beautifier\n name: \"JSCS Fixer\"\n link: \"https://github.com/jscs-dev/node-jscs/\"\n\n options: {\n JavaScript: false\n }\n\n beautify: (text, language, options) ->\n @verbose(\"JSCS Fixer language #{language}\")\n return new @Promise((resolve, reject) =>\n try\n if !checker?\n cliConfig = require 'jscs/lib/cli-config'\n Checker = require 'jscs'\n checker = new Checker()\n checker.registerDefaultRules()\n editor = atom.workspace.getActiveTextEditor()\n path = if editor? then editor.getPath() else undefined\n config = if path? then cliConfig.load(undefined, atom.project.relativizePath(path)[0]) else undefined\n if !config?\n throw new Error(\"No JSCS config found.\")\n checker.configure(config)\n result = checker.fixString(text, path)\n if result.errors.getErrorCount() > 0\n @error(result.errors.getErrorList().reduce((res, err) ->\n \"#{res}<br> Line #{err.line}: #{err.message}\"\n , \"JSCS Fixer error:\"))\n\n resolve result.output\n\n catch err\n @error(\"JSCS Fixer error: #{err}\")\n reject(err)\n\n )", "source_lang": "", "target_lang": "CoffeeScript", "repo": "Glavin001/atom-beautify", "path": "src/beautifiers/jscs.coffee", "license": "MIT", "commit": "41d5051b399f7fe11efd149504a232df16179d60", "stars": 1503, "source_url": "https://github.com/Glavin001/atom-beautify/blob/41d5051b399f7fe11efd149504a232df16179d60/src/beautifiers/jscs.coffee", "line_start": 1, "line_end": 43}566{"id": "Glavin001/atom-beautify:src/beautifiers/jscs.coffee:1:coffee_to_js", "type": "coffee_to_js", "prompt": "Convert this CoffeeScript to JavaScript.\n```coffeescript\n\"use strict\"\nBeautifier = require('./beautifier')\n\nChecker = null\ncliConfig = null\nchecker = null\n\nmodule.exports = class JSCSFixer extends Beautifier\n name: \"JSCS Fixer\"\n link: \"https://github.com/jscs-dev/node-jscs/\"\n\n options: {\n JavaScript: false\n }\n\n beautify: (text, language, options) ->\n @verbose(\"JSCS Fixer language #{language}\")\n return new @Promise((resolve, reject) =>\n try\n if !checker?\n cliConfig = require 'jscs/lib/cli-config'\n Checker = require 'jscs'\n checker = new Checker()\n checker.registerDefaultRules()\n editor = atom.workspace.getActiveTextEditor()\n path = if editor? then editor.getPath() else undefined\n config = if path? then cliConfig.load(undefined, atom.project.relativizePath(path)[0]) else undefined\n if !config?\n throw new Error(\"No JSCS config found.\")\n checker.configure(config)\n result = checker.fixString(text, path)\n if result.errors.getErrorCount() > 0\n @error(result.errors.getErrorList().reduce((res, err) ->\n \"#{res}<br> Line #{err.line}: #{err.message}\"\n , \"JSCS Fixer error:\"))\n\n resolve result.output\n\n catch err\n @error(\"JSCS Fixer error: #{err}\")\n reject(err)\n\n )\n```", "response": "\"use strict\";\nvar Beautifier, Checker, JSCSFixer, checker, cliConfig;\n\nBeautifier = require('./beautifier');\n\nChecker = null;\n\ncliConfig = null;\n\nchecker = null;\n\nmodule.exports = JSCSFixer = (function() {\n class JSCSFixer extends Beautifier {\n beautify(text, language, options) {\n this.verbose(`JSCS Fixer language ${language}`);\n return new this.Promise((resolve, reject) => {\n var config, editor, err, path, result;\n try {\n if (checker == null) {\n cliConfig = require('jscs/lib/cli-config');\n Checker = require('jscs');\n checker = new Checker();\n checker.registerDefaultRules();\n }\n editor = atom.workspace.getActiveTextEditor();\n path = editor != null ? editor.getPath() : void 0;\n config = path != null ? cliConfig.load(void 0, atom.project.relativizePath(path)[0]) : void 0;\n if (config == null) {\n throw new Error(\"No JSCS config found.\");\n }\n checker.configure(config);\n result = checker.fixString(text, path);\n if (result.errors.getErrorCount() > 0) {\n this.error(result.errors.getErrorList().reduce(function(res, err) {\n return `${res}<br> Line ${err.line}: ${err.message}`;\n }, \"JSCS Fixer error:\"));\n }\n return resolve(result.output);\n } catch (error) {\n err = error;\n this.error(`JSCS Fixer error: ${err}`);\n return reject(err);\n }\n });\n }\n\n };\n\n JSCSFixer.prototype.name = \"JSCS Fixer\";\n\n JSCSFixer.prototype.link = \"https://github.com/jscs-dev/node-jscs/\";\n\n JSCSFixer.prototype.options = {\n JavaScript: false\n };\n\n return JSCSFixer;\n\n}).call(this);", "source_lang": "CoffeeScript", "target_lang": "JavaScript", "repo": "Glavin001/atom-beautify", "path": "src/beautifiers/jscs.coffee", "license": "MIT", "commit": "41d5051b399f7fe11efd149504a232df16179d60", "stars": 1503, "source_url": "https://github.com/Glavin001/atom-beautify/blob/41d5051b399f7fe11efd149504a232df16179d60/src/beautifiers/jscs.coffee", "line_start": 1, "line_end": 43}567{"id": "Glavin001/atom-beautify:src/beautifiers/jscs.coffee:1:js_to_coffee", "type": "js_to_coffee", "prompt": "Convert this JavaScript to CoffeeScript.\n```javascript\n\"use strict\";\nvar Beautifier, Checker, JSCSFixer, checker, cliConfig;\n\nBeautifier = require('./beautifier');\n\nChecker = null;\n\ncliConfig = null;\n\nchecker = null;\n\nmodule.exports = JSCSFixer = (function() {\n class JSCSFixer extends Beautifier {\n beautify(text, language, options) {\n this.verbose(`JSCS Fixer language ${language}`);\n return new this.Promise((resolve, reject) => {\n var config, editor, err, path, result;\n try {\n if (checker == null) {\n cliConfig = require('jscs/lib/cli-config');\n Checker = require('jscs');\n checker = new Checker();\n checker.registerDefaultRules();\n }\n editor = atom.workspace.getActiveTextEditor();\n path = editor != null ? editor.getPath() : void 0;\n config = path != null ? cliConfig.load(void 0, atom.project.relativizePath(path)[0]) : void 0;\n if (config == null) {\n throw new Error(\"No JSCS config found.\");\n }\n checker.configure(config);\n result = checker.fixString(text, path);\n if (result.errors.getErrorCount() > 0) {\n this.error(result.errors.getErrorList().reduce(function(res, err) {\n return `${res}<br> Line ${err.line}: ${err.message}`;\n }, \"JSCS Fixer error:\"));\n }\n return resolve(result.output);\n } catch (error) {\n err = error;\n this.error(`JSCS Fixer error: ${err}`);\n return reject(err);\n }\n });\n }\n\n };\n\n JSCSFixer.prototype.name = \"JSCS Fixer\";\n\n JSCSFixer.prototype.link = \"https://github.com/jscs-dev/node-jscs/\";\n\n JSCSFixer.prototype.options = {\n JavaScript: false\n };\n\n return JSCSFixer;\n\n}).call(this);\n```", "response": "\"use strict\"\nBeautifier = require('./beautifier')\n\nChecker = null\ncliConfig = null\nchecker = null\n\nmodule.exports = class JSCSFixer extends Beautifier\n name: \"JSCS Fixer\"\n link: \"https://github.com/jscs-dev/node-jscs/\"\n\n options: {\n JavaScript: false\n }\n\n beautify: (text, language, options) ->\n @verbose(\"JSCS Fixer language #{language}\")\n return new @Promise((resolve, reject) =>\n try\n if !checker?\n cliConfig = require 'jscs/lib/cli-config'\n Checker = require 'jscs'\n checker = new Checker()\n checker.registerDefaultRules()\n editor = atom.workspace.getActiveTextEditor()\n path = if editor? then editor.getPath() else undefined\n config = if path? then cliConfig.load(undefined, atom.project.relativizePath(path)[0]) else undefined\n if !config?\n throw new Error(\"No JSCS config found.\")\n checker.configure(config)\n result = checker.fixString(text, path)\n if result.errors.getErrorCount() > 0\n @error(result.errors.getErrorList().reduce((res, err) ->\n \"#{res}<br> Line #{err.line}: #{err.message}\"\n , \"JSCS Fixer error:\"))\n\n resolve result.output\n\n catch err\n @error(\"JSCS Fixer error: #{err}\")\n reject(err)\n\n )", "source_lang": "JavaScript", "target_lang": "CoffeeScript", "repo": "Glavin001/atom-beautify", "path": "src/beautifiers/jscs.coffee", "license": "MIT", "commit": "41d5051b399f7fe11efd149504a232df16179d60", "stars": 1503, "source_url": "https://github.com/Glavin001/atom-beautify/blob/41d5051b399f7fe11efd149504a232df16179d60/src/beautifiers/jscs.coffee", "line_start": 1, "line_end": 43}568{"id": "Glavin001/atom-beautify:src/beautifiers/jscs.coffee:1:completion", "type": "completion", "prompt": "\"use strict\"\nBeautifier = require('./beautifier')\n\nChecker = null\ncliConfig = null\nchecker = null\n\nmodule.exports = class JSCSFixer extends Beautifier\n name: \"JSCS Fixer\"\n link: \"https://github.com/jscs-dev/node-jscs/\"\n\n options: {\n JavaScript: false\n }\n\n beautify: (text, language, options) ->\n @verbose(\"JSCS Fixer language #{language}\")\n return new @Promise((resolve, reject) =>\n try\n if !checker?\n cliConfig = require 'jscs/lib/cli-config'", "response": "Checker = require 'jscs'\n checker = new Checker()\n checker.registerDefaultRules()\n editor = atom.workspace.getActiveTextEditor()\n path = if editor? then editor.getPath() else undefined\n config = if path? then cliConfig.load(undefined, atom.project.relativizePath(path)[0]) else undefined\n if !config?\n throw new Error(\"No JSCS config found.\")\n checker.configure(config)\n result = checker.fixString(text, path)\n if result.errors.getErrorCount() > 0\n @error(result.errors.getErrorList().reduce((res, err) ->\n \"#{res}<br> Line #{err.line}: #{err.message}\"\n , \"JSCS Fixer error:\"))\n\n resolve result.output\n\n catch err\n @error(\"JSCS Fixer error: #{err}\")\n reject(err)\n\n )", "source_lang": "CoffeeScript", "target_lang": "CoffeeScript", "repo": "Glavin001/atom-beautify", "path": "src/beautifiers/jscs.coffee", "license": "MIT", "commit": "41d5051b399f7fe11efd149504a232df16179d60", "stars": 1503, "source_url": "https://github.com/Glavin001/atom-beautify/blob/41d5051b399f7fe11efd149504a232df16179d60/src/beautifiers/jscs.coffee", "line_start": 1, "line_end": 43}569{"id": "Pathgather/please-wait:src/please-wait.coffee:1:raw_corpus", "type": "raw_corpus", "prompt": "", "response": "((root, factory) ->\n if typeof exports is \"object\"\n # CommonJS\n factory exports\n else if typeof define is \"function\" and define.amd\n # AMD. Register as an anonymous module.\n define [\"exports\"], factory\n else\n # Browser globals\n factory root\n return\n) this, (exports) ->\n getTransitionEvent = ->\n el = document.createElement('fakeelement')\n transitions =\n 'WebkitAnimation': 'webkitAnimationEnd',\n 'OAnimation': 'oAnimationEnd',\n 'msAnimation': 'MSAnimationEnd',\n 'MozAnimation': 'mozAnimationEnd'\n 'animation' : 'animationend'\n\n for key, val of transitions\n return val if el.style[key]?\n\n transitionEvent = getTransitionEvent()\n\n class PleaseWait\n @_defaultOptions:\n backgroundColor: null\n logo: null\n loadingHtml: null\n template: \"\"\"\n <div class='pg-loading-inner'>\n <div class='pg-loading-center-outer'>\n <div class='pg-loading-center-middle'>\n <h1 class='pg-loading-logo-header'>\n <img class='pg-loading-logo'></img>\n </h1>\n <div class='pg-loading-html'>\n </div>\n </div>\n </div>\n </div>\n \"\"\"", "source_lang": "", "target_lang": "CoffeeScript", "repo": "Pathgather/please-wait", "path": "src/please-wait.coffee", "license": "MIT", "commit": "d99216f87ac8fbfecaa335fa8bd9bd1a5581f67c", "stars": 1583, "source_url": "https://github.com/Pathgather/please-wait/blob/d99216f87ac8fbfecaa335fa8bd9bd1a5581f67c/src/please-wait.coffee", "line_start": 1, "line_end": 44}570{"id": "Pathgather/please-wait:src/please-wait.coffee:1:coffee_to_js", "type": "coffee_to_js", "prompt": "Convert this CoffeeScript to JavaScript.\n```coffeescript\n((root, factory) ->\n if typeof exports is \"object\"\n # CommonJS\n factory exports\n else if typeof define is \"function\" and define.amd\n # AMD. Register as an anonymous module.\n define [\"exports\"], factory\n else\n # Browser globals\n factory root\n return\n) this, (exports) ->\n getTransitionEvent = ->\n el = document.createElement('fakeelement')\n transitions =\n 'WebkitAnimation': 'webkitAnimationEnd',\n 'OAnimation': 'oAnimationEnd',\n 'msAnimation': 'MSAnimationEnd',\n 'MozAnimation': 'mozAnimationEnd'\n 'animation' : 'animationend'\n\n for key, val of transitions\n return val if el.style[key]?\n\n transitionEvent = getTransitionEvent()\n\n class PleaseWait\n @_defaultOptions:\n backgroundColor: null\n logo: null\n loadingHtml: null\n template: \"\"\"\n <div class='pg-loading-inner'>\n <div class='pg-loading-center-outer'>\n <div class='pg-loading-center-middle'>\n <h1 class='pg-loading-logo-header'>\n <img class='pg-loading-logo'></img>\n </h1>\n <div class='pg-loading-html'>\n </div>\n </div>\n </div>\n </div>\n \"\"\"\n```", "response": "(function(root, factory) {\n if (typeof exports === \"object\") {\n // CommonJS\n factory(exports);\n } else if (typeof define === \"function\" && define.amd) {\n // AMD. Register as an anonymous module.\n define([\"exports\"], factory);\n } else {\n // Browser globals\n factory(root);\n }\n})(this, function(exports) {\n var PleaseWait, getTransitionEvent, transitionEvent;\n getTransitionEvent = function() {\n var el, key, transitions, val;\n el = document.createElement('fakeelement');\n transitions = {\n 'WebkitAnimation': 'webkitAnimationEnd',\n 'OAnimation': 'oAnimationEnd',\n 'msAnimation': 'MSAnimationEnd',\n 'MozAnimation': 'mozAnimationEnd',\n 'animation': 'animationend'\n };\n for (key in transitions) {\n val = transitions[key];\n if (el.style[key] != null) {\n return val;\n }\n }\n };\n transitionEvent = getTransitionEvent();\n return PleaseWait = (function() {\n class PleaseWait {};\n\n PleaseWait._defaultOptions = {\n backgroundColor: null,\n logo: null,\n loadingHtml: null,\n template: `<div class='pg-loading-inner'>\n <div class='pg-loading-center-outer'>\n <div class='pg-loading-center-middle'>\n <h1 class='pg-loading-logo-header'>\n <img class='pg-loading-logo'></img>\n </h1>\n <div class='pg-loading-html'>\n </div>\n </div>\n </div>\n</div>`\n };\n\n return PleaseWait;\n\n }).call(this);\n});", "source_lang": "CoffeeScript", "target_lang": "JavaScript", "repo": "Pathgather/please-wait", "path": "src/please-wait.coffee", "license": "MIT", "commit": "d99216f87ac8fbfecaa335fa8bd9bd1a5581f67c", "stars": 1583, "source_url": "https://github.com/Pathgather/please-wait/blob/d99216f87ac8fbfecaa335fa8bd9bd1a5581f67c/src/please-wait.coffee", "line_start": 1, "line_end": 44}571{"id": "Pathgather/please-wait:src/please-wait.coffee:1:js_to_coffee", "type": "js_to_coffee", "prompt": "Convert this JavaScript to CoffeeScript.\n```javascript\n(function(root, factory) {\n if (typeof exports === \"object\") {\n // CommonJS\n factory(exports);\n } else if (typeof define === \"function\" && define.amd) {\n // AMD. Register as an anonymous module.\n define([\"exports\"], factory);\n } else {\n // Browser globals\n factory(root);\n }\n})(this, function(exports) {\n var PleaseWait, getTransitionEvent, transitionEvent;\n getTransitionEvent = function() {\n var el, key, transitions, val;\n el = document.createElement('fakeelement');\n transitions = {\n 'WebkitAnimation': 'webkitAnimationEnd',\n 'OAnimation': 'oAnimationEnd',\n 'msAnimation': 'MSAnimationEnd',\n 'MozAnimation': 'mozAnimationEnd',\n 'animation': 'animationend'\n };\n for (key in transitions) {\n val = transitions[key];\n if (el.style[key] != null) {\n return val;\n }\n }\n };\n transitionEvent = getTransitionEvent();\n return PleaseWait = (function() {\n class PleaseWait {};\n\n PleaseWait._defaultOptions = {\n backgroundColor: null,\n logo: null,\n loadingHtml: null,\n template: `<div class='pg-loading-inner'>\n <div class='pg-loading-center-outer'>\n <div class='pg-loading-center-middle'>\n <h1 class='pg-loading-logo-header'>\n <img class='pg-loading-logo'></img>\n </h1>\n <div class='pg-loading-html'>\n </div>\n </div>\n </div>\n</div>`\n };\n\n return PleaseWait;\n\n }).call(this);\n});\n```", "response": "((root, factory) ->\n if typeof exports is \"object\"\n # CommonJS\n factory exports\n else if typeof define is \"function\" and define.amd\n # AMD. Register as an anonymous module.\n define [\"exports\"], factory\n else\n # Browser globals\n factory root\n return\n) this, (exports) ->\n getTransitionEvent = ->\n el = document.createElement('fakeelement')\n transitions =\n 'WebkitAnimation': 'webkitAnimationEnd',\n 'OAnimation': 'oAnimationEnd',\n 'msAnimation': 'MSAnimationEnd',\n 'MozAnimation': 'mozAnimationEnd'\n 'animation' : 'animationend'\n\n for key, val of transitions\n return val if el.style[key]?\n\n transitionEvent = getTransitionEvent()\n\n class PleaseWait\n @_defaultOptions:\n backgroundColor: null\n logo: null\n loadingHtml: null\n template: \"\"\"\n <div class='pg-loading-inner'>\n <div class='pg-loading-center-outer'>\n <div class='pg-loading-center-middle'>\n <h1 class='pg-loading-logo-header'>\n <img class='pg-loading-logo'></img>\n </h1>\n <div class='pg-loading-html'>\n </div>\n </div>\n </div>\n </div>\n \"\"\"", "source_lang": "JavaScript", "target_lang": "CoffeeScript", "repo": "Pathgather/please-wait", "path": "src/please-wait.coffee", "license": "MIT", "commit": "d99216f87ac8fbfecaa335fa8bd9bd1a5581f67c", "stars": 1583, "source_url": "https://github.com/Pathgather/please-wait/blob/d99216f87ac8fbfecaa335fa8bd9bd1a5581f67c/src/please-wait.coffee", "line_start": 1, "line_end": 44}572{"id": "Pathgather/please-wait:src/please-wait.coffee:1:completion", "type": "completion", "prompt": "((root, factory) ->\n if typeof exports is \"object\"\n # CommonJS\n factory exports\n else if typeof define is \"function\" and define.amd\n # AMD. Register as an anonymous module.\n define [\"exports\"], factory\n else\n # Browser globals\n factory root\n return\n) this, (exports) ->\n getTransitionEvent = ->\n el = document.createElement('fakeelement')\n transitions =\n 'WebkitAnimation': 'webkitAnimationEnd',\n 'OAnimation': 'oAnimationEnd',\n 'msAnimation': 'MSAnimationEnd',\n 'MozAnimation': 'mozAnimationEnd'\n 'animation' : 'animationend'\n\n for key, val of transitions", "response": "return val if el.style[key]?\n\n transitionEvent = getTransitionEvent()\n\n class PleaseWait\n @_defaultOptions:\n backgroundColor: null\n logo: null\n loadingHtml: null\n template: \"\"\"\n <div class='pg-loading-inner'>\n <div class='pg-loading-center-outer'>\n <div class='pg-loading-center-middle'>\n <h1 class='pg-loading-logo-header'>\n <img class='pg-loading-logo'></img>\n </h1>\n <div class='pg-loading-html'>\n </div>\n </div>\n </div>\n </div>\n \"\"\"", "source_lang": "CoffeeScript", "target_lang": "CoffeeScript", "repo": "Pathgather/please-wait", "path": "src/please-wait.coffee", "license": "MIT", "commit": "d99216f87ac8fbfecaa335fa8bd9bd1a5581f67c", "stars": 1583, "source_url": "https://github.com/Pathgather/please-wait/blob/d99216f87ac8fbfecaa335fa8bd9bd1a5581f67c/src/please-wait.coffee", "line_start": 1, "line_end": 44}573{"id": "Pathgather/please-wait:src/please-wait.coffee:2:raw_corpus", "type": "raw_corpus", "prompt": "", "response": "constructor: (options) ->\n defaultOptions = @constructor._defaultOptions\n @options = {}\n\n # Set initial options, merging given options with the defaults\n for k, v of defaultOptions\n @options[k] = if options[k]? then options[k] else v\n\n # Create the loading screen element\n @_loadingElem = document.createElement(\"div\")\n # Create an empty array to store the potential list of loading HTML (messages, spinners, etc)\n # we'll be displaying to the screen\n @_loadingHtmlToDisplay = []\n # Add a global class for easy styling\n @_loadingElem.className = \"pg-loading-screen\"\n # Set the background color of the loading screen, if supplied\n @_loadingElem.style.backgroundColor = @options.backgroundColor if @options.backgroundColor?\n # Initialize the loading screen's HTML with the defined template. The default can be overwritten via options\n @_loadingElem.innerHTML = @options.template\n # Find the element that will contain the loading HTML displayed to the user (typically a spinner/message)\n # This can be changed via updateLoadingHtml\n @_loadingHtmlElem = @_loadingElem.getElementsByClassName(\"pg-loading-html\")[0]\n # Set the initial loading HTML, if supplied\n @_loadingHtmlElem.innerHTML = @options.loadingHtml if @_loadingHtmlElem?\n # Set a flag that lets us know if the transitioning between loading HTML elements is finished.\n # If true, we can transition immediately to a new message/HTML\n @_readyToShowLoadingHtml = false\n # Find the element that displays the loading logo and set the src if supplied\n logoElem = @_loadingElem.getElementsByClassName(\"pg-loading-logo\")[0]\n logoElem.src = @options.logo if logoElem?\n # Add the loading screen to the body\n document.body.appendChild(@_loadingElem)\n # Add the CSS class that will trigger the initial transitions of the logo/loading HTML\n @_loadingElem.className += \" pg-loading\"\n\n # Define a listener to look for any new loading HTML that needs to be displayed after the intiial transition finishes\n listener = =>\n @_readyToShowLoadingHtml = true\n if transitionEvent? then @_loadingHtmlElem.removeEventListener(transitionEvent, listener)\n if @_loadingHtmlToDisplay.length > 0 then @_changeLoadingHtml()", "source_lang": "", "target_lang": "CoffeeScript", "repo": "Pathgather/please-wait", "path": "src/please-wait.coffee", "license": "MIT", "commit": "d99216f87ac8fbfecaa335fa8bd9bd1a5581f67c", "stars": 1583, "source_url": "https://github.com/Pathgather/please-wait/blob/d99216f87ac8fbfecaa335fa8bd9bd1a5581f67c/src/please-wait.coffee", "line_start": 46, "line_end": 85}574{"id": "Pathgather/please-wait:src/please-wait.coffee:2:coffee_to_js", "type": "coffee_to_js", "prompt": "Convert this CoffeeScript to JavaScript.\n```coffeescript\nconstructor: (options) ->\n defaultOptions = @constructor._defaultOptions\n @options = {}\n\n # Set initial options, merging given options with the defaults\n for k, v of defaultOptions\n @options[k] = if options[k]? then options[k] else v\n\n # Create the loading screen element\n @_loadingElem = document.createElement(\"div\")\n # Create an empty array to store the potential list of loading HTML (messages, spinners, etc)\n # we'll be displaying to the screen\n @_loadingHtmlToDisplay = []\n # Add a global class for easy styling\n @_loadingElem.className = \"pg-loading-screen\"\n # Set the background color of the loading screen, if supplied\n @_loadingElem.style.backgroundColor = @options.backgroundColor if @options.backgroundColor?\n # Initialize the loading screen's HTML with the defined template. The default can be overwritten via options\n @_loadingElem.innerHTML = @options.template\n # Find the element that will contain the loading HTML displayed to the user (typically a spinner/message)\n # This can be changed via updateLoadingHtml\n @_loadingHtmlElem = @_loadingElem.getElementsByClassName(\"pg-loading-html\")[0]\n # Set the initial loading HTML, if supplied\n @_loadingHtmlElem.innerHTML = @options.loadingHtml if @_loadingHtmlElem?\n # Set a flag that lets us know if the transitioning between loading HTML elements is finished.\n # If true, we can transition immediately to a new message/HTML\n @_readyToShowLoadingHtml = false\n # Find the element that displays the loading logo and set the src if supplied\n logoElem = @_loadingElem.getElementsByClassName(\"pg-loading-logo\")[0]\n logoElem.src = @options.logo if logoElem?\n # Add the loading screen to the body\n document.body.appendChild(@_loadingElem)\n # Add the CSS class that will trigger the initial transitions of the logo/loading HTML\n @_loadingElem.className += \" pg-loading\"\n\n # Define a listener to look for any new loading HTML that needs to be displayed after the intiial transition finishes\n listener = =>\n @_readyToShowLoadingHtml = true\n if transitionEvent? then @_loadingHtmlElem.removeEventListener(transitionEvent, listener)\n if @_loadingHtmlToDisplay.length > 0 then @_changeLoadingHtml()\n```", "response": "({\n constructor: function(options) {\n var defaultOptions, k, listener, logoElem, v;\n defaultOptions = this.constructor._defaultOptions;\n this.options = {};\n// Set initial options, merging given options with the defaults\n for (k in defaultOptions) {\n v = defaultOptions[k];\n this.options[k] = options[k] != null ? options[k] : v;\n }\n // Create the loading screen element\n this._loadingElem = document.createElement(\"div\");\n // Create an empty array to store the potential list of loading HTML (messages, spinners, etc)\n // we'll be displaying to the screen\n this._loadingHtmlToDisplay = [];\n // Add a global class for easy styling\n this._loadingElem.className = \"pg-loading-screen\";\n if (this.options.backgroundColor != null) {\n // Set the background color of the loading screen, if supplied\n this._loadingElem.style.backgroundColor = this.options.backgroundColor;\n }\n // Initialize the loading screen's HTML with the defined template. The default can be overwritten via options\n this._loadingElem.innerHTML = this.options.template;\n // Find the element that will contain the loading HTML displayed to the user (typically a spinner/message)\n // This can be changed via updateLoadingHtml\n this._loadingHtmlElem = this._loadingElem.getElementsByClassName(\"pg-loading-html\")[0];\n if (this._loadingHtmlElem != null) {\n // Set the initial loading HTML, if supplied\n this._loadingHtmlElem.innerHTML = this.options.loadingHtml;\n }\n // Set a flag that lets us know if the transitioning between loading HTML elements is finished.\n // If true, we can transition immediately to a new message/HTML\n this._readyToShowLoadingHtml = false;\n // Find the element that displays the loading logo and set the src if supplied\n logoElem = this._loadingElem.getElementsByClassName(\"pg-loading-logo\")[0];\n if (logoElem != null) {\n logoElem.src = this.options.logo;\n }\n // Add the loading screen to the body\n document.body.appendChild(this._loadingElem);\n // Add the CSS class that will trigger the initial transitions of the logo/loading HTML\n this._loadingElem.className += \" pg-loading\";\n // Define a listener to look for any new loading HTML that needs to be displayed after the intiial transition finishes\n return listener = () => {\n this._readyToShowLoadingHtml = true;\n if (typeof transitionEvent !== \"undefined\" && transitionEvent !== null) {\n this._loadingHtmlElem.removeEventListener(transitionEvent, listener);\n }\n if (this._loadingHtmlToDisplay.length > 0) {\n return this._changeLoadingHtml();\n }\n };\n }\n});", "source_lang": "CoffeeScript", "target_lang": "JavaScript", "repo": "Pathgather/please-wait", "path": "src/please-wait.coffee", "license": "MIT", "commit": "d99216f87ac8fbfecaa335fa8bd9bd1a5581f67c", "stars": 1583, "source_url": "https://github.com/Pathgather/please-wait/blob/d99216f87ac8fbfecaa335fa8bd9bd1a5581f67c/src/please-wait.coffee", "line_start": 46, "line_end": 85}575{"id": "Pathgather/please-wait:src/please-wait.coffee:2:js_to_coffee", "type": "js_to_coffee", "prompt": "Convert this JavaScript to CoffeeScript.\n```javascript\n({\n constructor: function(options) {\n var defaultOptions, k, listener, logoElem, v;\n defaultOptions = this.constructor._defaultOptions;\n this.options = {};\n// Set initial options, merging given options with the defaults\n for (k in defaultOptions) {\n v = defaultOptions[k];\n this.options[k] = options[k] != null ? options[k] : v;\n }\n // Create the loading screen element\n this._loadingElem = document.createElement(\"div\");\n // Create an empty array to store the potential list of loading HTML (messages, spinners, etc)\n // we'll be displaying to the screen\n this._loadingHtmlToDisplay = [];\n // Add a global class for easy styling\n this._loadingElem.className = \"pg-loading-screen\";\n if (this.options.backgroundColor != null) {\n // Set the background color of the loading screen, if supplied\n this._loadingElem.style.backgroundColor = this.options.backgroundColor;\n }\n // Initialize the loading screen's HTML with the defined template. The default can be overwritten via options\n this._loadingElem.innerHTML = this.options.template;\n // Find the element that will contain the loading HTML displayed to the user (typically a spinner/message)\n // This can be changed via updateLoadingHtml\n this._loadingHtmlElem = this._loadingElem.getElementsByClassName(\"pg-loading-html\")[0];\n if (this._loadingHtmlElem != null) {\n // Set the initial loading HTML, if supplied\n this._loadingHtmlElem.innerHTML = this.options.loadingHtml;\n }\n // Set a flag that lets us know if the transitioning between loading HTML elements is finished.\n // If true, we can transition immediately to a new message/HTML\n this._readyToShowLoadingHtml = false;\n // Find the element that displays the loading logo and set the src if supplied\n logoElem = this._loadingElem.getElementsByClassName(\"pg-loading-logo\")[0];\n if (logoElem != null) {\n logoElem.src = this.options.logo;\n }\n // Add the loading screen to the body\n document.body.appendChild(this._loadingElem);\n // Add the CSS class that will trigger the initial transitions of the logo/loading HTML\n this._loadingElem.className += \" pg-loading\";\n // Define a listener to look for any new loading HTML that needs to be displayed after the intiial transition finishes\n return listener = () => {\n this._readyToShowLoadingHtml = true;\n if (typeof transitionEvent !== \"undefined\" && transitionEvent !== null) {\n this._loadingHtmlElem.removeEventListener(transitionEvent, listener);\n }\n if (this._loadingHtmlToDisplay.length > 0) {\n return this._changeLoadingHtml();\n }\n };\n }\n});\n```", "response": "constructor: (options) ->\n defaultOptions = @constructor._defaultOptions\n @options = {}\n\n # Set initial options, merging given options with the defaults\n for k, v of defaultOptions\n @options[k] = if options[k]? then options[k] else v\n\n # Create the loading screen element\n @_loadingElem = document.createElement(\"div\")\n # Create an empty array to store the potential list of loading HTML (messages, spinners, etc)\n # we'll be displaying to the screen\n @_loadingHtmlToDisplay = []\n # Add a global class for easy styling\n @_loadingElem.className = \"pg-loading-screen\"\n # Set the background color of the loading screen, if supplied\n @_loadingElem.style.backgroundColor = @options.backgroundColor if @options.backgroundColor?\n # Initialize the loading screen's HTML with the defined template. The default can be overwritten via options\n @_loadingElem.innerHTML = @options.template\n # Find the element that will contain the loading HTML displayed to the user (typically a spinner/message)\n # This can be changed via updateLoadingHtml\n @_loadingHtmlElem = @_loadingElem.getElementsByClassName(\"pg-loading-html\")[0]\n # Set the initial loading HTML, if supplied\n @_loadingHtmlElem.innerHTML = @options.loadingHtml if @_loadingHtmlElem?\n # Set a flag that lets us know if the transitioning between loading HTML elements is finished.\n # If true, we can transition immediately to a new message/HTML\n @_readyToShowLoadingHtml = false\n # Find the element that displays the loading logo and set the src if supplied\n logoElem = @_loadingElem.getElementsByClassName(\"pg-loading-logo\")[0]\n logoElem.src = @options.logo if logoElem?\n # Add the loading screen to the body\n document.body.appendChild(@_loadingElem)\n # Add the CSS class that will trigger the initial transitions of the logo/loading HTML\n @_loadingElem.className += \" pg-loading\"\n\n # Define a listener to look for any new loading HTML that needs to be displayed after the intiial transition finishes\n listener = =>\n @_readyToShowLoadingHtml = true\n if transitionEvent? then @_loadingHtmlElem.removeEventListener(transitionEvent, listener)\n if @_loadingHtmlToDisplay.length > 0 then @_changeLoadingHtml()", "source_lang": "JavaScript", "target_lang": "CoffeeScript", "repo": "Pathgather/please-wait", "path": "src/please-wait.coffee", "license": "MIT", "commit": "d99216f87ac8fbfecaa335fa8bd9bd1a5581f67c", "stars": 1583, "source_url": "https://github.com/Pathgather/please-wait/blob/d99216f87ac8fbfecaa335fa8bd9bd1a5581f67c/src/please-wait.coffee", "line_start": 46, "line_end": 85}576{"id": "Pathgather/please-wait:src/please-wait.coffee:2:completion", "type": "completion", "prompt": "constructor: (options) ->\n defaultOptions = @constructor._defaultOptions\n @options = {}\n\n # Set initial options, merging given options with the defaults\n for k, v of defaultOptions\n @options[k] = if options[k]? then options[k] else v\n\n # Create the loading screen element\n @_loadingElem = document.createElement(\"div\")\n # Create an empty array to store the potential list of loading HTML (messages, spinners, etc)\n # we'll be displaying to the screen\n @_loadingHtmlToDisplay = []\n # Add a global class for easy styling\n @_loadingElem.className = \"pg-loading-screen\"\n # Set the background color of the loading screen, if supplied\n @_loadingElem.style.backgroundColor = @options.backgroundColor if @options.backgroundColor?\n # Initialize the loading screen's HTML with the defined template. The default can be overwritten via options\n @_loadingElem.innerHTML = @options.template\n # Find the element that will contain the loading HTML displayed to the user (typically a spinner/message)", "response": "# This can be changed via updateLoadingHtml\n @_loadingHtmlElem = @_loadingElem.getElementsByClassName(\"pg-loading-html\")[0]\n # Set the initial loading HTML, if supplied\n @_loadingHtmlElem.innerHTML = @options.loadingHtml if @_loadingHtmlElem?\n # Set a flag that lets us know if the transitioning between loading HTML elements is finished.\n # If true, we can transition immediately to a new message/HTML\n @_readyToShowLoadingHtml = false\n # Find the element that displays the loading logo and set the src if supplied\n logoElem = @_loadingElem.getElementsByClassName(\"pg-loading-logo\")[0]\n logoElem.src = @options.logo if logoElem?\n # Add the loading screen to the body\n document.body.appendChild(@_loadingElem)\n # Add the CSS class that will trigger the initial transitions of the logo/loading HTML\n @_loadingElem.className += \" pg-loading\"\n\n # Define a listener to look for any new loading HTML that needs to be displayed after the intiial transition finishes\n listener = =>\n @_readyToShowLoadingHtml = true\n if transitionEvent? then @_loadingHtmlElem.removeEventListener(transitionEvent, listener)\n if @_loadingHtmlToDisplay.length > 0 then @_changeLoadingHtml()", "source_lang": "CoffeeScript", "target_lang": "CoffeeScript", "repo": "Pathgather/please-wait", "path": "src/please-wait.coffee", "license": "MIT", "commit": "d99216f87ac8fbfecaa335fa8bd9bd1a5581f67c", "stars": 1583, "source_url": "https://github.com/Pathgather/please-wait/blob/d99216f87ac8fbfecaa335fa8bd9bd1a5581f67c/src/please-wait.coffee", "line_start": 46, "line_end": 85}577{"id": "Pathgather/please-wait:src/please-wait.coffee:3:raw_corpus", "type": "raw_corpus", "prompt": "", "response": "if @_loadingHtmlElem?\n # Detect CSS animation support. If not found, we'll call the listener immediately. Otherwise, we'll wait\n if transitionEvent?\n @_loadingHtmlElem.addEventListener(transitionEvent, listener)\n else\n listener()\n\n # Define listeners for the transtioning out and in of new loading HTML/messages\n @_loadingHtmlListener = =>\n # New loading HTML has fully transitioned in. We're now ready to show a new message/HTML\n @_readyToShowLoadingHtml = true\n # Remove the CSS class that triggered the fade in animation\n @_loadingHtmlElem.className = @_loadingHtmlElem.className.replace(\" pg-loading \", \"\")\n if transitionEvent? then @_loadingHtmlElem.removeEventListener(transitionEvent, @_loadingHtmlListener)\n # Check if there's still HTML left in the queue to display. If so, let's show it\n if @_loadingHtmlToDisplay.length > 0 then @_changeLoadingHtml()\n\n @_removingHtmlListener = =>\n # Last loading HTML to display has fully transitioned out. Time to transition the new in\n @_loadingHtmlElem.innerHTML = @_loadingHtmlToDisplay.shift()\n # Add the CSS class to trigger the fade in animation\n @_loadingHtmlElem.className = @_loadingHtmlElem.className.replace(\" pg-removing \", \" pg-loading \")\n if transitionEvent?\n @_loadingHtmlElem.removeEventListener(transitionEvent, @_removingHtmlListener)\n @_loadingHtmlElem.addEventListener(transitionEvent, @_loadingHtmlListener)\n else\n @_loadingHtmlListener()\n\n finish: ->\n return unless @_loadingElem?\n # Again, define a listener to run once the loading screen has fully transitioned out\n listener = =>\n # Remove the loading screen from the body\n document.body.removeChild(@_loadingElem)\n # Add a class to the body to signal that the loading screen has finished and the app is ready\n document.body.className += \" pg-loaded\"\n if transitionEvent? then @_loadingElem.removeEventListener(transitionEvent, listener)\n # Reset the loading screen element since it's no longer attached to the DOM\n @_loadingElem = null", "source_lang": "", "target_lang": "CoffeeScript", "repo": "Pathgather/please-wait", "path": "src/please-wait.coffee", "license": "MIT", "commit": "d99216f87ac8fbfecaa335fa8bd9bd1a5581f67c", "stars": 1583, "source_url": "https://github.com/Pathgather/please-wait/blob/d99216f87ac8fbfecaa335fa8bd9bd1a5581f67c/src/please-wait.coffee", "line_start": 87, "line_end": 125}578{"id": "Pathgather/please-wait:src/please-wait.coffee:3:coffee_to_js", "type": "coffee_to_js", "prompt": "Convert this CoffeeScript to JavaScript.\n```coffeescript\nif @_loadingHtmlElem?\n # Detect CSS animation support. If not found, we'll call the listener immediately. Otherwise, we'll wait\n if transitionEvent?\n @_loadingHtmlElem.addEventListener(transitionEvent, listener)\n else\n listener()\n\n # Define listeners for the transtioning out and in of new loading HTML/messages\n @_loadingHtmlListener = =>\n # New loading HTML has fully transitioned in. We're now ready to show a new message/HTML\n @_readyToShowLoadingHtml = true\n # Remove the CSS class that triggered the fade in animation\n @_loadingHtmlElem.className = @_loadingHtmlElem.className.replace(\" pg-loading \", \"\")\n if transitionEvent? then @_loadingHtmlElem.removeEventListener(transitionEvent, @_loadingHtmlListener)\n # Check if there's still HTML left in the queue to display. If so, let's show it\n if @_loadingHtmlToDisplay.length > 0 then @_changeLoadingHtml()\n\n @_removingHtmlListener = =>\n # Last loading HTML to display has fully transitioned out. Time to transition the new in\n @_loadingHtmlElem.innerHTML = @_loadingHtmlToDisplay.shift()\n # Add the CSS class to trigger the fade in animation\n @_loadingHtmlElem.className = @_loadingHtmlElem.className.replace(\" pg-removing \", \" pg-loading \")\n if transitionEvent?\n @_loadingHtmlElem.removeEventListener(transitionEvent, @_removingHtmlListener)\n @_loadingHtmlElem.addEventListener(transitionEvent, @_loadingHtmlListener)\n else\n @_loadingHtmlListener()\n\n finish: ->\n return unless @_loadingElem?\n # Again, define a listener to run once the loading screen has fully transitioned out\n listener = =>\n # Remove the loading screen from the body\n document.body.removeChild(@_loadingElem)\n # Add a class to the body to signal that the loading screen has finished and the app is ready\n document.body.className += \" pg-loaded\"\n if transitionEvent? then @_loadingElem.removeEventListener(transitionEvent, listener)\n # Reset the loading screen element since it's no longer attached to the DOM\n @_loadingElem = null\n```", "response": "if (this._loadingHtmlElem != null) {\n // Detect CSS animation support. If not found, we'll call the listener immediately. Otherwise, we'll wait\n if (typeof transitionEvent !== \"undefined\" && transitionEvent !== null) {\n this._loadingHtmlElem.addEventListener(transitionEvent, listener);\n } else {\n listener();\n }\n // Define listeners for the transtioning out and in of new loading HTML/messages\n this._loadingHtmlListener = () => {\n // New loading HTML has fully transitioned in. We're now ready to show a new message/HTML\n this._readyToShowLoadingHtml = true;\n // Remove the CSS class that triggered the fade in animation\n this._loadingHtmlElem.className = this._loadingHtmlElem.className.replace(\" pg-loading \", \"\");\n if (typeof transitionEvent !== \"undefined\" && transitionEvent !== null) {\n this._loadingHtmlElem.removeEventListener(transitionEvent, this._loadingHtmlListener);\n }\n // Check if there's still HTML left in the queue to display. If so, let's show it\n if (this._loadingHtmlToDisplay.length > 0) {\n return this._changeLoadingHtml();\n }\n };\n this._removingHtmlListener = () => {\n // Last loading HTML to display has fully transitioned out. Time to transition the new in\n this._loadingHtmlElem.innerHTML = this._loadingHtmlToDisplay.shift();\n // Add the CSS class to trigger the fade in animation\n this._loadingHtmlElem.className = this._loadingHtmlElem.className.replace(\" pg-removing \", \" pg-loading \");\n if (typeof transitionEvent !== \"undefined\" && transitionEvent !== null) {\n this._loadingHtmlElem.removeEventListener(transitionEvent, this._removingHtmlListener);\n return this._loadingHtmlElem.addEventListener(transitionEvent, this._loadingHtmlListener);\n } else {\n return this._loadingHtmlListener();\n }\n };\n}\n\n({\n finish: function() {\n var listener;\n if (this._loadingElem == null) {\n return;\n }\n // Again, define a listener to run once the loading screen has fully transitioned out\n return listener = () => {\n // Remove the loading screen from the body\n document.body.removeChild(this._loadingElem);\n // Add a class to the body to signal that the loading screen has finished and the app is ready\n document.body.className += \" pg-loaded\";\n if (typeof transitionEvent !== \"undefined\" && transitionEvent !== null) {\n this._loadingElem.removeEventListener(transitionEvent, listener);\n }\n // Reset the loading screen element since it's no longer attached to the DOM\n return this._loadingElem = null;\n };\n }\n});", "source_lang": "CoffeeScript", "target_lang": "JavaScript", "repo": "Pathgather/please-wait", "path": "src/please-wait.coffee", "license": "MIT", "commit": "d99216f87ac8fbfecaa335fa8bd9bd1a5581f67c", "stars": 1583, "source_url": "https://github.com/Pathgather/please-wait/blob/d99216f87ac8fbfecaa335fa8bd9bd1a5581f67c/src/please-wait.coffee", "line_start": 87, "line_end": 125}579{"id": "Pathgather/please-wait:src/please-wait.coffee:3:js_to_coffee", "type": "js_to_coffee", "prompt": "Convert this JavaScript to CoffeeScript.\n```javascript\nif (this._loadingHtmlElem != null) {\n // Detect CSS animation support. If not found, we'll call the listener immediately. Otherwise, we'll wait\n if (typeof transitionEvent !== \"undefined\" && transitionEvent !== null) {\n this._loadingHtmlElem.addEventListener(transitionEvent, listener);\n } else {\n listener();\n }\n // Define listeners for the transtioning out and in of new loading HTML/messages\n this._loadingHtmlListener = () => {\n // New loading HTML has fully transitioned in. We're now ready to show a new message/HTML\n this._readyToShowLoadingHtml = true;\n // Remove the CSS class that triggered the fade in animation\n this._loadingHtmlElem.className = this._loadingHtmlElem.className.replace(\" pg-loading \", \"\");\n if (typeof transitionEvent !== \"undefined\" && transitionEvent !== null) {\n this._loadingHtmlElem.removeEventListener(transitionEvent, this._loadingHtmlListener);\n }\n // Check if there's still HTML left in the queue to display. If so, let's show it\n if (this._loadingHtmlToDisplay.length > 0) {\n return this._changeLoadingHtml();\n }\n };\n this._removingHtmlListener = () => {\n // Last loading HTML to display has fully transitioned out. Time to transition the new in\n this._loadingHtmlElem.innerHTML = this._loadingHtmlToDisplay.shift();\n // Add the CSS class to trigger the fade in animation\n this._loadingHtmlElem.className = this._loadingHtmlElem.className.replace(\" pg-removing \", \" pg-loading \");\n if (typeof transitionEvent !== \"undefined\" && transitionEvent !== null) {\n this._loadingHtmlElem.removeEventListener(transitionEvent, this._removingHtmlListener);\n return this._loadingHtmlElem.addEventListener(transitionEvent, this._loadingHtmlListener);\n } else {\n return this._loadingHtmlListener();\n }\n };\n}\n\n({\n finish: function() {\n var listener;\n if (this._loadingElem == null) {\n return;\n }\n // Again, define a listener to run once the loading screen has fully transitioned out\n return listener = () => {\n // Remove the loading screen from the body\n document.body.removeChild(this._loadingElem);\n // Add a class to the body to signal that the loading screen has finished and the app is ready\n document.body.className += \" pg-loaded\";\n if (typeof transitionEvent !== \"undefined\" && transitionEvent !== null) {\n this._loadingElem.removeEventListener(transitionEvent, listener);\n }\n // Reset the loading screen element since it's no longer attached to the DOM\n return this._loadingElem = null;\n };\n }\n});\n```", "response": "if @_loadingHtmlElem?\n # Detect CSS animation support. If not found, we'll call the listener immediately. Otherwise, we'll wait\n if transitionEvent?\n @_loadingHtmlElem.addEventListener(transitionEvent, listener)\n else\n listener()\n\n # Define listeners for the transtioning out and in of new loading HTML/messages\n @_loadingHtmlListener = =>\n # New loading HTML has fully transitioned in. We're now ready to show a new message/HTML\n @_readyToShowLoadingHtml = true\n # Remove the CSS class that triggered the fade in animation\n @_loadingHtmlElem.className = @_loadingHtmlElem.className.replace(\" pg-loading \", \"\")\n if transitionEvent? then @_loadingHtmlElem.removeEventListener(transitionEvent, @_loadingHtmlListener)\n # Check if there's still HTML left in the queue to display. If so, let's show it\n if @_loadingHtmlToDisplay.length > 0 then @_changeLoadingHtml()\n\n @_removingHtmlListener = =>\n # Last loading HTML to display has fully transitioned out. Time to transition the new in\n @_loadingHtmlElem.innerHTML = @_loadingHtmlToDisplay.shift()\n # Add the CSS class to trigger the fade in animation\n @_loadingHtmlElem.className = @_loadingHtmlElem.className.replace(\" pg-removing \", \" pg-loading \")\n if transitionEvent?\n @_loadingHtmlElem.removeEventListener(transitionEvent, @_removingHtmlListener)\n @_loadingHtmlElem.addEventListener(transitionEvent, @_loadingHtmlListener)\n else\n @_loadingHtmlListener()\n\n finish: ->\n return unless @_loadingElem?\n # Again, define a listener to run once the loading screen has fully transitioned out\n listener = =>\n # Remove the loading screen from the body\n document.body.removeChild(@_loadingElem)\n # Add a class to the body to signal that the loading screen has finished and the app is ready\n document.body.className += \" pg-loaded\"\n if transitionEvent? then @_loadingElem.removeEventListener(transitionEvent, listener)\n # Reset the loading screen element since it's no longer attached to the DOM\n @_loadingElem = null", "source_lang": "JavaScript", "target_lang": "CoffeeScript", "repo": "Pathgather/please-wait", "path": "src/please-wait.coffee", "license": "MIT", "commit": "d99216f87ac8fbfecaa335fa8bd9bd1a5581f67c", "stars": 1583, "source_url": "https://github.com/Pathgather/please-wait/blob/d99216f87ac8fbfecaa335fa8bd9bd1a5581f67c/src/please-wait.coffee", "line_start": 87, "line_end": 125}580{"id": "Pathgather/please-wait:src/please-wait.coffee:3:completion", "type": "completion", "prompt": "if @_loadingHtmlElem?\n # Detect CSS animation support. If not found, we'll call the listener immediately. Otherwise, we'll wait\n if transitionEvent?\n @_loadingHtmlElem.addEventListener(transitionEvent, listener)\n else\n listener()\n\n # Define listeners for the transtioning out and in of new loading HTML/messages\n @_loadingHtmlListener = =>\n # New loading HTML has fully transitioned in. We're now ready to show a new message/HTML\n @_readyToShowLoadingHtml = true\n # Remove the CSS class that triggered the fade in animation\n @_loadingHtmlElem.className = @_loadingHtmlElem.className.replace(\" pg-loading \", \"\")\n if transitionEvent? then @_loadingHtmlElem.removeEventListener(transitionEvent, @_loadingHtmlListener)\n # Check if there's still HTML left in the queue to display. If so, let's show it\n if @_loadingHtmlToDisplay.length > 0 then @_changeLoadingHtml()\n\n @_removingHtmlListener = =>\n # Last loading HTML to display has fully transitioned out. Time to transition the new in", "response": "@_loadingHtmlElem.innerHTML = @_loadingHtmlToDisplay.shift()\n # Add the CSS class to trigger the fade in animation\n @_loadingHtmlElem.className = @_loadingHtmlElem.className.replace(\" pg-removing \", \" pg-loading \")\n if transitionEvent?\n @_loadingHtmlElem.removeEventListener(transitionEvent, @_removingHtmlListener)\n @_loadingHtmlElem.addEventListener(transitionEvent, @_loadingHtmlListener)\n else\n @_loadingHtmlListener()\n\n finish: ->\n return unless @_loadingElem?\n # Again, define a listener to run once the loading screen has fully transitioned out\n listener = =>\n # Remove the loading screen from the body\n document.body.removeChild(@_loadingElem)\n # Add a class to the body to signal that the loading screen has finished and the app is ready\n document.body.className += \" pg-loaded\"\n if transitionEvent? then @_loadingElem.removeEventListener(transitionEvent, listener)\n # Reset the loading screen element since it's no longer attached to the DOM\n @_loadingElem = null", "source_lang": "CoffeeScript", "target_lang": "CoffeeScript", "repo": "Pathgather/please-wait", "path": "src/please-wait.coffee", "license": "MIT", "commit": "d99216f87ac8fbfecaa335fa8bd9bd1a5581f67c", "stars": 1583, "source_url": "https://github.com/Pathgather/please-wait/blob/d99216f87ac8fbfecaa335fa8bd9bd1a5581f67c/src/please-wait.coffee", "line_start": 87, "line_end": 125}581{"id": "Pathgather/please-wait:src/please-wait.coffee:4:raw_corpus", "type": "raw_corpus", "prompt": "", "response": "# Detect CSS animation support. If not found, we'll call the listener immediately. Otherwise, we'll wait\n if transitionEvent?\n # Set a class on the loading screen to trigger a fadeout animation\n @_loadingElem.className += \" pg-loaded\"\n # When the loading screen is finished fading out, we'll remove it from the DOM\n @_loadingElem.addEventListener(transitionEvent, listener)\n else\n listener()\n\n updateLoadingHtml: (loadingHtml, immediately=false) ->\n unless @_loadingHtmlElem? then throw new Error(\"The loading template does not have an element of class 'pg-loading-html'\")\n if immediately\n # Ignore any loading HTML that may be queued up. Show this immediately\n @_loadingHtmlToDisplay = [loadingHtml]\n @_readyToShowLoadingHtml = true\n else\n # Add to an array of HTML to display to the user\n @_loadingHtmlToDisplay.push(loadingHtml)\n # If ready, let's display the new loading HTML\n if @_readyToShowLoadingHtml then @_changeLoadingHtml()\n\n # Private method to immediately change the loading HTML displayed\n _changeLoadingHtml: ->\n @_readyToShowLoadingHtml = false\n # Remove any old event listeners that may still be attached to the DOM\n @_loadingHtmlElem.removeEventListener(transitionEvent, @_loadingHtmlListener)\n @_loadingHtmlElem.removeEventListener(transitionEvent, @_removingHtmlListener)\n # Remove any old CSS transition classes that may still be on the element\n @_loadingHtmlElem.className = @_loadingHtmlElem.className.replace(\" pg-loading \", \"\").replace( \" pg-removing \", \"\")\n\n if transitionEvent?\n # Add the CSS class that will cause the HTML to fade out\n @_loadingHtmlElem.className += \" pg-removing \"\n @_loadingHtmlElem.addEventListener(transitionEvent, @_removingHtmlListener)\n else\n @_removingHtmlListener()\n\n pleaseWait = (options = {}) ->\n new PleaseWait(options)", "source_lang": "", "target_lang": "CoffeeScript", "repo": "Pathgather/please-wait", "path": "src/please-wait.coffee", "license": "MIT", "commit": "d99216f87ac8fbfecaa335fa8bd9bd1a5581f67c", "stars": 1583, "source_url": "https://github.com/Pathgather/please-wait/blob/d99216f87ac8fbfecaa335fa8bd9bd1a5581f67c/src/please-wait.coffee", "line_start": 127, "line_end": 165}582{"id": "Pathgather/please-wait:src/please-wait.coffee:4:completion", "type": "completion", "prompt": "# Detect CSS animation support. If not found, we'll call the listener immediately. Otherwise, we'll wait\n if transitionEvent?\n # Set a class on the loading screen to trigger a fadeout animation\n @_loadingElem.className += \" pg-loaded\"\n # When the loading screen is finished fading out, we'll remove it from the DOM\n @_loadingElem.addEventListener(transitionEvent, listener)\n else\n listener()\n\n updateLoadingHtml: (loadingHtml, immediately=false) ->\n unless @_loadingHtmlElem? then throw new Error(\"The loading template does not have an element of class 'pg-loading-html'\")\n if immediately\n # Ignore any loading HTML that may be queued up. Show this immediately\n @_loadingHtmlToDisplay = [loadingHtml]\n @_readyToShowLoadingHtml = true\n else\n # Add to an array of HTML to display to the user\n @_loadingHtmlToDisplay.push(loadingHtml)\n # If ready, let's display the new loading HTML", "response": "if @_readyToShowLoadingHtml then @_changeLoadingHtml()\n\n # Private method to immediately change the loading HTML displayed\n _changeLoadingHtml: ->\n @_readyToShowLoadingHtml = false\n # Remove any old event listeners that may still be attached to the DOM\n @_loadingHtmlElem.removeEventListener(transitionEvent, @_loadingHtmlListener)\n @_loadingHtmlElem.removeEventListener(transitionEvent, @_removingHtmlListener)\n # Remove any old CSS transition classes that may still be on the element\n @_loadingHtmlElem.className = @_loadingHtmlElem.className.replace(\" pg-loading \", \"\").replace( \" pg-removing \", \"\")\n\n if transitionEvent?\n # Add the CSS class that will cause the HTML to fade out\n @_loadingHtmlElem.className += \" pg-removing \"\n @_loadingHtmlElem.addEventListener(transitionEvent, @_removingHtmlListener)\n else\n @_removingHtmlListener()\n\n pleaseWait = (options = {}) ->\n new PleaseWait(options)", "source_lang": "CoffeeScript", "target_lang": "CoffeeScript", "repo": "Pathgather/please-wait", "path": "src/please-wait.coffee", "license": "MIT", "commit": "d99216f87ac8fbfecaa335fa8bd9bd1a5581f67c", "stars": 1583, "source_url": "https://github.com/Pathgather/please-wait/blob/d99216f87ac8fbfecaa335fa8bd9bd1a5581f67c/src/please-wait.coffee", "line_start": 127, "line_end": 165}583{"id": "Pathgather/please-wait:src/please-wait.coffee:3:raw_corpus", "type": "raw_corpus", "prompt": "", "response": "# Detect CSS animation support. If not found, we'll call the listener immediately. Otherwise, we'll wait\n if transitionEvent?\n @_loadingHtmlElem.addEventListener(transitionEvent, listener)\n else\n listener()\n\n # Define listeners for the transtioning out and in of new loading HTML/messages\n @_loadingHtmlListener = =>\n # New loading HTML has fully transitioned in. We're now ready to show a new message/HTML\n @_readyToShowLoadingHtml = true\n # Remove the CSS class that triggered the fade in animation\n @_loadingHtmlElem.className = @_loadingHtmlElem.className.replace(\" pg-loading \", \"\")\n if transitionEvent? then @_loadingHtmlElem.removeEventListener(transitionEvent, @_loadingHtmlListener)\n # Check if there's still HTML left in the queue to display. If so, let's show it\n if @_loadingHtmlToDisplay.length > 0 then @_changeLoadingHtml()\n\n @_removingHtmlListener = =>\n # Last loading HTML to display has fully transitioned out. Time to transition the new in\n @_loadingHtmlElem.innerHTML = @_loadingHtmlToDisplay.shift()\n # Add the CSS class to trigger the fade in animation\n @_loadingHtmlElem.className = @_loadingHtmlElem.className.replace(\" pg-removing \", \" pg-loading \")\n if transitionEvent?\n @_loadingHtmlElem.removeEventListener(transitionEvent, @_removingHtmlListener)\n @_loadingHtmlElem.addEventListener(transitionEvent, @_loadingHtmlListener)\n else\n @_loadingHtmlListener()\n\n finish: ->\n return unless @_loadingElem?\n # Again, define a listener to run once the loading screen has fully transitioned out\n listener = =>\n # Remove the loading screen from the body\n document.body.removeChild(@_loadingElem)\n # Add a class to the body to signal that the loading screen has finished and the app is ready\n document.body.className += \" pg-loaded\"\n if transitionEvent? then @_loadingElem.removeEventListener(transitionEvent, listener)\n # Reset the loading screen element since it's no longer attached to the DOM\n @_loadingElem = null\n\n # Detect CSS animation support. If not found, we'll call the listener immediately. Otherwise, we'll wait\n if transitionEvent?\n # Set a class on the loading screen to trigger a fadeout animation\n @_loadingElem.className += \" pg-loaded\"\n # When the loading screen is finished fading out, we'll remove it from the DOM\n @_loadingElem.addEventListener(transitionEvent, listener)\n else\n listener()", "source_lang": "", "target_lang": "CoffeeScript", "repo": "Pathgather/please-wait", "path": "src/please-wait.coffee", "license": "MIT", "commit": "7e8c4799ab00b94d00d6f0bef1478566b100806d", "stars": 1583, "source_url": "https://github.com/Pathgather/please-wait/blob/7e8c4799ab00b94d00d6f0bef1478566b100806d/src/please-wait.coffee", "line_start": 87, "line_end": 133}584{"id": "Pathgather/please-wait:src/please-wait.coffee:3:completion", "type": "completion", "prompt": "# Detect CSS animation support. If not found, we'll call the listener immediately. Otherwise, we'll wait\n if transitionEvent?\n @_loadingHtmlElem.addEventListener(transitionEvent, listener)\n else\n listener()\n\n # Define listeners for the transtioning out and in of new loading HTML/messages\n @_loadingHtmlListener = =>\n # New loading HTML has fully transitioned in. We're now ready to show a new message/HTML\n @_readyToShowLoadingHtml = true\n # Remove the CSS class that triggered the fade in animation\n @_loadingHtmlElem.className = @_loadingHtmlElem.className.replace(\" pg-loading \", \"\")\n if transitionEvent? then @_loadingHtmlElem.removeEventListener(transitionEvent, @_loadingHtmlListener)\n # Check if there's still HTML left in the queue to display. If so, let's show it\n if @_loadingHtmlToDisplay.length > 0 then @_changeLoadingHtml()\n\n @_removingHtmlListener = =>\n # Last loading HTML to display has fully transitioned out. Time to transition the new in\n @_loadingHtmlElem.innerHTML = @_loadingHtmlToDisplay.shift()\n # Add the CSS class to trigger the fade in animation\n @_loadingHtmlElem.className = @_loadingHtmlElem.className.replace(\" pg-removing \", \" pg-loading \")\n if transitionEvent?\n @_loadingHtmlElem.removeEventListener(transitionEvent, @_removingHtmlListener)", "response": "@_loadingHtmlElem.addEventListener(transitionEvent, @_loadingHtmlListener)\n else\n @_loadingHtmlListener()\n\n finish: ->\n return unless @_loadingElem?\n # Again, define a listener to run once the loading screen has fully transitioned out\n listener = =>\n # Remove the loading screen from the body\n document.body.removeChild(@_loadingElem)\n # Add a class to the body to signal that the loading screen has finished and the app is ready\n document.body.className += \" pg-loaded\"\n if transitionEvent? then @_loadingElem.removeEventListener(transitionEvent, listener)\n # Reset the loading screen element since it's no longer attached to the DOM\n @_loadingElem = null\n\n # Detect CSS animation support. If not found, we'll call the listener immediately. Otherwise, we'll wait\n if transitionEvent?\n # Set a class on the loading screen to trigger a fadeout animation\n @_loadingElem.className += \" pg-loaded\"\n # When the loading screen is finished fading out, we'll remove it from the DOM\n @_loadingElem.addEventListener(transitionEvent, listener)\n else\n listener()", "source_lang": "CoffeeScript", "target_lang": "CoffeeScript", "repo": "Pathgather/please-wait", "path": "src/please-wait.coffee", "license": "MIT", "commit": "7e8c4799ab00b94d00d6f0bef1478566b100806d", "stars": 1583, "source_url": "https://github.com/Pathgather/please-wait/blob/7e8c4799ab00b94d00d6f0bef1478566b100806d/src/please-wait.coffee", "line_start": 87, "line_end": 133}585{"id": "Pathgather/please-wait:src/please-wait.coffee:4:raw_corpus", "type": "raw_corpus", "prompt": "", "response": "updateLoadingHtml: (loadingHtml, immediately=false) ->\n if immediately\n # Ignore any loading HTML that may be queued up. Show this immediately\n @_loadingHtmlToDisplay = [loadingHtml]\n @_readyToShowLoadingHtml = true\n else\n # Add to an array of HTML to display to the user\n @_loadingHtmlToDisplay.push(loadingHtml)\n # If ready, let's display the new loading HTML\n if @_readyToShowLoadingHtml then @_changeLoadingHtml()\n\n # Private method to immediately change the loading HTML displayed\n _changeLoadingHtml: ->\n @_readyToShowLoadingHtml = false\n # Remove any old event listeners that may still be attached to the DOM\n @_loadingHtmlElem.removeEventListener(transitionEvent, @_loadingHtmlListener)\n @_loadingHtmlElem.removeEventListener(transitionEvent, @_removingHtmlListener)\n # Remove any old CSS transition classes that may still be on the element\n @_loadingHtmlElem.className = @_loadingHtmlElem.className.replace(\" pg-loading \", \"\").replace( \" pg-removing \", \"\")\n\n if transitionEvent?\n # Add the CSS class that will cause the HTML to fade out\n @_loadingHtmlElem.className += \" pg-removing \"\n @_loadingHtmlElem.addEventListener(transitionEvent, @_removingHtmlListener)\n else\n @_removingHtmlListener()\n\n pleaseWait = (options = {}) ->\n new PleaseWait(options)\n\n exports.pleaseWait = pleaseWait\n return pleaseWait", "source_lang": "", "target_lang": "CoffeeScript", "repo": "Pathgather/please-wait", "path": "src/please-wait.coffee", "license": "MIT", "commit": "7e8c4799ab00b94d00d6f0bef1478566b100806d", "stars": 1583, "source_url": "https://github.com/Pathgather/please-wait/blob/7e8c4799ab00b94d00d6f0bef1478566b100806d/src/please-wait.coffee", "line_start": 135, "line_end": 166}586{"id": "Pathgather/please-wait:src/please-wait.coffee:4:coffee_to_js", "type": "coffee_to_js", "prompt": "Convert this CoffeeScript to JavaScript.\n```coffeescript\nupdateLoadingHtml: (loadingHtml, immediately=false) ->\n if immediately\n # Ignore any loading HTML that may be queued up. Show this immediately\n @_loadingHtmlToDisplay = [loadingHtml]\n @_readyToShowLoadingHtml = true\n else\n # Add to an array of HTML to display to the user\n @_loadingHtmlToDisplay.push(loadingHtml)\n # If ready, let's display the new loading HTML\n if @_readyToShowLoadingHtml then @_changeLoadingHtml()\n\n # Private method to immediately change the loading HTML displayed\n _changeLoadingHtml: ->\n @_readyToShowLoadingHtml = false\n # Remove any old event listeners that may still be attached to the DOM\n @_loadingHtmlElem.removeEventListener(transitionEvent, @_loadingHtmlListener)\n @_loadingHtmlElem.removeEventListener(transitionEvent, @_removingHtmlListener)\n # Remove any old CSS transition classes that may still be on the element\n @_loadingHtmlElem.className = @_loadingHtmlElem.className.replace(\" pg-loading \", \"\").replace( \" pg-removing \", \"\")\n\n if transitionEvent?\n # Add the CSS class that will cause the HTML to fade out\n @_loadingHtmlElem.className += \" pg-removing \"\n @_loadingHtmlElem.addEventListener(transitionEvent, @_removingHtmlListener)\n else\n @_removingHtmlListener()\n\n pleaseWait = (options = {}) ->\n new PleaseWait(options)\n\n exports.pleaseWait = pleaseWait\n return pleaseWait\n```", "response": "var pleaseWait;\n\n({\n updateLoadingHtml: function(loadingHtml, immediately = false) {\n if (immediately) {\n // Ignore any loading HTML that may be queued up. Show this immediately\n this._loadingHtmlToDisplay = [loadingHtml];\n this._readyToShowLoadingHtml = true;\n } else {\n // Add to an array of HTML to display to the user\n this._loadingHtmlToDisplay.push(loadingHtml);\n }\n // If ready, let's display the new loading HTML\n if (this._readyToShowLoadingHtml) {\n return this._changeLoadingHtml();\n }\n },\n // Private method to immediately change the loading HTML displayed\n _changeLoadingHtml: function() {\n this._readyToShowLoadingHtml = false;\n // Remove any old event listeners that may still be attached to the DOM\n this._loadingHtmlElem.removeEventListener(transitionEvent, this._loadingHtmlListener);\n this._loadingHtmlElem.removeEventListener(transitionEvent, this._removingHtmlListener);\n // Remove any old CSS transition classes that may still be on the element\n this._loadingHtmlElem.className = this._loadingHtmlElem.className.replace(\" pg-loading \", \"\").replace(\" pg-removing \", \"\");\n if (typeof transitionEvent !== \"undefined\" && transitionEvent !== null) {\n // Add the CSS class that will cause the HTML to fade out\n this._loadingHtmlElem.className += \" pg-removing \";\n return this._loadingHtmlElem.addEventListener(transitionEvent, this._removingHtmlListener);\n } else {\n return this._removingHtmlListener();\n }\n }\n});\n\npleaseWait = function(options = {}) {\n return new PleaseWait(options);\n};\n\nexports.pleaseWait = pleaseWait;\n\nreturn pleaseWait;", "source_lang": "CoffeeScript", "target_lang": "JavaScript", "repo": "Pathgather/please-wait", "path": "src/please-wait.coffee", "license": "MIT", "commit": "7e8c4799ab00b94d00d6f0bef1478566b100806d", "stars": 1583, "source_url": "https://github.com/Pathgather/please-wait/blob/7e8c4799ab00b94d00d6f0bef1478566b100806d/src/please-wait.coffee", "line_start": 135, "line_end": 166}587{"id": "Pathgather/please-wait:src/please-wait.coffee:4:js_to_coffee", "type": "js_to_coffee", "prompt": "Convert this JavaScript to CoffeeScript.\n```javascript\nvar pleaseWait;\n\n({\n updateLoadingHtml: function(loadingHtml, immediately = false) {\n if (immediately) {\n // Ignore any loading HTML that may be queued up. Show this immediately\n this._loadingHtmlToDisplay = [loadingHtml];\n this._readyToShowLoadingHtml = true;\n } else {\n // Add to an array of HTML to display to the user\n this._loadingHtmlToDisplay.push(loadingHtml);\n }\n // If ready, let's display the new loading HTML\n if (this._readyToShowLoadingHtml) {\n return this._changeLoadingHtml();\n }\n },\n // Private method to immediately change the loading HTML displayed\n _changeLoadingHtml: function() {\n this._readyToShowLoadingHtml = false;\n // Remove any old event listeners that may still be attached to the DOM\n this._loadingHtmlElem.removeEventListener(transitionEvent, this._loadingHtmlListener);\n this._loadingHtmlElem.removeEventListener(transitionEvent, this._removingHtmlListener);\n // Remove any old CSS transition classes that may still be on the element\n this._loadingHtmlElem.className = this._loadingHtmlElem.className.replace(\" pg-loading \", \"\").replace(\" pg-removing \", \"\");\n if (typeof transitionEvent !== \"undefined\" && transitionEvent !== null) {\n // Add the CSS class that will cause the HTML to fade out\n this._loadingHtmlElem.className += \" pg-removing \";\n return this._loadingHtmlElem.addEventListener(transitionEvent, this._removingHtmlListener);\n } else {\n return this._removingHtmlListener();\n }\n }\n});\n\npleaseWait = function(options = {}) {\n return new PleaseWait(options);\n};\n\nexports.pleaseWait = pleaseWait;\n\nreturn pleaseWait;\n```", "response": "updateLoadingHtml: (loadingHtml, immediately=false) ->\n if immediately\n # Ignore any loading HTML that may be queued up. Show this immediately\n @_loadingHtmlToDisplay = [loadingHtml]\n @_readyToShowLoadingHtml = true\n else\n # Add to an array of HTML to display to the user\n @_loadingHtmlToDisplay.push(loadingHtml)\n # If ready, let's display the new loading HTML\n if @_readyToShowLoadingHtml then @_changeLoadingHtml()\n\n # Private method to immediately change the loading HTML displayed\n _changeLoadingHtml: ->\n @_readyToShowLoadingHtml = false\n # Remove any old event listeners that may still be attached to the DOM\n @_loadingHtmlElem.removeEventListener(transitionEvent, @_loadingHtmlListener)\n @_loadingHtmlElem.removeEventListener(transitionEvent, @_removingHtmlListener)\n # Remove any old CSS transition classes that may still be on the element\n @_loadingHtmlElem.className = @_loadingHtmlElem.className.replace(\" pg-loading \", \"\").replace( \" pg-removing \", \"\")\n\n if transitionEvent?\n # Add the CSS class that will cause the HTML to fade out\n @_loadingHtmlElem.className += \" pg-removing \"\n @_loadingHtmlElem.addEventListener(transitionEvent, @_removingHtmlListener)\n else\n @_removingHtmlListener()\n\n pleaseWait = (options = {}) ->\n new PleaseWait(options)\n\n exports.pleaseWait = pleaseWait\n return pleaseWait", "source_lang": "JavaScript", "target_lang": "CoffeeScript", "repo": "Pathgather/please-wait", "path": "src/please-wait.coffee", "license": "MIT", "commit": "7e8c4799ab00b94d00d6f0bef1478566b100806d", "stars": 1583, "source_url": "https://github.com/Pathgather/please-wait/blob/7e8c4799ab00b94d00d6f0bef1478566b100806d/src/please-wait.coffee", "line_start": 135, "line_end": 166}588{"id": "Pathgather/please-wait:src/please-wait.coffee:4:completion", "type": "completion", "prompt": "updateLoadingHtml: (loadingHtml, immediately=false) ->\n if immediately\n # Ignore any loading HTML that may be queued up. Show this immediately\n @_loadingHtmlToDisplay = [loadingHtml]\n @_readyToShowLoadingHtml = true\n else\n # Add to an array of HTML to display to the user\n @_loadingHtmlToDisplay.push(loadingHtml)\n # If ready, let's display the new loading HTML\n if @_readyToShowLoadingHtml then @_changeLoadingHtml()\n\n # Private method to immediately change the loading HTML displayed\n _changeLoadingHtml: ->\n @_readyToShowLoadingHtml = false\n # Remove any old event listeners that may still be attached to the DOM\n @_loadingHtmlElem.removeEventListener(transitionEvent, @_loadingHtmlListener)", "response": "@_loadingHtmlElem.removeEventListener(transitionEvent, @_removingHtmlListener)\n # Remove any old CSS transition classes that may still be on the element\n @_loadingHtmlElem.className = @_loadingHtmlElem.className.replace(\" pg-loading \", \"\").replace( \" pg-removing \", \"\")\n\n if transitionEvent?\n # Add the CSS class that will cause the HTML to fade out\n @_loadingHtmlElem.className += \" pg-removing \"\n @_loadingHtmlElem.addEventListener(transitionEvent, @_removingHtmlListener)\n else\n @_removingHtmlListener()\n\n pleaseWait = (options = {}) ->\n new PleaseWait(options)\n\n exports.pleaseWait = pleaseWait\n return pleaseWait", "source_lang": "CoffeeScript", "target_lang": "CoffeeScript", "repo": "Pathgather/please-wait", "path": "src/please-wait.coffee", "license": "MIT", "commit": "7e8c4799ab00b94d00d6f0bef1478566b100806d", "stars": 1583, "source_url": "https://github.com/Pathgather/please-wait/blob/7e8c4799ab00b94d00d6f0bef1478566b100806d/src/please-wait.coffee", "line_start": 135, "line_end": 166}589{"id": "Pathgather/please-wait:src/please-wait.coffee:2:raw_corpus", "type": "raw_corpus", "prompt": "", "response": "constructor: (options) ->\n defaultOptions = @constructor._defaultOptions\n @options = {}\n\n # Set initial options, merging given options with the defaults\n for k, v of defaultOptions\n @options[k] = if options[k]? then options[k] else v\n\n # Create the loading screen element\n @_loadingElem = document.createElement(\"div\")\n # Create an empty array to store the potential list of loading HTML (messages, spinners, etc)\n # we'll be displaying to the screen\n @_loadingHtmlToDisplay = []\n # Add a global class for easy styling\n @_loadingElem.className = \"pg-loading-screen\"\n # Set the background color of the loading screen, if supplied\n @_loadingElem.style.backgroundColor = @options.backgroundColor if @options.backgroundColor?\n # Initialize the loading screen's HTML with the defined template. The default can be overwritten via options\n @_loadingElem.innerHTML = @options.template\n # Find the element that will contain the loading HTML displayed to the user (typically a spinner/message)\n # This can be changed via updateLoadingHtml\n @_loadingHtmlElem = @_loadingElem.getElementsByClassName(\"pg-loading-html\")[0]\n # Set the initial loading HTML, if supplied\n @_loadingHtmlElem.innerHTML = @options.loadingHtml if @_loadingHtmlElem?\n # Set a flag that lets us know if the transitioning between loading HTML elements is finished.\n # If true, we can transition immediately to a new message/HTML\n @_readyToShowLoadingHtml = false\n # Find the element that displays the loading logo and set the src if supplied\n logoElem = @_loadingElem.getElementsByClassName(\"pg-loading-logo\")[0]\n logoElem.src = @options.logo if logoElem?\n # Add the loading screen to the body\n document.body.appendChild(@_loadingElem)\n # Add the CSS class that will trigger the initial transitions of the logo/loading HTML\n @_loadingElem.className += \" pg-loading\"\n # Define a listener to look for any new loading HTML that needs to be displayed after the intiial transition finishes\n listener = =>\n @_readyToShowLoadingHtml = true\n if transitionEvent? then @_loadingHtmlElem.removeEventListener(transitionEvent, listener)\n if @_loadingHtmlToDisplay.length > 0 then @_changeLoadingHtml()\n # Detect CSS animation support. If not found, we'll call the listener immediately. Otherwise, we'll wait\n if transitionEvent?\n @_loadingHtmlElem.addEventListener(transitionEvent, listener)\n else\n listener()", "source_lang": "", "target_lang": "CoffeeScript", "repo": "Pathgather/please-wait", "path": "src/please-wait.coffee", "license": "MIT", "commit": "a619fde4ea75ea695b1546a302e220ed065d5ff0", "stars": 1583, "source_url": "https://github.com/Pathgather/please-wait/blob/a619fde4ea75ea695b1546a302e220ed065d5ff0/src/please-wait.coffee", "line_start": 46, "line_end": 89}590{"id": "Pathgather/please-wait:src/please-wait.coffee:2:coffee_to_js", "type": "coffee_to_js", "prompt": "Convert this CoffeeScript to JavaScript.\n```coffeescript\nconstructor: (options) ->\n defaultOptions = @constructor._defaultOptions\n @options = {}\n\n # Set initial options, merging given options with the defaults\n for k, v of defaultOptions\n @options[k] = if options[k]? then options[k] else v\n\n # Create the loading screen element\n @_loadingElem = document.createElement(\"div\")\n # Create an empty array to store the potential list of loading HTML (messages, spinners, etc)\n # we'll be displaying to the screen\n @_loadingHtmlToDisplay = []\n # Add a global class for easy styling\n @_loadingElem.className = \"pg-loading-screen\"\n # Set the background color of the loading screen, if supplied\n @_loadingElem.style.backgroundColor = @options.backgroundColor if @options.backgroundColor?\n # Initialize the loading screen's HTML with the defined template. The default can be overwritten via options\n @_loadingElem.innerHTML = @options.template\n # Find the element that will contain the loading HTML displayed to the user (typically a spinner/message)\n # This can be changed via updateLoadingHtml\n @_loadingHtmlElem = @_loadingElem.getElementsByClassName(\"pg-loading-html\")[0]\n # Set the initial loading HTML, if supplied\n @_loadingHtmlElem.innerHTML = @options.loadingHtml if @_loadingHtmlElem?\n # Set a flag that lets us know if the transitioning between loading HTML elements is finished.\n # If true, we can transition immediately to a new message/HTML\n @_readyToShowLoadingHtml = false\n # Find the element that displays the loading logo and set the src if supplied\n logoElem = @_loadingElem.getElementsByClassName(\"pg-loading-logo\")[0]\n logoElem.src = @options.logo if logoElem?\n # Add the loading screen to the body\n document.body.appendChild(@_loadingElem)\n # Add the CSS class that will trigger the initial transitions of the logo/loading HTML\n @_loadingElem.className += \" pg-loading\"\n # Define a listener to look for any new loading HTML that needs to be displayed after the intiial transition finishes\n listener = =>\n @_readyToShowLoadingHtml = true\n if transitionEvent? then @_loadingHtmlElem.removeEventListener(transitionEvent, listener)\n if @_loadingHtmlToDisplay.length > 0 then @_changeLoadingHtml()\n # Detect CSS animation support. If not found, we'll call the listener immediately. Otherwise, we'll wait\n if transitionEvent?\n @_loadingHtmlElem.addEventListener(transitionEvent, listener)\n else\n listener()\n```", "response": "({\n constructor: function(options) {\n var defaultOptions, k, listener, logoElem, v;\n defaultOptions = this.constructor._defaultOptions;\n this.options = {};\n// Set initial options, merging given options with the defaults\n for (k in defaultOptions) {\n v = defaultOptions[k];\n this.options[k] = options[k] != null ? options[k] : v;\n }\n // Create the loading screen element\n this._loadingElem = document.createElement(\"div\");\n // Create an empty array to store the potential list of loading HTML (messages, spinners, etc)\n // we'll be displaying to the screen\n this._loadingHtmlToDisplay = [];\n // Add a global class for easy styling\n this._loadingElem.className = \"pg-loading-screen\";\n if (this.options.backgroundColor != null) {\n // Set the background color of the loading screen, if supplied\n this._loadingElem.style.backgroundColor = this.options.backgroundColor;\n }\n // Initialize the loading screen's HTML with the defined template. The default can be overwritten via options\n this._loadingElem.innerHTML = this.options.template;\n // Find the element that will contain the loading HTML displayed to the user (typically a spinner/message)\n // This can be changed via updateLoadingHtml\n this._loadingHtmlElem = this._loadingElem.getElementsByClassName(\"pg-loading-html\")[0];\n if (this._loadingHtmlElem != null) {\n // Set the initial loading HTML, if supplied\n this._loadingHtmlElem.innerHTML = this.options.loadingHtml;\n }\n // Set a flag that lets us know if the transitioning between loading HTML elements is finished.\n // If true, we can transition immediately to a new message/HTML\n this._readyToShowLoadingHtml = false;\n // Find the element that displays the loading logo and set the src if supplied\n logoElem = this._loadingElem.getElementsByClassName(\"pg-loading-logo\")[0];\n if (logoElem != null) {\n logoElem.src = this.options.logo;\n }\n // Add the loading screen to the body\n document.body.appendChild(this._loadingElem);\n // Add the CSS class that will trigger the initial transitions of the logo/loading HTML\n this._loadingElem.className += \" pg-loading\";\n // Define a listener to look for any new loading HTML that needs to be displayed after the intiial transition finishes\n listener = () => {\n this._readyToShowLoadingHtml = true;\n if (typeof transitionEvent !== \"undefined\" && transitionEvent !== null) {\n this._loadingHtmlElem.removeEventListener(transitionEvent, listener);\n }\n if (this._loadingHtmlToDisplay.length > 0) {\n return this._changeLoadingHtml();\n }\n };\n // Detect CSS animation support. If not found, we'll call the listener immediately. Otherwise, we'll wait\n if (typeof transitionEvent !== \"undefined\" && transitionEvent !== null) {\n return this._loadingHtmlElem.addEventListener(transitionEvent, listener);\n } else {\n return listener();\n }\n }\n});", "source_lang": "CoffeeScript", "target_lang": "JavaScript", "repo": "Pathgather/please-wait", "path": "src/please-wait.coffee", "license": "MIT", "commit": "a619fde4ea75ea695b1546a302e220ed065d5ff0", "stars": 1583, "source_url": "https://github.com/Pathgather/please-wait/blob/a619fde4ea75ea695b1546a302e220ed065d5ff0/src/please-wait.coffee", "line_start": 46, "line_end": 89}591{"id": "Pathgather/please-wait:src/please-wait.coffee:2:js_to_coffee", "type": "js_to_coffee", "prompt": "Convert this JavaScript to CoffeeScript.\n```javascript\n({\n constructor: function(options) {\n var defaultOptions, k, listener, logoElem, v;\n defaultOptions = this.constructor._defaultOptions;\n this.options = {};\n// Set initial options, merging given options with the defaults\n for (k in defaultOptions) {\n v = defaultOptions[k];\n this.options[k] = options[k] != null ? options[k] : v;\n }\n // Create the loading screen element\n this._loadingElem = document.createElement(\"div\");\n // Create an empty array to store the potential list of loading HTML (messages, spinners, etc)\n // we'll be displaying to the screen\n this._loadingHtmlToDisplay = [];\n // Add a global class for easy styling\n this._loadingElem.className = \"pg-loading-screen\";\n if (this.options.backgroundColor != null) {\n // Set the background color of the loading screen, if supplied\n this._loadingElem.style.backgroundColor = this.options.backgroundColor;\n }\n // Initialize the loading screen's HTML with the defined template. The default can be overwritten via options\n this._loadingElem.innerHTML = this.options.template;\n // Find the element that will contain the loading HTML displayed to the user (typically a spinner/message)\n // This can be changed via updateLoadingHtml\n this._loadingHtmlElem = this._loadingElem.getElementsByClassName(\"pg-loading-html\")[0];\n if (this._loadingHtmlElem != null) {\n // Set the initial loading HTML, if supplied\n this._loadingHtmlElem.innerHTML = this.options.loadingHtml;\n }\n // Set a flag that lets us know if the transitioning between loading HTML elements is finished.\n // If true, we can transition immediately to a new message/HTML\n this._readyToShowLoadingHtml = false;\n // Find the element that displays the loading logo and set the src if supplied\n logoElem = this._loadingElem.getElementsByClassName(\"pg-loading-logo\")[0];\n if (logoElem != null) {\n logoElem.src = this.options.logo;\n }\n // Add the loading screen to the body\n document.body.appendChild(this._loadingElem);\n // Add the CSS class that will trigger the initial transitions of the logo/loading HTML\n this._loadingElem.className += \" pg-loading\";\n // Define a listener to look for any new loading HTML that needs to be displayed after the intiial transition finishes\n listener = () => {\n this._readyToShowLoadingHtml = true;\n if (typeof transitionEvent !== \"undefined\" && transitionEvent !== null) {\n this._loadingHtmlElem.removeEventListener(transitionEvent, listener);\n }\n if (this._loadingHtmlToDisplay.length > 0) {\n return this._changeLoadingHtml();\n }\n };\n // Detect CSS animation support. If not found, we'll call the listener immediately. Otherwise, we'll wait\n if (typeof transitionEvent !== \"undefined\" && transitionEvent !== null) {\n return this._loadingHtmlElem.addEventListener(transitionEvent, listener);\n } else {\n return listener();\n }\n }\n});\n```", "response": "constructor: (options) ->\n defaultOptions = @constructor._defaultOptions\n @options = {}\n\n # Set initial options, merging given options with the defaults\n for k, v of defaultOptions\n @options[k] = if options[k]? then options[k] else v\n\n # Create the loading screen element\n @_loadingElem = document.createElement(\"div\")\n # Create an empty array to store the potential list of loading HTML (messages, spinners, etc)\n # we'll be displaying to the screen\n @_loadingHtmlToDisplay = []\n # Add a global class for easy styling\n @_loadingElem.className = \"pg-loading-screen\"\n # Set the background color of the loading screen, if supplied\n @_loadingElem.style.backgroundColor = @options.backgroundColor if @options.backgroundColor?\n # Initialize the loading screen's HTML with the defined template. The default can be overwritten via options\n @_loadingElem.innerHTML = @options.template\n # Find the element that will contain the loading HTML displayed to the user (typically a spinner/message)\n # This can be changed via updateLoadingHtml\n @_loadingHtmlElem = @_loadingElem.getElementsByClassName(\"pg-loading-html\")[0]\n # Set the initial loading HTML, if supplied\n @_loadingHtmlElem.innerHTML = @options.loadingHtml if @_loadingHtmlElem?\n # Set a flag that lets us know if the transitioning between loading HTML elements is finished.\n # If true, we can transition immediately to a new message/HTML\n @_readyToShowLoadingHtml = false\n # Find the element that displays the loading logo and set the src if supplied\n logoElem = @_loadingElem.getElementsByClassName(\"pg-loading-logo\")[0]\n logoElem.src = @options.logo if logoElem?\n # Add the loading screen to the body\n document.body.appendChild(@_loadingElem)\n # Add the CSS class that will trigger the initial transitions of the logo/loading HTML\n @_loadingElem.className += \" pg-loading\"\n # Define a listener to look for any new loading HTML that needs to be displayed after the intiial transition finishes\n listener = =>\n @_readyToShowLoadingHtml = true\n if transitionEvent? then @_loadingHtmlElem.removeEventListener(transitionEvent, listener)\n if @_loadingHtmlToDisplay.length > 0 then @_changeLoadingHtml()\n # Detect CSS animation support. If not found, we'll call the listener immediately. Otherwise, we'll wait\n if transitionEvent?\n @_loadingHtmlElem.addEventListener(transitionEvent, listener)\n else\n listener()", "source_lang": "JavaScript", "target_lang": "CoffeeScript", "repo": "Pathgather/please-wait", "path": "src/please-wait.coffee", "license": "MIT", "commit": "a619fde4ea75ea695b1546a302e220ed065d5ff0", "stars": 1583, "source_url": "https://github.com/Pathgather/please-wait/blob/a619fde4ea75ea695b1546a302e220ed065d5ff0/src/please-wait.coffee", "line_start": 46, "line_end": 89}592{"id": "Pathgather/please-wait:src/please-wait.coffee:2:completion", "type": "completion", "prompt": "constructor: (options) ->\n defaultOptions = @constructor._defaultOptions\n @options = {}\n\n # Set initial options, merging given options with the defaults\n for k, v of defaultOptions\n @options[k] = if options[k]? then options[k] else v\n\n # Create the loading screen element\n @_loadingElem = document.createElement(\"div\")\n # Create an empty array to store the potential list of loading HTML (messages, spinners, etc)\n # we'll be displaying to the screen\n @_loadingHtmlToDisplay = []\n # Add a global class for easy styling\n @_loadingElem.className = \"pg-loading-screen\"\n # Set the background color of the loading screen, if supplied\n @_loadingElem.style.backgroundColor = @options.backgroundColor if @options.backgroundColor?\n # Initialize the loading screen's HTML with the defined template. The default can be overwritten via options\n @_loadingElem.innerHTML = @options.template\n # Find the element that will contain the loading HTML displayed to the user (typically a spinner/message)\n # This can be changed via updateLoadingHtml\n @_loadingHtmlElem = @_loadingElem.getElementsByClassName(\"pg-loading-html\")[0]", "response": "# Set the initial loading HTML, if supplied\n @_loadingHtmlElem.innerHTML = @options.loadingHtml if @_loadingHtmlElem?\n # Set a flag that lets us know if the transitioning between loading HTML elements is finished.\n # If true, we can transition immediately to a new message/HTML\n @_readyToShowLoadingHtml = false\n # Find the element that displays the loading logo and set the src if supplied\n logoElem = @_loadingElem.getElementsByClassName(\"pg-loading-logo\")[0]\n logoElem.src = @options.logo if logoElem?\n # Add the loading screen to the body\n document.body.appendChild(@_loadingElem)\n # Add the CSS class that will trigger the initial transitions of the logo/loading HTML\n @_loadingElem.className += \" pg-loading\"\n # Define a listener to look for any new loading HTML that needs to be displayed after the intiial transition finishes\n listener = =>\n @_readyToShowLoadingHtml = true\n if transitionEvent? then @_loadingHtmlElem.removeEventListener(transitionEvent, listener)\n if @_loadingHtmlToDisplay.length > 0 then @_changeLoadingHtml()\n # Detect CSS animation support. If not found, we'll call the listener immediately. Otherwise, we'll wait\n if transitionEvent?\n @_loadingHtmlElem.addEventListener(transitionEvent, listener)\n else\n listener()", "source_lang": "CoffeeScript", "target_lang": "CoffeeScript", "repo": "Pathgather/please-wait", "path": "src/please-wait.coffee", "license": "MIT", "commit": "a619fde4ea75ea695b1546a302e220ed065d5ff0", "stars": 1583, "source_url": "https://github.com/Pathgather/please-wait/blob/a619fde4ea75ea695b1546a302e220ed065d5ff0/src/please-wait.coffee", "line_start": 46, "line_end": 89}593{"id": "Pathgather/please-wait:src/please-wait.coffee:3:raw_corpus", "type": "raw_corpus", "prompt": "", "response": "finish: ->\n return unless @_loadingElem?\n # Again, define a listener to run once the loading screen has fully transitioned out\n listener = =>\n # Remove the loading screen from the body\n document.body.removeChild(@_loadingElem)\n # Add a class to the body to signal that the loading screen has finished and the app is ready\n document.body.className += \" pg-loaded\"\n if transitionEvent? then @_loadingElem.removeEventListener(transitionEvent, listener)\n # Reset the loading screen element since it's no longer attached to the DOM\n @_loadingElem = null\n\n # Detect CSS animation support. If not found, we'll call the listener immediately. Otherwise, we'll wait\n if transitionEvent?\n # Set a class on the loading screen to trigger a fadeout animation\n @_loadingElem.className += \" pg-loaded\"\n # When the loading screen is finished fading out, we'll remove it from the DOM\n @_loadingElem.addEventListener(transitionEvent, listener)\n else\n listener()\n\n updateLoadingHtml: (loadingHtml, immediately=false) ->\n if immediately\n # Ignore any loading HTML that may be queued up. Show this immediately\n @_loadingHtmlToDisplay = [loadingHtml]\n @_readyToShowLoadingHtml = true\n else\n # Add to an array of HTML to display to the user\n @_loadingHtmlToDisplay.push(loadingHtml)\n # If ready, let's display the new loading HTML\n if @_readyToShowLoadingHtml then @_changeLoadingHtml()\n\n _changeLoadingHtml: ->\n @_readyToShowLoadingHtml = false\n\n loadingListener = =>\n # New loading HTML has fully transitioned in. We're now ready to show a new message/HTML\n @_readyToShowLoadingHtml = true\n # Remove the CSS class that triggered the fade in animation\n @_loadingHtmlElem.className = @_loadingHtmlElem.className.replace(\" pg-loading \", \"\")\n if transitionEvent? then @_loadingHtmlElem.removeEventListener(transitionEvent, loadingListener)\n # Check if there's still HTML left in the queue to display. If so, let's show it\n if @_loadingHtmlToDisplay.length > 0 then @_changeLoadingHtml()", "source_lang": "", "target_lang": "CoffeeScript", "repo": "Pathgather/please-wait", "path": "src/please-wait.coffee", "license": "MIT", "commit": "a619fde4ea75ea695b1546a302e220ed065d5ff0", "stars": 1583, "source_url": "https://github.com/Pathgather/please-wait/blob/a619fde4ea75ea695b1546a302e220ed065d5ff0/src/please-wait.coffee", "line_start": 91, "line_end": 133}594{"id": "Pathgather/please-wait:src/please-wait.coffee:3:coffee_to_js", "type": "coffee_to_js", "prompt": "Convert this CoffeeScript to JavaScript.\n```coffeescript\nfinish: ->\n return unless @_loadingElem?\n # Again, define a listener to run once the loading screen has fully transitioned out\n listener = =>\n # Remove the loading screen from the body\n document.body.removeChild(@_loadingElem)\n # Add a class to the body to signal that the loading screen has finished and the app is ready\n document.body.className += \" pg-loaded\"\n if transitionEvent? then @_loadingElem.removeEventListener(transitionEvent, listener)\n # Reset the loading screen element since it's no longer attached to the DOM\n @_loadingElem = null\n\n # Detect CSS animation support. If not found, we'll call the listener immediately. Otherwise, we'll wait\n if transitionEvent?\n # Set a class on the loading screen to trigger a fadeout animation\n @_loadingElem.className += \" pg-loaded\"\n # When the loading screen is finished fading out, we'll remove it from the DOM\n @_loadingElem.addEventListener(transitionEvent, listener)\n else\n listener()\n\n updateLoadingHtml: (loadingHtml, immediately=false) ->\n if immediately\n # Ignore any loading HTML that may be queued up. Show this immediately\n @_loadingHtmlToDisplay = [loadingHtml]\n @_readyToShowLoadingHtml = true\n else\n # Add to an array of HTML to display to the user\n @_loadingHtmlToDisplay.push(loadingHtml)\n # If ready, let's display the new loading HTML\n if @_readyToShowLoadingHtml then @_changeLoadingHtml()\n\n _changeLoadingHtml: ->\n @_readyToShowLoadingHtml = false\n\n loadingListener = =>\n # New loading HTML has fully transitioned in. We're now ready to show a new message/HTML\n @_readyToShowLoadingHtml = true\n # Remove the CSS class that triggered the fade in animation\n @_loadingHtmlElem.className = @_loadingHtmlElem.className.replace(\" pg-loading \", \"\")\n if transitionEvent? then @_loadingHtmlElem.removeEventListener(transitionEvent, loadingListener)\n # Check if there's still HTML left in the queue to display. If so, let's show it\n if @_loadingHtmlToDisplay.length > 0 then @_changeLoadingHtml()\n```", "response": "({\n finish: function() {\n var listener;\n if (this._loadingElem == null) {\n return;\n }\n // Again, define a listener to run once the loading screen has fully transitioned out\n listener = () => {\n // Remove the loading screen from the body\n document.body.removeChild(this._loadingElem);\n // Add a class to the body to signal that the loading screen has finished and the app is ready\n document.body.className += \" pg-loaded\";\n if (typeof transitionEvent !== \"undefined\" && transitionEvent !== null) {\n this._loadingElem.removeEventListener(transitionEvent, listener);\n }\n // Reset the loading screen element since it's no longer attached to the DOM\n return this._loadingElem = null;\n };\n // Detect CSS animation support. If not found, we'll call the listener immediately. Otherwise, we'll wait\n if (typeof transitionEvent !== \"undefined\" && transitionEvent !== null) {\n // Set a class on the loading screen to trigger a fadeout animation\n this._loadingElem.className += \" pg-loaded\";\n // When the loading screen is finished fading out, we'll remove it from the DOM\n return this._loadingElem.addEventListener(transitionEvent, listener);\n } else {\n return listener();\n }\n },\n updateLoadingHtml: function(loadingHtml, immediately = false) {\n if (immediately) {\n // Ignore any loading HTML that may be queued up. Show this immediately\n this._loadingHtmlToDisplay = [loadingHtml];\n this._readyToShowLoadingHtml = true;\n } else {\n // Add to an array of HTML to display to the user\n this._loadingHtmlToDisplay.push(loadingHtml);\n }\n // If ready, let's display the new loading HTML\n if (this._readyToShowLoadingHtml) {\n return this._changeLoadingHtml();\n }\n },\n _changeLoadingHtml: function() {\n var loadingListener;\n this._readyToShowLoadingHtml = false;\n return loadingListener = () => {\n // New loading HTML has fully transitioned in. We're now ready to show a new message/HTML\n this._readyToShowLoadingHtml = true;\n // Remove the CSS class that triggered the fade in animation\n this._loadingHtmlElem.className = this._loadingHtmlElem.className.replace(\" pg-loading \", \"\");\n if (typeof transitionEvent !== \"undefined\" && transitionEvent !== null) {\n this._loadingHtmlElem.removeEventListener(transitionEvent, loadingListener);\n }\n // Check if there's still HTML left in the queue to display. If so, let's show it\n if (this._loadingHtmlToDisplay.length > 0) {\n return this._changeLoadingHtml();\n }\n };\n }\n});", "source_lang": "CoffeeScript", "target_lang": "JavaScript", "repo": "Pathgather/please-wait", "path": "src/please-wait.coffee", "license": "MIT", "commit": "a619fde4ea75ea695b1546a302e220ed065d5ff0", "stars": 1583, "source_url": "https://github.com/Pathgather/please-wait/blob/a619fde4ea75ea695b1546a302e220ed065d5ff0/src/please-wait.coffee", "line_start": 91, "line_end": 133}595{"id": "Pathgather/please-wait:src/please-wait.coffee:3:js_to_coffee", "type": "js_to_coffee", "prompt": "Convert this JavaScript to CoffeeScript.\n```javascript\n({\n finish: function() {\n var listener;\n if (this._loadingElem == null) {\n return;\n }\n // Again, define a listener to run once the loading screen has fully transitioned out\n listener = () => {\n // Remove the loading screen from the body\n document.body.removeChild(this._loadingElem);\n // Add a class to the body to signal that the loading screen has finished and the app is ready\n document.body.className += \" pg-loaded\";\n if (typeof transitionEvent !== \"undefined\" && transitionEvent !== null) {\n this._loadingElem.removeEventListener(transitionEvent, listener);\n }\n // Reset the loading screen element since it's no longer attached to the DOM\n return this._loadingElem = null;\n };\n // Detect CSS animation support. If not found, we'll call the listener immediately. Otherwise, we'll wait\n if (typeof transitionEvent !== \"undefined\" && transitionEvent !== null) {\n // Set a class on the loading screen to trigger a fadeout animation\n this._loadingElem.className += \" pg-loaded\";\n // When the loading screen is finished fading out, we'll remove it from the DOM\n return this._loadingElem.addEventListener(transitionEvent, listener);\n } else {\n return listener();\n }\n },\n updateLoadingHtml: function(loadingHtml, immediately = false) {\n if (immediately) {\n // Ignore any loading HTML that may be queued up. Show this immediately\n this._loadingHtmlToDisplay = [loadingHtml];\n this._readyToShowLoadingHtml = true;\n } else {\n // Add to an array of HTML to display to the user\n this._loadingHtmlToDisplay.push(loadingHtml);\n }\n // If ready, let's display the new loading HTML\n if (this._readyToShowLoadingHtml) {\n return this._changeLoadingHtml();\n }\n },\n _changeLoadingHtml: function() {\n var loadingListener;\n this._readyToShowLoadingHtml = false;\n return loadingListener = () => {\n // New loading HTML has fully transitioned in. We're now ready to show a new message/HTML\n this._readyToShowLoadingHtml = true;\n // Remove the CSS class that triggered the fade in animation\n this._loadingHtmlElem.className = this._loadingHtmlElem.className.replace(\" pg-loading \", \"\");\n if (typeof transitionEvent !== \"undefined\" && transitionEvent !== null) {\n this._loadingHtmlElem.removeEventListener(transitionEvent, loadingListener);\n }\n // Check if there's still HTML left in the queue to display. If so, let's show it\n if (this._loadingHtmlToDisplay.length > 0) {\n return this._changeLoadingHtml();\n }\n };\n }\n});\n```", "response": "finish: ->\n return unless @_loadingElem?\n # Again, define a listener to run once the loading screen has fully transitioned out\n listener = =>\n # Remove the loading screen from the body\n document.body.removeChild(@_loadingElem)\n # Add a class to the body to signal that the loading screen has finished and the app is ready\n document.body.className += \" pg-loaded\"\n if transitionEvent? then @_loadingElem.removeEventListener(transitionEvent, listener)\n # Reset the loading screen element since it's no longer attached to the DOM\n @_loadingElem = null\n\n # Detect CSS animation support. If not found, we'll call the listener immediately. Otherwise, we'll wait\n if transitionEvent?\n # Set a class on the loading screen to trigger a fadeout animation\n @_loadingElem.className += \" pg-loaded\"\n # When the loading screen is finished fading out, we'll remove it from the DOM\n @_loadingElem.addEventListener(transitionEvent, listener)\n else\n listener()\n\n updateLoadingHtml: (loadingHtml, immediately=false) ->\n if immediately\n # Ignore any loading HTML that may be queued up. Show this immediately\n @_loadingHtmlToDisplay = [loadingHtml]\n @_readyToShowLoadingHtml = true\n else\n # Add to an array of HTML to display to the user\n @_loadingHtmlToDisplay.push(loadingHtml)\n # If ready, let's display the new loading HTML\n if @_readyToShowLoadingHtml then @_changeLoadingHtml()\n\n _changeLoadingHtml: ->\n @_readyToShowLoadingHtml = false\n\n loadingListener = =>\n # New loading HTML has fully transitioned in. We're now ready to show a new message/HTML\n @_readyToShowLoadingHtml = true\n # Remove the CSS class that triggered the fade in animation\n @_loadingHtmlElem.className = @_loadingHtmlElem.className.replace(\" pg-loading \", \"\")\n if transitionEvent? then @_loadingHtmlElem.removeEventListener(transitionEvent, loadingListener)\n # Check if there's still HTML left in the queue to display. If so, let's show it\n if @_loadingHtmlToDisplay.length > 0 then @_changeLoadingHtml()", "source_lang": "JavaScript", "target_lang": "CoffeeScript", "repo": "Pathgather/please-wait", "path": "src/please-wait.coffee", "license": "MIT", "commit": "a619fde4ea75ea695b1546a302e220ed065d5ff0", "stars": 1583, "source_url": "https://github.com/Pathgather/please-wait/blob/a619fde4ea75ea695b1546a302e220ed065d5ff0/src/please-wait.coffee", "line_start": 91, "line_end": 133}596{"id": "Pathgather/please-wait:src/please-wait.coffee:3:completion", "type": "completion", "prompt": "finish: ->\n return unless @_loadingElem?\n # Again, define a listener to run once the loading screen has fully transitioned out\n listener = =>\n # Remove the loading screen from the body\n document.body.removeChild(@_loadingElem)\n # Add a class to the body to signal that the loading screen has finished and the app is ready\n document.body.className += \" pg-loaded\"\n if transitionEvent? then @_loadingElem.removeEventListener(transitionEvent, listener)\n # Reset the loading screen element since it's no longer attached to the DOM\n @_loadingElem = null\n\n # Detect CSS animation support. If not found, we'll call the listener immediately. Otherwise, we'll wait\n if transitionEvent?\n # Set a class on the loading screen to trigger a fadeout animation\n @_loadingElem.className += \" pg-loaded\"\n # When the loading screen is finished fading out, we'll remove it from the DOM\n @_loadingElem.addEventListener(transitionEvent, listener)\n else\n listener()", "response": "updateLoadingHtml: (loadingHtml, immediately=false) ->\n if immediately\n # Ignore any loading HTML that may be queued up. Show this immediately\n @_loadingHtmlToDisplay = [loadingHtml]\n @_readyToShowLoadingHtml = true\n else\n # Add to an array of HTML to display to the user\n @_loadingHtmlToDisplay.push(loadingHtml)\n # If ready, let's display the new loading HTML\n if @_readyToShowLoadingHtml then @_changeLoadingHtml()\n\n _changeLoadingHtml: ->\n @_readyToShowLoadingHtml = false\n\n loadingListener = =>\n # New loading HTML has fully transitioned in. We're now ready to show a new message/HTML\n @_readyToShowLoadingHtml = true\n # Remove the CSS class that triggered the fade in animation\n @_loadingHtmlElem.className = @_loadingHtmlElem.className.replace(\" pg-loading \", \"\")\n if transitionEvent? then @_loadingHtmlElem.removeEventListener(transitionEvent, loadingListener)\n # Check if there's still HTML left in the queue to display. If so, let's show it\n if @_loadingHtmlToDisplay.length > 0 then @_changeLoadingHtml()", "source_lang": "CoffeeScript", "target_lang": "CoffeeScript", "repo": "Pathgather/please-wait", "path": "src/please-wait.coffee", "license": "MIT", "commit": "a619fde4ea75ea695b1546a302e220ed065d5ff0", "stars": 1583, "source_url": "https://github.com/Pathgather/please-wait/blob/a619fde4ea75ea695b1546a302e220ed065d5ff0/src/please-wait.coffee", "line_start": 91, "line_end": 133}597{"id": "Pathgather/please-wait:src/please-wait.coffee:4:raw_corpus", "type": "raw_corpus", "prompt": "", "response": "removingListener = =>\n # Last loading HTML to display has fully transitioned out. Time to transition the new in\n @_loadingHtmlElem.innerHTML = @_loadingHtmlToDisplay.shift()\n # Add the CSS class to trigger the fade in animation\n @_loadingHtmlElem.className = @_loadingHtmlElem.className.replace(\" pg-removing \", \" pg-loading \")\n if transitionEvent?\n @_loadingHtmlElem.removeEventListener(transitionEvent, removingListener)\n @_loadingHtmlElem.addEventListener(transitionEvent, loadingListener)\n else\n loadingListener()\n\n if transitionEvent?\n # Add the CSS class that will cause the HTML to fade out\n @_loadingHtmlElem.className += \" pg-removing \"\n @_loadingHtmlElem.addEventListener(transitionEvent, removingListener)\n else\n removingListener()\n\n pleaseWait = (options = {}) ->\n new PleaseWait(options)\n\n exports.pleaseWait = pleaseWait\n return pleaseWait", "source_lang": "", "target_lang": "CoffeeScript", "repo": "Pathgather/please-wait", "path": "src/please-wait.coffee", "license": "MIT", "commit": "a619fde4ea75ea695b1546a302e220ed065d5ff0", "stars": 1583, "source_url": "https://github.com/Pathgather/please-wait/blob/a619fde4ea75ea695b1546a302e220ed065d5ff0/src/please-wait.coffee", "line_start": 135, "line_end": 157}598{"id": "Pathgather/please-wait:src/please-wait.coffee:4:coffee_to_js", "type": "coffee_to_js", "prompt": "Convert this CoffeeScript to JavaScript.\n```coffeescript\nremovingListener = =>\n # Last loading HTML to display has fully transitioned out. Time to transition the new in\n @_loadingHtmlElem.innerHTML = @_loadingHtmlToDisplay.shift()\n # Add the CSS class to trigger the fade in animation\n @_loadingHtmlElem.className = @_loadingHtmlElem.className.replace(\" pg-removing \", \" pg-loading \")\n if transitionEvent?\n @_loadingHtmlElem.removeEventListener(transitionEvent, removingListener)\n @_loadingHtmlElem.addEventListener(transitionEvent, loadingListener)\n else\n loadingListener()\n\n if transitionEvent?\n # Add the CSS class that will cause the HTML to fade out\n @_loadingHtmlElem.className += \" pg-removing \"\n @_loadingHtmlElem.addEventListener(transitionEvent, removingListener)\n else\n removingListener()\n\n pleaseWait = (options = {}) ->\n new PleaseWait(options)\n\n exports.pleaseWait = pleaseWait\n return pleaseWait\n```", "response": "var pleaseWait, removingListener;\n\nremovingListener = () => {\n // Last loading HTML to display has fully transitioned out. Time to transition the new in\n this._loadingHtmlElem.innerHTML = this._loadingHtmlToDisplay.shift();\n // Add the CSS class to trigger the fade in animation\n this._loadingHtmlElem.className = this._loadingHtmlElem.className.replace(\" pg-removing \", \" pg-loading \");\n if (typeof transitionEvent !== \"undefined\" && transitionEvent !== null) {\n this._loadingHtmlElem.removeEventListener(transitionEvent, removingListener);\n return this._loadingHtmlElem.addEventListener(transitionEvent, loadingListener);\n } else {\n return loadingListener();\n }\n};\n\nif (typeof transitionEvent !== \"undefined\" && transitionEvent !== null) {\n // Add the CSS class that will cause the HTML to fade out\n this._loadingHtmlElem.className += \" pg-removing \";\n this._loadingHtmlElem.addEventListener(transitionEvent, removingListener);\n} else {\n removingListener();\n}\n\npleaseWait = function(options = {}) {\n return new PleaseWait(options);\n};\n\nexports.pleaseWait = pleaseWait;\n\nreturn pleaseWait;", "source_lang": "CoffeeScript", "target_lang": "JavaScript", "repo": "Pathgather/please-wait", "path": "src/please-wait.coffee", "license": "MIT", "commit": "a619fde4ea75ea695b1546a302e220ed065d5ff0", "stars": 1583, "source_url": "https://github.com/Pathgather/please-wait/blob/a619fde4ea75ea695b1546a302e220ed065d5ff0/src/please-wait.coffee", "line_start": 135, "line_end": 157}599{"id": "Pathgather/please-wait:src/please-wait.coffee:4:js_to_coffee", "type": "js_to_coffee", "prompt": "Convert this JavaScript to CoffeeScript.\n```javascript\nvar pleaseWait, removingListener;\n\nremovingListener = () => {\n // Last loading HTML to display has fully transitioned out. Time to transition the new in\n this._loadingHtmlElem.innerHTML = this._loadingHtmlToDisplay.shift();\n // Add the CSS class to trigger the fade in animation\n this._loadingHtmlElem.className = this._loadingHtmlElem.className.replace(\" pg-removing \", \" pg-loading \");\n if (typeof transitionEvent !== \"undefined\" && transitionEvent !== null) {\n this._loadingHtmlElem.removeEventListener(transitionEvent, removingListener);\n return this._loadingHtmlElem.addEventListener(transitionEvent, loadingListener);\n } else {\n return loadingListener();\n }\n};\n\nif (typeof transitionEvent !== \"undefined\" && transitionEvent !== null) {\n // Add the CSS class that will cause the HTML to fade out\n this._loadingHtmlElem.className += \" pg-removing \";\n this._loadingHtmlElem.addEventListener(transitionEvent, removingListener);\n} else {\n removingListener();\n}\n\npleaseWait = function(options = {}) {\n return new PleaseWait(options);\n};\n\nexports.pleaseWait = pleaseWait;\n\nreturn pleaseWait;\n```", "response": "removingListener = =>\n # Last loading HTML to display has fully transitioned out. Time to transition the new in\n @_loadingHtmlElem.innerHTML = @_loadingHtmlToDisplay.shift()\n # Add the CSS class to trigger the fade in animation\n @_loadingHtmlElem.className = @_loadingHtmlElem.className.replace(\" pg-removing \", \" pg-loading \")\n if transitionEvent?\n @_loadingHtmlElem.removeEventListener(transitionEvent, removingListener)\n @_loadingHtmlElem.addEventListener(transitionEvent, loadingListener)\n else\n loadingListener()\n\n if transitionEvent?\n # Add the CSS class that will cause the HTML to fade out\n @_loadingHtmlElem.className += \" pg-removing \"\n @_loadingHtmlElem.addEventListener(transitionEvent, removingListener)\n else\n removingListener()\n\n pleaseWait = (options = {}) ->\n new PleaseWait(options)\n\n exports.pleaseWait = pleaseWait\n return pleaseWait", "source_lang": "JavaScript", "target_lang": "CoffeeScript", "repo": "Pathgather/please-wait", "path": "src/please-wait.coffee", "license": "MIT", "commit": "a619fde4ea75ea695b1546a302e220ed065d5ff0", "stars": 1583, "source_url": "https://github.com/Pathgather/please-wait/blob/a619fde4ea75ea695b1546a302e220ed065d5ff0/src/please-wait.coffee", "line_start": 135, "line_end": 157}600{"id": "Pathgather/please-wait:src/please-wait.coffee:4:completion", "type": "completion", "prompt": "removingListener = =>\n # Last loading HTML to display has fully transitioned out. Time to transition the new in\n @_loadingHtmlElem.innerHTML = @_loadingHtmlToDisplay.shift()\n # Add the CSS class to trigger the fade in animation\n @_loadingHtmlElem.className = @_loadingHtmlElem.className.replace(\" pg-removing \", \" pg-loading \")\n if transitionEvent?\n @_loadingHtmlElem.removeEventListener(transitionEvent, removingListener)\n @_loadingHtmlElem.addEventListener(transitionEvent, loadingListener)\n else\n loadingListener()", "response": "if transitionEvent?\n # Add the CSS class that will cause the HTML to fade out\n @_loadingHtmlElem.className += \" pg-removing \"\n @_loadingHtmlElem.addEventListener(transitionEvent, removingListener)\n else\n removingListener()\n\n pleaseWait = (options = {}) ->\n new PleaseWait(options)\n\n exports.pleaseWait = pleaseWait\n return pleaseWait", "source_lang": "CoffeeScript", "target_lang": "CoffeeScript", "repo": "Pathgather/please-wait", "path": "src/please-wait.coffee", "license": "MIT", "commit": "a619fde4ea75ea695b1546a302e220ed065d5ff0", "stars": 1583, "source_url": "https://github.com/Pathgather/please-wait/blob/a619fde4ea75ea695b1546a302e220ed065d5ff0/src/please-wait.coffee", "line_start": 135, "line_end": 157}601{"id": "Pathgather/please-wait:src/please-wait.coffee:1:raw_corpus", "type": "raw_corpus", "prompt": "", "response": "((root, factory) ->\n if typeof exports is \"object\"\n # CommonJS\n factory exports\n else if typeof define is \"function\" and define.amd\n # AMD. Register as an anonymous module.\n define [\"exports\"], factory\n else\n # Browser globals\n factory root\n return\n) this, (exports) ->\n PleaseWait = ->\n getTransitionEvent = ->\n el = document.createElement('fakeelement')\n transitions =\n 'WebkitAnimation': 'webkitAnimationEnd',\n 'OAnimation': 'oAnimationEnd',\n 'msAnimation': 'MSAnimationEnd',\n 'MozAnimation': 'mozAnimationEnd'\n 'animation' : 'animationend'\n\n for key, val of transitions\n return val if el.style[key]?\n\n transitionEvent = getTransitionEvent()\n\n _pleaseWait =\n defaultOptions:\n backgroundColor: null\n logo: null\n loadingHtml: null\n template: \"\"\"\n <div class='pg-loading-inner'>\n <div class='pg-loading-center-outer'>\n <div class='pg-loading-center-middle'>\n <h1 class='pg-loading-logo-header'>\n <img class='pg-loading-logo'></img>\n </h1>\n <div class='pg-loading-html'>\n </div>\n </div>\n </div>\n </div>\n \"\"\"", "source_lang": "", "target_lang": "CoffeeScript", "repo": "Pathgather/please-wait", "path": "src/please-wait.coffee", "license": "MIT", "commit": "2a936837089956ff8350e421f9604ece2ebafd78", "stars": 1583, "source_url": "https://github.com/Pathgather/please-wait/blob/2a936837089956ff8350e421f9604ece2ebafd78/src/please-wait.coffee", "line_start": 1, "line_end": 45}602{"id": "Pathgather/please-wait:src/please-wait.coffee:1:coffee_to_js", "type": "coffee_to_js", "prompt": "Convert this CoffeeScript to JavaScript.\n```coffeescript\n((root, factory) ->\n if typeof exports is \"object\"\n # CommonJS\n factory exports\n else if typeof define is \"function\" and define.amd\n # AMD. Register as an anonymous module.\n define [\"exports\"], factory\n else\n # Browser globals\n factory root\n return\n) this, (exports) ->\n PleaseWait = ->\n getTransitionEvent = ->\n el = document.createElement('fakeelement')\n transitions =\n 'WebkitAnimation': 'webkitAnimationEnd',\n 'OAnimation': 'oAnimationEnd',\n 'msAnimation': 'MSAnimationEnd',\n 'MozAnimation': 'mozAnimationEnd'\n 'animation' : 'animationend'\n\n for key, val of transitions\n return val if el.style[key]?\n\n transitionEvent = getTransitionEvent()\n\n _pleaseWait =\n defaultOptions:\n backgroundColor: null\n logo: null\n loadingHtml: null\n template: \"\"\"\n <div class='pg-loading-inner'>\n <div class='pg-loading-center-outer'>\n <div class='pg-loading-center-middle'>\n <h1 class='pg-loading-logo-header'>\n <img class='pg-loading-logo'></img>\n </h1>\n <div class='pg-loading-html'>\n </div>\n </div>\n </div>\n </div>\n \"\"\"\n```", "response": "(function(root, factory) {\n if (typeof exports === \"object\") {\n // CommonJS\n factory(exports);\n } else if (typeof define === \"function\" && define.amd) {\n // AMD. Register as an anonymous module.\n define([\"exports\"], factory);\n } else {\n // Browser globals\n factory(root);\n }\n})(this, function(exports) {\n var PleaseWait;\n return PleaseWait = function() {\n var _pleaseWait, getTransitionEvent, transitionEvent;\n getTransitionEvent = function() {\n var el, key, transitions, val;\n el = document.createElement('fakeelement');\n transitions = {\n 'WebkitAnimation': 'webkitAnimationEnd',\n 'OAnimation': 'oAnimationEnd',\n 'msAnimation': 'MSAnimationEnd',\n 'MozAnimation': 'mozAnimationEnd',\n 'animation': 'animationend'\n };\n for (key in transitions) {\n val = transitions[key];\n if (el.style[key] != null) {\n return val;\n }\n }\n };\n transitionEvent = getTransitionEvent();\n return _pleaseWait = {\n defaultOptions: {\n backgroundColor: null,\n logo: null,\n loadingHtml: null,\n template: `<div class='pg-loading-inner'>\n <div class='pg-loading-center-outer'>\n <div class='pg-loading-center-middle'>\n <h1 class='pg-loading-logo-header'>\n <img class='pg-loading-logo'></img>\n </h1>\n <div class='pg-loading-html'>\n </div>\n </div>\n </div>\n</div>`\n }\n };\n };\n});", "source_lang": "CoffeeScript", "target_lang": "JavaScript", "repo": "Pathgather/please-wait", "path": "src/please-wait.coffee", "license": "MIT", "commit": "2a936837089956ff8350e421f9604ece2ebafd78", "stars": 1583, "source_url": "https://github.com/Pathgather/please-wait/blob/2a936837089956ff8350e421f9604ece2ebafd78/src/please-wait.coffee", "line_start": 1, "line_end": 45}603{"id": "Pathgather/please-wait:src/please-wait.coffee:1:js_to_coffee", "type": "js_to_coffee", "prompt": "Convert this JavaScript to CoffeeScript.\n```javascript\n(function(root, factory) {\n if (typeof exports === \"object\") {\n // CommonJS\n factory(exports);\n } else if (typeof define === \"function\" && define.amd) {\n // AMD. Register as an anonymous module.\n define([\"exports\"], factory);\n } else {\n // Browser globals\n factory(root);\n }\n})(this, function(exports) {\n var PleaseWait;\n return PleaseWait = function() {\n var _pleaseWait, getTransitionEvent, transitionEvent;\n getTransitionEvent = function() {\n var el, key, transitions, val;\n el = document.createElement('fakeelement');\n transitions = {\n 'WebkitAnimation': 'webkitAnimationEnd',\n 'OAnimation': 'oAnimationEnd',\n 'msAnimation': 'MSAnimationEnd',\n 'MozAnimation': 'mozAnimationEnd',\n 'animation': 'animationend'\n };\n for (key in transitions) {\n val = transitions[key];\n if (el.style[key] != null) {\n return val;\n }\n }\n };\n transitionEvent = getTransitionEvent();\n return _pleaseWait = {\n defaultOptions: {\n backgroundColor: null,\n logo: null,\n loadingHtml: null,\n template: `<div class='pg-loading-inner'>\n <div class='pg-loading-center-outer'>\n <div class='pg-loading-center-middle'>\n <h1 class='pg-loading-logo-header'>\n <img class='pg-loading-logo'></img>\n </h1>\n <div class='pg-loading-html'>\n </div>\n </div>\n </div>\n</div>`\n }\n };\n };\n});\n```", "response": "((root, factory) ->\n if typeof exports is \"object\"\n # CommonJS\n factory exports\n else if typeof define is \"function\" and define.amd\n # AMD. Register as an anonymous module.\n define [\"exports\"], factory\n else\n # Browser globals\n factory root\n return\n) this, (exports) ->\n PleaseWait = ->\n getTransitionEvent = ->\n el = document.createElement('fakeelement')\n transitions =\n 'WebkitAnimation': 'webkitAnimationEnd',\n 'OAnimation': 'oAnimationEnd',\n 'msAnimation': 'MSAnimationEnd',\n 'MozAnimation': 'mozAnimationEnd'\n 'animation' : 'animationend'\n\n for key, val of transitions\n return val if el.style[key]?\n\n transitionEvent = getTransitionEvent()\n\n _pleaseWait =\n defaultOptions:\n backgroundColor: null\n logo: null\n loadingHtml: null\n template: \"\"\"\n <div class='pg-loading-inner'>\n <div class='pg-loading-center-outer'>\n <div class='pg-loading-center-middle'>\n <h1 class='pg-loading-logo-header'>\n <img class='pg-loading-logo'></img>\n </h1>\n <div class='pg-loading-html'>\n </div>\n </div>\n </div>\n </div>\n \"\"\"", "source_lang": "JavaScript", "target_lang": "CoffeeScript", "repo": "Pathgather/please-wait", "path": "src/please-wait.coffee", "license": "MIT", "commit": "2a936837089956ff8350e421f9604ece2ebafd78", "stars": 1583, "source_url": "https://github.com/Pathgather/please-wait/blob/2a936837089956ff8350e421f9604ece2ebafd78/src/please-wait.coffee", "line_start": 1, "line_end": 45}604{"id": "Pathgather/please-wait:src/please-wait.coffee:1:completion", "type": "completion", "prompt": "((root, factory) ->\n if typeof exports is \"object\"\n # CommonJS\n factory exports\n else if typeof define is \"function\" and define.amd\n # AMD. Register as an anonymous module.\n define [\"exports\"], factory\n else\n # Browser globals\n factory root\n return\n) this, (exports) ->\n PleaseWait = ->\n getTransitionEvent = ->\n el = document.createElement('fakeelement')\n transitions =\n 'WebkitAnimation': 'webkitAnimationEnd',\n 'OAnimation': 'oAnimationEnd',\n 'msAnimation': 'MSAnimationEnd',\n 'MozAnimation': 'mozAnimationEnd'\n 'animation' : 'animationend'", "response": "for key, val of transitions\n return val if el.style[key]?\n\n transitionEvent = getTransitionEvent()\n\n _pleaseWait =\n defaultOptions:\n backgroundColor: null\n logo: null\n loadingHtml: null\n template: \"\"\"\n <div class='pg-loading-inner'>\n <div class='pg-loading-center-outer'>\n <div class='pg-loading-center-middle'>\n <h1 class='pg-loading-logo-header'>\n <img class='pg-loading-logo'></img>\n </h1>\n <div class='pg-loading-html'>\n </div>\n </div>\n </div>\n </div>\n \"\"\"", "source_lang": "CoffeeScript", "target_lang": "CoffeeScript", "repo": "Pathgather/please-wait", "path": "src/please-wait.coffee", "license": "MIT", "commit": "2a936837089956ff8350e421f9604ece2ebafd78", "stars": 1583, "source_url": "https://github.com/Pathgather/please-wait/blob/2a936837089956ff8350e421f9604ece2ebafd78/src/please-wait.coffee", "line_start": 1, "line_end": 45}605{"id": "Pathgather/please-wait:src/please-wait.coffee:2:raw_corpus", "type": "raw_corpus", "prompt": "", "response": "done: ->\n return unless @_loadingDiv?\n listener = =>\n document.body.removeChild(@_loadingDiv)\n document.body.className += \" pg-loaded\"\n if transitionEvent? then @_loadingDiv.removeEventListener(transitionEvent, listener)\n @_loadingDiv = null\n\n if transitionEvent?\n @_loadingDiv.className += \" pg-loaded\"\n @_loadingDiv.addEventListener(transitionEvent, listener)\n else\n listener()\n\n updateLoadingHtml: (loadingHtml, immediately=false) ->\n if immediately\n @_loadingHtmlToDisplay = [loadingHtml]\n @_readyToShowLoadingHtml = true\n else\n @_loadingHtmlToDisplay.push(loadingHtml)\n\n if @_readyToShowLoadingHtml then @_changeLoadingHtml()\n\n load: (options = {}) ->\n options = @_createOptions(options)\n @_loadingDiv ||= document.createElement(\"header\")\n @_loadingHtmlToDisplay = []\n @_loadingDiv.className = \"pg-loading-screen\"\n @_loadingDiv.style.backgroundColor = options.backgroundColor if options.backgroundColor?\n @_loadingDiv.innerHTML = options.template\n @_loadingHtml = @_loadingDiv.getElementsByClassName(\"pg-loading-html\")[0]\n @_loadingHtml.innerHTML = options.loadingHtml if @_loadingHtml?\n @_readyToShowLoadingHtml = false\n logo = @_loadingDiv.getElementsByClassName(\"pg-loading-logo\")[0]\n logo.src = options.logo if logo?\n\n document.body.appendChild(@_loadingDiv)\n @_loadingDiv.className += \" pg-loading\"\n\n listener = =>\n @_readyToShowLoadingHtml = true\n if transitionEvent? then @_loadingHtml.removeEventListener(transitionEvent, listener)\n if @_loadingHtmlToDisplay.length > 0 then @_changeLoadingHtml()", "source_lang": "", "target_lang": "CoffeeScript", "repo": "Pathgather/please-wait", "path": "src/please-wait.coffee", "license": "MIT", "commit": "2a936837089956ff8350e421f9604ece2ebafd78", "stars": 1583, "source_url": "https://github.com/Pathgather/please-wait/blob/2a936837089956ff8350e421f9604ece2ebafd78/src/please-wait.coffee", "line_start": 47, "line_end": 89}606{"id": "Pathgather/please-wait:src/please-wait.coffee:2:coffee_to_js", "type": "coffee_to_js", "prompt": "Convert this CoffeeScript to JavaScript.\n```coffeescript\ndone: ->\n return unless @_loadingDiv?\n listener = =>\n document.body.removeChild(@_loadingDiv)\n document.body.className += \" pg-loaded\"\n if transitionEvent? then @_loadingDiv.removeEventListener(transitionEvent, listener)\n @_loadingDiv = null\n\n if transitionEvent?\n @_loadingDiv.className += \" pg-loaded\"\n @_loadingDiv.addEventListener(transitionEvent, listener)\n else\n listener()\n\n updateLoadingHtml: (loadingHtml, immediately=false) ->\n if immediately\n @_loadingHtmlToDisplay = [loadingHtml]\n @_readyToShowLoadingHtml = true\n else\n @_loadingHtmlToDisplay.push(loadingHtml)\n\n if @_readyToShowLoadingHtml then @_changeLoadingHtml()\n\n load: (options = {}) ->\n options = @_createOptions(options)\n @_loadingDiv ||= document.createElement(\"header\")\n @_loadingHtmlToDisplay = []\n @_loadingDiv.className = \"pg-loading-screen\"\n @_loadingDiv.style.backgroundColor = options.backgroundColor if options.backgroundColor?\n @_loadingDiv.innerHTML = options.template\n @_loadingHtml = @_loadingDiv.getElementsByClassName(\"pg-loading-html\")[0]\n @_loadingHtml.innerHTML = options.loadingHtml if @_loadingHtml?\n @_readyToShowLoadingHtml = false\n logo = @_loadingDiv.getElementsByClassName(\"pg-loading-logo\")[0]\n logo.src = options.logo if logo?\n\n document.body.appendChild(@_loadingDiv)\n @_loadingDiv.className += \" pg-loading\"\n\n listener = =>\n @_readyToShowLoadingHtml = true\n if transitionEvent? then @_loadingHtml.removeEventListener(transitionEvent, listener)\n if @_loadingHtmlToDisplay.length > 0 then @_changeLoadingHtml()\n```", "response": "({\n done: function() {\n var listener;\n if (this._loadingDiv == null) {\n return;\n }\n listener = () => {\n document.body.removeChild(this._loadingDiv);\n document.body.className += \" pg-loaded\";\n if (typeof transitionEvent !== \"undefined\" && transitionEvent !== null) {\n this._loadingDiv.removeEventListener(transitionEvent, listener);\n }\n return this._loadingDiv = null;\n };\n if (typeof transitionEvent !== \"undefined\" && transitionEvent !== null) {\n this._loadingDiv.className += \" pg-loaded\";\n return this._loadingDiv.addEventListener(transitionEvent, listener);\n } else {\n return listener();\n }\n },\n updateLoadingHtml: function(loadingHtml, immediately = false) {\n if (immediately) {\n this._loadingHtmlToDisplay = [loadingHtml];\n this._readyToShowLoadingHtml = true;\n } else {\n this._loadingHtmlToDisplay.push(loadingHtml);\n }\n if (this._readyToShowLoadingHtml) {\n return this._changeLoadingHtml();\n }\n },\n load: function(options = {}) {\n var listener, logo;\n options = this._createOptions(options);\n this._loadingDiv || (this._loadingDiv = document.createElement(\"header\"));\n this._loadingHtmlToDisplay = [];\n this._loadingDiv.className = \"pg-loading-screen\";\n if (options.backgroundColor != null) {\n this._loadingDiv.style.backgroundColor = options.backgroundColor;\n }\n this._loadingDiv.innerHTML = options.template;\n this._loadingHtml = this._loadingDiv.getElementsByClassName(\"pg-loading-html\")[0];\n if (this._loadingHtml != null) {\n this._loadingHtml.innerHTML = options.loadingHtml;\n }\n this._readyToShowLoadingHtml = false;\n logo = this._loadingDiv.getElementsByClassName(\"pg-loading-logo\")[0];\n if (logo != null) {\n logo.src = options.logo;\n }\n document.body.appendChild(this._loadingDiv);\n this._loadingDiv.className += \" pg-loading\";\n return listener = () => {\n this._readyToShowLoadingHtml = true;\n if (typeof transitionEvent !== \"undefined\" && transitionEvent !== null) {\n this._loadingHtml.removeEventListener(transitionEvent, listener);\n }\n if (this._loadingHtmlToDisplay.length > 0) {\n return this._changeLoadingHtml();\n }\n };\n }\n});", "source_lang": "CoffeeScript", "target_lang": "JavaScript", "repo": "Pathgather/please-wait", "path": "src/please-wait.coffee", "license": "MIT", "commit": "2a936837089956ff8350e421f9604ece2ebafd78", "stars": 1583, "source_url": "https://github.com/Pathgather/please-wait/blob/2a936837089956ff8350e421f9604ece2ebafd78/src/please-wait.coffee", "line_start": 47, "line_end": 89}607{"id": "Pathgather/please-wait:src/please-wait.coffee:2:js_to_coffee", "type": "js_to_coffee", "prompt": "Convert this JavaScript to CoffeeScript.\n```javascript\n({\n done: function() {\n var listener;\n if (this._loadingDiv == null) {\n return;\n }\n listener = () => {\n document.body.removeChild(this._loadingDiv);\n document.body.className += \" pg-loaded\";\n if (typeof transitionEvent !== \"undefined\" && transitionEvent !== null) {\n this._loadingDiv.removeEventListener(transitionEvent, listener);\n }\n return this._loadingDiv = null;\n };\n if (typeof transitionEvent !== \"undefined\" && transitionEvent !== null) {\n this._loadingDiv.className += \" pg-loaded\";\n return this._loadingDiv.addEventListener(transitionEvent, listener);\n } else {\n return listener();\n }\n },\n updateLoadingHtml: function(loadingHtml, immediately = false) {\n if (immediately) {\n this._loadingHtmlToDisplay = [loadingHtml];\n this._readyToShowLoadingHtml = true;\n } else {\n this._loadingHtmlToDisplay.push(loadingHtml);\n }\n if (this._readyToShowLoadingHtml) {\n return this._changeLoadingHtml();\n }\n },\n load: function(options = {}) {\n var listener, logo;\n options = this._createOptions(options);\n this._loadingDiv || (this._loadingDiv = document.createElement(\"header\"));\n this._loadingHtmlToDisplay = [];\n this._loadingDiv.className = \"pg-loading-screen\";\n if (options.backgroundColor != null) {\n this._loadingDiv.style.backgroundColor = options.backgroundColor;\n }\n this._loadingDiv.innerHTML = options.template;\n this._loadingHtml = this._loadingDiv.getElementsByClassName(\"pg-loading-html\")[0];\n if (this._loadingHtml != null) {\n this._loadingHtml.innerHTML = options.loadingHtml;\n }\n this._readyToShowLoadingHtml = false;\n logo = this._loadingDiv.getElementsByClassName(\"pg-loading-logo\")[0];\n if (logo != null) {\n logo.src = options.logo;\n }\n document.body.appendChild(this._loadingDiv);\n this._loadingDiv.className += \" pg-loading\";\n return listener = () => {\n this._readyToShowLoadingHtml = true;\n if (typeof transitionEvent !== \"undefined\" && transitionEvent !== null) {\n this._loadingHtml.removeEventListener(transitionEvent, listener);\n }\n if (this._loadingHtmlToDisplay.length > 0) {\n return this._changeLoadingHtml();\n }\n };\n }\n});\n```", "response": "done: ->\n return unless @_loadingDiv?\n listener = =>\n document.body.removeChild(@_loadingDiv)\n document.body.className += \" pg-loaded\"\n if transitionEvent? then @_loadingDiv.removeEventListener(transitionEvent, listener)\n @_loadingDiv = null\n\n if transitionEvent?\n @_loadingDiv.className += \" pg-loaded\"\n @_loadingDiv.addEventListener(transitionEvent, listener)\n else\n listener()\n\n updateLoadingHtml: (loadingHtml, immediately=false) ->\n if immediately\n @_loadingHtmlToDisplay = [loadingHtml]\n @_readyToShowLoadingHtml = true\n else\n @_loadingHtmlToDisplay.push(loadingHtml)\n\n if @_readyToShowLoadingHtml then @_changeLoadingHtml()\n\n load: (options = {}) ->\n options = @_createOptions(options)\n @_loadingDiv ||= document.createElement(\"header\")\n @_loadingHtmlToDisplay = []\n @_loadingDiv.className = \"pg-loading-screen\"\n @_loadingDiv.style.backgroundColor = options.backgroundColor if options.backgroundColor?\n @_loadingDiv.innerHTML = options.template\n @_loadingHtml = @_loadingDiv.getElementsByClassName(\"pg-loading-html\")[0]\n @_loadingHtml.innerHTML = options.loadingHtml if @_loadingHtml?\n @_readyToShowLoadingHtml = false\n logo = @_loadingDiv.getElementsByClassName(\"pg-loading-logo\")[0]\n logo.src = options.logo if logo?\n\n document.body.appendChild(@_loadingDiv)\n @_loadingDiv.className += \" pg-loading\"\n\n listener = =>\n @_readyToShowLoadingHtml = true\n if transitionEvent? then @_loadingHtml.removeEventListener(transitionEvent, listener)\n if @_loadingHtmlToDisplay.length > 0 then @_changeLoadingHtml()", "source_lang": "JavaScript", "target_lang": "CoffeeScript", "repo": "Pathgather/please-wait", "path": "src/please-wait.coffee", "license": "MIT", "commit": "2a936837089956ff8350e421f9604ece2ebafd78", "stars": 1583, "source_url": "https://github.com/Pathgather/please-wait/blob/2a936837089956ff8350e421f9604ece2ebafd78/src/please-wait.coffee", "line_start": 47, "line_end": 89}608{"id": "Pathgather/please-wait:src/please-wait.coffee:2:completion", "type": "completion", "prompt": "done: ->\n return unless @_loadingDiv?\n listener = =>\n document.body.removeChild(@_loadingDiv)\n document.body.className += \" pg-loaded\"\n if transitionEvent? then @_loadingDiv.removeEventListener(transitionEvent, listener)\n @_loadingDiv = null\n\n if transitionEvent?\n @_loadingDiv.className += \" pg-loaded\"\n @_loadingDiv.addEventListener(transitionEvent, listener)\n else\n listener()\n\n updateLoadingHtml: (loadingHtml, immediately=false) ->\n if immediately\n @_loadingHtmlToDisplay = [loadingHtml]\n @_readyToShowLoadingHtml = true\n else\n @_loadingHtmlToDisplay.push(loadingHtml)", "response": "if @_readyToShowLoadingHtml then @_changeLoadingHtml()\n\n load: (options = {}) ->\n options = @_createOptions(options)\n @_loadingDiv ||= document.createElement(\"header\")\n @_loadingHtmlToDisplay = []\n @_loadingDiv.className = \"pg-loading-screen\"\n @_loadingDiv.style.backgroundColor = options.backgroundColor if options.backgroundColor?\n @_loadingDiv.innerHTML = options.template\n @_loadingHtml = @_loadingDiv.getElementsByClassName(\"pg-loading-html\")[0]\n @_loadingHtml.innerHTML = options.loadingHtml if @_loadingHtml?\n @_readyToShowLoadingHtml = false\n logo = @_loadingDiv.getElementsByClassName(\"pg-loading-logo\")[0]\n logo.src = options.logo if logo?\n\n document.body.appendChild(@_loadingDiv)\n @_loadingDiv.className += \" pg-loading\"\n\n listener = =>\n @_readyToShowLoadingHtml = true\n if transitionEvent? then @_loadingHtml.removeEventListener(transitionEvent, listener)\n if @_loadingHtmlToDisplay.length > 0 then @_changeLoadingHtml()", "source_lang": "CoffeeScript", "target_lang": "CoffeeScript", "repo": "Pathgather/please-wait", "path": "src/please-wait.coffee", "license": "MIT", "commit": "2a936837089956ff8350e421f9604ece2ebafd78", "stars": 1583, "source_url": "https://github.com/Pathgather/please-wait/blob/2a936837089956ff8350e421f9604ece2ebafd78/src/please-wait.coffee", "line_start": 47, "line_end": 89}609{"id": "Pathgather/please-wait:src/please-wait.coffee:3:raw_corpus", "type": "raw_corpus", "prompt": "", "response": "if transitionEvent?\n @_loadingHtml.addEventListener(transitionEvent, listener)\n else\n listener()\n\n return @_loadingDiv\n\n _createOptions: (options = {}) ->\n defaultOptions = @defaultOptions\n newOptions = {}\n\n # Set options\n for k, v of defaultOptions\n newOptions[k] = if options[k]? then options[k] else v\n\n newOptions\n\n _changeLoadingHtml: ->\n @_readyToShowLoadingHtml = false\n\n loadingListener = =>\n @_readyToShowLoadingHtml = true\n @_loadingHtml.className = @_loadingHtml.className.replace(\" pg-loading \", \"\")\n if transitionEvent? then @_loadingHtml.removeEventListener(transitionEvent, loadingListener)\n if @_loadingHtmlToDisplay.length > 0 then @_changeLoadingHtml()\n\n removingListener = =>\n @_loadingHtml.innerHTML = @_loadingHtmlToDisplay.shift()\n @_loadingHtml.className = @_loadingHtml.className.replace(\" pg-removing \", \" pg-loading \")\n if transitionEvent?\n @_loadingHtml.removeEventListener(transitionEvent, removingListener)\n @_loadingHtml.addEventListener(transitionEvent, loadingListener)\n else\n loadingListener()\n\n if transitionEvent?\n @_loadingHtml.className += \" pg-removing \"\n @_loadingHtml.addEventListener(transitionEvent, removingListener)\n else\n removingListener()", "source_lang": "", "target_lang": "CoffeeScript", "repo": "Pathgather/please-wait", "path": "src/please-wait.coffee", "license": "MIT", "commit": "2a936837089956ff8350e421f9604ece2ebafd78", "stars": 1583, "source_url": "https://github.com/Pathgather/please-wait/blob/2a936837089956ff8350e421f9604ece2ebafd78/src/please-wait.coffee", "line_start": 91, "line_end": 130}610{"id": "Pathgather/please-wait:src/please-wait.coffee:3:coffee_to_js", "type": "coffee_to_js", "prompt": "Convert this CoffeeScript to JavaScript.\n```coffeescript\nif transitionEvent?\n @_loadingHtml.addEventListener(transitionEvent, listener)\n else\n listener()\n\n return @_loadingDiv\n\n _createOptions: (options = {}) ->\n defaultOptions = @defaultOptions\n newOptions = {}\n\n # Set options\n for k, v of defaultOptions\n newOptions[k] = if options[k]? then options[k] else v\n\n newOptions\n\n _changeLoadingHtml: ->\n @_readyToShowLoadingHtml = false\n\n loadingListener = =>\n @_readyToShowLoadingHtml = true\n @_loadingHtml.className = @_loadingHtml.className.replace(\" pg-loading \", \"\")\n if transitionEvent? then @_loadingHtml.removeEventListener(transitionEvent, loadingListener)\n if @_loadingHtmlToDisplay.length > 0 then @_changeLoadingHtml()\n\n removingListener = =>\n @_loadingHtml.innerHTML = @_loadingHtmlToDisplay.shift()\n @_loadingHtml.className = @_loadingHtml.className.replace(\" pg-removing \", \" pg-loading \")\n if transitionEvent?\n @_loadingHtml.removeEventListener(transitionEvent, removingListener)\n @_loadingHtml.addEventListener(transitionEvent, loadingListener)\n else\n loadingListener()\n\n if transitionEvent?\n @_loadingHtml.className += \" pg-removing \"\n @_loadingHtml.addEventListener(transitionEvent, removingListener)\n else\n removingListener()\n```", "response": "if (typeof transitionEvent !== \"undefined\" && transitionEvent !== null) {\n this._loadingHtml.addEventListener(transitionEvent, listener);\n} else {\n listener();\n}\n\nreturn this._loadingDiv;\n\n({\n _createOptions: function(options = {}) {\n var defaultOptions, k, newOptions, v;\n defaultOptions = this.defaultOptions;\n newOptions = {};\n// Set options\n for (k in defaultOptions) {\n v = defaultOptions[k];\n newOptions[k] = options[k] != null ? options[k] : v;\n }\n return newOptions;\n },\n _changeLoadingHtml: function() {\n var loadingListener, removingListener;\n this._readyToShowLoadingHtml = false;\n loadingListener = () => {\n this._readyToShowLoadingHtml = true;\n this._loadingHtml.className = this._loadingHtml.className.replace(\" pg-loading \", \"\");\n if (typeof transitionEvent !== \"undefined\" && transitionEvent !== null) {\n this._loadingHtml.removeEventListener(transitionEvent, loadingListener);\n }\n if (this._loadingHtmlToDisplay.length > 0) {\n return this._changeLoadingHtml();\n }\n };\n removingListener = () => {\n this._loadingHtml.innerHTML = this._loadingHtmlToDisplay.shift();\n this._loadingHtml.className = this._loadingHtml.className.replace(\" pg-removing \", \" pg-loading \");\n if (typeof transitionEvent !== \"undefined\" && transitionEvent !== null) {\n this._loadingHtml.removeEventListener(transitionEvent, removingListener);\n return this._loadingHtml.addEventListener(transitionEvent, loadingListener);\n } else {\n return loadingListener();\n }\n };\n if (typeof transitionEvent !== \"undefined\" && transitionEvent !== null) {\n this._loadingHtml.className += \" pg-removing \";\n return this._loadingHtml.addEventListener(transitionEvent, removingListener);\n } else {\n return removingListener();\n }\n }\n});", "source_lang": "CoffeeScript", "target_lang": "JavaScript", "repo": "Pathgather/please-wait", "path": "src/please-wait.coffee", "license": "MIT", "commit": "2a936837089956ff8350e421f9604ece2ebafd78", "stars": 1583, "source_url": "https://github.com/Pathgather/please-wait/blob/2a936837089956ff8350e421f9604ece2ebafd78/src/please-wait.coffee", "line_start": 91, "line_end": 130}611{"id": "Pathgather/please-wait:src/please-wait.coffee:3:js_to_coffee", "type": "js_to_coffee", "prompt": "Convert this JavaScript to CoffeeScript.\n```javascript\nif (typeof transitionEvent !== \"undefined\" && transitionEvent !== null) {\n this._loadingHtml.addEventListener(transitionEvent, listener);\n} else {\n listener();\n}\n\nreturn this._loadingDiv;\n\n({\n _createOptions: function(options = {}) {\n var defaultOptions, k, newOptions, v;\n defaultOptions = this.defaultOptions;\n newOptions = {};\n// Set options\n for (k in defaultOptions) {\n v = defaultOptions[k];\n newOptions[k] = options[k] != null ? options[k] : v;\n }\n return newOptions;\n },\n _changeLoadingHtml: function() {\n var loadingListener, removingListener;\n this._readyToShowLoadingHtml = false;\n loadingListener = () => {\n this._readyToShowLoadingHtml = true;\n this._loadingHtml.className = this._loadingHtml.className.replace(\" pg-loading \", \"\");\n if (typeof transitionEvent !== \"undefined\" && transitionEvent !== null) {\n this._loadingHtml.removeEventListener(transitionEvent, loadingListener);\n }\n if (this._loadingHtmlToDisplay.length > 0) {\n return this._changeLoadingHtml();\n }\n };\n removingListener = () => {\n this._loadingHtml.innerHTML = this._loadingHtmlToDisplay.shift();\n this._loadingHtml.className = this._loadingHtml.className.replace(\" pg-removing \", \" pg-loading \");\n if (typeof transitionEvent !== \"undefined\" && transitionEvent !== null) {\n this._loadingHtml.removeEventListener(transitionEvent, removingListener);\n return this._loadingHtml.addEventListener(transitionEvent, loadingListener);\n } else {\n return loadingListener();\n }\n };\n if (typeof transitionEvent !== \"undefined\" && transitionEvent !== null) {\n this._loadingHtml.className += \" pg-removing \";\n return this._loadingHtml.addEventListener(transitionEvent, removingListener);\n } else {\n return removingListener();\n }\n }\n});\n```", "response": "if transitionEvent?\n @_loadingHtml.addEventListener(transitionEvent, listener)\n else\n listener()\n\n return @_loadingDiv\n\n _createOptions: (options = {}) ->\n defaultOptions = @defaultOptions\n newOptions = {}\n\n # Set options\n for k, v of defaultOptions\n newOptions[k] = if options[k]? then options[k] else v\n\n newOptions\n\n _changeLoadingHtml: ->\n @_readyToShowLoadingHtml = false\n\n loadingListener = =>\n @_readyToShowLoadingHtml = true\n @_loadingHtml.className = @_loadingHtml.className.replace(\" pg-loading \", \"\")\n if transitionEvent? then @_loadingHtml.removeEventListener(transitionEvent, loadingListener)\n if @_loadingHtmlToDisplay.length > 0 then @_changeLoadingHtml()\n\n removingListener = =>\n @_loadingHtml.innerHTML = @_loadingHtmlToDisplay.shift()\n @_loadingHtml.className = @_loadingHtml.className.replace(\" pg-removing \", \" pg-loading \")\n if transitionEvent?\n @_loadingHtml.removeEventListener(transitionEvent, removingListener)\n @_loadingHtml.addEventListener(transitionEvent, loadingListener)\n else\n loadingListener()\n\n if transitionEvent?\n @_loadingHtml.className += \" pg-removing \"\n @_loadingHtml.addEventListener(transitionEvent, removingListener)\n else\n removingListener()", "source_lang": "JavaScript", "target_lang": "CoffeeScript", "repo": "Pathgather/please-wait", "path": "src/please-wait.coffee", "license": "MIT", "commit": "2a936837089956ff8350e421f9604ece2ebafd78", "stars": 1583, "source_url": "https://github.com/Pathgather/please-wait/blob/2a936837089956ff8350e421f9604ece2ebafd78/src/please-wait.coffee", "line_start": 91, "line_end": 130}612{"id": "Pathgather/please-wait:src/please-wait.coffee:3:completion", "type": "completion", "prompt": "if transitionEvent?\n @_loadingHtml.addEventListener(transitionEvent, listener)\n else\n listener()\n\n return @_loadingDiv\n\n _createOptions: (options = {}) ->\n defaultOptions = @defaultOptions\n newOptions = {}\n\n # Set options\n for k, v of defaultOptions\n newOptions[k] = if options[k]? then options[k] else v\n\n newOptions\n\n _changeLoadingHtml: ->\n @_readyToShowLoadingHtml = false", "response": "loadingListener = =>\n @_readyToShowLoadingHtml = true\n @_loadingHtml.className = @_loadingHtml.className.replace(\" pg-loading \", \"\")\n if transitionEvent? then @_loadingHtml.removeEventListener(transitionEvent, loadingListener)\n if @_loadingHtmlToDisplay.length > 0 then @_changeLoadingHtml()\n\n removingListener = =>\n @_loadingHtml.innerHTML = @_loadingHtmlToDisplay.shift()\n @_loadingHtml.className = @_loadingHtml.className.replace(\" pg-removing \", \" pg-loading \")\n if transitionEvent?\n @_loadingHtml.removeEventListener(transitionEvent, removingListener)\n @_loadingHtml.addEventListener(transitionEvent, loadingListener)\n else\n loadingListener()\n\n if transitionEvent?\n @_loadingHtml.className += \" pg-removing \"\n @_loadingHtml.addEventListener(transitionEvent, removingListener)\n else\n removingListener()", "source_lang": "CoffeeScript", "target_lang": "CoffeeScript", "repo": "Pathgather/please-wait", "path": "src/please-wait.coffee", "license": "MIT", "commit": "2a936837089956ff8350e421f9604ece2ebafd78", "stars": 1583, "source_url": "https://github.com/Pathgather/please-wait/blob/2a936837089956ff8350e421f9604ece2ebafd78/src/please-wait.coffee", "line_start": 91, "line_end": 130}613{"id": "Pathgather/please-wait:src/please-wait.coffee:4:raw_corpus", "type": "raw_corpus", "prompt": "", "response": "return {\n start : (options = {}) -> _pleaseWait.load(options)\n finish : -> _pleaseWait.done()\n updateLoadingHtml: (html) -> _pleaseWait.updateLoadingHtml(html)\n }\n\n exports.pleaseWait = new PleaseWait()", "source_lang": "", "target_lang": "CoffeeScript", "repo": "Pathgather/please-wait", "path": "src/please-wait.coffee", "license": "MIT", "commit": "2a936837089956ff8350e421f9604ece2ebafd78", "stars": 1583, "source_url": "https://github.com/Pathgather/please-wait/blob/2a936837089956ff8350e421f9604ece2ebafd78/src/please-wait.coffee", "line_start": 132, "line_end": 138}614{"id": "Pathgather/please-wait:src/please-wait.coffee:4:completion", "type": "completion", "prompt": "return {\n start : (options = {}) -> _pleaseWait.load(options)\n finish : -> _pleaseWait.done()", "response": "updateLoadingHtml: (html) -> _pleaseWait.updateLoadingHtml(html)\n }\n\n exports.pleaseWait = new PleaseWait()", "source_lang": "CoffeeScript", "target_lang": "CoffeeScript", "repo": "Pathgather/please-wait", "path": "src/please-wait.coffee", "license": "MIT", "commit": "2a936837089956ff8350e421f9604ece2ebafd78", "stars": 1583, "source_url": "https://github.com/Pathgather/please-wait/blob/2a936837089956ff8350e421f9604ece2ebafd78/src/please-wait.coffee", "line_start": 132, "line_end": 138}615{"id": "Pathgather/please-wait:src/please-wait.coffee:2:raw_corpus", "type": "raw_corpus", "prompt": "", "response": "done: ->\n return unless @_loadingDiv?\n listener = =>\n document.body.removeChild(@_loadingDiv)\n document.body.className += \" pg-loaded\"\n if transitionEvent? then @_loadingDiv.removeEventListener(transitionEvent, listener)\n @_loadingDiv = null\n\n if transitionEvent?\n @_loadingDiv.className += \" pg-loaded\"\n @_loadingDiv.addEventListener(transitionEvent, listener)\n else\n listener()\n\n updateLoadingHtml: (loadingHtml) ->\n @_loadingHtmlToDisplay.push(options.loadingHtml)\n if @_readyToShowLoadingHtml then @_changeLoadingHtml()\n\n load: (options = {}) ->\n options = @_createOptions(options)\n @_loadingDiv ||= document.createElement(\"header\")\n @_loadingHtmlToDisplay = []\n @_loadingDiv.className = \"pg-loading-screen\"\n @_loadingDiv.style.backgroundColor = options.backgroundColor if options.backgroundColor?\n @_loadingDiv.innerHTML = options.template\n @_loadingHtml = @_loadingDiv.getElementsByClassName(\"pg-loading-html\")[0]\n @_loadingHtml.innerHTML = options.loadingHtml if @_loadingHtml?\n @_readyToShowLoadingHtml = false\n logo = @_loadingDiv.getElementsByClassName(\"pg-loading-logo\")[0]\n logo.src = options.logo if logo?\n\n document.body.appendChild(@_loadingDiv)\n @_loadingDiv.className += \" pg-loading\"\n\n listener = =>\n @_readyToShowLoadingHtml = true\n if transitionEvent? then @_loadingDiv.removeEventListener(transitionEvent, listener)\n if @_loadingHtmlToDisplay.length > 0 then @_changeLoadingHtml()\n\n if transitionEvent?\n @_loadingDiv.addEventListener(transitionEvent, listener)\n else\n listener()", "source_lang": "", "target_lang": "CoffeeScript", "repo": "Pathgather/please-wait", "path": "src/please-wait.coffee", "license": "MIT", "commit": "189d95b2c23eefe977465a3332b551ffa4fd58f3", "stars": 1583, "source_url": "https://github.com/Pathgather/please-wait/blob/189d95b2c23eefe977465a3332b551ffa4fd58f3/src/please-wait.coffee", "line_start": 47, "line_end": 89}616{"id": "Pathgather/please-wait:src/please-wait.coffee:2:coffee_to_js", "type": "coffee_to_js", "prompt": "Convert this CoffeeScript to JavaScript.\n```coffeescript\ndone: ->\n return unless @_loadingDiv?\n listener = =>\n document.body.removeChild(@_loadingDiv)\n document.body.className += \" pg-loaded\"\n if transitionEvent? then @_loadingDiv.removeEventListener(transitionEvent, listener)\n @_loadingDiv = null\n\n if transitionEvent?\n @_loadingDiv.className += \" pg-loaded\"\n @_loadingDiv.addEventListener(transitionEvent, listener)\n else\n listener()\n\n updateLoadingHtml: (loadingHtml) ->\n @_loadingHtmlToDisplay.push(options.loadingHtml)\n if @_readyToShowLoadingHtml then @_changeLoadingHtml()\n\n load: (options = {}) ->\n options = @_createOptions(options)\n @_loadingDiv ||= document.createElement(\"header\")\n @_loadingHtmlToDisplay = []\n @_loadingDiv.className = \"pg-loading-screen\"\n @_loadingDiv.style.backgroundColor = options.backgroundColor if options.backgroundColor?\n @_loadingDiv.innerHTML = options.template\n @_loadingHtml = @_loadingDiv.getElementsByClassName(\"pg-loading-html\")[0]\n @_loadingHtml.innerHTML = options.loadingHtml if @_loadingHtml?\n @_readyToShowLoadingHtml = false\n logo = @_loadingDiv.getElementsByClassName(\"pg-loading-logo\")[0]\n logo.src = options.logo if logo?\n\n document.body.appendChild(@_loadingDiv)\n @_loadingDiv.className += \" pg-loading\"\n\n listener = =>\n @_readyToShowLoadingHtml = true\n if transitionEvent? then @_loadingDiv.removeEventListener(transitionEvent, listener)\n if @_loadingHtmlToDisplay.length > 0 then @_changeLoadingHtml()\n\n if transitionEvent?\n @_loadingDiv.addEventListener(transitionEvent, listener)\n else\n listener()\n```", "response": "({\n done: function() {\n var listener;\n if (this._loadingDiv == null) {\n return;\n }\n listener = () => {\n document.body.removeChild(this._loadingDiv);\n document.body.className += \" pg-loaded\";\n if (typeof transitionEvent !== \"undefined\" && transitionEvent !== null) {\n this._loadingDiv.removeEventListener(transitionEvent, listener);\n }\n return this._loadingDiv = null;\n };\n if (typeof transitionEvent !== \"undefined\" && transitionEvent !== null) {\n this._loadingDiv.className += \" pg-loaded\";\n return this._loadingDiv.addEventListener(transitionEvent, listener);\n } else {\n return listener();\n }\n },\n updateLoadingHtml: function(loadingHtml) {\n this._loadingHtmlToDisplay.push(options.loadingHtml);\n if (this._readyToShowLoadingHtml) {\n return this._changeLoadingHtml();\n }\n },\n load: function(options = {}) {\n var listener, logo;\n options = this._createOptions(options);\n this._loadingDiv || (this._loadingDiv = document.createElement(\"header\"));\n this._loadingHtmlToDisplay = [];\n this._loadingDiv.className = \"pg-loading-screen\";\n if (options.backgroundColor != null) {\n this._loadingDiv.style.backgroundColor = options.backgroundColor;\n }\n this._loadingDiv.innerHTML = options.template;\n this._loadingHtml = this._loadingDiv.getElementsByClassName(\"pg-loading-html\")[0];\n if (this._loadingHtml != null) {\n this._loadingHtml.innerHTML = options.loadingHtml;\n }\n this._readyToShowLoadingHtml = false;\n logo = this._loadingDiv.getElementsByClassName(\"pg-loading-logo\")[0];\n if (logo != null) {\n logo.src = options.logo;\n }\n document.body.appendChild(this._loadingDiv);\n this._loadingDiv.className += \" pg-loading\";\n listener = () => {\n this._readyToShowLoadingHtml = true;\n if (typeof transitionEvent !== \"undefined\" && transitionEvent !== null) {\n this._loadingDiv.removeEventListener(transitionEvent, listener);\n }\n if (this._loadingHtmlToDisplay.length > 0) {\n return this._changeLoadingHtml();\n }\n };\n if (typeof transitionEvent !== \"undefined\" && transitionEvent !== null) {\n return this._loadingDiv.addEventListener(transitionEvent, listener);\n } else {\n return listener();\n }\n }\n});", "source_lang": "CoffeeScript", "target_lang": "JavaScript", "repo": "Pathgather/please-wait", "path": "src/please-wait.coffee", "license": "MIT", "commit": "189d95b2c23eefe977465a3332b551ffa4fd58f3", "stars": 1583, "source_url": "https://github.com/Pathgather/please-wait/blob/189d95b2c23eefe977465a3332b551ffa4fd58f3/src/please-wait.coffee", "line_start": 47, "line_end": 89}617{"id": "Pathgather/please-wait:src/please-wait.coffee:2:js_to_coffee", "type": "js_to_coffee", "prompt": "Convert this JavaScript to CoffeeScript.\n```javascript\n({\n done: function() {\n var listener;\n if (this._loadingDiv == null) {\n return;\n }\n listener = () => {\n document.body.removeChild(this._loadingDiv);\n document.body.className += \" pg-loaded\";\n if (typeof transitionEvent !== \"undefined\" && transitionEvent !== null) {\n this._loadingDiv.removeEventListener(transitionEvent, listener);\n }\n return this._loadingDiv = null;\n };\n if (typeof transitionEvent !== \"undefined\" && transitionEvent !== null) {\n this._loadingDiv.className += \" pg-loaded\";\n return this._loadingDiv.addEventListener(transitionEvent, listener);\n } else {\n return listener();\n }\n },\n updateLoadingHtml: function(loadingHtml) {\n this._loadingHtmlToDisplay.push(options.loadingHtml);\n if (this._readyToShowLoadingHtml) {\n return this._changeLoadingHtml();\n }\n },\n load: function(options = {}) {\n var listener, logo;\n options = this._createOptions(options);\n this._loadingDiv || (this._loadingDiv = document.createElement(\"header\"));\n this._loadingHtmlToDisplay = [];\n this._loadingDiv.className = \"pg-loading-screen\";\n if (options.backgroundColor != null) {\n this._loadingDiv.style.backgroundColor = options.backgroundColor;\n }\n this._loadingDiv.innerHTML = options.template;\n this._loadingHtml = this._loadingDiv.getElementsByClassName(\"pg-loading-html\")[0];\n if (this._loadingHtml != null) {\n this._loadingHtml.innerHTML = options.loadingHtml;\n }\n this._readyToShowLoadingHtml = false;\n logo = this._loadingDiv.getElementsByClassName(\"pg-loading-logo\")[0];\n if (logo != null) {\n logo.src = options.logo;\n }\n document.body.appendChild(this._loadingDiv);\n this._loadingDiv.className += \" pg-loading\";\n listener = () => {\n this._readyToShowLoadingHtml = true;\n if (typeof transitionEvent !== \"undefined\" && transitionEvent !== null) {\n this._loadingDiv.removeEventListener(transitionEvent, listener);\n }\n if (this._loadingHtmlToDisplay.length > 0) {\n return this._changeLoadingHtml();\n }\n };\n if (typeof transitionEvent !== \"undefined\" && transitionEvent !== null) {\n return this._loadingDiv.addEventListener(transitionEvent, listener);\n } else {\n return listener();\n }\n }\n});\n```", "response": "done: ->\n return unless @_loadingDiv?\n listener = =>\n document.body.removeChild(@_loadingDiv)\n document.body.className += \" pg-loaded\"\n if transitionEvent? then @_loadingDiv.removeEventListener(transitionEvent, listener)\n @_loadingDiv = null\n\n if transitionEvent?\n @_loadingDiv.className += \" pg-loaded\"\n @_loadingDiv.addEventListener(transitionEvent, listener)\n else\n listener()\n\n updateLoadingHtml: (loadingHtml) ->\n @_loadingHtmlToDisplay.push(options.loadingHtml)\n if @_readyToShowLoadingHtml then @_changeLoadingHtml()\n\n load: (options = {}) ->\n options = @_createOptions(options)\n @_loadingDiv ||= document.createElement(\"header\")\n @_loadingHtmlToDisplay = []\n @_loadingDiv.className = \"pg-loading-screen\"\n @_loadingDiv.style.backgroundColor = options.backgroundColor if options.backgroundColor?\n @_loadingDiv.innerHTML = options.template\n @_loadingHtml = @_loadingDiv.getElementsByClassName(\"pg-loading-html\")[0]\n @_loadingHtml.innerHTML = options.loadingHtml if @_loadingHtml?\n @_readyToShowLoadingHtml = false\n logo = @_loadingDiv.getElementsByClassName(\"pg-loading-logo\")[0]\n logo.src = options.logo if logo?\n\n document.body.appendChild(@_loadingDiv)\n @_loadingDiv.className += \" pg-loading\"\n\n listener = =>\n @_readyToShowLoadingHtml = true\n if transitionEvent? then @_loadingDiv.removeEventListener(transitionEvent, listener)\n if @_loadingHtmlToDisplay.length > 0 then @_changeLoadingHtml()\n\n if transitionEvent?\n @_loadingDiv.addEventListener(transitionEvent, listener)\n else\n listener()", "source_lang": "JavaScript", "target_lang": "CoffeeScript", "repo": "Pathgather/please-wait", "path": "src/please-wait.coffee", "license": "MIT", "commit": "189d95b2c23eefe977465a3332b551ffa4fd58f3", "stars": 1583, "source_url": "https://github.com/Pathgather/please-wait/blob/189d95b2c23eefe977465a3332b551ffa4fd58f3/src/please-wait.coffee", "line_start": 47, "line_end": 89}618{"id": "Pathgather/please-wait:src/please-wait.coffee:2:completion", "type": "completion", "prompt": "done: ->\n return unless @_loadingDiv?\n listener = =>\n document.body.removeChild(@_loadingDiv)\n document.body.className += \" pg-loaded\"\n if transitionEvent? then @_loadingDiv.removeEventListener(transitionEvent, listener)\n @_loadingDiv = null\n\n if transitionEvent?\n @_loadingDiv.className += \" pg-loaded\"\n @_loadingDiv.addEventListener(transitionEvent, listener)\n else\n listener()\n\n updateLoadingHtml: (loadingHtml) ->\n @_loadingHtmlToDisplay.push(options.loadingHtml)\n if @_readyToShowLoadingHtml then @_changeLoadingHtml()\n\n load: (options = {}) ->\n options = @_createOptions(options)\n @_loadingDiv ||= document.createElement(\"header\")", "response": "@_loadingHtmlToDisplay = []\n @_loadingDiv.className = \"pg-loading-screen\"\n @_loadingDiv.style.backgroundColor = options.backgroundColor if options.backgroundColor?\n @_loadingDiv.innerHTML = options.template\n @_loadingHtml = @_loadingDiv.getElementsByClassName(\"pg-loading-html\")[0]\n @_loadingHtml.innerHTML = options.loadingHtml if @_loadingHtml?\n @_readyToShowLoadingHtml = false\n logo = @_loadingDiv.getElementsByClassName(\"pg-loading-logo\")[0]\n logo.src = options.logo if logo?\n\n document.body.appendChild(@_loadingDiv)\n @_loadingDiv.className += \" pg-loading\"\n\n listener = =>\n @_readyToShowLoadingHtml = true\n if transitionEvent? then @_loadingDiv.removeEventListener(transitionEvent, listener)\n if @_loadingHtmlToDisplay.length > 0 then @_changeLoadingHtml()\n\n if transitionEvent?\n @_loadingDiv.addEventListener(transitionEvent, listener)\n else\n listener()", "source_lang": "CoffeeScript", "target_lang": "CoffeeScript", "repo": "Pathgather/please-wait", "path": "src/please-wait.coffee", "license": "MIT", "commit": "189d95b2c23eefe977465a3332b551ffa4fd58f3", "stars": 1583, "source_url": "https://github.com/Pathgather/please-wait/blob/189d95b2c23eefe977465a3332b551ffa4fd58f3/src/please-wait.coffee", "line_start": 47, "line_end": 89}619{"id": "Pathgather/please-wait:src/please-wait.coffee:3:raw_corpus", "type": "raw_corpus", "prompt": "", "response": "return @_loadingDiv\n\n _createOptions: (options = {}) ->\n defaultOptions = @defaultOptions\n newOptions = {}\n\n # Set options\n for k, v of defaultOptions\n newOptions[k] = if options[k]? then options[k] else v\n\n newOptions\n\n _changeLoadingHtml: ->\n @_readyToShowLoadingHtml = false\n\n loadingListener = =>\n @_readyToShowLoadingHtml = true\n @_loadingHtml.className = @_loadingHtml.className.replace(\" pg-loading \", \"\")\n if transitionEvent? then @_loadingHtml.removeEventListener(transitionEvent, loadingListener)\n if @_loadingHtmlToDisplay.length > 0 then @_changeLoadingHtml()\n\n removingListener = =>\n @_loadingHtml.innerHTML = @_loadingHtmlToDisplay.shift()\n @_loadingHtml.className = @_loadingHtml.className.replace(\" pg-removing \", \" pg-loading \")\n if transitionEvent?\n @_loadingHtml.removeEventListener(transitionEvent, removingListener)\n @_loadingHtml.addEventListener(transitionEvent, loadingListener)\n else\n loadingListener()\n\n if transitionEvent?\n @_loadingHtml.className += \" pg-removing \"\n @_loadingHtml.addEventListener(transitionEvent, removingListener)\n else\n removingListener()\n\n return {\n start : (options = {}) -> _pleaseWait.load(options)\n finish : -> _pleaseWait.done()\n updateLoadingHtml: (html) -> _pleaseWait.updateLoadingHtml(html)\n }", "source_lang": "", "target_lang": "CoffeeScript", "repo": "Pathgather/please-wait", "path": "src/please-wait.coffee", "license": "MIT", "commit": "189d95b2c23eefe977465a3332b551ffa4fd58f3", "stars": 1583, "source_url": "https://github.com/Pathgather/please-wait/blob/189d95b2c23eefe977465a3332b551ffa4fd58f3/src/please-wait.coffee", "line_start": 91, "line_end": 131}620{"id": "Pathgather/please-wait:src/please-wait.coffee:3:coffee_to_js", "type": "coffee_to_js", "prompt": "Convert this CoffeeScript to JavaScript.\n```coffeescript\nreturn @_loadingDiv\n\n _createOptions: (options = {}) ->\n defaultOptions = @defaultOptions\n newOptions = {}\n\n # Set options\n for k, v of defaultOptions\n newOptions[k] = if options[k]? then options[k] else v\n\n newOptions\n\n _changeLoadingHtml: ->\n @_readyToShowLoadingHtml = false\n\n loadingListener = =>\n @_readyToShowLoadingHtml = true\n @_loadingHtml.className = @_loadingHtml.className.replace(\" pg-loading \", \"\")\n if transitionEvent? then @_loadingHtml.removeEventListener(transitionEvent, loadingListener)\n if @_loadingHtmlToDisplay.length > 0 then @_changeLoadingHtml()\n\n removingListener = =>\n @_loadingHtml.innerHTML = @_loadingHtmlToDisplay.shift()\n @_loadingHtml.className = @_loadingHtml.className.replace(\" pg-removing \", \" pg-loading \")\n if transitionEvent?\n @_loadingHtml.removeEventListener(transitionEvent, removingListener)\n @_loadingHtml.addEventListener(transitionEvent, loadingListener)\n else\n loadingListener()\n\n if transitionEvent?\n @_loadingHtml.className += \" pg-removing \"\n @_loadingHtml.addEventListener(transitionEvent, removingListener)\n else\n removingListener()\n\n return {\n start : (options = {}) -> _pleaseWait.load(options)\n finish : -> _pleaseWait.done()\n updateLoadingHtml: (html) -> _pleaseWait.updateLoadingHtml(html)\n }\n```", "response": "return this._loadingDiv({\n _createOptions: function(options = {}) {\n var defaultOptions, k, newOptions, v;\n defaultOptions = this.defaultOptions;\n newOptions = {};\n// Set options\n for (k in defaultOptions) {\n v = defaultOptions[k];\n newOptions[k] = options[k] != null ? options[k] : v;\n }\n return newOptions;\n },\n _changeLoadingHtml: function() {\n var loadingListener, removingListener;\n this._readyToShowLoadingHtml = false;\n loadingListener = () => {\n this._readyToShowLoadingHtml = true;\n this._loadingHtml.className = this._loadingHtml.className.replace(\" pg-loading \", \"\");\n if (typeof transitionEvent !== \"undefined\" && transitionEvent !== null) {\n this._loadingHtml.removeEventListener(transitionEvent, loadingListener);\n }\n if (this._loadingHtmlToDisplay.length > 0) {\n return this._changeLoadingHtml();\n }\n };\n removingListener = () => {\n this._loadingHtml.innerHTML = this._loadingHtmlToDisplay.shift();\n this._loadingHtml.className = this._loadingHtml.className.replace(\" pg-removing \", \" pg-loading \");\n if (typeof transitionEvent !== \"undefined\" && transitionEvent !== null) {\n this._loadingHtml.removeEventListener(transitionEvent, removingListener);\n return this._loadingHtml.addEventListener(transitionEvent, loadingListener);\n } else {\n return loadingListener();\n }\n };\n if (typeof transitionEvent !== \"undefined\" && transitionEvent !== null) {\n this._loadingHtml.className += \" pg-removing \";\n return this._loadingHtml.addEventListener(transitionEvent, removingListener);\n } else {\n return removingListener();\n }\n }\n});\n\nreturn {\n start: function(options = {}) {\n return _pleaseWait.load(options);\n },\n finish: function() {\n return _pleaseWait.done();\n },\n updateLoadingHtml: function(html) {\n return _pleaseWait.updateLoadingHtml(html);\n }\n};", "source_lang": "CoffeeScript", "target_lang": "JavaScript", "repo": "Pathgather/please-wait", "path": "src/please-wait.coffee", "license": "MIT", "commit": "189d95b2c23eefe977465a3332b551ffa4fd58f3", "stars": 1583, "source_url": "https://github.com/Pathgather/please-wait/blob/189d95b2c23eefe977465a3332b551ffa4fd58f3/src/please-wait.coffee", "line_start": 91, "line_end": 131}621{"id": "Pathgather/please-wait:src/please-wait.coffee:3:js_to_coffee", "type": "js_to_coffee", "prompt": "Convert this JavaScript to CoffeeScript.\n```javascript\nreturn this._loadingDiv({\n _createOptions: function(options = {}) {\n var defaultOptions, k, newOptions, v;\n defaultOptions = this.defaultOptions;\n newOptions = {};\n// Set options\n for (k in defaultOptions) {\n v = defaultOptions[k];\n newOptions[k] = options[k] != null ? options[k] : v;\n }\n return newOptions;\n },\n _changeLoadingHtml: function() {\n var loadingListener, removingListener;\n this._readyToShowLoadingHtml = false;\n loadingListener = () => {\n this._readyToShowLoadingHtml = true;\n this._loadingHtml.className = this._loadingHtml.className.replace(\" pg-loading \", \"\");\n if (typeof transitionEvent !== \"undefined\" && transitionEvent !== null) {\n this._loadingHtml.removeEventListener(transitionEvent, loadingListener);\n }\n if (this._loadingHtmlToDisplay.length > 0) {\n return this._changeLoadingHtml();\n }\n };\n removingListener = () => {\n this._loadingHtml.innerHTML = this._loadingHtmlToDisplay.shift();\n this._loadingHtml.className = this._loadingHtml.className.replace(\" pg-removing \", \" pg-loading \");\n if (typeof transitionEvent !== \"undefined\" && transitionEvent !== null) {\n this._loadingHtml.removeEventListener(transitionEvent, removingListener);\n return this._loadingHtml.addEventListener(transitionEvent, loadingListener);\n } else {\n return loadingListener();\n }\n };\n if (typeof transitionEvent !== \"undefined\" && transitionEvent !== null) {\n this._loadingHtml.className += \" pg-removing \";\n return this._loadingHtml.addEventListener(transitionEvent, removingListener);\n } else {\n return removingListener();\n }\n }\n});\n\nreturn {\n start: function(options = {}) {\n return _pleaseWait.load(options);\n },\n finish: function() {\n return _pleaseWait.done();\n },\n updateLoadingHtml: function(html) {\n return _pleaseWait.updateLoadingHtml(html);\n }\n};\n```", "response": "return @_loadingDiv\n\n _createOptions: (options = {}) ->\n defaultOptions = @defaultOptions\n newOptions = {}\n\n # Set options\n for k, v of defaultOptions\n newOptions[k] = if options[k]? then options[k] else v\n\n newOptions\n\n _changeLoadingHtml: ->\n @_readyToShowLoadingHtml = false\n\n loadingListener = =>\n @_readyToShowLoadingHtml = true\n @_loadingHtml.className = @_loadingHtml.className.replace(\" pg-loading \", \"\")\n if transitionEvent? then @_loadingHtml.removeEventListener(transitionEvent, loadingListener)\n if @_loadingHtmlToDisplay.length > 0 then @_changeLoadingHtml()\n\n removingListener = =>\n @_loadingHtml.innerHTML = @_loadingHtmlToDisplay.shift()\n @_loadingHtml.className = @_loadingHtml.className.replace(\" pg-removing \", \" pg-loading \")\n if transitionEvent?\n @_loadingHtml.removeEventListener(transitionEvent, removingListener)\n @_loadingHtml.addEventListener(transitionEvent, loadingListener)\n else\n loadingListener()\n\n if transitionEvent?\n @_loadingHtml.className += \" pg-removing \"\n @_loadingHtml.addEventListener(transitionEvent, removingListener)\n else\n removingListener()\n\n return {\n start : (options = {}) -> _pleaseWait.load(options)\n finish : -> _pleaseWait.done()\n updateLoadingHtml: (html) -> _pleaseWait.updateLoadingHtml(html)\n }", "source_lang": "JavaScript", "target_lang": "CoffeeScript", "repo": "Pathgather/please-wait", "path": "src/please-wait.coffee", "license": "MIT", "commit": "189d95b2c23eefe977465a3332b551ffa4fd58f3", "stars": 1583, "source_url": "https://github.com/Pathgather/please-wait/blob/189d95b2c23eefe977465a3332b551ffa4fd58f3/src/please-wait.coffee", "line_start": 91, "line_end": 131}622{"id": "Pathgather/please-wait:src/please-wait.coffee:3:completion", "type": "completion", "prompt": "return @_loadingDiv\n\n _createOptions: (options = {}) ->\n defaultOptions = @defaultOptions\n newOptions = {}\n\n # Set options\n for k, v of defaultOptions\n newOptions[k] = if options[k]? then options[k] else v\n\n newOptions\n\n _changeLoadingHtml: ->\n @_readyToShowLoadingHtml = false\n\n loadingListener = =>\n @_readyToShowLoadingHtml = true\n @_loadingHtml.className = @_loadingHtml.className.replace(\" pg-loading \", \"\")\n if transitionEvent? then @_loadingHtml.removeEventListener(transitionEvent, loadingListener)\n if @_loadingHtmlToDisplay.length > 0 then @_changeLoadingHtml()", "response": "removingListener = =>\n @_loadingHtml.innerHTML = @_loadingHtmlToDisplay.shift()\n @_loadingHtml.className = @_loadingHtml.className.replace(\" pg-removing \", \" pg-loading \")\n if transitionEvent?\n @_loadingHtml.removeEventListener(transitionEvent, removingListener)\n @_loadingHtml.addEventListener(transitionEvent, loadingListener)\n else\n loadingListener()\n\n if transitionEvent?\n @_loadingHtml.className += \" pg-removing \"\n @_loadingHtml.addEventListener(transitionEvent, removingListener)\n else\n removingListener()\n\n return {\n start : (options = {}) -> _pleaseWait.load(options)\n finish : -> _pleaseWait.done()\n updateLoadingHtml: (html) -> _pleaseWait.updateLoadingHtml(html)\n }", "source_lang": "CoffeeScript", "target_lang": "CoffeeScript", "repo": "Pathgather/please-wait", "path": "src/please-wait.coffee", "license": "MIT", "commit": "189d95b2c23eefe977465a3332b551ffa4fd58f3", "stars": 1583, "source_url": "https://github.com/Pathgather/please-wait/blob/189d95b2c23eefe977465a3332b551ffa4fd58f3/src/please-wait.coffee", "line_start": 91, "line_end": 131}623{"id": "Pathgather/please-wait:src/please-wait.coffee:1:raw_corpus", "type": "raw_corpus", "prompt": "", "response": "((root, factory) ->\n if typeof exports is \"object\"\n # CommonJS\n factory exports\n else if typeof define is \"function\" and define.amd\n # AMD. Register as an anonymous module.\n define [\"exports\"], factory\n else\n # Browser globals\n factory root\n return\n) this, (exports) ->\n PleaseWait = ->\n getTransitionEvent = ->\n el = document.createElement('fakeelement')\n transitions =\n 'WebkitAnimation': 'webkitAnimationEnd',\n 'OAnimation': 'oAnimationEnd',\n 'msAnimation': 'MSAnimationEnd',\n 'MozAnimation': 'mozAnimationEnd'\n 'animation' : 'animationend'\n\n for key, val of transitions\n return val if el.style[key]?\n\n _pleaseWait =\n defaultOptions:\n backgroundColor: null\n message: null\n showEllipsis: true\n logo: null\n spinnerTemplate: null\n template: \"\"\"\n <div class='pg-loading-inner'>\n <div class='pg-loading-center-outer'>\n <div class='pg-loading-center-middle'>\n <h1 class='pg-loading-logo-header'>\n <img class='pg-loading-logo'></img>\n </h1>\n <p class='pg-loading-message'>\n </p>\n <div class='pg-loading-spinner'>\n </div>\n </div>\n </div>\n </div>\n \"\"\"", "source_lang": "", "target_lang": "CoffeeScript", "repo": "Pathgather/please-wait", "path": "src/please-wait.coffee", "license": "MIT", "commit": "34cdadf989d209e8f622bc2880654c018ea5af8f", "stars": 1583, "source_url": "https://github.com/Pathgather/please-wait/blob/34cdadf989d209e8f622bc2880654c018ea5af8f/src/please-wait.coffee", "line_start": 1, "line_end": 47}624{"id": "Pathgather/please-wait:src/please-wait.coffee:1:coffee_to_js", "type": "coffee_to_js", "prompt": "Convert this CoffeeScript to JavaScript.\n```coffeescript\n((root, factory) ->\n if typeof exports is \"object\"\n # CommonJS\n factory exports\n else if typeof define is \"function\" and define.amd\n # AMD. Register as an anonymous module.\n define [\"exports\"], factory\n else\n # Browser globals\n factory root\n return\n) this, (exports) ->\n PleaseWait = ->\n getTransitionEvent = ->\n el = document.createElement('fakeelement')\n transitions =\n 'WebkitAnimation': 'webkitAnimationEnd',\n 'OAnimation': 'oAnimationEnd',\n 'msAnimation': 'MSAnimationEnd',\n 'MozAnimation': 'mozAnimationEnd'\n 'animation' : 'animationend'\n\n for key, val of transitions\n return val if el.style[key]?\n\n _pleaseWait =\n defaultOptions:\n backgroundColor: null\n message: null\n showEllipsis: true\n logo: null\n spinnerTemplate: null\n template: \"\"\"\n <div class='pg-loading-inner'>\n <div class='pg-loading-center-outer'>\n <div class='pg-loading-center-middle'>\n <h1 class='pg-loading-logo-header'>\n <img class='pg-loading-logo'></img>\n </h1>\n <p class='pg-loading-message'>\n </p>\n <div class='pg-loading-spinner'>\n </div>\n </div>\n </div>\n </div>\n \"\"\"\n```", "response": "(function(root, factory) {\n if (typeof exports === \"object\") {\n // CommonJS\n factory(exports);\n } else if (typeof define === \"function\" && define.amd) {\n // AMD. Register as an anonymous module.\n define([\"exports\"], factory);\n } else {\n // Browser globals\n factory(root);\n }\n})(this, function(exports) {\n var PleaseWait;\n return PleaseWait = function() {\n var _pleaseWait, getTransitionEvent;\n getTransitionEvent = function() {\n var el, key, transitions, val;\n el = document.createElement('fakeelement');\n transitions = {\n 'WebkitAnimation': 'webkitAnimationEnd',\n 'OAnimation': 'oAnimationEnd',\n 'msAnimation': 'MSAnimationEnd',\n 'MozAnimation': 'mozAnimationEnd',\n 'animation': 'animationend'\n };\n for (key in transitions) {\n val = transitions[key];\n if (el.style[key] != null) {\n return val;\n }\n }\n };\n return _pleaseWait = {\n defaultOptions: {\n backgroundColor: null,\n message: null,\n showEllipsis: true,\n logo: null,\n spinnerTemplate: null,\n template: `<div class='pg-loading-inner'>\n <div class='pg-loading-center-outer'>\n <div class='pg-loading-center-middle'>\n <h1 class='pg-loading-logo-header'>\n <img class='pg-loading-logo'></img>\n </h1>\n <p class='pg-loading-message'>\n </p>\n <div class='pg-loading-spinner'>\n </div>\n </div>\n </div>\n</div>`\n }\n };\n };\n});", "source_lang": "CoffeeScript", "target_lang": "JavaScript", "repo": "Pathgather/please-wait", "path": "src/please-wait.coffee", "license": "MIT", "commit": "34cdadf989d209e8f622bc2880654c018ea5af8f", "stars": 1583, "source_url": "https://github.com/Pathgather/please-wait/blob/34cdadf989d209e8f622bc2880654c018ea5af8f/src/please-wait.coffee", "line_start": 1, "line_end": 47}625{"id": "Pathgather/please-wait:src/please-wait.coffee:1:js_to_coffee", "type": "js_to_coffee", "prompt": "Convert this JavaScript to CoffeeScript.\n```javascript\n(function(root, factory) {\n if (typeof exports === \"object\") {\n // CommonJS\n factory(exports);\n } else if (typeof define === \"function\" && define.amd) {\n // AMD. Register as an anonymous module.\n define([\"exports\"], factory);\n } else {\n // Browser globals\n factory(root);\n }\n})(this, function(exports) {\n var PleaseWait;\n return PleaseWait = function() {\n var _pleaseWait, getTransitionEvent;\n getTransitionEvent = function() {\n var el, key, transitions, val;\n el = document.createElement('fakeelement');\n transitions = {\n 'WebkitAnimation': 'webkitAnimationEnd',\n 'OAnimation': 'oAnimationEnd',\n 'msAnimation': 'MSAnimationEnd',\n 'MozAnimation': 'mozAnimationEnd',\n 'animation': 'animationend'\n };\n for (key in transitions) {\n val = transitions[key];\n if (el.style[key] != null) {\n return val;\n }\n }\n };\n return _pleaseWait = {\n defaultOptions: {\n backgroundColor: null,\n message: null,\n showEllipsis: true,\n logo: null,\n spinnerTemplate: null,\n template: `<div class='pg-loading-inner'>\n <div class='pg-loading-center-outer'>\n <div class='pg-loading-center-middle'>\n <h1 class='pg-loading-logo-header'>\n <img class='pg-loading-logo'></img>\n </h1>\n <p class='pg-loading-message'>\n </p>\n <div class='pg-loading-spinner'>\n </div>\n </div>\n </div>\n</div>`\n }\n };\n };\n});\n```", "response": "((root, factory) ->\n if typeof exports is \"object\"\n # CommonJS\n factory exports\n else if typeof define is \"function\" and define.amd\n # AMD. Register as an anonymous module.\n define [\"exports\"], factory\n else\n # Browser globals\n factory root\n return\n) this, (exports) ->\n PleaseWait = ->\n getTransitionEvent = ->\n el = document.createElement('fakeelement')\n transitions =\n 'WebkitAnimation': 'webkitAnimationEnd',\n 'OAnimation': 'oAnimationEnd',\n 'msAnimation': 'MSAnimationEnd',\n 'MozAnimation': 'mozAnimationEnd'\n 'animation' : 'animationend'\n\n for key, val of transitions\n return val if el.style[key]?\n\n _pleaseWait =\n defaultOptions:\n backgroundColor: null\n message: null\n showEllipsis: true\n logo: null\n spinnerTemplate: null\n template: \"\"\"\n <div class='pg-loading-inner'>\n <div class='pg-loading-center-outer'>\n <div class='pg-loading-center-middle'>\n <h1 class='pg-loading-logo-header'>\n <img class='pg-loading-logo'></img>\n </h1>\n <p class='pg-loading-message'>\n </p>\n <div class='pg-loading-spinner'>\n </div>\n </div>\n </div>\n </div>\n \"\"\"", "source_lang": "JavaScript", "target_lang": "CoffeeScript", "repo": "Pathgather/please-wait", "path": "src/please-wait.coffee", "license": "MIT", "commit": "34cdadf989d209e8f622bc2880654c018ea5af8f", "stars": 1583, "source_url": "https://github.com/Pathgather/please-wait/blob/34cdadf989d209e8f622bc2880654c018ea5af8f/src/please-wait.coffee", "line_start": 1, "line_end": 47}626{"id": "Pathgather/please-wait:src/please-wait.coffee:1:completion", "type": "completion", "prompt": "((root, factory) ->\n if typeof exports is \"object\"\n # CommonJS\n factory exports\n else if typeof define is \"function\" and define.amd\n # AMD. Register as an anonymous module.\n define [\"exports\"], factory\n else\n # Browser globals\n factory root\n return\n) this, (exports) ->\n PleaseWait = ->\n getTransitionEvent = ->\n el = document.createElement('fakeelement')\n transitions =\n 'WebkitAnimation': 'webkitAnimationEnd',\n 'OAnimation': 'oAnimationEnd',\n 'msAnimation': 'MSAnimationEnd',\n 'MozAnimation': 'mozAnimationEnd'\n 'animation' : 'animationend'\n\n for key, val of transitions", "response": "return val if el.style[key]?\n\n _pleaseWait =\n defaultOptions:\n backgroundColor: null\n message: null\n showEllipsis: true\n logo: null\n spinnerTemplate: null\n template: \"\"\"\n <div class='pg-loading-inner'>\n <div class='pg-loading-center-outer'>\n <div class='pg-loading-center-middle'>\n <h1 class='pg-loading-logo-header'>\n <img class='pg-loading-logo'></img>\n </h1>\n <p class='pg-loading-message'>\n </p>\n <div class='pg-loading-spinner'>\n </div>\n </div>\n </div>\n </div>\n \"\"\"", "source_lang": "CoffeeScript", "target_lang": "CoffeeScript", "repo": "Pathgather/please-wait", "path": "src/please-wait.coffee", "license": "MIT", "commit": "34cdadf989d209e8f622bc2880654c018ea5af8f", "stars": 1583, "source_url": "https://github.com/Pathgather/please-wait/blob/34cdadf989d209e8f622bc2880654c018ea5af8f/src/please-wait.coffee", "line_start": 1, "line_end": 47}627{"id": "Pathgather/please-wait:src/please-wait.coffee:2:raw_corpus", "type": "raw_corpus", "prompt": "", "response": "done: ->\n return unless @_loadingDiv?\n transitionEvent = getTransitionEvent()\n listener = =>\n document.body.removeChild(@_loadingDiv)\n document.body.className += \" pg-loaded\"\n if transitionEvent? then @_loadingDiv.removeEventListener(transitionEvent, listener)\n @_loadingDiv = null\n\n if transitionEvent?\n @_loadingDiv.className += \" pg-loaded\"\n @_loadingDiv.addEventListener(transitionEvent, listener)\n else\n listener()\n\n load: (options = {}) ->\n @_options = @_createOptions(options)\n @_loadingDiv = document.createElement(\"header\")\n @_loadingDiv.className = \"pg-loading-screen\"\n @_loadingDiv.style.backgroundColor = @_options.backgroundColor if @_options.backgroundColor?\n @_loadingDiv.innerHTML = @_options.template\n spinnerDiv = @_loadingDiv.getElementsByClassName(\"pg-loading-spinner\")[0]\n logo = @_loadingDiv.getElementsByClassName(\"pg-loading-logo\")[0]\n messageDiv = @_loadingDiv.getElementsByClassName(\"pg-loading-message\")[0]\n\n if logo?\n logo.src = @_options.logo\n\n if spinnerDiv?\n if @_options.spinnerTemplate?\n spinnerDiv.innerHTML = @_options.spinnerTemplate\n else\n spinnerDiv.style.display = 'none'\n\n if messageDiv?\n if @_options.message?\n messageDiv.innerHTML = if @_options.showEllipsis\n \"\"\"\n #{@_options.message}\n <span class='ellipsis one'>.</span>\n <span class='ellipsis two'>.</span>\n <span class='ellipsis three'>.</span>\n \"\"\"\n else\n @_options.message\n else\n messageDiv.style.display = 'none'", "source_lang": "", "target_lang": "CoffeeScript", "repo": "Pathgather/please-wait", "path": "src/please-wait.coffee", "license": "MIT", "commit": "34cdadf989d209e8f622bc2880654c018ea5af8f", "stars": 1583, "source_url": "https://github.com/Pathgather/please-wait/blob/34cdadf989d209e8f622bc2880654c018ea5af8f/src/please-wait.coffee", "line_start": 49, "line_end": 95}628{"id": "Pathgather/please-wait:src/please-wait.coffee:2:coffee_to_js", "type": "coffee_to_js", "prompt": "Convert this CoffeeScript to JavaScript.\n```coffeescript\ndone: ->\n return unless @_loadingDiv?\n transitionEvent = getTransitionEvent()\n listener = =>\n document.body.removeChild(@_loadingDiv)\n document.body.className += \" pg-loaded\"\n if transitionEvent? then @_loadingDiv.removeEventListener(transitionEvent, listener)\n @_loadingDiv = null\n\n if transitionEvent?\n @_loadingDiv.className += \" pg-loaded\"\n @_loadingDiv.addEventListener(transitionEvent, listener)\n else\n listener()\n\n load: (options = {}) ->\n @_options = @_createOptions(options)\n @_loadingDiv = document.createElement(\"header\")\n @_loadingDiv.className = \"pg-loading-screen\"\n @_loadingDiv.style.backgroundColor = @_options.backgroundColor if @_options.backgroundColor?\n @_loadingDiv.innerHTML = @_options.template\n spinnerDiv = @_loadingDiv.getElementsByClassName(\"pg-loading-spinner\")[0]\n logo = @_loadingDiv.getElementsByClassName(\"pg-loading-logo\")[0]\n messageDiv = @_loadingDiv.getElementsByClassName(\"pg-loading-message\")[0]\n\n if logo?\n logo.src = @_options.logo\n\n if spinnerDiv?\n if @_options.spinnerTemplate?\n spinnerDiv.innerHTML = @_options.spinnerTemplate\n else\n spinnerDiv.style.display = 'none'\n\n if messageDiv?\n if @_options.message?\n messageDiv.innerHTML = if @_options.showEllipsis\n \"\"\"\n #{@_options.message}\n <span class='ellipsis one'>.</span>\n <span class='ellipsis two'>.</span>\n <span class='ellipsis three'>.</span>\n \"\"\"\n else\n @_options.message\n else\n messageDiv.style.display = 'none'\n```", "response": "({\n done: function() {\n var listener, transitionEvent;\n if (this._loadingDiv == null) {\n return;\n }\n transitionEvent = getTransitionEvent();\n listener = () => {\n document.body.removeChild(this._loadingDiv);\n document.body.className += \" pg-loaded\";\n if (transitionEvent != null) {\n this._loadingDiv.removeEventListener(transitionEvent, listener);\n }\n return this._loadingDiv = null;\n };\n if (transitionEvent != null) {\n this._loadingDiv.className += \" pg-loaded\";\n return this._loadingDiv.addEventListener(transitionEvent, listener);\n } else {\n return listener();\n }\n },\n load: function(options = {}) {\n var logo, messageDiv, spinnerDiv;\n this._options = this._createOptions(options);\n this._loadingDiv = document.createElement(\"header\");\n this._loadingDiv.className = \"pg-loading-screen\";\n if (this._options.backgroundColor != null) {\n this._loadingDiv.style.backgroundColor = this._options.backgroundColor;\n }\n this._loadingDiv.innerHTML = this._options.template;\n spinnerDiv = this._loadingDiv.getElementsByClassName(\"pg-loading-spinner\")[0];\n logo = this._loadingDiv.getElementsByClassName(\"pg-loading-logo\")[0];\n messageDiv = this._loadingDiv.getElementsByClassName(\"pg-loading-message\")[0];\n if (logo != null) {\n logo.src = this._options.logo;\n }\n if (spinnerDiv != null) {\n if (this._options.spinnerTemplate != null) {\n spinnerDiv.innerHTML = this._options.spinnerTemplate;\n } else {\n spinnerDiv.style.display = 'none';\n }\n }\n if (messageDiv != null) {\n if (this._options.message != null) {\n return messageDiv.innerHTML = this._options.showEllipsis ? `${this._options.message}\n<span class='ellipsis one'>.</span>\n<span class='ellipsis two'>.</span>\n<span class='ellipsis three'>.</span>` : this._options.message;\n } else {\n return messageDiv.style.display = 'none';\n }\n }\n }\n});", "source_lang": "CoffeeScript", "target_lang": "JavaScript", "repo": "Pathgather/please-wait", "path": "src/please-wait.coffee", "license": "MIT", "commit": "34cdadf989d209e8f622bc2880654c018ea5af8f", "stars": 1583, "source_url": "https://github.com/Pathgather/please-wait/blob/34cdadf989d209e8f622bc2880654c018ea5af8f/src/please-wait.coffee", "line_start": 49, "line_end": 95}629{"id": "Pathgather/please-wait:src/please-wait.coffee:2:js_to_coffee", "type": "js_to_coffee", "prompt": "Convert this JavaScript to CoffeeScript.\n```javascript\n({\n done: function() {\n var listener, transitionEvent;\n if (this._loadingDiv == null) {\n return;\n }\n transitionEvent = getTransitionEvent();\n listener = () => {\n document.body.removeChild(this._loadingDiv);\n document.body.className += \" pg-loaded\";\n if (transitionEvent != null) {\n this._loadingDiv.removeEventListener(transitionEvent, listener);\n }\n return this._loadingDiv = null;\n };\n if (transitionEvent != null) {\n this._loadingDiv.className += \" pg-loaded\";\n return this._loadingDiv.addEventListener(transitionEvent, listener);\n } else {\n return listener();\n }\n },\n load: function(options = {}) {\n var logo, messageDiv, spinnerDiv;\n this._options = this._createOptions(options);\n this._loadingDiv = document.createElement(\"header\");\n this._loadingDiv.className = \"pg-loading-screen\";\n if (this._options.backgroundColor != null) {\n this._loadingDiv.style.backgroundColor = this._options.backgroundColor;\n }\n this._loadingDiv.innerHTML = this._options.template;\n spinnerDiv = this._loadingDiv.getElementsByClassName(\"pg-loading-spinner\")[0];\n logo = this._loadingDiv.getElementsByClassName(\"pg-loading-logo\")[0];\n messageDiv = this._loadingDiv.getElementsByClassName(\"pg-loading-message\")[0];\n if (logo != null) {\n logo.src = this._options.logo;\n }\n if (spinnerDiv != null) {\n if (this._options.spinnerTemplate != null) {\n spinnerDiv.innerHTML = this._options.spinnerTemplate;\n } else {\n spinnerDiv.style.display = 'none';\n }\n }\n if (messageDiv != null) {\n if (this._options.message != null) {\n return messageDiv.innerHTML = this._options.showEllipsis ? `${this._options.message}\n<span class='ellipsis one'>.</span>\n<span class='ellipsis two'>.</span>\n<span class='ellipsis three'>.</span>` : this._options.message;\n } else {\n return messageDiv.style.display = 'none';\n }\n }\n }\n});\n```", "response": "done: ->\n return unless @_loadingDiv?\n transitionEvent = getTransitionEvent()\n listener = =>\n document.body.removeChild(@_loadingDiv)\n document.body.className += \" pg-loaded\"\n if transitionEvent? then @_loadingDiv.removeEventListener(transitionEvent, listener)\n @_loadingDiv = null\n\n if transitionEvent?\n @_loadingDiv.className += \" pg-loaded\"\n @_loadingDiv.addEventListener(transitionEvent, listener)\n else\n listener()\n\n load: (options = {}) ->\n @_options = @_createOptions(options)\n @_loadingDiv = document.createElement(\"header\")\n @_loadingDiv.className = \"pg-loading-screen\"\n @_loadingDiv.style.backgroundColor = @_options.backgroundColor if @_options.backgroundColor?\n @_loadingDiv.innerHTML = @_options.template\n spinnerDiv = @_loadingDiv.getElementsByClassName(\"pg-loading-spinner\")[0]\n logo = @_loadingDiv.getElementsByClassName(\"pg-loading-logo\")[0]\n messageDiv = @_loadingDiv.getElementsByClassName(\"pg-loading-message\")[0]\n\n if logo?\n logo.src = @_options.logo\n\n if spinnerDiv?\n if @_options.spinnerTemplate?\n spinnerDiv.innerHTML = @_options.spinnerTemplate\n else\n spinnerDiv.style.display = 'none'\n\n if messageDiv?\n if @_options.message?\n messageDiv.innerHTML = if @_options.showEllipsis\n \"\"\"\n #{@_options.message}\n <span class='ellipsis one'>.</span>\n <span class='ellipsis two'>.</span>\n <span class='ellipsis three'>.</span>\n \"\"\"\n else\n @_options.message\n else\n messageDiv.style.display = 'none'", "source_lang": "JavaScript", "target_lang": "CoffeeScript", "repo": "Pathgather/please-wait", "path": "src/please-wait.coffee", "license": "MIT", "commit": "34cdadf989d209e8f622bc2880654c018ea5af8f", "stars": 1583, "source_url": "https://github.com/Pathgather/please-wait/blob/34cdadf989d209e8f622bc2880654c018ea5af8f/src/please-wait.coffee", "line_start": 49, "line_end": 95}630{"id": "Pathgather/please-wait:src/please-wait.coffee:2:completion", "type": "completion", "prompt": "done: ->\n return unless @_loadingDiv?\n transitionEvent = getTransitionEvent()\n listener = =>\n document.body.removeChild(@_loadingDiv)\n document.body.className += \" pg-loaded\"\n if transitionEvent? then @_loadingDiv.removeEventListener(transitionEvent, listener)\n @_loadingDiv = null\n\n if transitionEvent?\n @_loadingDiv.className += \" pg-loaded\"\n @_loadingDiv.addEventListener(transitionEvent, listener)\n else\n listener()\n\n load: (options = {}) ->\n @_options = @_createOptions(options)\n @_loadingDiv = document.createElement(\"header\")\n @_loadingDiv.className = \"pg-loading-screen\"\n @_loadingDiv.style.backgroundColor = @_options.backgroundColor if @_options.backgroundColor?\n @_loadingDiv.innerHTML = @_options.template\n spinnerDiv = @_loadingDiv.getElementsByClassName(\"pg-loading-spinner\")[0]\n logo = @_loadingDiv.getElementsByClassName(\"pg-loading-logo\")[0]", "response": "messageDiv = @_loadingDiv.getElementsByClassName(\"pg-loading-message\")[0]\n\n if logo?\n logo.src = @_options.logo\n\n if spinnerDiv?\n if @_options.spinnerTemplate?\n spinnerDiv.innerHTML = @_options.spinnerTemplate\n else\n spinnerDiv.style.display = 'none'\n\n if messageDiv?\n if @_options.message?\n messageDiv.innerHTML = if @_options.showEllipsis\n \"\"\"\n #{@_options.message}\n <span class='ellipsis one'>.</span>\n <span class='ellipsis two'>.</span>\n <span class='ellipsis three'>.</span>\n \"\"\"\n else\n @_options.message\n else\n messageDiv.style.display = 'none'", "source_lang": "CoffeeScript", "target_lang": "CoffeeScript", "repo": "Pathgather/please-wait", "path": "src/please-wait.coffee", "license": "MIT", "commit": "34cdadf989d209e8f622bc2880654c018ea5af8f", "stars": 1583, "source_url": "https://github.com/Pathgather/please-wait/blob/34cdadf989d209e8f622bc2880654c018ea5af8f/src/please-wait.coffee", "line_start": 49, "line_end": 95}631{"id": "Pathgather/please-wait:src/please-wait.coffee:3:raw_corpus", "type": "raw_corpus", "prompt": "", "response": "document.body.appendChild(@_loadingDiv)\n @_loadingDiv.className += \" pg-loading\"\n return @_loadingDiv\n\n _createOptions: (options = {}) ->\n defaultOptions = @defaultOptions\n newOptions = {}\n\n # Set options\n for k, v of defaultOptions\n newOptions[k] = if options[k]? then options[k] else v\n\n newOptions\n\n return {\n start : (options = {}) -> _pleaseWait.load(options)\n finish : -> _pleaseWait.done()\n }\n\n exports.pleaseWait = new PleaseWait()", "source_lang": "", "target_lang": "CoffeeScript", "repo": "Pathgather/please-wait", "path": "src/please-wait.coffee", "license": "MIT", "commit": "34cdadf989d209e8f622bc2880654c018ea5af8f", "stars": 1583, "source_url": "https://github.com/Pathgather/please-wait/blob/34cdadf989d209e8f622bc2880654c018ea5af8f/src/please-wait.coffee", "line_start": 97, "line_end": 116}632{"id": "Pathgather/please-wait:src/please-wait.coffee:3:completion", "type": "completion", "prompt": "document.body.appendChild(@_loadingDiv)\n @_loadingDiv.className += \" pg-loading\"\n return @_loadingDiv\n\n _createOptions: (options = {}) ->\n defaultOptions = @defaultOptions\n newOptions = {}\n\n # Set options\n for k, v of defaultOptions", "response": "newOptions[k] = if options[k]? then options[k] else v\n\n newOptions\n\n return {\n start : (options = {}) -> _pleaseWait.load(options)\n finish : -> _pleaseWait.done()\n }\n\n exports.pleaseWait = new PleaseWait()", "source_lang": "CoffeeScript", "target_lang": "CoffeeScript", "repo": "Pathgather/please-wait", "path": "src/please-wait.coffee", "license": "MIT", "commit": "34cdadf989d209e8f622bc2880654c018ea5af8f", "stars": 1583, "source_url": "https://github.com/Pathgather/please-wait/blob/34cdadf989d209e8f622bc2880654c018ea5af8f/src/please-wait.coffee", "line_start": 97, "line_end": 116}633{"id": "cdglabs/apparatus:src/View/Generic/EditableText.coffee:1:raw_corpus", "type": "raw_corpus", "prompt": "", "response": "_ = require \"underscore\"\nR = require \"../R\"\n\nR.create \"EditableText\",\n propTypes:\n value: String\n setValue: Function\n\n shouldComponentUpdate: (nextProps) ->\n return @_isDirty or nextProps.value != @props.value\n\n render: ->\n props = {\n contentEditable: true\n onInput: @_onInput\n onKeyDown: @_onKeyDown\n }\n _.defaults(props, @props)\n R.div props\n\n componentDidMount: ->\n @_refresh()\n # Autofocus if empty string value.\n if @props.value == \"\" or !@props.value\n R.findDOMNode(@).focus()\n\n componentDidUpdate: ->\n @_refresh()\n\n _refresh: ->\n el = R.findDOMNode(@)\n if el.textContent != @props.value\n el.textContent = @props.value\n @_isDirty = false\n\n _onInput: ->\n @_isDirty = true\n el = R.findDOMNode(@)\n newValue = el.textContent\n @props.setValue(newValue)\n\n _onKeyDown: (e) ->\n if e.keyCode == 13 # Enter\n e.preventDefault()", "source_lang": "", "target_lang": "CoffeeScript", "repo": "cdglabs/apparatus", "path": "src/View/Generic/EditableText.coffee", "license": "MIT", "commit": "107e0c2db5a0adf0f1c3b49f16f7625cff4e523b", "stars": 1052, "source_url": "https://github.com/cdglabs/apparatus/blob/107e0c2db5a0adf0f1c3b49f16f7625cff4e523b/src/View/Generic/EditableText.coffee", "line_start": 1, "line_end": 44}634{"id": "cdglabs/apparatus:src/View/Generic/EditableText.coffee:1:coffee_to_js", "type": "coffee_to_js", "prompt": "Convert this CoffeeScript to JavaScript.\n```coffeescript\n_ = require \"underscore\"\nR = require \"../R\"\n\nR.create \"EditableText\",\n propTypes:\n value: String\n setValue: Function\n\n shouldComponentUpdate: (nextProps) ->\n return @_isDirty or nextProps.value != @props.value\n\n render: ->\n props = {\n contentEditable: true\n onInput: @_onInput\n onKeyDown: @_onKeyDown\n }\n _.defaults(props, @props)\n R.div props\n\n componentDidMount: ->\n @_refresh()\n # Autofocus if empty string value.\n if @props.value == \"\" or !@props.value\n R.findDOMNode(@).focus()\n\n componentDidUpdate: ->\n @_refresh()\n\n _refresh: ->\n el = R.findDOMNode(@)\n if el.textContent != @props.value\n el.textContent = @props.value\n @_isDirty = false\n\n _onInput: ->\n @_isDirty = true\n el = R.findDOMNode(@)\n newValue = el.textContent\n @props.setValue(newValue)\n\n _onKeyDown: (e) ->\n if e.keyCode == 13 # Enter\n e.preventDefault()\n```", "response": "var R, _;\n\n_ = require(\"underscore\");\n\nR = require(\"../R\");\n\nR.create(\"EditableText\", {\n propTypes: {\n value: String,\n setValue: Function\n },\n shouldComponentUpdate: function(nextProps) {\n return this._isDirty || nextProps.value !== this.props.value;\n },\n render: function() {\n var props;\n props = {\n contentEditable: true,\n onInput: this._onInput,\n onKeyDown: this._onKeyDown\n };\n _.defaults(props, this.props);\n return R.div(props);\n },\n componentDidMount: function() {\n this._refresh();\n // Autofocus if empty string value.\n if (this.props.value === \"\" || !this.props.value) {\n return R.findDOMNode(this).focus();\n }\n },\n componentDidUpdate: function() {\n return this._refresh();\n },\n _refresh: function() {\n var el;\n el = R.findDOMNode(this);\n if (el.textContent !== this.props.value) {\n el.textContent = this.props.value;\n }\n return this._isDirty = false;\n },\n _onInput: function() {\n var el, newValue;\n this._isDirty = true;\n el = R.findDOMNode(this);\n newValue = el.textContent;\n return this.props.setValue(newValue);\n },\n _onKeyDown: function(e) {\n if (e.keyCode === 13) { // Enter\n return e.preventDefault();\n }\n }\n});", "source_lang": "CoffeeScript", "target_lang": "JavaScript", "repo": "cdglabs/apparatus", "path": "src/View/Generic/EditableText.coffee", "license": "MIT", "commit": "107e0c2db5a0adf0f1c3b49f16f7625cff4e523b", "stars": 1052, "source_url": "https://github.com/cdglabs/apparatus/blob/107e0c2db5a0adf0f1c3b49f16f7625cff4e523b/src/View/Generic/EditableText.coffee", "line_start": 1, "line_end": 44}635{"id": "cdglabs/apparatus:src/View/Generic/EditableText.coffee:1:js_to_coffee", "type": "js_to_coffee", "prompt": "Convert this JavaScript to CoffeeScript.\n```javascript\nvar R, _;\n\n_ = require(\"underscore\");\n\nR = require(\"../R\");\n\nR.create(\"EditableText\", {\n propTypes: {\n value: String,\n setValue: Function\n },\n shouldComponentUpdate: function(nextProps) {\n return this._isDirty || nextProps.value !== this.props.value;\n },\n render: function() {\n var props;\n props = {\n contentEditable: true,\n onInput: this._onInput,\n onKeyDown: this._onKeyDown\n };\n _.defaults(props, this.props);\n return R.div(props);\n },\n componentDidMount: function() {\n this._refresh();\n // Autofocus if empty string value.\n if (this.props.value === \"\" || !this.props.value) {\n return R.findDOMNode(this).focus();\n }\n },\n componentDidUpdate: function() {\n return this._refresh();\n },\n _refresh: function() {\n var el;\n el = R.findDOMNode(this);\n if (el.textContent !== this.props.value) {\n el.textContent = this.props.value;\n }\n return this._isDirty = false;\n },\n _onInput: function() {\n var el, newValue;\n this._isDirty = true;\n el = R.findDOMNode(this);\n newValue = el.textContent;\n return this.props.setValue(newValue);\n },\n _onKeyDown: function(e) {\n if (e.keyCode === 13) { // Enter\n return e.preventDefault();\n }\n }\n});\n```", "response": "_ = require \"underscore\"\nR = require \"../R\"\n\nR.create \"EditableText\",\n propTypes:\n value: String\n setValue: Function\n\n shouldComponentUpdate: (nextProps) ->\n return @_isDirty or nextProps.value != @props.value\n\n render: ->\n props = {\n contentEditable: true\n onInput: @_onInput\n onKeyDown: @_onKeyDown\n }\n _.defaults(props, @props)\n R.div props\n\n componentDidMount: ->\n @_refresh()\n # Autofocus if empty string value.\n if @props.value == \"\" or !@props.value\n R.findDOMNode(@).focus()\n\n componentDidUpdate: ->\n @_refresh()\n\n _refresh: ->\n el = R.findDOMNode(@)\n if el.textContent != @props.value\n el.textContent = @props.value\n @_isDirty = false\n\n _onInput: ->\n @_isDirty = true\n el = R.findDOMNode(@)\n newValue = el.textContent\n @props.setValue(newValue)\n\n _onKeyDown: (e) ->\n if e.keyCode == 13 # Enter\n e.preventDefault()", "source_lang": "JavaScript", "target_lang": "CoffeeScript", "repo": "cdglabs/apparatus", "path": "src/View/Generic/EditableText.coffee", "license": "MIT", "commit": "107e0c2db5a0adf0f1c3b49f16f7625cff4e523b", "stars": 1052, "source_url": "https://github.com/cdglabs/apparatus/blob/107e0c2db5a0adf0f1c3b49f16f7625cff4e523b/src/View/Generic/EditableText.coffee", "line_start": 1, "line_end": 44}636{"id": "cdglabs/apparatus:src/View/Generic/EditableText.coffee:1:completion", "type": "completion", "prompt": "_ = require \"underscore\"\nR = require \"../R\"\n\nR.create \"EditableText\",\n propTypes:\n value: String\n setValue: Function\n\n shouldComponentUpdate: (nextProps) ->\n return @_isDirty or nextProps.value != @props.value\n\n render: ->\n props = {\n contentEditable: true\n onInput: @_onInput\n onKeyDown: @_onKeyDown\n }\n _.defaults(props, @props)\n R.div props\n\n componentDidMount: ->\n @_refresh()", "response": "# Autofocus if empty string value.\n if @props.value == \"\" or !@props.value\n R.findDOMNode(@).focus()\n\n componentDidUpdate: ->\n @_refresh()\n\n _refresh: ->\n el = R.findDOMNode(@)\n if el.textContent != @props.value\n el.textContent = @props.value\n @_isDirty = false\n\n _onInput: ->\n @_isDirty = true\n el = R.findDOMNode(@)\n newValue = el.textContent\n @props.setValue(newValue)\n\n _onKeyDown: (e) ->\n if e.keyCode == 13 # Enter\n e.preventDefault()", "source_lang": "CoffeeScript", "target_lang": "CoffeeScript", "repo": "cdglabs/apparatus", "path": "src/View/Generic/EditableText.coffee", "license": "MIT", "commit": "107e0c2db5a0adf0f1c3b49f16f7625cff4e523b", "stars": 1052, "source_url": "https://github.com/cdglabs/apparatus/blob/107e0c2db5a0adf0f1c3b49f16f7625cff4e523b/src/View/Generic/EditableText.coffee", "line_start": 1, "line_end": 44}637{"id": "cdglabs/apparatus:src/View/Generic/EditableText.coffee:1:raw_corpus", "type": "raw_corpus", "prompt": "", "response": "_ = require \"underscore\"\nR = require \"../R\"\n\nR.create \"EditableText\",\n propTypes:\n value: String\n setValue: Function\n\n shouldComponentUpdate: (nextProps) ->\n return @_isDirty or nextProps.value != @props.value\n\n render: ->\n props = {\n contentEditable: true\n onInput: @_onInput\n onKeyDown: @_onKeyDown\n }\n _.defaults(props, @props)\n R.div props\n\n componentDidMount: ->\n @_refresh()\n # Autofocus if empty string value.\n if @props.value == \"\" or !@props.value\n @getDOMNode().focus()\n\n componentDidUpdate: ->\n @_refresh()\n\n _refresh: ->\n el = @getDOMNode()\n if el.textContent != @props.value\n el.textContent = @props.value\n @_isDirty = false\n\n _onInput: ->\n @_isDirty = true\n el = @getDOMNode()\n newValue = el.textContent\n @props.setValue(newValue)\n\n _onKeyDown: (e) ->\n if e.keyCode == 13 # Enter\n e.preventDefault()", "source_lang": "", "target_lang": "CoffeeScript", "repo": "cdglabs/apparatus", "path": "src/View/Generic/EditableText.coffee", "license": "MIT", "commit": "44bda500915b664456170b39144f1d5a40e73d24", "stars": 1052, "source_url": "https://github.com/cdglabs/apparatus/blob/44bda500915b664456170b39144f1d5a40e73d24/src/View/Generic/EditableText.coffee", "line_start": 1, "line_end": 44}638{"id": "cdglabs/apparatus:src/View/Generic/EditableText.coffee:1:coffee_to_js", "type": "coffee_to_js", "prompt": "Convert this CoffeeScript to JavaScript.\n```coffeescript\n_ = require \"underscore\"\nR = require \"../R\"\n\nR.create \"EditableText\",\n propTypes:\n value: String\n setValue: Function\n\n shouldComponentUpdate: (nextProps) ->\n return @_isDirty or nextProps.value != @props.value\n\n render: ->\n props = {\n contentEditable: true\n onInput: @_onInput\n onKeyDown: @_onKeyDown\n }\n _.defaults(props, @props)\n R.div props\n\n componentDidMount: ->\n @_refresh()\n # Autofocus if empty string value.\n if @props.value == \"\" or !@props.value\n @getDOMNode().focus()\n\n componentDidUpdate: ->\n @_refresh()\n\n _refresh: ->\n el = @getDOMNode()\n if el.textContent != @props.value\n el.textContent = @props.value\n @_isDirty = false\n\n _onInput: ->\n @_isDirty = true\n el = @getDOMNode()\n newValue = el.textContent\n @props.setValue(newValue)\n\n _onKeyDown: (e) ->\n if e.keyCode == 13 # Enter\n e.preventDefault()\n```", "response": "var R, _;\n\n_ = require(\"underscore\");\n\nR = require(\"../R\");\n\nR.create(\"EditableText\", {\n propTypes: {\n value: String,\n setValue: Function\n },\n shouldComponentUpdate: function(nextProps) {\n return this._isDirty || nextProps.value !== this.props.value;\n },\n render: function() {\n var props;\n props = {\n contentEditable: true,\n onInput: this._onInput,\n onKeyDown: this._onKeyDown\n };\n _.defaults(props, this.props);\n return R.div(props);\n },\n componentDidMount: function() {\n this._refresh();\n // Autofocus if empty string value.\n if (this.props.value === \"\" || !this.props.value) {\n return this.getDOMNode().focus();\n }\n },\n componentDidUpdate: function() {\n return this._refresh();\n },\n _refresh: function() {\n var el;\n el = this.getDOMNode();\n if (el.textContent !== this.props.value) {\n el.textContent = this.props.value;\n }\n return this._isDirty = false;\n },\n _onInput: function() {\n var el, newValue;\n this._isDirty = true;\n el = this.getDOMNode();\n newValue = el.textContent;\n return this.props.setValue(newValue);\n },\n _onKeyDown: function(e) {\n if (e.keyCode === 13) { // Enter\n return e.preventDefault();\n }\n }\n});", "source_lang": "CoffeeScript", "target_lang": "JavaScript", "repo": "cdglabs/apparatus", "path": "src/View/Generic/EditableText.coffee", "license": "MIT", "commit": "44bda500915b664456170b39144f1d5a40e73d24", "stars": 1052, "source_url": "https://github.com/cdglabs/apparatus/blob/44bda500915b664456170b39144f1d5a40e73d24/src/View/Generic/EditableText.coffee", "line_start": 1, "line_end": 44}639{"id": "cdglabs/apparatus:src/View/Generic/EditableText.coffee:1:js_to_coffee", "type": "js_to_coffee", "prompt": "Convert this JavaScript to CoffeeScript.\n```javascript\nvar R, _;\n\n_ = require(\"underscore\");\n\nR = require(\"../R\");\n\nR.create(\"EditableText\", {\n propTypes: {\n value: String,\n setValue: Function\n },\n shouldComponentUpdate: function(nextProps) {\n return this._isDirty || nextProps.value !== this.props.value;\n },\n render: function() {\n var props;\n props = {\n contentEditable: true,\n onInput: this._onInput,\n onKeyDown: this._onKeyDown\n };\n _.defaults(props, this.props);\n return R.div(props);\n },\n componentDidMount: function() {\n this._refresh();\n // Autofocus if empty string value.\n if (this.props.value === \"\" || !this.props.value) {\n return this.getDOMNode().focus();\n }\n },\n componentDidUpdate: function() {\n return this._refresh();\n },\n _refresh: function() {\n var el;\n el = this.getDOMNode();\n if (el.textContent !== this.props.value) {\n el.textContent = this.props.value;\n }\n return this._isDirty = false;\n },\n _onInput: function() {\n var el, newValue;\n this._isDirty = true;\n el = this.getDOMNode();\n newValue = el.textContent;\n return this.props.setValue(newValue);\n },\n _onKeyDown: function(e) {\n if (e.keyCode === 13) { // Enter\n return e.preventDefault();\n }\n }\n});\n```", "response": "_ = require \"underscore\"\nR = require \"../R\"\n\nR.create \"EditableText\",\n propTypes:\n value: String\n setValue: Function\n\n shouldComponentUpdate: (nextProps) ->\n return @_isDirty or nextProps.value != @props.value\n\n render: ->\n props = {\n contentEditable: true\n onInput: @_onInput\n onKeyDown: @_onKeyDown\n }\n _.defaults(props, @props)\n R.div props\n\n componentDidMount: ->\n @_refresh()\n # Autofocus if empty string value.\n if @props.value == \"\" or !@props.value\n @getDOMNode().focus()\n\n componentDidUpdate: ->\n @_refresh()\n\n _refresh: ->\n el = @getDOMNode()\n if el.textContent != @props.value\n el.textContent = @props.value\n @_isDirty = false\n\n _onInput: ->\n @_isDirty = true\n el = @getDOMNode()\n newValue = el.textContent\n @props.setValue(newValue)\n\n _onKeyDown: (e) ->\n if e.keyCode == 13 # Enter\n e.preventDefault()", "source_lang": "JavaScript", "target_lang": "CoffeeScript", "repo": "cdglabs/apparatus", "path": "src/View/Generic/EditableText.coffee", "license": "MIT", "commit": "44bda500915b664456170b39144f1d5a40e73d24", "stars": 1052, "source_url": "https://github.com/cdglabs/apparatus/blob/44bda500915b664456170b39144f1d5a40e73d24/src/View/Generic/EditableText.coffee", "line_start": 1, "line_end": 44}640{"id": "cdglabs/apparatus:src/View/Generic/EditableText.coffee:1:completion", "type": "completion", "prompt": "_ = require \"underscore\"\nR = require \"../R\"\n\nR.create \"EditableText\",\n propTypes:\n value: String\n setValue: Function\n\n shouldComponentUpdate: (nextProps) ->\n return @_isDirty or nextProps.value != @props.value\n\n render: ->\n props = {\n contentEditable: true\n onInput: @_onInput\n onKeyDown: @_onKeyDown\n }\n _.defaults(props, @props)\n R.div props\n\n componentDidMount: ->\n @_refresh()", "response": "# Autofocus if empty string value.\n if @props.value == \"\" or !@props.value\n @getDOMNode().focus()\n\n componentDidUpdate: ->\n @_refresh()\n\n _refresh: ->\n el = @getDOMNode()\n if el.textContent != @props.value\n el.textContent = @props.value\n @_isDirty = false\n\n _onInput: ->\n @_isDirty = true\n el = @getDOMNode()\n newValue = el.textContent\n @props.setValue(newValue)\n\n _onKeyDown: (e) ->\n if e.keyCode == 13 # Enter\n e.preventDefault()", "source_lang": "CoffeeScript", "target_lang": "CoffeeScript", "repo": "cdglabs/apparatus", "path": "src/View/Generic/EditableText.coffee", "license": "MIT", "commit": "44bda500915b664456170b39144f1d5a40e73d24", "stars": 1052, "source_url": "https://github.com/cdglabs/apparatus/blob/44bda500915b664456170b39144f1d5a40e73d24/src/View/Generic/EditableText.coffee", "line_start": 1, "line_end": 44}641{"id": "jsdf/coffee-react-transform:src/transformer.coffee:1:raw_corpus", "type": "raw_corpus", "prompt": "", "response": "Parser = require './parser'\nserialise = require './serialiser'\n\nmodule.exports.transform = (code, opts) ->\n serialise(new Parser().parse(code, opts), opts)", "source_lang": "", "target_lang": "CoffeeScript", "repo": "jsdf/coffee-react-transform", "path": "src/transformer.coffee", "license": "MIT", "commit": "873ab44f13a863c6783f3c90993541f1df6a0320", "stars": 431, "source_url": "https://github.com/jsdf/coffee-react-transform/blob/873ab44f13a863c6783f3c90993541f1df6a0320/src/transformer.coffee", "line_start": 1, "line_end": 5}642{"id": "jsdf/coffee-react-transform:src/transformer.coffee:1:coffee_to_js", "type": "coffee_to_js", "prompt": "Convert this CoffeeScript to JavaScript.\n```coffeescript\nParser = require './parser'\nserialise = require './serialiser'\n\nmodule.exports.transform = (code, opts) ->\n serialise(new Parser().parse(code, opts), opts)\n```", "response": "var Parser, serialise;\n\nParser = require('./parser');\n\nserialise = require('./serialiser');\n\nmodule.exports.transform = function(code, opts) {\n return serialise(new Parser().parse(code, opts), opts);\n};", "source_lang": "CoffeeScript", "target_lang": "JavaScript", "repo": "jsdf/coffee-react-transform", "path": "src/transformer.coffee", "license": "MIT", "commit": "873ab44f13a863c6783f3c90993541f1df6a0320", "stars": 431, "source_url": "https://github.com/jsdf/coffee-react-transform/blob/873ab44f13a863c6783f3c90993541f1df6a0320/src/transformer.coffee", "line_start": 1, "line_end": 5}643{"id": "jsdf/coffee-react-transform:src/transformer.coffee:1:js_to_coffee", "type": "js_to_coffee", "prompt": "Convert this JavaScript to CoffeeScript.\n```javascript\nvar Parser, serialise;\n\nParser = require('./parser');\n\nserialise = require('./serialiser');\n\nmodule.exports.transform = function(code, opts) {\n return serialise(new Parser().parse(code, opts), opts);\n};\n```", "response": "Parser = require './parser'\nserialise = require './serialiser'\n\nmodule.exports.transform = (code, opts) ->\n serialise(new Parser().parse(code, opts), opts)", "source_lang": "JavaScript", "target_lang": "CoffeeScript", "repo": "jsdf/coffee-react-transform", "path": "src/transformer.coffee", "license": "MIT", "commit": "873ab44f13a863c6783f3c90993541f1df6a0320", "stars": 431, "source_url": "https://github.com/jsdf/coffee-react-transform/blob/873ab44f13a863c6783f3c90993541f1df6a0320/src/transformer.coffee", "line_start": 1, "line_end": 5}644{"id": "jsdf/coffee-react-transform:src/transformer.coffee:1:completion", "type": "completion", "prompt": "Parser = require './parser'\nserialise = require './serialiser'", "response": "module.exports.transform = (code, opts) ->\n serialise(new Parser().parse(code, opts), opts)", "source_lang": "CoffeeScript", "target_lang": "CoffeeScript", "repo": "jsdf/coffee-react-transform", "path": "src/transformer.coffee", "license": "MIT", "commit": "873ab44f13a863c6783f3c90993541f1df6a0320", "stars": 431, "source_url": "https://github.com/jsdf/coffee-react-transform/blob/873ab44f13a863c6783f3c90993541f1df6a0320/src/transformer.coffee", "line_start": 1, "line_end": 5}645{"id": "jsdf/coffee-react-transform:src/transformer.coffee:1:raw_corpus", "type": "raw_corpus", "prompt": "", "response": "Parser = require './parser'\nserialise = require './serialiser'\n\nmodule.exports.transform = (code, opts) ->\n serialise(new Parser().parse(code, opts))", "source_lang": "", "target_lang": "CoffeeScript", "repo": "jsdf/coffee-react-transform", "path": "src/transformer.coffee", "license": "MIT", "commit": "4db08bfaf81c7d4092ea28342aa77de042dba7e9", "stars": 431, "source_url": "https://github.com/jsdf/coffee-react-transform/blob/4db08bfaf81c7d4092ea28342aa77de042dba7e9/src/transformer.coffee", "line_start": 1, "line_end": 5}646{"id": "jsdf/coffee-react-transform:src/transformer.coffee:1:coffee_to_js", "type": "coffee_to_js", "prompt": "Convert this CoffeeScript to JavaScript.\n```coffeescript\nParser = require './parser'\nserialise = require './serialiser'\n\nmodule.exports.transform = (code, opts) ->\n serialise(new Parser().parse(code, opts))\n```", "response": "var Parser, serialise;\n\nParser = require('./parser');\n\nserialise = require('./serialiser');\n\nmodule.exports.transform = function(code, opts) {\n return serialise(new Parser().parse(code, opts));\n};", "source_lang": "CoffeeScript", "target_lang": "JavaScript", "repo": "jsdf/coffee-react-transform", "path": "src/transformer.coffee", "license": "MIT", "commit": "4db08bfaf81c7d4092ea28342aa77de042dba7e9", "stars": 431, "source_url": "https://github.com/jsdf/coffee-react-transform/blob/4db08bfaf81c7d4092ea28342aa77de042dba7e9/src/transformer.coffee", "line_start": 1, "line_end": 5}647{"id": "jsdf/coffee-react-transform:src/transformer.coffee:1:js_to_coffee", "type": "js_to_coffee", "prompt": "Convert this JavaScript to CoffeeScript.\n```javascript\nvar Parser, serialise;\n\nParser = require('./parser');\n\nserialise = require('./serialiser');\n\nmodule.exports.transform = function(code, opts) {\n return serialise(new Parser().parse(code, opts));\n};\n```", "response": "Parser = require './parser'\nserialise = require './serialiser'\n\nmodule.exports.transform = (code, opts) ->\n serialise(new Parser().parse(code, opts))", "source_lang": "JavaScript", "target_lang": "CoffeeScript", "repo": "jsdf/coffee-react-transform", "path": "src/transformer.coffee", "license": "MIT", "commit": "4db08bfaf81c7d4092ea28342aa77de042dba7e9", "stars": 431, "source_url": "https://github.com/jsdf/coffee-react-transform/blob/4db08bfaf81c7d4092ea28342aa77de042dba7e9/src/transformer.coffee", "line_start": 1, "line_end": 5}648{"id": "jsdf/coffee-react-transform:src/transformer.coffee:1:completion", "type": "completion", "prompt": "Parser = require './parser'\nserialise = require './serialiser'", "response": "module.exports.transform = (code, opts) ->\n serialise(new Parser().parse(code, opts))", "source_lang": "CoffeeScript", "target_lang": "CoffeeScript", "repo": "jsdf/coffee-react-transform", "path": "src/transformer.coffee", "license": "MIT", "commit": "4db08bfaf81c7d4092ea28342aa77de042dba7e9", "stars": 431, "source_url": "https://github.com/jsdf/coffee-react-transform/blob/4db08bfaf81c7d4092ea28342aa77de042dba7e9/src/transformer.coffee", "line_start": 1, "line_end": 5}649{"id": "jsdf/coffee-react-transform:src/transformer.coffee:1:raw_corpus", "type": "raw_corpus", "prompt": "", "response": "# Import the helpers we need.\n{count, starts, compact, last, repeat,\nlocationDataToString, throwSyntaxError} = require './helpers'\n\nParser = require './parser'\nserialise = require './serialiser'\n\nmodule.exports.transform = (code, opts) ->\n serialise new Parser().parse code, opts", "source_lang": "", "target_lang": "CoffeeScript", "repo": "jsdf/coffee-react-transform", "path": "src/transformer.coffee", "license": "MIT", "commit": "054a384873f9ee6dd7e20ef83b98e9899a042718", "stars": 431, "source_url": "https://github.com/jsdf/coffee-react-transform/blob/054a384873f9ee6dd7e20ef83b98e9899a042718/src/transformer.coffee", "line_start": 1, "line_end": 9}650{"id": "jsdf/coffee-react-transform:src/transformer.coffee:1:coffee_to_js", "type": "coffee_to_js", "prompt": "Convert this CoffeeScript to JavaScript.\n```coffeescript\n# Import the helpers we need.\n{count, starts, compact, last, repeat,\nlocationDataToString, throwSyntaxError} = require './helpers'\n\nParser = require './parser'\nserialise = require './serialiser'\n\nmodule.exports.transform = (code, opts) ->\n serialise new Parser().parse code, opts\n```", "response": "// Import the helpers we need.\nvar Parser, compact, count, last, locationDataToString, repeat, serialise, starts, throwSyntaxError;\n\n({count, starts, compact, last, repeat, locationDataToString, throwSyntaxError} = require('./helpers'));\n\nParser = require('./parser');\n\nserialise = require('./serialiser');\n\nmodule.exports.transform = function(code, opts) {\n return serialise(new Parser().parse(code, opts));\n};", "source_lang": "CoffeeScript", "target_lang": "JavaScript", "repo": "jsdf/coffee-react-transform", "path": "src/transformer.coffee", "license": "MIT", "commit": "054a384873f9ee6dd7e20ef83b98e9899a042718", "stars": 431, "source_url": "https://github.com/jsdf/coffee-react-transform/blob/054a384873f9ee6dd7e20ef83b98e9899a042718/src/transformer.coffee", "line_start": 1, "line_end": 9}651{"id": "jsdf/coffee-react-transform:src/transformer.coffee:1:js_to_coffee", "type": "js_to_coffee", "prompt": "Convert this JavaScript to CoffeeScript.\n```javascript\n// Import the helpers we need.\nvar Parser, compact, count, last, locationDataToString, repeat, serialise, starts, throwSyntaxError;\n\n({count, starts, compact, last, repeat, locationDataToString, throwSyntaxError} = require('./helpers'));\n\nParser = require('./parser');\n\nserialise = require('./serialiser');\n\nmodule.exports.transform = function(code, opts) {\n return serialise(new Parser().parse(code, opts));\n};\n```", "response": "# Import the helpers we need.\n{count, starts, compact, last, repeat,\nlocationDataToString, throwSyntaxError} = require './helpers'\n\nParser = require './parser'\nserialise = require './serialiser'\n\nmodule.exports.transform = (code, opts) ->\n serialise new Parser().parse code, opts", "source_lang": "JavaScript", "target_lang": "CoffeeScript", "repo": "jsdf/coffee-react-transform", "path": "src/transformer.coffee", "license": "MIT", "commit": "054a384873f9ee6dd7e20ef83b98e9899a042718", "stars": 431, "source_url": "https://github.com/jsdf/coffee-react-transform/blob/054a384873f9ee6dd7e20ef83b98e9899a042718/src/transformer.coffee", "line_start": 1, "line_end": 9}652{"id": "jsdf/coffee-react-transform:src/transformer.coffee:1:completion", "type": "completion", "prompt": "# Import the helpers we need.\n{count, starts, compact, last, repeat,\nlocationDataToString, throwSyntaxError} = require './helpers'", "response": "Parser = require './parser'\nserialise = require './serialiser'\n\nmodule.exports.transform = (code, opts) ->\n serialise new Parser().parse code, opts", "source_lang": "CoffeeScript", "target_lang": "CoffeeScript", "repo": "jsdf/coffee-react-transform", "path": "src/transformer.coffee", "license": "MIT", "commit": "054a384873f9ee6dd7e20ef83b98e9899a042718", "stars": 431, "source_url": "https://github.com/jsdf/coffee-react-transform/blob/054a384873f9ee6dd7e20ef83b98e9899a042718/src/transformer.coffee", "line_start": 1, "line_end": 9}653{"id": "abe33/atom-pigments:lib/regexes.coffee:1:raw_corpus", "type": "raw_corpus", "prompt": "", "response": "int = '\\\\d+'\ndecimal = \"\\\\.#{int}\"\nfloat = \"(?:#{int}#{decimal}|#{int}|#{decimal})\"\npercent = \"#{float}%\"\nvariables = '(?:@[a-zA-Z0-9\\\\-_]+|\\\\$[a-zA-Z0-9\\\\-_]+|[a-zA-Z_][a-zA-Z0-9\\\\-_]*)'\nnamePrefixes = '^| |\\\\t|:|=|,|\\\\n|\\'|\"|`|\\\\(|\\\\[|\\\\{|>'\n\nmodule.exports =\n int: int\n float: float\n percent: percent\n optionalPercent: \"#{float}%?\"\n intOrPercent: \"(?:#{percent}|#{int})\"\n floatOrPercent: \"(?:#{percent}|#{float})\"\n comma: '\\\\s*,\\\\s*'\n notQuote: \"[^\\\"'`\\\\n\\\\r]+\"\n hexadecimal: '[\\\\da-fA-F]'\n ps: '\\\\(\\\\s*'\n pe: '\\\\s*\\\\)'\n variables: variables\n namePrefixes: namePrefixes\n createVariableRegExpString: (variables) ->\n variableNamesWithPrefix = []\n variableNamesWithoutPrefix = []\n withPrefixes = variables.filter (v) -> not v.noNamePrefix\n withoutPrefixes = variables.filter (v) -> v.noNamePrefix\n\n res = []\n\n if withPrefixes.length > 0\n for v in withPrefixes\n variableNamesWithPrefix.push v.name.replace(/[-\\[\\]\\/\\{\\}\\(\\)\\*\\+\\?\\.\\\\\\^\\$\\|]/g, \"\\\\$&\")\n\n res.push \"((?:#{namePrefixes})(#{variableNamesWithPrefix.join('|')})(\\\\s+!default)?(?!_|-|\\\\w|\\\\d|[ \\\\t]*[\\\\.:=]))\"\n\n if withoutPrefixes.length > 0\n for v in withoutPrefixes\n variableNamesWithoutPrefix.push v.name.replace(/[-\\[\\]\\/\\{\\}\\(\\)\\*\\+\\?\\.\\\\\\^\\$\\|]/g, \"\\\\$&\")\n\n res.push \"(#{variableNamesWithoutPrefix.join('|')})\"\n\n res.join('|')", "source_lang": "", "target_lang": "CoffeeScript", "repo": "abe33/atom-pigments", "path": "lib/regexes.coffee", "license": "MIT", "commit": "4bdef2e1ebeaa492a6c353c2fd9e7adecdebadf4", "stars": 518, "source_url": "https://github.com/abe33/atom-pigments/blob/4bdef2e1ebeaa492a6c353c2fd9e7adecdebadf4/lib/regexes.coffee", "line_start": 1, "line_end": 42}654{"id": "abe33/atom-pigments:lib/regexes.coffee:1:coffee_to_js", "type": "coffee_to_js", "prompt": "Convert this CoffeeScript to JavaScript.\n```coffeescript\nint = '\\\\d+'\ndecimal = \"\\\\.#{int}\"\nfloat = \"(?:#{int}#{decimal}|#{int}|#{decimal})\"\npercent = \"#{float}%\"\nvariables = '(?:@[a-zA-Z0-9\\\\-_]+|\\\\$[a-zA-Z0-9\\\\-_]+|[a-zA-Z_][a-zA-Z0-9\\\\-_]*)'\nnamePrefixes = '^| |\\\\t|:|=|,|\\\\n|\\'|\"|`|\\\\(|\\\\[|\\\\{|>'\n\nmodule.exports =\n int: int\n float: float\n percent: percent\n optionalPercent: \"#{float}%?\"\n intOrPercent: \"(?:#{percent}|#{int})\"\n floatOrPercent: \"(?:#{percent}|#{float})\"\n comma: '\\\\s*,\\\\s*'\n notQuote: \"[^\\\"'`\\\\n\\\\r]+\"\n hexadecimal: '[\\\\da-fA-F]'\n ps: '\\\\(\\\\s*'\n pe: '\\\\s*\\\\)'\n variables: variables\n namePrefixes: namePrefixes\n createVariableRegExpString: (variables) ->\n variableNamesWithPrefix = []\n variableNamesWithoutPrefix = []\n withPrefixes = variables.filter (v) -> not v.noNamePrefix\n withoutPrefixes = variables.filter (v) -> v.noNamePrefix\n\n res = []\n\n if withPrefixes.length > 0\n for v in withPrefixes\n variableNamesWithPrefix.push v.name.replace(/[-\\[\\]\\/\\{\\}\\(\\)\\*\\+\\?\\.\\\\\\^\\$\\|]/g, \"\\\\$&\")\n\n res.push \"((?:#{namePrefixes})(#{variableNamesWithPrefix.join('|')})(\\\\s+!default)?(?!_|-|\\\\w|\\\\d|[ \\\\t]*[\\\\.:=]))\"\n\n if withoutPrefixes.length > 0\n for v in withoutPrefixes\n variableNamesWithoutPrefix.push v.name.replace(/[-\\[\\]\\/\\{\\}\\(\\)\\*\\+\\?\\.\\\\\\^\\$\\|]/g, \"\\\\$&\")\n\n res.push \"(#{variableNamesWithoutPrefix.join('|')})\"\n\n res.join('|')\n```", "response": "var decimal, float, int, namePrefixes, percent, variables;\n\nint = '\\\\d+';\n\ndecimal = `\\\\.${int}`;\n\nfloat = `(?:${int}${decimal}|${int}|${decimal})`;\n\npercent = `${float}%`;\n\nvariables = '(?:@[a-zA-Z0-9\\\\-_]+|\\\\$[a-zA-Z0-9\\\\-_]+|[a-zA-Z_][a-zA-Z0-9\\\\-_]*)';\n\nnamePrefixes = '^| |\\\\t|:|=|,|\\\\n|\\'|\"|`|\\\\(|\\\\[|\\\\{|>';\n\nmodule.exports = {\n int: int,\n float: float,\n percent: percent,\n optionalPercent: `${float}%?`,\n intOrPercent: `(?:${percent}|${int})`,\n floatOrPercent: `(?:${percent}|${float})`,\n comma: '\\\\s*,\\\\s*',\n notQuote: \"[^\\\"'`\\\\n\\\\r]+\",\n hexadecimal: '[\\\\da-fA-F]',\n ps: '\\\\(\\\\s*',\n pe: '\\\\s*\\\\)',\n variables: variables,\n namePrefixes: namePrefixes,\n createVariableRegExpString: function(variables) {\n var i, j, len, len1, res, v, variableNamesWithPrefix, variableNamesWithoutPrefix, withPrefixes, withoutPrefixes;\n variableNamesWithPrefix = [];\n variableNamesWithoutPrefix = [];\n withPrefixes = variables.filter(function(v) {\n return !v.noNamePrefix;\n });\n withoutPrefixes = variables.filter(function(v) {\n return v.noNamePrefix;\n });\n res = [];\n if (withPrefixes.length > 0) {\n for (i = 0, len = withPrefixes.length; i < len; i++) {\n v = withPrefixes[i];\n variableNamesWithPrefix.push(v.name.replace(/[-\\[\\]\\/\\{\\}\\(\\)\\*\\+\\?\\.\\\\\\^\\$\\|]/g, \"\\\\$&\"));\n }\n res.push(`((?:${namePrefixes})(${variableNamesWithPrefix.join('|')})(\\\\s+!default)?(?!_|-|\\\\w|\\\\d|[ \\\\t]*[\\\\.:=]))`);\n }\n if (withoutPrefixes.length > 0) {\n for (j = 0, len1 = withoutPrefixes.length; j < len1; j++) {\n v = withoutPrefixes[j];\n variableNamesWithoutPrefix.push(v.name.replace(/[-\\[\\]\\/\\{\\}\\(\\)\\*\\+\\?\\.\\\\\\^\\$\\|]/g, \"\\\\$&\"));\n }\n res.push(`(${variableNamesWithoutPrefix.join('|')})`);\n }\n return res.join('|');\n }\n};", "source_lang": "CoffeeScript", "target_lang": "JavaScript", "repo": "abe33/atom-pigments", "path": "lib/regexes.coffee", "license": "MIT", "commit": "4bdef2e1ebeaa492a6c353c2fd9e7adecdebadf4", "stars": 518, "source_url": "https://github.com/abe33/atom-pigments/blob/4bdef2e1ebeaa492a6c353c2fd9e7adecdebadf4/lib/regexes.coffee", "line_start": 1, "line_end": 42}655{"id": "abe33/atom-pigments:lib/regexes.coffee:1:js_to_coffee", "type": "js_to_coffee", "prompt": "Convert this JavaScript to CoffeeScript.\n```javascript\nvar decimal, float, int, namePrefixes, percent, variables;\n\nint = '\\\\d+';\n\ndecimal = `\\\\.${int}`;\n\nfloat = `(?:${int}${decimal}|${int}|${decimal})`;\n\npercent = `${float}%`;\n\nvariables = '(?:@[a-zA-Z0-9\\\\-_]+|\\\\$[a-zA-Z0-9\\\\-_]+|[a-zA-Z_][a-zA-Z0-9\\\\-_]*)';\n\nnamePrefixes = '^| |\\\\t|:|=|,|\\\\n|\\'|\"|`|\\\\(|\\\\[|\\\\{|>';\n\nmodule.exports = {\n int: int,\n float: float,\n percent: percent,\n optionalPercent: `${float}%?`,\n intOrPercent: `(?:${percent}|${int})`,\n floatOrPercent: `(?:${percent}|${float})`,\n comma: '\\\\s*,\\\\s*',\n notQuote: \"[^\\\"'`\\\\n\\\\r]+\",\n hexadecimal: '[\\\\da-fA-F]',\n ps: '\\\\(\\\\s*',\n pe: '\\\\s*\\\\)',\n variables: variables,\n namePrefixes: namePrefixes,\n createVariableRegExpString: function(variables) {\n var i, j, len, len1, res, v, variableNamesWithPrefix, variableNamesWithoutPrefix, withPrefixes, withoutPrefixes;\n variableNamesWithPrefix = [];\n variableNamesWithoutPrefix = [];\n withPrefixes = variables.filter(function(v) {\n return !v.noNamePrefix;\n });\n withoutPrefixes = variables.filter(function(v) {\n return v.noNamePrefix;\n });\n res = [];\n if (withPrefixes.length > 0) {\n for (i = 0, len = withPrefixes.length; i < len; i++) {\n v = withPrefixes[i];\n variableNamesWithPrefix.push(v.name.replace(/[-\\[\\]\\/\\{\\}\\(\\)\\*\\+\\?\\.\\\\\\^\\$\\|]/g, \"\\\\$&\"));\n }\n res.push(`((?:${namePrefixes})(${variableNamesWithPrefix.join('|')})(\\\\s+!default)?(?!_|-|\\\\w|\\\\d|[ \\\\t]*[\\\\.:=]))`);\n }\n if (withoutPrefixes.length > 0) {\n for (j = 0, len1 = withoutPrefixes.length; j < len1; j++) {\n v = withoutPrefixes[j];\n variableNamesWithoutPrefix.push(v.name.replace(/[-\\[\\]\\/\\{\\}\\(\\)\\*\\+\\?\\.\\\\\\^\\$\\|]/g, \"\\\\$&\"));\n }\n res.push(`(${variableNamesWithoutPrefix.join('|')})`);\n }\n return res.join('|');\n }\n};\n```", "response": "int = '\\\\d+'\ndecimal = \"\\\\.#{int}\"\nfloat = \"(?:#{int}#{decimal}|#{int}|#{decimal})\"\npercent = \"#{float}%\"\nvariables = '(?:@[a-zA-Z0-9\\\\-_]+|\\\\$[a-zA-Z0-9\\\\-_]+|[a-zA-Z_][a-zA-Z0-9\\\\-_]*)'\nnamePrefixes = '^| |\\\\t|:|=|,|\\\\n|\\'|\"|`|\\\\(|\\\\[|\\\\{|>'\n\nmodule.exports =\n int: int\n float: float\n percent: percent\n optionalPercent: \"#{float}%?\"\n intOrPercent: \"(?:#{percent}|#{int})\"\n floatOrPercent: \"(?:#{percent}|#{float})\"\n comma: '\\\\s*,\\\\s*'\n notQuote: \"[^\\\"'`\\\\n\\\\r]+\"\n hexadecimal: '[\\\\da-fA-F]'\n ps: '\\\\(\\\\s*'\n pe: '\\\\s*\\\\)'\n variables: variables\n namePrefixes: namePrefixes\n createVariableRegExpString: (variables) ->\n variableNamesWithPrefix = []\n variableNamesWithoutPrefix = []\n withPrefixes = variables.filter (v) -> not v.noNamePrefix\n withoutPrefixes = variables.filter (v) -> v.noNamePrefix\n\n res = []\n\n if withPrefixes.length > 0\n for v in withPrefixes\n variableNamesWithPrefix.push v.name.replace(/[-\\[\\]\\/\\{\\}\\(\\)\\*\\+\\?\\.\\\\\\^\\$\\|]/g, \"\\\\$&\")\n\n res.push \"((?:#{namePrefixes})(#{variableNamesWithPrefix.join('|')})(\\\\s+!default)?(?!_|-|\\\\w|\\\\d|[ \\\\t]*[\\\\.:=]))\"\n\n if withoutPrefixes.length > 0\n for v in withoutPrefixes\n variableNamesWithoutPrefix.push v.name.replace(/[-\\[\\]\\/\\{\\}\\(\\)\\*\\+\\?\\.\\\\\\^\\$\\|]/g, \"\\\\$&\")\n\n res.push \"(#{variableNamesWithoutPrefix.join('|')})\"\n\n res.join('|')", "source_lang": "JavaScript", "target_lang": "CoffeeScript", "repo": "abe33/atom-pigments", "path": "lib/regexes.coffee", "license": "MIT", "commit": "4bdef2e1ebeaa492a6c353c2fd9e7adecdebadf4", "stars": 518, "source_url": "https://github.com/abe33/atom-pigments/blob/4bdef2e1ebeaa492a6c353c2fd9e7adecdebadf4/lib/regexes.coffee", "line_start": 1, "line_end": 42}656{"id": "abe33/atom-pigments:lib/regexes.coffee:1:completion", "type": "completion", "prompt": "int = '\\\\d+'\ndecimal = \"\\\\.#{int}\"\nfloat = \"(?:#{int}#{decimal}|#{int}|#{decimal})\"\npercent = \"#{float}%\"\nvariables = '(?:@[a-zA-Z0-9\\\\-_]+|\\\\$[a-zA-Z0-9\\\\-_]+|[a-zA-Z_][a-zA-Z0-9\\\\-_]*)'\nnamePrefixes = '^| |\\\\t|:|=|,|\\\\n|\\'|\"|`|\\\\(|\\\\[|\\\\{|>'\n\nmodule.exports =\n int: int\n float: float\n percent: percent\n optionalPercent: \"#{float}%?\"\n intOrPercent: \"(?:#{percent}|#{int})\"\n floatOrPercent: \"(?:#{percent}|#{float})\"\n comma: '\\\\s*,\\\\s*'\n notQuote: \"[^\\\"'`\\\\n\\\\r]+\"\n hexadecimal: '[\\\\da-fA-F]'\n ps: '\\\\(\\\\s*'\n pe: '\\\\s*\\\\)'\n variables: variables\n namePrefixes: namePrefixes", "response": "createVariableRegExpString: (variables) ->\n variableNamesWithPrefix = []\n variableNamesWithoutPrefix = []\n withPrefixes = variables.filter (v) -> not v.noNamePrefix\n withoutPrefixes = variables.filter (v) -> v.noNamePrefix\n\n res = []\n\n if withPrefixes.length > 0\n for v in withPrefixes\n variableNamesWithPrefix.push v.name.replace(/[-\\[\\]\\/\\{\\}\\(\\)\\*\\+\\?\\.\\\\\\^\\$\\|]/g, \"\\\\$&\")\n\n res.push \"((?:#{namePrefixes})(#{variableNamesWithPrefix.join('|')})(\\\\s+!default)?(?!_|-|\\\\w|\\\\d|[ \\\\t]*[\\\\.:=]))\"\n\n if withoutPrefixes.length > 0\n for v in withoutPrefixes\n variableNamesWithoutPrefix.push v.name.replace(/[-\\[\\]\\/\\{\\}\\(\\)\\*\\+\\?\\.\\\\\\^\\$\\|]/g, \"\\\\$&\")\n\n res.push \"(#{variableNamesWithoutPrefix.join('|')})\"\n\n res.join('|')", "source_lang": "CoffeeScript", "target_lang": "CoffeeScript", "repo": "abe33/atom-pigments", "path": "lib/regexes.coffee", "license": "MIT", "commit": "4bdef2e1ebeaa492a6c353c2fd9e7adecdebadf4", "stars": 518, "source_url": "https://github.com/abe33/atom-pigments/blob/4bdef2e1ebeaa492a6c353c2fd9e7adecdebadf4/lib/regexes.coffee", "line_start": 1, "line_end": 42}657{"id": "abe33/atom-pigments:lib/regexes.coffee:1:raw_corpus", "type": "raw_corpus", "prompt": "", "response": "int = '\\\\d+'\ndecimal = \"\\\\.#{int}\"\nfloat = \"(?:#{int}#{decimal}|#{int}|#{decimal})\"\npercent = \"#{float}%\"\nvariables = '(?:@[a-zA-Z0-9\\\\-_]+|\\\\$[a-zA-Z0-9\\\\-_]+|[a-zA-Z_][a-zA-Z0-9\\\\-_]*)'\nnamePrefixes = '^| |\\\\t|:|=|,|\\\\n|\\'|\"|\\\\(|\\\\[|\\\\{|>'\n\nmodule.exports =\n int: int\n float: float\n percent: percent\n optionalPercent: \"#{float}%?\"\n intOrPercent: \"(?:#{percent}|#{int})\"\n floatOrPercent: \"(?:#{percent}|#{float})\"\n comma: '\\\\s*,\\\\s*'\n notQuote: \"[^\\\"'\\\\n\\\\r]+\"\n hexadecimal: '[\\\\da-fA-F]'\n ps: '\\\\(\\\\s*'\n pe: '\\\\s*\\\\)'\n variables: variables\n namePrefixes: namePrefixes\n createVariableRegExpString: (variables) ->\n variableNamesWithPrefix = []\n variableNamesWithoutPrefix = []\n withPrefixes = variables.filter (v) -> not v.noNamePrefix\n withoutPrefixes = variables.filter (v) -> v.noNamePrefix\n\n res = []\n\n if withPrefixes.length > 0\n for v in withPrefixes\n variableNamesWithPrefix.push v.name.replace(/[-\\[\\]\\/\\{\\}\\(\\)\\*\\+\\?\\.\\\\\\^\\$\\|]/g, \"\\\\$&\")\n\n res.push \"((?:#{namePrefixes})(#{variableNamesWithPrefix.join('|')})(\\\\s+!default)?(?!_|-|\\\\w|\\\\d|[ \\\\t]*[\\\\.:=]))\"\n\n if withoutPrefixes.length > 0\n for v in withoutPrefixes\n variableNamesWithoutPrefix.push v.name.replace(/[-\\[\\]\\/\\{\\}\\(\\)\\*\\+\\?\\.\\\\\\^\\$\\|]/g, \"\\\\$&\")\n\n res.push \"(#{variableNamesWithoutPrefix.join('|')})\"\n\n res.join('|')", "source_lang": "", "target_lang": "CoffeeScript", "repo": "abe33/atom-pigments", "path": "lib/regexes.coffee", "license": "MIT", "commit": "fccbdeb8e6b926940f667b37d9d593f158261d10", "stars": 518, "source_url": "https://github.com/abe33/atom-pigments/blob/fccbdeb8e6b926940f667b37d9d593f158261d10/lib/regexes.coffee", "line_start": 1, "line_end": 42}658{"id": "abe33/atom-pigments:lib/regexes.coffee:1:coffee_to_js", "type": "coffee_to_js", "prompt": "Convert this CoffeeScript to JavaScript.\n```coffeescript\nint = '\\\\d+'\ndecimal = \"\\\\.#{int}\"\nfloat = \"(?:#{int}#{decimal}|#{int}|#{decimal})\"\npercent = \"#{float}%\"\nvariables = '(?:@[a-zA-Z0-9\\\\-_]+|\\\\$[a-zA-Z0-9\\\\-_]+|[a-zA-Z_][a-zA-Z0-9\\\\-_]*)'\nnamePrefixes = '^| |\\\\t|:|=|,|\\\\n|\\'|\"|\\\\(|\\\\[|\\\\{|>'\n\nmodule.exports =\n int: int\n float: float\n percent: percent\n optionalPercent: \"#{float}%?\"\n intOrPercent: \"(?:#{percent}|#{int})\"\n floatOrPercent: \"(?:#{percent}|#{float})\"\n comma: '\\\\s*,\\\\s*'\n notQuote: \"[^\\\"'\\\\n\\\\r]+\"\n hexadecimal: '[\\\\da-fA-F]'\n ps: '\\\\(\\\\s*'\n pe: '\\\\s*\\\\)'\n variables: variables\n namePrefixes: namePrefixes\n createVariableRegExpString: (variables) ->\n variableNamesWithPrefix = []\n variableNamesWithoutPrefix = []\n withPrefixes = variables.filter (v) -> not v.noNamePrefix\n withoutPrefixes = variables.filter (v) -> v.noNamePrefix\n\n res = []\n\n if withPrefixes.length > 0\n for v in withPrefixes\n variableNamesWithPrefix.push v.name.replace(/[-\\[\\]\\/\\{\\}\\(\\)\\*\\+\\?\\.\\\\\\^\\$\\|]/g, \"\\\\$&\")\n\n res.push \"((?:#{namePrefixes})(#{variableNamesWithPrefix.join('|')})(\\\\s+!default)?(?!_|-|\\\\w|\\\\d|[ \\\\t]*[\\\\.:=]))\"\n\n if withoutPrefixes.length > 0\n for v in withoutPrefixes\n variableNamesWithoutPrefix.push v.name.replace(/[-\\[\\]\\/\\{\\}\\(\\)\\*\\+\\?\\.\\\\\\^\\$\\|]/g, \"\\\\$&\")\n\n res.push \"(#{variableNamesWithoutPrefix.join('|')})\"\n\n res.join('|')\n```", "response": "var decimal, float, int, namePrefixes, percent, variables;\n\nint = '\\\\d+';\n\ndecimal = `\\\\.${int}`;\n\nfloat = `(?:${int}${decimal}|${int}|${decimal})`;\n\npercent = `${float}%`;\n\nvariables = '(?:@[a-zA-Z0-9\\\\-_]+|\\\\$[a-zA-Z0-9\\\\-_]+|[a-zA-Z_][a-zA-Z0-9\\\\-_]*)';\n\nnamePrefixes = '^| |\\\\t|:|=|,|\\\\n|\\'|\"|\\\\(|\\\\[|\\\\{|>';\n\nmodule.exports = {\n int: int,\n float: float,\n percent: percent,\n optionalPercent: `${float}%?`,\n intOrPercent: `(?:${percent}|${int})`,\n floatOrPercent: `(?:${percent}|${float})`,\n comma: '\\\\s*,\\\\s*',\n notQuote: \"[^\\\"'\\\\n\\\\r]+\",\n hexadecimal: '[\\\\da-fA-F]',\n ps: '\\\\(\\\\s*',\n pe: '\\\\s*\\\\)',\n variables: variables,\n namePrefixes: namePrefixes,\n createVariableRegExpString: function(variables) {\n var i, j, len, len1, res, v, variableNamesWithPrefix, variableNamesWithoutPrefix, withPrefixes, withoutPrefixes;\n variableNamesWithPrefix = [];\n variableNamesWithoutPrefix = [];\n withPrefixes = variables.filter(function(v) {\n return !v.noNamePrefix;\n });\n withoutPrefixes = variables.filter(function(v) {\n return v.noNamePrefix;\n });\n res = [];\n if (withPrefixes.length > 0) {\n for (i = 0, len = withPrefixes.length; i < len; i++) {\n v = withPrefixes[i];\n variableNamesWithPrefix.push(v.name.replace(/[-\\[\\]\\/\\{\\}\\(\\)\\*\\+\\?\\.\\\\\\^\\$\\|]/g, \"\\\\$&\"));\n }\n res.push(`((?:${namePrefixes})(${variableNamesWithPrefix.join('|')})(\\\\s+!default)?(?!_|-|\\\\w|\\\\d|[ \\\\t]*[\\\\.:=]))`);\n }\n if (withoutPrefixes.length > 0) {\n for (j = 0, len1 = withoutPrefixes.length; j < len1; j++) {\n v = withoutPrefixes[j];\n variableNamesWithoutPrefix.push(v.name.replace(/[-\\[\\]\\/\\{\\}\\(\\)\\*\\+\\?\\.\\\\\\^\\$\\|]/g, \"\\\\$&\"));\n }\n res.push(`(${variableNamesWithoutPrefix.join('|')})`);\n }\n return res.join('|');\n }\n};", "source_lang": "CoffeeScript", "target_lang": "JavaScript", "repo": "abe33/atom-pigments", "path": "lib/regexes.coffee", "license": "MIT", "commit": "fccbdeb8e6b926940f667b37d9d593f158261d10", "stars": 518, "source_url": "https://github.com/abe33/atom-pigments/blob/fccbdeb8e6b926940f667b37d9d593f158261d10/lib/regexes.coffee", "line_start": 1, "line_end": 42}659{"id": "abe33/atom-pigments:lib/regexes.coffee:1:js_to_coffee", "type": "js_to_coffee", "prompt": "Convert this JavaScript to CoffeeScript.\n```javascript\nvar decimal, float, int, namePrefixes, percent, variables;\n\nint = '\\\\d+';\n\ndecimal = `\\\\.${int}`;\n\nfloat = `(?:${int}${decimal}|${int}|${decimal})`;\n\npercent = `${float}%`;\n\nvariables = '(?:@[a-zA-Z0-9\\\\-_]+|\\\\$[a-zA-Z0-9\\\\-_]+|[a-zA-Z_][a-zA-Z0-9\\\\-_]*)';\n\nnamePrefixes = '^| |\\\\t|:|=|,|\\\\n|\\'|\"|\\\\(|\\\\[|\\\\{|>';\n\nmodule.exports = {\n int: int,\n float: float,\n percent: percent,\n optionalPercent: `${float}%?`,\n intOrPercent: `(?:${percent}|${int})`,\n floatOrPercent: `(?:${percent}|${float})`,\n comma: '\\\\s*,\\\\s*',\n notQuote: \"[^\\\"'\\\\n\\\\r]+\",\n hexadecimal: '[\\\\da-fA-F]',\n ps: '\\\\(\\\\s*',\n pe: '\\\\s*\\\\)',\n variables: variables,\n namePrefixes: namePrefixes,\n createVariableRegExpString: function(variables) {\n var i, j, len, len1, res, v, variableNamesWithPrefix, variableNamesWithoutPrefix, withPrefixes, withoutPrefixes;\n variableNamesWithPrefix = [];\n variableNamesWithoutPrefix = [];\n withPrefixes = variables.filter(function(v) {\n return !v.noNamePrefix;\n });\n withoutPrefixes = variables.filter(function(v) {\n return v.noNamePrefix;\n });\n res = [];\n if (withPrefixes.length > 0) {\n for (i = 0, len = withPrefixes.length; i < len; i++) {\n v = withPrefixes[i];\n variableNamesWithPrefix.push(v.name.replace(/[-\\[\\]\\/\\{\\}\\(\\)\\*\\+\\?\\.\\\\\\^\\$\\|]/g, \"\\\\$&\"));\n }\n res.push(`((?:${namePrefixes})(${variableNamesWithPrefix.join('|')})(\\\\s+!default)?(?!_|-|\\\\w|\\\\d|[ \\\\t]*[\\\\.:=]))`);\n }\n if (withoutPrefixes.length > 0) {\n for (j = 0, len1 = withoutPrefixes.length; j < len1; j++) {\n v = withoutPrefixes[j];\n variableNamesWithoutPrefix.push(v.name.replace(/[-\\[\\]\\/\\{\\}\\(\\)\\*\\+\\?\\.\\\\\\^\\$\\|]/g, \"\\\\$&\"));\n }\n res.push(`(${variableNamesWithoutPrefix.join('|')})`);\n }\n return res.join('|');\n }\n};\n```", "response": "int = '\\\\d+'\ndecimal = \"\\\\.#{int}\"\nfloat = \"(?:#{int}#{decimal}|#{int}|#{decimal})\"\npercent = \"#{float}%\"\nvariables = '(?:@[a-zA-Z0-9\\\\-_]+|\\\\$[a-zA-Z0-9\\\\-_]+|[a-zA-Z_][a-zA-Z0-9\\\\-_]*)'\nnamePrefixes = '^| |\\\\t|:|=|,|\\\\n|\\'|\"|\\\\(|\\\\[|\\\\{|>'\n\nmodule.exports =\n int: int\n float: float\n percent: percent\n optionalPercent: \"#{float}%?\"\n intOrPercent: \"(?:#{percent}|#{int})\"\n floatOrPercent: \"(?:#{percent}|#{float})\"\n comma: '\\\\s*,\\\\s*'\n notQuote: \"[^\\\"'\\\\n\\\\r]+\"\n hexadecimal: '[\\\\da-fA-F]'\n ps: '\\\\(\\\\s*'\n pe: '\\\\s*\\\\)'\n variables: variables\n namePrefixes: namePrefixes\n createVariableRegExpString: (variables) ->\n variableNamesWithPrefix = []\n variableNamesWithoutPrefix = []\n withPrefixes = variables.filter (v) -> not v.noNamePrefix\n withoutPrefixes = variables.filter (v) -> v.noNamePrefix\n\n res = []\n\n if withPrefixes.length > 0\n for v in withPrefixes\n variableNamesWithPrefix.push v.name.replace(/[-\\[\\]\\/\\{\\}\\(\\)\\*\\+\\?\\.\\\\\\^\\$\\|]/g, \"\\\\$&\")\n\n res.push \"((?:#{namePrefixes})(#{variableNamesWithPrefix.join('|')})(\\\\s+!default)?(?!_|-|\\\\w|\\\\d|[ \\\\t]*[\\\\.:=]))\"\n\n if withoutPrefixes.length > 0\n for v in withoutPrefixes\n variableNamesWithoutPrefix.push v.name.replace(/[-\\[\\]\\/\\{\\}\\(\\)\\*\\+\\?\\.\\\\\\^\\$\\|]/g, \"\\\\$&\")\n\n res.push \"(#{variableNamesWithoutPrefix.join('|')})\"\n\n res.join('|')", "source_lang": "JavaScript", "target_lang": "CoffeeScript", "repo": "abe33/atom-pigments", "path": "lib/regexes.coffee", "license": "MIT", "commit": "fccbdeb8e6b926940f667b37d9d593f158261d10", "stars": 518, "source_url": "https://github.com/abe33/atom-pigments/blob/fccbdeb8e6b926940f667b37d9d593f158261d10/lib/regexes.coffee", "line_start": 1, "line_end": 42}660{"id": "abe33/atom-pigments:lib/regexes.coffee:1:completion", "type": "completion", "prompt": "int = '\\\\d+'\ndecimal = \"\\\\.#{int}\"\nfloat = \"(?:#{int}#{decimal}|#{int}|#{decimal})\"\npercent = \"#{float}%\"\nvariables = '(?:@[a-zA-Z0-9\\\\-_]+|\\\\$[a-zA-Z0-9\\\\-_]+|[a-zA-Z_][a-zA-Z0-9\\\\-_]*)'\nnamePrefixes = '^| |\\\\t|:|=|,|\\\\n|\\'|\"|\\\\(|\\\\[|\\\\{|>'\n\nmodule.exports =\n int: int\n float: float\n percent: percent\n optionalPercent: \"#{float}%?\"\n intOrPercent: \"(?:#{percent}|#{int})\"\n floatOrPercent: \"(?:#{percent}|#{float})\"\n comma: '\\\\s*,\\\\s*'\n notQuote: \"[^\\\"'\\\\n\\\\r]+\"\n hexadecimal: '[\\\\da-fA-F]'\n ps: '\\\\(\\\\s*'\n pe: '\\\\s*\\\\)'\n variables: variables\n namePrefixes: namePrefixes", "response": "createVariableRegExpString: (variables) ->\n variableNamesWithPrefix = []\n variableNamesWithoutPrefix = []\n withPrefixes = variables.filter (v) -> not v.noNamePrefix\n withoutPrefixes = variables.filter (v) -> v.noNamePrefix\n\n res = []\n\n if withPrefixes.length > 0\n for v in withPrefixes\n variableNamesWithPrefix.push v.name.replace(/[-\\[\\]\\/\\{\\}\\(\\)\\*\\+\\?\\.\\\\\\^\\$\\|]/g, \"\\\\$&\")\n\n res.push \"((?:#{namePrefixes})(#{variableNamesWithPrefix.join('|')})(\\\\s+!default)?(?!_|-|\\\\w|\\\\d|[ \\\\t]*[\\\\.:=]))\"\n\n if withoutPrefixes.length > 0\n for v in withoutPrefixes\n variableNamesWithoutPrefix.push v.name.replace(/[-\\[\\]\\/\\{\\}\\(\\)\\*\\+\\?\\.\\\\\\^\\$\\|]/g, \"\\\\$&\")\n\n res.push \"(#{variableNamesWithoutPrefix.join('|')})\"\n\n res.join('|')", "source_lang": "CoffeeScript", "target_lang": "CoffeeScript", "repo": "abe33/atom-pigments", "path": "lib/regexes.coffee", "license": "MIT", "commit": "fccbdeb8e6b926940f667b37d9d593f158261d10", "stars": 518, "source_url": "https://github.com/abe33/atom-pigments/blob/fccbdeb8e6b926940f667b37d9d593f158261d10/lib/regexes.coffee", "line_start": 1, "line_end": 42}661{"id": "abe33/atom-pigments:lib/regexes.coffee:1:raw_corpus", "type": "raw_corpus", "prompt": "", "response": "int = '\\\\d+'\ndecimal = \"\\\\.#{int}\"\nfloat = \"(?:#{int}#{decimal}|#{int}|#{decimal})\"\npercent = \"#{float}%\"\nvariables = '(?:@[a-zA-Z0-9\\\\-_]+|\\\\$[a-zA-Z0-9\\\\-_]+|[a-zA-Z_][a-zA-Z0-9\\\\-_]*)'\nnamePrefixes = '^| |\\\\t|:|=|,|\\\\n|\\'|\"|\\\\(|\\\\[|\\\\{|>'\n\nmodule.exports =\n int: int\n float: float\n percent: percent\n optionalPercent: \"#{float}%?\"\n intOrPercent: \"(?:#{percent}|#{int})\"\n floatOrPercent: \"(?:#{percent}|#{float})\"\n comma: '\\\\s*,\\\\s*'\n notQuote: \"[^\\\"'\\\\n\\\\r]+\"\n hexadecimal: '[\\\\da-fA-F]'\n ps: '\\\\(\\\\s*'\n pe: '\\\\s*\\\\)'\n variables: variables\n namePrefixes: namePrefixes\n createVariableRegExpString: (variables) ->\n variableNamesWithPrefix = []\n variableNamesWithoutPrefix = []\n withPrefixes = variables.filter (v) -> not v.noNamePrefix\n withoutPrefixes = variables.filter (v) -> v.noNamePrefix\n\n for v in withPrefixes\n variableNamesWithPrefix.push v.name.replace(/[-\\[\\]\\/\\{\\}\\(\\)\\*\\+\\?\\.\\\\\\^\\$\\|]/g, \"\\\\$&\")\n\n for v in withoutPrefixes\n variableNamesWithoutPrefix.push v.name.replace(/[-\\[\\]\\/\\{\\}\\(\\)\\*\\+\\?\\.\\\\\\^\\$\\|]/g, \"\\\\$&\")\n\n \"((?:#{namePrefixes})(#{variableNamesWithPrefix.join('|')})(\\\\s+!default)?(?!_|-|\\\\w|\\\\d|[ \\\\t]*[\\\\.:=]))|(#{variableNamesWithoutPrefix.join('|')})\"", "source_lang": "", "target_lang": "CoffeeScript", "repo": "abe33/atom-pigments", "path": "lib/regexes.coffee", "license": "MIT", "commit": "a2ae863f0bee366d797cc98fa97a8c378aed688e", "stars": 518, "source_url": "https://github.com/abe33/atom-pigments/blob/a2ae863f0bee366d797cc98fa97a8c378aed688e/lib/regexes.coffee", "line_start": 1, "line_end": 34}662{"id": "abe33/atom-pigments:lib/regexes.coffee:1:coffee_to_js", "type": "coffee_to_js", "prompt": "Convert this CoffeeScript to JavaScript.\n```coffeescript\nint = '\\\\d+'\ndecimal = \"\\\\.#{int}\"\nfloat = \"(?:#{int}#{decimal}|#{int}|#{decimal})\"\npercent = \"#{float}%\"\nvariables = '(?:@[a-zA-Z0-9\\\\-_]+|\\\\$[a-zA-Z0-9\\\\-_]+|[a-zA-Z_][a-zA-Z0-9\\\\-_]*)'\nnamePrefixes = '^| |\\\\t|:|=|,|\\\\n|\\'|\"|\\\\(|\\\\[|\\\\{|>'\n\nmodule.exports =\n int: int\n float: float\n percent: percent\n optionalPercent: \"#{float}%?\"\n intOrPercent: \"(?:#{percent}|#{int})\"\n floatOrPercent: \"(?:#{percent}|#{float})\"\n comma: '\\\\s*,\\\\s*'\n notQuote: \"[^\\\"'\\\\n\\\\r]+\"\n hexadecimal: '[\\\\da-fA-F]'\n ps: '\\\\(\\\\s*'\n pe: '\\\\s*\\\\)'\n variables: variables\n namePrefixes: namePrefixes\n createVariableRegExpString: (variables) ->\n variableNamesWithPrefix = []\n variableNamesWithoutPrefix = []\n withPrefixes = variables.filter (v) -> not v.noNamePrefix\n withoutPrefixes = variables.filter (v) -> v.noNamePrefix\n\n for v in withPrefixes\n variableNamesWithPrefix.push v.name.replace(/[-\\[\\]\\/\\{\\}\\(\\)\\*\\+\\?\\.\\\\\\^\\$\\|]/g, \"\\\\$&\")\n\n for v in withoutPrefixes\n variableNamesWithoutPrefix.push v.name.replace(/[-\\[\\]\\/\\{\\}\\(\\)\\*\\+\\?\\.\\\\\\^\\$\\|]/g, \"\\\\$&\")\n\n \"((?:#{namePrefixes})(#{variableNamesWithPrefix.join('|')})(\\\\s+!default)?(?!_|-|\\\\w|\\\\d|[ \\\\t]*[\\\\.:=]))|(#{variableNamesWithoutPrefix.join('|')})\"\n```", "response": "var decimal, float, int, namePrefixes, percent, variables;\n\nint = '\\\\d+';\n\ndecimal = `\\\\.${int}`;\n\nfloat = `(?:${int}${decimal}|${int}|${decimal})`;\n\npercent = `${float}%`;\n\nvariables = '(?:@[a-zA-Z0-9\\\\-_]+|\\\\$[a-zA-Z0-9\\\\-_]+|[a-zA-Z_][a-zA-Z0-9\\\\-_]*)';\n\nnamePrefixes = '^| |\\\\t|:|=|,|\\\\n|\\'|\"|\\\\(|\\\\[|\\\\{|>';\n\nmodule.exports = {\n int: int,\n float: float,\n percent: percent,\n optionalPercent: `${float}%?`,\n intOrPercent: `(?:${percent}|${int})`,\n floatOrPercent: `(?:${percent}|${float})`,\n comma: '\\\\s*,\\\\s*',\n notQuote: \"[^\\\"'\\\\n\\\\r]+\",\n hexadecimal: '[\\\\da-fA-F]',\n ps: '\\\\(\\\\s*',\n pe: '\\\\s*\\\\)',\n variables: variables,\n namePrefixes: namePrefixes,\n createVariableRegExpString: function(variables) {\n var i, j, len, len1, v, variableNamesWithPrefix, variableNamesWithoutPrefix, withPrefixes, withoutPrefixes;\n variableNamesWithPrefix = [];\n variableNamesWithoutPrefix = [];\n withPrefixes = variables.filter(function(v) {\n return !v.noNamePrefix;\n });\n withoutPrefixes = variables.filter(function(v) {\n return v.noNamePrefix;\n });\n for (i = 0, len = withPrefixes.length; i < len; i++) {\n v = withPrefixes[i];\n variableNamesWithPrefix.push(v.name.replace(/[-\\[\\]\\/\\{\\}\\(\\)\\*\\+\\?\\.\\\\\\^\\$\\|]/g, \"\\\\$&\"));\n }\n for (j = 0, len1 = withoutPrefixes.length; j < len1; j++) {\n v = withoutPrefixes[j];\n variableNamesWithoutPrefix.push(v.name.replace(/[-\\[\\]\\/\\{\\}\\(\\)\\*\\+\\?\\.\\\\\\^\\$\\|]/g, \"\\\\$&\"));\n }\n return `((?:${namePrefixes})(${variableNamesWithPrefix.join('|')})(\\\\s+!default)?(?!_|-|\\\\w|\\\\d|[ \\\\t]*[\\\\.:=]))|(${variableNamesWithoutPrefix.join('|')})`;\n }\n};", "source_lang": "CoffeeScript", "target_lang": "JavaScript", "repo": "abe33/atom-pigments", "path": "lib/regexes.coffee", "license": "MIT", "commit": "a2ae863f0bee366d797cc98fa97a8c378aed688e", "stars": 518, "source_url": "https://github.com/abe33/atom-pigments/blob/a2ae863f0bee366d797cc98fa97a8c378aed688e/lib/regexes.coffee", "line_start": 1, "line_end": 34}663{"id": "abe33/atom-pigments:lib/regexes.coffee:1:js_to_coffee", "type": "js_to_coffee", "prompt": "Convert this JavaScript to CoffeeScript.\n```javascript\nvar decimal, float, int, namePrefixes, percent, variables;\n\nint = '\\\\d+';\n\ndecimal = `\\\\.${int}`;\n\nfloat = `(?:${int}${decimal}|${int}|${decimal})`;\n\npercent = `${float}%`;\n\nvariables = '(?:@[a-zA-Z0-9\\\\-_]+|\\\\$[a-zA-Z0-9\\\\-_]+|[a-zA-Z_][a-zA-Z0-9\\\\-_]*)';\n\nnamePrefixes = '^| |\\\\t|:|=|,|\\\\n|\\'|\"|\\\\(|\\\\[|\\\\{|>';\n\nmodule.exports = {\n int: int,\n float: float,\n percent: percent,\n optionalPercent: `${float}%?`,\n intOrPercent: `(?:${percent}|${int})`,\n floatOrPercent: `(?:${percent}|${float})`,\n comma: '\\\\s*,\\\\s*',\n notQuote: \"[^\\\"'\\\\n\\\\r]+\",\n hexadecimal: '[\\\\da-fA-F]',\n ps: '\\\\(\\\\s*',\n pe: '\\\\s*\\\\)',\n variables: variables,\n namePrefixes: namePrefixes,\n createVariableRegExpString: function(variables) {\n var i, j, len, len1, v, variableNamesWithPrefix, variableNamesWithoutPrefix, withPrefixes, withoutPrefixes;\n variableNamesWithPrefix = [];\n variableNamesWithoutPrefix = [];\n withPrefixes = variables.filter(function(v) {\n return !v.noNamePrefix;\n });\n withoutPrefixes = variables.filter(function(v) {\n return v.noNamePrefix;\n });\n for (i = 0, len = withPrefixes.length; i < len; i++) {\n v = withPrefixes[i];\n variableNamesWithPrefix.push(v.name.replace(/[-\\[\\]\\/\\{\\}\\(\\)\\*\\+\\?\\.\\\\\\^\\$\\|]/g, \"\\\\$&\"));\n }\n for (j = 0, len1 = withoutPrefixes.length; j < len1; j++) {\n v = withoutPrefixes[j];\n variableNamesWithoutPrefix.push(v.name.replace(/[-\\[\\]\\/\\{\\}\\(\\)\\*\\+\\?\\.\\\\\\^\\$\\|]/g, \"\\\\$&\"));\n }\n return `((?:${namePrefixes})(${variableNamesWithPrefix.join('|')})(\\\\s+!default)?(?!_|-|\\\\w|\\\\d|[ \\\\t]*[\\\\.:=]))|(${variableNamesWithoutPrefix.join('|')})`;\n }\n};\n```", "response": "int = '\\\\d+'\ndecimal = \"\\\\.#{int}\"\nfloat = \"(?:#{int}#{decimal}|#{int}|#{decimal})\"\npercent = \"#{float}%\"\nvariables = '(?:@[a-zA-Z0-9\\\\-_]+|\\\\$[a-zA-Z0-9\\\\-_]+|[a-zA-Z_][a-zA-Z0-9\\\\-_]*)'\nnamePrefixes = '^| |\\\\t|:|=|,|\\\\n|\\'|\"|\\\\(|\\\\[|\\\\{|>'\n\nmodule.exports =\n int: int\n float: float\n percent: percent\n optionalPercent: \"#{float}%?\"\n intOrPercent: \"(?:#{percent}|#{int})\"\n floatOrPercent: \"(?:#{percent}|#{float})\"\n comma: '\\\\s*,\\\\s*'\n notQuote: \"[^\\\"'\\\\n\\\\r]+\"\n hexadecimal: '[\\\\da-fA-F]'\n ps: '\\\\(\\\\s*'\n pe: '\\\\s*\\\\)'\n variables: variables\n namePrefixes: namePrefixes\n createVariableRegExpString: (variables) ->\n variableNamesWithPrefix = []\n variableNamesWithoutPrefix = []\n withPrefixes = variables.filter (v) -> not v.noNamePrefix\n withoutPrefixes = variables.filter (v) -> v.noNamePrefix\n\n for v in withPrefixes\n variableNamesWithPrefix.push v.name.replace(/[-\\[\\]\\/\\{\\}\\(\\)\\*\\+\\?\\.\\\\\\^\\$\\|]/g, \"\\\\$&\")\n\n for v in withoutPrefixes\n variableNamesWithoutPrefix.push v.name.replace(/[-\\[\\]\\/\\{\\}\\(\\)\\*\\+\\?\\.\\\\\\^\\$\\|]/g, \"\\\\$&\")\n\n \"((?:#{namePrefixes})(#{variableNamesWithPrefix.join('|')})(\\\\s+!default)?(?!_|-|\\\\w|\\\\d|[ \\\\t]*[\\\\.:=]))|(#{variableNamesWithoutPrefix.join('|')})\"", "source_lang": "JavaScript", "target_lang": "CoffeeScript", "repo": "abe33/atom-pigments", "path": "lib/regexes.coffee", "license": "MIT", "commit": "a2ae863f0bee366d797cc98fa97a8c378aed688e", "stars": 518, "source_url": "https://github.com/abe33/atom-pigments/blob/a2ae863f0bee366d797cc98fa97a8c378aed688e/lib/regexes.coffee", "line_start": 1, "line_end": 34}664{"id": "abe33/atom-pigments:lib/regexes.coffee:1:completion", "type": "completion", "prompt": "int = '\\\\d+'\ndecimal = \"\\\\.#{int}\"\nfloat = \"(?:#{int}#{decimal}|#{int}|#{decimal})\"\npercent = \"#{float}%\"\nvariables = '(?:@[a-zA-Z0-9\\\\-_]+|\\\\$[a-zA-Z0-9\\\\-_]+|[a-zA-Z_][a-zA-Z0-9\\\\-_]*)'\nnamePrefixes = '^| |\\\\t|:|=|,|\\\\n|\\'|\"|\\\\(|\\\\[|\\\\{|>'\n\nmodule.exports =\n int: int\n float: float\n percent: percent\n optionalPercent: \"#{float}%?\"\n intOrPercent: \"(?:#{percent}|#{int})\"\n floatOrPercent: \"(?:#{percent}|#{float})\"\n comma: '\\\\s*,\\\\s*'\n notQuote: \"[^\\\"'\\\\n\\\\r]+\"\n hexadecimal: '[\\\\da-fA-F]'", "response": "ps: '\\\\(\\\\s*'\n pe: '\\\\s*\\\\)'\n variables: variables\n namePrefixes: namePrefixes\n createVariableRegExpString: (variables) ->\n variableNamesWithPrefix = []\n variableNamesWithoutPrefix = []\n withPrefixes = variables.filter (v) -> not v.noNamePrefix\n withoutPrefixes = variables.filter (v) -> v.noNamePrefix\n\n for v in withPrefixes\n variableNamesWithPrefix.push v.name.replace(/[-\\[\\]\\/\\{\\}\\(\\)\\*\\+\\?\\.\\\\\\^\\$\\|]/g, \"\\\\$&\")\n\n for v in withoutPrefixes\n variableNamesWithoutPrefix.push v.name.replace(/[-\\[\\]\\/\\{\\}\\(\\)\\*\\+\\?\\.\\\\\\^\\$\\|]/g, \"\\\\$&\")\n\n \"((?:#{namePrefixes})(#{variableNamesWithPrefix.join('|')})(\\\\s+!default)?(?!_|-|\\\\w|\\\\d|[ \\\\t]*[\\\\.:=]))|(#{variableNamesWithoutPrefix.join('|')})\"", "source_lang": "CoffeeScript", "target_lang": "CoffeeScript", "repo": "abe33/atom-pigments", "path": "lib/regexes.coffee", "license": "MIT", "commit": "a2ae863f0bee366d797cc98fa97a8c378aed688e", "stars": 518, "source_url": "https://github.com/abe33/atom-pigments/blob/a2ae863f0bee366d797cc98fa97a8c378aed688e/lib/regexes.coffee", "line_start": 1, "line_end": 34}665{"id": "abe33/atom-pigments:lib/regexes.coffee:1:raw_corpus", "type": "raw_corpus", "prompt": "", "response": "int = '\\\\d+'\ndecimal = \"\\\\.#{int}\"\nfloat = \"(?:#{int}#{decimal}|#{int}|#{decimal})\"\npercent = \"#{float}%\"\nvariables = '(?:@[a-zA-Z0-9\\\\-_]+|\\\\$[a-zA-Z0-9\\\\-_]+|[a-zA-Z_][a-zA-Z0-9\\\\-_]*)'\nnamePrefixes = '^| |\\\\t|:|=|,|\\\\n|\\'|\"|\\\\(|\\\\[|\\\\{|>'\n\nmodule.exports =\n int: int\n float: float\n percent: percent\n optionalPercent: \"#{float}%?\"\n intOrPercent: \"(?:#{percent}|#{int})\"\n floatOrPercent: \"(?:#{percent}|#{float})\"\n comma: '\\\\s*,\\\\s*'\n notQuote: \"[^\\\"'\\\\n\\\\r]+\"\n hexadecimal: '[\\\\da-fA-F]'\n ps: '\\\\(\\\\s*'\n pe: '\\\\s*\\\\)'\n variables: variables\n namePrefixes: namePrefixes\n createVariableRegExpString: (variables) ->\n variableNames = []\n for v in variables\n variableNames.push v.name.replace(/[-\\[\\]\\/\\{\\}\\(\\)\\*\\+\\?\\.\\\\\\^\\$\\|]/g, \"\\\\$&\")\n variableNames = variableNames.join('|')\n\n \"(?:#{namePrefixes})(#{variableNames})(\\\\s+!default)?(?!_|-|\\\\w|\\\\d|[ \\\\t]*[\\\\.:=])\"", "source_lang": "", "target_lang": "CoffeeScript", "repo": "abe33/atom-pigments", "path": "lib/regexes.coffee", "license": "MIT", "commit": "941fc7a34f1fb3a5072defb3a5f7b04b0a3dcf97", "stars": 518, "source_url": "https://github.com/abe33/atom-pigments/blob/941fc7a34f1fb3a5072defb3a5f7b04b0a3dcf97/lib/regexes.coffee", "line_start": 1, "line_end": 28}666{"id": "abe33/atom-pigments:lib/regexes.coffee:1:coffee_to_js", "type": "coffee_to_js", "prompt": "Convert this CoffeeScript to JavaScript.\n```coffeescript\nint = '\\\\d+'\ndecimal = \"\\\\.#{int}\"\nfloat = \"(?:#{int}#{decimal}|#{int}|#{decimal})\"\npercent = \"#{float}%\"\nvariables = '(?:@[a-zA-Z0-9\\\\-_]+|\\\\$[a-zA-Z0-9\\\\-_]+|[a-zA-Z_][a-zA-Z0-9\\\\-_]*)'\nnamePrefixes = '^| |\\\\t|:|=|,|\\\\n|\\'|\"|\\\\(|\\\\[|\\\\{|>'\n\nmodule.exports =\n int: int\n float: float\n percent: percent\n optionalPercent: \"#{float}%?\"\n intOrPercent: \"(?:#{percent}|#{int})\"\n floatOrPercent: \"(?:#{percent}|#{float})\"\n comma: '\\\\s*,\\\\s*'\n notQuote: \"[^\\\"'\\\\n\\\\r]+\"\n hexadecimal: '[\\\\da-fA-F]'\n ps: '\\\\(\\\\s*'\n pe: '\\\\s*\\\\)'\n variables: variables\n namePrefixes: namePrefixes\n createVariableRegExpString: (variables) ->\n variableNames = []\n for v in variables\n variableNames.push v.name.replace(/[-\\[\\]\\/\\{\\}\\(\\)\\*\\+\\?\\.\\\\\\^\\$\\|]/g, \"\\\\$&\")\n variableNames = variableNames.join('|')\n\n \"(?:#{namePrefixes})(#{variableNames})(\\\\s+!default)?(?!_|-|\\\\w|\\\\d|[ \\\\t]*[\\\\.:=])\"\n```", "response": "var decimal, float, int, namePrefixes, percent, variables;\n\nint = '\\\\d+';\n\ndecimal = `\\\\.${int}`;\n\nfloat = `(?:${int}${decimal}|${int}|${decimal})`;\n\npercent = `${float}%`;\n\nvariables = '(?:@[a-zA-Z0-9\\\\-_]+|\\\\$[a-zA-Z0-9\\\\-_]+|[a-zA-Z_][a-zA-Z0-9\\\\-_]*)';\n\nnamePrefixes = '^| |\\\\t|:|=|,|\\\\n|\\'|\"|\\\\(|\\\\[|\\\\{|>';\n\nmodule.exports = {\n int: int,\n float: float,\n percent: percent,\n optionalPercent: `${float}%?`,\n intOrPercent: `(?:${percent}|${int})`,\n floatOrPercent: `(?:${percent}|${float})`,\n comma: '\\\\s*,\\\\s*',\n notQuote: \"[^\\\"'\\\\n\\\\r]+\",\n hexadecimal: '[\\\\da-fA-F]',\n ps: '\\\\(\\\\s*',\n pe: '\\\\s*\\\\)',\n variables: variables,\n namePrefixes: namePrefixes,\n createVariableRegExpString: function(variables) {\n var i, len, v, variableNames;\n variableNames = [];\n for (i = 0, len = variables.length; i < len; i++) {\n v = variables[i];\n variableNames.push(v.name.replace(/[-\\[\\]\\/\\{\\}\\(\\)\\*\\+\\?\\.\\\\\\^\\$\\|]/g, \"\\\\$&\"));\n }\n variableNames = variableNames.join('|');\n return `(?:${namePrefixes})(${variableNames})(\\\\s+!default)?(?!_|-|\\\\w|\\\\d|[ \\\\t]*[\\\\.:=])`;\n }\n};", "source_lang": "CoffeeScript", "target_lang": "JavaScript", "repo": "abe33/atom-pigments", "path": "lib/regexes.coffee", "license": "MIT", "commit": "941fc7a34f1fb3a5072defb3a5f7b04b0a3dcf97", "stars": 518, "source_url": "https://github.com/abe33/atom-pigments/blob/941fc7a34f1fb3a5072defb3a5f7b04b0a3dcf97/lib/regexes.coffee", "line_start": 1, "line_end": 28}667{"id": "abe33/atom-pigments:lib/regexes.coffee:1:js_to_coffee", "type": "js_to_coffee", "prompt": "Convert this JavaScript to CoffeeScript.\n```javascript\nvar decimal, float, int, namePrefixes, percent, variables;\n\nint = '\\\\d+';\n\ndecimal = `\\\\.${int}`;\n\nfloat = `(?:${int}${decimal}|${int}|${decimal})`;\n\npercent = `${float}%`;\n\nvariables = '(?:@[a-zA-Z0-9\\\\-_]+|\\\\$[a-zA-Z0-9\\\\-_]+|[a-zA-Z_][a-zA-Z0-9\\\\-_]*)';\n\nnamePrefixes = '^| |\\\\t|:|=|,|\\\\n|\\'|\"|\\\\(|\\\\[|\\\\{|>';\n\nmodule.exports = {\n int: int,\n float: float,\n percent: percent,\n optionalPercent: `${float}%?`,\n intOrPercent: `(?:${percent}|${int})`,\n floatOrPercent: `(?:${percent}|${float})`,\n comma: '\\\\s*,\\\\s*',\n notQuote: \"[^\\\"'\\\\n\\\\r]+\",\n hexadecimal: '[\\\\da-fA-F]',\n ps: '\\\\(\\\\s*',\n pe: '\\\\s*\\\\)',\n variables: variables,\n namePrefixes: namePrefixes,\n createVariableRegExpString: function(variables) {\n var i, len, v, variableNames;\n variableNames = [];\n for (i = 0, len = variables.length; i < len; i++) {\n v = variables[i];\n variableNames.push(v.name.replace(/[-\\[\\]\\/\\{\\}\\(\\)\\*\\+\\?\\.\\\\\\^\\$\\|]/g, \"\\\\$&\"));\n }\n variableNames = variableNames.join('|');\n return `(?:${namePrefixes})(${variableNames})(\\\\s+!default)?(?!_|-|\\\\w|\\\\d|[ \\\\t]*[\\\\.:=])`;\n }\n};\n```", "response": "int = '\\\\d+'\ndecimal = \"\\\\.#{int}\"\nfloat = \"(?:#{int}#{decimal}|#{int}|#{decimal})\"\npercent = \"#{float}%\"\nvariables = '(?:@[a-zA-Z0-9\\\\-_]+|\\\\$[a-zA-Z0-9\\\\-_]+|[a-zA-Z_][a-zA-Z0-9\\\\-_]*)'\nnamePrefixes = '^| |\\\\t|:|=|,|\\\\n|\\'|\"|\\\\(|\\\\[|\\\\{|>'\n\nmodule.exports =\n int: int\n float: float\n percent: percent\n optionalPercent: \"#{float}%?\"\n intOrPercent: \"(?:#{percent}|#{int})\"\n floatOrPercent: \"(?:#{percent}|#{float})\"\n comma: '\\\\s*,\\\\s*'\n notQuote: \"[^\\\"'\\\\n\\\\r]+\"\n hexadecimal: '[\\\\da-fA-F]'\n ps: '\\\\(\\\\s*'\n pe: '\\\\s*\\\\)'\n variables: variables\n namePrefixes: namePrefixes\n createVariableRegExpString: (variables) ->\n variableNames = []\n for v in variables\n variableNames.push v.name.replace(/[-\\[\\]\\/\\{\\}\\(\\)\\*\\+\\?\\.\\\\\\^\\$\\|]/g, \"\\\\$&\")\n variableNames = variableNames.join('|')\n\n \"(?:#{namePrefixes})(#{variableNames})(\\\\s+!default)?(?!_|-|\\\\w|\\\\d|[ \\\\t]*[\\\\.:=])\"", "source_lang": "JavaScript", "target_lang": "CoffeeScript", "repo": "abe33/atom-pigments", "path": "lib/regexes.coffee", "license": "MIT", "commit": "941fc7a34f1fb3a5072defb3a5f7b04b0a3dcf97", "stars": 518, "source_url": "https://github.com/abe33/atom-pigments/blob/941fc7a34f1fb3a5072defb3a5f7b04b0a3dcf97/lib/regexes.coffee", "line_start": 1, "line_end": 28}668{"id": "abe33/atom-pigments:lib/regexes.coffee:1:completion", "type": "completion", "prompt": "int = '\\\\d+'\ndecimal = \"\\\\.#{int}\"\nfloat = \"(?:#{int}#{decimal}|#{int}|#{decimal})\"\npercent = \"#{float}%\"\nvariables = '(?:@[a-zA-Z0-9\\\\-_]+|\\\\$[a-zA-Z0-9\\\\-_]+|[a-zA-Z_][a-zA-Z0-9\\\\-_]*)'\nnamePrefixes = '^| |\\\\t|:|=|,|\\\\n|\\'|\"|\\\\(|\\\\[|\\\\{|>'\n\nmodule.exports =\n int: int\n float: float\n percent: percent\n optionalPercent: \"#{float}%?\"\n intOrPercent: \"(?:#{percent}|#{int})\"\n floatOrPercent: \"(?:#{percent}|#{float})\"", "response": "comma: '\\\\s*,\\\\s*'\n notQuote: \"[^\\\"'\\\\n\\\\r]+\"\n hexadecimal: '[\\\\da-fA-F]'\n ps: '\\\\(\\\\s*'\n pe: '\\\\s*\\\\)'\n variables: variables\n namePrefixes: namePrefixes\n createVariableRegExpString: (variables) ->\n variableNames = []\n for v in variables\n variableNames.push v.name.replace(/[-\\[\\]\\/\\{\\}\\(\\)\\*\\+\\?\\.\\\\\\^\\$\\|]/g, \"\\\\$&\")\n variableNames = variableNames.join('|')\n\n \"(?:#{namePrefixes})(#{variableNames})(\\\\s+!default)?(?!_|-|\\\\w|\\\\d|[ \\\\t]*[\\\\.:=])\"", "source_lang": "CoffeeScript", "target_lang": "CoffeeScript", "repo": "abe33/atom-pigments", "path": "lib/regexes.coffee", "license": "MIT", "commit": "941fc7a34f1fb3a5072defb3a5f7b04b0a3dcf97", "stars": 518, "source_url": "https://github.com/abe33/atom-pigments/blob/941fc7a34f1fb3a5072defb3a5f7b04b0a3dcf97/lib/regexes.coffee", "line_start": 1, "line_end": 28}669{"id": "abe33/atom-pigments:lib/regexes.coffee:1:raw_corpus", "type": "raw_corpus", "prompt": "", "response": "int = '\\\\d+'\ndecimal = \"\\\\.#{int}\"\nfloat = \"(?:#{int}#{decimal}|#{int}|#{decimal})\"\npercent = \"#{float}%\"\nvariables = '(?:@[a-zA-Z0-9\\\\-_]+|\\\\$[a-zA-Z0-9\\\\-_]+|[a-zA-Z_][a-zA-Z0-9\\\\-_]*)'\nnamePrefixes = '^| |\\\\t|:|=|,|\\\\n|\\'|\"|\\\\(|\\\\[|\\\\{'\n\nmodule.exports =\n int: int\n float: float\n percent: percent\n optionalPercent: \"#{float}%?\"\n intOrPercent: \"(?:#{percent}|#{int})\"\n floatOrPercent: \"(?:#{percent}|#{float})\"\n comma: '\\\\s*,\\\\s*'\n notQuote: \"[^\\\"'\\\\n\\\\r]+\"\n hexadecimal: '[\\\\da-fA-F]'\n ps: '\\\\(\\\\s*'\n pe: '\\\\s*\\\\)'\n variables: variables\n namePrefixes: namePrefixes\n createVariableRegExpString: (variables) ->\n variableNames = []\n for v in variables\n variableNames.push v.name.replace(/[-\\[\\]\\/\\{\\}\\(\\)\\*\\+\\?\\.\\\\\\^\\$\\|]/g, \"\\\\$&\")\n variableNames = variableNames.join('|')\n\n \"(?:#{namePrefixes})(#{variableNames})(\\\\s+!default)?(?!_|-|\\\\w|\\\\d|[ \\\\t]*[\\\\.:=])\"", "source_lang": "", "target_lang": "CoffeeScript", "repo": "abe33/atom-pigments", "path": "lib/regexes.coffee", "license": "MIT", "commit": "7a735c05386dd147bcd190b93744397602e9b9c0", "stars": 518, "source_url": "https://github.com/abe33/atom-pigments/blob/7a735c05386dd147bcd190b93744397602e9b9c0/lib/regexes.coffee", "line_start": 1, "line_end": 28}670{"id": "abe33/atom-pigments:lib/regexes.coffee:1:coffee_to_js", "type": "coffee_to_js", "prompt": "Convert this CoffeeScript to JavaScript.\n```coffeescript\nint = '\\\\d+'\ndecimal = \"\\\\.#{int}\"\nfloat = \"(?:#{int}#{decimal}|#{int}|#{decimal})\"\npercent = \"#{float}%\"\nvariables = '(?:@[a-zA-Z0-9\\\\-_]+|\\\\$[a-zA-Z0-9\\\\-_]+|[a-zA-Z_][a-zA-Z0-9\\\\-_]*)'\nnamePrefixes = '^| |\\\\t|:|=|,|\\\\n|\\'|\"|\\\\(|\\\\[|\\\\{'\n\nmodule.exports =\n int: int\n float: float\n percent: percent\n optionalPercent: \"#{float}%?\"\n intOrPercent: \"(?:#{percent}|#{int})\"\n floatOrPercent: \"(?:#{percent}|#{float})\"\n comma: '\\\\s*,\\\\s*'\n notQuote: \"[^\\\"'\\\\n\\\\r]+\"\n hexadecimal: '[\\\\da-fA-F]'\n ps: '\\\\(\\\\s*'\n pe: '\\\\s*\\\\)'\n variables: variables\n namePrefixes: namePrefixes\n createVariableRegExpString: (variables) ->\n variableNames = []\n for v in variables\n variableNames.push v.name.replace(/[-\\[\\]\\/\\{\\}\\(\\)\\*\\+\\?\\.\\\\\\^\\$\\|]/g, \"\\\\$&\")\n variableNames = variableNames.join('|')\n\n \"(?:#{namePrefixes})(#{variableNames})(\\\\s+!default)?(?!_|-|\\\\w|\\\\d|[ \\\\t]*[\\\\.:=])\"\n```", "response": "var decimal, float, int, namePrefixes, percent, variables;\n\nint = '\\\\d+';\n\ndecimal = `\\\\.${int}`;\n\nfloat = `(?:${int}${decimal}|${int}|${decimal})`;\n\npercent = `${float}%`;\n\nvariables = '(?:@[a-zA-Z0-9\\\\-_]+|\\\\$[a-zA-Z0-9\\\\-_]+|[a-zA-Z_][a-zA-Z0-9\\\\-_]*)';\n\nnamePrefixes = '^| |\\\\t|:|=|,|\\\\n|\\'|\"|\\\\(|\\\\[|\\\\{';\n\nmodule.exports = {\n int: int,\n float: float,\n percent: percent,\n optionalPercent: `${float}%?`,\n intOrPercent: `(?:${percent}|${int})`,\n floatOrPercent: `(?:${percent}|${float})`,\n comma: '\\\\s*,\\\\s*',\n notQuote: \"[^\\\"'\\\\n\\\\r]+\",\n hexadecimal: '[\\\\da-fA-F]',\n ps: '\\\\(\\\\s*',\n pe: '\\\\s*\\\\)',\n variables: variables,\n namePrefixes: namePrefixes,\n createVariableRegExpString: function(variables) {\n var i, len, v, variableNames;\n variableNames = [];\n for (i = 0, len = variables.length; i < len; i++) {\n v = variables[i];\n variableNames.push(v.name.replace(/[-\\[\\]\\/\\{\\}\\(\\)\\*\\+\\?\\.\\\\\\^\\$\\|]/g, \"\\\\$&\"));\n }\n variableNames = variableNames.join('|');\n return `(?:${namePrefixes})(${variableNames})(\\\\s+!default)?(?!_|-|\\\\w|\\\\d|[ \\\\t]*[\\\\.:=])`;\n }\n};", "source_lang": "CoffeeScript", "target_lang": "JavaScript", "repo": "abe33/atom-pigments", "path": "lib/regexes.coffee", "license": "MIT", "commit": "7a735c05386dd147bcd190b93744397602e9b9c0", "stars": 518, "source_url": "https://github.com/abe33/atom-pigments/blob/7a735c05386dd147bcd190b93744397602e9b9c0/lib/regexes.coffee", "line_start": 1, "line_end": 28}671{"id": "abe33/atom-pigments:lib/regexes.coffee:1:js_to_coffee", "type": "js_to_coffee", "prompt": "Convert this JavaScript to CoffeeScript.\n```javascript\nvar decimal, float, int, namePrefixes, percent, variables;\n\nint = '\\\\d+';\n\ndecimal = `\\\\.${int}`;\n\nfloat = `(?:${int}${decimal}|${int}|${decimal})`;\n\npercent = `${float}%`;\n\nvariables = '(?:@[a-zA-Z0-9\\\\-_]+|\\\\$[a-zA-Z0-9\\\\-_]+|[a-zA-Z_][a-zA-Z0-9\\\\-_]*)';\n\nnamePrefixes = '^| |\\\\t|:|=|,|\\\\n|\\'|\"|\\\\(|\\\\[|\\\\{';\n\nmodule.exports = {\n int: int,\n float: float,\n percent: percent,\n optionalPercent: `${float}%?`,\n intOrPercent: `(?:${percent}|${int})`,\n floatOrPercent: `(?:${percent}|${float})`,\n comma: '\\\\s*,\\\\s*',\n notQuote: \"[^\\\"'\\\\n\\\\r]+\",\n hexadecimal: '[\\\\da-fA-F]',\n ps: '\\\\(\\\\s*',\n pe: '\\\\s*\\\\)',\n variables: variables,\n namePrefixes: namePrefixes,\n createVariableRegExpString: function(variables) {\n var i, len, v, variableNames;\n variableNames = [];\n for (i = 0, len = variables.length; i < len; i++) {\n v = variables[i];\n variableNames.push(v.name.replace(/[-\\[\\]\\/\\{\\}\\(\\)\\*\\+\\?\\.\\\\\\^\\$\\|]/g, \"\\\\$&\"));\n }\n variableNames = variableNames.join('|');\n return `(?:${namePrefixes})(${variableNames})(\\\\s+!default)?(?!_|-|\\\\w|\\\\d|[ \\\\t]*[\\\\.:=])`;\n }\n};\n```", "response": "int = '\\\\d+'\ndecimal = \"\\\\.#{int}\"\nfloat = \"(?:#{int}#{decimal}|#{int}|#{decimal})\"\npercent = \"#{float}%\"\nvariables = '(?:@[a-zA-Z0-9\\\\-_]+|\\\\$[a-zA-Z0-9\\\\-_]+|[a-zA-Z_][a-zA-Z0-9\\\\-_]*)'\nnamePrefixes = '^| |\\\\t|:|=|,|\\\\n|\\'|\"|\\\\(|\\\\[|\\\\{'\n\nmodule.exports =\n int: int\n float: float\n percent: percent\n optionalPercent: \"#{float}%?\"\n intOrPercent: \"(?:#{percent}|#{int})\"\n floatOrPercent: \"(?:#{percent}|#{float})\"\n comma: '\\\\s*,\\\\s*'\n notQuote: \"[^\\\"'\\\\n\\\\r]+\"\n hexadecimal: '[\\\\da-fA-F]'\n ps: '\\\\(\\\\s*'\n pe: '\\\\s*\\\\)'\n variables: variables\n namePrefixes: namePrefixes\n createVariableRegExpString: (variables) ->\n variableNames = []\n for v in variables\n variableNames.push v.name.replace(/[-\\[\\]\\/\\{\\}\\(\\)\\*\\+\\?\\.\\\\\\^\\$\\|]/g, \"\\\\$&\")\n variableNames = variableNames.join('|')\n\n \"(?:#{namePrefixes})(#{variableNames})(\\\\s+!default)?(?!_|-|\\\\w|\\\\d|[ \\\\t]*[\\\\.:=])\"", "source_lang": "JavaScript", "target_lang": "CoffeeScript", "repo": "abe33/atom-pigments", "path": "lib/regexes.coffee", "license": "MIT", "commit": "7a735c05386dd147bcd190b93744397602e9b9c0", "stars": 518, "source_url": "https://github.com/abe33/atom-pigments/blob/7a735c05386dd147bcd190b93744397602e9b9c0/lib/regexes.coffee", "line_start": 1, "line_end": 28}672{"id": "abe33/atom-pigments:lib/regexes.coffee:1:completion", "type": "completion", "prompt": "int = '\\\\d+'\ndecimal = \"\\\\.#{int}\"\nfloat = \"(?:#{int}#{decimal}|#{int}|#{decimal})\"\npercent = \"#{float}%\"\nvariables = '(?:@[a-zA-Z0-9\\\\-_]+|\\\\$[a-zA-Z0-9\\\\-_]+|[a-zA-Z_][a-zA-Z0-9\\\\-_]*)'\nnamePrefixes = '^| |\\\\t|:|=|,|\\\\n|\\'|\"|\\\\(|\\\\[|\\\\{'\n\nmodule.exports =\n int: int\n float: float\n percent: percent\n optionalPercent: \"#{float}%?\"\n intOrPercent: \"(?:#{percent}|#{int})\"\n floatOrPercent: \"(?:#{percent}|#{float})\"", "response": "comma: '\\\\s*,\\\\s*'\n notQuote: \"[^\\\"'\\\\n\\\\r]+\"\n hexadecimal: '[\\\\da-fA-F]'\n ps: '\\\\(\\\\s*'\n pe: '\\\\s*\\\\)'\n variables: variables\n namePrefixes: namePrefixes\n createVariableRegExpString: (variables) ->\n variableNames = []\n for v in variables\n variableNames.push v.name.replace(/[-\\[\\]\\/\\{\\}\\(\\)\\*\\+\\?\\.\\\\\\^\\$\\|]/g, \"\\\\$&\")\n variableNames = variableNames.join('|')\n\n \"(?:#{namePrefixes})(#{variableNames})(\\\\s+!default)?(?!_|-|\\\\w|\\\\d|[ \\\\t]*[\\\\.:=])\"", "source_lang": "CoffeeScript", "target_lang": "CoffeeScript", "repo": "abe33/atom-pigments", "path": "lib/regexes.coffee", "license": "MIT", "commit": "7a735c05386dd147bcd190b93744397602e9b9c0", "stars": 518, "source_url": "https://github.com/abe33/atom-pigments/blob/7a735c05386dd147bcd190b93744397602e9b9c0/lib/regexes.coffee", "line_start": 1, "line_end": 28}673{"id": "abe33/atom-pigments:lib/regexes.coffee:1:raw_corpus", "type": "raw_corpus", "prompt": "", "response": "int = '\\\\d+'\ndecimal = \"\\\\.#{int}\"\nfloat = \"(?:#{int}#{decimal}|#{int}|#{decimal})\"\npercent = \"#{float}%\"\nvariables = '(?:@[a-zA-Z0-9\\\\-_]+|\\\\$[a-zA-Z0-9\\\\-_]+|[a-zA-Z_][a-zA-Z0-9\\\\-_]*)'\nnamePrefixes = '^| |\\\\t|:|=|,|\\\\n|\\'|\"|\\\\(|\\\\[|\\\\{'\n\nmodule.exports =\n int: int\n float: float\n percent: percent\n optionalPercent: \"#{float}%?\"\n intOrPercent: \"(?:#{percent}|#{int})\"\n floatOrPercent: \"(?:#{percent}|#{float})\"\n comma: '\\\\s*,\\\\s*'\n notQuote: \"[^\\\"'\\\\n\\\\r]+\"\n hexadecimal: '[\\\\da-fA-F]'\n ps: '\\\\(\\\\s*'\n pe: '\\\\s*\\\\)'\n variables: variables\n namePrefixes: namePrefixes\n createVariableRegExpString: (variables) ->\n variableNames = []\n for v in variables\n variableNames.push v.name.replace(/[-\\[\\]\\/\\{\\}\\(\\)\\*\\+\\?\\.\\\\\\^\\$\\|]/g, \"\\\\$&\")\n variableNames = variableNames.join('|')\n\n \"(?:#{namePrefixes})(#{variableNames})(?!_|-|\\\\w|\\\\d|[ \\\\t]*[\\\\.:=])\"", "source_lang": "", "target_lang": "CoffeeScript", "repo": "abe33/atom-pigments", "path": "lib/regexes.coffee", "license": "MIT", "commit": "07117e1fe1c5215bc921085dd516ce72d6af6604", "stars": 518, "source_url": "https://github.com/abe33/atom-pigments/blob/07117e1fe1c5215bc921085dd516ce72d6af6604/lib/regexes.coffee", "line_start": 1, "line_end": 28}674{"id": "abe33/atom-pigments:lib/regexes.coffee:1:coffee_to_js", "type": "coffee_to_js", "prompt": "Convert this CoffeeScript to JavaScript.\n```coffeescript\nint = '\\\\d+'\ndecimal = \"\\\\.#{int}\"\nfloat = \"(?:#{int}#{decimal}|#{int}|#{decimal})\"\npercent = \"#{float}%\"\nvariables = '(?:@[a-zA-Z0-9\\\\-_]+|\\\\$[a-zA-Z0-9\\\\-_]+|[a-zA-Z_][a-zA-Z0-9\\\\-_]*)'\nnamePrefixes = '^| |\\\\t|:|=|,|\\\\n|\\'|\"|\\\\(|\\\\[|\\\\{'\n\nmodule.exports =\n int: int\n float: float\n percent: percent\n optionalPercent: \"#{float}%?\"\n intOrPercent: \"(?:#{percent}|#{int})\"\n floatOrPercent: \"(?:#{percent}|#{float})\"\n comma: '\\\\s*,\\\\s*'\n notQuote: \"[^\\\"'\\\\n\\\\r]+\"\n hexadecimal: '[\\\\da-fA-F]'\n ps: '\\\\(\\\\s*'\n pe: '\\\\s*\\\\)'\n variables: variables\n namePrefixes: namePrefixes\n createVariableRegExpString: (variables) ->\n variableNames = []\n for v in variables\n variableNames.push v.name.replace(/[-\\[\\]\\/\\{\\}\\(\\)\\*\\+\\?\\.\\\\\\^\\$\\|]/g, \"\\\\$&\")\n variableNames = variableNames.join('|')\n\n \"(?:#{namePrefixes})(#{variableNames})(?!_|-|\\\\w|\\\\d|[ \\\\t]*[\\\\.:=])\"\n```", "response": "var decimal, float, int, namePrefixes, percent, variables;\n\nint = '\\\\d+';\n\ndecimal = `\\\\.${int}`;\n\nfloat = `(?:${int}${decimal}|${int}|${decimal})`;\n\npercent = `${float}%`;\n\nvariables = '(?:@[a-zA-Z0-9\\\\-_]+|\\\\$[a-zA-Z0-9\\\\-_]+|[a-zA-Z_][a-zA-Z0-9\\\\-_]*)';\n\nnamePrefixes = '^| |\\\\t|:|=|,|\\\\n|\\'|\"|\\\\(|\\\\[|\\\\{';\n\nmodule.exports = {\n int: int,\n float: float,\n percent: percent,\n optionalPercent: `${float}%?`,\n intOrPercent: `(?:${percent}|${int})`,\n floatOrPercent: `(?:${percent}|${float})`,\n comma: '\\\\s*,\\\\s*',\n notQuote: \"[^\\\"'\\\\n\\\\r]+\",\n hexadecimal: '[\\\\da-fA-F]',\n ps: '\\\\(\\\\s*',\n pe: '\\\\s*\\\\)',\n variables: variables,\n namePrefixes: namePrefixes,\n createVariableRegExpString: function(variables) {\n var i, len, v, variableNames;\n variableNames = [];\n for (i = 0, len = variables.length; i < len; i++) {\n v = variables[i];\n variableNames.push(v.name.replace(/[-\\[\\]\\/\\{\\}\\(\\)\\*\\+\\?\\.\\\\\\^\\$\\|]/g, \"\\\\$&\"));\n }\n variableNames = variableNames.join('|');\n return `(?:${namePrefixes})(${variableNames})(?!_|-|\\\\w|\\\\d|[ \\\\t]*[\\\\.:=])`;\n }\n};", "source_lang": "CoffeeScript", "target_lang": "JavaScript", "repo": "abe33/atom-pigments", "path": "lib/regexes.coffee", "license": "MIT", "commit": "07117e1fe1c5215bc921085dd516ce72d6af6604", "stars": 518, "source_url": "https://github.com/abe33/atom-pigments/blob/07117e1fe1c5215bc921085dd516ce72d6af6604/lib/regexes.coffee", "line_start": 1, "line_end": 28}675{"id": "abe33/atom-pigments:lib/regexes.coffee:1:js_to_coffee", "type": "js_to_coffee", "prompt": "Convert this JavaScript to CoffeeScript.\n```javascript\nvar decimal, float, int, namePrefixes, percent, variables;\n\nint = '\\\\d+';\n\ndecimal = `\\\\.${int}`;\n\nfloat = `(?:${int}${decimal}|${int}|${decimal})`;\n\npercent = `${float}%`;\n\nvariables = '(?:@[a-zA-Z0-9\\\\-_]+|\\\\$[a-zA-Z0-9\\\\-_]+|[a-zA-Z_][a-zA-Z0-9\\\\-_]*)';\n\nnamePrefixes = '^| |\\\\t|:|=|,|\\\\n|\\'|\"|\\\\(|\\\\[|\\\\{';\n\nmodule.exports = {\n int: int,\n float: float,\n percent: percent,\n optionalPercent: `${float}%?`,\n intOrPercent: `(?:${percent}|${int})`,\n floatOrPercent: `(?:${percent}|${float})`,\n comma: '\\\\s*,\\\\s*',\n notQuote: \"[^\\\"'\\\\n\\\\r]+\",\n hexadecimal: '[\\\\da-fA-F]',\n ps: '\\\\(\\\\s*',\n pe: '\\\\s*\\\\)',\n variables: variables,\n namePrefixes: namePrefixes,\n createVariableRegExpString: function(variables) {\n var i, len, v, variableNames;\n variableNames = [];\n for (i = 0, len = variables.length; i < len; i++) {\n v = variables[i];\n variableNames.push(v.name.replace(/[-\\[\\]\\/\\{\\}\\(\\)\\*\\+\\?\\.\\\\\\^\\$\\|]/g, \"\\\\$&\"));\n }\n variableNames = variableNames.join('|');\n return `(?:${namePrefixes})(${variableNames})(?!_|-|\\\\w|\\\\d|[ \\\\t]*[\\\\.:=])`;\n }\n};\n```", "response": "int = '\\\\d+'\ndecimal = \"\\\\.#{int}\"\nfloat = \"(?:#{int}#{decimal}|#{int}|#{decimal})\"\npercent = \"#{float}%\"\nvariables = '(?:@[a-zA-Z0-9\\\\-_]+|\\\\$[a-zA-Z0-9\\\\-_]+|[a-zA-Z_][a-zA-Z0-9\\\\-_]*)'\nnamePrefixes = '^| |\\\\t|:|=|,|\\\\n|\\'|\"|\\\\(|\\\\[|\\\\{'\n\nmodule.exports =\n int: int\n float: float\n percent: percent\n optionalPercent: \"#{float}%?\"\n intOrPercent: \"(?:#{percent}|#{int})\"\n floatOrPercent: \"(?:#{percent}|#{float})\"\n comma: '\\\\s*,\\\\s*'\n notQuote: \"[^\\\"'\\\\n\\\\r]+\"\n hexadecimal: '[\\\\da-fA-F]'\n ps: '\\\\(\\\\s*'\n pe: '\\\\s*\\\\)'\n variables: variables\n namePrefixes: namePrefixes\n createVariableRegExpString: (variables) ->\n variableNames = []\n for v in variables\n variableNames.push v.name.replace(/[-\\[\\]\\/\\{\\}\\(\\)\\*\\+\\?\\.\\\\\\^\\$\\|]/g, \"\\\\$&\")\n variableNames = variableNames.join('|')\n\n \"(?:#{namePrefixes})(#{variableNames})(?!_|-|\\\\w|\\\\d|[ \\\\t]*[\\\\.:=])\"", "source_lang": "JavaScript", "target_lang": "CoffeeScript", "repo": "abe33/atom-pigments", "path": "lib/regexes.coffee", "license": "MIT", "commit": "07117e1fe1c5215bc921085dd516ce72d6af6604", "stars": 518, "source_url": "https://github.com/abe33/atom-pigments/blob/07117e1fe1c5215bc921085dd516ce72d6af6604/lib/regexes.coffee", "line_start": 1, "line_end": 28}676{"id": "abe33/atom-pigments:lib/regexes.coffee:1:completion", "type": "completion", "prompt": "int = '\\\\d+'\ndecimal = \"\\\\.#{int}\"\nfloat = \"(?:#{int}#{decimal}|#{int}|#{decimal})\"\npercent = \"#{float}%\"\nvariables = '(?:@[a-zA-Z0-9\\\\-_]+|\\\\$[a-zA-Z0-9\\\\-_]+|[a-zA-Z_][a-zA-Z0-9\\\\-_]*)'\nnamePrefixes = '^| |\\\\t|:|=|,|\\\\n|\\'|\"|\\\\(|\\\\[|\\\\{'\n\nmodule.exports =\n int: int\n float: float\n percent: percent\n optionalPercent: \"#{float}%?\"\n intOrPercent: \"(?:#{percent}|#{int})\"\n floatOrPercent: \"(?:#{percent}|#{float})\"", "response": "comma: '\\\\s*,\\\\s*'\n notQuote: \"[^\\\"'\\\\n\\\\r]+\"\n hexadecimal: '[\\\\da-fA-F]'\n ps: '\\\\(\\\\s*'\n pe: '\\\\s*\\\\)'\n variables: variables\n namePrefixes: namePrefixes\n createVariableRegExpString: (variables) ->\n variableNames = []\n for v in variables\n variableNames.push v.name.replace(/[-\\[\\]\\/\\{\\}\\(\\)\\*\\+\\?\\.\\\\\\^\\$\\|]/g, \"\\\\$&\")\n variableNames = variableNames.join('|')\n\n \"(?:#{namePrefixes})(#{variableNames})(?!_|-|\\\\w|\\\\d|[ \\\\t]*[\\\\.:=])\"", "source_lang": "CoffeeScript", "target_lang": "CoffeeScript", "repo": "abe33/atom-pigments", "path": "lib/regexes.coffee", "license": "MIT", "commit": "07117e1fe1c5215bc921085dd516ce72d6af6604", "stars": 518, "source_url": "https://github.com/abe33/atom-pigments/blob/07117e1fe1c5215bc921085dd516ce72d6af6604/lib/regexes.coffee", "line_start": 1, "line_end": 28}677{"id": "abe33/atom-pigments:lib/regexes.coffee:1:raw_corpus", "type": "raw_corpus", "prompt": "", "response": "int = '\\\\d+'\ndecimal = \"\\\\.#{int}\"\nfloat = \"(?:#{int}#{decimal}|#{int}|#{decimal})\"\npercent = \"#{float}%\"\nvariables = '(?:@[a-zA-Z0-9\\\\-_]+|\\\\$[a-zA-Z0-9\\\\-_]+|[a-zA-Z_][a-zA-Z0-9\\\\-_]*)'\nnamePrefixes = '^| |\\\\t|:|=|,|\\\\n|\\'|\"|\\\\(|\\\\[|\\\\{'\n\nmodule.exports =\n int: int\n float: float\n percent: percent\n optionalPercent: \"#{float}%?\"\n intOrPercent: \"(?:#{percent}|#{int})\"\n floatOrPercent: \"(?:#{percent}|#{float})\"\n comma: '\\\\s*,\\\\s*'\n notQuote: \"[^\\\"'\\\\n]+\"\n hexadecimal: '[\\\\da-fA-F]'\n ps: '\\\\(\\\\s*'\n pe: '\\\\s*\\\\)'\n variables: variables\n namePrefixes: namePrefixes\n createVariableRegExpString: (variables) ->\n variableNames = []\n for v in variables\n variableNames.push v.name.replace(/[-\\[\\]\\/\\{\\}\\(\\)\\*\\+\\?\\.\\\\\\^\\$\\|]/g, \"\\\\$&\")\n variableNames = variableNames.join('|')\n\n \"(?:#{namePrefixes})(#{variableNames})(?!_|-|\\\\w|\\\\d|[ \\\\t]*[\\\\.:=])\"", "source_lang": "", "target_lang": "CoffeeScript", "repo": "abe33/atom-pigments", "path": "lib/regexes.coffee", "license": "MIT", "commit": "114b772bf26b5217ff66cca1b42978fbca3a0fba", "stars": 518, "source_url": "https://github.com/abe33/atom-pigments/blob/114b772bf26b5217ff66cca1b42978fbca3a0fba/lib/regexes.coffee", "line_start": 1, "line_end": 28}678{"id": "abe33/atom-pigments:lib/regexes.coffee:1:coffee_to_js", "type": "coffee_to_js", "prompt": "Convert this CoffeeScript to JavaScript.\n```coffeescript\nint = '\\\\d+'\ndecimal = \"\\\\.#{int}\"\nfloat = \"(?:#{int}#{decimal}|#{int}|#{decimal})\"\npercent = \"#{float}%\"\nvariables = '(?:@[a-zA-Z0-9\\\\-_]+|\\\\$[a-zA-Z0-9\\\\-_]+|[a-zA-Z_][a-zA-Z0-9\\\\-_]*)'\nnamePrefixes = '^| |\\\\t|:|=|,|\\\\n|\\'|\"|\\\\(|\\\\[|\\\\{'\n\nmodule.exports =\n int: int\n float: float\n percent: percent\n optionalPercent: \"#{float}%?\"\n intOrPercent: \"(?:#{percent}|#{int})\"\n floatOrPercent: \"(?:#{percent}|#{float})\"\n comma: '\\\\s*,\\\\s*'\n notQuote: \"[^\\\"'\\\\n]+\"\n hexadecimal: '[\\\\da-fA-F]'\n ps: '\\\\(\\\\s*'\n pe: '\\\\s*\\\\)'\n variables: variables\n namePrefixes: namePrefixes\n createVariableRegExpString: (variables) ->\n variableNames = []\n for v in variables\n variableNames.push v.name.replace(/[-\\[\\]\\/\\{\\}\\(\\)\\*\\+\\?\\.\\\\\\^\\$\\|]/g, \"\\\\$&\")\n variableNames = variableNames.join('|')\n\n \"(?:#{namePrefixes})(#{variableNames})(?!_|-|\\\\w|\\\\d|[ \\\\t]*[\\\\.:=])\"\n```", "response": "var decimal, float, int, namePrefixes, percent, variables;\n\nint = '\\\\d+';\n\ndecimal = `\\\\.${int}`;\n\nfloat = `(?:${int}${decimal}|${int}|${decimal})`;\n\npercent = `${float}%`;\n\nvariables = '(?:@[a-zA-Z0-9\\\\-_]+|\\\\$[a-zA-Z0-9\\\\-_]+|[a-zA-Z_][a-zA-Z0-9\\\\-_]*)';\n\nnamePrefixes = '^| |\\\\t|:|=|,|\\\\n|\\'|\"|\\\\(|\\\\[|\\\\{';\n\nmodule.exports = {\n int: int,\n float: float,\n percent: percent,\n optionalPercent: `${float}%?`,\n intOrPercent: `(?:${percent}|${int})`,\n floatOrPercent: `(?:${percent}|${float})`,\n comma: '\\\\s*,\\\\s*',\n notQuote: \"[^\\\"'\\\\n]+\",\n hexadecimal: '[\\\\da-fA-F]',\n ps: '\\\\(\\\\s*',\n pe: '\\\\s*\\\\)',\n variables: variables,\n namePrefixes: namePrefixes,\n createVariableRegExpString: function(variables) {\n var i, len, v, variableNames;\n variableNames = [];\n for (i = 0, len = variables.length; i < len; i++) {\n v = variables[i];\n variableNames.push(v.name.replace(/[-\\[\\]\\/\\{\\}\\(\\)\\*\\+\\?\\.\\\\\\^\\$\\|]/g, \"\\\\$&\"));\n }\n variableNames = variableNames.join('|');\n return `(?:${namePrefixes})(${variableNames})(?!_|-|\\\\w|\\\\d|[ \\\\t]*[\\\\.:=])`;\n }\n};", "source_lang": "CoffeeScript", "target_lang": "JavaScript", "repo": "abe33/atom-pigments", "path": "lib/regexes.coffee", "license": "MIT", "commit": "114b772bf26b5217ff66cca1b42978fbca3a0fba", "stars": 518, "source_url": "https://github.com/abe33/atom-pigments/blob/114b772bf26b5217ff66cca1b42978fbca3a0fba/lib/regexes.coffee", "line_start": 1, "line_end": 28}679{"id": "abe33/atom-pigments:lib/regexes.coffee:1:js_to_coffee", "type": "js_to_coffee", "prompt": "Convert this JavaScript to CoffeeScript.\n```javascript\nvar decimal, float, int, namePrefixes, percent, variables;\n\nint = '\\\\d+';\n\ndecimal = `\\\\.${int}`;\n\nfloat = `(?:${int}${decimal}|${int}|${decimal})`;\n\npercent = `${float}%`;\n\nvariables = '(?:@[a-zA-Z0-9\\\\-_]+|\\\\$[a-zA-Z0-9\\\\-_]+|[a-zA-Z_][a-zA-Z0-9\\\\-_]*)';\n\nnamePrefixes = '^| |\\\\t|:|=|,|\\\\n|\\'|\"|\\\\(|\\\\[|\\\\{';\n\nmodule.exports = {\n int: int,\n float: float,\n percent: percent,\n optionalPercent: `${float}%?`,\n intOrPercent: `(?:${percent}|${int})`,\n floatOrPercent: `(?:${percent}|${float})`,\n comma: '\\\\s*,\\\\s*',\n notQuote: \"[^\\\"'\\\\n]+\",\n hexadecimal: '[\\\\da-fA-F]',\n ps: '\\\\(\\\\s*',\n pe: '\\\\s*\\\\)',\n variables: variables,\n namePrefixes: namePrefixes,\n createVariableRegExpString: function(variables) {\n var i, len, v, variableNames;\n variableNames = [];\n for (i = 0, len = variables.length; i < len; i++) {\n v = variables[i];\n variableNames.push(v.name.replace(/[-\\[\\]\\/\\{\\}\\(\\)\\*\\+\\?\\.\\\\\\^\\$\\|]/g, \"\\\\$&\"));\n }\n variableNames = variableNames.join('|');\n return `(?:${namePrefixes})(${variableNames})(?!_|-|\\\\w|\\\\d|[ \\\\t]*[\\\\.:=])`;\n }\n};\n```", "response": "int = '\\\\d+'\ndecimal = \"\\\\.#{int}\"\nfloat = \"(?:#{int}#{decimal}|#{int}|#{decimal})\"\npercent = \"#{float}%\"\nvariables = '(?:@[a-zA-Z0-9\\\\-_]+|\\\\$[a-zA-Z0-9\\\\-_]+|[a-zA-Z_][a-zA-Z0-9\\\\-_]*)'\nnamePrefixes = '^| |\\\\t|:|=|,|\\\\n|\\'|\"|\\\\(|\\\\[|\\\\{'\n\nmodule.exports =\n int: int\n float: float\n percent: percent\n optionalPercent: \"#{float}%?\"\n intOrPercent: \"(?:#{percent}|#{int})\"\n floatOrPercent: \"(?:#{percent}|#{float})\"\n comma: '\\\\s*,\\\\s*'\n notQuote: \"[^\\\"'\\\\n]+\"\n hexadecimal: '[\\\\da-fA-F]'\n ps: '\\\\(\\\\s*'\n pe: '\\\\s*\\\\)'\n variables: variables\n namePrefixes: namePrefixes\n createVariableRegExpString: (variables) ->\n variableNames = []\n for v in variables\n variableNames.push v.name.replace(/[-\\[\\]\\/\\{\\}\\(\\)\\*\\+\\?\\.\\\\\\^\\$\\|]/g, \"\\\\$&\")\n variableNames = variableNames.join('|')\n\n \"(?:#{namePrefixes})(#{variableNames})(?!_|-|\\\\w|\\\\d|[ \\\\t]*[\\\\.:=])\"", "source_lang": "JavaScript", "target_lang": "CoffeeScript", "repo": "abe33/atom-pigments", "path": "lib/regexes.coffee", "license": "MIT", "commit": "114b772bf26b5217ff66cca1b42978fbca3a0fba", "stars": 518, "source_url": "https://github.com/abe33/atom-pigments/blob/114b772bf26b5217ff66cca1b42978fbca3a0fba/lib/regexes.coffee", "line_start": 1, "line_end": 28}680{"id": "abe33/atom-pigments:lib/regexes.coffee:1:completion", "type": "completion", "prompt": "int = '\\\\d+'\ndecimal = \"\\\\.#{int}\"\nfloat = \"(?:#{int}#{decimal}|#{int}|#{decimal})\"\npercent = \"#{float}%\"\nvariables = '(?:@[a-zA-Z0-9\\\\-_]+|\\\\$[a-zA-Z0-9\\\\-_]+|[a-zA-Z_][a-zA-Z0-9\\\\-_]*)'\nnamePrefixes = '^| |\\\\t|:|=|,|\\\\n|\\'|\"|\\\\(|\\\\[|\\\\{'\n\nmodule.exports =\n int: int\n float: float\n percent: percent\n optionalPercent: \"#{float}%?\"\n intOrPercent: \"(?:#{percent}|#{int})\"\n floatOrPercent: \"(?:#{percent}|#{float})\"", "response": "comma: '\\\\s*,\\\\s*'\n notQuote: \"[^\\\"'\\\\n]+\"\n hexadecimal: '[\\\\da-fA-F]'\n ps: '\\\\(\\\\s*'\n pe: '\\\\s*\\\\)'\n variables: variables\n namePrefixes: namePrefixes\n createVariableRegExpString: (variables) ->\n variableNames = []\n for v in variables\n variableNames.push v.name.replace(/[-\\[\\]\\/\\{\\}\\(\\)\\*\\+\\?\\.\\\\\\^\\$\\|]/g, \"\\\\$&\")\n variableNames = variableNames.join('|')\n\n \"(?:#{namePrefixes})(#{variableNames})(?!_|-|\\\\w|\\\\d|[ \\\\t]*[\\\\.:=])\"", "source_lang": "CoffeeScript", "target_lang": "CoffeeScript", "repo": "abe33/atom-pigments", "path": "lib/regexes.coffee", "license": "MIT", "commit": "114b772bf26b5217ff66cca1b42978fbca3a0fba", "stars": 518, "source_url": "https://github.com/abe33/atom-pigments/blob/114b772bf26b5217ff66cca1b42978fbca3a0fba/lib/regexes.coffee", "line_start": 1, "line_end": 28}681{"id": "abe33/atom-pigments:lib/regexes.coffee:1:raw_corpus", "type": "raw_corpus", "prompt": "", "response": "int = '\\\\d+'\ndecimal = \"\\\\.#{int}\"\nfloat = \"(?:#{int}#{decimal}|#{int}|#{decimal})\"\npercent = \"#{float}%\"\nvariables = '(?:@[a-zA-Z0-9\\\\-_]+|\\\\$[a-zA-Z0-9\\\\-_]+|[a-zA-Z_][a-zA-Z0-9\\\\-_]*)'\nnamePrefixes = '^| |:|=|,|\\\\n|\\'|\"|\\\\(|\\\\[|\\\\{'\n\nmodule.exports =\n int: int\n float: float\n percent: percent\n optionalPercent: \"#{float}%?\"\n intOrPercent: \"(?:#{percent}|#{int})\"\n floatOrPercent: \"(?:#{percent}|#{float})\"\n comma: '\\\\s*,\\\\s*'\n notQuote: \"[^\\\"'\\\\n]+\"\n hexadecimal: '[\\\\da-fA-F]'\n ps: '\\\\(\\\\s*'\n pe: '\\\\s*\\\\)'\n variables: variables\n namePrefixes: namePrefixes\n createVariableRegExpString: (variables) ->\n variableNames = []\n for v in variables\n variableNames.push v.name.replace(/[-\\[\\]\\/\\{\\}\\(\\)\\*\\+\\?\\.\\\\\\^\\$\\|]/g, \"\\\\$&\")\n variableNames = variableNames.join('|')\n\n \"(?:#{namePrefixes})(#{variableNames})(?!_|-|\\\\w|\\\\d|[ \\\\t]*[\\\\.:=])\"", "source_lang": "", "target_lang": "CoffeeScript", "repo": "abe33/atom-pigments", "path": "lib/regexes.coffee", "license": "MIT", "commit": "75b059e09045bf7e060c3f9791dd7d98a44df133", "stars": 518, "source_url": "https://github.com/abe33/atom-pigments/blob/75b059e09045bf7e060c3f9791dd7d98a44df133/lib/regexes.coffee", "line_start": 1, "line_end": 28}682{"id": "abe33/atom-pigments:lib/regexes.coffee:1:coffee_to_js", "type": "coffee_to_js", "prompt": "Convert this CoffeeScript to JavaScript.\n```coffeescript\nint = '\\\\d+'\ndecimal = \"\\\\.#{int}\"\nfloat = \"(?:#{int}#{decimal}|#{int}|#{decimal})\"\npercent = \"#{float}%\"\nvariables = '(?:@[a-zA-Z0-9\\\\-_]+|\\\\$[a-zA-Z0-9\\\\-_]+|[a-zA-Z_][a-zA-Z0-9\\\\-_]*)'\nnamePrefixes = '^| |:|=|,|\\\\n|\\'|\"|\\\\(|\\\\[|\\\\{'\n\nmodule.exports =\n int: int\n float: float\n percent: percent\n optionalPercent: \"#{float}%?\"\n intOrPercent: \"(?:#{percent}|#{int})\"\n floatOrPercent: \"(?:#{percent}|#{float})\"\n comma: '\\\\s*,\\\\s*'\n notQuote: \"[^\\\"'\\\\n]+\"\n hexadecimal: '[\\\\da-fA-F]'\n ps: '\\\\(\\\\s*'\n pe: '\\\\s*\\\\)'\n variables: variables\n namePrefixes: namePrefixes\n createVariableRegExpString: (variables) ->\n variableNames = []\n for v in variables\n variableNames.push v.name.replace(/[-\\[\\]\\/\\{\\}\\(\\)\\*\\+\\?\\.\\\\\\^\\$\\|]/g, \"\\\\$&\")\n variableNames = variableNames.join('|')\n\n \"(?:#{namePrefixes})(#{variableNames})(?!_|-|\\\\w|\\\\d|[ \\\\t]*[\\\\.:=])\"\n```", "response": "var decimal, float, int, namePrefixes, percent, variables;\n\nint = '\\\\d+';\n\ndecimal = `\\\\.${int}`;\n\nfloat = `(?:${int}${decimal}|${int}|${decimal})`;\n\npercent = `${float}%`;\n\nvariables = '(?:@[a-zA-Z0-9\\\\-_]+|\\\\$[a-zA-Z0-9\\\\-_]+|[a-zA-Z_][a-zA-Z0-9\\\\-_]*)';\n\nnamePrefixes = '^| |:|=|,|\\\\n|\\'|\"|\\\\(|\\\\[|\\\\{';\n\nmodule.exports = {\n int: int,\n float: float,\n percent: percent,\n optionalPercent: `${float}%?`,\n intOrPercent: `(?:${percent}|${int})`,\n floatOrPercent: `(?:${percent}|${float})`,\n comma: '\\\\s*,\\\\s*',\n notQuote: \"[^\\\"'\\\\n]+\",\n hexadecimal: '[\\\\da-fA-F]',\n ps: '\\\\(\\\\s*',\n pe: '\\\\s*\\\\)',\n variables: variables,\n namePrefixes: namePrefixes,\n createVariableRegExpString: function(variables) {\n var i, len, v, variableNames;\n variableNames = [];\n for (i = 0, len = variables.length; i < len; i++) {\n v = variables[i];\n variableNames.push(v.name.replace(/[-\\[\\]\\/\\{\\}\\(\\)\\*\\+\\?\\.\\\\\\^\\$\\|]/g, \"\\\\$&\"));\n }\n variableNames = variableNames.join('|');\n return `(?:${namePrefixes})(${variableNames})(?!_|-|\\\\w|\\\\d|[ \\\\t]*[\\\\.:=])`;\n }\n};", "source_lang": "CoffeeScript", "target_lang": "JavaScript", "repo": "abe33/atom-pigments", "path": "lib/regexes.coffee", "license": "MIT", "commit": "75b059e09045bf7e060c3f9791dd7d98a44df133", "stars": 518, "source_url": "https://github.com/abe33/atom-pigments/blob/75b059e09045bf7e060c3f9791dd7d98a44df133/lib/regexes.coffee", "line_start": 1, "line_end": 28}683{"id": "abe33/atom-pigments:lib/regexes.coffee:1:js_to_coffee", "type": "js_to_coffee", "prompt": "Convert this JavaScript to CoffeeScript.\n```javascript\nvar decimal, float, int, namePrefixes, percent, variables;\n\nint = '\\\\d+';\n\ndecimal = `\\\\.${int}`;\n\nfloat = `(?:${int}${decimal}|${int}|${decimal})`;\n\npercent = `${float}%`;\n\nvariables = '(?:@[a-zA-Z0-9\\\\-_]+|\\\\$[a-zA-Z0-9\\\\-_]+|[a-zA-Z_][a-zA-Z0-9\\\\-_]*)';\n\nnamePrefixes = '^| |:|=|,|\\\\n|\\'|\"|\\\\(|\\\\[|\\\\{';\n\nmodule.exports = {\n int: int,\n float: float,\n percent: percent,\n optionalPercent: `${float}%?`,\n intOrPercent: `(?:${percent}|${int})`,\n floatOrPercent: `(?:${percent}|${float})`,\n comma: '\\\\s*,\\\\s*',\n notQuote: \"[^\\\"'\\\\n]+\",\n hexadecimal: '[\\\\da-fA-F]',\n ps: '\\\\(\\\\s*',\n pe: '\\\\s*\\\\)',\n variables: variables,\n namePrefixes: namePrefixes,\n createVariableRegExpString: function(variables) {\n var i, len, v, variableNames;\n variableNames = [];\n for (i = 0, len = variables.length; i < len; i++) {\n v = variables[i];\n variableNames.push(v.name.replace(/[-\\[\\]\\/\\{\\}\\(\\)\\*\\+\\?\\.\\\\\\^\\$\\|]/g, \"\\\\$&\"));\n }\n variableNames = variableNames.join('|');\n return `(?:${namePrefixes})(${variableNames})(?!_|-|\\\\w|\\\\d|[ \\\\t]*[\\\\.:=])`;\n }\n};\n```", "response": "int = '\\\\d+'\ndecimal = \"\\\\.#{int}\"\nfloat = \"(?:#{int}#{decimal}|#{int}|#{decimal})\"\npercent = \"#{float}%\"\nvariables = '(?:@[a-zA-Z0-9\\\\-_]+|\\\\$[a-zA-Z0-9\\\\-_]+|[a-zA-Z_][a-zA-Z0-9\\\\-_]*)'\nnamePrefixes = '^| |:|=|,|\\\\n|\\'|\"|\\\\(|\\\\[|\\\\{'\n\nmodule.exports =\n int: int\n float: float\n percent: percent\n optionalPercent: \"#{float}%?\"\n intOrPercent: \"(?:#{percent}|#{int})\"\n floatOrPercent: \"(?:#{percent}|#{float})\"\n comma: '\\\\s*,\\\\s*'\n notQuote: \"[^\\\"'\\\\n]+\"\n hexadecimal: '[\\\\da-fA-F]'\n ps: '\\\\(\\\\s*'\n pe: '\\\\s*\\\\)'\n variables: variables\n namePrefixes: namePrefixes\n createVariableRegExpString: (variables) ->\n variableNames = []\n for v in variables\n variableNames.push v.name.replace(/[-\\[\\]\\/\\{\\}\\(\\)\\*\\+\\?\\.\\\\\\^\\$\\|]/g, \"\\\\$&\")\n variableNames = variableNames.join('|')\n\n \"(?:#{namePrefixes})(#{variableNames})(?!_|-|\\\\w|\\\\d|[ \\\\t]*[\\\\.:=])\"", "source_lang": "JavaScript", "target_lang": "CoffeeScript", "repo": "abe33/atom-pigments", "path": "lib/regexes.coffee", "license": "MIT", "commit": "75b059e09045bf7e060c3f9791dd7d98a44df133", "stars": 518, "source_url": "https://github.com/abe33/atom-pigments/blob/75b059e09045bf7e060c3f9791dd7d98a44df133/lib/regexes.coffee", "line_start": 1, "line_end": 28}684{"id": "abe33/atom-pigments:lib/regexes.coffee:1:completion", "type": "completion", "prompt": "int = '\\\\d+'\ndecimal = \"\\\\.#{int}\"\nfloat = \"(?:#{int}#{decimal}|#{int}|#{decimal})\"\npercent = \"#{float}%\"\nvariables = '(?:@[a-zA-Z0-9\\\\-_]+|\\\\$[a-zA-Z0-9\\\\-_]+|[a-zA-Z_][a-zA-Z0-9\\\\-_]*)'\nnamePrefixes = '^| |:|=|,|\\\\n|\\'|\"|\\\\(|\\\\[|\\\\{'\n\nmodule.exports =\n int: int\n float: float\n percent: percent\n optionalPercent: \"#{float}%?\"\n intOrPercent: \"(?:#{percent}|#{int})\"\n floatOrPercent: \"(?:#{percent}|#{float})\"", "response": "comma: '\\\\s*,\\\\s*'\n notQuote: \"[^\\\"'\\\\n]+\"\n hexadecimal: '[\\\\da-fA-F]'\n ps: '\\\\(\\\\s*'\n pe: '\\\\s*\\\\)'\n variables: variables\n namePrefixes: namePrefixes\n createVariableRegExpString: (variables) ->\n variableNames = []\n for v in variables\n variableNames.push v.name.replace(/[-\\[\\]\\/\\{\\}\\(\\)\\*\\+\\?\\.\\\\\\^\\$\\|]/g, \"\\\\$&\")\n variableNames = variableNames.join('|')\n\n \"(?:#{namePrefixes})(#{variableNames})(?!_|-|\\\\w|\\\\d|[ \\\\t]*[\\\\.:=])\"", "source_lang": "CoffeeScript", "target_lang": "CoffeeScript", "repo": "abe33/atom-pigments", "path": "lib/regexes.coffee", "license": "MIT", "commit": "75b059e09045bf7e060c3f9791dd7d98a44df133", "stars": 518, "source_url": "https://github.com/abe33/atom-pigments/blob/75b059e09045bf7e060c3f9791dd7d98a44df133/lib/regexes.coffee", "line_start": 1, "line_end": 28}685{"id": "abe33/atom-pigments:lib/regexes.coffee:1:raw_corpus", "type": "raw_corpus", "prompt": "", "response": "int = '\\\\d+'\ndecimal = \"\\\\.#{int}\"\nfloat = \"(?:#{int}|#{int}#{decimal}|#{decimal})\"\npercent = \"#{float}%\"\nvariables = '(?:@[a-zA-Z0-9\\\\-_]+|\\\\$[a-zA-Z0-9\\\\-_]+|[a-zA-Z_][a-zA-Z0-9\\\\-_]*)'\nnamePrefixes = '^| |:|=|,|\\\\n|\\'|\"|\\\\(|\\\\[|\\\\{'\n\nmodule.exports =\n int: int\n float: float\n percent: percent\n optionalPercent: \"#{float}%?\"\n intOrPercent: \"(?:#{percent}|#{int})\"\n floatOrPercent: \"(?:#{percent}|#{float})\"\n comma: '\\\\s*,\\\\s*'\n notQuote: \"[^\\\"'\\\\n]+\"\n hexadecimal: '[\\\\da-fA-F]'\n ps: '\\\\(\\\\s*'\n pe: '\\\\s*\\\\)'\n variables: variables\n namePrefixes: namePrefixes\n createVariableRegExpString: (variables) ->\n variableNames = []\n for v in variables\n variableNames.push v.name.replace(/[-\\[\\]\\/\\{\\}\\(\\)\\*\\+\\?\\.\\\\\\^\\$\\|]/g, \"\\\\$&\")\n variableNames = variableNames.join('|')\n\n \"(?:#{namePrefixes})(#{variableNames})(?!_|-|\\\\w|\\\\d|[ \\\\t]*[\\\\.:=])\"", "source_lang": "", "target_lang": "CoffeeScript", "repo": "abe33/atom-pigments", "path": "lib/regexes.coffee", "license": "MIT", "commit": "6f47fab8df7e559308590a1e6fbed46a70251418", "stars": 518, "source_url": "https://github.com/abe33/atom-pigments/blob/6f47fab8df7e559308590a1e6fbed46a70251418/lib/regexes.coffee", "line_start": 1, "line_end": 28}686{"id": "abe33/atom-pigments:lib/regexes.coffee:1:coffee_to_js", "type": "coffee_to_js", "prompt": "Convert this CoffeeScript to JavaScript.\n```coffeescript\nint = '\\\\d+'\ndecimal = \"\\\\.#{int}\"\nfloat = \"(?:#{int}|#{int}#{decimal}|#{decimal})\"\npercent = \"#{float}%\"\nvariables = '(?:@[a-zA-Z0-9\\\\-_]+|\\\\$[a-zA-Z0-9\\\\-_]+|[a-zA-Z_][a-zA-Z0-9\\\\-_]*)'\nnamePrefixes = '^| |:|=|,|\\\\n|\\'|\"|\\\\(|\\\\[|\\\\{'\n\nmodule.exports =\n int: int\n float: float\n percent: percent\n optionalPercent: \"#{float}%?\"\n intOrPercent: \"(?:#{percent}|#{int})\"\n floatOrPercent: \"(?:#{percent}|#{float})\"\n comma: '\\\\s*,\\\\s*'\n notQuote: \"[^\\\"'\\\\n]+\"\n hexadecimal: '[\\\\da-fA-F]'\n ps: '\\\\(\\\\s*'\n pe: '\\\\s*\\\\)'\n variables: variables\n namePrefixes: namePrefixes\n createVariableRegExpString: (variables) ->\n variableNames = []\n for v in variables\n variableNames.push v.name.replace(/[-\\[\\]\\/\\{\\}\\(\\)\\*\\+\\?\\.\\\\\\^\\$\\|]/g, \"\\\\$&\")\n variableNames = variableNames.join('|')\n\n \"(?:#{namePrefixes})(#{variableNames})(?!_|-|\\\\w|\\\\d|[ \\\\t]*[\\\\.:=])\"\n```", "response": "var decimal, float, int, namePrefixes, percent, variables;\n\nint = '\\\\d+';\n\ndecimal = `\\\\.${int}`;\n\nfloat = `(?:${int}|${int}${decimal}|${decimal})`;\n\npercent = `${float}%`;\n\nvariables = '(?:@[a-zA-Z0-9\\\\-_]+|\\\\$[a-zA-Z0-9\\\\-_]+|[a-zA-Z_][a-zA-Z0-9\\\\-_]*)';\n\nnamePrefixes = '^| |:|=|,|\\\\n|\\'|\"|\\\\(|\\\\[|\\\\{';\n\nmodule.exports = {\n int: int,\n float: float,\n percent: percent,\n optionalPercent: `${float}%?`,\n intOrPercent: `(?:${percent}|${int})`,\n floatOrPercent: `(?:${percent}|${float})`,\n comma: '\\\\s*,\\\\s*',\n notQuote: \"[^\\\"'\\\\n]+\",\n hexadecimal: '[\\\\da-fA-F]',\n ps: '\\\\(\\\\s*',\n pe: '\\\\s*\\\\)',\n variables: variables,\n namePrefixes: namePrefixes,\n createVariableRegExpString: function(variables) {\n var i, len, v, variableNames;\n variableNames = [];\n for (i = 0, len = variables.length; i < len; i++) {\n v = variables[i];\n variableNames.push(v.name.replace(/[-\\[\\]\\/\\{\\}\\(\\)\\*\\+\\?\\.\\\\\\^\\$\\|]/g, \"\\\\$&\"));\n }\n variableNames = variableNames.join('|');\n return `(?:${namePrefixes})(${variableNames})(?!_|-|\\\\w|\\\\d|[ \\\\t]*[\\\\.:=])`;\n }\n};", "source_lang": "CoffeeScript", "target_lang": "JavaScript", "repo": "abe33/atom-pigments", "path": "lib/regexes.coffee", "license": "MIT", "commit": "6f47fab8df7e559308590a1e6fbed46a70251418", "stars": 518, "source_url": "https://github.com/abe33/atom-pigments/blob/6f47fab8df7e559308590a1e6fbed46a70251418/lib/regexes.coffee", "line_start": 1, "line_end": 28}687{"id": "abe33/atom-pigments:lib/regexes.coffee:1:js_to_coffee", "type": "js_to_coffee", "prompt": "Convert this JavaScript to CoffeeScript.\n```javascript\nvar decimal, float, int, namePrefixes, percent, variables;\n\nint = '\\\\d+';\n\ndecimal = `\\\\.${int}`;\n\nfloat = `(?:${int}|${int}${decimal}|${decimal})`;\n\npercent = `${float}%`;\n\nvariables = '(?:@[a-zA-Z0-9\\\\-_]+|\\\\$[a-zA-Z0-9\\\\-_]+|[a-zA-Z_][a-zA-Z0-9\\\\-_]*)';\n\nnamePrefixes = '^| |:|=|,|\\\\n|\\'|\"|\\\\(|\\\\[|\\\\{';\n\nmodule.exports = {\n int: int,\n float: float,\n percent: percent,\n optionalPercent: `${float}%?`,\n intOrPercent: `(?:${percent}|${int})`,\n floatOrPercent: `(?:${percent}|${float})`,\n comma: '\\\\s*,\\\\s*',\n notQuote: \"[^\\\"'\\\\n]+\",\n hexadecimal: '[\\\\da-fA-F]',\n ps: '\\\\(\\\\s*',\n pe: '\\\\s*\\\\)',\n variables: variables,\n namePrefixes: namePrefixes,\n createVariableRegExpString: function(variables) {\n var i, len, v, variableNames;\n variableNames = [];\n for (i = 0, len = variables.length; i < len; i++) {\n v = variables[i];\n variableNames.push(v.name.replace(/[-\\[\\]\\/\\{\\}\\(\\)\\*\\+\\?\\.\\\\\\^\\$\\|]/g, \"\\\\$&\"));\n }\n variableNames = variableNames.join('|');\n return `(?:${namePrefixes})(${variableNames})(?!_|-|\\\\w|\\\\d|[ \\\\t]*[\\\\.:=])`;\n }\n};\n```", "response": "int = '\\\\d+'\ndecimal = \"\\\\.#{int}\"\nfloat = \"(?:#{int}|#{int}#{decimal}|#{decimal})\"\npercent = \"#{float}%\"\nvariables = '(?:@[a-zA-Z0-9\\\\-_]+|\\\\$[a-zA-Z0-9\\\\-_]+|[a-zA-Z_][a-zA-Z0-9\\\\-_]*)'\nnamePrefixes = '^| |:|=|,|\\\\n|\\'|\"|\\\\(|\\\\[|\\\\{'\n\nmodule.exports =\n int: int\n float: float\n percent: percent\n optionalPercent: \"#{float}%?\"\n intOrPercent: \"(?:#{percent}|#{int})\"\n floatOrPercent: \"(?:#{percent}|#{float})\"\n comma: '\\\\s*,\\\\s*'\n notQuote: \"[^\\\"'\\\\n]+\"\n hexadecimal: '[\\\\da-fA-F]'\n ps: '\\\\(\\\\s*'\n pe: '\\\\s*\\\\)'\n variables: variables\n namePrefixes: namePrefixes\n createVariableRegExpString: (variables) ->\n variableNames = []\n for v in variables\n variableNames.push v.name.replace(/[-\\[\\]\\/\\{\\}\\(\\)\\*\\+\\?\\.\\\\\\^\\$\\|]/g, \"\\\\$&\")\n variableNames = variableNames.join('|')\n\n \"(?:#{namePrefixes})(#{variableNames})(?!_|-|\\\\w|\\\\d|[ \\\\t]*[\\\\.:=])\"", "source_lang": "JavaScript", "target_lang": "CoffeeScript", "repo": "abe33/atom-pigments", "path": "lib/regexes.coffee", "license": "MIT", "commit": "6f47fab8df7e559308590a1e6fbed46a70251418", "stars": 518, "source_url": "https://github.com/abe33/atom-pigments/blob/6f47fab8df7e559308590a1e6fbed46a70251418/lib/regexes.coffee", "line_start": 1, "line_end": 28}688{"id": "abe33/atom-pigments:lib/regexes.coffee:1:completion", "type": "completion", "prompt": "int = '\\\\d+'\ndecimal = \"\\\\.#{int}\"\nfloat = \"(?:#{int}|#{int}#{decimal}|#{decimal})\"\npercent = \"#{float}%\"\nvariables = '(?:@[a-zA-Z0-9\\\\-_]+|\\\\$[a-zA-Z0-9\\\\-_]+|[a-zA-Z_][a-zA-Z0-9\\\\-_]*)'\nnamePrefixes = '^| |:|=|,|\\\\n|\\'|\"|\\\\(|\\\\[|\\\\{'\n\nmodule.exports =\n int: int\n float: float\n percent: percent\n optionalPercent: \"#{float}%?\"\n intOrPercent: \"(?:#{percent}|#{int})\"\n floatOrPercent: \"(?:#{percent}|#{float})\"", "response": "comma: '\\\\s*,\\\\s*'\n notQuote: \"[^\\\"'\\\\n]+\"\n hexadecimal: '[\\\\da-fA-F]'\n ps: '\\\\(\\\\s*'\n pe: '\\\\s*\\\\)'\n variables: variables\n namePrefixes: namePrefixes\n createVariableRegExpString: (variables) ->\n variableNames = []\n for v in variables\n variableNames.push v.name.replace(/[-\\[\\]\\/\\{\\}\\(\\)\\*\\+\\?\\.\\\\\\^\\$\\|]/g, \"\\\\$&\")\n variableNames = variableNames.join('|')\n\n \"(?:#{namePrefixes})(#{variableNames})(?!_|-|\\\\w|\\\\d|[ \\\\t]*[\\\\.:=])\"", "source_lang": "CoffeeScript", "target_lang": "CoffeeScript", "repo": "abe33/atom-pigments", "path": "lib/regexes.coffee", "license": "MIT", "commit": "6f47fab8df7e559308590a1e6fbed46a70251418", "stars": 518, "source_url": "https://github.com/abe33/atom-pigments/blob/6f47fab8df7e559308590a1e6fbed46a70251418/lib/regexes.coffee", "line_start": 1, "line_end": 28}689{"id": "abe33/atom-pigments:lib/regexes.coffee:1:raw_corpus", "type": "raw_corpus", "prompt": "", "response": "int = '\\\\d+'\ndecimal = \"\\\\.#{int}\"\nfloat = \"(?:#{int}|#{int}#{decimal}|#{decimal})\"\npercent = \"#{float}%\"\nvariables = '(@[a-zA-Z0-9\\\\-_]+|\\\\$[a-zA-Z0-9\\\\-_]+|[a-zA-Z_][a-zA-Z0-9\\\\-_]*)'\nnamePrefixes = '^| |:|=|,|\\\\n|\\'|\"|\\\\(|\\\\[|\\\\{'\n\nmodule.exports =\n int: int\n float: float\n percent: percent\n optionalPercent: \"#{float}%?\"\n intOrPercent: \"(#{percent}|#{int})\"\n floatOrPercent: \"(#{percent}|#{float})\"\n comma: '\\\\s*,\\\\s*'\n notQuote: \"[^\\\"'\\\\n]+\"\n hexadecimal: '[\\\\da-fA-F]'\n ps: '\\\\(\\\\s*'\n pe: '\\\\s*\\\\)'\n variables: variables\n namePrefixes: namePrefixes\n createVariableRegExpString: (variables) ->\n variableNames = []\n for v in variables\n variableNames.push v.name.replace(/[-\\[\\]\\/\\{\\}\\(\\)\\*\\+\\?\\.\\\\\\^\\$\\|]/g, \"\\\\$&\")\n variableNames = variableNames.join('|')\n\n \"(#{namePrefixes})(#{variableNames})(?!_|-|\\\\w|\\\\d|[ \\\\t]*[\\\\.:=])\"", "source_lang": "", "target_lang": "CoffeeScript", "repo": "abe33/atom-pigments", "path": "lib/regexes.coffee", "license": "MIT", "commit": "6b9b5368e8a617bbb73ccdb1da96350aba9fd444", "stars": 518, "source_url": "https://github.com/abe33/atom-pigments/blob/6b9b5368e8a617bbb73ccdb1da96350aba9fd444/lib/regexes.coffee", "line_start": 1, "line_end": 28}690{"id": "abe33/atom-pigments:lib/regexes.coffee:1:coffee_to_js", "type": "coffee_to_js", "prompt": "Convert this CoffeeScript to JavaScript.\n```coffeescript\nint = '\\\\d+'\ndecimal = \"\\\\.#{int}\"\nfloat = \"(?:#{int}|#{int}#{decimal}|#{decimal})\"\npercent = \"#{float}%\"\nvariables = '(@[a-zA-Z0-9\\\\-_]+|\\\\$[a-zA-Z0-9\\\\-_]+|[a-zA-Z_][a-zA-Z0-9\\\\-_]*)'\nnamePrefixes = '^| |:|=|,|\\\\n|\\'|\"|\\\\(|\\\\[|\\\\{'\n\nmodule.exports =\n int: int\n float: float\n percent: percent\n optionalPercent: \"#{float}%?\"\n intOrPercent: \"(#{percent}|#{int})\"\n floatOrPercent: \"(#{percent}|#{float})\"\n comma: '\\\\s*,\\\\s*'\n notQuote: \"[^\\\"'\\\\n]+\"\n hexadecimal: '[\\\\da-fA-F]'\n ps: '\\\\(\\\\s*'\n pe: '\\\\s*\\\\)'\n variables: variables\n namePrefixes: namePrefixes\n createVariableRegExpString: (variables) ->\n variableNames = []\n for v in variables\n variableNames.push v.name.replace(/[-\\[\\]\\/\\{\\}\\(\\)\\*\\+\\?\\.\\\\\\^\\$\\|]/g, \"\\\\$&\")\n variableNames = variableNames.join('|')\n\n \"(#{namePrefixes})(#{variableNames})(?!_|-|\\\\w|\\\\d|[ \\\\t]*[\\\\.:=])\"\n```", "response": "var decimal, float, int, namePrefixes, percent, variables;\n\nint = '\\\\d+';\n\ndecimal = `\\\\.${int}`;\n\nfloat = `(?:${int}|${int}${decimal}|${decimal})`;\n\npercent = `${float}%`;\n\nvariables = '(@[a-zA-Z0-9\\\\-_]+|\\\\$[a-zA-Z0-9\\\\-_]+|[a-zA-Z_][a-zA-Z0-9\\\\-_]*)';\n\nnamePrefixes = '^| |:|=|,|\\\\n|\\'|\"|\\\\(|\\\\[|\\\\{';\n\nmodule.exports = {\n int: int,\n float: float,\n percent: percent,\n optionalPercent: `${float}%?`,\n intOrPercent: `(${percent}|${int})`,\n floatOrPercent: `(${percent}|${float})`,\n comma: '\\\\s*,\\\\s*',\n notQuote: \"[^\\\"'\\\\n]+\",\n hexadecimal: '[\\\\da-fA-F]',\n ps: '\\\\(\\\\s*',\n pe: '\\\\s*\\\\)',\n variables: variables,\n namePrefixes: namePrefixes,\n createVariableRegExpString: function(variables) {\n var i, len, v, variableNames;\n variableNames = [];\n for (i = 0, len = variables.length; i < len; i++) {\n v = variables[i];\n variableNames.push(v.name.replace(/[-\\[\\]\\/\\{\\}\\(\\)\\*\\+\\?\\.\\\\\\^\\$\\|]/g, \"\\\\$&\"));\n }\n variableNames = variableNames.join('|');\n return `(${namePrefixes})(${variableNames})(?!_|-|\\\\w|\\\\d|[ \\\\t]*[\\\\.:=])`;\n }\n};", "source_lang": "CoffeeScript", "target_lang": "JavaScript", "repo": "abe33/atom-pigments", "path": "lib/regexes.coffee", "license": "MIT", "commit": "6b9b5368e8a617bbb73ccdb1da96350aba9fd444", "stars": 518, "source_url": "https://github.com/abe33/atom-pigments/blob/6b9b5368e8a617bbb73ccdb1da96350aba9fd444/lib/regexes.coffee", "line_start": 1, "line_end": 28}691{"id": "abe33/atom-pigments:lib/regexes.coffee:1:js_to_coffee", "type": "js_to_coffee", "prompt": "Convert this JavaScript to CoffeeScript.\n```javascript\nvar decimal, float, int, namePrefixes, percent, variables;\n\nint = '\\\\d+';\n\ndecimal = `\\\\.${int}`;\n\nfloat = `(?:${int}|${int}${decimal}|${decimal})`;\n\npercent = `${float}%`;\n\nvariables = '(@[a-zA-Z0-9\\\\-_]+|\\\\$[a-zA-Z0-9\\\\-_]+|[a-zA-Z_][a-zA-Z0-9\\\\-_]*)';\n\nnamePrefixes = '^| |:|=|,|\\\\n|\\'|\"|\\\\(|\\\\[|\\\\{';\n\nmodule.exports = {\n int: int,\n float: float,\n percent: percent,\n optionalPercent: `${float}%?`,\n intOrPercent: `(${percent}|${int})`,\n floatOrPercent: `(${percent}|${float})`,\n comma: '\\\\s*,\\\\s*',\n notQuote: \"[^\\\"'\\\\n]+\",\n hexadecimal: '[\\\\da-fA-F]',\n ps: '\\\\(\\\\s*',\n pe: '\\\\s*\\\\)',\n variables: variables,\n namePrefixes: namePrefixes,\n createVariableRegExpString: function(variables) {\n var i, len, v, variableNames;\n variableNames = [];\n for (i = 0, len = variables.length; i < len; i++) {\n v = variables[i];\n variableNames.push(v.name.replace(/[-\\[\\]\\/\\{\\}\\(\\)\\*\\+\\?\\.\\\\\\^\\$\\|]/g, \"\\\\$&\"));\n }\n variableNames = variableNames.join('|');\n return `(${namePrefixes})(${variableNames})(?!_|-|\\\\w|\\\\d|[ \\\\t]*[\\\\.:=])`;\n }\n};\n```", "response": "int = '\\\\d+'\ndecimal = \"\\\\.#{int}\"\nfloat = \"(?:#{int}|#{int}#{decimal}|#{decimal})\"\npercent = \"#{float}%\"\nvariables = '(@[a-zA-Z0-9\\\\-_]+|\\\\$[a-zA-Z0-9\\\\-_]+|[a-zA-Z_][a-zA-Z0-9\\\\-_]*)'\nnamePrefixes = '^| |:|=|,|\\\\n|\\'|\"|\\\\(|\\\\[|\\\\{'\n\nmodule.exports =\n int: int\n float: float\n percent: percent\n optionalPercent: \"#{float}%?\"\n intOrPercent: \"(#{percent}|#{int})\"\n floatOrPercent: \"(#{percent}|#{float})\"\n comma: '\\\\s*,\\\\s*'\n notQuote: \"[^\\\"'\\\\n]+\"\n hexadecimal: '[\\\\da-fA-F]'\n ps: '\\\\(\\\\s*'\n pe: '\\\\s*\\\\)'\n variables: variables\n namePrefixes: namePrefixes\n createVariableRegExpString: (variables) ->\n variableNames = []\n for v in variables\n variableNames.push v.name.replace(/[-\\[\\]\\/\\{\\}\\(\\)\\*\\+\\?\\.\\\\\\^\\$\\|]/g, \"\\\\$&\")\n variableNames = variableNames.join('|')\n\n \"(#{namePrefixes})(#{variableNames})(?!_|-|\\\\w|\\\\d|[ \\\\t]*[\\\\.:=])\"", "source_lang": "JavaScript", "target_lang": "CoffeeScript", "repo": "abe33/atom-pigments", "path": "lib/regexes.coffee", "license": "MIT", "commit": "6b9b5368e8a617bbb73ccdb1da96350aba9fd444", "stars": 518, "source_url": "https://github.com/abe33/atom-pigments/blob/6b9b5368e8a617bbb73ccdb1da96350aba9fd444/lib/regexes.coffee", "line_start": 1, "line_end": 28}692{"id": "abe33/atom-pigments:lib/regexes.coffee:1:completion", "type": "completion", "prompt": "int = '\\\\d+'\ndecimal = \"\\\\.#{int}\"\nfloat = \"(?:#{int}|#{int}#{decimal}|#{decimal})\"\npercent = \"#{float}%\"\nvariables = '(@[a-zA-Z0-9\\\\-_]+|\\\\$[a-zA-Z0-9\\\\-_]+|[a-zA-Z_][a-zA-Z0-9\\\\-_]*)'\nnamePrefixes = '^| |:|=|,|\\\\n|\\'|\"|\\\\(|\\\\[|\\\\{'\n\nmodule.exports =\n int: int\n float: float\n percent: percent\n optionalPercent: \"#{float}%?\"\n intOrPercent: \"(#{percent}|#{int})\"\n floatOrPercent: \"(#{percent}|#{float})\"", "response": "comma: '\\\\s*,\\\\s*'\n notQuote: \"[^\\\"'\\\\n]+\"\n hexadecimal: '[\\\\da-fA-F]'\n ps: '\\\\(\\\\s*'\n pe: '\\\\s*\\\\)'\n variables: variables\n namePrefixes: namePrefixes\n createVariableRegExpString: (variables) ->\n variableNames = []\n for v in variables\n variableNames.push v.name.replace(/[-\\[\\]\\/\\{\\}\\(\\)\\*\\+\\?\\.\\\\\\^\\$\\|]/g, \"\\\\$&\")\n variableNames = variableNames.join('|')\n\n \"(#{namePrefixes})(#{variableNames})(?!_|-|\\\\w|\\\\d|[ \\\\t]*[\\\\.:=])\"", "source_lang": "CoffeeScript", "target_lang": "CoffeeScript", "repo": "abe33/atom-pigments", "path": "lib/regexes.coffee", "license": "MIT", "commit": "6b9b5368e8a617bbb73ccdb1da96350aba9fd444", "stars": 518, "source_url": "https://github.com/abe33/atom-pigments/blob/6b9b5368e8a617bbb73ccdb1da96350aba9fd444/lib/regexes.coffee", "line_start": 1, "line_end": 28}693{"id": "gterrono/houston:server/publications.coffee:2:raw_corpus", "type": "raw_corpus", "prompt": "", "response": "Houston._setup_collection = (collection) ->\n name = collection._name\n return if name of ADDED_COLLECTIONS\n\n Houston._setup_collection_methods(collection)\n\n Houston._publish name, (sort, filter, limit, unknown_arg) ->\n check sort, Match.Optional(Object)\n check filter, Match.Optional(Object)\n check limit, Match.Optional(Number)\n check unknown_arg, Match.Any\n unless Houston._user_is_admin @userId\n @ready()\n return\n try\n collection.find(filter, sort: sort, limit: limit)\n catch e\n console.log e\n\n collection.find().observe\n _suppress_initial: true # fixes houston for large initial datasets\n added: (document) ->\n Houston._collections.collections.update {name},\n $inc: {count: 1},\n $addToSet: fields: $each: Houston._get_fields([document])\n changed: (document) ->\n Houston._collections.collections.update {name},\n $addToSet: fields: $each: Houston._get_fields([document])\n removed: (document) ->\n Houston._collections.collections.update {name}, {$inc: {count: -1}}\n\n fields = Houston._get_fields_from_collection(collection)\n c = Houston._collections.collections.findOne {name}\n count = collection.find().count()\n if c\n Houston._collections.collections.update c._id, {$set: {count, fields}}\n else\n Houston._collections.collections.insert {name, count, fields}\n ADDED_COLLECTIONS[name] = collection", "source_lang": "", "target_lang": "CoffeeScript", "repo": "gterrono/houston", "path": "server/publications.coffee", "license": "MIT", "commit": "581357048f3577f0487ed598e26eaf063c813183", "stars": 802, "source_url": "https://github.com/gterrono/houston/blob/581357048f3577f0487ed598e26eaf063c813183/server/publications.coffee", "line_start": 9, "line_end": 47}694{"id": "gterrono/houston:server/publications.coffee:2:coffee_to_js", "type": "coffee_to_js", "prompt": "Convert this CoffeeScript to JavaScript.\n```coffeescript\nHouston._setup_collection = (collection) ->\n name = collection._name\n return if name of ADDED_COLLECTIONS\n\n Houston._setup_collection_methods(collection)\n\n Houston._publish name, (sort, filter, limit, unknown_arg) ->\n check sort, Match.Optional(Object)\n check filter, Match.Optional(Object)\n check limit, Match.Optional(Number)\n check unknown_arg, Match.Any\n unless Houston._user_is_admin @userId\n @ready()\n return\n try\n collection.find(filter, sort: sort, limit: limit)\n catch e\n console.log e\n\n collection.find().observe\n _suppress_initial: true # fixes houston for large initial datasets\n added: (document) ->\n Houston._collections.collections.update {name},\n $inc: {count: 1},\n $addToSet: fields: $each: Houston._get_fields([document])\n changed: (document) ->\n Houston._collections.collections.update {name},\n $addToSet: fields: $each: Houston._get_fields([document])\n removed: (document) ->\n Houston._collections.collections.update {name}, {$inc: {count: -1}}\n\n fields = Houston._get_fields_from_collection(collection)\n c = Houston._collections.collections.findOne {name}\n count = collection.find().count()\n if c\n Houston._collections.collections.update c._id, {$set: {count, fields}}\n else\n Houston._collections.collections.insert {name, count, fields}\n ADDED_COLLECTIONS[name] = collection\n```", "response": "Houston._setup_collection = function(collection) {\n var c, count, fields, name;\n name = collection._name;\n if (name in ADDED_COLLECTIONS) {\n return;\n }\n Houston._setup_collection_methods(collection);\n Houston._publish(name, function(sort, filter, limit, unknown_arg) {\n var e;\n check(sort, Match.Optional(Object));\n check(filter, Match.Optional(Object));\n check(limit, Match.Optional(Number));\n check(unknown_arg, Match.Any);\n if (!Houston._user_is_admin(this.userId)) {\n this.ready();\n return;\n }\n try {\n return collection.find(filter, {\n sort: sort,\n limit: limit\n });\n } catch (error) {\n e = error;\n return console.log(e);\n }\n });\n collection.find().observe({\n _suppress_initial: true, // fixes houston for large initial datasets\n added: function(document) {\n return Houston._collections.collections.update({name}, {\n $inc: {\n count: 1\n },\n $addToSet: {\n fields: {\n $each: Houston._get_fields([document])\n }\n }\n });\n },\n changed: function(document) {\n return Houston._collections.collections.update({name}, {\n $addToSet: {\n fields: {\n $each: Houston._get_fields([document])\n }\n }\n });\n },\n removed: function(document) {\n return Houston._collections.collections.update({name}, {\n $inc: {\n count: -1\n }\n });\n }\n });\n fields = Houston._get_fields_from_collection(collection);\n c = Houston._collections.collections.findOne({name});\n count = collection.find().count();\n if (c) {\n Houston._collections.collections.update(c._id, {\n $set: {count, fields}\n });\n } else {\n Houston._collections.collections.insert({name, count, fields});\n }\n return ADDED_COLLECTIONS[name] = collection;\n};", "source_lang": "CoffeeScript", "target_lang": "JavaScript", "repo": "gterrono/houston", "path": "server/publications.coffee", "license": "MIT", "commit": "581357048f3577f0487ed598e26eaf063c813183", "stars": 802, "source_url": "https://github.com/gterrono/houston/blob/581357048f3577f0487ed598e26eaf063c813183/server/publications.coffee", "line_start": 9, "line_end": 47}695{"id": "gterrono/houston:server/publications.coffee:2:js_to_coffee", "type": "js_to_coffee", "prompt": "Convert this JavaScript to CoffeeScript.\n```javascript\nHouston._setup_collection = function(collection) {\n var c, count, fields, name;\n name = collection._name;\n if (name in ADDED_COLLECTIONS) {\n return;\n }\n Houston._setup_collection_methods(collection);\n Houston._publish(name, function(sort, filter, limit, unknown_arg) {\n var e;\n check(sort, Match.Optional(Object));\n check(filter, Match.Optional(Object));\n check(limit, Match.Optional(Number));\n check(unknown_arg, Match.Any);\n if (!Houston._user_is_admin(this.userId)) {\n this.ready();\n return;\n }\n try {\n return collection.find(filter, {\n sort: sort,\n limit: limit\n });\n } catch (error) {\n e = error;\n return console.log(e);\n }\n });\n collection.find().observe({\n _suppress_initial: true, // fixes houston for large initial datasets\n added: function(document) {\n return Houston._collections.collections.update({name}, {\n $inc: {\n count: 1\n },\n $addToSet: {\n fields: {\n $each: Houston._get_fields([document])\n }\n }\n });\n },\n changed: function(document) {\n return Houston._collections.collections.update({name}, {\n $addToSet: {\n fields: {\n $each: Houston._get_fields([document])\n }\n }\n });\n },\n removed: function(document) {\n return Houston._collections.collections.update({name}, {\n $inc: {\n count: -1\n }\n });\n }\n });\n fields = Houston._get_fields_from_collection(collection);\n c = Houston._collections.collections.findOne({name});\n count = collection.find().count();\n if (c) {\n Houston._collections.collections.update(c._id, {\n $set: {count, fields}\n });\n } else {\n Houston._collections.collections.insert({name, count, fields});\n }\n return ADDED_COLLECTIONS[name] = collection;\n};\n```", "response": "Houston._setup_collection = (collection) ->\n name = collection._name\n return if name of ADDED_COLLECTIONS\n\n Houston._setup_collection_methods(collection)\n\n Houston._publish name, (sort, filter, limit, unknown_arg) ->\n check sort, Match.Optional(Object)\n check filter, Match.Optional(Object)\n check limit, Match.Optional(Number)\n check unknown_arg, Match.Any\n unless Houston._user_is_admin @userId\n @ready()\n return\n try\n collection.find(filter, sort: sort, limit: limit)\n catch e\n console.log e\n\n collection.find().observe\n _suppress_initial: true # fixes houston for large initial datasets\n added: (document) ->\n Houston._collections.collections.update {name},\n $inc: {count: 1},\n $addToSet: fields: $each: Houston._get_fields([document])\n changed: (document) ->\n Houston._collections.collections.update {name},\n $addToSet: fields: $each: Houston._get_fields([document])\n removed: (document) ->\n Houston._collections.collections.update {name}, {$inc: {count: -1}}\n\n fields = Houston._get_fields_from_collection(collection)\n c = Houston._collections.collections.findOne {name}\n count = collection.find().count()\n if c\n Houston._collections.collections.update c._id, {$set: {count, fields}}\n else\n Houston._collections.collections.insert {name, count, fields}\n ADDED_COLLECTIONS[name] = collection", "source_lang": "JavaScript", "target_lang": "CoffeeScript", "repo": "gterrono/houston", "path": "server/publications.coffee", "license": "MIT", "commit": "581357048f3577f0487ed598e26eaf063c813183", "stars": 802, "source_url": "https://github.com/gterrono/houston/blob/581357048f3577f0487ed598e26eaf063c813183/server/publications.coffee", "line_start": 9, "line_end": 47}696{"id": "gterrono/houston:server/publications.coffee:2:completion", "type": "completion", "prompt": "Houston._setup_collection = (collection) ->\n name = collection._name\n return if name of ADDED_COLLECTIONS\n\n Houston._setup_collection_methods(collection)\n\n Houston._publish name, (sort, filter, limit, unknown_arg) ->\n check sort, Match.Optional(Object)\n check filter, Match.Optional(Object)\n check limit, Match.Optional(Number)\n check unknown_arg, Match.Any\n unless Houston._user_is_admin @userId\n @ready()\n return\n try\n collection.find(filter, sort: sort, limit: limit)\n catch e\n console.log e", "response": "collection.find().observe\n _suppress_initial: true # fixes houston for large initial datasets\n added: (document) ->\n Houston._collections.collections.update {name},\n $inc: {count: 1},\n $addToSet: fields: $each: Houston._get_fields([document])\n changed: (document) ->\n Houston._collections.collections.update {name},\n $addToSet: fields: $each: Houston._get_fields([document])\n removed: (document) ->\n Houston._collections.collections.update {name}, {$inc: {count: -1}}\n\n fields = Houston._get_fields_from_collection(collection)\n c = Houston._collections.collections.findOne {name}\n count = collection.find().count()\n if c\n Houston._collections.collections.update c._id, {$set: {count, fields}}\n else\n Houston._collections.collections.insert {name, count, fields}\n ADDED_COLLECTIONS[name] = collection", "source_lang": "CoffeeScript", "target_lang": "CoffeeScript", "repo": "gterrono/houston", "path": "server/publications.coffee", "license": "MIT", "commit": "581357048f3577f0487ed598e26eaf063c813183", "stars": 802, "source_url": "https://github.com/gterrono/houston/blob/581357048f3577f0487ed598e26eaf063c813183/server/publications.coffee", "line_start": 9, "line_end": 47}697{"id": "gterrono/houston:server/publications.coffee:3:raw_corpus", "type": "raw_corpus", "prompt": "", "response": "sync_collections = ->\n Houston._admins.findOne() # TODO Why is this here?\n\n collections = {}\n for collection in (Mongo.Collection.getAll() ? [])\n collections[collection.name] = collection.instance\n\n _sync_collections = (meh, collections_db) ->\n collection_names = (col.collectionName for col in collections_db \\\n when (col.collectionName.indexOf \"system.\") isnt 0 and\n (col.collectionName.indexOf \"houston_\") isnt 0)\n\n collection_names.forEach (name) ->\n unless name of ADDED_COLLECTIONS or name of Houston._HIDDEN_COLLECTIONS\n Houston._setup_collection(collections[name]) if collections[name]?\n\n bound_sync_collections = Meteor.bindEnvironment _sync_collections, (e) ->\n console.log \"Failed while syncing collections for reason: #{e}\"\n\n # MongoInternals is the 'right' solution as of 0.6.5\n mongo_driver = MongoInternals?.defaultRemoteCollectionDriver() or Meteor._RemoteCollectionDriver\n mongo_driver.mongo.db.collections bound_sync_collections\n\nMeteor.methods\n _houston_make_admin: (user_id) ->\n check user_id, String\n # limit one admin\n return if Houston._admins.findOne {'user_id': $exists: true}\n Houston._admins.insert {user_id}\n Houston._admins.insert {exists: true}\n sync_collections() # reloads collections in case of new app\n return true\n\n# publish our analysis of the app's collections\nHouston._publish 'collections', ->\n unless Houston._user_is_admin @userId\n @ready()\n return\n Houston._collections.collections.find()\n\n# TODO address inherent security issue\nHouston._publish 'admin_user', ->\n unless Houston._user_is_admin @userId\n return Houston._admins.find {exists: true}\n return Houston._admins.find {}\n\nMeteor.startup ->\n sync_collections()\n if Houston._admins.find().count() > 0 and !Houston._admins.findOne({exists: true})\n Houston._admins.insert {exists: true}", "source_lang": "", "target_lang": "CoffeeScript", "repo": "gterrono/houston", "path": "server/publications.coffee", "license": "MIT", "commit": "581357048f3577f0487ed598e26eaf063c813183", "stars": 802, "source_url": "https://github.com/gterrono/houston/blob/581357048f3577f0487ed598e26eaf063c813183/server/publications.coffee", "line_start": 49, "line_end": 98}698{"id": "gterrono/houston:server/publications.coffee:3:coffee_to_js", "type": "coffee_to_js", "prompt": "Convert this CoffeeScript to JavaScript.\n```coffeescript\nsync_collections = ->\n Houston._admins.findOne() # TODO Why is this here?\n\n collections = {}\n for collection in (Mongo.Collection.getAll() ? [])\n collections[collection.name] = collection.instance\n\n _sync_collections = (meh, collections_db) ->\n collection_names = (col.collectionName for col in collections_db \\\n when (col.collectionName.indexOf \"system.\") isnt 0 and\n (col.collectionName.indexOf \"houston_\") isnt 0)\n\n collection_names.forEach (name) ->\n unless name of ADDED_COLLECTIONS or name of Houston._HIDDEN_COLLECTIONS\n Houston._setup_collection(collections[name]) if collections[name]?\n\n bound_sync_collections = Meteor.bindEnvironment _sync_collections, (e) ->\n console.log \"Failed while syncing collections for reason: #{e}\"\n\n # MongoInternals is the 'right' solution as of 0.6.5\n mongo_driver = MongoInternals?.defaultRemoteCollectionDriver() or Meteor._RemoteCollectionDriver\n mongo_driver.mongo.db.collections bound_sync_collections\n\nMeteor.methods\n _houston_make_admin: (user_id) ->\n check user_id, String\n # limit one admin\n return if Houston._admins.findOne {'user_id': $exists: true}\n Houston._admins.insert {user_id}\n Houston._admins.insert {exists: true}\n sync_collections() # reloads collections in case of new app\n return true\n\n# publish our analysis of the app's collections\nHouston._publish 'collections', ->\n unless Houston._user_is_admin @userId\n @ready()\n return\n Houston._collections.collections.find()\n\n# TODO address inherent security issue\nHouston._publish 'admin_user', ->\n unless Houston._user_is_admin @userId\n return Houston._admins.find {exists: true}\n return Houston._admins.find {}\n\nMeteor.startup ->\n sync_collections()\n if Houston._admins.find().count() > 0 and !Houston._admins.findOne({exists: true})\n Houston._admins.insert {exists: true}\n```", "response": "var sync_collections;\n\nsync_collections = function() {\n var _sync_collections, bound_sync_collections, collection, collections, i, len, mongo_driver, ref, ref1;\n Houston._admins.findOne(); // TODO Why is this here?\n collections = {};\n ref1 = (ref = Mongo.Collection.getAll()) != null ? ref : [];\n for (i = 0, len = ref1.length; i < len; i++) {\n collection = ref1[i];\n collections[collection.name] = collection.instance;\n }\n _sync_collections = function(meh, collections_db) {\n var col, collection_names;\n collection_names = (function() {\n var j, len1, results;\n results = [];\n for (j = 0, len1 = collections_db.length; j < len1; j++) {\n col = collections_db[j];\n if ((col.collectionName.indexOf(\"system.\")) !== 0 && (col.collectionName.indexOf(\"houston_\")) !== 0) {\n results.push(col.collectionName);\n }\n }\n return results;\n })();\n return collection_names.forEach(function(name) {\n if (!(name in ADDED_COLLECTIONS || name in Houston._HIDDEN_COLLECTIONS)) {\n if (collections[name] != null) {\n return Houston._setup_collection(collections[name]);\n }\n }\n });\n };\n bound_sync_collections = Meteor.bindEnvironment(_sync_collections, function(e) {\n return console.log(`Failed while syncing collections for reason: ${e}`);\n });\n // MongoInternals is the 'right' solution as of 0.6.5\n mongo_driver = (typeof MongoInternals !== \"undefined\" && MongoInternals !== null ? MongoInternals.defaultRemoteCollectionDriver() : void 0) || Meteor._RemoteCollectionDriver;\n return mongo_driver.mongo.db.collections(bound_sync_collections);\n};\n\nMeteor.methods({\n _houston_make_admin: function(user_id) {\n check(user_id, String);\n // limit one admin\n if (Houston._admins.findOne({\n 'user_id': {\n $exists: true\n }\n })) {\n return;\n }\n Houston._admins.insert({user_id});\n Houston._admins.insert({\n exists: true\n });\n sync_collections(); // reloads collections in case of new app\n return true;\n }\n});\n\n// publish our analysis of the app's collections\nHouston._publish('collections', function() {\n if (!Houston._user_is_admin(this.userId)) {\n this.ready();\n return;\n }\n return Houston._collections.collections.find();\n});\n\n// TODO address inherent security issue\nHouston._publish('admin_user', function() {\n if (!Houston._user_is_admin(this.userId)) {\n return Houston._admins.find({\n exists: true\n });\n }\n return Houston._admins.find({});\n});\n\nMeteor.startup(function() {\n sync_collections();\n if (Houston._admins.find().count() > 0 && !Houston._admins.findOne({\n exists: true\n })) {\n return Houston._admins.insert({\n exists: true\n });\n }\n});", "source_lang": "CoffeeScript", "target_lang": "JavaScript", "repo": "gterrono/houston", "path": "server/publications.coffee", "license": "MIT", "commit": "581357048f3577f0487ed598e26eaf063c813183", "stars": 802, "source_url": "https://github.com/gterrono/houston/blob/581357048f3577f0487ed598e26eaf063c813183/server/publications.coffee", "line_start": 49, "line_end": 98}699{"id": "gterrono/houston:server/publications.coffee:3:js_to_coffee", "type": "js_to_coffee", "prompt": "Convert this JavaScript to CoffeeScript.\n```javascript\nvar sync_collections;\n\nsync_collections = function() {\n var _sync_collections, bound_sync_collections, collection, collections, i, len, mongo_driver, ref, ref1;\n Houston._admins.findOne(); // TODO Why is this here?\n collections = {};\n ref1 = (ref = Mongo.Collection.getAll()) != null ? ref : [];\n for (i = 0, len = ref1.length; i < len; i++) {\n collection = ref1[i];\n collections[collection.name] = collection.instance;\n }\n _sync_collections = function(meh, collections_db) {\n var col, collection_names;\n collection_names = (function() {\n var j, len1, results;\n results = [];\n for (j = 0, len1 = collections_db.length; j < len1; j++) {\n col = collections_db[j];\n if ((col.collectionName.indexOf(\"system.\")) !== 0 && (col.collectionName.indexOf(\"houston_\")) !== 0) {\n results.push(col.collectionName);\n }\n }\n return results;\n })();\n return collection_names.forEach(function(name) {\n if (!(name in ADDED_COLLECTIONS || name in Houston._HIDDEN_COLLECTIONS)) {\n if (collections[name] != null) {\n return Houston._setup_collection(collections[name]);\n }\n }\n });\n };\n bound_sync_collections = Meteor.bindEnvironment(_sync_collections, function(e) {\n return console.log(`Failed while syncing collections for reason: ${e}`);\n });\n // MongoInternals is the 'right' solution as of 0.6.5\n mongo_driver = (typeof MongoInternals !== \"undefined\" && MongoInternals !== null ? MongoInternals.defaultRemoteCollectionDriver() : void 0) || Meteor._RemoteCollectionDriver;\n return mongo_driver.mongo.db.collections(bound_sync_collections);\n};\n\nMeteor.methods({\n _houston_make_admin: function(user_id) {\n check(user_id, String);\n // limit one admin\n if (Houston._admins.findOne({\n 'user_id': {\n $exists: true\n }\n })) {\n return;\n }\n Houston._admins.insert({user_id});\n Houston._admins.insert({\n exists: true\n });\n sync_collections(); // reloads collections in case of new app\n return true;\n }\n});\n\n// publish our analysis of the app's collections\nHouston._publish('collections', function() {\n if (!Houston._user_is_admin(this.userId)) {\n this.ready();\n return;\n }\n return Houston._collections.collections.find();\n});\n\n// TODO address inherent security issue\nHouston._publish('admin_user', function() {\n if (!Houston._user_is_admin(this.userId)) {\n return Houston._admins.find({\n exists: true\n });\n }\n return Houston._admins.find({});\n});\n\nMeteor.startup(function() {\n sync_collections();\n if (Houston._admins.find().count() > 0 && !Houston._admins.findOne({\n exists: true\n })) {\n return Houston._admins.insert({\n exists: true\n });\n }\n});\n```", "response": "sync_collections = ->\n Houston._admins.findOne() # TODO Why is this here?\n\n collections = {}\n for collection in (Mongo.Collection.getAll() ? [])\n collections[collection.name] = collection.instance\n\n _sync_collections = (meh, collections_db) ->\n collection_names = (col.collectionName for col in collections_db \\\n when (col.collectionName.indexOf \"system.\") isnt 0 and\n (col.collectionName.indexOf \"houston_\") isnt 0)\n\n collection_names.forEach (name) ->\n unless name of ADDED_COLLECTIONS or name of Houston._HIDDEN_COLLECTIONS\n Houston._setup_collection(collections[name]) if collections[name]?\n\n bound_sync_collections = Meteor.bindEnvironment _sync_collections, (e) ->\n console.log \"Failed while syncing collections for reason: #{e}\"\n\n # MongoInternals is the 'right' solution as of 0.6.5\n mongo_driver = MongoInternals?.defaultRemoteCollectionDriver() or Meteor._RemoteCollectionDriver\n mongo_driver.mongo.db.collections bound_sync_collections\n\nMeteor.methods\n _houston_make_admin: (user_id) ->\n check user_id, String\n # limit one admin\n return if Houston._admins.findOne {'user_id': $exists: true}\n Houston._admins.insert {user_id}\n Houston._admins.insert {exists: true}\n sync_collections() # reloads collections in case of new app\n return true\n\n# publish our analysis of the app's collections\nHouston._publish 'collections', ->\n unless Houston._user_is_admin @userId\n @ready()\n return\n Houston._collections.collections.find()\n\n# TODO address inherent security issue\nHouston._publish 'admin_user', ->\n unless Houston._user_is_admin @userId\n return Houston._admins.find {exists: true}\n return Houston._admins.find {}\n\nMeteor.startup ->\n sync_collections()\n if Houston._admins.find().count() > 0 and !Houston._admins.findOne({exists: true})\n Houston._admins.insert {exists: true}", "source_lang": "JavaScript", "target_lang": "CoffeeScript", "repo": "gterrono/houston", "path": "server/publications.coffee", "license": "MIT", "commit": "581357048f3577f0487ed598e26eaf063c813183", "stars": 802, "source_url": "https://github.com/gterrono/houston/blob/581357048f3577f0487ed598e26eaf063c813183/server/publications.coffee", "line_start": 49, "line_end": 98}700{"id": "gterrono/houston:server/publications.coffee:3:completion", "type": "completion", "prompt": "sync_collections = ->\n Houston._admins.findOne() # TODO Why is this here?\n\n collections = {}\n for collection in (Mongo.Collection.getAll() ? [])\n collections[collection.name] = collection.instance\n\n _sync_collections = (meh, collections_db) ->\n collection_names = (col.collectionName for col in collections_db \\\n when (col.collectionName.indexOf \"system.\") isnt 0 and\n (col.collectionName.indexOf \"houston_\") isnt 0)\n\n collection_names.forEach (name) ->\n unless name of ADDED_COLLECTIONS or name of Houston._HIDDEN_COLLECTIONS\n Houston._setup_collection(collections[name]) if collections[name]?\n\n bound_sync_collections = Meteor.bindEnvironment _sync_collections, (e) ->\n console.log \"Failed while syncing collections for reason: #{e}\"\n\n # MongoInternals is the 'right' solution as of 0.6.5\n mongo_driver = MongoInternals?.defaultRemoteCollectionDriver() or Meteor._RemoteCollectionDriver\n mongo_driver.mongo.db.collections bound_sync_collections\n\nMeteor.methods\n _houston_make_admin: (user_id) ->", "response": "check user_id, String\n # limit one admin\n return if Houston._admins.findOne {'user_id': $exists: true}\n Houston._admins.insert {user_id}\n Houston._admins.insert {exists: true}\n sync_collections() # reloads collections in case of new app\n return true\n\n# publish our analysis of the app's collections\nHouston._publish 'collections', ->\n unless Houston._user_is_admin @userId\n @ready()\n return\n Houston._collections.collections.find()\n\n# TODO address inherent security issue\nHouston._publish 'admin_user', ->\n unless Houston._user_is_admin @userId\n return Houston._admins.find {exists: true}\n return Houston._admins.find {}\n\nMeteor.startup ->\n sync_collections()\n if Houston._admins.find().count() > 0 and !Houston._admins.findOne({exists: true})\n Houston._admins.insert {exists: true}", "source_lang": "CoffeeScript", "target_lang": "CoffeeScript", "repo": "gterrono/houston", "path": "server/publications.coffee", "license": "MIT", "commit": "581357048f3577f0487ed598e26eaf063c813183", "stars": 802, "source_url": "https://github.com/gterrono/houston/blob/581357048f3577f0487ed598e26eaf063c813183/server/publications.coffee", "line_start": 49, "line_end": 98}701{"id": "gterrono/houston:server/publications.coffee:3:raw_corpus", "type": "raw_corpus", "prompt": "", "response": "sync_collections = ->\n Houston._admins.findOne() # TODO Why is this here?\n\n collections = {}\n for collection in (Mongo.Collection.getAll() ? [])\n collections[collection.name] = collection.instance\n\n _sync_collections = (meh, collections_db) ->\n collection_names = (col.collectionName for col in collections_db \\\n when (col.collectionName.indexOf \"system.\") isnt 0 and\n (col.collectionName.indexOf \"houston_\") isnt 0)\n\n collection_names.forEach (name) ->\n unless name of ADDED_COLLECTIONS or name of Houston._HIDDEN_COLLECTIONS\n Houston._setup_collection(collections[name]) if collections[name]?\n\n bound_sync_collections = Meteor.bindEnvironment _sync_collections, (e) ->\n console.log \"Failed while syncing collections for reason: #{e}\"\n\n # MongoInternals is the 'right' solution as of 0.6.5\n mongo_driver = MongoInternals?.defaultRemoteCollectionDriver() or Meteor._RemoteCollectionDriver\n mongo_driver.mongo.db.collections bound_sync_collections\n\nMeteor.methods\n _houston_make_admin: (user_id) ->\n check user_id, String\n # limit one admin\n return if Houston._admins.findOne {'user_id': $exists: true}\n Houston._admins.insert {user_id}\n sync_collections() # reloads collections in case of new app\n return true\n\n# publish our analysis of the app's collections\nHouston._publish 'collections', ->\n unless Houston._user_is_admin @userId\n @ready()\n return\n Houston._collections.collections.find()\n\n# TODO address inherent security issue\nHouston._publish 'admin_user', ->\n Houston._admins.find {}\n\nMeteor.startup ->\n sync_collections()", "source_lang": "", "target_lang": "CoffeeScript", "repo": "gterrono/houston", "path": "server/publications.coffee", "license": "MIT", "commit": "a01e5b4c1464c7b33b31fe1be6bec43e22dd3f8d", "stars": 802, "source_url": "https://github.com/gterrono/houston/blob/a01e5b4c1464c7b33b31fe1be6bec43e22dd3f8d/server/publications.coffee", "line_start": 49, "line_end": 93}702{"id": "gterrono/houston:server/publications.coffee:3:coffee_to_js", "type": "coffee_to_js", "prompt": "Convert this CoffeeScript to JavaScript.\n```coffeescript\nsync_collections = ->\n Houston._admins.findOne() # TODO Why is this here?\n\n collections = {}\n for collection in (Mongo.Collection.getAll() ? [])\n collections[collection.name] = collection.instance\n\n _sync_collections = (meh, collections_db) ->\n collection_names = (col.collectionName for col in collections_db \\\n when (col.collectionName.indexOf \"system.\") isnt 0 and\n (col.collectionName.indexOf \"houston_\") isnt 0)\n\n collection_names.forEach (name) ->\n unless name of ADDED_COLLECTIONS or name of Houston._HIDDEN_COLLECTIONS\n Houston._setup_collection(collections[name]) if collections[name]?\n\n bound_sync_collections = Meteor.bindEnvironment _sync_collections, (e) ->\n console.log \"Failed while syncing collections for reason: #{e}\"\n\n # MongoInternals is the 'right' solution as of 0.6.5\n mongo_driver = MongoInternals?.defaultRemoteCollectionDriver() or Meteor._RemoteCollectionDriver\n mongo_driver.mongo.db.collections bound_sync_collections\n\nMeteor.methods\n _houston_make_admin: (user_id) ->\n check user_id, String\n # limit one admin\n return if Houston._admins.findOne {'user_id': $exists: true}\n Houston._admins.insert {user_id}\n sync_collections() # reloads collections in case of new app\n return true\n\n# publish our analysis of the app's collections\nHouston._publish 'collections', ->\n unless Houston._user_is_admin @userId\n @ready()\n return\n Houston._collections.collections.find()\n\n# TODO address inherent security issue\nHouston._publish 'admin_user', ->\n Houston._admins.find {}\n\nMeteor.startup ->\n sync_collections()\n```", "response": "var sync_collections;\n\nsync_collections = function() {\n var _sync_collections, bound_sync_collections, collection, collections, i, len, mongo_driver, ref, ref1;\n Houston._admins.findOne(); // TODO Why is this here?\n collections = {};\n ref1 = (ref = Mongo.Collection.getAll()) != null ? ref : [];\n for (i = 0, len = ref1.length; i < len; i++) {\n collection = ref1[i];\n collections[collection.name] = collection.instance;\n }\n _sync_collections = function(meh, collections_db) {\n var col, collection_names;\n collection_names = (function() {\n var j, len1, results;\n results = [];\n for (j = 0, len1 = collections_db.length; j < len1; j++) {\n col = collections_db[j];\n if ((col.collectionName.indexOf(\"system.\")) !== 0 && (col.collectionName.indexOf(\"houston_\")) !== 0) {\n results.push(col.collectionName);\n }\n }\n return results;\n })();\n return collection_names.forEach(function(name) {\n if (!(name in ADDED_COLLECTIONS || name in Houston._HIDDEN_COLLECTIONS)) {\n if (collections[name] != null) {\n return Houston._setup_collection(collections[name]);\n }\n }\n });\n };\n bound_sync_collections = Meteor.bindEnvironment(_sync_collections, function(e) {\n return console.log(`Failed while syncing collections for reason: ${e}`);\n });\n // MongoInternals is the 'right' solution as of 0.6.5\n mongo_driver = (typeof MongoInternals !== \"undefined\" && MongoInternals !== null ? MongoInternals.defaultRemoteCollectionDriver() : void 0) || Meteor._RemoteCollectionDriver;\n return mongo_driver.mongo.db.collections(bound_sync_collections);\n};\n\nMeteor.methods({\n _houston_make_admin: function(user_id) {\n check(user_id, String);\n // limit one admin\n if (Houston._admins.findOne({\n 'user_id': {\n $exists: true\n }\n })) {\n return;\n }\n Houston._admins.insert({user_id});\n sync_collections(); // reloads collections in case of new app\n return true;\n }\n});\n\n// publish our analysis of the app's collections\nHouston._publish('collections', function() {\n if (!Houston._user_is_admin(this.userId)) {\n this.ready();\n return;\n }\n return Houston._collections.collections.find();\n});\n\n// TODO address inherent security issue\nHouston._publish('admin_user', function() {\n return Houston._admins.find({});\n});\n\nMeteor.startup(function() {\n return sync_collections();\n});", "source_lang": "CoffeeScript", "target_lang": "JavaScript", "repo": "gterrono/houston", "path": "server/publications.coffee", "license": "MIT", "commit": "a01e5b4c1464c7b33b31fe1be6bec43e22dd3f8d", "stars": 802, "source_url": "https://github.com/gterrono/houston/blob/a01e5b4c1464c7b33b31fe1be6bec43e22dd3f8d/server/publications.coffee", "line_start": 49, "line_end": 93}703{"id": "gterrono/houston:server/publications.coffee:3:js_to_coffee", "type": "js_to_coffee", "prompt": "Convert this JavaScript to CoffeeScript.\n```javascript\nvar sync_collections;\n\nsync_collections = function() {\n var _sync_collections, bound_sync_collections, collection, collections, i, len, mongo_driver, ref, ref1;\n Houston._admins.findOne(); // TODO Why is this here?\n collections = {};\n ref1 = (ref = Mongo.Collection.getAll()) != null ? ref : [];\n for (i = 0, len = ref1.length; i < len; i++) {\n collection = ref1[i];\n collections[collection.name] = collection.instance;\n }\n _sync_collections = function(meh, collections_db) {\n var col, collection_names;\n collection_names = (function() {\n var j, len1, results;\n results = [];\n for (j = 0, len1 = collections_db.length; j < len1; j++) {\n col = collections_db[j];\n if ((col.collectionName.indexOf(\"system.\")) !== 0 && (col.collectionName.indexOf(\"houston_\")) !== 0) {\n results.push(col.collectionName);\n }\n }\n return results;\n })();\n return collection_names.forEach(function(name) {\n if (!(name in ADDED_COLLECTIONS || name in Houston._HIDDEN_COLLECTIONS)) {\n if (collections[name] != null) {\n return Houston._setup_collection(collections[name]);\n }\n }\n });\n };\n bound_sync_collections = Meteor.bindEnvironment(_sync_collections, function(e) {\n return console.log(`Failed while syncing collections for reason: ${e}`);\n });\n // MongoInternals is the 'right' solution as of 0.6.5\n mongo_driver = (typeof MongoInternals !== \"undefined\" && MongoInternals !== null ? MongoInternals.defaultRemoteCollectionDriver() : void 0) || Meteor._RemoteCollectionDriver;\n return mongo_driver.mongo.db.collections(bound_sync_collections);\n};\n\nMeteor.methods({\n _houston_make_admin: function(user_id) {\n check(user_id, String);\n // limit one admin\n if (Houston._admins.findOne({\n 'user_id': {\n $exists: true\n }\n })) {\n return;\n }\n Houston._admins.insert({user_id});\n sync_collections(); // reloads collections in case of new app\n return true;\n }\n});\n\n// publish our analysis of the app's collections\nHouston._publish('collections', function() {\n if (!Houston._user_is_admin(this.userId)) {\n this.ready();\n return;\n }\n return Houston._collections.collections.find();\n});\n\n// TODO address inherent security issue\nHouston._publish('admin_user', function() {\n return Houston._admins.find({});\n});\n\nMeteor.startup(function() {\n return sync_collections();\n});\n```", "response": "sync_collections = ->\n Houston._admins.findOne() # TODO Why is this here?\n\n collections = {}\n for collection in (Mongo.Collection.getAll() ? [])\n collections[collection.name] = collection.instance\n\n _sync_collections = (meh, collections_db) ->\n collection_names = (col.collectionName for col in collections_db \\\n when (col.collectionName.indexOf \"system.\") isnt 0 and\n (col.collectionName.indexOf \"houston_\") isnt 0)\n\n collection_names.forEach (name) ->\n unless name of ADDED_COLLECTIONS or name of Houston._HIDDEN_COLLECTIONS\n Houston._setup_collection(collections[name]) if collections[name]?\n\n bound_sync_collections = Meteor.bindEnvironment _sync_collections, (e) ->\n console.log \"Failed while syncing collections for reason: #{e}\"\n\n # MongoInternals is the 'right' solution as of 0.6.5\n mongo_driver = MongoInternals?.defaultRemoteCollectionDriver() or Meteor._RemoteCollectionDriver\n mongo_driver.mongo.db.collections bound_sync_collections\n\nMeteor.methods\n _houston_make_admin: (user_id) ->\n check user_id, String\n # limit one admin\n return if Houston._admins.findOne {'user_id': $exists: true}\n Houston._admins.insert {user_id}\n sync_collections() # reloads collections in case of new app\n return true\n\n# publish our analysis of the app's collections\nHouston._publish 'collections', ->\n unless Houston._user_is_admin @userId\n @ready()\n return\n Houston._collections.collections.find()\n\n# TODO address inherent security issue\nHouston._publish 'admin_user', ->\n Houston._admins.find {}\n\nMeteor.startup ->\n sync_collections()", "source_lang": "JavaScript", "target_lang": "CoffeeScript", "repo": "gterrono/houston", "path": "server/publications.coffee", "license": "MIT", "commit": "a01e5b4c1464c7b33b31fe1be6bec43e22dd3f8d", "stars": 802, "source_url": "https://github.com/gterrono/houston/blob/a01e5b4c1464c7b33b31fe1be6bec43e22dd3f8d/server/publications.coffee", "line_start": 49, "line_end": 93}704{"id": "gterrono/houston:server/publications.coffee:3:completion", "type": "completion", "prompt": "sync_collections = ->\n Houston._admins.findOne() # TODO Why is this here?\n\n collections = {}\n for collection in (Mongo.Collection.getAll() ? [])\n collections[collection.name] = collection.instance\n\n _sync_collections = (meh, collections_db) ->\n collection_names = (col.collectionName for col in collections_db \\\n when (col.collectionName.indexOf \"system.\") isnt 0 and\n (col.collectionName.indexOf \"houston_\") isnt 0)\n\n collection_names.forEach (name) ->\n unless name of ADDED_COLLECTIONS or name of Houston._HIDDEN_COLLECTIONS\n Houston._setup_collection(collections[name]) if collections[name]?\n\n bound_sync_collections = Meteor.bindEnvironment _sync_collections, (e) ->\n console.log \"Failed while syncing collections for reason: #{e}\"\n\n # MongoInternals is the 'right' solution as of 0.6.5\n mongo_driver = MongoInternals?.defaultRemoteCollectionDriver() or Meteor._RemoteCollectionDriver\n mongo_driver.mongo.db.collections bound_sync_collections", "response": "Meteor.methods\n _houston_make_admin: (user_id) ->\n check user_id, String\n # limit one admin\n return if Houston._admins.findOne {'user_id': $exists: true}\n Houston._admins.insert {user_id}\n sync_collections() # reloads collections in case of new app\n return true\n\n# publish our analysis of the app's collections\nHouston._publish 'collections', ->\n unless Houston._user_is_admin @userId\n @ready()\n return\n Houston._collections.collections.find()\n\n# TODO address inherent security issue\nHouston._publish 'admin_user', ->\n Houston._admins.find {}\n\nMeteor.startup ->\n sync_collections()", "source_lang": "CoffeeScript", "target_lang": "CoffeeScript", "repo": "gterrono/houston", "path": "server/publications.coffee", "license": "MIT", "commit": "a01e5b4c1464c7b33b31fe1be6bec43e22dd3f8d", "stars": 802, "source_url": "https://github.com/gterrono/houston/blob/a01e5b4c1464c7b33b31fe1be6bec43e22dd3f8d/server/publications.coffee", "line_start": 49, "line_end": 93}705{"id": "gterrono/houston:server/publications.coffee:3:raw_corpus", "type": "raw_corpus", "prompt": "", "response": "sync_collections = ->\n Houston._admins.findOne()\n\n collections = {}\n for collection in (Mongo.Collection.getAll() ? [])\n collections[collection.name] = collection.instance\n\n _sync_collections = (meh, collections_db) ->\n collection_names = (col.collectionName for col in collections_db \\\n when (col.collectionName.indexOf \"system.\") isnt 0 and\n (col.collectionName.indexOf \"houston_\") isnt 0)\n\n collection_names.forEach (name) ->\n unless name of ADDED_COLLECTIONS or name of Houston._HIDDEN_COLLECTIONS\n Houston._setup_collection(collections[name]) if collections[name]?\n\n bound_sync_collections = Meteor.bindEnvironment _sync_collections, (e) ->\n console.log \"Failed while syncing collections for reason: #{e}\"\n\n # MongoInternals is the 'right' solution as of 0.6.5\n mongo_driver = MongoInternals?.defaultRemoteCollectionDriver() or Meteor._RemoteCollectionDriver\n mongo_driver.mongo.db.collections bound_sync_collections\n\nMeteor.methods\n _houston_make_admin: (user_id) ->\n check user_id, String\n # limit one admin\n return if Houston._admins.findOne {'user_id': $exists: true}\n Houston._admins.insert {user_id}\n sync_collections() # reloads collections in case of new app\n return true\n\n# publish our analysis of the app's collections\nHouston._publish 'collections', ->\n unless Houston._user_is_admin @userId\n @ready()\n return\n Houston._collections.collections.find()\n\n# TODO address inherent security issue\nHouston._publish 'admin_user', ->\n Houston._admins.find {}\n\nMeteor.startup ->\n sync_collections()", "source_lang": "", "target_lang": "CoffeeScript", "repo": "gterrono/houston", "path": "server/publications.coffee", "license": "MIT", "commit": "f0e3d957d8dbc2f1796c5570b8ea7a9f6fdf5397", "stars": 802, "source_url": "https://github.com/gterrono/houston/blob/f0e3d957d8dbc2f1796c5570b8ea7a9f6fdf5397/server/publications.coffee", "line_start": 49, "line_end": 93}706{"id": "gterrono/houston:server/publications.coffee:3:coffee_to_js", "type": "coffee_to_js", "prompt": "Convert this CoffeeScript to JavaScript.\n```coffeescript\nsync_collections = ->\n Houston._admins.findOne()\n\n collections = {}\n for collection in (Mongo.Collection.getAll() ? [])\n collections[collection.name] = collection.instance\n\n _sync_collections = (meh, collections_db) ->\n collection_names = (col.collectionName for col in collections_db \\\n when (col.collectionName.indexOf \"system.\") isnt 0 and\n (col.collectionName.indexOf \"houston_\") isnt 0)\n\n collection_names.forEach (name) ->\n unless name of ADDED_COLLECTIONS or name of Houston._HIDDEN_COLLECTIONS\n Houston._setup_collection(collections[name]) if collections[name]?\n\n bound_sync_collections = Meteor.bindEnvironment _sync_collections, (e) ->\n console.log \"Failed while syncing collections for reason: #{e}\"\n\n # MongoInternals is the 'right' solution as of 0.6.5\n mongo_driver = MongoInternals?.defaultRemoteCollectionDriver() or Meteor._RemoteCollectionDriver\n mongo_driver.mongo.db.collections bound_sync_collections\n\nMeteor.methods\n _houston_make_admin: (user_id) ->\n check user_id, String\n # limit one admin\n return if Houston._admins.findOne {'user_id': $exists: true}\n Houston._admins.insert {user_id}\n sync_collections() # reloads collections in case of new app\n return true\n\n# publish our analysis of the app's collections\nHouston._publish 'collections', ->\n unless Houston._user_is_admin @userId\n @ready()\n return\n Houston._collections.collections.find()\n\n# TODO address inherent security issue\nHouston._publish 'admin_user', ->\n Houston._admins.find {}\n\nMeteor.startup ->\n sync_collections()\n```", "response": "var sync_collections;\n\nsync_collections = function() {\n var _sync_collections, bound_sync_collections, collection, collections, i, len, mongo_driver, ref, ref1;\n Houston._admins.findOne();\n collections = {};\n ref1 = (ref = Mongo.Collection.getAll()) != null ? ref : [];\n for (i = 0, len = ref1.length; i < len; i++) {\n collection = ref1[i];\n collections[collection.name] = collection.instance;\n }\n _sync_collections = function(meh, collections_db) {\n var col, collection_names;\n collection_names = (function() {\n var j, len1, results;\n results = [];\n for (j = 0, len1 = collections_db.length; j < len1; j++) {\n col = collections_db[j];\n if ((col.collectionName.indexOf(\"system.\")) !== 0 && (col.collectionName.indexOf(\"houston_\")) !== 0) {\n results.push(col.collectionName);\n }\n }\n return results;\n })();\n return collection_names.forEach(function(name) {\n if (!(name in ADDED_COLLECTIONS || name in Houston._HIDDEN_COLLECTIONS)) {\n if (collections[name] != null) {\n return Houston._setup_collection(collections[name]);\n }\n }\n });\n };\n bound_sync_collections = Meteor.bindEnvironment(_sync_collections, function(e) {\n return console.log(`Failed while syncing collections for reason: ${e}`);\n });\n // MongoInternals is the 'right' solution as of 0.6.5\n mongo_driver = (typeof MongoInternals !== \"undefined\" && MongoInternals !== null ? MongoInternals.defaultRemoteCollectionDriver() : void 0) || Meteor._RemoteCollectionDriver;\n return mongo_driver.mongo.db.collections(bound_sync_collections);\n};\n\nMeteor.methods({\n _houston_make_admin: function(user_id) {\n check(user_id, String);\n // limit one admin\n if (Houston._admins.findOne({\n 'user_id': {\n $exists: true\n }\n })) {\n return;\n }\n Houston._admins.insert({user_id});\n sync_collections(); // reloads collections in case of new app\n return true;\n }\n});\n\n// publish our analysis of the app's collections\nHouston._publish('collections', function() {\n if (!Houston._user_is_admin(this.userId)) {\n this.ready();\n return;\n }\n return Houston._collections.collections.find();\n});\n\n// TODO address inherent security issue\nHouston._publish('admin_user', function() {\n return Houston._admins.find({});\n});\n\nMeteor.startup(function() {\n return sync_collections();\n});", "source_lang": "CoffeeScript", "target_lang": "JavaScript", "repo": "gterrono/houston", "path": "server/publications.coffee", "license": "MIT", "commit": "f0e3d957d8dbc2f1796c5570b8ea7a9f6fdf5397", "stars": 802, "source_url": "https://github.com/gterrono/houston/blob/f0e3d957d8dbc2f1796c5570b8ea7a9f6fdf5397/server/publications.coffee", "line_start": 49, "line_end": 93}707{"id": "gterrono/houston:server/publications.coffee:3:js_to_coffee", "type": "js_to_coffee", "prompt": "Convert this JavaScript to CoffeeScript.\n```javascript\nvar sync_collections;\n\nsync_collections = function() {\n var _sync_collections, bound_sync_collections, collection, collections, i, len, mongo_driver, ref, ref1;\n Houston._admins.findOne();\n collections = {};\n ref1 = (ref = Mongo.Collection.getAll()) != null ? ref : [];\n for (i = 0, len = ref1.length; i < len; i++) {\n collection = ref1[i];\n collections[collection.name] = collection.instance;\n }\n _sync_collections = function(meh, collections_db) {\n var col, collection_names;\n collection_names = (function() {\n var j, len1, results;\n results = [];\n for (j = 0, len1 = collections_db.length; j < len1; j++) {\n col = collections_db[j];\n if ((col.collectionName.indexOf(\"system.\")) !== 0 && (col.collectionName.indexOf(\"houston_\")) !== 0) {\n results.push(col.collectionName);\n }\n }\n return results;\n })();\n return collection_names.forEach(function(name) {\n if (!(name in ADDED_COLLECTIONS || name in Houston._HIDDEN_COLLECTIONS)) {\n if (collections[name] != null) {\n return Houston._setup_collection(collections[name]);\n }\n }\n });\n };\n bound_sync_collections = Meteor.bindEnvironment(_sync_collections, function(e) {\n return console.log(`Failed while syncing collections for reason: ${e}`);\n });\n // MongoInternals is the 'right' solution as of 0.6.5\n mongo_driver = (typeof MongoInternals !== \"undefined\" && MongoInternals !== null ? MongoInternals.defaultRemoteCollectionDriver() : void 0) || Meteor._RemoteCollectionDriver;\n return mongo_driver.mongo.db.collections(bound_sync_collections);\n};\n\nMeteor.methods({\n _houston_make_admin: function(user_id) {\n check(user_id, String);\n // limit one admin\n if (Houston._admins.findOne({\n 'user_id': {\n $exists: true\n }\n })) {\n return;\n }\n Houston._admins.insert({user_id});\n sync_collections(); // reloads collections in case of new app\n return true;\n }\n});\n\n// publish our analysis of the app's collections\nHouston._publish('collections', function() {\n if (!Houston._user_is_admin(this.userId)) {\n this.ready();\n return;\n }\n return Houston._collections.collections.find();\n});\n\n// TODO address inherent security issue\nHouston._publish('admin_user', function() {\n return Houston._admins.find({});\n});\n\nMeteor.startup(function() {\n return sync_collections();\n});\n```", "response": "sync_collections = ->\n Houston._admins.findOne()\n\n collections = {}\n for collection in (Mongo.Collection.getAll() ? [])\n collections[collection.name] = collection.instance\n\n _sync_collections = (meh, collections_db) ->\n collection_names = (col.collectionName for col in collections_db \\\n when (col.collectionName.indexOf \"system.\") isnt 0 and\n (col.collectionName.indexOf \"houston_\") isnt 0)\n\n collection_names.forEach (name) ->\n unless name of ADDED_COLLECTIONS or name of Houston._HIDDEN_COLLECTIONS\n Houston._setup_collection(collections[name]) if collections[name]?\n\n bound_sync_collections = Meteor.bindEnvironment _sync_collections, (e) ->\n console.log \"Failed while syncing collections for reason: #{e}\"\n\n # MongoInternals is the 'right' solution as of 0.6.5\n mongo_driver = MongoInternals?.defaultRemoteCollectionDriver() or Meteor._RemoteCollectionDriver\n mongo_driver.mongo.db.collections bound_sync_collections\n\nMeteor.methods\n _houston_make_admin: (user_id) ->\n check user_id, String\n # limit one admin\n return if Houston._admins.findOne {'user_id': $exists: true}\n Houston._admins.insert {user_id}\n sync_collections() # reloads collections in case of new app\n return true\n\n# publish our analysis of the app's collections\nHouston._publish 'collections', ->\n unless Houston._user_is_admin @userId\n @ready()\n return\n Houston._collections.collections.find()\n\n# TODO address inherent security issue\nHouston._publish 'admin_user', ->\n Houston._admins.find {}\n\nMeteor.startup ->\n sync_collections()", "source_lang": "JavaScript", "target_lang": "CoffeeScript", "repo": "gterrono/houston", "path": "server/publications.coffee", "license": "MIT", "commit": "f0e3d957d8dbc2f1796c5570b8ea7a9f6fdf5397", "stars": 802, "source_url": "https://github.com/gterrono/houston/blob/f0e3d957d8dbc2f1796c5570b8ea7a9f6fdf5397/server/publications.coffee", "line_start": 49, "line_end": 93}708{"id": "gterrono/houston:server/publications.coffee:3:completion", "type": "completion", "prompt": "sync_collections = ->\n Houston._admins.findOne()\n\n collections = {}\n for collection in (Mongo.Collection.getAll() ? [])\n collections[collection.name] = collection.instance\n\n _sync_collections = (meh, collections_db) ->\n collection_names = (col.collectionName for col in collections_db \\\n when (col.collectionName.indexOf \"system.\") isnt 0 and\n (col.collectionName.indexOf \"houston_\") isnt 0)\n\n collection_names.forEach (name) ->\n unless name of ADDED_COLLECTIONS or name of Houston._HIDDEN_COLLECTIONS\n Houston._setup_collection(collections[name]) if collections[name]?\n\n bound_sync_collections = Meteor.bindEnvironment _sync_collections, (e) ->\n console.log \"Failed while syncing collections for reason: #{e}\"\n\n # MongoInternals is the 'right' solution as of 0.6.5\n mongo_driver = MongoInternals?.defaultRemoteCollectionDriver() or Meteor._RemoteCollectionDriver\n mongo_driver.mongo.db.collections bound_sync_collections", "response": "Meteor.methods\n _houston_make_admin: (user_id) ->\n check user_id, String\n # limit one admin\n return if Houston._admins.findOne {'user_id': $exists: true}\n Houston._admins.insert {user_id}\n sync_collections() # reloads collections in case of new app\n return true\n\n# publish our analysis of the app's collections\nHouston._publish 'collections', ->\n unless Houston._user_is_admin @userId\n @ready()\n return\n Houston._collections.collections.find()\n\n# TODO address inherent security issue\nHouston._publish 'admin_user', ->\n Houston._admins.find {}\n\nMeteor.startup ->\n sync_collections()", "source_lang": "CoffeeScript", "target_lang": "CoffeeScript", "repo": "gterrono/houston", "path": "server/publications.coffee", "license": "MIT", "commit": "f0e3d957d8dbc2f1796c5570b8ea7a9f6fdf5397", "stars": 802, "source_url": "https://github.com/gterrono/houston/blob/f0e3d957d8dbc2f1796c5570b8ea7a9f6fdf5397/server/publications.coffee", "line_start": 49, "line_end": 93}709{"id": "gterrono/houston:server/publications.coffee:2:raw_corpus", "type": "raw_corpus", "prompt": "", "response": "Houston._setup_collection = (collection) ->\n name = collection._name\n return if name of ADDED_COLLECTIONS\n\n Houston._setup_collection_methods(collection)\n\n Houston._publish name, (sort, filter, limit, unknown_arg) ->\n check sort, Match.Optional(Object)\n check filter, Match.Optional(Object)\n check limit, Match.Optional(Number)\n check unknown_arg, Match.Any\n unless Houston._user_is_admin @userId\n @ready()\n return\n try\n collection.find(filter, sort: sort, limit: limit)\n catch e\n console.log e\n\n collection.find().observe\n _suppress_initial: true # fixes houston for large initial datasets\n added: (document) ->\n Houston._collections.collections.update {name},\n $inc: {count: 1},\n $addToSet: fields: $each: Houston._get_fields([document])\n changed: (document) ->\n Houston._collections.collections.update {name},\n $addToSet: fields: $each: Houston._get_fields([document])\n removed: (document) -> Houston._collections.collections.update {name}, {$inc: {count: -1}}\n\n fields = Houston._get_fields_from_collection(collection)\n c = Houston._collections.collections.findOne {name}\n count = collection.find().count()\n if c\n Houston._collections.collections.update c._id, {$set: {count, fields}}\n else\n Houston._collections.collections.insert {name, count, fields}\n ADDED_COLLECTIONS[name] = collection", "source_lang": "", "target_lang": "CoffeeScript", "repo": "gterrono/houston", "path": "server/publications.coffee", "license": "MIT", "commit": "b9e66f6adc9e835faa3d14c77409147d1393dabc", "stars": 802, "source_url": "https://github.com/gterrono/houston/blob/b9e66f6adc9e835faa3d14c77409147d1393dabc/server/publications.coffee", "line_start": 9, "line_end": 46}710{"id": "gterrono/houston:server/publications.coffee:2:coffee_to_js", "type": "coffee_to_js", "prompt": "Convert this CoffeeScript to JavaScript.\n```coffeescript\nHouston._setup_collection = (collection) ->\n name = collection._name\n return if name of ADDED_COLLECTIONS\n\n Houston._setup_collection_methods(collection)\n\n Houston._publish name, (sort, filter, limit, unknown_arg) ->\n check sort, Match.Optional(Object)\n check filter, Match.Optional(Object)\n check limit, Match.Optional(Number)\n check unknown_arg, Match.Any\n unless Houston._user_is_admin @userId\n @ready()\n return\n try\n collection.find(filter, sort: sort, limit: limit)\n catch e\n console.log e\n\n collection.find().observe\n _suppress_initial: true # fixes houston for large initial datasets\n added: (document) ->\n Houston._collections.collections.update {name},\n $inc: {count: 1},\n $addToSet: fields: $each: Houston._get_fields([document])\n changed: (document) ->\n Houston._collections.collections.update {name},\n $addToSet: fields: $each: Houston._get_fields([document])\n removed: (document) -> Houston._collections.collections.update {name}, {$inc: {count: -1}}\n\n fields = Houston._get_fields_from_collection(collection)\n c = Houston._collections.collections.findOne {name}\n count = collection.find().count()\n if c\n Houston._collections.collections.update c._id, {$set: {count, fields}}\n else\n Houston._collections.collections.insert {name, count, fields}\n ADDED_COLLECTIONS[name] = collection\n```", "response": "Houston._setup_collection = function(collection) {\n var c, count, fields, name;\n name = collection._name;\n if (name in ADDED_COLLECTIONS) {\n return;\n }\n Houston._setup_collection_methods(collection);\n Houston._publish(name, function(sort, filter, limit, unknown_arg) {\n var e;\n check(sort, Match.Optional(Object));\n check(filter, Match.Optional(Object));\n check(limit, Match.Optional(Number));\n check(unknown_arg, Match.Any);\n if (!Houston._user_is_admin(this.userId)) {\n this.ready();\n return;\n }\n try {\n return collection.find(filter, {\n sort: sort,\n limit: limit\n });\n } catch (error) {\n e = error;\n return console.log(e);\n }\n });\n collection.find().observe({\n _suppress_initial: true, // fixes houston for large initial datasets\n added: function(document) {\n return Houston._collections.collections.update({name}, {\n $inc: {\n count: 1\n },\n $addToSet: {\n fields: {\n $each: Houston._get_fields([document])\n }\n }\n });\n },\n changed: function(document) {\n return Houston._collections.collections.update({name}, {\n $addToSet: {\n fields: {\n $each: Houston._get_fields([document])\n }\n }\n });\n },\n removed: function(document) {\n return Houston._collections.collections.update({name}, {\n $inc: {\n count: -1\n }\n });\n }\n });\n fields = Houston._get_fields_from_collection(collection);\n c = Houston._collections.collections.findOne({name});\n count = collection.find().count();\n if (c) {\n Houston._collections.collections.update(c._id, {\n $set: {count, fields}\n });\n } else {\n Houston._collections.collections.insert({name, count, fields});\n }\n return ADDED_COLLECTIONS[name] = collection;\n};", "source_lang": "CoffeeScript", "target_lang": "JavaScript", "repo": "gterrono/houston", "path": "server/publications.coffee", "license": "MIT", "commit": "b9e66f6adc9e835faa3d14c77409147d1393dabc", "stars": 802, "source_url": "https://github.com/gterrono/houston/blob/b9e66f6adc9e835faa3d14c77409147d1393dabc/server/publications.coffee", "line_start": 9, "line_end": 46}711{"id": "gterrono/houston:server/publications.coffee:2:js_to_coffee", "type": "js_to_coffee", "prompt": "Convert this JavaScript to CoffeeScript.\n```javascript\nHouston._setup_collection = function(collection) {\n var c, count, fields, name;\n name = collection._name;\n if (name in ADDED_COLLECTIONS) {\n return;\n }\n Houston._setup_collection_methods(collection);\n Houston._publish(name, function(sort, filter, limit, unknown_arg) {\n var e;\n check(sort, Match.Optional(Object));\n check(filter, Match.Optional(Object));\n check(limit, Match.Optional(Number));\n check(unknown_arg, Match.Any);\n if (!Houston._user_is_admin(this.userId)) {\n this.ready();\n return;\n }\n try {\n return collection.find(filter, {\n sort: sort,\n limit: limit\n });\n } catch (error) {\n e = error;\n return console.log(e);\n }\n });\n collection.find().observe({\n _suppress_initial: true, // fixes houston for large initial datasets\n added: function(document) {\n return Houston._collections.collections.update({name}, {\n $inc: {\n count: 1\n },\n $addToSet: {\n fields: {\n $each: Houston._get_fields([document])\n }\n }\n });\n },\n changed: function(document) {\n return Houston._collections.collections.update({name}, {\n $addToSet: {\n fields: {\n $each: Houston._get_fields([document])\n }\n }\n });\n },\n removed: function(document) {\n return Houston._collections.collections.update({name}, {\n $inc: {\n count: -1\n }\n });\n }\n });\n fields = Houston._get_fields_from_collection(collection);\n c = Houston._collections.collections.findOne({name});\n count = collection.find().count();\n if (c) {\n Houston._collections.collections.update(c._id, {\n $set: {count, fields}\n });\n } else {\n Houston._collections.collections.insert({name, count, fields});\n }\n return ADDED_COLLECTIONS[name] = collection;\n};\n```", "response": "Houston._setup_collection = (collection) ->\n name = collection._name\n return if name of ADDED_COLLECTIONS\n\n Houston._setup_collection_methods(collection)\n\n Houston._publish name, (sort, filter, limit, unknown_arg) ->\n check sort, Match.Optional(Object)\n check filter, Match.Optional(Object)\n check limit, Match.Optional(Number)\n check unknown_arg, Match.Any\n unless Houston._user_is_admin @userId\n @ready()\n return\n try\n collection.find(filter, sort: sort, limit: limit)\n catch e\n console.log e\n\n collection.find().observe\n _suppress_initial: true # fixes houston for large initial datasets\n added: (document) ->\n Houston._collections.collections.update {name},\n $inc: {count: 1},\n $addToSet: fields: $each: Houston._get_fields([document])\n changed: (document) ->\n Houston._collections.collections.update {name},\n $addToSet: fields: $each: Houston._get_fields([document])\n removed: (document) -> Houston._collections.collections.update {name}, {$inc: {count: -1}}\n\n fields = Houston._get_fields_from_collection(collection)\n c = Houston._collections.collections.findOne {name}\n count = collection.find().count()\n if c\n Houston._collections.collections.update c._id, {$set: {count, fields}}\n else\n Houston._collections.collections.insert {name, count, fields}\n ADDED_COLLECTIONS[name] = collection", "source_lang": "JavaScript", "target_lang": "CoffeeScript", "repo": "gterrono/houston", "path": "server/publications.coffee", "license": "MIT", "commit": "b9e66f6adc9e835faa3d14c77409147d1393dabc", "stars": 802, "source_url": "https://github.com/gterrono/houston/blob/b9e66f6adc9e835faa3d14c77409147d1393dabc/server/publications.coffee", "line_start": 9, "line_end": 46}712{"id": "gterrono/houston:server/publications.coffee:2:completion", "type": "completion", "prompt": "Houston._setup_collection = (collection) ->\n name = collection._name\n return if name of ADDED_COLLECTIONS\n\n Houston._setup_collection_methods(collection)\n\n Houston._publish name, (sort, filter, limit, unknown_arg) ->\n check sort, Match.Optional(Object)\n check filter, Match.Optional(Object)\n check limit, Match.Optional(Number)\n check unknown_arg, Match.Any\n unless Houston._user_is_admin @userId\n @ready()\n return\n try\n collection.find(filter, sort: sort, limit: limit)\n catch e\n console.log e", "response": "collection.find().observe\n _suppress_initial: true # fixes houston for large initial datasets\n added: (document) ->\n Houston._collections.collections.update {name},\n $inc: {count: 1},\n $addToSet: fields: $each: Houston._get_fields([document])\n changed: (document) ->\n Houston._collections.collections.update {name},\n $addToSet: fields: $each: Houston._get_fields([document])\n removed: (document) -> Houston._collections.collections.update {name}, {$inc: {count: -1}}\n\n fields = Houston._get_fields_from_collection(collection)\n c = Houston._collections.collections.findOne {name}\n count = collection.find().count()\n if c\n Houston._collections.collections.update c._id, {$set: {count, fields}}\n else\n Houston._collections.collections.insert {name, count, fields}\n ADDED_COLLECTIONS[name] = collection", "source_lang": "CoffeeScript", "target_lang": "CoffeeScript", "repo": "gterrono/houston", "path": "server/publications.coffee", "license": "MIT", "commit": "b9e66f6adc9e835faa3d14c77409147d1393dabc", "stars": 802, "source_url": "https://github.com/gterrono/houston/blob/b9e66f6adc9e835faa3d14c77409147d1393dabc/server/publications.coffee", "line_start": 9, "line_end": 46}713{"id": "gterrono/houston:server/publications.coffee:2:raw_corpus", "type": "raw_corpus", "prompt": "", "response": "Houston._setup_collection = (collection) ->\n name = collection._name\n return if name of ADDED_COLLECTIONS\n\n console.log(name)\n Houston._setup_collection_methods(collection)\n\n Houston._publish name, (sort, filter, limit, unknown_arg) ->\n check sort, Match.Optional(Object)\n check filter, Match.Optional(Object)\n check limit, Match.Optional(Number)\n check unknown_arg, Match.Any\n unless Houston._user_is_admin @userId\n @ready()\n return\n try\n collection.find(filter, sort: sort, limit: limit)\n catch e\n console.log e\n\n collection.find().observe\n _suppress_initial: true # fixes houston for large initial datasets\n added: (document) ->\n Houston._collections.collections.update {name},\n $inc: {count: 1},\n $addToSet: fields: $each: Houston._get_fields([document])\n changed: (document) ->\n Houston._collections.collections.update {name},\n $addToSet: fields: $each: Houston._get_fields([document])\n removed: (document) -> Houston._collections.collections.update {name}, {$inc: {count: -1}}\n\n fields = Houston._get_fields_from_collection(collection)\n c = Houston._collections.collections.findOne {name}\n count = collection.find().count()\n if c\n Houston._collections.collections.update c._id, {$set: {count, fields}}\n else\n Houston._collections.collections.insert {name, count, fields}\n ADDED_COLLECTIONS[name] = collection", "source_lang": "", "target_lang": "CoffeeScript", "repo": "gterrono/houston", "path": "server/publications.coffee", "license": "MIT", "commit": "64a267beba7d744420fae3663cff272f38247bc7", "stars": 802, "source_url": "https://github.com/gterrono/houston/blob/64a267beba7d744420fae3663cff272f38247bc7/server/publications.coffee", "line_start": 9, "line_end": 47}714{"id": "gterrono/houston:server/publications.coffee:2:coffee_to_js", "type": "coffee_to_js", "prompt": "Convert this CoffeeScript to JavaScript.\n```coffeescript\nHouston._setup_collection = (collection) ->\n name = collection._name\n return if name of ADDED_COLLECTIONS\n\n console.log(name)\n Houston._setup_collection_methods(collection)\n\n Houston._publish name, (sort, filter, limit, unknown_arg) ->\n check sort, Match.Optional(Object)\n check filter, Match.Optional(Object)\n check limit, Match.Optional(Number)\n check unknown_arg, Match.Any\n unless Houston._user_is_admin @userId\n @ready()\n return\n try\n collection.find(filter, sort: sort, limit: limit)\n catch e\n console.log e\n\n collection.find().observe\n _suppress_initial: true # fixes houston for large initial datasets\n added: (document) ->\n Houston._collections.collections.update {name},\n $inc: {count: 1},\n $addToSet: fields: $each: Houston._get_fields([document])\n changed: (document) ->\n Houston._collections.collections.update {name},\n $addToSet: fields: $each: Houston._get_fields([document])\n removed: (document) -> Houston._collections.collections.update {name}, {$inc: {count: -1}}\n\n fields = Houston._get_fields_from_collection(collection)\n c = Houston._collections.collections.findOne {name}\n count = collection.find().count()\n if c\n Houston._collections.collections.update c._id, {$set: {count, fields}}\n else\n Houston._collections.collections.insert {name, count, fields}\n ADDED_COLLECTIONS[name] = collection\n```", "response": "Houston._setup_collection = function(collection) {\n var c, count, fields, name;\n name = collection._name;\n if (name in ADDED_COLLECTIONS) {\n return;\n }\n console.log(name);\n Houston._setup_collection_methods(collection);\n Houston._publish(name, function(sort, filter, limit, unknown_arg) {\n var e;\n check(sort, Match.Optional(Object));\n check(filter, Match.Optional(Object));\n check(limit, Match.Optional(Number));\n check(unknown_arg, Match.Any);\n if (!Houston._user_is_admin(this.userId)) {\n this.ready();\n return;\n }\n try {\n return collection.find(filter, {\n sort: sort,\n limit: limit\n });\n } catch (error) {\n e = error;\n return console.log(e);\n }\n });\n collection.find().observe({\n _suppress_initial: true, // fixes houston for large initial datasets\n added: function(document) {\n return Houston._collections.collections.update({name}, {\n $inc: {\n count: 1\n },\n $addToSet: {\n fields: {\n $each: Houston._get_fields([document])\n }\n }\n });\n },\n changed: function(document) {\n return Houston._collections.collections.update({name}, {\n $addToSet: {\n fields: {\n $each: Houston._get_fields([document])\n }\n }\n });\n },\n removed: function(document) {\n return Houston._collections.collections.update({name}, {\n $inc: {\n count: -1\n }\n });\n }\n });\n fields = Houston._get_fields_from_collection(collection);\n c = Houston._collections.collections.findOne({name});\n count = collection.find().count();\n if (c) {\n Houston._collections.collections.update(c._id, {\n $set: {count, fields}\n });\n } else {\n Houston._collections.collections.insert({name, count, fields});\n }\n return ADDED_COLLECTIONS[name] = collection;\n};", "source_lang": "CoffeeScript", "target_lang": "JavaScript", "repo": "gterrono/houston", "path": "server/publications.coffee", "license": "MIT", "commit": "64a267beba7d744420fae3663cff272f38247bc7", "stars": 802, "source_url": "https://github.com/gterrono/houston/blob/64a267beba7d744420fae3663cff272f38247bc7/server/publications.coffee", "line_start": 9, "line_end": 47}715{"id": "gterrono/houston:server/publications.coffee:2:js_to_coffee", "type": "js_to_coffee", "prompt": "Convert this JavaScript to CoffeeScript.\n```javascript\nHouston._setup_collection = function(collection) {\n var c, count, fields, name;\n name = collection._name;\n if (name in ADDED_COLLECTIONS) {\n return;\n }\n console.log(name);\n Houston._setup_collection_methods(collection);\n Houston._publish(name, function(sort, filter, limit, unknown_arg) {\n var e;\n check(sort, Match.Optional(Object));\n check(filter, Match.Optional(Object));\n check(limit, Match.Optional(Number));\n check(unknown_arg, Match.Any);\n if (!Houston._user_is_admin(this.userId)) {\n this.ready();\n return;\n }\n try {\n return collection.find(filter, {\n sort: sort,\n limit: limit\n });\n } catch (error) {\n e = error;\n return console.log(e);\n }\n });\n collection.find().observe({\n _suppress_initial: true, // fixes houston for large initial datasets\n added: function(document) {\n return Houston._collections.collections.update({name}, {\n $inc: {\n count: 1\n },\n $addToSet: {\n fields: {\n $each: Houston._get_fields([document])\n }\n }\n });\n },\n changed: function(document) {\n return Houston._collections.collections.update({name}, {\n $addToSet: {\n fields: {\n $each: Houston._get_fields([document])\n }\n }\n });\n },\n removed: function(document) {\n return Houston._collections.collections.update({name}, {\n $inc: {\n count: -1\n }\n });\n }\n });\n fields = Houston._get_fields_from_collection(collection);\n c = Houston._collections.collections.findOne({name});\n count = collection.find().count();\n if (c) {\n Houston._collections.collections.update(c._id, {\n $set: {count, fields}\n });\n } else {\n Houston._collections.collections.insert({name, count, fields});\n }\n return ADDED_COLLECTIONS[name] = collection;\n};\n```", "response": "Houston._setup_collection = (collection) ->\n name = collection._name\n return if name of ADDED_COLLECTIONS\n\n console.log(name)\n Houston._setup_collection_methods(collection)\n\n Houston._publish name, (sort, filter, limit, unknown_arg) ->\n check sort, Match.Optional(Object)\n check filter, Match.Optional(Object)\n check limit, Match.Optional(Number)\n check unknown_arg, Match.Any\n unless Houston._user_is_admin @userId\n @ready()\n return\n try\n collection.find(filter, sort: sort, limit: limit)\n catch e\n console.log e\n\n collection.find().observe\n _suppress_initial: true # fixes houston for large initial datasets\n added: (document) ->\n Houston._collections.collections.update {name},\n $inc: {count: 1},\n $addToSet: fields: $each: Houston._get_fields([document])\n changed: (document) ->\n Houston._collections.collections.update {name},\n $addToSet: fields: $each: Houston._get_fields([document])\n removed: (document) -> Houston._collections.collections.update {name}, {$inc: {count: -1}}\n\n fields = Houston._get_fields_from_collection(collection)\n c = Houston._collections.collections.findOne {name}\n count = collection.find().count()\n if c\n Houston._collections.collections.update c._id, {$set: {count, fields}}\n else\n Houston._collections.collections.insert {name, count, fields}\n ADDED_COLLECTIONS[name] = collection", "source_lang": "JavaScript", "target_lang": "CoffeeScript", "repo": "gterrono/houston", "path": "server/publications.coffee", "license": "MIT", "commit": "64a267beba7d744420fae3663cff272f38247bc7", "stars": 802, "source_url": "https://github.com/gterrono/houston/blob/64a267beba7d744420fae3663cff272f38247bc7/server/publications.coffee", "line_start": 9, "line_end": 47}716{"id": "gterrono/houston:server/publications.coffee:2:completion", "type": "completion", "prompt": "Houston._setup_collection = (collection) ->\n name = collection._name\n return if name of ADDED_COLLECTIONS\n\n console.log(name)\n Houston._setup_collection_methods(collection)\n\n Houston._publish name, (sort, filter, limit, unknown_arg) ->\n check sort, Match.Optional(Object)\n check filter, Match.Optional(Object)\n check limit, Match.Optional(Number)\n check unknown_arg, Match.Any\n unless Houston._user_is_admin @userId\n @ready()\n return\n try\n collection.find(filter, sort: sort, limit: limit)\n catch e\n console.log e", "response": "collection.find().observe\n _suppress_initial: true # fixes houston for large initial datasets\n added: (document) ->\n Houston._collections.collections.update {name},\n $inc: {count: 1},\n $addToSet: fields: $each: Houston._get_fields([document])\n changed: (document) ->\n Houston._collections.collections.update {name},\n $addToSet: fields: $each: Houston._get_fields([document])\n removed: (document) -> Houston._collections.collections.update {name}, {$inc: {count: -1}}\n\n fields = Houston._get_fields_from_collection(collection)\n c = Houston._collections.collections.findOne {name}\n count = collection.find().count()\n if c\n Houston._collections.collections.update c._id, {$set: {count, fields}}\n else\n Houston._collections.collections.insert {name, count, fields}\n ADDED_COLLECTIONS[name] = collection", "source_lang": "CoffeeScript", "target_lang": "CoffeeScript", "repo": "gterrono/houston", "path": "server/publications.coffee", "license": "MIT", "commit": "64a267beba7d744420fae3663cff272f38247bc7", "stars": 802, "source_url": "https://github.com/gterrono/houston/blob/64a267beba7d744420fae3663cff272f38247bc7/server/publications.coffee", "line_start": 9, "line_end": 47}717{"id": "gterrono/houston:server/publications.coffee:3:raw_corpus", "type": "raw_corpus", "prompt": "", "response": "sync_collections = ->\n Houston._admins.findOne()\n\n _sync_collections = (meh, collections_db) ->\n collection_names = (col.collectionName for col in collections_db \\\n when (col.collectionName.indexOf \"system.\") isnt 0 and\n (col.collectionName.indexOf \"houston_\") isnt 0)\n\n collection_names.forEach (name) ->\n unless name of ADDED_COLLECTIONS or name of Houston._HIDDEN_COLLECTIONS\n new_collection = null\n try\n new_collection = new Meteor.Collection(name)\n catch e\n for key, value of root\n if name == value?._name # TODO here - typecheck also?\n new_collection = value\n\n if new_collection? # found it!\n Houston._setup_collection(new_collection)\n else\n console.log \"\"\"\nHouston: couldn't find access to the #{name} collection.\nIf you'd like to access the collection from Houston, either\n(1) make sure it is available as a global (top-level namespace) within the server or\n(2) add the collection manually via Houston.add_collection\n\"\"\"\n\n bound_sync_collections = Meteor.bindEnvironment _sync_collections, (e) ->\n console.log \"Failed while syncing collections for reason: #{e}\"\n\n # MongoInternals is the 'right' solution as of 0.6.5\n mongo_driver = MongoInternals?.defaultRemoteCollectionDriver() or Meteor._RemoteCollectionDriver\n mongo_driver.mongo.db.collections bound_sync_collections\n\nMeteor.methods\n _houston_make_admin: (user_id) ->\n check user_id, String\n # limit one admin\n return if Houston._admins.findOne {'user_id': $exists: true}\n Houston._admins.insert {user_id}\n sync_collections() # reloads collections in case of new app\n return true\n\n# publish our analysis of the app's collections\nHouston._publish 'collections', ->\n unless Houston._user_is_admin @userId\n @ready()\n return\n Houston._collections.collections.find()", "source_lang": "", "target_lang": "CoffeeScript", "repo": "gterrono/houston", "path": "server/publications.coffee", "license": "MIT", "commit": "beb31b46dbf5811b883e4ff25270b73ea67bbfa8", "stars": 802, "source_url": "https://github.com/gterrono/houston/blob/beb31b46dbf5811b883e4ff25270b73ea67bbfa8/server/publications.coffee", "line_start": 48, "line_end": 97}718{"id": "gterrono/houston:server/publications.coffee:3:coffee_to_js", "type": "coffee_to_js", "prompt": "Convert this CoffeeScript to JavaScript.\n```coffeescript\nsync_collections = ->\n Houston._admins.findOne()\n\n _sync_collections = (meh, collections_db) ->\n collection_names = (col.collectionName for col in collections_db \\\n when (col.collectionName.indexOf \"system.\") isnt 0 and\n (col.collectionName.indexOf \"houston_\") isnt 0)\n\n collection_names.forEach (name) ->\n unless name of ADDED_COLLECTIONS or name of Houston._HIDDEN_COLLECTIONS\n new_collection = null\n try\n new_collection = new Meteor.Collection(name)\n catch e\n for key, value of root\n if name == value?._name # TODO here - typecheck also?\n new_collection = value\n\n if new_collection? # found it!\n Houston._setup_collection(new_collection)\n else\n console.log \"\"\"\nHouston: couldn't find access to the #{name} collection.\nIf you'd like to access the collection from Houston, either\n(1) make sure it is available as a global (top-level namespace) within the server or\n(2) add the collection manually via Houston.add_collection\n\"\"\"\n\n bound_sync_collections = Meteor.bindEnvironment _sync_collections, (e) ->\n console.log \"Failed while syncing collections for reason: #{e}\"\n\n # MongoInternals is the 'right' solution as of 0.6.5\n mongo_driver = MongoInternals?.defaultRemoteCollectionDriver() or Meteor._RemoteCollectionDriver\n mongo_driver.mongo.db.collections bound_sync_collections\n\nMeteor.methods\n _houston_make_admin: (user_id) ->\n check user_id, String\n # limit one admin\n return if Houston._admins.findOne {'user_id': $exists: true}\n Houston._admins.insert {user_id}\n sync_collections() # reloads collections in case of new app\n return true\n\n# publish our analysis of the app's collections\nHouston._publish 'collections', ->\n unless Houston._user_is_admin @userId\n @ready()\n return\n Houston._collections.collections.find()\n```", "response": "var sync_collections;\n\nsync_collections = function() {\n var _sync_collections, bound_sync_collections, mongo_driver;\n Houston._admins.findOne();\n _sync_collections = function(meh, collections_db) {\n var col, collection_names;\n collection_names = (function() {\n var i, len, results;\n results = [];\n for (i = 0, len = collections_db.length; i < len; i++) {\n col = collections_db[i];\n if ((col.collectionName.indexOf(\"system.\")) !== 0 && (col.collectionName.indexOf(\"houston_\")) !== 0) {\n results.push(col.collectionName);\n }\n }\n return results;\n })();\n return collection_names.forEach(function(name) {\n var e, key, new_collection, value;\n if (!(name in ADDED_COLLECTIONS || name in Houston._HIDDEN_COLLECTIONS)) {\n new_collection = null;\n try {\n new_collection = new Meteor.Collection(name);\n } catch (error) {\n e = error;\n for (key in root) {\n value = root[key];\n if (name === (value != null ? value._name : void 0)) { // TODO here - typecheck also?\n new_collection = value;\n }\n }\n }\n if (new_collection != null) {\n return Houston._setup_collection(new_collection);\n } else {\n return console.log(`Houston: couldn't find access to the ${name} collection.\nIf you'd like to access the collection from Houston, either\n(1) make sure it is available as a global (top-level namespace) within the server or\n(2) add the collection manually via Houston.add_collection`); // found it!\n }\n }\n });\n };\n bound_sync_collections = Meteor.bindEnvironment(_sync_collections, function(e) {\n return console.log(`Failed while syncing collections for reason: ${e}`);\n });\n // MongoInternals is the 'right' solution as of 0.6.5\n mongo_driver = (typeof MongoInternals !== \"undefined\" && MongoInternals !== null ? MongoInternals.defaultRemoteCollectionDriver() : void 0) || Meteor._RemoteCollectionDriver;\n return mongo_driver.mongo.db.collections(bound_sync_collections);\n};\n\nMeteor.methods({\n _houston_make_admin: function(user_id) {\n check(user_id, String);\n // limit one admin\n if (Houston._admins.findOne({\n 'user_id': {\n $exists: true\n }\n })) {\n return;\n }\n Houston._admins.insert({user_id});\n sync_collections(); // reloads collections in case of new app\n return true;\n }\n});\n\n// publish our analysis of the app's collections\nHouston._publish('collections', function() {\n if (!Houston._user_is_admin(this.userId)) {\n this.ready();\n return;\n }\n return Houston._collections.collections.find();\n});", "source_lang": "CoffeeScript", "target_lang": "JavaScript", "repo": "gterrono/houston", "path": "server/publications.coffee", "license": "MIT", "commit": "beb31b46dbf5811b883e4ff25270b73ea67bbfa8", "stars": 802, "source_url": "https://github.com/gterrono/houston/blob/beb31b46dbf5811b883e4ff25270b73ea67bbfa8/server/publications.coffee", "line_start": 48, "line_end": 97}719{"id": "gterrono/houston:server/publications.coffee:3:js_to_coffee", "type": "js_to_coffee", "prompt": "Convert this JavaScript to CoffeeScript.\n```javascript\nvar sync_collections;\n\nsync_collections = function() {\n var _sync_collections, bound_sync_collections, mongo_driver;\n Houston._admins.findOne();\n _sync_collections = function(meh, collections_db) {\n var col, collection_names;\n collection_names = (function() {\n var i, len, results;\n results = [];\n for (i = 0, len = collections_db.length; i < len; i++) {\n col = collections_db[i];\n if ((col.collectionName.indexOf(\"system.\")) !== 0 && (col.collectionName.indexOf(\"houston_\")) !== 0) {\n results.push(col.collectionName);\n }\n }\n return results;\n })();\n return collection_names.forEach(function(name) {\n var e, key, new_collection, value;\n if (!(name in ADDED_COLLECTIONS || name in Houston._HIDDEN_COLLECTIONS)) {\n new_collection = null;\n try {\n new_collection = new Meteor.Collection(name);\n } catch (error) {\n e = error;\n for (key in root) {\n value = root[key];\n if (name === (value != null ? value._name : void 0)) { // TODO here - typecheck also?\n new_collection = value;\n }\n }\n }\n if (new_collection != null) {\n return Houston._setup_collection(new_collection);\n } else {\n return console.log(`Houston: couldn't find access to the ${name} collection.\nIf you'd like to access the collection from Houston, either\n(1) make sure it is available as a global (top-level namespace) within the server or\n(2) add the collection manually via Houston.add_collection`); // found it!\n }\n }\n });\n };\n bound_sync_collections = Meteor.bindEnvironment(_sync_collections, function(e) {\n return console.log(`Failed while syncing collections for reason: ${e}`);\n });\n // MongoInternals is the 'right' solution as of 0.6.5\n mongo_driver = (typeof MongoInternals !== \"undefined\" && MongoInternals !== null ? MongoInternals.defaultRemoteCollectionDriver() : void 0) || Meteor._RemoteCollectionDriver;\n return mongo_driver.mongo.db.collections(bound_sync_collections);\n};\n\nMeteor.methods({\n _houston_make_admin: function(user_id) {\n check(user_id, String);\n // limit one admin\n if (Houston._admins.findOne({\n 'user_id': {\n $exists: true\n }\n })) {\n return;\n }\n Houston._admins.insert({user_id});\n sync_collections(); // reloads collections in case of new app\n return true;\n }\n});\n\n// publish our analysis of the app's collections\nHouston._publish('collections', function() {\n if (!Houston._user_is_admin(this.userId)) {\n this.ready();\n return;\n }\n return Houston._collections.collections.find();\n});\n```", "response": "sync_collections = ->\n Houston._admins.findOne()\n\n _sync_collections = (meh, collections_db) ->\n collection_names = (col.collectionName for col in collections_db \\\n when (col.collectionName.indexOf \"system.\") isnt 0 and\n (col.collectionName.indexOf \"houston_\") isnt 0)\n\n collection_names.forEach (name) ->\n unless name of ADDED_COLLECTIONS or name of Houston._HIDDEN_COLLECTIONS\n new_collection = null\n try\n new_collection = new Meteor.Collection(name)\n catch e\n for key, value of root\n if name == value?._name # TODO here - typecheck also?\n new_collection = value\n\n if new_collection? # found it!\n Houston._setup_collection(new_collection)\n else\n console.log \"\"\"\nHouston: couldn't find access to the #{name} collection.\nIf you'd like to access the collection from Houston, either\n(1) make sure it is available as a global (top-level namespace) within the server or\n(2) add the collection manually via Houston.add_collection\n\"\"\"\n\n bound_sync_collections = Meteor.bindEnvironment _sync_collections, (e) ->\n console.log \"Failed while syncing collections for reason: #{e}\"\n\n # MongoInternals is the 'right' solution as of 0.6.5\n mongo_driver = MongoInternals?.defaultRemoteCollectionDriver() or Meteor._RemoteCollectionDriver\n mongo_driver.mongo.db.collections bound_sync_collections\n\nMeteor.methods\n _houston_make_admin: (user_id) ->\n check user_id, String\n # limit one admin\n return if Houston._admins.findOne {'user_id': $exists: true}\n Houston._admins.insert {user_id}\n sync_collections() # reloads collections in case of new app\n return true\n\n# publish our analysis of the app's collections\nHouston._publish 'collections', ->\n unless Houston._user_is_admin @userId\n @ready()\n return\n Houston._collections.collections.find()", "source_lang": "JavaScript", "target_lang": "CoffeeScript", "repo": "gterrono/houston", "path": "server/publications.coffee", "license": "MIT", "commit": "beb31b46dbf5811b883e4ff25270b73ea67bbfa8", "stars": 802, "source_url": "https://github.com/gterrono/houston/blob/beb31b46dbf5811b883e4ff25270b73ea67bbfa8/server/publications.coffee", "line_start": 48, "line_end": 97}720{"id": "gterrono/houston:server/publications.coffee:3:completion", "type": "completion", "prompt": "sync_collections = ->\n Houston._admins.findOne()\n\n _sync_collections = (meh, collections_db) ->\n collection_names = (col.collectionName for col in collections_db \\\n when (col.collectionName.indexOf \"system.\") isnt 0 and\n (col.collectionName.indexOf \"houston_\") isnt 0)\n\n collection_names.forEach (name) ->\n unless name of ADDED_COLLECTIONS or name of Houston._HIDDEN_COLLECTIONS\n new_collection = null\n try\n new_collection = new Meteor.Collection(name)\n catch e\n for key, value of root\n if name == value?._name # TODO here - typecheck also?\n new_collection = value\n\n if new_collection? # found it!\n Houston._setup_collection(new_collection)\n else\n console.log \"\"\"\nHouston: couldn't find access to the #{name} collection.\nIf you'd like to access the collection from Houston, either\n(1) make sure it is available as a global (top-level namespace) within the server or", "response": "(2) add the collection manually via Houston.add_collection\n\"\"\"\n\n bound_sync_collections = Meteor.bindEnvironment _sync_collections, (e) ->\n console.log \"Failed while syncing collections for reason: #{e}\"\n\n # MongoInternals is the 'right' solution as of 0.6.5\n mongo_driver = MongoInternals?.defaultRemoteCollectionDriver() or Meteor._RemoteCollectionDriver\n mongo_driver.mongo.db.collections bound_sync_collections\n\nMeteor.methods\n _houston_make_admin: (user_id) ->\n check user_id, String\n # limit one admin\n return if Houston._admins.findOne {'user_id': $exists: true}\n Houston._admins.insert {user_id}\n sync_collections() # reloads collections in case of new app\n return true\n\n# publish our analysis of the app's collections\nHouston._publish 'collections', ->\n unless Houston._user_is_admin @userId\n @ready()\n return\n Houston._collections.collections.find()", "source_lang": "CoffeeScript", "target_lang": "CoffeeScript", "repo": "gterrono/houston", "path": "server/publications.coffee", "license": "MIT", "commit": "beb31b46dbf5811b883e4ff25270b73ea67bbfa8", "stars": 802, "source_url": "https://github.com/gterrono/houston/blob/beb31b46dbf5811b883e4ff25270b73ea67bbfa8/server/publications.coffee", "line_start": 48, "line_end": 97}721{"id": "gterrono/houston:server/publications.coffee:4:raw_corpus", "type": "raw_corpus", "prompt": "", "response": "# TODO address inherent security issue\nHouston._publish 'admin_user', ->\n Houston._admins.find {}\n\nMeteor.startup ->\n sync_collections()", "source_lang": "", "target_lang": "CoffeeScript", "repo": "gterrono/houston", "path": "server/publications.coffee", "license": "MIT", "commit": "beb31b46dbf5811b883e4ff25270b73ea67bbfa8", "stars": 802, "source_url": "https://github.com/gterrono/houston/blob/beb31b46dbf5811b883e4ff25270b73ea67bbfa8/server/publications.coffee", "line_start": 98, "line_end": 104}722{"id": "gterrono/houston:server/publications.coffee:4:coffee_to_js", "type": "coffee_to_js", "prompt": "Convert this CoffeeScript to JavaScript.\n```coffeescript\n# TODO address inherent security issue\nHouston._publish 'admin_user', ->\n Houston._admins.find {}\n\nMeteor.startup ->\n sync_collections()\n```", "response": "// TODO address inherent security issue\nHouston._publish('admin_user', function() {\n return Houston._admins.find({});\n});\n\nMeteor.startup(function() {\n return sync_collections();\n});", "source_lang": "CoffeeScript", "target_lang": "JavaScript", "repo": "gterrono/houston", "path": "server/publications.coffee", "license": "MIT", "commit": "beb31b46dbf5811b883e4ff25270b73ea67bbfa8", "stars": 802, "source_url": "https://github.com/gterrono/houston/blob/beb31b46dbf5811b883e4ff25270b73ea67bbfa8/server/publications.coffee", "line_start": 98, "line_end": 104}723{"id": "gterrono/houston:server/publications.coffee:4:js_to_coffee", "type": "js_to_coffee", "prompt": "Convert this JavaScript to CoffeeScript.\n```javascript\n// TODO address inherent security issue\nHouston._publish('admin_user', function() {\n return Houston._admins.find({});\n});\n\nMeteor.startup(function() {\n return sync_collections();\n});\n```", "response": "# TODO address inherent security issue\nHouston._publish 'admin_user', ->\n Houston._admins.find {}\n\nMeteor.startup ->\n sync_collections()", "source_lang": "JavaScript", "target_lang": "CoffeeScript", "repo": "gterrono/houston", "path": "server/publications.coffee", "license": "MIT", "commit": "beb31b46dbf5811b883e4ff25270b73ea67bbfa8", "stars": 802, "source_url": "https://github.com/gterrono/houston/blob/beb31b46dbf5811b883e4ff25270b73ea67bbfa8/server/publications.coffee", "line_start": 98, "line_end": 104}724{"id": "gterrono/houston:server/publications.coffee:4:completion", "type": "completion", "prompt": "# TODO address inherent security issue\nHouston._publish 'admin_user', ->\n Houston._admins.find {}", "response": "Meteor.startup ->\n sync_collections()", "source_lang": "CoffeeScript", "target_lang": "CoffeeScript", "repo": "gterrono/houston", "path": "server/publications.coffee", "license": "MIT", "commit": "beb31b46dbf5811b883e4ff25270b73ea67bbfa8", "stars": 802, "source_url": "https://github.com/gterrono/houston/blob/beb31b46dbf5811b883e4ff25270b73ea67bbfa8/server/publications.coffee", "line_start": 98, "line_end": 104}725{"id": "gterrono/houston:server/publications.coffee:2:raw_corpus", "type": "raw_corpus", "prompt": "", "response": "Houston._setup_collection = (collection) ->\n name = collection._name\n return if name of ADDED_COLLECTIONS\n\n Houston._setup_collection_methods(collection)\n\n Houston._publish name, (sort, filter, limit, unknown_arg) ->\n check sort, Match.Optional(Object)\n check filter, Match.Optional(Object)\n check limit, Match.Optional(Number)\n check unknown_arg, Match.Any\n unless Houston._user_is_admin @userId\n @ready()\n return\n try\n collection.find(filter, sort: sort, limit: limit)\n catch e\n console.log e\n\n collection.find().observe\n _suppress_initial: true # fixes houston for large initial datasets\n added: (document) ->\n Houston._collections.collections.update {name},\n $inc: {count: 1},\n $addToSet: fields: $each: Houston._get_fields([document])\n removed: (document) -> Houston._collections.collections.update {name}, {$inc: {count: -1}}\n\n fields = Houston._get_fields_from_collection(collection)\n c = Houston._collections.collections.findOne {name}\n count = collection.find().count()\n if c\n Houston._collections.collections.update c._id, {$set: {count, fields}}\n else\n Houston._collections.collections.insert {name, count, fields}\n ADDED_COLLECTIONS[name] = collection", "source_lang": "", "target_lang": "CoffeeScript", "repo": "gterrono/houston", "path": "server/publications.coffee", "license": "MIT", "commit": "2183bc16871b6de4df0dbe0c6ab1eb09be6e531a", "stars": 802, "source_url": "https://github.com/gterrono/houston/blob/2183bc16871b6de4df0dbe0c6ab1eb09be6e531a/server/publications.coffee", "line_start": 9, "line_end": 43}726{"id": "gterrono/houston:server/publications.coffee:2:coffee_to_js", "type": "coffee_to_js", "prompt": "Convert this CoffeeScript to JavaScript.\n```coffeescript\nHouston._setup_collection = (collection) ->\n name = collection._name\n return if name of ADDED_COLLECTIONS\n\n Houston._setup_collection_methods(collection)\n\n Houston._publish name, (sort, filter, limit, unknown_arg) ->\n check sort, Match.Optional(Object)\n check filter, Match.Optional(Object)\n check limit, Match.Optional(Number)\n check unknown_arg, Match.Any\n unless Houston._user_is_admin @userId\n @ready()\n return\n try\n collection.find(filter, sort: sort, limit: limit)\n catch e\n console.log e\n\n collection.find().observe\n _suppress_initial: true # fixes houston for large initial datasets\n added: (document) ->\n Houston._collections.collections.update {name},\n $inc: {count: 1},\n $addToSet: fields: $each: Houston._get_fields([document])\n removed: (document) -> Houston._collections.collections.update {name}, {$inc: {count: -1}}\n\n fields = Houston._get_fields_from_collection(collection)\n c = Houston._collections.collections.findOne {name}\n count = collection.find().count()\n if c\n Houston._collections.collections.update c._id, {$set: {count, fields}}\n else\n Houston._collections.collections.insert {name, count, fields}\n ADDED_COLLECTIONS[name] = collection\n```", "response": "Houston._setup_collection = function(collection) {\n var c, count, fields, name;\n name = collection._name;\n if (name in ADDED_COLLECTIONS) {\n return;\n }\n Houston._setup_collection_methods(collection);\n Houston._publish(name, function(sort, filter, limit, unknown_arg) {\n var e;\n check(sort, Match.Optional(Object));\n check(filter, Match.Optional(Object));\n check(limit, Match.Optional(Number));\n check(unknown_arg, Match.Any);\n if (!Houston._user_is_admin(this.userId)) {\n this.ready();\n return;\n }\n try {\n return collection.find(filter, {\n sort: sort,\n limit: limit\n });\n } catch (error) {\n e = error;\n return console.log(e);\n }\n });\n collection.find().observe({\n _suppress_initial: true, // fixes houston for large initial datasets\n added: function(document) {\n return Houston._collections.collections.update({name}, {\n $inc: {\n count: 1\n },\n $addToSet: {\n fields: {\n $each: Houston._get_fields([document])\n }\n }\n });\n },\n removed: function(document) {\n return Houston._collections.collections.update({name}, {\n $inc: {\n count: -1\n }\n });\n }\n });\n fields = Houston._get_fields_from_collection(collection);\n c = Houston._collections.collections.findOne({name});\n count = collection.find().count();\n if (c) {\n Houston._collections.collections.update(c._id, {\n $set: {count, fields}\n });\n } else {\n Houston._collections.collections.insert({name, count, fields});\n }\n return ADDED_COLLECTIONS[name] = collection;\n};", "source_lang": "CoffeeScript", "target_lang": "JavaScript", "repo": "gterrono/houston", "path": "server/publications.coffee", "license": "MIT", "commit": "2183bc16871b6de4df0dbe0c6ab1eb09be6e531a", "stars": 802, "source_url": "https://github.com/gterrono/houston/blob/2183bc16871b6de4df0dbe0c6ab1eb09be6e531a/server/publications.coffee", "line_start": 9, "line_end": 43}727{"id": "gterrono/houston:server/publications.coffee:2:js_to_coffee", "type": "js_to_coffee", "prompt": "Convert this JavaScript to CoffeeScript.\n```javascript\nHouston._setup_collection = function(collection) {\n var c, count, fields, name;\n name = collection._name;\n if (name in ADDED_COLLECTIONS) {\n return;\n }\n Houston._setup_collection_methods(collection);\n Houston._publish(name, function(sort, filter, limit, unknown_arg) {\n var e;\n check(sort, Match.Optional(Object));\n check(filter, Match.Optional(Object));\n check(limit, Match.Optional(Number));\n check(unknown_arg, Match.Any);\n if (!Houston._user_is_admin(this.userId)) {\n this.ready();\n return;\n }\n try {\n return collection.find(filter, {\n sort: sort,\n limit: limit\n });\n } catch (error) {\n e = error;\n return console.log(e);\n }\n });\n collection.find().observe({\n _suppress_initial: true, // fixes houston for large initial datasets\n added: function(document) {\n return Houston._collections.collections.update({name}, {\n $inc: {\n count: 1\n },\n $addToSet: {\n fields: {\n $each: Houston._get_fields([document])\n }\n }\n });\n },\n removed: function(document) {\n return Houston._collections.collections.update({name}, {\n $inc: {\n count: -1\n }\n });\n }\n });\n fields = Houston._get_fields_from_collection(collection);\n c = Houston._collections.collections.findOne({name});\n count = collection.find().count();\n if (c) {\n Houston._collections.collections.update(c._id, {\n $set: {count, fields}\n });\n } else {\n Houston._collections.collections.insert({name, count, fields});\n }\n return ADDED_COLLECTIONS[name] = collection;\n};\n```", "response": "Houston._setup_collection = (collection) ->\n name = collection._name\n return if name of ADDED_COLLECTIONS\n\n Houston._setup_collection_methods(collection)\n\n Houston._publish name, (sort, filter, limit, unknown_arg) ->\n check sort, Match.Optional(Object)\n check filter, Match.Optional(Object)\n check limit, Match.Optional(Number)\n check unknown_arg, Match.Any\n unless Houston._user_is_admin @userId\n @ready()\n return\n try\n collection.find(filter, sort: sort, limit: limit)\n catch e\n console.log e\n\n collection.find().observe\n _suppress_initial: true # fixes houston for large initial datasets\n added: (document) ->\n Houston._collections.collections.update {name},\n $inc: {count: 1},\n $addToSet: fields: $each: Houston._get_fields([document])\n removed: (document) -> Houston._collections.collections.update {name}, {$inc: {count: -1}}\n\n fields = Houston._get_fields_from_collection(collection)\n c = Houston._collections.collections.findOne {name}\n count = collection.find().count()\n if c\n Houston._collections.collections.update c._id, {$set: {count, fields}}\n else\n Houston._collections.collections.insert {name, count, fields}\n ADDED_COLLECTIONS[name] = collection", "source_lang": "JavaScript", "target_lang": "CoffeeScript", "repo": "gterrono/houston", "path": "server/publications.coffee", "license": "MIT", "commit": "2183bc16871b6de4df0dbe0c6ab1eb09be6e531a", "stars": 802, "source_url": "https://github.com/gterrono/houston/blob/2183bc16871b6de4df0dbe0c6ab1eb09be6e531a/server/publications.coffee", "line_start": 9, "line_end": 43}728{"id": "gterrono/houston:server/publications.coffee:2:completion", "type": "completion", "prompt": "Houston._setup_collection = (collection) ->\n name = collection._name\n return if name of ADDED_COLLECTIONS\n\n Houston._setup_collection_methods(collection)\n\n Houston._publish name, (sort, filter, limit, unknown_arg) ->\n check sort, Match.Optional(Object)\n check filter, Match.Optional(Object)\n check limit, Match.Optional(Number)\n check unknown_arg, Match.Any\n unless Houston._user_is_admin @userId\n @ready()\n return\n try\n collection.find(filter, sort: sort, limit: limit)\n catch e", "response": "console.log e\n\n collection.find().observe\n _suppress_initial: true # fixes houston for large initial datasets\n added: (document) ->\n Houston._collections.collections.update {name},\n $inc: {count: 1},\n $addToSet: fields: $each: Houston._get_fields([document])\n removed: (document) -> Houston._collections.collections.update {name}, {$inc: {count: -1}}\n\n fields = Houston._get_fields_from_collection(collection)\n c = Houston._collections.collections.findOne {name}\n count = collection.find().count()\n if c\n Houston._collections.collections.update c._id, {$set: {count, fields}}\n else\n Houston._collections.collections.insert {name, count, fields}\n ADDED_COLLECTIONS[name] = collection", "source_lang": "CoffeeScript", "target_lang": "CoffeeScript", "repo": "gterrono/houston", "path": "server/publications.coffee", "license": "MIT", "commit": "2183bc16871b6de4df0dbe0c6ab1eb09be6e531a", "stars": 802, "source_url": "https://github.com/gterrono/houston/blob/2183bc16871b6de4df0dbe0c6ab1eb09be6e531a/server/publications.coffee", "line_start": 9, "line_end": 43}729{"id": "gterrono/houston:server/publications.coffee:2:raw_corpus", "type": "raw_corpus", "prompt": "", "response": "Houston._setup_collection = (collection) ->\n return if collection._name of ADDED_COLLECTIONS\n\n name = collection._name\n methods = {}\n methods[Houston._houstonize \"#{name}_insert\"] = (doc) ->\n check doc, Object\n return unless Houston._user_is_admin @userId\n collection.insert(doc)\n\n methods[Houston._houstonize \"#{name}_update\"] = (id, update_dict) ->\n check id, Match.Any\n check update_dict, Object\n return unless Houston._user_is_admin @userId\n if collection.findOne(id)\n collection.update(id, update_dict)\n else\n id = collection.findOne(new Meteor.Collection.ObjectID(id))\n collection.update(id, update_dict)\n\n methods[Houston._houstonize \"#{name}_delete\"] = (id) ->\n check id, Match.Any\n return unless Houston._user_is_admin @userId\n if collection.findOne(id)\n collection.remove(id)\n else\n id = collection.findOne(new Meteor.Collection.ObjectID(id))\n collection.remove(id)\n\n Meteor.methods methods\n\n Houston._publish name, (sort, filter, limit, unknown_arg) ->\n check sort, Match.Optional(Object)\n check filter, Match.Optional(Object)\n check limit, Match.Optional(Number)\n check unknown_arg, Match.Any\n return unless Houston._user_is_admin @userId\n try\n collection.find(filter, sort: sort, limit: limit)\n catch e\n console.log e\n\n collection.find().observe\n _suppress_initial: true # fixes houston for large initial datasets\n added: (document) ->\n Houston._collections.collections.update {name},\n $inc: {count: 1},\n $addToSet: fields: $each: Houston._get_fields([document])\n removed: (document) -> Houston._collections.collections.update {name}, {$inc: {count: -1}}", "source_lang": "", "target_lang": "CoffeeScript", "repo": "gterrono/houston", "path": "server/publications.coffee", "license": "MIT", "commit": "9eb40369d9b923cf0ebb33f504697ead89954ea0", "stars": 802, "source_url": "https://github.com/gterrono/houston/blob/9eb40369d9b923cf0ebb33f504697ead89954ea0/server/publications.coffee", "line_start": 9, "line_end": 58}730{"id": "gterrono/houston:server/publications.coffee:2:coffee_to_js", "type": "coffee_to_js", "prompt": "Convert this CoffeeScript to JavaScript.\n```coffeescript\nHouston._setup_collection = (collection) ->\n return if collection._name of ADDED_COLLECTIONS\n\n name = collection._name\n methods = {}\n methods[Houston._houstonize \"#{name}_insert\"] = (doc) ->\n check doc, Object\n return unless Houston._user_is_admin @userId\n collection.insert(doc)\n\n methods[Houston._houstonize \"#{name}_update\"] = (id, update_dict) ->\n check id, Match.Any\n check update_dict, Object\n return unless Houston._user_is_admin @userId\n if collection.findOne(id)\n collection.update(id, update_dict)\n else\n id = collection.findOne(new Meteor.Collection.ObjectID(id))\n collection.update(id, update_dict)\n\n methods[Houston._houstonize \"#{name}_delete\"] = (id) ->\n check id, Match.Any\n return unless Houston._user_is_admin @userId\n if collection.findOne(id)\n collection.remove(id)\n else\n id = collection.findOne(new Meteor.Collection.ObjectID(id))\n collection.remove(id)\n\n Meteor.methods methods\n\n Houston._publish name, (sort, filter, limit, unknown_arg) ->\n check sort, Match.Optional(Object)\n check filter, Match.Optional(Object)\n check limit, Match.Optional(Number)\n check unknown_arg, Match.Any\n return unless Houston._user_is_admin @userId\n try\n collection.find(filter, sort: sort, limit: limit)\n catch e\n console.log e\n\n collection.find().observe\n _suppress_initial: true # fixes houston for large initial datasets\n added: (document) ->\n Houston._collections.collections.update {name},\n $inc: {count: 1},\n $addToSet: fields: $each: Houston._get_fields([document])\n removed: (document) -> Houston._collections.collections.update {name}, {$inc: {count: -1}}\n```", "response": "Houston._setup_collection = function(collection) {\n var methods, name;\n if (collection._name in ADDED_COLLECTIONS) {\n return;\n }\n name = collection._name;\n methods = {};\n methods[Houston._houstonize(`${name}_insert`)] = function(doc) {\n check(doc, Object);\n if (!Houston._user_is_admin(this.userId)) {\n return;\n }\n return collection.insert(doc);\n };\n methods[Houston._houstonize(`${name}_update`)] = function(id, update_dict) {\n check(id, Match.Any);\n check(update_dict, Object);\n if (!Houston._user_is_admin(this.userId)) {\n return;\n }\n if (collection.findOne(id)) {\n return collection.update(id, update_dict);\n } else {\n id = collection.findOne(new Meteor.Collection.ObjectID(id));\n return collection.update(id, update_dict);\n }\n };\n methods[Houston._houstonize(`${name}_delete`)] = function(id) {\n check(id, Match.Any);\n if (!Houston._user_is_admin(this.userId)) {\n return;\n }\n if (collection.findOne(id)) {\n return collection.remove(id);\n } else {\n id = collection.findOne(new Meteor.Collection.ObjectID(id));\n return collection.remove(id);\n }\n };\n Meteor.methods(methods);\n Houston._publish(name, function(sort, filter, limit, unknown_arg) {\n var e;\n check(sort, Match.Optional(Object));\n check(filter, Match.Optional(Object));\n check(limit, Match.Optional(Number));\n check(unknown_arg, Match.Any);\n if (!Houston._user_is_admin(this.userId)) {\n return;\n }\n try {\n return collection.find(filter, {\n sort: sort,\n limit: limit\n });\n } catch (error) {\n e = error;\n return console.log(e);\n }\n });\n return collection.find().observe({\n _suppress_initial: true, // fixes houston for large initial datasets\n added: function(document) {\n return Houston._collections.collections.update({name}, {\n $inc: {\n count: 1\n },\n $addToSet: {\n fields: {\n $each: Houston._get_fields([document])\n }\n }\n });\n },\n removed: function(document) {\n return Houston._collections.collections.update({name}, {\n $inc: {\n count: -1\n }\n });\n }\n });\n};", "source_lang": "CoffeeScript", "target_lang": "JavaScript", "repo": "gterrono/houston", "path": "server/publications.coffee", "license": "MIT", "commit": "9eb40369d9b923cf0ebb33f504697ead89954ea0", "stars": 802, "source_url": "https://github.com/gterrono/houston/blob/9eb40369d9b923cf0ebb33f504697ead89954ea0/server/publications.coffee", "line_start": 9, "line_end": 58}731{"id": "gterrono/houston:server/publications.coffee:2:js_to_coffee", "type": "js_to_coffee", "prompt": "Convert this JavaScript to CoffeeScript.\n```javascript\nHouston._setup_collection = function(collection) {\n var methods, name;\n if (collection._name in ADDED_COLLECTIONS) {\n return;\n }\n name = collection._name;\n methods = {};\n methods[Houston._houstonize(`${name}_insert`)] = function(doc) {\n check(doc, Object);\n if (!Houston._user_is_admin(this.userId)) {\n return;\n }\n return collection.insert(doc);\n };\n methods[Houston._houstonize(`${name}_update`)] = function(id, update_dict) {\n check(id, Match.Any);\n check(update_dict, Object);\n if (!Houston._user_is_admin(this.userId)) {\n return;\n }\n if (collection.findOne(id)) {\n return collection.update(id, update_dict);\n } else {\n id = collection.findOne(new Meteor.Collection.ObjectID(id));\n return collection.update(id, update_dict);\n }\n };\n methods[Houston._houstonize(`${name}_delete`)] = function(id) {\n check(id, Match.Any);\n if (!Houston._user_is_admin(this.userId)) {\n return;\n }\n if (collection.findOne(id)) {\n return collection.remove(id);\n } else {\n id = collection.findOne(new Meteor.Collection.ObjectID(id));\n return collection.remove(id);\n }\n };\n Meteor.methods(methods);\n Houston._publish(name, function(sort, filter, limit, unknown_arg) {\n var e;\n check(sort, Match.Optional(Object));\n check(filter, Match.Optional(Object));\n check(limit, Match.Optional(Number));\n check(unknown_arg, Match.Any);\n if (!Houston._user_is_admin(this.userId)) {\n return;\n }\n try {\n return collection.find(filter, {\n sort: sort,\n limit: limit\n });\n } catch (error) {\n e = error;\n return console.log(e);\n }\n });\n return collection.find().observe({\n _suppress_initial: true, // fixes houston for large initial datasets\n added: function(document) {\n return Houston._collections.collections.update({name}, {\n $inc: {\n count: 1\n },\n $addToSet: {\n fields: {\n $each: Houston._get_fields([document])\n }\n }\n });\n },\n removed: function(document) {\n return Houston._collections.collections.update({name}, {\n $inc: {\n count: -1\n }\n });\n }\n });\n};\n```", "response": "Houston._setup_collection = (collection) ->\n return if collection._name of ADDED_COLLECTIONS\n\n name = collection._name\n methods = {}\n methods[Houston._houstonize \"#{name}_insert\"] = (doc) ->\n check doc, Object\n return unless Houston._user_is_admin @userId\n collection.insert(doc)\n\n methods[Houston._houstonize \"#{name}_update\"] = (id, update_dict) ->\n check id, Match.Any\n check update_dict, Object\n return unless Houston._user_is_admin @userId\n if collection.findOne(id)\n collection.update(id, update_dict)\n else\n id = collection.findOne(new Meteor.Collection.ObjectID(id))\n collection.update(id, update_dict)\n\n methods[Houston._houstonize \"#{name}_delete\"] = (id) ->\n check id, Match.Any\n return unless Houston._user_is_admin @userId\n if collection.findOne(id)\n collection.remove(id)\n else\n id = collection.findOne(new Meteor.Collection.ObjectID(id))\n collection.remove(id)\n\n Meteor.methods methods\n\n Houston._publish name, (sort, filter, limit, unknown_arg) ->\n check sort, Match.Optional(Object)\n check filter, Match.Optional(Object)\n check limit, Match.Optional(Number)\n check unknown_arg, Match.Any\n return unless Houston._user_is_admin @userId\n try\n collection.find(filter, sort: sort, limit: limit)\n catch e\n console.log e\n\n collection.find().observe\n _suppress_initial: true # fixes houston for large initial datasets\n added: (document) ->\n Houston._collections.collections.update {name},\n $inc: {count: 1},\n $addToSet: fields: $each: Houston._get_fields([document])\n removed: (document) -> Houston._collections.collections.update {name}, {$inc: {count: -1}}", "source_lang": "JavaScript", "target_lang": "CoffeeScript", "repo": "gterrono/houston", "path": "server/publications.coffee", "license": "MIT", "commit": "9eb40369d9b923cf0ebb33f504697ead89954ea0", "stars": 802, "source_url": "https://github.com/gterrono/houston/blob/9eb40369d9b923cf0ebb33f504697ead89954ea0/server/publications.coffee", "line_start": 9, "line_end": 58}732{"id": "gterrono/houston:server/publications.coffee:2:completion", "type": "completion", "prompt": "Houston._setup_collection = (collection) ->\n return if collection._name of ADDED_COLLECTIONS\n\n name = collection._name\n methods = {}\n methods[Houston._houstonize \"#{name}_insert\"] = (doc) ->\n check doc, Object\n return unless Houston._user_is_admin @userId\n collection.insert(doc)\n\n methods[Houston._houstonize \"#{name}_update\"] = (id, update_dict) ->\n check id, Match.Any\n check update_dict, Object\n return unless Houston._user_is_admin @userId\n if collection.findOne(id)\n collection.update(id, update_dict)\n else\n id = collection.findOne(new Meteor.Collection.ObjectID(id))\n collection.update(id, update_dict)\n\n methods[Houston._houstonize \"#{name}_delete\"] = (id) ->\n check id, Match.Any\n return unless Houston._user_is_admin @userId\n if collection.findOne(id)", "response": "collection.remove(id)\n else\n id = collection.findOne(new Meteor.Collection.ObjectID(id))\n collection.remove(id)\n\n Meteor.methods methods\n\n Houston._publish name, (sort, filter, limit, unknown_arg) ->\n check sort, Match.Optional(Object)\n check filter, Match.Optional(Object)\n check limit, Match.Optional(Number)\n check unknown_arg, Match.Any\n return unless Houston._user_is_admin @userId\n try\n collection.find(filter, sort: sort, limit: limit)\n catch e\n console.log e\n\n collection.find().observe\n _suppress_initial: true # fixes houston for large initial datasets\n added: (document) ->\n Houston._collections.collections.update {name},\n $inc: {count: 1},\n $addToSet: fields: $each: Houston._get_fields([document])\n removed: (document) -> Houston._collections.collections.update {name}, {$inc: {count: -1}}", "source_lang": "CoffeeScript", "target_lang": "CoffeeScript", "repo": "gterrono/houston", "path": "server/publications.coffee", "license": "MIT", "commit": "9eb40369d9b923cf0ebb33f504697ead89954ea0", "stars": 802, "source_url": "https://github.com/gterrono/houston/blob/9eb40369d9b923cf0ebb33f504697ead89954ea0/server/publications.coffee", "line_start": 9, "line_end": 58}733{"id": "gterrono/houston:server/publications.coffee:3:raw_corpus", "type": "raw_corpus", "prompt": "", "response": "fields = Houston._get_fields_from_collection(collection)\n c = Houston._collections.collections.findOne {name}\n count = collection.find().count()\n if c\n Houston._collections.collections.update c._id, {$set: {count, fields}}\n else\n Houston._collections.collections.insert {name, count, fields}\n ADDED_COLLECTIONS[name] = collection", "source_lang": "", "target_lang": "CoffeeScript", "repo": "gterrono/houston", "path": "server/publications.coffee", "license": "MIT", "commit": "9eb40369d9b923cf0ebb33f504697ead89954ea0", "stars": 802, "source_url": "https://github.com/gterrono/houston/blob/9eb40369d9b923cf0ebb33f504697ead89954ea0/server/publications.coffee", "line_start": 59, "line_end": 66}734{"id": "gterrono/houston:server/publications.coffee:3:completion", "type": "completion", "prompt": "fields = Houston._get_fields_from_collection(collection)\n c = Houston._collections.collections.findOne {name}\n count = collection.find().count()\n if c", "response": "Houston._collections.collections.update c._id, {$set: {count, fields}}\n else\n Houston._collections.collections.insert {name, count, fields}\n ADDED_COLLECTIONS[name] = collection", "source_lang": "CoffeeScript", "target_lang": "CoffeeScript", "repo": "gterrono/houston", "path": "server/publications.coffee", "license": "MIT", "commit": "9eb40369d9b923cf0ebb33f504697ead89954ea0", "stars": 802, "source_url": "https://github.com/gterrono/houston/blob/9eb40369d9b923cf0ebb33f504697ead89954ea0/server/publications.coffee", "line_start": 59, "line_end": 66}735{"id": "gterrono/houston:server/publications.coffee:2:raw_corpus", "type": "raw_corpus", "prompt": "", "response": "Houston._setup_collection = (collection) ->\n name = collection._name\n return if name of ADDED_COLLECTIONS\n\n Houston._setup_collection_methods(collection)\n\n Houston._publish name, (sort, filter, limit, unknown_arg) ->\n check sort, Match.Optional(Object)\n check filter, Match.Optional(Object)\n check limit, Match.Optional(Number)\n check unknown_arg, Match.Any\n return unless Houston._user_is_admin @userId\n try\n collection.find(filter, sort: sort, limit: limit)\n catch e\n console.log e\n\n collection.find().observe\n _suppress_initial: true # fixes houston for large initial datasets\n added: (document) ->\n Houston._collections.collections.update {name},\n $inc: {count: 1},\n $addToSet: fields: $each: Houston._get_fields([document])\n removed: (document) -> Houston._collections.collections.update {name}, {$inc: {count: -1}}\n\n fields = Houston._get_fields_from_collection(collection)\n c = Houston._collections.collections.findOne {name}\n count = collection.find().count()\n if c\n Houston._collections.collections.update c._id, {$set: {count, fields}}\n else\n Houston._collections.collections.insert {name, count, fields}\n ADDED_COLLECTIONS[name] = collection", "source_lang": "", "target_lang": "CoffeeScript", "repo": "gterrono/houston", "path": "server/publications.coffee", "license": "MIT", "commit": "b4a46e43f3ed061be17c56c577d6f5ba73995bc6", "stars": 802, "source_url": "https://github.com/gterrono/houston/blob/b4a46e43f3ed061be17c56c577d6f5ba73995bc6/server/publications.coffee", "line_start": 9, "line_end": 41}736{"id": "gterrono/houston:server/publications.coffee:2:coffee_to_js", "type": "coffee_to_js", "prompt": "Convert this CoffeeScript to JavaScript.\n```coffeescript\nHouston._setup_collection = (collection) ->\n name = collection._name\n return if name of ADDED_COLLECTIONS\n\n Houston._setup_collection_methods(collection)\n\n Houston._publish name, (sort, filter, limit, unknown_arg) ->\n check sort, Match.Optional(Object)\n check filter, Match.Optional(Object)\n check limit, Match.Optional(Number)\n check unknown_arg, Match.Any\n return unless Houston._user_is_admin @userId\n try\n collection.find(filter, sort: sort, limit: limit)\n catch e\n console.log e\n\n collection.find().observe\n _suppress_initial: true # fixes houston for large initial datasets\n added: (document) ->\n Houston._collections.collections.update {name},\n $inc: {count: 1},\n $addToSet: fields: $each: Houston._get_fields([document])\n removed: (document) -> Houston._collections.collections.update {name}, {$inc: {count: -1}}\n\n fields = Houston._get_fields_from_collection(collection)\n c = Houston._collections.collections.findOne {name}\n count = collection.find().count()\n if c\n Houston._collections.collections.update c._id, {$set: {count, fields}}\n else\n Houston._collections.collections.insert {name, count, fields}\n ADDED_COLLECTIONS[name] = collection\n```", "response": "Houston._setup_collection = function(collection) {\n var c, count, fields, name;\n name = collection._name;\n if (name in ADDED_COLLECTIONS) {\n return;\n }\n Houston._setup_collection_methods(collection);\n Houston._publish(name, function(sort, filter, limit, unknown_arg) {\n var e;\n check(sort, Match.Optional(Object));\n check(filter, Match.Optional(Object));\n check(limit, Match.Optional(Number));\n check(unknown_arg, Match.Any);\n if (!Houston._user_is_admin(this.userId)) {\n return;\n }\n try {\n return collection.find(filter, {\n sort: sort,\n limit: limit\n });\n } catch (error) {\n e = error;\n return console.log(e);\n }\n });\n collection.find().observe({\n _suppress_initial: true, // fixes houston for large initial datasets\n added: function(document) {\n return Houston._collections.collections.update({name}, {\n $inc: {\n count: 1\n },\n $addToSet: {\n fields: {\n $each: Houston._get_fields([document])\n }\n }\n });\n },\n removed: function(document) {\n return Houston._collections.collections.update({name}, {\n $inc: {\n count: -1\n }\n });\n }\n });\n fields = Houston._get_fields_from_collection(collection);\n c = Houston._collections.collections.findOne({name});\n count = collection.find().count();\n if (c) {\n Houston._collections.collections.update(c._id, {\n $set: {count, fields}\n });\n } else {\n Houston._collections.collections.insert({name, count, fields});\n }\n return ADDED_COLLECTIONS[name] = collection;\n};", "source_lang": "CoffeeScript", "target_lang": "JavaScript", "repo": "gterrono/houston", "path": "server/publications.coffee", "license": "MIT", "commit": "b4a46e43f3ed061be17c56c577d6f5ba73995bc6", "stars": 802, "source_url": "https://github.com/gterrono/houston/blob/b4a46e43f3ed061be17c56c577d6f5ba73995bc6/server/publications.coffee", "line_start": 9, "line_end": 41}737{"id": "gterrono/houston:server/publications.coffee:2:js_to_coffee", "type": "js_to_coffee", "prompt": "Convert this JavaScript to CoffeeScript.\n```javascript\nHouston._setup_collection = function(collection) {\n var c, count, fields, name;\n name = collection._name;\n if (name in ADDED_COLLECTIONS) {\n return;\n }\n Houston._setup_collection_methods(collection);\n Houston._publish(name, function(sort, filter, limit, unknown_arg) {\n var e;\n check(sort, Match.Optional(Object));\n check(filter, Match.Optional(Object));\n check(limit, Match.Optional(Number));\n check(unknown_arg, Match.Any);\n if (!Houston._user_is_admin(this.userId)) {\n return;\n }\n try {\n return collection.find(filter, {\n sort: sort,\n limit: limit\n });\n } catch (error) {\n e = error;\n return console.log(e);\n }\n });\n collection.find().observe({\n _suppress_initial: true, // fixes houston for large initial datasets\n added: function(document) {\n return Houston._collections.collections.update({name}, {\n $inc: {\n count: 1\n },\n $addToSet: {\n fields: {\n $each: Houston._get_fields([document])\n }\n }\n });\n },\n removed: function(document) {\n return Houston._collections.collections.update({name}, {\n $inc: {\n count: -1\n }\n });\n }\n });\n fields = Houston._get_fields_from_collection(collection);\n c = Houston._collections.collections.findOne({name});\n count = collection.find().count();\n if (c) {\n Houston._collections.collections.update(c._id, {\n $set: {count, fields}\n });\n } else {\n Houston._collections.collections.insert({name, count, fields});\n }\n return ADDED_COLLECTIONS[name] = collection;\n};\n```", "response": "Houston._setup_collection = (collection) ->\n name = collection._name\n return if name of ADDED_COLLECTIONS\n\n Houston._setup_collection_methods(collection)\n\n Houston._publish name, (sort, filter, limit, unknown_arg) ->\n check sort, Match.Optional(Object)\n check filter, Match.Optional(Object)\n check limit, Match.Optional(Number)\n check unknown_arg, Match.Any\n return unless Houston._user_is_admin @userId\n try\n collection.find(filter, sort: sort, limit: limit)\n catch e\n console.log e\n\n collection.find().observe\n _suppress_initial: true # fixes houston for large initial datasets\n added: (document) ->\n Houston._collections.collections.update {name},\n $inc: {count: 1},\n $addToSet: fields: $each: Houston._get_fields([document])\n removed: (document) -> Houston._collections.collections.update {name}, {$inc: {count: -1}}\n\n fields = Houston._get_fields_from_collection(collection)\n c = Houston._collections.collections.findOne {name}\n count = collection.find().count()\n if c\n Houston._collections.collections.update c._id, {$set: {count, fields}}\n else\n Houston._collections.collections.insert {name, count, fields}\n ADDED_COLLECTIONS[name] = collection", "source_lang": "JavaScript", "target_lang": "CoffeeScript", "repo": "gterrono/houston", "path": "server/publications.coffee", "license": "MIT", "commit": "b4a46e43f3ed061be17c56c577d6f5ba73995bc6", "stars": 802, "source_url": "https://github.com/gterrono/houston/blob/b4a46e43f3ed061be17c56c577d6f5ba73995bc6/server/publications.coffee", "line_start": 9, "line_end": 41}738{"id": "gterrono/houston:server/publications.coffee:2:completion", "type": "completion", "prompt": "Houston._setup_collection = (collection) ->\n name = collection._name\n return if name of ADDED_COLLECTIONS\n\n Houston._setup_collection_methods(collection)\n\n Houston._publish name, (sort, filter, limit, unknown_arg) ->\n check sort, Match.Optional(Object)\n check filter, Match.Optional(Object)\n check limit, Match.Optional(Number)\n check unknown_arg, Match.Any\n return unless Houston._user_is_admin @userId\n try\n collection.find(filter, sort: sort, limit: limit)\n catch e\n console.log e", "response": "collection.find().observe\n _suppress_initial: true # fixes houston for large initial datasets\n added: (document) ->\n Houston._collections.collections.update {name},\n $inc: {count: 1},\n $addToSet: fields: $each: Houston._get_fields([document])\n removed: (document) -> Houston._collections.collections.update {name}, {$inc: {count: -1}}\n\n fields = Houston._get_fields_from_collection(collection)\n c = Houston._collections.collections.findOne {name}\n count = collection.find().count()\n if c\n Houston._collections.collections.update c._id, {$set: {count, fields}}\n else\n Houston._collections.collections.insert {name, count, fields}\n ADDED_COLLECTIONS[name] = collection", "source_lang": "CoffeeScript", "target_lang": "CoffeeScript", "repo": "gterrono/houston", "path": "server/publications.coffee", "license": "MIT", "commit": "b4a46e43f3ed061be17c56c577d6f5ba73995bc6", "stars": 802, "source_url": "https://github.com/gterrono/houston/blob/b4a46e43f3ed061be17c56c577d6f5ba73995bc6/server/publications.coffee", "line_start": 9, "line_end": 41}739{"id": "gterrono/houston:server/publications.coffee:3:raw_corpus", "type": "raw_corpus", "prompt": "", "response": "sync_collections = ->\n Houston._admins.findOne()\n\n _sync_collections = (meh, collections_db) ->\n collection_names = (col.collectionName for col in collections_db \\\n when (col.collectionName.indexOf \"system.\") isnt 0 and\n (col.collectionName.indexOf \"houston_\") isnt 0)\n\n collection_names.forEach (name) ->\n unless name of ADDED_COLLECTIONS or name of Houston._HIDDEN_COLLECTIONS\n new_collection = null\n try\n new_collection = new Meteor.Collection(name)\n catch e\n for key, value of root\n if name == value?._name # TODO here - typecheck also?\n new_collection = value\n\n if new_collection? # found it!\n Houston._setup_collection(new_collection)\n else\n console.log \"\"\"\nHouston: couldn't find access to the #{name} collection.\nIf you'd like to access the collection from Houston, either\n(1) make sure it is available as a global (top-level namespace) within the server or\n(2) add the collection manually via Houston.add_collection\n\"\"\"\n\n bound_sync_collections = Meteor.bindEnvironment _sync_collections, (e) ->\n console.log \"Failed while syncing collections for reason: #{e}\"\n\n # MongoInternals is the 'right' solution as of 0.6.5\n mongo_driver = MongoInternals?.defaultRemoteCollectionDriver() or Meteor._RemoteCollectionDriver\n mongo_driver.mongo.db.collections bound_sync_collections\n\nMeteor.methods\n _houston_make_admin: (user_id) ->\n check user_id, String\n # limit one admin\n return if Houston._admins.findOne {'user_id': $exists: true}\n Houston._admins.insert {user_id}\n sync_collections() # reloads collections in case of new app\n return true\n\n# publish our analysis of the app's collections\nHouston._publish 'collections', ->\n return unless Houston._user_is_admin @userId\n Houston._collections.collections.find()\n\n# TODO address inherent security issue", "source_lang": "", "target_lang": "CoffeeScript", "repo": "gterrono/houston", "path": "server/publications.coffee", "license": "MIT", "commit": "b4a46e43f3ed061be17c56c577d6f5ba73995bc6", "stars": 802, "source_url": "https://github.com/gterrono/houston/blob/b4a46e43f3ed061be17c56c577d6f5ba73995bc6/server/publications.coffee", "line_start": 43, "line_end": 92}740{"id": "gterrono/houston:server/publications.coffee:3:coffee_to_js", "type": "coffee_to_js", "prompt": "Convert this CoffeeScript to JavaScript.\n```coffeescript\nsync_collections = ->\n Houston._admins.findOne()\n\n _sync_collections = (meh, collections_db) ->\n collection_names = (col.collectionName for col in collections_db \\\n when (col.collectionName.indexOf \"system.\") isnt 0 and\n (col.collectionName.indexOf \"houston_\") isnt 0)\n\n collection_names.forEach (name) ->\n unless name of ADDED_COLLECTIONS or name of Houston._HIDDEN_COLLECTIONS\n new_collection = null\n try\n new_collection = new Meteor.Collection(name)\n catch e\n for key, value of root\n if name == value?._name # TODO here - typecheck also?\n new_collection = value\n\n if new_collection? # found it!\n Houston._setup_collection(new_collection)\n else\n console.log \"\"\"\nHouston: couldn't find access to the #{name} collection.\nIf you'd like to access the collection from Houston, either\n(1) make sure it is available as a global (top-level namespace) within the server or\n(2) add the collection manually via Houston.add_collection\n\"\"\"\n\n bound_sync_collections = Meteor.bindEnvironment _sync_collections, (e) ->\n console.log \"Failed while syncing collections for reason: #{e}\"\n\n # MongoInternals is the 'right' solution as of 0.6.5\n mongo_driver = MongoInternals?.defaultRemoteCollectionDriver() or Meteor._RemoteCollectionDriver\n mongo_driver.mongo.db.collections bound_sync_collections\n\nMeteor.methods\n _houston_make_admin: (user_id) ->\n check user_id, String\n # limit one admin\n return if Houston._admins.findOne {'user_id': $exists: true}\n Houston._admins.insert {user_id}\n sync_collections() # reloads collections in case of new app\n return true\n\n# publish our analysis of the app's collections\nHouston._publish 'collections', ->\n return unless Houston._user_is_admin @userId\n Houston._collections.collections.find()\n\n# TODO address inherent security issue\n```", "response": "var sync_collections;\n\nsync_collections = function() {\n var _sync_collections, bound_sync_collections, mongo_driver;\n Houston._admins.findOne();\n _sync_collections = function(meh, collections_db) {\n var col, collection_names;\n collection_names = (function() {\n var i, len, results;\n results = [];\n for (i = 0, len = collections_db.length; i < len; i++) {\n col = collections_db[i];\n if ((col.collectionName.indexOf(\"system.\")) !== 0 && (col.collectionName.indexOf(\"houston_\")) !== 0) {\n results.push(col.collectionName);\n }\n }\n return results;\n })();\n return collection_names.forEach(function(name) {\n var e, key, new_collection, value;\n if (!(name in ADDED_COLLECTIONS || name in Houston._HIDDEN_COLLECTIONS)) {\n new_collection = null;\n try {\n new_collection = new Meteor.Collection(name);\n } catch (error) {\n e = error;\n for (key in root) {\n value = root[key];\n if (name === (value != null ? value._name : void 0)) { // TODO here - typecheck also?\n new_collection = value;\n }\n }\n }\n if (new_collection != null) {\n return Houston._setup_collection(new_collection);\n } else {\n return console.log(`Houston: couldn't find access to the ${name} collection.\nIf you'd like to access the collection from Houston, either\n(1) make sure it is available as a global (top-level namespace) within the server or\n(2) add the collection manually via Houston.add_collection`); // found it!\n }\n }\n });\n };\n bound_sync_collections = Meteor.bindEnvironment(_sync_collections, function(e) {\n return console.log(`Failed while syncing collections for reason: ${e}`);\n });\n // MongoInternals is the 'right' solution as of 0.6.5\n mongo_driver = (typeof MongoInternals !== \"undefined\" && MongoInternals !== null ? MongoInternals.defaultRemoteCollectionDriver() : void 0) || Meteor._RemoteCollectionDriver;\n return mongo_driver.mongo.db.collections(bound_sync_collections);\n};\n\nMeteor.methods({\n _houston_make_admin: function(user_id) {\n check(user_id, String);\n // limit one admin\n if (Houston._admins.findOne({\n 'user_id': {\n $exists: true\n }\n })) {\n return;\n }\n Houston._admins.insert({user_id});\n sync_collections(); // reloads collections in case of new app\n return true;\n }\n});\n\n// publish our analysis of the app's collections\nHouston._publish('collections', function() {\n if (!Houston._user_is_admin(this.userId)) {\n return;\n }\n return Houston._collections.collections.find();\n});\n\n// TODO address inherent security issue", "source_lang": "CoffeeScript", "target_lang": "JavaScript", "repo": "gterrono/houston", "path": "server/publications.coffee", "license": "MIT", "commit": "b4a46e43f3ed061be17c56c577d6f5ba73995bc6", "stars": 802, "source_url": "https://github.com/gterrono/houston/blob/b4a46e43f3ed061be17c56c577d6f5ba73995bc6/server/publications.coffee", "line_start": 43, "line_end": 92}741{"id": "gterrono/houston:server/publications.coffee:3:js_to_coffee", "type": "js_to_coffee", "prompt": "Convert this JavaScript to CoffeeScript.\n```javascript\nvar sync_collections;\n\nsync_collections = function() {\n var _sync_collections, bound_sync_collections, mongo_driver;\n Houston._admins.findOne();\n _sync_collections = function(meh, collections_db) {\n var col, collection_names;\n collection_names = (function() {\n var i, len, results;\n results = [];\n for (i = 0, len = collections_db.length; i < len; i++) {\n col = collections_db[i];\n if ((col.collectionName.indexOf(\"system.\")) !== 0 && (col.collectionName.indexOf(\"houston_\")) !== 0) {\n results.push(col.collectionName);\n }\n }\n return results;\n })();\n return collection_names.forEach(function(name) {\n var e, key, new_collection, value;\n if (!(name in ADDED_COLLECTIONS || name in Houston._HIDDEN_COLLECTIONS)) {\n new_collection = null;\n try {\n new_collection = new Meteor.Collection(name);\n } catch (error) {\n e = error;\n for (key in root) {\n value = root[key];\n if (name === (value != null ? value._name : void 0)) { // TODO here - typecheck also?\n new_collection = value;\n }\n }\n }\n if (new_collection != null) {\n return Houston._setup_collection(new_collection);\n } else {\n return console.log(`Houston: couldn't find access to the ${name} collection.\nIf you'd like to access the collection from Houston, either\n(1) make sure it is available as a global (top-level namespace) within the server or\n(2) add the collection manually via Houston.add_collection`); // found it!\n }\n }\n });\n };\n bound_sync_collections = Meteor.bindEnvironment(_sync_collections, function(e) {\n return console.log(`Failed while syncing collections for reason: ${e}`);\n });\n // MongoInternals is the 'right' solution as of 0.6.5\n mongo_driver = (typeof MongoInternals !== \"undefined\" && MongoInternals !== null ? MongoInternals.defaultRemoteCollectionDriver() : void 0) || Meteor._RemoteCollectionDriver;\n return mongo_driver.mongo.db.collections(bound_sync_collections);\n};\n\nMeteor.methods({\n _houston_make_admin: function(user_id) {\n check(user_id, String);\n // limit one admin\n if (Houston._admins.findOne({\n 'user_id': {\n $exists: true\n }\n })) {\n return;\n }\n Houston._admins.insert({user_id});\n sync_collections(); // reloads collections in case of new app\n return true;\n }\n});\n\n// publish our analysis of the app's collections\nHouston._publish('collections', function() {\n if (!Houston._user_is_admin(this.userId)) {\n return;\n }\n return Houston._collections.collections.find();\n});\n\n// TODO address inherent security issue\n```", "response": "sync_collections = ->\n Houston._admins.findOne()\n\n _sync_collections = (meh, collections_db) ->\n collection_names = (col.collectionName for col in collections_db \\\n when (col.collectionName.indexOf \"system.\") isnt 0 and\n (col.collectionName.indexOf \"houston_\") isnt 0)\n\n collection_names.forEach (name) ->\n unless name of ADDED_COLLECTIONS or name of Houston._HIDDEN_COLLECTIONS\n new_collection = null\n try\n new_collection = new Meteor.Collection(name)\n catch e\n for key, value of root\n if name == value?._name # TODO here - typecheck also?\n new_collection = value\n\n if new_collection? # found it!\n Houston._setup_collection(new_collection)\n else\n console.log \"\"\"\nHouston: couldn't find access to the #{name} collection.\nIf you'd like to access the collection from Houston, either\n(1) make sure it is available as a global (top-level namespace) within the server or\n(2) add the collection manually via Houston.add_collection\n\"\"\"\n\n bound_sync_collections = Meteor.bindEnvironment _sync_collections, (e) ->\n console.log \"Failed while syncing collections for reason: #{e}\"\n\n # MongoInternals is the 'right' solution as of 0.6.5\n mongo_driver = MongoInternals?.defaultRemoteCollectionDriver() or Meteor._RemoteCollectionDriver\n mongo_driver.mongo.db.collections bound_sync_collections\n\nMeteor.methods\n _houston_make_admin: (user_id) ->\n check user_id, String\n # limit one admin\n return if Houston._admins.findOne {'user_id': $exists: true}\n Houston._admins.insert {user_id}\n sync_collections() # reloads collections in case of new app\n return true\n\n# publish our analysis of the app's collections\nHouston._publish 'collections', ->\n return unless Houston._user_is_admin @userId\n Houston._collections.collections.find()\n\n# TODO address inherent security issue", "source_lang": "JavaScript", "target_lang": "CoffeeScript", "repo": "gterrono/houston", "path": "server/publications.coffee", "license": "MIT", "commit": "b4a46e43f3ed061be17c56c577d6f5ba73995bc6", "stars": 802, "source_url": "https://github.com/gterrono/houston/blob/b4a46e43f3ed061be17c56c577d6f5ba73995bc6/server/publications.coffee", "line_start": 43, "line_end": 92}742{"id": "gterrono/houston:server/publications.coffee:3:completion", "type": "completion", "prompt": "sync_collections = ->\n Houston._admins.findOne()\n\n _sync_collections = (meh, collections_db) ->\n collection_names = (col.collectionName for col in collections_db \\\n when (col.collectionName.indexOf \"system.\") isnt 0 and\n (col.collectionName.indexOf \"houston_\") isnt 0)\n\n collection_names.forEach (name) ->\n unless name of ADDED_COLLECTIONS or name of Houston._HIDDEN_COLLECTIONS\n new_collection = null\n try\n new_collection = new Meteor.Collection(name)\n catch e\n for key, value of root\n if name == value?._name # TODO here - typecheck also?\n new_collection = value\n\n if new_collection? # found it!\n Houston._setup_collection(new_collection)\n else\n console.log \"\"\"\nHouston: couldn't find access to the #{name} collection.\nIf you'd like to access the collection from Houston, either\n(1) make sure it is available as a global (top-level namespace) within the server or", "response": "(2) add the collection manually via Houston.add_collection\n\"\"\"\n\n bound_sync_collections = Meteor.bindEnvironment _sync_collections, (e) ->\n console.log \"Failed while syncing collections for reason: #{e}\"\n\n # MongoInternals is the 'right' solution as of 0.6.5\n mongo_driver = MongoInternals?.defaultRemoteCollectionDriver() or Meteor._RemoteCollectionDriver\n mongo_driver.mongo.db.collections bound_sync_collections\n\nMeteor.methods\n _houston_make_admin: (user_id) ->\n check user_id, String\n # limit one admin\n return if Houston._admins.findOne {'user_id': $exists: true}\n Houston._admins.insert {user_id}\n sync_collections() # reloads collections in case of new app\n return true\n\n# publish our analysis of the app's collections\nHouston._publish 'collections', ->\n return unless Houston._user_is_admin @userId\n Houston._collections.collections.find()\n\n# TODO address inherent security issue", "source_lang": "CoffeeScript", "target_lang": "CoffeeScript", "repo": "gterrono/houston", "path": "server/publications.coffee", "license": "MIT", "commit": "b4a46e43f3ed061be17c56c577d6f5ba73995bc6", "stars": 802, "source_url": "https://github.com/gterrono/houston/blob/b4a46e43f3ed061be17c56c577d6f5ba73995bc6/server/publications.coffee", "line_start": 43, "line_end": 92}743{"id": "gterrono/houston:server/publications.coffee:4:raw_corpus", "type": "raw_corpus", "prompt": "", "response": "Houston._publish 'admin_user', ->\n Houston._admins.find {}\n\nMeteor.startup ->\n sync_collections()", "source_lang": "", "target_lang": "CoffeeScript", "repo": "gterrono/houston", "path": "server/publications.coffee", "license": "MIT", "commit": "b4a46e43f3ed061be17c56c577d6f5ba73995bc6", "stars": 802, "source_url": "https://github.com/gterrono/houston/blob/b4a46e43f3ed061be17c56c577d6f5ba73995bc6/server/publications.coffee", "line_start": 93, "line_end": 97}744{"id": "gterrono/houston:server/publications.coffee:4:coffee_to_js", "type": "coffee_to_js", "prompt": "Convert this CoffeeScript to JavaScript.\n```coffeescript\nHouston._publish 'admin_user', ->\n Houston._admins.find {}\n\nMeteor.startup ->\n sync_collections()\n```", "response": "Houston._publish('admin_user', function() {\n return Houston._admins.find({});\n});\n\nMeteor.startup(function() {\n return sync_collections();\n});", "source_lang": "CoffeeScript", "target_lang": "JavaScript", "repo": "gterrono/houston", "path": "server/publications.coffee", "license": "MIT", "commit": "b4a46e43f3ed061be17c56c577d6f5ba73995bc6", "stars": 802, "source_url": "https://github.com/gterrono/houston/blob/b4a46e43f3ed061be17c56c577d6f5ba73995bc6/server/publications.coffee", "line_start": 93, "line_end": 97}745{"id": "gterrono/houston:server/publications.coffee:4:js_to_coffee", "type": "js_to_coffee", "prompt": "Convert this JavaScript to CoffeeScript.\n```javascript\nHouston._publish('admin_user', function() {\n return Houston._admins.find({});\n});\n\nMeteor.startup(function() {\n return sync_collections();\n});\n```", "response": "Houston._publish 'admin_user', ->\n Houston._admins.find {}\n\nMeteor.startup ->\n sync_collections()", "source_lang": "JavaScript", "target_lang": "CoffeeScript", "repo": "gterrono/houston", "path": "server/publications.coffee", "license": "MIT", "commit": "b4a46e43f3ed061be17c56c577d6f5ba73995bc6", "stars": 802, "source_url": "https://github.com/gterrono/houston/blob/b4a46e43f3ed061be17c56c577d6f5ba73995bc6/server/publications.coffee", "line_start": 93, "line_end": 97}746{"id": "gterrono/houston:server/publications.coffee:4:completion", "type": "completion", "prompt": "Houston._publish 'admin_user', ->\n Houston._admins.find {}", "response": "Meteor.startup ->\n sync_collections()", "source_lang": "CoffeeScript", "target_lang": "CoffeeScript", "repo": "gterrono/houston", "path": "server/publications.coffee", "license": "MIT", "commit": "b4a46e43f3ed061be17c56c577d6f5ba73995bc6", "stars": 802, "source_url": "https://github.com/gterrono/houston/blob/b4a46e43f3ed061be17c56c577d6f5ba73995bc6/server/publications.coffee", "line_start": 93, "line_end": 97}747{"id": "gterrono/houston:server/publications.coffee:2:raw_corpus", "type": "raw_corpus", "prompt": "", "response": "Houston._setup_collection = (collection) ->\n return if collection._name of ADDED_COLLECTIONS\n\n Houston._setup_collection_methods(collection)\n\n Houston._publish name, (sort, filter, limit, unknown_arg) ->\n check sort, Match.Optional(Object)\n check filter, Match.Optional(Object)\n check limit, Match.Optional(Number)\n check unknown_arg, Match.Any\n return unless Houston._user_is_admin @userId\n try\n collection.find(filter, sort: sort, limit: limit)\n catch e\n console.log e\n\n collection.find().observe\n _suppress_initial: true # fixes houston for large initial datasets\n added: (document) ->\n Houston._collections.collections.update {name},\n $inc: {count: 1},\n $addToSet: fields: $each: Houston._get_fields([document])\n removed: (document) -> Houston._collections.collections.update {name}, {$inc: {count: -1}}\n\n fields = Houston._get_fields_from_collection(collection)\n c = Houston._collections.collections.findOne {name}\n count = collection.find().count()\n if c\n Houston._collections.collections.update c._id, {$set: {count, fields}}\n else\n Houston._collections.collections.insert {name, count, fields}\n ADDED_COLLECTIONS[name] = collection", "source_lang": "", "target_lang": "CoffeeScript", "repo": "gterrono/houston", "path": "server/publications.coffee", "license": "MIT", "commit": "8d5f8c9307a1af844b98e36909ac06d444a87c4a", "stars": 802, "source_url": "https://github.com/gterrono/houston/blob/8d5f8c9307a1af844b98e36909ac06d444a87c4a/server/publications.coffee", "line_start": 9, "line_end": 40}748{"id": "gterrono/houston:server/publications.coffee:2:coffee_to_js", "type": "coffee_to_js", "prompt": "Convert this CoffeeScript to JavaScript.\n```coffeescript\nHouston._setup_collection = (collection) ->\n return if collection._name of ADDED_COLLECTIONS\n\n Houston._setup_collection_methods(collection)\n\n Houston._publish name, (sort, filter, limit, unknown_arg) ->\n check sort, Match.Optional(Object)\n check filter, Match.Optional(Object)\n check limit, Match.Optional(Number)\n check unknown_arg, Match.Any\n return unless Houston._user_is_admin @userId\n try\n collection.find(filter, sort: sort, limit: limit)\n catch e\n console.log e\n\n collection.find().observe\n _suppress_initial: true # fixes houston for large initial datasets\n added: (document) ->\n Houston._collections.collections.update {name},\n $inc: {count: 1},\n $addToSet: fields: $each: Houston._get_fields([document])\n removed: (document) -> Houston._collections.collections.update {name}, {$inc: {count: -1}}\n\n fields = Houston._get_fields_from_collection(collection)\n c = Houston._collections.collections.findOne {name}\n count = collection.find().count()\n if c\n Houston._collections.collections.update c._id, {$set: {count, fields}}\n else\n Houston._collections.collections.insert {name, count, fields}\n ADDED_COLLECTIONS[name] = collection\n```", "response": "Houston._setup_collection = function(collection) {\n var c, count, fields;\n if (collection._name in ADDED_COLLECTIONS) {\n return;\n }\n Houston._setup_collection_methods(collection);\n Houston._publish(name, function(sort, filter, limit, unknown_arg) {\n var e;\n check(sort, Match.Optional(Object));\n check(filter, Match.Optional(Object));\n check(limit, Match.Optional(Number));\n check(unknown_arg, Match.Any);\n if (!Houston._user_is_admin(this.userId)) {\n return;\n }\n try {\n return collection.find(filter, {\n sort: sort,\n limit: limit\n });\n } catch (error) {\n e = error;\n return console.log(e);\n }\n });\n collection.find().observe({\n _suppress_initial: true, // fixes houston for large initial datasets\n added: function(document) {\n return Houston._collections.collections.update({name}, {\n $inc: {\n count: 1\n },\n $addToSet: {\n fields: {\n $each: Houston._get_fields([document])\n }\n }\n });\n },\n removed: function(document) {\n return Houston._collections.collections.update({name}, {\n $inc: {\n count: -1\n }\n });\n }\n });\n fields = Houston._get_fields_from_collection(collection);\n c = Houston._collections.collections.findOne({name});\n count = collection.find().count();\n if (c) {\n Houston._collections.collections.update(c._id, {\n $set: {count, fields}\n });\n } else {\n Houston._collections.collections.insert({name, count, fields});\n }\n return ADDED_COLLECTIONS[name] = collection;\n};", "source_lang": "CoffeeScript", "target_lang": "JavaScript", "repo": "gterrono/houston", "path": "server/publications.coffee", "license": "MIT", "commit": "8d5f8c9307a1af844b98e36909ac06d444a87c4a", "stars": 802, "source_url": "https://github.com/gterrono/houston/blob/8d5f8c9307a1af844b98e36909ac06d444a87c4a/server/publications.coffee", "line_start": 9, "line_end": 40}749{"id": "gterrono/houston:server/publications.coffee:2:js_to_coffee", "type": "js_to_coffee", "prompt": "Convert this JavaScript to CoffeeScript.\n```javascript\nHouston._setup_collection = function(collection) {\n var c, count, fields;\n if (collection._name in ADDED_COLLECTIONS) {\n return;\n }\n Houston._setup_collection_methods(collection);\n Houston._publish(name, function(sort, filter, limit, unknown_arg) {\n var e;\n check(sort, Match.Optional(Object));\n check(filter, Match.Optional(Object));\n check(limit, Match.Optional(Number));\n check(unknown_arg, Match.Any);\n if (!Houston._user_is_admin(this.userId)) {\n return;\n }\n try {\n return collection.find(filter, {\n sort: sort,\n limit: limit\n });\n } catch (error) {\n e = error;\n return console.log(e);\n }\n });\n collection.find().observe({\n _suppress_initial: true, // fixes houston for large initial datasets\n added: function(document) {\n return Houston._collections.collections.update({name}, {\n $inc: {\n count: 1\n },\n $addToSet: {\n fields: {\n $each: Houston._get_fields([document])\n }\n }\n });\n },\n removed: function(document) {\n return Houston._collections.collections.update({name}, {\n $inc: {\n count: -1\n }\n });\n }\n });\n fields = Houston._get_fields_from_collection(collection);\n c = Houston._collections.collections.findOne({name});\n count = collection.find().count();\n if (c) {\n Houston._collections.collections.update(c._id, {\n $set: {count, fields}\n });\n } else {\n Houston._collections.collections.insert({name, count, fields});\n }\n return ADDED_COLLECTIONS[name] = collection;\n};\n```", "response": "Houston._setup_collection = (collection) ->\n return if collection._name of ADDED_COLLECTIONS\n\n Houston._setup_collection_methods(collection)\n\n Houston._publish name, (sort, filter, limit, unknown_arg) ->\n check sort, Match.Optional(Object)\n check filter, Match.Optional(Object)\n check limit, Match.Optional(Number)\n check unknown_arg, Match.Any\n return unless Houston._user_is_admin @userId\n try\n collection.find(filter, sort: sort, limit: limit)\n catch e\n console.log e\n\n collection.find().observe\n _suppress_initial: true # fixes houston for large initial datasets\n added: (document) ->\n Houston._collections.collections.update {name},\n $inc: {count: 1},\n $addToSet: fields: $each: Houston._get_fields([document])\n removed: (document) -> Houston._collections.collections.update {name}, {$inc: {count: -1}}\n\n fields = Houston._get_fields_from_collection(collection)\n c = Houston._collections.collections.findOne {name}\n count = collection.find().count()\n if c\n Houston._collections.collections.update c._id, {$set: {count, fields}}\n else\n Houston._collections.collections.insert {name, count, fields}\n ADDED_COLLECTIONS[name] = collection", "source_lang": "JavaScript", "target_lang": "CoffeeScript", "repo": "gterrono/houston", "path": "server/publications.coffee", "license": "MIT", "commit": "8d5f8c9307a1af844b98e36909ac06d444a87c4a", "stars": 802, "source_url": "https://github.com/gterrono/houston/blob/8d5f8c9307a1af844b98e36909ac06d444a87c4a/server/publications.coffee", "line_start": 9, "line_end": 40}750{"id": "gterrono/houston:server/publications.coffee:2:completion", "type": "completion", "prompt": "Houston._setup_collection = (collection) ->\n return if collection._name of ADDED_COLLECTIONS\n\n Houston._setup_collection_methods(collection)\n\n Houston._publish name, (sort, filter, limit, unknown_arg) ->\n check sort, Match.Optional(Object)\n check filter, Match.Optional(Object)\n check limit, Match.Optional(Number)\n check unknown_arg, Match.Any\n return unless Houston._user_is_admin @userId\n try\n collection.find(filter, sort: sort, limit: limit)\n catch e\n console.log e", "response": "collection.find().observe\n _suppress_initial: true # fixes houston for large initial datasets\n added: (document) ->\n Houston._collections.collections.update {name},\n $inc: {count: 1},\n $addToSet: fields: $each: Houston._get_fields([document])\n removed: (document) -> Houston._collections.collections.update {name}, {$inc: {count: -1}}\n\n fields = Houston._get_fields_from_collection(collection)\n c = Houston._collections.collections.findOne {name}\n count = collection.find().count()\n if c\n Houston._collections.collections.update c._id, {$set: {count, fields}}\n else\n Houston._collections.collections.insert {name, count, fields}\n ADDED_COLLECTIONS[name] = collection", "source_lang": "CoffeeScript", "target_lang": "CoffeeScript", "repo": "gterrono/houston", "path": "server/publications.coffee", "license": "MIT", "commit": "8d5f8c9307a1af844b98e36909ac06d444a87c4a", "stars": 802, "source_url": "https://github.com/gterrono/houston/blob/8d5f8c9307a1af844b98e36909ac06d444a87c4a/server/publications.coffee", "line_start": 9, "line_end": 40}751{"id": "gterrono/houston:server/publications.coffee:4:raw_corpus", "type": "raw_corpus", "prompt": "", "response": "sync_collections = ->\n Dummy.findOne() # hack. TODO: verify this is still necessary\n\n _sync_collections = (meh, collections_db) ->\n collection_names = (col.collectionName for col in collections_db \\\n when (col.collectionName.indexOf \"system.\") isnt 0 and\n (col.collectionName.indexOf \"houston_\") isnt 0)\n\n collection_names.forEach (name) ->\n unless name of ADDED_COLLECTIONS or name of Houston._HIDDEN_COLLECTIONS\n new_collection = null\n try\n new_collection = new Meteor.Collection(name)\n catch e\n for key, value of root\n if name == value?._name # TODO here - typecheck also?\n new_collection = value\n\n if new_collection? # found it!\n Houston._setup_collection(new_collection)\n else\n console.log \"\"\"\nHouston: couldn't find access to the #{name} collection.\nIf you'd like to access the collection from Houston, either\n(1) make sure it is available as a global (top-level namespace) within the server or\n(2) add the collection manually via Houston.add_collection\n\"\"\"\n\n bound_sync_collections = Meteor.bindEnvironment _sync_collections, (e) ->\n console.log \"Failed while syncing collections for reason: #{e}\"\n\n # MongoInternals is the 'right' solution as of 0.6.5\n mongo_driver = MongoInternals?.defaultRemoteCollectionDriver() or Meteor._RemoteCollectionDriver\n mongo_driver.mongo.db.collections bound_sync_collections\n\nMeteor.methods\n _houston_make_admin: (user_id) ->\n check user_id, String\n # limit one admin\n return if Houston._admins.findOne {'user_id': $exists: true}\n Houston._admins.insert {user_id}\n sync_collections() # reloads collections in case of new app\n return true\n\n# publish our analysis of the app's collections\nHouston._publish 'collections', ->\n return unless Houston._user_is_admin @userId\n Houston._collections.collections.find()\n\n# TODO address inherent security issue", "source_lang": "", "target_lang": "CoffeeScript", "repo": "gterrono/houston", "path": "server/publications.coffee", "license": "MIT", "commit": "41c5fcf9d8f42ed9b8d338372cae2031a88e95b6", "stars": 802, "source_url": "https://github.com/gterrono/houston/blob/41c5fcf9d8f42ed9b8d338372cae2031a88e95b6/server/publications.coffee", "line_start": 70, "line_end": 119}752{"id": "gterrono/houston:server/publications.coffee:4:coffee_to_js", "type": "coffee_to_js", "prompt": "Convert this CoffeeScript to JavaScript.\n```coffeescript\nsync_collections = ->\n Dummy.findOne() # hack. TODO: verify this is still necessary\n\n _sync_collections = (meh, collections_db) ->\n collection_names = (col.collectionName for col in collections_db \\\n when (col.collectionName.indexOf \"system.\") isnt 0 and\n (col.collectionName.indexOf \"houston_\") isnt 0)\n\n collection_names.forEach (name) ->\n unless name of ADDED_COLLECTIONS or name of Houston._HIDDEN_COLLECTIONS\n new_collection = null\n try\n new_collection = new Meteor.Collection(name)\n catch e\n for key, value of root\n if name == value?._name # TODO here - typecheck also?\n new_collection = value\n\n if new_collection? # found it!\n Houston._setup_collection(new_collection)\n else\n console.log \"\"\"\nHouston: couldn't find access to the #{name} collection.\nIf you'd like to access the collection from Houston, either\n(1) make sure it is available as a global (top-level namespace) within the server or\n(2) add the collection manually via Houston.add_collection\n\"\"\"\n\n bound_sync_collections = Meteor.bindEnvironment _sync_collections, (e) ->\n console.log \"Failed while syncing collections for reason: #{e}\"\n\n # MongoInternals is the 'right' solution as of 0.6.5\n mongo_driver = MongoInternals?.defaultRemoteCollectionDriver() or Meteor._RemoteCollectionDriver\n mongo_driver.mongo.db.collections bound_sync_collections\n\nMeteor.methods\n _houston_make_admin: (user_id) ->\n check user_id, String\n # limit one admin\n return if Houston._admins.findOne {'user_id': $exists: true}\n Houston._admins.insert {user_id}\n sync_collections() # reloads collections in case of new app\n return true\n\n# publish our analysis of the app's collections\nHouston._publish 'collections', ->\n return unless Houston._user_is_admin @userId\n Houston._collections.collections.find()\n\n# TODO address inherent security issue\n```", "response": "var sync_collections;\n\nsync_collections = function() {\n var _sync_collections, bound_sync_collections, mongo_driver;\n Dummy.findOne(); // hack. TODO: verify this is still necessary\n _sync_collections = function(meh, collections_db) {\n var col, collection_names;\n collection_names = (function() {\n var i, len, results;\n results = [];\n for (i = 0, len = collections_db.length; i < len; i++) {\n col = collections_db[i];\n if ((col.collectionName.indexOf(\"system.\")) !== 0 && (col.collectionName.indexOf(\"houston_\")) !== 0) {\n results.push(col.collectionName);\n }\n }\n return results;\n })();\n return collection_names.forEach(function(name) {\n var e, key, new_collection, value;\n if (!(name in ADDED_COLLECTIONS || name in Houston._HIDDEN_COLLECTIONS)) {\n new_collection = null;\n try {\n new_collection = new Meteor.Collection(name);\n } catch (error) {\n e = error;\n for (key in root) {\n value = root[key];\n if (name === (value != null ? value._name : void 0)) { // TODO here - typecheck also?\n new_collection = value;\n }\n }\n }\n if (new_collection != null) {\n return Houston._setup_collection(new_collection);\n } else {\n return console.log(`Houston: couldn't find access to the ${name} collection.\nIf you'd like to access the collection from Houston, either\n(1) make sure it is available as a global (top-level namespace) within the server or\n(2) add the collection manually via Houston.add_collection`); // found it!\n }\n }\n });\n };\n bound_sync_collections = Meteor.bindEnvironment(_sync_collections, function(e) {\n return console.log(`Failed while syncing collections for reason: ${e}`);\n });\n // MongoInternals is the 'right' solution as of 0.6.5\n mongo_driver = (typeof MongoInternals !== \"undefined\" && MongoInternals !== null ? MongoInternals.defaultRemoteCollectionDriver() : void 0) || Meteor._RemoteCollectionDriver;\n return mongo_driver.mongo.db.collections(bound_sync_collections);\n};\n\nMeteor.methods({\n _houston_make_admin: function(user_id) {\n check(user_id, String);\n // limit one admin\n if (Houston._admins.findOne({\n 'user_id': {\n $exists: true\n }\n })) {\n return;\n }\n Houston._admins.insert({user_id});\n sync_collections(); // reloads collections in case of new app\n return true;\n }\n});\n\n// publish our analysis of the app's collections\nHouston._publish('collections', function() {\n if (!Houston._user_is_admin(this.userId)) {\n return;\n }\n return Houston._collections.collections.find();\n});\n\n// TODO address inherent security issue", "source_lang": "CoffeeScript", "target_lang": "JavaScript", "repo": "gterrono/houston", "path": "server/publications.coffee", "license": "MIT", "commit": "41c5fcf9d8f42ed9b8d338372cae2031a88e95b6", "stars": 802, "source_url": "https://github.com/gterrono/houston/blob/41c5fcf9d8f42ed9b8d338372cae2031a88e95b6/server/publications.coffee", "line_start": 70, "line_end": 119}753{"id": "gterrono/houston:server/publications.coffee:4:js_to_coffee", "type": "js_to_coffee", "prompt": "Convert this JavaScript to CoffeeScript.\n```javascript\nvar sync_collections;\n\nsync_collections = function() {\n var _sync_collections, bound_sync_collections, mongo_driver;\n Dummy.findOne(); // hack. TODO: verify this is still necessary\n _sync_collections = function(meh, collections_db) {\n var col, collection_names;\n collection_names = (function() {\n var i, len, results;\n results = [];\n for (i = 0, len = collections_db.length; i < len; i++) {\n col = collections_db[i];\n if ((col.collectionName.indexOf(\"system.\")) !== 0 && (col.collectionName.indexOf(\"houston_\")) !== 0) {\n results.push(col.collectionName);\n }\n }\n return results;\n })();\n return collection_names.forEach(function(name) {\n var e, key, new_collection, value;\n if (!(name in ADDED_COLLECTIONS || name in Houston._HIDDEN_COLLECTIONS)) {\n new_collection = null;\n try {\n new_collection = new Meteor.Collection(name);\n } catch (error) {\n e = error;\n for (key in root) {\n value = root[key];\n if (name === (value != null ? value._name : void 0)) { // TODO here - typecheck also?\n new_collection = value;\n }\n }\n }\n if (new_collection != null) {\n return Houston._setup_collection(new_collection);\n } else {\n return console.log(`Houston: couldn't find access to the ${name} collection.\nIf you'd like to access the collection from Houston, either\n(1) make sure it is available as a global (top-level namespace) within the server or\n(2) add the collection manually via Houston.add_collection`); // found it!\n }\n }\n });\n };\n bound_sync_collections = Meteor.bindEnvironment(_sync_collections, function(e) {\n return console.log(`Failed while syncing collections for reason: ${e}`);\n });\n // MongoInternals is the 'right' solution as of 0.6.5\n mongo_driver = (typeof MongoInternals !== \"undefined\" && MongoInternals !== null ? MongoInternals.defaultRemoteCollectionDriver() : void 0) || Meteor._RemoteCollectionDriver;\n return mongo_driver.mongo.db.collections(bound_sync_collections);\n};\n\nMeteor.methods({\n _houston_make_admin: function(user_id) {\n check(user_id, String);\n // limit one admin\n if (Houston._admins.findOne({\n 'user_id': {\n $exists: true\n }\n })) {\n return;\n }\n Houston._admins.insert({user_id});\n sync_collections(); // reloads collections in case of new app\n return true;\n }\n});\n\n// publish our analysis of the app's collections\nHouston._publish('collections', function() {\n if (!Houston._user_is_admin(this.userId)) {\n return;\n }\n return Houston._collections.collections.find();\n});\n\n// TODO address inherent security issue\n```", "response": "sync_collections = ->\n Dummy.findOne() # hack. TODO: verify this is still necessary\n\n _sync_collections = (meh, collections_db) ->\n collection_names = (col.collectionName for col in collections_db \\\n when (col.collectionName.indexOf \"system.\") isnt 0 and\n (col.collectionName.indexOf \"houston_\") isnt 0)\n\n collection_names.forEach (name) ->\n unless name of ADDED_COLLECTIONS or name of Houston._HIDDEN_COLLECTIONS\n new_collection = null\n try\n new_collection = new Meteor.Collection(name)\n catch e\n for key, value of root\n if name == value?._name # TODO here - typecheck also?\n new_collection = value\n\n if new_collection? # found it!\n Houston._setup_collection(new_collection)\n else\n console.log \"\"\"\nHouston: couldn't find access to the #{name} collection.\nIf you'd like to access the collection from Houston, either\n(1) make sure it is available as a global (top-level namespace) within the server or\n(2) add the collection manually via Houston.add_collection\n\"\"\"\n\n bound_sync_collections = Meteor.bindEnvironment _sync_collections, (e) ->\n console.log \"Failed while syncing collections for reason: #{e}\"\n\n # MongoInternals is the 'right' solution as of 0.6.5\n mongo_driver = MongoInternals?.defaultRemoteCollectionDriver() or Meteor._RemoteCollectionDriver\n mongo_driver.mongo.db.collections bound_sync_collections\n\nMeteor.methods\n _houston_make_admin: (user_id) ->\n check user_id, String\n # limit one admin\n return if Houston._admins.findOne {'user_id': $exists: true}\n Houston._admins.insert {user_id}\n sync_collections() # reloads collections in case of new app\n return true\n\n# publish our analysis of the app's collections\nHouston._publish 'collections', ->\n return unless Houston._user_is_admin @userId\n Houston._collections.collections.find()\n\n# TODO address inherent security issue", "source_lang": "JavaScript", "target_lang": "CoffeeScript", "repo": "gterrono/houston", "path": "server/publications.coffee", "license": "MIT", "commit": "41c5fcf9d8f42ed9b8d338372cae2031a88e95b6", "stars": 802, "source_url": "https://github.com/gterrono/houston/blob/41c5fcf9d8f42ed9b8d338372cae2031a88e95b6/server/publications.coffee", "line_start": 70, "line_end": 119}754{"id": "gterrono/houston:server/publications.coffee:4:completion", "type": "completion", "prompt": "sync_collections = ->\n Dummy.findOne() # hack. TODO: verify this is still necessary\n\n _sync_collections = (meh, collections_db) ->\n collection_names = (col.collectionName for col in collections_db \\\n when (col.collectionName.indexOf \"system.\") isnt 0 and\n (col.collectionName.indexOf \"houston_\") isnt 0)\n\n collection_names.forEach (name) ->\n unless name of ADDED_COLLECTIONS or name of Houston._HIDDEN_COLLECTIONS\n new_collection = null\n try\n new_collection = new Meteor.Collection(name)\n catch e\n for key, value of root\n if name == value?._name # TODO here - typecheck also?\n new_collection = value\n\n if new_collection? # found it!\n Houston._setup_collection(new_collection)\n else\n console.log \"\"\"\nHouston: couldn't find access to the #{name} collection.\nIf you'd like to access the collection from Houston, either\n(1) make sure it is available as a global (top-level namespace) within the server or", "response": "(2) add the collection manually via Houston.add_collection\n\"\"\"\n\n bound_sync_collections = Meteor.bindEnvironment _sync_collections, (e) ->\n console.log \"Failed while syncing collections for reason: #{e}\"\n\n # MongoInternals is the 'right' solution as of 0.6.5\n mongo_driver = MongoInternals?.defaultRemoteCollectionDriver() or Meteor._RemoteCollectionDriver\n mongo_driver.mongo.db.collections bound_sync_collections\n\nMeteor.methods\n _houston_make_admin: (user_id) ->\n check user_id, String\n # limit one admin\n return if Houston._admins.findOne {'user_id': $exists: true}\n Houston._admins.insert {user_id}\n sync_collections() # reloads collections in case of new app\n return true\n\n# publish our analysis of the app's collections\nHouston._publish 'collections', ->\n return unless Houston._user_is_admin @userId\n Houston._collections.collections.find()\n\n# TODO address inherent security issue", "source_lang": "CoffeeScript", "target_lang": "CoffeeScript", "repo": "gterrono/houston", "path": "server/publications.coffee", "license": "MIT", "commit": "41c5fcf9d8f42ed9b8d338372cae2031a88e95b6", "stars": 802, "source_url": "https://github.com/gterrono/houston/blob/41c5fcf9d8f42ed9b8d338372cae2031a88e95b6/server/publications.coffee", "line_start": 70, "line_end": 119}755{"id": "gterrono/houston:server/publications.coffee:2:raw_corpus", "type": "raw_corpus", "prompt": "", "response": "Houston._setup_collection = (collection) ->\n return if collection._name of ADDED_COLLECTIONS\n\n name = collection._name\n methods = {}\n methods[Houston._houstonize \"#{name}_insert\"] = (doc) ->\n check doc, Object\n return unless Houston._user_is_admin @userId\n collection.insert(doc)\n\n methods[Houston._houstonize \"#{name}_update\"] = (id, update_dict) ->\n check id, Match.Any\n check update_dict, Object\n return unless Houston._user_is_admin @userId\n if collection.findOne(id)\n collection.update(id, update_dict)\n else\n id = collection.findOne(new Meteor.Collection.ObjectID(id))\n collection.update(id, update_dict)\n\n methods[Houston._houstonize \"#{name}_delete\"] = (id) ->\n check id, Match.Any\n return unless Houston._user_is_admin @userId\n if collection.findOne(id)\n collection.remove(id)\n else\n id = collection.findOne(new Meteor.Collection.ObjectID(id))\n collection.remove(id)\n\n Meteor.methods methods\n\n Houston._publish name, (sort, filter, limit, unknown_arg) ->\n check sort, Match.Optional(Object)\n check filter, Match.Optional(Object)\n check limit, Match.Optional(Number)\n check unknown_arg, Match.Any\n return unless Houston._user_is_admin @userId\n try\n collection.find(filter, sort: sort, limit: limit)\n catch e\n console.log e\n\n collection.find().observe\n added: (document) ->\n Houston._collections.collections.update {name},\n $inc: {count: 1},\n $addToSet: fields: $each: Houston._get_fields([document])\n removed: (document) -> Houston._collections.collections.update {name}, {$inc: {count: -1}}\n\n fields = Houston._get_fields(collection.find().fetch())", "source_lang": "", "target_lang": "CoffeeScript", "repo": "gterrono/houston", "path": "server/publications.coffee", "license": "MIT", "commit": "610792505b6af1a34d4e0a3f846df923f114d531", "stars": 802, "source_url": "https://github.com/gterrono/houston/blob/610792505b6af1a34d4e0a3f846df923f114d531/server/publications.coffee", "line_start": 11, "line_end": 60}756{"id": "gterrono/houston:server/publications.coffee:2:coffee_to_js", "type": "coffee_to_js", "prompt": "Convert this CoffeeScript to JavaScript.\n```coffeescript\nHouston._setup_collection = (collection) ->\n return if collection._name of ADDED_COLLECTIONS\n\n name = collection._name\n methods = {}\n methods[Houston._houstonize \"#{name}_insert\"] = (doc) ->\n check doc, Object\n return unless Houston._user_is_admin @userId\n collection.insert(doc)\n\n methods[Houston._houstonize \"#{name}_update\"] = (id, update_dict) ->\n check id, Match.Any\n check update_dict, Object\n return unless Houston._user_is_admin @userId\n if collection.findOne(id)\n collection.update(id, update_dict)\n else\n id = collection.findOne(new Meteor.Collection.ObjectID(id))\n collection.update(id, update_dict)\n\n methods[Houston._houstonize \"#{name}_delete\"] = (id) ->\n check id, Match.Any\n return unless Houston._user_is_admin @userId\n if collection.findOne(id)\n collection.remove(id)\n else\n id = collection.findOne(new Meteor.Collection.ObjectID(id))\n collection.remove(id)\n\n Meteor.methods methods\n\n Houston._publish name, (sort, filter, limit, unknown_arg) ->\n check sort, Match.Optional(Object)\n check filter, Match.Optional(Object)\n check limit, Match.Optional(Number)\n check unknown_arg, Match.Any\n return unless Houston._user_is_admin @userId\n try\n collection.find(filter, sort: sort, limit: limit)\n catch e\n console.log e\n\n collection.find().observe\n added: (document) ->\n Houston._collections.collections.update {name},\n $inc: {count: 1},\n $addToSet: fields: $each: Houston._get_fields([document])\n removed: (document) -> Houston._collections.collections.update {name}, {$inc: {count: -1}}\n\n fields = Houston._get_fields(collection.find().fetch())\n```", "response": "Houston._setup_collection = function(collection) {\n var fields, methods, name;\n if (collection._name in ADDED_COLLECTIONS) {\n return;\n }\n name = collection._name;\n methods = {};\n methods[Houston._houstonize(`${name}_insert`)] = function(doc) {\n check(doc, Object);\n if (!Houston._user_is_admin(this.userId)) {\n return;\n }\n return collection.insert(doc);\n };\n methods[Houston._houstonize(`${name}_update`)] = function(id, update_dict) {\n check(id, Match.Any);\n check(update_dict, Object);\n if (!Houston._user_is_admin(this.userId)) {\n return;\n }\n if (collection.findOne(id)) {\n return collection.update(id, update_dict);\n } else {\n id = collection.findOne(new Meteor.Collection.ObjectID(id));\n return collection.update(id, update_dict);\n }\n };\n methods[Houston._houstonize(`${name}_delete`)] = function(id) {\n check(id, Match.Any);\n if (!Houston._user_is_admin(this.userId)) {\n return;\n }\n if (collection.findOne(id)) {\n return collection.remove(id);\n } else {\n id = collection.findOne(new Meteor.Collection.ObjectID(id));\n return collection.remove(id);\n }\n };\n Meteor.methods(methods);\n Houston._publish(name, function(sort, filter, limit, unknown_arg) {\n var e;\n check(sort, Match.Optional(Object));\n check(filter, Match.Optional(Object));\n check(limit, Match.Optional(Number));\n check(unknown_arg, Match.Any);\n if (!Houston._user_is_admin(this.userId)) {\n return;\n }\n try {\n return collection.find(filter, {\n sort: sort,\n limit: limit\n });\n } catch (error) {\n e = error;\n return console.log(e);\n }\n });\n collection.find().observe({\n added: function(document) {\n return Houston._collections.collections.update({name}, {\n $inc: {\n count: 1\n },\n $addToSet: {\n fields: {\n $each: Houston._get_fields([document])\n }\n }\n });\n },\n removed: function(document) {\n return Houston._collections.collections.update({name}, {\n $inc: {\n count: -1\n }\n });\n }\n });\n return fields = Houston._get_fields(collection.find().fetch());\n};", "source_lang": "CoffeeScript", "target_lang": "JavaScript", "repo": "gterrono/houston", "path": "server/publications.coffee", "license": "MIT", "commit": "610792505b6af1a34d4e0a3f846df923f114d531", "stars": 802, "source_url": "https://github.com/gterrono/houston/blob/610792505b6af1a34d4e0a3f846df923f114d531/server/publications.coffee", "line_start": 11, "line_end": 60}757{"id": "gterrono/houston:server/publications.coffee:2:js_to_coffee", "type": "js_to_coffee", "prompt": "Convert this JavaScript to CoffeeScript.\n```javascript\nHouston._setup_collection = function(collection) {\n var fields, methods, name;\n if (collection._name in ADDED_COLLECTIONS) {\n return;\n }\n name = collection._name;\n methods = {};\n methods[Houston._houstonize(`${name}_insert`)] = function(doc) {\n check(doc, Object);\n if (!Houston._user_is_admin(this.userId)) {\n return;\n }\n return collection.insert(doc);\n };\n methods[Houston._houstonize(`${name}_update`)] = function(id, update_dict) {\n check(id, Match.Any);\n check(update_dict, Object);\n if (!Houston._user_is_admin(this.userId)) {\n return;\n }\n if (collection.findOne(id)) {\n return collection.update(id, update_dict);\n } else {\n id = collection.findOne(new Meteor.Collection.ObjectID(id));\n return collection.update(id, update_dict);\n }\n };\n methods[Houston._houstonize(`${name}_delete`)] = function(id) {\n check(id, Match.Any);\n if (!Houston._user_is_admin(this.userId)) {\n return;\n }\n if (collection.findOne(id)) {\n return collection.remove(id);\n } else {\n id = collection.findOne(new Meteor.Collection.ObjectID(id));\n return collection.remove(id);\n }\n };\n Meteor.methods(methods);\n Houston._publish(name, function(sort, filter, limit, unknown_arg) {\n var e;\n check(sort, Match.Optional(Object));\n check(filter, Match.Optional(Object));\n check(limit, Match.Optional(Number));\n check(unknown_arg, Match.Any);\n if (!Houston._user_is_admin(this.userId)) {\n return;\n }\n try {\n return collection.find(filter, {\n sort: sort,\n limit: limit\n });\n } catch (error) {\n e = error;\n return console.log(e);\n }\n });\n collection.find().observe({\n added: function(document) {\n return Houston._collections.collections.update({name}, {\n $inc: {\n count: 1\n },\n $addToSet: {\n fields: {\n $each: Houston._get_fields([document])\n }\n }\n });\n },\n removed: function(document) {\n return Houston._collections.collections.update({name}, {\n $inc: {\n count: -1\n }\n });\n }\n });\n return fields = Houston._get_fields(collection.find().fetch());\n};\n```", "response": "Houston._setup_collection = (collection) ->\n return if collection._name of ADDED_COLLECTIONS\n\n name = collection._name\n methods = {}\n methods[Houston._houstonize \"#{name}_insert\"] = (doc) ->\n check doc, Object\n return unless Houston._user_is_admin @userId\n collection.insert(doc)\n\n methods[Houston._houstonize \"#{name}_update\"] = (id, update_dict) ->\n check id, Match.Any\n check update_dict, Object\n return unless Houston._user_is_admin @userId\n if collection.findOne(id)\n collection.update(id, update_dict)\n else\n id = collection.findOne(new Meteor.Collection.ObjectID(id))\n collection.update(id, update_dict)\n\n methods[Houston._houstonize \"#{name}_delete\"] = (id) ->\n check id, Match.Any\n return unless Houston._user_is_admin @userId\n if collection.findOne(id)\n collection.remove(id)\n else\n id = collection.findOne(new Meteor.Collection.ObjectID(id))\n collection.remove(id)\n\n Meteor.methods methods\n\n Houston._publish name, (sort, filter, limit, unknown_arg) ->\n check sort, Match.Optional(Object)\n check filter, Match.Optional(Object)\n check limit, Match.Optional(Number)\n check unknown_arg, Match.Any\n return unless Houston._user_is_admin @userId\n try\n collection.find(filter, sort: sort, limit: limit)\n catch e\n console.log e\n\n collection.find().observe\n added: (document) ->\n Houston._collections.collections.update {name},\n $inc: {count: 1},\n $addToSet: fields: $each: Houston._get_fields([document])\n removed: (document) -> Houston._collections.collections.update {name}, {$inc: {count: -1}}\n\n fields = Houston._get_fields(collection.find().fetch())", "source_lang": "JavaScript", "target_lang": "CoffeeScript", "repo": "gterrono/houston", "path": "server/publications.coffee", "license": "MIT", "commit": "610792505b6af1a34d4e0a3f846df923f114d531", "stars": 802, "source_url": "https://github.com/gterrono/houston/blob/610792505b6af1a34d4e0a3f846df923f114d531/server/publications.coffee", "line_start": 11, "line_end": 60}758{"id": "gterrono/houston:server/publications.coffee:2:completion", "type": "completion", "prompt": "Houston._setup_collection = (collection) ->\n return if collection._name of ADDED_COLLECTIONS\n\n name = collection._name\n methods = {}\n methods[Houston._houstonize \"#{name}_insert\"] = (doc) ->\n check doc, Object\n return unless Houston._user_is_admin @userId\n collection.insert(doc)\n\n methods[Houston._houstonize \"#{name}_update\"] = (id, update_dict) ->\n check id, Match.Any\n check update_dict, Object\n return unless Houston._user_is_admin @userId\n if collection.findOne(id)\n collection.update(id, update_dict)\n else\n id = collection.findOne(new Meteor.Collection.ObjectID(id))\n collection.update(id, update_dict)\n\n methods[Houston._houstonize \"#{name}_delete\"] = (id) ->\n check id, Match.Any\n return unless Houston._user_is_admin @userId\n if collection.findOne(id)\n collection.remove(id)", "response": "else\n id = collection.findOne(new Meteor.Collection.ObjectID(id))\n collection.remove(id)\n\n Meteor.methods methods\n\n Houston._publish name, (sort, filter, limit, unknown_arg) ->\n check sort, Match.Optional(Object)\n check filter, Match.Optional(Object)\n check limit, Match.Optional(Number)\n check unknown_arg, Match.Any\n return unless Houston._user_is_admin @userId\n try\n collection.find(filter, sort: sort, limit: limit)\n catch e\n console.log e\n\n collection.find().observe\n added: (document) ->\n Houston._collections.collections.update {name},\n $inc: {count: 1},\n $addToSet: fields: $each: Houston._get_fields([document])\n removed: (document) -> Houston._collections.collections.update {name}, {$inc: {count: -1}}\n\n fields = Houston._get_fields(collection.find().fetch())", "source_lang": "CoffeeScript", "target_lang": "CoffeeScript", "repo": "gterrono/houston", "path": "server/publications.coffee", "license": "MIT", "commit": "610792505b6af1a34d4e0a3f846df923f114d531", "stars": 802, "source_url": "https://github.com/gterrono/houston/blob/610792505b6af1a34d4e0a3f846df923f114d531/server/publications.coffee", "line_start": 11, "line_end": 60}759{"id": "gterrono/houston:server/publications.coffee:3:raw_corpus", "type": "raw_corpus", "prompt": "", "response": "c = Houston._collections.collections.findOne {name}\n if c\n Houston._collections.collections.update c._id, {$set: count: collection.find().count(), fields: fields}\n else\n Houston._collections.collections.insert {name, count: collection.find().count(), fields: fields}\n ADDED_COLLECTIONS[name] = collection", "source_lang": "", "target_lang": "CoffeeScript", "repo": "gterrono/houston", "path": "server/publications.coffee", "license": "MIT", "commit": "610792505b6af1a34d4e0a3f846df923f114d531", "stars": 802, "source_url": "https://github.com/gterrono/houston/blob/610792505b6af1a34d4e0a3f846df923f114d531/server/publications.coffee", "line_start": 61, "line_end": 66}760{"id": "gterrono/houston:server/publications.coffee:3:completion", "type": "completion", "prompt": "c = Houston._collections.collections.findOne {name}\n if c\n Houston._collections.collections.update c._id, {$set: count: collection.find().count(), fields: fields}", "response": "else\n Houston._collections.collections.insert {name, count: collection.find().count(), fields: fields}\n ADDED_COLLECTIONS[name] = collection", "source_lang": "CoffeeScript", "target_lang": "CoffeeScript", "repo": "gterrono/houston", "path": "server/publications.coffee", "license": "MIT", "commit": "610792505b6af1a34d4e0a3f846df923f114d531", "stars": 802, "source_url": "https://github.com/gterrono/houston/blob/610792505b6af1a34d4e0a3f846df923f114d531/server/publications.coffee", "line_start": 61, "line_end": 66}761{"id": "gterrono/houston:server/publications.coffee:2:raw_corpus", "type": "raw_corpus", "prompt": "", "response": "Houston._setup_collection = (collection) ->\n return if collection._name of ADDED_COLLECTIONS\n\n name = collection._name\n methods = {}\n methods[Houston._houstonize \"#{name}_insert\"] = (doc) ->\n check doc, Object\n return unless Houston._user_is_admin @userId\n collection.insert(doc)\n\n methods[Houston._houstonize \"#{name}_update\"] = (id, update_dict) ->\n check id, Match.Any\n check update_dict, Object\n return unless Houston._user_is_admin @userId\n if collection.findOne(id)\n collection.update(id, update_dict)\n else\n id = collection.findOne(new Meteor.Collection.ObjectID(id))\n collection.update(id, update_dict)\n\n methods[Houston._houstonize \"#{name}_delete\"] = (id) ->\n check id, Match.Any\n return unless Houston._user_is_admin @userId\n if collection.findOne(id)\n collection.remove(id)\n else\n id = collection.findOne(new Meteor.Collection.ObjectID(id))\n collection.remove(id)\n\n Meteor.methods methods\n\n Houston._publish name, (sort, filter, limit, unknown_arg) ->\n check sort, Match.Optional(Object)\n check filter, Match.Optional(Object)\n check limit, Match.Optional(Number)\n check unknown_arg, Match.Any\n return unless Houston._user_is_admin @userId\n try\n collection.find(filter, sort: sort, limit: limit)\n catch e\n console.log e\n\n collection.find().observe\n added: (document) ->\n Houston._collections.collections.update {name},\n $inc: {count: 1},\n $addToSet: fields: $each: Houston._get_field_names([document])\n removed: (document) -> Houston._collections.collections.update {name}, {$inc: {count: -1}}\n\n fields = Houston._get_field_names(collection.find().fetch())", "source_lang": "", "target_lang": "CoffeeScript", "repo": "gterrono/houston", "path": "server/publications.coffee", "license": "MIT", "commit": "6c8017af343a6de6eb6ef616d0de13dba04eda29", "stars": 802, "source_url": "https://github.com/gterrono/houston/blob/6c8017af343a6de6eb6ef616d0de13dba04eda29/server/publications.coffee", "line_start": 11, "line_end": 60}762{"id": "gterrono/houston:server/publications.coffee:2:coffee_to_js", "type": "coffee_to_js", "prompt": "Convert this CoffeeScript to JavaScript.\n```coffeescript\nHouston._setup_collection = (collection) ->\n return if collection._name of ADDED_COLLECTIONS\n\n name = collection._name\n methods = {}\n methods[Houston._houstonize \"#{name}_insert\"] = (doc) ->\n check doc, Object\n return unless Houston._user_is_admin @userId\n collection.insert(doc)\n\n methods[Houston._houstonize \"#{name}_update\"] = (id, update_dict) ->\n check id, Match.Any\n check update_dict, Object\n return unless Houston._user_is_admin @userId\n if collection.findOne(id)\n collection.update(id, update_dict)\n else\n id = collection.findOne(new Meteor.Collection.ObjectID(id))\n collection.update(id, update_dict)\n\n methods[Houston._houstonize \"#{name}_delete\"] = (id) ->\n check id, Match.Any\n return unless Houston._user_is_admin @userId\n if collection.findOne(id)\n collection.remove(id)\n else\n id = collection.findOne(new Meteor.Collection.ObjectID(id))\n collection.remove(id)\n\n Meteor.methods methods\n\n Houston._publish name, (sort, filter, limit, unknown_arg) ->\n check sort, Match.Optional(Object)\n check filter, Match.Optional(Object)\n check limit, Match.Optional(Number)\n check unknown_arg, Match.Any\n return unless Houston._user_is_admin @userId\n try\n collection.find(filter, sort: sort, limit: limit)\n catch e\n console.log e\n\n collection.find().observe\n added: (document) ->\n Houston._collections.collections.update {name},\n $inc: {count: 1},\n $addToSet: fields: $each: Houston._get_field_names([document])\n removed: (document) -> Houston._collections.collections.update {name}, {$inc: {count: -1}}\n\n fields = Houston._get_field_names(collection.find().fetch())\n```", "response": "Houston._setup_collection = function(collection) {\n var fields, methods, name;\n if (collection._name in ADDED_COLLECTIONS) {\n return;\n }\n name = collection._name;\n methods = {};\n methods[Houston._houstonize(`${name}_insert`)] = function(doc) {\n check(doc, Object);\n if (!Houston._user_is_admin(this.userId)) {\n return;\n }\n return collection.insert(doc);\n };\n methods[Houston._houstonize(`${name}_update`)] = function(id, update_dict) {\n check(id, Match.Any);\n check(update_dict, Object);\n if (!Houston._user_is_admin(this.userId)) {\n return;\n }\n if (collection.findOne(id)) {\n return collection.update(id, update_dict);\n } else {\n id = collection.findOne(new Meteor.Collection.ObjectID(id));\n return collection.update(id, update_dict);\n }\n };\n methods[Houston._houstonize(`${name}_delete`)] = function(id) {\n check(id, Match.Any);\n if (!Houston._user_is_admin(this.userId)) {\n return;\n }\n if (collection.findOne(id)) {\n return collection.remove(id);\n } else {\n id = collection.findOne(new Meteor.Collection.ObjectID(id));\n return collection.remove(id);\n }\n };\n Meteor.methods(methods);\n Houston._publish(name, function(sort, filter, limit, unknown_arg) {\n var e;\n check(sort, Match.Optional(Object));\n check(filter, Match.Optional(Object));\n check(limit, Match.Optional(Number));\n check(unknown_arg, Match.Any);\n if (!Houston._user_is_admin(this.userId)) {\n return;\n }\n try {\n return collection.find(filter, {\n sort: sort,\n limit: limit\n });\n } catch (error) {\n e = error;\n return console.log(e);\n }\n });\n collection.find().observe({\n added: function(document) {\n return Houston._collections.collections.update({name}, {\n $inc: {\n count: 1\n },\n $addToSet: {\n fields: {\n $each: Houston._get_field_names([document])\n }\n }\n });\n },\n removed: function(document) {\n return Houston._collections.collections.update({name}, {\n $inc: {\n count: -1\n }\n });\n }\n });\n return fields = Houston._get_field_names(collection.find().fetch());\n};", "source_lang": "CoffeeScript", "target_lang": "JavaScript", "repo": "gterrono/houston", "path": "server/publications.coffee", "license": "MIT", "commit": "6c8017af343a6de6eb6ef616d0de13dba04eda29", "stars": 802, "source_url": "https://github.com/gterrono/houston/blob/6c8017af343a6de6eb6ef616d0de13dba04eda29/server/publications.coffee", "line_start": 11, "line_end": 60}763{"id": "gterrono/houston:server/publications.coffee:2:js_to_coffee", "type": "js_to_coffee", "prompt": "Convert this JavaScript to CoffeeScript.\n```javascript\nHouston._setup_collection = function(collection) {\n var fields, methods, name;\n if (collection._name in ADDED_COLLECTIONS) {\n return;\n }\n name = collection._name;\n methods = {};\n methods[Houston._houstonize(`${name}_insert`)] = function(doc) {\n check(doc, Object);\n if (!Houston._user_is_admin(this.userId)) {\n return;\n }\n return collection.insert(doc);\n };\n methods[Houston._houstonize(`${name}_update`)] = function(id, update_dict) {\n check(id, Match.Any);\n check(update_dict, Object);\n if (!Houston._user_is_admin(this.userId)) {\n return;\n }\n if (collection.findOne(id)) {\n return collection.update(id, update_dict);\n } else {\n id = collection.findOne(new Meteor.Collection.ObjectID(id));\n return collection.update(id, update_dict);\n }\n };\n methods[Houston._houstonize(`${name}_delete`)] = function(id) {\n check(id, Match.Any);\n if (!Houston._user_is_admin(this.userId)) {\n return;\n }\n if (collection.findOne(id)) {\n return collection.remove(id);\n } else {\n id = collection.findOne(new Meteor.Collection.ObjectID(id));\n return collection.remove(id);\n }\n };\n Meteor.methods(methods);\n Houston._publish(name, function(sort, filter, limit, unknown_arg) {\n var e;\n check(sort, Match.Optional(Object));\n check(filter, Match.Optional(Object));\n check(limit, Match.Optional(Number));\n check(unknown_arg, Match.Any);\n if (!Houston._user_is_admin(this.userId)) {\n return;\n }\n try {\n return collection.find(filter, {\n sort: sort,\n limit: limit\n });\n } catch (error) {\n e = error;\n return console.log(e);\n }\n });\n collection.find().observe({\n added: function(document) {\n return Houston._collections.collections.update({name}, {\n $inc: {\n count: 1\n },\n $addToSet: {\n fields: {\n $each: Houston._get_field_names([document])\n }\n }\n });\n },\n removed: function(document) {\n return Houston._collections.collections.update({name}, {\n $inc: {\n count: -1\n }\n });\n }\n });\n return fields = Houston._get_field_names(collection.find().fetch());\n};\n```", "response": "Houston._setup_collection = (collection) ->\n return if collection._name of ADDED_COLLECTIONS\n\n name = collection._name\n methods = {}\n methods[Houston._houstonize \"#{name}_insert\"] = (doc) ->\n check doc, Object\n return unless Houston._user_is_admin @userId\n collection.insert(doc)\n\n methods[Houston._houstonize \"#{name}_update\"] = (id, update_dict) ->\n check id, Match.Any\n check update_dict, Object\n return unless Houston._user_is_admin @userId\n if collection.findOne(id)\n collection.update(id, update_dict)\n else\n id = collection.findOne(new Meteor.Collection.ObjectID(id))\n collection.update(id, update_dict)\n\n methods[Houston._houstonize \"#{name}_delete\"] = (id) ->\n check id, Match.Any\n return unless Houston._user_is_admin @userId\n if collection.findOne(id)\n collection.remove(id)\n else\n id = collection.findOne(new Meteor.Collection.ObjectID(id))\n collection.remove(id)\n\n Meteor.methods methods\n\n Houston._publish name, (sort, filter, limit, unknown_arg) ->\n check sort, Match.Optional(Object)\n check filter, Match.Optional(Object)\n check limit, Match.Optional(Number)\n check unknown_arg, Match.Any\n return unless Houston._user_is_admin @userId\n try\n collection.find(filter, sort: sort, limit: limit)\n catch e\n console.log e\n\n collection.find().observe\n added: (document) ->\n Houston._collections.collections.update {name},\n $inc: {count: 1},\n $addToSet: fields: $each: Houston._get_field_names([document])\n removed: (document) -> Houston._collections.collections.update {name}, {$inc: {count: -1}}\n\n fields = Houston._get_field_names(collection.find().fetch())", "source_lang": "JavaScript", "target_lang": "CoffeeScript", "repo": "gterrono/houston", "path": "server/publications.coffee", "license": "MIT", "commit": "6c8017af343a6de6eb6ef616d0de13dba04eda29", "stars": 802, "source_url": "https://github.com/gterrono/houston/blob/6c8017af343a6de6eb6ef616d0de13dba04eda29/server/publications.coffee", "line_start": 11, "line_end": 60}764{"id": "gterrono/houston:server/publications.coffee:2:completion", "type": "completion", "prompt": "Houston._setup_collection = (collection) ->\n return if collection._name of ADDED_COLLECTIONS\n\n name = collection._name\n methods = {}\n methods[Houston._houstonize \"#{name}_insert\"] = (doc) ->\n check doc, Object\n return unless Houston._user_is_admin @userId\n collection.insert(doc)\n\n methods[Houston._houstonize \"#{name}_update\"] = (id, update_dict) ->\n check id, Match.Any\n check update_dict, Object\n return unless Houston._user_is_admin @userId\n if collection.findOne(id)\n collection.update(id, update_dict)\n else\n id = collection.findOne(new Meteor.Collection.ObjectID(id))\n collection.update(id, update_dict)\n\n methods[Houston._houstonize \"#{name}_delete\"] = (id) ->\n check id, Match.Any\n return unless Houston._user_is_admin @userId\n if collection.findOne(id)\n collection.remove(id)", "response": "else\n id = collection.findOne(new Meteor.Collection.ObjectID(id))\n collection.remove(id)\n\n Meteor.methods methods\n\n Houston._publish name, (sort, filter, limit, unknown_arg) ->\n check sort, Match.Optional(Object)\n check filter, Match.Optional(Object)\n check limit, Match.Optional(Number)\n check unknown_arg, Match.Any\n return unless Houston._user_is_admin @userId\n try\n collection.find(filter, sort: sort, limit: limit)\n catch e\n console.log e\n\n collection.find().observe\n added: (document) ->\n Houston._collections.collections.update {name},\n $inc: {count: 1},\n $addToSet: fields: $each: Houston._get_field_names([document])\n removed: (document) -> Houston._collections.collections.update {name}, {$inc: {count: -1}}\n\n fields = Houston._get_field_names(collection.find().fetch())", "source_lang": "CoffeeScript", "target_lang": "CoffeeScript", "repo": "gterrono/houston", "path": "server/publications.coffee", "license": "MIT", "commit": "6c8017af343a6de6eb6ef616d0de13dba04eda29", "stars": 802, "source_url": "https://github.com/gterrono/houston/blob/6c8017af343a6de6eb6ef616d0de13dba04eda29/server/publications.coffee", "line_start": 11, "line_end": 60}765{"id": "gterrono/houston:server/publications.coffee:2:raw_corpus", "type": "raw_corpus", "prompt": "", "response": "Houston._setup_collection = (collection) ->\n return if collection._name of ADDED_COLLECTIONS\n\n name = collection._name\n methods = {}\n methods[Houston._houstonize \"#{name}_insert\"] = (doc) ->\n return unless Houston._user_is_admin @userId\n collection.insert(doc)\n\n methods[Houston._houstonize \"#{name}_update\"] = (id, update_dict) ->\n return unless Houston._user_is_admin @userId\n if collection.findOne(id)\n collection.update(id, update_dict)\n else\n id = collection.findOne(new Meteor.Collection.ObjectID(id))\n collection.update(id, update_dict)\n\n methods[Houston._houstonize \"#{name}_delete\"] = (id, update_dict) ->\n return unless Houston._user_is_admin @userId\n if collection.findOne(id)\n collection.remove(id)\n else\n id = collection.findOne(new Meteor.Collection.ObjectID(id))\n collection.remove(id)\n\n Meteor.methods methods\n\n Houston._publish name, (sort, filter, limit) ->\n check sort, Match.Optional(Object)\n check filter, Match.Optional(Object)\n check limit, Match.Optional(Number)\n return unless Houston._user_is_admin @userId\n try\n collection.find(filter, sort: sort, limit: limit)\n catch e\n console.log e\n\n collection.find().observe\n added: (document) ->\n Houston._collections.collections.update {name},\n $inc: {count: 1},\n $addToSet: fields: $each: Houston._get_field_names([document])\n removed: (document) -> Houston._collections.collections.update {name}, {$inc: {count: -1}}\n\n fields = Houston._get_field_names(collection.find().fetch())\n c = Houston._collections.collections.findOne {name}\n if c\n Houston._collections.collections.update c._id, {$set: count: collection.find().count(), fields: fields}\n else\n Houston._collections.collections.insert {name, count: collection.find().count(), fields: fields}", "source_lang": "", "target_lang": "CoffeeScript", "repo": "gterrono/houston", "path": "server/publications.coffee", "license": "MIT", "commit": "62588db41fa572526d01f25843f32addd4f0eb1d", "stars": 802, "source_url": "https://github.com/gterrono/houston/blob/62588db41fa572526d01f25843f32addd4f0eb1d/server/publications.coffee", "line_start": 11, "line_end": 60}766{"id": "gterrono/houston:server/publications.coffee:2:coffee_to_js", "type": "coffee_to_js", "prompt": "Convert this CoffeeScript to JavaScript.\n```coffeescript\nHouston._setup_collection = (collection) ->\n return if collection._name of ADDED_COLLECTIONS\n\n name = collection._name\n methods = {}\n methods[Houston._houstonize \"#{name}_insert\"] = (doc) ->\n return unless Houston._user_is_admin @userId\n collection.insert(doc)\n\n methods[Houston._houstonize \"#{name}_update\"] = (id, update_dict) ->\n return unless Houston._user_is_admin @userId\n if collection.findOne(id)\n collection.update(id, update_dict)\n else\n id = collection.findOne(new Meteor.Collection.ObjectID(id))\n collection.update(id, update_dict)\n\n methods[Houston._houstonize \"#{name}_delete\"] = (id, update_dict) ->\n return unless Houston._user_is_admin @userId\n if collection.findOne(id)\n collection.remove(id)\n else\n id = collection.findOne(new Meteor.Collection.ObjectID(id))\n collection.remove(id)\n\n Meteor.methods methods\n\n Houston._publish name, (sort, filter, limit) ->\n check sort, Match.Optional(Object)\n check filter, Match.Optional(Object)\n check limit, Match.Optional(Number)\n return unless Houston._user_is_admin @userId\n try\n collection.find(filter, sort: sort, limit: limit)\n catch e\n console.log e\n\n collection.find().observe\n added: (document) ->\n Houston._collections.collections.update {name},\n $inc: {count: 1},\n $addToSet: fields: $each: Houston._get_field_names([document])\n removed: (document) -> Houston._collections.collections.update {name}, {$inc: {count: -1}}\n\n fields = Houston._get_field_names(collection.find().fetch())\n c = Houston._collections.collections.findOne {name}\n if c\n Houston._collections.collections.update c._id, {$set: count: collection.find().count(), fields: fields}\n else\n Houston._collections.collections.insert {name, count: collection.find().count(), fields: fields}\n```", "response": "Houston._setup_collection = function(collection) {\n var c, fields, methods, name;\n if (collection._name in ADDED_COLLECTIONS) {\n return;\n }\n name = collection._name;\n methods = {};\n methods[Houston._houstonize(`${name}_insert`)] = function(doc) {\n if (!Houston._user_is_admin(this.userId)) {\n return;\n }\n return collection.insert(doc);\n };\n methods[Houston._houstonize(`${name}_update`)] = function(id, update_dict) {\n if (!Houston._user_is_admin(this.userId)) {\n return;\n }\n if (collection.findOne(id)) {\n return collection.update(id, update_dict);\n } else {\n id = collection.findOne(new Meteor.Collection.ObjectID(id));\n return collection.update(id, update_dict);\n }\n };\n methods[Houston._houstonize(`${name}_delete`)] = function(id, update_dict) {\n if (!Houston._user_is_admin(this.userId)) {\n return;\n }\n if (collection.findOne(id)) {\n return collection.remove(id);\n } else {\n id = collection.findOne(new Meteor.Collection.ObjectID(id));\n return collection.remove(id);\n }\n };\n Meteor.methods(methods);\n Houston._publish(name, function(sort, filter, limit) {\n var e;\n check(sort, Match.Optional(Object));\n check(filter, Match.Optional(Object));\n check(limit, Match.Optional(Number));\n if (!Houston._user_is_admin(this.userId)) {\n return;\n }\n try {\n return collection.find(filter, {\n sort: sort,\n limit: limit\n });\n } catch (error) {\n e = error;\n return console.log(e);\n }\n });\n collection.find().observe({\n added: function(document) {\n return Houston._collections.collections.update({name}, {\n $inc: {\n count: 1\n },\n $addToSet: {\n fields: {\n $each: Houston._get_field_names([document])\n }\n }\n });\n },\n removed: function(document) {\n return Houston._collections.collections.update({name}, {\n $inc: {\n count: -1\n }\n });\n }\n });\n fields = Houston._get_field_names(collection.find().fetch());\n c = Houston._collections.collections.findOne({name});\n if (c) {\n return Houston._collections.collections.update(c._id, {\n $set: {\n count: collection.find().count(),\n fields: fields\n }\n });\n } else {\n return Houston._collections.collections.insert({\n name,\n count: collection.find().count(),\n fields: fields\n });\n }\n};", "source_lang": "CoffeeScript", "target_lang": "JavaScript", "repo": "gterrono/houston", "path": "server/publications.coffee", "license": "MIT", "commit": "62588db41fa572526d01f25843f32addd4f0eb1d", "stars": 802, "source_url": "https://github.com/gterrono/houston/blob/62588db41fa572526d01f25843f32addd4f0eb1d/server/publications.coffee", "line_start": 11, "line_end": 60}767{"id": "gterrono/houston:server/publications.coffee:2:js_to_coffee", "type": "js_to_coffee", "prompt": "Convert this JavaScript to CoffeeScript.\n```javascript\nHouston._setup_collection = function(collection) {\n var c, fields, methods, name;\n if (collection._name in ADDED_COLLECTIONS) {\n return;\n }\n name = collection._name;\n methods = {};\n methods[Houston._houstonize(`${name}_insert`)] = function(doc) {\n if (!Houston._user_is_admin(this.userId)) {\n return;\n }\n return collection.insert(doc);\n };\n methods[Houston._houstonize(`${name}_update`)] = function(id, update_dict) {\n if (!Houston._user_is_admin(this.userId)) {\n return;\n }\n if (collection.findOne(id)) {\n return collection.update(id, update_dict);\n } else {\n id = collection.findOne(new Meteor.Collection.ObjectID(id));\n return collection.update(id, update_dict);\n }\n };\n methods[Houston._houstonize(`${name}_delete`)] = function(id, update_dict) {\n if (!Houston._user_is_admin(this.userId)) {\n return;\n }\n if (collection.findOne(id)) {\n return collection.remove(id);\n } else {\n id = collection.findOne(new Meteor.Collection.ObjectID(id));\n return collection.remove(id);\n }\n };\n Meteor.methods(methods);\n Houston._publish(name, function(sort, filter, limit) {\n var e;\n check(sort, Match.Optional(Object));\n check(filter, Match.Optional(Object));\n check(limit, Match.Optional(Number));\n if (!Houston._user_is_admin(this.userId)) {\n return;\n }\n try {\n return collection.find(filter, {\n sort: sort,\n limit: limit\n });\n } catch (error) {\n e = error;\n return console.log(e);\n }\n });\n collection.find().observe({\n added: function(document) {\n return Houston._collections.collections.update({name}, {\n $inc: {\n count: 1\n },\n $addToSet: {\n fields: {\n $each: Houston._get_field_names([document])\n }\n }\n });\n },\n removed: function(document) {\n return Houston._collections.collections.update({name}, {\n $inc: {\n count: -1\n }\n });\n }\n });\n fields = Houston._get_field_names(collection.find().fetch());\n c = Houston._collections.collections.findOne({name});\n if (c) {\n return Houston._collections.collections.update(c._id, {\n $set: {\n count: collection.find().count(),\n fields: fields\n }\n });\n } else {\n return Houston._collections.collections.insert({\n name,\n count: collection.find().count(),\n fields: fields\n });\n }\n};\n```", "response": "Houston._setup_collection = (collection) ->\n return if collection._name of ADDED_COLLECTIONS\n\n name = collection._name\n methods = {}\n methods[Houston._houstonize \"#{name}_insert\"] = (doc) ->\n return unless Houston._user_is_admin @userId\n collection.insert(doc)\n\n methods[Houston._houstonize \"#{name}_update\"] = (id, update_dict) ->\n return unless Houston._user_is_admin @userId\n if collection.findOne(id)\n collection.update(id, update_dict)\n else\n id = collection.findOne(new Meteor.Collection.ObjectID(id))\n collection.update(id, update_dict)\n\n methods[Houston._houstonize \"#{name}_delete\"] = (id, update_dict) ->\n return unless Houston._user_is_admin @userId\n if collection.findOne(id)\n collection.remove(id)\n else\n id = collection.findOne(new Meteor.Collection.ObjectID(id))\n collection.remove(id)\n\n Meteor.methods methods\n\n Houston._publish name, (sort, filter, limit) ->\n check sort, Match.Optional(Object)\n check filter, Match.Optional(Object)\n check limit, Match.Optional(Number)\n return unless Houston._user_is_admin @userId\n try\n collection.find(filter, sort: sort, limit: limit)\n catch e\n console.log e\n\n collection.find().observe\n added: (document) ->\n Houston._collections.collections.update {name},\n $inc: {count: 1},\n $addToSet: fields: $each: Houston._get_field_names([document])\n removed: (document) -> Houston._collections.collections.update {name}, {$inc: {count: -1}}\n\n fields = Houston._get_field_names(collection.find().fetch())\n c = Houston._collections.collections.findOne {name}\n if c\n Houston._collections.collections.update c._id, {$set: count: collection.find().count(), fields: fields}\n else\n Houston._collections.collections.insert {name, count: collection.find().count(), fields: fields}", "source_lang": "JavaScript", "target_lang": "CoffeeScript", "repo": "gterrono/houston", "path": "server/publications.coffee", "license": "MIT", "commit": "62588db41fa572526d01f25843f32addd4f0eb1d", "stars": 802, "source_url": "https://github.com/gterrono/houston/blob/62588db41fa572526d01f25843f32addd4f0eb1d/server/publications.coffee", "line_start": 11, "line_end": 60}768{"id": "gterrono/houston:server/publications.coffee:2:completion", "type": "completion", "prompt": "Houston._setup_collection = (collection) ->\n return if collection._name of ADDED_COLLECTIONS\n\n name = collection._name\n methods = {}\n methods[Houston._houstonize \"#{name}_insert\"] = (doc) ->\n return unless Houston._user_is_admin @userId\n collection.insert(doc)\n\n methods[Houston._houstonize \"#{name}_update\"] = (id, update_dict) ->\n return unless Houston._user_is_admin @userId\n if collection.findOne(id)\n collection.update(id, update_dict)\n else\n id = collection.findOne(new Meteor.Collection.ObjectID(id))\n collection.update(id, update_dict)\n\n methods[Houston._houstonize \"#{name}_delete\"] = (id, update_dict) ->\n return unless Houston._user_is_admin @userId\n if collection.findOne(id)\n collection.remove(id)\n else\n id = collection.findOne(new Meteor.Collection.ObjectID(id))\n collection.remove(id)", "response": "Meteor.methods methods\n\n Houston._publish name, (sort, filter, limit) ->\n check sort, Match.Optional(Object)\n check filter, Match.Optional(Object)\n check limit, Match.Optional(Number)\n return unless Houston._user_is_admin @userId\n try\n collection.find(filter, sort: sort, limit: limit)\n catch e\n console.log e\n\n collection.find().observe\n added: (document) ->\n Houston._collections.collections.update {name},\n $inc: {count: 1},\n $addToSet: fields: $each: Houston._get_field_names([document])\n removed: (document) -> Houston._collections.collections.update {name}, {$inc: {count: -1}}\n\n fields = Houston._get_field_names(collection.find().fetch())\n c = Houston._collections.collections.findOne {name}\n if c\n Houston._collections.collections.update c._id, {$set: count: collection.find().count(), fields: fields}\n else\n Houston._collections.collections.insert {name, count: collection.find().count(), fields: fields}", "source_lang": "CoffeeScript", "target_lang": "CoffeeScript", "repo": "gterrono/houston", "path": "server/publications.coffee", "license": "MIT", "commit": "62588db41fa572526d01f25843f32addd4f0eb1d", "stars": 802, "source_url": "https://github.com/gterrono/houston/blob/62588db41fa572526d01f25843f32addd4f0eb1d/server/publications.coffee", "line_start": 11, "line_end": 60}769{"id": "gterrono/houston:server/publications.coffee:4:raw_corpus", "type": "raw_corpus", "prompt": "", "response": "sync_collections = ->\n Dummy.findOne() # hack. TODO: verify this is still necessary\n\n _sync_collections = (meh, collections_db) ->\n collection_names = (col.collectionName for col in collections_db \\\n when (col.collectionName.indexOf \"system.\") isnt 0 and\n (col.collectionName.indexOf \"houston_\") isnt 0)\n\n collection_names.forEach (name) ->\n unless name of ADDED_COLLECTIONS or name of HIDDEN_COLLECTIONS\n new_collection = null\n try\n new_collection = new Meteor.Collection(name)\n catch e\n for key, value of root\n if name == value?._name # TODO here - typecheck also?\n new_collection = value\n\n if new_collection? # found it!\n Houston._setup_collection(new_collection)\n else\n console.log \"\"\"\nHouston: couldn't find access to the #{name} collection.\nIf you'd like to access the collection from Houston, either\n(1) make sure it is available as a global (top-level namespace) within the server or\n(2) add the collection manually via Houston.add_collection\n\"\"\"\n\n bound_sync_collections = Meteor.bindEnvironment _sync_collections, (e) ->\n console.log \"Failed while syncing collections for reason: #{e}\"\n\n # MongoInternals is the 'right' solution as of 0.6.5\n mongo_driver = MongoInternals?.defaultRemoteCollectionDriver() or Meteor._RemoteCollectionDriver\n mongo_driver.mongo.db.collections bound_sync_collections\n\nMeteor.methods\n _houston_make_admin: (user_id) ->\n check user_id, String\n # limit one admin\n return if Houston._admins.findOne {'user_id': $exists: true}\n Houston._admins.insert {user_id}\n sync_collections() # reloads collections in case of new app\n return true\n\n# publish our analysis of the app's collections\nHouston._publish 'collections', ->\n return unless Houston._user_is_admin @userId\n Houston._collections.collections.find()\n\n# TODO address inherent security issue", "source_lang": "", "target_lang": "CoffeeScript", "repo": "gterrono/houston", "path": "server/publications.coffee", "license": "MIT", "commit": "e60d6cc4b3150262e34672baf6ac4b7a2193b71f", "stars": 802, "source_url": "https://github.com/gterrono/houston/blob/e60d6cc4b3150262e34672baf6ac4b7a2193b71f/server/publications.coffee", "line_start": 63, "line_end": 112}770{"id": "gterrono/houston:server/publications.coffee:4:coffee_to_js", "type": "coffee_to_js", "prompt": "Convert this CoffeeScript to JavaScript.\n```coffeescript\nsync_collections = ->\n Dummy.findOne() # hack. TODO: verify this is still necessary\n\n _sync_collections = (meh, collections_db) ->\n collection_names = (col.collectionName for col in collections_db \\\n when (col.collectionName.indexOf \"system.\") isnt 0 and\n (col.collectionName.indexOf \"houston_\") isnt 0)\n\n collection_names.forEach (name) ->\n unless name of ADDED_COLLECTIONS or name of HIDDEN_COLLECTIONS\n new_collection = null\n try\n new_collection = new Meteor.Collection(name)\n catch e\n for key, value of root\n if name == value?._name # TODO here - typecheck also?\n new_collection = value\n\n if new_collection? # found it!\n Houston._setup_collection(new_collection)\n else\n console.log \"\"\"\nHouston: couldn't find access to the #{name} collection.\nIf you'd like to access the collection from Houston, either\n(1) make sure it is available as a global (top-level namespace) within the server or\n(2) add the collection manually via Houston.add_collection\n\"\"\"\n\n bound_sync_collections = Meteor.bindEnvironment _sync_collections, (e) ->\n console.log \"Failed while syncing collections for reason: #{e}\"\n\n # MongoInternals is the 'right' solution as of 0.6.5\n mongo_driver = MongoInternals?.defaultRemoteCollectionDriver() or Meteor._RemoteCollectionDriver\n mongo_driver.mongo.db.collections bound_sync_collections\n\nMeteor.methods\n _houston_make_admin: (user_id) ->\n check user_id, String\n # limit one admin\n return if Houston._admins.findOne {'user_id': $exists: true}\n Houston._admins.insert {user_id}\n sync_collections() # reloads collections in case of new app\n return true\n\n# publish our analysis of the app's collections\nHouston._publish 'collections', ->\n return unless Houston._user_is_admin @userId\n Houston._collections.collections.find()\n\n# TODO address inherent security issue\n```", "response": "var sync_collections;\n\nsync_collections = function() {\n var _sync_collections, bound_sync_collections, mongo_driver;\n Dummy.findOne(); // hack. TODO: verify this is still necessary\n _sync_collections = function(meh, collections_db) {\n var col, collection_names;\n collection_names = (function() {\n var i, len, results;\n results = [];\n for (i = 0, len = collections_db.length; i < len; i++) {\n col = collections_db[i];\n if ((col.collectionName.indexOf(\"system.\")) !== 0 && (col.collectionName.indexOf(\"houston_\")) !== 0) {\n results.push(col.collectionName);\n }\n }\n return results;\n })();\n return collection_names.forEach(function(name) {\n var e, key, new_collection, value;\n if (!(name in ADDED_COLLECTIONS || name in HIDDEN_COLLECTIONS)) {\n new_collection = null;\n try {\n new_collection = new Meteor.Collection(name);\n } catch (error) {\n e = error;\n for (key in root) {\n value = root[key];\n if (name === (value != null ? value._name : void 0)) { // TODO here - typecheck also?\n new_collection = value;\n }\n }\n }\n if (new_collection != null) {\n return Houston._setup_collection(new_collection);\n } else {\n return console.log(`Houston: couldn't find access to the ${name} collection.\nIf you'd like to access the collection from Houston, either\n(1) make sure it is available as a global (top-level namespace) within the server or\n(2) add the collection manually via Houston.add_collection`); // found it!\n }\n }\n });\n };\n bound_sync_collections = Meteor.bindEnvironment(_sync_collections, function(e) {\n return console.log(`Failed while syncing collections for reason: ${e}`);\n });\n // MongoInternals is the 'right' solution as of 0.6.5\n mongo_driver = (typeof MongoInternals !== \"undefined\" && MongoInternals !== null ? MongoInternals.defaultRemoteCollectionDriver() : void 0) || Meteor._RemoteCollectionDriver;\n return mongo_driver.mongo.db.collections(bound_sync_collections);\n};\n\nMeteor.methods({\n _houston_make_admin: function(user_id) {\n check(user_id, String);\n // limit one admin\n if (Houston._admins.findOne({\n 'user_id': {\n $exists: true\n }\n })) {\n return;\n }\n Houston._admins.insert({user_id});\n sync_collections(); // reloads collections in case of new app\n return true;\n }\n});\n\n// publish our analysis of the app's collections\nHouston._publish('collections', function() {\n if (!Houston._user_is_admin(this.userId)) {\n return;\n }\n return Houston._collections.collections.find();\n});\n\n// TODO address inherent security issue", "source_lang": "CoffeeScript", "target_lang": "JavaScript", "repo": "gterrono/houston", "path": "server/publications.coffee", "license": "MIT", "commit": "e60d6cc4b3150262e34672baf6ac4b7a2193b71f", "stars": 802, "source_url": "https://github.com/gterrono/houston/blob/e60d6cc4b3150262e34672baf6ac4b7a2193b71f/server/publications.coffee", "line_start": 63, "line_end": 112}771{"id": "gterrono/houston:server/publications.coffee:4:js_to_coffee", "type": "js_to_coffee", "prompt": "Convert this JavaScript to CoffeeScript.\n```javascript\nvar sync_collections;\n\nsync_collections = function() {\n var _sync_collections, bound_sync_collections, mongo_driver;\n Dummy.findOne(); // hack. TODO: verify this is still necessary\n _sync_collections = function(meh, collections_db) {\n var col, collection_names;\n collection_names = (function() {\n var i, len, results;\n results = [];\n for (i = 0, len = collections_db.length; i < len; i++) {\n col = collections_db[i];\n if ((col.collectionName.indexOf(\"system.\")) !== 0 && (col.collectionName.indexOf(\"houston_\")) !== 0) {\n results.push(col.collectionName);\n }\n }\n return results;\n })();\n return collection_names.forEach(function(name) {\n var e, key, new_collection, value;\n if (!(name in ADDED_COLLECTIONS || name in HIDDEN_COLLECTIONS)) {\n new_collection = null;\n try {\n new_collection = new Meteor.Collection(name);\n } catch (error) {\n e = error;\n for (key in root) {\n value = root[key];\n if (name === (value != null ? value._name : void 0)) { // TODO here - typecheck also?\n new_collection = value;\n }\n }\n }\n if (new_collection != null) {\n return Houston._setup_collection(new_collection);\n } else {\n return console.log(`Houston: couldn't find access to the ${name} collection.\nIf you'd like to access the collection from Houston, either\n(1) make sure it is available as a global (top-level namespace) within the server or\n(2) add the collection manually via Houston.add_collection`); // found it!\n }\n }\n });\n };\n bound_sync_collections = Meteor.bindEnvironment(_sync_collections, function(e) {\n return console.log(`Failed while syncing collections for reason: ${e}`);\n });\n // MongoInternals is the 'right' solution as of 0.6.5\n mongo_driver = (typeof MongoInternals !== \"undefined\" && MongoInternals !== null ? MongoInternals.defaultRemoteCollectionDriver() : void 0) || Meteor._RemoteCollectionDriver;\n return mongo_driver.mongo.db.collections(bound_sync_collections);\n};\n\nMeteor.methods({\n _houston_make_admin: function(user_id) {\n check(user_id, String);\n // limit one admin\n if (Houston._admins.findOne({\n 'user_id': {\n $exists: true\n }\n })) {\n return;\n }\n Houston._admins.insert({user_id});\n sync_collections(); // reloads collections in case of new app\n return true;\n }\n});\n\n// publish our analysis of the app's collections\nHouston._publish('collections', function() {\n if (!Houston._user_is_admin(this.userId)) {\n return;\n }\n return Houston._collections.collections.find();\n});\n\n// TODO address inherent security issue\n```", "response": "sync_collections = ->\n Dummy.findOne() # hack. TODO: verify this is still necessary\n\n _sync_collections = (meh, collections_db) ->\n collection_names = (col.collectionName for col in collections_db \\\n when (col.collectionName.indexOf \"system.\") isnt 0 and\n (col.collectionName.indexOf \"houston_\") isnt 0)\n\n collection_names.forEach (name) ->\n unless name of ADDED_COLLECTIONS or name of HIDDEN_COLLECTIONS\n new_collection = null\n try\n new_collection = new Meteor.Collection(name)\n catch e\n for key, value of root\n if name == value?._name # TODO here - typecheck also?\n new_collection = value\n\n if new_collection? # found it!\n Houston._setup_collection(new_collection)\n else\n console.log \"\"\"\nHouston: couldn't find access to the #{name} collection.\nIf you'd like to access the collection from Houston, either\n(1) make sure it is available as a global (top-level namespace) within the server or\n(2) add the collection manually via Houston.add_collection\n\"\"\"\n\n bound_sync_collections = Meteor.bindEnvironment _sync_collections, (e) ->\n console.log \"Failed while syncing collections for reason: #{e}\"\n\n # MongoInternals is the 'right' solution as of 0.6.5\n mongo_driver = MongoInternals?.defaultRemoteCollectionDriver() or Meteor._RemoteCollectionDriver\n mongo_driver.mongo.db.collections bound_sync_collections\n\nMeteor.methods\n _houston_make_admin: (user_id) ->\n check user_id, String\n # limit one admin\n return if Houston._admins.findOne {'user_id': $exists: true}\n Houston._admins.insert {user_id}\n sync_collections() # reloads collections in case of new app\n return true\n\n# publish our analysis of the app's collections\nHouston._publish 'collections', ->\n return unless Houston._user_is_admin @userId\n Houston._collections.collections.find()\n\n# TODO address inherent security issue", "source_lang": "JavaScript", "target_lang": "CoffeeScript", "repo": "gterrono/houston", "path": "server/publications.coffee", "license": "MIT", "commit": "e60d6cc4b3150262e34672baf6ac4b7a2193b71f", "stars": 802, "source_url": "https://github.com/gterrono/houston/blob/e60d6cc4b3150262e34672baf6ac4b7a2193b71f/server/publications.coffee", "line_start": 63, "line_end": 112}772{"id": "gterrono/houston:server/publications.coffee:4:completion", "type": "completion", "prompt": "sync_collections = ->\n Dummy.findOne() # hack. TODO: verify this is still necessary\n\n _sync_collections = (meh, collections_db) ->\n collection_names = (col.collectionName for col in collections_db \\\n when (col.collectionName.indexOf \"system.\") isnt 0 and\n (col.collectionName.indexOf \"houston_\") isnt 0)\n\n collection_names.forEach (name) ->\n unless name of ADDED_COLLECTIONS or name of HIDDEN_COLLECTIONS\n new_collection = null\n try\n new_collection = new Meteor.Collection(name)\n catch e\n for key, value of root\n if name == value?._name # TODO here - typecheck also?\n new_collection = value\n\n if new_collection? # found it!\n Houston._setup_collection(new_collection)\n else\n console.log \"\"\"\nHouston: couldn't find access to the #{name} collection.\nIf you'd like to access the collection from Houston, either\n(1) make sure it is available as a global (top-level namespace) within the server or", "response": "(2) add the collection manually via Houston.add_collection\n\"\"\"\n\n bound_sync_collections = Meteor.bindEnvironment _sync_collections, (e) ->\n console.log \"Failed while syncing collections for reason: #{e}\"\n\n # MongoInternals is the 'right' solution as of 0.6.5\n mongo_driver = MongoInternals?.defaultRemoteCollectionDriver() or Meteor._RemoteCollectionDriver\n mongo_driver.mongo.db.collections bound_sync_collections\n\nMeteor.methods\n _houston_make_admin: (user_id) ->\n check user_id, String\n # limit one admin\n return if Houston._admins.findOne {'user_id': $exists: true}\n Houston._admins.insert {user_id}\n sync_collections() # reloads collections in case of new app\n return true\n\n# publish our analysis of the app's collections\nHouston._publish 'collections', ->\n return unless Houston._user_is_admin @userId\n Houston._collections.collections.find()\n\n# TODO address inherent security issue", "source_lang": "CoffeeScript", "target_lang": "CoffeeScript", "repo": "gterrono/houston", "path": "server/publications.coffee", "license": "MIT", "commit": "e60d6cc4b3150262e34672baf6ac4b7a2193b71f", "stars": 802, "source_url": "https://github.com/gterrono/houston/blob/e60d6cc4b3150262e34672baf6ac4b7a2193b71f/server/publications.coffee", "line_start": 63, "line_end": 112}773{"id": "gterrono/houston:server/publications.coffee:4:raw_corpus", "type": "raw_corpus", "prompt": "", "response": "sync_collections = ->\n Dummy.findOne() # hack. TODO: verify this is still necessary\n\n _sync_collections = (meh, collections_db) ->\n collection_names = (col.collectionName for col in collections_db \\\n when (col.collectionName.indexOf \"system.\") isnt 0 and\n (col.collectionName.indexOf \"houston_\") isnt 0)\n\n collection_names.forEach (name) ->\n unless name of ADDED_COLLECTIONS or name of HIDDEN_COLLECTIONS\n new_collection = null\n try\n new_collection = new Meteor.Collection(name)\n catch e\n for key, value of root\n if name == value._name # TODO here - typecheck also?\n new_collection = value\n\n if new_collection? # found it!\n Houston._setup_collection(new_collection)\n else\n console.log \"\"\"\nHouston: couldn't find access to the #{name} collection.\nIf you'd like to access the collection from Houston, either\n(1) make sure it is available as a global (top-level namespace) within the server or\n(2) add the collection manually via Houston.add_collection\n\"\"\"\n\n bound_sync_collections = Meteor.bindEnvironment _sync_collections, (e) ->\n console.log \"Failed while syncing collections for reason: #{e}\"\n\n # MongoInternals is the 'right' solution as of 0.6.5\n mongo_driver = MongoInternals?.defaultRemoteCollectionDriver() or Meteor._RemoteCollectionDriver\n mongo_driver.mongo.db.collections bound_sync_collections\n\nMeteor.methods\n _houston_make_admin: (user_id) ->\n check userId, String\n # limit one admin\n return if Houston._admins.findOne {'user_id': $exists: true}\n Houston._admins.insert {user_id}\n sync_collections() # reloads collections in case of new app\n return true\n\n# publish our analysis of the app's collections\nHouston._publish 'collections', ->\n return unless Houston._user_is_admin @userId\n Houston._collections.collections.find()\n\n# TODO address inherent security issue", "source_lang": "", "target_lang": "CoffeeScript", "repo": "gterrono/houston", "path": "server/publications.coffee", "license": "MIT", "commit": "c79a4d08ec66ce4c52d1e5a8bf29b0f79956e418", "stars": 802, "source_url": "https://github.com/gterrono/houston/blob/c79a4d08ec66ce4c52d1e5a8bf29b0f79956e418/server/publications.coffee", "line_start": 63, "line_end": 112}774{"id": "gterrono/houston:server/publications.coffee:4:coffee_to_js", "type": "coffee_to_js", "prompt": "Convert this CoffeeScript to JavaScript.\n```coffeescript\nsync_collections = ->\n Dummy.findOne() # hack. TODO: verify this is still necessary\n\n _sync_collections = (meh, collections_db) ->\n collection_names = (col.collectionName for col in collections_db \\\n when (col.collectionName.indexOf \"system.\") isnt 0 and\n (col.collectionName.indexOf \"houston_\") isnt 0)\n\n collection_names.forEach (name) ->\n unless name of ADDED_COLLECTIONS or name of HIDDEN_COLLECTIONS\n new_collection = null\n try\n new_collection = new Meteor.Collection(name)\n catch e\n for key, value of root\n if name == value._name # TODO here - typecheck also?\n new_collection = value\n\n if new_collection? # found it!\n Houston._setup_collection(new_collection)\n else\n console.log \"\"\"\nHouston: couldn't find access to the #{name} collection.\nIf you'd like to access the collection from Houston, either\n(1) make sure it is available as a global (top-level namespace) within the server or\n(2) add the collection manually via Houston.add_collection\n\"\"\"\n\n bound_sync_collections = Meteor.bindEnvironment _sync_collections, (e) ->\n console.log \"Failed while syncing collections for reason: #{e}\"\n\n # MongoInternals is the 'right' solution as of 0.6.5\n mongo_driver = MongoInternals?.defaultRemoteCollectionDriver() or Meteor._RemoteCollectionDriver\n mongo_driver.mongo.db.collections bound_sync_collections\n\nMeteor.methods\n _houston_make_admin: (user_id) ->\n check userId, String\n # limit one admin\n return if Houston._admins.findOne {'user_id': $exists: true}\n Houston._admins.insert {user_id}\n sync_collections() # reloads collections in case of new app\n return true\n\n# publish our analysis of the app's collections\nHouston._publish 'collections', ->\n return unless Houston._user_is_admin @userId\n Houston._collections.collections.find()\n\n# TODO address inherent security issue\n```", "response": "var sync_collections;\n\nsync_collections = function() {\n var _sync_collections, bound_sync_collections, mongo_driver;\n Dummy.findOne(); // hack. TODO: verify this is still necessary\n _sync_collections = function(meh, collections_db) {\n var col, collection_names;\n collection_names = (function() {\n var i, len, results;\n results = [];\n for (i = 0, len = collections_db.length; i < len; i++) {\n col = collections_db[i];\n if ((col.collectionName.indexOf(\"system.\")) !== 0 && (col.collectionName.indexOf(\"houston_\")) !== 0) {\n results.push(col.collectionName);\n }\n }\n return results;\n })();\n return collection_names.forEach(function(name) {\n var e, key, new_collection, value;\n if (!(name in ADDED_COLLECTIONS || name in HIDDEN_COLLECTIONS)) {\n new_collection = null;\n try {\n new_collection = new Meteor.Collection(name);\n } catch (error) {\n e = error;\n for (key in root) {\n value = root[key];\n if (name === value._name) { // TODO here - typecheck also?\n new_collection = value;\n }\n }\n }\n if (new_collection != null) {\n return Houston._setup_collection(new_collection);\n } else {\n return console.log(`Houston: couldn't find access to the ${name} collection.\nIf you'd like to access the collection from Houston, either\n(1) make sure it is available as a global (top-level namespace) within the server or\n(2) add the collection manually via Houston.add_collection`); // found it!\n }\n }\n });\n };\n bound_sync_collections = Meteor.bindEnvironment(_sync_collections, function(e) {\n return console.log(`Failed while syncing collections for reason: ${e}`);\n });\n // MongoInternals is the 'right' solution as of 0.6.5\n mongo_driver = (typeof MongoInternals !== \"undefined\" && MongoInternals !== null ? MongoInternals.defaultRemoteCollectionDriver() : void 0) || Meteor._RemoteCollectionDriver;\n return mongo_driver.mongo.db.collections(bound_sync_collections);\n};\n\nMeteor.methods({\n _houston_make_admin: function(user_id) {\n check(userId, String);\n // limit one admin\n if (Houston._admins.findOne({\n 'user_id': {\n $exists: true\n }\n })) {\n return;\n }\n Houston._admins.insert({user_id});\n sync_collections(); // reloads collections in case of new app\n return true;\n }\n});\n\n// publish our analysis of the app's collections\nHouston._publish('collections', function() {\n if (!Houston._user_is_admin(this.userId)) {\n return;\n }\n return Houston._collections.collections.find();\n});\n\n// TODO address inherent security issue", "source_lang": "CoffeeScript", "target_lang": "JavaScript", "repo": "gterrono/houston", "path": "server/publications.coffee", "license": "MIT", "commit": "c79a4d08ec66ce4c52d1e5a8bf29b0f79956e418", "stars": 802, "source_url": "https://github.com/gterrono/houston/blob/c79a4d08ec66ce4c52d1e5a8bf29b0f79956e418/server/publications.coffee", "line_start": 63, "line_end": 112}775{"id": "gterrono/houston:server/publications.coffee:4:js_to_coffee", "type": "js_to_coffee", "prompt": "Convert this JavaScript to CoffeeScript.\n```javascript\nvar sync_collections;\n\nsync_collections = function() {\n var _sync_collections, bound_sync_collections, mongo_driver;\n Dummy.findOne(); // hack. TODO: verify this is still necessary\n _sync_collections = function(meh, collections_db) {\n var col, collection_names;\n collection_names = (function() {\n var i, len, results;\n results = [];\n for (i = 0, len = collections_db.length; i < len; i++) {\n col = collections_db[i];\n if ((col.collectionName.indexOf(\"system.\")) !== 0 && (col.collectionName.indexOf(\"houston_\")) !== 0) {\n results.push(col.collectionName);\n }\n }\n return results;\n })();\n return collection_names.forEach(function(name) {\n var e, key, new_collection, value;\n if (!(name in ADDED_COLLECTIONS || name in HIDDEN_COLLECTIONS)) {\n new_collection = null;\n try {\n new_collection = new Meteor.Collection(name);\n } catch (error) {\n e = error;\n for (key in root) {\n value = root[key];\n if (name === value._name) { // TODO here - typecheck also?\n new_collection = value;\n }\n }\n }\n if (new_collection != null) {\n return Houston._setup_collection(new_collection);\n } else {\n return console.log(`Houston: couldn't find access to the ${name} collection.\nIf you'd like to access the collection from Houston, either\n(1) make sure it is available as a global (top-level namespace) within the server or\n(2) add the collection manually via Houston.add_collection`); // found it!\n }\n }\n });\n };\n bound_sync_collections = Meteor.bindEnvironment(_sync_collections, function(e) {\n return console.log(`Failed while syncing collections for reason: ${e}`);\n });\n // MongoInternals is the 'right' solution as of 0.6.5\n mongo_driver = (typeof MongoInternals !== \"undefined\" && MongoInternals !== null ? MongoInternals.defaultRemoteCollectionDriver() : void 0) || Meteor._RemoteCollectionDriver;\n return mongo_driver.mongo.db.collections(bound_sync_collections);\n};\n\nMeteor.methods({\n _houston_make_admin: function(user_id) {\n check(userId, String);\n // limit one admin\n if (Houston._admins.findOne({\n 'user_id': {\n $exists: true\n }\n })) {\n return;\n }\n Houston._admins.insert({user_id});\n sync_collections(); // reloads collections in case of new app\n return true;\n }\n});\n\n// publish our analysis of the app's collections\nHouston._publish('collections', function() {\n if (!Houston._user_is_admin(this.userId)) {\n return;\n }\n return Houston._collections.collections.find();\n});\n\n// TODO address inherent security issue\n```", "response": "sync_collections = ->\n Dummy.findOne() # hack. TODO: verify this is still necessary\n\n _sync_collections = (meh, collections_db) ->\n collection_names = (col.collectionName for col in collections_db \\\n when (col.collectionName.indexOf \"system.\") isnt 0 and\n (col.collectionName.indexOf \"houston_\") isnt 0)\n\n collection_names.forEach (name) ->\n unless name of ADDED_COLLECTIONS or name of HIDDEN_COLLECTIONS\n new_collection = null\n try\n new_collection = new Meteor.Collection(name)\n catch e\n for key, value of root\n if name == value._name # TODO here - typecheck also?\n new_collection = value\n\n if new_collection? # found it!\n Houston._setup_collection(new_collection)\n else\n console.log \"\"\"\nHouston: couldn't find access to the #{name} collection.\nIf you'd like to access the collection from Houston, either\n(1) make sure it is available as a global (top-level namespace) within the server or\n(2) add the collection manually via Houston.add_collection\n\"\"\"\n\n bound_sync_collections = Meteor.bindEnvironment _sync_collections, (e) ->\n console.log \"Failed while syncing collections for reason: #{e}\"\n\n # MongoInternals is the 'right' solution as of 0.6.5\n mongo_driver = MongoInternals?.defaultRemoteCollectionDriver() or Meteor._RemoteCollectionDriver\n mongo_driver.mongo.db.collections bound_sync_collections\n\nMeteor.methods\n _houston_make_admin: (user_id) ->\n check userId, String\n # limit one admin\n return if Houston._admins.findOne {'user_id': $exists: true}\n Houston._admins.insert {user_id}\n sync_collections() # reloads collections in case of new app\n return true\n\n# publish our analysis of the app's collections\nHouston._publish 'collections', ->\n return unless Houston._user_is_admin @userId\n Houston._collections.collections.find()\n\n# TODO address inherent security issue", "source_lang": "JavaScript", "target_lang": "CoffeeScript", "repo": "gterrono/houston", "path": "server/publications.coffee", "license": "MIT", "commit": "c79a4d08ec66ce4c52d1e5a8bf29b0f79956e418", "stars": 802, "source_url": "https://github.com/gterrono/houston/blob/c79a4d08ec66ce4c52d1e5a8bf29b0f79956e418/server/publications.coffee", "line_start": 63, "line_end": 112}776{"id": "gterrono/houston:server/publications.coffee:4:completion", "type": "completion", "prompt": "sync_collections = ->\n Dummy.findOne() # hack. TODO: verify this is still necessary\n\n _sync_collections = (meh, collections_db) ->\n collection_names = (col.collectionName for col in collections_db \\\n when (col.collectionName.indexOf \"system.\") isnt 0 and\n (col.collectionName.indexOf \"houston_\") isnt 0)\n\n collection_names.forEach (name) ->\n unless name of ADDED_COLLECTIONS or name of HIDDEN_COLLECTIONS\n new_collection = null\n try\n new_collection = new Meteor.Collection(name)\n catch e\n for key, value of root\n if name == value._name # TODO here - typecheck also?\n new_collection = value\n\n if new_collection? # found it!\n Houston._setup_collection(new_collection)\n else\n console.log \"\"\"\nHouston: couldn't find access to the #{name} collection.\nIf you'd like to access the collection from Houston, either\n(1) make sure it is available as a global (top-level namespace) within the server or", "response": "(2) add the collection manually via Houston.add_collection\n\"\"\"\n\n bound_sync_collections = Meteor.bindEnvironment _sync_collections, (e) ->\n console.log \"Failed while syncing collections for reason: #{e}\"\n\n # MongoInternals is the 'right' solution as of 0.6.5\n mongo_driver = MongoInternals?.defaultRemoteCollectionDriver() or Meteor._RemoteCollectionDriver\n mongo_driver.mongo.db.collections bound_sync_collections\n\nMeteor.methods\n _houston_make_admin: (user_id) ->\n check userId, String\n # limit one admin\n return if Houston._admins.findOne {'user_id': $exists: true}\n Houston._admins.insert {user_id}\n sync_collections() # reloads collections in case of new app\n return true\n\n# publish our analysis of the app's collections\nHouston._publish 'collections', ->\n return unless Houston._user_is_admin @userId\n Houston._collections.collections.find()\n\n# TODO address inherent security issue", "source_lang": "CoffeeScript", "target_lang": "CoffeeScript", "repo": "gterrono/houston", "path": "server/publications.coffee", "license": "MIT", "commit": "c79a4d08ec66ce4c52d1e5a8bf29b0f79956e418", "stars": 802, "source_url": "https://github.com/gterrono/houston/blob/c79a4d08ec66ce4c52d1e5a8bf29b0f79956e418/server/publications.coffee", "line_start": 63, "line_end": 112}777{"id": "gterrono/houston:server/publications.coffee:2:raw_corpus", "type": "raw_corpus", "prompt": "", "response": "Houston._setup_collection = (collection) ->\n return if collection._name of ADDED_COLLECTIONS\n\n name = collection._name\n methods = {}\n methods[Houston._houstonize \"#{name}_insert\"] = (doc) ->\n return unless Houston._user_is_admin @userId\n collection.insert(doc)\n\n methods[Houston._houstonize \"#{name}_update\"] = (id, update_dict) ->\n return unless Houston._user_is_admin @userId\n if collection.findOne(id)\n collection.update(id, update_dict)\n else\n id = collection.findOne(new Meteor.Collection.ObjectID(id))\n collection.update(id, update_dict)\n\n methods[Houston._houstonize \"#{name}_delete\"] = (id, update_dict) ->\n return unless Houston._user_is_admin @userId\n if collection.findOne(id)\n collection.remove(id)\n else\n id = collection.findOne(new Meteor.Collection.ObjectID(id))\n collection.remove(id)\n\n Meteor.methods methods\n\n Houston._publish name, (sort, filter, limit) ->\n check sort, Object\n check filter, Object\n check limit, Number\n return unless Houston._user_is_admin @userId\n try\n collection.find(filter, sort: sort, limit: limit)\n catch e\n console.log e\n\n collection.find().observe\n added: (document) ->\n Houston._collections.collections.update {name},\n $inc: {count: 1},\n $addToSet: fields: $each: Houston._get_field_names([document])\n removed: (document) -> Houston._collections.collections.update {name}, {$inc: {count: -1}}\n\n fields = Houston._get_field_names(collection.find().fetch())\n c = Houston._collections.collections.findOne {name}\n if c\n Houston._collections.collections.update c._id, {$set: count: collection.find().count(), fields: fields}\n else\n Houston._collections.collections.insert {name, count: collection.find().count(), fields: fields}", "source_lang": "", "target_lang": "CoffeeScript", "repo": "gterrono/houston", "path": "server/publications.coffee", "license": "MIT", "commit": "03e16f4ac8263d902f245d3edebaa09d54382329", "stars": 802, "source_url": "https://github.com/gterrono/houston/blob/03e16f4ac8263d902f245d3edebaa09d54382329/server/publications.coffee", "line_start": 11, "line_end": 60}778{"id": "gterrono/houston:server/publications.coffee:2:coffee_to_js", "type": "coffee_to_js", "prompt": "Convert this CoffeeScript to JavaScript.\n```coffeescript\nHouston._setup_collection = (collection) ->\n return if collection._name of ADDED_COLLECTIONS\n\n name = collection._name\n methods = {}\n methods[Houston._houstonize \"#{name}_insert\"] = (doc) ->\n return unless Houston._user_is_admin @userId\n collection.insert(doc)\n\n methods[Houston._houstonize \"#{name}_update\"] = (id, update_dict) ->\n return unless Houston._user_is_admin @userId\n if collection.findOne(id)\n collection.update(id, update_dict)\n else\n id = collection.findOne(new Meteor.Collection.ObjectID(id))\n collection.update(id, update_dict)\n\n methods[Houston._houstonize \"#{name}_delete\"] = (id, update_dict) ->\n return unless Houston._user_is_admin @userId\n if collection.findOne(id)\n collection.remove(id)\n else\n id = collection.findOne(new Meteor.Collection.ObjectID(id))\n collection.remove(id)\n\n Meteor.methods methods\n\n Houston._publish name, (sort, filter, limit) ->\n check sort, Object\n check filter, Object\n check limit, Number\n return unless Houston._user_is_admin @userId\n try\n collection.find(filter, sort: sort, limit: limit)\n catch e\n console.log e\n\n collection.find().observe\n added: (document) ->\n Houston._collections.collections.update {name},\n $inc: {count: 1},\n $addToSet: fields: $each: Houston._get_field_names([document])\n removed: (document) -> Houston._collections.collections.update {name}, {$inc: {count: -1}}\n\n fields = Houston._get_field_names(collection.find().fetch())\n c = Houston._collections.collections.findOne {name}\n if c\n Houston._collections.collections.update c._id, {$set: count: collection.find().count(), fields: fields}\n else\n Houston._collections.collections.insert {name, count: collection.find().count(), fields: fields}\n```", "response": "Houston._setup_collection = function(collection) {\n var c, fields, methods, name;\n if (collection._name in ADDED_COLLECTIONS) {\n return;\n }\n name = collection._name;\n methods = {};\n methods[Houston._houstonize(`${name}_insert`)] = function(doc) {\n if (!Houston._user_is_admin(this.userId)) {\n return;\n }\n return collection.insert(doc);\n };\n methods[Houston._houstonize(`${name}_update`)] = function(id, update_dict) {\n if (!Houston._user_is_admin(this.userId)) {\n return;\n }\n if (collection.findOne(id)) {\n return collection.update(id, update_dict);\n } else {\n id = collection.findOne(new Meteor.Collection.ObjectID(id));\n return collection.update(id, update_dict);\n }\n };\n methods[Houston._houstonize(`${name}_delete`)] = function(id, update_dict) {\n if (!Houston._user_is_admin(this.userId)) {\n return;\n }\n if (collection.findOne(id)) {\n return collection.remove(id);\n } else {\n id = collection.findOne(new Meteor.Collection.ObjectID(id));\n return collection.remove(id);\n }\n };\n Meteor.methods(methods);\n Houston._publish(name, function(sort, filter, limit) {\n var e;\n check(sort, Object);\n check(filter, Object);\n check(limit, Number);\n if (!Houston._user_is_admin(this.userId)) {\n return;\n }\n try {\n return collection.find(filter, {\n sort: sort,\n limit: limit\n });\n } catch (error) {\n e = error;\n return console.log(e);\n }\n });\n collection.find().observe({\n added: function(document) {\n return Houston._collections.collections.update({name}, {\n $inc: {\n count: 1\n },\n $addToSet: {\n fields: {\n $each: Houston._get_field_names([document])\n }\n }\n });\n },\n removed: function(document) {\n return Houston._collections.collections.update({name}, {\n $inc: {\n count: -1\n }\n });\n }\n });\n fields = Houston._get_field_names(collection.find().fetch());\n c = Houston._collections.collections.findOne({name});\n if (c) {\n return Houston._collections.collections.update(c._id, {\n $set: {\n count: collection.find().count(),\n fields: fields\n }\n });\n } else {\n return Houston._collections.collections.insert({\n name,\n count: collection.find().count(),\n fields: fields\n });\n }\n};", "source_lang": "CoffeeScript", "target_lang": "JavaScript", "repo": "gterrono/houston", "path": "server/publications.coffee", "license": "MIT", "commit": "03e16f4ac8263d902f245d3edebaa09d54382329", "stars": 802, "source_url": "https://github.com/gterrono/houston/blob/03e16f4ac8263d902f245d3edebaa09d54382329/server/publications.coffee", "line_start": 11, "line_end": 60}779{"id": "gterrono/houston:server/publications.coffee:2:js_to_coffee", "type": "js_to_coffee", "prompt": "Convert this JavaScript to CoffeeScript.\n```javascript\nHouston._setup_collection = function(collection) {\n var c, fields, methods, name;\n if (collection._name in ADDED_COLLECTIONS) {\n return;\n }\n name = collection._name;\n methods = {};\n methods[Houston._houstonize(`${name}_insert`)] = function(doc) {\n if (!Houston._user_is_admin(this.userId)) {\n return;\n }\n return collection.insert(doc);\n };\n methods[Houston._houstonize(`${name}_update`)] = function(id, update_dict) {\n if (!Houston._user_is_admin(this.userId)) {\n return;\n }\n if (collection.findOne(id)) {\n return collection.update(id, update_dict);\n } else {\n id = collection.findOne(new Meteor.Collection.ObjectID(id));\n return collection.update(id, update_dict);\n }\n };\n methods[Houston._houstonize(`${name}_delete`)] = function(id, update_dict) {\n if (!Houston._user_is_admin(this.userId)) {\n return;\n }\n if (collection.findOne(id)) {\n return collection.remove(id);\n } else {\n id = collection.findOne(new Meteor.Collection.ObjectID(id));\n return collection.remove(id);\n }\n };\n Meteor.methods(methods);\n Houston._publish(name, function(sort, filter, limit) {\n var e;\n check(sort, Object);\n check(filter, Object);\n check(limit, Number);\n if (!Houston._user_is_admin(this.userId)) {\n return;\n }\n try {\n return collection.find(filter, {\n sort: sort,\n limit: limit\n });\n } catch (error) {\n e = error;\n return console.log(e);\n }\n });\n collection.find().observe({\n added: function(document) {\n return Houston._collections.collections.update({name}, {\n $inc: {\n count: 1\n },\n $addToSet: {\n fields: {\n $each: Houston._get_field_names([document])\n }\n }\n });\n },\n removed: function(document) {\n return Houston._collections.collections.update({name}, {\n $inc: {\n count: -1\n }\n });\n }\n });\n fields = Houston._get_field_names(collection.find().fetch());\n c = Houston._collections.collections.findOne({name});\n if (c) {\n return Houston._collections.collections.update(c._id, {\n $set: {\n count: collection.find().count(),\n fields: fields\n }\n });\n } else {\n return Houston._collections.collections.insert({\n name,\n count: collection.find().count(),\n fields: fields\n });\n }\n};\n```", "response": "Houston._setup_collection = (collection) ->\n return if collection._name of ADDED_COLLECTIONS\n\n name = collection._name\n methods = {}\n methods[Houston._houstonize \"#{name}_insert\"] = (doc) ->\n return unless Houston._user_is_admin @userId\n collection.insert(doc)\n\n methods[Houston._houstonize \"#{name}_update\"] = (id, update_dict) ->\n return unless Houston._user_is_admin @userId\n if collection.findOne(id)\n collection.update(id, update_dict)\n else\n id = collection.findOne(new Meteor.Collection.ObjectID(id))\n collection.update(id, update_dict)\n\n methods[Houston._houstonize \"#{name}_delete\"] = (id, update_dict) ->\n return unless Houston._user_is_admin @userId\n if collection.findOne(id)\n collection.remove(id)\n else\n id = collection.findOne(new Meteor.Collection.ObjectID(id))\n collection.remove(id)\n\n Meteor.methods methods\n\n Houston._publish name, (sort, filter, limit) ->\n check sort, Object\n check filter, Object\n check limit, Number\n return unless Houston._user_is_admin @userId\n try\n collection.find(filter, sort: sort, limit: limit)\n catch e\n console.log e\n\n collection.find().observe\n added: (document) ->\n Houston._collections.collections.update {name},\n $inc: {count: 1},\n $addToSet: fields: $each: Houston._get_field_names([document])\n removed: (document) -> Houston._collections.collections.update {name}, {$inc: {count: -1}}\n\n fields = Houston._get_field_names(collection.find().fetch())\n c = Houston._collections.collections.findOne {name}\n if c\n Houston._collections.collections.update c._id, {$set: count: collection.find().count(), fields: fields}\n else\n Houston._collections.collections.insert {name, count: collection.find().count(), fields: fields}", "source_lang": "JavaScript", "target_lang": "CoffeeScript", "repo": "gterrono/houston", "path": "server/publications.coffee", "license": "MIT", "commit": "03e16f4ac8263d902f245d3edebaa09d54382329", "stars": 802, "source_url": "https://github.com/gterrono/houston/blob/03e16f4ac8263d902f245d3edebaa09d54382329/server/publications.coffee", "line_start": 11, "line_end": 60}780{"id": "gterrono/houston:server/publications.coffee:2:completion", "type": "completion", "prompt": "Houston._setup_collection = (collection) ->\n return if collection._name of ADDED_COLLECTIONS\n\n name = collection._name\n methods = {}\n methods[Houston._houstonize \"#{name}_insert\"] = (doc) ->\n return unless Houston._user_is_admin @userId\n collection.insert(doc)\n\n methods[Houston._houstonize \"#{name}_update\"] = (id, update_dict) ->\n return unless Houston._user_is_admin @userId\n if collection.findOne(id)\n collection.update(id, update_dict)\n else\n id = collection.findOne(new Meteor.Collection.ObjectID(id))\n collection.update(id, update_dict)\n\n methods[Houston._houstonize \"#{name}_delete\"] = (id, update_dict) ->\n return unless Houston._user_is_admin @userId\n if collection.findOne(id)\n collection.remove(id)\n else\n id = collection.findOne(new Meteor.Collection.ObjectID(id))\n collection.remove(id)", "response": "Meteor.methods methods\n\n Houston._publish name, (sort, filter, limit) ->\n check sort, Object\n check filter, Object\n check limit, Number\n return unless Houston._user_is_admin @userId\n try\n collection.find(filter, sort: sort, limit: limit)\n catch e\n console.log e\n\n collection.find().observe\n added: (document) ->\n Houston._collections.collections.update {name},\n $inc: {count: 1},\n $addToSet: fields: $each: Houston._get_field_names([document])\n removed: (document) -> Houston._collections.collections.update {name}, {$inc: {count: -1}}\n\n fields = Houston._get_field_names(collection.find().fetch())\n c = Houston._collections.collections.findOne {name}\n if c\n Houston._collections.collections.update c._id, {$set: count: collection.find().count(), fields: fields}\n else\n Houston._collections.collections.insert {name, count: collection.find().count(), fields: fields}", "source_lang": "CoffeeScript", "target_lang": "CoffeeScript", "repo": "gterrono/houston", "path": "server/publications.coffee", "license": "MIT", "commit": "03e16f4ac8263d902f245d3edebaa09d54382329", "stars": 802, "source_url": "https://github.com/gterrono/houston/blob/03e16f4ac8263d902f245d3edebaa09d54382329/server/publications.coffee", "line_start": 11, "line_end": 60}781{"id": "gterrono/houston:server/publications.coffee:2:raw_corpus", "type": "raw_corpus", "prompt": "", "response": "Houston._setup_collection = (collection) ->\n return if collection._name of ADDED_COLLECTIONS\n\n name = collection._name\n methods = {}\n methods[Houston._houstonize \"#{name}_insert\"] = (doc) ->\n return unless Houston._user_is_admin @userId\n collection.insert(doc)\n\n methods[Houston._houstonize \"#{name}_update\"] = (id, update_dict) ->\n return unless Houston._user_is_admin @userId\n if collection.findOne(id)\n collection.update(id, update_dict)\n else\n id = collection.findOne(new Meteor.Collection.ObjectID(id))\n collection.update(id, update_dict)\n\n methods[Houston._houstonize \"#{name}_delete\"] = (id, update_dict) ->\n return unless Houston._user_is_admin @userId\n if collection.findOne(id)\n collection.remove(id)\n else\n id = collection.findOne(new Meteor.Collection.ObjectID(id))\n collection.remove(id)\n\n Meteor.methods methods\n\n Houston._publish name, (sort, filter, limit) ->\n return unless Houston._user_is_admin @userId\n try\n collection.find(filter, sort: sort, limit: limit)\n catch e\n console.log e\n\n collection.find().observe\n added: (document) ->\n Houston._collections.collections.update {name},\n $inc: {count: 1},\n $addToSet: fields: $each: Houston._get_field_names([document])\n removed: (document) -> Houston._collections.collections.update {name}, {$inc: {count: -1}}\n\n fields = Houston._get_field_names(collection.find().fetch())\n c = Houston._collections.collections.findOne {name}\n if c\n Houston._collections.collections.update c._id, {$set: count: collection.find().count(), fields: fields}\n else\n Houston._collections.collections.insert {name, count: collection.find().count(), fields: fields}\n ADDED_COLLECTIONS[name] = collection", "source_lang": "", "target_lang": "CoffeeScript", "repo": "gterrono/houston", "path": "server/publications.coffee", "license": "MIT", "commit": "f4fae47b2e1a20bb2c44c506a2e226c158a4ce8a", "stars": 802, "source_url": "https://github.com/gterrono/houston/blob/f4fae47b2e1a20bb2c44c506a2e226c158a4ce8a/server/publications.coffee", "line_start": 11, "line_end": 58}782{"id": "gterrono/houston:server/publications.coffee:2:coffee_to_js", "type": "coffee_to_js", "prompt": "Convert this CoffeeScript to JavaScript.\n```coffeescript\nHouston._setup_collection = (collection) ->\n return if collection._name of ADDED_COLLECTIONS\n\n name = collection._name\n methods = {}\n methods[Houston._houstonize \"#{name}_insert\"] = (doc) ->\n return unless Houston._user_is_admin @userId\n collection.insert(doc)\n\n methods[Houston._houstonize \"#{name}_update\"] = (id, update_dict) ->\n return unless Houston._user_is_admin @userId\n if collection.findOne(id)\n collection.update(id, update_dict)\n else\n id = collection.findOne(new Meteor.Collection.ObjectID(id))\n collection.update(id, update_dict)\n\n methods[Houston._houstonize \"#{name}_delete\"] = (id, update_dict) ->\n return unless Houston._user_is_admin @userId\n if collection.findOne(id)\n collection.remove(id)\n else\n id = collection.findOne(new Meteor.Collection.ObjectID(id))\n collection.remove(id)\n\n Meteor.methods methods\n\n Houston._publish name, (sort, filter, limit) ->\n return unless Houston._user_is_admin @userId\n try\n collection.find(filter, sort: sort, limit: limit)\n catch e\n console.log e\n\n collection.find().observe\n added: (document) ->\n Houston._collections.collections.update {name},\n $inc: {count: 1},\n $addToSet: fields: $each: Houston._get_field_names([document])\n removed: (document) -> Houston._collections.collections.update {name}, {$inc: {count: -1}}\n\n fields = Houston._get_field_names(collection.find().fetch())\n c = Houston._collections.collections.findOne {name}\n if c\n Houston._collections.collections.update c._id, {$set: count: collection.find().count(), fields: fields}\n else\n Houston._collections.collections.insert {name, count: collection.find().count(), fields: fields}\n ADDED_COLLECTIONS[name] = collection\n```", "response": "Houston._setup_collection = function(collection) {\n var c, fields, methods, name;\n if (collection._name in ADDED_COLLECTIONS) {\n return;\n }\n name = collection._name;\n methods = {};\n methods[Houston._houstonize(`${name}_insert`)] = function(doc) {\n if (!Houston._user_is_admin(this.userId)) {\n return;\n }\n return collection.insert(doc);\n };\n methods[Houston._houstonize(`${name}_update`)] = function(id, update_dict) {\n if (!Houston._user_is_admin(this.userId)) {\n return;\n }\n if (collection.findOne(id)) {\n return collection.update(id, update_dict);\n } else {\n id = collection.findOne(new Meteor.Collection.ObjectID(id));\n return collection.update(id, update_dict);\n }\n };\n methods[Houston._houstonize(`${name}_delete`)] = function(id, update_dict) {\n if (!Houston._user_is_admin(this.userId)) {\n return;\n }\n if (collection.findOne(id)) {\n return collection.remove(id);\n } else {\n id = collection.findOne(new Meteor.Collection.ObjectID(id));\n return collection.remove(id);\n }\n };\n Meteor.methods(methods);\n Houston._publish(name, function(sort, filter, limit) {\n var e;\n if (!Houston._user_is_admin(this.userId)) {\n return;\n }\n try {\n return collection.find(filter, {\n sort: sort,\n limit: limit\n });\n } catch (error) {\n e = error;\n return console.log(e);\n }\n });\n collection.find().observe({\n added: function(document) {\n return Houston._collections.collections.update({name}, {\n $inc: {\n count: 1\n },\n $addToSet: {\n fields: {\n $each: Houston._get_field_names([document])\n }\n }\n });\n },\n removed: function(document) {\n return Houston._collections.collections.update({name}, {\n $inc: {\n count: -1\n }\n });\n }\n });\n fields = Houston._get_field_names(collection.find().fetch());\n c = Houston._collections.collections.findOne({name});\n if (c) {\n Houston._collections.collections.update(c._id, {\n $set: {\n count: collection.find().count(),\n fields: fields\n }\n });\n } else {\n Houston._collections.collections.insert({\n name,\n count: collection.find().count(),\n fields: fields\n });\n }\n return ADDED_COLLECTIONS[name] = collection;\n};", "source_lang": "CoffeeScript", "target_lang": "JavaScript", "repo": "gterrono/houston", "path": "server/publications.coffee", "license": "MIT", "commit": "f4fae47b2e1a20bb2c44c506a2e226c158a4ce8a", "stars": 802, "source_url": "https://github.com/gterrono/houston/blob/f4fae47b2e1a20bb2c44c506a2e226c158a4ce8a/server/publications.coffee", "line_start": 11, "line_end": 58}783{"id": "gterrono/houston:server/publications.coffee:2:js_to_coffee", "type": "js_to_coffee", "prompt": "Convert this JavaScript to CoffeeScript.\n```javascript\nHouston._setup_collection = function(collection) {\n var c, fields, methods, name;\n if (collection._name in ADDED_COLLECTIONS) {\n return;\n }\n name = collection._name;\n methods = {};\n methods[Houston._houstonize(`${name}_insert`)] = function(doc) {\n if (!Houston._user_is_admin(this.userId)) {\n return;\n }\n return collection.insert(doc);\n };\n methods[Houston._houstonize(`${name}_update`)] = function(id, update_dict) {\n if (!Houston._user_is_admin(this.userId)) {\n return;\n }\n if (collection.findOne(id)) {\n return collection.update(id, update_dict);\n } else {\n id = collection.findOne(new Meteor.Collection.ObjectID(id));\n return collection.update(id, update_dict);\n }\n };\n methods[Houston._houstonize(`${name}_delete`)] = function(id, update_dict) {\n if (!Houston._user_is_admin(this.userId)) {\n return;\n }\n if (collection.findOne(id)) {\n return collection.remove(id);\n } else {\n id = collection.findOne(new Meteor.Collection.ObjectID(id));\n return collection.remove(id);\n }\n };\n Meteor.methods(methods);\n Houston._publish(name, function(sort, filter, limit) {\n var e;\n if (!Houston._user_is_admin(this.userId)) {\n return;\n }\n try {\n return collection.find(filter, {\n sort: sort,\n limit: limit\n });\n } catch (error) {\n e = error;\n return console.log(e);\n }\n });\n collection.find().observe({\n added: function(document) {\n return Houston._collections.collections.update({name}, {\n $inc: {\n count: 1\n },\n $addToSet: {\n fields: {\n $each: Houston._get_field_names([document])\n }\n }\n });\n },\n removed: function(document) {\n return Houston._collections.collections.update({name}, {\n $inc: {\n count: -1\n }\n });\n }\n });\n fields = Houston._get_field_names(collection.find().fetch());\n c = Houston._collections.collections.findOne({name});\n if (c) {\n Houston._collections.collections.update(c._id, {\n $set: {\n count: collection.find().count(),\n fields: fields\n }\n });\n } else {\n Houston._collections.collections.insert({\n name,\n count: collection.find().count(),\n fields: fields\n });\n }\n return ADDED_COLLECTIONS[name] = collection;\n};\n```", "response": "Houston._setup_collection = (collection) ->\n return if collection._name of ADDED_COLLECTIONS\n\n name = collection._name\n methods = {}\n methods[Houston._houstonize \"#{name}_insert\"] = (doc) ->\n return unless Houston._user_is_admin @userId\n collection.insert(doc)\n\n methods[Houston._houstonize \"#{name}_update\"] = (id, update_dict) ->\n return unless Houston._user_is_admin @userId\n if collection.findOne(id)\n collection.update(id, update_dict)\n else\n id = collection.findOne(new Meteor.Collection.ObjectID(id))\n collection.update(id, update_dict)\n\n methods[Houston._houstonize \"#{name}_delete\"] = (id, update_dict) ->\n return unless Houston._user_is_admin @userId\n if collection.findOne(id)\n collection.remove(id)\n else\n id = collection.findOne(new Meteor.Collection.ObjectID(id))\n collection.remove(id)\n\n Meteor.methods methods\n\n Houston._publish name, (sort, filter, limit) ->\n return unless Houston._user_is_admin @userId\n try\n collection.find(filter, sort: sort, limit: limit)\n catch e\n console.log e\n\n collection.find().observe\n added: (document) ->\n Houston._collections.collections.update {name},\n $inc: {count: 1},\n $addToSet: fields: $each: Houston._get_field_names([document])\n removed: (document) -> Houston._collections.collections.update {name}, {$inc: {count: -1}}\n\n fields = Houston._get_field_names(collection.find().fetch())\n c = Houston._collections.collections.findOne {name}\n if c\n Houston._collections.collections.update c._id, {$set: count: collection.find().count(), fields: fields}\n else\n Houston._collections.collections.insert {name, count: collection.find().count(), fields: fields}\n ADDED_COLLECTIONS[name] = collection", "source_lang": "JavaScript", "target_lang": "CoffeeScript", "repo": "gterrono/houston", "path": "server/publications.coffee", "license": "MIT", "commit": "f4fae47b2e1a20bb2c44c506a2e226c158a4ce8a", "stars": 802, "source_url": "https://github.com/gterrono/houston/blob/f4fae47b2e1a20bb2c44c506a2e226c158a4ce8a/server/publications.coffee", "line_start": 11, "line_end": 58}784{"id": "gterrono/houston:server/publications.coffee:2:completion", "type": "completion", "prompt": "Houston._setup_collection = (collection) ->\n return if collection._name of ADDED_COLLECTIONS\n\n name = collection._name\n methods = {}\n methods[Houston._houstonize \"#{name}_insert\"] = (doc) ->\n return unless Houston._user_is_admin @userId\n collection.insert(doc)\n\n methods[Houston._houstonize \"#{name}_update\"] = (id, update_dict) ->\n return unless Houston._user_is_admin @userId\n if collection.findOne(id)\n collection.update(id, update_dict)\n else\n id = collection.findOne(new Meteor.Collection.ObjectID(id))\n collection.update(id, update_dict)\n\n methods[Houston._houstonize \"#{name}_delete\"] = (id, update_dict) ->\n return unless Houston._user_is_admin @userId\n if collection.findOne(id)\n collection.remove(id)\n else\n id = collection.findOne(new Meteor.Collection.ObjectID(id))\n collection.remove(id)", "response": "Meteor.methods methods\n\n Houston._publish name, (sort, filter, limit) ->\n return unless Houston._user_is_admin @userId\n try\n collection.find(filter, sort: sort, limit: limit)\n catch e\n console.log e\n\n collection.find().observe\n added: (document) ->\n Houston._collections.collections.update {name},\n $inc: {count: 1},\n $addToSet: fields: $each: Houston._get_field_names([document])\n removed: (document) -> Houston._collections.collections.update {name}, {$inc: {count: -1}}\n\n fields = Houston._get_field_names(collection.find().fetch())\n c = Houston._collections.collections.findOne {name}\n if c\n Houston._collections.collections.update c._id, {$set: count: collection.find().count(), fields: fields}\n else\n Houston._collections.collections.insert {name, count: collection.find().count(), fields: fields}\n ADDED_COLLECTIONS[name] = collection", "source_lang": "CoffeeScript", "target_lang": "CoffeeScript", "repo": "gterrono/houston", "path": "server/publications.coffee", "license": "MIT", "commit": "f4fae47b2e1a20bb2c44c506a2e226c158a4ce8a", "stars": 802, "source_url": "https://github.com/gterrono/houston/blob/f4fae47b2e1a20bb2c44c506a2e226c158a4ce8a/server/publications.coffee", "line_start": 11, "line_end": 58}785{"id": "gterrono/houston:server/publications.coffee:3:raw_corpus", "type": "raw_corpus", "prompt": "", "response": "sync_collections = ->\n Dummy.findOne() # hack. TODO: verify this is still necessary\n\n _sync_collections = (meh, collections_db) ->\n collection_names = (col.collectionName for col in collections_db \\\n when (col.collectionName.indexOf \"system.\") isnt 0 and\n (col.collectionName.indexOf \"houston_\") isnt 0)\n\n collection_names.forEach (name) ->\n unless name of ADDED_COLLECTIONS or name of HIDDEN_COLLECTIONS\n new_collection = null\n try\n new_collection = new Meteor.Collection(name)\n catch e\n for key, value of root\n if name == value?._name # TODO here - typecheck also?\n new_collection = value\n\n if new_collection? # found it!\n Houston._setup_collection(new_collection)\n else\n console.log \"\"\"\nHouston: couldn't find access to the #{name} collection.\nIf you'd like to access the collection from Houston, either\n(1) make sure it is available as a global (top-level namespace) within the server or\n(2) add the collection manually via Houston.add_collection\n\"\"\"\n\n bound_sync_collections = Meteor.bindEnvironment _sync_collections, (e) ->\n console.log \"Failed while syncing collections for reason: #{e}\"\n\n # MongoInternals is the 'right' solution as of 0.6.5\n mongo_driver = MongoInternals?.defaultRemoteCollectionDriver() or Meteor._RemoteCollectionDriver\n mongo_driver.mongo.db.collections bound_sync_collections\n\nMeteor.methods\n _houston_make_admin: (user_id) ->\n # limit one admin\n return if Houston._admins.findOne {'user_id': $exists: true}\n Houston._admins.insert {user_id}\n sync_collections() # reloads collections in case of new app\n return true\n\n# publish our analysis of the app's collections\nHouston._publish 'collections', ->\n return unless Houston._user_is_admin @userId\n Houston._collections.collections.find()\n\n# TODO address inherent security issue\nHouston._publish 'admin_user', ->", "source_lang": "", "target_lang": "CoffeeScript", "repo": "gterrono/houston", "path": "server/publications.coffee", "license": "MIT", "commit": "f4fae47b2e1a20bb2c44c506a2e226c158a4ce8a", "stars": 802, "source_url": "https://github.com/gterrono/houston/blob/f4fae47b2e1a20bb2c44c506a2e226c158a4ce8a/server/publications.coffee", "line_start": 60, "line_end": 109}786{"id": "gterrono/houston:server/publications.coffee:3:coffee_to_js", "type": "coffee_to_js", "prompt": "Convert this CoffeeScript to JavaScript.\n```coffeescript\nsync_collections = ->\n Dummy.findOne() # hack. TODO: verify this is still necessary\n\n _sync_collections = (meh, collections_db) ->\n collection_names = (col.collectionName for col in collections_db \\\n when (col.collectionName.indexOf \"system.\") isnt 0 and\n (col.collectionName.indexOf \"houston_\") isnt 0)\n\n collection_names.forEach (name) ->\n unless name of ADDED_COLLECTIONS or name of HIDDEN_COLLECTIONS\n new_collection = null\n try\n new_collection = new Meteor.Collection(name)\n catch e\n for key, value of root\n if name == value?._name # TODO here - typecheck also?\n new_collection = value\n\n if new_collection? # found it!\n Houston._setup_collection(new_collection)\n else\n console.log \"\"\"\nHouston: couldn't find access to the #{name} collection.\nIf you'd like to access the collection from Houston, either\n(1) make sure it is available as a global (top-level namespace) within the server or\n(2) add the collection manually via Houston.add_collection\n\"\"\"\n\n bound_sync_collections = Meteor.bindEnvironment _sync_collections, (e) ->\n console.log \"Failed while syncing collections for reason: #{e}\"\n\n # MongoInternals is the 'right' solution as of 0.6.5\n mongo_driver = MongoInternals?.defaultRemoteCollectionDriver() or Meteor._RemoteCollectionDriver\n mongo_driver.mongo.db.collections bound_sync_collections\n\nMeteor.methods\n _houston_make_admin: (user_id) ->\n # limit one admin\n return if Houston._admins.findOne {'user_id': $exists: true}\n Houston._admins.insert {user_id}\n sync_collections() # reloads collections in case of new app\n return true\n\n# publish our analysis of the app's collections\nHouston._publish 'collections', ->\n return unless Houston._user_is_admin @userId\n Houston._collections.collections.find()\n\n# TODO address inherent security issue\nHouston._publish 'admin_user', ->\n```", "response": "var sync_collections;\n\nsync_collections = function() {\n var _sync_collections, bound_sync_collections, mongo_driver;\n Dummy.findOne(); // hack. TODO: verify this is still necessary\n _sync_collections = function(meh, collections_db) {\n var col, collection_names;\n collection_names = (function() {\n var i, len, results;\n results = [];\n for (i = 0, len = collections_db.length; i < len; i++) {\n col = collections_db[i];\n if ((col.collectionName.indexOf(\"system.\")) !== 0 && (col.collectionName.indexOf(\"houston_\")) !== 0) {\n results.push(col.collectionName);\n }\n }\n return results;\n })();\n return collection_names.forEach(function(name) {\n var e, key, new_collection, value;\n if (!(name in ADDED_COLLECTIONS || name in HIDDEN_COLLECTIONS)) {\n new_collection = null;\n try {\n new_collection = new Meteor.Collection(name);\n } catch (error) {\n e = error;\n for (key in root) {\n value = root[key];\n if (name === (value != null ? value._name : void 0)) { // TODO here - typecheck also?\n new_collection = value;\n }\n }\n }\n if (new_collection != null) {\n return Houston._setup_collection(new_collection);\n } else {\n return console.log(`Houston: couldn't find access to the ${name} collection.\nIf you'd like to access the collection from Houston, either\n(1) make sure it is available as a global (top-level namespace) within the server or\n(2) add the collection manually via Houston.add_collection`); // found it!\n }\n }\n });\n };\n bound_sync_collections = Meteor.bindEnvironment(_sync_collections, function(e) {\n return console.log(`Failed while syncing collections for reason: ${e}`);\n });\n // MongoInternals is the 'right' solution as of 0.6.5\n mongo_driver = (typeof MongoInternals !== \"undefined\" && MongoInternals !== null ? MongoInternals.defaultRemoteCollectionDriver() : void 0) || Meteor._RemoteCollectionDriver;\n return mongo_driver.mongo.db.collections(bound_sync_collections);\n};\n\nMeteor.methods({\n _houston_make_admin: function(user_id) {\n // limit one admin\n if (Houston._admins.findOne({\n 'user_id': {\n $exists: true\n }\n })) {\n return;\n }\n Houston._admins.insert({user_id});\n sync_collections(); // reloads collections in case of new app\n return true;\n }\n});\n\n// publish our analysis of the app's collections\nHouston._publish('collections', function() {\n if (!Houston._user_is_admin(this.userId)) {\n return;\n }\n return Houston._collections.collections.find();\n});\n\n// TODO address inherent security issue\nHouston._publish('admin_user', function() {});", "source_lang": "CoffeeScript", "target_lang": "JavaScript", "repo": "gterrono/houston", "path": "server/publications.coffee", "license": "MIT", "commit": "f4fae47b2e1a20bb2c44c506a2e226c158a4ce8a", "stars": 802, "source_url": "https://github.com/gterrono/houston/blob/f4fae47b2e1a20bb2c44c506a2e226c158a4ce8a/server/publications.coffee", "line_start": 60, "line_end": 109}787{"id": "gterrono/houston:server/publications.coffee:3:js_to_coffee", "type": "js_to_coffee", "prompt": "Convert this JavaScript to CoffeeScript.\n```javascript\nvar sync_collections;\n\nsync_collections = function() {\n var _sync_collections, bound_sync_collections, mongo_driver;\n Dummy.findOne(); // hack. TODO: verify this is still necessary\n _sync_collections = function(meh, collections_db) {\n var col, collection_names;\n collection_names = (function() {\n var i, len, results;\n results = [];\n for (i = 0, len = collections_db.length; i < len; i++) {\n col = collections_db[i];\n if ((col.collectionName.indexOf(\"system.\")) !== 0 && (col.collectionName.indexOf(\"houston_\")) !== 0) {\n results.push(col.collectionName);\n }\n }\n return results;\n })();\n return collection_names.forEach(function(name) {\n var e, key, new_collection, value;\n if (!(name in ADDED_COLLECTIONS || name in HIDDEN_COLLECTIONS)) {\n new_collection = null;\n try {\n new_collection = new Meteor.Collection(name);\n } catch (error) {\n e = error;\n for (key in root) {\n value = root[key];\n if (name === (value != null ? value._name : void 0)) { // TODO here - typecheck also?\n new_collection = value;\n }\n }\n }\n if (new_collection != null) {\n return Houston._setup_collection(new_collection);\n } else {\n return console.log(`Houston: couldn't find access to the ${name} collection.\nIf you'd like to access the collection from Houston, either\n(1) make sure it is available as a global (top-level namespace) within the server or\n(2) add the collection manually via Houston.add_collection`); // found it!\n }\n }\n });\n };\n bound_sync_collections = Meteor.bindEnvironment(_sync_collections, function(e) {\n return console.log(`Failed while syncing collections for reason: ${e}`);\n });\n // MongoInternals is the 'right' solution as of 0.6.5\n mongo_driver = (typeof MongoInternals !== \"undefined\" && MongoInternals !== null ? MongoInternals.defaultRemoteCollectionDriver() : void 0) || Meteor._RemoteCollectionDriver;\n return mongo_driver.mongo.db.collections(bound_sync_collections);\n};\n\nMeteor.methods({\n _houston_make_admin: function(user_id) {\n // limit one admin\n if (Houston._admins.findOne({\n 'user_id': {\n $exists: true\n }\n })) {\n return;\n }\n Houston._admins.insert({user_id});\n sync_collections(); // reloads collections in case of new app\n return true;\n }\n});\n\n// publish our analysis of the app's collections\nHouston._publish('collections', function() {\n if (!Houston._user_is_admin(this.userId)) {\n return;\n }\n return Houston._collections.collections.find();\n});\n\n// TODO address inherent security issue\nHouston._publish('admin_user', function() {});\n```", "response": "sync_collections = ->\n Dummy.findOne() # hack. TODO: verify this is still necessary\n\n _sync_collections = (meh, collections_db) ->\n collection_names = (col.collectionName for col in collections_db \\\n when (col.collectionName.indexOf \"system.\") isnt 0 and\n (col.collectionName.indexOf \"houston_\") isnt 0)\n\n collection_names.forEach (name) ->\n unless name of ADDED_COLLECTIONS or name of HIDDEN_COLLECTIONS\n new_collection = null\n try\n new_collection = new Meteor.Collection(name)\n catch e\n for key, value of root\n if name == value?._name # TODO here - typecheck also?\n new_collection = value\n\n if new_collection? # found it!\n Houston._setup_collection(new_collection)\n else\n console.log \"\"\"\nHouston: couldn't find access to the #{name} collection.\nIf you'd like to access the collection from Houston, either\n(1) make sure it is available as a global (top-level namespace) within the server or\n(2) add the collection manually via Houston.add_collection\n\"\"\"\n\n bound_sync_collections = Meteor.bindEnvironment _sync_collections, (e) ->\n console.log \"Failed while syncing collections for reason: #{e}\"\n\n # MongoInternals is the 'right' solution as of 0.6.5\n mongo_driver = MongoInternals?.defaultRemoteCollectionDriver() or Meteor._RemoteCollectionDriver\n mongo_driver.mongo.db.collections bound_sync_collections\n\nMeteor.methods\n _houston_make_admin: (user_id) ->\n # limit one admin\n return if Houston._admins.findOne {'user_id': $exists: true}\n Houston._admins.insert {user_id}\n sync_collections() # reloads collections in case of new app\n return true\n\n# publish our analysis of the app's collections\nHouston._publish 'collections', ->\n return unless Houston._user_is_admin @userId\n Houston._collections.collections.find()\n\n# TODO address inherent security issue\nHouston._publish 'admin_user', ->", "source_lang": "JavaScript", "target_lang": "CoffeeScript", "repo": "gterrono/houston", "path": "server/publications.coffee", "license": "MIT", "commit": "f4fae47b2e1a20bb2c44c506a2e226c158a4ce8a", "stars": 802, "source_url": "https://github.com/gterrono/houston/blob/f4fae47b2e1a20bb2c44c506a2e226c158a4ce8a/server/publications.coffee", "line_start": 60, "line_end": 109}788{"id": "gterrono/houston:server/publications.coffee:3:completion", "type": "completion", "prompt": "sync_collections = ->\n Dummy.findOne() # hack. TODO: verify this is still necessary\n\n _sync_collections = (meh, collections_db) ->\n collection_names = (col.collectionName for col in collections_db \\\n when (col.collectionName.indexOf \"system.\") isnt 0 and\n (col.collectionName.indexOf \"houston_\") isnt 0)\n\n collection_names.forEach (name) ->\n unless name of ADDED_COLLECTIONS or name of HIDDEN_COLLECTIONS\n new_collection = null\n try\n new_collection = new Meteor.Collection(name)\n catch e\n for key, value of root\n if name == value?._name # TODO here - typecheck also?\n new_collection = value\n\n if new_collection? # found it!\n Houston._setup_collection(new_collection)\n else\n console.log \"\"\"\nHouston: couldn't find access to the #{name} collection.\nIf you'd like to access the collection from Houston, either\n(1) make sure it is available as a global (top-level namespace) within the server or", "response": "(2) add the collection manually via Houston.add_collection\n\"\"\"\n\n bound_sync_collections = Meteor.bindEnvironment _sync_collections, (e) ->\n console.log \"Failed while syncing collections for reason: #{e}\"\n\n # MongoInternals is the 'right' solution as of 0.6.5\n mongo_driver = MongoInternals?.defaultRemoteCollectionDriver() or Meteor._RemoteCollectionDriver\n mongo_driver.mongo.db.collections bound_sync_collections\n\nMeteor.methods\n _houston_make_admin: (user_id) ->\n # limit one admin\n return if Houston._admins.findOne {'user_id': $exists: true}\n Houston._admins.insert {user_id}\n sync_collections() # reloads collections in case of new app\n return true\n\n# publish our analysis of the app's collections\nHouston._publish 'collections', ->\n return unless Houston._user_is_admin @userId\n Houston._collections.collections.find()\n\n# TODO address inherent security issue\nHouston._publish 'admin_user', ->", "source_lang": "CoffeeScript", "target_lang": "CoffeeScript", "repo": "gterrono/houston", "path": "server/publications.coffee", "license": "MIT", "commit": "f4fae47b2e1a20bb2c44c506a2e226c158a4ce8a", "stars": 802, "source_url": "https://github.com/gterrono/houston/blob/f4fae47b2e1a20bb2c44c506a2e226c158a4ce8a/server/publications.coffee", "line_start": 60, "line_end": 109}789{"id": "gterrono/houston:server/publications.coffee:4:raw_corpus", "type": "raw_corpus", "prompt": "", "response": "Houston._admins.find {}\n\nMeteor.startup ->\n sync_collections()", "source_lang": "", "target_lang": "CoffeeScript", "repo": "gterrono/houston", "path": "server/publications.coffee", "license": "MIT", "commit": "f4fae47b2e1a20bb2c44c506a2e226c158a4ce8a", "stars": 802, "source_url": "https://github.com/gterrono/houston/blob/f4fae47b2e1a20bb2c44c506a2e226c158a4ce8a/server/publications.coffee", "line_start": 110, "line_end": 113}790{"id": "gterrono/houston:server/publications.coffee:4:coffee_to_js", "type": "coffee_to_js", "prompt": "Convert this CoffeeScript to JavaScript.\n```coffeescript\nHouston._admins.find {}\n\nMeteor.startup ->\n sync_collections()\n```", "response": "Houston._admins.find({});\n\nMeteor.startup(function() {\n return sync_collections();\n});", "source_lang": "CoffeeScript", "target_lang": "JavaScript", "repo": "gterrono/houston", "path": "server/publications.coffee", "license": "MIT", "commit": "f4fae47b2e1a20bb2c44c506a2e226c158a4ce8a", "stars": 802, "source_url": "https://github.com/gterrono/houston/blob/f4fae47b2e1a20bb2c44c506a2e226c158a4ce8a/server/publications.coffee", "line_start": 110, "line_end": 113}791{"id": "gterrono/houston:server/publications.coffee:4:js_to_coffee", "type": "js_to_coffee", "prompt": "Convert this JavaScript to CoffeeScript.\n```javascript\nHouston._admins.find({});\n\nMeteor.startup(function() {\n return sync_collections();\n});\n```", "response": "Houston._admins.find {}\n\nMeteor.startup ->\n sync_collections()", "source_lang": "JavaScript", "target_lang": "CoffeeScript", "repo": "gterrono/houston", "path": "server/publications.coffee", "license": "MIT", "commit": "f4fae47b2e1a20bb2c44c506a2e226c158a4ce8a", "stars": 802, "source_url": "https://github.com/gterrono/houston/blob/f4fae47b2e1a20bb2c44c506a2e226c158a4ce8a/server/publications.coffee", "line_start": 110, "line_end": 113}792{"id": "gterrono/houston:server/publications.coffee:4:completion", "type": "completion", "prompt": "Houston._admins.find {}", "response": "Meteor.startup ->\n sync_collections()", "source_lang": "CoffeeScript", "target_lang": "CoffeeScript", "repo": "gterrono/houston", "path": "server/publications.coffee", "license": "MIT", "commit": "f4fae47b2e1a20bb2c44c506a2e226c158a4ce8a", "stars": 802, "source_url": "https://github.com/gterrono/houston/blob/f4fae47b2e1a20bb2c44c506a2e226c158a4ce8a/server/publications.coffee", "line_start": 110, "line_end": 113}793{"id": "gterrono/houston:server/publications.coffee:2:raw_corpus", "type": "raw_corpus", "prompt": "", "response": "Houston._setup_collection = (collection) ->\n return if collection._name of ADDED_COLLECTIONS\n\n name = collection._name\n methods = {}\n methods[Houston._houstonize \"#{name}_insert\"] = (doc) ->\n return unless Houston._user_is_admin @userId\n collection.insert(doc)\n\n methods[Houston._houstonize \"#{name}_update\"] = (id, update_dict) ->\n return unless Houston._user_is_admin @userId\n if collection.findOne(id)\n collection.update(id, update_dict)\n else\n id = collection.findOne(new Meteor.Collection.ObjectID(id))\n collection.update(id, update_dict)\n\n methods[Houston._houstonize \"#{name}_delete\"] = (id, update_dict) ->\n return unless Houston._user_is_admin @userId\n if collection.findOne(id)\n collection.remove(id)\n else\n id = collection.findOne(new Meteor.Collection.ObjectID(id))\n collection.remove(id)\n\n Meteor.methods methods\n\n Houston._publish name, (sort, filter, limit) ->\n check sort, Match.Any\n check filter, Match.Any\n check limit, Number\n return unless Houston._user_is_admin @userId\n try\n collection.find(filter, sort: sort, limit: limit)\n catch e\n console.log e\n\n collection.find().observe\n added: (document) ->\n Houston._collections.collections.update {name},\n $inc: {count: 1},\n $addToSet: fields: $each: Houston._get_field_names([document])\n removed: (document) -> Houston._collections.collections.update {name}, {$inc: {count: -1}}\n\n fields = Houston._get_field_names(collection.find().fetch())\n c = Houston._collections.collections.findOne {name}\n if c\n Houston._collections.collections.update c._id, {$set: count: collection.find().count(), fields: fields}\n else\n Houston._collections.collections.insert {name, count: collection.find().count(), fields: fields}", "source_lang": "", "target_lang": "CoffeeScript", "repo": "gterrono/houston", "path": "server/publications.coffee", "license": "MIT", "commit": "b9dcb66a44e3caadcdd2384c8721d041bd880de3", "stars": 802, "source_url": "https://github.com/gterrono/houston/blob/b9dcb66a44e3caadcdd2384c8721d041bd880de3/server/publications.coffee", "line_start": 11, "line_end": 60}794{"id": "gterrono/houston:server/publications.coffee:2:coffee_to_js", "type": "coffee_to_js", "prompt": "Convert this CoffeeScript to JavaScript.\n```coffeescript\nHouston._setup_collection = (collection) ->\n return if collection._name of ADDED_COLLECTIONS\n\n name = collection._name\n methods = {}\n methods[Houston._houstonize \"#{name}_insert\"] = (doc) ->\n return unless Houston._user_is_admin @userId\n collection.insert(doc)\n\n methods[Houston._houstonize \"#{name}_update\"] = (id, update_dict) ->\n return unless Houston._user_is_admin @userId\n if collection.findOne(id)\n collection.update(id, update_dict)\n else\n id = collection.findOne(new Meteor.Collection.ObjectID(id))\n collection.update(id, update_dict)\n\n methods[Houston._houstonize \"#{name}_delete\"] = (id, update_dict) ->\n return unless Houston._user_is_admin @userId\n if collection.findOne(id)\n collection.remove(id)\n else\n id = collection.findOne(new Meteor.Collection.ObjectID(id))\n collection.remove(id)\n\n Meteor.methods methods\n\n Houston._publish name, (sort, filter, limit) ->\n check sort, Match.Any\n check filter, Match.Any\n check limit, Number\n return unless Houston._user_is_admin @userId\n try\n collection.find(filter, sort: sort, limit: limit)\n catch e\n console.log e\n\n collection.find().observe\n added: (document) ->\n Houston._collections.collections.update {name},\n $inc: {count: 1},\n $addToSet: fields: $each: Houston._get_field_names([document])\n removed: (document) -> Houston._collections.collections.update {name}, {$inc: {count: -1}}\n\n fields = Houston._get_field_names(collection.find().fetch())\n c = Houston._collections.collections.findOne {name}\n if c\n Houston._collections.collections.update c._id, {$set: count: collection.find().count(), fields: fields}\n else\n Houston._collections.collections.insert {name, count: collection.find().count(), fields: fields}\n```", "response": "Houston._setup_collection = function(collection) {\n var c, fields, methods, name;\n if (collection._name in ADDED_COLLECTIONS) {\n return;\n }\n name = collection._name;\n methods = {};\n methods[Houston._houstonize(`${name}_insert`)] = function(doc) {\n if (!Houston._user_is_admin(this.userId)) {\n return;\n }\n return collection.insert(doc);\n };\n methods[Houston._houstonize(`${name}_update`)] = function(id, update_dict) {\n if (!Houston._user_is_admin(this.userId)) {\n return;\n }\n if (collection.findOne(id)) {\n return collection.update(id, update_dict);\n } else {\n id = collection.findOne(new Meteor.Collection.ObjectID(id));\n return collection.update(id, update_dict);\n }\n };\n methods[Houston._houstonize(`${name}_delete`)] = function(id, update_dict) {\n if (!Houston._user_is_admin(this.userId)) {\n return;\n }\n if (collection.findOne(id)) {\n return collection.remove(id);\n } else {\n id = collection.findOne(new Meteor.Collection.ObjectID(id));\n return collection.remove(id);\n }\n };\n Meteor.methods(methods);\n Houston._publish(name, function(sort, filter, limit) {\n var e;\n check(sort, Match.Any);\n check(filter, Match.Any);\n check(limit, Number);\n if (!Houston._user_is_admin(this.userId)) {\n return;\n }\n try {\n return collection.find(filter, {\n sort: sort,\n limit: limit\n });\n } catch (error) {\n e = error;\n return console.log(e);\n }\n });\n collection.find().observe({\n added: function(document) {\n return Houston._collections.collections.update({name}, {\n $inc: {\n count: 1\n },\n $addToSet: {\n fields: {\n $each: Houston._get_field_names([document])\n }\n }\n });\n },\n removed: function(document) {\n return Houston._collections.collections.update({name}, {\n $inc: {\n count: -1\n }\n });\n }\n });\n fields = Houston._get_field_names(collection.find().fetch());\n c = Houston._collections.collections.findOne({name});\n if (c) {\n return Houston._collections.collections.update(c._id, {\n $set: {\n count: collection.find().count(),\n fields: fields\n }\n });\n } else {\n return Houston._collections.collections.insert({\n name,\n count: collection.find().count(),\n fields: fields\n });\n }\n};", "source_lang": "CoffeeScript", "target_lang": "JavaScript", "repo": "gterrono/houston", "path": "server/publications.coffee", "license": "MIT", "commit": "b9dcb66a44e3caadcdd2384c8721d041bd880de3", "stars": 802, "source_url": "https://github.com/gterrono/houston/blob/b9dcb66a44e3caadcdd2384c8721d041bd880de3/server/publications.coffee", "line_start": 11, "line_end": 60}795{"id": "gterrono/houston:server/publications.coffee:2:js_to_coffee", "type": "js_to_coffee", "prompt": "Convert this JavaScript to CoffeeScript.\n```javascript\nHouston._setup_collection = function(collection) {\n var c, fields, methods, name;\n if (collection._name in ADDED_COLLECTIONS) {\n return;\n }\n name = collection._name;\n methods = {};\n methods[Houston._houstonize(`${name}_insert`)] = function(doc) {\n if (!Houston._user_is_admin(this.userId)) {\n return;\n }\n return collection.insert(doc);\n };\n methods[Houston._houstonize(`${name}_update`)] = function(id, update_dict) {\n if (!Houston._user_is_admin(this.userId)) {\n return;\n }\n if (collection.findOne(id)) {\n return collection.update(id, update_dict);\n } else {\n id = collection.findOne(new Meteor.Collection.ObjectID(id));\n return collection.update(id, update_dict);\n }\n };\n methods[Houston._houstonize(`${name}_delete`)] = function(id, update_dict) {\n if (!Houston._user_is_admin(this.userId)) {\n return;\n }\n if (collection.findOne(id)) {\n return collection.remove(id);\n } else {\n id = collection.findOne(new Meteor.Collection.ObjectID(id));\n return collection.remove(id);\n }\n };\n Meteor.methods(methods);\n Houston._publish(name, function(sort, filter, limit) {\n var e;\n check(sort, Match.Any);\n check(filter, Match.Any);\n check(limit, Number);\n if (!Houston._user_is_admin(this.userId)) {\n return;\n }\n try {\n return collection.find(filter, {\n sort: sort,\n limit: limit\n });\n } catch (error) {\n e = error;\n return console.log(e);\n }\n });\n collection.find().observe({\n added: function(document) {\n return Houston._collections.collections.update({name}, {\n $inc: {\n count: 1\n },\n $addToSet: {\n fields: {\n $each: Houston._get_field_names([document])\n }\n }\n });\n },\n removed: function(document) {\n return Houston._collections.collections.update({name}, {\n $inc: {\n count: -1\n }\n });\n }\n });\n fields = Houston._get_field_names(collection.find().fetch());\n c = Houston._collections.collections.findOne({name});\n if (c) {\n return Houston._collections.collections.update(c._id, {\n $set: {\n count: collection.find().count(),\n fields: fields\n }\n });\n } else {\n return Houston._collections.collections.insert({\n name,\n count: collection.find().count(),\n fields: fields\n });\n }\n};\n```", "response": "Houston._setup_collection = (collection) ->\n return if collection._name of ADDED_COLLECTIONS\n\n name = collection._name\n methods = {}\n methods[Houston._houstonize \"#{name}_insert\"] = (doc) ->\n return unless Houston._user_is_admin @userId\n collection.insert(doc)\n\n methods[Houston._houstonize \"#{name}_update\"] = (id, update_dict) ->\n return unless Houston._user_is_admin @userId\n if collection.findOne(id)\n collection.update(id, update_dict)\n else\n id = collection.findOne(new Meteor.Collection.ObjectID(id))\n collection.update(id, update_dict)\n\n methods[Houston._houstonize \"#{name}_delete\"] = (id, update_dict) ->\n return unless Houston._user_is_admin @userId\n if collection.findOne(id)\n collection.remove(id)\n else\n id = collection.findOne(new Meteor.Collection.ObjectID(id))\n collection.remove(id)\n\n Meteor.methods methods\n\n Houston._publish name, (sort, filter, limit) ->\n check sort, Match.Any\n check filter, Match.Any\n check limit, Number\n return unless Houston._user_is_admin @userId\n try\n collection.find(filter, sort: sort, limit: limit)\n catch e\n console.log e\n\n collection.find().observe\n added: (document) ->\n Houston._collections.collections.update {name},\n $inc: {count: 1},\n $addToSet: fields: $each: Houston._get_field_names([document])\n removed: (document) -> Houston._collections.collections.update {name}, {$inc: {count: -1}}\n\n fields = Houston._get_field_names(collection.find().fetch())\n c = Houston._collections.collections.findOne {name}\n if c\n Houston._collections.collections.update c._id, {$set: count: collection.find().count(), fields: fields}\n else\n Houston._collections.collections.insert {name, count: collection.find().count(), fields: fields}", "source_lang": "JavaScript", "target_lang": "CoffeeScript", "repo": "gterrono/houston", "path": "server/publications.coffee", "license": "MIT", "commit": "b9dcb66a44e3caadcdd2384c8721d041bd880de3", "stars": 802, "source_url": "https://github.com/gterrono/houston/blob/b9dcb66a44e3caadcdd2384c8721d041bd880de3/server/publications.coffee", "line_start": 11, "line_end": 60}796{"id": "gterrono/houston:server/publications.coffee:2:completion", "type": "completion", "prompt": "Houston._setup_collection = (collection) ->\n return if collection._name of ADDED_COLLECTIONS\n\n name = collection._name\n methods = {}\n methods[Houston._houstonize \"#{name}_insert\"] = (doc) ->\n return unless Houston._user_is_admin @userId\n collection.insert(doc)\n\n methods[Houston._houstonize \"#{name}_update\"] = (id, update_dict) ->\n return unless Houston._user_is_admin @userId\n if collection.findOne(id)\n collection.update(id, update_dict)\n else\n id = collection.findOne(new Meteor.Collection.ObjectID(id))\n collection.update(id, update_dict)\n\n methods[Houston._houstonize \"#{name}_delete\"] = (id, update_dict) ->\n return unless Houston._user_is_admin @userId\n if collection.findOne(id)\n collection.remove(id)\n else\n id = collection.findOne(new Meteor.Collection.ObjectID(id))\n collection.remove(id)", "response": "Meteor.methods methods\n\n Houston._publish name, (sort, filter, limit) ->\n check sort, Match.Any\n check filter, Match.Any\n check limit, Number\n return unless Houston._user_is_admin @userId\n try\n collection.find(filter, sort: sort, limit: limit)\n catch e\n console.log e\n\n collection.find().observe\n added: (document) ->\n Houston._collections.collections.update {name},\n $inc: {count: 1},\n $addToSet: fields: $each: Houston._get_field_names([document])\n removed: (document) -> Houston._collections.collections.update {name}, {$inc: {count: -1}}\n\n fields = Houston._get_field_names(collection.find().fetch())\n c = Houston._collections.collections.findOne {name}\n if c\n Houston._collections.collections.update c._id, {$set: count: collection.find().count(), fields: fields}\n else\n Houston._collections.collections.insert {name, count: collection.find().count(), fields: fields}", "source_lang": "CoffeeScript", "target_lang": "CoffeeScript", "repo": "gterrono/houston", "path": "server/publications.coffee", "license": "MIT", "commit": "b9dcb66a44e3caadcdd2384c8721d041bd880de3", "stars": 802, "source_url": "https://github.com/gterrono/houston/blob/b9dcb66a44e3caadcdd2384c8721d041bd880de3/server/publications.coffee", "line_start": 11, "line_end": 60}797{"id": "gterrono/houston:server/publications.coffee:2:raw_corpus", "type": "raw_corpus", "prompt": "", "response": "Houston._setup_collection = (collection) ->\n return if collection._name of ADDED_COLLECTIONS\n\n name = collection._name\n methods = {}\n methods[Houston._houstonize \"#{name}_insert\"] = (doc) ->\n return unless Houston._user_is_admin @userId\n collection.insert(doc)\n\n methods[Houston._houstonize \"#{name}_update\"] = (id, update_dict) ->\n return unless Houston._user_is_admin @userId\n if collection.findOne(id)\n collection.update(id, update_dict)\n else\n id = collection.findOne(new Meteor.Collection.ObjectID(id))\n collection.update(id, update_dict)\n\n methods[Houston._houstonize \"#{name}_delete\"] = (id, update_dict) ->\n return unless Houston._user_is_admin @userId\n if collection.findOne(id)\n collection.remove(id)\n else\n id = collection.findOne(new Meteor.Collection.ObjectID(id))\n collection.remove(id)\n\n Meteor.methods methods\n\n Houston._publish name, (sort, filter, limit) ->\n check sort, Match.Any\n check filter, Match.Any\n check limit, Match.Any\n return unless Houston._user_is_admin @userId\n try\n collection.find(filter, sort: sort, limit: limit)\n catch e\n console.log e\n\n collection.find().observe\n added: (document) ->\n Houston._collections.collections.update {name},\n $inc: {count: 1},\n $addToSet: fields: $each: Houston._get_field_names([document])\n removed: (document) -> Houston._collections.collections.update {name}, {$inc: {count: -1}}\n\n fields = Houston._get_field_names(collection.find().fetch())\n c = Houston._collections.collections.findOne {name}\n if c\n Houston._collections.collections.update c._id, {$set: count: collection.find().count(), fields: fields}\n else\n Houston._collections.collections.insert {name, count: collection.find().count(), fields: fields}", "source_lang": "", "target_lang": "CoffeeScript", "repo": "gterrono/houston", "path": "server/publications.coffee", "license": "MIT", "commit": "ed68291dd9f7704f64df48b59b19f0f59dcdce87", "stars": 802, "source_url": "https://github.com/gterrono/houston/blob/ed68291dd9f7704f64df48b59b19f0f59dcdce87/server/publications.coffee", "line_start": 11, "line_end": 60}798{"id": "gterrono/houston:server/publications.coffee:2:coffee_to_js", "type": "coffee_to_js", "prompt": "Convert this CoffeeScript to JavaScript.\n```coffeescript\nHouston._setup_collection = (collection) ->\n return if collection._name of ADDED_COLLECTIONS\n\n name = collection._name\n methods = {}\n methods[Houston._houstonize \"#{name}_insert\"] = (doc) ->\n return unless Houston._user_is_admin @userId\n collection.insert(doc)\n\n methods[Houston._houstonize \"#{name}_update\"] = (id, update_dict) ->\n return unless Houston._user_is_admin @userId\n if collection.findOne(id)\n collection.update(id, update_dict)\n else\n id = collection.findOne(new Meteor.Collection.ObjectID(id))\n collection.update(id, update_dict)\n\n methods[Houston._houstonize \"#{name}_delete\"] = (id, update_dict) ->\n return unless Houston._user_is_admin @userId\n if collection.findOne(id)\n collection.remove(id)\n else\n id = collection.findOne(new Meteor.Collection.ObjectID(id))\n collection.remove(id)\n\n Meteor.methods methods\n\n Houston._publish name, (sort, filter, limit) ->\n check sort, Match.Any\n check filter, Match.Any\n check limit, Match.Any\n return unless Houston._user_is_admin @userId\n try\n collection.find(filter, sort: sort, limit: limit)\n catch e\n console.log e\n\n collection.find().observe\n added: (document) ->\n Houston._collections.collections.update {name},\n $inc: {count: 1},\n $addToSet: fields: $each: Houston._get_field_names([document])\n removed: (document) -> Houston._collections.collections.update {name}, {$inc: {count: -1}}\n\n fields = Houston._get_field_names(collection.find().fetch())\n c = Houston._collections.collections.findOne {name}\n if c\n Houston._collections.collections.update c._id, {$set: count: collection.find().count(), fields: fields}\n else\n Houston._collections.collections.insert {name, count: collection.find().count(), fields: fields}\n```", "response": "Houston._setup_collection = function(collection) {\n var c, fields, methods, name;\n if (collection._name in ADDED_COLLECTIONS) {\n return;\n }\n name = collection._name;\n methods = {};\n methods[Houston._houstonize(`${name}_insert`)] = function(doc) {\n if (!Houston._user_is_admin(this.userId)) {\n return;\n }\n return collection.insert(doc);\n };\n methods[Houston._houstonize(`${name}_update`)] = function(id, update_dict) {\n if (!Houston._user_is_admin(this.userId)) {\n return;\n }\n if (collection.findOne(id)) {\n return collection.update(id, update_dict);\n } else {\n id = collection.findOne(new Meteor.Collection.ObjectID(id));\n return collection.update(id, update_dict);\n }\n };\n methods[Houston._houstonize(`${name}_delete`)] = function(id, update_dict) {\n if (!Houston._user_is_admin(this.userId)) {\n return;\n }\n if (collection.findOne(id)) {\n return collection.remove(id);\n } else {\n id = collection.findOne(new Meteor.Collection.ObjectID(id));\n return collection.remove(id);\n }\n };\n Meteor.methods(methods);\n Houston._publish(name, function(sort, filter, limit) {\n var e;\n check(sort, Match.Any);\n check(filter, Match.Any);\n check(limit, Match.Any);\n if (!Houston._user_is_admin(this.userId)) {\n return;\n }\n try {\n return collection.find(filter, {\n sort: sort,\n limit: limit\n });\n } catch (error) {\n e = error;\n return console.log(e);\n }\n });\n collection.find().observe({\n added: function(document) {\n return Houston._collections.collections.update({name}, {\n $inc: {\n count: 1\n },\n $addToSet: {\n fields: {\n $each: Houston._get_field_names([document])\n }\n }\n });\n },\n removed: function(document) {\n return Houston._collections.collections.update({name}, {\n $inc: {\n count: -1\n }\n });\n }\n });\n fields = Houston._get_field_names(collection.find().fetch());\n c = Houston._collections.collections.findOne({name});\n if (c) {\n return Houston._collections.collections.update(c._id, {\n $set: {\n count: collection.find().count(),\n fields: fields\n }\n });\n } else {\n return Houston._collections.collections.insert({\n name,\n count: collection.find().count(),\n fields: fields\n });\n }\n};", "source_lang": "CoffeeScript", "target_lang": "JavaScript", "repo": "gterrono/houston", "path": "server/publications.coffee", "license": "MIT", "commit": "ed68291dd9f7704f64df48b59b19f0f59dcdce87", "stars": 802, "source_url": "https://github.com/gterrono/houston/blob/ed68291dd9f7704f64df48b59b19f0f59dcdce87/server/publications.coffee", "line_start": 11, "line_end": 60}799{"id": "gterrono/houston:server/publications.coffee:2:js_to_coffee", "type": "js_to_coffee", "prompt": "Convert this JavaScript to CoffeeScript.\n```javascript\nHouston._setup_collection = function(collection) {\n var c, fields, methods, name;\n if (collection._name in ADDED_COLLECTIONS) {\n return;\n }\n name = collection._name;\n methods = {};\n methods[Houston._houstonize(`${name}_insert`)] = function(doc) {\n if (!Houston._user_is_admin(this.userId)) {\n return;\n }\n return collection.insert(doc);\n };\n methods[Houston._houstonize(`${name}_update`)] = function(id, update_dict) {\n if (!Houston._user_is_admin(this.userId)) {\n return;\n }\n if (collection.findOne(id)) {\n return collection.update(id, update_dict);\n } else {\n id = collection.findOne(new Meteor.Collection.ObjectID(id));\n return collection.update(id, update_dict);\n }\n };\n methods[Houston._houstonize(`${name}_delete`)] = function(id, update_dict) {\n if (!Houston._user_is_admin(this.userId)) {\n return;\n }\n if (collection.findOne(id)) {\n return collection.remove(id);\n } else {\n id = collection.findOne(new Meteor.Collection.ObjectID(id));\n return collection.remove(id);\n }\n };\n Meteor.methods(methods);\n Houston._publish(name, function(sort, filter, limit) {\n var e;\n check(sort, Match.Any);\n check(filter, Match.Any);\n check(limit, Match.Any);\n if (!Houston._user_is_admin(this.userId)) {\n return;\n }\n try {\n return collection.find(filter, {\n sort: sort,\n limit: limit\n });\n } catch (error) {\n e = error;\n return console.log(e);\n }\n });\n collection.find().observe({\n added: function(document) {\n return Houston._collections.collections.update({name}, {\n $inc: {\n count: 1\n },\n $addToSet: {\n fields: {\n $each: Houston._get_field_names([document])\n }\n }\n });\n },\n removed: function(document) {\n return Houston._collections.collections.update({name}, {\n $inc: {\n count: -1\n }\n });\n }\n });\n fields = Houston._get_field_names(collection.find().fetch());\n c = Houston._collections.collections.findOne({name});\n if (c) {\n return Houston._collections.collections.update(c._id, {\n $set: {\n count: collection.find().count(),\n fields: fields\n }\n });\n } else {\n return Houston._collections.collections.insert({\n name,\n count: collection.find().count(),\n fields: fields\n });\n }\n};\n```", "response": "Houston._setup_collection = (collection) ->\n return if collection._name of ADDED_COLLECTIONS\n\n name = collection._name\n methods = {}\n methods[Houston._houstonize \"#{name}_insert\"] = (doc) ->\n return unless Houston._user_is_admin @userId\n collection.insert(doc)\n\n methods[Houston._houstonize \"#{name}_update\"] = (id, update_dict) ->\n return unless Houston._user_is_admin @userId\n if collection.findOne(id)\n collection.update(id, update_dict)\n else\n id = collection.findOne(new Meteor.Collection.ObjectID(id))\n collection.update(id, update_dict)\n\n methods[Houston._houstonize \"#{name}_delete\"] = (id, update_dict) ->\n return unless Houston._user_is_admin @userId\n if collection.findOne(id)\n collection.remove(id)\n else\n id = collection.findOne(new Meteor.Collection.ObjectID(id))\n collection.remove(id)\n\n Meteor.methods methods\n\n Houston._publish name, (sort, filter, limit) ->\n check sort, Match.Any\n check filter, Match.Any\n check limit, Match.Any\n return unless Houston._user_is_admin @userId\n try\n collection.find(filter, sort: sort, limit: limit)\n catch e\n console.log e\n\n collection.find().observe\n added: (document) ->\n Houston._collections.collections.update {name},\n $inc: {count: 1},\n $addToSet: fields: $each: Houston._get_field_names([document])\n removed: (document) -> Houston._collections.collections.update {name}, {$inc: {count: -1}}\n\n fields = Houston._get_field_names(collection.find().fetch())\n c = Houston._collections.collections.findOne {name}\n if c\n Houston._collections.collections.update c._id, {$set: count: collection.find().count(), fields: fields}\n else\n Houston._collections.collections.insert {name, count: collection.find().count(), fields: fields}", "source_lang": "JavaScript", "target_lang": "CoffeeScript", "repo": "gterrono/houston", "path": "server/publications.coffee", "license": "MIT", "commit": "ed68291dd9f7704f64df48b59b19f0f59dcdce87", "stars": 802, "source_url": "https://github.com/gterrono/houston/blob/ed68291dd9f7704f64df48b59b19f0f59dcdce87/server/publications.coffee", "line_start": 11, "line_end": 60}800{"id": "gterrono/houston:server/publications.coffee:2:completion", "type": "completion", "prompt": "Houston._setup_collection = (collection) ->\n return if collection._name of ADDED_COLLECTIONS\n\n name = collection._name\n methods = {}\n methods[Houston._houstonize \"#{name}_insert\"] = (doc) ->\n return unless Houston._user_is_admin @userId\n collection.insert(doc)\n\n methods[Houston._houstonize \"#{name}_update\"] = (id, update_dict) ->\n return unless Houston._user_is_admin @userId\n if collection.findOne(id)\n collection.update(id, update_dict)\n else\n id = collection.findOne(new Meteor.Collection.ObjectID(id))\n collection.update(id, update_dict)\n\n methods[Houston._houstonize \"#{name}_delete\"] = (id, update_dict) ->\n return unless Houston._user_is_admin @userId\n if collection.findOne(id)\n collection.remove(id)\n else\n id = collection.findOne(new Meteor.Collection.ObjectID(id))\n collection.remove(id)", "response": "Meteor.methods methods\n\n Houston._publish name, (sort, filter, limit) ->\n check sort, Match.Any\n check filter, Match.Any\n check limit, Match.Any\n return unless Houston._user_is_admin @userId\n try\n collection.find(filter, sort: sort, limit: limit)\n catch e\n console.log e\n\n collection.find().observe\n added: (document) ->\n Houston._collections.collections.update {name},\n $inc: {count: 1},\n $addToSet: fields: $each: Houston._get_field_names([document])\n removed: (document) -> Houston._collections.collections.update {name}, {$inc: {count: -1}}\n\n fields = Houston._get_field_names(collection.find().fetch())\n c = Houston._collections.collections.findOne {name}\n if c\n Houston._collections.collections.update c._id, {$set: count: collection.find().count(), fields: fields}\n else\n Houston._collections.collections.insert {name, count: collection.find().count(), fields: fields}", "source_lang": "CoffeeScript", "target_lang": "CoffeeScript", "repo": "gterrono/houston", "path": "server/publications.coffee", "license": "MIT", "commit": "ed68291dd9f7704f64df48b59b19f0f59dcdce87", "stars": 802, "source_url": "https://github.com/gterrono/houston/blob/ed68291dd9f7704f64df48b59b19f0f59dcdce87/server/publications.coffee", "line_start": 11, "line_end": 60}801{"id": "gterrono/houston:server/publications.coffee:3:raw_corpus", "type": "raw_corpus", "prompt": "", "response": "sync_collections = ->\n Dummy.findOne() # hack. TODO: verify this is still necessary\n\n _sync_collections = (meh, collections_db) ->\n collection_names = (col.collectionName for col in collections_db \\\n when (col.collectionName.indexOf \"system.\") isnt 0 and\n (col.collectionName.indexOf \"houston_\") isnt 0)\n\n collection_names.forEach (name) ->\n unless name of ADDED_COLLECTIONS or name of HIDDEN_COLLECTIONS\n new_collection = null\n try\n new_collection = new Meteor.Collection(name)\n catch e\n for key, value of root\n if name == value._name # TODO here - typecheck also?\n new_collection = value\n\n if new_collection? # found it!\n Houston._setup_collection(new_collection)\n else\n console.log \"\"\"\nHouston: couldn't find access to the #{name} collection.\nIf you'd like to access the collection from Houston, either\n(1) make sure it is available as a global (top-level namespace) within the server or\n(2) add the collection manually via Houston.add_collection\n\"\"\"\n\n bound_sync_collections = Meteor.bindEnvironment _sync_collections, (e) ->\n console.log \"Failed while syncing collections for reason: #{e}\"\n\n # MongoInternals is the 'right' solution as of 0.6.5\n mongo_driver = MongoInternals?.defaultRemoteCollectionDriver() or Meteor._RemoteCollectionDriver\n mongo_driver.mongo.db.collections bound_sync_collections\n\nMeteor.methods\n _houston_make_admin: (user_id) ->\n # limit one admin\n return if Houston._admins.findOne {'user_id': $exists: true}\n Houston._admins.insert {user_id}\n sync_collections() # reloads collections in case of new app\n return true\n\n# publish our analysis of the app's collections\nHouston._publish 'collections', ->\n return unless Houston._user_is_admin @userId\n Houston._collections.collections.find()\n\n# TODO address inherent security issue\nHouston._publish 'admin_user', ->", "source_lang": "", "target_lang": "CoffeeScript", "repo": "gterrono/houston", "path": "server/publications.coffee", "license": "MIT", "commit": "95ce4b30967eb84acda672c81fea04c55e366e99", "stars": 802, "source_url": "https://github.com/gterrono/houston/blob/95ce4b30967eb84acda672c81fea04c55e366e99/server/publications.coffee", "line_start": 60, "line_end": 109}802{"id": "gterrono/houston:server/publications.coffee:3:coffee_to_js", "type": "coffee_to_js", "prompt": "Convert this CoffeeScript to JavaScript.\n```coffeescript\nsync_collections = ->\n Dummy.findOne() # hack. TODO: verify this is still necessary\n\n _sync_collections = (meh, collections_db) ->\n collection_names = (col.collectionName for col in collections_db \\\n when (col.collectionName.indexOf \"system.\") isnt 0 and\n (col.collectionName.indexOf \"houston_\") isnt 0)\n\n collection_names.forEach (name) ->\n unless name of ADDED_COLLECTIONS or name of HIDDEN_COLLECTIONS\n new_collection = null\n try\n new_collection = new Meteor.Collection(name)\n catch e\n for key, value of root\n if name == value._name # TODO here - typecheck also?\n new_collection = value\n\n if new_collection? # found it!\n Houston._setup_collection(new_collection)\n else\n console.log \"\"\"\nHouston: couldn't find access to the #{name} collection.\nIf you'd like to access the collection from Houston, either\n(1) make sure it is available as a global (top-level namespace) within the server or\n(2) add the collection manually via Houston.add_collection\n\"\"\"\n\n bound_sync_collections = Meteor.bindEnvironment _sync_collections, (e) ->\n console.log \"Failed while syncing collections for reason: #{e}\"\n\n # MongoInternals is the 'right' solution as of 0.6.5\n mongo_driver = MongoInternals?.defaultRemoteCollectionDriver() or Meteor._RemoteCollectionDriver\n mongo_driver.mongo.db.collections bound_sync_collections\n\nMeteor.methods\n _houston_make_admin: (user_id) ->\n # limit one admin\n return if Houston._admins.findOne {'user_id': $exists: true}\n Houston._admins.insert {user_id}\n sync_collections() # reloads collections in case of new app\n return true\n\n# publish our analysis of the app's collections\nHouston._publish 'collections', ->\n return unless Houston._user_is_admin @userId\n Houston._collections.collections.find()\n\n# TODO address inherent security issue\nHouston._publish 'admin_user', ->\n```", "response": "var sync_collections;\n\nsync_collections = function() {\n var _sync_collections, bound_sync_collections, mongo_driver;\n Dummy.findOne(); // hack. TODO: verify this is still necessary\n _sync_collections = function(meh, collections_db) {\n var col, collection_names;\n collection_names = (function() {\n var i, len, results;\n results = [];\n for (i = 0, len = collections_db.length; i < len; i++) {\n col = collections_db[i];\n if ((col.collectionName.indexOf(\"system.\")) !== 0 && (col.collectionName.indexOf(\"houston_\")) !== 0) {\n results.push(col.collectionName);\n }\n }\n return results;\n })();\n return collection_names.forEach(function(name) {\n var e, key, new_collection, value;\n if (!(name in ADDED_COLLECTIONS || name in HIDDEN_COLLECTIONS)) {\n new_collection = null;\n try {\n new_collection = new Meteor.Collection(name);\n } catch (error) {\n e = error;\n for (key in root) {\n value = root[key];\n if (name === value._name) { // TODO here - typecheck also?\n new_collection = value;\n }\n }\n }\n if (new_collection != null) {\n return Houston._setup_collection(new_collection);\n } else {\n return console.log(`Houston: couldn't find access to the ${name} collection.\nIf you'd like to access the collection from Houston, either\n(1) make sure it is available as a global (top-level namespace) within the server or\n(2) add the collection manually via Houston.add_collection`); // found it!\n }\n }\n });\n };\n bound_sync_collections = Meteor.bindEnvironment(_sync_collections, function(e) {\n return console.log(`Failed while syncing collections for reason: ${e}`);\n });\n // MongoInternals is the 'right' solution as of 0.6.5\n mongo_driver = (typeof MongoInternals !== \"undefined\" && MongoInternals !== null ? MongoInternals.defaultRemoteCollectionDriver() : void 0) || Meteor._RemoteCollectionDriver;\n return mongo_driver.mongo.db.collections(bound_sync_collections);\n};\n\nMeteor.methods({\n _houston_make_admin: function(user_id) {\n // limit one admin\n if (Houston._admins.findOne({\n 'user_id': {\n $exists: true\n }\n })) {\n return;\n }\n Houston._admins.insert({user_id});\n sync_collections(); // reloads collections in case of new app\n return true;\n }\n});\n\n// publish our analysis of the app's collections\nHouston._publish('collections', function() {\n if (!Houston._user_is_admin(this.userId)) {\n return;\n }\n return Houston._collections.collections.find();\n});\n\n// TODO address inherent security issue\nHouston._publish('admin_user', function() {});", "source_lang": "CoffeeScript", "target_lang": "JavaScript", "repo": "gterrono/houston", "path": "server/publications.coffee", "license": "MIT", "commit": "95ce4b30967eb84acda672c81fea04c55e366e99", "stars": 802, "source_url": "https://github.com/gterrono/houston/blob/95ce4b30967eb84acda672c81fea04c55e366e99/server/publications.coffee", "line_start": 60, "line_end": 109}803{"id": "gterrono/houston:server/publications.coffee:3:js_to_coffee", "type": "js_to_coffee", "prompt": "Convert this JavaScript to CoffeeScript.\n```javascript\nvar sync_collections;\n\nsync_collections = function() {\n var _sync_collections, bound_sync_collections, mongo_driver;\n Dummy.findOne(); // hack. TODO: verify this is still necessary\n _sync_collections = function(meh, collections_db) {\n var col, collection_names;\n collection_names = (function() {\n var i, len, results;\n results = [];\n for (i = 0, len = collections_db.length; i < len; i++) {\n col = collections_db[i];\n if ((col.collectionName.indexOf(\"system.\")) !== 0 && (col.collectionName.indexOf(\"houston_\")) !== 0) {\n results.push(col.collectionName);\n }\n }\n return results;\n })();\n return collection_names.forEach(function(name) {\n var e, key, new_collection, value;\n if (!(name in ADDED_COLLECTIONS || name in HIDDEN_COLLECTIONS)) {\n new_collection = null;\n try {\n new_collection = new Meteor.Collection(name);\n } catch (error) {\n e = error;\n for (key in root) {\n value = root[key];\n if (name === value._name) { // TODO here - typecheck also?\n new_collection = value;\n }\n }\n }\n if (new_collection != null) {\n return Houston._setup_collection(new_collection);\n } else {\n return console.log(`Houston: couldn't find access to the ${name} collection.\nIf you'd like to access the collection from Houston, either\n(1) make sure it is available as a global (top-level namespace) within the server or\n(2) add the collection manually via Houston.add_collection`); // found it!\n }\n }\n });\n };\n bound_sync_collections = Meteor.bindEnvironment(_sync_collections, function(e) {\n return console.log(`Failed while syncing collections for reason: ${e}`);\n });\n // MongoInternals is the 'right' solution as of 0.6.5\n mongo_driver = (typeof MongoInternals !== \"undefined\" && MongoInternals !== null ? MongoInternals.defaultRemoteCollectionDriver() : void 0) || Meteor._RemoteCollectionDriver;\n return mongo_driver.mongo.db.collections(bound_sync_collections);\n};\n\nMeteor.methods({\n _houston_make_admin: function(user_id) {\n // limit one admin\n if (Houston._admins.findOne({\n 'user_id': {\n $exists: true\n }\n })) {\n return;\n }\n Houston._admins.insert({user_id});\n sync_collections(); // reloads collections in case of new app\n return true;\n }\n});\n\n// publish our analysis of the app's collections\nHouston._publish('collections', function() {\n if (!Houston._user_is_admin(this.userId)) {\n return;\n }\n return Houston._collections.collections.find();\n});\n\n// TODO address inherent security issue\nHouston._publish('admin_user', function() {});\n```", "response": "sync_collections = ->\n Dummy.findOne() # hack. TODO: verify this is still necessary\n\n _sync_collections = (meh, collections_db) ->\n collection_names = (col.collectionName for col in collections_db \\\n when (col.collectionName.indexOf \"system.\") isnt 0 and\n (col.collectionName.indexOf \"houston_\") isnt 0)\n\n collection_names.forEach (name) ->\n unless name of ADDED_COLLECTIONS or name of HIDDEN_COLLECTIONS\n new_collection = null\n try\n new_collection = new Meteor.Collection(name)\n catch e\n for key, value of root\n if name == value._name # TODO here - typecheck also?\n new_collection = value\n\n if new_collection? # found it!\n Houston._setup_collection(new_collection)\n else\n console.log \"\"\"\nHouston: couldn't find access to the #{name} collection.\nIf you'd like to access the collection from Houston, either\n(1) make sure it is available as a global (top-level namespace) within the server or\n(2) add the collection manually via Houston.add_collection\n\"\"\"\n\n bound_sync_collections = Meteor.bindEnvironment _sync_collections, (e) ->\n console.log \"Failed while syncing collections for reason: #{e}\"\n\n # MongoInternals is the 'right' solution as of 0.6.5\n mongo_driver = MongoInternals?.defaultRemoteCollectionDriver() or Meteor._RemoteCollectionDriver\n mongo_driver.mongo.db.collections bound_sync_collections\n\nMeteor.methods\n _houston_make_admin: (user_id) ->\n # limit one admin\n return if Houston._admins.findOne {'user_id': $exists: true}\n Houston._admins.insert {user_id}\n sync_collections() # reloads collections in case of new app\n return true\n\n# publish our analysis of the app's collections\nHouston._publish 'collections', ->\n return unless Houston._user_is_admin @userId\n Houston._collections.collections.find()\n\n# TODO address inherent security issue\nHouston._publish 'admin_user', ->", "source_lang": "JavaScript", "target_lang": "CoffeeScript", "repo": "gterrono/houston", "path": "server/publications.coffee", "license": "MIT", "commit": "95ce4b30967eb84acda672c81fea04c55e366e99", "stars": 802, "source_url": "https://github.com/gterrono/houston/blob/95ce4b30967eb84acda672c81fea04c55e366e99/server/publications.coffee", "line_start": 60, "line_end": 109}804{"id": "gterrono/houston:server/publications.coffee:3:completion", "type": "completion", "prompt": "sync_collections = ->\n Dummy.findOne() # hack. TODO: verify this is still necessary\n\n _sync_collections = (meh, collections_db) ->\n collection_names = (col.collectionName for col in collections_db \\\n when (col.collectionName.indexOf \"system.\") isnt 0 and\n (col.collectionName.indexOf \"houston_\") isnt 0)\n\n collection_names.forEach (name) ->\n unless name of ADDED_COLLECTIONS or name of HIDDEN_COLLECTIONS\n new_collection = null\n try\n new_collection = new Meteor.Collection(name)\n catch e\n for key, value of root\n if name == value._name # TODO here - typecheck also?\n new_collection = value\n\n if new_collection? # found it!\n Houston._setup_collection(new_collection)\n else\n console.log \"\"\"\nHouston: couldn't find access to the #{name} collection.\nIf you'd like to access the collection from Houston, either\n(1) make sure it is available as a global (top-level namespace) within the server or", "response": "(2) add the collection manually via Houston.add_collection\n\"\"\"\n\n bound_sync_collections = Meteor.bindEnvironment _sync_collections, (e) ->\n console.log \"Failed while syncing collections for reason: #{e}\"\n\n # MongoInternals is the 'right' solution as of 0.6.5\n mongo_driver = MongoInternals?.defaultRemoteCollectionDriver() or Meteor._RemoteCollectionDriver\n mongo_driver.mongo.db.collections bound_sync_collections\n\nMeteor.methods\n _houston_make_admin: (user_id) ->\n # limit one admin\n return if Houston._admins.findOne {'user_id': $exists: true}\n Houston._admins.insert {user_id}\n sync_collections() # reloads collections in case of new app\n return true\n\n# publish our analysis of the app's collections\nHouston._publish 'collections', ->\n return unless Houston._user_is_admin @userId\n Houston._collections.collections.find()\n\n# TODO address inherent security issue\nHouston._publish 'admin_user', ->", "source_lang": "CoffeeScript", "target_lang": "CoffeeScript", "repo": "gterrono/houston", "path": "server/publications.coffee", "license": "MIT", "commit": "95ce4b30967eb84acda672c81fea04c55e366e99", "stars": 802, "source_url": "https://github.com/gterrono/houston/blob/95ce4b30967eb84acda672c81fea04c55e366e99/server/publications.coffee", "line_start": 60, "line_end": 109}805{"id": "gterrono/houston:server/publications.coffee:2:raw_corpus", "type": "raw_corpus", "prompt": "", "response": "Houston._setup_collection = (collection) ->\n return if collection._name in collections\n name = collection._name\n methods = {}\n methods[Houston._houstonize \"#{name}_insert\"] = (doc) ->\n return unless Houston._user_is_admin @userId\n collection.insert(doc)\n\n methods[Houston._houstonize \"#{name}_update\"] = (id, update_dict) ->\n return unless Houston._user_is_admin @userId\n if collection.findOne(id)\n collection.update(id, update_dict)\n else\n id = collection.findOne(new Meteor.Collection.ObjectID(id))\n collection.update(id, update_dict)\n\n methods[Houston._houstonize \"#{name}_delete\"] = (id, update_dict) ->\n return unless Houston._user_is_admin @userId\n if collection.findOne(id)\n collection.remove(id)\n else\n id = collection.findOne(new Meteor.Collection.ObjectID(id))\n collection.remove(id)\n\n Meteor.methods methods\n\n Houston._publish name, (sort, filter, limit) ->\n return unless Houston._user_is_admin @userId\n try\n collection.find(filter, sort: sort, limit: limit)\n catch e\n console.log e\n\n collection.find().observe\n added: (document) ->\n Houston._collections.collections.update {name},\n $inc: {count: 1},\n $addToSet: fields: $each: Houston._get_field_names([document])\n removed: (document) -> Houston._collections.collections.update {name}, {$inc: {count: -1}}\n\n fields = Houston._get_field_names(collection.find().fetch())\n c = Houston._collections.collections.findOne {name}\n if c\n Houston._collections.collections.update c._id, {$set: count: collection.find().count(), fields: fields}\n else\n Houston._collections.collections.insert {name, count: collection.find().count(), fields: fields}", "source_lang": "", "target_lang": "CoffeeScript", "repo": "gterrono/houston", "path": "server/publications.coffee", "license": "MIT", "commit": "89b884a6728e9da926151103ed136593aac30c9d", "stars": 802, "source_url": "https://github.com/gterrono/houston/blob/89b884a6728e9da926151103ed136593aac30c9d/server/publications.coffee", "line_start": 12, "line_end": 57}806{"id": "gterrono/houston:server/publications.coffee:2:coffee_to_js", "type": "coffee_to_js", "prompt": "Convert this CoffeeScript to JavaScript.\n```coffeescript\nHouston._setup_collection = (collection) ->\n return if collection._name in collections\n name = collection._name\n methods = {}\n methods[Houston._houstonize \"#{name}_insert\"] = (doc) ->\n return unless Houston._user_is_admin @userId\n collection.insert(doc)\n\n methods[Houston._houstonize \"#{name}_update\"] = (id, update_dict) ->\n return unless Houston._user_is_admin @userId\n if collection.findOne(id)\n collection.update(id, update_dict)\n else\n id = collection.findOne(new Meteor.Collection.ObjectID(id))\n collection.update(id, update_dict)\n\n methods[Houston._houstonize \"#{name}_delete\"] = (id, update_dict) ->\n return unless Houston._user_is_admin @userId\n if collection.findOne(id)\n collection.remove(id)\n else\n id = collection.findOne(new Meteor.Collection.ObjectID(id))\n collection.remove(id)\n\n Meteor.methods methods\n\n Houston._publish name, (sort, filter, limit) ->\n return unless Houston._user_is_admin @userId\n try\n collection.find(filter, sort: sort, limit: limit)\n catch e\n console.log e\n\n collection.find().observe\n added: (document) ->\n Houston._collections.collections.update {name},\n $inc: {count: 1},\n $addToSet: fields: $each: Houston._get_field_names([document])\n removed: (document) -> Houston._collections.collections.update {name}, {$inc: {count: -1}}\n\n fields = Houston._get_field_names(collection.find().fetch())\n c = Houston._collections.collections.findOne {name}\n if c\n Houston._collections.collections.update c._id, {$set: count: collection.find().count(), fields: fields}\n else\n Houston._collections.collections.insert {name, count: collection.find().count(), fields: fields}\n```", "response": "var indexOf = [].indexOf;\n\nHouston._setup_collection = function(collection) {\n var c, fields, methods, name, ref;\n if (ref = collection._name, indexOf.call(collections, ref) >= 0) {\n return;\n }\n name = collection._name;\n methods = {};\n methods[Houston._houstonize(`${name}_insert`)] = function(doc) {\n if (!Houston._user_is_admin(this.userId)) {\n return;\n }\n return collection.insert(doc);\n };\n methods[Houston._houstonize(`${name}_update`)] = function(id, update_dict) {\n if (!Houston._user_is_admin(this.userId)) {\n return;\n }\n if (collection.findOne(id)) {\n return collection.update(id, update_dict);\n } else {\n id = collection.findOne(new Meteor.Collection.ObjectID(id));\n return collection.update(id, update_dict);\n }\n };\n methods[Houston._houstonize(`${name}_delete`)] = function(id, update_dict) {\n if (!Houston._user_is_admin(this.userId)) {\n return;\n }\n if (collection.findOne(id)) {\n return collection.remove(id);\n } else {\n id = collection.findOne(new Meteor.Collection.ObjectID(id));\n return collection.remove(id);\n }\n };\n Meteor.methods(methods);\n Houston._publish(name, function(sort, filter, limit) {\n var e;\n if (!Houston._user_is_admin(this.userId)) {\n return;\n }\n try {\n return collection.find(filter, {\n sort: sort,\n limit: limit\n });\n } catch (error) {\n e = error;\n return console.log(e);\n }\n });\n collection.find().observe({\n added: function(document) {\n return Houston._collections.collections.update({name}, {\n $inc: {\n count: 1\n },\n $addToSet: {\n fields: {\n $each: Houston._get_field_names([document])\n }\n }\n });\n },\n removed: function(document) {\n return Houston._collections.collections.update({name}, {\n $inc: {\n count: -1\n }\n });\n }\n });\n fields = Houston._get_field_names(collection.find().fetch());\n c = Houston._collections.collections.findOne({name});\n if (c) {\n return Houston._collections.collections.update(c._id, {\n $set: {\n count: collection.find().count(),\n fields: fields\n }\n });\n } else {\n return Houston._collections.collections.insert({\n name,\n count: collection.find().count(),\n fields: fields\n });\n }\n};", "source_lang": "CoffeeScript", "target_lang": "JavaScript", "repo": "gterrono/houston", "path": "server/publications.coffee", "license": "MIT", "commit": "89b884a6728e9da926151103ed136593aac30c9d", "stars": 802, "source_url": "https://github.com/gterrono/houston/blob/89b884a6728e9da926151103ed136593aac30c9d/server/publications.coffee", "line_start": 12, "line_end": 57}807{"id": "gterrono/houston:server/publications.coffee:2:js_to_coffee", "type": "js_to_coffee", "prompt": "Convert this JavaScript to CoffeeScript.\n```javascript\nvar indexOf = [].indexOf;\n\nHouston._setup_collection = function(collection) {\n var c, fields, methods, name, ref;\n if (ref = collection._name, indexOf.call(collections, ref) >= 0) {\n return;\n }\n name = collection._name;\n methods = {};\n methods[Houston._houstonize(`${name}_insert`)] = function(doc) {\n if (!Houston._user_is_admin(this.userId)) {\n return;\n }\n return collection.insert(doc);\n };\n methods[Houston._houstonize(`${name}_update`)] = function(id, update_dict) {\n if (!Houston._user_is_admin(this.userId)) {\n return;\n }\n if (collection.findOne(id)) {\n return collection.update(id, update_dict);\n } else {\n id = collection.findOne(new Meteor.Collection.ObjectID(id));\n return collection.update(id, update_dict);\n }\n };\n methods[Houston._houstonize(`${name}_delete`)] = function(id, update_dict) {\n if (!Houston._user_is_admin(this.userId)) {\n return;\n }\n if (collection.findOne(id)) {\n return collection.remove(id);\n } else {\n id = collection.findOne(new Meteor.Collection.ObjectID(id));\n return collection.remove(id);\n }\n };\n Meteor.methods(methods);\n Houston._publish(name, function(sort, filter, limit) {\n var e;\n if (!Houston._user_is_admin(this.userId)) {\n return;\n }\n try {\n return collection.find(filter, {\n sort: sort,\n limit: limit\n });\n } catch (error) {\n e = error;\n return console.log(e);\n }\n });\n collection.find().observe({\n added: function(document) {\n return Houston._collections.collections.update({name}, {\n $inc: {\n count: 1\n },\n $addToSet: {\n fields: {\n $each: Houston._get_field_names([document])\n }\n }\n });\n },\n removed: function(document) {\n return Houston._collections.collections.update({name}, {\n $inc: {\n count: -1\n }\n });\n }\n });\n fields = Houston._get_field_names(collection.find().fetch());\n c = Houston._collections.collections.findOne({name});\n if (c) {\n return Houston._collections.collections.update(c._id, {\n $set: {\n count: collection.find().count(),\n fields: fields\n }\n });\n } else {\n return Houston._collections.collections.insert({\n name,\n count: collection.find().count(),\n fields: fields\n });\n }\n};\n```", "response": "Houston._setup_collection = (collection) ->\n return if collection._name in collections\n name = collection._name\n methods = {}\n methods[Houston._houstonize \"#{name}_insert\"] = (doc) ->\n return unless Houston._user_is_admin @userId\n collection.insert(doc)\n\n methods[Houston._houstonize \"#{name}_update\"] = (id, update_dict) ->\n return unless Houston._user_is_admin @userId\n if collection.findOne(id)\n collection.update(id, update_dict)\n else\n id = collection.findOne(new Meteor.Collection.ObjectID(id))\n collection.update(id, update_dict)\n\n methods[Houston._houstonize \"#{name}_delete\"] = (id, update_dict) ->\n return unless Houston._user_is_admin @userId\n if collection.findOne(id)\n collection.remove(id)\n else\n id = collection.findOne(new Meteor.Collection.ObjectID(id))\n collection.remove(id)\n\n Meteor.methods methods\n\n Houston._publish name, (sort, filter, limit) ->\n return unless Houston._user_is_admin @userId\n try\n collection.find(filter, sort: sort, limit: limit)\n catch e\n console.log e\n\n collection.find().observe\n added: (document) ->\n Houston._collections.collections.update {name},\n $inc: {count: 1},\n $addToSet: fields: $each: Houston._get_field_names([document])\n removed: (document) -> Houston._collections.collections.update {name}, {$inc: {count: -1}}\n\n fields = Houston._get_field_names(collection.find().fetch())\n c = Houston._collections.collections.findOne {name}\n if c\n Houston._collections.collections.update c._id, {$set: count: collection.find().count(), fields: fields}\n else\n Houston._collections.collections.insert {name, count: collection.find().count(), fields: fields}", "source_lang": "JavaScript", "target_lang": "CoffeeScript", "repo": "gterrono/houston", "path": "server/publications.coffee", "license": "MIT", "commit": "89b884a6728e9da926151103ed136593aac30c9d", "stars": 802, "source_url": "https://github.com/gterrono/houston/blob/89b884a6728e9da926151103ed136593aac30c9d/server/publications.coffee", "line_start": 12, "line_end": 57}808{"id": "gterrono/houston:server/publications.coffee:2:completion", "type": "completion", "prompt": "Houston._setup_collection = (collection) ->\n return if collection._name in collections\n name = collection._name\n methods = {}\n methods[Houston._houstonize \"#{name}_insert\"] = (doc) ->\n return unless Houston._user_is_admin @userId\n collection.insert(doc)\n\n methods[Houston._houstonize \"#{name}_update\"] = (id, update_dict) ->\n return unless Houston._user_is_admin @userId\n if collection.findOne(id)\n collection.update(id, update_dict)\n else\n id = collection.findOne(new Meteor.Collection.ObjectID(id))\n collection.update(id, update_dict)\n\n methods[Houston._houstonize \"#{name}_delete\"] = (id, update_dict) ->\n return unless Houston._user_is_admin @userId\n if collection.findOne(id)\n collection.remove(id)\n else\n id = collection.findOne(new Meteor.Collection.ObjectID(id))\n collection.remove(id)", "response": "Meteor.methods methods\n\n Houston._publish name, (sort, filter, limit) ->\n return unless Houston._user_is_admin @userId\n try\n collection.find(filter, sort: sort, limit: limit)\n catch e\n console.log e\n\n collection.find().observe\n added: (document) ->\n Houston._collections.collections.update {name},\n $inc: {count: 1},\n $addToSet: fields: $each: Houston._get_field_names([document])\n removed: (document) -> Houston._collections.collections.update {name}, {$inc: {count: -1}}\n\n fields = Houston._get_field_names(collection.find().fetch())\n c = Houston._collections.collections.findOne {name}\n if c\n Houston._collections.collections.update c._id, {$set: count: collection.find().count(), fields: fields}\n else\n Houston._collections.collections.insert {name, count: collection.find().count(), fields: fields}", "source_lang": "CoffeeScript", "target_lang": "CoffeeScript", "repo": "gterrono/houston", "path": "server/publications.coffee", "license": "MIT", "commit": "89b884a6728e9da926151103ed136593aac30c9d", "stars": 802, "source_url": "https://github.com/gterrono/houston/blob/89b884a6728e9da926151103ed136593aac30c9d/server/publications.coffee", "line_start": 12, "line_end": 57}809{"id": "gterrono/houston:server/publications.coffee:3:raw_corpus", "type": "raw_corpus", "prompt": "", "response": "sync_collections = ->\n Dummy.findOne() # hack. TODO: verify this is still necessary\n\n _sync_collections = (meh, collections_db) ->\n collection_names = (col.collectionName for col in collections_db \\\n when (col.collectionName.indexOf \"system.\") isnt 0 and\n (col.collectionName.indexOf \"houston_\") isnt 0)\n\n collection_names.forEach (name) ->\n unless name of collections or name of hidden_collections\n try\n collections[name] = new Meteor.Collection(name)\n catch e\n for key, value of root\n if name == value._name # TODO here - typecheck also?\n collections[name] = value\n\n if name of collections # found it!\n Houston._setup_collection(collections[name])\n else\n console.log \"\"\"\nHouston: couldn't find access to the #{name} collection.\nIf you'd like to access the collection from Houston, either\n(1) make sure it is available as a global (top-level namespace) within the server or\n(2) add the collection manually via Houston.add_collection\n\"\"\"\n\n bound_sync_collections = Meteor.bindEnvironment _sync_collections, (e) ->\n console.log \"Failed while syncing collections for reason: #{e}\"\n\n # MongoInternals is the 'right' solution as of 0.6.5\n mongo_driver = MongoInternals?.defaultRemoteCollectionDriver() or Meteor._RemoteCollectionDriver\n mongo_driver.mongo.db.collections bound_sync_collections\n\nMeteor.methods\n _houston_make_admin: (user_id) ->\n # limit one admin\n return if Houston._admins.findOne {'user_id': $exists: true}\n Houston._admins.insert {user_id}\n sync_collections() # reloads collections in case of new app\n return true\n\n# publish our analysis of the app's collections\nHouston._publish 'collections', ->\n return unless Houston._user_is_admin @userId\n Houston._collections.collections.find()\n\n# TODO address inherent security issue\nHouston._publish 'admin_user', ->\n Houston._admins.find {}", "source_lang": "", "target_lang": "CoffeeScript", "repo": "gterrono/houston", "path": "server/publications.coffee", "license": "MIT", "commit": "89b884a6728e9da926151103ed136593aac30c9d", "stars": 802, "source_url": "https://github.com/gterrono/houston/blob/89b884a6728e9da926151103ed136593aac30c9d/server/publications.coffee", "line_start": 59, "line_end": 108}810{"id": "gterrono/houston:server/publications.coffee:3:coffee_to_js", "type": "coffee_to_js", "prompt": "Convert this CoffeeScript to JavaScript.\n```coffeescript\nsync_collections = ->\n Dummy.findOne() # hack. TODO: verify this is still necessary\n\n _sync_collections = (meh, collections_db) ->\n collection_names = (col.collectionName for col in collections_db \\\n when (col.collectionName.indexOf \"system.\") isnt 0 and\n (col.collectionName.indexOf \"houston_\") isnt 0)\n\n collection_names.forEach (name) ->\n unless name of collections or name of hidden_collections\n try\n collections[name] = new Meteor.Collection(name)\n catch e\n for key, value of root\n if name == value._name # TODO here - typecheck also?\n collections[name] = value\n\n if name of collections # found it!\n Houston._setup_collection(collections[name])\n else\n console.log \"\"\"\nHouston: couldn't find access to the #{name} collection.\nIf you'd like to access the collection from Houston, either\n(1) make sure it is available as a global (top-level namespace) within the server or\n(2) add the collection manually via Houston.add_collection\n\"\"\"\n\n bound_sync_collections = Meteor.bindEnvironment _sync_collections, (e) ->\n console.log \"Failed while syncing collections for reason: #{e}\"\n\n # MongoInternals is the 'right' solution as of 0.6.5\n mongo_driver = MongoInternals?.defaultRemoteCollectionDriver() or Meteor._RemoteCollectionDriver\n mongo_driver.mongo.db.collections bound_sync_collections\n\nMeteor.methods\n _houston_make_admin: (user_id) ->\n # limit one admin\n return if Houston._admins.findOne {'user_id': $exists: true}\n Houston._admins.insert {user_id}\n sync_collections() # reloads collections in case of new app\n return true\n\n# publish our analysis of the app's collections\nHouston._publish 'collections', ->\n return unless Houston._user_is_admin @userId\n Houston._collections.collections.find()\n\n# TODO address inherent security issue\nHouston._publish 'admin_user', ->\n Houston._admins.find {}\n```", "response": "var sync_collections;\n\nsync_collections = function() {\n var _sync_collections, bound_sync_collections, mongo_driver;\n Dummy.findOne(); // hack. TODO: verify this is still necessary\n _sync_collections = function(meh, collections_db) {\n var col, collection_names;\n collection_names = (function() {\n var i, len, results;\n results = [];\n for (i = 0, len = collections_db.length; i < len; i++) {\n col = collections_db[i];\n if ((col.collectionName.indexOf(\"system.\")) !== 0 && (col.collectionName.indexOf(\"houston_\")) !== 0) {\n results.push(col.collectionName);\n }\n }\n return results;\n })();\n return collection_names.forEach(function(name) {\n var e, key, value;\n if (!(name in collections || name in hidden_collections)) {\n try {\n collections[name] = new Meteor.Collection(name);\n } catch (error) {\n e = error;\n for (key in root) {\n value = root[key];\n if (name === value._name) { // TODO here - typecheck also?\n collections[name] = value;\n }\n }\n }\n if (name in collections) { // found it!\n return Houston._setup_collection(collections[name]);\n } else {\n return console.log(`Houston: couldn't find access to the ${name} collection.\nIf you'd like to access the collection from Houston, either\n(1) make sure it is available as a global (top-level namespace) within the server or\n(2) add the collection manually via Houston.add_collection`);\n }\n }\n });\n };\n bound_sync_collections = Meteor.bindEnvironment(_sync_collections, function(e) {\n return console.log(`Failed while syncing collections for reason: ${e}`);\n });\n // MongoInternals is the 'right' solution as of 0.6.5\n mongo_driver = (typeof MongoInternals !== \"undefined\" && MongoInternals !== null ? MongoInternals.defaultRemoteCollectionDriver() : void 0) || Meteor._RemoteCollectionDriver;\n return mongo_driver.mongo.db.collections(bound_sync_collections);\n};\n\nMeteor.methods({\n _houston_make_admin: function(user_id) {\n // limit one admin\n if (Houston._admins.findOne({\n 'user_id': {\n $exists: true\n }\n })) {\n return;\n }\n Houston._admins.insert({user_id});\n sync_collections(); // reloads collections in case of new app\n return true;\n }\n});\n\n// publish our analysis of the app's collections\nHouston._publish('collections', function() {\n if (!Houston._user_is_admin(this.userId)) {\n return;\n }\n return Houston._collections.collections.find();\n});\n\n// TODO address inherent security issue\nHouston._publish('admin_user', function() {\n return Houston._admins.find({});\n});", "source_lang": "CoffeeScript", "target_lang": "JavaScript", "repo": "gterrono/houston", "path": "server/publications.coffee", "license": "MIT", "commit": "89b884a6728e9da926151103ed136593aac30c9d", "stars": 802, "source_url": "https://github.com/gterrono/houston/blob/89b884a6728e9da926151103ed136593aac30c9d/server/publications.coffee", "line_start": 59, "line_end": 108}811{"id": "gterrono/houston:server/publications.coffee:3:js_to_coffee", "type": "js_to_coffee", "prompt": "Convert this JavaScript to CoffeeScript.\n```javascript\nvar sync_collections;\n\nsync_collections = function() {\n var _sync_collections, bound_sync_collections, mongo_driver;\n Dummy.findOne(); // hack. TODO: verify this is still necessary\n _sync_collections = function(meh, collections_db) {\n var col, collection_names;\n collection_names = (function() {\n var i, len, results;\n results = [];\n for (i = 0, len = collections_db.length; i < len; i++) {\n col = collections_db[i];\n if ((col.collectionName.indexOf(\"system.\")) !== 0 && (col.collectionName.indexOf(\"houston_\")) !== 0) {\n results.push(col.collectionName);\n }\n }\n return results;\n })();\n return collection_names.forEach(function(name) {\n var e, key, value;\n if (!(name in collections || name in hidden_collections)) {\n try {\n collections[name] = new Meteor.Collection(name);\n } catch (error) {\n e = error;\n for (key in root) {\n value = root[key];\n if (name === value._name) { // TODO here - typecheck also?\n collections[name] = value;\n }\n }\n }\n if (name in collections) { // found it!\n return Houston._setup_collection(collections[name]);\n } else {\n return console.log(`Houston: couldn't find access to the ${name} collection.\nIf you'd like to access the collection from Houston, either\n(1) make sure it is available as a global (top-level namespace) within the server or\n(2) add the collection manually via Houston.add_collection`);\n }\n }\n });\n };\n bound_sync_collections = Meteor.bindEnvironment(_sync_collections, function(e) {\n return console.log(`Failed while syncing collections for reason: ${e}`);\n });\n // MongoInternals is the 'right' solution as of 0.6.5\n mongo_driver = (typeof MongoInternals !== \"undefined\" && MongoInternals !== null ? MongoInternals.defaultRemoteCollectionDriver() : void 0) || Meteor._RemoteCollectionDriver;\n return mongo_driver.mongo.db.collections(bound_sync_collections);\n};\n\nMeteor.methods({\n _houston_make_admin: function(user_id) {\n // limit one admin\n if (Houston._admins.findOne({\n 'user_id': {\n $exists: true\n }\n })) {\n return;\n }\n Houston._admins.insert({user_id});\n sync_collections(); // reloads collections in case of new app\n return true;\n }\n});\n\n// publish our analysis of the app's collections\nHouston._publish('collections', function() {\n if (!Houston._user_is_admin(this.userId)) {\n return;\n }\n return Houston._collections.collections.find();\n});\n\n// TODO address inherent security issue\nHouston._publish('admin_user', function() {\n return Houston._admins.find({});\n});\n```", "response": "sync_collections = ->\n Dummy.findOne() # hack. TODO: verify this is still necessary\n\n _sync_collections = (meh, collections_db) ->\n collection_names = (col.collectionName for col in collections_db \\\n when (col.collectionName.indexOf \"system.\") isnt 0 and\n (col.collectionName.indexOf \"houston_\") isnt 0)\n\n collection_names.forEach (name) ->\n unless name of collections or name of hidden_collections\n try\n collections[name] = new Meteor.Collection(name)\n catch e\n for key, value of root\n if name == value._name # TODO here - typecheck also?\n collections[name] = value\n\n if name of collections # found it!\n Houston._setup_collection(collections[name])\n else\n console.log \"\"\"\nHouston: couldn't find access to the #{name} collection.\nIf you'd like to access the collection from Houston, either\n(1) make sure it is available as a global (top-level namespace) within the server or\n(2) add the collection manually via Houston.add_collection\n\"\"\"\n\n bound_sync_collections = Meteor.bindEnvironment _sync_collections, (e) ->\n console.log \"Failed while syncing collections for reason: #{e}\"\n\n # MongoInternals is the 'right' solution as of 0.6.5\n mongo_driver = MongoInternals?.defaultRemoteCollectionDriver() or Meteor._RemoteCollectionDriver\n mongo_driver.mongo.db.collections bound_sync_collections\n\nMeteor.methods\n _houston_make_admin: (user_id) ->\n # limit one admin\n return if Houston._admins.findOne {'user_id': $exists: true}\n Houston._admins.insert {user_id}\n sync_collections() # reloads collections in case of new app\n return true\n\n# publish our analysis of the app's collections\nHouston._publish 'collections', ->\n return unless Houston._user_is_admin @userId\n Houston._collections.collections.find()\n\n# TODO address inherent security issue\nHouston._publish 'admin_user', ->\n Houston._admins.find {}", "source_lang": "JavaScript", "target_lang": "CoffeeScript", "repo": "gterrono/houston", "path": "server/publications.coffee", "license": "MIT", "commit": "89b884a6728e9da926151103ed136593aac30c9d", "stars": 802, "source_url": "https://github.com/gterrono/houston/blob/89b884a6728e9da926151103ed136593aac30c9d/server/publications.coffee", "line_start": 59, "line_end": 108}812{"id": "gterrono/houston:server/publications.coffee:3:completion", "type": "completion", "prompt": "sync_collections = ->\n Dummy.findOne() # hack. TODO: verify this is still necessary\n\n _sync_collections = (meh, collections_db) ->\n collection_names = (col.collectionName for col in collections_db \\\n when (col.collectionName.indexOf \"system.\") isnt 0 and\n (col.collectionName.indexOf \"houston_\") isnt 0)\n\n collection_names.forEach (name) ->\n unless name of collections or name of hidden_collections\n try\n collections[name] = new Meteor.Collection(name)\n catch e\n for key, value of root\n if name == value._name # TODO here - typecheck also?\n collections[name] = value\n\n if name of collections # found it!\n Houston._setup_collection(collections[name])\n else\n console.log \"\"\"\nHouston: couldn't find access to the #{name} collection.\nIf you'd like to access the collection from Houston, either\n(1) make sure it is available as a global (top-level namespace) within the server or\n(2) add the collection manually via Houston.add_collection", "response": "\"\"\"\n\n bound_sync_collections = Meteor.bindEnvironment _sync_collections, (e) ->\n console.log \"Failed while syncing collections for reason: #{e}\"\n\n # MongoInternals is the 'right' solution as of 0.6.5\n mongo_driver = MongoInternals?.defaultRemoteCollectionDriver() or Meteor._RemoteCollectionDriver\n mongo_driver.mongo.db.collections bound_sync_collections\n\nMeteor.methods\n _houston_make_admin: (user_id) ->\n # limit one admin\n return if Houston._admins.findOne {'user_id': $exists: true}\n Houston._admins.insert {user_id}\n sync_collections() # reloads collections in case of new app\n return true\n\n# publish our analysis of the app's collections\nHouston._publish 'collections', ->\n return unless Houston._user_is_admin @userId\n Houston._collections.collections.find()\n\n# TODO address inherent security issue\nHouston._publish 'admin_user', ->\n Houston._admins.find {}", "source_lang": "CoffeeScript", "target_lang": "CoffeeScript", "repo": "gterrono/houston", "path": "server/publications.coffee", "license": "MIT", "commit": "89b884a6728e9da926151103ed136593aac30c9d", "stars": 802, "source_url": "https://github.com/gterrono/houston/blob/89b884a6728e9da926151103ed136593aac30c9d/server/publications.coffee", "line_start": 59, "line_end": 108}813{"id": "gterrono/houston:server/publications.coffee:3:raw_corpus", "type": "raw_corpus", "prompt": "", "response": "sync_collections = ->\n Dummy.findOne() # hack. TODO: verify this is still necessary\n\n _sync_collections = (meh, collections_db) ->\n collection_names = (col.collectionName for col in collections_db \\\n when (col.collectionName.indexOf \"system.\") isnt 0 and\n (col.collectionName.indexOf \"houston_\") isnt 0)\n\n collection_names.forEach (name) ->\n unless name of collections or name of hidden_collections\n try\n collections[name] = new Meteor.Collection(name)\n catch e\n for key, value of root\n if name == value._name # TODO here - typecheck also?\n collections[name] = value\n Houston._setup_collection(collections[name])\n\n unless name of collections\n console.log \"\"\"\nHouston: couldn't find access to the #{name} collection.\nIf you'd like to access the collection from Houston, either\n(1) make sure it is available as a global (top-level namespace) within the server or\n(2) add the collection manually via Houston.add_collection\n\"\"\"\n\n bound_sync_collections = Meteor.bindEnvironment _sync_collections, (e) ->\n console.log \"Failed while syncing collections for reason: #{e}\"\n\n # MongoInternals is the 'right' solution as of 0.6.5\n mongo_driver = MongoInternals?.defaultRemoteCollectionDriver() or Meteor._RemoteCollectionDriver\n mongo_driver.mongo.db.collections bound_sync_collections\n\nMeteor.methods\n _houston_make_admin: (user_id) ->\n # limit one admin\n return if Houston._admins.findOne {'user_id': $exists: true}\n Houston._admins.insert {user_id}\n sync_collections() # reloads collections in case of new app\n return true\n\n# publish our analysis of the app's collections\nHouston._publish 'collections', ->\n return unless Houston._user_is_admin @userId\n Houston._collections.collections.find()\n\n# TODO address inherent security issue\nHouston._publish 'admin_user', ->\n Houston._admins.find {}", "source_lang": "", "target_lang": "CoffeeScript", "repo": "gterrono/houston", "path": "server/publications.coffee", "license": "MIT", "commit": "11aeed77b3c7238ecfe30a37f7a1ebc250789adf", "stars": 802, "source_url": "https://github.com/gterrono/houston/blob/11aeed77b3c7238ecfe30a37f7a1ebc250789adf/server/publications.coffee", "line_start": 59, "line_end": 108}814{"id": "gterrono/houston:server/publications.coffee:3:coffee_to_js", "type": "coffee_to_js", "prompt": "Convert this CoffeeScript to JavaScript.\n```coffeescript\nsync_collections = ->\n Dummy.findOne() # hack. TODO: verify this is still necessary\n\n _sync_collections = (meh, collections_db) ->\n collection_names = (col.collectionName for col in collections_db \\\n when (col.collectionName.indexOf \"system.\") isnt 0 and\n (col.collectionName.indexOf \"houston_\") isnt 0)\n\n collection_names.forEach (name) ->\n unless name of collections or name of hidden_collections\n try\n collections[name] = new Meteor.Collection(name)\n catch e\n for key, value of root\n if name == value._name # TODO here - typecheck also?\n collections[name] = value\n Houston._setup_collection(collections[name])\n\n unless name of collections\n console.log \"\"\"\nHouston: couldn't find access to the #{name} collection.\nIf you'd like to access the collection from Houston, either\n(1) make sure it is available as a global (top-level namespace) within the server or\n(2) add the collection manually via Houston.add_collection\n\"\"\"\n\n bound_sync_collections = Meteor.bindEnvironment _sync_collections, (e) ->\n console.log \"Failed while syncing collections for reason: #{e}\"\n\n # MongoInternals is the 'right' solution as of 0.6.5\n mongo_driver = MongoInternals?.defaultRemoteCollectionDriver() or Meteor._RemoteCollectionDriver\n mongo_driver.mongo.db.collections bound_sync_collections\n\nMeteor.methods\n _houston_make_admin: (user_id) ->\n # limit one admin\n return if Houston._admins.findOne {'user_id': $exists: true}\n Houston._admins.insert {user_id}\n sync_collections() # reloads collections in case of new app\n return true\n\n# publish our analysis of the app's collections\nHouston._publish 'collections', ->\n return unless Houston._user_is_admin @userId\n Houston._collections.collections.find()\n\n# TODO address inherent security issue\nHouston._publish 'admin_user', ->\n Houston._admins.find {}\n```", "response": "var sync_collections;\n\nsync_collections = function() {\n var _sync_collections, bound_sync_collections, mongo_driver;\n Dummy.findOne(); // hack. TODO: verify this is still necessary\n _sync_collections = function(meh, collections_db) {\n var col, collection_names;\n collection_names = (function() {\n var i, len, results;\n results = [];\n for (i = 0, len = collections_db.length; i < len; i++) {\n col = collections_db[i];\n if ((col.collectionName.indexOf(\"system.\")) !== 0 && (col.collectionName.indexOf(\"houston_\")) !== 0) {\n results.push(col.collectionName);\n }\n }\n return results;\n })();\n return collection_names.forEach(function(name) {\n var e, key, value;\n if (!(name in collections || name in hidden_collections)) {\n try {\n return collections[name] = new Meteor.Collection(name);\n } catch (error) {\n e = error;\n for (key in root) {\n value = root[key];\n if (name === value._name) { // TODO here - typecheck also?\n collections[name] = value;\n Houston._setup_collection(collections[name]);\n }\n }\n if (!(name in collections)) {\n return console.log(`Houston: couldn't find access to the ${name} collection.\nIf you'd like to access the collection from Houston, either\n(1) make sure it is available as a global (top-level namespace) within the server or\n(2) add the collection manually via Houston.add_collection`);\n }\n }\n }\n });\n };\n bound_sync_collections = Meteor.bindEnvironment(_sync_collections, function(e) {\n return console.log(`Failed while syncing collections for reason: ${e}`);\n });\n // MongoInternals is the 'right' solution as of 0.6.5\n mongo_driver = (typeof MongoInternals !== \"undefined\" && MongoInternals !== null ? MongoInternals.defaultRemoteCollectionDriver() : void 0) || Meteor._RemoteCollectionDriver;\n return mongo_driver.mongo.db.collections(bound_sync_collections);\n};\n\nMeteor.methods({\n _houston_make_admin: function(user_id) {\n // limit one admin\n if (Houston._admins.findOne({\n 'user_id': {\n $exists: true\n }\n })) {\n return;\n }\n Houston._admins.insert({user_id});\n sync_collections(); // reloads collections in case of new app\n return true;\n }\n});\n\n// publish our analysis of the app's collections\nHouston._publish('collections', function() {\n if (!Houston._user_is_admin(this.userId)) {\n return;\n }\n return Houston._collections.collections.find();\n});\n\n// TODO address inherent security issue\nHouston._publish('admin_user', function() {\n return Houston._admins.find({});\n});", "source_lang": "CoffeeScript", "target_lang": "JavaScript", "repo": "gterrono/houston", "path": "server/publications.coffee", "license": "MIT", "commit": "11aeed77b3c7238ecfe30a37f7a1ebc250789adf", "stars": 802, "source_url": "https://github.com/gterrono/houston/blob/11aeed77b3c7238ecfe30a37f7a1ebc250789adf/server/publications.coffee", "line_start": 59, "line_end": 108}815{"id": "gterrono/houston:server/publications.coffee:3:js_to_coffee", "type": "js_to_coffee", "prompt": "Convert this JavaScript to CoffeeScript.\n```javascript\nvar sync_collections;\n\nsync_collections = function() {\n var _sync_collections, bound_sync_collections, mongo_driver;\n Dummy.findOne(); // hack. TODO: verify this is still necessary\n _sync_collections = function(meh, collections_db) {\n var col, collection_names;\n collection_names = (function() {\n var i, len, results;\n results = [];\n for (i = 0, len = collections_db.length; i < len; i++) {\n col = collections_db[i];\n if ((col.collectionName.indexOf(\"system.\")) !== 0 && (col.collectionName.indexOf(\"houston_\")) !== 0) {\n results.push(col.collectionName);\n }\n }\n return results;\n })();\n return collection_names.forEach(function(name) {\n var e, key, value;\n if (!(name in collections || name in hidden_collections)) {\n try {\n return collections[name] = new Meteor.Collection(name);\n } catch (error) {\n e = error;\n for (key in root) {\n value = root[key];\n if (name === value._name) { // TODO here - typecheck also?\n collections[name] = value;\n Houston._setup_collection(collections[name]);\n }\n }\n if (!(name in collections)) {\n return console.log(`Houston: couldn't find access to the ${name} collection.\nIf you'd like to access the collection from Houston, either\n(1) make sure it is available as a global (top-level namespace) within the server or\n(2) add the collection manually via Houston.add_collection`);\n }\n }\n }\n });\n };\n bound_sync_collections = Meteor.bindEnvironment(_sync_collections, function(e) {\n return console.log(`Failed while syncing collections for reason: ${e}`);\n });\n // MongoInternals is the 'right' solution as of 0.6.5\n mongo_driver = (typeof MongoInternals !== \"undefined\" && MongoInternals !== null ? MongoInternals.defaultRemoteCollectionDriver() : void 0) || Meteor._RemoteCollectionDriver;\n return mongo_driver.mongo.db.collections(bound_sync_collections);\n};\n\nMeteor.methods({\n _houston_make_admin: function(user_id) {\n // limit one admin\n if (Houston._admins.findOne({\n 'user_id': {\n $exists: true\n }\n })) {\n return;\n }\n Houston._admins.insert({user_id});\n sync_collections(); // reloads collections in case of new app\n return true;\n }\n});\n\n// publish our analysis of the app's collections\nHouston._publish('collections', function() {\n if (!Houston._user_is_admin(this.userId)) {\n return;\n }\n return Houston._collections.collections.find();\n});\n\n// TODO address inherent security issue\nHouston._publish('admin_user', function() {\n return Houston._admins.find({});\n});\n```", "response": "sync_collections = ->\n Dummy.findOne() # hack. TODO: verify this is still necessary\n\n _sync_collections = (meh, collections_db) ->\n collection_names = (col.collectionName for col in collections_db \\\n when (col.collectionName.indexOf \"system.\") isnt 0 and\n (col.collectionName.indexOf \"houston_\") isnt 0)\n\n collection_names.forEach (name) ->\n unless name of collections or name of hidden_collections\n try\n collections[name] = new Meteor.Collection(name)\n catch e\n for key, value of root\n if name == value._name # TODO here - typecheck also?\n collections[name] = value\n Houston._setup_collection(collections[name])\n\n unless name of collections\n console.log \"\"\"\nHouston: couldn't find access to the #{name} collection.\nIf you'd like to access the collection from Houston, either\n(1) make sure it is available as a global (top-level namespace) within the server or\n(2) add the collection manually via Houston.add_collection\n\"\"\"\n\n bound_sync_collections = Meteor.bindEnvironment _sync_collections, (e) ->\n console.log \"Failed while syncing collections for reason: #{e}\"\n\n # MongoInternals is the 'right' solution as of 0.6.5\n mongo_driver = MongoInternals?.defaultRemoteCollectionDriver() or Meteor._RemoteCollectionDriver\n mongo_driver.mongo.db.collections bound_sync_collections\n\nMeteor.methods\n _houston_make_admin: (user_id) ->\n # limit one admin\n return if Houston._admins.findOne {'user_id': $exists: true}\n Houston._admins.insert {user_id}\n sync_collections() # reloads collections in case of new app\n return true\n\n# publish our analysis of the app's collections\nHouston._publish 'collections', ->\n return unless Houston._user_is_admin @userId\n Houston._collections.collections.find()\n\n# TODO address inherent security issue\nHouston._publish 'admin_user', ->\n Houston._admins.find {}", "source_lang": "JavaScript", "target_lang": "CoffeeScript", "repo": "gterrono/houston", "path": "server/publications.coffee", "license": "MIT", "commit": "11aeed77b3c7238ecfe30a37f7a1ebc250789adf", "stars": 802, "source_url": "https://github.com/gterrono/houston/blob/11aeed77b3c7238ecfe30a37f7a1ebc250789adf/server/publications.coffee", "line_start": 59, "line_end": 108}816{"id": "gterrono/houston:server/publications.coffee:3:completion", "type": "completion", "prompt": "sync_collections = ->\n Dummy.findOne() # hack. TODO: verify this is still necessary\n\n _sync_collections = (meh, collections_db) ->\n collection_names = (col.collectionName for col in collections_db \\\n when (col.collectionName.indexOf \"system.\") isnt 0 and\n (col.collectionName.indexOf \"houston_\") isnt 0)\n\n collection_names.forEach (name) ->\n unless name of collections or name of hidden_collections\n try\n collections[name] = new Meteor.Collection(name)\n catch e\n for key, value of root\n if name == value._name # TODO here - typecheck also?\n collections[name] = value\n Houston._setup_collection(collections[name])\n\n unless name of collections\n console.log \"\"\"\nHouston: couldn't find access to the #{name} collection.\nIf you'd like to access the collection from Houston, either\n(1) make sure it is available as a global (top-level namespace) within the server or\n(2) add the collection manually via Houston.add_collection", "response": "\"\"\"\n\n bound_sync_collections = Meteor.bindEnvironment _sync_collections, (e) ->\n console.log \"Failed while syncing collections for reason: #{e}\"\n\n # MongoInternals is the 'right' solution as of 0.6.5\n mongo_driver = MongoInternals?.defaultRemoteCollectionDriver() or Meteor._RemoteCollectionDriver\n mongo_driver.mongo.db.collections bound_sync_collections\n\nMeteor.methods\n _houston_make_admin: (user_id) ->\n # limit one admin\n return if Houston._admins.findOne {'user_id': $exists: true}\n Houston._admins.insert {user_id}\n sync_collections() # reloads collections in case of new app\n return true\n\n# publish our analysis of the app's collections\nHouston._publish 'collections', ->\n return unless Houston._user_is_admin @userId\n Houston._collections.collections.find()\n\n# TODO address inherent security issue\nHouston._publish 'admin_user', ->\n Houston._admins.find {}", "source_lang": "CoffeeScript", "target_lang": "CoffeeScript", "repo": "gterrono/houston", "path": "server/publications.coffee", "license": "MIT", "commit": "11aeed77b3c7238ecfe30a37f7a1ebc250789adf", "stars": 802, "source_url": "https://github.com/gterrono/houston/blob/11aeed77b3c7238ecfe30a37f7a1ebc250789adf/server/publications.coffee", "line_start": 59, "line_end": 108}817{"id": "gterrono/houston:server/publications.coffee:2:raw_corpus", "type": "raw_corpus", "prompt": "", "response": "setup_collection = (name, collection) ->\n methods = {}\n methods[Houston._houstonize \"#{name}_insert\"] = (doc) ->\n return unless Houston._user_is_admin @userId\n collection.insert(doc)\n\n methods[Houston._houstonize \"#{name}_update\"] = (id, update_dict) ->\n return unless Houston._user_is_admin @userId\n if collection.findOne(id)\n collection.update(id, update_dict)\n else\n id = collection.findOne(new Meteor.Collection.ObjectID(id))\n collection.update(id, update_dict)\n\n methods[Houston._houstonize \"#{name}_delete\"] = (id, update_dict) ->\n return unless Houston._user_is_admin @userId\n if collection.findOne(id)\n collection.remove(id)\n else\n id = collection.findOne(new Meteor.Collection.ObjectID(id))\n collection.remove(id)\n\n Meteor.methods methods\n\n Houston._publish name, (sort, filter, limit) ->\n return unless Houston._user_is_admin @userId\n try\n collection.find(filter, sort: sort, limit: limit)\n catch e\n console.log e\n\n collection.find().observe\n added: (document) ->\n Houston._collections.collections.update {name},\n $inc: {count: 1},\n $addToSet: fields: $each: Houston._get_field_names([document])\n removed: (document) -> Houston._collections.collections.update {name}, {$inc: {count: -1}}\n\n fields = Houston._get_field_names(collection.find().fetch())\n c = Houston._collections.collections.findOne {name}\n if c\n Houston._collections.collections.update c._id, {$set: count: collection.find().count(), fields: fields}\n else\n Houston._collections.collections.insert {name, count: collection.find().count(), fields: fields}\n\ncollections = {'users': Meteor.users} #TODO verify this is still relevant", "source_lang": "", "target_lang": "CoffeeScript", "repo": "gterrono/houston", "path": "server/publications.coffee", "license": "MIT", "commit": "227fa0e254151bcdf3c2a163f7f0ff4a9d3a31c4", "stars": 802, "source_url": "https://github.com/gterrono/houston/blob/227fa0e254151bcdf3c2a163f7f0ff4a9d3a31c4/server/publications.coffee", "line_start": 8, "line_end": 53}818{"id": "gterrono/houston:server/publications.coffee:2:coffee_to_js", "type": "coffee_to_js", "prompt": "Convert this CoffeeScript to JavaScript.\n```coffeescript\nsetup_collection = (name, collection) ->\n methods = {}\n methods[Houston._houstonize \"#{name}_insert\"] = (doc) ->\n return unless Houston._user_is_admin @userId\n collection.insert(doc)\n\n methods[Houston._houstonize \"#{name}_update\"] = (id, update_dict) ->\n return unless Houston._user_is_admin @userId\n if collection.findOne(id)\n collection.update(id, update_dict)\n else\n id = collection.findOne(new Meteor.Collection.ObjectID(id))\n collection.update(id, update_dict)\n\n methods[Houston._houstonize \"#{name}_delete\"] = (id, update_dict) ->\n return unless Houston._user_is_admin @userId\n if collection.findOne(id)\n collection.remove(id)\n else\n id = collection.findOne(new Meteor.Collection.ObjectID(id))\n collection.remove(id)\n\n Meteor.methods methods\n\n Houston._publish name, (sort, filter, limit) ->\n return unless Houston._user_is_admin @userId\n try\n collection.find(filter, sort: sort, limit: limit)\n catch e\n console.log e\n\n collection.find().observe\n added: (document) ->\n Houston._collections.collections.update {name},\n $inc: {count: 1},\n $addToSet: fields: $each: Houston._get_field_names([document])\n removed: (document) -> Houston._collections.collections.update {name}, {$inc: {count: -1}}\n\n fields = Houston._get_field_names(collection.find().fetch())\n c = Houston._collections.collections.findOne {name}\n if c\n Houston._collections.collections.update c._id, {$set: count: collection.find().count(), fields: fields}\n else\n Houston._collections.collections.insert {name, count: collection.find().count(), fields: fields}\n\ncollections = {'users': Meteor.users} #TODO verify this is still relevant\n```", "response": "var collections, setup_collection;\n\nsetup_collection = function(name, collection) {\n var c, fields, methods;\n methods = {};\n methods[Houston._houstonize(`${name}_insert`)] = function(doc) {\n if (!Houston._user_is_admin(this.userId)) {\n return;\n }\n return collection.insert(doc);\n };\n methods[Houston._houstonize(`${name}_update`)] = function(id, update_dict) {\n if (!Houston._user_is_admin(this.userId)) {\n return;\n }\n if (collection.findOne(id)) {\n return collection.update(id, update_dict);\n } else {\n id = collection.findOne(new Meteor.Collection.ObjectID(id));\n return collection.update(id, update_dict);\n }\n };\n methods[Houston._houstonize(`${name}_delete`)] = function(id, update_dict) {\n if (!Houston._user_is_admin(this.userId)) {\n return;\n }\n if (collection.findOne(id)) {\n return collection.remove(id);\n } else {\n id = collection.findOne(new Meteor.Collection.ObjectID(id));\n return collection.remove(id);\n }\n };\n Meteor.methods(methods);\n Houston._publish(name, function(sort, filter, limit) {\n var e;\n if (!Houston._user_is_admin(this.userId)) {\n return;\n }\n try {\n return collection.find(filter, {\n sort: sort,\n limit: limit\n });\n } catch (error) {\n e = error;\n return console.log(e);\n }\n });\n collection.find().observe({\n added: function(document) {\n return Houston._collections.collections.update({name}, {\n $inc: {\n count: 1\n },\n $addToSet: {\n fields: {\n $each: Houston._get_field_names([document])\n }\n }\n });\n },\n removed: function(document) {\n return Houston._collections.collections.update({name}, {\n $inc: {\n count: -1\n }\n });\n }\n });\n fields = Houston._get_field_names(collection.find().fetch());\n c = Houston._collections.collections.findOne({name});\n if (c) {\n return Houston._collections.collections.update(c._id, {\n $set: {\n count: collection.find().count(),\n fields: fields\n }\n });\n } else {\n return Houston._collections.collections.insert({\n name,\n count: collection.find().count(),\n fields: fields\n });\n }\n};\n\ncollections = {\n 'users': Meteor.users //TODO verify this is still relevant\n};", "source_lang": "CoffeeScript", "target_lang": "JavaScript", "repo": "gterrono/houston", "path": "server/publications.coffee", "license": "MIT", "commit": "227fa0e254151bcdf3c2a163f7f0ff4a9d3a31c4", "stars": 802, "source_url": "https://github.com/gterrono/houston/blob/227fa0e254151bcdf3c2a163f7f0ff4a9d3a31c4/server/publications.coffee", "line_start": 8, "line_end": 53}819{"id": "gterrono/houston:server/publications.coffee:2:js_to_coffee", "type": "js_to_coffee", "prompt": "Convert this JavaScript to CoffeeScript.\n```javascript\nvar collections, setup_collection;\n\nsetup_collection = function(name, collection) {\n var c, fields, methods;\n methods = {};\n methods[Houston._houstonize(`${name}_insert`)] = function(doc) {\n if (!Houston._user_is_admin(this.userId)) {\n return;\n }\n return collection.insert(doc);\n };\n methods[Houston._houstonize(`${name}_update`)] = function(id, update_dict) {\n if (!Houston._user_is_admin(this.userId)) {\n return;\n }\n if (collection.findOne(id)) {\n return collection.update(id, update_dict);\n } else {\n id = collection.findOne(new Meteor.Collection.ObjectID(id));\n return collection.update(id, update_dict);\n }\n };\n methods[Houston._houstonize(`${name}_delete`)] = function(id, update_dict) {\n if (!Houston._user_is_admin(this.userId)) {\n return;\n }\n if (collection.findOne(id)) {\n return collection.remove(id);\n } else {\n id = collection.findOne(new Meteor.Collection.ObjectID(id));\n return collection.remove(id);\n }\n };\n Meteor.methods(methods);\n Houston._publish(name, function(sort, filter, limit) {\n var e;\n if (!Houston._user_is_admin(this.userId)) {\n return;\n }\n try {\n return collection.find(filter, {\n sort: sort,\n limit: limit\n });\n } catch (error) {\n e = error;\n return console.log(e);\n }\n });\n collection.find().observe({\n added: function(document) {\n return Houston._collections.collections.update({name}, {\n $inc: {\n count: 1\n },\n $addToSet: {\n fields: {\n $each: Houston._get_field_names([document])\n }\n }\n });\n },\n removed: function(document) {\n return Houston._collections.collections.update({name}, {\n $inc: {\n count: -1\n }\n });\n }\n });\n fields = Houston._get_field_names(collection.find().fetch());\n c = Houston._collections.collections.findOne({name});\n if (c) {\n return Houston._collections.collections.update(c._id, {\n $set: {\n count: collection.find().count(),\n fields: fields\n }\n });\n } else {\n return Houston._collections.collections.insert({\n name,\n count: collection.find().count(),\n fields: fields\n });\n }\n};\n\ncollections = {\n 'users': Meteor.users //TODO verify this is still relevant\n};\n```", "response": "setup_collection = (name, collection) ->\n methods = {}\n methods[Houston._houstonize \"#{name}_insert\"] = (doc) ->\n return unless Houston._user_is_admin @userId\n collection.insert(doc)\n\n methods[Houston._houstonize \"#{name}_update\"] = (id, update_dict) ->\n return unless Houston._user_is_admin @userId\n if collection.findOne(id)\n collection.update(id, update_dict)\n else\n id = collection.findOne(new Meteor.Collection.ObjectID(id))\n collection.update(id, update_dict)\n\n methods[Houston._houstonize \"#{name}_delete\"] = (id, update_dict) ->\n return unless Houston._user_is_admin @userId\n if collection.findOne(id)\n collection.remove(id)\n else\n id = collection.findOne(new Meteor.Collection.ObjectID(id))\n collection.remove(id)\n\n Meteor.methods methods\n\n Houston._publish name, (sort, filter, limit) ->\n return unless Houston._user_is_admin @userId\n try\n collection.find(filter, sort: sort, limit: limit)\n catch e\n console.log e\n\n collection.find().observe\n added: (document) ->\n Houston._collections.collections.update {name},\n $inc: {count: 1},\n $addToSet: fields: $each: Houston._get_field_names([document])\n removed: (document) -> Houston._collections.collections.update {name}, {$inc: {count: -1}}\n\n fields = Houston._get_field_names(collection.find().fetch())\n c = Houston._collections.collections.findOne {name}\n if c\n Houston._collections.collections.update c._id, {$set: count: collection.find().count(), fields: fields}\n else\n Houston._collections.collections.insert {name, count: collection.find().count(), fields: fields}\n\ncollections = {'users': Meteor.users} #TODO verify this is still relevant", "source_lang": "JavaScript", "target_lang": "CoffeeScript", "repo": "gterrono/houston", "path": "server/publications.coffee", "license": "MIT", "commit": "227fa0e254151bcdf3c2a163f7f0ff4a9d3a31c4", "stars": 802, "source_url": "https://github.com/gterrono/houston/blob/227fa0e254151bcdf3c2a163f7f0ff4a9d3a31c4/server/publications.coffee", "line_start": 8, "line_end": 53}820{"id": "gterrono/houston:server/publications.coffee:2:completion", "type": "completion", "prompt": "setup_collection = (name, collection) ->\n methods = {}\n methods[Houston._houstonize \"#{name}_insert\"] = (doc) ->\n return unless Houston._user_is_admin @userId\n collection.insert(doc)\n\n methods[Houston._houstonize \"#{name}_update\"] = (id, update_dict) ->\n return unless Houston._user_is_admin @userId\n if collection.findOne(id)\n collection.update(id, update_dict)\n else\n id = collection.findOne(new Meteor.Collection.ObjectID(id))\n collection.update(id, update_dict)\n\n methods[Houston._houstonize \"#{name}_delete\"] = (id, update_dict) ->\n return unless Houston._user_is_admin @userId\n if collection.findOne(id)\n collection.remove(id)\n else\n id = collection.findOne(new Meteor.Collection.ObjectID(id))\n collection.remove(id)\n\n Meteor.methods methods", "response": "Houston._publish name, (sort, filter, limit) ->\n return unless Houston._user_is_admin @userId\n try\n collection.find(filter, sort: sort, limit: limit)\n catch e\n console.log e\n\n collection.find().observe\n added: (document) ->\n Houston._collections.collections.update {name},\n $inc: {count: 1},\n $addToSet: fields: $each: Houston._get_field_names([document])\n removed: (document) -> Houston._collections.collections.update {name}, {$inc: {count: -1}}\n\n fields = Houston._get_field_names(collection.find().fetch())\n c = Houston._collections.collections.findOne {name}\n if c\n Houston._collections.collections.update c._id, {$set: count: collection.find().count(), fields: fields}\n else\n Houston._collections.collections.insert {name, count: collection.find().count(), fields: fields}\n\ncollections = {'users': Meteor.users} #TODO verify this is still relevant", "source_lang": "CoffeeScript", "target_lang": "CoffeeScript", "repo": "gterrono/houston", "path": "server/publications.coffee", "license": "MIT", "commit": "227fa0e254151bcdf3c2a163f7f0ff4a9d3a31c4", "stars": 802, "source_url": "https://github.com/gterrono/houston/blob/227fa0e254151bcdf3c2a163f7f0ff4a9d3a31c4/server/publications.coffee", "line_start": 8, "line_end": 53}821{"id": "gterrono/houston:server/publications.coffee:3:raw_corpus", "type": "raw_corpus", "prompt": "", "response": "sync_collections = ->\n Dummy.findOne() # hack. TODO: verify this is still necessary\n\n _sync_collections = (meh, collections_db) ->\n collection_names = (col.collectionName for col in collections_db \\\n when (col.collectionName.indexOf \"system.\") isnt 0 and\n (col.collectionName.indexOf \"houston_\") isnt 0)\n\n collection_names.forEach (name) ->\n unless name of collections\n try\n collections[name] = new Meteor.Collection(name)\n catch e\n console.log e\n for key, value of root\n if name == value._name\n collections[name] = value\n console.log e unless collections[name]?\n setup_collection(name, collections[name])\n\n bound_sync_collections = Meteor.bindEnvironment _sync_collections, (e) ->\n console.log \"Failed while syncing collections for reason: #{e}\"\n\n # MongoInternals is the 'right' solution as of 0.6.5\n mongo_driver = MongoInternals?.defaultRemoteCollectionDriver() or Meteor._RemoteCollectionDriver\n mongo_driver.mongo.db.collections bound_sync_collections\n\nMeteor.methods\n _houston_make_admin: (user_id) ->\n # limit one admin\n return if Houston._admins.findOne {'user_id': $exists: true}\n Houston._admins.insert {user_id}\n sync_collections() # reloads collections in case of new app\n return true\n\n# publish our analysis of the app's collections\nHouston._publish 'collections', ->\n return unless Houston._user_is_admin @userId\n Houston._collections.collections.find()\n\n# TODO address inherent security issue\nHouston._publish 'admin_user', ->\n Houston._admins.find {}\n\nMeteor.startup ->\n sync_collections()", "source_lang": "", "target_lang": "CoffeeScript", "repo": "gterrono/houston", "path": "server/publications.coffee", "license": "MIT", "commit": "227fa0e254151bcdf3c2a163f7f0ff4a9d3a31c4", "stars": 802, "source_url": "https://github.com/gterrono/houston/blob/227fa0e254151bcdf3c2a163f7f0ff4a9d3a31c4/server/publications.coffee", "line_start": 54, "line_end": 99}822{"id": "gterrono/houston:server/publications.coffee:3:coffee_to_js", "type": "coffee_to_js", "prompt": "Convert this CoffeeScript to JavaScript.\n```coffeescript\nsync_collections = ->\n Dummy.findOne() # hack. TODO: verify this is still necessary\n\n _sync_collections = (meh, collections_db) ->\n collection_names = (col.collectionName for col in collections_db \\\n when (col.collectionName.indexOf \"system.\") isnt 0 and\n (col.collectionName.indexOf \"houston_\") isnt 0)\n\n collection_names.forEach (name) ->\n unless name of collections\n try\n collections[name] = new Meteor.Collection(name)\n catch e\n console.log e\n for key, value of root\n if name == value._name\n collections[name] = value\n console.log e unless collections[name]?\n setup_collection(name, collections[name])\n\n bound_sync_collections = Meteor.bindEnvironment _sync_collections, (e) ->\n console.log \"Failed while syncing collections for reason: #{e}\"\n\n # MongoInternals is the 'right' solution as of 0.6.5\n mongo_driver = MongoInternals?.defaultRemoteCollectionDriver() or Meteor._RemoteCollectionDriver\n mongo_driver.mongo.db.collections bound_sync_collections\n\nMeteor.methods\n _houston_make_admin: (user_id) ->\n # limit one admin\n return if Houston._admins.findOne {'user_id': $exists: true}\n Houston._admins.insert {user_id}\n sync_collections() # reloads collections in case of new app\n return true\n\n# publish our analysis of the app's collections\nHouston._publish 'collections', ->\n return unless Houston._user_is_admin @userId\n Houston._collections.collections.find()\n\n# TODO address inherent security issue\nHouston._publish 'admin_user', ->\n Houston._admins.find {}\n\nMeteor.startup ->\n sync_collections()\n```", "response": "var sync_collections;\n\nsync_collections = function() {\n var _sync_collections, bound_sync_collections, mongo_driver;\n Dummy.findOne(); // hack. TODO: verify this is still necessary\n _sync_collections = function(meh, collections_db) {\n var col, collection_names;\n collection_names = (function() {\n var i, len, results;\n results = [];\n for (i = 0, len = collections_db.length; i < len; i++) {\n col = collections_db[i];\n if ((col.collectionName.indexOf(\"system.\")) !== 0 && (col.collectionName.indexOf(\"houston_\")) !== 0) {\n results.push(col.collectionName);\n }\n }\n return results;\n })();\n return collection_names.forEach(function(name) {\n var e, key, value;\n if (!(name in collections)) {\n try {\n collections[name] = new Meteor.Collection(name);\n } catch (error) {\n e = error;\n console.log(e);\n for (key in root) {\n value = root[key];\n if (name === value._name) {\n collections[name] = value;\n }\n }\n if (collections[name] == null) {\n console.log(e);\n }\n }\n return setup_collection(name, collections[name]);\n }\n });\n };\n bound_sync_collections = Meteor.bindEnvironment(_sync_collections, function(e) {\n return console.log(`Failed while syncing collections for reason: ${e}`);\n });\n // MongoInternals is the 'right' solution as of 0.6.5\n mongo_driver = (typeof MongoInternals !== \"undefined\" && MongoInternals !== null ? MongoInternals.defaultRemoteCollectionDriver() : void 0) || Meteor._RemoteCollectionDriver;\n return mongo_driver.mongo.db.collections(bound_sync_collections);\n};\n\nMeteor.methods({\n _houston_make_admin: function(user_id) {\n // limit one admin\n if (Houston._admins.findOne({\n 'user_id': {\n $exists: true\n }\n })) {\n return;\n }\n Houston._admins.insert({user_id});\n sync_collections(); // reloads collections in case of new app\n return true;\n }\n});\n\n// publish our analysis of the app's collections\nHouston._publish('collections', function() {\n if (!Houston._user_is_admin(this.userId)) {\n return;\n }\n return Houston._collections.collections.find();\n});\n\n// TODO address inherent security issue\nHouston._publish('admin_user', function() {\n return Houston._admins.find({});\n});\n\nMeteor.startup(function() {\n return sync_collections();\n});", "source_lang": "CoffeeScript", "target_lang": "JavaScript", "repo": "gterrono/houston", "path": "server/publications.coffee", "license": "MIT", "commit": "227fa0e254151bcdf3c2a163f7f0ff4a9d3a31c4", "stars": 802, "source_url": "https://github.com/gterrono/houston/blob/227fa0e254151bcdf3c2a163f7f0ff4a9d3a31c4/server/publications.coffee", "line_start": 54, "line_end": 99}823{"id": "gterrono/houston:server/publications.coffee:3:js_to_coffee", "type": "js_to_coffee", "prompt": "Convert this JavaScript to CoffeeScript.\n```javascript\nvar sync_collections;\n\nsync_collections = function() {\n var _sync_collections, bound_sync_collections, mongo_driver;\n Dummy.findOne(); // hack. TODO: verify this is still necessary\n _sync_collections = function(meh, collections_db) {\n var col, collection_names;\n collection_names = (function() {\n var i, len, results;\n results = [];\n for (i = 0, len = collections_db.length; i < len; i++) {\n col = collections_db[i];\n if ((col.collectionName.indexOf(\"system.\")) !== 0 && (col.collectionName.indexOf(\"houston_\")) !== 0) {\n results.push(col.collectionName);\n }\n }\n return results;\n })();\n return collection_names.forEach(function(name) {\n var e, key, value;\n if (!(name in collections)) {\n try {\n collections[name] = new Meteor.Collection(name);\n } catch (error) {\n e = error;\n console.log(e);\n for (key in root) {\n value = root[key];\n if (name === value._name) {\n collections[name] = value;\n }\n }\n if (collections[name] == null) {\n console.log(e);\n }\n }\n return setup_collection(name, collections[name]);\n }\n });\n };\n bound_sync_collections = Meteor.bindEnvironment(_sync_collections, function(e) {\n return console.log(`Failed while syncing collections for reason: ${e}`);\n });\n // MongoInternals is the 'right' solution as of 0.6.5\n mongo_driver = (typeof MongoInternals !== \"undefined\" && MongoInternals !== null ? MongoInternals.defaultRemoteCollectionDriver() : void 0) || Meteor._RemoteCollectionDriver;\n return mongo_driver.mongo.db.collections(bound_sync_collections);\n};\n\nMeteor.methods({\n _houston_make_admin: function(user_id) {\n // limit one admin\n if (Houston._admins.findOne({\n 'user_id': {\n $exists: true\n }\n })) {\n return;\n }\n Houston._admins.insert({user_id});\n sync_collections(); // reloads collections in case of new app\n return true;\n }\n});\n\n// publish our analysis of the app's collections\nHouston._publish('collections', function() {\n if (!Houston._user_is_admin(this.userId)) {\n return;\n }\n return Houston._collections.collections.find();\n});\n\n// TODO address inherent security issue\nHouston._publish('admin_user', function() {\n return Houston._admins.find({});\n});\n\nMeteor.startup(function() {\n return sync_collections();\n});\n```", "response": "sync_collections = ->\n Dummy.findOne() # hack. TODO: verify this is still necessary\n\n _sync_collections = (meh, collections_db) ->\n collection_names = (col.collectionName for col in collections_db \\\n when (col.collectionName.indexOf \"system.\") isnt 0 and\n (col.collectionName.indexOf \"houston_\") isnt 0)\n\n collection_names.forEach (name) ->\n unless name of collections\n try\n collections[name] = new Meteor.Collection(name)\n catch e\n console.log e\n for key, value of root\n if name == value._name\n collections[name] = value\n console.log e unless collections[name]?\n setup_collection(name, collections[name])\n\n bound_sync_collections = Meteor.bindEnvironment _sync_collections, (e) ->\n console.log \"Failed while syncing collections for reason: #{e}\"\n\n # MongoInternals is the 'right' solution as of 0.6.5\n mongo_driver = MongoInternals?.defaultRemoteCollectionDriver() or Meteor._RemoteCollectionDriver\n mongo_driver.mongo.db.collections bound_sync_collections\n\nMeteor.methods\n _houston_make_admin: (user_id) ->\n # limit one admin\n return if Houston._admins.findOne {'user_id': $exists: true}\n Houston._admins.insert {user_id}\n sync_collections() # reloads collections in case of new app\n return true\n\n# publish our analysis of the app's collections\nHouston._publish 'collections', ->\n return unless Houston._user_is_admin @userId\n Houston._collections.collections.find()\n\n# TODO address inherent security issue\nHouston._publish 'admin_user', ->\n Houston._admins.find {}\n\nMeteor.startup ->\n sync_collections()", "source_lang": "JavaScript", "target_lang": "CoffeeScript", "repo": "gterrono/houston", "path": "server/publications.coffee", "license": "MIT", "commit": "227fa0e254151bcdf3c2a163f7f0ff4a9d3a31c4", "stars": 802, "source_url": "https://github.com/gterrono/houston/blob/227fa0e254151bcdf3c2a163f7f0ff4a9d3a31c4/server/publications.coffee", "line_start": 54, "line_end": 99}824{"id": "gterrono/houston:server/publications.coffee:3:completion", "type": "completion", "prompt": "sync_collections = ->\n Dummy.findOne() # hack. TODO: verify this is still necessary\n\n _sync_collections = (meh, collections_db) ->\n collection_names = (col.collectionName for col in collections_db \\\n when (col.collectionName.indexOf \"system.\") isnt 0 and\n (col.collectionName.indexOf \"houston_\") isnt 0)\n\n collection_names.forEach (name) ->\n unless name of collections\n try\n collections[name] = new Meteor.Collection(name)\n catch e\n console.log e\n for key, value of root\n if name == value._name\n collections[name] = value\n console.log e unless collections[name]?\n setup_collection(name, collections[name])\n\n bound_sync_collections = Meteor.bindEnvironment _sync_collections, (e) ->\n console.log \"Failed while syncing collections for reason: #{e}\"", "response": "# MongoInternals is the 'right' solution as of 0.6.5\n mongo_driver = MongoInternals?.defaultRemoteCollectionDriver() or Meteor._RemoteCollectionDriver\n mongo_driver.mongo.db.collections bound_sync_collections\n\nMeteor.methods\n _houston_make_admin: (user_id) ->\n # limit one admin\n return if Houston._admins.findOne {'user_id': $exists: true}\n Houston._admins.insert {user_id}\n sync_collections() # reloads collections in case of new app\n return true\n\n# publish our analysis of the app's collections\nHouston._publish 'collections', ->\n return unless Houston._user_is_admin @userId\n Houston._collections.collections.find()\n\n# TODO address inherent security issue\nHouston._publish 'admin_user', ->\n Houston._admins.find {}\n\nMeteor.startup ->\n sync_collections()", "source_lang": "CoffeeScript", "target_lang": "CoffeeScript", "repo": "gterrono/houston", "path": "server/publications.coffee", "license": "MIT", "commit": "227fa0e254151bcdf3c2a163f7f0ff4a9d3a31c4", "stars": 802, "source_url": "https://github.com/gterrono/houston/blob/227fa0e254151bcdf3c2a163f7f0ff4a9d3a31c4/server/publications.coffee", "line_start": 54, "line_end": 99}825{"id": "gterrono/houston:server/publications.coffee:2:raw_corpus", "type": "raw_corpus", "prompt": "", "response": "setup_collection = (name, collection) ->\n methods = {}\n methods[Houston._houstonize \"#{name}_insert\"] = (doc) ->\n return unless Houston._user_is_admin @userId\n collection.insert(doc)\n\n methods[Houston._houstonize \"#{name}_update\"] = (id, update_dict) ->\n return unless Houston._user_is_admin @userId\n if collection.findOne(id)\n collection.update(id, update_dict)\n else\n id = collection.findOne(new Meteor.Collection.ObjectID(id))\n collection.update(id, update_dict)\n\n methods[Houston._houstonize \"#{name}_delete\"] = (id, update_dict) ->\n return unless Houston._user_is_admin @userId\n if collection.findOne(id)\n collection.remove(id)\n else\n id = collection.findOne(new Meteor.Collection.ObjectID(id))\n collection.remove(id)\n\n Meteor.methods methods\n\n Houston._publish name, (sort, filter, limit) ->\n return unless Houston._user_is_admin @userId\n try\n collection.find(filter, sort: sort, limit: limit)\n catch e\n console.log e\n\n collection.find().observe\n added: (document) ->\n Houston._collections.collections.update {name},\n $inc: {count: 1},\n $addToSet: fields: $each: Houston._get_field_names([document])\n removed: (document) -> Houston._collections.collections.update {name}, {$inc: {count: -1}}\n\n fields = Houston._get_field_names(collection.find().fetch())\n c = Houston._collections.collections.findOne {name}\n if c\n Houston._collections.collections.update c._id, {$set: count: collection.find().count(), fields: fields}\n else\n Houston._collections.collections.insert {name, count: collection.find().count(), fields: fields}\n\nhidden_collections = {'users': Meteor.users, 'meteor_accounts_loginServiceConfiguration': undefined}\ncollections = {}", "source_lang": "", "target_lang": "CoffeeScript", "repo": "gterrono/houston", "path": "server/publications.coffee", "license": "MIT", "commit": "35dd6c055fcbbede8c2e00bc5f73b42e90effa98", "stars": 802, "source_url": "https://github.com/gterrono/houston/blob/35dd6c055fcbbede8c2e00bc5f73b42e90effa98/server/publications.coffee", "line_start": 8, "line_end": 54}826{"id": "gterrono/houston:server/publications.coffee:2:coffee_to_js", "type": "coffee_to_js", "prompt": "Convert this CoffeeScript to JavaScript.\n```coffeescript\nsetup_collection = (name, collection) ->\n methods = {}\n methods[Houston._houstonize \"#{name}_insert\"] = (doc) ->\n return unless Houston._user_is_admin @userId\n collection.insert(doc)\n\n methods[Houston._houstonize \"#{name}_update\"] = (id, update_dict) ->\n return unless Houston._user_is_admin @userId\n if collection.findOne(id)\n collection.update(id, update_dict)\n else\n id = collection.findOne(new Meteor.Collection.ObjectID(id))\n collection.update(id, update_dict)\n\n methods[Houston._houstonize \"#{name}_delete\"] = (id, update_dict) ->\n return unless Houston._user_is_admin @userId\n if collection.findOne(id)\n collection.remove(id)\n else\n id = collection.findOne(new Meteor.Collection.ObjectID(id))\n collection.remove(id)\n\n Meteor.methods methods\n\n Houston._publish name, (sort, filter, limit) ->\n return unless Houston._user_is_admin @userId\n try\n collection.find(filter, sort: sort, limit: limit)\n catch e\n console.log e\n\n collection.find().observe\n added: (document) ->\n Houston._collections.collections.update {name},\n $inc: {count: 1},\n $addToSet: fields: $each: Houston._get_field_names([document])\n removed: (document) -> Houston._collections.collections.update {name}, {$inc: {count: -1}}\n\n fields = Houston._get_field_names(collection.find().fetch())\n c = Houston._collections.collections.findOne {name}\n if c\n Houston._collections.collections.update c._id, {$set: count: collection.find().count(), fields: fields}\n else\n Houston._collections.collections.insert {name, count: collection.find().count(), fields: fields}\n\nhidden_collections = {'users': Meteor.users, 'meteor_accounts_loginServiceConfiguration': undefined}\ncollections = {}\n```", "response": "var collections, hidden_collections, setup_collection;\n\nsetup_collection = function(name, collection) {\n var c, fields, methods;\n methods = {};\n methods[Houston._houstonize(`${name}_insert`)] = function(doc) {\n if (!Houston._user_is_admin(this.userId)) {\n return;\n }\n return collection.insert(doc);\n };\n methods[Houston._houstonize(`${name}_update`)] = function(id, update_dict) {\n if (!Houston._user_is_admin(this.userId)) {\n return;\n }\n if (collection.findOne(id)) {\n return collection.update(id, update_dict);\n } else {\n id = collection.findOne(new Meteor.Collection.ObjectID(id));\n return collection.update(id, update_dict);\n }\n };\n methods[Houston._houstonize(`${name}_delete`)] = function(id, update_dict) {\n if (!Houston._user_is_admin(this.userId)) {\n return;\n }\n if (collection.findOne(id)) {\n return collection.remove(id);\n } else {\n id = collection.findOne(new Meteor.Collection.ObjectID(id));\n return collection.remove(id);\n }\n };\n Meteor.methods(methods);\n Houston._publish(name, function(sort, filter, limit) {\n var e;\n if (!Houston._user_is_admin(this.userId)) {\n return;\n }\n try {\n return collection.find(filter, {\n sort: sort,\n limit: limit\n });\n } catch (error) {\n e = error;\n return console.log(e);\n }\n });\n collection.find().observe({\n added: function(document) {\n return Houston._collections.collections.update({name}, {\n $inc: {\n count: 1\n },\n $addToSet: {\n fields: {\n $each: Houston._get_field_names([document])\n }\n }\n });\n },\n removed: function(document) {\n return Houston._collections.collections.update({name}, {\n $inc: {\n count: -1\n }\n });\n }\n });\n fields = Houston._get_field_names(collection.find().fetch());\n c = Houston._collections.collections.findOne({name});\n if (c) {\n return Houston._collections.collections.update(c._id, {\n $set: {\n count: collection.find().count(),\n fields: fields\n }\n });\n } else {\n return Houston._collections.collections.insert({\n name,\n count: collection.find().count(),\n fields: fields\n });\n }\n};\n\nhidden_collections = {\n 'users': Meteor.users,\n 'meteor_accounts_loginServiceConfiguration': void 0\n};\n\ncollections = {};", "source_lang": "CoffeeScript", "target_lang": "JavaScript", "repo": "gterrono/houston", "path": "server/publications.coffee", "license": "MIT", "commit": "35dd6c055fcbbede8c2e00bc5f73b42e90effa98", "stars": 802, "source_url": "https://github.com/gterrono/houston/blob/35dd6c055fcbbede8c2e00bc5f73b42e90effa98/server/publications.coffee", "line_start": 8, "line_end": 54}827{"id": "gterrono/houston:server/publications.coffee:2:js_to_coffee", "type": "js_to_coffee", "prompt": "Convert this JavaScript to CoffeeScript.\n```javascript\nvar collections, hidden_collections, setup_collection;\n\nsetup_collection = function(name, collection) {\n var c, fields, methods;\n methods = {};\n methods[Houston._houstonize(`${name}_insert`)] = function(doc) {\n if (!Houston._user_is_admin(this.userId)) {\n return;\n }\n return collection.insert(doc);\n };\n methods[Houston._houstonize(`${name}_update`)] = function(id, update_dict) {\n if (!Houston._user_is_admin(this.userId)) {\n return;\n }\n if (collection.findOne(id)) {\n return collection.update(id, update_dict);\n } else {\n id = collection.findOne(new Meteor.Collection.ObjectID(id));\n return collection.update(id, update_dict);\n }\n };\n methods[Houston._houstonize(`${name}_delete`)] = function(id, update_dict) {\n if (!Houston._user_is_admin(this.userId)) {\n return;\n }\n if (collection.findOne(id)) {\n return collection.remove(id);\n } else {\n id = collection.findOne(new Meteor.Collection.ObjectID(id));\n return collection.remove(id);\n }\n };\n Meteor.methods(methods);\n Houston._publish(name, function(sort, filter, limit) {\n var e;\n if (!Houston._user_is_admin(this.userId)) {\n return;\n }\n try {\n return collection.find(filter, {\n sort: sort,\n limit: limit\n });\n } catch (error) {\n e = error;\n return console.log(e);\n }\n });\n collection.find().observe({\n added: function(document) {\n return Houston._collections.collections.update({name}, {\n $inc: {\n count: 1\n },\n $addToSet: {\n fields: {\n $each: Houston._get_field_names([document])\n }\n }\n });\n },\n removed: function(document) {\n return Houston._collections.collections.update({name}, {\n $inc: {\n count: -1\n }\n });\n }\n });\n fields = Houston._get_field_names(collection.find().fetch());\n c = Houston._collections.collections.findOne({name});\n if (c) {\n return Houston._collections.collections.update(c._id, {\n $set: {\n count: collection.find().count(),\n fields: fields\n }\n });\n } else {\n return Houston._collections.collections.insert({\n name,\n count: collection.find().count(),\n fields: fields\n });\n }\n};\n\nhidden_collections = {\n 'users': Meteor.users,\n 'meteor_accounts_loginServiceConfiguration': void 0\n};\n\ncollections = {};\n```", "response": "setup_collection = (name, collection) ->\n methods = {}\n methods[Houston._houstonize \"#{name}_insert\"] = (doc) ->\n return unless Houston._user_is_admin @userId\n collection.insert(doc)\n\n methods[Houston._houstonize \"#{name}_update\"] = (id, update_dict) ->\n return unless Houston._user_is_admin @userId\n if collection.findOne(id)\n collection.update(id, update_dict)\n else\n id = collection.findOne(new Meteor.Collection.ObjectID(id))\n collection.update(id, update_dict)\n\n methods[Houston._houstonize \"#{name}_delete\"] = (id, update_dict) ->\n return unless Houston._user_is_admin @userId\n if collection.findOne(id)\n collection.remove(id)\n else\n id = collection.findOne(new Meteor.Collection.ObjectID(id))\n collection.remove(id)\n\n Meteor.methods methods\n\n Houston._publish name, (sort, filter, limit) ->\n return unless Houston._user_is_admin @userId\n try\n collection.find(filter, sort: sort, limit: limit)\n catch e\n console.log e\n\n collection.find().observe\n added: (document) ->\n Houston._collections.collections.update {name},\n $inc: {count: 1},\n $addToSet: fields: $each: Houston._get_field_names([document])\n removed: (document) -> Houston._collections.collections.update {name}, {$inc: {count: -1}}\n\n fields = Houston._get_field_names(collection.find().fetch())\n c = Houston._collections.collections.findOne {name}\n if c\n Houston._collections.collections.update c._id, {$set: count: collection.find().count(), fields: fields}\n else\n Houston._collections.collections.insert {name, count: collection.find().count(), fields: fields}\n\nhidden_collections = {'users': Meteor.users, 'meteor_accounts_loginServiceConfiguration': undefined}\ncollections = {}", "source_lang": "JavaScript", "target_lang": "CoffeeScript", "repo": "gterrono/houston", "path": "server/publications.coffee", "license": "MIT", "commit": "35dd6c055fcbbede8c2e00bc5f73b42e90effa98", "stars": 802, "source_url": "https://github.com/gterrono/houston/blob/35dd6c055fcbbede8c2e00bc5f73b42e90effa98/server/publications.coffee", "line_start": 8, "line_end": 54}828{"id": "gterrono/houston:server/publications.coffee:2:completion", "type": "completion", "prompt": "setup_collection = (name, collection) ->\n methods = {}\n methods[Houston._houstonize \"#{name}_insert\"] = (doc) ->\n return unless Houston._user_is_admin @userId\n collection.insert(doc)\n\n methods[Houston._houstonize \"#{name}_update\"] = (id, update_dict) ->\n return unless Houston._user_is_admin @userId\n if collection.findOne(id)\n collection.update(id, update_dict)\n else\n id = collection.findOne(new Meteor.Collection.ObjectID(id))\n collection.update(id, update_dict)\n\n methods[Houston._houstonize \"#{name}_delete\"] = (id, update_dict) ->\n return unless Houston._user_is_admin @userId\n if collection.findOne(id)\n collection.remove(id)\n else\n id = collection.findOne(new Meteor.Collection.ObjectID(id))\n collection.remove(id)\n\n Meteor.methods methods", "response": "Houston._publish name, (sort, filter, limit) ->\n return unless Houston._user_is_admin @userId\n try\n collection.find(filter, sort: sort, limit: limit)\n catch e\n console.log e\n\n collection.find().observe\n added: (document) ->\n Houston._collections.collections.update {name},\n $inc: {count: 1},\n $addToSet: fields: $each: Houston._get_field_names([document])\n removed: (document) -> Houston._collections.collections.update {name}, {$inc: {count: -1}}\n\n fields = Houston._get_field_names(collection.find().fetch())\n c = Houston._collections.collections.findOne {name}\n if c\n Houston._collections.collections.update c._id, {$set: count: collection.find().count(), fields: fields}\n else\n Houston._collections.collections.insert {name, count: collection.find().count(), fields: fields}\n\nhidden_collections = {'users': Meteor.users, 'meteor_accounts_loginServiceConfiguration': undefined}\ncollections = {}", "source_lang": "CoffeeScript", "target_lang": "CoffeeScript", "repo": "gterrono/houston", "path": "server/publications.coffee", "license": "MIT", "commit": "35dd6c055fcbbede8c2e00bc5f73b42e90effa98", "stars": 802, "source_url": "https://github.com/gterrono/houston/blob/35dd6c055fcbbede8c2e00bc5f73b42e90effa98/server/publications.coffee", "line_start": 8, "line_end": 54}829{"id": "gterrono/houston:server/publications.coffee:3:raw_corpus", "type": "raw_corpus", "prompt": "", "response": "sync_collections = ->\n Dummy.findOne() # hack. TODO: verify this is still necessary\n\n _sync_collections = (meh, collections_db) ->\n collection_names = (col.collectionName for col in collections_db \\\n when (col.collectionName.indexOf \"system.\") isnt 0 and\n (col.collectionName.indexOf \"houston_\") isnt 0)\n\n collection_names.forEach (name) ->\n unless name of collections or name of hidden_collections\n try\n collections[name] = new Meteor.Collection(name)\n catch e\n for key, value of root\n if name == value._name\n collections[name] = value\n console.log e unless collections[name]?\n setup_collection(name, collections[name]) if collections[name]?\n\n bound_sync_collections = Meteor.bindEnvironment _sync_collections, (e) ->\n console.log \"Failed while syncing collections for reason: #{e}\"\n\n # MongoInternals is the 'right' solution as of 0.6.5\n mongo_driver = MongoInternals?.defaultRemoteCollectionDriver() or Meteor._RemoteCollectionDriver\n mongo_driver.mongo.db.collections bound_sync_collections\n\nMeteor.methods\n _houston_make_admin: (user_id) ->\n # limit one admin\n return if Houston._admins.findOne {'user_id': $exists: true}\n Houston._admins.insert {user_id}\n sync_collections() # reloads collections in case of new app\n return true\n\n# publish our analysis of the app's collections\nHouston._publish 'collections', ->\n return unless Houston._user_is_admin @userId\n Houston._collections.collections.find()\n\n# TODO address inherent security issue\nHouston._publish 'admin_user', ->\n Houston._admins.find {}\n\nMeteor.startup ->\n sync_collections()", "source_lang": "", "target_lang": "CoffeeScript", "repo": "gterrono/houston", "path": "server/publications.coffee", "license": "MIT", "commit": "35dd6c055fcbbede8c2e00bc5f73b42e90effa98", "stars": 802, "source_url": "https://github.com/gterrono/houston/blob/35dd6c055fcbbede8c2e00bc5f73b42e90effa98/server/publications.coffee", "line_start": 55, "line_end": 99}830{"id": "gterrono/houston:server/publications.coffee:3:coffee_to_js", "type": "coffee_to_js", "prompt": "Convert this CoffeeScript to JavaScript.\n```coffeescript\nsync_collections = ->\n Dummy.findOne() # hack. TODO: verify this is still necessary\n\n _sync_collections = (meh, collections_db) ->\n collection_names = (col.collectionName for col in collections_db \\\n when (col.collectionName.indexOf \"system.\") isnt 0 and\n (col.collectionName.indexOf \"houston_\") isnt 0)\n\n collection_names.forEach (name) ->\n unless name of collections or name of hidden_collections\n try\n collections[name] = new Meteor.Collection(name)\n catch e\n for key, value of root\n if name == value._name\n collections[name] = value\n console.log e unless collections[name]?\n setup_collection(name, collections[name]) if collections[name]?\n\n bound_sync_collections = Meteor.bindEnvironment _sync_collections, (e) ->\n console.log \"Failed while syncing collections for reason: #{e}\"\n\n # MongoInternals is the 'right' solution as of 0.6.5\n mongo_driver = MongoInternals?.defaultRemoteCollectionDriver() or Meteor._RemoteCollectionDriver\n mongo_driver.mongo.db.collections bound_sync_collections\n\nMeteor.methods\n _houston_make_admin: (user_id) ->\n # limit one admin\n return if Houston._admins.findOne {'user_id': $exists: true}\n Houston._admins.insert {user_id}\n sync_collections() # reloads collections in case of new app\n return true\n\n# publish our analysis of the app's collections\nHouston._publish 'collections', ->\n return unless Houston._user_is_admin @userId\n Houston._collections.collections.find()\n\n# TODO address inherent security issue\nHouston._publish 'admin_user', ->\n Houston._admins.find {}\n\nMeteor.startup ->\n sync_collections()\n```", "response": "var sync_collections;\n\nsync_collections = function() {\n var _sync_collections, bound_sync_collections, mongo_driver;\n Dummy.findOne(); // hack. TODO: verify this is still necessary\n _sync_collections = function(meh, collections_db) {\n var col, collection_names;\n collection_names = (function() {\n var i, len, results;\n results = [];\n for (i = 0, len = collections_db.length; i < len; i++) {\n col = collections_db[i];\n if ((col.collectionName.indexOf(\"system.\")) !== 0 && (col.collectionName.indexOf(\"houston_\")) !== 0) {\n results.push(col.collectionName);\n }\n }\n return results;\n })();\n return collection_names.forEach(function(name) {\n var e, key, value;\n if (!(name in collections || name in hidden_collections)) {\n try {\n collections[name] = new Meteor.Collection(name);\n } catch (error) {\n e = error;\n for (key in root) {\n value = root[key];\n if (name === value._name) {\n collections[name] = value;\n }\n }\n if (collections[name] == null) {\n console.log(e);\n }\n }\n if (collections[name] != null) {\n return setup_collection(name, collections[name]);\n }\n }\n });\n };\n bound_sync_collections = Meteor.bindEnvironment(_sync_collections, function(e) {\n return console.log(`Failed while syncing collections for reason: ${e}`);\n });\n // MongoInternals is the 'right' solution as of 0.6.5\n mongo_driver = (typeof MongoInternals !== \"undefined\" && MongoInternals !== null ? MongoInternals.defaultRemoteCollectionDriver() : void 0) || Meteor._RemoteCollectionDriver;\n return mongo_driver.mongo.db.collections(bound_sync_collections);\n};\n\nMeteor.methods({\n _houston_make_admin: function(user_id) {\n // limit one admin\n if (Houston._admins.findOne({\n 'user_id': {\n $exists: true\n }\n })) {\n return;\n }\n Houston._admins.insert({user_id});\n sync_collections(); // reloads collections in case of new app\n return true;\n }\n});\n\n// publish our analysis of the app's collections\nHouston._publish('collections', function() {\n if (!Houston._user_is_admin(this.userId)) {\n return;\n }\n return Houston._collections.collections.find();\n});\n\n// TODO address inherent security issue\nHouston._publish('admin_user', function() {\n return Houston._admins.find({});\n});\n\nMeteor.startup(function() {\n return sync_collections();\n});", "source_lang": "CoffeeScript", "target_lang": "JavaScript", "repo": "gterrono/houston", "path": "server/publications.coffee", "license": "MIT", "commit": "35dd6c055fcbbede8c2e00bc5f73b42e90effa98", "stars": 802, "source_url": "https://github.com/gterrono/houston/blob/35dd6c055fcbbede8c2e00bc5f73b42e90effa98/server/publications.coffee", "line_start": 55, "line_end": 99}831{"id": "gterrono/houston:server/publications.coffee:3:js_to_coffee", "type": "js_to_coffee", "prompt": "Convert this JavaScript to CoffeeScript.\n```javascript\nvar sync_collections;\n\nsync_collections = function() {\n var _sync_collections, bound_sync_collections, mongo_driver;\n Dummy.findOne(); // hack. TODO: verify this is still necessary\n _sync_collections = function(meh, collections_db) {\n var col, collection_names;\n collection_names = (function() {\n var i, len, results;\n results = [];\n for (i = 0, len = collections_db.length; i < len; i++) {\n col = collections_db[i];\n if ((col.collectionName.indexOf(\"system.\")) !== 0 && (col.collectionName.indexOf(\"houston_\")) !== 0) {\n results.push(col.collectionName);\n }\n }\n return results;\n })();\n return collection_names.forEach(function(name) {\n var e, key, value;\n if (!(name in collections || name in hidden_collections)) {\n try {\n collections[name] = new Meteor.Collection(name);\n } catch (error) {\n e = error;\n for (key in root) {\n value = root[key];\n if (name === value._name) {\n collections[name] = value;\n }\n }\n if (collections[name] == null) {\n console.log(e);\n }\n }\n if (collections[name] != null) {\n return setup_collection(name, collections[name]);\n }\n }\n });\n };\n bound_sync_collections = Meteor.bindEnvironment(_sync_collections, function(e) {\n return console.log(`Failed while syncing collections for reason: ${e}`);\n });\n // MongoInternals is the 'right' solution as of 0.6.5\n mongo_driver = (typeof MongoInternals !== \"undefined\" && MongoInternals !== null ? MongoInternals.defaultRemoteCollectionDriver() : void 0) || Meteor._RemoteCollectionDriver;\n return mongo_driver.mongo.db.collections(bound_sync_collections);\n};\n\nMeteor.methods({\n _houston_make_admin: function(user_id) {\n // limit one admin\n if (Houston._admins.findOne({\n 'user_id': {\n $exists: true\n }\n })) {\n return;\n }\n Houston._admins.insert({user_id});\n sync_collections(); // reloads collections in case of new app\n return true;\n }\n});\n\n// publish our analysis of the app's collections\nHouston._publish('collections', function() {\n if (!Houston._user_is_admin(this.userId)) {\n return;\n }\n return Houston._collections.collections.find();\n});\n\n// TODO address inherent security issue\nHouston._publish('admin_user', function() {\n return Houston._admins.find({});\n});\n\nMeteor.startup(function() {\n return sync_collections();\n});\n```", "response": "sync_collections = ->\n Dummy.findOne() # hack. TODO: verify this is still necessary\n\n _sync_collections = (meh, collections_db) ->\n collection_names = (col.collectionName for col in collections_db \\\n when (col.collectionName.indexOf \"system.\") isnt 0 and\n (col.collectionName.indexOf \"houston_\") isnt 0)\n\n collection_names.forEach (name) ->\n unless name of collections or name of hidden_collections\n try\n collections[name] = new Meteor.Collection(name)\n catch e\n for key, value of root\n if name == value._name\n collections[name] = value\n console.log e unless collections[name]?\n setup_collection(name, collections[name]) if collections[name]?\n\n bound_sync_collections = Meteor.bindEnvironment _sync_collections, (e) ->\n console.log \"Failed while syncing collections for reason: #{e}\"\n\n # MongoInternals is the 'right' solution as of 0.6.5\n mongo_driver = MongoInternals?.defaultRemoteCollectionDriver() or Meteor._RemoteCollectionDriver\n mongo_driver.mongo.db.collections bound_sync_collections\n\nMeteor.methods\n _houston_make_admin: (user_id) ->\n # limit one admin\n return if Houston._admins.findOne {'user_id': $exists: true}\n Houston._admins.insert {user_id}\n sync_collections() # reloads collections in case of new app\n return true\n\n# publish our analysis of the app's collections\nHouston._publish 'collections', ->\n return unless Houston._user_is_admin @userId\n Houston._collections.collections.find()\n\n# TODO address inherent security issue\nHouston._publish 'admin_user', ->\n Houston._admins.find {}\n\nMeteor.startup ->\n sync_collections()", "source_lang": "JavaScript", "target_lang": "CoffeeScript", "repo": "gterrono/houston", "path": "server/publications.coffee", "license": "MIT", "commit": "35dd6c055fcbbede8c2e00bc5f73b42e90effa98", "stars": 802, "source_url": "https://github.com/gterrono/houston/blob/35dd6c055fcbbede8c2e00bc5f73b42e90effa98/server/publications.coffee", "line_start": 55, "line_end": 99}832{"id": "gterrono/houston:server/publications.coffee:3:completion", "type": "completion", "prompt": "sync_collections = ->\n Dummy.findOne() # hack. TODO: verify this is still necessary\n\n _sync_collections = (meh, collections_db) ->\n collection_names = (col.collectionName for col in collections_db \\\n when (col.collectionName.indexOf \"system.\") isnt 0 and\n (col.collectionName.indexOf \"houston_\") isnt 0)\n\n collection_names.forEach (name) ->\n unless name of collections or name of hidden_collections\n try\n collections[name] = new Meteor.Collection(name)\n catch e\n for key, value of root\n if name == value._name\n collections[name] = value\n console.log e unless collections[name]?\n setup_collection(name, collections[name]) if collections[name]?\n\n bound_sync_collections = Meteor.bindEnvironment _sync_collections, (e) ->\n console.log \"Failed while syncing collections for reason: #{e}\"", "response": "# MongoInternals is the 'right' solution as of 0.6.5\n mongo_driver = MongoInternals?.defaultRemoteCollectionDriver() or Meteor._RemoteCollectionDriver\n mongo_driver.mongo.db.collections bound_sync_collections\n\nMeteor.methods\n _houston_make_admin: (user_id) ->\n # limit one admin\n return if Houston._admins.findOne {'user_id': $exists: true}\n Houston._admins.insert {user_id}\n sync_collections() # reloads collections in case of new app\n return true\n\n# publish our analysis of the app's collections\nHouston._publish 'collections', ->\n return unless Houston._user_is_admin @userId\n Houston._collections.collections.find()\n\n# TODO address inherent security issue\nHouston._publish 'admin_user', ->\n Houston._admins.find {}\n\nMeteor.startup ->\n sync_collections()", "source_lang": "CoffeeScript", "target_lang": "CoffeeScript", "repo": "gterrono/houston", "path": "server/publications.coffee", "license": "MIT", "commit": "35dd6c055fcbbede8c2e00bc5f73b42e90effa98", "stars": 802, "source_url": "https://github.com/gterrono/houston/blob/35dd6c055fcbbede8c2e00bc5f73b42e90effa98/server/publications.coffee", "line_start": 55, "line_end": 99}833{"id": "gterrono/houston:server/publications.coffee:2:raw_corpus", "type": "raw_corpus", "prompt": "", "response": "setup_collection = (name, collection) ->\n methods = {}\n methods[Houston._houstonize \"#{name}_insert\"] = (doc) ->\n return unless Houston._user_is_admin @userId\n collection.insert(doc)\n\n methods[Houston._houstonize \"#{name}_update\"] = (id, update_dict) ->\n return unless Houston._user_is_admin @userId\n if collection.findOne(id)\n collection.update(id, update_dict)\n else\n id = collection.findOne(new Meteor.Collection.ObjectID(id))\n collection.update(id, update_dict)\n\n methods[Houston._houstonize \"#{name}_delete\"] = (id, update_dict) ->\n return unless Houston._user_is_admin @userId\n if collection.findOne(id)\n collection.remove(id)\n else\n id = collection.findOne(new Meteor.Collection.ObjectID(id))\n collection.remove(id)\n\n Meteor.methods methods\n\n Houston._publish name, (sort, filter, limit) ->\n return unless Houston._user_is_admin @userId\n try\n collection.find(filter, sort: sort, limit: limit)\n catch e\n console.log e\n\n collection.find().observe\n added: (document) ->\n Houston._collections.collections.update {name},\n $inc: {count: 1},\n $addToSet: fields: $each: Houston._get_field_names([document])\n removed: (document) -> Houston._collections.collections.update {name}, {$inc: {count: -1}}\n\n fields = Houston._get_field_names(collection.find().fetch())\n c = Houston._collections.collections.findOne {name}\n if c\n Houston._collections.collections.update c._id, {$set: count: collection.find().count(), fields: fields}\n else\n Houston._collections.collections.insert {name, count: collection.find().count(), fields: fields}\n\ncollections = {'users': Meteor.users, 'meteor_accounts_loginServiceConfiguration': undefined}", "source_lang": "", "target_lang": "CoffeeScript", "repo": "gterrono/houston", "path": "server/publications.coffee", "license": "MIT", "commit": "8b1d9f2bf910a38c1a6645f11c5dfd4512226d34", "stars": 802, "source_url": "https://github.com/gterrono/houston/blob/8b1d9f2bf910a38c1a6645f11c5dfd4512226d34/server/publications.coffee", "line_start": 8, "line_end": 53}834{"id": "gterrono/houston:server/publications.coffee:2:coffee_to_js", "type": "coffee_to_js", "prompt": "Convert this CoffeeScript to JavaScript.\n```coffeescript\nsetup_collection = (name, collection) ->\n methods = {}\n methods[Houston._houstonize \"#{name}_insert\"] = (doc) ->\n return unless Houston._user_is_admin @userId\n collection.insert(doc)\n\n methods[Houston._houstonize \"#{name}_update\"] = (id, update_dict) ->\n return unless Houston._user_is_admin @userId\n if collection.findOne(id)\n collection.update(id, update_dict)\n else\n id = collection.findOne(new Meteor.Collection.ObjectID(id))\n collection.update(id, update_dict)\n\n methods[Houston._houstonize \"#{name}_delete\"] = (id, update_dict) ->\n return unless Houston._user_is_admin @userId\n if collection.findOne(id)\n collection.remove(id)\n else\n id = collection.findOne(new Meteor.Collection.ObjectID(id))\n collection.remove(id)\n\n Meteor.methods methods\n\n Houston._publish name, (sort, filter, limit) ->\n return unless Houston._user_is_admin @userId\n try\n collection.find(filter, sort: sort, limit: limit)\n catch e\n console.log e\n\n collection.find().observe\n added: (document) ->\n Houston._collections.collections.update {name},\n $inc: {count: 1},\n $addToSet: fields: $each: Houston._get_field_names([document])\n removed: (document) -> Houston._collections.collections.update {name}, {$inc: {count: -1}}\n\n fields = Houston._get_field_names(collection.find().fetch())\n c = Houston._collections.collections.findOne {name}\n if c\n Houston._collections.collections.update c._id, {$set: count: collection.find().count(), fields: fields}\n else\n Houston._collections.collections.insert {name, count: collection.find().count(), fields: fields}\n\ncollections = {'users': Meteor.users, 'meteor_accounts_loginServiceConfiguration': undefined}\n```", "response": "var collections, setup_collection;\n\nsetup_collection = function(name, collection) {\n var c, fields, methods;\n methods = {};\n methods[Houston._houstonize(`${name}_insert`)] = function(doc) {\n if (!Houston._user_is_admin(this.userId)) {\n return;\n }\n return collection.insert(doc);\n };\n methods[Houston._houstonize(`${name}_update`)] = function(id, update_dict) {\n if (!Houston._user_is_admin(this.userId)) {\n return;\n }\n if (collection.findOne(id)) {\n return collection.update(id, update_dict);\n } else {\n id = collection.findOne(new Meteor.Collection.ObjectID(id));\n return collection.update(id, update_dict);\n }\n };\n methods[Houston._houstonize(`${name}_delete`)] = function(id, update_dict) {\n if (!Houston._user_is_admin(this.userId)) {\n return;\n }\n if (collection.findOne(id)) {\n return collection.remove(id);\n } else {\n id = collection.findOne(new Meteor.Collection.ObjectID(id));\n return collection.remove(id);\n }\n };\n Meteor.methods(methods);\n Houston._publish(name, function(sort, filter, limit) {\n var e;\n if (!Houston._user_is_admin(this.userId)) {\n return;\n }\n try {\n return collection.find(filter, {\n sort: sort,\n limit: limit\n });\n } catch (error) {\n e = error;\n return console.log(e);\n }\n });\n collection.find().observe({\n added: function(document) {\n return Houston._collections.collections.update({name}, {\n $inc: {\n count: 1\n },\n $addToSet: {\n fields: {\n $each: Houston._get_field_names([document])\n }\n }\n });\n },\n removed: function(document) {\n return Houston._collections.collections.update({name}, {\n $inc: {\n count: -1\n }\n });\n }\n });\n fields = Houston._get_field_names(collection.find().fetch());\n c = Houston._collections.collections.findOne({name});\n if (c) {\n return Houston._collections.collections.update(c._id, {\n $set: {\n count: collection.find().count(),\n fields: fields\n }\n });\n } else {\n return Houston._collections.collections.insert({\n name,\n count: collection.find().count(),\n fields: fields\n });\n }\n};\n\ncollections = {\n 'users': Meteor.users,\n 'meteor_accounts_loginServiceConfiguration': void 0\n};", "source_lang": "CoffeeScript", "target_lang": "JavaScript", "repo": "gterrono/houston", "path": "server/publications.coffee", "license": "MIT", "commit": "8b1d9f2bf910a38c1a6645f11c5dfd4512226d34", "stars": 802, "source_url": "https://github.com/gterrono/houston/blob/8b1d9f2bf910a38c1a6645f11c5dfd4512226d34/server/publications.coffee", "line_start": 8, "line_end": 53}835{"id": "gterrono/houston:server/publications.coffee:2:js_to_coffee", "type": "js_to_coffee", "prompt": "Convert this JavaScript to CoffeeScript.\n```javascript\nvar collections, setup_collection;\n\nsetup_collection = function(name, collection) {\n var c, fields, methods;\n methods = {};\n methods[Houston._houstonize(`${name}_insert`)] = function(doc) {\n if (!Houston._user_is_admin(this.userId)) {\n return;\n }\n return collection.insert(doc);\n };\n methods[Houston._houstonize(`${name}_update`)] = function(id, update_dict) {\n if (!Houston._user_is_admin(this.userId)) {\n return;\n }\n if (collection.findOne(id)) {\n return collection.update(id, update_dict);\n } else {\n id = collection.findOne(new Meteor.Collection.ObjectID(id));\n return collection.update(id, update_dict);\n }\n };\n methods[Houston._houstonize(`${name}_delete`)] = function(id, update_dict) {\n if (!Houston._user_is_admin(this.userId)) {\n return;\n }\n if (collection.findOne(id)) {\n return collection.remove(id);\n } else {\n id = collection.findOne(new Meteor.Collection.ObjectID(id));\n return collection.remove(id);\n }\n };\n Meteor.methods(methods);\n Houston._publish(name, function(sort, filter, limit) {\n var e;\n if (!Houston._user_is_admin(this.userId)) {\n return;\n }\n try {\n return collection.find(filter, {\n sort: sort,\n limit: limit\n });\n } catch (error) {\n e = error;\n return console.log(e);\n }\n });\n collection.find().observe({\n added: function(document) {\n return Houston._collections.collections.update({name}, {\n $inc: {\n count: 1\n },\n $addToSet: {\n fields: {\n $each: Houston._get_field_names([document])\n }\n }\n });\n },\n removed: function(document) {\n return Houston._collections.collections.update({name}, {\n $inc: {\n count: -1\n }\n });\n }\n });\n fields = Houston._get_field_names(collection.find().fetch());\n c = Houston._collections.collections.findOne({name});\n if (c) {\n return Houston._collections.collections.update(c._id, {\n $set: {\n count: collection.find().count(),\n fields: fields\n }\n });\n } else {\n return Houston._collections.collections.insert({\n name,\n count: collection.find().count(),\n fields: fields\n });\n }\n};\n\ncollections = {\n 'users': Meteor.users,\n 'meteor_accounts_loginServiceConfiguration': void 0\n};\n```", "response": "setup_collection = (name, collection) ->\n methods = {}\n methods[Houston._houstonize \"#{name}_insert\"] = (doc) ->\n return unless Houston._user_is_admin @userId\n collection.insert(doc)\n\n methods[Houston._houstonize \"#{name}_update\"] = (id, update_dict) ->\n return unless Houston._user_is_admin @userId\n if collection.findOne(id)\n collection.update(id, update_dict)\n else\n id = collection.findOne(new Meteor.Collection.ObjectID(id))\n collection.update(id, update_dict)\n\n methods[Houston._houstonize \"#{name}_delete\"] = (id, update_dict) ->\n return unless Houston._user_is_admin @userId\n if collection.findOne(id)\n collection.remove(id)\n else\n id = collection.findOne(new Meteor.Collection.ObjectID(id))\n collection.remove(id)\n\n Meteor.methods methods\n\n Houston._publish name, (sort, filter, limit) ->\n return unless Houston._user_is_admin @userId\n try\n collection.find(filter, sort: sort, limit: limit)\n catch e\n console.log e\n\n collection.find().observe\n added: (document) ->\n Houston._collections.collections.update {name},\n $inc: {count: 1},\n $addToSet: fields: $each: Houston._get_field_names([document])\n removed: (document) -> Houston._collections.collections.update {name}, {$inc: {count: -1}}\n\n fields = Houston._get_field_names(collection.find().fetch())\n c = Houston._collections.collections.findOne {name}\n if c\n Houston._collections.collections.update c._id, {$set: count: collection.find().count(), fields: fields}\n else\n Houston._collections.collections.insert {name, count: collection.find().count(), fields: fields}\n\ncollections = {'users': Meteor.users, 'meteor_accounts_loginServiceConfiguration': undefined}", "source_lang": "JavaScript", "target_lang": "CoffeeScript", "repo": "gterrono/houston", "path": "server/publications.coffee", "license": "MIT", "commit": "8b1d9f2bf910a38c1a6645f11c5dfd4512226d34", "stars": 802, "source_url": "https://github.com/gterrono/houston/blob/8b1d9f2bf910a38c1a6645f11c5dfd4512226d34/server/publications.coffee", "line_start": 8, "line_end": 53}836{"id": "gterrono/houston:server/publications.coffee:2:completion", "type": "completion", "prompt": "setup_collection = (name, collection) ->\n methods = {}\n methods[Houston._houstonize \"#{name}_insert\"] = (doc) ->\n return unless Houston._user_is_admin @userId\n collection.insert(doc)\n\n methods[Houston._houstonize \"#{name}_update\"] = (id, update_dict) ->\n return unless Houston._user_is_admin @userId\n if collection.findOne(id)\n collection.update(id, update_dict)\n else\n id = collection.findOne(new Meteor.Collection.ObjectID(id))\n collection.update(id, update_dict)\n\n methods[Houston._houstonize \"#{name}_delete\"] = (id, update_dict) ->\n return unless Houston._user_is_admin @userId\n if collection.findOne(id)\n collection.remove(id)\n else\n id = collection.findOne(new Meteor.Collection.ObjectID(id))\n collection.remove(id)\n\n Meteor.methods methods", "response": "Houston._publish name, (sort, filter, limit) ->\n return unless Houston._user_is_admin @userId\n try\n collection.find(filter, sort: sort, limit: limit)\n catch e\n console.log e\n\n collection.find().observe\n added: (document) ->\n Houston._collections.collections.update {name},\n $inc: {count: 1},\n $addToSet: fields: $each: Houston._get_field_names([document])\n removed: (document) -> Houston._collections.collections.update {name}, {$inc: {count: -1}}\n\n fields = Houston._get_field_names(collection.find().fetch())\n c = Houston._collections.collections.findOne {name}\n if c\n Houston._collections.collections.update c._id, {$set: count: collection.find().count(), fields: fields}\n else\n Houston._collections.collections.insert {name, count: collection.find().count(), fields: fields}\n\ncollections = {'users': Meteor.users, 'meteor_accounts_loginServiceConfiguration': undefined}", "source_lang": "CoffeeScript", "target_lang": "CoffeeScript", "repo": "gterrono/houston", "path": "server/publications.coffee", "license": "MIT", "commit": "8b1d9f2bf910a38c1a6645f11c5dfd4512226d34", "stars": 802, "source_url": "https://github.com/gterrono/houston/blob/8b1d9f2bf910a38c1a6645f11c5dfd4512226d34/server/publications.coffee", "line_start": 8, "line_end": 53}837{"id": "gterrono/houston:server/publications.coffee:3:raw_corpus", "type": "raw_corpus", "prompt": "", "response": "sync_collections = ->\n Dummy.findOne() # hack. TODO: verify this is still necessary\n\n _sync_collections = (meh, collections_db) ->\n collection_names = (col.collectionName for col in collections_db \\\n when (col.collectionName.indexOf \"system.\") isnt 0 and\n (col.collectionName.indexOf \"houston_\") isnt 0)\n\n collection_names.forEach (name) ->\n unless name of collections\n try\n collections[name] = new Meteor.Collection(name)\n catch e\n for key, value of root\n if name == value._name\n collections[name] = value\n console.log e unless collections[name]?\n setup_collection(name, collections[name]) if collections[name]?\n\n bound_sync_collections = Meteor.bindEnvironment _sync_collections, (e) ->\n console.log \"Failed while syncing collections for reason: #{e}\"\n\n # MongoInternals is the 'right' solution as of 0.6.5\n mongo_driver = MongoInternals?.defaultRemoteCollectionDriver() or Meteor._RemoteCollectionDriver\n mongo_driver.mongo.db.collections bound_sync_collections\n\nMeteor.methods\n _houston_make_admin: (user_id) ->\n # limit one admin\n return if Houston._admins.findOne {'user_id': $exists: true}\n Houston._admins.insert {user_id}\n sync_collections() # reloads collections in case of new app\n return true\n\n# publish our analysis of the app's collections\nHouston._publish 'collections', ->\n return unless Houston._user_is_admin @userId\n Houston._collections.collections.find()\n\n# TODO address inherent security issue\nHouston._publish 'admin_user', ->\n Houston._admins.find {}\n\nMeteor.startup ->\n sync_collections()", "source_lang": "", "target_lang": "CoffeeScript", "repo": "gterrono/houston", "path": "server/publications.coffee", "license": "MIT", "commit": "8b1d9f2bf910a38c1a6645f11c5dfd4512226d34", "stars": 802, "source_url": "https://github.com/gterrono/houston/blob/8b1d9f2bf910a38c1a6645f11c5dfd4512226d34/server/publications.coffee", "line_start": 54, "line_end": 98}838{"id": "gterrono/houston:server/publications.coffee:3:coffee_to_js", "type": "coffee_to_js", "prompt": "Convert this CoffeeScript to JavaScript.\n```coffeescript\nsync_collections = ->\n Dummy.findOne() # hack. TODO: verify this is still necessary\n\n _sync_collections = (meh, collections_db) ->\n collection_names = (col.collectionName for col in collections_db \\\n when (col.collectionName.indexOf \"system.\") isnt 0 and\n (col.collectionName.indexOf \"houston_\") isnt 0)\n\n collection_names.forEach (name) ->\n unless name of collections\n try\n collections[name] = new Meteor.Collection(name)\n catch e\n for key, value of root\n if name == value._name\n collections[name] = value\n console.log e unless collections[name]?\n setup_collection(name, collections[name]) if collections[name]?\n\n bound_sync_collections = Meteor.bindEnvironment _sync_collections, (e) ->\n console.log \"Failed while syncing collections for reason: #{e}\"\n\n # MongoInternals is the 'right' solution as of 0.6.5\n mongo_driver = MongoInternals?.defaultRemoteCollectionDriver() or Meteor._RemoteCollectionDriver\n mongo_driver.mongo.db.collections bound_sync_collections\n\nMeteor.methods\n _houston_make_admin: (user_id) ->\n # limit one admin\n return if Houston._admins.findOne {'user_id': $exists: true}\n Houston._admins.insert {user_id}\n sync_collections() # reloads collections in case of new app\n return true\n\n# publish our analysis of the app's collections\nHouston._publish 'collections', ->\n return unless Houston._user_is_admin @userId\n Houston._collections.collections.find()\n\n# TODO address inherent security issue\nHouston._publish 'admin_user', ->\n Houston._admins.find {}\n\nMeteor.startup ->\n sync_collections()\n```", "response": "var sync_collections;\n\nsync_collections = function() {\n var _sync_collections, bound_sync_collections, mongo_driver;\n Dummy.findOne(); // hack. TODO: verify this is still necessary\n _sync_collections = function(meh, collections_db) {\n var col, collection_names;\n collection_names = (function() {\n var i, len, results;\n results = [];\n for (i = 0, len = collections_db.length; i < len; i++) {\n col = collections_db[i];\n if ((col.collectionName.indexOf(\"system.\")) !== 0 && (col.collectionName.indexOf(\"houston_\")) !== 0) {\n results.push(col.collectionName);\n }\n }\n return results;\n })();\n return collection_names.forEach(function(name) {\n var e, key, value;\n if (!(name in collections)) {\n try {\n collections[name] = new Meteor.Collection(name);\n } catch (error) {\n e = error;\n for (key in root) {\n value = root[key];\n if (name === value._name) {\n collections[name] = value;\n }\n }\n if (collections[name] == null) {\n console.log(e);\n }\n }\n if (collections[name] != null) {\n return setup_collection(name, collections[name]);\n }\n }\n });\n };\n bound_sync_collections = Meteor.bindEnvironment(_sync_collections, function(e) {\n return console.log(`Failed while syncing collections for reason: ${e}`);\n });\n // MongoInternals is the 'right' solution as of 0.6.5\n mongo_driver = (typeof MongoInternals !== \"undefined\" && MongoInternals !== null ? MongoInternals.defaultRemoteCollectionDriver() : void 0) || Meteor._RemoteCollectionDriver;\n return mongo_driver.mongo.db.collections(bound_sync_collections);\n};\n\nMeteor.methods({\n _houston_make_admin: function(user_id) {\n // limit one admin\n if (Houston._admins.findOne({\n 'user_id': {\n $exists: true\n }\n })) {\n return;\n }\n Houston._admins.insert({user_id});\n sync_collections(); // reloads collections in case of new app\n return true;\n }\n});\n\n// publish our analysis of the app's collections\nHouston._publish('collections', function() {\n if (!Houston._user_is_admin(this.userId)) {\n return;\n }\n return Houston._collections.collections.find();\n});\n\n// TODO address inherent security issue\nHouston._publish('admin_user', function() {\n return Houston._admins.find({});\n});\n\nMeteor.startup(function() {\n return sync_collections();\n});", "source_lang": "CoffeeScript", "target_lang": "JavaScript", "repo": "gterrono/houston", "path": "server/publications.coffee", "license": "MIT", "commit": "8b1d9f2bf910a38c1a6645f11c5dfd4512226d34", "stars": 802, "source_url": "https://github.com/gterrono/houston/blob/8b1d9f2bf910a38c1a6645f11c5dfd4512226d34/server/publications.coffee", "line_start": 54, "line_end": 98}839{"id": "gterrono/houston:server/publications.coffee:3:js_to_coffee", "type": "js_to_coffee", "prompt": "Convert this JavaScript to CoffeeScript.\n```javascript\nvar sync_collections;\n\nsync_collections = function() {\n var _sync_collections, bound_sync_collections, mongo_driver;\n Dummy.findOne(); // hack. TODO: verify this is still necessary\n _sync_collections = function(meh, collections_db) {\n var col, collection_names;\n collection_names = (function() {\n var i, len, results;\n results = [];\n for (i = 0, len = collections_db.length; i < len; i++) {\n col = collections_db[i];\n if ((col.collectionName.indexOf(\"system.\")) !== 0 && (col.collectionName.indexOf(\"houston_\")) !== 0) {\n results.push(col.collectionName);\n }\n }\n return results;\n })();\n return collection_names.forEach(function(name) {\n var e, key, value;\n if (!(name in collections)) {\n try {\n collections[name] = new Meteor.Collection(name);\n } catch (error) {\n e = error;\n for (key in root) {\n value = root[key];\n if (name === value._name) {\n collections[name] = value;\n }\n }\n if (collections[name] == null) {\n console.log(e);\n }\n }\n if (collections[name] != null) {\n return setup_collection(name, collections[name]);\n }\n }\n });\n };\n bound_sync_collections = Meteor.bindEnvironment(_sync_collections, function(e) {\n return console.log(`Failed while syncing collections for reason: ${e}`);\n });\n // MongoInternals is the 'right' solution as of 0.6.5\n mongo_driver = (typeof MongoInternals !== \"undefined\" && MongoInternals !== null ? MongoInternals.defaultRemoteCollectionDriver() : void 0) || Meteor._RemoteCollectionDriver;\n return mongo_driver.mongo.db.collections(bound_sync_collections);\n};\n\nMeteor.methods({\n _houston_make_admin: function(user_id) {\n // limit one admin\n if (Houston._admins.findOne({\n 'user_id': {\n $exists: true\n }\n })) {\n return;\n }\n Houston._admins.insert({user_id});\n sync_collections(); // reloads collections in case of new app\n return true;\n }\n});\n\n// publish our analysis of the app's collections\nHouston._publish('collections', function() {\n if (!Houston._user_is_admin(this.userId)) {\n return;\n }\n return Houston._collections.collections.find();\n});\n\n// TODO address inherent security issue\nHouston._publish('admin_user', function() {\n return Houston._admins.find({});\n});\n\nMeteor.startup(function() {\n return sync_collections();\n});\n```", "response": "sync_collections = ->\n Dummy.findOne() # hack. TODO: verify this is still necessary\n\n _sync_collections = (meh, collections_db) ->\n collection_names = (col.collectionName for col in collections_db \\\n when (col.collectionName.indexOf \"system.\") isnt 0 and\n (col.collectionName.indexOf \"houston_\") isnt 0)\n\n collection_names.forEach (name) ->\n unless name of collections\n try\n collections[name] = new Meteor.Collection(name)\n catch e\n for key, value of root\n if name == value._name\n collections[name] = value\n console.log e unless collections[name]?\n setup_collection(name, collections[name]) if collections[name]?\n\n bound_sync_collections = Meteor.bindEnvironment _sync_collections, (e) ->\n console.log \"Failed while syncing collections for reason: #{e}\"\n\n # MongoInternals is the 'right' solution as of 0.6.5\n mongo_driver = MongoInternals?.defaultRemoteCollectionDriver() or Meteor._RemoteCollectionDriver\n mongo_driver.mongo.db.collections bound_sync_collections\n\nMeteor.methods\n _houston_make_admin: (user_id) ->\n # limit one admin\n return if Houston._admins.findOne {'user_id': $exists: true}\n Houston._admins.insert {user_id}\n sync_collections() # reloads collections in case of new app\n return true\n\n# publish our analysis of the app's collections\nHouston._publish 'collections', ->\n return unless Houston._user_is_admin @userId\n Houston._collections.collections.find()\n\n# TODO address inherent security issue\nHouston._publish 'admin_user', ->\n Houston._admins.find {}\n\nMeteor.startup ->\n sync_collections()", "source_lang": "JavaScript", "target_lang": "CoffeeScript", "repo": "gterrono/houston", "path": "server/publications.coffee", "license": "MIT", "commit": "8b1d9f2bf910a38c1a6645f11c5dfd4512226d34", "stars": 802, "source_url": "https://github.com/gterrono/houston/blob/8b1d9f2bf910a38c1a6645f11c5dfd4512226d34/server/publications.coffee", "line_start": 54, "line_end": 98}840{"id": "gterrono/houston:server/publications.coffee:3:completion", "type": "completion", "prompt": "sync_collections = ->\n Dummy.findOne() # hack. TODO: verify this is still necessary\n\n _sync_collections = (meh, collections_db) ->\n collection_names = (col.collectionName for col in collections_db \\\n when (col.collectionName.indexOf \"system.\") isnt 0 and\n (col.collectionName.indexOf \"houston_\") isnt 0)\n\n collection_names.forEach (name) ->\n unless name of collections\n try\n collections[name] = new Meteor.Collection(name)\n catch e\n for key, value of root\n if name == value._name\n collections[name] = value\n console.log e unless collections[name]?\n setup_collection(name, collections[name]) if collections[name]?\n\n bound_sync_collections = Meteor.bindEnvironment _sync_collections, (e) ->\n console.log \"Failed while syncing collections for reason: #{e}\"", "response": "# MongoInternals is the 'right' solution as of 0.6.5\n mongo_driver = MongoInternals?.defaultRemoteCollectionDriver() or Meteor._RemoteCollectionDriver\n mongo_driver.mongo.db.collections bound_sync_collections\n\nMeteor.methods\n _houston_make_admin: (user_id) ->\n # limit one admin\n return if Houston._admins.findOne {'user_id': $exists: true}\n Houston._admins.insert {user_id}\n sync_collections() # reloads collections in case of new app\n return true\n\n# publish our analysis of the app's collections\nHouston._publish 'collections', ->\n return unless Houston._user_is_admin @userId\n Houston._collections.collections.find()\n\n# TODO address inherent security issue\nHouston._publish 'admin_user', ->\n Houston._admins.find {}\n\nMeteor.startup ->\n sync_collections()", "source_lang": "CoffeeScript", "target_lang": "CoffeeScript", "repo": "gterrono/houston", "path": "server/publications.coffee", "license": "MIT", "commit": "8b1d9f2bf910a38c1a6645f11c5dfd4512226d34", "stars": 802, "source_url": "https://github.com/gterrono/houston/blob/8b1d9f2bf910a38c1a6645f11c5dfd4512226d34/server/publications.coffee", "line_start": 54, "line_end": 98}841{"id": "gterrono/houston:server/publications.coffee:2:raw_corpus", "type": "raw_corpus", "prompt": "", "response": "setup_collection = (name, collection) ->\n console.log name, collection\n methods = {}\n methods[Houston._houstonize \"#{name}_insert\"] = (doc) ->\n return unless Houston._user_is_admin @userId\n collection.insert(doc)\n\n methods[Houston._houstonize \"#{name}_update\"] = (id, update_dict) ->\n return unless Houston._user_is_admin @userId\n if collection.findOne(id)\n collection.update(id, update_dict)\n else\n id = collection.findOne(new Meteor.Collection.ObjectID(id))\n collection.update(id, update_dict)\n\n methods[Houston._houstonize \"#{name}_delete\"] = (id, update_dict) ->\n return unless Houston._user_is_admin @userId\n if collection.findOne(id)\n collection.remove(id)\n else\n id = collection.findOne(new Meteor.Collection.ObjectID(id))\n collection.remove(id)\n\n Meteor.methods methods\n\n Houston._publish name, (sort, filter, limit) ->\n return unless Houston._user_is_admin @userId\n try\n collection.find(filter, sort: sort, limit: limit)\n catch e\n console.log e\n\n collection.find().observe\n added: (document) ->\n Houston._collections.collections.update {name},\n $inc: {count: 1},\n $addToSet: fields: $each: Houston._get_field_names([document])\n removed: (document) -> Houston._collections.collections.update {name}, {$inc: {count: -1}}\n\n fields = Houston._get_field_names(collection.find().fetch())\n c = Houston._collections.collections.findOne {name}\n if c\n Houston._collections.collections.update c._id, {$set: count: collection.find().count(), fields: fields}\n else\n Houston._collections.collections.insert {name, count: collection.find().count(), fields: fields}\n\ncollections = {'users': Meteor.users, 'meteor_accounts_loginServiceConfiguration': undefined}", "source_lang": "", "target_lang": "CoffeeScript", "repo": "gterrono/houston", "path": "server/publications.coffee", "license": "MIT", "commit": "7eb4e053da1414fd572c841d4f26a07eb73dea58", "stars": 802, "source_url": "https://github.com/gterrono/houston/blob/7eb4e053da1414fd572c841d4f26a07eb73dea58/server/publications.coffee", "line_start": 8, "line_end": 54}842{"id": "gterrono/houston:server/publications.coffee:2:coffee_to_js", "type": "coffee_to_js", "prompt": "Convert this CoffeeScript to JavaScript.\n```coffeescript\nsetup_collection = (name, collection) ->\n console.log name, collection\n methods = {}\n methods[Houston._houstonize \"#{name}_insert\"] = (doc) ->\n return unless Houston._user_is_admin @userId\n collection.insert(doc)\n\n methods[Houston._houstonize \"#{name}_update\"] = (id, update_dict) ->\n return unless Houston._user_is_admin @userId\n if collection.findOne(id)\n collection.update(id, update_dict)\n else\n id = collection.findOne(new Meteor.Collection.ObjectID(id))\n collection.update(id, update_dict)\n\n methods[Houston._houstonize \"#{name}_delete\"] = (id, update_dict) ->\n return unless Houston._user_is_admin @userId\n if collection.findOne(id)\n collection.remove(id)\n else\n id = collection.findOne(new Meteor.Collection.ObjectID(id))\n collection.remove(id)\n\n Meteor.methods methods\n\n Houston._publish name, (sort, filter, limit) ->\n return unless Houston._user_is_admin @userId\n try\n collection.find(filter, sort: sort, limit: limit)\n catch e\n console.log e\n\n collection.find().observe\n added: (document) ->\n Houston._collections.collections.update {name},\n $inc: {count: 1},\n $addToSet: fields: $each: Houston._get_field_names([document])\n removed: (document) -> Houston._collections.collections.update {name}, {$inc: {count: -1}}\n\n fields = Houston._get_field_names(collection.find().fetch())\n c = Houston._collections.collections.findOne {name}\n if c\n Houston._collections.collections.update c._id, {$set: count: collection.find().count(), fields: fields}\n else\n Houston._collections.collections.insert {name, count: collection.find().count(), fields: fields}\n\ncollections = {'users': Meteor.users, 'meteor_accounts_loginServiceConfiguration': undefined}\n```", "response": "var collections, setup_collection;\n\nsetup_collection = function(name, collection) {\n var c, fields, methods;\n console.log(name, collection);\n methods = {};\n methods[Houston._houstonize(`${name}_insert`)] = function(doc) {\n if (!Houston._user_is_admin(this.userId)) {\n return;\n }\n return collection.insert(doc);\n };\n methods[Houston._houstonize(`${name}_update`)] = function(id, update_dict) {\n if (!Houston._user_is_admin(this.userId)) {\n return;\n }\n if (collection.findOne(id)) {\n return collection.update(id, update_dict);\n } else {\n id = collection.findOne(new Meteor.Collection.ObjectID(id));\n return collection.update(id, update_dict);\n }\n };\n methods[Houston._houstonize(`${name}_delete`)] = function(id, update_dict) {\n if (!Houston._user_is_admin(this.userId)) {\n return;\n }\n if (collection.findOne(id)) {\n return collection.remove(id);\n } else {\n id = collection.findOne(new Meteor.Collection.ObjectID(id));\n return collection.remove(id);\n }\n };\n Meteor.methods(methods);\n Houston._publish(name, function(sort, filter, limit) {\n var e;\n if (!Houston._user_is_admin(this.userId)) {\n return;\n }\n try {\n return collection.find(filter, {\n sort: sort,\n limit: limit\n });\n } catch (error) {\n e = error;\n return console.log(e);\n }\n });\n collection.find().observe({\n added: function(document) {\n return Houston._collections.collections.update({name}, {\n $inc: {\n count: 1\n },\n $addToSet: {\n fields: {\n $each: Houston._get_field_names([document])\n }\n }\n });\n },\n removed: function(document) {\n return Houston._collections.collections.update({name}, {\n $inc: {\n count: -1\n }\n });\n }\n });\n fields = Houston._get_field_names(collection.find().fetch());\n c = Houston._collections.collections.findOne({name});\n if (c) {\n return Houston._collections.collections.update(c._id, {\n $set: {\n count: collection.find().count(),\n fields: fields\n }\n });\n } else {\n return Houston._collections.collections.insert({\n name,\n count: collection.find().count(),\n fields: fields\n });\n }\n};\n\ncollections = {\n 'users': Meteor.users,\n 'meteor_accounts_loginServiceConfiguration': void 0\n};", "source_lang": "CoffeeScript", "target_lang": "JavaScript", "repo": "gterrono/houston", "path": "server/publications.coffee", "license": "MIT", "commit": "7eb4e053da1414fd572c841d4f26a07eb73dea58", "stars": 802, "source_url": "https://github.com/gterrono/houston/blob/7eb4e053da1414fd572c841d4f26a07eb73dea58/server/publications.coffee", "line_start": 8, "line_end": 54}843{"id": "gterrono/houston:server/publications.coffee:2:js_to_coffee", "type": "js_to_coffee", "prompt": "Convert this JavaScript to CoffeeScript.\n```javascript\nvar collections, setup_collection;\n\nsetup_collection = function(name, collection) {\n var c, fields, methods;\n console.log(name, collection);\n methods = {};\n methods[Houston._houstonize(`${name}_insert`)] = function(doc) {\n if (!Houston._user_is_admin(this.userId)) {\n return;\n }\n return collection.insert(doc);\n };\n methods[Houston._houstonize(`${name}_update`)] = function(id, update_dict) {\n if (!Houston._user_is_admin(this.userId)) {\n return;\n }\n if (collection.findOne(id)) {\n return collection.update(id, update_dict);\n } else {\n id = collection.findOne(new Meteor.Collection.ObjectID(id));\n return collection.update(id, update_dict);\n }\n };\n methods[Houston._houstonize(`${name}_delete`)] = function(id, update_dict) {\n if (!Houston._user_is_admin(this.userId)) {\n return;\n }\n if (collection.findOne(id)) {\n return collection.remove(id);\n } else {\n id = collection.findOne(new Meteor.Collection.ObjectID(id));\n return collection.remove(id);\n }\n };\n Meteor.methods(methods);\n Houston._publish(name, function(sort, filter, limit) {\n var e;\n if (!Houston._user_is_admin(this.userId)) {\n return;\n }\n try {\n return collection.find(filter, {\n sort: sort,\n limit: limit\n });\n } catch (error) {\n e = error;\n return console.log(e);\n }\n });\n collection.find().observe({\n added: function(document) {\n return Houston._collections.collections.update({name}, {\n $inc: {\n count: 1\n },\n $addToSet: {\n fields: {\n $each: Houston._get_field_names([document])\n }\n }\n });\n },\n removed: function(document) {\n return Houston._collections.collections.update({name}, {\n $inc: {\n count: -1\n }\n });\n }\n });\n fields = Houston._get_field_names(collection.find().fetch());\n c = Houston._collections.collections.findOne({name});\n if (c) {\n return Houston._collections.collections.update(c._id, {\n $set: {\n count: collection.find().count(),\n fields: fields\n }\n });\n } else {\n return Houston._collections.collections.insert({\n name,\n count: collection.find().count(),\n fields: fields\n });\n }\n};\n\ncollections = {\n 'users': Meteor.users,\n 'meteor_accounts_loginServiceConfiguration': void 0\n};\n```", "response": "setup_collection = (name, collection) ->\n console.log name, collection\n methods = {}\n methods[Houston._houstonize \"#{name}_insert\"] = (doc) ->\n return unless Houston._user_is_admin @userId\n collection.insert(doc)\n\n methods[Houston._houstonize \"#{name}_update\"] = (id, update_dict) ->\n return unless Houston._user_is_admin @userId\n if collection.findOne(id)\n collection.update(id, update_dict)\n else\n id = collection.findOne(new Meteor.Collection.ObjectID(id))\n collection.update(id, update_dict)\n\n methods[Houston._houstonize \"#{name}_delete\"] = (id, update_dict) ->\n return unless Houston._user_is_admin @userId\n if collection.findOne(id)\n collection.remove(id)\n else\n id = collection.findOne(new Meteor.Collection.ObjectID(id))\n collection.remove(id)\n\n Meteor.methods methods\n\n Houston._publish name, (sort, filter, limit) ->\n return unless Houston._user_is_admin @userId\n try\n collection.find(filter, sort: sort, limit: limit)\n catch e\n console.log e\n\n collection.find().observe\n added: (document) ->\n Houston._collections.collections.update {name},\n $inc: {count: 1},\n $addToSet: fields: $each: Houston._get_field_names([document])\n removed: (document) -> Houston._collections.collections.update {name}, {$inc: {count: -1}}\n\n fields = Houston._get_field_names(collection.find().fetch())\n c = Houston._collections.collections.findOne {name}\n if c\n Houston._collections.collections.update c._id, {$set: count: collection.find().count(), fields: fields}\n else\n Houston._collections.collections.insert {name, count: collection.find().count(), fields: fields}\n\ncollections = {'users': Meteor.users, 'meteor_accounts_loginServiceConfiguration': undefined}", "source_lang": "JavaScript", "target_lang": "CoffeeScript", "repo": "gterrono/houston", "path": "server/publications.coffee", "license": "MIT", "commit": "7eb4e053da1414fd572c841d4f26a07eb73dea58", "stars": 802, "source_url": "https://github.com/gterrono/houston/blob/7eb4e053da1414fd572c841d4f26a07eb73dea58/server/publications.coffee", "line_start": 8, "line_end": 54}844{"id": "gterrono/houston:server/publications.coffee:2:completion", "type": "completion", "prompt": "setup_collection = (name, collection) ->\n console.log name, collection\n methods = {}\n methods[Houston._houstonize \"#{name}_insert\"] = (doc) ->\n return unless Houston._user_is_admin @userId\n collection.insert(doc)\n\n methods[Houston._houstonize \"#{name}_update\"] = (id, update_dict) ->\n return unless Houston._user_is_admin @userId\n if collection.findOne(id)\n collection.update(id, update_dict)\n else\n id = collection.findOne(new Meteor.Collection.ObjectID(id))\n collection.update(id, update_dict)\n\n methods[Houston._houstonize \"#{name}_delete\"] = (id, update_dict) ->\n return unless Houston._user_is_admin @userId\n if collection.findOne(id)\n collection.remove(id)\n else\n id = collection.findOne(new Meteor.Collection.ObjectID(id))\n collection.remove(id)", "response": "Meteor.methods methods\n\n Houston._publish name, (sort, filter, limit) ->\n return unless Houston._user_is_admin @userId\n try\n collection.find(filter, sort: sort, limit: limit)\n catch e\n console.log e\n\n collection.find().observe\n added: (document) ->\n Houston._collections.collections.update {name},\n $inc: {count: 1},\n $addToSet: fields: $each: Houston._get_field_names([document])\n removed: (document) -> Houston._collections.collections.update {name}, {$inc: {count: -1}}\n\n fields = Houston._get_field_names(collection.find().fetch())\n c = Houston._collections.collections.findOne {name}\n if c\n Houston._collections.collections.update c._id, {$set: count: collection.find().count(), fields: fields}\n else\n Houston._collections.collections.insert {name, count: collection.find().count(), fields: fields}\n\ncollections = {'users': Meteor.users, 'meteor_accounts_loginServiceConfiguration': undefined}", "source_lang": "CoffeeScript", "target_lang": "CoffeeScript", "repo": "gterrono/houston", "path": "server/publications.coffee", "license": "MIT", "commit": "7eb4e053da1414fd572c841d4f26a07eb73dea58", "stars": 802, "source_url": "https://github.com/gterrono/houston/blob/7eb4e053da1414fd572c841d4f26a07eb73dea58/server/publications.coffee", "line_start": 8, "line_end": 54}845{"id": "gterrono/houston:server/publications.coffee:2:raw_corpus", "type": "raw_corpus", "prompt": "", "response": "setup_collection = (name, collection) ->\n console.log name, collection\n methods = {}\n methods[Houston._houstonize \"#{name}_insert\"] = (doc) ->\n return unless Houston._user_is_admin @userId\n collection.insert(doc)\n\n methods[Houston._houstonize \"#{name}_update\"] = (id, update_dict) ->\n return unless Houston._user_is_admin @userId\n if collection.findOne(id)\n collection.update(id, update_dict)\n else\n id = collection.findOne(new Meteor.Collection.ObjectID(id))\n collection.update(id, update_dict)\n\n methods[Houston._houstonize \"#{name}_delete\"] = (id, update_dict) ->\n return unless Houston._user_is_admin @userId\n if collection.findOne(id)\n collection.remove(id)\n else\n id = collection.findOne(new Meteor.Collection.ObjectID(id))\n collection.remove(id)\n\n Meteor.methods methods\n\n Houston._publish name, (sort, filter, limit) ->\n return unless Houston._user_is_admin @userId\n try\n collection.find(filter, sort: sort, limit: limit)\n catch e\n console.log e\n\n collection.find().observe\n added: (document) ->\n Houston._collections.collections.update {name},\n $inc: {count: 1},\n $addToSet: fields: $each: Houston._get_field_names([document])\n removed: (document) -> Houston._collections.collections.update {name}, {$inc: {count: -1}}\n\n fields = Houston._get_field_names(collection.find().fetch())\n c = Houston._collections.collections.findOne {name}\n if c\n Houston._collections.collections.update c._id, {$set: count: collection.find().count(), fields: fields}\n else\n Houston._collections.collections.insert {name, count: collection.find().count(), fields: fields}\n\ncollections = {'users': Meteor.users, 'meteor_accounts_loginServiceConfiguration': undefined} #TODO verify this is still relevant", "source_lang": "", "target_lang": "CoffeeScript", "repo": "gterrono/houston", "path": "server/publications.coffee", "license": "MIT", "commit": "4da2e20614ad93be4e94a65c65752e6f231ea9fb", "stars": 802, "source_url": "https://github.com/gterrono/houston/blob/4da2e20614ad93be4e94a65c65752e6f231ea9fb/server/publications.coffee", "line_start": 8, "line_end": 54}846{"id": "gterrono/houston:server/publications.coffee:2:coffee_to_js", "type": "coffee_to_js", "prompt": "Convert this CoffeeScript to JavaScript.\n```coffeescript\nsetup_collection = (name, collection) ->\n console.log name, collection\n methods = {}\n methods[Houston._houstonize \"#{name}_insert\"] = (doc) ->\n return unless Houston._user_is_admin @userId\n collection.insert(doc)\n\n methods[Houston._houstonize \"#{name}_update\"] = (id, update_dict) ->\n return unless Houston._user_is_admin @userId\n if collection.findOne(id)\n collection.update(id, update_dict)\n else\n id = collection.findOne(new Meteor.Collection.ObjectID(id))\n collection.update(id, update_dict)\n\n methods[Houston._houstonize \"#{name}_delete\"] = (id, update_dict) ->\n return unless Houston._user_is_admin @userId\n if collection.findOne(id)\n collection.remove(id)\n else\n id = collection.findOne(new Meteor.Collection.ObjectID(id))\n collection.remove(id)\n\n Meteor.methods methods\n\n Houston._publish name, (sort, filter, limit) ->\n return unless Houston._user_is_admin @userId\n try\n collection.find(filter, sort: sort, limit: limit)\n catch e\n console.log e\n\n collection.find().observe\n added: (document) ->\n Houston._collections.collections.update {name},\n $inc: {count: 1},\n $addToSet: fields: $each: Houston._get_field_names([document])\n removed: (document) -> Houston._collections.collections.update {name}, {$inc: {count: -1}}\n\n fields = Houston._get_field_names(collection.find().fetch())\n c = Houston._collections.collections.findOne {name}\n if c\n Houston._collections.collections.update c._id, {$set: count: collection.find().count(), fields: fields}\n else\n Houston._collections.collections.insert {name, count: collection.find().count(), fields: fields}\n\ncollections = {'users': Meteor.users, 'meteor_accounts_loginServiceConfiguration': undefined} #TODO verify this is still relevant\n```", "response": "var collections, setup_collection;\n\nsetup_collection = function(name, collection) {\n var c, fields, methods;\n console.log(name, collection);\n methods = {};\n methods[Houston._houstonize(`${name}_insert`)] = function(doc) {\n if (!Houston._user_is_admin(this.userId)) {\n return;\n }\n return collection.insert(doc);\n };\n methods[Houston._houstonize(`${name}_update`)] = function(id, update_dict) {\n if (!Houston._user_is_admin(this.userId)) {\n return;\n }\n if (collection.findOne(id)) {\n return collection.update(id, update_dict);\n } else {\n id = collection.findOne(new Meteor.Collection.ObjectID(id));\n return collection.update(id, update_dict);\n }\n };\n methods[Houston._houstonize(`${name}_delete`)] = function(id, update_dict) {\n if (!Houston._user_is_admin(this.userId)) {\n return;\n }\n if (collection.findOne(id)) {\n return collection.remove(id);\n } else {\n id = collection.findOne(new Meteor.Collection.ObjectID(id));\n return collection.remove(id);\n }\n };\n Meteor.methods(methods);\n Houston._publish(name, function(sort, filter, limit) {\n var e;\n if (!Houston._user_is_admin(this.userId)) {\n return;\n }\n try {\n return collection.find(filter, {\n sort: sort,\n limit: limit\n });\n } catch (error) {\n e = error;\n return console.log(e);\n }\n });\n collection.find().observe({\n added: function(document) {\n return Houston._collections.collections.update({name}, {\n $inc: {\n count: 1\n },\n $addToSet: {\n fields: {\n $each: Houston._get_field_names([document])\n }\n }\n });\n },\n removed: function(document) {\n return Houston._collections.collections.update({name}, {\n $inc: {\n count: -1\n }\n });\n }\n });\n fields = Houston._get_field_names(collection.find().fetch());\n c = Houston._collections.collections.findOne({name});\n if (c) {\n return Houston._collections.collections.update(c._id, {\n $set: {\n count: collection.find().count(),\n fields: fields\n }\n });\n } else {\n return Houston._collections.collections.insert({\n name,\n count: collection.find().count(),\n fields: fields\n });\n }\n};\n\ncollections = {\n 'users': Meteor.users,\n 'meteor_accounts_loginServiceConfiguration': void 0 //TODO verify this is still relevant\n};", "source_lang": "CoffeeScript", "target_lang": "JavaScript", "repo": "gterrono/houston", "path": "server/publications.coffee", "license": "MIT", "commit": "4da2e20614ad93be4e94a65c65752e6f231ea9fb", "stars": 802, "source_url": "https://github.com/gterrono/houston/blob/4da2e20614ad93be4e94a65c65752e6f231ea9fb/server/publications.coffee", "line_start": 8, "line_end": 54}847{"id": "gterrono/houston:server/publications.coffee:2:js_to_coffee", "type": "js_to_coffee", "prompt": "Convert this JavaScript to CoffeeScript.\n```javascript\nvar collections, setup_collection;\n\nsetup_collection = function(name, collection) {\n var c, fields, methods;\n console.log(name, collection);\n methods = {};\n methods[Houston._houstonize(`${name}_insert`)] = function(doc) {\n if (!Houston._user_is_admin(this.userId)) {\n return;\n }\n return collection.insert(doc);\n };\n methods[Houston._houstonize(`${name}_update`)] = function(id, update_dict) {\n if (!Houston._user_is_admin(this.userId)) {\n return;\n }\n if (collection.findOne(id)) {\n return collection.update(id, update_dict);\n } else {\n id = collection.findOne(new Meteor.Collection.ObjectID(id));\n return collection.update(id, update_dict);\n }\n };\n methods[Houston._houstonize(`${name}_delete`)] = function(id, update_dict) {\n if (!Houston._user_is_admin(this.userId)) {\n return;\n }\n if (collection.findOne(id)) {\n return collection.remove(id);\n } else {\n id = collection.findOne(new Meteor.Collection.ObjectID(id));\n return collection.remove(id);\n }\n };\n Meteor.methods(methods);\n Houston._publish(name, function(sort, filter, limit) {\n var e;\n if (!Houston._user_is_admin(this.userId)) {\n return;\n }\n try {\n return collection.find(filter, {\n sort: sort,\n limit: limit\n });\n } catch (error) {\n e = error;\n return console.log(e);\n }\n });\n collection.find().observe({\n added: function(document) {\n return Houston._collections.collections.update({name}, {\n $inc: {\n count: 1\n },\n $addToSet: {\n fields: {\n $each: Houston._get_field_names([document])\n }\n }\n });\n },\n removed: function(document) {\n return Houston._collections.collections.update({name}, {\n $inc: {\n count: -1\n }\n });\n }\n });\n fields = Houston._get_field_names(collection.find().fetch());\n c = Houston._collections.collections.findOne({name});\n if (c) {\n return Houston._collections.collections.update(c._id, {\n $set: {\n count: collection.find().count(),\n fields: fields\n }\n });\n } else {\n return Houston._collections.collections.insert({\n name,\n count: collection.find().count(),\n fields: fields\n });\n }\n};\n\ncollections = {\n 'users': Meteor.users,\n 'meteor_accounts_loginServiceConfiguration': void 0 //TODO verify this is still relevant\n};\n```", "response": "setup_collection = (name, collection) ->\n console.log name, collection\n methods = {}\n methods[Houston._houstonize \"#{name}_insert\"] = (doc) ->\n return unless Houston._user_is_admin @userId\n collection.insert(doc)\n\n methods[Houston._houstonize \"#{name}_update\"] = (id, update_dict) ->\n return unless Houston._user_is_admin @userId\n if collection.findOne(id)\n collection.update(id, update_dict)\n else\n id = collection.findOne(new Meteor.Collection.ObjectID(id))\n collection.update(id, update_dict)\n\n methods[Houston._houstonize \"#{name}_delete\"] = (id, update_dict) ->\n return unless Houston._user_is_admin @userId\n if collection.findOne(id)\n collection.remove(id)\n else\n id = collection.findOne(new Meteor.Collection.ObjectID(id))\n collection.remove(id)\n\n Meteor.methods methods\n\n Houston._publish name, (sort, filter, limit) ->\n return unless Houston._user_is_admin @userId\n try\n collection.find(filter, sort: sort, limit: limit)\n catch e\n console.log e\n\n collection.find().observe\n added: (document) ->\n Houston._collections.collections.update {name},\n $inc: {count: 1},\n $addToSet: fields: $each: Houston._get_field_names([document])\n removed: (document) -> Houston._collections.collections.update {name}, {$inc: {count: -1}}\n\n fields = Houston._get_field_names(collection.find().fetch())\n c = Houston._collections.collections.findOne {name}\n if c\n Houston._collections.collections.update c._id, {$set: count: collection.find().count(), fields: fields}\n else\n Houston._collections.collections.insert {name, count: collection.find().count(), fields: fields}\n\ncollections = {'users': Meteor.users, 'meteor_accounts_loginServiceConfiguration': undefined} #TODO verify this is still relevant", "source_lang": "JavaScript", "target_lang": "CoffeeScript", "repo": "gterrono/houston", "path": "server/publications.coffee", "license": "MIT", "commit": "4da2e20614ad93be4e94a65c65752e6f231ea9fb", "stars": 802, "source_url": "https://github.com/gterrono/houston/blob/4da2e20614ad93be4e94a65c65752e6f231ea9fb/server/publications.coffee", "line_start": 8, "line_end": 54}848{"id": "gterrono/houston:server/publications.coffee:2:completion", "type": "completion", "prompt": "setup_collection = (name, collection) ->\n console.log name, collection\n methods = {}\n methods[Houston._houstonize \"#{name}_insert\"] = (doc) ->\n return unless Houston._user_is_admin @userId\n collection.insert(doc)\n\n methods[Houston._houstonize \"#{name}_update\"] = (id, update_dict) ->\n return unless Houston._user_is_admin @userId\n if collection.findOne(id)\n collection.update(id, update_dict)\n else\n id = collection.findOne(new Meteor.Collection.ObjectID(id))\n collection.update(id, update_dict)\n\n methods[Houston._houstonize \"#{name}_delete\"] = (id, update_dict) ->\n return unless Houston._user_is_admin @userId\n if collection.findOne(id)\n collection.remove(id)\n else\n id = collection.findOne(new Meteor.Collection.ObjectID(id))\n collection.remove(id)", "response": "Meteor.methods methods\n\n Houston._publish name, (sort, filter, limit) ->\n return unless Houston._user_is_admin @userId\n try\n collection.find(filter, sort: sort, limit: limit)\n catch e\n console.log e\n\n collection.find().observe\n added: (document) ->\n Houston._collections.collections.update {name},\n $inc: {count: 1},\n $addToSet: fields: $each: Houston._get_field_names([document])\n removed: (document) -> Houston._collections.collections.update {name}, {$inc: {count: -1}}\n\n fields = Houston._get_field_names(collection.find().fetch())\n c = Houston._collections.collections.findOne {name}\n if c\n Houston._collections.collections.update c._id, {$set: count: collection.find().count(), fields: fields}\n else\n Houston._collections.collections.insert {name, count: collection.find().count(), fields: fields}\n\ncollections = {'users': Meteor.users, 'meteor_accounts_loginServiceConfiguration': undefined} #TODO verify this is still relevant", "source_lang": "CoffeeScript", "target_lang": "CoffeeScript", "repo": "gterrono/houston", "path": "server/publications.coffee", "license": "MIT", "commit": "4da2e20614ad93be4e94a65c65752e6f231ea9fb", "stars": 802, "source_url": "https://github.com/gterrono/houston/blob/4da2e20614ad93be4e94a65c65752e6f231ea9fb/server/publications.coffee", "line_start": 8, "line_end": 54}849{"id": "gterrono/houston:server/publications.coffee:3:raw_corpus", "type": "raw_corpus", "prompt": "", "response": "sync_collections = ->\n Dummy.findOne() # hack. TODO: verify this is still necessary\n\n _sync_collections = (meh, collections_db) ->\n collection_names = (col.collectionName for col in collections_db \\\n when (col.collectionName.indexOf \"system.\") isnt 0 and\n (col.collectionName.indexOf \"houston_\") isnt 0)\n\n collection_names.forEach (name) ->\n unless name of collections\n try\n collections[name] = new Meteor.Collection(name)\n catch e\n console.log Meteor\n for key, value of root\n if name == value._name\n collections[name] = value\n console.log e unless collections[name]?\n setup_collection(name, collections[name]) if collections[name]?\n\n bound_sync_collections = Meteor.bindEnvironment _sync_collections, (e) ->\n console.log \"Failed while syncing collections for reason: #{e}\"\n\n # MongoInternals is the 'right' solution as of 0.6.5\n mongo_driver = MongoInternals?.defaultRemoteCollectionDriver() or Meteor._RemoteCollectionDriver\n mongo_driver.mongo.db.collections bound_sync_collections\n\nMeteor.methods\n _houston_make_admin: (user_id) ->\n # limit one admin\n return if Houston._admins.findOne {'user_id': $exists: true}\n Houston._admins.insert {user_id}\n sync_collections() # reloads collections in case of new app\n return true\n\n# publish our analysis of the app's collections\nHouston._publish 'collections', ->\n return unless Houston._user_is_admin @userId\n Houston._collections.collections.find()\n\n# TODO address inherent security issue\nHouston._publish 'admin_user', ->\n Houston._admins.find {}\n\nMeteor.startup ->\n sync_collections()", "source_lang": "", "target_lang": "CoffeeScript", "repo": "gterrono/houston", "path": "server/publications.coffee", "license": "MIT", "commit": "c17c375d08fddee02ae19fd234e24f6d04bfaf46", "stars": 802, "source_url": "https://github.com/gterrono/houston/blob/c17c375d08fddee02ae19fd234e24f6d04bfaf46/server/publications.coffee", "line_start": 55, "line_end": 100}850{"id": "gterrono/houston:server/publications.coffee:3:coffee_to_js", "type": "coffee_to_js", "prompt": "Convert this CoffeeScript to JavaScript.\n```coffeescript\nsync_collections = ->\n Dummy.findOne() # hack. TODO: verify this is still necessary\n\n _sync_collections = (meh, collections_db) ->\n collection_names = (col.collectionName for col in collections_db \\\n when (col.collectionName.indexOf \"system.\") isnt 0 and\n (col.collectionName.indexOf \"houston_\") isnt 0)\n\n collection_names.forEach (name) ->\n unless name of collections\n try\n collections[name] = new Meteor.Collection(name)\n catch e\n console.log Meteor\n for key, value of root\n if name == value._name\n collections[name] = value\n console.log e unless collections[name]?\n setup_collection(name, collections[name]) if collections[name]?\n\n bound_sync_collections = Meteor.bindEnvironment _sync_collections, (e) ->\n console.log \"Failed while syncing collections for reason: #{e}\"\n\n # MongoInternals is the 'right' solution as of 0.6.5\n mongo_driver = MongoInternals?.defaultRemoteCollectionDriver() or Meteor._RemoteCollectionDriver\n mongo_driver.mongo.db.collections bound_sync_collections\n\nMeteor.methods\n _houston_make_admin: (user_id) ->\n # limit one admin\n return if Houston._admins.findOne {'user_id': $exists: true}\n Houston._admins.insert {user_id}\n sync_collections() # reloads collections in case of new app\n return true\n\n# publish our analysis of the app's collections\nHouston._publish 'collections', ->\n return unless Houston._user_is_admin @userId\n Houston._collections.collections.find()\n\n# TODO address inherent security issue\nHouston._publish 'admin_user', ->\n Houston._admins.find {}\n\nMeteor.startup ->\n sync_collections()\n```", "response": "var sync_collections;\n\nsync_collections = function() {\n var _sync_collections, bound_sync_collections, mongo_driver;\n Dummy.findOne(); // hack. TODO: verify this is still necessary\n _sync_collections = function(meh, collections_db) {\n var col, collection_names;\n collection_names = (function() {\n var i, len, results;\n results = [];\n for (i = 0, len = collections_db.length; i < len; i++) {\n col = collections_db[i];\n if ((col.collectionName.indexOf(\"system.\")) !== 0 && (col.collectionName.indexOf(\"houston_\")) !== 0) {\n results.push(col.collectionName);\n }\n }\n return results;\n })();\n return collection_names.forEach(function(name) {\n var e, key, value;\n if (!(name in collections)) {\n try {\n collections[name] = new Meteor.Collection(name);\n } catch (error) {\n e = error;\n console.log(Meteor);\n for (key in root) {\n value = root[key];\n if (name === value._name) {\n collections[name] = value;\n }\n }\n if (collections[name] == null) {\n console.log(e);\n }\n }\n if (collections[name] != null) {\n return setup_collection(name, collections[name]);\n }\n }\n });\n };\n bound_sync_collections = Meteor.bindEnvironment(_sync_collections, function(e) {\n return console.log(`Failed while syncing collections for reason: ${e}`);\n });\n // MongoInternals is the 'right' solution as of 0.6.5\n mongo_driver = (typeof MongoInternals !== \"undefined\" && MongoInternals !== null ? MongoInternals.defaultRemoteCollectionDriver() : void 0) || Meteor._RemoteCollectionDriver;\n return mongo_driver.mongo.db.collections(bound_sync_collections);\n};\n\nMeteor.methods({\n _houston_make_admin: function(user_id) {\n // limit one admin\n if (Houston._admins.findOne({\n 'user_id': {\n $exists: true\n }\n })) {\n return;\n }\n Houston._admins.insert({user_id});\n sync_collections(); // reloads collections in case of new app\n return true;\n }\n});\n\n// publish our analysis of the app's collections\nHouston._publish('collections', function() {\n if (!Houston._user_is_admin(this.userId)) {\n return;\n }\n return Houston._collections.collections.find();\n});\n\n// TODO address inherent security issue\nHouston._publish('admin_user', function() {\n return Houston._admins.find({});\n});\n\nMeteor.startup(function() {\n return sync_collections();\n});", "source_lang": "CoffeeScript", "target_lang": "JavaScript", "repo": "gterrono/houston", "path": "server/publications.coffee", "license": "MIT", "commit": "c17c375d08fddee02ae19fd234e24f6d04bfaf46", "stars": 802, "source_url": "https://github.com/gterrono/houston/blob/c17c375d08fddee02ae19fd234e24f6d04bfaf46/server/publications.coffee", "line_start": 55, "line_end": 100}851{"id": "gterrono/houston:server/publications.coffee:3:js_to_coffee", "type": "js_to_coffee", "prompt": "Convert this JavaScript to CoffeeScript.\n```javascript\nvar sync_collections;\n\nsync_collections = function() {\n var _sync_collections, bound_sync_collections, mongo_driver;\n Dummy.findOne(); // hack. TODO: verify this is still necessary\n _sync_collections = function(meh, collections_db) {\n var col, collection_names;\n collection_names = (function() {\n var i, len, results;\n results = [];\n for (i = 0, len = collections_db.length; i < len; i++) {\n col = collections_db[i];\n if ((col.collectionName.indexOf(\"system.\")) !== 0 && (col.collectionName.indexOf(\"houston_\")) !== 0) {\n results.push(col.collectionName);\n }\n }\n return results;\n })();\n return collection_names.forEach(function(name) {\n var e, key, value;\n if (!(name in collections)) {\n try {\n collections[name] = new Meteor.Collection(name);\n } catch (error) {\n e = error;\n console.log(Meteor);\n for (key in root) {\n value = root[key];\n if (name === value._name) {\n collections[name] = value;\n }\n }\n if (collections[name] == null) {\n console.log(e);\n }\n }\n if (collections[name] != null) {\n return setup_collection(name, collections[name]);\n }\n }\n });\n };\n bound_sync_collections = Meteor.bindEnvironment(_sync_collections, function(e) {\n return console.log(`Failed while syncing collections for reason: ${e}`);\n });\n // MongoInternals is the 'right' solution as of 0.6.5\n mongo_driver = (typeof MongoInternals !== \"undefined\" && MongoInternals !== null ? MongoInternals.defaultRemoteCollectionDriver() : void 0) || Meteor._RemoteCollectionDriver;\n return mongo_driver.mongo.db.collections(bound_sync_collections);\n};\n\nMeteor.methods({\n _houston_make_admin: function(user_id) {\n // limit one admin\n if (Houston._admins.findOne({\n 'user_id': {\n $exists: true\n }\n })) {\n return;\n }\n Houston._admins.insert({user_id});\n sync_collections(); // reloads collections in case of new app\n return true;\n }\n});\n\n// publish our analysis of the app's collections\nHouston._publish('collections', function() {\n if (!Houston._user_is_admin(this.userId)) {\n return;\n }\n return Houston._collections.collections.find();\n});\n\n// TODO address inherent security issue\nHouston._publish('admin_user', function() {\n return Houston._admins.find({});\n});\n\nMeteor.startup(function() {\n return sync_collections();\n});\n```", "response": "sync_collections = ->\n Dummy.findOne() # hack. TODO: verify this is still necessary\n\n _sync_collections = (meh, collections_db) ->\n collection_names = (col.collectionName for col in collections_db \\\n when (col.collectionName.indexOf \"system.\") isnt 0 and\n (col.collectionName.indexOf \"houston_\") isnt 0)\n\n collection_names.forEach (name) ->\n unless name of collections\n try\n collections[name] = new Meteor.Collection(name)\n catch e\n console.log Meteor\n for key, value of root\n if name == value._name\n collections[name] = value\n console.log e unless collections[name]?\n setup_collection(name, collections[name]) if collections[name]?\n\n bound_sync_collections = Meteor.bindEnvironment _sync_collections, (e) ->\n console.log \"Failed while syncing collections for reason: #{e}\"\n\n # MongoInternals is the 'right' solution as of 0.6.5\n mongo_driver = MongoInternals?.defaultRemoteCollectionDriver() or Meteor._RemoteCollectionDriver\n mongo_driver.mongo.db.collections bound_sync_collections\n\nMeteor.methods\n _houston_make_admin: (user_id) ->\n # limit one admin\n return if Houston._admins.findOne {'user_id': $exists: true}\n Houston._admins.insert {user_id}\n sync_collections() # reloads collections in case of new app\n return true\n\n# publish our analysis of the app's collections\nHouston._publish 'collections', ->\n return unless Houston._user_is_admin @userId\n Houston._collections.collections.find()\n\n# TODO address inherent security issue\nHouston._publish 'admin_user', ->\n Houston._admins.find {}\n\nMeteor.startup ->\n sync_collections()", "source_lang": "JavaScript", "target_lang": "CoffeeScript", "repo": "gterrono/houston", "path": "server/publications.coffee", "license": "MIT", "commit": "c17c375d08fddee02ae19fd234e24f6d04bfaf46", "stars": 802, "source_url": "https://github.com/gterrono/houston/blob/c17c375d08fddee02ae19fd234e24f6d04bfaf46/server/publications.coffee", "line_start": 55, "line_end": 100}852{"id": "gterrono/houston:server/publications.coffee:3:completion", "type": "completion", "prompt": "sync_collections = ->\n Dummy.findOne() # hack. TODO: verify this is still necessary\n\n _sync_collections = (meh, collections_db) ->\n collection_names = (col.collectionName for col in collections_db \\\n when (col.collectionName.indexOf \"system.\") isnt 0 and\n (col.collectionName.indexOf \"houston_\") isnt 0)\n\n collection_names.forEach (name) ->\n unless name of collections\n try\n collections[name] = new Meteor.Collection(name)\n catch e\n console.log Meteor\n for key, value of root\n if name == value._name\n collections[name] = value\n console.log e unless collections[name]?\n setup_collection(name, collections[name]) if collections[name]?\n\n bound_sync_collections = Meteor.bindEnvironment _sync_collections, (e) ->\n console.log \"Failed while syncing collections for reason: #{e}\"", "response": "# MongoInternals is the 'right' solution as of 0.6.5\n mongo_driver = MongoInternals?.defaultRemoteCollectionDriver() or Meteor._RemoteCollectionDriver\n mongo_driver.mongo.db.collections bound_sync_collections\n\nMeteor.methods\n _houston_make_admin: (user_id) ->\n # limit one admin\n return if Houston._admins.findOne {'user_id': $exists: true}\n Houston._admins.insert {user_id}\n sync_collections() # reloads collections in case of new app\n return true\n\n# publish our analysis of the app's collections\nHouston._publish 'collections', ->\n return unless Houston._user_is_admin @userId\n Houston._collections.collections.find()\n\n# TODO address inherent security issue\nHouston._publish 'admin_user', ->\n Houston._admins.find {}\n\nMeteor.startup ->\n sync_collections()", "source_lang": "CoffeeScript", "target_lang": "CoffeeScript", "repo": "gterrono/houston", "path": "server/publications.coffee", "license": "MIT", "commit": "c17c375d08fddee02ae19fd234e24f6d04bfaf46", "stars": 802, "source_url": "https://github.com/gterrono/houston/blob/c17c375d08fddee02ae19fd234e24f6d04bfaf46/server/publications.coffee", "line_start": 55, "line_end": 100}853{"id": "gterrono/houston:server/publications.coffee:3:raw_corpus", "type": "raw_corpus", "prompt": "", "response": "sync_collections = ->\n Dummy.findOne() # hack. TODO: verify this is still necessary\n\n _sync_collections = (meh, collections_db) ->\n collection_names = (col.collectionName for col in collections_db \\\n when (col.collectionName.indexOf \"system.\") isnt 0 and\n (col.collectionName.indexOf \"houston_\") isnt 0)\n\n collection_names.forEach (name) ->\n unless name of collections\n try\n collections[name] = new Meteor.Collection(name)\n catch e\n for key, value of root\n if name == value._name\n collections[name] = value\n console.log e unless collections[name]?\n setup_collection(name, collections[name])\n\n bound_sync_collections = Meteor.bindEnvironment _sync_collections, (e) ->\n console.log \"Failed while syncing collections for reason: #{e}\"\n\n # MongoInternals is the 'right' solution as of 0.6.5\n mongo_driver = MongoInternals?.defaultRemoteCollectionDriver() or Meteor._RemoteCollectionDriver\n mongo_driver.mongo.db.collections bound_sync_collections\n\nMeteor.methods\n _houston_make_admin: (user_id) ->\n # limit one admin\n return if Houston._admins.findOne {'user_id': $exists: true}\n Houston._admins.insert {user_id}\n sync_collections() # reloads collections in case of new app\n return true\n\n# publish our analysis of the app's collections\nHouston._publish 'collections', ->\n return unless Houston._user_is_admin @userId\n Houston._collections.collections.find()\n\n# TODO address inherent security issue\nHouston._publish 'admin_user', ->\n Houston._admins.find {}\n\nMeteor.startup ->\n sync_collections()", "source_lang": "", "target_lang": "CoffeeScript", "repo": "gterrono/houston", "path": "server/publications.coffee", "license": "MIT", "commit": "a2fcc5917a05b5e46e6a434ede172034f0cbcda7", "stars": 802, "source_url": "https://github.com/gterrono/houston/blob/a2fcc5917a05b5e46e6a434ede172034f0cbcda7/server/publications.coffee", "line_start": 54, "line_end": 98}854{"id": "gterrono/houston:server/publications.coffee:3:coffee_to_js", "type": "coffee_to_js", "prompt": "Convert this CoffeeScript to JavaScript.\n```coffeescript\nsync_collections = ->\n Dummy.findOne() # hack. TODO: verify this is still necessary\n\n _sync_collections = (meh, collections_db) ->\n collection_names = (col.collectionName for col in collections_db \\\n when (col.collectionName.indexOf \"system.\") isnt 0 and\n (col.collectionName.indexOf \"houston_\") isnt 0)\n\n collection_names.forEach (name) ->\n unless name of collections\n try\n collections[name] = new Meteor.Collection(name)\n catch e\n for key, value of root\n if name == value._name\n collections[name] = value\n console.log e unless collections[name]?\n setup_collection(name, collections[name])\n\n bound_sync_collections = Meteor.bindEnvironment _sync_collections, (e) ->\n console.log \"Failed while syncing collections for reason: #{e}\"\n\n # MongoInternals is the 'right' solution as of 0.6.5\n mongo_driver = MongoInternals?.defaultRemoteCollectionDriver() or Meteor._RemoteCollectionDriver\n mongo_driver.mongo.db.collections bound_sync_collections\n\nMeteor.methods\n _houston_make_admin: (user_id) ->\n # limit one admin\n return if Houston._admins.findOne {'user_id': $exists: true}\n Houston._admins.insert {user_id}\n sync_collections() # reloads collections in case of new app\n return true\n\n# publish our analysis of the app's collections\nHouston._publish 'collections', ->\n return unless Houston._user_is_admin @userId\n Houston._collections.collections.find()\n\n# TODO address inherent security issue\nHouston._publish 'admin_user', ->\n Houston._admins.find {}\n\nMeteor.startup ->\n sync_collections()\n```", "response": "var sync_collections;\n\nsync_collections = function() {\n var _sync_collections, bound_sync_collections, mongo_driver;\n Dummy.findOne(); // hack. TODO: verify this is still necessary\n _sync_collections = function(meh, collections_db) {\n var col, collection_names;\n collection_names = (function() {\n var i, len, results;\n results = [];\n for (i = 0, len = collections_db.length; i < len; i++) {\n col = collections_db[i];\n if ((col.collectionName.indexOf(\"system.\")) !== 0 && (col.collectionName.indexOf(\"houston_\")) !== 0) {\n results.push(col.collectionName);\n }\n }\n return results;\n })();\n return collection_names.forEach(function(name) {\n var e, key, value;\n if (!(name in collections)) {\n try {\n collections[name] = new Meteor.Collection(name);\n } catch (error) {\n e = error;\n for (key in root) {\n value = root[key];\n if (name === value._name) {\n collections[name] = value;\n }\n }\n if (collections[name] == null) {\n console.log(e);\n }\n }\n return setup_collection(name, collections[name]);\n }\n });\n };\n bound_sync_collections = Meteor.bindEnvironment(_sync_collections, function(e) {\n return console.log(`Failed while syncing collections for reason: ${e}`);\n });\n // MongoInternals is the 'right' solution as of 0.6.5\n mongo_driver = (typeof MongoInternals !== \"undefined\" && MongoInternals !== null ? MongoInternals.defaultRemoteCollectionDriver() : void 0) || Meteor._RemoteCollectionDriver;\n return mongo_driver.mongo.db.collections(bound_sync_collections);\n};\n\nMeteor.methods({\n _houston_make_admin: function(user_id) {\n // limit one admin\n if (Houston._admins.findOne({\n 'user_id': {\n $exists: true\n }\n })) {\n return;\n }\n Houston._admins.insert({user_id});\n sync_collections(); // reloads collections in case of new app\n return true;\n }\n});\n\n// publish our analysis of the app's collections\nHouston._publish('collections', function() {\n if (!Houston._user_is_admin(this.userId)) {\n return;\n }\n return Houston._collections.collections.find();\n});\n\n// TODO address inherent security issue\nHouston._publish('admin_user', function() {\n return Houston._admins.find({});\n});\n\nMeteor.startup(function() {\n return sync_collections();\n});", "source_lang": "CoffeeScript", "target_lang": "JavaScript", "repo": "gterrono/houston", "path": "server/publications.coffee", "license": "MIT", "commit": "a2fcc5917a05b5e46e6a434ede172034f0cbcda7", "stars": 802, "source_url": "https://github.com/gterrono/houston/blob/a2fcc5917a05b5e46e6a434ede172034f0cbcda7/server/publications.coffee", "line_start": 54, "line_end": 98}855{"id": "gterrono/houston:server/publications.coffee:3:js_to_coffee", "type": "js_to_coffee", "prompt": "Convert this JavaScript to CoffeeScript.\n```javascript\nvar sync_collections;\n\nsync_collections = function() {\n var _sync_collections, bound_sync_collections, mongo_driver;\n Dummy.findOne(); // hack. TODO: verify this is still necessary\n _sync_collections = function(meh, collections_db) {\n var col, collection_names;\n collection_names = (function() {\n var i, len, results;\n results = [];\n for (i = 0, len = collections_db.length; i < len; i++) {\n col = collections_db[i];\n if ((col.collectionName.indexOf(\"system.\")) !== 0 && (col.collectionName.indexOf(\"houston_\")) !== 0) {\n results.push(col.collectionName);\n }\n }\n return results;\n })();\n return collection_names.forEach(function(name) {\n var e, key, value;\n if (!(name in collections)) {\n try {\n collections[name] = new Meteor.Collection(name);\n } catch (error) {\n e = error;\n for (key in root) {\n value = root[key];\n if (name === value._name) {\n collections[name] = value;\n }\n }\n if (collections[name] == null) {\n console.log(e);\n }\n }\n return setup_collection(name, collections[name]);\n }\n });\n };\n bound_sync_collections = Meteor.bindEnvironment(_sync_collections, function(e) {\n return console.log(`Failed while syncing collections for reason: ${e}`);\n });\n // MongoInternals is the 'right' solution as of 0.6.5\n mongo_driver = (typeof MongoInternals !== \"undefined\" && MongoInternals !== null ? MongoInternals.defaultRemoteCollectionDriver() : void 0) || Meteor._RemoteCollectionDriver;\n return mongo_driver.mongo.db.collections(bound_sync_collections);\n};\n\nMeteor.methods({\n _houston_make_admin: function(user_id) {\n // limit one admin\n if (Houston._admins.findOne({\n 'user_id': {\n $exists: true\n }\n })) {\n return;\n }\n Houston._admins.insert({user_id});\n sync_collections(); // reloads collections in case of new app\n return true;\n }\n});\n\n// publish our analysis of the app's collections\nHouston._publish('collections', function() {\n if (!Houston._user_is_admin(this.userId)) {\n return;\n }\n return Houston._collections.collections.find();\n});\n\n// TODO address inherent security issue\nHouston._publish('admin_user', function() {\n return Houston._admins.find({});\n});\n\nMeteor.startup(function() {\n return sync_collections();\n});\n```", "response": "sync_collections = ->\n Dummy.findOne() # hack. TODO: verify this is still necessary\n\n _sync_collections = (meh, collections_db) ->\n collection_names = (col.collectionName for col in collections_db \\\n when (col.collectionName.indexOf \"system.\") isnt 0 and\n (col.collectionName.indexOf \"houston_\") isnt 0)\n\n collection_names.forEach (name) ->\n unless name of collections\n try\n collections[name] = new Meteor.Collection(name)\n catch e\n for key, value of root\n if name == value._name\n collections[name] = value\n console.log e unless collections[name]?\n setup_collection(name, collections[name])\n\n bound_sync_collections = Meteor.bindEnvironment _sync_collections, (e) ->\n console.log \"Failed while syncing collections for reason: #{e}\"\n\n # MongoInternals is the 'right' solution as of 0.6.5\n mongo_driver = MongoInternals?.defaultRemoteCollectionDriver() or Meteor._RemoteCollectionDriver\n mongo_driver.mongo.db.collections bound_sync_collections\n\nMeteor.methods\n _houston_make_admin: (user_id) ->\n # limit one admin\n return if Houston._admins.findOne {'user_id': $exists: true}\n Houston._admins.insert {user_id}\n sync_collections() # reloads collections in case of new app\n return true\n\n# publish our analysis of the app's collections\nHouston._publish 'collections', ->\n return unless Houston._user_is_admin @userId\n Houston._collections.collections.find()\n\n# TODO address inherent security issue\nHouston._publish 'admin_user', ->\n Houston._admins.find {}\n\nMeteor.startup ->\n sync_collections()", "source_lang": "JavaScript", "target_lang": "CoffeeScript", "repo": "gterrono/houston", "path": "server/publications.coffee", "license": "MIT", "commit": "a2fcc5917a05b5e46e6a434ede172034f0cbcda7", "stars": 802, "source_url": "https://github.com/gterrono/houston/blob/a2fcc5917a05b5e46e6a434ede172034f0cbcda7/server/publications.coffee", "line_start": 54, "line_end": 98}856{"id": "gterrono/houston:server/publications.coffee:3:completion", "type": "completion", "prompt": "sync_collections = ->\n Dummy.findOne() # hack. TODO: verify this is still necessary\n\n _sync_collections = (meh, collections_db) ->\n collection_names = (col.collectionName for col in collections_db \\\n when (col.collectionName.indexOf \"system.\") isnt 0 and\n (col.collectionName.indexOf \"houston_\") isnt 0)\n\n collection_names.forEach (name) ->\n unless name of collections\n try\n collections[name] = new Meteor.Collection(name)\n catch e\n for key, value of root\n if name == value._name\n collections[name] = value\n console.log e unless collections[name]?\n setup_collection(name, collections[name])\n\n bound_sync_collections = Meteor.bindEnvironment _sync_collections, (e) ->\n console.log \"Failed while syncing collections for reason: #{e}\"", "response": "# MongoInternals is the 'right' solution as of 0.6.5\n mongo_driver = MongoInternals?.defaultRemoteCollectionDriver() or Meteor._RemoteCollectionDriver\n mongo_driver.mongo.db.collections bound_sync_collections\n\nMeteor.methods\n _houston_make_admin: (user_id) ->\n # limit one admin\n return if Houston._admins.findOne {'user_id': $exists: true}\n Houston._admins.insert {user_id}\n sync_collections() # reloads collections in case of new app\n return true\n\n# publish our analysis of the app's collections\nHouston._publish 'collections', ->\n return unless Houston._user_is_admin @userId\n Houston._collections.collections.find()\n\n# TODO address inherent security issue\nHouston._publish 'admin_user', ->\n Houston._admins.find {}\n\nMeteor.startup ->\n sync_collections()", "source_lang": "CoffeeScript", "target_lang": "CoffeeScript", "repo": "gterrono/houston", "path": "server/publications.coffee", "license": "MIT", "commit": "a2fcc5917a05b5e46e6a434ede172034f0cbcda7", "stars": 802, "source_url": "https://github.com/gterrono/houston/blob/a2fcc5917a05b5e46e6a434ede172034f0cbcda7/server/publications.coffee", "line_start": 54, "line_end": 98}857{"id": "gterrono/houston:server/publications.coffee:3:raw_corpus", "type": "raw_corpus", "prompt": "", "response": "sync_collections = ->\n Dummy.findOne() # hack. TODO: verify this is still necessary\n\n _sync_collections = (meh, collections_db) ->\n collection_names = (col.collectionName for col in collections_db \\\n when (col.collectionName.indexOf \"system.\") isnt 0 and\n (col.collectionName.indexOf \"houston_\") isnt 0)\n\n collection_names.forEach (name) ->\n unless name of collections\n try\n collections[name] = new Meteor.Collection(name)\n catch e\n for key, value of root\n if name == value._name\n collections[name] = value\n console.log e unless collections[name]?\n setup_collection(name, collections[name])\n\n bound_sync_collections = Meteor.bindEnvironment _sync_collections, (e) ->\n console.log \"Failed while syncing collections for reason: #{e}\"\n\n # MongoInternals is the 'right' solution as of 0.6.5\n mongo_driver = MongoInternals?.defaultRemoteCollectionDriver() or Meteor._RemoteCollectionDriver\n mongo_driver.mongo.db.collections bound_sync_collections\n\nMeteor.startup ->\n sync_collections()\n\nMeteor.methods\n _houston_make_admin: (userId) ->\n # limit one admin\n return if Houston._admins.findOne {'user_id': $exists: true}\n Houston._admins.insert user_id: userId\n sync_collections() # reloads collections in case of new app\n return true\n\n# publish our analysis of the app's collections\nHouston._publish 'collections', ->\n return unless Houston._user_is_admin @userId\n Houston._collections.collections.find()\n\n# used by login page to see if admin has been created yet\nHouston._publish 'admin_user', ->\n if Houston._user_is_admin @userId\n return Houston._admins.find user_id: @userId\n Houston._admins.find {user_id: $exists: true}, fields: _id: true", "source_lang": "", "target_lang": "CoffeeScript", "repo": "gterrono/houston", "path": "server/publications.coffee", "license": "MIT", "commit": "b872b6d21b080b40715e3478e83a6ffd22f83b73", "stars": 802, "source_url": "https://github.com/gterrono/houston/blob/b872b6d21b080b40715e3478e83a6ffd22f83b73/server/publications.coffee", "line_start": 54, "line_end": 100}858{"id": "gterrono/houston:server/publications.coffee:3:coffee_to_js", "type": "coffee_to_js", "prompt": "Convert this CoffeeScript to JavaScript.\n```coffeescript\nsync_collections = ->\n Dummy.findOne() # hack. TODO: verify this is still necessary\n\n _sync_collections = (meh, collections_db) ->\n collection_names = (col.collectionName for col in collections_db \\\n when (col.collectionName.indexOf \"system.\") isnt 0 and\n (col.collectionName.indexOf \"houston_\") isnt 0)\n\n collection_names.forEach (name) ->\n unless name of collections\n try\n collections[name] = new Meteor.Collection(name)\n catch e\n for key, value of root\n if name == value._name\n collections[name] = value\n console.log e unless collections[name]?\n setup_collection(name, collections[name])\n\n bound_sync_collections = Meteor.bindEnvironment _sync_collections, (e) ->\n console.log \"Failed while syncing collections for reason: #{e}\"\n\n # MongoInternals is the 'right' solution as of 0.6.5\n mongo_driver = MongoInternals?.defaultRemoteCollectionDriver() or Meteor._RemoteCollectionDriver\n mongo_driver.mongo.db.collections bound_sync_collections\n\nMeteor.startup ->\n sync_collections()\n\nMeteor.methods\n _houston_make_admin: (userId) ->\n # limit one admin\n return if Houston._admins.findOne {'user_id': $exists: true}\n Houston._admins.insert user_id: userId\n sync_collections() # reloads collections in case of new app\n return true\n\n# publish our analysis of the app's collections\nHouston._publish 'collections', ->\n return unless Houston._user_is_admin @userId\n Houston._collections.collections.find()\n\n# used by login page to see if admin has been created yet\nHouston._publish 'admin_user', ->\n if Houston._user_is_admin @userId\n return Houston._admins.find user_id: @userId\n Houston._admins.find {user_id: $exists: true}, fields: _id: true\n```", "response": "var sync_collections;\n\nsync_collections = function() {\n var _sync_collections, bound_sync_collections, mongo_driver;\n Dummy.findOne(); // hack. TODO: verify this is still necessary\n _sync_collections = function(meh, collections_db) {\n var col, collection_names;\n collection_names = (function() {\n var i, len, results;\n results = [];\n for (i = 0, len = collections_db.length; i < len; i++) {\n col = collections_db[i];\n if ((col.collectionName.indexOf(\"system.\")) !== 0 && (col.collectionName.indexOf(\"houston_\")) !== 0) {\n results.push(col.collectionName);\n }\n }\n return results;\n })();\n return collection_names.forEach(function(name) {\n var e, key, value;\n if (!(name in collections)) {\n try {\n collections[name] = new Meteor.Collection(name);\n } catch (error) {\n e = error;\n for (key in root) {\n value = root[key];\n if (name === value._name) {\n collections[name] = value;\n }\n }\n if (collections[name] == null) {\n console.log(e);\n }\n }\n return setup_collection(name, collections[name]);\n }\n });\n };\n bound_sync_collections = Meteor.bindEnvironment(_sync_collections, function(e) {\n return console.log(`Failed while syncing collections for reason: ${e}`);\n });\n // MongoInternals is the 'right' solution as of 0.6.5\n mongo_driver = (typeof MongoInternals !== \"undefined\" && MongoInternals !== null ? MongoInternals.defaultRemoteCollectionDriver() : void 0) || Meteor._RemoteCollectionDriver;\n return mongo_driver.mongo.db.collections(bound_sync_collections);\n};\n\nMeteor.startup(function() {\n return sync_collections();\n});\n\nMeteor.methods({\n _houston_make_admin: function(userId) {\n // limit one admin\n if (Houston._admins.findOne({\n 'user_id': {\n $exists: true\n }\n })) {\n return;\n }\n Houston._admins.insert({\n user_id: userId\n });\n sync_collections(); // reloads collections in case of new app\n return true;\n }\n});\n\n// publish our analysis of the app's collections\nHouston._publish('collections', function() {\n if (!Houston._user_is_admin(this.userId)) {\n return;\n }\n return Houston._collections.collections.find();\n});\n\n// used by login page to see if admin has been created yet\nHouston._publish('admin_user', function() {\n if (Houston._user_is_admin(this.userId)) {\n return Houston._admins.find({\n user_id: this.userId\n });\n }\n return Houston._admins.find({\n user_id: {\n $exists: true\n }\n }, {\n fields: {\n _id: true\n }\n });\n});", "source_lang": "CoffeeScript", "target_lang": "JavaScript", "repo": "gterrono/houston", "path": "server/publications.coffee", "license": "MIT", "commit": "b872b6d21b080b40715e3478e83a6ffd22f83b73", "stars": 802, "source_url": "https://github.com/gterrono/houston/blob/b872b6d21b080b40715e3478e83a6ffd22f83b73/server/publications.coffee", "line_start": 54, "line_end": 100}859{"id": "gterrono/houston:server/publications.coffee:3:js_to_coffee", "type": "js_to_coffee", "prompt": "Convert this JavaScript to CoffeeScript.\n```javascript\nvar sync_collections;\n\nsync_collections = function() {\n var _sync_collections, bound_sync_collections, mongo_driver;\n Dummy.findOne(); // hack. TODO: verify this is still necessary\n _sync_collections = function(meh, collections_db) {\n var col, collection_names;\n collection_names = (function() {\n var i, len, results;\n results = [];\n for (i = 0, len = collections_db.length; i < len; i++) {\n col = collections_db[i];\n if ((col.collectionName.indexOf(\"system.\")) !== 0 && (col.collectionName.indexOf(\"houston_\")) !== 0) {\n results.push(col.collectionName);\n }\n }\n return results;\n })();\n return collection_names.forEach(function(name) {\n var e, key, value;\n if (!(name in collections)) {\n try {\n collections[name] = new Meteor.Collection(name);\n } catch (error) {\n e = error;\n for (key in root) {\n value = root[key];\n if (name === value._name) {\n collections[name] = value;\n }\n }\n if (collections[name] == null) {\n console.log(e);\n }\n }\n return setup_collection(name, collections[name]);\n }\n });\n };\n bound_sync_collections = Meteor.bindEnvironment(_sync_collections, function(e) {\n return console.log(`Failed while syncing collections for reason: ${e}`);\n });\n // MongoInternals is the 'right' solution as of 0.6.5\n mongo_driver = (typeof MongoInternals !== \"undefined\" && MongoInternals !== null ? MongoInternals.defaultRemoteCollectionDriver() : void 0) || Meteor._RemoteCollectionDriver;\n return mongo_driver.mongo.db.collections(bound_sync_collections);\n};\n\nMeteor.startup(function() {\n return sync_collections();\n});\n\nMeteor.methods({\n _houston_make_admin: function(userId) {\n // limit one admin\n if (Houston._admins.findOne({\n 'user_id': {\n $exists: true\n }\n })) {\n return;\n }\n Houston._admins.insert({\n user_id: userId\n });\n sync_collections(); // reloads collections in case of new app\n return true;\n }\n});\n\n// publish our analysis of the app's collections\nHouston._publish('collections', function() {\n if (!Houston._user_is_admin(this.userId)) {\n return;\n }\n return Houston._collections.collections.find();\n});\n\n// used by login page to see if admin has been created yet\nHouston._publish('admin_user', function() {\n if (Houston._user_is_admin(this.userId)) {\n return Houston._admins.find({\n user_id: this.userId\n });\n }\n return Houston._admins.find({\n user_id: {\n $exists: true\n }\n }, {\n fields: {\n _id: true\n }\n });\n});\n```", "response": "sync_collections = ->\n Dummy.findOne() # hack. TODO: verify this is still necessary\n\n _sync_collections = (meh, collections_db) ->\n collection_names = (col.collectionName for col in collections_db \\\n when (col.collectionName.indexOf \"system.\") isnt 0 and\n (col.collectionName.indexOf \"houston_\") isnt 0)\n\n collection_names.forEach (name) ->\n unless name of collections\n try\n collections[name] = new Meteor.Collection(name)\n catch e\n for key, value of root\n if name == value._name\n collections[name] = value\n console.log e unless collections[name]?\n setup_collection(name, collections[name])\n\n bound_sync_collections = Meteor.bindEnvironment _sync_collections, (e) ->\n console.log \"Failed while syncing collections for reason: #{e}\"\n\n # MongoInternals is the 'right' solution as of 0.6.5\n mongo_driver = MongoInternals?.defaultRemoteCollectionDriver() or Meteor._RemoteCollectionDriver\n mongo_driver.mongo.db.collections bound_sync_collections\n\nMeteor.startup ->\n sync_collections()\n\nMeteor.methods\n _houston_make_admin: (userId) ->\n # limit one admin\n return if Houston._admins.findOne {'user_id': $exists: true}\n Houston._admins.insert user_id: userId\n sync_collections() # reloads collections in case of new app\n return true\n\n# publish our analysis of the app's collections\nHouston._publish 'collections', ->\n return unless Houston._user_is_admin @userId\n Houston._collections.collections.find()\n\n# used by login page to see if admin has been created yet\nHouston._publish 'admin_user', ->\n if Houston._user_is_admin @userId\n return Houston._admins.find user_id: @userId\n Houston._admins.find {user_id: $exists: true}, fields: _id: true", "source_lang": "JavaScript", "target_lang": "CoffeeScript", "repo": "gterrono/houston", "path": "server/publications.coffee", "license": "MIT", "commit": "b872b6d21b080b40715e3478e83a6ffd22f83b73", "stars": 802, "source_url": "https://github.com/gterrono/houston/blob/b872b6d21b080b40715e3478e83a6ffd22f83b73/server/publications.coffee", "line_start": 54, "line_end": 100}860{"id": "gterrono/houston:server/publications.coffee:3:completion", "type": "completion", "prompt": "sync_collections = ->\n Dummy.findOne() # hack. TODO: verify this is still necessary\n\n _sync_collections = (meh, collections_db) ->\n collection_names = (col.collectionName for col in collections_db \\\n when (col.collectionName.indexOf \"system.\") isnt 0 and\n (col.collectionName.indexOf \"houston_\") isnt 0)\n\n collection_names.forEach (name) ->\n unless name of collections\n try\n collections[name] = new Meteor.Collection(name)\n catch e\n for key, value of root\n if name == value._name\n collections[name] = value\n console.log e unless collections[name]?\n setup_collection(name, collections[name])\n\n bound_sync_collections = Meteor.bindEnvironment _sync_collections, (e) ->\n console.log \"Failed while syncing collections for reason: #{e}\"\n\n # MongoInternals is the 'right' solution as of 0.6.5", "response": "mongo_driver = MongoInternals?.defaultRemoteCollectionDriver() or Meteor._RemoteCollectionDriver\n mongo_driver.mongo.db.collections bound_sync_collections\n\nMeteor.startup ->\n sync_collections()\n\nMeteor.methods\n _houston_make_admin: (userId) ->\n # limit one admin\n return if Houston._admins.findOne {'user_id': $exists: true}\n Houston._admins.insert user_id: userId\n sync_collections() # reloads collections in case of new app\n return true\n\n# publish our analysis of the app's collections\nHouston._publish 'collections', ->\n return unless Houston._user_is_admin @userId\n Houston._collections.collections.find()\n\n# used by login page to see if admin has been created yet\nHouston._publish 'admin_user', ->\n if Houston._user_is_admin @userId\n return Houston._admins.find user_id: @userId\n Houston._admins.find {user_id: $exists: true}, fields: _id: true", "source_lang": "CoffeeScript", "target_lang": "CoffeeScript", "repo": "gterrono/houston", "path": "server/publications.coffee", "license": "MIT", "commit": "b872b6d21b080b40715e3478e83a6ffd22f83b73", "stars": 802, "source_url": "https://github.com/gterrono/houston/blob/b872b6d21b080b40715e3478e83a6ffd22f83b73/server/publications.coffee", "line_start": 54, "line_end": 100}861{"id": "gterrono/houston:server/publications.coffee:2:raw_corpus", "type": "raw_corpus", "prompt": "", "response": "setup_collection = (name, collection) ->\n methods = {}\n methods[Houston._houstonize \"#{name}_insert\"] = (doc) ->\n return unless Houston._user_is_admin @userId\n collection.insert(doc)\n\n methods[Houston._houstonize \"#{name}_update\"] = (id, update_dict) ->\n return unless Houston._user_is_admin @userId\n if collection.findOne(id)\n collection.update(id, update_dict)\n else\n id = collection.findOne(new Meteor.Collection.ObjectID(id))\n collection.update(id, update_dict)\n\n methods[Houston._houstonize \"#{name}_delete\"] = (id, update_dict) ->\n return unless Houston._user_is_admin @userId\n if collection.findOne(id)\n collection.remove(id)\n else\n id = collection.findOne(new Meteor.Collection.ObjectID(id))\n collection.remove(id)\n\n Meteor.methods methods\n\n Houston._publish name, (sort, filter, limit) ->\n return unless Houston._user_is_admin @userId\n try\n collection.find(filter, sort: sort, limit: limit)\n catch e\n console.log e\n\n collection.find().observe\n added: (document) ->\n Houston._collections.collections.update {name},\n $inc: {count: 1},\n $addToSet: fields: $each: Houston._get_field_names([document])\n removed: (document) -> Houston._collections.collections.update {name}, {$inc: {count: -1}}\n\n fields = Houston._get_field_names(collection.find().fetch())\n c = Houston._collections.collections.findOne {name}\n if c\n Houston._collections.collections.update c._id, {$set: count: collection.find().count(), fields: fields}\n else\n Houston._collections.collections.insert {name, count: collection.find().count(), fields: fields}\n console.log \"synced #{name}\"\n\ncollections = {'users': Meteor.users} #TODO verify this is still relevant", "source_lang": "", "target_lang": "CoffeeScript", "repo": "gterrono/houston", "path": "server/publications.coffee", "license": "MIT", "commit": "9036c3045bf008d08dc4ffef1717965986a8cc33", "stars": 802, "source_url": "https://github.com/gterrono/houston/blob/9036c3045bf008d08dc4ffef1717965986a8cc33/server/publications.coffee", "line_start": 8, "line_end": 54}862{"id": "gterrono/houston:server/publications.coffee:2:coffee_to_js", "type": "coffee_to_js", "prompt": "Convert this CoffeeScript to JavaScript.\n```coffeescript\nsetup_collection = (name, collection) ->\n methods = {}\n methods[Houston._houstonize \"#{name}_insert\"] = (doc) ->\n return unless Houston._user_is_admin @userId\n collection.insert(doc)\n\n methods[Houston._houstonize \"#{name}_update\"] = (id, update_dict) ->\n return unless Houston._user_is_admin @userId\n if collection.findOne(id)\n collection.update(id, update_dict)\n else\n id = collection.findOne(new Meteor.Collection.ObjectID(id))\n collection.update(id, update_dict)\n\n methods[Houston._houstonize \"#{name}_delete\"] = (id, update_dict) ->\n return unless Houston._user_is_admin @userId\n if collection.findOne(id)\n collection.remove(id)\n else\n id = collection.findOne(new Meteor.Collection.ObjectID(id))\n collection.remove(id)\n\n Meteor.methods methods\n\n Houston._publish name, (sort, filter, limit) ->\n return unless Houston._user_is_admin @userId\n try\n collection.find(filter, sort: sort, limit: limit)\n catch e\n console.log e\n\n collection.find().observe\n added: (document) ->\n Houston._collections.collections.update {name},\n $inc: {count: 1},\n $addToSet: fields: $each: Houston._get_field_names([document])\n removed: (document) -> Houston._collections.collections.update {name}, {$inc: {count: -1}}\n\n fields = Houston._get_field_names(collection.find().fetch())\n c = Houston._collections.collections.findOne {name}\n if c\n Houston._collections.collections.update c._id, {$set: count: collection.find().count(), fields: fields}\n else\n Houston._collections.collections.insert {name, count: collection.find().count(), fields: fields}\n console.log \"synced #{name}\"\n\ncollections = {'users': Meteor.users} #TODO verify this is still relevant\n```", "response": "var collections, setup_collection;\n\nsetup_collection = function(name, collection) {\n var c, fields, methods;\n methods = {};\n methods[Houston._houstonize(`${name}_insert`)] = function(doc) {\n if (!Houston._user_is_admin(this.userId)) {\n return;\n }\n return collection.insert(doc);\n };\n methods[Houston._houstonize(`${name}_update`)] = function(id, update_dict) {\n if (!Houston._user_is_admin(this.userId)) {\n return;\n }\n if (collection.findOne(id)) {\n return collection.update(id, update_dict);\n } else {\n id = collection.findOne(new Meteor.Collection.ObjectID(id));\n return collection.update(id, update_dict);\n }\n };\n methods[Houston._houstonize(`${name}_delete`)] = function(id, update_dict) {\n if (!Houston._user_is_admin(this.userId)) {\n return;\n }\n if (collection.findOne(id)) {\n return collection.remove(id);\n } else {\n id = collection.findOne(new Meteor.Collection.ObjectID(id));\n return collection.remove(id);\n }\n };\n Meteor.methods(methods);\n Houston._publish(name, function(sort, filter, limit) {\n var e;\n if (!Houston._user_is_admin(this.userId)) {\n return;\n }\n try {\n return collection.find(filter, {\n sort: sort,\n limit: limit\n });\n } catch (error) {\n e = error;\n return console.log(e);\n }\n });\n collection.find().observe({\n added: function(document) {\n return Houston._collections.collections.update({name}, {\n $inc: {\n count: 1\n },\n $addToSet: {\n fields: {\n $each: Houston._get_field_names([document])\n }\n }\n });\n },\n removed: function(document) {\n return Houston._collections.collections.update({name}, {\n $inc: {\n count: -1\n }\n });\n }\n });\n fields = Houston._get_field_names(collection.find().fetch());\n c = Houston._collections.collections.findOne({name});\n if (c) {\n Houston._collections.collections.update(c._id, {\n $set: {\n count: collection.find().count(),\n fields: fields\n }\n });\n } else {\n Houston._collections.collections.insert({\n name,\n count: collection.find().count(),\n fields: fields\n });\n }\n return console.log(`synced ${name}`);\n};\n\ncollections = {\n 'users': Meteor.users //TODO verify this is still relevant\n};", "source_lang": "CoffeeScript", "target_lang": "JavaScript", "repo": "gterrono/houston", "path": "server/publications.coffee", "license": "MIT", "commit": "9036c3045bf008d08dc4ffef1717965986a8cc33", "stars": 802, "source_url": "https://github.com/gterrono/houston/blob/9036c3045bf008d08dc4ffef1717965986a8cc33/server/publications.coffee", "line_start": 8, "line_end": 54}863{"id": "gterrono/houston:server/publications.coffee:2:js_to_coffee", "type": "js_to_coffee", "prompt": "Convert this JavaScript to CoffeeScript.\n```javascript\nvar collections, setup_collection;\n\nsetup_collection = function(name, collection) {\n var c, fields, methods;\n methods = {};\n methods[Houston._houstonize(`${name}_insert`)] = function(doc) {\n if (!Houston._user_is_admin(this.userId)) {\n return;\n }\n return collection.insert(doc);\n };\n methods[Houston._houstonize(`${name}_update`)] = function(id, update_dict) {\n if (!Houston._user_is_admin(this.userId)) {\n return;\n }\n if (collection.findOne(id)) {\n return collection.update(id, update_dict);\n } else {\n id = collection.findOne(new Meteor.Collection.ObjectID(id));\n return collection.update(id, update_dict);\n }\n };\n methods[Houston._houstonize(`${name}_delete`)] = function(id, update_dict) {\n if (!Houston._user_is_admin(this.userId)) {\n return;\n }\n if (collection.findOne(id)) {\n return collection.remove(id);\n } else {\n id = collection.findOne(new Meteor.Collection.ObjectID(id));\n return collection.remove(id);\n }\n };\n Meteor.methods(methods);\n Houston._publish(name, function(sort, filter, limit) {\n var e;\n if (!Houston._user_is_admin(this.userId)) {\n return;\n }\n try {\n return collection.find(filter, {\n sort: sort,\n limit: limit\n });\n } catch (error) {\n e = error;\n return console.log(e);\n }\n });\n collection.find().observe({\n added: function(document) {\n return Houston._collections.collections.update({name}, {\n $inc: {\n count: 1\n },\n $addToSet: {\n fields: {\n $each: Houston._get_field_names([document])\n }\n }\n });\n },\n removed: function(document) {\n return Houston._collections.collections.update({name}, {\n $inc: {\n count: -1\n }\n });\n }\n });\n fields = Houston._get_field_names(collection.find().fetch());\n c = Houston._collections.collections.findOne({name});\n if (c) {\n Houston._collections.collections.update(c._id, {\n $set: {\n count: collection.find().count(),\n fields: fields\n }\n });\n } else {\n Houston._collections.collections.insert({\n name,\n count: collection.find().count(),\n fields: fields\n });\n }\n return console.log(`synced ${name}`);\n};\n\ncollections = {\n 'users': Meteor.users //TODO verify this is still relevant\n};\n```", "response": "setup_collection = (name, collection) ->\n methods = {}\n methods[Houston._houstonize \"#{name}_insert\"] = (doc) ->\n return unless Houston._user_is_admin @userId\n collection.insert(doc)\n\n methods[Houston._houstonize \"#{name}_update\"] = (id, update_dict) ->\n return unless Houston._user_is_admin @userId\n if collection.findOne(id)\n collection.update(id, update_dict)\n else\n id = collection.findOne(new Meteor.Collection.ObjectID(id))\n collection.update(id, update_dict)\n\n methods[Houston._houstonize \"#{name}_delete\"] = (id, update_dict) ->\n return unless Houston._user_is_admin @userId\n if collection.findOne(id)\n collection.remove(id)\n else\n id = collection.findOne(new Meteor.Collection.ObjectID(id))\n collection.remove(id)\n\n Meteor.methods methods\n\n Houston._publish name, (sort, filter, limit) ->\n return unless Houston._user_is_admin @userId\n try\n collection.find(filter, sort: sort, limit: limit)\n catch e\n console.log e\n\n collection.find().observe\n added: (document) ->\n Houston._collections.collections.update {name},\n $inc: {count: 1},\n $addToSet: fields: $each: Houston._get_field_names([document])\n removed: (document) -> Houston._collections.collections.update {name}, {$inc: {count: -1}}\n\n fields = Houston._get_field_names(collection.find().fetch())\n c = Houston._collections.collections.findOne {name}\n if c\n Houston._collections.collections.update c._id, {$set: count: collection.find().count(), fields: fields}\n else\n Houston._collections.collections.insert {name, count: collection.find().count(), fields: fields}\n console.log \"synced #{name}\"\n\ncollections = {'users': Meteor.users} #TODO verify this is still relevant", "source_lang": "JavaScript", "target_lang": "CoffeeScript", "repo": "gterrono/houston", "path": "server/publications.coffee", "license": "MIT", "commit": "9036c3045bf008d08dc4ffef1717965986a8cc33", "stars": 802, "source_url": "https://github.com/gterrono/houston/blob/9036c3045bf008d08dc4ffef1717965986a8cc33/server/publications.coffee", "line_start": 8, "line_end": 54}864{"id": "gterrono/houston:server/publications.coffee:2:completion", "type": "completion", "prompt": "setup_collection = (name, collection) ->\n methods = {}\n methods[Houston._houstonize \"#{name}_insert\"] = (doc) ->\n return unless Houston._user_is_admin @userId\n collection.insert(doc)\n\n methods[Houston._houstonize \"#{name}_update\"] = (id, update_dict) ->\n return unless Houston._user_is_admin @userId\n if collection.findOne(id)\n collection.update(id, update_dict)\n else\n id = collection.findOne(new Meteor.Collection.ObjectID(id))\n collection.update(id, update_dict)\n\n methods[Houston._houstonize \"#{name}_delete\"] = (id, update_dict) ->\n return unless Houston._user_is_admin @userId\n if collection.findOne(id)\n collection.remove(id)\n else\n id = collection.findOne(new Meteor.Collection.ObjectID(id))\n collection.remove(id)\n\n Meteor.methods methods", "response": "Houston._publish name, (sort, filter, limit) ->\n return unless Houston._user_is_admin @userId\n try\n collection.find(filter, sort: sort, limit: limit)\n catch e\n console.log e\n\n collection.find().observe\n added: (document) ->\n Houston._collections.collections.update {name},\n $inc: {count: 1},\n $addToSet: fields: $each: Houston._get_field_names([document])\n removed: (document) -> Houston._collections.collections.update {name}, {$inc: {count: -1}}\n\n fields = Houston._get_field_names(collection.find().fetch())\n c = Houston._collections.collections.findOne {name}\n if c\n Houston._collections.collections.update c._id, {$set: count: collection.find().count(), fields: fields}\n else\n Houston._collections.collections.insert {name, count: collection.find().count(), fields: fields}\n console.log \"synced #{name}\"\n\ncollections = {'users': Meteor.users} #TODO verify this is still relevant", "source_lang": "CoffeeScript", "target_lang": "CoffeeScript", "repo": "gterrono/houston", "path": "server/publications.coffee", "license": "MIT", "commit": "9036c3045bf008d08dc4ffef1717965986a8cc33", "stars": 802, "source_url": "https://github.com/gterrono/houston/blob/9036c3045bf008d08dc4ffef1717965986a8cc33/server/publications.coffee", "line_start": 8, "line_end": 54}865{"id": "gterrono/houston:server/publications.coffee:3:raw_corpus", "type": "raw_corpus", "prompt": "", "response": "sync_collections = ->\n Dummy.findOne() # hack. TODO: verify this is still necessary\n\n _sync_collections = (meh, collections_db) ->\n collection_names = (col.collectionName for col in collections_db \\\n when (col.collectionName.indexOf \"system.\") isnt 0 and\n (col.collectionName.indexOf \"houston_\") isnt 0)\n\n collection_names.forEach (name) ->\n unless name of collections\n try\n collections[name] = new Meteor.Collection(name)\n catch e\n for key, value of root\n if name == value._name\n collections[name] = value\n console.log e unless collections[name]?\n setup_collection(name, collections[name])\n console.log \"sync collections done\"\n\n bound_sync_collections = Meteor.bindEnvironment _sync_collections, (e) ->\n console.log \"Failed while syncing collections for reason: #{e}\"\n\n # MongoInternals is the 'right' solution as of 0.6.5\n mongo_driver = MongoInternals?.defaultRemoteCollectionDriver() or Meteor._RemoteCollectionDriver\n mongo_driver.mongo.db.collections bound_sync_collections\n\nMeteor.startup ->\n sync_collections()\n\nMeteor.methods\n _houston_make_admin: (userId) ->\n # limit one admin\n return if Houston._admins.findOne {'user_id': $exists: true}\n Houston._admins.insert user_id: userId\n sync_collections() # reloads collections in case of new app\n return true\n\n# publish our analysis of the app's collections\nHouston._publish 'collections', ->\n return unless Houston._user_is_admin @userId\n Houston._collections.collections.find()\n\n# used by login page to see if admin has been created yet\nHouston._publish 'admin_user', ->\n if Houston._user_is_admin @userId\n return Houston._admins.find user_id: @userId\n Houston._admins.find {user_id: $exists: true}, fields: _id: true", "source_lang": "", "target_lang": "CoffeeScript", "repo": "gterrono/houston", "path": "server/publications.coffee", "license": "MIT", "commit": "9036c3045bf008d08dc4ffef1717965986a8cc33", "stars": 802, "source_url": "https://github.com/gterrono/houston/blob/9036c3045bf008d08dc4ffef1717965986a8cc33/server/publications.coffee", "line_start": 55, "line_end": 102}866{"id": "gterrono/houston:server/publications.coffee:3:coffee_to_js", "type": "coffee_to_js", "prompt": "Convert this CoffeeScript to JavaScript.\n```coffeescript\nsync_collections = ->\n Dummy.findOne() # hack. TODO: verify this is still necessary\n\n _sync_collections = (meh, collections_db) ->\n collection_names = (col.collectionName for col in collections_db \\\n when (col.collectionName.indexOf \"system.\") isnt 0 and\n (col.collectionName.indexOf \"houston_\") isnt 0)\n\n collection_names.forEach (name) ->\n unless name of collections\n try\n collections[name] = new Meteor.Collection(name)\n catch e\n for key, value of root\n if name == value._name\n collections[name] = value\n console.log e unless collections[name]?\n setup_collection(name, collections[name])\n console.log \"sync collections done\"\n\n bound_sync_collections = Meteor.bindEnvironment _sync_collections, (e) ->\n console.log \"Failed while syncing collections for reason: #{e}\"\n\n # MongoInternals is the 'right' solution as of 0.6.5\n mongo_driver = MongoInternals?.defaultRemoteCollectionDriver() or Meteor._RemoteCollectionDriver\n mongo_driver.mongo.db.collections bound_sync_collections\n\nMeteor.startup ->\n sync_collections()\n\nMeteor.methods\n _houston_make_admin: (userId) ->\n # limit one admin\n return if Houston._admins.findOne {'user_id': $exists: true}\n Houston._admins.insert user_id: userId\n sync_collections() # reloads collections in case of new app\n return true\n\n# publish our analysis of the app's collections\nHouston._publish 'collections', ->\n return unless Houston._user_is_admin @userId\n Houston._collections.collections.find()\n\n# used by login page to see if admin has been created yet\nHouston._publish 'admin_user', ->\n if Houston._user_is_admin @userId\n return Houston._admins.find user_id: @userId\n Houston._admins.find {user_id: $exists: true}, fields: _id: true\n```", "response": "var sync_collections;\n\nsync_collections = function() {\n var _sync_collections, bound_sync_collections, mongo_driver;\n Dummy.findOne(); // hack. TODO: verify this is still necessary\n _sync_collections = function(meh, collections_db) {\n var col, collection_names;\n collection_names = (function() {\n var i, len, results;\n results = [];\n for (i = 0, len = collections_db.length; i < len; i++) {\n col = collections_db[i];\n if ((col.collectionName.indexOf(\"system.\")) !== 0 && (col.collectionName.indexOf(\"houston_\")) !== 0) {\n results.push(col.collectionName);\n }\n }\n return results;\n })();\n collection_names.forEach(function(name) {\n var e, key, value;\n if (!(name in collections)) {\n try {\n collections[name] = new Meteor.Collection(name);\n } catch (error) {\n e = error;\n for (key in root) {\n value = root[key];\n if (name === value._name) {\n collections[name] = value;\n }\n }\n if (collections[name] == null) {\n console.log(e);\n }\n }\n return setup_collection(name, collections[name]);\n }\n });\n return console.log(\"sync collections done\");\n };\n bound_sync_collections = Meteor.bindEnvironment(_sync_collections, function(e) {\n return console.log(`Failed while syncing collections for reason: ${e}`);\n });\n // MongoInternals is the 'right' solution as of 0.6.5\n mongo_driver = (typeof MongoInternals !== \"undefined\" && MongoInternals !== null ? MongoInternals.defaultRemoteCollectionDriver() : void 0) || Meteor._RemoteCollectionDriver;\n return mongo_driver.mongo.db.collections(bound_sync_collections);\n};\n\nMeteor.startup(function() {\n return sync_collections();\n});\n\nMeteor.methods({\n _houston_make_admin: function(userId) {\n // limit one admin\n if (Houston._admins.findOne({\n 'user_id': {\n $exists: true\n }\n })) {\n return;\n }\n Houston._admins.insert({\n user_id: userId\n });\n sync_collections(); // reloads collections in case of new app\n return true;\n }\n});\n\n// publish our analysis of the app's collections\nHouston._publish('collections', function() {\n if (!Houston._user_is_admin(this.userId)) {\n return;\n }\n return Houston._collections.collections.find();\n});\n\n// used by login page to see if admin has been created yet\nHouston._publish('admin_user', function() {\n if (Houston._user_is_admin(this.userId)) {\n return Houston._admins.find({\n user_id: this.userId\n });\n }\n return Houston._admins.find({\n user_id: {\n $exists: true\n }\n }, {\n fields: {\n _id: true\n }\n });\n});", "source_lang": "CoffeeScript", "target_lang": "JavaScript", "repo": "gterrono/houston", "path": "server/publications.coffee", "license": "MIT", "commit": "9036c3045bf008d08dc4ffef1717965986a8cc33", "stars": 802, "source_url": "https://github.com/gterrono/houston/blob/9036c3045bf008d08dc4ffef1717965986a8cc33/server/publications.coffee", "line_start": 55, "line_end": 102}867{"id": "gterrono/houston:server/publications.coffee:3:js_to_coffee", "type": "js_to_coffee", "prompt": "Convert this JavaScript to CoffeeScript.\n```javascript\nvar sync_collections;\n\nsync_collections = function() {\n var _sync_collections, bound_sync_collections, mongo_driver;\n Dummy.findOne(); // hack. TODO: verify this is still necessary\n _sync_collections = function(meh, collections_db) {\n var col, collection_names;\n collection_names = (function() {\n var i, len, results;\n results = [];\n for (i = 0, len = collections_db.length; i < len; i++) {\n col = collections_db[i];\n if ((col.collectionName.indexOf(\"system.\")) !== 0 && (col.collectionName.indexOf(\"houston_\")) !== 0) {\n results.push(col.collectionName);\n }\n }\n return results;\n })();\n collection_names.forEach(function(name) {\n var e, key, value;\n if (!(name in collections)) {\n try {\n collections[name] = new Meteor.Collection(name);\n } catch (error) {\n e = error;\n for (key in root) {\n value = root[key];\n if (name === value._name) {\n collections[name] = value;\n }\n }\n if (collections[name] == null) {\n console.log(e);\n }\n }\n return setup_collection(name, collections[name]);\n }\n });\n return console.log(\"sync collections done\");\n };\n bound_sync_collections = Meteor.bindEnvironment(_sync_collections, function(e) {\n return console.log(`Failed while syncing collections for reason: ${e}`);\n });\n // MongoInternals is the 'right' solution as of 0.6.5\n mongo_driver = (typeof MongoInternals !== \"undefined\" && MongoInternals !== null ? MongoInternals.defaultRemoteCollectionDriver() : void 0) || Meteor._RemoteCollectionDriver;\n return mongo_driver.mongo.db.collections(bound_sync_collections);\n};\n\nMeteor.startup(function() {\n return sync_collections();\n});\n\nMeteor.methods({\n _houston_make_admin: function(userId) {\n // limit one admin\n if (Houston._admins.findOne({\n 'user_id': {\n $exists: true\n }\n })) {\n return;\n }\n Houston._admins.insert({\n user_id: userId\n });\n sync_collections(); // reloads collections in case of new app\n return true;\n }\n});\n\n// publish our analysis of the app's collections\nHouston._publish('collections', function() {\n if (!Houston._user_is_admin(this.userId)) {\n return;\n }\n return Houston._collections.collections.find();\n});\n\n// used by login page to see if admin has been created yet\nHouston._publish('admin_user', function() {\n if (Houston._user_is_admin(this.userId)) {\n return Houston._admins.find({\n user_id: this.userId\n });\n }\n return Houston._admins.find({\n user_id: {\n $exists: true\n }\n }, {\n fields: {\n _id: true\n }\n });\n});\n```", "response": "sync_collections = ->\n Dummy.findOne() # hack. TODO: verify this is still necessary\n\n _sync_collections = (meh, collections_db) ->\n collection_names = (col.collectionName for col in collections_db \\\n when (col.collectionName.indexOf \"system.\") isnt 0 and\n (col.collectionName.indexOf \"houston_\") isnt 0)\n\n collection_names.forEach (name) ->\n unless name of collections\n try\n collections[name] = new Meteor.Collection(name)\n catch e\n for key, value of root\n if name == value._name\n collections[name] = value\n console.log e unless collections[name]?\n setup_collection(name, collections[name])\n console.log \"sync collections done\"\n\n bound_sync_collections = Meteor.bindEnvironment _sync_collections, (e) ->\n console.log \"Failed while syncing collections for reason: #{e}\"\n\n # MongoInternals is the 'right' solution as of 0.6.5\n mongo_driver = MongoInternals?.defaultRemoteCollectionDriver() or Meteor._RemoteCollectionDriver\n mongo_driver.mongo.db.collections bound_sync_collections\n\nMeteor.startup ->\n sync_collections()\n\nMeteor.methods\n _houston_make_admin: (userId) ->\n # limit one admin\n return if Houston._admins.findOne {'user_id': $exists: true}\n Houston._admins.insert user_id: userId\n sync_collections() # reloads collections in case of new app\n return true\n\n# publish our analysis of the app's collections\nHouston._publish 'collections', ->\n return unless Houston._user_is_admin @userId\n Houston._collections.collections.find()\n\n# used by login page to see if admin has been created yet\nHouston._publish 'admin_user', ->\n if Houston._user_is_admin @userId\n return Houston._admins.find user_id: @userId\n Houston._admins.find {user_id: $exists: true}, fields: _id: true", "source_lang": "JavaScript", "target_lang": "CoffeeScript", "repo": "gterrono/houston", "path": "server/publications.coffee", "license": "MIT", "commit": "9036c3045bf008d08dc4ffef1717965986a8cc33", "stars": 802, "source_url": "https://github.com/gterrono/houston/blob/9036c3045bf008d08dc4ffef1717965986a8cc33/server/publications.coffee", "line_start": 55, "line_end": 102}868{"id": "gterrono/houston:server/publications.coffee:3:completion", "type": "completion", "prompt": "sync_collections = ->\n Dummy.findOne() # hack. TODO: verify this is still necessary\n\n _sync_collections = (meh, collections_db) ->\n collection_names = (col.collectionName for col in collections_db \\\n when (col.collectionName.indexOf \"system.\") isnt 0 and\n (col.collectionName.indexOf \"houston_\") isnt 0)\n\n collection_names.forEach (name) ->\n unless name of collections\n try\n collections[name] = new Meteor.Collection(name)\n catch e\n for key, value of root\n if name == value._name\n collections[name] = value\n console.log e unless collections[name]?\n setup_collection(name, collections[name])\n console.log \"sync collections done\"\n\n bound_sync_collections = Meteor.bindEnvironment _sync_collections, (e) ->\n console.log \"Failed while syncing collections for reason: #{e}\"\n\n # MongoInternals is the 'right' solution as of 0.6.5", "response": "mongo_driver = MongoInternals?.defaultRemoteCollectionDriver() or Meteor._RemoteCollectionDriver\n mongo_driver.mongo.db.collections bound_sync_collections\n\nMeteor.startup ->\n sync_collections()\n\nMeteor.methods\n _houston_make_admin: (userId) ->\n # limit one admin\n return if Houston._admins.findOne {'user_id': $exists: true}\n Houston._admins.insert user_id: userId\n sync_collections() # reloads collections in case of new app\n return true\n\n# publish our analysis of the app's collections\nHouston._publish 'collections', ->\n return unless Houston._user_is_admin @userId\n Houston._collections.collections.find()\n\n# used by login page to see if admin has been created yet\nHouston._publish 'admin_user', ->\n if Houston._user_is_admin @userId\n return Houston._admins.find user_id: @userId\n Houston._admins.find {user_id: $exists: true}, fields: _id: true", "source_lang": "CoffeeScript", "target_lang": "CoffeeScript", "repo": "gterrono/houston", "path": "server/publications.coffee", "license": "MIT", "commit": "9036c3045bf008d08dc4ffef1717965986a8cc33", "stars": 802, "source_url": "https://github.com/gterrono/houston/blob/9036c3045bf008d08dc4ffef1717965986a8cc33/server/publications.coffee", "line_start": 55, "line_end": 102}869{"id": "gterrono/houston:server/publications.coffee:2:raw_corpus", "type": "raw_corpus", "prompt": "", "response": "setup_collection = (name, collection) ->\n methods = {}\n methods[Houston._houstonize \"#{name}_insert\"] = (doc) ->\n return unless Houston._user_is_admin @userId\n collection.insert(doc)\n\n methods[Houston._houstonize \"#{name}_update\"] = (id, update_dict) ->\n return unless Houston._user_is_admin @userId\n if collection.findOne(id)\n collection.update(id, update_dict)\n else\n id = collection.findOne(new Meteor.Collection.ObjectID(id))\n collection.update(id, update_dict)\n\n methods[Houston._houstonize \"#{name}_delete\"] = (id, update_dict) ->\n return unless Houston._user_is_admin @userId\n if collection.findOne(id)\n collection.remove(id)\n else\n id = collection.findOne(new Meteor.Collection.ObjectID(id))\n collection.remove(id)\n\n Meteor.methods methods\n\n Houston._publish name, (sort, filter, limit) ->\n return unless Houston._user_is_admin @userId\n try\n collection.find(filter, sort: sort, limit: limit)\n catch e\n console.log e\n\n collection.find().observe\n added: (document) ->\n Houston._collections.collections.update {name},\n $inc: {count: 1},\n $addToSet: fields: $each: Houston._get_field_names([document])\n removed: (document) -> Houston._collections.collections.update {name}, {$inc: {count: -1}}\n\n fields = Houston._get_field_names(collection.find().fetch())\n c = Houston._collections.collections.findOne {name}\n if c\n Houston._collections.collections.update c._id, {$set: count: collection.find().count(), fields: fields}\n else\n Houston._collections.collections.insert {name, count: collection.find().count(), fields: fields}\n console.log \"synced #{name}\"", "source_lang": "", "target_lang": "CoffeeScript", "repo": "gterrono/houston", "path": "server/publications.coffee", "license": "MIT", "commit": "93e4884c3adaadbcf3cabe34bf4fc196e59d3001", "stars": 802, "source_url": "https://github.com/gterrono/houston/blob/93e4884c3adaadbcf3cabe34bf4fc196e59d3001/server/publications.coffee", "line_start": 9, "line_end": 53}870{"id": "gterrono/houston:server/publications.coffee:2:coffee_to_js", "type": "coffee_to_js", "prompt": "Convert this CoffeeScript to JavaScript.\n```coffeescript\nsetup_collection = (name, collection) ->\n methods = {}\n methods[Houston._houstonize \"#{name}_insert\"] = (doc) ->\n return unless Houston._user_is_admin @userId\n collection.insert(doc)\n\n methods[Houston._houstonize \"#{name}_update\"] = (id, update_dict) ->\n return unless Houston._user_is_admin @userId\n if collection.findOne(id)\n collection.update(id, update_dict)\n else\n id = collection.findOne(new Meteor.Collection.ObjectID(id))\n collection.update(id, update_dict)\n\n methods[Houston._houstonize \"#{name}_delete\"] = (id, update_dict) ->\n return unless Houston._user_is_admin @userId\n if collection.findOne(id)\n collection.remove(id)\n else\n id = collection.findOne(new Meteor.Collection.ObjectID(id))\n collection.remove(id)\n\n Meteor.methods methods\n\n Houston._publish name, (sort, filter, limit) ->\n return unless Houston._user_is_admin @userId\n try\n collection.find(filter, sort: sort, limit: limit)\n catch e\n console.log e\n\n collection.find().observe\n added: (document) ->\n Houston._collections.collections.update {name},\n $inc: {count: 1},\n $addToSet: fields: $each: Houston._get_field_names([document])\n removed: (document) -> Houston._collections.collections.update {name}, {$inc: {count: -1}}\n\n fields = Houston._get_field_names(collection.find().fetch())\n c = Houston._collections.collections.findOne {name}\n if c\n Houston._collections.collections.update c._id, {$set: count: collection.find().count(), fields: fields}\n else\n Houston._collections.collections.insert {name, count: collection.find().count(), fields: fields}\n console.log \"synced #{name}\"\n```", "response": "var setup_collection;\n\nsetup_collection = function(name, collection) {\n var c, fields, methods;\n methods = {};\n methods[Houston._houstonize(`${name}_insert`)] = function(doc) {\n if (!Houston._user_is_admin(this.userId)) {\n return;\n }\n return collection.insert(doc);\n };\n methods[Houston._houstonize(`${name}_update`)] = function(id, update_dict) {\n if (!Houston._user_is_admin(this.userId)) {\n return;\n }\n if (collection.findOne(id)) {\n return collection.update(id, update_dict);\n } else {\n id = collection.findOne(new Meteor.Collection.ObjectID(id));\n return collection.update(id, update_dict);\n }\n };\n methods[Houston._houstonize(`${name}_delete`)] = function(id, update_dict) {\n if (!Houston._user_is_admin(this.userId)) {\n return;\n }\n if (collection.findOne(id)) {\n return collection.remove(id);\n } else {\n id = collection.findOne(new Meteor.Collection.ObjectID(id));\n return collection.remove(id);\n }\n };\n Meteor.methods(methods);\n Houston._publish(name, function(sort, filter, limit) {\n var e;\n if (!Houston._user_is_admin(this.userId)) {\n return;\n }\n try {\n return collection.find(filter, {\n sort: sort,\n limit: limit\n });\n } catch (error) {\n e = error;\n return console.log(e);\n }\n });\n collection.find().observe({\n added: function(document) {\n return Houston._collections.collections.update({name}, {\n $inc: {\n count: 1\n },\n $addToSet: {\n fields: {\n $each: Houston._get_field_names([document])\n }\n }\n });\n },\n removed: function(document) {\n return Houston._collections.collections.update({name}, {\n $inc: {\n count: -1\n }\n });\n }\n });\n fields = Houston._get_field_names(collection.find().fetch());\n c = Houston._collections.collections.findOne({name});\n if (c) {\n Houston._collections.collections.update(c._id, {\n $set: {\n count: collection.find().count(),\n fields: fields\n }\n });\n } else {\n Houston._collections.collections.insert({\n name,\n count: collection.find().count(),\n fields: fields\n });\n }\n return console.log(`synced ${name}`);\n};", "source_lang": "CoffeeScript", "target_lang": "JavaScript", "repo": "gterrono/houston", "path": "server/publications.coffee", "license": "MIT", "commit": "93e4884c3adaadbcf3cabe34bf4fc196e59d3001", "stars": 802, "source_url": "https://github.com/gterrono/houston/blob/93e4884c3adaadbcf3cabe34bf4fc196e59d3001/server/publications.coffee", "line_start": 9, "line_end": 53}871{"id": "gterrono/houston:server/publications.coffee:2:js_to_coffee", "type": "js_to_coffee", "prompt": "Convert this JavaScript to CoffeeScript.\n```javascript\nvar setup_collection;\n\nsetup_collection = function(name, collection) {\n var c, fields, methods;\n methods = {};\n methods[Houston._houstonize(`${name}_insert`)] = function(doc) {\n if (!Houston._user_is_admin(this.userId)) {\n return;\n }\n return collection.insert(doc);\n };\n methods[Houston._houstonize(`${name}_update`)] = function(id, update_dict) {\n if (!Houston._user_is_admin(this.userId)) {\n return;\n }\n if (collection.findOne(id)) {\n return collection.update(id, update_dict);\n } else {\n id = collection.findOne(new Meteor.Collection.ObjectID(id));\n return collection.update(id, update_dict);\n }\n };\n methods[Houston._houstonize(`${name}_delete`)] = function(id, update_dict) {\n if (!Houston._user_is_admin(this.userId)) {\n return;\n }\n if (collection.findOne(id)) {\n return collection.remove(id);\n } else {\n id = collection.findOne(new Meteor.Collection.ObjectID(id));\n return collection.remove(id);\n }\n };\n Meteor.methods(methods);\n Houston._publish(name, function(sort, filter, limit) {\n var e;\n if (!Houston._user_is_admin(this.userId)) {\n return;\n }\n try {\n return collection.find(filter, {\n sort: sort,\n limit: limit\n });\n } catch (error) {\n e = error;\n return console.log(e);\n }\n });\n collection.find().observe({\n added: function(document) {\n return Houston._collections.collections.update({name}, {\n $inc: {\n count: 1\n },\n $addToSet: {\n fields: {\n $each: Houston._get_field_names([document])\n }\n }\n });\n },\n removed: function(document) {\n return Houston._collections.collections.update({name}, {\n $inc: {\n count: -1\n }\n });\n }\n });\n fields = Houston._get_field_names(collection.find().fetch());\n c = Houston._collections.collections.findOne({name});\n if (c) {\n Houston._collections.collections.update(c._id, {\n $set: {\n count: collection.find().count(),\n fields: fields\n }\n });\n } else {\n Houston._collections.collections.insert({\n name,\n count: collection.find().count(),\n fields: fields\n });\n }\n return console.log(`synced ${name}`);\n};\n```", "response": "setup_collection = (name, collection) ->\n methods = {}\n methods[Houston._houstonize \"#{name}_insert\"] = (doc) ->\n return unless Houston._user_is_admin @userId\n collection.insert(doc)\n\n methods[Houston._houstonize \"#{name}_update\"] = (id, update_dict) ->\n return unless Houston._user_is_admin @userId\n if collection.findOne(id)\n collection.update(id, update_dict)\n else\n id = collection.findOne(new Meteor.Collection.ObjectID(id))\n collection.update(id, update_dict)\n\n methods[Houston._houstonize \"#{name}_delete\"] = (id, update_dict) ->\n return unless Houston._user_is_admin @userId\n if collection.findOne(id)\n collection.remove(id)\n else\n id = collection.findOne(new Meteor.Collection.ObjectID(id))\n collection.remove(id)\n\n Meteor.methods methods\n\n Houston._publish name, (sort, filter, limit) ->\n return unless Houston._user_is_admin @userId\n try\n collection.find(filter, sort: sort, limit: limit)\n catch e\n console.log e\n\n collection.find().observe\n added: (document) ->\n Houston._collections.collections.update {name},\n $inc: {count: 1},\n $addToSet: fields: $each: Houston._get_field_names([document])\n removed: (document) -> Houston._collections.collections.update {name}, {$inc: {count: -1}}\n\n fields = Houston._get_field_names(collection.find().fetch())\n c = Houston._collections.collections.findOne {name}\n if c\n Houston._collections.collections.update c._id, {$set: count: collection.find().count(), fields: fields}\n else\n Houston._collections.collections.insert {name, count: collection.find().count(), fields: fields}\n console.log \"synced #{name}\"", "source_lang": "JavaScript", "target_lang": "CoffeeScript", "repo": "gterrono/houston", "path": "server/publications.coffee", "license": "MIT", "commit": "93e4884c3adaadbcf3cabe34bf4fc196e59d3001", "stars": 802, "source_url": "https://github.com/gterrono/houston/blob/93e4884c3adaadbcf3cabe34bf4fc196e59d3001/server/publications.coffee", "line_start": 9, "line_end": 53}872{"id": "gterrono/houston:server/publications.coffee:2:completion", "type": "completion", "prompt": "setup_collection = (name, collection) ->\n methods = {}\n methods[Houston._houstonize \"#{name}_insert\"] = (doc) ->\n return unless Houston._user_is_admin @userId\n collection.insert(doc)\n\n methods[Houston._houstonize \"#{name}_update\"] = (id, update_dict) ->\n return unless Houston._user_is_admin @userId\n if collection.findOne(id)\n collection.update(id, update_dict)\n else\n id = collection.findOne(new Meteor.Collection.ObjectID(id))\n collection.update(id, update_dict)\n\n methods[Houston._houstonize \"#{name}_delete\"] = (id, update_dict) ->\n return unless Houston._user_is_admin @userId\n if collection.findOne(id)\n collection.remove(id)\n else\n id = collection.findOne(new Meteor.Collection.ObjectID(id))\n collection.remove(id)", "response": "Meteor.methods methods\n\n Houston._publish name, (sort, filter, limit) ->\n return unless Houston._user_is_admin @userId\n try\n collection.find(filter, sort: sort, limit: limit)\n catch e\n console.log e\n\n collection.find().observe\n added: (document) ->\n Houston._collections.collections.update {name},\n $inc: {count: 1},\n $addToSet: fields: $each: Houston._get_field_names([document])\n removed: (document) -> Houston._collections.collections.update {name}, {$inc: {count: -1}}\n\n fields = Houston._get_field_names(collection.find().fetch())\n c = Houston._collections.collections.findOne {name}\n if c\n Houston._collections.collections.update c._id, {$set: count: collection.find().count(), fields: fields}\n else\n Houston._collections.collections.insert {name, count: collection.find().count(), fields: fields}\n console.log \"synced #{name}\"", "source_lang": "CoffeeScript", "target_lang": "CoffeeScript", "repo": "gterrono/houston", "path": "server/publications.coffee", "license": "MIT", "commit": "93e4884c3adaadbcf3cabe34bf4fc196e59d3001", "stars": 802, "source_url": "https://github.com/gterrono/houston/blob/93e4884c3adaadbcf3cabe34bf4fc196e59d3001/server/publications.coffee", "line_start": 9, "line_end": 53}873{"id": "gterrono/houston:server/publications.coffee:3:raw_corpus", "type": "raw_corpus", "prompt": "", "response": "sync_collections = (meh, collections_db) ->\n collection_names = (col.collectionName for col in collections_db \\\n when (col.collectionName.indexOf \"system.\") isnt 0 and\n (col.collectionName.indexOf \"houston_\") isnt 0)\n\n collection_names.forEach (name) ->\n unless name of collections\n try\n collections[name] = new Meteor.Collection(name)\n catch e\n for key, value of root\n if name == value._name\n collections[name] = value\n console.log e unless collections[name]?\n\n setup_collection(name, collections[name])\n console.log \"sync collections done\"\n\nMeteor.startup ->\n Dummy.findOne() # hack. TODO: verify this is still necessary\n\n # TODO put bindEnvironment as part of syncCollections\n sync_fn = Meteor.bindEnvironment sync_collections, (e) ->\n console.log \"sync error\"\n console.log e\n\n # MongoInternals is the 'right' solution as of 0.6.5\n mongo_driver = MongoInternals?.defaultRemoteCollectionDriver() or Meteor._RemoteCollectionDriver\n mongo_driver.mongo.db.collections sync_fn\n\nMeteor.methods\n _houston_make_admin: (userId) ->\n # limit one admin\n console.log \"making admin: #{userId}\"\n return if Houston._admins.findOne {'user_id': $exists: true}\n Houston._admins.insert user_id: userId\n return true\n\n# publish our analysis of the app's collections\nHouston._publish 'collections', ->\n return unless Houston._user_is_admin @userId\n Houston._collections.collections.find()\n\n# used by login page to see if admin has been created yet\nHouston._publish 'admin_user', ->\n if Houston._user_is_admin @userId\n return Houston._admins.find user_id: @userId\n Houston._admins.find {user_id: $exists: true}, fields: _id: true", "source_lang": "", "target_lang": "CoffeeScript", "repo": "gterrono/houston", "path": "server/publications.coffee", "license": "MIT", "commit": "93e4884c3adaadbcf3cabe34bf4fc196e59d3001", "stars": 802, "source_url": "https://github.com/gterrono/houston/blob/93e4884c3adaadbcf3cabe34bf4fc196e59d3001/server/publications.coffee", "line_start": 55, "line_end": 102}874{"id": "gterrono/houston:server/publications.coffee:3:coffee_to_js", "type": "coffee_to_js", "prompt": "Convert this CoffeeScript to JavaScript.\n```coffeescript\nsync_collections = (meh, collections_db) ->\n collection_names = (col.collectionName for col in collections_db \\\n when (col.collectionName.indexOf \"system.\") isnt 0 and\n (col.collectionName.indexOf \"houston_\") isnt 0)\n\n collection_names.forEach (name) ->\n unless name of collections\n try\n collections[name] = new Meteor.Collection(name)\n catch e\n for key, value of root\n if name == value._name\n collections[name] = value\n console.log e unless collections[name]?\n\n setup_collection(name, collections[name])\n console.log \"sync collections done\"\n\nMeteor.startup ->\n Dummy.findOne() # hack. TODO: verify this is still necessary\n\n # TODO put bindEnvironment as part of syncCollections\n sync_fn = Meteor.bindEnvironment sync_collections, (e) ->\n console.log \"sync error\"\n console.log e\n\n # MongoInternals is the 'right' solution as of 0.6.5\n mongo_driver = MongoInternals?.defaultRemoteCollectionDriver() or Meteor._RemoteCollectionDriver\n mongo_driver.mongo.db.collections sync_fn\n\nMeteor.methods\n _houston_make_admin: (userId) ->\n # limit one admin\n console.log \"making admin: #{userId}\"\n return if Houston._admins.findOne {'user_id': $exists: true}\n Houston._admins.insert user_id: userId\n return true\n\n# publish our analysis of the app's collections\nHouston._publish 'collections', ->\n return unless Houston._user_is_admin @userId\n Houston._collections.collections.find()\n\n# used by login page to see if admin has been created yet\nHouston._publish 'admin_user', ->\n if Houston._user_is_admin @userId\n return Houston._admins.find user_id: @userId\n Houston._admins.find {user_id: $exists: true}, fields: _id: true\n```", "response": "var sync_collections;\n\nsync_collections = function(meh, collections_db) {\n var col, collection_names;\n collection_names = (function() {\n var i, len, results;\n results = [];\n for (i = 0, len = collections_db.length; i < len; i++) {\n col = collections_db[i];\n if ((col.collectionName.indexOf(\"system.\")) !== 0 && (col.collectionName.indexOf(\"houston_\")) !== 0) {\n results.push(col.collectionName);\n }\n }\n return results;\n })();\n collection_names.forEach(function(name) {\n var e, key, value;\n if (!(name in collections)) {\n try {\n collections[name] = new Meteor.Collection(name);\n } catch (error) {\n e = error;\n for (key in root) {\n value = root[key];\n if (name === value._name) {\n collections[name] = value;\n }\n }\n if (collections[name] == null) {\n console.log(e);\n }\n }\n return setup_collection(name, collections[name]);\n }\n });\n return console.log(\"sync collections done\");\n};\n\nMeteor.startup(function() {\n var mongo_driver, sync_fn;\n Dummy.findOne(); // hack. TODO: verify this is still necessary\n\n // TODO put bindEnvironment as part of syncCollections\n sync_fn = Meteor.bindEnvironment(sync_collections, function(e) {\n console.log(\"sync error\");\n return console.log(e);\n });\n // MongoInternals is the 'right' solution as of 0.6.5\n mongo_driver = (typeof MongoInternals !== \"undefined\" && MongoInternals !== null ? MongoInternals.defaultRemoteCollectionDriver() : void 0) || Meteor._RemoteCollectionDriver;\n return mongo_driver.mongo.db.collections(sync_fn);\n});\n\nMeteor.methods({\n _houston_make_admin: function(userId) {\n // limit one admin\n console.log(`making admin: ${userId}`);\n if (Houston._admins.findOne({\n 'user_id': {\n $exists: true\n }\n })) {\n return;\n }\n Houston._admins.insert({\n user_id: userId\n });\n return true;\n }\n});\n\n// publish our analysis of the app's collections\nHouston._publish('collections', function() {\n if (!Houston._user_is_admin(this.userId)) {\n return;\n }\n return Houston._collections.collections.find();\n});\n\n// used by login page to see if admin has been created yet\nHouston._publish('admin_user', function() {\n if (Houston._user_is_admin(this.userId)) {\n return Houston._admins.find({\n user_id: this.userId\n });\n }\n return Houston._admins.find({\n user_id: {\n $exists: true\n }\n }, {\n fields: {\n _id: true\n }\n });\n});", "source_lang": "CoffeeScript", "target_lang": "JavaScript", "repo": "gterrono/houston", "path": "server/publications.coffee", "license": "MIT", "commit": "93e4884c3adaadbcf3cabe34bf4fc196e59d3001", "stars": 802, "source_url": "https://github.com/gterrono/houston/blob/93e4884c3adaadbcf3cabe34bf4fc196e59d3001/server/publications.coffee", "line_start": 55, "line_end": 102}875{"id": "gterrono/houston:server/publications.coffee:3:js_to_coffee", "type": "js_to_coffee", "prompt": "Convert this JavaScript to CoffeeScript.\n```javascript\nvar sync_collections;\n\nsync_collections = function(meh, collections_db) {\n var col, collection_names;\n collection_names = (function() {\n var i, len, results;\n results = [];\n for (i = 0, len = collections_db.length; i < len; i++) {\n col = collections_db[i];\n if ((col.collectionName.indexOf(\"system.\")) !== 0 && (col.collectionName.indexOf(\"houston_\")) !== 0) {\n results.push(col.collectionName);\n }\n }\n return results;\n })();\n collection_names.forEach(function(name) {\n var e, key, value;\n if (!(name in collections)) {\n try {\n collections[name] = new Meteor.Collection(name);\n } catch (error) {\n e = error;\n for (key in root) {\n value = root[key];\n if (name === value._name) {\n collections[name] = value;\n }\n }\n if (collections[name] == null) {\n console.log(e);\n }\n }\n return setup_collection(name, collections[name]);\n }\n });\n return console.log(\"sync collections done\");\n};\n\nMeteor.startup(function() {\n var mongo_driver, sync_fn;\n Dummy.findOne(); // hack. TODO: verify this is still necessary\n\n // TODO put bindEnvironment as part of syncCollections\n sync_fn = Meteor.bindEnvironment(sync_collections, function(e) {\n console.log(\"sync error\");\n return console.log(e);\n });\n // MongoInternals is the 'right' solution as of 0.6.5\n mongo_driver = (typeof MongoInternals !== \"undefined\" && MongoInternals !== null ? MongoInternals.defaultRemoteCollectionDriver() : void 0) || Meteor._RemoteCollectionDriver;\n return mongo_driver.mongo.db.collections(sync_fn);\n});\n\nMeteor.methods({\n _houston_make_admin: function(userId) {\n // limit one admin\n console.log(`making admin: ${userId}`);\n if (Houston._admins.findOne({\n 'user_id': {\n $exists: true\n }\n })) {\n return;\n }\n Houston._admins.insert({\n user_id: userId\n });\n return true;\n }\n});\n\n// publish our analysis of the app's collections\nHouston._publish('collections', function() {\n if (!Houston._user_is_admin(this.userId)) {\n return;\n }\n return Houston._collections.collections.find();\n});\n\n// used by login page to see if admin has been created yet\nHouston._publish('admin_user', function() {\n if (Houston._user_is_admin(this.userId)) {\n return Houston._admins.find({\n user_id: this.userId\n });\n }\n return Houston._admins.find({\n user_id: {\n $exists: true\n }\n }, {\n fields: {\n _id: true\n }\n });\n});\n```", "response": "sync_collections = (meh, collections_db) ->\n collection_names = (col.collectionName for col in collections_db \\\n when (col.collectionName.indexOf \"system.\") isnt 0 and\n (col.collectionName.indexOf \"houston_\") isnt 0)\n\n collection_names.forEach (name) ->\n unless name of collections\n try\n collections[name] = new Meteor.Collection(name)\n catch e\n for key, value of root\n if name == value._name\n collections[name] = value\n console.log e unless collections[name]?\n\n setup_collection(name, collections[name])\n console.log \"sync collections done\"\n\nMeteor.startup ->\n Dummy.findOne() # hack. TODO: verify this is still necessary\n\n # TODO put bindEnvironment as part of syncCollections\n sync_fn = Meteor.bindEnvironment sync_collections, (e) ->\n console.log \"sync error\"\n console.log e\n\n # MongoInternals is the 'right' solution as of 0.6.5\n mongo_driver = MongoInternals?.defaultRemoteCollectionDriver() or Meteor._RemoteCollectionDriver\n mongo_driver.mongo.db.collections sync_fn\n\nMeteor.methods\n _houston_make_admin: (userId) ->\n # limit one admin\n console.log \"making admin: #{userId}\"\n return if Houston._admins.findOne {'user_id': $exists: true}\n Houston._admins.insert user_id: userId\n return true\n\n# publish our analysis of the app's collections\nHouston._publish 'collections', ->\n return unless Houston._user_is_admin @userId\n Houston._collections.collections.find()\n\n# used by login page to see if admin has been created yet\nHouston._publish 'admin_user', ->\n if Houston._user_is_admin @userId\n return Houston._admins.find user_id: @userId\n Houston._admins.find {user_id: $exists: true}, fields: _id: true", "source_lang": "JavaScript", "target_lang": "CoffeeScript", "repo": "gterrono/houston", "path": "server/publications.coffee", "license": "MIT", "commit": "93e4884c3adaadbcf3cabe34bf4fc196e59d3001", "stars": 802, "source_url": "https://github.com/gterrono/houston/blob/93e4884c3adaadbcf3cabe34bf4fc196e59d3001/server/publications.coffee", "line_start": 55, "line_end": 102}876{"id": "gterrono/houston:server/publications.coffee:3:completion", "type": "completion", "prompt": "sync_collections = (meh, collections_db) ->\n collection_names = (col.collectionName for col in collections_db \\\n when (col.collectionName.indexOf \"system.\") isnt 0 and\n (col.collectionName.indexOf \"houston_\") isnt 0)\n\n collection_names.forEach (name) ->\n unless name of collections\n try\n collections[name] = new Meteor.Collection(name)\n catch e\n for key, value of root\n if name == value._name\n collections[name] = value\n console.log e unless collections[name]?\n\n setup_collection(name, collections[name])\n console.log \"sync collections done\"\n\nMeteor.startup ->\n Dummy.findOne() # hack. TODO: verify this is still necessary\n\n # TODO put bindEnvironment as part of syncCollections\n sync_fn = Meteor.bindEnvironment sync_collections, (e) ->\n console.log \"sync error\"", "response": "console.log e\n\n # MongoInternals is the 'right' solution as of 0.6.5\n mongo_driver = MongoInternals?.defaultRemoteCollectionDriver() or Meteor._RemoteCollectionDriver\n mongo_driver.mongo.db.collections sync_fn\n\nMeteor.methods\n _houston_make_admin: (userId) ->\n # limit one admin\n console.log \"making admin: #{userId}\"\n return if Houston._admins.findOne {'user_id': $exists: true}\n Houston._admins.insert user_id: userId\n return true\n\n# publish our analysis of the app's collections\nHouston._publish 'collections', ->\n return unless Houston._user_is_admin @userId\n Houston._collections.collections.find()\n\n# used by login page to see if admin has been created yet\nHouston._publish 'admin_user', ->\n if Houston._user_is_admin @userId\n return Houston._admins.find user_id: @userId\n Houston._admins.find {user_id: $exists: true}, fields: _id: true", "source_lang": "CoffeeScript", "target_lang": "CoffeeScript", "repo": "gterrono/houston", "path": "server/publications.coffee", "license": "MIT", "commit": "93e4884c3adaadbcf3cabe34bf4fc196e59d3001", "stars": 802, "source_url": "https://github.com/gterrono/houston/blob/93e4884c3adaadbcf3cabe34bf4fc196e59d3001/server/publications.coffee", "line_start": 55, "line_end": 102}877{"id": "gterrono/houston:server/publications.coffee:1:raw_corpus", "type": "raw_corpus", "prompt": "", "response": "Houston._publish = (name, func) ->\n Meteor.publish Houston._houstonize(name), func\n\nMeteor.startup ->\n set_up_collection = (name, collection) ->\n methods = {}\n methods[Houston._houstonize \"#{name}_insert\"] = ([doc]) ->\n return unless Houston._user_is_admin @userId\n collection.insert(doc)\n\n methods[Houston._houstonize \"#{name}_update\"] = ([id, update_dict]) ->\n return unless Houston._user_is_admin @userId\n if collection.findOne(id)\n collection.update(id, update_dict)\n else\n id = collection.findOne(new Meteor.Collection.ObjectID(id))\n collection.update(id, update_dict)\n\n methods[Houston._houstonize \"#{name}_delete\"] = ([id, update_dict]) ->\n return unless Houston._user_is_admin @userId\n if collection.findOne(id)\n collection.remove(id)\n else\n id = collection.findOne(new Meteor.Collection.ObjectID(id))\n collection.remove(id)\n\n Meteor.methods methods\n\n Houston._publish name, (sort, filter, limit) ->\n return unless Houston._user_is_admin @userId\n try\n collection.find(filter, sort: sort, limit: limit)\n catch e\n console.log e\n\n collection.find().observe\n added: (document) ->\n Houston._collections.collections.update {name},\n $inc: {count: 1},\n $addToSet: fields: $each: Houston._get_field_names([document])\n removed: (document) -> Houston._collections.collections.update {name}, {$inc: {count: -1}}\n\n fields = Houston._get_field_names(collection.find().fetch())\n c = Houston._collections.collections.findOne {name}\n if c\n Houston._collections.collections.update c._id, {$set: count: collection.find().count(), fields: fields}\n else\n Houston._collections.collections.insert {name, count: collection.find().count(), fields: fields}\n\n Dummy.findOne() # hack", "source_lang": "", "target_lang": "CoffeeScript", "repo": "gterrono/houston", "path": "server/publications.coffee", "license": "MIT", "commit": "4b18561921e57c866348c671e76597b67f4ea52e", "stars": 802, "source_url": "https://github.com/gterrono/houston/blob/4b18561921e57c866348c671e76597b67f4ea52e/server/publications.coffee", "line_start": 6, "line_end": 55}878{"id": "gterrono/houston:server/publications.coffee:1:coffee_to_js", "type": "coffee_to_js", "prompt": "Convert this CoffeeScript to JavaScript.\n```coffeescript\nHouston._publish = (name, func) ->\n Meteor.publish Houston._houstonize(name), func\n\nMeteor.startup ->\n set_up_collection = (name, collection) ->\n methods = {}\n methods[Houston._houstonize \"#{name}_insert\"] = ([doc]) ->\n return unless Houston._user_is_admin @userId\n collection.insert(doc)\n\n methods[Houston._houstonize \"#{name}_update\"] = ([id, update_dict]) ->\n return unless Houston._user_is_admin @userId\n if collection.findOne(id)\n collection.update(id, update_dict)\n else\n id = collection.findOne(new Meteor.Collection.ObjectID(id))\n collection.update(id, update_dict)\n\n methods[Houston._houstonize \"#{name}_delete\"] = ([id, update_dict]) ->\n return unless Houston._user_is_admin @userId\n if collection.findOne(id)\n collection.remove(id)\n else\n id = collection.findOne(new Meteor.Collection.ObjectID(id))\n collection.remove(id)\n\n Meteor.methods methods\n\n Houston._publish name, (sort, filter, limit) ->\n return unless Houston._user_is_admin @userId\n try\n collection.find(filter, sort: sort, limit: limit)\n catch e\n console.log e\n\n collection.find().observe\n added: (document) ->\n Houston._collections.collections.update {name},\n $inc: {count: 1},\n $addToSet: fields: $each: Houston._get_field_names([document])\n removed: (document) -> Houston._collections.collections.update {name}, {$inc: {count: -1}}\n\n fields = Houston._get_field_names(collection.find().fetch())\n c = Houston._collections.collections.findOne {name}\n if c\n Houston._collections.collections.update c._id, {$set: count: collection.find().count(), fields: fields}\n else\n Houston._collections.collections.insert {name, count: collection.find().count(), fields: fields}\n\n Dummy.findOne() # hack\n```", "response": "Houston._publish = function(name, func) {\n return Meteor.publish(Houston._houstonize(name), func);\n};\n\nMeteor.startup(function() {\n var set_up_collection;\n set_up_collection = function(name, collection) {\n var c, fields, methods;\n methods = {};\n methods[Houston._houstonize(`${name}_insert`)] = function([doc]) {\n if (!Houston._user_is_admin(this.userId)) {\n return;\n }\n return collection.insert(doc);\n };\n methods[Houston._houstonize(`${name}_update`)] = function([id, update_dict]) {\n if (!Houston._user_is_admin(this.userId)) {\n return;\n }\n if (collection.findOne(id)) {\n return collection.update(id, update_dict);\n } else {\n id = collection.findOne(new Meteor.Collection.ObjectID(id));\n return collection.update(id, update_dict);\n }\n };\n methods[Houston._houstonize(`${name}_delete`)] = function([id, update_dict]) {\n if (!Houston._user_is_admin(this.userId)) {\n return;\n }\n if (collection.findOne(id)) {\n return collection.remove(id);\n } else {\n id = collection.findOne(new Meteor.Collection.ObjectID(id));\n return collection.remove(id);\n }\n };\n Meteor.methods(methods);\n Houston._publish(name, function(sort, filter, limit) {\n var e;\n if (!Houston._user_is_admin(this.userId)) {\n return;\n }\n try {\n return collection.find(filter, {\n sort: sort,\n limit: limit\n });\n } catch (error) {\n e = error;\n return console.log(e);\n }\n });\n collection.find().observe({\n added: function(document) {\n return Houston._collections.collections.update({name}, {\n $inc: {\n count: 1\n },\n $addToSet: {\n fields: {\n $each: Houston._get_field_names([document])\n }\n }\n });\n },\n removed: function(document) {\n return Houston._collections.collections.update({name}, {\n $inc: {\n count: -1\n }\n });\n }\n });\n fields = Houston._get_field_names(collection.find().fetch());\n c = Houston._collections.collections.findOne({name});\n if (c) {\n return Houston._collections.collections.update(c._id, {\n $set: {\n count: collection.find().count(),\n fields: fields\n }\n });\n } else {\n return Houston._collections.collections.insert({\n name,\n count: collection.find().count(),\n fields: fields\n });\n }\n };\n return Dummy.findOne(); // hack\n});", "source_lang": "CoffeeScript", "target_lang": "JavaScript", "repo": "gterrono/houston", "path": "server/publications.coffee", "license": "MIT", "commit": "4b18561921e57c866348c671e76597b67f4ea52e", "stars": 802, "source_url": "https://github.com/gterrono/houston/blob/4b18561921e57c866348c671e76597b67f4ea52e/server/publications.coffee", "line_start": 6, "line_end": 55}879{"id": "gterrono/houston:server/publications.coffee:1:js_to_coffee", "type": "js_to_coffee", "prompt": "Convert this JavaScript to CoffeeScript.\n```javascript\nHouston._publish = function(name, func) {\n return Meteor.publish(Houston._houstonize(name), func);\n};\n\nMeteor.startup(function() {\n var set_up_collection;\n set_up_collection = function(name, collection) {\n var c, fields, methods;\n methods = {};\n methods[Houston._houstonize(`${name}_insert`)] = function([doc]) {\n if (!Houston._user_is_admin(this.userId)) {\n return;\n }\n return collection.insert(doc);\n };\n methods[Houston._houstonize(`${name}_update`)] = function([id, update_dict]) {\n if (!Houston._user_is_admin(this.userId)) {\n return;\n }\n if (collection.findOne(id)) {\n return collection.update(id, update_dict);\n } else {\n id = collection.findOne(new Meteor.Collection.ObjectID(id));\n return collection.update(id, update_dict);\n }\n };\n methods[Houston._houstonize(`${name}_delete`)] = function([id, update_dict]) {\n if (!Houston._user_is_admin(this.userId)) {\n return;\n }\n if (collection.findOne(id)) {\n return collection.remove(id);\n } else {\n id = collection.findOne(new Meteor.Collection.ObjectID(id));\n return collection.remove(id);\n }\n };\n Meteor.methods(methods);\n Houston._publish(name, function(sort, filter, limit) {\n var e;\n if (!Houston._user_is_admin(this.userId)) {\n return;\n }\n try {\n return collection.find(filter, {\n sort: sort,\n limit: limit\n });\n } catch (error) {\n e = error;\n return console.log(e);\n }\n });\n collection.find().observe({\n added: function(document) {\n return Houston._collections.collections.update({name}, {\n $inc: {\n count: 1\n },\n $addToSet: {\n fields: {\n $each: Houston._get_field_names([document])\n }\n }\n });\n },\n removed: function(document) {\n return Houston._collections.collections.update({name}, {\n $inc: {\n count: -1\n }\n });\n }\n });\n fields = Houston._get_field_names(collection.find().fetch());\n c = Houston._collections.collections.findOne({name});\n if (c) {\n return Houston._collections.collections.update(c._id, {\n $set: {\n count: collection.find().count(),\n fields: fields\n }\n });\n } else {\n return Houston._collections.collections.insert({\n name,\n count: collection.find().count(),\n fields: fields\n });\n }\n };\n return Dummy.findOne(); // hack\n});\n```", "response": "Houston._publish = (name, func) ->\n Meteor.publish Houston._houstonize(name), func\n\nMeteor.startup ->\n set_up_collection = (name, collection) ->\n methods = {}\n methods[Houston._houstonize \"#{name}_insert\"] = ([doc]) ->\n return unless Houston._user_is_admin @userId\n collection.insert(doc)\n\n methods[Houston._houstonize \"#{name}_update\"] = ([id, update_dict]) ->\n return unless Houston._user_is_admin @userId\n if collection.findOne(id)\n collection.update(id, update_dict)\n else\n id = collection.findOne(new Meteor.Collection.ObjectID(id))\n collection.update(id, update_dict)\n\n methods[Houston._houstonize \"#{name}_delete\"] = ([id, update_dict]) ->\n return unless Houston._user_is_admin @userId\n if collection.findOne(id)\n collection.remove(id)\n else\n id = collection.findOne(new Meteor.Collection.ObjectID(id))\n collection.remove(id)\n\n Meteor.methods methods\n\n Houston._publish name, (sort, filter, limit) ->\n return unless Houston._user_is_admin @userId\n try\n collection.find(filter, sort: sort, limit: limit)\n catch e\n console.log e\n\n collection.find().observe\n added: (document) ->\n Houston._collections.collections.update {name},\n $inc: {count: 1},\n $addToSet: fields: $each: Houston._get_field_names([document])\n removed: (document) -> Houston._collections.collections.update {name}, {$inc: {count: -1}}\n\n fields = Houston._get_field_names(collection.find().fetch())\n c = Houston._collections.collections.findOne {name}\n if c\n Houston._collections.collections.update c._id, {$set: count: collection.find().count(), fields: fields}\n else\n Houston._collections.collections.insert {name, count: collection.find().count(), fields: fields}\n\n Dummy.findOne() # hack", "source_lang": "JavaScript", "target_lang": "CoffeeScript", "repo": "gterrono/houston", "path": "server/publications.coffee", "license": "MIT", "commit": "4b18561921e57c866348c671e76597b67f4ea52e", "stars": 802, "source_url": "https://github.com/gterrono/houston/blob/4b18561921e57c866348c671e76597b67f4ea52e/server/publications.coffee", "line_start": 6, "line_end": 55}880{"id": "gterrono/houston:server/publications.coffee:1:completion", "type": "completion", "prompt": "Houston._publish = (name, func) ->\n Meteor.publish Houston._houstonize(name), func\n\nMeteor.startup ->\n set_up_collection = (name, collection) ->\n methods = {}\n methods[Houston._houstonize \"#{name}_insert\"] = ([doc]) ->\n return unless Houston._user_is_admin @userId\n collection.insert(doc)\n\n methods[Houston._houstonize \"#{name}_update\"] = ([id, update_dict]) ->\n return unless Houston._user_is_admin @userId\n if collection.findOne(id)\n collection.update(id, update_dict)\n else\n id = collection.findOne(new Meteor.Collection.ObjectID(id))\n collection.update(id, update_dict)\n\n methods[Houston._houstonize \"#{name}_delete\"] = ([id, update_dict]) ->\n return unless Houston._user_is_admin @userId\n if collection.findOne(id)\n collection.remove(id)\n else\n id = collection.findOne(new Meteor.Collection.ObjectID(id))\n collection.remove(id)", "response": "Meteor.methods methods\n\n Houston._publish name, (sort, filter, limit) ->\n return unless Houston._user_is_admin @userId\n try\n collection.find(filter, sort: sort, limit: limit)\n catch e\n console.log e\n\n collection.find().observe\n added: (document) ->\n Houston._collections.collections.update {name},\n $inc: {count: 1},\n $addToSet: fields: $each: Houston._get_field_names([document])\n removed: (document) -> Houston._collections.collections.update {name}, {$inc: {count: -1}}\n\n fields = Houston._get_field_names(collection.find().fetch())\n c = Houston._collections.collections.findOne {name}\n if c\n Houston._collections.collections.update c._id, {$set: count: collection.find().count(), fields: fields}\n else\n Houston._collections.collections.insert {name, count: collection.find().count(), fields: fields}\n\n Dummy.findOne() # hack", "source_lang": "CoffeeScript", "target_lang": "CoffeeScript", "repo": "gterrono/houston", "path": "server/publications.coffee", "license": "MIT", "commit": "4b18561921e57c866348c671e76597b67f4ea52e", "stars": 802, "source_url": "https://github.com/gterrono/houston/blob/4b18561921e57c866348c671e76597b67f4ea52e/server/publications.coffee", "line_start": 6, "line_end": 55}881{"id": "gterrono/houston:server/publications.coffee:2:raw_corpus", "type": "raw_corpus", "prompt": "", "response": "save_collections = (meh, collections_db) ->\n collection_names = (col.collectionName for col in collections_db \\\n when (col.collectionName.indexOf \"system.\") isnt 0 and\n (col.collectionName.indexOf \"houston_\") isnt 0)\n\n collection_names.forEach (name) ->\n unless name of collections\n try\n collections[name] = new Meteor.Collection(name)\n catch e\n for key, value of root\n if name == value._name\n collections[name] = value\n console.log e unless collections[name]?\n\n set_up_collection(name, collections[name])\n\n Meteor.methods\n _houston_make_admin: ([userId]) ->\n # limit one admin\n return if Houston._admins.findOne {'user_id': $exists: true}\n Houston._admins.insert user_id: userId\n return true\n\n fn = Meteor.bindEnvironment save_collections, (e) ->\n console.log e\n\n # MongoInternals is the 'right' solution as of 0.6.5\n mongo_driver = MongoInternals?.defaultRemoteCollectionDriver() or Meteor._RemoteCollectionDriver\n mongo_driver.mongo.db.collections fn\n\n\n# publish our analysis of the app's collections\nHouston._publish 'collections', ->\n return unless Houston._user_is_admin @userId\n Houston._collections.collections.find()\n\n\n# used by login page to see if admin has been created yet\nHouston._publish 'admin_user', ->\n if Houston._user_is_admin @userId\n return Houston._admins.find user_id: @userId\n Houston._admins.find {user_id: $exists: true}, fields: _id: true", "source_lang": "", "target_lang": "CoffeeScript", "repo": "gterrono/houston", "path": "server/publications.coffee", "license": "MIT", "commit": "4b18561921e57c866348c671e76597b67f4ea52e", "stars": 802, "source_url": "https://github.com/gterrono/houston/blob/4b18561921e57c866348c671e76597b67f4ea52e/server/publications.coffee", "line_start": 56, "line_end": 99}882{"id": "gterrono/houston:server/publications.coffee:2:coffee_to_js", "type": "coffee_to_js", "prompt": "Convert this CoffeeScript to JavaScript.\n```coffeescript\nsave_collections = (meh, collections_db) ->\n collection_names = (col.collectionName for col in collections_db \\\n when (col.collectionName.indexOf \"system.\") isnt 0 and\n (col.collectionName.indexOf \"houston_\") isnt 0)\n\n collection_names.forEach (name) ->\n unless name of collections\n try\n collections[name] = new Meteor.Collection(name)\n catch e\n for key, value of root\n if name == value._name\n collections[name] = value\n console.log e unless collections[name]?\n\n set_up_collection(name, collections[name])\n\n Meteor.methods\n _houston_make_admin: ([userId]) ->\n # limit one admin\n return if Houston._admins.findOne {'user_id': $exists: true}\n Houston._admins.insert user_id: userId\n return true\n\n fn = Meteor.bindEnvironment save_collections, (e) ->\n console.log e\n\n # MongoInternals is the 'right' solution as of 0.6.5\n mongo_driver = MongoInternals?.defaultRemoteCollectionDriver() or Meteor._RemoteCollectionDriver\n mongo_driver.mongo.db.collections fn\n\n\n# publish our analysis of the app's collections\nHouston._publish 'collections', ->\n return unless Houston._user_is_admin @userId\n Houston._collections.collections.find()\n\n\n# used by login page to see if admin has been created yet\nHouston._publish 'admin_user', ->\n if Houston._user_is_admin @userId\n return Houston._admins.find user_id: @userId\n Houston._admins.find {user_id: $exists: true}, fields: _id: true\n```", "response": "var fn, mongo_driver, save_collections;\n\nsave_collections = function(meh, collections_db) {\n var col, collection_names;\n collection_names = (function() {\n var i, len, results;\n results = [];\n for (i = 0, len = collections_db.length; i < len; i++) {\n col = collections_db[i];\n if ((col.collectionName.indexOf(\"system.\")) !== 0 && (col.collectionName.indexOf(\"houston_\")) !== 0) {\n results.push(col.collectionName);\n }\n }\n return results;\n })();\n return collection_names.forEach(function(name) {\n var e, key, value;\n if (!(name in collections)) {\n try {\n collections[name] = new Meteor.Collection(name);\n } catch (error) {\n e = error;\n for (key in root) {\n value = root[key];\n if (name === value._name) {\n collections[name] = value;\n }\n }\n if (collections[name] == null) {\n console.log(e);\n }\n }\n return set_up_collection(name, collections[name]);\n }\n });\n};\n\nMeteor.methods({\n _houston_make_admin: function([userId]) {\n // limit one admin\n if (Houston._admins.findOne({\n 'user_id': {\n $exists: true\n }\n })) {\n return;\n }\n Houston._admins.insert({\n user_id: userId\n });\n return true;\n }\n});\n\nfn = Meteor.bindEnvironment(save_collections, function(e) {\n return console.log(e);\n});\n\n// MongoInternals is the 'right' solution as of 0.6.5\nmongo_driver = (typeof MongoInternals !== \"undefined\" && MongoInternals !== null ? MongoInternals.defaultRemoteCollectionDriver() : void 0) || Meteor._RemoteCollectionDriver;\n\nmongo_driver.mongo.db.collections(fn);\n\n// publish our analysis of the app's collections\nHouston._publish('collections', function() {\n if (!Houston._user_is_admin(this.userId)) {\n return;\n }\n return Houston._collections.collections.find();\n});\n\n// used by login page to see if admin has been created yet\nHouston._publish('admin_user', function() {\n if (Houston._user_is_admin(this.userId)) {\n return Houston._admins.find({\n user_id: this.userId\n });\n }\n return Houston._admins.find({\n user_id: {\n $exists: true\n }\n }, {\n fields: {\n _id: true\n }\n });\n});", "source_lang": "CoffeeScript", "target_lang": "JavaScript", "repo": "gterrono/houston", "path": "server/publications.coffee", "license": "MIT", "commit": "4b18561921e57c866348c671e76597b67f4ea52e", "stars": 802, "source_url": "https://github.com/gterrono/houston/blob/4b18561921e57c866348c671e76597b67f4ea52e/server/publications.coffee", "line_start": 56, "line_end": 99}883{"id": "gterrono/houston:server/publications.coffee:2:js_to_coffee", "type": "js_to_coffee", "prompt": "Convert this JavaScript to CoffeeScript.\n```javascript\nvar fn, mongo_driver, save_collections;\n\nsave_collections = function(meh, collections_db) {\n var col, collection_names;\n collection_names = (function() {\n var i, len, results;\n results = [];\n for (i = 0, len = collections_db.length; i < len; i++) {\n col = collections_db[i];\n if ((col.collectionName.indexOf(\"system.\")) !== 0 && (col.collectionName.indexOf(\"houston_\")) !== 0) {\n results.push(col.collectionName);\n }\n }\n return results;\n })();\n return collection_names.forEach(function(name) {\n var e, key, value;\n if (!(name in collections)) {\n try {\n collections[name] = new Meteor.Collection(name);\n } catch (error) {\n e = error;\n for (key in root) {\n value = root[key];\n if (name === value._name) {\n collections[name] = value;\n }\n }\n if (collections[name] == null) {\n console.log(e);\n }\n }\n return set_up_collection(name, collections[name]);\n }\n });\n};\n\nMeteor.methods({\n _houston_make_admin: function([userId]) {\n // limit one admin\n if (Houston._admins.findOne({\n 'user_id': {\n $exists: true\n }\n })) {\n return;\n }\n Houston._admins.insert({\n user_id: userId\n });\n return true;\n }\n});\n\nfn = Meteor.bindEnvironment(save_collections, function(e) {\n return console.log(e);\n});\n\n// MongoInternals is the 'right' solution as of 0.6.5\nmongo_driver = (typeof MongoInternals !== \"undefined\" && MongoInternals !== null ? MongoInternals.defaultRemoteCollectionDriver() : void 0) || Meteor._RemoteCollectionDriver;\n\nmongo_driver.mongo.db.collections(fn);\n\n// publish our analysis of the app's collections\nHouston._publish('collections', function() {\n if (!Houston._user_is_admin(this.userId)) {\n return;\n }\n return Houston._collections.collections.find();\n});\n\n// used by login page to see if admin has been created yet\nHouston._publish('admin_user', function() {\n if (Houston._user_is_admin(this.userId)) {\n return Houston._admins.find({\n user_id: this.userId\n });\n }\n return Houston._admins.find({\n user_id: {\n $exists: true\n }\n }, {\n fields: {\n _id: true\n }\n });\n});\n```", "response": "save_collections = (meh, collections_db) ->\n collection_names = (col.collectionName for col in collections_db \\\n when (col.collectionName.indexOf \"system.\") isnt 0 and\n (col.collectionName.indexOf \"houston_\") isnt 0)\n\n collection_names.forEach (name) ->\n unless name of collections\n try\n collections[name] = new Meteor.Collection(name)\n catch e\n for key, value of root\n if name == value._name\n collections[name] = value\n console.log e unless collections[name]?\n\n set_up_collection(name, collections[name])\n\n Meteor.methods\n _houston_make_admin: ([userId]) ->\n # limit one admin\n return if Houston._admins.findOne {'user_id': $exists: true}\n Houston._admins.insert user_id: userId\n return true\n\n fn = Meteor.bindEnvironment save_collections, (e) ->\n console.log e\n\n # MongoInternals is the 'right' solution as of 0.6.5\n mongo_driver = MongoInternals?.defaultRemoteCollectionDriver() or Meteor._RemoteCollectionDriver\n mongo_driver.mongo.db.collections fn\n\n\n# publish our analysis of the app's collections\nHouston._publish 'collections', ->\n return unless Houston._user_is_admin @userId\n Houston._collections.collections.find()\n\n\n# used by login page to see if admin has been created yet\nHouston._publish 'admin_user', ->\n if Houston._user_is_admin @userId\n return Houston._admins.find user_id: @userId\n Houston._admins.find {user_id: $exists: true}, fields: _id: true", "source_lang": "JavaScript", "target_lang": "CoffeeScript", "repo": "gterrono/houston", "path": "server/publications.coffee", "license": "MIT", "commit": "4b18561921e57c866348c671e76597b67f4ea52e", "stars": 802, "source_url": "https://github.com/gterrono/houston/blob/4b18561921e57c866348c671e76597b67f4ea52e/server/publications.coffee", "line_start": 56, "line_end": 99}884{"id": "gterrono/houston:server/publications.coffee:2:completion", "type": "completion", "prompt": "save_collections = (meh, collections_db) ->\n collection_names = (col.collectionName for col in collections_db \\\n when (col.collectionName.indexOf \"system.\") isnt 0 and\n (col.collectionName.indexOf \"houston_\") isnt 0)\n\n collection_names.forEach (name) ->\n unless name of collections\n try\n collections[name] = new Meteor.Collection(name)\n catch e\n for key, value of root\n if name == value._name\n collections[name] = value\n console.log e unless collections[name]?\n\n set_up_collection(name, collections[name])\n\n Meteor.methods\n _houston_make_admin: ([userId]) ->\n # limit one admin\n return if Houston._admins.findOne {'user_id': $exists: true}", "response": "Houston._admins.insert user_id: userId\n return true\n\n fn = Meteor.bindEnvironment save_collections, (e) ->\n console.log e\n\n # MongoInternals is the 'right' solution as of 0.6.5\n mongo_driver = MongoInternals?.defaultRemoteCollectionDriver() or Meteor._RemoteCollectionDriver\n mongo_driver.mongo.db.collections fn\n\n\n# publish our analysis of the app's collections\nHouston._publish 'collections', ->\n return unless Houston._user_is_admin @userId\n Houston._collections.collections.find()\n\n\n# used by login page to see if admin has been created yet\nHouston._publish 'admin_user', ->\n if Houston._user_is_admin @userId\n return Houston._admins.find user_id: @userId\n Houston._admins.find {user_id: $exists: true}, fields: _id: true", "source_lang": "CoffeeScript", "target_lang": "CoffeeScript", "repo": "gterrono/houston", "path": "server/publications.coffee", "license": "MIT", "commit": "4b18561921e57c866348c671e76597b67f4ea52e", "stars": 802, "source_url": "https://github.com/gterrono/houston/blob/4b18561921e57c866348c671e76597b67f4ea52e/server/publications.coffee", "line_start": 56, "line_end": 99}885{"id": "gterrono/houston:server/publications.coffee:1:raw_corpus", "type": "raw_corpus", "prompt": "", "response": "Houston._publish = (name, func) ->\n Meteor.publish Houston._houstonize(name), func\n\nMeteor.startup ->\n set_up_collection = (name, collection) ->\n methods = {}\n methods[Houston._houstonize \"#{name}_insert\"] = (doc) ->\n return unless Houston._user_is_admin @userId\n collection.insert(doc)\n\n methods[Houston._houstonize \"#{name}_update\"] = (id, update_dict) ->\n return unless Houston._user_is_admin @userId\n if collection.findOne(id)\n collection.update(id, update_dict)\n else\n id = collection.findOne(new Meteor.Collection.ObjectID(id))\n collection.update(id, update_dict)\n\n methods[Houston._houstonize \"#{name}_delete\"] = (id, update_dict) ->\n return unless Houston._user_is_admin @userId\n if collection.findOne(id)\n collection.remove(id)\n else\n id = collection.findOne(new Meteor.Collection.ObjectID(id))\n collection.remove(id)\n\n Meteor.methods methods\n\n Houston._publish name, (sort, filter, limit) ->\n return unless Houston._user_is_admin @userId\n try\n collection.find(filter, sort: sort, limit: limit)\n catch e\n console.log e\n\n collection.find().observe\n added: (document) ->\n Houston._collections.collections.update {name},\n $inc: {count: 1},\n $addToSet: fields: $each: Houston._get_field_names([document])\n removed: (document) -> Houston._collections.collections.update {name}, {$inc: {count: -1}}\n\n fields = Houston._get_field_names(collection.find().fetch())\n c = Houston._collections.collections.findOne {name}\n if c\n Houston._collections.collections.update c._id, {$set: count: collection.find().count(), fields: fields}\n else\n Houston._collections.collections.insert {name, count: collection.find().count(), fields: fields}\n\n Dummy.findOne() # hack", "source_lang": "", "target_lang": "CoffeeScript", "repo": "gterrono/houston", "path": "server/publications.coffee", "license": "MIT", "commit": "ac73043990093b2ecd87e947bd30c1fe3dba1de6", "stars": 802, "source_url": "https://github.com/gterrono/houston/blob/ac73043990093b2ecd87e947bd30c1fe3dba1de6/server/publications.coffee", "line_start": 6, "line_end": 55}886{"id": "gterrono/houston:server/publications.coffee:1:coffee_to_js", "type": "coffee_to_js", "prompt": "Convert this CoffeeScript to JavaScript.\n```coffeescript\nHouston._publish = (name, func) ->\n Meteor.publish Houston._houstonize(name), func\n\nMeteor.startup ->\n set_up_collection = (name, collection) ->\n methods = {}\n methods[Houston._houstonize \"#{name}_insert\"] = (doc) ->\n return unless Houston._user_is_admin @userId\n collection.insert(doc)\n\n methods[Houston._houstonize \"#{name}_update\"] = (id, update_dict) ->\n return unless Houston._user_is_admin @userId\n if collection.findOne(id)\n collection.update(id, update_dict)\n else\n id = collection.findOne(new Meteor.Collection.ObjectID(id))\n collection.update(id, update_dict)\n\n methods[Houston._houstonize \"#{name}_delete\"] = (id, update_dict) ->\n return unless Houston._user_is_admin @userId\n if collection.findOne(id)\n collection.remove(id)\n else\n id = collection.findOne(new Meteor.Collection.ObjectID(id))\n collection.remove(id)\n\n Meteor.methods methods\n\n Houston._publish name, (sort, filter, limit) ->\n return unless Houston._user_is_admin @userId\n try\n collection.find(filter, sort: sort, limit: limit)\n catch e\n console.log e\n\n collection.find().observe\n added: (document) ->\n Houston._collections.collections.update {name},\n $inc: {count: 1},\n $addToSet: fields: $each: Houston._get_field_names([document])\n removed: (document) -> Houston._collections.collections.update {name}, {$inc: {count: -1}}\n\n fields = Houston._get_field_names(collection.find().fetch())\n c = Houston._collections.collections.findOne {name}\n if c\n Houston._collections.collections.update c._id, {$set: count: collection.find().count(), fields: fields}\n else\n Houston._collections.collections.insert {name, count: collection.find().count(), fields: fields}\n\n Dummy.findOne() # hack\n```", "response": "Houston._publish = function(name, func) {\n return Meteor.publish(Houston._houstonize(name), func);\n};\n\nMeteor.startup(function() {\n var set_up_collection;\n set_up_collection = function(name, collection) {\n var c, fields, methods;\n methods = {};\n methods[Houston._houstonize(`${name}_insert`)] = function(doc) {\n if (!Houston._user_is_admin(this.userId)) {\n return;\n }\n return collection.insert(doc);\n };\n methods[Houston._houstonize(`${name}_update`)] = function(id, update_dict) {\n if (!Houston._user_is_admin(this.userId)) {\n return;\n }\n if (collection.findOne(id)) {\n return collection.update(id, update_dict);\n } else {\n id = collection.findOne(new Meteor.Collection.ObjectID(id));\n return collection.update(id, update_dict);\n }\n };\n methods[Houston._houstonize(`${name}_delete`)] = function(id, update_dict) {\n if (!Houston._user_is_admin(this.userId)) {\n return;\n }\n if (collection.findOne(id)) {\n return collection.remove(id);\n } else {\n id = collection.findOne(new Meteor.Collection.ObjectID(id));\n return collection.remove(id);\n }\n };\n Meteor.methods(methods);\n Houston._publish(name, function(sort, filter, limit) {\n var e;\n if (!Houston._user_is_admin(this.userId)) {\n return;\n }\n try {\n return collection.find(filter, {\n sort: sort,\n limit: limit\n });\n } catch (error) {\n e = error;\n return console.log(e);\n }\n });\n collection.find().observe({\n added: function(document) {\n return Houston._collections.collections.update({name}, {\n $inc: {\n count: 1\n },\n $addToSet: {\n fields: {\n $each: Houston._get_field_names([document])\n }\n }\n });\n },\n removed: function(document) {\n return Houston._collections.collections.update({name}, {\n $inc: {\n count: -1\n }\n });\n }\n });\n fields = Houston._get_field_names(collection.find().fetch());\n c = Houston._collections.collections.findOne({name});\n if (c) {\n return Houston._collections.collections.update(c._id, {\n $set: {\n count: collection.find().count(),\n fields: fields\n }\n });\n } else {\n return Houston._collections.collections.insert({\n name,\n count: collection.find().count(),\n fields: fields\n });\n }\n };\n return Dummy.findOne(); // hack\n});", "source_lang": "CoffeeScript", "target_lang": "JavaScript", "repo": "gterrono/houston", "path": "server/publications.coffee", "license": "MIT", "commit": "ac73043990093b2ecd87e947bd30c1fe3dba1de6", "stars": 802, "source_url": "https://github.com/gterrono/houston/blob/ac73043990093b2ecd87e947bd30c1fe3dba1de6/server/publications.coffee", "line_start": 6, "line_end": 55}887{"id": "gterrono/houston:server/publications.coffee:1:js_to_coffee", "type": "js_to_coffee", "prompt": "Convert this JavaScript to CoffeeScript.\n```javascript\nHouston._publish = function(name, func) {\n return Meteor.publish(Houston._houstonize(name), func);\n};\n\nMeteor.startup(function() {\n var set_up_collection;\n set_up_collection = function(name, collection) {\n var c, fields, methods;\n methods = {};\n methods[Houston._houstonize(`${name}_insert`)] = function(doc) {\n if (!Houston._user_is_admin(this.userId)) {\n return;\n }\n return collection.insert(doc);\n };\n methods[Houston._houstonize(`${name}_update`)] = function(id, update_dict) {\n if (!Houston._user_is_admin(this.userId)) {\n return;\n }\n if (collection.findOne(id)) {\n return collection.update(id, update_dict);\n } else {\n id = collection.findOne(new Meteor.Collection.ObjectID(id));\n return collection.update(id, update_dict);\n }\n };\n methods[Houston._houstonize(`${name}_delete`)] = function(id, update_dict) {\n if (!Houston._user_is_admin(this.userId)) {\n return;\n }\n if (collection.findOne(id)) {\n return collection.remove(id);\n } else {\n id = collection.findOne(new Meteor.Collection.ObjectID(id));\n return collection.remove(id);\n }\n };\n Meteor.methods(methods);\n Houston._publish(name, function(sort, filter, limit) {\n var e;\n if (!Houston._user_is_admin(this.userId)) {\n return;\n }\n try {\n return collection.find(filter, {\n sort: sort,\n limit: limit\n });\n } catch (error) {\n e = error;\n return console.log(e);\n }\n });\n collection.find().observe({\n added: function(document) {\n return Houston._collections.collections.update({name}, {\n $inc: {\n count: 1\n },\n $addToSet: {\n fields: {\n $each: Houston._get_field_names([document])\n }\n }\n });\n },\n removed: function(document) {\n return Houston._collections.collections.update({name}, {\n $inc: {\n count: -1\n }\n });\n }\n });\n fields = Houston._get_field_names(collection.find().fetch());\n c = Houston._collections.collections.findOne({name});\n if (c) {\n return Houston._collections.collections.update(c._id, {\n $set: {\n count: collection.find().count(),\n fields: fields\n }\n });\n } else {\n return Houston._collections.collections.insert({\n name,\n count: collection.find().count(),\n fields: fields\n });\n }\n };\n return Dummy.findOne(); // hack\n});\n```", "response": "Houston._publish = (name, func) ->\n Meteor.publish Houston._houstonize(name), func\n\nMeteor.startup ->\n set_up_collection = (name, collection) ->\n methods = {}\n methods[Houston._houstonize \"#{name}_insert\"] = (doc) ->\n return unless Houston._user_is_admin @userId\n collection.insert(doc)\n\n methods[Houston._houstonize \"#{name}_update\"] = (id, update_dict) ->\n return unless Houston._user_is_admin @userId\n if collection.findOne(id)\n collection.update(id, update_dict)\n else\n id = collection.findOne(new Meteor.Collection.ObjectID(id))\n collection.update(id, update_dict)\n\n methods[Houston._houstonize \"#{name}_delete\"] = (id, update_dict) ->\n return unless Houston._user_is_admin @userId\n if collection.findOne(id)\n collection.remove(id)\n else\n id = collection.findOne(new Meteor.Collection.ObjectID(id))\n collection.remove(id)\n\n Meteor.methods methods\n\n Houston._publish name, (sort, filter, limit) ->\n return unless Houston._user_is_admin @userId\n try\n collection.find(filter, sort: sort, limit: limit)\n catch e\n console.log e\n\n collection.find().observe\n added: (document) ->\n Houston._collections.collections.update {name},\n $inc: {count: 1},\n $addToSet: fields: $each: Houston._get_field_names([document])\n removed: (document) -> Houston._collections.collections.update {name}, {$inc: {count: -1}}\n\n fields = Houston._get_field_names(collection.find().fetch())\n c = Houston._collections.collections.findOne {name}\n if c\n Houston._collections.collections.update c._id, {$set: count: collection.find().count(), fields: fields}\n else\n Houston._collections.collections.insert {name, count: collection.find().count(), fields: fields}\n\n Dummy.findOne() # hack", "source_lang": "JavaScript", "target_lang": "CoffeeScript", "repo": "gterrono/houston", "path": "server/publications.coffee", "license": "MIT", "commit": "ac73043990093b2ecd87e947bd30c1fe3dba1de6", "stars": 802, "source_url": "https://github.com/gterrono/houston/blob/ac73043990093b2ecd87e947bd30c1fe3dba1de6/server/publications.coffee", "line_start": 6, "line_end": 55}888{"id": "gterrono/houston:server/publications.coffee:1:completion", "type": "completion", "prompt": "Houston._publish = (name, func) ->\n Meteor.publish Houston._houstonize(name), func\n\nMeteor.startup ->\n set_up_collection = (name, collection) ->\n methods = {}\n methods[Houston._houstonize \"#{name}_insert\"] = (doc) ->\n return unless Houston._user_is_admin @userId\n collection.insert(doc)\n\n methods[Houston._houstonize \"#{name}_update\"] = (id, update_dict) ->\n return unless Houston._user_is_admin @userId\n if collection.findOne(id)\n collection.update(id, update_dict)\n else\n id = collection.findOne(new Meteor.Collection.ObjectID(id))\n collection.update(id, update_dict)\n\n methods[Houston._houstonize \"#{name}_delete\"] = (id, update_dict) ->\n return unless Houston._user_is_admin @userId\n if collection.findOne(id)\n collection.remove(id)\n else\n id = collection.findOne(new Meteor.Collection.ObjectID(id))\n collection.remove(id)", "response": "Meteor.methods methods\n\n Houston._publish name, (sort, filter, limit) ->\n return unless Houston._user_is_admin @userId\n try\n collection.find(filter, sort: sort, limit: limit)\n catch e\n console.log e\n\n collection.find().observe\n added: (document) ->\n Houston._collections.collections.update {name},\n $inc: {count: 1},\n $addToSet: fields: $each: Houston._get_field_names([document])\n removed: (document) -> Houston._collections.collections.update {name}, {$inc: {count: -1}}\n\n fields = Houston._get_field_names(collection.find().fetch())\n c = Houston._collections.collections.findOne {name}\n if c\n Houston._collections.collections.update c._id, {$set: count: collection.find().count(), fields: fields}\n else\n Houston._collections.collections.insert {name, count: collection.find().count(), fields: fields}\n\n Dummy.findOne() # hack", "source_lang": "CoffeeScript", "target_lang": "CoffeeScript", "repo": "gterrono/houston", "path": "server/publications.coffee", "license": "MIT", "commit": "ac73043990093b2ecd87e947bd30c1fe3dba1de6", "stars": 802, "source_url": "https://github.com/gterrono/houston/blob/ac73043990093b2ecd87e947bd30c1fe3dba1de6/server/publications.coffee", "line_start": 6, "line_end": 55}889{"id": "gterrono/houston:server/publications.coffee:2:raw_corpus", "type": "raw_corpus", "prompt": "", "response": "save_collections = (meh, collections_db) ->\n collection_names = (col.collectionName for col in collections_db \\\n when (col.collectionName.indexOf \"system.\") isnt 0 and\n (col.collectionName.indexOf \"houston_\") isnt 0)\n\n collection_names.forEach (name) ->\n unless name of collections\n try\n collections[name] = new Meteor.Collection(name)\n catch e\n for key, value of root\n if name == value._name\n collections[name] = value\n console.log e unless collections[name]?\n\n set_up_collection(name, collections[name])\n\n Meteor.methods\n _houston_make_admin: (userId) ->\n # limit one admin\n return if Houston._admins.findOne {'user_id': $exists: true}\n Houston._admins.insert user_id: userId\n return true\n\n fn = Meteor.bindEnvironment save_collections, (e) ->\n console.log e\n\n # MongoInternals is the 'right' solution as of 0.6.5\n mongo_driver = MongoInternals?.defaultRemoteCollectionDriver() or Meteor._RemoteCollectionDriver\n mongo_driver.mongo.db.collections fn\n\n\n# publish our analysis of the app's collections\nHouston._publish 'collections', ->\n return unless Houston._user_is_admin @userId\n Houston._collections.collections.find()\n\n\n# used by login page to see if admin has been created yet\nHouston._publish 'admin_user', ->\n if Houston._user_is_admin @userId\n return Houston._admins.find user_id: @userId\n Houston._admins.find {user_id: $exists: true}, fields: _id: true", "source_lang": "", "target_lang": "CoffeeScript", "repo": "gterrono/houston", "path": "server/publications.coffee", "license": "MIT", "commit": "ac73043990093b2ecd87e947bd30c1fe3dba1de6", "stars": 802, "source_url": "https://github.com/gterrono/houston/blob/ac73043990093b2ecd87e947bd30c1fe3dba1de6/server/publications.coffee", "line_start": 56, "line_end": 99}890{"id": "gterrono/houston:server/publications.coffee:2:coffee_to_js", "type": "coffee_to_js", "prompt": "Convert this CoffeeScript to JavaScript.\n```coffeescript\nsave_collections = (meh, collections_db) ->\n collection_names = (col.collectionName for col in collections_db \\\n when (col.collectionName.indexOf \"system.\") isnt 0 and\n (col.collectionName.indexOf \"houston_\") isnt 0)\n\n collection_names.forEach (name) ->\n unless name of collections\n try\n collections[name] = new Meteor.Collection(name)\n catch e\n for key, value of root\n if name == value._name\n collections[name] = value\n console.log e unless collections[name]?\n\n set_up_collection(name, collections[name])\n\n Meteor.methods\n _houston_make_admin: (userId) ->\n # limit one admin\n return if Houston._admins.findOne {'user_id': $exists: true}\n Houston._admins.insert user_id: userId\n return true\n\n fn = Meteor.bindEnvironment save_collections, (e) ->\n console.log e\n\n # MongoInternals is the 'right' solution as of 0.6.5\n mongo_driver = MongoInternals?.defaultRemoteCollectionDriver() or Meteor._RemoteCollectionDriver\n mongo_driver.mongo.db.collections fn\n\n\n# publish our analysis of the app's collections\nHouston._publish 'collections', ->\n return unless Houston._user_is_admin @userId\n Houston._collections.collections.find()\n\n\n# used by login page to see if admin has been created yet\nHouston._publish 'admin_user', ->\n if Houston._user_is_admin @userId\n return Houston._admins.find user_id: @userId\n Houston._admins.find {user_id: $exists: true}, fields: _id: true\n```", "response": "var fn, mongo_driver, save_collections;\n\nsave_collections = function(meh, collections_db) {\n var col, collection_names;\n collection_names = (function() {\n var i, len, results;\n results = [];\n for (i = 0, len = collections_db.length; i < len; i++) {\n col = collections_db[i];\n if ((col.collectionName.indexOf(\"system.\")) !== 0 && (col.collectionName.indexOf(\"houston_\")) !== 0) {\n results.push(col.collectionName);\n }\n }\n return results;\n })();\n return collection_names.forEach(function(name) {\n var e, key, value;\n if (!(name in collections)) {\n try {\n collections[name] = new Meteor.Collection(name);\n } catch (error) {\n e = error;\n for (key in root) {\n value = root[key];\n if (name === value._name) {\n collections[name] = value;\n }\n }\n if (collections[name] == null) {\n console.log(e);\n }\n }\n return set_up_collection(name, collections[name]);\n }\n });\n};\n\nMeteor.methods({\n _houston_make_admin: function(userId) {\n // limit one admin\n if (Houston._admins.findOne({\n 'user_id': {\n $exists: true\n }\n })) {\n return;\n }\n Houston._admins.insert({\n user_id: userId\n });\n return true;\n }\n});\n\nfn = Meteor.bindEnvironment(save_collections, function(e) {\n return console.log(e);\n});\n\n// MongoInternals is the 'right' solution as of 0.6.5\nmongo_driver = (typeof MongoInternals !== \"undefined\" && MongoInternals !== null ? MongoInternals.defaultRemoteCollectionDriver() : void 0) || Meteor._RemoteCollectionDriver;\n\nmongo_driver.mongo.db.collections(fn);\n\n// publish our analysis of the app's collections\nHouston._publish('collections', function() {\n if (!Houston._user_is_admin(this.userId)) {\n return;\n }\n return Houston._collections.collections.find();\n});\n\n// used by login page to see if admin has been created yet\nHouston._publish('admin_user', function() {\n if (Houston._user_is_admin(this.userId)) {\n return Houston._admins.find({\n user_id: this.userId\n });\n }\n return Houston._admins.find({\n user_id: {\n $exists: true\n }\n }, {\n fields: {\n _id: true\n }\n });\n});", "source_lang": "CoffeeScript", "target_lang": "JavaScript", "repo": "gterrono/houston", "path": "server/publications.coffee", "license": "MIT", "commit": "ac73043990093b2ecd87e947bd30c1fe3dba1de6", "stars": 802, "source_url": "https://github.com/gterrono/houston/blob/ac73043990093b2ecd87e947bd30c1fe3dba1de6/server/publications.coffee", "line_start": 56, "line_end": 99}891{"id": "gterrono/houston:server/publications.coffee:2:js_to_coffee", "type": "js_to_coffee", "prompt": "Convert this JavaScript to CoffeeScript.\n```javascript\nvar fn, mongo_driver, save_collections;\n\nsave_collections = function(meh, collections_db) {\n var col, collection_names;\n collection_names = (function() {\n var i, len, results;\n results = [];\n for (i = 0, len = collections_db.length; i < len; i++) {\n col = collections_db[i];\n if ((col.collectionName.indexOf(\"system.\")) !== 0 && (col.collectionName.indexOf(\"houston_\")) !== 0) {\n results.push(col.collectionName);\n }\n }\n return results;\n })();\n return collection_names.forEach(function(name) {\n var e, key, value;\n if (!(name in collections)) {\n try {\n collections[name] = new Meteor.Collection(name);\n } catch (error) {\n e = error;\n for (key in root) {\n value = root[key];\n if (name === value._name) {\n collections[name] = value;\n }\n }\n if (collections[name] == null) {\n console.log(e);\n }\n }\n return set_up_collection(name, collections[name]);\n }\n });\n};\n\nMeteor.methods({\n _houston_make_admin: function(userId) {\n // limit one admin\n if (Houston._admins.findOne({\n 'user_id': {\n $exists: true\n }\n })) {\n return;\n }\n Houston._admins.insert({\n user_id: userId\n });\n return true;\n }\n});\n\nfn = Meteor.bindEnvironment(save_collections, function(e) {\n return console.log(e);\n});\n\n// MongoInternals is the 'right' solution as of 0.6.5\nmongo_driver = (typeof MongoInternals !== \"undefined\" && MongoInternals !== null ? MongoInternals.defaultRemoteCollectionDriver() : void 0) || Meteor._RemoteCollectionDriver;\n\nmongo_driver.mongo.db.collections(fn);\n\n// publish our analysis of the app's collections\nHouston._publish('collections', function() {\n if (!Houston._user_is_admin(this.userId)) {\n return;\n }\n return Houston._collections.collections.find();\n});\n\n// used by login page to see if admin has been created yet\nHouston._publish('admin_user', function() {\n if (Houston._user_is_admin(this.userId)) {\n return Houston._admins.find({\n user_id: this.userId\n });\n }\n return Houston._admins.find({\n user_id: {\n $exists: true\n }\n }, {\n fields: {\n _id: true\n }\n });\n});\n```", "response": "save_collections = (meh, collections_db) ->\n collection_names = (col.collectionName for col in collections_db \\\n when (col.collectionName.indexOf \"system.\") isnt 0 and\n (col.collectionName.indexOf \"houston_\") isnt 0)\n\n collection_names.forEach (name) ->\n unless name of collections\n try\n collections[name] = new Meteor.Collection(name)\n catch e\n for key, value of root\n if name == value._name\n collections[name] = value\n console.log e unless collections[name]?\n\n set_up_collection(name, collections[name])\n\n Meteor.methods\n _houston_make_admin: (userId) ->\n # limit one admin\n return if Houston._admins.findOne {'user_id': $exists: true}\n Houston._admins.insert user_id: userId\n return true\n\n fn = Meteor.bindEnvironment save_collections, (e) ->\n console.log e\n\n # MongoInternals is the 'right' solution as of 0.6.5\n mongo_driver = MongoInternals?.defaultRemoteCollectionDriver() or Meteor._RemoteCollectionDriver\n mongo_driver.mongo.db.collections fn\n\n\n# publish our analysis of the app's collections\nHouston._publish 'collections', ->\n return unless Houston._user_is_admin @userId\n Houston._collections.collections.find()\n\n\n# used by login page to see if admin has been created yet\nHouston._publish 'admin_user', ->\n if Houston._user_is_admin @userId\n return Houston._admins.find user_id: @userId\n Houston._admins.find {user_id: $exists: true}, fields: _id: true", "source_lang": "JavaScript", "target_lang": "CoffeeScript", "repo": "gterrono/houston", "path": "server/publications.coffee", "license": "MIT", "commit": "ac73043990093b2ecd87e947bd30c1fe3dba1de6", "stars": 802, "source_url": "https://github.com/gterrono/houston/blob/ac73043990093b2ecd87e947bd30c1fe3dba1de6/server/publications.coffee", "line_start": 56, "line_end": 99}892{"id": "gterrono/houston:server/publications.coffee:2:completion", "type": "completion", "prompt": "save_collections = (meh, collections_db) ->\n collection_names = (col.collectionName for col in collections_db \\\n when (col.collectionName.indexOf \"system.\") isnt 0 and\n (col.collectionName.indexOf \"houston_\") isnt 0)\n\n collection_names.forEach (name) ->\n unless name of collections\n try\n collections[name] = new Meteor.Collection(name)\n catch e\n for key, value of root\n if name == value._name\n collections[name] = value\n console.log e unless collections[name]?\n\n set_up_collection(name, collections[name])\n\n Meteor.methods\n _houston_make_admin: (userId) ->\n # limit one admin\n return if Houston._admins.findOne {'user_id': $exists: true}", "response": "Houston._admins.insert user_id: userId\n return true\n\n fn = Meteor.bindEnvironment save_collections, (e) ->\n console.log e\n\n # MongoInternals is the 'right' solution as of 0.6.5\n mongo_driver = MongoInternals?.defaultRemoteCollectionDriver() or Meteor._RemoteCollectionDriver\n mongo_driver.mongo.db.collections fn\n\n\n# publish our analysis of the app's collections\nHouston._publish 'collections', ->\n return unless Houston._user_is_admin @userId\n Houston._collections.collections.find()\n\n\n# used by login page to see if admin has been created yet\nHouston._publish 'admin_user', ->\n if Houston._user_is_admin @userId\n return Houston._admins.find user_id: @userId\n Houston._admins.find {user_id: $exists: true}, fields: _id: true", "source_lang": "CoffeeScript", "target_lang": "CoffeeScript", "repo": "gterrono/houston", "path": "server/publications.coffee", "license": "MIT", "commit": "ac73043990093b2ecd87e947bd30c1fe3dba1de6", "stars": 802, "source_url": "https://github.com/gterrono/houston/blob/ac73043990093b2ecd87e947bd30c1fe3dba1de6/server/publications.coffee", "line_start": 56, "line_end": 99}893{"id": "gterrono/houston:server/publications.coffee:1:raw_corpus", "type": "raw_corpus", "prompt": "", "response": "Houston._publish = (name, func) ->\n Meteor.publish Houston._houstonize(name), func\n\nMeteor.startup ->\n set_up_collection = (name, collection) ->\n methods = {}\n methods[Houston._houstonize \"#{name}_insert\"] = ([doc]) ->\n return unless @userId\n user = Meteor.users.findOne(@userId)\n return unless user?.profile.admin\n collection.insert(doc)\n\n methods[Houston._houstonize \"#{name}_update\"] = ([id, update_dict]) ->\n return unless @userId\n user = Meteor.users.findOne(@userId)\n return unless user?.profile.admin\n if collection.findOne(id)\n collection.update(id, update_dict)\n else\n id = collection.findOne(new Meteor.Collection.ObjectID(id))\n collection.update(id, update_dict)\n\n methods[Houston._houstonize \"#{name}_delete\"] = ([id, update_dict]) ->\n return unless @userId\n user = Meteor.users.findOne(@userId)\n return unless user?.profile.admin\n if collection.findOne(id)\n collection.remove(id)\n else\n id = collection.findOne(new Meteor.Collection.ObjectID(id))\n collection.remove(id)\n\n Meteor.methods methods\n\n Houston._publish name, (sort, filter, limit) ->\n if Meteor.users.findOne(_id: @userId, 'profile.admin': true)\n try\n collection.find(filter, sort: sort, limit: limit)\n catch e\n console.log e\n\n collection.find().observe\n added: (document) ->\n Houston._collections.collections.update {name},\n $inc: {count: 1},\n $addToSet: fields: $each: Houston._get_field_names([document])\n removed: (document) -> Houston._collections.collections.update {name}, {$inc: {count: -1}}\n\n fields = Houston._get_field_names(collection.find().fetch())\n c = Houston._collections.collections.findOne {name}", "source_lang": "", "target_lang": "CoffeeScript", "repo": "gterrono/houston", "path": "server/publications.coffee", "license": "MIT", "commit": "c64d37df458f49f3aec190bdf793fa665473895a", "stars": 802, "source_url": "https://github.com/gterrono/houston/blob/c64d37df458f49f3aec190bdf793fa665473895a/server/publications.coffee", "line_start": 6, "line_end": 55}894{"id": "gterrono/houston:server/publications.coffee:1:coffee_to_js", "type": "coffee_to_js", "prompt": "Convert this CoffeeScript to JavaScript.\n```coffeescript\nHouston._publish = (name, func) ->\n Meteor.publish Houston._houstonize(name), func\n\nMeteor.startup ->\n set_up_collection = (name, collection) ->\n methods = {}\n methods[Houston._houstonize \"#{name}_insert\"] = ([doc]) ->\n return unless @userId\n user = Meteor.users.findOne(@userId)\n return unless user?.profile.admin\n collection.insert(doc)\n\n methods[Houston._houstonize \"#{name}_update\"] = ([id, update_dict]) ->\n return unless @userId\n user = Meteor.users.findOne(@userId)\n return unless user?.profile.admin\n if collection.findOne(id)\n collection.update(id, update_dict)\n else\n id = collection.findOne(new Meteor.Collection.ObjectID(id))\n collection.update(id, update_dict)\n\n methods[Houston._houstonize \"#{name}_delete\"] = ([id, update_dict]) ->\n return unless @userId\n user = Meteor.users.findOne(@userId)\n return unless user?.profile.admin\n if collection.findOne(id)\n collection.remove(id)\n else\n id = collection.findOne(new Meteor.Collection.ObjectID(id))\n collection.remove(id)\n\n Meteor.methods methods\n\n Houston._publish name, (sort, filter, limit) ->\n if Meteor.users.findOne(_id: @userId, 'profile.admin': true)\n try\n collection.find(filter, sort: sort, limit: limit)\n catch e\n console.log e\n\n collection.find().observe\n added: (document) ->\n Houston._collections.collections.update {name},\n $inc: {count: 1},\n $addToSet: fields: $each: Houston._get_field_names([document])\n removed: (document) -> Houston._collections.collections.update {name}, {$inc: {count: -1}}\n\n fields = Houston._get_field_names(collection.find().fetch())\n c = Houston._collections.collections.findOne {name}\n```", "response": "Houston._publish = function(name, func) {\n return Meteor.publish(Houston._houstonize(name), func);\n};\n\nMeteor.startup(function() {\n var set_up_collection;\n return set_up_collection = function(name, collection) {\n var c, fields, methods;\n methods = {};\n methods[Houston._houstonize(`${name}_insert`)] = function([doc]) {\n var user;\n if (!this.userId) {\n return;\n }\n user = Meteor.users.findOne(this.userId);\n if (!(user != null ? user.profile.admin : void 0)) {\n return;\n }\n return collection.insert(doc);\n };\n methods[Houston._houstonize(`${name}_update`)] = function([id, update_dict]) {\n var user;\n if (!this.userId) {\n return;\n }\n user = Meteor.users.findOne(this.userId);\n if (!(user != null ? user.profile.admin : void 0)) {\n return;\n }\n if (collection.findOne(id)) {\n return collection.update(id, update_dict);\n } else {\n id = collection.findOne(new Meteor.Collection.ObjectID(id));\n return collection.update(id, update_dict);\n }\n };\n methods[Houston._houstonize(`${name}_delete`)] = function([id, update_dict]) {\n var user;\n if (!this.userId) {\n return;\n }\n user = Meteor.users.findOne(this.userId);\n if (!(user != null ? user.profile.admin : void 0)) {\n return;\n }\n if (collection.findOne(id)) {\n return collection.remove(id);\n } else {\n id = collection.findOne(new Meteor.Collection.ObjectID(id));\n return collection.remove(id);\n }\n };\n Meteor.methods(methods);\n Houston._publish(name, function(sort, filter, limit) {\n var e;\n if (Meteor.users.findOne({\n _id: this.userId,\n 'profile.admin': true\n })) {\n try {\n return collection.find(filter, {\n sort: sort,\n limit: limit\n });\n } catch (error) {\n e = error;\n return console.log(e);\n }\n }\n });\n collection.find().observe({\n added: function(document) {\n return Houston._collections.collections.update({name}, {\n $inc: {\n count: 1\n },\n $addToSet: {\n fields: {\n $each: Houston._get_field_names([document])\n }\n }\n });\n },\n removed: function(document) {\n return Houston._collections.collections.update({name}, {\n $inc: {\n count: -1\n }\n });\n }\n });\n fields = Houston._get_field_names(collection.find().fetch());\n return c = Houston._collections.collections.findOne({name});\n };\n});", "source_lang": "CoffeeScript", "target_lang": "JavaScript", "repo": "gterrono/houston", "path": "server/publications.coffee", "license": "MIT", "commit": "c64d37df458f49f3aec190bdf793fa665473895a", "stars": 802, "source_url": "https://github.com/gterrono/houston/blob/c64d37df458f49f3aec190bdf793fa665473895a/server/publications.coffee", "line_start": 6, "line_end": 55}895{"id": "gterrono/houston:server/publications.coffee:1:js_to_coffee", "type": "js_to_coffee", "prompt": "Convert this JavaScript to CoffeeScript.\n```javascript\nHouston._publish = function(name, func) {\n return Meteor.publish(Houston._houstonize(name), func);\n};\n\nMeteor.startup(function() {\n var set_up_collection;\n return set_up_collection = function(name, collection) {\n var c, fields, methods;\n methods = {};\n methods[Houston._houstonize(`${name}_insert`)] = function([doc]) {\n var user;\n if (!this.userId) {\n return;\n }\n user = Meteor.users.findOne(this.userId);\n if (!(user != null ? user.profile.admin : void 0)) {\n return;\n }\n return collection.insert(doc);\n };\n methods[Houston._houstonize(`${name}_update`)] = function([id, update_dict]) {\n var user;\n if (!this.userId) {\n return;\n }\n user = Meteor.users.findOne(this.userId);\n if (!(user != null ? user.profile.admin : void 0)) {\n return;\n }\n if (collection.findOne(id)) {\n return collection.update(id, update_dict);\n } else {\n id = collection.findOne(new Meteor.Collection.ObjectID(id));\n return collection.update(id, update_dict);\n }\n };\n methods[Houston._houstonize(`${name}_delete`)] = function([id, update_dict]) {\n var user;\n if (!this.userId) {\n return;\n }\n user = Meteor.users.findOne(this.userId);\n if (!(user != null ? user.profile.admin : void 0)) {\n return;\n }\n if (collection.findOne(id)) {\n return collection.remove(id);\n } else {\n id = collection.findOne(new Meteor.Collection.ObjectID(id));\n return collection.remove(id);\n }\n };\n Meteor.methods(methods);\n Houston._publish(name, function(sort, filter, limit) {\n var e;\n if (Meteor.users.findOne({\n _id: this.userId,\n 'profile.admin': true\n })) {\n try {\n return collection.find(filter, {\n sort: sort,\n limit: limit\n });\n } catch (error) {\n e = error;\n return console.log(e);\n }\n }\n });\n collection.find().observe({\n added: function(document) {\n return Houston._collections.collections.update({name}, {\n $inc: {\n count: 1\n },\n $addToSet: {\n fields: {\n $each: Houston._get_field_names([document])\n }\n }\n });\n },\n removed: function(document) {\n return Houston._collections.collections.update({name}, {\n $inc: {\n count: -1\n }\n });\n }\n });\n fields = Houston._get_field_names(collection.find().fetch());\n return c = Houston._collections.collections.findOne({name});\n };\n});\n```", "response": "Houston._publish = (name, func) ->\n Meteor.publish Houston._houstonize(name), func\n\nMeteor.startup ->\n set_up_collection = (name, collection) ->\n methods = {}\n methods[Houston._houstonize \"#{name}_insert\"] = ([doc]) ->\n return unless @userId\n user = Meteor.users.findOne(@userId)\n return unless user?.profile.admin\n collection.insert(doc)\n\n methods[Houston._houstonize \"#{name}_update\"] = ([id, update_dict]) ->\n return unless @userId\n user = Meteor.users.findOne(@userId)\n return unless user?.profile.admin\n if collection.findOne(id)\n collection.update(id, update_dict)\n else\n id = collection.findOne(new Meteor.Collection.ObjectID(id))\n collection.update(id, update_dict)\n\n methods[Houston._houstonize \"#{name}_delete\"] = ([id, update_dict]) ->\n return unless @userId\n user = Meteor.users.findOne(@userId)\n return unless user?.profile.admin\n if collection.findOne(id)\n collection.remove(id)\n else\n id = collection.findOne(new Meteor.Collection.ObjectID(id))\n collection.remove(id)\n\n Meteor.methods methods\n\n Houston._publish name, (sort, filter, limit) ->\n if Meteor.users.findOne(_id: @userId, 'profile.admin': true)\n try\n collection.find(filter, sort: sort, limit: limit)\n catch e\n console.log e\n\n collection.find().observe\n added: (document) ->\n Houston._collections.collections.update {name},\n $inc: {count: 1},\n $addToSet: fields: $each: Houston._get_field_names([document])\n removed: (document) -> Houston._collections.collections.update {name}, {$inc: {count: -1}}\n\n fields = Houston._get_field_names(collection.find().fetch())\n c = Houston._collections.collections.findOne {name}", "source_lang": "JavaScript", "target_lang": "CoffeeScript", "repo": "gterrono/houston", "path": "server/publications.coffee", "license": "MIT", "commit": "c64d37df458f49f3aec190bdf793fa665473895a", "stars": 802, "source_url": "https://github.com/gterrono/houston/blob/c64d37df458f49f3aec190bdf793fa665473895a/server/publications.coffee", "line_start": 6, "line_end": 55}896{"id": "gterrono/houston:server/publications.coffee:1:completion", "type": "completion", "prompt": "Houston._publish = (name, func) ->\n Meteor.publish Houston._houstonize(name), func\n\nMeteor.startup ->\n set_up_collection = (name, collection) ->\n methods = {}\n methods[Houston._houstonize \"#{name}_insert\"] = ([doc]) ->\n return unless @userId\n user = Meteor.users.findOne(@userId)\n return unless user?.profile.admin\n collection.insert(doc)\n\n methods[Houston._houstonize \"#{name}_update\"] = ([id, update_dict]) ->\n return unless @userId\n user = Meteor.users.findOne(@userId)\n return unless user?.profile.admin\n if collection.findOne(id)\n collection.update(id, update_dict)\n else\n id = collection.findOne(new Meteor.Collection.ObjectID(id))\n collection.update(id, update_dict)\n\n methods[Houston._houstonize \"#{name}_delete\"] = ([id, update_dict]) ->\n return unless @userId\n user = Meteor.users.findOne(@userId)", "response": "return unless user?.profile.admin\n if collection.findOne(id)\n collection.remove(id)\n else\n id = collection.findOne(new Meteor.Collection.ObjectID(id))\n collection.remove(id)\n\n Meteor.methods methods\n\n Houston._publish name, (sort, filter, limit) ->\n if Meteor.users.findOne(_id: @userId, 'profile.admin': true)\n try\n collection.find(filter, sort: sort, limit: limit)\n catch e\n console.log e\n\n collection.find().observe\n added: (document) ->\n Houston._collections.collections.update {name},\n $inc: {count: 1},\n $addToSet: fields: $each: Houston._get_field_names([document])\n removed: (document) -> Houston._collections.collections.update {name}, {$inc: {count: -1}}\n\n fields = Houston._get_field_names(collection.find().fetch())\n c = Houston._collections.collections.findOne {name}", "source_lang": "CoffeeScript", "target_lang": "CoffeeScript", "repo": "gterrono/houston", "path": "server/publications.coffee", "license": "MIT", "commit": "c64d37df458f49f3aec190bdf793fa665473895a", "stars": 802, "source_url": "https://github.com/gterrono/houston/blob/c64d37df458f49f3aec190bdf793fa665473895a/server/publications.coffee", "line_start": 6, "line_end": 55}897{"id": "gterrono/houston:server/publications.coffee:2:raw_corpus", "type": "raw_corpus", "prompt": "", "response": "if c\n Houston._collections.collections.update c._id, {$set: count: collection.find().count(), fields: fields}\n else\n Houston._collections.collections.insert {name, count: collection.find().count(), fields: fields}\n\n Dummy.findOne() # hack\n\n save_collections = (meh, collections_db) ->\n collection_names = (col.collectionName for col in collections_db \\\n when (col.collectionName.indexOf \"system.\") isnt 0 and\n (col.collectionName.indexOf \"houston_\") isnt 0)\n\n collection_names.forEach (name) ->\n unless name of collections\n try\n collections[name] = new Meteor.Collection(name)\n catch e\n for key, value of root\n if name == value._name\n collections[name] = value\n console.log e unless collections[name]?\n\n set_up_collection(name, collections[name])\n\n Meteor.methods\n _houston_make_admin: ([userId]) ->\n # limit one admin\n return if Meteor.users.findOne {'profile.admin': true}\n Meteor.users.update userId, $set: {'profile.admin': true}\n return true\n\n fn = Meteor.bindEnvironment save_collections, (e) ->\n console.log e\n\n # MongoInternals is the 'right' solution as of 0.6.5\n mongo_driver = MongoInternals?.defaultRemoteCollectionDriver() or Meteor._RemoteCollectionDriver\n mongo_driver.mongo.db.collections fn\n\n\n# publish our own internal state\nMeteor.publish '_houston', ->\n if Meteor.users.findOne(_id: @userId, 'profile.admin': true)\n Houston._collections.collections.find()\n\n\nHouston._publish 'adminUser', -> # used by login page to see if admin has been created yet\n Meteor.users.find({'profile.admin': true}, fields: 'profile.admin': true)", "source_lang": "", "target_lang": "CoffeeScript", "repo": "gterrono/houston", "path": "server/publications.coffee", "license": "MIT", "commit": "c64d37df458f49f3aec190bdf793fa665473895a", "stars": 802, "source_url": "https://github.com/gterrono/houston/blob/c64d37df458f49f3aec190bdf793fa665473895a/server/publications.coffee", "line_start": 56, "line_end": 102}898{"id": "gterrono/houston:server/publications.coffee:2:coffee_to_js", "type": "coffee_to_js", "prompt": "Convert this CoffeeScript to JavaScript.\n```coffeescript\nif c\n Houston._collections.collections.update c._id, {$set: count: collection.find().count(), fields: fields}\n else\n Houston._collections.collections.insert {name, count: collection.find().count(), fields: fields}\n\n Dummy.findOne() # hack\n\n save_collections = (meh, collections_db) ->\n collection_names = (col.collectionName for col in collections_db \\\n when (col.collectionName.indexOf \"system.\") isnt 0 and\n (col.collectionName.indexOf \"houston_\") isnt 0)\n\n collection_names.forEach (name) ->\n unless name of collections\n try\n collections[name] = new Meteor.Collection(name)\n catch e\n for key, value of root\n if name == value._name\n collections[name] = value\n console.log e unless collections[name]?\n\n set_up_collection(name, collections[name])\n\n Meteor.methods\n _houston_make_admin: ([userId]) ->\n # limit one admin\n return if Meteor.users.findOne {'profile.admin': true}\n Meteor.users.update userId, $set: {'profile.admin': true}\n return true\n\n fn = Meteor.bindEnvironment save_collections, (e) ->\n console.log e\n\n # MongoInternals is the 'right' solution as of 0.6.5\n mongo_driver = MongoInternals?.defaultRemoteCollectionDriver() or Meteor._RemoteCollectionDriver\n mongo_driver.mongo.db.collections fn\n\n\n# publish our own internal state\nMeteor.publish '_houston', ->\n if Meteor.users.findOne(_id: @userId, 'profile.admin': true)\n Houston._collections.collections.find()\n\n\nHouston._publish 'adminUser', -> # used by login page to see if admin has been created yet\n Meteor.users.find({'profile.admin': true}, fields: 'profile.admin': true)\n```", "response": "var fn, mongo_driver, save_collections;\n\nif (c) {\n Houston._collections.collections.update(c._id, {\n $set: {\n count: collection.find().count(),\n fields: fields\n }\n });\n} else {\n Houston._collections.collections.insert({\n name,\n count: collection.find().count(),\n fields: fields\n });\n}\n\nDummy.findOne(); // hack\n\nsave_collections = function(meh, collections_db) {\n var col, collection_names;\n collection_names = (function() {\n var i, len, results;\n results = [];\n for (i = 0, len = collections_db.length; i < len; i++) {\n col = collections_db[i];\n if ((col.collectionName.indexOf(\"system.\")) !== 0 && (col.collectionName.indexOf(\"houston_\")) !== 0) {\n results.push(col.collectionName);\n }\n }\n return results;\n })();\n return collection_names.forEach(function(name) {\n var e, key, value;\n if (!(name in collections)) {\n try {\n collections[name] = new Meteor.Collection(name);\n } catch (error) {\n e = error;\n for (key in root) {\n value = root[key];\n if (name === value._name) {\n collections[name] = value;\n }\n }\n if (collections[name] == null) {\n console.log(e);\n }\n }\n return set_up_collection(name, collections[name]);\n }\n });\n};\n\nMeteor.methods({\n _houston_make_admin: function([userId]) {\n // limit one admin\n if (Meteor.users.findOne({\n 'profile.admin': true\n })) {\n return;\n }\n Meteor.users.update(userId, {\n $set: {\n 'profile.admin': true\n }\n });\n return true;\n }\n});\n\nfn = Meteor.bindEnvironment(save_collections, function(e) {\n return console.log(e);\n});\n\n// MongoInternals is the 'right' solution as of 0.6.5\nmongo_driver = (typeof MongoInternals !== \"undefined\" && MongoInternals !== null ? MongoInternals.defaultRemoteCollectionDriver() : void 0) || Meteor._RemoteCollectionDriver;\n\nmongo_driver.mongo.db.collections(fn);\n\n// publish our own internal state\nMeteor.publish('_houston', function() {\n if (Meteor.users.findOne({\n _id: this.userId,\n 'profile.admin': true\n })) {\n return Houston._collections.collections.find();\n }\n});\n\nHouston._publish('adminUser', function() { // used by login page to see if admin has been created yet\n return Meteor.users.find({\n 'profile.admin': true\n }, {\n fields: {\n 'profile.admin': true\n }\n });\n});", "source_lang": "CoffeeScript", "target_lang": "JavaScript", "repo": "gterrono/houston", "path": "server/publications.coffee", "license": "MIT", "commit": "c64d37df458f49f3aec190bdf793fa665473895a", "stars": 802, "source_url": "https://github.com/gterrono/houston/blob/c64d37df458f49f3aec190bdf793fa665473895a/server/publications.coffee", "line_start": 56, "line_end": 102}899{"id": "gterrono/houston:server/publications.coffee:2:js_to_coffee", "type": "js_to_coffee", "prompt": "Convert this JavaScript to CoffeeScript.\n```javascript\nvar fn, mongo_driver, save_collections;\n\nif (c) {\n Houston._collections.collections.update(c._id, {\n $set: {\n count: collection.find().count(),\n fields: fields\n }\n });\n} else {\n Houston._collections.collections.insert({\n name,\n count: collection.find().count(),\n fields: fields\n });\n}\n\nDummy.findOne(); // hack\n\nsave_collections = function(meh, collections_db) {\n var col, collection_names;\n collection_names = (function() {\n var i, len, results;\n results = [];\n for (i = 0, len = collections_db.length; i < len; i++) {\n col = collections_db[i];\n if ((col.collectionName.indexOf(\"system.\")) !== 0 && (col.collectionName.indexOf(\"houston_\")) !== 0) {\n results.push(col.collectionName);\n }\n }\n return results;\n })();\n return collection_names.forEach(function(name) {\n var e, key, value;\n if (!(name in collections)) {\n try {\n collections[name] = new Meteor.Collection(name);\n } catch (error) {\n e = error;\n for (key in root) {\n value = root[key];\n if (name === value._name) {\n collections[name] = value;\n }\n }\n if (collections[name] == null) {\n console.log(e);\n }\n }\n return set_up_collection(name, collections[name]);\n }\n });\n};\n\nMeteor.methods({\n _houston_make_admin: function([userId]) {\n // limit one admin\n if (Meteor.users.findOne({\n 'profile.admin': true\n })) {\n return;\n }\n Meteor.users.update(userId, {\n $set: {\n 'profile.admin': true\n }\n });\n return true;\n }\n});\n\nfn = Meteor.bindEnvironment(save_collections, function(e) {\n return console.log(e);\n});\n\n// MongoInternals is the 'right' solution as of 0.6.5\nmongo_driver = (typeof MongoInternals !== \"undefined\" && MongoInternals !== null ? MongoInternals.defaultRemoteCollectionDriver() : void 0) || Meteor._RemoteCollectionDriver;\n\nmongo_driver.mongo.db.collections(fn);\n\n// publish our own internal state\nMeteor.publish('_houston', function() {\n if (Meteor.users.findOne({\n _id: this.userId,\n 'profile.admin': true\n })) {\n return Houston._collections.collections.find();\n }\n});\n\nHouston._publish('adminUser', function() { // used by login page to see if admin has been created yet\n return Meteor.users.find({\n 'profile.admin': true\n }, {\n fields: {\n 'profile.admin': true\n }\n });\n});\n```", "response": "if c\n Houston._collections.collections.update c._id, {$set: count: collection.find().count(), fields: fields}\n else\n Houston._collections.collections.insert {name, count: collection.find().count(), fields: fields}\n\n Dummy.findOne() # hack\n\n save_collections = (meh, collections_db) ->\n collection_names = (col.collectionName for col in collections_db \\\n when (col.collectionName.indexOf \"system.\") isnt 0 and\n (col.collectionName.indexOf \"houston_\") isnt 0)\n\n collection_names.forEach (name) ->\n unless name of collections\n try\n collections[name] = new Meteor.Collection(name)\n catch e\n for key, value of root\n if name == value._name\n collections[name] = value\n console.log e unless collections[name]?\n\n set_up_collection(name, collections[name])\n\n Meteor.methods\n _houston_make_admin: ([userId]) ->\n # limit one admin\n return if Meteor.users.findOne {'profile.admin': true}\n Meteor.users.update userId, $set: {'profile.admin': true}\n return true\n\n fn = Meteor.bindEnvironment save_collections, (e) ->\n console.log e\n\n # MongoInternals is the 'right' solution as of 0.6.5\n mongo_driver = MongoInternals?.defaultRemoteCollectionDriver() or Meteor._RemoteCollectionDriver\n mongo_driver.mongo.db.collections fn\n\n\n# publish our own internal state\nMeteor.publish '_houston', ->\n if Meteor.users.findOne(_id: @userId, 'profile.admin': true)\n Houston._collections.collections.find()\n\n\nHouston._publish 'adminUser', -> # used by login page to see if admin has been created yet\n Meteor.users.find({'profile.admin': true}, fields: 'profile.admin': true)", "source_lang": "JavaScript", "target_lang": "CoffeeScript", "repo": "gterrono/houston", "path": "server/publications.coffee", "license": "MIT", "commit": "c64d37df458f49f3aec190bdf793fa665473895a", "stars": 802, "source_url": "https://github.com/gterrono/houston/blob/c64d37df458f49f3aec190bdf793fa665473895a/server/publications.coffee", "line_start": 56, "line_end": 102}900{"id": "gterrono/houston:server/publications.coffee:2:completion", "type": "completion", "prompt": "if c\n Houston._collections.collections.update c._id, {$set: count: collection.find().count(), fields: fields}\n else\n Houston._collections.collections.insert {name, count: collection.find().count(), fields: fields}\n\n Dummy.findOne() # hack\n\n save_collections = (meh, collections_db) ->\n collection_names = (col.collectionName for col in collections_db \\\n when (col.collectionName.indexOf \"system.\") isnt 0 and\n (col.collectionName.indexOf \"houston_\") isnt 0)\n\n collection_names.forEach (name) ->\n unless name of collections\n try\n collections[name] = new Meteor.Collection(name)\n catch e\n for key, value of root\n if name == value._name\n collections[name] = value\n console.log e unless collections[name]?\n\n set_up_collection(name, collections[name])", "response": "Meteor.methods\n _houston_make_admin: ([userId]) ->\n # limit one admin\n return if Meteor.users.findOne {'profile.admin': true}\n Meteor.users.update userId, $set: {'profile.admin': true}\n return true\n\n fn = Meteor.bindEnvironment save_collections, (e) ->\n console.log e\n\n # MongoInternals is the 'right' solution as of 0.6.5\n mongo_driver = MongoInternals?.defaultRemoteCollectionDriver() or Meteor._RemoteCollectionDriver\n mongo_driver.mongo.db.collections fn\n\n\n# publish our own internal state\nMeteor.publish '_houston', ->\n if Meteor.users.findOne(_id: @userId, 'profile.admin': true)\n Houston._collections.collections.find()\n\n\nHouston._publish 'adminUser', -> # used by login page to see if admin has been created yet\n Meteor.users.find({'profile.admin': true}, fields: 'profile.admin': true)", "source_lang": "CoffeeScript", "target_lang": "CoffeeScript", "repo": "gterrono/houston", "path": "server/publications.coffee", "license": "MIT", "commit": "c64d37df458f49f3aec190bdf793fa665473895a", "stars": 802, "source_url": "https://github.com/gterrono/houston/blob/c64d37df458f49f3aec190bdf793fa665473895a/server/publications.coffee", "line_start": 56, "line_end": 102}901{"id": "gterrono/houston:server/publications.coffee:1:raw_corpus", "type": "raw_corpus", "prompt": "", "response": "root = exports ? this\n\nDummy = new Meteor.Collection(\"system.dummy\") # hack.\ncollections = {'users': Meteor.users}\n\nMeteor.startup ->\n set_up_collection = (name, collection) ->\n methods = {}\n methods[\"_houston_#{name}_insert\"] = (doc) ->\n return unless @userId\n user = Meteor.users.findOne(@userId)\n return unless user?.profile.admin\n collection.insert(doc)\n\n methods[\"_houston_#{name}_update\"] = (id, update_dict) ->\n return unless @userId\n user = Meteor.users.findOne(@userId)\n return unless user?.profile.admin\n if collection.findOne(id)\n collection.update(id, update_dict)\n else\n id = collection.findOne(new Meteor.Collection.ObjectID(id))\n collection.update(id, update_dict)\n\n methods[\"_houston_#{name}_delete\"] = (id, update_dict) ->\n return unless @userId\n user = Meteor.users.findOne(@userId)\n return unless user?.profile.admin\n if collection.findOne(id)\n collection.remove(id)\n else\n id = collection.findOne(new Meteor.Collection.ObjectID(id))\n collection.remove(id)\n\n Meteor.methods methods\n\n Meteor.publish \"_houston_#{name}\", (sort, filter, limit) ->\n if Meteor.users.findOne(_id: @userId, 'profile.admin': true)\n try\n collection.find(filter, sort: sort, limit: limit)\n catch e\n console.log e", "source_lang": "", "target_lang": "CoffeeScript", "repo": "gterrono/houston", "path": "server/publications.coffee", "license": "MIT", "commit": "446fa960c31d33c521b881308100a6ac27b904d0", "stars": 802, "source_url": "https://github.com/gterrono/houston/blob/446fa960c31d33c521b881308100a6ac27b904d0/server/publications.coffee", "line_start": 1, "line_end": 42}902{"id": "gterrono/houston:server/publications.coffee:1:coffee_to_js", "type": "coffee_to_js", "prompt": "Convert this CoffeeScript to JavaScript.\n```coffeescript\nroot = exports ? this\n\nDummy = new Meteor.Collection(\"system.dummy\") # hack.\ncollections = {'users': Meteor.users}\n\nMeteor.startup ->\n set_up_collection = (name, collection) ->\n methods = {}\n methods[\"_houston_#{name}_insert\"] = (doc) ->\n return unless @userId\n user = Meteor.users.findOne(@userId)\n return unless user?.profile.admin\n collection.insert(doc)\n\n methods[\"_houston_#{name}_update\"] = (id, update_dict) ->\n return unless @userId\n user = Meteor.users.findOne(@userId)\n return unless user?.profile.admin\n if collection.findOne(id)\n collection.update(id, update_dict)\n else\n id = collection.findOne(new Meteor.Collection.ObjectID(id))\n collection.update(id, update_dict)\n\n methods[\"_houston_#{name}_delete\"] = (id, update_dict) ->\n return unless @userId\n user = Meteor.users.findOne(@userId)\n return unless user?.profile.admin\n if collection.findOne(id)\n collection.remove(id)\n else\n id = collection.findOne(new Meteor.Collection.ObjectID(id))\n collection.remove(id)\n\n Meteor.methods methods\n\n Meteor.publish \"_houston_#{name}\", (sort, filter, limit) ->\n if Meteor.users.findOne(_id: @userId, 'profile.admin': true)\n try\n collection.find(filter, sort: sort, limit: limit)\n catch e\n console.log e\n```", "response": "var Dummy, collections, root;\n\nroot = typeof exports !== \"undefined\" && exports !== null ? exports : this;\n\nDummy = new Meteor.Collection(\"system.dummy\"); // hack.\n\ncollections = {\n 'users': Meteor.users\n};\n\nMeteor.startup(function() {\n var set_up_collection;\n return set_up_collection = function(name, collection) {\n var methods;\n methods = {};\n methods[`_houston_${name}_insert`] = function(doc) {\n var user;\n if (!this.userId) {\n return;\n }\n user = Meteor.users.findOne(this.userId);\n if (!(user != null ? user.profile.admin : void 0)) {\n return;\n }\n return collection.insert(doc);\n };\n methods[`_houston_${name}_update`] = function(id, update_dict) {\n var user;\n if (!this.userId) {\n return;\n }\n user = Meteor.users.findOne(this.userId);\n if (!(user != null ? user.profile.admin : void 0)) {\n return;\n }\n if (collection.findOne(id)) {\n return collection.update(id, update_dict);\n } else {\n id = collection.findOne(new Meteor.Collection.ObjectID(id));\n return collection.update(id, update_dict);\n }\n };\n methods[`_houston_${name}_delete`] = function(id, update_dict) {\n var user;\n if (!this.userId) {\n return;\n }\n user = Meteor.users.findOne(this.userId);\n if (!(user != null ? user.profile.admin : void 0)) {\n return;\n }\n if (collection.findOne(id)) {\n return collection.remove(id);\n } else {\n id = collection.findOne(new Meteor.Collection.ObjectID(id));\n return collection.remove(id);\n }\n };\n Meteor.methods(methods);\n return Meteor.publish(`_houston_${name}`, function(sort, filter, limit) {\n var e;\n if (Meteor.users.findOne({\n _id: this.userId,\n 'profile.admin': true\n })) {\n try {\n return collection.find(filter, {\n sort: sort,\n limit: limit\n });\n } catch (error) {\n e = error;\n return console.log(e);\n }\n }\n });\n };\n});", "source_lang": "CoffeeScript", "target_lang": "JavaScript", "repo": "gterrono/houston", "path": "server/publications.coffee", "license": "MIT", "commit": "446fa960c31d33c521b881308100a6ac27b904d0", "stars": 802, "source_url": "https://github.com/gterrono/houston/blob/446fa960c31d33c521b881308100a6ac27b904d0/server/publications.coffee", "line_start": 1, "line_end": 42}903{"id": "gterrono/houston:server/publications.coffee:1:js_to_coffee", "type": "js_to_coffee", "prompt": "Convert this JavaScript to CoffeeScript.\n```javascript\nvar Dummy, collections, root;\n\nroot = typeof exports !== \"undefined\" && exports !== null ? exports : this;\n\nDummy = new Meteor.Collection(\"system.dummy\"); // hack.\n\ncollections = {\n 'users': Meteor.users\n};\n\nMeteor.startup(function() {\n var set_up_collection;\n return set_up_collection = function(name, collection) {\n var methods;\n methods = {};\n methods[`_houston_${name}_insert`] = function(doc) {\n var user;\n if (!this.userId) {\n return;\n }\n user = Meteor.users.findOne(this.userId);\n if (!(user != null ? user.profile.admin : void 0)) {\n return;\n }\n return collection.insert(doc);\n };\n methods[`_houston_${name}_update`] = function(id, update_dict) {\n var user;\n if (!this.userId) {\n return;\n }\n user = Meteor.users.findOne(this.userId);\n if (!(user != null ? user.profile.admin : void 0)) {\n return;\n }\n if (collection.findOne(id)) {\n return collection.update(id, update_dict);\n } else {\n id = collection.findOne(new Meteor.Collection.ObjectID(id));\n return collection.update(id, update_dict);\n }\n };\n methods[`_houston_${name}_delete`] = function(id, update_dict) {\n var user;\n if (!this.userId) {\n return;\n }\n user = Meteor.users.findOne(this.userId);\n if (!(user != null ? user.profile.admin : void 0)) {\n return;\n }\n if (collection.findOne(id)) {\n return collection.remove(id);\n } else {\n id = collection.findOne(new Meteor.Collection.ObjectID(id));\n return collection.remove(id);\n }\n };\n Meteor.methods(methods);\n return Meteor.publish(`_houston_${name}`, function(sort, filter, limit) {\n var e;\n if (Meteor.users.findOne({\n _id: this.userId,\n 'profile.admin': true\n })) {\n try {\n return collection.find(filter, {\n sort: sort,\n limit: limit\n });\n } catch (error) {\n e = error;\n return console.log(e);\n }\n }\n });\n };\n});\n```", "response": "root = exports ? this\n\nDummy = new Meteor.Collection(\"system.dummy\") # hack.\ncollections = {'users': Meteor.users}\n\nMeteor.startup ->\n set_up_collection = (name, collection) ->\n methods = {}\n methods[\"_houston_#{name}_insert\"] = (doc) ->\n return unless @userId\n user = Meteor.users.findOne(@userId)\n return unless user?.profile.admin\n collection.insert(doc)\n\n methods[\"_houston_#{name}_update\"] = (id, update_dict) ->\n return unless @userId\n user = Meteor.users.findOne(@userId)\n return unless user?.profile.admin\n if collection.findOne(id)\n collection.update(id, update_dict)\n else\n id = collection.findOne(new Meteor.Collection.ObjectID(id))\n collection.update(id, update_dict)\n\n methods[\"_houston_#{name}_delete\"] = (id, update_dict) ->\n return unless @userId\n user = Meteor.users.findOne(@userId)\n return unless user?.profile.admin\n if collection.findOne(id)\n collection.remove(id)\n else\n id = collection.findOne(new Meteor.Collection.ObjectID(id))\n collection.remove(id)\n\n Meteor.methods methods\n\n Meteor.publish \"_houston_#{name}\", (sort, filter, limit) ->\n if Meteor.users.findOne(_id: @userId, 'profile.admin': true)\n try\n collection.find(filter, sort: sort, limit: limit)\n catch e\n console.log e", "source_lang": "JavaScript", "target_lang": "CoffeeScript", "repo": "gterrono/houston", "path": "server/publications.coffee", "license": "MIT", "commit": "446fa960c31d33c521b881308100a6ac27b904d0", "stars": 802, "source_url": "https://github.com/gterrono/houston/blob/446fa960c31d33c521b881308100a6ac27b904d0/server/publications.coffee", "line_start": 1, "line_end": 42}904{"id": "gterrono/houston:server/publications.coffee:1:completion", "type": "completion", "prompt": "root = exports ? this\n\nDummy = new Meteor.Collection(\"system.dummy\") # hack.\ncollections = {'users': Meteor.users}\n\nMeteor.startup ->\n set_up_collection = (name, collection) ->\n methods = {}\n methods[\"_houston_#{name}_insert\"] = (doc) ->\n return unless @userId\n user = Meteor.users.findOne(@userId)\n return unless user?.profile.admin\n collection.insert(doc)\n\n methods[\"_houston_#{name}_update\"] = (id, update_dict) ->\n return unless @userId\n user = Meteor.users.findOne(@userId)\n return unless user?.profile.admin\n if collection.findOne(id)\n collection.update(id, update_dict)\n else", "response": "id = collection.findOne(new Meteor.Collection.ObjectID(id))\n collection.update(id, update_dict)\n\n methods[\"_houston_#{name}_delete\"] = (id, update_dict) ->\n return unless @userId\n user = Meteor.users.findOne(@userId)\n return unless user?.profile.admin\n if collection.findOne(id)\n collection.remove(id)\n else\n id = collection.findOne(new Meteor.Collection.ObjectID(id))\n collection.remove(id)\n\n Meteor.methods methods\n\n Meteor.publish \"_houston_#{name}\", (sort, filter, limit) ->\n if Meteor.users.findOne(_id: @userId, 'profile.admin': true)\n try\n collection.find(filter, sort: sort, limit: limit)\n catch e\n console.log e", "source_lang": "CoffeeScript", "target_lang": "CoffeeScript", "repo": "gterrono/houston", "path": "server/publications.coffee", "license": "MIT", "commit": "446fa960c31d33c521b881308100a6ac27b904d0", "stars": 802, "source_url": "https://github.com/gterrono/houston/blob/446fa960c31d33c521b881308100a6ac27b904d0/server/publications.coffee", "line_start": 1, "line_end": 42}905{"id": "gterrono/houston:server/publications.coffee:2:raw_corpus", "type": "raw_corpus", "prompt": "", "response": "collection.find().observe\n added: (document) ->\n Houston._collections.collections.update {name},\n $inc: {count: 1},\n $addToSet: fields: $each: Houston._get_field_names([document])\n removed: (document) -> Houston._collections.collections.update {name}, {$inc: {count: -1}}\n\n fields = Houston._get_field_names(collection.find().fetch())\n c = Houston._collections.collections.findOne {name}\n if c\n Houston._collections.collections.update c._id, {$set: count: collection.find().count(), fields: fields}\n else\n Houston._collections.collections.insert {name, count: collection.find().count(), fields: fields}\n\n Dummy.findOne() # hack\n\n save_collections = (meh, collections_db) ->\n collection_names = (col.collectionName for col in collections_db \\\n when (col.collectionName.indexOf \"system.\") isnt 0 and\n (col.collectionName.indexOf \"houston_\") isnt 0)\n\n collection_names.forEach (name) ->\n unless name of collections\n try\n collections[name] = new Meteor.Collection(name)\n catch e\n for key, value of root\n if name == value._name\n collections[name] = value\n console.log e unless collections[name]?\n\n set_up_collection(name, collections[name])\n\n Meteor.methods\n _houston_make_admin: (userId) ->\n # limit one admin\n return if Meteor.users.findOne {'profile.admin': true}\n Meteor.users.update userId, $set: {'profile.admin': true}\n return true", "source_lang": "", "target_lang": "CoffeeScript", "repo": "gterrono/houston", "path": "server/publications.coffee", "license": "MIT", "commit": "446fa960c31d33c521b881308100a6ac27b904d0", "stars": 802, "source_url": "https://github.com/gterrono/houston/blob/446fa960c31d33c521b881308100a6ac27b904d0/server/publications.coffee", "line_start": 44, "line_end": 82}906{"id": "gterrono/houston:server/publications.coffee:2:coffee_to_js", "type": "coffee_to_js", "prompt": "Convert this CoffeeScript to JavaScript.\n```coffeescript\ncollection.find().observe\n added: (document) ->\n Houston._collections.collections.update {name},\n $inc: {count: 1},\n $addToSet: fields: $each: Houston._get_field_names([document])\n removed: (document) -> Houston._collections.collections.update {name}, {$inc: {count: -1}}\n\n fields = Houston._get_field_names(collection.find().fetch())\n c = Houston._collections.collections.findOne {name}\n if c\n Houston._collections.collections.update c._id, {$set: count: collection.find().count(), fields: fields}\n else\n Houston._collections.collections.insert {name, count: collection.find().count(), fields: fields}\n\n Dummy.findOne() # hack\n\n save_collections = (meh, collections_db) ->\n collection_names = (col.collectionName for col in collections_db \\\n when (col.collectionName.indexOf \"system.\") isnt 0 and\n (col.collectionName.indexOf \"houston_\") isnt 0)\n\n collection_names.forEach (name) ->\n unless name of collections\n try\n collections[name] = new Meteor.Collection(name)\n catch e\n for key, value of root\n if name == value._name\n collections[name] = value\n console.log e unless collections[name]?\n\n set_up_collection(name, collections[name])\n\n Meteor.methods\n _houston_make_admin: (userId) ->\n # limit one admin\n return if Meteor.users.findOne {'profile.admin': true}\n Meteor.users.update userId, $set: {'profile.admin': true}\n return true\n```", "response": "var c, fields, save_collections;\n\ncollection.find().observe({\n added: function(document) {\n return Houston._collections.collections.update({name}, {\n $inc: {\n count: 1\n },\n $addToSet: {\n fields: {\n $each: Houston._get_field_names([document])\n }\n }\n });\n },\n removed: function(document) {\n return Houston._collections.collections.update({name}, {\n $inc: {\n count: -1\n }\n });\n }\n});\n\nfields = Houston._get_field_names(collection.find().fetch());\n\nc = Houston._collections.collections.findOne({name});\n\nif (c) {\n Houston._collections.collections.update(c._id, {\n $set: {\n count: collection.find().count(),\n fields: fields\n }\n });\n} else {\n Houston._collections.collections.insert({\n name,\n count: collection.find().count(),\n fields: fields\n });\n}\n\nDummy.findOne(); // hack\n\nsave_collections = function(meh, collections_db) {\n var col, collection_names;\n collection_names = (function() {\n var i, len, results;\n results = [];\n for (i = 0, len = collections_db.length; i < len; i++) {\n col = collections_db[i];\n if ((col.collectionName.indexOf(\"system.\")) !== 0 && (col.collectionName.indexOf(\"houston_\")) !== 0) {\n results.push(col.collectionName);\n }\n }\n return results;\n })();\n return collection_names.forEach(function(name) {\n var e, key, value;\n if (!(name in collections)) {\n try {\n collections[name] = new Meteor.Collection(name);\n } catch (error) {\n e = error;\n for (key in root) {\n value = root[key];\n if (name === value._name) {\n collections[name] = value;\n }\n }\n if (collections[name] == null) {\n console.log(e);\n }\n }\n return set_up_collection(name, collections[name]);\n }\n });\n};\n\nMeteor.methods({\n _houston_make_admin: function(userId) {\n // limit one admin\n if (Meteor.users.findOne({\n 'profile.admin': true\n })) {\n return;\n }\n Meteor.users.update(userId, {\n $set: {\n 'profile.admin': true\n }\n });\n return true;\n }\n});", "source_lang": "CoffeeScript", "target_lang": "JavaScript", "repo": "gterrono/houston", "path": "server/publications.coffee", "license": "MIT", "commit": "446fa960c31d33c521b881308100a6ac27b904d0", "stars": 802, "source_url": "https://github.com/gterrono/houston/blob/446fa960c31d33c521b881308100a6ac27b904d0/server/publications.coffee", "line_start": 44, "line_end": 82}907{"id": "gterrono/houston:server/publications.coffee:2:js_to_coffee", "type": "js_to_coffee", "prompt": "Convert this JavaScript to CoffeeScript.\n```javascript\nvar c, fields, save_collections;\n\ncollection.find().observe({\n added: function(document) {\n return Houston._collections.collections.update({name}, {\n $inc: {\n count: 1\n },\n $addToSet: {\n fields: {\n $each: Houston._get_field_names([document])\n }\n }\n });\n },\n removed: function(document) {\n return Houston._collections.collections.update({name}, {\n $inc: {\n count: -1\n }\n });\n }\n});\n\nfields = Houston._get_field_names(collection.find().fetch());\n\nc = Houston._collections.collections.findOne({name});\n\nif (c) {\n Houston._collections.collections.update(c._id, {\n $set: {\n count: collection.find().count(),\n fields: fields\n }\n });\n} else {\n Houston._collections.collections.insert({\n name,\n count: collection.find().count(),\n fields: fields\n });\n}\n\nDummy.findOne(); // hack\n\nsave_collections = function(meh, collections_db) {\n var col, collection_names;\n collection_names = (function() {\n var i, len, results;\n results = [];\n for (i = 0, len = collections_db.length; i < len; i++) {\n col = collections_db[i];\n if ((col.collectionName.indexOf(\"system.\")) !== 0 && (col.collectionName.indexOf(\"houston_\")) !== 0) {\n results.push(col.collectionName);\n }\n }\n return results;\n })();\n return collection_names.forEach(function(name) {\n var e, key, value;\n if (!(name in collections)) {\n try {\n collections[name] = new Meteor.Collection(name);\n } catch (error) {\n e = error;\n for (key in root) {\n value = root[key];\n if (name === value._name) {\n collections[name] = value;\n }\n }\n if (collections[name] == null) {\n console.log(e);\n }\n }\n return set_up_collection(name, collections[name]);\n }\n });\n};\n\nMeteor.methods({\n _houston_make_admin: function(userId) {\n // limit one admin\n if (Meteor.users.findOne({\n 'profile.admin': true\n })) {\n return;\n }\n Meteor.users.update(userId, {\n $set: {\n 'profile.admin': true\n }\n });\n return true;\n }\n});\n```", "response": "collection.find().observe\n added: (document) ->\n Houston._collections.collections.update {name},\n $inc: {count: 1},\n $addToSet: fields: $each: Houston._get_field_names([document])\n removed: (document) -> Houston._collections.collections.update {name}, {$inc: {count: -1}}\n\n fields = Houston._get_field_names(collection.find().fetch())\n c = Houston._collections.collections.findOne {name}\n if c\n Houston._collections.collections.update c._id, {$set: count: collection.find().count(), fields: fields}\n else\n Houston._collections.collections.insert {name, count: collection.find().count(), fields: fields}\n\n Dummy.findOne() # hack\n\n save_collections = (meh, collections_db) ->\n collection_names = (col.collectionName for col in collections_db \\\n when (col.collectionName.indexOf \"system.\") isnt 0 and\n (col.collectionName.indexOf \"houston_\") isnt 0)\n\n collection_names.forEach (name) ->\n unless name of collections\n try\n collections[name] = new Meteor.Collection(name)\n catch e\n for key, value of root\n if name == value._name\n collections[name] = value\n console.log e unless collections[name]?\n\n set_up_collection(name, collections[name])\n\n Meteor.methods\n _houston_make_admin: (userId) ->\n # limit one admin\n return if Meteor.users.findOne {'profile.admin': true}\n Meteor.users.update userId, $set: {'profile.admin': true}\n return true", "source_lang": "JavaScript", "target_lang": "CoffeeScript", "repo": "gterrono/houston", "path": "server/publications.coffee", "license": "MIT", "commit": "446fa960c31d33c521b881308100a6ac27b904d0", "stars": 802, "source_url": "https://github.com/gterrono/houston/blob/446fa960c31d33c521b881308100a6ac27b904d0/server/publications.coffee", "line_start": 44, "line_end": 82}908{"id": "gterrono/houston:server/publications.coffee:2:completion", "type": "completion", "prompt": "collection.find().observe\n added: (document) ->\n Houston._collections.collections.update {name},\n $inc: {count: 1},\n $addToSet: fields: $each: Houston._get_field_names([document])\n removed: (document) -> Houston._collections.collections.update {name}, {$inc: {count: -1}}\n\n fields = Houston._get_field_names(collection.find().fetch())\n c = Houston._collections.collections.findOne {name}\n if c\n Houston._collections.collections.update c._id, {$set: count: collection.find().count(), fields: fields}\n else\n Houston._collections.collections.insert {name, count: collection.find().count(), fields: fields}\n\n Dummy.findOne() # hack\n\n save_collections = (meh, collections_db) ->\n collection_names = (col.collectionName for col in collections_db \\\n when (col.collectionName.indexOf \"system.\") isnt 0 and", "response": "(col.collectionName.indexOf \"houston_\") isnt 0)\n\n collection_names.forEach (name) ->\n unless name of collections\n try\n collections[name] = new Meteor.Collection(name)\n catch e\n for key, value of root\n if name == value._name\n collections[name] = value\n console.log e unless collections[name]?\n\n set_up_collection(name, collections[name])\n\n Meteor.methods\n _houston_make_admin: (userId) ->\n # limit one admin\n return if Meteor.users.findOne {'profile.admin': true}\n Meteor.users.update userId, $set: {'profile.admin': true}\n return true", "source_lang": "CoffeeScript", "target_lang": "CoffeeScript", "repo": "gterrono/houston", "path": "server/publications.coffee", "license": "MIT", "commit": "446fa960c31d33c521b881308100a6ac27b904d0", "stars": 802, "source_url": "https://github.com/gterrono/houston/blob/446fa960c31d33c521b881308100a6ac27b904d0/server/publications.coffee", "line_start": 44, "line_end": 82}909{"id": "gterrono/houston:server/publications.coffee:3:raw_corpus", "type": "raw_corpus", "prompt": "", "response": "fn = Meteor.bindEnvironment save_collections, (e) ->\n console.log e\n\n # MongoInternals is the 'right' solution as of 0.6.5\n mongo_driver = MongoInternals?.defaultRemoteCollectionDriver() or Meteor._RemoteCollectionDriver\n mongo_driver.mongo.db.collections fn\n\n\n# publish our own internal state\nMeteor.publish '_houston', ->\n if Meteor.users.findOne(_id: @userId, 'profile.admin': true)\n Houston._collections.collections.find()\n\n\nMeteor.publish '_houston_adminUser', -> # used by login page to see if admin has been created yet\n Meteor.users.find({'profile.admin': true}, fields: 'profile.admin': true)", "source_lang": "", "target_lang": "CoffeeScript", "repo": "gterrono/houston", "path": "server/publications.coffee", "license": "MIT", "commit": "446fa960c31d33c521b881308100a6ac27b904d0", "stars": 802, "source_url": "https://github.com/gterrono/houston/blob/446fa960c31d33c521b881308100a6ac27b904d0/server/publications.coffee", "line_start": 84, "line_end": 99}910{"id": "gterrono/houston:server/publications.coffee:3:coffee_to_js", "type": "coffee_to_js", "prompt": "Convert this CoffeeScript to JavaScript.\n```coffeescript\nfn = Meteor.bindEnvironment save_collections, (e) ->\n console.log e\n\n # MongoInternals is the 'right' solution as of 0.6.5\n mongo_driver = MongoInternals?.defaultRemoteCollectionDriver() or Meteor._RemoteCollectionDriver\n mongo_driver.mongo.db.collections fn\n\n\n# publish our own internal state\nMeteor.publish '_houston', ->\n if Meteor.users.findOne(_id: @userId, 'profile.admin': true)\n Houston._collections.collections.find()\n\n\nMeteor.publish '_houston_adminUser', -> # used by login page to see if admin has been created yet\n Meteor.users.find({'profile.admin': true}, fields: 'profile.admin': true)\n```", "response": "var fn, mongo_driver;\n\nfn = Meteor.bindEnvironment(save_collections, function(e) {\n return console.log(e);\n});\n\n// MongoInternals is the 'right' solution as of 0.6.5\nmongo_driver = (typeof MongoInternals !== \"undefined\" && MongoInternals !== null ? MongoInternals.defaultRemoteCollectionDriver() : void 0) || Meteor._RemoteCollectionDriver;\n\nmongo_driver.mongo.db.collections(fn);\n\n// publish our own internal state\nMeteor.publish('_houston', function() {\n if (Meteor.users.findOne({\n _id: this.userId,\n 'profile.admin': true\n })) {\n return Houston._collections.collections.find();\n }\n});\n\nMeteor.publish('_houston_adminUser', function() { // used by login page to see if admin has been created yet\n return Meteor.users.find({\n 'profile.admin': true\n }, {\n fields: {\n 'profile.admin': true\n }\n });\n});", "source_lang": "CoffeeScript", "target_lang": "JavaScript", "repo": "gterrono/houston", "path": "server/publications.coffee", "license": "MIT", "commit": "446fa960c31d33c521b881308100a6ac27b904d0", "stars": 802, "source_url": "https://github.com/gterrono/houston/blob/446fa960c31d33c521b881308100a6ac27b904d0/server/publications.coffee", "line_start": 84, "line_end": 99}911{"id": "gterrono/houston:server/publications.coffee:3:js_to_coffee", "type": "js_to_coffee", "prompt": "Convert this JavaScript to CoffeeScript.\n```javascript\nvar fn, mongo_driver;\n\nfn = Meteor.bindEnvironment(save_collections, function(e) {\n return console.log(e);\n});\n\n// MongoInternals is the 'right' solution as of 0.6.5\nmongo_driver = (typeof MongoInternals !== \"undefined\" && MongoInternals !== null ? MongoInternals.defaultRemoteCollectionDriver() : void 0) || Meteor._RemoteCollectionDriver;\n\nmongo_driver.mongo.db.collections(fn);\n\n// publish our own internal state\nMeteor.publish('_houston', function() {\n if (Meteor.users.findOne({\n _id: this.userId,\n 'profile.admin': true\n })) {\n return Houston._collections.collections.find();\n }\n});\n\nMeteor.publish('_houston_adminUser', function() { // used by login page to see if admin has been created yet\n return Meteor.users.find({\n 'profile.admin': true\n }, {\n fields: {\n 'profile.admin': true\n }\n });\n});\n```", "response": "fn = Meteor.bindEnvironment save_collections, (e) ->\n console.log e\n\n # MongoInternals is the 'right' solution as of 0.6.5\n mongo_driver = MongoInternals?.defaultRemoteCollectionDriver() or Meteor._RemoteCollectionDriver\n mongo_driver.mongo.db.collections fn\n\n\n# publish our own internal state\nMeteor.publish '_houston', ->\n if Meteor.users.findOne(_id: @userId, 'profile.admin': true)\n Houston._collections.collections.find()\n\n\nMeteor.publish '_houston_adminUser', -> # used by login page to see if admin has been created yet\n Meteor.users.find({'profile.admin': true}, fields: 'profile.admin': true)", "source_lang": "JavaScript", "target_lang": "CoffeeScript", "repo": "gterrono/houston", "path": "server/publications.coffee", "license": "MIT", "commit": "446fa960c31d33c521b881308100a6ac27b904d0", "stars": 802, "source_url": "https://github.com/gterrono/houston/blob/446fa960c31d33c521b881308100a6ac27b904d0/server/publications.coffee", "line_start": 84, "line_end": 99}912{"id": "gterrono/houston:server/publications.coffee:3:completion", "type": "completion", "prompt": "fn = Meteor.bindEnvironment save_collections, (e) ->\n console.log e\n\n # MongoInternals is the 'right' solution as of 0.6.5\n mongo_driver = MongoInternals?.defaultRemoteCollectionDriver() or Meteor._RemoteCollectionDriver\n mongo_driver.mongo.db.collections fn", "response": "# publish our own internal state\nMeteor.publish '_houston', ->\n if Meteor.users.findOne(_id: @userId, 'profile.admin': true)\n Houston._collections.collections.find()\n\n\nMeteor.publish '_houston_adminUser', -> # used by login page to see if admin has been created yet\n Meteor.users.find({'profile.admin': true}, fields: 'profile.admin': true)", "source_lang": "CoffeeScript", "target_lang": "CoffeeScript", "repo": "gterrono/houston", "path": "server/publications.coffee", "license": "MIT", "commit": "446fa960c31d33c521b881308100a6ac27b904d0", "stars": 802, "source_url": "https://github.com/gterrono/houston/blob/446fa960c31d33c521b881308100a6ac27b904d0/server/publications.coffee", "line_start": 84, "line_end": 99}913{"id": "gterrono/houston:server/publications.coffee:2:raw_corpus", "type": "raw_corpus", "prompt": "", "response": "collection.find().observe\n added: (document) ->\n Houston._collections.update {name},\n $inc: {count: 1},\n $addToSet: fields: Houston._get_field_names([document])\n removed: (document) -> Houston._collections.update {name}, {$inc: {count: -1}}\n\n fields = Houston._get_field_names(collection.find().fetch())\n c = Houston._collections.findOne {name}\n if c\n Houston._collections.update c._id, {$set: count: collection.find().count(), fields: fields}\n else\n Houston._collections.insert {name, count: collection.find().count(), fields: fields}\n\n Dummy.findOne() # hack\n\n save_collections = (meh, collections_db) ->\n collection_names = (col.collectionName for col in collections_db \\\n when (col.collectionName.indexOf \"system.\") isnt 0 and\n (col.collectionName.indexOf \"houston_\") isnt 0)\n\n collection_names.forEach (name) ->\n unless name of collections\n try\n collections[name] = new Meteor.Collection(name)\n catch e\n for key, value of root\n if name == value._name\n collections[name] = value\n console.log e unless collections[name]?\n\n set_up_collection(name, collections[name])\n\n Meteor.methods\n _houston_make_admin: (userId) ->\n # limit one admin\n return if Meteor.users.findOne {'profile.admin': true}\n Meteor.users.update userId, $set: {'profile.admin': true}\n return true", "source_lang": "", "target_lang": "CoffeeScript", "repo": "gterrono/houston", "path": "server/publications.coffee", "license": "MIT", "commit": "3fa4b927aee4e23c39e194ee4e97fadbf627c39c", "stars": 802, "source_url": "https://github.com/gterrono/houston/blob/3fa4b927aee4e23c39e194ee4e97fadbf627c39c/server/publications.coffee", "line_start": 44, "line_end": 82}914{"id": "gterrono/houston:server/publications.coffee:2:coffee_to_js", "type": "coffee_to_js", "prompt": "Convert this CoffeeScript to JavaScript.\n```coffeescript\ncollection.find().observe\n added: (document) ->\n Houston._collections.update {name},\n $inc: {count: 1},\n $addToSet: fields: Houston._get_field_names([document])\n removed: (document) -> Houston._collections.update {name}, {$inc: {count: -1}}\n\n fields = Houston._get_field_names(collection.find().fetch())\n c = Houston._collections.findOne {name}\n if c\n Houston._collections.update c._id, {$set: count: collection.find().count(), fields: fields}\n else\n Houston._collections.insert {name, count: collection.find().count(), fields: fields}\n\n Dummy.findOne() # hack\n\n save_collections = (meh, collections_db) ->\n collection_names = (col.collectionName for col in collections_db \\\n when (col.collectionName.indexOf \"system.\") isnt 0 and\n (col.collectionName.indexOf \"houston_\") isnt 0)\n\n collection_names.forEach (name) ->\n unless name of collections\n try\n collections[name] = new Meteor.Collection(name)\n catch e\n for key, value of root\n if name == value._name\n collections[name] = value\n console.log e unless collections[name]?\n\n set_up_collection(name, collections[name])\n\n Meteor.methods\n _houston_make_admin: (userId) ->\n # limit one admin\n return if Meteor.users.findOne {'profile.admin': true}\n Meteor.users.update userId, $set: {'profile.admin': true}\n return true\n```", "response": "var c, fields, save_collections;\n\ncollection.find().observe({\n added: function(document) {\n return Houston._collections.update({name}, {\n $inc: {\n count: 1\n },\n $addToSet: {\n fields: Houston._get_field_names([document])\n }\n });\n },\n removed: function(document) {\n return Houston._collections.update({name}, {\n $inc: {\n count: -1\n }\n });\n }\n});\n\nfields = Houston._get_field_names(collection.find().fetch());\n\nc = Houston._collections.findOne({name});\n\nif (c) {\n Houston._collections.update(c._id, {\n $set: {\n count: collection.find().count(),\n fields: fields\n }\n });\n} else {\n Houston._collections.insert({\n name,\n count: collection.find().count(),\n fields: fields\n });\n}\n\nDummy.findOne(); // hack\n\nsave_collections = function(meh, collections_db) {\n var col, collection_names;\n collection_names = (function() {\n var i, len, results;\n results = [];\n for (i = 0, len = collections_db.length; i < len; i++) {\n col = collections_db[i];\n if ((col.collectionName.indexOf(\"system.\")) !== 0 && (col.collectionName.indexOf(\"houston_\")) !== 0) {\n results.push(col.collectionName);\n }\n }\n return results;\n })();\n return collection_names.forEach(function(name) {\n var e, key, value;\n if (!(name in collections)) {\n try {\n collections[name] = new Meteor.Collection(name);\n } catch (error) {\n e = error;\n for (key in root) {\n value = root[key];\n if (name === value._name) {\n collections[name] = value;\n }\n }\n if (collections[name] == null) {\n console.log(e);\n }\n }\n return set_up_collection(name, collections[name]);\n }\n });\n};\n\nMeteor.methods({\n _houston_make_admin: function(userId) {\n // limit one admin\n if (Meteor.users.findOne({\n 'profile.admin': true\n })) {\n return;\n }\n Meteor.users.update(userId, {\n $set: {\n 'profile.admin': true\n }\n });\n return true;\n }\n});", "source_lang": "CoffeeScript", "target_lang": "JavaScript", "repo": "gterrono/houston", "path": "server/publications.coffee", "license": "MIT", "commit": "3fa4b927aee4e23c39e194ee4e97fadbf627c39c", "stars": 802, "source_url": "https://github.com/gterrono/houston/blob/3fa4b927aee4e23c39e194ee4e97fadbf627c39c/server/publications.coffee", "line_start": 44, "line_end": 82}915{"id": "gterrono/houston:server/publications.coffee:2:js_to_coffee", "type": "js_to_coffee", "prompt": "Convert this JavaScript to CoffeeScript.\n```javascript\nvar c, fields, save_collections;\n\ncollection.find().observe({\n added: function(document) {\n return Houston._collections.update({name}, {\n $inc: {\n count: 1\n },\n $addToSet: {\n fields: Houston._get_field_names([document])\n }\n });\n },\n removed: function(document) {\n return Houston._collections.update({name}, {\n $inc: {\n count: -1\n }\n });\n }\n});\n\nfields = Houston._get_field_names(collection.find().fetch());\n\nc = Houston._collections.findOne({name});\n\nif (c) {\n Houston._collections.update(c._id, {\n $set: {\n count: collection.find().count(),\n fields: fields\n }\n });\n} else {\n Houston._collections.insert({\n name,\n count: collection.find().count(),\n fields: fields\n });\n}\n\nDummy.findOne(); // hack\n\nsave_collections = function(meh, collections_db) {\n var col, collection_names;\n collection_names = (function() {\n var i, len, results;\n results = [];\n for (i = 0, len = collections_db.length; i < len; i++) {\n col = collections_db[i];\n if ((col.collectionName.indexOf(\"system.\")) !== 0 && (col.collectionName.indexOf(\"houston_\")) !== 0) {\n results.push(col.collectionName);\n }\n }\n return results;\n })();\n return collection_names.forEach(function(name) {\n var e, key, value;\n if (!(name in collections)) {\n try {\n collections[name] = new Meteor.Collection(name);\n } catch (error) {\n e = error;\n for (key in root) {\n value = root[key];\n if (name === value._name) {\n collections[name] = value;\n }\n }\n if (collections[name] == null) {\n console.log(e);\n }\n }\n return set_up_collection(name, collections[name]);\n }\n });\n};\n\nMeteor.methods({\n _houston_make_admin: function(userId) {\n // limit one admin\n if (Meteor.users.findOne({\n 'profile.admin': true\n })) {\n return;\n }\n Meteor.users.update(userId, {\n $set: {\n 'profile.admin': true\n }\n });\n return true;\n }\n});\n```", "response": "collection.find().observe\n added: (document) ->\n Houston._collections.update {name},\n $inc: {count: 1},\n $addToSet: fields: Houston._get_field_names([document])\n removed: (document) -> Houston._collections.update {name}, {$inc: {count: -1}}\n\n fields = Houston._get_field_names(collection.find().fetch())\n c = Houston._collections.findOne {name}\n if c\n Houston._collections.update c._id, {$set: count: collection.find().count(), fields: fields}\n else\n Houston._collections.insert {name, count: collection.find().count(), fields: fields}\n\n Dummy.findOne() # hack\n\n save_collections = (meh, collections_db) ->\n collection_names = (col.collectionName for col in collections_db \\\n when (col.collectionName.indexOf \"system.\") isnt 0 and\n (col.collectionName.indexOf \"houston_\") isnt 0)\n\n collection_names.forEach (name) ->\n unless name of collections\n try\n collections[name] = new Meteor.Collection(name)\n catch e\n for key, value of root\n if name == value._name\n collections[name] = value\n console.log e unless collections[name]?\n\n set_up_collection(name, collections[name])\n\n Meteor.methods\n _houston_make_admin: (userId) ->\n # limit one admin\n return if Meteor.users.findOne {'profile.admin': true}\n Meteor.users.update userId, $set: {'profile.admin': true}\n return true", "source_lang": "JavaScript", "target_lang": "CoffeeScript", "repo": "gterrono/houston", "path": "server/publications.coffee", "license": "MIT", "commit": "3fa4b927aee4e23c39e194ee4e97fadbf627c39c", "stars": 802, "source_url": "https://github.com/gterrono/houston/blob/3fa4b927aee4e23c39e194ee4e97fadbf627c39c/server/publications.coffee", "line_start": 44, "line_end": 82}916{"id": "gterrono/houston:server/publications.coffee:2:completion", "type": "completion", "prompt": "collection.find().observe\n added: (document) ->\n Houston._collections.update {name},\n $inc: {count: 1},\n $addToSet: fields: Houston._get_field_names([document])\n removed: (document) -> Houston._collections.update {name}, {$inc: {count: -1}}\n\n fields = Houston._get_field_names(collection.find().fetch())\n c = Houston._collections.findOne {name}\n if c\n Houston._collections.update c._id, {$set: count: collection.find().count(), fields: fields}\n else\n Houston._collections.insert {name, count: collection.find().count(), fields: fields}\n\n Dummy.findOne() # hack\n\n save_collections = (meh, collections_db) ->\n collection_names = (col.collectionName for col in collections_db \\\n when (col.collectionName.indexOf \"system.\") isnt 0 and", "response": "(col.collectionName.indexOf \"houston_\") isnt 0)\n\n collection_names.forEach (name) ->\n unless name of collections\n try\n collections[name] = new Meteor.Collection(name)\n catch e\n for key, value of root\n if name == value._name\n collections[name] = value\n console.log e unless collections[name]?\n\n set_up_collection(name, collections[name])\n\n Meteor.methods\n _houston_make_admin: (userId) ->\n # limit one admin\n return if Meteor.users.findOne {'profile.admin': true}\n Meteor.users.update userId, $set: {'profile.admin': true}\n return true", "source_lang": "CoffeeScript", "target_lang": "CoffeeScript", "repo": "gterrono/houston", "path": "server/publications.coffee", "license": "MIT", "commit": "3fa4b927aee4e23c39e194ee4e97fadbf627c39c", "stars": 802, "source_url": "https://github.com/gterrono/houston/blob/3fa4b927aee4e23c39e194ee4e97fadbf627c39c/server/publications.coffee", "line_start": 44, "line_end": 82}917{"id": "gterrono/houston:server/publications.coffee:3:raw_corpus", "type": "raw_corpus", "prompt": "", "response": "fn = Meteor.bindEnvironment save_collections, (e) ->\n console.log e\n\n # MongoInternals is the 'right' solution as of 0.6.5\n mongo_driver = MongoInternals?.defaultRemoteCollectionDriver() or Meteor._RemoteCollectionDriver\n mongo_driver.mongo.db.collections fn\n\n\n# publish our own internal state\nMeteor.publish '_houston', ->\n if Meteor.users.findOne(_id: @userId, 'profile.admin': true)\n Houston._collections.find()\n\n\nMeteor.publish '_houston_adminUser', -> # used by login page to see if admin has been created yet\n Meteor.users.find({'profile.admin': true}, fields: 'profile.admin': true)", "source_lang": "", "target_lang": "CoffeeScript", "repo": "gterrono/houston", "path": "server/publications.coffee", "license": "MIT", "commit": "3fa4b927aee4e23c39e194ee4e97fadbf627c39c", "stars": 802, "source_url": "https://github.com/gterrono/houston/blob/3fa4b927aee4e23c39e194ee4e97fadbf627c39c/server/publications.coffee", "line_start": 84, "line_end": 99}918{"id": "gterrono/houston:server/publications.coffee:3:coffee_to_js", "type": "coffee_to_js", "prompt": "Convert this CoffeeScript to JavaScript.\n```coffeescript\nfn = Meteor.bindEnvironment save_collections, (e) ->\n console.log e\n\n # MongoInternals is the 'right' solution as of 0.6.5\n mongo_driver = MongoInternals?.defaultRemoteCollectionDriver() or Meteor._RemoteCollectionDriver\n mongo_driver.mongo.db.collections fn\n\n\n# publish our own internal state\nMeteor.publish '_houston', ->\n if Meteor.users.findOne(_id: @userId, 'profile.admin': true)\n Houston._collections.find()\n\n\nMeteor.publish '_houston_adminUser', -> # used by login page to see if admin has been created yet\n Meteor.users.find({'profile.admin': true}, fields: 'profile.admin': true)\n```", "response": "var fn, mongo_driver;\n\nfn = Meteor.bindEnvironment(save_collections, function(e) {\n return console.log(e);\n});\n\n// MongoInternals is the 'right' solution as of 0.6.5\nmongo_driver = (typeof MongoInternals !== \"undefined\" && MongoInternals !== null ? MongoInternals.defaultRemoteCollectionDriver() : void 0) || Meteor._RemoteCollectionDriver;\n\nmongo_driver.mongo.db.collections(fn);\n\n// publish our own internal state\nMeteor.publish('_houston', function() {\n if (Meteor.users.findOne({\n _id: this.userId,\n 'profile.admin': true\n })) {\n return Houston._collections.find();\n }\n});\n\nMeteor.publish('_houston_adminUser', function() { // used by login page to see if admin has been created yet\n return Meteor.users.find({\n 'profile.admin': true\n }, {\n fields: {\n 'profile.admin': true\n }\n });\n});", "source_lang": "CoffeeScript", "target_lang": "JavaScript", "repo": "gterrono/houston", "path": "server/publications.coffee", "license": "MIT", "commit": "3fa4b927aee4e23c39e194ee4e97fadbf627c39c", "stars": 802, "source_url": "https://github.com/gterrono/houston/blob/3fa4b927aee4e23c39e194ee4e97fadbf627c39c/server/publications.coffee", "line_start": 84, "line_end": 99}919{"id": "gterrono/houston:server/publications.coffee:3:js_to_coffee", "type": "js_to_coffee", "prompt": "Convert this JavaScript to CoffeeScript.\n```javascript\nvar fn, mongo_driver;\n\nfn = Meteor.bindEnvironment(save_collections, function(e) {\n return console.log(e);\n});\n\n// MongoInternals is the 'right' solution as of 0.6.5\nmongo_driver = (typeof MongoInternals !== \"undefined\" && MongoInternals !== null ? MongoInternals.defaultRemoteCollectionDriver() : void 0) || Meteor._RemoteCollectionDriver;\n\nmongo_driver.mongo.db.collections(fn);\n\n// publish our own internal state\nMeteor.publish('_houston', function() {\n if (Meteor.users.findOne({\n _id: this.userId,\n 'profile.admin': true\n })) {\n return Houston._collections.find();\n }\n});\n\nMeteor.publish('_houston_adminUser', function() { // used by login page to see if admin has been created yet\n return Meteor.users.find({\n 'profile.admin': true\n }, {\n fields: {\n 'profile.admin': true\n }\n });\n});\n```", "response": "fn = Meteor.bindEnvironment save_collections, (e) ->\n console.log e\n\n # MongoInternals is the 'right' solution as of 0.6.5\n mongo_driver = MongoInternals?.defaultRemoteCollectionDriver() or Meteor._RemoteCollectionDriver\n mongo_driver.mongo.db.collections fn\n\n\n# publish our own internal state\nMeteor.publish '_houston', ->\n if Meteor.users.findOne(_id: @userId, 'profile.admin': true)\n Houston._collections.find()\n\n\nMeteor.publish '_houston_adminUser', -> # used by login page to see if admin has been created yet\n Meteor.users.find({'profile.admin': true}, fields: 'profile.admin': true)", "source_lang": "JavaScript", "target_lang": "CoffeeScript", "repo": "gterrono/houston", "path": "server/publications.coffee", "license": "MIT", "commit": "3fa4b927aee4e23c39e194ee4e97fadbf627c39c", "stars": 802, "source_url": "https://github.com/gterrono/houston/blob/3fa4b927aee4e23c39e194ee4e97fadbf627c39c/server/publications.coffee", "line_start": 84, "line_end": 99}920{"id": "gterrono/houston:server/publications.coffee:3:completion", "type": "completion", "prompt": "fn = Meteor.bindEnvironment save_collections, (e) ->\n console.log e\n\n # MongoInternals is the 'right' solution as of 0.6.5\n mongo_driver = MongoInternals?.defaultRemoteCollectionDriver() or Meteor._RemoteCollectionDriver\n mongo_driver.mongo.db.collections fn", "response": "# publish our own internal state\nMeteor.publish '_houston', ->\n if Meteor.users.findOne(_id: @userId, 'profile.admin': true)\n Houston._collections.find()\n\n\nMeteor.publish '_houston_adminUser', -> # used by login page to see if admin has been created yet\n Meteor.users.find({'profile.admin': true}, fields: 'profile.admin': true)", "source_lang": "CoffeeScript", "target_lang": "CoffeeScript", "repo": "gterrono/houston", "path": "server/publications.coffee", "license": "MIT", "commit": "3fa4b927aee4e23c39e194ee4e97fadbf627c39c", "stars": 802, "source_url": "https://github.com/gterrono/houston/blob/3fa4b927aee4e23c39e194ee4e97fadbf627c39c/server/publications.coffee", "line_start": 84, "line_end": 99}921{"id": "gterrono/houston:server/publications.coffee:3:raw_corpus", "type": "raw_corpus", "prompt": "", "response": "_houston_setupNewCollection: (name) ->\n return unless @userId\n user = Meteor.users.findOne(@userId)\n return unless user?.profile.admin\n unless name of collections\n try\n collections[name] = new Meteor.Collection(name)\n catch e\n for key, value of root\n if name == value._name\n collections[name] = value\n console.log e\n\n set_up_collection(name, collections[name])\n\n fn = Meteor.bindEnvironment save_collections, (e) ->\n console.log e\n\n # MongoInternals is the 'right' solution as of 0.6.5\n mongo_driver = MongoInternals?.defaultRemoteCollectionDriver() or Meteor._RemoteCollectionDriver\n mongo_driver.mongo.db.collections fn\n\n\n# publish our own internal state\nMeteor.publish '_houston', ->\n if Meteor.users.findOne(_id: @userId, 'profile.admin': true)\n Houston._collections.find()\n\n\nMeteor.publish '_houston_adminUser', -> # used by login page to see if admin has been created yet\n Meteor.users.find({'profile.admin': true}, fields: 'profile.admin': true)", "source_lang": "", "target_lang": "CoffeeScript", "repo": "gterrono/houston", "path": "server/publications.coffee", "license": "MIT", "commit": "16ea359dbf8dfec50191fb5cf8c98d6c81120457", "stars": 802, "source_url": "https://github.com/gterrono/houston/blob/16ea359dbf8dfec50191fb5cf8c98d6c81120457/server/publications.coffee", "line_start": 84, "line_end": 114}922{"id": "gterrono/houston:server/publications.coffee:3:coffee_to_js", "type": "coffee_to_js", "prompt": "Convert this CoffeeScript to JavaScript.\n```coffeescript\n_houston_setupNewCollection: (name) ->\n return unless @userId\n user = Meteor.users.findOne(@userId)\n return unless user?.profile.admin\n unless name of collections\n try\n collections[name] = new Meteor.Collection(name)\n catch e\n for key, value of root\n if name == value._name\n collections[name] = value\n console.log e\n\n set_up_collection(name, collections[name])\n\n fn = Meteor.bindEnvironment save_collections, (e) ->\n console.log e\n\n # MongoInternals is the 'right' solution as of 0.6.5\n mongo_driver = MongoInternals?.defaultRemoteCollectionDriver() or Meteor._RemoteCollectionDriver\n mongo_driver.mongo.db.collections fn\n\n\n# publish our own internal state\nMeteor.publish '_houston', ->\n if Meteor.users.findOne(_id: @userId, 'profile.admin': true)\n Houston._collections.find()\n\n\nMeteor.publish '_houston_adminUser', -> # used by login page to see if admin has been created yet\n Meteor.users.find({'profile.admin': true}, fields: 'profile.admin': true)\n```", "response": "var fn, mongo_driver;\n\n({\n _houston_setupNewCollection: function(name) {\n var e, key, user, value;\n if (!this.userId) {\n return;\n }\n user = Meteor.users.findOne(this.userId);\n if (!(user != null ? user.profile.admin : void 0)) {\n return;\n }\n if (!(name in collections)) {\n try {\n collections[name] = new Meteor.Collection(name);\n } catch (error) {\n e = error;\n for (key in root) {\n value = root[key];\n if (name === value._name) {\n collections[name] = value;\n }\n }\n console.log(e);\n }\n return set_up_collection(name, collections[name]);\n }\n }\n});\n\nfn = Meteor.bindEnvironment(save_collections, function(e) {\n return console.log(e);\n});\n\n// MongoInternals is the 'right' solution as of 0.6.5\nmongo_driver = (typeof MongoInternals !== \"undefined\" && MongoInternals !== null ? MongoInternals.defaultRemoteCollectionDriver() : void 0) || Meteor._RemoteCollectionDriver;\n\nmongo_driver.mongo.db.collections(fn);\n\n// publish our own internal state\nMeteor.publish('_houston', function() {\n if (Meteor.users.findOne({\n _id: this.userId,\n 'profile.admin': true\n })) {\n return Houston._collections.find();\n }\n});\n\nMeteor.publish('_houston_adminUser', function() { // used by login page to see if admin has been created yet\n return Meteor.users.find({\n 'profile.admin': true\n }, {\n fields: {\n 'profile.admin': true\n }\n });\n});", "source_lang": "CoffeeScript", "target_lang": "JavaScript", "repo": "gterrono/houston", "path": "server/publications.coffee", "license": "MIT", "commit": "16ea359dbf8dfec50191fb5cf8c98d6c81120457", "stars": 802, "source_url": "https://github.com/gterrono/houston/blob/16ea359dbf8dfec50191fb5cf8c98d6c81120457/server/publications.coffee", "line_start": 84, "line_end": 114}923{"id": "gterrono/houston:server/publications.coffee:3:js_to_coffee", "type": "js_to_coffee", "prompt": "Convert this JavaScript to CoffeeScript.\n```javascript\nvar fn, mongo_driver;\n\n({\n _houston_setupNewCollection: function(name) {\n var e, key, user, value;\n if (!this.userId) {\n return;\n }\n user = Meteor.users.findOne(this.userId);\n if (!(user != null ? user.profile.admin : void 0)) {\n return;\n }\n if (!(name in collections)) {\n try {\n collections[name] = new Meteor.Collection(name);\n } catch (error) {\n e = error;\n for (key in root) {\n value = root[key];\n if (name === value._name) {\n collections[name] = value;\n }\n }\n console.log(e);\n }\n return set_up_collection(name, collections[name]);\n }\n }\n});\n\nfn = Meteor.bindEnvironment(save_collections, function(e) {\n return console.log(e);\n});\n\n// MongoInternals is the 'right' solution as of 0.6.5\nmongo_driver = (typeof MongoInternals !== \"undefined\" && MongoInternals !== null ? MongoInternals.defaultRemoteCollectionDriver() : void 0) || Meteor._RemoteCollectionDriver;\n\nmongo_driver.mongo.db.collections(fn);\n\n// publish our own internal state\nMeteor.publish('_houston', function() {\n if (Meteor.users.findOne({\n _id: this.userId,\n 'profile.admin': true\n })) {\n return Houston._collections.find();\n }\n});\n\nMeteor.publish('_houston_adminUser', function() { // used by login page to see if admin has been created yet\n return Meteor.users.find({\n 'profile.admin': true\n }, {\n fields: {\n 'profile.admin': true\n }\n });\n});\n```", "response": "_houston_setupNewCollection: (name) ->\n return unless @userId\n user = Meteor.users.findOne(@userId)\n return unless user?.profile.admin\n unless name of collections\n try\n collections[name] = new Meteor.Collection(name)\n catch e\n for key, value of root\n if name == value._name\n collections[name] = value\n console.log e\n\n set_up_collection(name, collections[name])\n\n fn = Meteor.bindEnvironment save_collections, (e) ->\n console.log e\n\n # MongoInternals is the 'right' solution as of 0.6.5\n mongo_driver = MongoInternals?.defaultRemoteCollectionDriver() or Meteor._RemoteCollectionDriver\n mongo_driver.mongo.db.collections fn\n\n\n# publish our own internal state\nMeteor.publish '_houston', ->\n if Meteor.users.findOne(_id: @userId, 'profile.admin': true)\n Houston._collections.find()\n\n\nMeteor.publish '_houston_adminUser', -> # used by login page to see if admin has been created yet\n Meteor.users.find({'profile.admin': true}, fields: 'profile.admin': true)", "source_lang": "JavaScript", "target_lang": "CoffeeScript", "repo": "gterrono/houston", "path": "server/publications.coffee", "license": "MIT", "commit": "16ea359dbf8dfec50191fb5cf8c98d6c81120457", "stars": 802, "source_url": "https://github.com/gterrono/houston/blob/16ea359dbf8dfec50191fb5cf8c98d6c81120457/server/publications.coffee", "line_start": 84, "line_end": 114}924{"id": "gterrono/houston:server/publications.coffee:3:completion", "type": "completion", "prompt": "_houston_setupNewCollection: (name) ->\n return unless @userId\n user = Meteor.users.findOne(@userId)\n return unless user?.profile.admin\n unless name of collections\n try\n collections[name] = new Meteor.Collection(name)\n catch e\n for key, value of root\n if name == value._name\n collections[name] = value\n console.log e\n\n set_up_collection(name, collections[name])", "response": "fn = Meteor.bindEnvironment save_collections, (e) ->\n console.log e\n\n # MongoInternals is the 'right' solution as of 0.6.5\n mongo_driver = MongoInternals?.defaultRemoteCollectionDriver() or Meteor._RemoteCollectionDriver\n mongo_driver.mongo.db.collections fn\n\n\n# publish our own internal state\nMeteor.publish '_houston', ->\n if Meteor.users.findOne(_id: @userId, 'profile.admin': true)\n Houston._collections.find()\n\n\nMeteor.publish '_houston_adminUser', -> # used by login page to see if admin has been created yet\n Meteor.users.find({'profile.admin': true}, fields: 'profile.admin': true)", "source_lang": "CoffeeScript", "target_lang": "CoffeeScript", "repo": "gterrono/houston", "path": "server/publications.coffee", "license": "MIT", "commit": "16ea359dbf8dfec50191fb5cf8c98d6c81120457", "stars": 802, "source_url": "https://github.com/gterrono/houston/blob/16ea359dbf8dfec50191fb5cf8c98d6c81120457/server/publications.coffee", "line_start": 84, "line_end": 114}925{"id": "gterrono/houston:server/publications.coffee:1:raw_corpus", "type": "raw_corpus", "prompt": "", "response": "root = exports ? this\n\nDummy = new Meteor.Collection(\"system.dummy\") # hack.\ncollections = {'users': Meteor.users}\n\nMeteor.startup ->\n set_up_collection = (name, collection) ->\n methods = {}\n methods[\"admin_#{name}_insert\"] = (doc) ->\n return unless @userId\n user = Meteor.users.findOne(@userId)\n return unless user?.profile.admin\n collection.insert(doc)\n\n methods[\"admin_#{name}_update\"] = (id, update_dict) ->\n return unless @userId\n user = Meteor.users.findOne(@userId)\n return unless user?.profile.admin\n if collection.findOne(id)\n collection.update(id, update_dict)\n else\n id = collection.findOne(new Meteor.Collection.ObjectID(id))\n collection.update(id, update_dict)\n\n methods[\"admin_#{name}_delete\"] = (id, update_dict) ->\n return unless @userId\n user = Meteor.users.findOne(@userId)\n return unless user?.profile.admin\n if collection.findOne(id)\n collection.remove(id)\n else\n id = collection.findOne(new Meteor.Collection.ObjectID(id))\n collection.remove(id)\n\n Meteor.methods methods\n\n Meteor.publish \"admin_#{name}\", (sort, filter, limit) ->\n if Meteor.users.findOne(_id: @userId, 'profile.admin': true)\n try\n collection.find(filter, sort: sort, limit: limit)\n catch e\n console.log e", "source_lang": "", "target_lang": "CoffeeScript", "repo": "gterrono/houston", "path": "server/publications.coffee", "license": "MIT", "commit": "e652379d68f6c94ff5ac4cd9f4dccafc62c185cf", "stars": 802, "source_url": "https://github.com/gterrono/houston/blob/e652379d68f6c94ff5ac4cd9f4dccafc62c185cf/server/publications.coffee", "line_start": 1, "line_end": 42}926{"id": "gterrono/houston:server/publications.coffee:1:coffee_to_js", "type": "coffee_to_js", "prompt": "Convert this CoffeeScript to JavaScript.\n```coffeescript\nroot = exports ? this\n\nDummy = new Meteor.Collection(\"system.dummy\") # hack.\ncollections = {'users': Meteor.users}\n\nMeteor.startup ->\n set_up_collection = (name, collection) ->\n methods = {}\n methods[\"admin_#{name}_insert\"] = (doc) ->\n return unless @userId\n user = Meteor.users.findOne(@userId)\n return unless user?.profile.admin\n collection.insert(doc)\n\n methods[\"admin_#{name}_update\"] = (id, update_dict) ->\n return unless @userId\n user = Meteor.users.findOne(@userId)\n return unless user?.profile.admin\n if collection.findOne(id)\n collection.update(id, update_dict)\n else\n id = collection.findOne(new Meteor.Collection.ObjectID(id))\n collection.update(id, update_dict)\n\n methods[\"admin_#{name}_delete\"] = (id, update_dict) ->\n return unless @userId\n user = Meteor.users.findOne(@userId)\n return unless user?.profile.admin\n if collection.findOne(id)\n collection.remove(id)\n else\n id = collection.findOne(new Meteor.Collection.ObjectID(id))\n collection.remove(id)\n\n Meteor.methods methods\n\n Meteor.publish \"admin_#{name}\", (sort, filter, limit) ->\n if Meteor.users.findOne(_id: @userId, 'profile.admin': true)\n try\n collection.find(filter, sort: sort, limit: limit)\n catch e\n console.log e\n```", "response": "var Dummy, collections, root;\n\nroot = typeof exports !== \"undefined\" && exports !== null ? exports : this;\n\nDummy = new Meteor.Collection(\"system.dummy\"); // hack.\n\ncollections = {\n 'users': Meteor.users\n};\n\nMeteor.startup(function() {\n var set_up_collection;\n return set_up_collection = function(name, collection) {\n var methods;\n methods = {};\n methods[`admin_${name}_insert`] = function(doc) {\n var user;\n if (!this.userId) {\n return;\n }\n user = Meteor.users.findOne(this.userId);\n if (!(user != null ? user.profile.admin : void 0)) {\n return;\n }\n return collection.insert(doc);\n };\n methods[`admin_${name}_update`] = function(id, update_dict) {\n var user;\n if (!this.userId) {\n return;\n }\n user = Meteor.users.findOne(this.userId);\n if (!(user != null ? user.profile.admin : void 0)) {\n return;\n }\n if (collection.findOne(id)) {\n return collection.update(id, update_dict);\n } else {\n id = collection.findOne(new Meteor.Collection.ObjectID(id));\n return collection.update(id, update_dict);\n }\n };\n methods[`admin_${name}_delete`] = function(id, update_dict) {\n var user;\n if (!this.userId) {\n return;\n }\n user = Meteor.users.findOne(this.userId);\n if (!(user != null ? user.profile.admin : void 0)) {\n return;\n }\n if (collection.findOne(id)) {\n return collection.remove(id);\n } else {\n id = collection.findOne(new Meteor.Collection.ObjectID(id));\n return collection.remove(id);\n }\n };\n Meteor.methods(methods);\n return Meteor.publish(`admin_${name}`, function(sort, filter, limit) {\n var e;\n if (Meteor.users.findOne({\n _id: this.userId,\n 'profile.admin': true\n })) {\n try {\n return collection.find(filter, {\n sort: sort,\n limit: limit\n });\n } catch (error) {\n e = error;\n return console.log(e);\n }\n }\n });\n };\n});", "source_lang": "CoffeeScript", "target_lang": "JavaScript", "repo": "gterrono/houston", "path": "server/publications.coffee", "license": "MIT", "commit": "e652379d68f6c94ff5ac4cd9f4dccafc62c185cf", "stars": 802, "source_url": "https://github.com/gterrono/houston/blob/e652379d68f6c94ff5ac4cd9f4dccafc62c185cf/server/publications.coffee", "line_start": 1, "line_end": 42}927{"id": "gterrono/houston:server/publications.coffee:1:js_to_coffee", "type": "js_to_coffee", "prompt": "Convert this JavaScript to CoffeeScript.\n```javascript\nvar Dummy, collections, root;\n\nroot = typeof exports !== \"undefined\" && exports !== null ? exports : this;\n\nDummy = new Meteor.Collection(\"system.dummy\"); // hack.\n\ncollections = {\n 'users': Meteor.users\n};\n\nMeteor.startup(function() {\n var set_up_collection;\n return set_up_collection = function(name, collection) {\n var methods;\n methods = {};\n methods[`admin_${name}_insert`] = function(doc) {\n var user;\n if (!this.userId) {\n return;\n }\n user = Meteor.users.findOne(this.userId);\n if (!(user != null ? user.profile.admin : void 0)) {\n return;\n }\n return collection.insert(doc);\n };\n methods[`admin_${name}_update`] = function(id, update_dict) {\n var user;\n if (!this.userId) {\n return;\n }\n user = Meteor.users.findOne(this.userId);\n if (!(user != null ? user.profile.admin : void 0)) {\n return;\n }\n if (collection.findOne(id)) {\n return collection.update(id, update_dict);\n } else {\n id = collection.findOne(new Meteor.Collection.ObjectID(id));\n return collection.update(id, update_dict);\n }\n };\n methods[`admin_${name}_delete`] = function(id, update_dict) {\n var user;\n if (!this.userId) {\n return;\n }\n user = Meteor.users.findOne(this.userId);\n if (!(user != null ? user.profile.admin : void 0)) {\n return;\n }\n if (collection.findOne(id)) {\n return collection.remove(id);\n } else {\n id = collection.findOne(new Meteor.Collection.ObjectID(id));\n return collection.remove(id);\n }\n };\n Meteor.methods(methods);\n return Meteor.publish(`admin_${name}`, function(sort, filter, limit) {\n var e;\n if (Meteor.users.findOne({\n _id: this.userId,\n 'profile.admin': true\n })) {\n try {\n return collection.find(filter, {\n sort: sort,\n limit: limit\n });\n } catch (error) {\n e = error;\n return console.log(e);\n }\n }\n });\n };\n});\n```", "response": "root = exports ? this\n\nDummy = new Meteor.Collection(\"system.dummy\") # hack.\ncollections = {'users': Meteor.users}\n\nMeteor.startup ->\n set_up_collection = (name, collection) ->\n methods = {}\n methods[\"admin_#{name}_insert\"] = (doc) ->\n return unless @userId\n user = Meteor.users.findOne(@userId)\n return unless user?.profile.admin\n collection.insert(doc)\n\n methods[\"admin_#{name}_update\"] = (id, update_dict) ->\n return unless @userId\n user = Meteor.users.findOne(@userId)\n return unless user?.profile.admin\n if collection.findOne(id)\n collection.update(id, update_dict)\n else\n id = collection.findOne(new Meteor.Collection.ObjectID(id))\n collection.update(id, update_dict)\n\n methods[\"admin_#{name}_delete\"] = (id, update_dict) ->\n return unless @userId\n user = Meteor.users.findOne(@userId)\n return unless user?.profile.admin\n if collection.findOne(id)\n collection.remove(id)\n else\n id = collection.findOne(new Meteor.Collection.ObjectID(id))\n collection.remove(id)\n\n Meteor.methods methods\n\n Meteor.publish \"admin_#{name}\", (sort, filter, limit) ->\n if Meteor.users.findOne(_id: @userId, 'profile.admin': true)\n try\n collection.find(filter, sort: sort, limit: limit)\n catch e\n console.log e", "source_lang": "JavaScript", "target_lang": "CoffeeScript", "repo": "gterrono/houston", "path": "server/publications.coffee", "license": "MIT", "commit": "e652379d68f6c94ff5ac4cd9f4dccafc62c185cf", "stars": 802, "source_url": "https://github.com/gterrono/houston/blob/e652379d68f6c94ff5ac4cd9f4dccafc62c185cf/server/publications.coffee", "line_start": 1, "line_end": 42}928{"id": "gterrono/houston:server/publications.coffee:1:completion", "type": "completion", "prompt": "root = exports ? this\n\nDummy = new Meteor.Collection(\"system.dummy\") # hack.\ncollections = {'users': Meteor.users}\n\nMeteor.startup ->\n set_up_collection = (name, collection) ->\n methods = {}\n methods[\"admin_#{name}_insert\"] = (doc) ->\n return unless @userId\n user = Meteor.users.findOne(@userId)\n return unless user?.profile.admin\n collection.insert(doc)\n\n methods[\"admin_#{name}_update\"] = (id, update_dict) ->\n return unless @userId\n user = Meteor.users.findOne(@userId)\n return unless user?.profile.admin\n if collection.findOne(id)\n collection.update(id, update_dict)\n else", "response": "id = collection.findOne(new Meteor.Collection.ObjectID(id))\n collection.update(id, update_dict)\n\n methods[\"admin_#{name}_delete\"] = (id, update_dict) ->\n return unless @userId\n user = Meteor.users.findOne(@userId)\n return unless user?.profile.admin\n if collection.findOne(id)\n collection.remove(id)\n else\n id = collection.findOne(new Meteor.Collection.ObjectID(id))\n collection.remove(id)\n\n Meteor.methods methods\n\n Meteor.publish \"admin_#{name}\", (sort, filter, limit) ->\n if Meteor.users.findOne(_id: @userId, 'profile.admin': true)\n try\n collection.find(filter, sort: sort, limit: limit)\n catch e\n console.log e", "source_lang": "CoffeeScript", "target_lang": "CoffeeScript", "repo": "gterrono/houston", "path": "server/publications.coffee", "license": "MIT", "commit": "e652379d68f6c94ff5ac4cd9f4dccafc62c185cf", "stars": 802, "source_url": "https://github.com/gterrono/houston/blob/e652379d68f6c94ff5ac4cd9f4dccafc62c185cf/server/publications.coffee", "line_start": 1, "line_end": 42}929{"id": "gterrono/houston:server/publications.coffee:2:raw_corpus", "type": "raw_corpus", "prompt": "", "response": "collection.find().observe\n added: (document) ->\n Collections.update {name},\n $inc: {count: 1},\n $addToSet: fields: $each: get_field_names([document])\n removed: (document) -> Collections.update {name}, {$inc: {count: -1}}\n\n fields = get_field_names(collection.find().fetch())\n c = Collections.findOne {name}\n if c\n Collections.update c._id, {$set: count: collection.find().count(), fields: fields}\n else\n Collections.insert {name, count: collection.find().count(), fields: fields}\n\n Dummy.findOne() # hack\n\n save_collections = (meh, collections_db) ->\n collection_names = (col.collectionName for col in collections_db \\\n when (col.collectionName.indexOf \"system.\") isnt 0 and\n (col.collectionName.indexOf \"admin_\") isnt 0)\n\n collection_names.forEach (name) ->\n unless name of collections\n try\n collections[name] = new Meteor.Collection(name)\n catch e\n for key, value of root\n if name == value._name\n collections[name] = value\n console.log e unless collections[name]?\n\n set_up_collection(name, collections[name])\n\n Meteor.methods\n make_admin: (userId) ->\n # limit one admin\n return if Meteor.users.findOne {'profile.admin': true}\n Meteor.users.update userId, $set: {'profile.admin': true}\n return true", "source_lang": "", "target_lang": "CoffeeScript", "repo": "gterrono/houston", "path": "server/publications.coffee", "license": "MIT", "commit": "e652379d68f6c94ff5ac4cd9f4dccafc62c185cf", "stars": 802, "source_url": "https://github.com/gterrono/houston/blob/e652379d68f6c94ff5ac4cd9f4dccafc62c185cf/server/publications.coffee", "line_start": 44, "line_end": 82}930{"id": "gterrono/houston:server/publications.coffee:2:coffee_to_js", "type": "coffee_to_js", "prompt": "Convert this CoffeeScript to JavaScript.\n```coffeescript\ncollection.find().observe\n added: (document) ->\n Collections.update {name},\n $inc: {count: 1},\n $addToSet: fields: $each: get_field_names([document])\n removed: (document) -> Collections.update {name}, {$inc: {count: -1}}\n\n fields = get_field_names(collection.find().fetch())\n c = Collections.findOne {name}\n if c\n Collections.update c._id, {$set: count: collection.find().count(), fields: fields}\n else\n Collections.insert {name, count: collection.find().count(), fields: fields}\n\n Dummy.findOne() # hack\n\n save_collections = (meh, collections_db) ->\n collection_names = (col.collectionName for col in collections_db \\\n when (col.collectionName.indexOf \"system.\") isnt 0 and\n (col.collectionName.indexOf \"admin_\") isnt 0)\n\n collection_names.forEach (name) ->\n unless name of collections\n try\n collections[name] = new Meteor.Collection(name)\n catch e\n for key, value of root\n if name == value._name\n collections[name] = value\n console.log e unless collections[name]?\n\n set_up_collection(name, collections[name])\n\n Meteor.methods\n make_admin: (userId) ->\n # limit one admin\n return if Meteor.users.findOne {'profile.admin': true}\n Meteor.users.update userId, $set: {'profile.admin': true}\n return true\n```", "response": "var c, fields, save_collections;\n\ncollection.find().observe({\n added: function(document) {\n return Collections.update({name}, {\n $inc: {\n count: 1\n },\n $addToSet: {\n fields: {\n $each: get_field_names([document])\n }\n }\n });\n },\n removed: function(document) {\n return Collections.update({name}, {\n $inc: {\n count: -1\n }\n });\n }\n});\n\nfields = get_field_names(collection.find().fetch());\n\nc = Collections.findOne({name});\n\nif (c) {\n Collections.update(c._id, {\n $set: {\n count: collection.find().count(),\n fields: fields\n }\n });\n} else {\n Collections.insert({\n name,\n count: collection.find().count(),\n fields: fields\n });\n}\n\nDummy.findOne(); // hack\n\nsave_collections = function(meh, collections_db) {\n var col, collection_names;\n collection_names = (function() {\n var i, len, results;\n results = [];\n for (i = 0, len = collections_db.length; i < len; i++) {\n col = collections_db[i];\n if ((col.collectionName.indexOf(\"system.\")) !== 0 && (col.collectionName.indexOf(\"admin_\")) !== 0) {\n results.push(col.collectionName);\n }\n }\n return results;\n })();\n return collection_names.forEach(function(name) {\n var e, key, value;\n if (!(name in collections)) {\n try {\n collections[name] = new Meteor.Collection(name);\n } catch (error) {\n e = error;\n for (key in root) {\n value = root[key];\n if (name === value._name) {\n collections[name] = value;\n }\n }\n if (collections[name] == null) {\n console.log(e);\n }\n }\n return set_up_collection(name, collections[name]);\n }\n });\n};\n\nMeteor.methods({\n make_admin: function(userId) {\n // limit one admin\n if (Meteor.users.findOne({\n 'profile.admin': true\n })) {\n return;\n }\n Meteor.users.update(userId, {\n $set: {\n 'profile.admin': true\n }\n });\n return true;\n }\n});", "source_lang": "CoffeeScript", "target_lang": "JavaScript", "repo": "gterrono/houston", "path": "server/publications.coffee", "license": "MIT", "commit": "e652379d68f6c94ff5ac4cd9f4dccafc62c185cf", "stars": 802, "source_url": "https://github.com/gterrono/houston/blob/e652379d68f6c94ff5ac4cd9f4dccafc62c185cf/server/publications.coffee", "line_start": 44, "line_end": 82}931{"id": "gterrono/houston:server/publications.coffee:2:js_to_coffee", "type": "js_to_coffee", "prompt": "Convert this JavaScript to CoffeeScript.\n```javascript\nvar c, fields, save_collections;\n\ncollection.find().observe({\n added: function(document) {\n return Collections.update({name}, {\n $inc: {\n count: 1\n },\n $addToSet: {\n fields: {\n $each: get_field_names([document])\n }\n }\n });\n },\n removed: function(document) {\n return Collections.update({name}, {\n $inc: {\n count: -1\n }\n });\n }\n});\n\nfields = get_field_names(collection.find().fetch());\n\nc = Collections.findOne({name});\n\nif (c) {\n Collections.update(c._id, {\n $set: {\n count: collection.find().count(),\n fields: fields\n }\n });\n} else {\n Collections.insert({\n name,\n count: collection.find().count(),\n fields: fields\n });\n}\n\nDummy.findOne(); // hack\n\nsave_collections = function(meh, collections_db) {\n var col, collection_names;\n collection_names = (function() {\n var i, len, results;\n results = [];\n for (i = 0, len = collections_db.length; i < len; i++) {\n col = collections_db[i];\n if ((col.collectionName.indexOf(\"system.\")) !== 0 && (col.collectionName.indexOf(\"admin_\")) !== 0) {\n results.push(col.collectionName);\n }\n }\n return results;\n })();\n return collection_names.forEach(function(name) {\n var e, key, value;\n if (!(name in collections)) {\n try {\n collections[name] = new Meteor.Collection(name);\n } catch (error) {\n e = error;\n for (key in root) {\n value = root[key];\n if (name === value._name) {\n collections[name] = value;\n }\n }\n if (collections[name] == null) {\n console.log(e);\n }\n }\n return set_up_collection(name, collections[name]);\n }\n });\n};\n\nMeteor.methods({\n make_admin: function(userId) {\n // limit one admin\n if (Meteor.users.findOne({\n 'profile.admin': true\n })) {\n return;\n }\n Meteor.users.update(userId, {\n $set: {\n 'profile.admin': true\n }\n });\n return true;\n }\n});\n```", "response": "collection.find().observe\n added: (document) ->\n Collections.update {name},\n $inc: {count: 1},\n $addToSet: fields: $each: get_field_names([document])\n removed: (document) -> Collections.update {name}, {$inc: {count: -1}}\n\n fields = get_field_names(collection.find().fetch())\n c = Collections.findOne {name}\n if c\n Collections.update c._id, {$set: count: collection.find().count(), fields: fields}\n else\n Collections.insert {name, count: collection.find().count(), fields: fields}\n\n Dummy.findOne() # hack\n\n save_collections = (meh, collections_db) ->\n collection_names = (col.collectionName for col in collections_db \\\n when (col.collectionName.indexOf \"system.\") isnt 0 and\n (col.collectionName.indexOf \"admin_\") isnt 0)\n\n collection_names.forEach (name) ->\n unless name of collections\n try\n collections[name] = new Meteor.Collection(name)\n catch e\n for key, value of root\n if name == value._name\n collections[name] = value\n console.log e unless collections[name]?\n\n set_up_collection(name, collections[name])\n\n Meteor.methods\n make_admin: (userId) ->\n # limit one admin\n return if Meteor.users.findOne {'profile.admin': true}\n Meteor.users.update userId, $set: {'profile.admin': true}\n return true", "source_lang": "JavaScript", "target_lang": "CoffeeScript", "repo": "gterrono/houston", "path": "server/publications.coffee", "license": "MIT", "commit": "e652379d68f6c94ff5ac4cd9f4dccafc62c185cf", "stars": 802, "source_url": "https://github.com/gterrono/houston/blob/e652379d68f6c94ff5ac4cd9f4dccafc62c185cf/server/publications.coffee", "line_start": 44, "line_end": 82}932{"id": "gterrono/houston:server/publications.coffee:2:completion", "type": "completion", "prompt": "collection.find().observe\n added: (document) ->\n Collections.update {name},\n $inc: {count: 1},\n $addToSet: fields: $each: get_field_names([document])\n removed: (document) -> Collections.update {name}, {$inc: {count: -1}}\n\n fields = get_field_names(collection.find().fetch())\n c = Collections.findOne {name}\n if c\n Collections.update c._id, {$set: count: collection.find().count(), fields: fields}\n else\n Collections.insert {name, count: collection.find().count(), fields: fields}\n\n Dummy.findOne() # hack\n\n save_collections = (meh, collections_db) ->\n collection_names = (col.collectionName for col in collections_db \\\n when (col.collectionName.indexOf \"system.\") isnt 0 and", "response": "(col.collectionName.indexOf \"admin_\") isnt 0)\n\n collection_names.forEach (name) ->\n unless name of collections\n try\n collections[name] = new Meteor.Collection(name)\n catch e\n for key, value of root\n if name == value._name\n collections[name] = value\n console.log e unless collections[name]?\n\n set_up_collection(name, collections[name])\n\n Meteor.methods\n make_admin: (userId) ->\n # limit one admin\n return if Meteor.users.findOne {'profile.admin': true}\n Meteor.users.update userId, $set: {'profile.admin': true}\n return true", "source_lang": "CoffeeScript", "target_lang": "CoffeeScript", "repo": "gterrono/houston", "path": "server/publications.coffee", "license": "MIT", "commit": "e652379d68f6c94ff5ac4cd9f4dccafc62c185cf", "stars": 802, "source_url": "https://github.com/gterrono/houston/blob/e652379d68f6c94ff5ac4cd9f4dccafc62c185cf/server/publications.coffee", "line_start": 44, "line_end": 82}933{"id": "gterrono/houston:server/publications.coffee:3:raw_corpus", "type": "raw_corpus", "prompt": "", "response": "setupNewCollection: (name) ->\n return unless @userId\n user = Meteor.users.findOne(@userId)\n return unless user?.profile.admin\n unless name of collections\n try\n collections[name] = new Meteor.Collection(name)\n catch e\n for key, value of root\n if name == value._name\n collections[name] = value\n console.log e\n\n set_up_collection(name, collections[name])\n\n fn = Meteor.bindEnvironment save_collections, (e) ->\n console.log e\n\n # MongoInternals is the 'right' solution as of 0.6.5\n mongo_driver = MongoInternals?.defaultRemoteCollectionDriver() or Meteor._RemoteCollectionDriver\n mongo_driver.mongo.db.collections fn\n\n\n# publish our own internal state\nMeteor.publish \"admin\", ->\n if Meteor.users.findOne(_id: @userId, 'profile.admin': true)\n Collections.find()\n\n\nMeteor.publish 'adminUser', -> # used by login page to see if admin has been created yet\n Meteor.users.find({'profile.admin': true}, fields: 'profile.admin': true)", "source_lang": "", "target_lang": "CoffeeScript", "repo": "gterrono/houston", "path": "server/publications.coffee", "license": "MIT", "commit": "e652379d68f6c94ff5ac4cd9f4dccafc62c185cf", "stars": 802, "source_url": "https://github.com/gterrono/houston/blob/e652379d68f6c94ff5ac4cd9f4dccafc62c185cf/server/publications.coffee", "line_start": 84, "line_end": 114}934{"id": "gterrono/houston:server/publications.coffee:3:coffee_to_js", "type": "coffee_to_js", "prompt": "Convert this CoffeeScript to JavaScript.\n```coffeescript\nsetupNewCollection: (name) ->\n return unless @userId\n user = Meteor.users.findOne(@userId)\n return unless user?.profile.admin\n unless name of collections\n try\n collections[name] = new Meteor.Collection(name)\n catch e\n for key, value of root\n if name == value._name\n collections[name] = value\n console.log e\n\n set_up_collection(name, collections[name])\n\n fn = Meteor.bindEnvironment save_collections, (e) ->\n console.log e\n\n # MongoInternals is the 'right' solution as of 0.6.5\n mongo_driver = MongoInternals?.defaultRemoteCollectionDriver() or Meteor._RemoteCollectionDriver\n mongo_driver.mongo.db.collections fn\n\n\n# publish our own internal state\nMeteor.publish \"admin\", ->\n if Meteor.users.findOne(_id: @userId, 'profile.admin': true)\n Collections.find()\n\n\nMeteor.publish 'adminUser', -> # used by login page to see if admin has been created yet\n Meteor.users.find({'profile.admin': true}, fields: 'profile.admin': true)\n```", "response": "var fn, mongo_driver;\n\n({\n setupNewCollection: function(name) {\n var e, key, user, value;\n if (!this.userId) {\n return;\n }\n user = Meteor.users.findOne(this.userId);\n if (!(user != null ? user.profile.admin : void 0)) {\n return;\n }\n if (!(name in collections)) {\n try {\n collections[name] = new Meteor.Collection(name);\n } catch (error) {\n e = error;\n for (key in root) {\n value = root[key];\n if (name === value._name) {\n collections[name] = value;\n }\n }\n console.log(e);\n }\n return set_up_collection(name, collections[name]);\n }\n }\n});\n\nfn = Meteor.bindEnvironment(save_collections, function(e) {\n return console.log(e);\n});\n\n// MongoInternals is the 'right' solution as of 0.6.5\nmongo_driver = (typeof MongoInternals !== \"undefined\" && MongoInternals !== null ? MongoInternals.defaultRemoteCollectionDriver() : void 0) || Meteor._RemoteCollectionDriver;\n\nmongo_driver.mongo.db.collections(fn);\n\n// publish our own internal state\nMeteor.publish(\"admin\", function() {\n if (Meteor.users.findOne({\n _id: this.userId,\n 'profile.admin': true\n })) {\n return Collections.find();\n }\n});\n\nMeteor.publish('adminUser', function() { // used by login page to see if admin has been created yet\n return Meteor.users.find({\n 'profile.admin': true\n }, {\n fields: {\n 'profile.admin': true\n }\n });\n});", "source_lang": "CoffeeScript", "target_lang": "JavaScript", "repo": "gterrono/houston", "path": "server/publications.coffee", "license": "MIT", "commit": "e652379d68f6c94ff5ac4cd9f4dccafc62c185cf", "stars": 802, "source_url": "https://github.com/gterrono/houston/blob/e652379d68f6c94ff5ac4cd9f4dccafc62c185cf/server/publications.coffee", "line_start": 84, "line_end": 114}935{"id": "gterrono/houston:server/publications.coffee:3:js_to_coffee", "type": "js_to_coffee", "prompt": "Convert this JavaScript to CoffeeScript.\n```javascript\nvar fn, mongo_driver;\n\n({\n setupNewCollection: function(name) {\n var e, key, user, value;\n if (!this.userId) {\n return;\n }\n user = Meteor.users.findOne(this.userId);\n if (!(user != null ? user.profile.admin : void 0)) {\n return;\n }\n if (!(name in collections)) {\n try {\n collections[name] = new Meteor.Collection(name);\n } catch (error) {\n e = error;\n for (key in root) {\n value = root[key];\n if (name === value._name) {\n collections[name] = value;\n }\n }\n console.log(e);\n }\n return set_up_collection(name, collections[name]);\n }\n }\n});\n\nfn = Meteor.bindEnvironment(save_collections, function(e) {\n return console.log(e);\n});\n\n// MongoInternals is the 'right' solution as of 0.6.5\nmongo_driver = (typeof MongoInternals !== \"undefined\" && MongoInternals !== null ? MongoInternals.defaultRemoteCollectionDriver() : void 0) || Meteor._RemoteCollectionDriver;\n\nmongo_driver.mongo.db.collections(fn);\n\n// publish our own internal state\nMeteor.publish(\"admin\", function() {\n if (Meteor.users.findOne({\n _id: this.userId,\n 'profile.admin': true\n })) {\n return Collections.find();\n }\n});\n\nMeteor.publish('adminUser', function() { // used by login page to see if admin has been created yet\n return Meteor.users.find({\n 'profile.admin': true\n }, {\n fields: {\n 'profile.admin': true\n }\n });\n});\n```", "response": "setupNewCollection: (name) ->\n return unless @userId\n user = Meteor.users.findOne(@userId)\n return unless user?.profile.admin\n unless name of collections\n try\n collections[name] = new Meteor.Collection(name)\n catch e\n for key, value of root\n if name == value._name\n collections[name] = value\n console.log e\n\n set_up_collection(name, collections[name])\n\n fn = Meteor.bindEnvironment save_collections, (e) ->\n console.log e\n\n # MongoInternals is the 'right' solution as of 0.6.5\n mongo_driver = MongoInternals?.defaultRemoteCollectionDriver() or Meteor._RemoteCollectionDriver\n mongo_driver.mongo.db.collections fn\n\n\n# publish our own internal state\nMeteor.publish \"admin\", ->\n if Meteor.users.findOne(_id: @userId, 'profile.admin': true)\n Collections.find()\n\n\nMeteor.publish 'adminUser', -> # used by login page to see if admin has been created yet\n Meteor.users.find({'profile.admin': true}, fields: 'profile.admin': true)", "source_lang": "JavaScript", "target_lang": "CoffeeScript", "repo": "gterrono/houston", "path": "server/publications.coffee", "license": "MIT", "commit": "e652379d68f6c94ff5ac4cd9f4dccafc62c185cf", "stars": 802, "source_url": "https://github.com/gterrono/houston/blob/e652379d68f6c94ff5ac4cd9f4dccafc62c185cf/server/publications.coffee", "line_start": 84, "line_end": 114}936{"id": "gterrono/houston:server/publications.coffee:3:completion", "type": "completion", "prompt": "setupNewCollection: (name) ->\n return unless @userId\n user = Meteor.users.findOne(@userId)\n return unless user?.profile.admin\n unless name of collections\n try\n collections[name] = new Meteor.Collection(name)\n catch e\n for key, value of root\n if name == value._name\n collections[name] = value\n console.log e\n\n set_up_collection(name, collections[name])", "response": "fn = Meteor.bindEnvironment save_collections, (e) ->\n console.log e\n\n # MongoInternals is the 'right' solution as of 0.6.5\n mongo_driver = MongoInternals?.defaultRemoteCollectionDriver() or Meteor._RemoteCollectionDriver\n mongo_driver.mongo.db.collections fn\n\n\n# publish our own internal state\nMeteor.publish \"admin\", ->\n if Meteor.users.findOne(_id: @userId, 'profile.admin': true)\n Collections.find()\n\n\nMeteor.publish 'adminUser', -> # used by login page to see if admin has been created yet\n Meteor.users.find({'profile.admin': true}, fields: 'profile.admin': true)", "source_lang": "CoffeeScript", "target_lang": "CoffeeScript", "repo": "gterrono/houston", "path": "server/publications.coffee", "license": "MIT", "commit": "e652379d68f6c94ff5ac4cd9f4dccafc62c185cf", "stars": 802, "source_url": "https://github.com/gterrono/houston/blob/e652379d68f6c94ff5ac4cd9f4dccafc62c185cf/server/publications.coffee", "line_start": 84, "line_end": 114}937{"id": "gterrono/houston:server/publications.coffee:1:raw_corpus", "type": "raw_corpus", "prompt": "", "response": "root = exports ? this\n\nDummy = new Meteor.Collection(\"system.dummy\") # hack.\ncollections = {'users': Meteor.users}\n\nMeteor.startup ->\n set_up_collection = (name, collection) ->\n methods = {}\n methods[\"_houston_#{name}_insert\"] = (doc) ->\n return unless @userId\n user = Meteor.users.findOne(@userId)\n return unless user?.profile.admin\n collection.insert(doc)\n\n methods[\"_houston_#{name}_update\"] = (id, update_dict) ->\n return unless @userId\n user = Meteor.users.findOne(@userId)\n return unless user?.profile.admin\n if collection.findOne(id)\n collection.update(id, update_dict)\n else\n id = collection.findOne(new Meteor.Collection.ObjectID(id))\n collection.update(id, update_dict)\n\n methods[\"_houston_#{name}_delete\"] = (id, update_dict) ->\n return unless @userId\n user = Meteor.users.findOne(@userId)\n return unless user?.profile.admin\n if collection.findOne(id)\n collection.remove(id)\n else\n id = collection.findOne(new Meteor.Collection.ObjectID(id))\n collection.remove(id)\n\n Meteor.methods methods\n\n Meteor.publish \"_houston_#{name}\", (sort, filter, limit)->\n if Meteor.users.findOne(_id: @userId, 'profile.admin': true)\n try\n collection.find(filter, sort: sort, limit: limit)\n catch e\n console.log e", "source_lang": "", "target_lang": "CoffeeScript", "repo": "gterrono/houston", "path": "server/publications.coffee", "license": "MIT", "commit": "93e06a251afa99843d47e26f6bfde1ba3c93c47e", "stars": 802, "source_url": "https://github.com/gterrono/houston/blob/93e06a251afa99843d47e26f6bfde1ba3c93c47e/server/publications.coffee", "line_start": 1, "line_end": 42}938{"id": "gterrono/houston:server/publications.coffee:1:coffee_to_js", "type": "coffee_to_js", "prompt": "Convert this CoffeeScript to JavaScript.\n```coffeescript\nroot = exports ? this\n\nDummy = new Meteor.Collection(\"system.dummy\") # hack.\ncollections = {'users': Meteor.users}\n\nMeteor.startup ->\n set_up_collection = (name, collection) ->\n methods = {}\n methods[\"_houston_#{name}_insert\"] = (doc) ->\n return unless @userId\n user = Meteor.users.findOne(@userId)\n return unless user?.profile.admin\n collection.insert(doc)\n\n methods[\"_houston_#{name}_update\"] = (id, update_dict) ->\n return unless @userId\n user = Meteor.users.findOne(@userId)\n return unless user?.profile.admin\n if collection.findOne(id)\n collection.update(id, update_dict)\n else\n id = collection.findOne(new Meteor.Collection.ObjectID(id))\n collection.update(id, update_dict)\n\n methods[\"_houston_#{name}_delete\"] = (id, update_dict) ->\n return unless @userId\n user = Meteor.users.findOne(@userId)\n return unless user?.profile.admin\n if collection.findOne(id)\n collection.remove(id)\n else\n id = collection.findOne(new Meteor.Collection.ObjectID(id))\n collection.remove(id)\n\n Meteor.methods methods\n\n Meteor.publish \"_houston_#{name}\", (sort, filter, limit)->\n if Meteor.users.findOne(_id: @userId, 'profile.admin': true)\n try\n collection.find(filter, sort: sort, limit: limit)\n catch e\n console.log e\n```", "response": "var Dummy, collections, root;\n\nroot = typeof exports !== \"undefined\" && exports !== null ? exports : this;\n\nDummy = new Meteor.Collection(\"system.dummy\"); // hack.\n\ncollections = {\n 'users': Meteor.users\n};\n\nMeteor.startup(function() {\n var set_up_collection;\n return set_up_collection = function(name, collection) {\n var methods;\n methods = {};\n methods[`_houston_${name}_insert`] = function(doc) {\n var user;\n if (!this.userId) {\n return;\n }\n user = Meteor.users.findOne(this.userId);\n if (!(user != null ? user.profile.admin : void 0)) {\n return;\n }\n return collection.insert(doc);\n };\n methods[`_houston_${name}_update`] = function(id, update_dict) {\n var user;\n if (!this.userId) {\n return;\n }\n user = Meteor.users.findOne(this.userId);\n if (!(user != null ? user.profile.admin : void 0)) {\n return;\n }\n if (collection.findOne(id)) {\n return collection.update(id, update_dict);\n } else {\n id = collection.findOne(new Meteor.Collection.ObjectID(id));\n return collection.update(id, update_dict);\n }\n };\n methods[`_houston_${name}_delete`] = function(id, update_dict) {\n var user;\n if (!this.userId) {\n return;\n }\n user = Meteor.users.findOne(this.userId);\n if (!(user != null ? user.profile.admin : void 0)) {\n return;\n }\n if (collection.findOne(id)) {\n return collection.remove(id);\n } else {\n id = collection.findOne(new Meteor.Collection.ObjectID(id));\n return collection.remove(id);\n }\n };\n Meteor.methods(methods);\n return Meteor.publish(`_houston_${name}`, function(sort, filter, limit) {\n var e;\n if (Meteor.users.findOne({\n _id: this.userId,\n 'profile.admin': true\n })) {\n try {\n return collection.find(filter, {\n sort: sort,\n limit: limit\n });\n } catch (error) {\n e = error;\n return console.log(e);\n }\n }\n });\n };\n});", "source_lang": "CoffeeScript", "target_lang": "JavaScript", "repo": "gterrono/houston", "path": "server/publications.coffee", "license": "MIT", "commit": "93e06a251afa99843d47e26f6bfde1ba3c93c47e", "stars": 802, "source_url": "https://github.com/gterrono/houston/blob/93e06a251afa99843d47e26f6bfde1ba3c93c47e/server/publications.coffee", "line_start": 1, "line_end": 42}939{"id": "gterrono/houston:server/publications.coffee:1:js_to_coffee", "type": "js_to_coffee", "prompt": "Convert this JavaScript to CoffeeScript.\n```javascript\nvar Dummy, collections, root;\n\nroot = typeof exports !== \"undefined\" && exports !== null ? exports : this;\n\nDummy = new Meteor.Collection(\"system.dummy\"); // hack.\n\ncollections = {\n 'users': Meteor.users\n};\n\nMeteor.startup(function() {\n var set_up_collection;\n return set_up_collection = function(name, collection) {\n var methods;\n methods = {};\n methods[`_houston_${name}_insert`] = function(doc) {\n var user;\n if (!this.userId) {\n return;\n }\n user = Meteor.users.findOne(this.userId);\n if (!(user != null ? user.profile.admin : void 0)) {\n return;\n }\n return collection.insert(doc);\n };\n methods[`_houston_${name}_update`] = function(id, update_dict) {\n var user;\n if (!this.userId) {\n return;\n }\n user = Meteor.users.findOne(this.userId);\n if (!(user != null ? user.profile.admin : void 0)) {\n return;\n }\n if (collection.findOne(id)) {\n return collection.update(id, update_dict);\n } else {\n id = collection.findOne(new Meteor.Collection.ObjectID(id));\n return collection.update(id, update_dict);\n }\n };\n methods[`_houston_${name}_delete`] = function(id, update_dict) {\n var user;\n if (!this.userId) {\n return;\n }\n user = Meteor.users.findOne(this.userId);\n if (!(user != null ? user.profile.admin : void 0)) {\n return;\n }\n if (collection.findOne(id)) {\n return collection.remove(id);\n } else {\n id = collection.findOne(new Meteor.Collection.ObjectID(id));\n return collection.remove(id);\n }\n };\n Meteor.methods(methods);\n return Meteor.publish(`_houston_${name}`, function(sort, filter, limit) {\n var e;\n if (Meteor.users.findOne({\n _id: this.userId,\n 'profile.admin': true\n })) {\n try {\n return collection.find(filter, {\n sort: sort,\n limit: limit\n });\n } catch (error) {\n e = error;\n return console.log(e);\n }\n }\n });\n };\n});\n```", "response": "root = exports ? this\n\nDummy = new Meteor.Collection(\"system.dummy\") # hack.\ncollections = {'users': Meteor.users}\n\nMeteor.startup ->\n set_up_collection = (name, collection) ->\n methods = {}\n methods[\"_houston_#{name}_insert\"] = (doc) ->\n return unless @userId\n user = Meteor.users.findOne(@userId)\n return unless user?.profile.admin\n collection.insert(doc)\n\n methods[\"_houston_#{name}_update\"] = (id, update_dict) ->\n return unless @userId\n user = Meteor.users.findOne(@userId)\n return unless user?.profile.admin\n if collection.findOne(id)\n collection.update(id, update_dict)\n else\n id = collection.findOne(new Meteor.Collection.ObjectID(id))\n collection.update(id, update_dict)\n\n methods[\"_houston_#{name}_delete\"] = (id, update_dict) ->\n return unless @userId\n user = Meteor.users.findOne(@userId)\n return unless user?.profile.admin\n if collection.findOne(id)\n collection.remove(id)\n else\n id = collection.findOne(new Meteor.Collection.ObjectID(id))\n collection.remove(id)\n\n Meteor.methods methods\n\n Meteor.publish \"_houston_#{name}\", (sort, filter, limit)->\n if Meteor.users.findOne(_id: @userId, 'profile.admin': true)\n try\n collection.find(filter, sort: sort, limit: limit)\n catch e\n console.log e", "source_lang": "JavaScript", "target_lang": "CoffeeScript", "repo": "gterrono/houston", "path": "server/publications.coffee", "license": "MIT", "commit": "93e06a251afa99843d47e26f6bfde1ba3c93c47e", "stars": 802, "source_url": "https://github.com/gterrono/houston/blob/93e06a251afa99843d47e26f6bfde1ba3c93c47e/server/publications.coffee", "line_start": 1, "line_end": 42}940{"id": "gterrono/houston:server/publications.coffee:1:completion", "type": "completion", "prompt": "root = exports ? this\n\nDummy = new Meteor.Collection(\"system.dummy\") # hack.\ncollections = {'users': Meteor.users}\n\nMeteor.startup ->\n set_up_collection = (name, collection) ->\n methods = {}\n methods[\"_houston_#{name}_insert\"] = (doc) ->\n return unless @userId\n user = Meteor.users.findOne(@userId)\n return unless user?.profile.admin\n collection.insert(doc)\n\n methods[\"_houston_#{name}_update\"] = (id, update_dict) ->\n return unless @userId\n user = Meteor.users.findOne(@userId)\n return unless user?.profile.admin\n if collection.findOne(id)\n collection.update(id, update_dict)\n else", "response": "id = collection.findOne(new Meteor.Collection.ObjectID(id))\n collection.update(id, update_dict)\n\n methods[\"_houston_#{name}_delete\"] = (id, update_dict) ->\n return unless @userId\n user = Meteor.users.findOne(@userId)\n return unless user?.profile.admin\n if collection.findOne(id)\n collection.remove(id)\n else\n id = collection.findOne(new Meteor.Collection.ObjectID(id))\n collection.remove(id)\n\n Meteor.methods methods\n\n Meteor.publish \"_houston_#{name}\", (sort, filter, limit)->\n if Meteor.users.findOne(_id: @userId, 'profile.admin': true)\n try\n collection.find(filter, sort: sort, limit: limit)\n catch e\n console.log e", "source_lang": "CoffeeScript", "target_lang": "CoffeeScript", "repo": "gterrono/houston", "path": "server/publications.coffee", "license": "MIT", "commit": "93e06a251afa99843d47e26f6bfde1ba3c93c47e", "stars": 802, "source_url": "https://github.com/gterrono/houston/blob/93e06a251afa99843d47e26f6bfde1ba3c93c47e/server/publications.coffee", "line_start": 1, "line_end": 42}941{"id": "gterrono/houston:server/publications.coffee:2:raw_corpus", "type": "raw_corpus", "prompt": "", "response": "collection.find().observe\n added: (document) ->\n Houston._collections.update {name},\n $inc: {count: 1},\n $addToSet: fields: Houston._get_field_names([document])\n removed: (document) -> Houston._collections.update {name}, {$inc: {count: -1}}\n fields = Houston._get_field_names(collection.find().fetch())\n if Houston._collections.findOne {name}\n Houston._collections.update {name}, {$set: count: collection.find().count(), fields: fields}\n else\n Houston._collections.insert {name, count: collection.find().count(), fields: fields}\n\n\n Dummy.findOne() # hack\n save_collections = (meh, collections_db) ->\n collection_names = (col.collectionName for col in collections_db \\\n when (col.collectionName.indexOf \"system.\") isnt 0 and\n (col.collectionName.indexOf \"houston_\") isnt 0)\n\n collection_names.forEach (name) ->\n unless name of collections\n try\n collections[name] = new Meteor.Collection(name)\n catch e\n for key, value of root\n if name == value._name\n collections[name] = value\n console.log e unless collections[name]?\n\n set_up_collection(name, collections[name])\n\n Meteor.methods\n _houston_make_admin: (userId) ->\n # limit one admin\n return if Meteor.users.findOne {'profile.admin': true}\n Meteor.users.update userId, $set: {'profile.admin': true}\n return True\n\n _houston_setupNewCollection: (name) ->\n return unless @userId\n user = Meteor.users.findOne(@userId)\n return unless user?.profile.admin\n unless name of collections\n try\n collections[name] = new Meteor.Collection(name)\n catch e\n for key, value of root\n if name == value._name\n collections[name] = value\n console.log e", "source_lang": "", "target_lang": "CoffeeScript", "repo": "gterrono/houston", "path": "server/publications.coffee", "license": "MIT", "commit": "93e06a251afa99843d47e26f6bfde1ba3c93c47e", "stars": 802, "source_url": "https://github.com/gterrono/houston/blob/93e06a251afa99843d47e26f6bfde1ba3c93c47e/server/publications.coffee", "line_start": 44, "line_end": 93}942{"id": "gterrono/houston:server/publications.coffee:2:coffee_to_js", "type": "coffee_to_js", "prompt": "Convert this CoffeeScript to JavaScript.\n```coffeescript\ncollection.find().observe\n added: (document) ->\n Houston._collections.update {name},\n $inc: {count: 1},\n $addToSet: fields: Houston._get_field_names([document])\n removed: (document) -> Houston._collections.update {name}, {$inc: {count: -1}}\n fields = Houston._get_field_names(collection.find().fetch())\n if Houston._collections.findOne {name}\n Houston._collections.update {name}, {$set: count: collection.find().count(), fields: fields}\n else\n Houston._collections.insert {name, count: collection.find().count(), fields: fields}\n\n\n Dummy.findOne() # hack\n save_collections = (meh, collections_db) ->\n collection_names = (col.collectionName for col in collections_db \\\n when (col.collectionName.indexOf \"system.\") isnt 0 and\n (col.collectionName.indexOf \"houston_\") isnt 0)\n\n collection_names.forEach (name) ->\n unless name of collections\n try\n collections[name] = new Meteor.Collection(name)\n catch e\n for key, value of root\n if name == value._name\n collections[name] = value\n console.log e unless collections[name]?\n\n set_up_collection(name, collections[name])\n\n Meteor.methods\n _houston_make_admin: (userId) ->\n # limit one admin\n return if Meteor.users.findOne {'profile.admin': true}\n Meteor.users.update userId, $set: {'profile.admin': true}\n return True\n\n _houston_setupNewCollection: (name) ->\n return unless @userId\n user = Meteor.users.findOne(@userId)\n return unless user?.profile.admin\n unless name of collections\n try\n collections[name] = new Meteor.Collection(name)\n catch e\n for key, value of root\n if name == value._name\n collections[name] = value\n console.log e\n```", "response": "var fields, save_collections;\n\ncollection.find().observe({\n added: function(document) {\n return Houston._collections.update({name}, {\n $inc: {\n count: 1\n },\n $addToSet: {\n fields: Houston._get_field_names([document])\n }\n });\n },\n removed: function(document) {\n return Houston._collections.update({name}, {\n $inc: {\n count: -1\n }\n });\n }\n});\n\nfields = Houston._get_field_names(collection.find().fetch());\n\nif (Houston._collections.findOne({name})) {\n Houston._collections.update({name}, {\n $set: {\n count: collection.find().count(),\n fields: fields\n }\n });\n} else {\n Houston._collections.insert({\n name,\n count: collection.find().count(),\n fields: fields\n });\n}\n\nDummy.findOne(); // hack\n\nsave_collections = function(meh, collections_db) {\n var col, collection_names;\n collection_names = (function() {\n var i, len, results;\n results = [];\n for (i = 0, len = collections_db.length; i < len; i++) {\n col = collections_db[i];\n if ((col.collectionName.indexOf(\"system.\")) !== 0 && (col.collectionName.indexOf(\"houston_\")) !== 0) {\n results.push(col.collectionName);\n }\n }\n return results;\n })();\n return collection_names.forEach(function(name) {\n var e, key, value;\n if (!(name in collections)) {\n try {\n collections[name] = new Meteor.Collection(name);\n } catch (error) {\n e = error;\n for (key in root) {\n value = root[key];\n if (name === value._name) {\n collections[name] = value;\n }\n }\n if (collections[name] == null) {\n console.log(e);\n }\n }\n return set_up_collection(name, collections[name]);\n }\n });\n};\n\nMeteor.methods({\n _houston_make_admin: function(userId) {\n // limit one admin\n if (Meteor.users.findOne({\n 'profile.admin': true\n })) {\n return;\n }\n Meteor.users.update(userId, {\n $set: {\n 'profile.admin': true\n }\n });\n return True;\n },\n _houston_setupNewCollection: function(name) {\n var e, key, user, value;\n if (!this.userId) {\n return;\n }\n user = Meteor.users.findOne(this.userId);\n if (!(user != null ? user.profile.admin : void 0)) {\n return;\n }\n if (!(name in collections)) {\n try {\n return collections[name] = new Meteor.Collection(name);\n } catch (error) {\n e = error;\n for (key in root) {\n value = root[key];\n if (name === value._name) {\n collections[name] = value;\n }\n }\n return console.log(e);\n }\n }\n }\n});", "source_lang": "CoffeeScript", "target_lang": "JavaScript", "repo": "gterrono/houston", "path": "server/publications.coffee", "license": "MIT", "commit": "93e06a251afa99843d47e26f6bfde1ba3c93c47e", "stars": 802, "source_url": "https://github.com/gterrono/houston/blob/93e06a251afa99843d47e26f6bfde1ba3c93c47e/server/publications.coffee", "line_start": 44, "line_end": 93}943{"id": "gterrono/houston:server/publications.coffee:2:js_to_coffee", "type": "js_to_coffee", "prompt": "Convert this JavaScript to CoffeeScript.\n```javascript\nvar fields, save_collections;\n\ncollection.find().observe({\n added: function(document) {\n return Houston._collections.update({name}, {\n $inc: {\n count: 1\n },\n $addToSet: {\n fields: Houston._get_field_names([document])\n }\n });\n },\n removed: function(document) {\n return Houston._collections.update({name}, {\n $inc: {\n count: -1\n }\n });\n }\n});\n\nfields = Houston._get_field_names(collection.find().fetch());\n\nif (Houston._collections.findOne({name})) {\n Houston._collections.update({name}, {\n $set: {\n count: collection.find().count(),\n fields: fields\n }\n });\n} else {\n Houston._collections.insert({\n name,\n count: collection.find().count(),\n fields: fields\n });\n}\n\nDummy.findOne(); // hack\n\nsave_collections = function(meh, collections_db) {\n var col, collection_names;\n collection_names = (function() {\n var i, len, results;\n results = [];\n for (i = 0, len = collections_db.length; i < len; i++) {\n col = collections_db[i];\n if ((col.collectionName.indexOf(\"system.\")) !== 0 && (col.collectionName.indexOf(\"houston_\")) !== 0) {\n results.push(col.collectionName);\n }\n }\n return results;\n })();\n return collection_names.forEach(function(name) {\n var e, key, value;\n if (!(name in collections)) {\n try {\n collections[name] = new Meteor.Collection(name);\n } catch (error) {\n e = error;\n for (key in root) {\n value = root[key];\n if (name === value._name) {\n collections[name] = value;\n }\n }\n if (collections[name] == null) {\n console.log(e);\n }\n }\n return set_up_collection(name, collections[name]);\n }\n });\n};\n\nMeteor.methods({\n _houston_make_admin: function(userId) {\n // limit one admin\n if (Meteor.users.findOne({\n 'profile.admin': true\n })) {\n return;\n }\n Meteor.users.update(userId, {\n $set: {\n 'profile.admin': true\n }\n });\n return True;\n },\n _houston_setupNewCollection: function(name) {\n var e, key, user, value;\n if (!this.userId) {\n return;\n }\n user = Meteor.users.findOne(this.userId);\n if (!(user != null ? user.profile.admin : void 0)) {\n return;\n }\n if (!(name in collections)) {\n try {\n return collections[name] = new Meteor.Collection(name);\n } catch (error) {\n e = error;\n for (key in root) {\n value = root[key];\n if (name === value._name) {\n collections[name] = value;\n }\n }\n return console.log(e);\n }\n }\n }\n});\n```", "response": "collection.find().observe\n added: (document) ->\n Houston._collections.update {name},\n $inc: {count: 1},\n $addToSet: fields: Houston._get_field_names([document])\n removed: (document) -> Houston._collections.update {name}, {$inc: {count: -1}}\n fields = Houston._get_field_names(collection.find().fetch())\n if Houston._collections.findOne {name}\n Houston._collections.update {name}, {$set: count: collection.find().count(), fields: fields}\n else\n Houston._collections.insert {name, count: collection.find().count(), fields: fields}\n\n\n Dummy.findOne() # hack\n save_collections = (meh, collections_db) ->\n collection_names = (col.collectionName for col in collections_db \\\n when (col.collectionName.indexOf \"system.\") isnt 0 and\n (col.collectionName.indexOf \"houston_\") isnt 0)\n\n collection_names.forEach (name) ->\n unless name of collections\n try\n collections[name] = new Meteor.Collection(name)\n catch e\n for key, value of root\n if name == value._name\n collections[name] = value\n console.log e unless collections[name]?\n\n set_up_collection(name, collections[name])\n\n Meteor.methods\n _houston_make_admin: (userId) ->\n # limit one admin\n return if Meteor.users.findOne {'profile.admin': true}\n Meteor.users.update userId, $set: {'profile.admin': true}\n return True\n\n _houston_setupNewCollection: (name) ->\n return unless @userId\n user = Meteor.users.findOne(@userId)\n return unless user?.profile.admin\n unless name of collections\n try\n collections[name] = new Meteor.Collection(name)\n catch e\n for key, value of root\n if name == value._name\n collections[name] = value\n console.log e", "source_lang": "JavaScript", "target_lang": "CoffeeScript", "repo": "gterrono/houston", "path": "server/publications.coffee", "license": "MIT", "commit": "93e06a251afa99843d47e26f6bfde1ba3c93c47e", "stars": 802, "source_url": "https://github.com/gterrono/houston/blob/93e06a251afa99843d47e26f6bfde1ba3c93c47e/server/publications.coffee", "line_start": 44, "line_end": 93}944{"id": "gterrono/houston:server/publications.coffee:2:completion", "type": "completion", "prompt": "collection.find().observe\n added: (document) ->\n Houston._collections.update {name},\n $inc: {count: 1},\n $addToSet: fields: Houston._get_field_names([document])\n removed: (document) -> Houston._collections.update {name}, {$inc: {count: -1}}\n fields = Houston._get_field_names(collection.find().fetch())\n if Houston._collections.findOne {name}\n Houston._collections.update {name}, {$set: count: collection.find().count(), fields: fields}\n else\n Houston._collections.insert {name, count: collection.find().count(), fields: fields}\n\n\n Dummy.findOne() # hack\n save_collections = (meh, collections_db) ->\n collection_names = (col.collectionName for col in collections_db \\\n when (col.collectionName.indexOf \"system.\") isnt 0 and\n (col.collectionName.indexOf \"houston_\") isnt 0)\n\n collection_names.forEach (name) ->\n unless name of collections\n try\n collections[name] = new Meteor.Collection(name)\n catch e\n for key, value of root", "response": "if name == value._name\n collections[name] = value\n console.log e unless collections[name]?\n\n set_up_collection(name, collections[name])\n\n Meteor.methods\n _houston_make_admin: (userId) ->\n # limit one admin\n return if Meteor.users.findOne {'profile.admin': true}\n Meteor.users.update userId, $set: {'profile.admin': true}\n return True\n\n _houston_setupNewCollection: (name) ->\n return unless @userId\n user = Meteor.users.findOne(@userId)\n return unless user?.profile.admin\n unless name of collections\n try\n collections[name] = new Meteor.Collection(name)\n catch e\n for key, value of root\n if name == value._name\n collections[name] = value\n console.log e", "source_lang": "CoffeeScript", "target_lang": "CoffeeScript", "repo": "gterrono/houston", "path": "server/publications.coffee", "license": "MIT", "commit": "93e06a251afa99843d47e26f6bfde1ba3c93c47e", "stars": 802, "source_url": "https://github.com/gterrono/houston/blob/93e06a251afa99843d47e26f6bfde1ba3c93c47e/server/publications.coffee", "line_start": 44, "line_end": 93}945{"id": "gterrono/houston:server/publications.coffee:3:raw_corpus", "type": "raw_corpus", "prompt": "", "response": "set_up_collection(name, collections[name])\n\n fn = Meteor.bindEnvironment save_collections, (e) ->\n console.log e\n\n # MongoInternals is the 'right' solution as of 0.6.5\n mongo_driver = MongoInternals?.defaultRemoteCollectionDriver() or Meteor._RemoteCollectionDriver\n mongo_driver.mongo.db.collections fn\n\n\n# publish our own internal state\nMeteor.publish '_houston', ->\n if Meteor.users.findOne(_id: @userId, 'profile.admin': true)\n Houston._collections.find()\n\n\nMeteor.publish '_houston_adminUser', -> # used by login page to see if admin has been created yet\n Meteor.users.find({'profile.admin': true}, fields: 'profile.admin': true)", "source_lang": "", "target_lang": "CoffeeScript", "repo": "gterrono/houston", "path": "server/publications.coffee", "license": "MIT", "commit": "93e06a251afa99843d47e26f6bfde1ba3c93c47e", "stars": 802, "source_url": "https://github.com/gterrono/houston/blob/93e06a251afa99843d47e26f6bfde1ba3c93c47e/server/publications.coffee", "line_start": 95, "line_end": 112}946{"id": "gterrono/houston:server/publications.coffee:3:completion", "type": "completion", "prompt": "set_up_collection(name, collections[name])\n\n fn = Meteor.bindEnvironment save_collections, (e) ->\n console.log e\n\n # MongoInternals is the 'right' solution as of 0.6.5\n mongo_driver = MongoInternals?.defaultRemoteCollectionDriver() or Meteor._RemoteCollectionDriver\n mongo_driver.mongo.db.collections fn", "response": "# publish our own internal state\nMeteor.publish '_houston', ->\n if Meteor.users.findOne(_id: @userId, 'profile.admin': true)\n Houston._collections.find()\n\n\nMeteor.publish '_houston_adminUser', -> # used by login page to see if admin has been created yet\n Meteor.users.find({'profile.admin': true}, fields: 'profile.admin': true)", "source_lang": "CoffeeScript", "target_lang": "CoffeeScript", "repo": "gterrono/houston", "path": "server/publications.coffee", "license": "MIT", "commit": "93e06a251afa99843d47e26f6bfde1ba3c93c47e", "stars": 802, "source_url": "https://github.com/gterrono/houston/blob/93e06a251afa99843d47e26f6bfde1ba3c93c47e/server/publications.coffee", "line_start": 95, "line_end": 112}947{"id": "gterrono/houston:server/publications.coffee:2:raw_corpus", "type": "raw_corpus", "prompt": "", "response": "collection.find().observe\n added: (document) ->\n Collections.update {name},\n $inc: {count: 1},\n $addToSet: fields: get_field_names([document])\n removed: (document) -> Collections.update {name}, {$inc: {count: -1}}\n\n fields = get_field_names(collection.find().fetch())\n c = Collections.findOne {name}\n if c\n Collections.update c._id, {$set: count: collection.find().count(), fields: fields}\n else\n Collections.insert {name, count: collection.find().count(), fields: fields}\n\n Dummy.findOne() # hack\n\n save_collections = (meh, collections_db) ->\n collection_names = (col.collectionName for col in collections_db \\\n when (col.collectionName.indexOf \"system.\") isnt 0 and\n (col.collectionName.indexOf \"admin_\") isnt 0)\n\n collection_names.forEach (name) ->\n unless name of collections\n try\n collections[name] = new Meteor.Collection(name)\n catch e\n for key, value of root\n if name == value._name\n collections[name] = value\n console.log e unless collections[name]?\n\n set_up_collection(name, collections[name])\n\n Meteor.methods\n make_admin: (userId) ->\n # limit one admin\n return if Meteor.users.findOne {'profile.admin': true}\n Meteor.users.update userId, $set: {'profile.admin': true}\n return true", "source_lang": "", "target_lang": "CoffeeScript", "repo": "gterrono/houston", "path": "server/publications.coffee", "license": "MIT", "commit": "7e4aad8f9e664f8439e4b61705ba5af449be99cc", "stars": 802, "source_url": "https://github.com/gterrono/houston/blob/7e4aad8f9e664f8439e4b61705ba5af449be99cc/server/publications.coffee", "line_start": 44, "line_end": 82}948{"id": "gterrono/houston:server/publications.coffee:2:coffee_to_js", "type": "coffee_to_js", "prompt": "Convert this CoffeeScript to JavaScript.\n```coffeescript\ncollection.find().observe\n added: (document) ->\n Collections.update {name},\n $inc: {count: 1},\n $addToSet: fields: get_field_names([document])\n removed: (document) -> Collections.update {name}, {$inc: {count: -1}}\n\n fields = get_field_names(collection.find().fetch())\n c = Collections.findOne {name}\n if c\n Collections.update c._id, {$set: count: collection.find().count(), fields: fields}\n else\n Collections.insert {name, count: collection.find().count(), fields: fields}\n\n Dummy.findOne() # hack\n\n save_collections = (meh, collections_db) ->\n collection_names = (col.collectionName for col in collections_db \\\n when (col.collectionName.indexOf \"system.\") isnt 0 and\n (col.collectionName.indexOf \"admin_\") isnt 0)\n\n collection_names.forEach (name) ->\n unless name of collections\n try\n collections[name] = new Meteor.Collection(name)\n catch e\n for key, value of root\n if name == value._name\n collections[name] = value\n console.log e unless collections[name]?\n\n set_up_collection(name, collections[name])\n\n Meteor.methods\n make_admin: (userId) ->\n # limit one admin\n return if Meteor.users.findOne {'profile.admin': true}\n Meteor.users.update userId, $set: {'profile.admin': true}\n return true\n```", "response": "var c, fields, save_collections;\n\ncollection.find().observe({\n added: function(document) {\n return Collections.update({name}, {\n $inc: {\n count: 1\n },\n $addToSet: {\n fields: get_field_names([document])\n }\n });\n },\n removed: function(document) {\n return Collections.update({name}, {\n $inc: {\n count: -1\n }\n });\n }\n});\n\nfields = get_field_names(collection.find().fetch());\n\nc = Collections.findOne({name});\n\nif (c) {\n Collections.update(c._id, {\n $set: {\n count: collection.find().count(),\n fields: fields\n }\n });\n} else {\n Collections.insert({\n name,\n count: collection.find().count(),\n fields: fields\n });\n}\n\nDummy.findOne(); // hack\n\nsave_collections = function(meh, collections_db) {\n var col, collection_names;\n collection_names = (function() {\n var i, len, results;\n results = [];\n for (i = 0, len = collections_db.length; i < len; i++) {\n col = collections_db[i];\n if ((col.collectionName.indexOf(\"system.\")) !== 0 && (col.collectionName.indexOf(\"admin_\")) !== 0) {\n results.push(col.collectionName);\n }\n }\n return results;\n })();\n return collection_names.forEach(function(name) {\n var e, key, value;\n if (!(name in collections)) {\n try {\n collections[name] = new Meteor.Collection(name);\n } catch (error) {\n e = error;\n for (key in root) {\n value = root[key];\n if (name === value._name) {\n collections[name] = value;\n }\n }\n if (collections[name] == null) {\n console.log(e);\n }\n }\n return set_up_collection(name, collections[name]);\n }\n });\n};\n\nMeteor.methods({\n make_admin: function(userId) {\n // limit one admin\n if (Meteor.users.findOne({\n 'profile.admin': true\n })) {\n return;\n }\n Meteor.users.update(userId, {\n $set: {\n 'profile.admin': true\n }\n });\n return true;\n }\n});", "source_lang": "CoffeeScript", "target_lang": "JavaScript", "repo": "gterrono/houston", "path": "server/publications.coffee", "license": "MIT", "commit": "7e4aad8f9e664f8439e4b61705ba5af449be99cc", "stars": 802, "source_url": "https://github.com/gterrono/houston/blob/7e4aad8f9e664f8439e4b61705ba5af449be99cc/server/publications.coffee", "line_start": 44, "line_end": 82}949{"id": "gterrono/houston:server/publications.coffee:2:js_to_coffee", "type": "js_to_coffee", "prompt": "Convert this JavaScript to CoffeeScript.\n```javascript\nvar c, fields, save_collections;\n\ncollection.find().observe({\n added: function(document) {\n return Collections.update({name}, {\n $inc: {\n count: 1\n },\n $addToSet: {\n fields: get_field_names([document])\n }\n });\n },\n removed: function(document) {\n return Collections.update({name}, {\n $inc: {\n count: -1\n }\n });\n }\n});\n\nfields = get_field_names(collection.find().fetch());\n\nc = Collections.findOne({name});\n\nif (c) {\n Collections.update(c._id, {\n $set: {\n count: collection.find().count(),\n fields: fields\n }\n });\n} else {\n Collections.insert({\n name,\n count: collection.find().count(),\n fields: fields\n });\n}\n\nDummy.findOne(); // hack\n\nsave_collections = function(meh, collections_db) {\n var col, collection_names;\n collection_names = (function() {\n var i, len, results;\n results = [];\n for (i = 0, len = collections_db.length; i < len; i++) {\n col = collections_db[i];\n if ((col.collectionName.indexOf(\"system.\")) !== 0 && (col.collectionName.indexOf(\"admin_\")) !== 0) {\n results.push(col.collectionName);\n }\n }\n return results;\n })();\n return collection_names.forEach(function(name) {\n var e, key, value;\n if (!(name in collections)) {\n try {\n collections[name] = new Meteor.Collection(name);\n } catch (error) {\n e = error;\n for (key in root) {\n value = root[key];\n if (name === value._name) {\n collections[name] = value;\n }\n }\n if (collections[name] == null) {\n console.log(e);\n }\n }\n return set_up_collection(name, collections[name]);\n }\n });\n};\n\nMeteor.methods({\n make_admin: function(userId) {\n // limit one admin\n if (Meteor.users.findOne({\n 'profile.admin': true\n })) {\n return;\n }\n Meteor.users.update(userId, {\n $set: {\n 'profile.admin': true\n }\n });\n return true;\n }\n});\n```", "response": "collection.find().observe\n added: (document) ->\n Collections.update {name},\n $inc: {count: 1},\n $addToSet: fields: get_field_names([document])\n removed: (document) -> Collections.update {name}, {$inc: {count: -1}}\n\n fields = get_field_names(collection.find().fetch())\n c = Collections.findOne {name}\n if c\n Collections.update c._id, {$set: count: collection.find().count(), fields: fields}\n else\n Collections.insert {name, count: collection.find().count(), fields: fields}\n\n Dummy.findOne() # hack\n\n save_collections = (meh, collections_db) ->\n collection_names = (col.collectionName for col in collections_db \\\n when (col.collectionName.indexOf \"system.\") isnt 0 and\n (col.collectionName.indexOf \"admin_\") isnt 0)\n\n collection_names.forEach (name) ->\n unless name of collections\n try\n collections[name] = new Meteor.Collection(name)\n catch e\n for key, value of root\n if name == value._name\n collections[name] = value\n console.log e unless collections[name]?\n\n set_up_collection(name, collections[name])\n\n Meteor.methods\n make_admin: (userId) ->\n # limit one admin\n return if Meteor.users.findOne {'profile.admin': true}\n Meteor.users.update userId, $set: {'profile.admin': true}\n return true", "source_lang": "JavaScript", "target_lang": "CoffeeScript", "repo": "gterrono/houston", "path": "server/publications.coffee", "license": "MIT", "commit": "7e4aad8f9e664f8439e4b61705ba5af449be99cc", "stars": 802, "source_url": "https://github.com/gterrono/houston/blob/7e4aad8f9e664f8439e4b61705ba5af449be99cc/server/publications.coffee", "line_start": 44, "line_end": 82}950{"id": "gterrono/houston:server/publications.coffee:2:completion", "type": "completion", "prompt": "collection.find().observe\n added: (document) ->\n Collections.update {name},\n $inc: {count: 1},\n $addToSet: fields: get_field_names([document])\n removed: (document) -> Collections.update {name}, {$inc: {count: -1}}\n\n fields = get_field_names(collection.find().fetch())\n c = Collections.findOne {name}\n if c\n Collections.update c._id, {$set: count: collection.find().count(), fields: fields}\n else\n Collections.insert {name, count: collection.find().count(), fields: fields}\n\n Dummy.findOne() # hack\n\n save_collections = (meh, collections_db) ->\n collection_names = (col.collectionName for col in collections_db \\\n when (col.collectionName.indexOf \"system.\") isnt 0 and", "response": "(col.collectionName.indexOf \"admin_\") isnt 0)\n\n collection_names.forEach (name) ->\n unless name of collections\n try\n collections[name] = new Meteor.Collection(name)\n catch e\n for key, value of root\n if name == value._name\n collections[name] = value\n console.log e unless collections[name]?\n\n set_up_collection(name, collections[name])\n\n Meteor.methods\n make_admin: (userId) ->\n # limit one admin\n return if Meteor.users.findOne {'profile.admin': true}\n Meteor.users.update userId, $set: {'profile.admin': true}\n return true", "source_lang": "CoffeeScript", "target_lang": "CoffeeScript", "repo": "gterrono/houston", "path": "server/publications.coffee", "license": "MIT", "commit": "7e4aad8f9e664f8439e4b61705ba5af449be99cc", "stars": 802, "source_url": "https://github.com/gterrono/houston/blob/7e4aad8f9e664f8439e4b61705ba5af449be99cc/server/publications.coffee", "line_start": 44, "line_end": 82}951{"id": "gterrono/houston:server/publications.coffee:2:raw_corpus", "type": "raw_corpus", "prompt": "", "response": "collection.find().observe\n added: (document) ->\n Collections.update {name},\n $inc: {count: 1},\n $addToSet: fields: get_field_names([document])\n removed: (document) -> Collections.update {name}, {$inc: {count: -1}}\n fields = get_field_names(collection.find().fetch())\n if Collections.findOne {name}\n Collections.update {name}, {$set: count: collection.find().count(), fields: fields}\n else\n Collections.insert {name, count: collection.find().count(), fields: fields}\n\n\n Dummy.findOne() # hack\n save_collections = (meh, collections_db) ->\n collection_names = (col.collectionName for col in collections_db \\\n when (col.collectionName.indexOf \"system.\") isnt 0 and\n (col.collectionName.indexOf \"admin_\") isnt 0)\n\n collection_names.forEach (name) ->\n unless name of collections\n try\n collections[name] = new Meteor.Collection(name)\n catch e\n for key, value of root\n if name == value._name\n collections[name] = value\n console.log e unless collections[name]?\n\n set_up_collection(name, collections[name])\n\n Meteor.methods\n make_admin: (userId) ->\n # limit one admin\n return if Meteor.users.findOne {'profile.admin': true}\n Meteor.users.update userId, $set: {'profile.admin': true}\n return true\n\n setupNewCollection: (name) ->\n return unless @userId\n user = Meteor.users.findOne(@userId)\n return unless user?.profile.admin\n unless name of collections\n try\n collections[name] = new Meteor.Collection(name)\n catch e\n for key, value of root\n if name == value._name\n collections[name] = value\n console.log e", "source_lang": "", "target_lang": "CoffeeScript", "repo": "gterrono/houston", "path": "server/publications.coffee", "license": "MIT", "commit": "7cce4b29f5b59e631855fdc915e97958ec3693b7", "stars": 802, "source_url": "https://github.com/gterrono/houston/blob/7cce4b29f5b59e631855fdc915e97958ec3693b7/server/publications.coffee", "line_start": 44, "line_end": 93}952{"id": "gterrono/houston:server/publications.coffee:2:coffee_to_js", "type": "coffee_to_js", "prompt": "Convert this CoffeeScript to JavaScript.\n```coffeescript\ncollection.find().observe\n added: (document) ->\n Collections.update {name},\n $inc: {count: 1},\n $addToSet: fields: get_field_names([document])\n removed: (document) -> Collections.update {name}, {$inc: {count: -1}}\n fields = get_field_names(collection.find().fetch())\n if Collections.findOne {name}\n Collections.update {name}, {$set: count: collection.find().count(), fields: fields}\n else\n Collections.insert {name, count: collection.find().count(), fields: fields}\n\n\n Dummy.findOne() # hack\n save_collections = (meh, collections_db) ->\n collection_names = (col.collectionName for col in collections_db \\\n when (col.collectionName.indexOf \"system.\") isnt 0 and\n (col.collectionName.indexOf \"admin_\") isnt 0)\n\n collection_names.forEach (name) ->\n unless name of collections\n try\n collections[name] = new Meteor.Collection(name)\n catch e\n for key, value of root\n if name == value._name\n collections[name] = value\n console.log e unless collections[name]?\n\n set_up_collection(name, collections[name])\n\n Meteor.methods\n make_admin: (userId) ->\n # limit one admin\n return if Meteor.users.findOne {'profile.admin': true}\n Meteor.users.update userId, $set: {'profile.admin': true}\n return true\n\n setupNewCollection: (name) ->\n return unless @userId\n user = Meteor.users.findOne(@userId)\n return unless user?.profile.admin\n unless name of collections\n try\n collections[name] = new Meteor.Collection(name)\n catch e\n for key, value of root\n if name == value._name\n collections[name] = value\n console.log e\n```", "response": "var fields, save_collections;\n\ncollection.find().observe({\n added: function(document) {\n return Collections.update({name}, {\n $inc: {\n count: 1\n },\n $addToSet: {\n fields: get_field_names([document])\n }\n });\n },\n removed: function(document) {\n return Collections.update({name}, {\n $inc: {\n count: -1\n }\n });\n }\n});\n\nfields = get_field_names(collection.find().fetch());\n\nif (Collections.findOne({name})) {\n Collections.update({name}, {\n $set: {\n count: collection.find().count(),\n fields: fields\n }\n });\n} else {\n Collections.insert({\n name,\n count: collection.find().count(),\n fields: fields\n });\n}\n\nDummy.findOne(); // hack\n\nsave_collections = function(meh, collections_db) {\n var col, collection_names;\n collection_names = (function() {\n var i, len, results;\n results = [];\n for (i = 0, len = collections_db.length; i < len; i++) {\n col = collections_db[i];\n if ((col.collectionName.indexOf(\"system.\")) !== 0 && (col.collectionName.indexOf(\"admin_\")) !== 0) {\n results.push(col.collectionName);\n }\n }\n return results;\n })();\n return collection_names.forEach(function(name) {\n var e, key, value;\n if (!(name in collections)) {\n try {\n collections[name] = new Meteor.Collection(name);\n } catch (error) {\n e = error;\n for (key in root) {\n value = root[key];\n if (name === value._name) {\n collections[name] = value;\n }\n }\n if (collections[name] == null) {\n console.log(e);\n }\n }\n return set_up_collection(name, collections[name]);\n }\n });\n};\n\nMeteor.methods({\n make_admin: function(userId) {\n // limit one admin\n if (Meteor.users.findOne({\n 'profile.admin': true\n })) {\n return;\n }\n Meteor.users.update(userId, {\n $set: {\n 'profile.admin': true\n }\n });\n return true;\n },\n setupNewCollection: function(name) {\n var e, key, user, value;\n if (!this.userId) {\n return;\n }\n user = Meteor.users.findOne(this.userId);\n if (!(user != null ? user.profile.admin : void 0)) {\n return;\n }\n if (!(name in collections)) {\n try {\n return collections[name] = new Meteor.Collection(name);\n } catch (error) {\n e = error;\n for (key in root) {\n value = root[key];\n if (name === value._name) {\n collections[name] = value;\n }\n }\n return console.log(e);\n }\n }\n }\n});", "source_lang": "CoffeeScript", "target_lang": "JavaScript", "repo": "gterrono/houston", "path": "server/publications.coffee", "license": "MIT", "commit": "7cce4b29f5b59e631855fdc915e97958ec3693b7", "stars": 802, "source_url": "https://github.com/gterrono/houston/blob/7cce4b29f5b59e631855fdc915e97958ec3693b7/server/publications.coffee", "line_start": 44, "line_end": 93}953{"id": "gterrono/houston:server/publications.coffee:2:js_to_coffee", "type": "js_to_coffee", "prompt": "Convert this JavaScript to CoffeeScript.\n```javascript\nvar fields, save_collections;\n\ncollection.find().observe({\n added: function(document) {\n return Collections.update({name}, {\n $inc: {\n count: 1\n },\n $addToSet: {\n fields: get_field_names([document])\n }\n });\n },\n removed: function(document) {\n return Collections.update({name}, {\n $inc: {\n count: -1\n }\n });\n }\n});\n\nfields = get_field_names(collection.find().fetch());\n\nif (Collections.findOne({name})) {\n Collections.update({name}, {\n $set: {\n count: collection.find().count(),\n fields: fields\n }\n });\n} else {\n Collections.insert({\n name,\n count: collection.find().count(),\n fields: fields\n });\n}\n\nDummy.findOne(); // hack\n\nsave_collections = function(meh, collections_db) {\n var col, collection_names;\n collection_names = (function() {\n var i, len, results;\n results = [];\n for (i = 0, len = collections_db.length; i < len; i++) {\n col = collections_db[i];\n if ((col.collectionName.indexOf(\"system.\")) !== 0 && (col.collectionName.indexOf(\"admin_\")) !== 0) {\n results.push(col.collectionName);\n }\n }\n return results;\n })();\n return collection_names.forEach(function(name) {\n var e, key, value;\n if (!(name in collections)) {\n try {\n collections[name] = new Meteor.Collection(name);\n } catch (error) {\n e = error;\n for (key in root) {\n value = root[key];\n if (name === value._name) {\n collections[name] = value;\n }\n }\n if (collections[name] == null) {\n console.log(e);\n }\n }\n return set_up_collection(name, collections[name]);\n }\n });\n};\n\nMeteor.methods({\n make_admin: function(userId) {\n // limit one admin\n if (Meteor.users.findOne({\n 'profile.admin': true\n })) {\n return;\n }\n Meteor.users.update(userId, {\n $set: {\n 'profile.admin': true\n }\n });\n return true;\n },\n setupNewCollection: function(name) {\n var e, key, user, value;\n if (!this.userId) {\n return;\n }\n user = Meteor.users.findOne(this.userId);\n if (!(user != null ? user.profile.admin : void 0)) {\n return;\n }\n if (!(name in collections)) {\n try {\n return collections[name] = new Meteor.Collection(name);\n } catch (error) {\n e = error;\n for (key in root) {\n value = root[key];\n if (name === value._name) {\n collections[name] = value;\n }\n }\n return console.log(e);\n }\n }\n }\n});\n```", "response": "collection.find().observe\n added: (document) ->\n Collections.update {name},\n $inc: {count: 1},\n $addToSet: fields: get_field_names([document])\n removed: (document) -> Collections.update {name}, {$inc: {count: -1}}\n fields = get_field_names(collection.find().fetch())\n if Collections.findOne {name}\n Collections.update {name}, {$set: count: collection.find().count(), fields: fields}\n else\n Collections.insert {name, count: collection.find().count(), fields: fields}\n\n\n Dummy.findOne() # hack\n save_collections = (meh, collections_db) ->\n collection_names = (col.collectionName for col in collections_db \\\n when (col.collectionName.indexOf \"system.\") isnt 0 and\n (col.collectionName.indexOf \"admin_\") isnt 0)\n\n collection_names.forEach (name) ->\n unless name of collections\n try\n collections[name] = new Meteor.Collection(name)\n catch e\n for key, value of root\n if name == value._name\n collections[name] = value\n console.log e unless collections[name]?\n\n set_up_collection(name, collections[name])\n\n Meteor.methods\n make_admin: (userId) ->\n # limit one admin\n return if Meteor.users.findOne {'profile.admin': true}\n Meteor.users.update userId, $set: {'profile.admin': true}\n return true\n\n setupNewCollection: (name) ->\n return unless @userId\n user = Meteor.users.findOne(@userId)\n return unless user?.profile.admin\n unless name of collections\n try\n collections[name] = new Meteor.Collection(name)\n catch e\n for key, value of root\n if name == value._name\n collections[name] = value\n console.log e", "source_lang": "JavaScript", "target_lang": "CoffeeScript", "repo": "gterrono/houston", "path": "server/publications.coffee", "license": "MIT", "commit": "7cce4b29f5b59e631855fdc915e97958ec3693b7", "stars": 802, "source_url": "https://github.com/gterrono/houston/blob/7cce4b29f5b59e631855fdc915e97958ec3693b7/server/publications.coffee", "line_start": 44, "line_end": 93}954{"id": "gterrono/houston:server/publications.coffee:2:completion", "type": "completion", "prompt": "collection.find().observe\n added: (document) ->\n Collections.update {name},\n $inc: {count: 1},\n $addToSet: fields: get_field_names([document])\n removed: (document) -> Collections.update {name}, {$inc: {count: -1}}\n fields = get_field_names(collection.find().fetch())\n if Collections.findOne {name}\n Collections.update {name}, {$set: count: collection.find().count(), fields: fields}\n else\n Collections.insert {name, count: collection.find().count(), fields: fields}\n\n\n Dummy.findOne() # hack\n save_collections = (meh, collections_db) ->\n collection_names = (col.collectionName for col in collections_db \\\n when (col.collectionName.indexOf \"system.\") isnt 0 and\n (col.collectionName.indexOf \"admin_\") isnt 0)\n\n collection_names.forEach (name) ->\n unless name of collections\n try\n collections[name] = new Meteor.Collection(name)\n catch e\n for key, value of root", "response": "if name == value._name\n collections[name] = value\n console.log e unless collections[name]?\n\n set_up_collection(name, collections[name])\n\n Meteor.methods\n make_admin: (userId) ->\n # limit one admin\n return if Meteor.users.findOne {'profile.admin': true}\n Meteor.users.update userId, $set: {'profile.admin': true}\n return true\n\n setupNewCollection: (name) ->\n return unless @userId\n user = Meteor.users.findOne(@userId)\n return unless user?.profile.admin\n unless name of collections\n try\n collections[name] = new Meteor.Collection(name)\n catch e\n for key, value of root\n if name == value._name\n collections[name] = value\n console.log e", "source_lang": "CoffeeScript", "target_lang": "CoffeeScript", "repo": "gterrono/houston", "path": "server/publications.coffee", "license": "MIT", "commit": "7cce4b29f5b59e631855fdc915e97958ec3693b7", "stars": 802, "source_url": "https://github.com/gterrono/houston/blob/7cce4b29f5b59e631855fdc915e97958ec3693b7/server/publications.coffee", "line_start": 44, "line_end": 93}955{"id": "gterrono/houston:server/publications.coffee:3:raw_corpus", "type": "raw_corpus", "prompt": "", "response": "set_up_collection(name, collections[name])\n\n fn = Meteor.bindEnvironment save_collections, (e) ->\n console.log e\n\n # MongoInternals is the 'right' solution as of 0.6.5\n mongo_driver = MongoInternals?.defaultRemoteCollectionDriver() or Meteor._RemoteCollectionDriver\n mongo_driver.mongo.db.collections fn\n\n\n# publish our own internal state\nMeteor.publish \"admin\", ->\n if Meteor.users.findOne(_id: @userId, 'profile.admin': true)\n Collections.find()\n\n\nMeteor.publish 'adminUser', -> # used by login page to see if admin has been created yet\n Meteor.users.find({'profile.admin': true}, fields: 'profile.admin': true)", "source_lang": "", "target_lang": "CoffeeScript", "repo": "gterrono/houston", "path": "server/publications.coffee", "license": "MIT", "commit": "7cce4b29f5b59e631855fdc915e97958ec3693b7", "stars": 802, "source_url": "https://github.com/gterrono/houston/blob/7cce4b29f5b59e631855fdc915e97958ec3693b7/server/publications.coffee", "line_start": 95, "line_end": 112}956{"id": "gterrono/houston:server/publications.coffee:3:completion", "type": "completion", "prompt": "set_up_collection(name, collections[name])\n\n fn = Meteor.bindEnvironment save_collections, (e) ->\n console.log e\n\n # MongoInternals is the 'right' solution as of 0.6.5\n mongo_driver = MongoInternals?.defaultRemoteCollectionDriver() or Meteor._RemoteCollectionDriver\n mongo_driver.mongo.db.collections fn", "response": "# publish our own internal state\nMeteor.publish \"admin\", ->\n if Meteor.users.findOne(_id: @userId, 'profile.admin': true)\n Collections.find()\n\n\nMeteor.publish 'adminUser', -> # used by login page to see if admin has been created yet\n Meteor.users.find({'profile.admin': true}, fields: 'profile.admin': true)", "source_lang": "CoffeeScript", "target_lang": "CoffeeScript", "repo": "gterrono/houston", "path": "server/publications.coffee", "license": "MIT", "commit": "7cce4b29f5b59e631855fdc915e97958ec3693b7", "stars": 802, "source_url": "https://github.com/gterrono/houston/blob/7cce4b29f5b59e631855fdc915e97958ec3693b7/server/publications.coffee", "line_start": 95, "line_end": 112}957{"id": "gterrono/houston:server/publications.coffee:1:raw_corpus", "type": "raw_corpus", "prompt": "", "response": "publish_to_admin = (name, publish_func) ->\n Meteor.publish name, ->\n if Meteor.users.findOne(_id: @userId, 'profile.admin': true)\n publish_func()\n\n\n# publish our own internal state\n\npublish_to_admin \"admin\", -> Collections.find()\n\nMeteor.publish 'adminUser', -> # used by login page to see if admin has been created yet\n Meteor.users.find({'profile.admin': true}, fields: 'profile.admin': true)", "source_lang": "", "target_lang": "CoffeeScript", "repo": "gterrono/houston", "path": "server/publications.coffee", "license": "MIT", "commit": "ab83a364fe8bd756c044e8a2fd9fff260954469f", "stars": 802, "source_url": "https://github.com/gterrono/houston/blob/ab83a364fe8bd756c044e8a2fd9fff260954469f/server/publications.coffee", "line_start": 98, "line_end": 109}958{"id": "gterrono/houston:server/publications.coffee:1:coffee_to_js", "type": "coffee_to_js", "prompt": "Convert this CoffeeScript to JavaScript.\n```coffeescript\npublish_to_admin = (name, publish_func) ->\n Meteor.publish name, ->\n if Meteor.users.findOne(_id: @userId, 'profile.admin': true)\n publish_func()\n\n\n# publish our own internal state\n\npublish_to_admin \"admin\", -> Collections.find()\n\nMeteor.publish 'adminUser', -> # used by login page to see if admin has been created yet\n Meteor.users.find({'profile.admin': true}, fields: 'profile.admin': true)\n```", "response": "var publish_to_admin;\n\npublish_to_admin = function(name, publish_func) {\n return Meteor.publish(name, function() {\n if (Meteor.users.findOne({\n _id: this.userId,\n 'profile.admin': true\n })) {\n return publish_func();\n }\n });\n};\n\n// publish our own internal state\npublish_to_admin(\"admin\", function() {\n return Collections.find();\n});\n\nMeteor.publish('adminUser', function() { // used by login page to see if admin has been created yet\n return Meteor.users.find({\n 'profile.admin': true\n }, {\n fields: {\n 'profile.admin': true\n }\n });\n});", "source_lang": "CoffeeScript", "target_lang": "JavaScript", "repo": "gterrono/houston", "path": "server/publications.coffee", "license": "MIT", "commit": "ab83a364fe8bd756c044e8a2fd9fff260954469f", "stars": 802, "source_url": "https://github.com/gterrono/houston/blob/ab83a364fe8bd756c044e8a2fd9fff260954469f/server/publications.coffee", "line_start": 98, "line_end": 109}959{"id": "gterrono/houston:server/publications.coffee:1:js_to_coffee", "type": "js_to_coffee", "prompt": "Convert this JavaScript to CoffeeScript.\n```javascript\nvar publish_to_admin;\n\npublish_to_admin = function(name, publish_func) {\n return Meteor.publish(name, function() {\n if (Meteor.users.findOne({\n _id: this.userId,\n 'profile.admin': true\n })) {\n return publish_func();\n }\n });\n};\n\n// publish our own internal state\npublish_to_admin(\"admin\", function() {\n return Collections.find();\n});\n\nMeteor.publish('adminUser', function() { // used by login page to see if admin has been created yet\n return Meteor.users.find({\n 'profile.admin': true\n }, {\n fields: {\n 'profile.admin': true\n }\n });\n});\n```", "response": "publish_to_admin = (name, publish_func) ->\n Meteor.publish name, ->\n if Meteor.users.findOne(_id: @userId, 'profile.admin': true)\n publish_func()\n\n\n# publish our own internal state\n\npublish_to_admin \"admin\", -> Collections.find()\n\nMeteor.publish 'adminUser', -> # used by login page to see if admin has been created yet\n Meteor.users.find({'profile.admin': true}, fields: 'profile.admin': true)", "source_lang": "JavaScript", "target_lang": "CoffeeScript", "repo": "gterrono/houston", "path": "server/publications.coffee", "license": "MIT", "commit": "ab83a364fe8bd756c044e8a2fd9fff260954469f", "stars": 802, "source_url": "https://github.com/gterrono/houston/blob/ab83a364fe8bd756c044e8a2fd9fff260954469f/server/publications.coffee", "line_start": 98, "line_end": 109}960{"id": "gterrono/houston:server/publications.coffee:1:completion", "type": "completion", "prompt": "publish_to_admin = (name, publish_func) ->\n Meteor.publish name, ->\n if Meteor.users.findOne(_id: @userId, 'profile.admin': true)\n publish_func()", "response": "# publish our own internal state\n\npublish_to_admin \"admin\", -> Collections.find()\n\nMeteor.publish 'adminUser', -> # used by login page to see if admin has been created yet\n Meteor.users.find({'profile.admin': true}, fields: 'profile.admin': true)", "source_lang": "CoffeeScript", "target_lang": "CoffeeScript", "repo": "gterrono/houston", "path": "server/publications.coffee", "license": "MIT", "commit": "ab83a364fe8bd756c044e8a2fd9fff260954469f", "stars": 802, "source_url": "https://github.com/gterrono/houston/blob/ab83a364fe8bd756c044e8a2fd9fff260954469f/server/publications.coffee", "line_start": 98, "line_end": 109}961{"id": "gterrono/houston:server/publications.coffee:1:raw_corpus", "type": "raw_corpus", "prompt": "", "response": "root = exports ? this\n\nDummy = new Meteor.Collection(\"system.dummy\") # hack.\ncollections = {'users': Meteor.users}\n\nMeteor.startup ->\n set_up_collection = (name, collection) ->\n methods = {}\n methods[\"admin_#{name}_insert\"] = (doc) ->\n return unless @userId\n user = Meteor.users.findOne(@userId)\n return unless user?.profile.admin\n collection.insert(doc)\n\n methods[\"admin_#{name}_update\"] = (id, update_dict) ->\n return unless @userId\n user = Meteor.users.findOne(@userId)\n return unless user?.profile.admin\n if collection.findOne(id)\n collection.update(id, update_dict)\n else\n id = collection.findOne(new Meteor.Collection.ObjectID(id))\n collection.update(id, update_dict)\n\n methods[\"admin_#{name}_delete\"] = (id, update_dict) ->\n return unless @userId\n user = Meteor.users.findOne(@userId)\n return unless user?.profile.admin\n if collection.findOne(id)\n collection.remove(id)\n else\n id = collection.findOne(new Meteor.Collection.ObjectID(id))\n collection.remove(id)\n\n Meteor.methods methods\n\n Meteor.publish \"admin_#{name}\", (sort, filter, limit)->\n if Meteor.users.findOne(_id: @userId, 'profile.admin': true)\n try\n collection.find(filter, sort: sort, limit: limit)\n catch e\n console.log e", "source_lang": "", "target_lang": "CoffeeScript", "repo": "gterrono/houston", "path": "server/publications.coffee", "license": "MIT", "commit": "3100fa1dc6400b701d528c78a54050b3cc8af877", "stars": 802, "source_url": "https://github.com/gterrono/houston/blob/3100fa1dc6400b701d528c78a54050b3cc8af877/server/publications.coffee", "line_start": 1, "line_end": 42}962{"id": "gterrono/houston:server/publications.coffee:1:coffee_to_js", "type": "coffee_to_js", "prompt": "Convert this CoffeeScript to JavaScript.\n```coffeescript\nroot = exports ? this\n\nDummy = new Meteor.Collection(\"system.dummy\") # hack.\ncollections = {'users': Meteor.users}\n\nMeteor.startup ->\n set_up_collection = (name, collection) ->\n methods = {}\n methods[\"admin_#{name}_insert\"] = (doc) ->\n return unless @userId\n user = Meteor.users.findOne(@userId)\n return unless user?.profile.admin\n collection.insert(doc)\n\n methods[\"admin_#{name}_update\"] = (id, update_dict) ->\n return unless @userId\n user = Meteor.users.findOne(@userId)\n return unless user?.profile.admin\n if collection.findOne(id)\n collection.update(id, update_dict)\n else\n id = collection.findOne(new Meteor.Collection.ObjectID(id))\n collection.update(id, update_dict)\n\n methods[\"admin_#{name}_delete\"] = (id, update_dict) ->\n return unless @userId\n user = Meteor.users.findOne(@userId)\n return unless user?.profile.admin\n if collection.findOne(id)\n collection.remove(id)\n else\n id = collection.findOne(new Meteor.Collection.ObjectID(id))\n collection.remove(id)\n\n Meteor.methods methods\n\n Meteor.publish \"admin_#{name}\", (sort, filter, limit)->\n if Meteor.users.findOne(_id: @userId, 'profile.admin': true)\n try\n collection.find(filter, sort: sort, limit: limit)\n catch e\n console.log e\n```", "response": "var Dummy, collections, root;\n\nroot = typeof exports !== \"undefined\" && exports !== null ? exports : this;\n\nDummy = new Meteor.Collection(\"system.dummy\"); // hack.\n\ncollections = {\n 'users': Meteor.users\n};\n\nMeteor.startup(function() {\n var set_up_collection;\n return set_up_collection = function(name, collection) {\n var methods;\n methods = {};\n methods[`admin_${name}_insert`] = function(doc) {\n var user;\n if (!this.userId) {\n return;\n }\n user = Meteor.users.findOne(this.userId);\n if (!(user != null ? user.profile.admin : void 0)) {\n return;\n }\n return collection.insert(doc);\n };\n methods[`admin_${name}_update`] = function(id, update_dict) {\n var user;\n if (!this.userId) {\n return;\n }\n user = Meteor.users.findOne(this.userId);\n if (!(user != null ? user.profile.admin : void 0)) {\n return;\n }\n if (collection.findOne(id)) {\n return collection.update(id, update_dict);\n } else {\n id = collection.findOne(new Meteor.Collection.ObjectID(id));\n return collection.update(id, update_dict);\n }\n };\n methods[`admin_${name}_delete`] = function(id, update_dict) {\n var user;\n if (!this.userId) {\n return;\n }\n user = Meteor.users.findOne(this.userId);\n if (!(user != null ? user.profile.admin : void 0)) {\n return;\n }\n if (collection.findOne(id)) {\n return collection.remove(id);\n } else {\n id = collection.findOne(new Meteor.Collection.ObjectID(id));\n return collection.remove(id);\n }\n };\n Meteor.methods(methods);\n return Meteor.publish(`admin_${name}`, function(sort, filter, limit) {\n var e;\n if (Meteor.users.findOne({\n _id: this.userId,\n 'profile.admin': true\n })) {\n try {\n return collection.find(filter, {\n sort: sort,\n limit: limit\n });\n } catch (error) {\n e = error;\n return console.log(e);\n }\n }\n });\n };\n});", "source_lang": "CoffeeScript", "target_lang": "JavaScript", "repo": "gterrono/houston", "path": "server/publications.coffee", "license": "MIT", "commit": "3100fa1dc6400b701d528c78a54050b3cc8af877", "stars": 802, "source_url": "https://github.com/gterrono/houston/blob/3100fa1dc6400b701d528c78a54050b3cc8af877/server/publications.coffee", "line_start": 1, "line_end": 42}963{"id": "gterrono/houston:server/publications.coffee:1:js_to_coffee", "type": "js_to_coffee", "prompt": "Convert this JavaScript to CoffeeScript.\n```javascript\nvar Dummy, collections, root;\n\nroot = typeof exports !== \"undefined\" && exports !== null ? exports : this;\n\nDummy = new Meteor.Collection(\"system.dummy\"); // hack.\n\ncollections = {\n 'users': Meteor.users\n};\n\nMeteor.startup(function() {\n var set_up_collection;\n return set_up_collection = function(name, collection) {\n var methods;\n methods = {};\n methods[`admin_${name}_insert`] = function(doc) {\n var user;\n if (!this.userId) {\n return;\n }\n user = Meteor.users.findOne(this.userId);\n if (!(user != null ? user.profile.admin : void 0)) {\n return;\n }\n return collection.insert(doc);\n };\n methods[`admin_${name}_update`] = function(id, update_dict) {\n var user;\n if (!this.userId) {\n return;\n }\n user = Meteor.users.findOne(this.userId);\n if (!(user != null ? user.profile.admin : void 0)) {\n return;\n }\n if (collection.findOne(id)) {\n return collection.update(id, update_dict);\n } else {\n id = collection.findOne(new Meteor.Collection.ObjectID(id));\n return collection.update(id, update_dict);\n }\n };\n methods[`admin_${name}_delete`] = function(id, update_dict) {\n var user;\n if (!this.userId) {\n return;\n }\n user = Meteor.users.findOne(this.userId);\n if (!(user != null ? user.profile.admin : void 0)) {\n return;\n }\n if (collection.findOne(id)) {\n return collection.remove(id);\n } else {\n id = collection.findOne(new Meteor.Collection.ObjectID(id));\n return collection.remove(id);\n }\n };\n Meteor.methods(methods);\n return Meteor.publish(`admin_${name}`, function(sort, filter, limit) {\n var e;\n if (Meteor.users.findOne({\n _id: this.userId,\n 'profile.admin': true\n })) {\n try {\n return collection.find(filter, {\n sort: sort,\n limit: limit\n });\n } catch (error) {\n e = error;\n return console.log(e);\n }\n }\n });\n };\n});\n```", "response": "root = exports ? this\n\nDummy = new Meteor.Collection(\"system.dummy\") # hack.\ncollections = {'users': Meteor.users}\n\nMeteor.startup ->\n set_up_collection = (name, collection) ->\n methods = {}\n methods[\"admin_#{name}_insert\"] = (doc) ->\n return unless @userId\n user = Meteor.users.findOne(@userId)\n return unless user?.profile.admin\n collection.insert(doc)\n\n methods[\"admin_#{name}_update\"] = (id, update_dict) ->\n return unless @userId\n user = Meteor.users.findOne(@userId)\n return unless user?.profile.admin\n if collection.findOne(id)\n collection.update(id, update_dict)\n else\n id = collection.findOne(new Meteor.Collection.ObjectID(id))\n collection.update(id, update_dict)\n\n methods[\"admin_#{name}_delete\"] = (id, update_dict) ->\n return unless @userId\n user = Meteor.users.findOne(@userId)\n return unless user?.profile.admin\n if collection.findOne(id)\n collection.remove(id)\n else\n id = collection.findOne(new Meteor.Collection.ObjectID(id))\n collection.remove(id)\n\n Meteor.methods methods\n\n Meteor.publish \"admin_#{name}\", (sort, filter, limit)->\n if Meteor.users.findOne(_id: @userId, 'profile.admin': true)\n try\n collection.find(filter, sort: sort, limit: limit)\n catch e\n console.log e", "source_lang": "JavaScript", "target_lang": "CoffeeScript", "repo": "gterrono/houston", "path": "server/publications.coffee", "license": "MIT", "commit": "3100fa1dc6400b701d528c78a54050b3cc8af877", "stars": 802, "source_url": "https://github.com/gterrono/houston/blob/3100fa1dc6400b701d528c78a54050b3cc8af877/server/publications.coffee", "line_start": 1, "line_end": 42}964{"id": "gterrono/houston:server/publications.coffee:1:completion", "type": "completion", "prompt": "root = exports ? this\n\nDummy = new Meteor.Collection(\"system.dummy\") # hack.\ncollections = {'users': Meteor.users}\n\nMeteor.startup ->\n set_up_collection = (name, collection) ->\n methods = {}\n methods[\"admin_#{name}_insert\"] = (doc) ->\n return unless @userId\n user = Meteor.users.findOne(@userId)\n return unless user?.profile.admin\n collection.insert(doc)\n\n methods[\"admin_#{name}_update\"] = (id, update_dict) ->\n return unless @userId\n user = Meteor.users.findOne(@userId)\n return unless user?.profile.admin\n if collection.findOne(id)\n collection.update(id, update_dict)\n else", "response": "id = collection.findOne(new Meteor.Collection.ObjectID(id))\n collection.update(id, update_dict)\n\n methods[\"admin_#{name}_delete\"] = (id, update_dict) ->\n return unless @userId\n user = Meteor.users.findOne(@userId)\n return unless user?.profile.admin\n if collection.findOne(id)\n collection.remove(id)\n else\n id = collection.findOne(new Meteor.Collection.ObjectID(id))\n collection.remove(id)\n\n Meteor.methods methods\n\n Meteor.publish \"admin_#{name}\", (sort, filter, limit)->\n if Meteor.users.findOne(_id: @userId, 'profile.admin': true)\n try\n collection.find(filter, sort: sort, limit: limit)\n catch e\n console.log e", "source_lang": "CoffeeScript", "target_lang": "CoffeeScript", "repo": "gterrono/houston", "path": "server/publications.coffee", "license": "MIT", "commit": "3100fa1dc6400b701d528c78a54050b3cc8af877", "stars": 802, "source_url": "https://github.com/gterrono/houston/blob/3100fa1dc6400b701d528c78a54050b3cc8af877/server/publications.coffee", "line_start": 1, "line_end": 42}965{"id": "gterrono/houston:server/publications.coffee:2:raw_corpus", "type": "raw_corpus", "prompt": "", "response": "collection.find().observe\n added: (document) ->\n Collections.update {name},\n $inc: {count: 1},\n $addToSet: fields: get_field_names([document])\n removed: (document) -> Collections.update {name}, {$inc: {count: -1}}\n fields = get_field_names(collection.find().fetch())\n if Collections.findOne {name}\n Collections.update {name}, {$set: count: collection.find().count(), fields: fields}\n else\n Collections.insert {name, count: collection.find().count(), fields: fields}\n\n\n Dummy.findOne() # hack\n save_collections = (meh, collections_db) ->\n collection_names = (col.collectionName for col in collections_db \\\n when (col.collectionName.indexOf \"system.\") isnt 0 and\n (col.collectionName.indexOf \"admin_\") isnt 0)\n\n collection_names.forEach (name) ->\n unless name of collections\n try\n collections[name] = new Meteor.Collection(name)\n catch e\n for key, value of root\n if name == value._name\n collections[name] = value\n console.log e\n\n set_up_collection(name, collections[name])\n\n Meteor.methods\n make_admin: (userId) ->\n # limit one admin\n return if Meteor.users.findOne {'profile.admin': true}\n Meteor.users.update userId, $set: {'profile.admin': true}\n return True\n\n setupNewCollection: (name) ->\n return unless @userId\n user = Meteor.users.findOne(@userId)\n return unless user?.profile.admin\n unless name of collections\n try\n collections[name] = new Meteor.Collection(name)\n catch e\n for key, value of root\n if name == value._name\n collections[name] = value\n console.log e", "source_lang": "", "target_lang": "CoffeeScript", "repo": "gterrono/houston", "path": "server/publications.coffee", "license": "MIT", "commit": "3100fa1dc6400b701d528c78a54050b3cc8af877", "stars": 802, "source_url": "https://github.com/gterrono/houston/blob/3100fa1dc6400b701d528c78a54050b3cc8af877/server/publications.coffee", "line_start": 44, "line_end": 93}966{"id": "gterrono/houston:server/publications.coffee:2:coffee_to_js", "type": "coffee_to_js", "prompt": "Convert this CoffeeScript to JavaScript.\n```coffeescript\ncollection.find().observe\n added: (document) ->\n Collections.update {name},\n $inc: {count: 1},\n $addToSet: fields: get_field_names([document])\n removed: (document) -> Collections.update {name}, {$inc: {count: -1}}\n fields = get_field_names(collection.find().fetch())\n if Collections.findOne {name}\n Collections.update {name}, {$set: count: collection.find().count(), fields: fields}\n else\n Collections.insert {name, count: collection.find().count(), fields: fields}\n\n\n Dummy.findOne() # hack\n save_collections = (meh, collections_db) ->\n collection_names = (col.collectionName for col in collections_db \\\n when (col.collectionName.indexOf \"system.\") isnt 0 and\n (col.collectionName.indexOf \"admin_\") isnt 0)\n\n collection_names.forEach (name) ->\n unless name of collections\n try\n collections[name] = new Meteor.Collection(name)\n catch e\n for key, value of root\n if name == value._name\n collections[name] = value\n console.log e\n\n set_up_collection(name, collections[name])\n\n Meteor.methods\n make_admin: (userId) ->\n # limit one admin\n return if Meteor.users.findOne {'profile.admin': true}\n Meteor.users.update userId, $set: {'profile.admin': true}\n return True\n\n setupNewCollection: (name) ->\n return unless @userId\n user = Meteor.users.findOne(@userId)\n return unless user?.profile.admin\n unless name of collections\n try\n collections[name] = new Meteor.Collection(name)\n catch e\n for key, value of root\n if name == value._name\n collections[name] = value\n console.log e\n```", "response": "var fields, save_collections;\n\ncollection.find().observe({\n added: function(document) {\n return Collections.update({name}, {\n $inc: {\n count: 1\n },\n $addToSet: {\n fields: get_field_names([document])\n }\n });\n },\n removed: function(document) {\n return Collections.update({name}, {\n $inc: {\n count: -1\n }\n });\n }\n});\n\nfields = get_field_names(collection.find().fetch());\n\nif (Collections.findOne({name})) {\n Collections.update({name}, {\n $set: {\n count: collection.find().count(),\n fields: fields\n }\n });\n} else {\n Collections.insert({\n name,\n count: collection.find().count(),\n fields: fields\n });\n}\n\nDummy.findOne(); // hack\n\nsave_collections = function(meh, collections_db) {\n var col, collection_names;\n collection_names = (function() {\n var i, len, results;\n results = [];\n for (i = 0, len = collections_db.length; i < len; i++) {\n col = collections_db[i];\n if ((col.collectionName.indexOf(\"system.\")) !== 0 && (col.collectionName.indexOf(\"admin_\")) !== 0) {\n results.push(col.collectionName);\n }\n }\n return results;\n })();\n return collection_names.forEach(function(name) {\n var e, key, value;\n if (!(name in collections)) {\n try {\n collections[name] = new Meteor.Collection(name);\n } catch (error) {\n e = error;\n for (key in root) {\n value = root[key];\n if (name === value._name) {\n collections[name] = value;\n }\n }\n console.log(e);\n }\n return set_up_collection(name, collections[name]);\n }\n });\n};\n\nMeteor.methods({\n make_admin: function(userId) {\n // limit one admin\n if (Meteor.users.findOne({\n 'profile.admin': true\n })) {\n return;\n }\n Meteor.users.update(userId, {\n $set: {\n 'profile.admin': true\n }\n });\n return True;\n },\n setupNewCollection: function(name) {\n var e, key, user, value;\n if (!this.userId) {\n return;\n }\n user = Meteor.users.findOne(this.userId);\n if (!(user != null ? user.profile.admin : void 0)) {\n return;\n }\n if (!(name in collections)) {\n try {\n return collections[name] = new Meteor.Collection(name);\n } catch (error) {\n e = error;\n for (key in root) {\n value = root[key];\n if (name === value._name) {\n collections[name] = value;\n }\n }\n return console.log(e);\n }\n }\n }\n});", "source_lang": "CoffeeScript", "target_lang": "JavaScript", "repo": "gterrono/houston", "path": "server/publications.coffee", "license": "MIT", "commit": "3100fa1dc6400b701d528c78a54050b3cc8af877", "stars": 802, "source_url": "https://github.com/gterrono/houston/blob/3100fa1dc6400b701d528c78a54050b3cc8af877/server/publications.coffee", "line_start": 44, "line_end": 93}967{"id": "gterrono/houston:server/publications.coffee:2:js_to_coffee", "type": "js_to_coffee", "prompt": "Convert this JavaScript to CoffeeScript.\n```javascript\nvar fields, save_collections;\n\ncollection.find().observe({\n added: function(document) {\n return Collections.update({name}, {\n $inc: {\n count: 1\n },\n $addToSet: {\n fields: get_field_names([document])\n }\n });\n },\n removed: function(document) {\n return Collections.update({name}, {\n $inc: {\n count: -1\n }\n });\n }\n});\n\nfields = get_field_names(collection.find().fetch());\n\nif (Collections.findOne({name})) {\n Collections.update({name}, {\n $set: {\n count: collection.find().count(),\n fields: fields\n }\n });\n} else {\n Collections.insert({\n name,\n count: collection.find().count(),\n fields: fields\n });\n}\n\nDummy.findOne(); // hack\n\nsave_collections = function(meh, collections_db) {\n var col, collection_names;\n collection_names = (function() {\n var i, len, results;\n results = [];\n for (i = 0, len = collections_db.length; i < len; i++) {\n col = collections_db[i];\n if ((col.collectionName.indexOf(\"system.\")) !== 0 && (col.collectionName.indexOf(\"admin_\")) !== 0) {\n results.push(col.collectionName);\n }\n }\n return results;\n })();\n return collection_names.forEach(function(name) {\n var e, key, value;\n if (!(name in collections)) {\n try {\n collections[name] = new Meteor.Collection(name);\n } catch (error) {\n e = error;\n for (key in root) {\n value = root[key];\n if (name === value._name) {\n collections[name] = value;\n }\n }\n console.log(e);\n }\n return set_up_collection(name, collections[name]);\n }\n });\n};\n\nMeteor.methods({\n make_admin: function(userId) {\n // limit one admin\n if (Meteor.users.findOne({\n 'profile.admin': true\n })) {\n return;\n }\n Meteor.users.update(userId, {\n $set: {\n 'profile.admin': true\n }\n });\n return True;\n },\n setupNewCollection: function(name) {\n var e, key, user, value;\n if (!this.userId) {\n return;\n }\n user = Meteor.users.findOne(this.userId);\n if (!(user != null ? user.profile.admin : void 0)) {\n return;\n }\n if (!(name in collections)) {\n try {\n return collections[name] = new Meteor.Collection(name);\n } catch (error) {\n e = error;\n for (key in root) {\n value = root[key];\n if (name === value._name) {\n collections[name] = value;\n }\n }\n return console.log(e);\n }\n }\n }\n});\n```", "response": "collection.find().observe\n added: (document) ->\n Collections.update {name},\n $inc: {count: 1},\n $addToSet: fields: get_field_names([document])\n removed: (document) -> Collections.update {name}, {$inc: {count: -1}}\n fields = get_field_names(collection.find().fetch())\n if Collections.findOne {name}\n Collections.update {name}, {$set: count: collection.find().count(), fields: fields}\n else\n Collections.insert {name, count: collection.find().count(), fields: fields}\n\n\n Dummy.findOne() # hack\n save_collections = (meh, collections_db) ->\n collection_names = (col.collectionName for col in collections_db \\\n when (col.collectionName.indexOf \"system.\") isnt 0 and\n (col.collectionName.indexOf \"admin_\") isnt 0)\n\n collection_names.forEach (name) ->\n unless name of collections\n try\n collections[name] = new Meteor.Collection(name)\n catch e\n for key, value of root\n if name == value._name\n collections[name] = value\n console.log e\n\n set_up_collection(name, collections[name])\n\n Meteor.methods\n make_admin: (userId) ->\n # limit one admin\n return if Meteor.users.findOne {'profile.admin': true}\n Meteor.users.update userId, $set: {'profile.admin': true}\n return True\n\n setupNewCollection: (name) ->\n return unless @userId\n user = Meteor.users.findOne(@userId)\n return unless user?.profile.admin\n unless name of collections\n try\n collections[name] = new Meteor.Collection(name)\n catch e\n for key, value of root\n if name == value._name\n collections[name] = value\n console.log e", "source_lang": "JavaScript", "target_lang": "CoffeeScript", "repo": "gterrono/houston", "path": "server/publications.coffee", "license": "MIT", "commit": "3100fa1dc6400b701d528c78a54050b3cc8af877", "stars": 802, "source_url": "https://github.com/gterrono/houston/blob/3100fa1dc6400b701d528c78a54050b3cc8af877/server/publications.coffee", "line_start": 44, "line_end": 93}968{"id": "gterrono/houston:server/publications.coffee:2:completion", "type": "completion", "prompt": "collection.find().observe\n added: (document) ->\n Collections.update {name},\n $inc: {count: 1},\n $addToSet: fields: get_field_names([document])\n removed: (document) -> Collections.update {name}, {$inc: {count: -1}}\n fields = get_field_names(collection.find().fetch())\n if Collections.findOne {name}\n Collections.update {name}, {$set: count: collection.find().count(), fields: fields}\n else\n Collections.insert {name, count: collection.find().count(), fields: fields}\n\n\n Dummy.findOne() # hack\n save_collections = (meh, collections_db) ->\n collection_names = (col.collectionName for col in collections_db \\\n when (col.collectionName.indexOf \"system.\") isnt 0 and\n (col.collectionName.indexOf \"admin_\") isnt 0)\n\n collection_names.forEach (name) ->\n unless name of collections\n try\n collections[name] = new Meteor.Collection(name)\n catch e\n for key, value of root", "response": "if name == value._name\n collections[name] = value\n console.log e\n\n set_up_collection(name, collections[name])\n\n Meteor.methods\n make_admin: (userId) ->\n # limit one admin\n return if Meteor.users.findOne {'profile.admin': true}\n Meteor.users.update userId, $set: {'profile.admin': true}\n return True\n\n setupNewCollection: (name) ->\n return unless @userId\n user = Meteor.users.findOne(@userId)\n return unless user?.profile.admin\n unless name of collections\n try\n collections[name] = new Meteor.Collection(name)\n catch e\n for key, value of root\n if name == value._name\n collections[name] = value\n console.log e", "source_lang": "CoffeeScript", "target_lang": "CoffeeScript", "repo": "gterrono/houston", "path": "server/publications.coffee", "license": "MIT", "commit": "3100fa1dc6400b701d528c78a54050b3cc8af877", "stars": 802, "source_url": "https://github.com/gterrono/houston/blob/3100fa1dc6400b701d528c78a54050b3cc8af877/server/publications.coffee", "line_start": 44, "line_end": 93}969{"id": "gterrono/houston:server/publications.coffee:2:raw_corpus", "type": "raw_corpus", "prompt": "", "response": "collection.find().observe\n added: (document) -> Collections.update {name}, {$inc: {count: 1}}\n removed: (document) -> Collections.update {name}, {$inc: {count: -1}}\n if Collections.findOne {name}\n Collections.update {name}, {$set: count: collection.find().count()}\n else\n Collections.insert {name, count: collection.find().count()}\n\n\n Dummy.findOne() # hack\n save_collections = (meh, collections_db) ->\n collection_names = (col.collectionName for col in collections_db \\\n when (col.collectionName.indexOf \"system.\") isnt 0 and\n (col.collectionName.indexOf \"admin_\") isnt 0)\n\n collection_names.forEach (name) ->\n unless name of collections\n try\n collections[name] = new Meteor.Collection(name)\n catch e\n for key, value of root\n if name == value._name\n collections[name] = value\n console.log e\n\n set_up_collection(name, collections[name])\n\n Meteor.methods\n make_admin: (userId) ->\n # limit one admin\n return if Meteor.users.findOne {'profile.admin': true}\n Meteor.users.update userId, $set: {'profile.admin': true}\n return True\n\n setupNewCollection: (name) ->\n return unless @userId\n user = Meteor.users.findOne(@userId)\n return unless user?.profile.admin\n unless name of collections\n try\n collections[name] = new Meteor.Collection(name)\n catch e\n for key, value of root\n if name == value._name\n collections[name] = value\n console.log e", "source_lang": "", "target_lang": "CoffeeScript", "repo": "gterrono/houston", "path": "server/publications.coffee", "license": "MIT", "commit": "a962936d195a609ad2cc573291390e4dda53929b", "stars": 802, "source_url": "https://github.com/gterrono/houston/blob/a962936d195a609ad2cc573291390e4dda53929b/server/publications.coffee", "line_start": 44, "line_end": 89}970{"id": "gterrono/houston:server/publications.coffee:2:coffee_to_js", "type": "coffee_to_js", "prompt": "Convert this CoffeeScript to JavaScript.\n```coffeescript\ncollection.find().observe\n added: (document) -> Collections.update {name}, {$inc: {count: 1}}\n removed: (document) -> Collections.update {name}, {$inc: {count: -1}}\n if Collections.findOne {name}\n Collections.update {name}, {$set: count: collection.find().count()}\n else\n Collections.insert {name, count: collection.find().count()}\n\n\n Dummy.findOne() # hack\n save_collections = (meh, collections_db) ->\n collection_names = (col.collectionName for col in collections_db \\\n when (col.collectionName.indexOf \"system.\") isnt 0 and\n (col.collectionName.indexOf \"admin_\") isnt 0)\n\n collection_names.forEach (name) ->\n unless name of collections\n try\n collections[name] = new Meteor.Collection(name)\n catch e\n for key, value of root\n if name == value._name\n collections[name] = value\n console.log e\n\n set_up_collection(name, collections[name])\n\n Meteor.methods\n make_admin: (userId) ->\n # limit one admin\n return if Meteor.users.findOne {'profile.admin': true}\n Meteor.users.update userId, $set: {'profile.admin': true}\n return True\n\n setupNewCollection: (name) ->\n return unless @userId\n user = Meteor.users.findOne(@userId)\n return unless user?.profile.admin\n unless name of collections\n try\n collections[name] = new Meteor.Collection(name)\n catch e\n for key, value of root\n if name == value._name\n collections[name] = value\n console.log e\n```", "response": "var save_collections;\n\ncollection.find().observe({\n added: function(document) {\n return Collections.update({name}, {\n $inc: {\n count: 1\n }\n });\n },\n removed: function(document) {\n return Collections.update({name}, {\n $inc: {\n count: -1\n }\n });\n }\n});\n\nif (Collections.findOne({name})) {\n Collections.update({name}, {\n $set: {\n count: collection.find().count()\n }\n });\n} else {\n Collections.insert({\n name,\n count: collection.find().count()\n });\n}\n\nDummy.findOne(); // hack\n\nsave_collections = function(meh, collections_db) {\n var col, collection_names;\n collection_names = (function() {\n var i, len, results;\n results = [];\n for (i = 0, len = collections_db.length; i < len; i++) {\n col = collections_db[i];\n if ((col.collectionName.indexOf(\"system.\")) !== 0 && (col.collectionName.indexOf(\"admin_\")) !== 0) {\n results.push(col.collectionName);\n }\n }\n return results;\n })();\n return collection_names.forEach(function(name) {\n var e, key, value;\n if (!(name in collections)) {\n try {\n collections[name] = new Meteor.Collection(name);\n } catch (error) {\n e = error;\n for (key in root) {\n value = root[key];\n if (name === value._name) {\n collections[name] = value;\n }\n }\n console.log(e);\n }\n return set_up_collection(name, collections[name]);\n }\n });\n};\n\nMeteor.methods({\n make_admin: function(userId) {\n // limit one admin\n if (Meteor.users.findOne({\n 'profile.admin': true\n })) {\n return;\n }\n Meteor.users.update(userId, {\n $set: {\n 'profile.admin': true\n }\n });\n return True;\n },\n setupNewCollection: function(name) {\n var e, key, user, value;\n if (!this.userId) {\n return;\n }\n user = Meteor.users.findOne(this.userId);\n if (!(user != null ? user.profile.admin : void 0)) {\n return;\n }\n if (!(name in collections)) {\n try {\n return collections[name] = new Meteor.Collection(name);\n } catch (error) {\n e = error;\n for (key in root) {\n value = root[key];\n if (name === value._name) {\n collections[name] = value;\n }\n }\n return console.log(e);\n }\n }\n }\n});", "source_lang": "CoffeeScript", "target_lang": "JavaScript", "repo": "gterrono/houston", "path": "server/publications.coffee", "license": "MIT", "commit": "a962936d195a609ad2cc573291390e4dda53929b", "stars": 802, "source_url": "https://github.com/gterrono/houston/blob/a962936d195a609ad2cc573291390e4dda53929b/server/publications.coffee", "line_start": 44, "line_end": 89}971{"id": "gterrono/houston:server/publications.coffee:2:js_to_coffee", "type": "js_to_coffee", "prompt": "Convert this JavaScript to CoffeeScript.\n```javascript\nvar save_collections;\n\ncollection.find().observe({\n added: function(document) {\n return Collections.update({name}, {\n $inc: {\n count: 1\n }\n });\n },\n removed: function(document) {\n return Collections.update({name}, {\n $inc: {\n count: -1\n }\n });\n }\n});\n\nif (Collections.findOne({name})) {\n Collections.update({name}, {\n $set: {\n count: collection.find().count()\n }\n });\n} else {\n Collections.insert({\n name,\n count: collection.find().count()\n });\n}\n\nDummy.findOne(); // hack\n\nsave_collections = function(meh, collections_db) {\n var col, collection_names;\n collection_names = (function() {\n var i, len, results;\n results = [];\n for (i = 0, len = collections_db.length; i < len; i++) {\n col = collections_db[i];\n if ((col.collectionName.indexOf(\"system.\")) !== 0 && (col.collectionName.indexOf(\"admin_\")) !== 0) {\n results.push(col.collectionName);\n }\n }\n return results;\n })();\n return collection_names.forEach(function(name) {\n var e, key, value;\n if (!(name in collections)) {\n try {\n collections[name] = new Meteor.Collection(name);\n } catch (error) {\n e = error;\n for (key in root) {\n value = root[key];\n if (name === value._name) {\n collections[name] = value;\n }\n }\n console.log(e);\n }\n return set_up_collection(name, collections[name]);\n }\n });\n};\n\nMeteor.methods({\n make_admin: function(userId) {\n // limit one admin\n if (Meteor.users.findOne({\n 'profile.admin': true\n })) {\n return;\n }\n Meteor.users.update(userId, {\n $set: {\n 'profile.admin': true\n }\n });\n return True;\n },\n setupNewCollection: function(name) {\n var e, key, user, value;\n if (!this.userId) {\n return;\n }\n user = Meteor.users.findOne(this.userId);\n if (!(user != null ? user.profile.admin : void 0)) {\n return;\n }\n if (!(name in collections)) {\n try {\n return collections[name] = new Meteor.Collection(name);\n } catch (error) {\n e = error;\n for (key in root) {\n value = root[key];\n if (name === value._name) {\n collections[name] = value;\n }\n }\n return console.log(e);\n }\n }\n }\n});\n```", "response": "collection.find().observe\n added: (document) -> Collections.update {name}, {$inc: {count: 1}}\n removed: (document) -> Collections.update {name}, {$inc: {count: -1}}\n if Collections.findOne {name}\n Collections.update {name}, {$set: count: collection.find().count()}\n else\n Collections.insert {name, count: collection.find().count()}\n\n\n Dummy.findOne() # hack\n save_collections = (meh, collections_db) ->\n collection_names = (col.collectionName for col in collections_db \\\n when (col.collectionName.indexOf \"system.\") isnt 0 and\n (col.collectionName.indexOf \"admin_\") isnt 0)\n\n collection_names.forEach (name) ->\n unless name of collections\n try\n collections[name] = new Meteor.Collection(name)\n catch e\n for key, value of root\n if name == value._name\n collections[name] = value\n console.log e\n\n set_up_collection(name, collections[name])\n\n Meteor.methods\n make_admin: (userId) ->\n # limit one admin\n return if Meteor.users.findOne {'profile.admin': true}\n Meteor.users.update userId, $set: {'profile.admin': true}\n return True\n\n setupNewCollection: (name) ->\n return unless @userId\n user = Meteor.users.findOne(@userId)\n return unless user?.profile.admin\n unless name of collections\n try\n collections[name] = new Meteor.Collection(name)\n catch e\n for key, value of root\n if name == value._name\n collections[name] = value\n console.log e", "source_lang": "JavaScript", "target_lang": "CoffeeScript", "repo": "gterrono/houston", "path": "server/publications.coffee", "license": "MIT", "commit": "a962936d195a609ad2cc573291390e4dda53929b", "stars": 802, "source_url": "https://github.com/gterrono/houston/blob/a962936d195a609ad2cc573291390e4dda53929b/server/publications.coffee", "line_start": 44, "line_end": 89}972{"id": "gterrono/houston:server/publications.coffee:2:completion", "type": "completion", "prompt": "collection.find().observe\n added: (document) -> Collections.update {name}, {$inc: {count: 1}}\n removed: (document) -> Collections.update {name}, {$inc: {count: -1}}\n if Collections.findOne {name}\n Collections.update {name}, {$set: count: collection.find().count()}\n else\n Collections.insert {name, count: collection.find().count()}\n\n\n Dummy.findOne() # hack\n save_collections = (meh, collections_db) ->\n collection_names = (col.collectionName for col in collections_db \\\n when (col.collectionName.indexOf \"system.\") isnt 0 and\n (col.collectionName.indexOf \"admin_\") isnt 0)\n\n collection_names.forEach (name) ->\n unless name of collections\n try\n collections[name] = new Meteor.Collection(name)\n catch e\n for key, value of root\n if name == value._name\n collections[name] = value", "response": "console.log e\n\n set_up_collection(name, collections[name])\n\n Meteor.methods\n make_admin: (userId) ->\n # limit one admin\n return if Meteor.users.findOne {'profile.admin': true}\n Meteor.users.update userId, $set: {'profile.admin': true}\n return True\n\n setupNewCollection: (name) ->\n return unless @userId\n user = Meteor.users.findOne(@userId)\n return unless user?.profile.admin\n unless name of collections\n try\n collections[name] = new Meteor.Collection(name)\n catch e\n for key, value of root\n if name == value._name\n collections[name] = value\n console.log e", "source_lang": "CoffeeScript", "target_lang": "CoffeeScript", "repo": "gterrono/houston", "path": "server/publications.coffee", "license": "MIT", "commit": "a962936d195a609ad2cc573291390e4dda53929b", "stars": 802, "source_url": "https://github.com/gterrono/houston/blob/a962936d195a609ad2cc573291390e4dda53929b/server/publications.coffee", "line_start": 44, "line_end": 89}973{"id": "gterrono/houston:server/publications.coffee:1:raw_corpus", "type": "raw_corpus", "prompt": "", "response": "publish_to_admin_with_pagination = (name, publish_func) ->\n Meteor.publish name, ->\n if Meteor.users.findOne(_id: @userId, 'profile.admin': true)\n publish_func()\n\n\n# publish our own internal state\nMeteor.publish \"admin\", ->\n if Meteor.users.findOne(_id: @userId, 'profile.admin': true)\n Collections.find()\n\n\nMeteor.publish 'adminUser', -> # used by login page to see if admin has been created yet\n Meteor.users.find({'profile.admin': true}, fields: 'profile.admin': true)", "source_lang": "", "target_lang": "CoffeeScript", "repo": "gterrono/houston", "path": "server/publications.coffee", "license": "MIT", "commit": "eb1016772c4e7ce8bb8698aad6c7d891e869155c", "stars": 802, "source_url": "https://github.com/gterrono/houston/blob/eb1016772c4e7ce8bb8698aad6c7d891e869155c/server/publications.coffee", "line_start": 100, "line_end": 113}974{"id": "gterrono/houston:server/publications.coffee:1:coffee_to_js", "type": "coffee_to_js", "prompt": "Convert this CoffeeScript to JavaScript.\n```coffeescript\npublish_to_admin_with_pagination = (name, publish_func) ->\n Meteor.publish name, ->\n if Meteor.users.findOne(_id: @userId, 'profile.admin': true)\n publish_func()\n\n\n# publish our own internal state\nMeteor.publish \"admin\", ->\n if Meteor.users.findOne(_id: @userId, 'profile.admin': true)\n Collections.find()\n\n\nMeteor.publish 'adminUser', -> # used by login page to see if admin has been created yet\n Meteor.users.find({'profile.admin': true}, fields: 'profile.admin': true)\n```", "response": "var publish_to_admin_with_pagination;\n\npublish_to_admin_with_pagination = function(name, publish_func) {\n return Meteor.publish(name, function() {\n if (Meteor.users.findOne({\n _id: this.userId,\n 'profile.admin': true\n })) {\n return publish_func();\n }\n });\n};\n\n// publish our own internal state\nMeteor.publish(\"admin\", function() {\n if (Meteor.users.findOne({\n _id: this.userId,\n 'profile.admin': true\n })) {\n return Collections.find();\n }\n});\n\nMeteor.publish('adminUser', function() { // used by login page to see if admin has been created yet\n return Meteor.users.find({\n 'profile.admin': true\n }, {\n fields: {\n 'profile.admin': true\n }\n });\n});", "source_lang": "CoffeeScript", "target_lang": "JavaScript", "repo": "gterrono/houston", "path": "server/publications.coffee", "license": "MIT", "commit": "eb1016772c4e7ce8bb8698aad6c7d891e869155c", "stars": 802, "source_url": "https://github.com/gterrono/houston/blob/eb1016772c4e7ce8bb8698aad6c7d891e869155c/server/publications.coffee", "line_start": 100, "line_end": 113}975{"id": "gterrono/houston:server/publications.coffee:1:js_to_coffee", "type": "js_to_coffee", "prompt": "Convert this JavaScript to CoffeeScript.\n```javascript\nvar publish_to_admin_with_pagination;\n\npublish_to_admin_with_pagination = function(name, publish_func) {\n return Meteor.publish(name, function() {\n if (Meteor.users.findOne({\n _id: this.userId,\n 'profile.admin': true\n })) {\n return publish_func();\n }\n });\n};\n\n// publish our own internal state\nMeteor.publish(\"admin\", function() {\n if (Meteor.users.findOne({\n _id: this.userId,\n 'profile.admin': true\n })) {\n return Collections.find();\n }\n});\n\nMeteor.publish('adminUser', function() { // used by login page to see if admin has been created yet\n return Meteor.users.find({\n 'profile.admin': true\n }, {\n fields: {\n 'profile.admin': true\n }\n });\n});\n```", "response": "publish_to_admin_with_pagination = (name, publish_func) ->\n Meteor.publish name, ->\n if Meteor.users.findOne(_id: @userId, 'profile.admin': true)\n publish_func()\n\n\n# publish our own internal state\nMeteor.publish \"admin\", ->\n if Meteor.users.findOne(_id: @userId, 'profile.admin': true)\n Collections.find()\n\n\nMeteor.publish 'adminUser', -> # used by login page to see if admin has been created yet\n Meteor.users.find({'profile.admin': true}, fields: 'profile.admin': true)", "source_lang": "JavaScript", "target_lang": "CoffeeScript", "repo": "gterrono/houston", "path": "server/publications.coffee", "license": "MIT", "commit": "eb1016772c4e7ce8bb8698aad6c7d891e869155c", "stars": 802, "source_url": "https://github.com/gterrono/houston/blob/eb1016772c4e7ce8bb8698aad6c7d891e869155c/server/publications.coffee", "line_start": 100, "line_end": 113}976{"id": "gterrono/houston:server/publications.coffee:1:completion", "type": "completion", "prompt": "publish_to_admin_with_pagination = (name, publish_func) ->\n Meteor.publish name, ->\n if Meteor.users.findOne(_id: @userId, 'profile.admin': true)\n publish_func()\n\n\n# publish our own internal state", "response": "Meteor.publish \"admin\", ->\n if Meteor.users.findOne(_id: @userId, 'profile.admin': true)\n Collections.find()\n\n\nMeteor.publish 'adminUser', -> # used by login page to see if admin has been created yet\n Meteor.users.find({'profile.admin': true}, fields: 'profile.admin': true)", "source_lang": "CoffeeScript", "target_lang": "CoffeeScript", "repo": "gterrono/houston", "path": "server/publications.coffee", "license": "MIT", "commit": "eb1016772c4e7ce8bb8698aad6c7d891e869155c", "stars": 802, "source_url": "https://github.com/gterrono/houston/blob/eb1016772c4e7ce8bb8698aad6c7d891e869155c/server/publications.coffee", "line_start": 100, "line_end": 113}977{"id": "octoblu/meshblu:integration/rest-spec.coffee:1:raw_corpus", "type": "raw_corpus", "prompt": "", "response": "_ = require 'lodash'\npath = require 'path'\nurl = require 'url'\nMeshbluHTTP = require 'meshblu-http'\nMeshbluConfig = require 'meshblu-config'\nmeshblu = require 'meshblu'\nrequest = require 'request'\n\ndescribe 'REST', ->\n before (done) ->\n filename = path.join __dirname, 'meshblu.json'\n @config = new MeshbluConfig(filename: filename).toJSON()\n @meshblu = new MeshbluHTTP @config\n @conx = meshblu.createConnection\n server : @config.server\n port : @config.port\n uuid : @config.uuid\n token : @config.token\n\n @conx.on 'ready', => done()\n @conx.on 'notReady', done\n\n it 'should get here', ->\n expect(true).to.be.true\n\n describe 'GET /devices', ->\n describe 'when called with a valid request', ->\n beforeEach (done) ->\n @meshblu.devices {}, =>\n @conx.once 'message', (@message) =>\n done()\n\n it 'should send a \"devices\" message', ->\n expect(@message.topic).to.deep.equal 'devices'\n expect(@message.payload).to.deep.equal {\n fromUuid: \"66b2928b-a317-4bc3-893e-245946e9672a\"\n request: {}\n }\n\n describe 'when called with an invalid request', ->\n beforeEach (done) ->\n @meshblu.devices {uuid: 'invalid-uuid'}, =>\n @conx.once 'message', (@message) =>\n done()", "source_lang": "", "target_lang": "CoffeeScript", "repo": "octoblu/meshblu", "path": "integration/rest-spec.coffee", "license": "MIT", "commit": "72718bfe5bfbea9f47c53308cea7bc61c52931d7", "stars": 815, "source_url": "https://github.com/octoblu/meshblu/blob/72718bfe5bfbea9f47c53308cea7bc61c52931d7/integration/rest-spec.coffee", "line_start": 1, "line_end": 44}978{"id": "octoblu/meshblu:integration/rest-spec.coffee:1:coffee_to_js", "type": "coffee_to_js", "prompt": "Convert this CoffeeScript to JavaScript.\n```coffeescript\n_ = require 'lodash'\npath = require 'path'\nurl = require 'url'\nMeshbluHTTP = require 'meshblu-http'\nMeshbluConfig = require 'meshblu-config'\nmeshblu = require 'meshblu'\nrequest = require 'request'\n\ndescribe 'REST', ->\n before (done) ->\n filename = path.join __dirname, 'meshblu.json'\n @config = new MeshbluConfig(filename: filename).toJSON()\n @meshblu = new MeshbluHTTP @config\n @conx = meshblu.createConnection\n server : @config.server\n port : @config.port\n uuid : @config.uuid\n token : @config.token\n\n @conx.on 'ready', => done()\n @conx.on 'notReady', done\n\n it 'should get here', ->\n expect(true).to.be.true\n\n describe 'GET /devices', ->\n describe 'when called with a valid request', ->\n beforeEach (done) ->\n @meshblu.devices {}, =>\n @conx.once 'message', (@message) =>\n done()\n\n it 'should send a \"devices\" message', ->\n expect(@message.topic).to.deep.equal 'devices'\n expect(@message.payload).to.deep.equal {\n fromUuid: \"66b2928b-a317-4bc3-893e-245946e9672a\"\n request: {}\n }\n\n describe 'when called with an invalid request', ->\n beforeEach (done) ->\n @meshblu.devices {uuid: 'invalid-uuid'}, =>\n @conx.once 'message', (@message) =>\n done()\n```", "response": "var MeshbluConfig, MeshbluHTTP, _, meshblu, path, request, url;\n\n_ = require('lodash');\n\npath = require('path');\n\nurl = require('url');\n\nMeshbluHTTP = require('meshblu-http');\n\nMeshbluConfig = require('meshblu-config');\n\nmeshblu = require('meshblu');\n\nrequest = require('request');\n\ndescribe('REST', function() {\n before(function(done) {\n var filename;\n filename = path.join(__dirname, 'meshblu.json');\n this.config = new MeshbluConfig({\n filename: filename\n }).toJSON();\n this.meshblu = new MeshbluHTTP(this.config);\n this.conx = meshblu.createConnection({\n server: this.config.server,\n port: this.config.port,\n uuid: this.config.uuid,\n token: this.config.token\n });\n this.conx.on('ready', () => {\n return done();\n });\n return this.conx.on('notReady', done);\n });\n it('should get here', function() {\n return expect(true).to.be.true;\n });\n return describe('GET /devices', function() {\n describe('when called with a valid request', function() {\n beforeEach(function(done) {\n return this.meshblu.devices({}, () => {\n return this.conx.once('message', (message) => {\n this.message = message;\n return done();\n });\n });\n });\n return it('should send a \"devices\" message', function() {\n expect(this.message.topic).to.deep.equal('devices');\n return expect(this.message.payload).to.deep.equal({\n fromUuid: \"66b2928b-a317-4bc3-893e-245946e9672a\",\n request: {}\n });\n });\n });\n return describe('when called with an invalid request', function() {\n return beforeEach(function(done) {\n return this.meshblu.devices({\n uuid: 'invalid-uuid'\n }, () => {\n return this.conx.once('message', (message) => {\n this.message = message;\n return done();\n });\n });\n });\n });\n });\n});", "source_lang": "CoffeeScript", "target_lang": "JavaScript", "repo": "octoblu/meshblu", "path": "integration/rest-spec.coffee", "license": "MIT", "commit": "72718bfe5bfbea9f47c53308cea7bc61c52931d7", "stars": 815, "source_url": "https://github.com/octoblu/meshblu/blob/72718bfe5bfbea9f47c53308cea7bc61c52931d7/integration/rest-spec.coffee", "line_start": 1, "line_end": 44}979{"id": "octoblu/meshblu:integration/rest-spec.coffee:1:js_to_coffee", "type": "js_to_coffee", "prompt": "Convert this JavaScript to CoffeeScript.\n```javascript\nvar MeshbluConfig, MeshbluHTTP, _, meshblu, path, request, url;\n\n_ = require('lodash');\n\npath = require('path');\n\nurl = require('url');\n\nMeshbluHTTP = require('meshblu-http');\n\nMeshbluConfig = require('meshblu-config');\n\nmeshblu = require('meshblu');\n\nrequest = require('request');\n\ndescribe('REST', function() {\n before(function(done) {\n var filename;\n filename = path.join(__dirname, 'meshblu.json');\n this.config = new MeshbluConfig({\n filename: filename\n }).toJSON();\n this.meshblu = new MeshbluHTTP(this.config);\n this.conx = meshblu.createConnection({\n server: this.config.server,\n port: this.config.port,\n uuid: this.config.uuid,\n token: this.config.token\n });\n this.conx.on('ready', () => {\n return done();\n });\n return this.conx.on('notReady', done);\n });\n it('should get here', function() {\n return expect(true).to.be.true;\n });\n return describe('GET /devices', function() {\n describe('when called with a valid request', function() {\n beforeEach(function(done) {\n return this.meshblu.devices({}, () => {\n return this.conx.once('message', (message) => {\n this.message = message;\n return done();\n });\n });\n });\n return it('should send a \"devices\" message', function() {\n expect(this.message.topic).to.deep.equal('devices');\n return expect(this.message.payload).to.deep.equal({\n fromUuid: \"66b2928b-a317-4bc3-893e-245946e9672a\",\n request: {}\n });\n });\n });\n return describe('when called with an invalid request', function() {\n return beforeEach(function(done) {\n return this.meshblu.devices({\n uuid: 'invalid-uuid'\n }, () => {\n return this.conx.once('message', (message) => {\n this.message = message;\n return done();\n });\n });\n });\n });\n });\n});\n```", "response": "_ = require 'lodash'\npath = require 'path'\nurl = require 'url'\nMeshbluHTTP = require 'meshblu-http'\nMeshbluConfig = require 'meshblu-config'\nmeshblu = require 'meshblu'\nrequest = require 'request'\n\ndescribe 'REST', ->\n before (done) ->\n filename = path.join __dirname, 'meshblu.json'\n @config = new MeshbluConfig(filename: filename).toJSON()\n @meshblu = new MeshbluHTTP @config\n @conx = meshblu.createConnection\n server : @config.server\n port : @config.port\n uuid : @config.uuid\n token : @config.token\n\n @conx.on 'ready', => done()\n @conx.on 'notReady', done\n\n it 'should get here', ->\n expect(true).to.be.true\n\n describe 'GET /devices', ->\n describe 'when called with a valid request', ->\n beforeEach (done) ->\n @meshblu.devices {}, =>\n @conx.once 'message', (@message) =>\n done()\n\n it 'should send a \"devices\" message', ->\n expect(@message.topic).to.deep.equal 'devices'\n expect(@message.payload).to.deep.equal {\n fromUuid: \"66b2928b-a317-4bc3-893e-245946e9672a\"\n request: {}\n }\n\n describe 'when called with an invalid request', ->\n beforeEach (done) ->\n @meshblu.devices {uuid: 'invalid-uuid'}, =>\n @conx.once 'message', (@message) =>\n done()", "source_lang": "JavaScript", "target_lang": "CoffeeScript", "repo": "octoblu/meshblu", "path": "integration/rest-spec.coffee", "license": "MIT", "commit": "72718bfe5bfbea9f47c53308cea7bc61c52931d7", "stars": 815, "source_url": "https://github.com/octoblu/meshblu/blob/72718bfe5bfbea9f47c53308cea7bc61c52931d7/integration/rest-spec.coffee", "line_start": 1, "line_end": 44}980{"id": "octoblu/meshblu:integration/rest-spec.coffee:1:completion", "type": "completion", "prompt": "_ = require 'lodash'\npath = require 'path'\nurl = require 'url'\nMeshbluHTTP = require 'meshblu-http'\nMeshbluConfig = require 'meshblu-config'\nmeshblu = require 'meshblu'\nrequest = require 'request'\n\ndescribe 'REST', ->\n before (done) ->\n filename = path.join __dirname, 'meshblu.json'\n @config = new MeshbluConfig(filename: filename).toJSON()\n @meshblu = new MeshbluHTTP @config\n @conx = meshblu.createConnection\n server : @config.server\n port : @config.port\n uuid : @config.uuid\n token : @config.token\n\n @conx.on 'ready', => done()\n @conx.on 'notReady', done", "response": "it 'should get here', ->\n expect(true).to.be.true\n\n describe 'GET /devices', ->\n describe 'when called with a valid request', ->\n beforeEach (done) ->\n @meshblu.devices {}, =>\n @conx.once 'message', (@message) =>\n done()\n\n it 'should send a \"devices\" message', ->\n expect(@message.topic).to.deep.equal 'devices'\n expect(@message.payload).to.deep.equal {\n fromUuid: \"66b2928b-a317-4bc3-893e-245946e9672a\"\n request: {}\n }\n\n describe 'when called with an invalid request', ->\n beforeEach (done) ->\n @meshblu.devices {uuid: 'invalid-uuid'}, =>\n @conx.once 'message', (@message) =>\n done()", "source_lang": "CoffeeScript", "target_lang": "CoffeeScript", "repo": "octoblu/meshblu", "path": "integration/rest-spec.coffee", "license": "MIT", "commit": "72718bfe5bfbea9f47c53308cea7bc61c52931d7", "stars": 815, "source_url": "https://github.com/octoblu/meshblu/blob/72718bfe5bfbea9f47c53308cea7bc61c52931d7/integration/rest-spec.coffee", "line_start": 1, "line_end": 44}981{"id": "octoblu/meshblu:integration/rest-spec.coffee:2:raw_corpus", "type": "raw_corpus", "prompt": "", "response": "it 'should send a \"devices-error\" message', ->\n expect(@message.topic).to.deep.equal 'devices-error'\n expect(@message.payload).to.deep.equal {\n fromUuid: \"66b2928b-a317-4bc3-893e-245946e9672a\"\n error: \"Devices not found\"\n request:\n uuid: 'invalid-uuid'\n }\n\n describe 'GET /devices/:uuid', ->\n describe 'when called with a valid request', ->\n beforeEach (done) ->\n pathname = \"/devices/#{@config.uuid}\"\n uri = url.format protocol: @config.protocol, hostname: @config.server, port: @config.port, pathname: pathname\n auth = user: @config.uuid, pass: @config.token\n request.get uri, auth: auth, (error) =>\n return done error if error?\n @conx.once 'message', (@message) =>\n done()\n\n it 'should send a \"devices\" message', ->\n expect(@message.topic).to.deep.equal 'devices'\n expect(@message.payload).to.deep.equal {\n fromUuid: \"66b2928b-a317-4bc3-893e-245946e9672a\"\n request:\n uuid: @config.uuid\n }\n\n describe 'when called with an invalid request', ->\n beforeEach (done) ->\n pathname = \"/devices/invalid-uuid\"\n uri = url.format protocol: @config.protocol, hostname: @config.server, port: @config.port, pathname: pathname\n auth = user: @config.uuid, pass: @config.token\n request.get uri, auth: auth, (error) =>\n return done error if error?\n @conx.once 'message', (@message) =>\n done()\n\n it 'should send a \"devices-error\" message', ->\n expect(@message.topic).to.deep.equal 'devices-error'\n expect(@message.payload).to.deep.equal {\n fromUuid: \"66b2928b-a317-4bc3-893e-245946e9672a\"\n error: \"Devices not found\"\n request:\n uuid: 'invalid-uuid'\n }", "source_lang": "", "target_lang": "CoffeeScript", "repo": "octoblu/meshblu", "path": "integration/rest-spec.coffee", "license": "MIT", "commit": "72718bfe5bfbea9f47c53308cea7bc61c52931d7", "stars": 815, "source_url": "https://github.com/octoblu/meshblu/blob/72718bfe5bfbea9f47c53308cea7bc61c52931d7/integration/rest-spec.coffee", "line_start": 46, "line_end": 91}982{"id": "octoblu/meshblu:integration/rest-spec.coffee:2:coffee_to_js", "type": "coffee_to_js", "prompt": "Convert this CoffeeScript to JavaScript.\n```coffeescript\nit 'should send a \"devices-error\" message', ->\n expect(@message.topic).to.deep.equal 'devices-error'\n expect(@message.payload).to.deep.equal {\n fromUuid: \"66b2928b-a317-4bc3-893e-245946e9672a\"\n error: \"Devices not found\"\n request:\n uuid: 'invalid-uuid'\n }\n\n describe 'GET /devices/:uuid', ->\n describe 'when called with a valid request', ->\n beforeEach (done) ->\n pathname = \"/devices/#{@config.uuid}\"\n uri = url.format protocol: @config.protocol, hostname: @config.server, port: @config.port, pathname: pathname\n auth = user: @config.uuid, pass: @config.token\n request.get uri, auth: auth, (error) =>\n return done error if error?\n @conx.once 'message', (@message) =>\n done()\n\n it 'should send a \"devices\" message', ->\n expect(@message.topic).to.deep.equal 'devices'\n expect(@message.payload).to.deep.equal {\n fromUuid: \"66b2928b-a317-4bc3-893e-245946e9672a\"\n request:\n uuid: @config.uuid\n }\n\n describe 'when called with an invalid request', ->\n beforeEach (done) ->\n pathname = \"/devices/invalid-uuid\"\n uri = url.format protocol: @config.protocol, hostname: @config.server, port: @config.port, pathname: pathname\n auth = user: @config.uuid, pass: @config.token\n request.get uri, auth: auth, (error) =>\n return done error if error?\n @conx.once 'message', (@message) =>\n done()\n\n it 'should send a \"devices-error\" message', ->\n expect(@message.topic).to.deep.equal 'devices-error'\n expect(@message.payload).to.deep.equal {\n fromUuid: \"66b2928b-a317-4bc3-893e-245946e9672a\"\n error: \"Devices not found\"\n request:\n uuid: 'invalid-uuid'\n }\n```", "response": "it('should send a \"devices-error\" message', function() {\n expect(this.message.topic).to.deep.equal('devices-error');\n return expect(this.message.payload).to.deep.equal({\n fromUuid: \"66b2928b-a317-4bc3-893e-245946e9672a\",\n error: \"Devices not found\",\n request: {\n uuid: 'invalid-uuid'\n }\n });\n});\n\ndescribe('GET /devices/:uuid', function() {\n describe('when called with a valid request', function() {\n beforeEach(function(done) {\n var auth, pathname, uri;\n pathname = `/devices/${this.config.uuid}`;\n uri = url.format({\n protocol: this.config.protocol,\n hostname: this.config.server,\n port: this.config.port,\n pathname: pathname\n });\n auth = {\n user: this.config.uuid,\n pass: this.config.token\n };\n return request.get(uri, {\n auth: auth\n }, (error) => {\n if (error != null) {\n return done(error);\n }\n return this.conx.once('message', (message) => {\n this.message = message;\n return done();\n });\n });\n });\n return it('should send a \"devices\" message', function() {\n expect(this.message.topic).to.deep.equal('devices');\n return expect(this.message.payload).to.deep.equal({\n fromUuid: \"66b2928b-a317-4bc3-893e-245946e9672a\",\n request: {\n uuid: this.config.uuid\n }\n });\n });\n });\n return describe('when called with an invalid request', function() {\n beforeEach(function(done) {\n var auth, pathname, uri;\n pathname = \"/devices/invalid-uuid\";\n uri = url.format({\n protocol: this.config.protocol,\n hostname: this.config.server,\n port: this.config.port,\n pathname: pathname\n });\n auth = {\n user: this.config.uuid,\n pass: this.config.token\n };\n return request.get(uri, {\n auth: auth\n }, (error) => {\n if (error != null) {\n return done(error);\n }\n return this.conx.once('message', (message) => {\n this.message = message;\n return done();\n });\n });\n });\n return it('should send a \"devices-error\" message', function() {\n expect(this.message.topic).to.deep.equal('devices-error');\n return expect(this.message.payload).to.deep.equal({\n fromUuid: \"66b2928b-a317-4bc3-893e-245946e9672a\",\n error: \"Devices not found\",\n request: {\n uuid: 'invalid-uuid'\n }\n });\n });\n });\n});", "source_lang": "CoffeeScript", "target_lang": "JavaScript", "repo": "octoblu/meshblu", "path": "integration/rest-spec.coffee", "license": "MIT", "commit": "72718bfe5bfbea9f47c53308cea7bc61c52931d7", "stars": 815, "source_url": "https://github.com/octoblu/meshblu/blob/72718bfe5bfbea9f47c53308cea7bc61c52931d7/integration/rest-spec.coffee", "line_start": 46, "line_end": 91}983{"id": "octoblu/meshblu:integration/rest-spec.coffee:2:js_to_coffee", "type": "js_to_coffee", "prompt": "Convert this JavaScript to CoffeeScript.\n```javascript\nit('should send a \"devices-error\" message', function() {\n expect(this.message.topic).to.deep.equal('devices-error');\n return expect(this.message.payload).to.deep.equal({\n fromUuid: \"66b2928b-a317-4bc3-893e-245946e9672a\",\n error: \"Devices not found\",\n request: {\n uuid: 'invalid-uuid'\n }\n });\n});\n\ndescribe('GET /devices/:uuid', function() {\n describe('when called with a valid request', function() {\n beforeEach(function(done) {\n var auth, pathname, uri;\n pathname = `/devices/${this.config.uuid}`;\n uri = url.format({\n protocol: this.config.protocol,\n hostname: this.config.server,\n port: this.config.port,\n pathname: pathname\n });\n auth = {\n user: this.config.uuid,\n pass: this.config.token\n };\n return request.get(uri, {\n auth: auth\n }, (error) => {\n if (error != null) {\n return done(error);\n }\n return this.conx.once('message', (message) => {\n this.message = message;\n return done();\n });\n });\n });\n return it('should send a \"devices\" message', function() {\n expect(this.message.topic).to.deep.equal('devices');\n return expect(this.message.payload).to.deep.equal({\n fromUuid: \"66b2928b-a317-4bc3-893e-245946e9672a\",\n request: {\n uuid: this.config.uuid\n }\n });\n });\n });\n return describe('when called with an invalid request', function() {\n beforeEach(function(done) {\n var auth, pathname, uri;\n pathname = \"/devices/invalid-uuid\";\n uri = url.format({\n protocol: this.config.protocol,\n hostname: this.config.server,\n port: this.config.port,\n pathname: pathname\n });\n auth = {\n user: this.config.uuid,\n pass: this.config.token\n };\n return request.get(uri, {\n auth: auth\n }, (error) => {\n if (error != null) {\n return done(error);\n }\n return this.conx.once('message', (message) => {\n this.message = message;\n return done();\n });\n });\n });\n return it('should send a \"devices-error\" message', function() {\n expect(this.message.topic).to.deep.equal('devices-error');\n return expect(this.message.payload).to.deep.equal({\n fromUuid: \"66b2928b-a317-4bc3-893e-245946e9672a\",\n error: \"Devices not found\",\n request: {\n uuid: 'invalid-uuid'\n }\n });\n });\n });\n});\n```", "response": "it 'should send a \"devices-error\" message', ->\n expect(@message.topic).to.deep.equal 'devices-error'\n expect(@message.payload).to.deep.equal {\n fromUuid: \"66b2928b-a317-4bc3-893e-245946e9672a\"\n error: \"Devices not found\"\n request:\n uuid: 'invalid-uuid'\n }\n\n describe 'GET /devices/:uuid', ->\n describe 'when called with a valid request', ->\n beforeEach (done) ->\n pathname = \"/devices/#{@config.uuid}\"\n uri = url.format protocol: @config.protocol, hostname: @config.server, port: @config.port, pathname: pathname\n auth = user: @config.uuid, pass: @config.token\n request.get uri, auth: auth, (error) =>\n return done error if error?\n @conx.once 'message', (@message) =>\n done()\n\n it 'should send a \"devices\" message', ->\n expect(@message.topic).to.deep.equal 'devices'\n expect(@message.payload).to.deep.equal {\n fromUuid: \"66b2928b-a317-4bc3-893e-245946e9672a\"\n request:\n uuid: @config.uuid\n }\n\n describe 'when called with an invalid request', ->\n beforeEach (done) ->\n pathname = \"/devices/invalid-uuid\"\n uri = url.format protocol: @config.protocol, hostname: @config.server, port: @config.port, pathname: pathname\n auth = user: @config.uuid, pass: @config.token\n request.get uri, auth: auth, (error) =>\n return done error if error?\n @conx.once 'message', (@message) =>\n done()\n\n it 'should send a \"devices-error\" message', ->\n expect(@message.topic).to.deep.equal 'devices-error'\n expect(@message.payload).to.deep.equal {\n fromUuid: \"66b2928b-a317-4bc3-893e-245946e9672a\"\n error: \"Devices not found\"\n request:\n uuid: 'invalid-uuid'\n }", "source_lang": "JavaScript", "target_lang": "CoffeeScript", "repo": "octoblu/meshblu", "path": "integration/rest-spec.coffee", "license": "MIT", "commit": "72718bfe5bfbea9f47c53308cea7bc61c52931d7", "stars": 815, "source_url": "https://github.com/octoblu/meshblu/blob/72718bfe5bfbea9f47c53308cea7bc61c52931d7/integration/rest-spec.coffee", "line_start": 46, "line_end": 91}984{"id": "octoblu/meshblu:integration/rest-spec.coffee:2:completion", "type": "completion", "prompt": "it 'should send a \"devices-error\" message', ->\n expect(@message.topic).to.deep.equal 'devices-error'\n expect(@message.payload).to.deep.equal {\n fromUuid: \"66b2928b-a317-4bc3-893e-245946e9672a\"\n error: \"Devices not found\"\n request:\n uuid: 'invalid-uuid'\n }\n\n describe 'GET /devices/:uuid', ->\n describe 'when called with a valid request', ->\n beforeEach (done) ->\n pathname = \"/devices/#{@config.uuid}\"\n uri = url.format protocol: @config.protocol, hostname: @config.server, port: @config.port, pathname: pathname\n auth = user: @config.uuid, pass: @config.token\n request.get uri, auth: auth, (error) =>\n return done error if error?\n @conx.once 'message', (@message) =>\n done()\n\n it 'should send a \"devices\" message', ->\n expect(@message.topic).to.deep.equal 'devices'\n expect(@message.payload).to.deep.equal {", "response": "fromUuid: \"66b2928b-a317-4bc3-893e-245946e9672a\"\n request:\n uuid: @config.uuid\n }\n\n describe 'when called with an invalid request', ->\n beforeEach (done) ->\n pathname = \"/devices/invalid-uuid\"\n uri = url.format protocol: @config.protocol, hostname: @config.server, port: @config.port, pathname: pathname\n auth = user: @config.uuid, pass: @config.token\n request.get uri, auth: auth, (error) =>\n return done error if error?\n @conx.once 'message', (@message) =>\n done()\n\n it 'should send a \"devices-error\" message', ->\n expect(@message.topic).to.deep.equal 'devices-error'\n expect(@message.payload).to.deep.equal {\n fromUuid: \"66b2928b-a317-4bc3-893e-245946e9672a\"\n error: \"Devices not found\"\n request:\n uuid: 'invalid-uuid'\n }", "source_lang": "CoffeeScript", "target_lang": "CoffeeScript", "repo": "octoblu/meshblu", "path": "integration/rest-spec.coffee", "license": "MIT", "commit": "72718bfe5bfbea9f47c53308cea7bc61c52931d7", "stars": 815, "source_url": "https://github.com/octoblu/meshblu/blob/72718bfe5bfbea9f47c53308cea7bc61c52931d7/integration/rest-spec.coffee", "line_start": 46, "line_end": 91}985{"id": "octoblu/meshblu:integration/rest-spec.coffee:3:raw_corpus", "type": "raw_corpus", "prompt": "", "response": "describe 'GET /v2/whoami', ->\n describe 'when called with a valid request', ->\n beforeEach (done) ->\n @meshblu.whoami (error) =>\n return done error if error?\n @conx.once 'message', (@message) =>\n done()\n\n it 'should send a \"whoami\" message', ->\n expect(@message.topic).to.deep.equal 'whoami'\n expect(@message.payload).to.deep.equal {\n fromUuid: \"66b2928b-a317-4bc3-893e-245946e9672a\"\n request: {}\n }\n\n describe 'GET /v2/devices/:uuid', ->\n describe 'when called with a valid request', ->\n beforeEach (done) ->\n @meshblu.device @config.uuid, (error) =>\n return done error if error?\n @conx.once 'message', (@message) =>\n done()\n\n it 'should send a \"devices\" message', ->\n expect(@message.topic).to.deep.equal 'devices'\n expect(@message.payload).to.deep.equal {\n fromUuid: \"66b2928b-a317-4bc3-893e-245946e9672a\"\n request:\n uuid: @config.uuid\n }\n\n describe 'when called with an invalid request', ->\n beforeEach (done) ->\n @meshblu.device 'invalid-uuid', (error) =>\n @conx.once 'message', (@message) =>\n done()\n\n it 'should send a \"devices-error\" message', ->\n expect(@message.topic).to.deep.equal 'devices-error'\n expect(@message.payload).to.deep.equal {\n fromUuid: \"66b2928b-a317-4bc3-893e-245946e9672a\"\n error: 'Devices not found'\n request:\n uuid: 'invalid-uuid'\n }", "source_lang": "", "target_lang": "CoffeeScript", "repo": "octoblu/meshblu", "path": "integration/rest-spec.coffee", "license": "MIT", "commit": "72718bfe5bfbea9f47c53308cea7bc61c52931d7", "stars": 815, "source_url": "https://github.com/octoblu/meshblu/blob/72718bfe5bfbea9f47c53308cea7bc61c52931d7/integration/rest-spec.coffee", "line_start": 93, "line_end": 137}986{"id": "octoblu/meshblu:integration/rest-spec.coffee:3:coffee_to_js", "type": "coffee_to_js", "prompt": "Convert this CoffeeScript to JavaScript.\n```coffeescript\ndescribe 'GET /v2/whoami', ->\n describe 'when called with a valid request', ->\n beforeEach (done) ->\n @meshblu.whoami (error) =>\n return done error if error?\n @conx.once 'message', (@message) =>\n done()\n\n it 'should send a \"whoami\" message', ->\n expect(@message.topic).to.deep.equal 'whoami'\n expect(@message.payload).to.deep.equal {\n fromUuid: \"66b2928b-a317-4bc3-893e-245946e9672a\"\n request: {}\n }\n\n describe 'GET /v2/devices/:uuid', ->\n describe 'when called with a valid request', ->\n beforeEach (done) ->\n @meshblu.device @config.uuid, (error) =>\n return done error if error?\n @conx.once 'message', (@message) =>\n done()\n\n it 'should send a \"devices\" message', ->\n expect(@message.topic).to.deep.equal 'devices'\n expect(@message.payload).to.deep.equal {\n fromUuid: \"66b2928b-a317-4bc3-893e-245946e9672a\"\n request:\n uuid: @config.uuid\n }\n\n describe 'when called with an invalid request', ->\n beforeEach (done) ->\n @meshblu.device 'invalid-uuid', (error) =>\n @conx.once 'message', (@message) =>\n done()\n\n it 'should send a \"devices-error\" message', ->\n expect(@message.topic).to.deep.equal 'devices-error'\n expect(@message.payload).to.deep.equal {\n fromUuid: \"66b2928b-a317-4bc3-893e-245946e9672a\"\n error: 'Devices not found'\n request:\n uuid: 'invalid-uuid'\n }\n```", "response": "describe('GET /v2/whoami', function() {\n return describe('when called with a valid request', function() {\n beforeEach(function(done) {\n return this.meshblu.whoami((error) => {\n if (error != null) {\n return done(error);\n }\n return this.conx.once('message', (message) => {\n this.message = message;\n return done();\n });\n });\n });\n return it('should send a \"whoami\" message', function() {\n expect(this.message.topic).to.deep.equal('whoami');\n return expect(this.message.payload).to.deep.equal({\n fromUuid: \"66b2928b-a317-4bc3-893e-245946e9672a\",\n request: {}\n });\n });\n });\n});\n\ndescribe('GET /v2/devices/:uuid', function() {\n describe('when called with a valid request', function() {\n beforeEach(function(done) {\n return this.meshblu.device(this.config.uuid, (error) => {\n if (error != null) {\n return done(error);\n }\n return this.conx.once('message', (message) => {\n this.message = message;\n return done();\n });\n });\n });\n return it('should send a \"devices\" message', function() {\n expect(this.message.topic).to.deep.equal('devices');\n return expect(this.message.payload).to.deep.equal({\n fromUuid: \"66b2928b-a317-4bc3-893e-245946e9672a\",\n request: {\n uuid: this.config.uuid\n }\n });\n });\n });\n return describe('when called with an invalid request', function() {\n beforeEach(function(done) {\n return this.meshblu.device('invalid-uuid', (error) => {\n return this.conx.once('message', (message) => {\n this.message = message;\n return done();\n });\n });\n });\n return it('should send a \"devices-error\" message', function() {\n expect(this.message.topic).to.deep.equal('devices-error');\n return expect(this.message.payload).to.deep.equal({\n fromUuid: \"66b2928b-a317-4bc3-893e-245946e9672a\",\n error: 'Devices not found',\n request: {\n uuid: 'invalid-uuid'\n }\n });\n });\n });\n});", "source_lang": "CoffeeScript", "target_lang": "JavaScript", "repo": "octoblu/meshblu", "path": "integration/rest-spec.coffee", "license": "MIT", "commit": "72718bfe5bfbea9f47c53308cea7bc61c52931d7", "stars": 815, "source_url": "https://github.com/octoblu/meshblu/blob/72718bfe5bfbea9f47c53308cea7bc61c52931d7/integration/rest-spec.coffee", "line_start": 93, "line_end": 137}987{"id": "octoblu/meshblu:integration/rest-spec.coffee:3:js_to_coffee", "type": "js_to_coffee", "prompt": "Convert this JavaScript to CoffeeScript.\n```javascript\ndescribe('GET /v2/whoami', function() {\n return describe('when called with a valid request', function() {\n beforeEach(function(done) {\n return this.meshblu.whoami((error) => {\n if (error != null) {\n return done(error);\n }\n return this.conx.once('message', (message) => {\n this.message = message;\n return done();\n });\n });\n });\n return it('should send a \"whoami\" message', function() {\n expect(this.message.topic).to.deep.equal('whoami');\n return expect(this.message.payload).to.deep.equal({\n fromUuid: \"66b2928b-a317-4bc3-893e-245946e9672a\",\n request: {}\n });\n });\n });\n});\n\ndescribe('GET /v2/devices/:uuid', function() {\n describe('when called with a valid request', function() {\n beforeEach(function(done) {\n return this.meshblu.device(this.config.uuid, (error) => {\n if (error != null) {\n return done(error);\n }\n return this.conx.once('message', (message) => {\n this.message = message;\n return done();\n });\n });\n });\n return it('should send a \"devices\" message', function() {\n expect(this.message.topic).to.deep.equal('devices');\n return expect(this.message.payload).to.deep.equal({\n fromUuid: \"66b2928b-a317-4bc3-893e-245946e9672a\",\n request: {\n uuid: this.config.uuid\n }\n });\n });\n });\n return describe('when called with an invalid request', function() {\n beforeEach(function(done) {\n return this.meshblu.device('invalid-uuid', (error) => {\n return this.conx.once('message', (message) => {\n this.message = message;\n return done();\n });\n });\n });\n return it('should send a \"devices-error\" message', function() {\n expect(this.message.topic).to.deep.equal('devices-error');\n return expect(this.message.payload).to.deep.equal({\n fromUuid: \"66b2928b-a317-4bc3-893e-245946e9672a\",\n error: 'Devices not found',\n request: {\n uuid: 'invalid-uuid'\n }\n });\n });\n });\n});\n```", "response": "describe 'GET /v2/whoami', ->\n describe 'when called with a valid request', ->\n beforeEach (done) ->\n @meshblu.whoami (error) =>\n return done error if error?\n @conx.once 'message', (@message) =>\n done()\n\n it 'should send a \"whoami\" message', ->\n expect(@message.topic).to.deep.equal 'whoami'\n expect(@message.payload).to.deep.equal {\n fromUuid: \"66b2928b-a317-4bc3-893e-245946e9672a\"\n request: {}\n }\n\n describe 'GET /v2/devices/:uuid', ->\n describe 'when called with a valid request', ->\n beforeEach (done) ->\n @meshblu.device @config.uuid, (error) =>\n return done error if error?\n @conx.once 'message', (@message) =>\n done()\n\n it 'should send a \"devices\" message', ->\n expect(@message.topic).to.deep.equal 'devices'\n expect(@message.payload).to.deep.equal {\n fromUuid: \"66b2928b-a317-4bc3-893e-245946e9672a\"\n request:\n uuid: @config.uuid\n }\n\n describe 'when called with an invalid request', ->\n beforeEach (done) ->\n @meshblu.device 'invalid-uuid', (error) =>\n @conx.once 'message', (@message) =>\n done()\n\n it 'should send a \"devices-error\" message', ->\n expect(@message.topic).to.deep.equal 'devices-error'\n expect(@message.payload).to.deep.equal {\n fromUuid: \"66b2928b-a317-4bc3-893e-245946e9672a\"\n error: 'Devices not found'\n request:\n uuid: 'invalid-uuid'\n }", "source_lang": "JavaScript", "target_lang": "CoffeeScript", "repo": "octoblu/meshblu", "path": "integration/rest-spec.coffee", "license": "MIT", "commit": "72718bfe5bfbea9f47c53308cea7bc61c52931d7", "stars": 815, "source_url": "https://github.com/octoblu/meshblu/blob/72718bfe5bfbea9f47c53308cea7bc61c52931d7/integration/rest-spec.coffee", "line_start": 93, "line_end": 137}988{"id": "octoblu/meshblu:integration/rest-spec.coffee:3:completion", "type": "completion", "prompt": "describe 'GET /v2/whoami', ->\n describe 'when called with a valid request', ->\n beforeEach (done) ->\n @meshblu.whoami (error) =>\n return done error if error?\n @conx.once 'message', (@message) =>\n done()\n\n it 'should send a \"whoami\" message', ->\n expect(@message.topic).to.deep.equal 'whoami'\n expect(@message.payload).to.deep.equal {\n fromUuid: \"66b2928b-a317-4bc3-893e-245946e9672a\"\n request: {}\n }\n\n describe 'GET /v2/devices/:uuid', ->\n describe 'when called with a valid request', ->\n beforeEach (done) ->\n @meshblu.device @config.uuid, (error) =>\n return done error if error?\n @conx.once 'message', (@message) =>\n done()", "response": "it 'should send a \"devices\" message', ->\n expect(@message.topic).to.deep.equal 'devices'\n expect(@message.payload).to.deep.equal {\n fromUuid: \"66b2928b-a317-4bc3-893e-245946e9672a\"\n request:\n uuid: @config.uuid\n }\n\n describe 'when called with an invalid request', ->\n beforeEach (done) ->\n @meshblu.device 'invalid-uuid', (error) =>\n @conx.once 'message', (@message) =>\n done()\n\n it 'should send a \"devices-error\" message', ->\n expect(@message.topic).to.deep.equal 'devices-error'\n expect(@message.payload).to.deep.equal {\n fromUuid: \"66b2928b-a317-4bc3-893e-245946e9672a\"\n error: 'Devices not found'\n request:\n uuid: 'invalid-uuid'\n }", "source_lang": "CoffeeScript", "target_lang": "CoffeeScript", "repo": "octoblu/meshblu", "path": "integration/rest-spec.coffee", "license": "MIT", "commit": "72718bfe5bfbea9f47c53308cea7bc61c52931d7", "stars": 815, "source_url": "https://github.com/octoblu/meshblu/blob/72718bfe5bfbea9f47c53308cea7bc61c52931d7/integration/rest-spec.coffee", "line_start": 93, "line_end": 137}989{"id": "octoblu/meshblu:integration/rest-spec.coffee:4:raw_corpus", "type": "raw_corpus", "prompt": "", "response": "describe 'PATCH /v2/devices/:uuid', ->\n describe 'when called with a valid request', ->\n beforeEach (done) ->\n @meshblu.update @config.uuid, foo: 'bar', (error) =>\n return done error if error?\n @conx.once 'message', (@message) =>\n done()\n\n it 'should send a \"update\" message', ->\n expect(@message.topic).to.deep.equal 'update'\n expect(@message.payload).to.deep.equal {\n fromUuid: \"66b2928b-a317-4bc3-893e-245946e9672a\"\n request:\n query: {uuid: @config.uuid}\n params: {$set: {foo: 'bar'}}\n }\n\n describe 'when called with an invalid request', ->\n beforeEach (done) ->\n @meshblu.update @config.uuid, {$foo: 'bar'}, (error) =>\n @conx.once 'message', (@message) =>\n done()\n\n it 'should send an \"update-error\" message', ->\n expect(@message.topic).to.deep.equal 'update-error'\n expect(@message.payload).to.deep.equal {\n fromUuid: \"66b2928b-a317-4bc3-893e-245946e9672a\"\n error: \"The dollar ($) prefixed field '$foo' in '$foo' is not valid for storage.\"\n request:\n query: {uuid: @config.uuid}\n params: {$set: {\"$foo\": 'bar'}}\n }", "source_lang": "", "target_lang": "CoffeeScript", "repo": "octoblu/meshblu", "path": "integration/rest-spec.coffee", "license": "MIT", "commit": "72718bfe5bfbea9f47c53308cea7bc61c52931d7", "stars": 815, "source_url": "https://github.com/octoblu/meshblu/blob/72718bfe5bfbea9f47c53308cea7bc61c52931d7/integration/rest-spec.coffee", "line_start": 139, "line_end": 170}990{"id": "octoblu/meshblu:integration/rest-spec.coffee:4:coffee_to_js", "type": "coffee_to_js", "prompt": "Convert this CoffeeScript to JavaScript.\n```coffeescript\ndescribe 'PATCH /v2/devices/:uuid', ->\n describe 'when called with a valid request', ->\n beforeEach (done) ->\n @meshblu.update @config.uuid, foo: 'bar', (error) =>\n return done error if error?\n @conx.once 'message', (@message) =>\n done()\n\n it 'should send a \"update\" message', ->\n expect(@message.topic).to.deep.equal 'update'\n expect(@message.payload).to.deep.equal {\n fromUuid: \"66b2928b-a317-4bc3-893e-245946e9672a\"\n request:\n query: {uuid: @config.uuid}\n params: {$set: {foo: 'bar'}}\n }\n\n describe 'when called with an invalid request', ->\n beforeEach (done) ->\n @meshblu.update @config.uuid, {$foo: 'bar'}, (error) =>\n @conx.once 'message', (@message) =>\n done()\n\n it 'should send an \"update-error\" message', ->\n expect(@message.topic).to.deep.equal 'update-error'\n expect(@message.payload).to.deep.equal {\n fromUuid: \"66b2928b-a317-4bc3-893e-245946e9672a\"\n error: \"The dollar ($) prefixed field '$foo' in '$foo' is not valid for storage.\"\n request:\n query: {uuid: @config.uuid}\n params: {$set: {\"$foo\": 'bar'}}\n }\n```", "response": "describe('PATCH /v2/devices/:uuid', function() {\n describe('when called with a valid request', function() {\n beforeEach(function(done) {\n return this.meshblu.update(this.config.uuid, {\n foo: 'bar'\n }, (error) => {\n if (error != null) {\n return done(error);\n }\n return this.conx.once('message', (message) => {\n this.message = message;\n return done();\n });\n });\n });\n return it('should send a \"update\" message', function() {\n expect(this.message.topic).to.deep.equal('update');\n return expect(this.message.payload).to.deep.equal({\n fromUuid: \"66b2928b-a317-4bc3-893e-245946e9672a\",\n request: {\n query: {\n uuid: this.config.uuid\n },\n params: {\n $set: {\n foo: 'bar'\n }\n }\n }\n });\n });\n });\n return describe('when called with an invalid request', function() {\n beforeEach(function(done) {\n return this.meshblu.update(this.config.uuid, {\n $foo: 'bar'\n }, (error) => {\n return this.conx.once('message', (message) => {\n this.message = message;\n return done();\n });\n });\n });\n return it('should send an \"update-error\" message', function() {\n expect(this.message.topic).to.deep.equal('update-error');\n return expect(this.message.payload).to.deep.equal({\n fromUuid: \"66b2928b-a317-4bc3-893e-245946e9672a\",\n error: \"The dollar ($) prefixed field '$foo' in '$foo' is not valid for storage.\",\n request: {\n query: {\n uuid: this.config.uuid\n },\n params: {\n $set: {\n \"$foo\": 'bar'\n }\n }\n }\n });\n });\n });\n});", "source_lang": "CoffeeScript", "target_lang": "JavaScript", "repo": "octoblu/meshblu", "path": "integration/rest-spec.coffee", "license": "MIT", "commit": "72718bfe5bfbea9f47c53308cea7bc61c52931d7", "stars": 815, "source_url": "https://github.com/octoblu/meshblu/blob/72718bfe5bfbea9f47c53308cea7bc61c52931d7/integration/rest-spec.coffee", "line_start": 139, "line_end": 170}991{"id": "octoblu/meshblu:integration/rest-spec.coffee:4:js_to_coffee", "type": "js_to_coffee", "prompt": "Convert this JavaScript to CoffeeScript.\n```javascript\ndescribe('PATCH /v2/devices/:uuid', function() {\n describe('when called with a valid request', function() {\n beforeEach(function(done) {\n return this.meshblu.update(this.config.uuid, {\n foo: 'bar'\n }, (error) => {\n if (error != null) {\n return done(error);\n }\n return this.conx.once('message', (message) => {\n this.message = message;\n return done();\n });\n });\n });\n return it('should send a \"update\" message', function() {\n expect(this.message.topic).to.deep.equal('update');\n return expect(this.message.payload).to.deep.equal({\n fromUuid: \"66b2928b-a317-4bc3-893e-245946e9672a\",\n request: {\n query: {\n uuid: this.config.uuid\n },\n params: {\n $set: {\n foo: 'bar'\n }\n }\n }\n });\n });\n });\n return describe('when called with an invalid request', function() {\n beforeEach(function(done) {\n return this.meshblu.update(this.config.uuid, {\n $foo: 'bar'\n }, (error) => {\n return this.conx.once('message', (message) => {\n this.message = message;\n return done();\n });\n });\n });\n return it('should send an \"update-error\" message', function() {\n expect(this.message.topic).to.deep.equal('update-error');\n return expect(this.message.payload).to.deep.equal({\n fromUuid: \"66b2928b-a317-4bc3-893e-245946e9672a\",\n error: \"The dollar ($) prefixed field '$foo' in '$foo' is not valid for storage.\",\n request: {\n query: {\n uuid: this.config.uuid\n },\n params: {\n $set: {\n \"$foo\": 'bar'\n }\n }\n }\n });\n });\n });\n});\n```", "response": "describe 'PATCH /v2/devices/:uuid', ->\n describe 'when called with a valid request', ->\n beforeEach (done) ->\n @meshblu.update @config.uuid, foo: 'bar', (error) =>\n return done error if error?\n @conx.once 'message', (@message) =>\n done()\n\n it 'should send a \"update\" message', ->\n expect(@message.topic).to.deep.equal 'update'\n expect(@message.payload).to.deep.equal {\n fromUuid: \"66b2928b-a317-4bc3-893e-245946e9672a\"\n request:\n query: {uuid: @config.uuid}\n params: {$set: {foo: 'bar'}}\n }\n\n describe 'when called with an invalid request', ->\n beforeEach (done) ->\n @meshblu.update @config.uuid, {$foo: 'bar'}, (error) =>\n @conx.once 'message', (@message) =>\n done()\n\n it 'should send an \"update-error\" message', ->\n expect(@message.topic).to.deep.equal 'update-error'\n expect(@message.payload).to.deep.equal {\n fromUuid: \"66b2928b-a317-4bc3-893e-245946e9672a\"\n error: \"The dollar ($) prefixed field '$foo' in '$foo' is not valid for storage.\"\n request:\n query: {uuid: @config.uuid}\n params: {$set: {\"$foo\": 'bar'}}\n }", "source_lang": "JavaScript", "target_lang": "CoffeeScript", "repo": "octoblu/meshblu", "path": "integration/rest-spec.coffee", "license": "MIT", "commit": "72718bfe5bfbea9f47c53308cea7bc61c52931d7", "stars": 815, "source_url": "https://github.com/octoblu/meshblu/blob/72718bfe5bfbea9f47c53308cea7bc61c52931d7/integration/rest-spec.coffee", "line_start": 139, "line_end": 170}992{"id": "octoblu/meshblu:integration/rest-spec.coffee:4:completion", "type": "completion", "prompt": "describe 'PATCH /v2/devices/:uuid', ->\n describe 'when called with a valid request', ->\n beforeEach (done) ->\n @meshblu.update @config.uuid, foo: 'bar', (error) =>\n return done error if error?\n @conx.once 'message', (@message) =>\n done()\n\n it 'should send a \"update\" message', ->\n expect(@message.topic).to.deep.equal 'update'\n expect(@message.payload).to.deep.equal {\n fromUuid: \"66b2928b-a317-4bc3-893e-245946e9672a\"\n request:\n query: {uuid: @config.uuid}\n params: {$set: {foo: 'bar'}}\n }", "response": "describe 'when called with an invalid request', ->\n beforeEach (done) ->\n @meshblu.update @config.uuid, {$foo: 'bar'}, (error) =>\n @conx.once 'message', (@message) =>\n done()\n\n it 'should send an \"update-error\" message', ->\n expect(@message.topic).to.deep.equal 'update-error'\n expect(@message.payload).to.deep.equal {\n fromUuid: \"66b2928b-a317-4bc3-893e-245946e9672a\"\n error: \"The dollar ($) prefixed field '$foo' in '$foo' is not valid for storage.\"\n request:\n query: {uuid: @config.uuid}\n params: {$set: {\"$foo\": 'bar'}}\n }", "source_lang": "CoffeeScript", "target_lang": "CoffeeScript", "repo": "octoblu/meshblu", "path": "integration/rest-spec.coffee", "license": "MIT", "commit": "72718bfe5bfbea9f47c53308cea7bc61c52931d7", "stars": 815, "source_url": "https://github.com/octoblu/meshblu/blob/72718bfe5bfbea9f47c53308cea7bc61c52931d7/integration/rest-spec.coffee", "line_start": 139, "line_end": 170}993{"id": "octoblu/meshblu:integration/rest-spec.coffee:1:raw_corpus", "type": "raw_corpus", "prompt": "", "response": "_ = require 'lodash'\npath = require 'path'\nurl = require 'url'\nMeshbluHTTP = require 'meshblu-http'\nMeshbluConfig = require 'meshblu-config'\nmeshblu = require 'meshblu'\nrequest = require 'request'\n\ndescribe 'REST', ->\n before (done) ->\n filename = path.join __dirname, 'meshblu.json'\n @config = new MeshbluConfig(filename: filename).toJSON()\n @meshblu = new MeshbluHTTP @config\n @conx = meshblu.createConnection\n server : @config.server\n port : @config.port\n uuid : @config.uuid\n token : @config.token\n\n @conx.on 'ready', => done()\n @conx.on 'notReady', done\n\n it 'should get here', ->\n expect(true).to.be.true\n\n describe '/devices', ->\n describe 'when called with a valid request', ->\n beforeEach (done) ->\n @meshblu.devices {}, =>\n @conx.once 'message', (@message) =>\n done()\n\n it 'should send a \"devices\" message', ->\n expect(@message.topic).to.deep.equal 'devices'\n expect(@message.payload).to.deep.equal {\n fromUuid: \"66b2928b-a317-4bc3-893e-245946e9672a\"\n request: {}\n }\n\n describe 'when called with an invalid request', ->\n beforeEach (done) ->\n @meshblu.devices {uuid: 'invalid-uuid'}, =>\n @conx.once 'message', (@message) =>\n done()", "source_lang": "", "target_lang": "CoffeeScript", "repo": "octoblu/meshblu", "path": "integration/rest-spec.coffee", "license": "MIT", "commit": "2075133e6fe1feec355b369e2c8978a254891dde", "stars": 815, "source_url": "https://github.com/octoblu/meshblu/blob/2075133e6fe1feec355b369e2c8978a254891dde/integration/rest-spec.coffee", "line_start": 1, "line_end": 44}994{"id": "octoblu/meshblu:integration/rest-spec.coffee:1:coffee_to_js", "type": "coffee_to_js", "prompt": "Convert this CoffeeScript to JavaScript.\n```coffeescript\n_ = require 'lodash'\npath = require 'path'\nurl = require 'url'\nMeshbluHTTP = require 'meshblu-http'\nMeshbluConfig = require 'meshblu-config'\nmeshblu = require 'meshblu'\nrequest = require 'request'\n\ndescribe 'REST', ->\n before (done) ->\n filename = path.join __dirname, 'meshblu.json'\n @config = new MeshbluConfig(filename: filename).toJSON()\n @meshblu = new MeshbluHTTP @config\n @conx = meshblu.createConnection\n server : @config.server\n port : @config.port\n uuid : @config.uuid\n token : @config.token\n\n @conx.on 'ready', => done()\n @conx.on 'notReady', done\n\n it 'should get here', ->\n expect(true).to.be.true\n\n describe '/devices', ->\n describe 'when called with a valid request', ->\n beforeEach (done) ->\n @meshblu.devices {}, =>\n @conx.once 'message', (@message) =>\n done()\n\n it 'should send a \"devices\" message', ->\n expect(@message.topic).to.deep.equal 'devices'\n expect(@message.payload).to.deep.equal {\n fromUuid: \"66b2928b-a317-4bc3-893e-245946e9672a\"\n request: {}\n }\n\n describe 'when called with an invalid request', ->\n beforeEach (done) ->\n @meshblu.devices {uuid: 'invalid-uuid'}, =>\n @conx.once 'message', (@message) =>\n done()\n```", "response": "var MeshbluConfig, MeshbluHTTP, _, meshblu, path, request, url;\n\n_ = require('lodash');\n\npath = require('path');\n\nurl = require('url');\n\nMeshbluHTTP = require('meshblu-http');\n\nMeshbluConfig = require('meshblu-config');\n\nmeshblu = require('meshblu');\n\nrequest = require('request');\n\ndescribe('REST', function() {\n before(function(done) {\n var filename;\n filename = path.join(__dirname, 'meshblu.json');\n this.config = new MeshbluConfig({\n filename: filename\n }).toJSON();\n this.meshblu = new MeshbluHTTP(this.config);\n this.conx = meshblu.createConnection({\n server: this.config.server,\n port: this.config.port,\n uuid: this.config.uuid,\n token: this.config.token\n });\n this.conx.on('ready', () => {\n return done();\n });\n return this.conx.on('notReady', done);\n });\n it('should get here', function() {\n return expect(true).to.be.true;\n });\n return describe('/devices', function() {\n describe('when called with a valid request', function() {\n beforeEach(function(done) {\n return this.meshblu.devices({}, () => {\n return this.conx.once('message', (message) => {\n this.message = message;\n return done();\n });\n });\n });\n return it('should send a \"devices\" message', function() {\n expect(this.message.topic).to.deep.equal('devices');\n return expect(this.message.payload).to.deep.equal({\n fromUuid: \"66b2928b-a317-4bc3-893e-245946e9672a\",\n request: {}\n });\n });\n });\n return describe('when called with an invalid request', function() {\n return beforeEach(function(done) {\n return this.meshblu.devices({\n uuid: 'invalid-uuid'\n }, () => {\n return this.conx.once('message', (message) => {\n this.message = message;\n return done();\n });\n });\n });\n });\n });\n});", "source_lang": "CoffeeScript", "target_lang": "JavaScript", "repo": "octoblu/meshblu", "path": "integration/rest-spec.coffee", "license": "MIT", "commit": "2075133e6fe1feec355b369e2c8978a254891dde", "stars": 815, "source_url": "https://github.com/octoblu/meshblu/blob/2075133e6fe1feec355b369e2c8978a254891dde/integration/rest-spec.coffee", "line_start": 1, "line_end": 44}995{"id": "octoblu/meshblu:integration/rest-spec.coffee:1:js_to_coffee", "type": "js_to_coffee", "prompt": "Convert this JavaScript to CoffeeScript.\n```javascript\nvar MeshbluConfig, MeshbluHTTP, _, meshblu, path, request, url;\n\n_ = require('lodash');\n\npath = require('path');\n\nurl = require('url');\n\nMeshbluHTTP = require('meshblu-http');\n\nMeshbluConfig = require('meshblu-config');\n\nmeshblu = require('meshblu');\n\nrequest = require('request');\n\ndescribe('REST', function() {\n before(function(done) {\n var filename;\n filename = path.join(__dirname, 'meshblu.json');\n this.config = new MeshbluConfig({\n filename: filename\n }).toJSON();\n this.meshblu = new MeshbluHTTP(this.config);\n this.conx = meshblu.createConnection({\n server: this.config.server,\n port: this.config.port,\n uuid: this.config.uuid,\n token: this.config.token\n });\n this.conx.on('ready', () => {\n return done();\n });\n return this.conx.on('notReady', done);\n });\n it('should get here', function() {\n return expect(true).to.be.true;\n });\n return describe('/devices', function() {\n describe('when called with a valid request', function() {\n beforeEach(function(done) {\n return this.meshblu.devices({}, () => {\n return this.conx.once('message', (message) => {\n this.message = message;\n return done();\n });\n });\n });\n return it('should send a \"devices\" message', function() {\n expect(this.message.topic).to.deep.equal('devices');\n return expect(this.message.payload).to.deep.equal({\n fromUuid: \"66b2928b-a317-4bc3-893e-245946e9672a\",\n request: {}\n });\n });\n });\n return describe('when called with an invalid request', function() {\n return beforeEach(function(done) {\n return this.meshblu.devices({\n uuid: 'invalid-uuid'\n }, () => {\n return this.conx.once('message', (message) => {\n this.message = message;\n return done();\n });\n });\n });\n });\n });\n});\n```", "response": "_ = require 'lodash'\npath = require 'path'\nurl = require 'url'\nMeshbluHTTP = require 'meshblu-http'\nMeshbluConfig = require 'meshblu-config'\nmeshblu = require 'meshblu'\nrequest = require 'request'\n\ndescribe 'REST', ->\n before (done) ->\n filename = path.join __dirname, 'meshblu.json'\n @config = new MeshbluConfig(filename: filename).toJSON()\n @meshblu = new MeshbluHTTP @config\n @conx = meshblu.createConnection\n server : @config.server\n port : @config.port\n uuid : @config.uuid\n token : @config.token\n\n @conx.on 'ready', => done()\n @conx.on 'notReady', done\n\n it 'should get here', ->\n expect(true).to.be.true\n\n describe '/devices', ->\n describe 'when called with a valid request', ->\n beforeEach (done) ->\n @meshblu.devices {}, =>\n @conx.once 'message', (@message) =>\n done()\n\n it 'should send a \"devices\" message', ->\n expect(@message.topic).to.deep.equal 'devices'\n expect(@message.payload).to.deep.equal {\n fromUuid: \"66b2928b-a317-4bc3-893e-245946e9672a\"\n request: {}\n }\n\n describe 'when called with an invalid request', ->\n beforeEach (done) ->\n @meshblu.devices {uuid: 'invalid-uuid'}, =>\n @conx.once 'message', (@message) =>\n done()", "source_lang": "JavaScript", "target_lang": "CoffeeScript", "repo": "octoblu/meshblu", "path": "integration/rest-spec.coffee", "license": "MIT", "commit": "2075133e6fe1feec355b369e2c8978a254891dde", "stars": 815, "source_url": "https://github.com/octoblu/meshblu/blob/2075133e6fe1feec355b369e2c8978a254891dde/integration/rest-spec.coffee", "line_start": 1, "line_end": 44}996{"id": "octoblu/meshblu:integration/rest-spec.coffee:1:completion", "type": "completion", "prompt": "_ = require 'lodash'\npath = require 'path'\nurl = require 'url'\nMeshbluHTTP = require 'meshblu-http'\nMeshbluConfig = require 'meshblu-config'\nmeshblu = require 'meshblu'\nrequest = require 'request'\n\ndescribe 'REST', ->\n before (done) ->\n filename = path.join __dirname, 'meshblu.json'\n @config = new MeshbluConfig(filename: filename).toJSON()\n @meshblu = new MeshbluHTTP @config\n @conx = meshblu.createConnection\n server : @config.server\n port : @config.port\n uuid : @config.uuid\n token : @config.token\n\n @conx.on 'ready', => done()\n @conx.on 'notReady', done", "response": "it 'should get here', ->\n expect(true).to.be.true\n\n describe '/devices', ->\n describe 'when called with a valid request', ->\n beforeEach (done) ->\n @meshblu.devices {}, =>\n @conx.once 'message', (@message) =>\n done()\n\n it 'should send a \"devices\" message', ->\n expect(@message.topic).to.deep.equal 'devices'\n expect(@message.payload).to.deep.equal {\n fromUuid: \"66b2928b-a317-4bc3-893e-245946e9672a\"\n request: {}\n }\n\n describe 'when called with an invalid request', ->\n beforeEach (done) ->\n @meshblu.devices {uuid: 'invalid-uuid'}, =>\n @conx.once 'message', (@message) =>\n done()", "source_lang": "CoffeeScript", "target_lang": "CoffeeScript", "repo": "octoblu/meshblu", "path": "integration/rest-spec.coffee", "license": "MIT", "commit": "2075133e6fe1feec355b369e2c8978a254891dde", "stars": 815, "source_url": "https://github.com/octoblu/meshblu/blob/2075133e6fe1feec355b369e2c8978a254891dde/integration/rest-spec.coffee", "line_start": 1, "line_end": 44}997{"id": "octoblu/meshblu:integration/rest-spec.coffee:2:raw_corpus", "type": "raw_corpus", "prompt": "", "response": "it 'should send a \"devices-error\" message', ->\n expect(@message.topic).to.deep.equal 'devices-error'\n expect(@message.payload).to.deep.equal {\n fromUuid: \"66b2928b-a317-4bc3-893e-245946e9672a\"\n error: \"Devices not found\"\n request:\n uuid: 'invalid-uuid'\n }\n\n describe '/devices/:uuid', ->\n describe 'when called with a valid request', ->\n beforeEach (done) ->\n pathname = \"/devices/#{@config.uuid}\"\n uri = url.format protocol: @config.protocol, hostname: @config.server, port: @config.port, pathname: pathname\n auth = user: @config.uuid, pass: @config.token\n request.get uri, auth: auth, (error) =>\n return done error if error?\n @conx.once 'message', (@message) =>\n done()\n\n it 'should send a \"devices\" message', ->\n expect(@message.topic).to.deep.equal 'devices'\n expect(@message.payload).to.deep.equal {\n fromUuid: \"66b2928b-a317-4bc3-893e-245946e9672a\"\n request:\n uuid: @config.uuid\n }\n\n describe 'when called with an invalid request', ->\n beforeEach (done) ->\n pathname = \"/devices/invalid-uuid\"\n uri = url.format protocol: @config.protocol, hostname: @config.server, port: @config.port, pathname: pathname\n auth = user: @config.uuid, pass: @config.token\n request.get uri, auth: auth, (error) =>\n return done error if error?\n @conx.once 'message', (@message) =>\n done()\n\n it 'should send a \"devices-error\" message', ->\n expect(@message.topic).to.deep.equal 'devices-error'\n expect(@message.payload).to.deep.equal {\n fromUuid: \"66b2928b-a317-4bc3-893e-245946e9672a\"\n error: \"Devices not found\"\n request:\n uuid: 'invalid-uuid'\n }", "source_lang": "", "target_lang": "CoffeeScript", "repo": "octoblu/meshblu", "path": "integration/rest-spec.coffee", "license": "MIT", "commit": "2075133e6fe1feec355b369e2c8978a254891dde", "stars": 815, "source_url": "https://github.com/octoblu/meshblu/blob/2075133e6fe1feec355b369e2c8978a254891dde/integration/rest-spec.coffee", "line_start": 46, "line_end": 91}998{"id": "octoblu/meshblu:integration/rest-spec.coffee:2:coffee_to_js", "type": "coffee_to_js", "prompt": "Convert this CoffeeScript to JavaScript.\n```coffeescript\nit 'should send a \"devices-error\" message', ->\n expect(@message.topic).to.deep.equal 'devices-error'\n expect(@message.payload).to.deep.equal {\n fromUuid: \"66b2928b-a317-4bc3-893e-245946e9672a\"\n error: \"Devices not found\"\n request:\n uuid: 'invalid-uuid'\n }\n\n describe '/devices/:uuid', ->\n describe 'when called with a valid request', ->\n beforeEach (done) ->\n pathname = \"/devices/#{@config.uuid}\"\n uri = url.format protocol: @config.protocol, hostname: @config.server, port: @config.port, pathname: pathname\n auth = user: @config.uuid, pass: @config.token\n request.get uri, auth: auth, (error) =>\n return done error if error?\n @conx.once 'message', (@message) =>\n done()\n\n it 'should send a \"devices\" message', ->\n expect(@message.topic).to.deep.equal 'devices'\n expect(@message.payload).to.deep.equal {\n fromUuid: \"66b2928b-a317-4bc3-893e-245946e9672a\"\n request:\n uuid: @config.uuid\n }\n\n describe 'when called with an invalid request', ->\n beforeEach (done) ->\n pathname = \"/devices/invalid-uuid\"\n uri = url.format protocol: @config.protocol, hostname: @config.server, port: @config.port, pathname: pathname\n auth = user: @config.uuid, pass: @config.token\n request.get uri, auth: auth, (error) =>\n return done error if error?\n @conx.once 'message', (@message) =>\n done()\n\n it 'should send a \"devices-error\" message', ->\n expect(@message.topic).to.deep.equal 'devices-error'\n expect(@message.payload).to.deep.equal {\n fromUuid: \"66b2928b-a317-4bc3-893e-245946e9672a\"\n error: \"Devices not found\"\n request:\n uuid: 'invalid-uuid'\n }\n```", "response": "it('should send a \"devices-error\" message', function() {\n expect(this.message.topic).to.deep.equal('devices-error');\n return expect(this.message.payload).to.deep.equal({\n fromUuid: \"66b2928b-a317-4bc3-893e-245946e9672a\",\n error: \"Devices not found\",\n request: {\n uuid: 'invalid-uuid'\n }\n });\n});\n\ndescribe('/devices/:uuid', function() {\n describe('when called with a valid request', function() {\n beforeEach(function(done) {\n var auth, pathname, uri;\n pathname = `/devices/${this.config.uuid}`;\n uri = url.format({\n protocol: this.config.protocol,\n hostname: this.config.server,\n port: this.config.port,\n pathname: pathname\n });\n auth = {\n user: this.config.uuid,\n pass: this.config.token\n };\n return request.get(uri, {\n auth: auth\n }, (error) => {\n if (error != null) {\n return done(error);\n }\n return this.conx.once('message', (message) => {\n this.message = message;\n return done();\n });\n });\n });\n return it('should send a \"devices\" message', function() {\n expect(this.message.topic).to.deep.equal('devices');\n return expect(this.message.payload).to.deep.equal({\n fromUuid: \"66b2928b-a317-4bc3-893e-245946e9672a\",\n request: {\n uuid: this.config.uuid\n }\n });\n });\n });\n return describe('when called with an invalid request', function() {\n beforeEach(function(done) {\n var auth, pathname, uri;\n pathname = \"/devices/invalid-uuid\";\n uri = url.format({\n protocol: this.config.protocol,\n hostname: this.config.server,\n port: this.config.port,\n pathname: pathname\n });\n auth = {\n user: this.config.uuid,\n pass: this.config.token\n };\n return request.get(uri, {\n auth: auth\n }, (error) => {\n if (error != null) {\n return done(error);\n }\n return this.conx.once('message', (message) => {\n this.message = message;\n return done();\n });\n });\n });\n return it('should send a \"devices-error\" message', function() {\n expect(this.message.topic).to.deep.equal('devices-error');\n return expect(this.message.payload).to.deep.equal({\n fromUuid: \"66b2928b-a317-4bc3-893e-245946e9672a\",\n error: \"Devices not found\",\n request: {\n uuid: 'invalid-uuid'\n }\n });\n });\n });\n});", "source_lang": "CoffeeScript", "target_lang": "JavaScript", "repo": "octoblu/meshblu", "path": "integration/rest-spec.coffee", "license": "MIT", "commit": "2075133e6fe1feec355b369e2c8978a254891dde", "stars": 815, "source_url": "https://github.com/octoblu/meshblu/blob/2075133e6fe1feec355b369e2c8978a254891dde/integration/rest-spec.coffee", "line_start": 46, "line_end": 91}999{"id": "octoblu/meshblu:integration/rest-spec.coffee:2:js_to_coffee", "type": "js_to_coffee", "prompt": "Convert this JavaScript to CoffeeScript.\n```javascript\nit('should send a \"devices-error\" message', function() {\n expect(this.message.topic).to.deep.equal('devices-error');\n return expect(this.message.payload).to.deep.equal({\n fromUuid: \"66b2928b-a317-4bc3-893e-245946e9672a\",\n error: \"Devices not found\",\n request: {\n uuid: 'invalid-uuid'\n }\n });\n});\n\ndescribe('/devices/:uuid', function() {\n describe('when called with a valid request', function() {\n beforeEach(function(done) {\n var auth, pathname, uri;\n pathname = `/devices/${this.config.uuid}`;\n uri = url.format({\n protocol: this.config.protocol,\n hostname: this.config.server,\n port: this.config.port,\n pathname: pathname\n });\n auth = {\n user: this.config.uuid,\n pass: this.config.token\n };\n return request.get(uri, {\n auth: auth\n }, (error) => {\n if (error != null) {\n return done(error);\n }\n return this.conx.once('message', (message) => {\n this.message = message;\n return done();\n });\n });\n });\n return it('should send a \"devices\" message', function() {\n expect(this.message.topic).to.deep.equal('devices');\n return expect(this.message.payload).to.deep.equal({\n fromUuid: \"66b2928b-a317-4bc3-893e-245946e9672a\",\n request: {\n uuid: this.config.uuid\n }\n });\n });\n });\n return describe('when called with an invalid request', function() {\n beforeEach(function(done) {\n var auth, pathname, uri;\n pathname = \"/devices/invalid-uuid\";\n uri = url.format({\n protocol: this.config.protocol,\n hostname: this.config.server,\n port: this.config.port,\n pathname: pathname\n });\n auth = {\n user: this.config.uuid,\n pass: this.config.token\n };\n return request.get(uri, {\n auth: auth\n }, (error) => {\n if (error != null) {\n return done(error);\n }\n return this.conx.once('message', (message) => {\n this.message = message;\n return done();\n });\n });\n });\n return it('should send a \"devices-error\" message', function() {\n expect(this.message.topic).to.deep.equal('devices-error');\n return expect(this.message.payload).to.deep.equal({\n fromUuid: \"66b2928b-a317-4bc3-893e-245946e9672a\",\n error: \"Devices not found\",\n request: {\n uuid: 'invalid-uuid'\n }\n });\n });\n });\n});\n```", "response": "it 'should send a \"devices-error\" message', ->\n expect(@message.topic).to.deep.equal 'devices-error'\n expect(@message.payload).to.deep.equal {\n fromUuid: \"66b2928b-a317-4bc3-893e-245946e9672a\"\n error: \"Devices not found\"\n request:\n uuid: 'invalid-uuid'\n }\n\n describe '/devices/:uuid', ->\n describe 'when called with a valid request', ->\n beforeEach (done) ->\n pathname = \"/devices/#{@config.uuid}\"\n uri = url.format protocol: @config.protocol, hostname: @config.server, port: @config.port, pathname: pathname\n auth = user: @config.uuid, pass: @config.token\n request.get uri, auth: auth, (error) =>\n return done error if error?\n @conx.once 'message', (@message) =>\n done()\n\n it 'should send a \"devices\" message', ->\n expect(@message.topic).to.deep.equal 'devices'\n expect(@message.payload).to.deep.equal {\n fromUuid: \"66b2928b-a317-4bc3-893e-245946e9672a\"\n request:\n uuid: @config.uuid\n }\n\n describe 'when called with an invalid request', ->\n beforeEach (done) ->\n pathname = \"/devices/invalid-uuid\"\n uri = url.format protocol: @config.protocol, hostname: @config.server, port: @config.port, pathname: pathname\n auth = user: @config.uuid, pass: @config.token\n request.get uri, auth: auth, (error) =>\n return done error if error?\n @conx.once 'message', (@message) =>\n done()\n\n it 'should send a \"devices-error\" message', ->\n expect(@message.topic).to.deep.equal 'devices-error'\n expect(@message.payload).to.deep.equal {\n fromUuid: \"66b2928b-a317-4bc3-893e-245946e9672a\"\n error: \"Devices not found\"\n request:\n uuid: 'invalid-uuid'\n }", "source_lang": "JavaScript", "target_lang": "CoffeeScript", "repo": "octoblu/meshblu", "path": "integration/rest-spec.coffee", "license": "MIT", "commit": "2075133e6fe1feec355b369e2c8978a254891dde", "stars": 815, "source_url": "https://github.com/octoblu/meshblu/blob/2075133e6fe1feec355b369e2c8978a254891dde/integration/rest-spec.coffee", "line_start": 46, "line_end": 91}1000{"id": "octoblu/meshblu:integration/rest-spec.coffee:2:completion", "type": "completion", "prompt": "it 'should send a \"devices-error\" message', ->\n expect(@message.topic).to.deep.equal 'devices-error'\n expect(@message.payload).to.deep.equal {\n fromUuid: \"66b2928b-a317-4bc3-893e-245946e9672a\"\n error: \"Devices not found\"\n request:\n uuid: 'invalid-uuid'\n }\n\n describe '/devices/:uuid', ->\n describe 'when called with a valid request', ->\n beforeEach (done) ->\n pathname = \"/devices/#{@config.uuid}\"\n uri = url.format protocol: @config.protocol, hostname: @config.server, port: @config.port, pathname: pathname\n auth = user: @config.uuid, pass: @config.token\n request.get uri, auth: auth, (error) =>\n return done error if error?\n @conx.once 'message', (@message) =>\n done()\n\n it 'should send a \"devices\" message', ->\n expect(@message.topic).to.deep.equal 'devices'\n expect(@message.payload).to.deep.equal {", "response": "fromUuid: \"66b2928b-a317-4bc3-893e-245946e9672a\"\n request:\n uuid: @config.uuid\n }\n\n describe 'when called with an invalid request', ->\n beforeEach (done) ->\n pathname = \"/devices/invalid-uuid\"\n uri = url.format protocol: @config.protocol, hostname: @config.server, port: @config.port, pathname: pathname\n auth = user: @config.uuid, pass: @config.token\n request.get uri, auth: auth, (error) =>\n return done error if error?\n @conx.once 'message', (@message) =>\n done()\n\n it 'should send a \"devices-error\" message', ->\n expect(@message.topic).to.deep.equal 'devices-error'\n expect(@message.payload).to.deep.equal {\n fromUuid: \"66b2928b-a317-4bc3-893e-245946e9672a\"\n error: \"Devices not found\"\n request:\n uuid: 'invalid-uuid'\n }", "source_lang": "CoffeeScript", "target_lang": "CoffeeScript", "repo": "octoblu/meshblu", "path": "integration/rest-spec.coffee", "license": "MIT", "commit": "2075133e6fe1feec355b369e2c8978a254891dde", "stars": 815, "source_url": "https://github.com/octoblu/meshblu/blob/2075133e6fe1feec355b369e2c8978a254891dde/integration/rest-spec.coffee", "line_start": 46, "line_end": 91}1001{"id": "octoblu/meshblu:integration/rest-spec.coffee:1:raw_corpus", "type": "raw_corpus", "prompt": "", "response": "_ = require 'lodash'\npath = require 'path'\nurl = require 'url'\nMeshbluHTTP = require 'meshblu-http'\nMeshbluConfig = require 'meshblu-config'\nmeshblu = require 'meshblu'\nrequest = require 'request'\n\ndescribe 'REST', ->\n before (done) ->\n filename = path.join __dirname, 'meshblu.json'\n @config = new MeshbluConfig(filename: filename).toJSON()\n @meshblu = new MeshbluHTTP @config\n @conx = meshblu.createConnection\n server : @config.server\n port : @config.port\n uuid : @config.uuid\n token : @config.token\n\n @conx.on 'ready', => done()\n @conx.on 'notReady', done\n\n it 'should get here', ->\n expect(true).to.be.true\n\n describe '/devices', ->\n describe 'when called with a valid request', ->\n beforeEach (done) ->\n @meshblu.devices {}, =>\n @conx.once 'message', (@message) =>\n done()\n\n it 'should send a \"devices\" message', ->\n expect(@message.topic).to.deep.equal 'devices'\n expect(@message.payload).to.deep.equal {\n fromUuid: \"66b2928b-a317-4bc3-893e-245946e9672a\"\n request: {}\n }\n\n describe 'when called with an invalid request', ->\n beforeEach (done) ->\n @meshblu.devices {uuid: 'invalid-uuid'}, =>\n @conx.once 'message', (@message) =>\n done()\n\n it 'should send a \"devices-error\" message', ->\n expect(@message.topic).to.deep.equal 'devices-error'\n expect(@message.payload).to.deep.equal {\n fromUuid: \"66b2928b-a317-4bc3-893e-245946e9672a\"\n error: \"Devices not found\"", "source_lang": "", "target_lang": "CoffeeScript", "repo": "octoblu/meshblu", "path": "integration/rest-spec.coffee", "license": "MIT", "commit": "e82d7328d24647cb39b0cc6aeb331a2272182878", "stars": 815, "source_url": "https://github.com/octoblu/meshblu/blob/e82d7328d24647cb39b0cc6aeb331a2272182878/integration/rest-spec.coffee", "line_start": 1, "line_end": 50}1002{"id": "octoblu/meshblu:integration/rest-spec.coffee:1:completion", "type": "completion", "prompt": "_ = require 'lodash'\npath = require 'path'\nurl = require 'url'\nMeshbluHTTP = require 'meshblu-http'\nMeshbluConfig = require 'meshblu-config'\nmeshblu = require 'meshblu'\nrequest = require 'request'\n\ndescribe 'REST', ->\n before (done) ->\n filename = path.join __dirname, 'meshblu.json'\n @config = new MeshbluConfig(filename: filename).toJSON()\n @meshblu = new MeshbluHTTP @config\n @conx = meshblu.createConnection\n server : @config.server\n port : @config.port\n uuid : @config.uuid\n token : @config.token\n\n @conx.on 'ready', => done()\n @conx.on 'notReady', done\n\n it 'should get here', ->\n expect(true).to.be.true", "response": "describe '/devices', ->\n describe 'when called with a valid request', ->\n beforeEach (done) ->\n @meshblu.devices {}, =>\n @conx.once 'message', (@message) =>\n done()\n\n it 'should send a \"devices\" message', ->\n expect(@message.topic).to.deep.equal 'devices'\n expect(@message.payload).to.deep.equal {\n fromUuid: \"66b2928b-a317-4bc3-893e-245946e9672a\"\n request: {}\n }\n\n describe 'when called with an invalid request', ->\n beforeEach (done) ->\n @meshblu.devices {uuid: 'invalid-uuid'}, =>\n @conx.once 'message', (@message) =>\n done()\n\n it 'should send a \"devices-error\" message', ->\n expect(@message.topic).to.deep.equal 'devices-error'\n expect(@message.payload).to.deep.equal {\n fromUuid: \"66b2928b-a317-4bc3-893e-245946e9672a\"\n error: \"Devices not found\"", "source_lang": "CoffeeScript", "target_lang": "CoffeeScript", "repo": "octoblu/meshblu", "path": "integration/rest-spec.coffee", "license": "MIT", "commit": "e82d7328d24647cb39b0cc6aeb331a2272182878", "stars": 815, "source_url": "https://github.com/octoblu/meshblu/blob/e82d7328d24647cb39b0cc6aeb331a2272182878/integration/rest-spec.coffee", "line_start": 1, "line_end": 50}1003{"id": "octoblu/meshblu:integration/rest-spec.coffee:2:raw_corpus", "type": "raw_corpus", "prompt": "", "response": "request:\n uuid: 'invalid-uuid'\n }\n\n describe '/device/:uuid', ->\n describe 'when called with a valid request', ->\n beforeEach (done) ->\n pathname = \"/devices/#{@config.uuid}\"\n uri = url.format protocol: @config.protocol, hostname: @config.server, port: @config.port, pathname: pathname\n request.get uri, (error) =>\n return done error if error?\n @conx.once 'message', (@message) =>\n done()\n\n it 'should send a \"device\" message', ->\n expect(@message.topic).to.deep.equal 'device'", "source_lang": "", "target_lang": "CoffeeScript", "repo": "octoblu/meshblu", "path": "integration/rest-spec.coffee", "license": "MIT", "commit": "e82d7328d24647cb39b0cc6aeb331a2272182878", "stars": 815, "source_url": "https://github.com/octoblu/meshblu/blob/e82d7328d24647cb39b0cc6aeb331a2272182878/integration/rest-spec.coffee", "line_start": 51, "line_end": 66}1004{"id": "octoblu/meshblu:integration/rest-spec.coffee:2:completion", "type": "completion", "prompt": "request:\n uuid: 'invalid-uuid'\n }\n\n describe '/device/:uuid', ->\n describe 'when called with a valid request', ->\n beforeEach (done) ->\n pathname = \"/devices/#{@config.uuid}\"", "response": "uri = url.format protocol: @config.protocol, hostname: @config.server, port: @config.port, pathname: pathname\n request.get uri, (error) =>\n return done error if error?\n @conx.once 'message', (@message) =>\n done()\n\n it 'should send a \"device\" message', ->\n expect(@message.topic).to.deep.equal 'device'", "source_lang": "CoffeeScript", "target_lang": "CoffeeScript", "repo": "octoblu/meshblu", "path": "integration/rest-spec.coffee", "license": "MIT", "commit": "e82d7328d24647cb39b0cc6aeb331a2272182878", "stars": 815, "source_url": "https://github.com/octoblu/meshblu/blob/e82d7328d24647cb39b0cc6aeb331a2272182878/integration/rest-spec.coffee", "line_start": 51, "line_end": 66}1005{"id": "octoblu/meshblu:integration/rest-spec.coffee:1:raw_corpus", "type": "raw_corpus", "prompt": "", "response": "path = require 'path'\nMeshbluHTTP = require 'meshblu-http'\nMeshbluConfig = require 'meshblu-config'\nmeshblu = require 'meshblu'\n\ndescribe 'REST', ->\n before (done) ->\n filename = path.join __dirname, 'meshblu.json'\n @config = new MeshbluConfig(filename: filename).toJSON()\n @meshblu = new MeshbluHTTP @config\n @conx = meshblu.createConnection\n server : @config.server\n port : @config.port\n uuid : @config.uuid\n token : @config.token\n\n @conx.on 'ready', => done()\n @conx.on 'notReady', done\n\n it 'should get here', ->\n expect(true).to.be.true\n\n describe '/devices', ->\n describe 'when called with a valid request', ->\n beforeEach (done) ->\n @meshblu.devices {}, =>\n @conx.once 'message', (@message) =>\n done()\n\n it 'should send a \"devices\" message', ->\n expect(@message.topic).to.deep.equal 'devices'\n expect(@message.payload).to.deep.equal {\n fromUuid: \"66b2928b-a317-4bc3-893e-245946e9672a\"\n request: {}\n }\n\n describe 'when called with an invalid request', ->\n beforeEach (done) ->\n @meshblu.devices {uuid: 'invalid-uuid'}, =>\n @conx.once 'message', (@message) =>\n done()\n\n it 'should send a \"devices-error\" message', ->\n expect(@message.topic).to.deep.equal 'devices-error'\n expect(@message.payload).to.deep.equal {\n fromUuid: \"66b2928b-a317-4bc3-893e-245946e9672a\"\n error: \"Devices not found\"\n request:\n uuid: 'invalid-uuid'\n }", "source_lang": "", "target_lang": "CoffeeScript", "repo": "octoblu/meshblu", "path": "integration/rest-spec.coffee", "license": "MIT", "commit": "28ccd25f88f0b16104dad02f5514b42ca9e42010", "stars": 815, "source_url": "https://github.com/octoblu/meshblu/blob/28ccd25f88f0b16104dad02f5514b42ca9e42010/integration/rest-spec.coffee", "line_start": 1, "line_end": 50}1006{"id": "octoblu/meshblu:integration/rest-spec.coffee:1:coffee_to_js", "type": "coffee_to_js", "prompt": "Convert this CoffeeScript to JavaScript.\n```coffeescript\npath = require 'path'\nMeshbluHTTP = require 'meshblu-http'\nMeshbluConfig = require 'meshblu-config'\nmeshblu = require 'meshblu'\n\ndescribe 'REST', ->\n before (done) ->\n filename = path.join __dirname, 'meshblu.json'\n @config = new MeshbluConfig(filename: filename).toJSON()\n @meshblu = new MeshbluHTTP @config\n @conx = meshblu.createConnection\n server : @config.server\n port : @config.port\n uuid : @config.uuid\n token : @config.token\n\n @conx.on 'ready', => done()\n @conx.on 'notReady', done\n\n it 'should get here', ->\n expect(true).to.be.true\n\n describe '/devices', ->\n describe 'when called with a valid request', ->\n beforeEach (done) ->\n @meshblu.devices {}, =>\n @conx.once 'message', (@message) =>\n done()\n\n it 'should send a \"devices\" message', ->\n expect(@message.topic).to.deep.equal 'devices'\n expect(@message.payload).to.deep.equal {\n fromUuid: \"66b2928b-a317-4bc3-893e-245946e9672a\"\n request: {}\n }\n\n describe 'when called with an invalid request', ->\n beforeEach (done) ->\n @meshblu.devices {uuid: 'invalid-uuid'}, =>\n @conx.once 'message', (@message) =>\n done()\n\n it 'should send a \"devices-error\" message', ->\n expect(@message.topic).to.deep.equal 'devices-error'\n expect(@message.payload).to.deep.equal {\n fromUuid: \"66b2928b-a317-4bc3-893e-245946e9672a\"\n error: \"Devices not found\"\n request:\n uuid: 'invalid-uuid'\n }\n```", "response": "var MeshbluConfig, MeshbluHTTP, meshblu, path;\n\npath = require('path');\n\nMeshbluHTTP = require('meshblu-http');\n\nMeshbluConfig = require('meshblu-config');\n\nmeshblu = require('meshblu');\n\ndescribe('REST', function() {\n before(function(done) {\n var filename;\n filename = path.join(__dirname, 'meshblu.json');\n this.config = new MeshbluConfig({\n filename: filename\n }).toJSON();\n this.meshblu = new MeshbluHTTP(this.config);\n this.conx = meshblu.createConnection({\n server: this.config.server,\n port: this.config.port,\n uuid: this.config.uuid,\n token: this.config.token\n });\n this.conx.on('ready', () => {\n return done();\n });\n return this.conx.on('notReady', done);\n });\n it('should get here', function() {\n return expect(true).to.be.true;\n });\n return describe('/devices', function() {\n describe('when called with a valid request', function() {\n beforeEach(function(done) {\n return this.meshblu.devices({}, () => {\n return this.conx.once('message', (message) => {\n this.message = message;\n return done();\n });\n });\n });\n return it('should send a \"devices\" message', function() {\n expect(this.message.topic).to.deep.equal('devices');\n return expect(this.message.payload).to.deep.equal({\n fromUuid: \"66b2928b-a317-4bc3-893e-245946e9672a\",\n request: {}\n });\n });\n });\n return describe('when called with an invalid request', function() {\n beforeEach(function(done) {\n return this.meshblu.devices({\n uuid: 'invalid-uuid'\n }, () => {\n return this.conx.once('message', (message) => {\n this.message = message;\n return done();\n });\n });\n });\n return it('should send a \"devices-error\" message', function() {\n expect(this.message.topic).to.deep.equal('devices-error');\n return expect(this.message.payload).to.deep.equal({\n fromUuid: \"66b2928b-a317-4bc3-893e-245946e9672a\",\n error: \"Devices not found\",\n request: {\n uuid: 'invalid-uuid'\n }\n });\n });\n });\n });\n});", "source_lang": "CoffeeScript", "target_lang": "JavaScript", "repo": "octoblu/meshblu", "path": "integration/rest-spec.coffee", "license": "MIT", "commit": "28ccd25f88f0b16104dad02f5514b42ca9e42010", "stars": 815, "source_url": "https://github.com/octoblu/meshblu/blob/28ccd25f88f0b16104dad02f5514b42ca9e42010/integration/rest-spec.coffee", "line_start": 1, "line_end": 50}1007{"id": "octoblu/meshblu:integration/rest-spec.coffee:1:js_to_coffee", "type": "js_to_coffee", "prompt": "Convert this JavaScript to CoffeeScript.\n```javascript\nvar MeshbluConfig, MeshbluHTTP, meshblu, path;\n\npath = require('path');\n\nMeshbluHTTP = require('meshblu-http');\n\nMeshbluConfig = require('meshblu-config');\n\nmeshblu = require('meshblu');\n\ndescribe('REST', function() {\n before(function(done) {\n var filename;\n filename = path.join(__dirname, 'meshblu.json');\n this.config = new MeshbluConfig({\n filename: filename\n }).toJSON();\n this.meshblu = new MeshbluHTTP(this.config);\n this.conx = meshblu.createConnection({\n server: this.config.server,\n port: this.config.port,\n uuid: this.config.uuid,\n token: this.config.token\n });\n this.conx.on('ready', () => {\n return done();\n });\n return this.conx.on('notReady', done);\n });\n it('should get here', function() {\n return expect(true).to.be.true;\n });\n return describe('/devices', function() {\n describe('when called with a valid request', function() {\n beforeEach(function(done) {\n return this.meshblu.devices({}, () => {\n return this.conx.once('message', (message) => {\n this.message = message;\n return done();\n });\n });\n });\n return it('should send a \"devices\" message', function() {\n expect(this.message.topic).to.deep.equal('devices');\n return expect(this.message.payload).to.deep.equal({\n fromUuid: \"66b2928b-a317-4bc3-893e-245946e9672a\",\n request: {}\n });\n });\n });\n return describe('when called with an invalid request', function() {\n beforeEach(function(done) {\n return this.meshblu.devices({\n uuid: 'invalid-uuid'\n }, () => {\n return this.conx.once('message', (message) => {\n this.message = message;\n return done();\n });\n });\n });\n return it('should send a \"devices-error\" message', function() {\n expect(this.message.topic).to.deep.equal('devices-error');\n return expect(this.message.payload).to.deep.equal({\n fromUuid: \"66b2928b-a317-4bc3-893e-245946e9672a\",\n error: \"Devices not found\",\n request: {\n uuid: 'invalid-uuid'\n }\n });\n });\n });\n });\n});\n```", "response": "path = require 'path'\nMeshbluHTTP = require 'meshblu-http'\nMeshbluConfig = require 'meshblu-config'\nmeshblu = require 'meshblu'\n\ndescribe 'REST', ->\n before (done) ->\n filename = path.join __dirname, 'meshblu.json'\n @config = new MeshbluConfig(filename: filename).toJSON()\n @meshblu = new MeshbluHTTP @config\n @conx = meshblu.createConnection\n server : @config.server\n port : @config.port\n uuid : @config.uuid\n token : @config.token\n\n @conx.on 'ready', => done()\n @conx.on 'notReady', done\n\n it 'should get here', ->\n expect(true).to.be.true\n\n describe '/devices', ->\n describe 'when called with a valid request', ->\n beforeEach (done) ->\n @meshblu.devices {}, =>\n @conx.once 'message', (@message) =>\n done()\n\n it 'should send a \"devices\" message', ->\n expect(@message.topic).to.deep.equal 'devices'\n expect(@message.payload).to.deep.equal {\n fromUuid: \"66b2928b-a317-4bc3-893e-245946e9672a\"\n request: {}\n }\n\n describe 'when called with an invalid request', ->\n beforeEach (done) ->\n @meshblu.devices {uuid: 'invalid-uuid'}, =>\n @conx.once 'message', (@message) =>\n done()\n\n it 'should send a \"devices-error\" message', ->\n expect(@message.topic).to.deep.equal 'devices-error'\n expect(@message.payload).to.deep.equal {\n fromUuid: \"66b2928b-a317-4bc3-893e-245946e9672a\"\n error: \"Devices not found\"\n request:\n uuid: 'invalid-uuid'\n }", "source_lang": "JavaScript", "target_lang": "CoffeeScript", "repo": "octoblu/meshblu", "path": "integration/rest-spec.coffee", "license": "MIT", "commit": "28ccd25f88f0b16104dad02f5514b42ca9e42010", "stars": 815, "source_url": "https://github.com/octoblu/meshblu/blob/28ccd25f88f0b16104dad02f5514b42ca9e42010/integration/rest-spec.coffee", "line_start": 1, "line_end": 50}1008{"id": "octoblu/meshblu:integration/rest-spec.coffee:1:completion", "type": "completion", "prompt": "path = require 'path'\nMeshbluHTTP = require 'meshblu-http'\nMeshbluConfig = require 'meshblu-config'\nmeshblu = require 'meshblu'\n\ndescribe 'REST', ->\n before (done) ->\n filename = path.join __dirname, 'meshblu.json'\n @config = new MeshbluConfig(filename: filename).toJSON()\n @meshblu = new MeshbluHTTP @config\n @conx = meshblu.createConnection\n server : @config.server\n port : @config.port\n uuid : @config.uuid\n token : @config.token\n\n @conx.on 'ready', => done()\n @conx.on 'notReady', done\n\n it 'should get here', ->\n expect(true).to.be.true\n\n describe '/devices', ->\n describe 'when called with a valid request', ->\n beforeEach (done) ->", "response": "@meshblu.devices {}, =>\n @conx.once 'message', (@message) =>\n done()\n\n it 'should send a \"devices\" message', ->\n expect(@message.topic).to.deep.equal 'devices'\n expect(@message.payload).to.deep.equal {\n fromUuid: \"66b2928b-a317-4bc3-893e-245946e9672a\"\n request: {}\n }\n\n describe 'when called with an invalid request', ->\n beforeEach (done) ->\n @meshblu.devices {uuid: 'invalid-uuid'}, =>\n @conx.once 'message', (@message) =>\n done()\n\n it 'should send a \"devices-error\" message', ->\n expect(@message.topic).to.deep.equal 'devices-error'\n expect(@message.payload).to.deep.equal {\n fromUuid: \"66b2928b-a317-4bc3-893e-245946e9672a\"\n error: \"Devices not found\"\n request:\n uuid: 'invalid-uuid'\n }", "source_lang": "CoffeeScript", "target_lang": "CoffeeScript", "repo": "octoblu/meshblu", "path": "integration/rest-spec.coffee", "license": "MIT", "commit": "28ccd25f88f0b16104dad02f5514b42ca9e42010", "stars": 815, "source_url": "https://github.com/octoblu/meshblu/blob/28ccd25f88f0b16104dad02f5514b42ca9e42010/integration/rest-spec.coffee", "line_start": 1, "line_end": 50}1009{"id": "cdglabs/apparatus:src/Util/ImageCache.coffee:1:raw_corpus", "type": "raw_corpus", "prompt": "", "response": "module.exports = class ImageCache\n constructor: ->\n @_images = {}\n @_callbacksToRun = {}\n\n getSync: (url) ->\n @_images[url] # will be undefined if url is not saved\n\n get: (url, callback) ->\n # Either the image is cached...\n if @_images[url]\n callback(@_images[url])\n\n # Or it is already being loaded...\n else if @_callbacksToRun[url]\n @_callbacksToRun[url].push(callback)\n\n # Or it's totally new...\n else\n @_callbacksToRun[url] = [callback]\n\n image = new Image()\n if not url.startsWith(\"data:\")\n # (Safari doesn't like .crossOrigin when loading \"data:\" URLs)\n image.crossOrigin = \"Anonymous\"\n image.addEventListener \"load\", =>\n @_images[url] = image\n anyCallback(image) for anyCallback in @_callbacksToRun[url]\n delete @_callbacksToRun[url]\n image.src = url", "source_lang": "", "target_lang": "CoffeeScript", "repo": "cdglabs/apparatus", "path": "src/Util/ImageCache.coffee", "license": "MIT", "commit": "107e0c2db5a0adf0f1c3b49f16f7625cff4e523b", "stars": 1052, "source_url": "https://github.com/cdglabs/apparatus/blob/107e0c2db5a0adf0f1c3b49f16f7625cff4e523b/src/Util/ImageCache.coffee", "line_start": 1, "line_end": 30}1010{"id": "cdglabs/apparatus:src/Util/ImageCache.coffee:1:coffee_to_js", "type": "coffee_to_js", "prompt": "Convert this CoffeeScript to JavaScript.\n```coffeescript\nmodule.exports = class ImageCache\n constructor: ->\n @_images = {}\n @_callbacksToRun = {}\n\n getSync: (url) ->\n @_images[url] # will be undefined if url is not saved\n\n get: (url, callback) ->\n # Either the image is cached...\n if @_images[url]\n callback(@_images[url])\n\n # Or it is already being loaded...\n else if @_callbacksToRun[url]\n @_callbacksToRun[url].push(callback)\n\n # Or it's totally new...\n else\n @_callbacksToRun[url] = [callback]\n\n image = new Image()\n if not url.startsWith(\"data:\")\n # (Safari doesn't like .crossOrigin when loading \"data:\" URLs)\n image.crossOrigin = \"Anonymous\"\n image.addEventListener \"load\", =>\n @_images[url] = image\n anyCallback(image) for anyCallback in @_callbacksToRun[url]\n delete @_callbacksToRun[url]\n image.src = url\n```", "response": "var ImageCache;\n\nmodule.exports = ImageCache = class ImageCache {\n constructor() {\n this._images = {};\n this._callbacksToRun = {};\n }\n\n getSync(url) {\n return this._images[url];\n }\n\n get(url, callback) {\n var image;\n // Either the image is cached...\n if (this._images[url]) {\n return callback(this._images[url]);\n // Or it is already being loaded...\n } else if (this._callbacksToRun[url]) {\n return this._callbacksToRun[url].push(callback);\n } else {\n // Or it's totally new...\n this._callbacksToRun[url] = [callback];\n image = new Image();\n if (!url.startsWith(\"data:\")) {\n // (Safari doesn't like .crossOrigin when loading \"data:\" URLs)\n image.crossOrigin = \"Anonymous\";\n }\n image.addEventListener(\"load\", () => {\n var anyCallback, i, len, ref;\n this._images[url] = image;\n ref = this._callbacksToRun[url];\n for (i = 0, len = ref.length; i < len; i++) {\n anyCallback = ref[i];\n anyCallback(image);\n }\n return delete this._callbacksToRun[url];\n });\n return image.src = url;\n }\n }\n\n};", "source_lang": "CoffeeScript", "target_lang": "JavaScript", "repo": "cdglabs/apparatus", "path": "src/Util/ImageCache.coffee", "license": "MIT", "commit": "107e0c2db5a0adf0f1c3b49f16f7625cff4e523b", "stars": 1052, "source_url": "https://github.com/cdglabs/apparatus/blob/107e0c2db5a0adf0f1c3b49f16f7625cff4e523b/src/Util/ImageCache.coffee", "line_start": 1, "line_end": 30}1011{"id": "cdglabs/apparatus:src/Util/ImageCache.coffee:1:js_to_coffee", "type": "js_to_coffee", "prompt": "Convert this JavaScript to CoffeeScript.\n```javascript\nvar ImageCache;\n\nmodule.exports = ImageCache = class ImageCache {\n constructor() {\n this._images = {};\n this._callbacksToRun = {};\n }\n\n getSync(url) {\n return this._images[url];\n }\n\n get(url, callback) {\n var image;\n // Either the image is cached...\n if (this._images[url]) {\n return callback(this._images[url]);\n // Or it is already being loaded...\n } else if (this._callbacksToRun[url]) {\n return this._callbacksToRun[url].push(callback);\n } else {\n // Or it's totally new...\n this._callbacksToRun[url] = [callback];\n image = new Image();\n if (!url.startsWith(\"data:\")) {\n // (Safari doesn't like .crossOrigin when loading \"data:\" URLs)\n image.crossOrigin = \"Anonymous\";\n }\n image.addEventListener(\"load\", () => {\n var anyCallback, i, len, ref;\n this._images[url] = image;\n ref = this._callbacksToRun[url];\n for (i = 0, len = ref.length; i < len; i++) {\n anyCallback = ref[i];\n anyCallback(image);\n }\n return delete this._callbacksToRun[url];\n });\n return image.src = url;\n }\n }\n\n};\n```", "response": "module.exports = class ImageCache\n constructor: ->\n @_images = {}\n @_callbacksToRun = {}\n\n getSync: (url) ->\n @_images[url] # will be undefined if url is not saved\n\n get: (url, callback) ->\n # Either the image is cached...\n if @_images[url]\n callback(@_images[url])\n\n # Or it is already being loaded...\n else if @_callbacksToRun[url]\n @_callbacksToRun[url].push(callback)\n\n # Or it's totally new...\n else\n @_callbacksToRun[url] = [callback]\n\n image = new Image()\n if not url.startsWith(\"data:\")\n # (Safari doesn't like .crossOrigin when loading \"data:\" URLs)\n image.crossOrigin = \"Anonymous\"\n image.addEventListener \"load\", =>\n @_images[url] = image\n anyCallback(image) for anyCallback in @_callbacksToRun[url]\n delete @_callbacksToRun[url]\n image.src = url", "source_lang": "JavaScript", "target_lang": "CoffeeScript", "repo": "cdglabs/apparatus", "path": "src/Util/ImageCache.coffee", "license": "MIT", "commit": "107e0c2db5a0adf0f1c3b49f16f7625cff4e523b", "stars": 1052, "source_url": "https://github.com/cdglabs/apparatus/blob/107e0c2db5a0adf0f1c3b49f16f7625cff4e523b/src/Util/ImageCache.coffee", "line_start": 1, "line_end": 30}1012{"id": "cdglabs/apparatus:src/Util/ImageCache.coffee:1:completion", "type": "completion", "prompt": "module.exports = class ImageCache\n constructor: ->\n @_images = {}\n @_callbacksToRun = {}\n\n getSync: (url) ->\n @_images[url] # will be undefined if url is not saved\n\n get: (url, callback) ->\n # Either the image is cached...\n if @_images[url]\n callback(@_images[url])\n\n # Or it is already being loaded...\n else if @_callbacksToRun[url]", "response": "@_callbacksToRun[url].push(callback)\n\n # Or it's totally new...\n else\n @_callbacksToRun[url] = [callback]\n\n image = new Image()\n if not url.startsWith(\"data:\")\n # (Safari doesn't like .crossOrigin when loading \"data:\" URLs)\n image.crossOrigin = \"Anonymous\"\n image.addEventListener \"load\", =>\n @_images[url] = image\n anyCallback(image) for anyCallback in @_callbacksToRun[url]\n delete @_callbacksToRun[url]\n image.src = url", "source_lang": "CoffeeScript", "target_lang": "CoffeeScript", "repo": "cdglabs/apparatus", "path": "src/Util/ImageCache.coffee", "license": "MIT", "commit": "107e0c2db5a0adf0f1c3b49f16f7625cff4e523b", "stars": 1052, "source_url": "https://github.com/cdglabs/apparatus/blob/107e0c2db5a0adf0f1c3b49f16f7625cff4e523b/src/Util/ImageCache.coffee", "line_start": 1, "line_end": 30}1013{"id": "octoblu/meshblu:test/lib/getDevice-spec.coffee:1:raw_corpus", "type": "raw_corpus", "prompt": "", "response": "_ = require 'lodash'\nTestDatabase = require '../test-database'\n\ndescribe 'getDevice', ->\n beforeEach (done) ->\n @sut = require '../../lib/getDevice'\n TestDatabase.open (error, database) =>\n @database = database\n done error\n\n describe 'when a device does not exist', ->\n beforeEach (done) ->\n storeDevice = (@error, @device) => done()\n @sut 'does-not-exist', storeDevice, @database\n\n it 'should not have a device', ->\n expect(@device).to.not.exist\n\n it 'should have an error', ->\n expect(@error).to.exist\n\n describe 'when a device exists', ->\n beforeEach (done) ->\n @devices = @database.devices\n @devices.insert uuid: 'valid-uuid', token: 'some-token', done\n\n describe 'when passed a valid uuid', ->\n beforeEach (done) ->\n storeDevice = (@error, @device) => done()\n @sut 'valid-uuid', storeDevice, @database\n\n it 'should have a device', ->\n expect(@device).to.exist\n\n it 'should not have an error', ->\n expect(@error).to.not.exist\n\n it 'should not have a token', ->\n expect(@device.token).to.not.exist", "source_lang": "", "target_lang": "CoffeeScript", "repo": "octoblu/meshblu", "path": "test/lib/getDevice-spec.coffee", "license": "MIT", "commit": "7b2b76a0707d26f2ffd7db6dcfbb6c4cfdf690f5", "stars": 815, "source_url": "https://github.com/octoblu/meshblu/blob/7b2b76a0707d26f2ffd7db6dcfbb6c4cfdf690f5/test/lib/getDevice-spec.coffee", "line_start": 1, "line_end": 39}1014{"id": "octoblu/meshblu:test/lib/getDevice-spec.coffee:1:coffee_to_js", "type": "coffee_to_js", "prompt": "Convert this CoffeeScript to JavaScript.\n```coffeescript\n_ = require 'lodash'\nTestDatabase = require '../test-database'\n\ndescribe 'getDevice', ->\n beforeEach (done) ->\n @sut = require '../../lib/getDevice'\n TestDatabase.open (error, database) =>\n @database = database\n done error\n\n describe 'when a device does not exist', ->\n beforeEach (done) ->\n storeDevice = (@error, @device) => done()\n @sut 'does-not-exist', storeDevice, @database\n\n it 'should not have a device', ->\n expect(@device).to.not.exist\n\n it 'should have an error', ->\n expect(@error).to.exist\n\n describe 'when a device exists', ->\n beforeEach (done) ->\n @devices = @database.devices\n @devices.insert uuid: 'valid-uuid', token: 'some-token', done\n\n describe 'when passed a valid uuid', ->\n beforeEach (done) ->\n storeDevice = (@error, @device) => done()\n @sut 'valid-uuid', storeDevice, @database\n\n it 'should have a device', ->\n expect(@device).to.exist\n\n it 'should not have an error', ->\n expect(@error).to.not.exist\n\n it 'should not have a token', ->\n expect(@device.token).to.not.exist\n```", "response": "var TestDatabase, _;\n\n_ = require('lodash');\n\nTestDatabase = require('../test-database');\n\ndescribe('getDevice', function() {\n beforeEach(function(done) {\n this.sut = require('../../lib/getDevice');\n return TestDatabase.open((error, database) => {\n this.database = database;\n return done(error);\n });\n });\n describe('when a device does not exist', function() {\n beforeEach(function(done) {\n var storeDevice;\n storeDevice = (error1, device) => {\n this.error = error1;\n this.device = device;\n return done();\n };\n return this.sut('does-not-exist', storeDevice, this.database);\n });\n it('should not have a device', function() {\n return expect(this.device).to.not.exist;\n });\n return it('should have an error', function() {\n return expect(this.error).to.exist;\n });\n });\n return describe('when a device exists', function() {\n beforeEach(function(done) {\n this.devices = this.database.devices;\n return this.devices.insert({\n uuid: 'valid-uuid',\n token: 'some-token'\n }, done);\n });\n return describe('when passed a valid uuid', function() {\n beforeEach(function(done) {\n var storeDevice;\n storeDevice = (error1, device) => {\n this.error = error1;\n this.device = device;\n return done();\n };\n return this.sut('valid-uuid', storeDevice, this.database);\n });\n it('should have a device', function() {\n return expect(this.device).to.exist;\n });\n it('should not have an error', function() {\n return expect(this.error).to.not.exist;\n });\n return it('should not have a token', function() {\n return expect(this.device.token).to.not.exist;\n });\n });\n });\n});", "source_lang": "CoffeeScript", "target_lang": "JavaScript", "repo": "octoblu/meshblu", "path": "test/lib/getDevice-spec.coffee", "license": "MIT", "commit": "7b2b76a0707d26f2ffd7db6dcfbb6c4cfdf690f5", "stars": 815, "source_url": "https://github.com/octoblu/meshblu/blob/7b2b76a0707d26f2ffd7db6dcfbb6c4cfdf690f5/test/lib/getDevice-spec.coffee", "line_start": 1, "line_end": 39}1015{"id": "octoblu/meshblu:test/lib/getDevice-spec.coffee:1:js_to_coffee", "type": "js_to_coffee", "prompt": "Convert this JavaScript to CoffeeScript.\n```javascript\nvar TestDatabase, _;\n\n_ = require('lodash');\n\nTestDatabase = require('../test-database');\n\ndescribe('getDevice', function() {\n beforeEach(function(done) {\n this.sut = require('../../lib/getDevice');\n return TestDatabase.open((error, database) => {\n this.database = database;\n return done(error);\n });\n });\n describe('when a device does not exist', function() {\n beforeEach(function(done) {\n var storeDevice;\n storeDevice = (error1, device) => {\n this.error = error1;\n this.device = device;\n return done();\n };\n return this.sut('does-not-exist', storeDevice, this.database);\n });\n it('should not have a device', function() {\n return expect(this.device).to.not.exist;\n });\n return it('should have an error', function() {\n return expect(this.error).to.exist;\n });\n });\n return describe('when a device exists', function() {\n beforeEach(function(done) {\n this.devices = this.database.devices;\n return this.devices.insert({\n uuid: 'valid-uuid',\n token: 'some-token'\n }, done);\n });\n return describe('when passed a valid uuid', function() {\n beforeEach(function(done) {\n var storeDevice;\n storeDevice = (error1, device) => {\n this.error = error1;\n this.device = device;\n return done();\n };\n return this.sut('valid-uuid', storeDevice, this.database);\n });\n it('should have a device', function() {\n return expect(this.device).to.exist;\n });\n it('should not have an error', function() {\n return expect(this.error).to.not.exist;\n });\n return it('should not have a token', function() {\n return expect(this.device.token).to.not.exist;\n });\n });\n });\n});\n```", "response": "_ = require 'lodash'\nTestDatabase = require '../test-database'\n\ndescribe 'getDevice', ->\n beforeEach (done) ->\n @sut = require '../../lib/getDevice'\n TestDatabase.open (error, database) =>\n @database = database\n done error\n\n describe 'when a device does not exist', ->\n beforeEach (done) ->\n storeDevice = (@error, @device) => done()\n @sut 'does-not-exist', storeDevice, @database\n\n it 'should not have a device', ->\n expect(@device).to.not.exist\n\n it 'should have an error', ->\n expect(@error).to.exist\n\n describe 'when a device exists', ->\n beforeEach (done) ->\n @devices = @database.devices\n @devices.insert uuid: 'valid-uuid', token: 'some-token', done\n\n describe 'when passed a valid uuid', ->\n beforeEach (done) ->\n storeDevice = (@error, @device) => done()\n @sut 'valid-uuid', storeDevice, @database\n\n it 'should have a device', ->\n expect(@device).to.exist\n\n it 'should not have an error', ->\n expect(@error).to.not.exist\n\n it 'should not have a token', ->\n expect(@device.token).to.not.exist", "source_lang": "JavaScript", "target_lang": "CoffeeScript", "repo": "octoblu/meshblu", "path": "test/lib/getDevice-spec.coffee", "license": "MIT", "commit": "7b2b76a0707d26f2ffd7db6dcfbb6c4cfdf690f5", "stars": 815, "source_url": "https://github.com/octoblu/meshblu/blob/7b2b76a0707d26f2ffd7db6dcfbb6c4cfdf690f5/test/lib/getDevice-spec.coffee", "line_start": 1, "line_end": 39}1016{"id": "octoblu/meshblu:test/lib/getDevice-spec.coffee:1:completion", "type": "completion", "prompt": "_ = require 'lodash'\nTestDatabase = require '../test-database'\n\ndescribe 'getDevice', ->\n beforeEach (done) ->\n @sut = require '../../lib/getDevice'\n TestDatabase.open (error, database) =>\n @database = database\n done error\n\n describe 'when a device does not exist', ->\n beforeEach (done) ->\n storeDevice = (@error, @device) => done()\n @sut 'does-not-exist', storeDevice, @database\n\n it 'should not have a device', ->\n expect(@device).to.not.exist\n\n it 'should have an error', ->", "response": "expect(@error).to.exist\n\n describe 'when a device exists', ->\n beforeEach (done) ->\n @devices = @database.devices\n @devices.insert uuid: 'valid-uuid', token: 'some-token', done\n\n describe 'when passed a valid uuid', ->\n beforeEach (done) ->\n storeDevice = (@error, @device) => done()\n @sut 'valid-uuid', storeDevice, @database\n\n it 'should have a device', ->\n expect(@device).to.exist\n\n it 'should not have an error', ->\n expect(@error).to.not.exist\n\n it 'should not have a token', ->\n expect(@device.token).to.not.exist", "source_lang": "CoffeeScript", "target_lang": "CoffeeScript", "repo": "octoblu/meshblu", "path": "test/lib/getDevice-spec.coffee", "license": "MIT", "commit": "7b2b76a0707d26f2ffd7db6dcfbb6c4cfdf690f5", "stars": 815, "source_url": "https://github.com/octoblu/meshblu/blob/7b2b76a0707d26f2ffd7db6dcfbb6c4cfdf690f5/test/lib/getDevice-spec.coffee", "line_start": 1, "line_end": 39}1017{"id": "xhan/qqbot:src/apiserver.coffee:2:raw_corpus", "type": "raw_corpus", "prompt": "", "response": "on_stdin = (req,res,params)->\n value = params.value.trim()\n log.info 'stdin value',value\n process.emit 'data', value\n res.endjson()", "source_lang": "", "target_lang": "CoffeeScript", "repo": "xhan/qqbot", "path": "src/apiserver.coffee", "license": "MIT", "commit": "bf22a42121fb4b660de8d6fdfc9148250d749c5c", "stars": 1435, "source_url": "https://github.com/xhan/qqbot/blob/bf22a42121fb4b660de8d6fdfc9148250d749c5c/src/apiserver.coffee", "line_start": 51, "line_end": 55}1018{"id": "xhan/qqbot:src/apiserver.coffee:2:coffee_to_js", "type": "coffee_to_js", "prompt": "Convert this CoffeeScript to JavaScript.\n```coffeescript\non_stdin = (req,res,params)->\n value = params.value.trim()\n log.info 'stdin value',value\n process.emit 'data', value\n res.endjson()\n```", "response": "var on_stdin;\n\non_stdin = function(req, res, params) {\n var value;\n value = params.value.trim();\n log.info('stdin value', value);\n process.emit('data', value);\n return res.endjson();\n};", "source_lang": "CoffeeScript", "target_lang": "JavaScript", "repo": "xhan/qqbot", "path": "src/apiserver.coffee", "license": "MIT", "commit": "bf22a42121fb4b660de8d6fdfc9148250d749c5c", "stars": 1435, "source_url": "https://github.com/xhan/qqbot/blob/bf22a42121fb4b660de8d6fdfc9148250d749c5c/src/apiserver.coffee", "line_start": 51, "line_end": 55}1019{"id": "xhan/qqbot:src/apiserver.coffee:2:js_to_coffee", "type": "js_to_coffee", "prompt": "Convert this JavaScript to CoffeeScript.\n```javascript\nvar on_stdin;\n\non_stdin = function(req, res, params) {\n var value;\n value = params.value.trim();\n log.info('stdin value', value);\n process.emit('data', value);\n return res.endjson();\n};\n```", "response": "on_stdin = (req,res,params)->\n value = params.value.trim()\n log.info 'stdin value',value\n process.emit 'data', value\n res.endjson()", "source_lang": "JavaScript", "target_lang": "CoffeeScript", "repo": "xhan/qqbot", "path": "src/apiserver.coffee", "license": "MIT", "commit": "bf22a42121fb4b660de8d6fdfc9148250d749c5c", "stars": 1435, "source_url": "https://github.com/xhan/qqbot/blob/bf22a42121fb4b660de8d6fdfc9148250d749c5c/src/apiserver.coffee", "line_start": 51, "line_end": 55}1020{"id": "xhan/qqbot:src/apiserver.coffee:2:completion", "type": "completion", "prompt": "on_stdin = (req,res,params)->\n value = params.value.trim()", "response": "log.info 'stdin value',value\n process.emit 'data', value\n res.endjson()", "source_lang": "CoffeeScript", "target_lang": "CoffeeScript", "repo": "xhan/qqbot", "path": "src/apiserver.coffee", "license": "MIT", "commit": "bf22a42121fb4b660de8d6fdfc9148250d749c5c", "stars": 1435, "source_url": "https://github.com/xhan/qqbot/blob/bf22a42121fb4b660de8d6fdfc9148250d749c5c/src/apiserver.coffee", "line_start": 51, "line_end": 55}1021{"id": "xhan/qqbot:src/apiserver.coffee:3:raw_corpus", "type": "raw_corpus", "prompt": "", "response": "on_sendmsg = (req,res,params)->\n log.info \"will send #{params.type} #{params.to} : #{params.msg}\"\n if params.type == 'buddy'\n msg = \"unimplement type #{params.type}\"\n log.warning msg\n res.endjson {err:100,msg:msg}\n else if params.type == 'group'\n cb_sendmessage params.to, params.msg, res\n else\n msg = \"unimplement type #{params.type}\"\n log.warning msg\n res.endjson {err:100,msg:msg}", "source_lang": "", "target_lang": "CoffeeScript", "repo": "xhan/qqbot", "path": "src/apiserver.coffee", "license": "MIT", "commit": "bf22a42121fb4b660de8d6fdfc9148250d749c5c", "stars": 1435, "source_url": "https://github.com/xhan/qqbot/blob/bf22a42121fb4b660de8d6fdfc9148250d749c5c/src/apiserver.coffee", "line_start": 57, "line_end": 68}1022{"id": "xhan/qqbot:src/apiserver.coffee:3:coffee_to_js", "type": "coffee_to_js", "prompt": "Convert this CoffeeScript to JavaScript.\n```coffeescript\non_sendmsg = (req,res,params)->\n log.info \"will send #{params.type} #{params.to} : #{params.msg}\"\n if params.type == 'buddy'\n msg = \"unimplement type #{params.type}\"\n log.warning msg\n res.endjson {err:100,msg:msg}\n else if params.type == 'group'\n cb_sendmessage params.to, params.msg, res\n else\n msg = \"unimplement type #{params.type}\"\n log.warning msg\n res.endjson {err:100,msg:msg}\n```", "response": "var on_sendmsg;\n\non_sendmsg = function(req, res, params) {\n var msg;\n log.info(`will send ${params.type} ${params.to} : ${params.msg}`);\n if (params.type === 'buddy') {\n msg = `unimplement type ${params.type}`;\n log.warning(msg);\n return res.endjson({\n err: 100,\n msg: msg\n });\n } else if (params.type === 'group') {\n return cb_sendmessage(params.to, params.msg, res);\n } else {\n msg = `unimplement type ${params.type}`;\n log.warning(msg);\n return res.endjson({\n err: 100,\n msg: msg\n });\n }\n};", "source_lang": "CoffeeScript", "target_lang": "JavaScript", "repo": "xhan/qqbot", "path": "src/apiserver.coffee", "license": "MIT", "commit": "bf22a42121fb4b660de8d6fdfc9148250d749c5c", "stars": 1435, "source_url": "https://github.com/xhan/qqbot/blob/bf22a42121fb4b660de8d6fdfc9148250d749c5c/src/apiserver.coffee", "line_start": 57, "line_end": 68}1023{"id": "xhan/qqbot:src/apiserver.coffee:3:js_to_coffee", "type": "js_to_coffee", "prompt": "Convert this JavaScript to CoffeeScript.\n```javascript\nvar on_sendmsg;\n\non_sendmsg = function(req, res, params) {\n var msg;\n log.info(`will send ${params.type} ${params.to} : ${params.msg}`);\n if (params.type === 'buddy') {\n msg = `unimplement type ${params.type}`;\n log.warning(msg);\n return res.endjson({\n err: 100,\n msg: msg\n });\n } else if (params.type === 'group') {\n return cb_sendmessage(params.to, params.msg, res);\n } else {\n msg = `unimplement type ${params.type}`;\n log.warning(msg);\n return res.endjson({\n err: 100,\n msg: msg\n });\n }\n};\n```", "response": "on_sendmsg = (req,res,params)->\n log.info \"will send #{params.type} #{params.to} : #{params.msg}\"\n if params.type == 'buddy'\n msg = \"unimplement type #{params.type}\"\n log.warning msg\n res.endjson {err:100,msg:msg}\n else if params.type == 'group'\n cb_sendmessage params.to, params.msg, res\n else\n msg = \"unimplement type #{params.type}\"\n log.warning msg\n res.endjson {err:100,msg:msg}", "source_lang": "JavaScript", "target_lang": "CoffeeScript", "repo": "xhan/qqbot", "path": "src/apiserver.coffee", "license": "MIT", "commit": "bf22a42121fb4b660de8d6fdfc9148250d749c5c", "stars": 1435, "source_url": "https://github.com/xhan/qqbot/blob/bf22a42121fb4b660de8d6fdfc9148250d749c5c/src/apiserver.coffee", "line_start": 57, "line_end": 68}1024{"id": "xhan/qqbot:src/apiserver.coffee:3:completion", "type": "completion", "prompt": "on_sendmsg = (req,res,params)->\n log.info \"will send #{params.type} #{params.to} : #{params.msg}\"\n if params.type == 'buddy'\n msg = \"unimplement type #{params.type}\"\n log.warning msg\n res.endjson {err:100,msg:msg}", "response": "else if params.type == 'group'\n cb_sendmessage params.to, params.msg, res\n else\n msg = \"unimplement type #{params.type}\"\n log.warning msg\n res.endjson {err:100,msg:msg}", "source_lang": "CoffeeScript", "target_lang": "CoffeeScript", "repo": "xhan/qqbot", "path": "src/apiserver.coffee", "license": "MIT", "commit": "bf22a42121fb4b660de8d6fdfc9148250d749c5c", "stars": 1435, "source_url": "https://github.com/xhan/qqbot/blob/bf22a42121fb4b660de8d6fdfc9148250d749c5c/src/apiserver.coffee", "line_start": 57, "line_end": 68}1025{"id": "xhan/qqbot:src/apiserver.coffee:5:raw_corpus", "type": "raw_corpus", "prompt": "", "response": "handle_request = (req,res,path,params)->\n res.endjson = (dict={})->\n ret_dict =\n err: 0\n msg: 'ok'\n for key,value of dict\n ret_dict[key] = value\n\n res.writeHead 200\n res.end jsons ret_dict\n\n if config_token and params.token isnt config_token\n res.endjson {err:503,msg:'token failed'}\n return\n\n switch path\n when '/stdin' then on_stdin(req,res,params)\n when '/send' then on_sendmsg(req,res,params)\n when '/reload'then on_reload_plugin(req,res,params)", "source_lang": "", "target_lang": "CoffeeScript", "repo": "xhan/qqbot", "path": "src/apiserver.coffee", "license": "MIT", "commit": "bf22a42121fb4b660de8d6fdfc9148250d749c5c", "stars": 1435, "source_url": "https://github.com/xhan/qqbot/blob/bf22a42121fb4b660de8d6fdfc9148250d749c5c/src/apiserver.coffee", "line_start": 73, "line_end": 91}1026{"id": "xhan/qqbot:src/apiserver.coffee:5:coffee_to_js", "type": "coffee_to_js", "prompt": "Convert this CoffeeScript to JavaScript.\n```coffeescript\nhandle_request = (req,res,path,params)->\n res.endjson = (dict={})->\n ret_dict =\n err: 0\n msg: 'ok'\n for key,value of dict\n ret_dict[key] = value\n\n res.writeHead 200\n res.end jsons ret_dict\n\n if config_token and params.token isnt config_token\n res.endjson {err:503,msg:'token failed'}\n return\n\n switch path\n when '/stdin' then on_stdin(req,res,params)\n when '/send' then on_sendmsg(req,res,params)\n when '/reload'then on_reload_plugin(req,res,params)\n```", "response": "var handle_request;\n\nhandle_request = function(req, res, path, params) {\n res.endjson = function(dict = {}) {\n var key, ret_dict, value;\n ret_dict = {\n err: 0,\n msg: 'ok'\n };\n for (key in dict) {\n value = dict[key];\n ret_dict[key] = value;\n }\n res.writeHead(200);\n return res.end(jsons(ret_dict));\n };\n if (config_token && params.token !== config_token) {\n res.endjson({\n err: 503,\n msg: 'token failed'\n });\n return;\n }\n switch (path) {\n case '/stdin':\n return on_stdin(req, res, params);\n case '/send':\n return on_sendmsg(req, res, params);\n case '/reload':\n return on_reload_plugin(req, res, params);\n }\n};", "source_lang": "CoffeeScript", "target_lang": "JavaScript", "repo": "xhan/qqbot", "path": "src/apiserver.coffee", "license": "MIT", "commit": "bf22a42121fb4b660de8d6fdfc9148250d749c5c", "stars": 1435, "source_url": "https://github.com/xhan/qqbot/blob/bf22a42121fb4b660de8d6fdfc9148250d749c5c/src/apiserver.coffee", "line_start": 73, "line_end": 91}1027{"id": "xhan/qqbot:src/apiserver.coffee:5:js_to_coffee", "type": "js_to_coffee", "prompt": "Convert this JavaScript to CoffeeScript.\n```javascript\nvar handle_request;\n\nhandle_request = function(req, res, path, params) {\n res.endjson = function(dict = {}) {\n var key, ret_dict, value;\n ret_dict = {\n err: 0,\n msg: 'ok'\n };\n for (key in dict) {\n value = dict[key];\n ret_dict[key] = value;\n }\n res.writeHead(200);\n return res.end(jsons(ret_dict));\n };\n if (config_token && params.token !== config_token) {\n res.endjson({\n err: 503,\n msg: 'token failed'\n });\n return;\n }\n switch (path) {\n case '/stdin':\n return on_stdin(req, res, params);\n case '/send':\n return on_sendmsg(req, res, params);\n case '/reload':\n return on_reload_plugin(req, res, params);\n }\n};\n```", "response": "handle_request = (req,res,path,params)->\n res.endjson = (dict={})->\n ret_dict =\n err: 0\n msg: 'ok'\n for key,value of dict\n ret_dict[key] = value\n\n res.writeHead 200\n res.end jsons ret_dict\n\n if config_token and params.token isnt config_token\n res.endjson {err:503,msg:'token failed'}\n return\n\n switch path\n when '/stdin' then on_stdin(req,res,params)\n when '/send' then on_sendmsg(req,res,params)\n when '/reload'then on_reload_plugin(req,res,params)", "source_lang": "JavaScript", "target_lang": "CoffeeScript", "repo": "xhan/qqbot", "path": "src/apiserver.coffee", "license": "MIT", "commit": "bf22a42121fb4b660de8d6fdfc9148250d749c5c", "stars": 1435, "source_url": "https://github.com/xhan/qqbot/blob/bf22a42121fb4b660de8d6fdfc9148250d749c5c/src/apiserver.coffee", "line_start": 73, "line_end": 91}1028{"id": "xhan/qqbot:src/apiserver.coffee:5:completion", "type": "completion", "prompt": "handle_request = (req,res,path,params)->\n res.endjson = (dict={})->\n ret_dict =\n err: 0\n msg: 'ok'\n for key,value of dict\n ret_dict[key] = value\n\n res.writeHead 200", "response": "res.end jsons ret_dict\n\n if config_token and params.token isnt config_token\n res.endjson {err:503,msg:'token failed'}\n return\n\n switch path\n when '/stdin' then on_stdin(req,res,params)\n when '/send' then on_sendmsg(req,res,params)\n when '/reload'then on_reload_plugin(req,res,params)", "source_lang": "CoffeeScript", "target_lang": "CoffeeScript", "repo": "xhan/qqbot", "path": "src/apiserver.coffee", "license": "MIT", "commit": "bf22a42121fb4b660de8d6fdfc9148250d749c5c", "stars": 1435, "source_url": "https://github.com/xhan/qqbot/blob/bf22a42121fb4b660de8d6fdfc9148250d749c5c/src/apiserver.coffee", "line_start": 73, "line_end": 91}1029{"id": "xhan/qqbot:src/apiserver.coffee:6:raw_corpus", "type": "raw_corpus", "prompt": "", "response": "create_server = (port)->\n server = http.createServer (req, res) ->\n log.debug '[api]' , req.url\n url = URL.parse req.url\n path = url.pathname\n if req.method == 'POST'\n processPost req, res, (body)->\n handle_request(req, res, path, body)\n else if req.method == 'GET'\n query = querystring.parse url.query\n handle_request(req, res, path, query)\n\n server.listen port\n log.info 'api server started at port',port", "source_lang": "", "target_lang": "CoffeeScript", "repo": "xhan/qqbot", "path": "src/apiserver.coffee", "license": "MIT", "commit": "bf22a42121fb4b660de8d6fdfc9148250d749c5c", "stars": 1435, "source_url": "https://github.com/xhan/qqbot/blob/bf22a42121fb4b660de8d6fdfc9148250d749c5c/src/apiserver.coffee", "line_start": 94, "line_end": 107}1030{"id": "xhan/qqbot:src/apiserver.coffee:6:coffee_to_js", "type": "coffee_to_js", "prompt": "Convert this CoffeeScript to JavaScript.\n```coffeescript\ncreate_server = (port)->\n server = http.createServer (req, res) ->\n log.debug '[api]' , req.url\n url = URL.parse req.url\n path = url.pathname\n if req.method == 'POST'\n processPost req, res, (body)->\n handle_request(req, res, path, body)\n else if req.method == 'GET'\n query = querystring.parse url.query\n handle_request(req, res, path, query)\n\n server.listen port\n log.info 'api server started at port',port\n```", "response": "var create_server;\n\ncreate_server = function(port) {\n var server;\n server = http.createServer(function(req, res) {\n var path, query, url;\n log.debug('[api]', req.url);\n url = URL.parse(req.url);\n path = url.pathname;\n if (req.method === 'POST') {\n return processPost(req, res, function(body) {\n return handle_request(req, res, path, body);\n });\n } else if (req.method === 'GET') {\n query = querystring.parse(url.query);\n return handle_request(req, res, path, query);\n }\n });\n server.listen(port);\n return log.info('api server started at port', port);\n};", "source_lang": "CoffeeScript", "target_lang": "JavaScript", "repo": "xhan/qqbot", "path": "src/apiserver.coffee", "license": "MIT", "commit": "bf22a42121fb4b660de8d6fdfc9148250d749c5c", "stars": 1435, "source_url": "https://github.com/xhan/qqbot/blob/bf22a42121fb4b660de8d6fdfc9148250d749c5c/src/apiserver.coffee", "line_start": 94, "line_end": 107}1031{"id": "xhan/qqbot:src/apiserver.coffee:6:js_to_coffee", "type": "js_to_coffee", "prompt": "Convert this JavaScript to CoffeeScript.\n```javascript\nvar create_server;\n\ncreate_server = function(port) {\n var server;\n server = http.createServer(function(req, res) {\n var path, query, url;\n log.debug('[api]', req.url);\n url = URL.parse(req.url);\n path = url.pathname;\n if (req.method === 'POST') {\n return processPost(req, res, function(body) {\n return handle_request(req, res, path, body);\n });\n } else if (req.method === 'GET') {\n query = querystring.parse(url.query);\n return handle_request(req, res, path, query);\n }\n });\n server.listen(port);\n return log.info('api server started at port', port);\n};\n```", "response": "create_server = (port)->\n server = http.createServer (req, res) ->\n log.debug '[api]' , req.url\n url = URL.parse req.url\n path = url.pathname\n if req.method == 'POST'\n processPost req, res, (body)->\n handle_request(req, res, path, body)\n else if req.method == 'GET'\n query = querystring.parse url.query\n handle_request(req, res, path, query)\n\n server.listen port\n log.info 'api server started at port',port", "source_lang": "JavaScript", "target_lang": "CoffeeScript", "repo": "xhan/qqbot", "path": "src/apiserver.coffee", "license": "MIT", "commit": "bf22a42121fb4b660de8d6fdfc9148250d749c5c", "stars": 1435, "source_url": "https://github.com/xhan/qqbot/blob/bf22a42121fb4b660de8d6fdfc9148250d749c5c/src/apiserver.coffee", "line_start": 94, "line_end": 107}1032{"id": "xhan/qqbot:src/apiserver.coffee:6:completion", "type": "completion", "prompt": "create_server = (port)->\n server = http.createServer (req, res) ->\n log.debug '[api]' , req.url\n url = URL.parse req.url\n path = url.pathname\n if req.method == 'POST'\n processPost req, res, (body)->", "response": "handle_request(req, res, path, body)\n else if req.method == 'GET'\n query = querystring.parse url.query\n handle_request(req, res, path, query)\n\n server.listen port\n log.info 'api server started at port',port", "source_lang": "CoffeeScript", "target_lang": "CoffeeScript", "repo": "xhan/qqbot", "path": "src/apiserver.coffee", "license": "MIT", "commit": "bf22a42121fb4b660de8d6fdfc9148250d749c5c", "stars": 1435, "source_url": "https://github.com/xhan/qqbot/blob/bf22a42121fb4b660de8d6fdfc9148250d749c5c/src/apiserver.coffee", "line_start": 94, "line_end": 107}1033{"id": "xhan/qqbot:src/apiserver.coffee:7:raw_corpus", "type": "raw_corpus", "prompt": "", "response": "exports.run = (port,token)->\n config_port = port or 3000\n config_token = token\n create_server config_port", "source_lang": "", "target_lang": "CoffeeScript", "repo": "xhan/qqbot", "path": "src/apiserver.coffee", "license": "MIT", "commit": "bf22a42121fb4b660de8d6fdfc9148250d749c5c", "stars": 1435, "source_url": "https://github.com/xhan/qqbot/blob/bf22a42121fb4b660de8d6fdfc9148250d749c5c/src/apiserver.coffee", "line_start": 110, "line_end": 113}1034{"id": "xhan/qqbot:src/apiserver.coffee:7:coffee_to_js", "type": "coffee_to_js", "prompt": "Convert this CoffeeScript to JavaScript.\n```coffeescript\nexports.run = (port,token)->\n config_port = port or 3000\n config_token = token\n create_server config_port\n```", "response": "exports.run = function(port, token) {\n var config_port, config_token;\n config_port = port || 3000;\n config_token = token;\n return create_server(config_port);\n};", "source_lang": "CoffeeScript", "target_lang": "JavaScript", "repo": "xhan/qqbot", "path": "src/apiserver.coffee", "license": "MIT", "commit": "bf22a42121fb4b660de8d6fdfc9148250d749c5c", "stars": 1435, "source_url": "https://github.com/xhan/qqbot/blob/bf22a42121fb4b660de8d6fdfc9148250d749c5c/src/apiserver.coffee", "line_start": 110, "line_end": 113}1035{"id": "xhan/qqbot:src/apiserver.coffee:7:js_to_coffee", "type": "js_to_coffee", "prompt": "Convert this JavaScript to CoffeeScript.\n```javascript\nexports.run = function(port, token) {\n var config_port, config_token;\n config_port = port || 3000;\n config_token = token;\n return create_server(config_port);\n};\n```", "response": "exports.run = (port,token)->\n config_port = port or 3000\n config_token = token\n create_server config_port", "source_lang": "JavaScript", "target_lang": "CoffeeScript", "repo": "xhan/qqbot", "path": "src/apiserver.coffee", "license": "MIT", "commit": "bf22a42121fb4b660de8d6fdfc9148250d749c5c", "stars": 1435, "source_url": "https://github.com/xhan/qqbot/blob/bf22a42121fb4b660de8d6fdfc9148250d749c5c/src/apiserver.coffee", "line_start": 110, "line_end": 113}1036{"id": "xhan/qqbot:src/apiserver.coffee:7:completion", "type": "completion", "prompt": "exports.run = (port,token)->\n config_port = port or 3000", "response": "config_token = token\n create_server config_port", "source_lang": "CoffeeScript", "target_lang": "CoffeeScript", "repo": "xhan/qqbot", "path": "src/apiserver.coffee", "license": "MIT", "commit": "bf22a42121fb4b660de8d6fdfc9148250d749c5c", "stars": 1435, "source_url": "https://github.com/xhan/qqbot/blob/bf22a42121fb4b660de8d6fdfc9148250d749c5c/src/apiserver.coffee", "line_start": 110, "line_end": 113}1037{"id": "xhan/qqbot:src/apiserver.coffee:8:raw_corpus", "type": "raw_corpus", "prompt": "", "response": "exports.stop = ->\n server.close() if server\n server = null\n\n# @callback group_name, message, res\n# need call res.endjson {} to finish request", "source_lang": "", "target_lang": "CoffeeScript", "repo": "xhan/qqbot", "path": "src/apiserver.coffee", "license": "MIT", "commit": "bf22a42121fb4b660de8d6fdfc9148250d749c5c", "stars": 1435, "source_url": "https://github.com/xhan/qqbot/blob/bf22a42121fb4b660de8d6fdfc9148250d749c5c/src/apiserver.coffee", "line_start": 115, "line_end": 120}1038{"id": "xhan/qqbot:src/apiserver.coffee:8:coffee_to_js", "type": "coffee_to_js", "prompt": "Convert this CoffeeScript to JavaScript.\n```coffeescript\nexports.stop = ->\n server.close() if server\n server = null\n\n# @callback group_name, message, res\n# need call res.endjson {} to finish request\n```", "response": "exports.stop = function() {\n var server;\n if (server) {\n server.close();\n }\n return server = null;\n};\n\n// @callback group_name, message, res\n// need call res.endjson {} to finish request", "source_lang": "CoffeeScript", "target_lang": "JavaScript", "repo": "xhan/qqbot", "path": "src/apiserver.coffee", "license": "MIT", "commit": "bf22a42121fb4b660de8d6fdfc9148250d749c5c", "stars": 1435, "source_url": "https://github.com/xhan/qqbot/blob/bf22a42121fb4b660de8d6fdfc9148250d749c5c/src/apiserver.coffee", "line_start": 115, "line_end": 120}1039{"id": "xhan/qqbot:src/apiserver.coffee:8:js_to_coffee", "type": "js_to_coffee", "prompt": "Convert this JavaScript to CoffeeScript.\n```javascript\nexports.stop = function() {\n var server;\n if (server) {\n server.close();\n }\n return server = null;\n};\n\n// @callback group_name, message, res\n// need call res.endjson {} to finish request\n```", "response": "exports.stop = ->\n server.close() if server\n server = null\n\n# @callback group_name, message, res\n# need call res.endjson {} to finish request", "source_lang": "JavaScript", "target_lang": "CoffeeScript", "repo": "xhan/qqbot", "path": "src/apiserver.coffee", "license": "MIT", "commit": "bf22a42121fb4b660de8d6fdfc9148250d749c5c", "stars": 1435, "source_url": "https://github.com/xhan/qqbot/blob/bf22a42121fb4b660de8d6fdfc9148250d749c5c/src/apiserver.coffee", "line_start": 115, "line_end": 120}1040{"id": "xhan/qqbot:src/apiserver.coffee:4:raw_corpus", "type": "raw_corpus", "prompt": "", "response": "handle_request = (req,res,path,params)->\n res.endjson = (dict={})->\n ret_dict =\n err: 0\n msg: 'ok'\n for key,value of dict\n ret_dict[key] = value\n\n res.writeHead 200\n res.end jsons ret_dict\n\n if config_token and params.token isnt config_token\n res.endjson {err:503,msg:'token failed'}\n return\n\n switch path\n when '/stdin' then on_stdin(req,res,params)\n when '/send' then on_sendmsg(req,res,params)", "source_lang": "", "target_lang": "CoffeeScript", "repo": "xhan/qqbot", "path": "src/apiserver.coffee", "license": "MIT", "commit": "3fcb3b3cca6f26be591fe86a7e57d6797b164ed5", "stars": 1435, "source_url": "https://github.com/xhan/qqbot/blob/3fcb3b3cca6f26be591fe86a7e57d6797b164ed5/src/apiserver.coffee", "line_start": 67, "line_end": 84}1041{"id": "xhan/qqbot:src/apiserver.coffee:4:coffee_to_js", "type": "coffee_to_js", "prompt": "Convert this CoffeeScript to JavaScript.\n```coffeescript\nhandle_request = (req,res,path,params)->\n res.endjson = (dict={})->\n ret_dict =\n err: 0\n msg: 'ok'\n for key,value of dict\n ret_dict[key] = value\n\n res.writeHead 200\n res.end jsons ret_dict\n\n if config_token and params.token isnt config_token\n res.endjson {err:503,msg:'token failed'}\n return\n\n switch path\n when '/stdin' then on_stdin(req,res,params)\n when '/send' then on_sendmsg(req,res,params)\n```", "response": "var handle_request;\n\nhandle_request = function(req, res, path, params) {\n res.endjson = function(dict = {}) {\n var key, ret_dict, value;\n ret_dict = {\n err: 0,\n msg: 'ok'\n };\n for (key in dict) {\n value = dict[key];\n ret_dict[key] = value;\n }\n res.writeHead(200);\n return res.end(jsons(ret_dict));\n };\n if (config_token && params.token !== config_token) {\n res.endjson({\n err: 503,\n msg: 'token failed'\n });\n return;\n }\n switch (path) {\n case '/stdin':\n return on_stdin(req, res, params);\n case '/send':\n return on_sendmsg(req, res, params);\n }\n};", "source_lang": "CoffeeScript", "target_lang": "JavaScript", "repo": "xhan/qqbot", "path": "src/apiserver.coffee", "license": "MIT", "commit": "3fcb3b3cca6f26be591fe86a7e57d6797b164ed5", "stars": 1435, "source_url": "https://github.com/xhan/qqbot/blob/3fcb3b3cca6f26be591fe86a7e57d6797b164ed5/src/apiserver.coffee", "line_start": 67, "line_end": 84}1042{"id": "xhan/qqbot:src/apiserver.coffee:4:js_to_coffee", "type": "js_to_coffee", "prompt": "Convert this JavaScript to CoffeeScript.\n```javascript\nvar handle_request;\n\nhandle_request = function(req, res, path, params) {\n res.endjson = function(dict = {}) {\n var key, ret_dict, value;\n ret_dict = {\n err: 0,\n msg: 'ok'\n };\n for (key in dict) {\n value = dict[key];\n ret_dict[key] = value;\n }\n res.writeHead(200);\n return res.end(jsons(ret_dict));\n };\n if (config_token && params.token !== config_token) {\n res.endjson({\n err: 503,\n msg: 'token failed'\n });\n return;\n }\n switch (path) {\n case '/stdin':\n return on_stdin(req, res, params);\n case '/send':\n return on_sendmsg(req, res, params);\n }\n};\n```", "response": "handle_request = (req,res,path,params)->\n res.endjson = (dict={})->\n ret_dict =\n err: 0\n msg: 'ok'\n for key,value of dict\n ret_dict[key] = value\n\n res.writeHead 200\n res.end jsons ret_dict\n\n if config_token and params.token isnt config_token\n res.endjson {err:503,msg:'token failed'}\n return\n\n switch path\n when '/stdin' then on_stdin(req,res,params)\n when '/send' then on_sendmsg(req,res,params)", "source_lang": "JavaScript", "target_lang": "CoffeeScript", "repo": "xhan/qqbot", "path": "src/apiserver.coffee", "license": "MIT", "commit": "3fcb3b3cca6f26be591fe86a7e57d6797b164ed5", "stars": 1435, "source_url": "https://github.com/xhan/qqbot/blob/3fcb3b3cca6f26be591fe86a7e57d6797b164ed5/src/apiserver.coffee", "line_start": 67, "line_end": 84}1043{"id": "xhan/qqbot:src/apiserver.coffee:4:completion", "type": "completion", "prompt": "handle_request = (req,res,path,params)->\n res.endjson = (dict={})->\n ret_dict =\n err: 0\n msg: 'ok'\n for key,value of dict\n ret_dict[key] = value\n\n res.writeHead 200", "response": "res.end jsons ret_dict\n\n if config_token and params.token isnt config_token\n res.endjson {err:503,msg:'token failed'}\n return\n\n switch path\n when '/stdin' then on_stdin(req,res,params)\n when '/send' then on_sendmsg(req,res,params)", "source_lang": "CoffeeScript", "target_lang": "CoffeeScript", "repo": "xhan/qqbot", "path": "src/apiserver.coffee", "license": "MIT", "commit": "3fcb3b3cca6f26be591fe86a7e57d6797b164ed5", "stars": 1435, "source_url": "https://github.com/xhan/qqbot/blob/3fcb3b3cca6f26be591fe86a7e57d6797b164ed5/src/apiserver.coffee", "line_start": 67, "line_end": 84}1044{"id": "gss/engine:src/properties/Dimensions.coffee:1:raw_corpus", "type": "raw_corpus", "prompt": "", "response": "# Known formulas\n\nclass Dimensions\n\n right: (scope) ->\n id = @identify(scope)\n return ['+', ['get', @getPath(id, 'x')], ['get', @getPath(id, 'width')]]\n\n bottom: (scope, path) ->\n id = @identify(scope)\n return ['+', ['get', @getPath(id, 'y')], ['get', @getPath(id, 'height')]]\n\n center:\n x: (scope, path) ->\n id = @identify(scope)\n return ['+', ['get', @getPath(id, 'x')], ['/', ['get', @getPath(id, 'width')], 2]]\n\n y: (scope, path) ->\n id = @identify(scope)\n return ['+', ['get', @getPath(id, 'y')], ['/', ['get', @getPath(id, 'height')], 2]]\n\nmodule.exports = Dimensions", "source_lang": "", "target_lang": "CoffeeScript", "repo": "gss/engine", "path": "src/properties/Dimensions.coffee", "license": "MIT", "commit": "d3a6c74b85e6d12a9ec02c24fef87d4c22bd9cb0", "stars": 2854, "source_url": "https://github.com/gss/engine/blob/d3a6c74b85e6d12a9ec02c24fef87d4c22bd9cb0/src/properties/Dimensions.coffee", "line_start": 1, "line_end": 22}1045{"id": "gss/engine:src/properties/Dimensions.coffee:1:coffee_to_js", "type": "coffee_to_js", "prompt": "Convert this CoffeeScript to JavaScript.\n```coffeescript\n# Known formulas\n\nclass Dimensions\n\n right: (scope) ->\n id = @identify(scope)\n return ['+', ['get', @getPath(id, 'x')], ['get', @getPath(id, 'width')]]\n\n bottom: (scope, path) ->\n id = @identify(scope)\n return ['+', ['get', @getPath(id, 'y')], ['get', @getPath(id, 'height')]]\n\n center:\n x: (scope, path) ->\n id = @identify(scope)\n return ['+', ['get', @getPath(id, 'x')], ['/', ['get', @getPath(id, 'width')], 2]]\n\n y: (scope, path) ->\n id = @identify(scope)\n return ['+', ['get', @getPath(id, 'y')], ['/', ['get', @getPath(id, 'height')], 2]]\n\nmodule.exports = Dimensions\n```", "response": "// Known formulas\nvar Dimensions;\n\nDimensions = (function() {\n class Dimensions {\n right(scope) {\n var id;\n id = this.identify(scope);\n return ['+', ['get', this.getPath(id, 'x')], ['get', this.getPath(id, 'width')]];\n }\n\n bottom(scope, path) {\n var id;\n id = this.identify(scope);\n return ['+', ['get', this.getPath(id, 'y')], ['get', this.getPath(id, 'height')]];\n }\n\n };\n\n Dimensions.prototype.center = {\n x: function(scope, path) {\n var id;\n id = this.identify(scope);\n return ['+', ['get', this.getPath(id, 'x')], ['/', ['get', this.getPath(id, 'width')], 2]];\n },\n y: function(scope, path) {\n var id;\n id = this.identify(scope);\n return ['+', ['get', this.getPath(id, 'y')], ['/', ['get', this.getPath(id, 'height')], 2]];\n }\n };\n\n return Dimensions;\n\n}).call(this);\n\nmodule.exports = Dimensions;", "source_lang": "CoffeeScript", "target_lang": "JavaScript", "repo": "gss/engine", "path": "src/properties/Dimensions.coffee", "license": "MIT", "commit": "d3a6c74b85e6d12a9ec02c24fef87d4c22bd9cb0", "stars": 2854, "source_url": "https://github.com/gss/engine/blob/d3a6c74b85e6d12a9ec02c24fef87d4c22bd9cb0/src/properties/Dimensions.coffee", "line_start": 1, "line_end": 22}1046{"id": "gss/engine:src/properties/Dimensions.coffee:1:js_to_coffee", "type": "js_to_coffee", "prompt": "Convert this JavaScript to CoffeeScript.\n```javascript\n// Known formulas\nvar Dimensions;\n\nDimensions = (function() {\n class Dimensions {\n right(scope) {\n var id;\n id = this.identify(scope);\n return ['+', ['get', this.getPath(id, 'x')], ['get', this.getPath(id, 'width')]];\n }\n\n bottom(scope, path) {\n var id;\n id = this.identify(scope);\n return ['+', ['get', this.getPath(id, 'y')], ['get', this.getPath(id, 'height')]];\n }\n\n };\n\n Dimensions.prototype.center = {\n x: function(scope, path) {\n var id;\n id = this.identify(scope);\n return ['+', ['get', this.getPath(id, 'x')], ['/', ['get', this.getPath(id, 'width')], 2]];\n },\n y: function(scope, path) {\n var id;\n id = this.identify(scope);\n return ['+', ['get', this.getPath(id, 'y')], ['/', ['get', this.getPath(id, 'height')], 2]];\n }\n };\n\n return Dimensions;\n\n}).call(this);\n\nmodule.exports = Dimensions;\n```", "response": "# Known formulas\n\nclass Dimensions\n\n right: (scope) ->\n id = @identify(scope)\n return ['+', ['get', @getPath(id, 'x')], ['get', @getPath(id, 'width')]]\n\n bottom: (scope, path) ->\n id = @identify(scope)\n return ['+', ['get', @getPath(id, 'y')], ['get', @getPath(id, 'height')]]\n\n center:\n x: (scope, path) ->\n id = @identify(scope)\n return ['+', ['get', @getPath(id, 'x')], ['/', ['get', @getPath(id, 'width')], 2]]\n\n y: (scope, path) ->\n id = @identify(scope)\n return ['+', ['get', @getPath(id, 'y')], ['/', ['get', @getPath(id, 'height')], 2]]\n\nmodule.exports = Dimensions", "source_lang": "JavaScript", "target_lang": "CoffeeScript", "repo": "gss/engine", "path": "src/properties/Dimensions.coffee", "license": "MIT", "commit": "d3a6c74b85e6d12a9ec02c24fef87d4c22bd9cb0", "stars": 2854, "source_url": "https://github.com/gss/engine/blob/d3a6c74b85e6d12a9ec02c24fef87d4c22bd9cb0/src/properties/Dimensions.coffee", "line_start": 1, "line_end": 22}1047{"id": "gss/engine:src/properties/Dimensions.coffee:1:completion", "type": "completion", "prompt": "# Known formulas\n\nclass Dimensions\n\n right: (scope) ->\n id = @identify(scope)\n return ['+', ['get', @getPath(id, 'x')], ['get', @getPath(id, 'width')]]\n\n bottom: (scope, path) ->\n id = @identify(scope)\n return ['+', ['get', @getPath(id, 'y')], ['get', @getPath(id, 'height')]]", "response": "center:\n x: (scope, path) ->\n id = @identify(scope)\n return ['+', ['get', @getPath(id, 'x')], ['/', ['get', @getPath(id, 'width')], 2]]\n\n y: (scope, path) ->\n id = @identify(scope)\n return ['+', ['get', @getPath(id, 'y')], ['/', ['get', @getPath(id, 'height')], 2]]\n\nmodule.exports = Dimensions", "source_lang": "CoffeeScript", "target_lang": "CoffeeScript", "repo": "gss/engine", "path": "src/properties/Dimensions.coffee", "license": "MIT", "commit": "d3a6c74b85e6d12a9ec02c24fef87d4c22bd9cb0", "stars": 2854, "source_url": "https://github.com/gss/engine/blob/d3a6c74b85e6d12a9ec02c24fef87d4c22bd9cb0/src/properties/Dimensions.coffee", "line_start": 1, "line_end": 22}1048{"id": "gss/engine:src/properties/Dimensions.coffee:1:raw_corpus", "type": "raw_corpus", "prompt": "", "response": "class Dimensions\n # Global variables managed by the engine\n\n\n '::window':\n\n width: ->\n return window.innerWidth\n\n height: ->\n return window.innerHeight\n\n #right: '::window[width]'\n #bottom: '::window[height]'\n #\n #center:\n # x: ->\n # return window.innerWidth / 2\n #\n # y: ->\n # return window.innerHeight / 2\n\n scroll:\n\n left: ->\n return window.pageXOffset || document.documentElement.scrollLeft || document.body.scrollLeft\n\n top: ->\n return window.pageYOffset || document.documentElement.scrollTop || document.body.scrollTop\n\n x: 0\n y: 0\n\n '::document':\n\n scroll:\n left: '::window[scroll-left]'\n top: '::window[scroll-top]'\n\n x: '::window[x]'\n y: '::window[y]'\n\n intrinsic:\n\n height: (element) ->\n return# element.offsetHeight\n\n width: (element) ->\n return# element.offsetWidth", "source_lang": "", "target_lang": "CoffeeScript", "repo": "gss/engine", "path": "src/properties/Dimensions.coffee", "license": "MIT", "commit": "6a58b41bad01c4f4c7c64e670394ffd607937fc3", "stars": 2854, "source_url": "https://github.com/gss/engine/blob/6a58b41bad01c4f4c7c64e670394ffd607937fc3/src/properties/Dimensions.coffee", "line_start": 1, "line_end": 50}1049{"id": "gss/engine:src/properties/Dimensions.coffee:1:coffee_to_js", "type": "coffee_to_js", "prompt": "Convert this CoffeeScript to JavaScript.\n```coffeescript\nclass Dimensions\n # Global variables managed by the engine\n\n\n '::window':\n\n width: ->\n return window.innerWidth\n\n height: ->\n return window.innerHeight\n\n #right: '::window[width]'\n #bottom: '::window[height]'\n #\n #center:\n # x: ->\n # return window.innerWidth / 2\n #\n # y: ->\n # return window.innerHeight / 2\n\n scroll:\n\n left: ->\n return window.pageXOffset || document.documentElement.scrollLeft || document.body.scrollLeft\n\n top: ->\n return window.pageYOffset || document.documentElement.scrollTop || document.body.scrollTop\n\n x: 0\n y: 0\n\n '::document':\n\n scroll:\n left: '::window[scroll-left]'\n top: '::window[scroll-top]'\n\n x: '::window[x]'\n y: '::window[y]'\n\n intrinsic:\n\n height: (element) ->\n return# element.offsetHeight\n\n width: (element) ->\n return# element.offsetWidth\n```", "response": "var Dimensions;\n\nDimensions = (function() {\n class Dimensions {};\n\n // Global variables managed by the engine\n Dimensions.prototype['::window'] = {\n width: function() {\n return window.innerWidth;\n },\n height: function() {\n return window.innerHeight;\n },\n //right: '::window[width]'\n //bottom: '::window[height]'\n\n //center:\n // x: ->\n // return window.innerWidth / 2\n\n // y: ->\n // return window.innerHeight / 2\n scroll: {\n left: function() {\n return window.pageXOffset || document.documentElement.scrollLeft || document.body.scrollLeft;\n },\n top: function() {\n return window.pageYOffset || document.documentElement.scrollTop || document.body.scrollTop;\n }\n },\n x: 0,\n y: 0\n };\n\n Dimensions.prototype['::document'] = {\n scroll: {\n left: '::window[scroll-left]',\n top: '::window[scroll-top]'\n },\n x: '::window[x]',\n y: '::window[y]'\n };\n\n Dimensions.prototype.intrinsic = {\n height: function(element) {}, // element.offsetHeight\n width: function(element) {} // element.offsetWidth\n };\n\n return Dimensions;\n\n}).call(this);", "source_lang": "CoffeeScript", "target_lang": "JavaScript", "repo": "gss/engine", "path": "src/properties/Dimensions.coffee", "license": "MIT", "commit": "6a58b41bad01c4f4c7c64e670394ffd607937fc3", "stars": 2854, "source_url": "https://github.com/gss/engine/blob/6a58b41bad01c4f4c7c64e670394ffd607937fc3/src/properties/Dimensions.coffee", "line_start": 1, "line_end": 50}1050{"id": "gss/engine:src/properties/Dimensions.coffee:1:js_to_coffee", "type": "js_to_coffee", "prompt": "Convert this JavaScript to CoffeeScript.\n```javascript\nvar Dimensions;\n\nDimensions = (function() {\n class Dimensions {};\n\n // Global variables managed by the engine\n Dimensions.prototype['::window'] = {\n width: function() {\n return window.innerWidth;\n },\n height: function() {\n return window.innerHeight;\n },\n //right: '::window[width]'\n //bottom: '::window[height]'\n\n //center:\n // x: ->\n // return window.innerWidth / 2\n\n // y: ->\n // return window.innerHeight / 2\n scroll: {\n left: function() {\n return window.pageXOffset || document.documentElement.scrollLeft || document.body.scrollLeft;\n },\n top: function() {\n return window.pageYOffset || document.documentElement.scrollTop || document.body.scrollTop;\n }\n },\n x: 0,\n y: 0\n };\n\n Dimensions.prototype['::document'] = {\n scroll: {\n left: '::window[scroll-left]',\n top: '::window[scroll-top]'\n },\n x: '::window[x]',\n y: '::window[y]'\n };\n\n Dimensions.prototype.intrinsic = {\n height: function(element) {}, // element.offsetHeight\n width: function(element) {} // element.offsetWidth\n };\n\n return Dimensions;\n\n}).call(this);\n```", "response": "class Dimensions\n # Global variables managed by the engine\n\n\n '::window':\n\n width: ->\n return window.innerWidth\n\n height: ->\n return window.innerHeight\n\n #right: '::window[width]'\n #bottom: '::window[height]'\n #\n #center:\n # x: ->\n # return window.innerWidth / 2\n #\n # y: ->\n # return window.innerHeight / 2\n\n scroll:\n\n left: ->\n return window.pageXOffset || document.documentElement.scrollLeft || document.body.scrollLeft\n\n top: ->\n return window.pageYOffset || document.documentElement.scrollTop || document.body.scrollTop\n\n x: 0\n y: 0\n\n '::document':\n\n scroll:\n left: '::window[scroll-left]'\n top: '::window[scroll-top]'\n\n x: '::window[x]'\n y: '::window[y]'\n\n intrinsic:\n\n height: (element) ->\n return# element.offsetHeight\n\n width: (element) ->\n return# element.offsetWidth", "source_lang": "JavaScript", "target_lang": "CoffeeScript", "repo": "gss/engine", "path": "src/properties/Dimensions.coffee", "license": "MIT", "commit": "6a58b41bad01c4f4c7c64e670394ffd607937fc3", "stars": 2854, "source_url": "https://github.com/gss/engine/blob/6a58b41bad01c4f4c7c64e670394ffd607937fc3/src/properties/Dimensions.coffee", "line_start": 1, "line_end": 50}1051{"id": "gss/engine:src/properties/Dimensions.coffee:1:completion", "type": "completion", "prompt": "class Dimensions\n # Global variables managed by the engine\n\n\n '::window':\n\n width: ->\n return window.innerWidth\n\n height: ->\n return window.innerHeight\n\n #right: '::window[width]'\n #bottom: '::window[height]'\n #\n #center:\n # x: ->\n # return window.innerWidth / 2\n #\n # y: ->\n # return window.innerHeight / 2\n\n scroll:", "response": "left: ->\n return window.pageXOffset || document.documentElement.scrollLeft || document.body.scrollLeft\n\n top: ->\n return window.pageYOffset || document.documentElement.scrollTop || document.body.scrollTop\n\n x: 0\n y: 0\n\n '::document':\n\n scroll:\n left: '::window[scroll-left]'\n top: '::window[scroll-top]'\n\n x: '::window[x]'\n y: '::window[y]'\n\n intrinsic:\n\n height: (element) ->\n return# element.offsetHeight\n\n width: (element) ->\n return# element.offsetWidth", "source_lang": "CoffeeScript", "target_lang": "CoffeeScript", "repo": "gss/engine", "path": "src/properties/Dimensions.coffee", "license": "MIT", "commit": "6a58b41bad01c4f4c7c64e670394ffd607937fc3", "stars": 2854, "source_url": "https://github.com/gss/engine/blob/6a58b41bad01c4f4c7c64e670394ffd607937fc3/src/properties/Dimensions.coffee", "line_start": 1, "line_end": 50}1052{"id": "gss/engine:src/properties/Dimensions.coffee:1:raw_corpus", "type": "raw_corpus", "prompt": "", "response": "class Dimensions\n # Global variables managed by the engine\n\n\n '::window':\n\n width: ->\n return window.innerWidth\n\n height: ->\n return window.innerHeight\n\n #right: '::window[width]'\n #bottom: '::window[height]'\n #\n #center:\n # x: ->\n # return window.innerWidth / 2\n #\n # y: ->\n # return window.innerHeight / 2\n\n scroll:\n\n left: ->\n return window.pageXOffset || document.documentElement.scrollLeft || document.body.scrollLeft\n\n top: ->\n return window.pageYOffset || document.documentElement.scrollTop || document.body.scrollTop\n\n x: 0\n y: 0\n\n '::document':\n\n scroll:\n left: '::window[scroll-left]'\n top: '::window[scroll-top]'\n\n x: '::window[x]'\n y: '::window[y]'\n\n intrinsic:\n\n height: (element) ->\n return element.offsetHeight\n\n width: (element) ->\n return element.offsetWidth", "source_lang": "", "target_lang": "CoffeeScript", "repo": "gss/engine", "path": "src/properties/Dimensions.coffee", "license": "MIT", "commit": "527308fd09ab6b18a30ad7b6194f0fd00f872647", "stars": 2854, "source_url": "https://github.com/gss/engine/blob/527308fd09ab6b18a30ad7b6194f0fd00f872647/src/properties/Dimensions.coffee", "line_start": 1, "line_end": 50}1053{"id": "gss/engine:src/properties/Dimensions.coffee:1:coffee_to_js", "type": "coffee_to_js", "prompt": "Convert this CoffeeScript to JavaScript.\n```coffeescript\nclass Dimensions\n # Global variables managed by the engine\n\n\n '::window':\n\n width: ->\n return window.innerWidth\n\n height: ->\n return window.innerHeight\n\n #right: '::window[width]'\n #bottom: '::window[height]'\n #\n #center:\n # x: ->\n # return window.innerWidth / 2\n #\n # y: ->\n # return window.innerHeight / 2\n\n scroll:\n\n left: ->\n return window.pageXOffset || document.documentElement.scrollLeft || document.body.scrollLeft\n\n top: ->\n return window.pageYOffset || document.documentElement.scrollTop || document.body.scrollTop\n\n x: 0\n y: 0\n\n '::document':\n\n scroll:\n left: '::window[scroll-left]'\n top: '::window[scroll-top]'\n\n x: '::window[x]'\n y: '::window[y]'\n\n intrinsic:\n\n height: (element) ->\n return element.offsetHeight\n\n width: (element) ->\n return element.offsetWidth\n```", "response": "var Dimensions;\n\nDimensions = (function() {\n class Dimensions {};\n\n // Global variables managed by the engine\n Dimensions.prototype['::window'] = {\n width: function() {\n return window.innerWidth;\n },\n height: function() {\n return window.innerHeight;\n },\n //right: '::window[width]'\n //bottom: '::window[height]'\n\n //center:\n // x: ->\n // return window.innerWidth / 2\n\n // y: ->\n // return window.innerHeight / 2\n scroll: {\n left: function() {\n return window.pageXOffset || document.documentElement.scrollLeft || document.body.scrollLeft;\n },\n top: function() {\n return window.pageYOffset || document.documentElement.scrollTop || document.body.scrollTop;\n }\n },\n x: 0,\n y: 0\n };\n\n Dimensions.prototype['::document'] = {\n scroll: {\n left: '::window[scroll-left]',\n top: '::window[scroll-top]'\n },\n x: '::window[x]',\n y: '::window[y]'\n };\n\n Dimensions.prototype.intrinsic = {\n height: function(element) {\n return element.offsetHeight;\n },\n width: function(element) {\n return element.offsetWidth;\n }\n };\n\n return Dimensions;\n\n}).call(this);", "source_lang": "CoffeeScript", "target_lang": "JavaScript", "repo": "gss/engine", "path": "src/properties/Dimensions.coffee", "license": "MIT", "commit": "527308fd09ab6b18a30ad7b6194f0fd00f872647", "stars": 2854, "source_url": "https://github.com/gss/engine/blob/527308fd09ab6b18a30ad7b6194f0fd00f872647/src/properties/Dimensions.coffee", "line_start": 1, "line_end": 50}1054{"id": "gss/engine:src/properties/Dimensions.coffee:1:js_to_coffee", "type": "js_to_coffee", "prompt": "Convert this JavaScript to CoffeeScript.\n```javascript\nvar Dimensions;\n\nDimensions = (function() {\n class Dimensions {};\n\n // Global variables managed by the engine\n Dimensions.prototype['::window'] = {\n width: function() {\n return window.innerWidth;\n },\n height: function() {\n return window.innerHeight;\n },\n //right: '::window[width]'\n //bottom: '::window[height]'\n\n //center:\n // x: ->\n // return window.innerWidth / 2\n\n // y: ->\n // return window.innerHeight / 2\n scroll: {\n left: function() {\n return window.pageXOffset || document.documentElement.scrollLeft || document.body.scrollLeft;\n },\n top: function() {\n return window.pageYOffset || document.documentElement.scrollTop || document.body.scrollTop;\n }\n },\n x: 0,\n y: 0\n };\n\n Dimensions.prototype['::document'] = {\n scroll: {\n left: '::window[scroll-left]',\n top: '::window[scroll-top]'\n },\n x: '::window[x]',\n y: '::window[y]'\n };\n\n Dimensions.prototype.intrinsic = {\n height: function(element) {\n return element.offsetHeight;\n },\n width: function(element) {\n return element.offsetWidth;\n }\n };\n\n return Dimensions;\n\n}).call(this);\n```", "response": "class Dimensions\n # Global variables managed by the engine\n\n\n '::window':\n\n width: ->\n return window.innerWidth\n\n height: ->\n return window.innerHeight\n\n #right: '::window[width]'\n #bottom: '::window[height]'\n #\n #center:\n # x: ->\n # return window.innerWidth / 2\n #\n # y: ->\n # return window.innerHeight / 2\n\n scroll:\n\n left: ->\n return window.pageXOffset || document.documentElement.scrollLeft || document.body.scrollLeft\n\n top: ->\n return window.pageYOffset || document.documentElement.scrollTop || document.body.scrollTop\n\n x: 0\n y: 0\n\n '::document':\n\n scroll:\n left: '::window[scroll-left]'\n top: '::window[scroll-top]'\n\n x: '::window[x]'\n y: '::window[y]'\n\n intrinsic:\n\n height: (element) ->\n return element.offsetHeight\n\n width: (element) ->\n return element.offsetWidth", "source_lang": "JavaScript", "target_lang": "CoffeeScript", "repo": "gss/engine", "path": "src/properties/Dimensions.coffee", "license": "MIT", "commit": "527308fd09ab6b18a30ad7b6194f0fd00f872647", "stars": 2854, "source_url": "https://github.com/gss/engine/blob/527308fd09ab6b18a30ad7b6194f0fd00f872647/src/properties/Dimensions.coffee", "line_start": 1, "line_end": 50}1055{"id": "gss/engine:src/properties/Dimensions.coffee:1:completion", "type": "completion", "prompt": "class Dimensions\n # Global variables managed by the engine\n\n\n '::window':\n\n width: ->\n return window.innerWidth\n\n height: ->\n return window.innerHeight\n\n #right: '::window[width]'\n #bottom: '::window[height]'\n #\n #center:\n # x: ->\n # return window.innerWidth / 2\n #\n # y: ->\n # return window.innerHeight / 2\n\n scroll:", "response": "left: ->\n return window.pageXOffset || document.documentElement.scrollLeft || document.body.scrollLeft\n\n top: ->\n return window.pageYOffset || document.documentElement.scrollTop || document.body.scrollTop\n\n x: 0\n y: 0\n\n '::document':\n\n scroll:\n left: '::window[scroll-left]'\n top: '::window[scroll-top]'\n\n x: '::window[x]'\n y: '::window[y]'\n\n intrinsic:\n\n height: (element) ->\n return element.offsetHeight\n\n width: (element) ->\n return element.offsetWidth", "source_lang": "CoffeeScript", "target_lang": "CoffeeScript", "repo": "gss/engine", "path": "src/properties/Dimensions.coffee", "license": "MIT", "commit": "527308fd09ab6b18a30ad7b6194f0fd00f872647", "stars": 2854, "source_url": "https://github.com/gss/engine/blob/527308fd09ab6b18a30ad7b6194f0fd00f872647/src/properties/Dimensions.coffee", "line_start": 1, "line_end": 50}1056{"id": "oozcitak/xmlbuilder-js:test/basic/tostring.coffee:1:raw_corpus", "type": "raw_corpus", "prompt": "", "response": "suite 'Test toString() function with built-in XML writer:', ->\n test 'Nodes', ->\n eq xml('root').doc().toString(), '<?xml version=\"1.0\"?><root/>'\n eq xml('root').toString(), '<root/>'\n eq xml('root').att('att', 'val').attribs['att'].toString(), ' att=\"val\"'\n eq xml('root').dat('val').children[0].toString(), '<![CDATA[val]]>'\n eq xml('root').com('val').children[0].toString(), '<!-- val -->'\n eq xml('root').ins('target', 'val').children[0].toString(), '<?target val?>'\n eq xml('root').raw('val').children[0].toString(), 'val'\n eq xml('root').text('val').children[0].toString(), 'val'\n\n test 'DTD', ->\n eq(\n xml('root').dtd({pubID: 'pub', sysID: 'sys'}).toString()\n '<!DOCTYPE root PUBLIC \"pub\" \"sys\">'\n )\n eq(\n xml('root').dtd().att('img', 'visible', '(yes|no)', '#DEFAULT', \"yes\").children[0].toString()\n '<!ATTLIST img visible (yes|no) \"yes\">'\n )\n eq(\n xml('root').dtd().ele('img', 'EMPTY').children[0].toString()\n '<!ELEMENT img EMPTY>'\n )\n eq(\n xml('root').dtd().ent('ent', 'my val').children[0].toString()\n '<!ENTITY ent \"my val\">'\n )\n eq(\n xml('root').dtd().not('fs', { sysID: 'http://my.fs.com/reader' }).children[0].toString()\n '<!NOTATION fs SYSTEM \"http://my.fs.com/reader\">'\n )\n\n test 'XML Declaration', ->\n eq(\n xml('root').dec().doc().children[0].toString()\n '<?xml version=\"1.0\"?>'\n )", "source_lang": "", "target_lang": "CoffeeScript", "repo": "oozcitak/xmlbuilder-js", "path": "test/basic/tostring.coffee", "license": "MIT", "commit": "ce625aeb9f52d1f75d5d94260794d3b5fd74a8b1", "stars": 926, "source_url": "https://github.com/oozcitak/xmlbuilder-js/blob/ce625aeb9f52d1f75d5d94260794d3b5fd74a8b1/test/basic/tostring.coffee", "line_start": 1, "line_end": 38}1057{"id": "oozcitak/xmlbuilder-js:test/basic/tostring.coffee:1:coffee_to_js", "type": "coffee_to_js", "prompt": "Convert this CoffeeScript to JavaScript.\n```coffeescript\nsuite 'Test toString() function with built-in XML writer:', ->\n test 'Nodes', ->\n eq xml('root').doc().toString(), '<?xml version=\"1.0\"?><root/>'\n eq xml('root').toString(), '<root/>'\n eq xml('root').att('att', 'val').attribs['att'].toString(), ' att=\"val\"'\n eq xml('root').dat('val').children[0].toString(), '<![CDATA[val]]>'\n eq xml('root').com('val').children[0].toString(), '<!-- val -->'\n eq xml('root').ins('target', 'val').children[0].toString(), '<?target val?>'\n eq xml('root').raw('val').children[0].toString(), 'val'\n eq xml('root').text('val').children[0].toString(), 'val'\n\n test 'DTD', ->\n eq(\n xml('root').dtd({pubID: 'pub', sysID: 'sys'}).toString()\n '<!DOCTYPE root PUBLIC \"pub\" \"sys\">'\n )\n eq(\n xml('root').dtd().att('img', 'visible', '(yes|no)', '#DEFAULT', \"yes\").children[0].toString()\n '<!ATTLIST img visible (yes|no) \"yes\">'\n )\n eq(\n xml('root').dtd().ele('img', 'EMPTY').children[0].toString()\n '<!ELEMENT img EMPTY>'\n )\n eq(\n xml('root').dtd().ent('ent', 'my val').children[0].toString()\n '<!ENTITY ent \"my val\">'\n )\n eq(\n xml('root').dtd().not('fs', { sysID: 'http://my.fs.com/reader' }).children[0].toString()\n '<!NOTATION fs SYSTEM \"http://my.fs.com/reader\">'\n )\n\n test 'XML Declaration', ->\n eq(\n xml('root').dec().doc().children[0].toString()\n '<?xml version=\"1.0\"?>'\n )\n```", "response": "suite('Test toString() function with built-in XML writer:', function() {\n test('Nodes', function() {\n eq(xml('root').doc().toString(), '<?xml version=\"1.0\"?><root/>');\n eq(xml('root').toString(), '<root/>');\n eq(xml('root').att('att', 'val').attribs['att'].toString(), ' att=\"val\"');\n eq(xml('root').dat('val').children[0].toString(), '<![CDATA[val]]>');\n eq(xml('root').com('val').children[0].toString(), '<!-- val -->');\n eq(xml('root').ins('target', 'val').children[0].toString(), '<?target val?>');\n eq(xml('root').raw('val').children[0].toString(), 'val');\n return eq(xml('root').text('val').children[0].toString(), 'val');\n });\n test('DTD', function() {\n eq(xml('root').dtd({\n pubID: 'pub',\n sysID: 'sys'\n }).toString(), '<!DOCTYPE root PUBLIC \"pub\" \"sys\">');\n eq(xml('root').dtd().att('img', 'visible', '(yes|no)', '#DEFAULT', \"yes\").children[0].toString(), '<!ATTLIST img visible (yes|no) \"yes\">');\n eq(xml('root').dtd().ele('img', 'EMPTY').children[0].toString(), '<!ELEMENT img EMPTY>');\n eq(xml('root').dtd().ent('ent', 'my val').children[0].toString(), '<!ENTITY ent \"my val\">');\n return eq(xml('root').dtd().not('fs', {\n sysID: 'http://my.fs.com/reader'\n }).children[0].toString(), '<!NOTATION fs SYSTEM \"http://my.fs.com/reader\">');\n });\n return test('XML Declaration', function() {\n return eq(xml('root').dec().doc().children[0].toString(), '<?xml version=\"1.0\"?>');\n });\n});", "source_lang": "CoffeeScript", "target_lang": "JavaScript", "repo": "oozcitak/xmlbuilder-js", "path": "test/basic/tostring.coffee", "license": "MIT", "commit": "ce625aeb9f52d1f75d5d94260794d3b5fd74a8b1", "stars": 926, "source_url": "https://github.com/oozcitak/xmlbuilder-js/blob/ce625aeb9f52d1f75d5d94260794d3b5fd74a8b1/test/basic/tostring.coffee", "line_start": 1, "line_end": 38}1058{"id": "oozcitak/xmlbuilder-js:test/basic/tostring.coffee:1:js_to_coffee", "type": "js_to_coffee", "prompt": "Convert this JavaScript to CoffeeScript.\n```javascript\nsuite('Test toString() function with built-in XML writer:', function() {\n test('Nodes', function() {\n eq(xml('root').doc().toString(), '<?xml version=\"1.0\"?><root/>');\n eq(xml('root').toString(), '<root/>');\n eq(xml('root').att('att', 'val').attribs['att'].toString(), ' att=\"val\"');\n eq(xml('root').dat('val').children[0].toString(), '<![CDATA[val]]>');\n eq(xml('root').com('val').children[0].toString(), '<!-- val -->');\n eq(xml('root').ins('target', 'val').children[0].toString(), '<?target val?>');\n eq(xml('root').raw('val').children[0].toString(), 'val');\n return eq(xml('root').text('val').children[0].toString(), 'val');\n });\n test('DTD', function() {\n eq(xml('root').dtd({\n pubID: 'pub',\n sysID: 'sys'\n }).toString(), '<!DOCTYPE root PUBLIC \"pub\" \"sys\">');\n eq(xml('root').dtd().att('img', 'visible', '(yes|no)', '#DEFAULT', \"yes\").children[0].toString(), '<!ATTLIST img visible (yes|no) \"yes\">');\n eq(xml('root').dtd().ele('img', 'EMPTY').children[0].toString(), '<!ELEMENT img EMPTY>');\n eq(xml('root').dtd().ent('ent', 'my val').children[0].toString(), '<!ENTITY ent \"my val\">');\n return eq(xml('root').dtd().not('fs', {\n sysID: 'http://my.fs.com/reader'\n }).children[0].toString(), '<!NOTATION fs SYSTEM \"http://my.fs.com/reader\">');\n });\n return test('XML Declaration', function() {\n return eq(xml('root').dec().doc().children[0].toString(), '<?xml version=\"1.0\"?>');\n });\n});\n```", "response": "suite 'Test toString() function with built-in XML writer:', ->\n test 'Nodes', ->\n eq xml('root').doc().toString(), '<?xml version=\"1.0\"?><root/>'\n eq xml('root').toString(), '<root/>'\n eq xml('root').att('att', 'val').attribs['att'].toString(), ' att=\"val\"'\n eq xml('root').dat('val').children[0].toString(), '<![CDATA[val]]>'\n eq xml('root').com('val').children[0].toString(), '<!-- val -->'\n eq xml('root').ins('target', 'val').children[0].toString(), '<?target val?>'\n eq xml('root').raw('val').children[0].toString(), 'val'\n eq xml('root').text('val').children[0].toString(), 'val'\n\n test 'DTD', ->\n eq(\n xml('root').dtd({pubID: 'pub', sysID: 'sys'}).toString()\n '<!DOCTYPE root PUBLIC \"pub\" \"sys\">'\n )\n eq(\n xml('root').dtd().att('img', 'visible', '(yes|no)', '#DEFAULT', \"yes\").children[0].toString()\n '<!ATTLIST img visible (yes|no) \"yes\">'\n )\n eq(\n xml('root').dtd().ele('img', 'EMPTY').children[0].toString()\n '<!ELEMENT img EMPTY>'\n )\n eq(\n xml('root').dtd().ent('ent', 'my val').children[0].toString()\n '<!ENTITY ent \"my val\">'\n )\n eq(\n xml('root').dtd().not('fs', { sysID: 'http://my.fs.com/reader' }).children[0].toString()\n '<!NOTATION fs SYSTEM \"http://my.fs.com/reader\">'\n )\n\n test 'XML Declaration', ->\n eq(\n xml('root').dec().doc().children[0].toString()\n '<?xml version=\"1.0\"?>'\n )", "source_lang": "JavaScript", "target_lang": "CoffeeScript", "repo": "oozcitak/xmlbuilder-js", "path": "test/basic/tostring.coffee", "license": "MIT", "commit": "ce625aeb9f52d1f75d5d94260794d3b5fd74a8b1", "stars": 926, "source_url": "https://github.com/oozcitak/xmlbuilder-js/blob/ce625aeb9f52d1f75d5d94260794d3b5fd74a8b1/test/basic/tostring.coffee", "line_start": 1, "line_end": 38}1059{"id": "oozcitak/xmlbuilder-js:test/basic/tostring.coffee:1:completion", "type": "completion", "prompt": "suite 'Test toString() function with built-in XML writer:', ->\n test 'Nodes', ->\n eq xml('root').doc().toString(), '<?xml version=\"1.0\"?><root/>'\n eq xml('root').toString(), '<root/>'\n eq xml('root').att('att', 'val').attribs['att'].toString(), ' att=\"val\"'\n eq xml('root').dat('val').children[0].toString(), '<![CDATA[val]]>'\n eq xml('root').com('val').children[0].toString(), '<!-- val -->'\n eq xml('root').ins('target', 'val').children[0].toString(), '<?target val?>'\n eq xml('root').raw('val').children[0].toString(), 'val'\n eq xml('root').text('val').children[0].toString(), 'val'\n\n test 'DTD', ->\n eq(\n xml('root').dtd({pubID: 'pub', sysID: 'sys'}).toString()\n '<!DOCTYPE root PUBLIC \"pub\" \"sys\">'\n )\n eq(\n xml('root').dtd().att('img', 'visible', '(yes|no)', '#DEFAULT', \"yes\").children[0].toString()\n '<!ATTLIST img visible (yes|no) \"yes\">'", "response": ")\n eq(\n xml('root').dtd().ele('img', 'EMPTY').children[0].toString()\n '<!ELEMENT img EMPTY>'\n )\n eq(\n xml('root').dtd().ent('ent', 'my val').children[0].toString()\n '<!ENTITY ent \"my val\">'\n )\n eq(\n xml('root').dtd().not('fs', { sysID: 'http://my.fs.com/reader' }).children[0].toString()\n '<!NOTATION fs SYSTEM \"http://my.fs.com/reader\">'\n )\n\n test 'XML Declaration', ->\n eq(\n xml('root').dec().doc().children[0].toString()\n '<?xml version=\"1.0\"?>'\n )", "source_lang": "CoffeeScript", "target_lang": "CoffeeScript", "repo": "oozcitak/xmlbuilder-js", "path": "test/basic/tostring.coffee", "license": "MIT", "commit": "ce625aeb9f52d1f75d5d94260794d3b5fd74a8b1", "stars": 926, "source_url": "https://github.com/oozcitak/xmlbuilder-js/blob/ce625aeb9f52d1f75d5d94260794d3b5fd74a8b1/test/basic/tostring.coffee", "line_start": 1, "line_end": 38}1060{"id": "gterrono/houston:lib/collections.coffee:1:raw_corpus", "type": "raw_corpus", "prompt": "", "response": "root = exports ? this\n\nroot.Houston ?= {}\n\nHouston._collections ?= {}\n\nHouston._collections.collections = new Meteor.Collection('houston_collections')\n\nHouston._admins = new Meteor.Collection('houston_admins')\n\nHouston._user_is_admin = (id) ->\n return id? and Houston._admins.findOne user_id: id", "source_lang": "", "target_lang": "CoffeeScript", "repo": "gterrono/houston", "path": "lib/collections.coffee", "license": "MIT", "commit": "581357048f3577f0487ed598e26eaf063c813183", "stars": 802, "source_url": "https://github.com/gterrono/houston/blob/581357048f3577f0487ed598e26eaf063c813183/lib/collections.coffee", "line_start": 1, "line_end": 12}1061{"id": "gterrono/houston:lib/collections.coffee:1:coffee_to_js", "type": "coffee_to_js", "prompt": "Convert this CoffeeScript to JavaScript.\n```coffeescript\nroot = exports ? this\n\nroot.Houston ?= {}\n\nHouston._collections ?= {}\n\nHouston._collections.collections = new Meteor.Collection('houston_collections')\n\nHouston._admins = new Meteor.Collection('houston_admins')\n\nHouston._user_is_admin = (id) ->\n return id? and Houston._admins.findOne user_id: id\n```", "response": "var root;\n\nroot = typeof exports !== \"undefined\" && exports !== null ? exports : this;\n\nif (root.Houston == null) {\n root.Houston = {};\n}\n\nif (Houston._collections == null) {\n Houston._collections = {};\n}\n\nHouston._collections.collections = new Meteor.Collection('houston_collections');\n\nHouston._admins = new Meteor.Collection('houston_admins');\n\nHouston._user_is_admin = function(id) {\n return (id != null) && Houston._admins.findOne({\n user_id: id\n });\n};", "source_lang": "CoffeeScript", "target_lang": "JavaScript", "repo": "gterrono/houston", "path": "lib/collections.coffee", "license": "MIT", "commit": "581357048f3577f0487ed598e26eaf063c813183", "stars": 802, "source_url": "https://github.com/gterrono/houston/blob/581357048f3577f0487ed598e26eaf063c813183/lib/collections.coffee", "line_start": 1, "line_end": 12}1062{"id": "gterrono/houston:lib/collections.coffee:1:js_to_coffee", "type": "js_to_coffee", "prompt": "Convert this JavaScript to CoffeeScript.\n```javascript\nvar root;\n\nroot = typeof exports !== \"undefined\" && exports !== null ? exports : this;\n\nif (root.Houston == null) {\n root.Houston = {};\n}\n\nif (Houston._collections == null) {\n Houston._collections = {};\n}\n\nHouston._collections.collections = new Meteor.Collection('houston_collections');\n\nHouston._admins = new Meteor.Collection('houston_admins');\n\nHouston._user_is_admin = function(id) {\n return (id != null) && Houston._admins.findOne({\n user_id: id\n });\n};\n```", "response": "root = exports ? this\n\nroot.Houston ?= {}\n\nHouston._collections ?= {}\n\nHouston._collections.collections = new Meteor.Collection('houston_collections')\n\nHouston._admins = new Meteor.Collection('houston_admins')\n\nHouston._user_is_admin = (id) ->\n return id? and Houston._admins.findOne user_id: id", "source_lang": "JavaScript", "target_lang": "CoffeeScript", "repo": "gterrono/houston", "path": "lib/collections.coffee", "license": "MIT", "commit": "581357048f3577f0487ed598e26eaf063c813183", "stars": 802, "source_url": "https://github.com/gterrono/houston/blob/581357048f3577f0487ed598e26eaf063c813183/lib/collections.coffee", "line_start": 1, "line_end": 12}1063{"id": "gterrono/houston:lib/collections.coffee:1:completion", "type": "completion", "prompt": "root = exports ? this\n\nroot.Houston ?= {}\n\nHouston._collections ?= {}", "response": "Houston._collections.collections = new Meteor.Collection('houston_collections')\n\nHouston._admins = new Meteor.Collection('houston_admins')\n\nHouston._user_is_admin = (id) ->\n return id? and Houston._admins.findOne user_id: id", "source_lang": "CoffeeScript", "target_lang": "CoffeeScript", "repo": "gterrono/houston", "path": "lib/collections.coffee", "license": "MIT", "commit": "581357048f3577f0487ed598e26eaf063c813183", "stars": 802, "source_url": "https://github.com/gterrono/houston/blob/581357048f3577f0487ed598e26eaf063c813183/lib/collections.coffee", "line_start": 1, "line_end": 12}1064{"id": "ExpediaGroup/cyclotron:cyclotron-site/app/scripts/mgmt/directives/directives.propertyTable.coffee:1:raw_corpus", "type": "raw_corpus", "prompt": "", "response": "###\n# Copyright (c) 2013-2018 the original author or authors.\n#\n# Licensed under the MIT License (the \"License\");\n# you may not use this file except in compliance with the License.\n# You may obtain a copy of the License at\n#\n# http://www.opensource.org/licenses/mit-license.php\n#\n# Unless required by applicable law or agreed to in writing,\n# software distributed under the License is distributed on an\n# \"AS IS\" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND,\n# either express or implied. See the License for the specific\n# language governing permissions and limitations under the License.\n###\n\ncyclotronDirectives.directive 'propertyTable', ->\n {\n restrict: 'EAC'\n scope:\n properties: '='\n templateUrl: 'partials/help/propertyTable.html'\n\n link: (scope, element, attrs) ->\n return\n }", "source_lang": "", "target_lang": "CoffeeScript", "repo": "ExpediaGroup/cyclotron", "path": "cyclotron-site/app/scripts/mgmt/directives/directives.propertyTable.coffee", "license": "MIT", "commit": "0228db71d84a3138a9ffddb50d8f4f8ff37cc5ab", "stars": 1544, "source_url": "https://github.com/ExpediaGroup/cyclotron/blob/0228db71d84a3138a9ffddb50d8f4f8ff37cc5ab/cyclotron-site/app/scripts/mgmt/directives/directives.propertyTable.coffee", "line_start": 1, "line_end": 26}1065{"id": "ExpediaGroup/cyclotron:cyclotron-site/app/scripts/mgmt/directives/directives.propertyTable.coffee:1:coffee_to_js", "type": "coffee_to_js", "prompt": "Convert this CoffeeScript to JavaScript.\n```coffeescript\n###\n# Copyright (c) 2013-2018 the original author or authors.\n#\n# Licensed under the MIT License (the \"License\");\n# you may not use this file except in compliance with the License.\n# You may obtain a copy of the License at\n#\n# http://www.opensource.org/licenses/mit-license.php\n#\n# Unless required by applicable law or agreed to in writing,\n# software distributed under the License is distributed on an\n# \"AS IS\" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND,\n# either express or implied. See the License for the specific\n# language governing permissions and limitations under the License.\n###\n\ncyclotronDirectives.directive 'propertyTable', ->\n {\n restrict: 'EAC'\n scope:\n properties: '='\n templateUrl: 'partials/help/propertyTable.html'\n\n link: (scope, element, attrs) ->\n return\n }\n```", "response": "/*\n * Copyright (c) 2013-2018 the original author or authors.\n *\n * Licensed under the MIT License (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.opensource.org/licenses/mit-license.php\n *\n * Unless required by applicable law or agreed to in writing,\n * software distributed under the License is distributed on an\n * \"AS IS\" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND,\n * either express or implied. See the License for the specific\n * language governing permissions and limitations under the License.\n */\ncyclotronDirectives.directive('propertyTable', function() {\n return {\n restrict: 'EAC',\n scope: {\n properties: '='\n },\n templateUrl: 'partials/help/propertyTable.html',\n link: function(scope, element, attrs) {}\n };\n});", "source_lang": "CoffeeScript", "target_lang": "JavaScript", "repo": "ExpediaGroup/cyclotron", "path": "cyclotron-site/app/scripts/mgmt/directives/directives.propertyTable.coffee", "license": "MIT", "commit": "0228db71d84a3138a9ffddb50d8f4f8ff37cc5ab", "stars": 1544, "source_url": "https://github.com/ExpediaGroup/cyclotron/blob/0228db71d84a3138a9ffddb50d8f4f8ff37cc5ab/cyclotron-site/app/scripts/mgmt/directives/directives.propertyTable.coffee", "line_start": 1, "line_end": 26}1066{"id": "ExpediaGroup/cyclotron:cyclotron-site/app/scripts/mgmt/directives/directives.propertyTable.coffee:1:js_to_coffee", "type": "js_to_coffee", "prompt": "Convert this JavaScript to CoffeeScript.\n```javascript\n/*\n * Copyright (c) 2013-2018 the original author or authors.\n *\n * Licensed under the MIT License (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.opensource.org/licenses/mit-license.php\n *\n * Unless required by applicable law or agreed to in writing,\n * software distributed under the License is distributed on an\n * \"AS IS\" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND,\n * either express or implied. See the License for the specific\n * language governing permissions and limitations under the License.\n */\ncyclotronDirectives.directive('propertyTable', function() {\n return {\n restrict: 'EAC',\n scope: {\n properties: '='\n },\n templateUrl: 'partials/help/propertyTable.html',\n link: function(scope, element, attrs) {}\n };\n});\n```", "response": "###\n# Copyright (c) 2013-2018 the original author or authors.\n#\n# Licensed under the MIT License (the \"License\");\n# you may not use this file except in compliance with the License.\n# You may obtain a copy of the License at\n#\n# http://www.opensource.org/licenses/mit-license.php\n#\n# Unless required by applicable law or agreed to in writing,\n# software distributed under the License is distributed on an\n# \"AS IS\" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND,\n# either express or implied. See the License for the specific\n# language governing permissions and limitations under the License.\n###\n\ncyclotronDirectives.directive 'propertyTable', ->\n {\n restrict: 'EAC'\n scope:\n properties: '='\n templateUrl: 'partials/help/propertyTable.html'\n\n link: (scope, element, attrs) ->\n return\n }", "source_lang": "JavaScript", "target_lang": "CoffeeScript", "repo": "ExpediaGroup/cyclotron", "path": "cyclotron-site/app/scripts/mgmt/directives/directives.propertyTable.coffee", "license": "MIT", "commit": "0228db71d84a3138a9ffddb50d8f4f8ff37cc5ab", "stars": 1544, "source_url": "https://github.com/ExpediaGroup/cyclotron/blob/0228db71d84a3138a9ffddb50d8f4f8ff37cc5ab/cyclotron-site/app/scripts/mgmt/directives/directives.propertyTable.coffee", "line_start": 1, "line_end": 26}1067{"id": "ExpediaGroup/cyclotron:cyclotron-site/app/scripts/mgmt/directives/directives.propertyTable.coffee:1:completion", "type": "completion", "prompt": "###\n# Copyright (c) 2013-2018 the original author or authors.\n#\n# Licensed under the MIT License (the \"License\");\n# you may not use this file except in compliance with the License.\n# You may obtain a copy of the License at\n#\n# http://www.opensource.org/licenses/mit-license.php\n#\n# Unless required by applicable law or agreed to in writing,\n# software distributed under the License is distributed on an\n# \"AS IS\" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND,\n# either express or implied. See the License for the specific", "response": "# language governing permissions and limitations under the License.\n###\n\ncyclotronDirectives.directive 'propertyTable', ->\n {\n restrict: 'EAC'\n scope:\n properties: '='\n templateUrl: 'partials/help/propertyTable.html'\n\n link: (scope, element, attrs) ->\n return\n }", "source_lang": "CoffeeScript", "target_lang": "CoffeeScript", "repo": "ExpediaGroup/cyclotron", "path": "cyclotron-site/app/scripts/mgmt/directives/directives.propertyTable.coffee", "license": "MIT", "commit": "0228db71d84a3138a9ffddb50d8f4f8ff37cc5ab", "stars": 1544, "source_url": "https://github.com/ExpediaGroup/cyclotron/blob/0228db71d84a3138a9ffddb50d8f4f8ff37cc5ab/cyclotron-site/app/scripts/mgmt/directives/directives.propertyTable.coffee", "line_start": 1, "line_end": 26}1068{"id": "ExpediaGroup/cyclotron:cyclotron-site/app/scripts/mgmt/directives/directives.propertyTable.coffee:1:raw_corpus", "type": "raw_corpus", "prompt": "", "response": "###\n# Copyright (c) 2013-2015 the original author or authors.\n#\n# Licensed under the MIT License (the \"License\");\n# you may not use this file except in compliance with the License.\n# You may obtain a copy of the License at\n#\n# http://www.opensource.org/licenses/mit-license.php\n#\n# Unless required by applicable law or agreed to in writing,\n# software distributed under the License is distributed on an\n# \"AS IS\" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND,\n# either express or implied. See the License for the specific\n# language governing permissions and limitations under the License.\n###\n\ncyclotronDirectives.directive 'propertyTable', ->\n {\n restrict: 'EAC'\n scope:\n properties: '='\n templateUrl: 'partials/help/propertyTable.html'\n\n link: (scope, element, attrs) ->\n return\n }", "source_lang": "", "target_lang": "CoffeeScript", "repo": "ExpediaGroup/cyclotron", "path": "cyclotron-site/app/scripts/mgmt/directives/directives.propertyTable.coffee", "license": "MIT", "commit": "14b0e411415be801f94fe13ea6f63d5ad957c2ed", "stars": 1544, "source_url": "https://github.com/ExpediaGroup/cyclotron/blob/14b0e411415be801f94fe13ea6f63d5ad957c2ed/cyclotron-site/app/scripts/mgmt/directives/directives.propertyTable.coffee", "line_start": 1, "line_end": 26}1069{"id": "ExpediaGroup/cyclotron:cyclotron-site/app/scripts/mgmt/directives/directives.propertyTable.coffee:1:coffee_to_js", "type": "coffee_to_js", "prompt": "Convert this CoffeeScript to JavaScript.\n```coffeescript\n###\n# Copyright (c) 2013-2015 the original author or authors.\n#\n# Licensed under the MIT License (the \"License\");\n# you may not use this file except in compliance with the License.\n# You may obtain a copy of the License at\n#\n# http://www.opensource.org/licenses/mit-license.php\n#\n# Unless required by applicable law or agreed to in writing,\n# software distributed under the License is distributed on an\n# \"AS IS\" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND,\n# either express or implied. See the License for the specific\n# language governing permissions and limitations under the License.\n###\n\ncyclotronDirectives.directive 'propertyTable', ->\n {\n restrict: 'EAC'\n scope:\n properties: '='\n templateUrl: 'partials/help/propertyTable.html'\n\n link: (scope, element, attrs) ->\n return\n }\n```", "response": "/*\n * Copyright (c) 2013-2015 the original author or authors.\n *\n * Licensed under the MIT License (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.opensource.org/licenses/mit-license.php\n *\n * Unless required by applicable law or agreed to in writing,\n * software distributed under the License is distributed on an\n * \"AS IS\" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND,\n * either express or implied. See the License for the specific\n * language governing permissions and limitations under the License.\n */\ncyclotronDirectives.directive('propertyTable', function() {\n return {\n restrict: 'EAC',\n scope: {\n properties: '='\n },\n templateUrl: 'partials/help/propertyTable.html',\n link: function(scope, element, attrs) {}\n };\n});", "source_lang": "CoffeeScript", "target_lang": "JavaScript", "repo": "ExpediaGroup/cyclotron", "path": "cyclotron-site/app/scripts/mgmt/directives/directives.propertyTable.coffee", "license": "MIT", "commit": "14b0e411415be801f94fe13ea6f63d5ad957c2ed", "stars": 1544, "source_url": "https://github.com/ExpediaGroup/cyclotron/blob/14b0e411415be801f94fe13ea6f63d5ad957c2ed/cyclotron-site/app/scripts/mgmt/directives/directives.propertyTable.coffee", "line_start": 1, "line_end": 26}1070{"id": "ExpediaGroup/cyclotron:cyclotron-site/app/scripts/mgmt/directives/directives.propertyTable.coffee:1:js_to_coffee", "type": "js_to_coffee", "prompt": "Convert this JavaScript to CoffeeScript.\n```javascript\n/*\n * Copyright (c) 2013-2015 the original author or authors.\n *\n * Licensed under the MIT License (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.opensource.org/licenses/mit-license.php\n *\n * Unless required by applicable law or agreed to in writing,\n * software distributed under the License is distributed on an\n * \"AS IS\" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND,\n * either express or implied. See the License for the specific\n * language governing permissions and limitations under the License.\n */\ncyclotronDirectives.directive('propertyTable', function() {\n return {\n restrict: 'EAC',\n scope: {\n properties: '='\n },\n templateUrl: 'partials/help/propertyTable.html',\n link: function(scope, element, attrs) {}\n };\n});\n```", "response": "###\n# Copyright (c) 2013-2015 the original author or authors.\n#\n# Licensed under the MIT License (the \"License\");\n# you may not use this file except in compliance with the License.\n# You may obtain a copy of the License at\n#\n# http://www.opensource.org/licenses/mit-license.php\n#\n# Unless required by applicable law or agreed to in writing,\n# software distributed under the License is distributed on an\n# \"AS IS\" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND,\n# either express or implied. See the License for the specific\n# language governing permissions and limitations under the License.\n###\n\ncyclotronDirectives.directive 'propertyTable', ->\n {\n restrict: 'EAC'\n scope:\n properties: '='\n templateUrl: 'partials/help/propertyTable.html'\n\n link: (scope, element, attrs) ->\n return\n }", "source_lang": "JavaScript", "target_lang": "CoffeeScript", "repo": "ExpediaGroup/cyclotron", "path": "cyclotron-site/app/scripts/mgmt/directives/directives.propertyTable.coffee", "license": "MIT", "commit": "14b0e411415be801f94fe13ea6f63d5ad957c2ed", "stars": 1544, "source_url": "https://github.com/ExpediaGroup/cyclotron/blob/14b0e411415be801f94fe13ea6f63d5ad957c2ed/cyclotron-site/app/scripts/mgmt/directives/directives.propertyTable.coffee", "line_start": 1, "line_end": 26}1071{"id": "ExpediaGroup/cyclotron:cyclotron-site/app/scripts/mgmt/directives/directives.propertyTable.coffee:1:completion", "type": "completion", "prompt": "###\n# Copyright (c) 2013-2015 the original author or authors.\n#\n# Licensed under the MIT License (the \"License\");\n# you may not use this file except in compliance with the License.\n# You may obtain a copy of the License at\n#\n# http://www.opensource.org/licenses/mit-license.php\n#\n# Unless required by applicable law or agreed to in writing,\n# software distributed under the License is distributed on an\n# \"AS IS\" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND,\n# either express or implied. See the License for the specific", "response": "# language governing permissions and limitations under the License.\n###\n\ncyclotronDirectives.directive 'propertyTable', ->\n {\n restrict: 'EAC'\n scope:\n properties: '='\n templateUrl: 'partials/help/propertyTable.html'\n\n link: (scope, element, attrs) ->\n return\n }", "source_lang": "CoffeeScript", "target_lang": "CoffeeScript", "repo": "ExpediaGroup/cyclotron", "path": "cyclotron-site/app/scripts/mgmt/directives/directives.propertyTable.coffee", "license": "MIT", "commit": "14b0e411415be801f94fe13ea6f63d5ad957c2ed", "stars": 1544, "source_url": "https://github.com/ExpediaGroup/cyclotron/blob/14b0e411415be801f94fe13ea6f63d5ad957c2ed/cyclotron-site/app/scripts/mgmt/directives/directives.propertyTable.coffee", "line_start": 1, "line_end": 26}1072{"id": "snd/url-pattern:test/util.coffee:1:raw_corpus", "type": "raw_corpus", "prompt": "", "response": "util = require '../src/util'\n\nmodule.exports =\n\n 'getNames':\n\n 'no names': (test) ->\n test.deepEqual [], util.getNames '/foo/bar/baz'\n test.done()\n\n 'one name': (test) ->\n test.deepEqual ['foo'], util.getNames '/foo/:foo/bar/baz'\n test.done()\n\n 'three names': (test) ->\n test.deepEqual ['foo', 'bar', 'baz'], util.getNames '/foo/:foo/bar/:bar/baz/:baz'\n test.done()\n\n 'names with prefix wildcard': (test) ->\n test.deepEqual ['_', 'bar', 'baz'], util.getNames '/foo/*/bar/:bar/baz/:baz'\n test.done()\n\n 'names with infix wildcard': (test) ->\n test.deepEqual ['foo', '_', 'baz'], util.getNames '/foo/:foo/bar/*/baz/:baz'\n test.done()\n\n 'names with postfix wildcard': (test) ->\n test.deepEqual ['foo', 'bar', '_'], util.getNames '/foo/:foo/bar/:bar/baz/*'\n test.done()\n\n 'name _ is disallowed': (test) ->\n test.throws ->\n util.getNames '/foo/:_'\n test.done()\n\n 'duplicate pattern names are disallowed': (test) ->\n test.throws ->\n util.getNames '/:foo/:foo'\n test.done()\n\n 'toRegexString':\n\n '^ and $ are added': (test) ->\n test.equals '^foo$', util.toRegexString 'foo'\n test.done()\n\n '/ are escaped': (test) ->\n test.equals '^/foo$', util.toRegexString '/foo'\n test.done()", "source_lang": "", "target_lang": "CoffeeScript", "repo": "snd/url-pattern", "path": "test/util.coffee", "license": "MIT", "commit": "7a949d79610b4a174753a939303a928b5267633b", "stars": 588, "source_url": "https://github.com/snd/url-pattern/blob/7a949d79610b4a174753a939303a928b5267633b/test/util.coffee", "line_start": 1, "line_end": 50}1073{"id": "snd/url-pattern:test/util.coffee:1:coffee_to_js", "type": "coffee_to_js", "prompt": "Convert this CoffeeScript to JavaScript.\n```coffeescript\nutil = require '../src/util'\n\nmodule.exports =\n\n 'getNames':\n\n 'no names': (test) ->\n test.deepEqual [], util.getNames '/foo/bar/baz'\n test.done()\n\n 'one name': (test) ->\n test.deepEqual ['foo'], util.getNames '/foo/:foo/bar/baz'\n test.done()\n\n 'three names': (test) ->\n test.deepEqual ['foo', 'bar', 'baz'], util.getNames '/foo/:foo/bar/:bar/baz/:baz'\n test.done()\n\n 'names with prefix wildcard': (test) ->\n test.deepEqual ['_', 'bar', 'baz'], util.getNames '/foo/*/bar/:bar/baz/:baz'\n test.done()\n\n 'names with infix wildcard': (test) ->\n test.deepEqual ['foo', '_', 'baz'], util.getNames '/foo/:foo/bar/*/baz/:baz'\n test.done()\n\n 'names with postfix wildcard': (test) ->\n test.deepEqual ['foo', 'bar', '_'], util.getNames '/foo/:foo/bar/:bar/baz/*'\n test.done()\n\n 'name _ is disallowed': (test) ->\n test.throws ->\n util.getNames '/foo/:_'\n test.done()\n\n 'duplicate pattern names are disallowed': (test) ->\n test.throws ->\n util.getNames '/:foo/:foo'\n test.done()\n\n 'toRegexString':\n\n '^ and $ are added': (test) ->\n test.equals '^foo$', util.toRegexString 'foo'\n test.done()\n\n '/ are escaped': (test) ->\n test.equals '^/foo$', util.toRegexString '/foo'\n test.done()\n```", "response": "var util;\n\nutil = require('../src/util');\n\nmodule.exports = {\n 'getNames': {\n 'no names': function(test) {\n test.deepEqual([], util.getNames('/foo/bar/baz'));\n return test.done();\n },\n 'one name': function(test) {\n test.deepEqual(['foo'], util.getNames('/foo/:foo/bar/baz'));\n return test.done();\n },\n 'three names': function(test) {\n test.deepEqual(['foo', 'bar', 'baz'], util.getNames('/foo/:foo/bar/:bar/baz/:baz'));\n return test.done();\n },\n 'names with prefix wildcard': function(test) {\n test.deepEqual(['_', 'bar', 'baz'], util.getNames('/foo/*/bar/:bar/baz/:baz'));\n return test.done();\n },\n 'names with infix wildcard': function(test) {\n test.deepEqual(['foo', '_', 'baz'], util.getNames('/foo/:foo/bar/*/baz/:baz'));\n return test.done();\n },\n 'names with postfix wildcard': function(test) {\n test.deepEqual(['foo', 'bar', '_'], util.getNames('/foo/:foo/bar/:bar/baz/*'));\n return test.done();\n },\n 'name _ is disallowed': function(test) {\n test.throws(function() {\n return util.getNames('/foo/:_');\n });\n return test.done();\n },\n 'duplicate pattern names are disallowed': function(test) {\n test.throws(function() {\n return util.getNames('/:foo/:foo');\n });\n return test.done();\n }\n },\n 'toRegexString': {\n '^ and $ are added': function(test) {\n test.equals('^foo$', util.toRegexString('foo'));\n return test.done();\n },\n '/ are escaped': function(test) {\n test.equals('^/foo$', util.toRegexString('/foo'));\n return test.done();\n }\n }\n};", "source_lang": "CoffeeScript", "target_lang": "JavaScript", "repo": "snd/url-pattern", "path": "test/util.coffee", "license": "MIT", "commit": "7a949d79610b4a174753a939303a928b5267633b", "stars": 588, "source_url": "https://github.com/snd/url-pattern/blob/7a949d79610b4a174753a939303a928b5267633b/test/util.coffee", "line_start": 1, "line_end": 50}1074{"id": "snd/url-pattern:test/util.coffee:1:js_to_coffee", "type": "js_to_coffee", "prompt": "Convert this JavaScript to CoffeeScript.\n```javascript\nvar util;\n\nutil = require('../src/util');\n\nmodule.exports = {\n 'getNames': {\n 'no names': function(test) {\n test.deepEqual([], util.getNames('/foo/bar/baz'));\n return test.done();\n },\n 'one name': function(test) {\n test.deepEqual(['foo'], util.getNames('/foo/:foo/bar/baz'));\n return test.done();\n },\n 'three names': function(test) {\n test.deepEqual(['foo', 'bar', 'baz'], util.getNames('/foo/:foo/bar/:bar/baz/:baz'));\n return test.done();\n },\n 'names with prefix wildcard': function(test) {\n test.deepEqual(['_', 'bar', 'baz'], util.getNames('/foo/*/bar/:bar/baz/:baz'));\n return test.done();\n },\n 'names with infix wildcard': function(test) {\n test.deepEqual(['foo', '_', 'baz'], util.getNames('/foo/:foo/bar/*/baz/:baz'));\n return test.done();\n },\n 'names with postfix wildcard': function(test) {\n test.deepEqual(['foo', 'bar', '_'], util.getNames('/foo/:foo/bar/:bar/baz/*'));\n return test.done();\n },\n 'name _ is disallowed': function(test) {\n test.throws(function() {\n return util.getNames('/foo/:_');\n });\n return test.done();\n },\n 'duplicate pattern names are disallowed': function(test) {\n test.throws(function() {\n return util.getNames('/:foo/:foo');\n });\n return test.done();\n }\n },\n 'toRegexString': {\n '^ and $ are added': function(test) {\n test.equals('^foo$', util.toRegexString('foo'));\n return test.done();\n },\n '/ are escaped': function(test) {\n test.equals('^/foo$', util.toRegexString('/foo'));\n return test.done();\n }\n }\n};\n```", "response": "util = require '../src/util'\n\nmodule.exports =\n\n 'getNames':\n\n 'no names': (test) ->\n test.deepEqual [], util.getNames '/foo/bar/baz'\n test.done()\n\n 'one name': (test) ->\n test.deepEqual ['foo'], util.getNames '/foo/:foo/bar/baz'\n test.done()\n\n 'three names': (test) ->\n test.deepEqual ['foo', 'bar', 'baz'], util.getNames '/foo/:foo/bar/:bar/baz/:baz'\n test.done()\n\n 'names with prefix wildcard': (test) ->\n test.deepEqual ['_', 'bar', 'baz'], util.getNames '/foo/*/bar/:bar/baz/:baz'\n test.done()\n\n 'names with infix wildcard': (test) ->\n test.deepEqual ['foo', '_', 'baz'], util.getNames '/foo/:foo/bar/*/baz/:baz'\n test.done()\n\n 'names with postfix wildcard': (test) ->\n test.deepEqual ['foo', 'bar', '_'], util.getNames '/foo/:foo/bar/:bar/baz/*'\n test.done()\n\n 'name _ is disallowed': (test) ->\n test.throws ->\n util.getNames '/foo/:_'\n test.done()\n\n 'duplicate pattern names are disallowed': (test) ->\n test.throws ->\n util.getNames '/:foo/:foo'\n test.done()\n\n 'toRegexString':\n\n '^ and $ are added': (test) ->\n test.equals '^foo$', util.toRegexString 'foo'\n test.done()\n\n '/ are escaped': (test) ->\n test.equals '^/foo$', util.toRegexString '/foo'\n test.done()", "source_lang": "JavaScript", "target_lang": "CoffeeScript", "repo": "snd/url-pattern", "path": "test/util.coffee", "license": "MIT", "commit": "7a949d79610b4a174753a939303a928b5267633b", "stars": 588, "source_url": "https://github.com/snd/url-pattern/blob/7a949d79610b4a174753a939303a928b5267633b/test/util.coffee", "line_start": 1, "line_end": 50}1075{"id": "snd/url-pattern:test/util.coffee:1:completion", "type": "completion", "prompt": "util = require '../src/util'\n\nmodule.exports =\n\n 'getNames':\n\n 'no names': (test) ->\n test.deepEqual [], util.getNames '/foo/bar/baz'\n test.done()\n\n 'one name': (test) ->\n test.deepEqual ['foo'], util.getNames '/foo/:foo/bar/baz'\n test.done()\n\n 'three names': (test) ->\n test.deepEqual ['foo', 'bar', 'baz'], util.getNames '/foo/:foo/bar/:bar/baz/:baz'\n test.done()\n\n 'names with prefix wildcard': (test) ->\n test.deepEqual ['_', 'bar', 'baz'], util.getNames '/foo/*/bar/:bar/baz/:baz'\n test.done()\n\n 'names with infix wildcard': (test) ->\n test.deepEqual ['foo', '_', 'baz'], util.getNames '/foo/:foo/bar/*/baz/:baz'", "response": "test.done()\n\n 'names with postfix wildcard': (test) ->\n test.deepEqual ['foo', 'bar', '_'], util.getNames '/foo/:foo/bar/:bar/baz/*'\n test.done()\n\n 'name _ is disallowed': (test) ->\n test.throws ->\n util.getNames '/foo/:_'\n test.done()\n\n 'duplicate pattern names are disallowed': (test) ->\n test.throws ->\n util.getNames '/:foo/:foo'\n test.done()\n\n 'toRegexString':\n\n '^ and $ are added': (test) ->\n test.equals '^foo$', util.toRegexString 'foo'\n test.done()\n\n '/ are escaped': (test) ->\n test.equals '^/foo$', util.toRegexString '/foo'\n test.done()", "source_lang": "CoffeeScript", "target_lang": "CoffeeScript", "repo": "snd/url-pattern", "path": "test/util.coffee", "license": "MIT", "commit": "7a949d79610b4a174753a939303a928b5267633b", "stars": 588, "source_url": "https://github.com/snd/url-pattern/blob/7a949d79610b4a174753a939303a928b5267633b/test/util.coffee", "line_start": 1, "line_end": 50}1076{"id": "snd/url-pattern:test/util.coffee:2:raw_corpus", "type": "raw_corpus", "prompt": "", "response": "'names are replaced': (test) ->\n test.equals '^/users/([^/]+)/tasks/([^/]+)$',\n util.toRegexString '/users/:userId/tasks/:taskId'\n test.done()\n\n 'wildcards are replaced': (test) ->\n test.equals '^(.*)foo$', util.toRegexString '*foo'\n test.equals '^(.*)foo(.*)$', util.toRegexString '*foo*'\n test.done()", "source_lang": "", "target_lang": "CoffeeScript", "repo": "snd/url-pattern", "path": "test/util.coffee", "license": "MIT", "commit": "7a949d79610b4a174753a939303a928b5267633b", "stars": 588, "source_url": "https://github.com/snd/url-pattern/blob/7a949d79610b4a174753a939303a928b5267633b/test/util.coffee", "line_start": 51, "line_end": 59}1077{"id": "snd/url-pattern:test/util.coffee:2:coffee_to_js", "type": "coffee_to_js", "prompt": "Convert this CoffeeScript to JavaScript.\n```coffeescript\n'names are replaced': (test) ->\n test.equals '^/users/([^/]+)/tasks/([^/]+)$',\n util.toRegexString '/users/:userId/tasks/:taskId'\n test.done()\n\n 'wildcards are replaced': (test) ->\n test.equals '^(.*)foo$', util.toRegexString '*foo'\n test.equals '^(.*)foo(.*)$', util.toRegexString '*foo*'\n test.done()\n```", "response": "({\n 'names are replaced': function(test) {\n test.equals('^/users/([^/]+)/tasks/([^/]+)$', util.toRegexString('/users/:userId/tasks/:taskId'));\n return test.done();\n },\n 'wildcards are replaced': function(test) {\n test.equals('^(.*)foo$', util.toRegexString('*foo'));\n test.equals('^(.*)foo(.*)$', util.toRegexString('*foo*'));\n return test.done();\n }\n});", "source_lang": "CoffeeScript", "target_lang": "JavaScript", "repo": "snd/url-pattern", "path": "test/util.coffee", "license": "MIT", "commit": "7a949d79610b4a174753a939303a928b5267633b", "stars": 588, "source_url": "https://github.com/snd/url-pattern/blob/7a949d79610b4a174753a939303a928b5267633b/test/util.coffee", "line_start": 51, "line_end": 59}1078{"id": "snd/url-pattern:test/util.coffee:2:js_to_coffee", "type": "js_to_coffee", "prompt": "Convert this JavaScript to CoffeeScript.\n```javascript\n({\n 'names are replaced': function(test) {\n test.equals('^/users/([^/]+)/tasks/([^/]+)$', util.toRegexString('/users/:userId/tasks/:taskId'));\n return test.done();\n },\n 'wildcards are replaced': function(test) {\n test.equals('^(.*)foo$', util.toRegexString('*foo'));\n test.equals('^(.*)foo(.*)$', util.toRegexString('*foo*'));\n return test.done();\n }\n});\n```", "response": "'names are replaced': (test) ->\n test.equals '^/users/([^/]+)/tasks/([^/]+)$',\n util.toRegexString '/users/:userId/tasks/:taskId'\n test.done()\n\n 'wildcards are replaced': (test) ->\n test.equals '^(.*)foo$', util.toRegexString '*foo'\n test.equals '^(.*)foo(.*)$', util.toRegexString '*foo*'\n test.done()", "source_lang": "JavaScript", "target_lang": "CoffeeScript", "repo": "snd/url-pattern", "path": "test/util.coffee", "license": "MIT", "commit": "7a949d79610b4a174753a939303a928b5267633b", "stars": 588, "source_url": "https://github.com/snd/url-pattern/blob/7a949d79610b4a174753a939303a928b5267633b/test/util.coffee", "line_start": 51, "line_end": 59}1079{"id": "snd/url-pattern:test/util.coffee:2:completion", "type": "completion", "prompt": "'names are replaced': (test) ->\n test.equals '^/users/([^/]+)/tasks/([^/]+)$',\n util.toRegexString '/users/:userId/tasks/:taskId'\n test.done()", "response": "'wildcards are replaced': (test) ->\n test.equals '^(.*)foo$', util.toRegexString '*foo'\n test.equals '^(.*)foo(.*)$', util.toRegexString '*foo*'\n test.done()", "source_lang": "CoffeeScript", "target_lang": "CoffeeScript", "repo": "snd/url-pattern", "path": "test/util.coffee", "license": "MIT", "commit": "7a949d79610b4a174753a939303a928b5267633b", "stars": 588, "source_url": "https://github.com/snd/url-pattern/blob/7a949d79610b4a174753a939303a928b5267633b/test/util.coffee", "line_start": 51, "line_end": 59}1080{"id": "nevir/groc:lib/styles/default/behavior-old.coffee:1:raw_corpus", "type": "raw_corpus", "prompt": "", "response": "appendSearchNode = (node$) ->\n searchableNodes.push [node$.text().toLowerCase(), node$]\n\ncurrentQuery = ''", "source_lang": "", "target_lang": "CoffeeScript", "repo": "nevir/groc", "path": "lib/styles/default/behavior-old.coffee", "license": "MIT", "commit": "e2d2229cac05e6ef5625b636587ca61e21edc288", "stars": 579, "source_url": "https://github.com/nevir/groc/blob/e2d2229cac05e6ef5625b636587ca61e21edc288/lib/styles/default/behavior-old.coffee", "line_start": 12, "line_end": 15}1081{"id": "nevir/groc:lib/styles/default/behavior-old.coffee:1:coffee_to_js", "type": "coffee_to_js", "prompt": "Convert this CoffeeScript to JavaScript.\n```coffeescript\nappendSearchNode = (node$) ->\n searchableNodes.push [node$.text().toLowerCase(), node$]\n\ncurrentQuery = ''\n```", "response": "var appendSearchNode, currentQuery;\n\nappendSearchNode = function(node$) {\n return searchableNodes.push([node$.text().toLowerCase(), node$]);\n};\n\ncurrentQuery = '';", "source_lang": "CoffeeScript", "target_lang": "JavaScript", "repo": "nevir/groc", "path": "lib/styles/default/behavior-old.coffee", "license": "MIT", "commit": "e2d2229cac05e6ef5625b636587ca61e21edc288", "stars": 579, "source_url": "https://github.com/nevir/groc/blob/e2d2229cac05e6ef5625b636587ca61e21edc288/lib/styles/default/behavior-old.coffee", "line_start": 12, "line_end": 15}1082{"id": "nevir/groc:lib/styles/default/behavior-old.coffee:1:js_to_coffee", "type": "js_to_coffee", "prompt": "Convert this JavaScript to CoffeeScript.\n```javascript\nvar appendSearchNode, currentQuery;\n\nappendSearchNode = function(node$) {\n return searchableNodes.push([node$.text().toLowerCase(), node$]);\n};\n\ncurrentQuery = '';\n```", "response": "appendSearchNode = (node$) ->\n searchableNodes.push [node$.text().toLowerCase(), node$]\n\ncurrentQuery = ''", "source_lang": "JavaScript", "target_lang": "CoffeeScript", "repo": "nevir/groc", "path": "lib/styles/default/behavior-old.coffee", "license": "MIT", "commit": "e2d2229cac05e6ef5625b636587ca61e21edc288", "stars": 579, "source_url": "https://github.com/nevir/groc/blob/e2d2229cac05e6ef5625b636587ca61e21edc288/lib/styles/default/behavior-old.coffee", "line_start": 12, "line_end": 15}1083{"id": "nevir/groc:lib/styles/default/behavior-old.coffee:2:raw_corpus", "type": "raw_corpus", "prompt": "", "response": "searchNodes = (queryString) ->\n queryString = queryString.toLowerCase().replace(/\\s+/, '')\n return if queryString == currentQuery\n currentQuery = queryString\n\n return clearFilter() if queryString == ''\n\n matcher = new RegExp (c.replace /[-[\\]{}()*+?.,\\\\^$|#\\s]/, \"\\\\$&\" for c in queryString).join '.*'\n matched = []\n filtered = []\n\n for nodeInfo in searchableNodes\n if matcher.test nodeInfo[0] then matched.push nodeInfo[1] else filtered.push nodeInfo[1]\n\n return clearFilter() if matched.length > MAX_FILTER_SIZE\n\n # Update the DOM\n for node$ in filtered\n node$.removeClass 'matched-child'\n node$.addClass 'filtered'\n\n for node$ in matched\n node$.removeClass 'filtered matched-child'\n\n highlightMatch node$, queryString\n\n # Filter out our immediate parent\n $(p).find('> a').addClass 'matched-child' for p in node$.parent().parents 'li'", "source_lang": "", "target_lang": "CoffeeScript", "repo": "nevir/groc", "path": "lib/styles/default/behavior-old.coffee", "license": "MIT", "commit": "e2d2229cac05e6ef5625b636587ca61e21edc288", "stars": 579, "source_url": "https://github.com/nevir/groc/blob/e2d2229cac05e6ef5625b636587ca61e21edc288/lib/styles/default/behavior-old.coffee", "line_start": 16, "line_end": 43}1084{"id": "nevir/groc:lib/styles/default/behavior-old.coffee:2:coffee_to_js", "type": "coffee_to_js", "prompt": "Convert this CoffeeScript to JavaScript.\n```coffeescript\nsearchNodes = (queryString) ->\n queryString = queryString.toLowerCase().replace(/\\s+/, '')\n return if queryString == currentQuery\n currentQuery = queryString\n\n return clearFilter() if queryString == ''\n\n matcher = new RegExp (c.replace /[-[\\]{}()*+?.,\\\\^$|#\\s]/, \"\\\\$&\" for c in queryString).join '.*'\n matched = []\n filtered = []\n\n for nodeInfo in searchableNodes\n if matcher.test nodeInfo[0] then matched.push nodeInfo[1] else filtered.push nodeInfo[1]\n\n return clearFilter() if matched.length > MAX_FILTER_SIZE\n\n # Update the DOM\n for node$ in filtered\n node$.removeClass 'matched-child'\n node$.addClass 'filtered'\n\n for node$ in matched\n node$.removeClass 'filtered matched-child'\n\n highlightMatch node$, queryString\n\n # Filter out our immediate parent\n $(p).find('> a').addClass 'matched-child' for p in node$.parent().parents 'li'\n```", "response": "var searchNodes;\n\nsearchNodes = function(queryString) {\n var c, currentQuery, filtered, i, j, k, len, len1, len2, matched, matcher, node$, nodeInfo, p, results;\n queryString = queryString.toLowerCase().replace(/\\s+/, '');\n if (queryString === currentQuery) {\n return;\n }\n currentQuery = queryString;\n if (queryString === '') {\n return clearFilter();\n }\n matcher = new RegExp(((function() {\n var i, len, results;\n results = [];\n for (i = 0, len = queryString.length; i < len; i++) {\n c = queryString[i];\n results.push(c.replace(/[-[\\]{}()*+?.,\\\\^$|#\\s]/, \"\\\\$&\"));\n }\n return results;\n })()).join('.*'));\n matched = [];\n filtered = [];\n for (i = 0, len = searchableNodes.length; i < len; i++) {\n nodeInfo = searchableNodes[i];\n if (matcher.test(nodeInfo[0])) {\n matched.push(nodeInfo[1]);\n } else {\n filtered.push(nodeInfo[1]);\n }\n }\n if (matched.length > MAX_FILTER_SIZE) {\n return clearFilter();\n }\n// Update the DOM\n for (j = 0, len1 = filtered.length; j < len1; j++) {\n node$ = filtered[j];\n node$.removeClass('matched-child');\n node$.addClass('filtered');\n }\n results = [];\n for (k = 0, len2 = matched.length; k < len2; k++) {\n node$ = matched[k];\n node$.removeClass('filtered matched-child');\n highlightMatch(node$, queryString);\n results.push((function() {\n var l, len3, ref, results1;\n ref = node$.parent().parents('li');\n results1 = [];\n for (l = 0, len3 = ref.length; l < len3; l++) {\n p = ref[l];\n // Filter out our immediate parent\n results1.push($(p).find('> a').addClass('matched-child'));\n }\n return results1;\n })());\n }\n return results;\n};", "source_lang": "CoffeeScript", "target_lang": "JavaScript", "repo": "nevir/groc", "path": "lib/styles/default/behavior-old.coffee", "license": "MIT", "commit": "e2d2229cac05e6ef5625b636587ca61e21edc288", "stars": 579, "source_url": "https://github.com/nevir/groc/blob/e2d2229cac05e6ef5625b636587ca61e21edc288/lib/styles/default/behavior-old.coffee", "line_start": 16, "line_end": 43}1085{"id": "nevir/groc:lib/styles/default/behavior-old.coffee:2:js_to_coffee", "type": "js_to_coffee", "prompt": "Convert this JavaScript to CoffeeScript.\n```javascript\nvar searchNodes;\n\nsearchNodes = function(queryString) {\n var c, currentQuery, filtered, i, j, k, len, len1, len2, matched, matcher, node$, nodeInfo, p, results;\n queryString = queryString.toLowerCase().replace(/\\s+/, '');\n if (queryString === currentQuery) {\n return;\n }\n currentQuery = queryString;\n if (queryString === '') {\n return clearFilter();\n }\n matcher = new RegExp(((function() {\n var i, len, results;\n results = [];\n for (i = 0, len = queryString.length; i < len; i++) {\n c = queryString[i];\n results.push(c.replace(/[-[\\]{}()*+?.,\\\\^$|#\\s]/, \"\\\\$&\"));\n }\n return results;\n })()).join('.*'));\n matched = [];\n filtered = [];\n for (i = 0, len = searchableNodes.length; i < len; i++) {\n nodeInfo = searchableNodes[i];\n if (matcher.test(nodeInfo[0])) {\n matched.push(nodeInfo[1]);\n } else {\n filtered.push(nodeInfo[1]);\n }\n }\n if (matched.length > MAX_FILTER_SIZE) {\n return clearFilter();\n }\n// Update the DOM\n for (j = 0, len1 = filtered.length; j < len1; j++) {\n node$ = filtered[j];\n node$.removeClass('matched-child');\n node$.addClass('filtered');\n }\n results = [];\n for (k = 0, len2 = matched.length; k < len2; k++) {\n node$ = matched[k];\n node$.removeClass('filtered matched-child');\n highlightMatch(node$, queryString);\n results.push((function() {\n var l, len3, ref, results1;\n ref = node$.parent().parents('li');\n results1 = [];\n for (l = 0, len3 = ref.length; l < len3; l++) {\n p = ref[l];\n // Filter out our immediate parent\n results1.push($(p).find('> a').addClass('matched-child'));\n }\n return results1;\n })());\n }\n return results;\n};\n```", "response": "searchNodes = (queryString) ->\n queryString = queryString.toLowerCase().replace(/\\s+/, '')\n return if queryString == currentQuery\n currentQuery = queryString\n\n return clearFilter() if queryString == ''\n\n matcher = new RegExp (c.replace /[-[\\]{}()*+?.,\\\\^$|#\\s]/, \"\\\\$&\" for c in queryString).join '.*'\n matched = []\n filtered = []\n\n for nodeInfo in searchableNodes\n if matcher.test nodeInfo[0] then matched.push nodeInfo[1] else filtered.push nodeInfo[1]\n\n return clearFilter() if matched.length > MAX_FILTER_SIZE\n\n # Update the DOM\n for node$ in filtered\n node$.removeClass 'matched-child'\n node$.addClass 'filtered'\n\n for node$ in matched\n node$.removeClass 'filtered matched-child'\n\n highlightMatch node$, queryString\n\n # Filter out our immediate parent\n $(p).find('> a').addClass 'matched-child' for p in node$.parent().parents 'li'", "source_lang": "JavaScript", "target_lang": "CoffeeScript", "repo": "nevir/groc", "path": "lib/styles/default/behavior-old.coffee", "license": "MIT", "commit": "e2d2229cac05e6ef5625b636587ca61e21edc288", "stars": 579, "source_url": "https://github.com/nevir/groc/blob/e2d2229cac05e6ef5625b636587ca61e21edc288/lib/styles/default/behavior-old.coffee", "line_start": 16, "line_end": 43}1086{"id": "nevir/groc:lib/styles/default/behavior-old.coffee:2:completion", "type": "completion", "prompt": "searchNodes = (queryString) ->\n queryString = queryString.toLowerCase().replace(/\\s+/, '')\n return if queryString == currentQuery\n currentQuery = queryString\n\n return clearFilter() if queryString == ''\n\n matcher = new RegExp (c.replace /[-[\\]{}()*+?.,\\\\^$|#\\s]/, \"\\\\$&\" for c in queryString).join '.*'\n matched = []\n filtered = []\n\n for nodeInfo in searchableNodes\n if matcher.test nodeInfo[0] then matched.push nodeInfo[1] else filtered.push nodeInfo[1]", "response": "return clearFilter() if matched.length > MAX_FILTER_SIZE\n\n # Update the DOM\n for node$ in filtered\n node$.removeClass 'matched-child'\n node$.addClass 'filtered'\n\n for node$ in matched\n node$.removeClass 'filtered matched-child'\n\n highlightMatch node$, queryString\n\n # Filter out our immediate parent\n $(p).find('> a').addClass 'matched-child' for p in node$.parent().parents 'li'", "source_lang": "CoffeeScript", "target_lang": "CoffeeScript", "repo": "nevir/groc", "path": "lib/styles/default/behavior-old.coffee", "license": "MIT", "commit": "e2d2229cac05e6ef5625b636587ca61e21edc288", "stars": 579, "source_url": "https://github.com/nevir/groc/blob/e2d2229cac05e6ef5625b636587ca61e21edc288/lib/styles/default/behavior-old.coffee", "line_start": 16, "line_end": 43}1087{"id": "nevir/groc:lib/styles/default/behavior-old.coffee:3:raw_corpus", "type": "raw_corpus", "prompt": "", "response": "clearFilter = ->\n currentQuery = ''\n for nodeInfo in searchableNodes\n node$ = nodeInfo[1]\n node$.removeClass 'filtered matched-child'\n node$.text node$.text()", "source_lang": "", "target_lang": "CoffeeScript", "repo": "nevir/groc", "path": "lib/styles/default/behavior-old.coffee", "license": "MIT", "commit": "e2d2229cac05e6ef5625b636587ca61e21edc288", "stars": 579, "source_url": "https://github.com/nevir/groc/blob/e2d2229cac05e6ef5625b636587ca61e21edc288/lib/styles/default/behavior-old.coffee", "line_start": 45, "line_end": 50}1088{"id": "nevir/groc:lib/styles/default/behavior-old.coffee:3:coffee_to_js", "type": "coffee_to_js", "prompt": "Convert this CoffeeScript to JavaScript.\n```coffeescript\nclearFilter = ->\n currentQuery = ''\n for nodeInfo in searchableNodes\n node$ = nodeInfo[1]\n node$.removeClass 'filtered matched-child'\n node$.text node$.text()\n```", "response": "var clearFilter;\n\nclearFilter = function() {\n var currentQuery, i, len, node$, nodeInfo, results;\n currentQuery = '';\n results = [];\n for (i = 0, len = searchableNodes.length; i < len; i++) {\n nodeInfo = searchableNodes[i];\n node$ = nodeInfo[1];\n node$.removeClass('filtered matched-child');\n results.push(node$.text(node$.text()));\n }\n return results;\n};", "source_lang": "CoffeeScript", "target_lang": "JavaScript", "repo": "nevir/groc", "path": "lib/styles/default/behavior-old.coffee", "license": "MIT", "commit": "e2d2229cac05e6ef5625b636587ca61e21edc288", "stars": 579, "source_url": "https://github.com/nevir/groc/blob/e2d2229cac05e6ef5625b636587ca61e21edc288/lib/styles/default/behavior-old.coffee", "line_start": 45, "line_end": 50}1089{"id": "nevir/groc:lib/styles/default/behavior-old.coffee:3:js_to_coffee", "type": "js_to_coffee", "prompt": "Convert this JavaScript to CoffeeScript.\n```javascript\nvar clearFilter;\n\nclearFilter = function() {\n var currentQuery, i, len, node$, nodeInfo, results;\n currentQuery = '';\n results = [];\n for (i = 0, len = searchableNodes.length; i < len; i++) {\n nodeInfo = searchableNodes[i];\n node$ = nodeInfo[1];\n node$.removeClass('filtered matched-child');\n results.push(node$.text(node$.text()));\n }\n return results;\n};\n```", "response": "clearFilter = ->\n currentQuery = ''\n for nodeInfo in searchableNodes\n node$ = nodeInfo[1]\n node$.removeClass 'filtered matched-child'\n node$.text node$.text()", "source_lang": "JavaScript", "target_lang": "CoffeeScript", "repo": "nevir/groc", "path": "lib/styles/default/behavior-old.coffee", "license": "MIT", "commit": "e2d2229cac05e6ef5625b636587ca61e21edc288", "stars": 579, "source_url": "https://github.com/nevir/groc/blob/e2d2229cac05e6ef5625b636587ca61e21edc288/lib/styles/default/behavior-old.coffee", "line_start": 45, "line_end": 50}1090{"id": "nevir/groc:lib/styles/default/behavior-old.coffee:3:completion", "type": "completion", "prompt": "clearFilter = ->\n currentQuery = ''\n for nodeInfo in searchableNodes", "response": "node$ = nodeInfo[1]\n node$.removeClass 'filtered matched-child'\n node$.text node$.text()", "source_lang": "CoffeeScript", "target_lang": "CoffeeScript", "repo": "nevir/groc", "path": "lib/styles/default/behavior-old.coffee", "license": "MIT", "commit": "e2d2229cac05e6ef5625b636587ca61e21edc288", "stars": 579, "source_url": "https://github.com/nevir/groc/blob/e2d2229cac05e6ef5625b636587ca61e21edc288/lib/styles/default/behavior-old.coffee", "line_start": 45, "line_end": 50}1091{"id": "nevir/groc:lib/styles/default/behavior-old.coffee:4:raw_corpus", "type": "raw_corpus", "prompt": "", "response": "highlightMatch = (node$, queryString) ->\n nodeText = node$.text()\n lowerText = nodeText.toLowerCase()\n\n markedText = ''\n furthestIndex = 0\n\n for char in queryString\n foundIndex = lowerText.indexOf char, furthestIndex\n markedText += nodeText[furthestIndex...foundIndex] + \"<em>#{nodeText[foundIndex]}</em>\"\n furthestIndex = foundIndex + 1\n\n node$.html markedText + nodeText[furthestIndex...]\n\n\n# ## DOM Construction", "source_lang": "", "target_lang": "CoffeeScript", "repo": "nevir/groc", "path": "lib/styles/default/behavior-old.coffee", "license": "MIT", "commit": "e2d2229cac05e6ef5625b636587ca61e21edc288", "stars": 579, "source_url": "https://github.com/nevir/groc/blob/e2d2229cac05e6ef5625b636587ca61e21edc288/lib/styles/default/behavior-old.coffee", "line_start": 52, "line_end": 67}1092{"id": "nevir/groc:lib/styles/default/behavior-old.coffee:4:coffee_to_js", "type": "coffee_to_js", "prompt": "Convert this CoffeeScript to JavaScript.\n```coffeescript\nhighlightMatch = (node$, queryString) ->\n nodeText = node$.text()\n lowerText = nodeText.toLowerCase()\n\n markedText = ''\n furthestIndex = 0\n\n for char in queryString\n foundIndex = lowerText.indexOf char, furthestIndex\n markedText += nodeText[furthestIndex...foundIndex] + \"<em>#{nodeText[foundIndex]}</em>\"\n furthestIndex = foundIndex + 1\n\n node$.html markedText + nodeText[furthestIndex...]\n\n\n# ## DOM Construction\n```", "response": "var highlightMatch;\n\nhighlightMatch = function(node$, queryString) {\n var char, foundIndex, furthestIndex, i, len, lowerText, markedText, nodeText;\n nodeText = node$.text();\n lowerText = nodeText.toLowerCase();\n markedText = '';\n furthestIndex = 0;\n for (i = 0, len = queryString.length; i < len; i++) {\n char = queryString[i];\n foundIndex = lowerText.indexOf(char, furthestIndex);\n markedText += nodeText.slice(furthestIndex, foundIndex) + `<em>${nodeText[foundIndex]}</em>`;\n furthestIndex = foundIndex + 1;\n }\n return node$.html(markedText + nodeText.slice(furthestIndex));\n};\n\n// ## DOM Construction", "source_lang": "CoffeeScript", "target_lang": "JavaScript", "repo": "nevir/groc", "path": "lib/styles/default/behavior-old.coffee", "license": "MIT", "commit": "e2d2229cac05e6ef5625b636587ca61e21edc288", "stars": 579, "source_url": "https://github.com/nevir/groc/blob/e2d2229cac05e6ef5625b636587ca61e21edc288/lib/styles/default/behavior-old.coffee", "line_start": 52, "line_end": 67}1093{"id": "nevir/groc:lib/styles/default/behavior-old.coffee:4:js_to_coffee", "type": "js_to_coffee", "prompt": "Convert this JavaScript to CoffeeScript.\n```javascript\nvar highlightMatch;\n\nhighlightMatch = function(node$, queryString) {\n var char, foundIndex, furthestIndex, i, len, lowerText, markedText, nodeText;\n nodeText = node$.text();\n lowerText = nodeText.toLowerCase();\n markedText = '';\n furthestIndex = 0;\n for (i = 0, len = queryString.length; i < len; i++) {\n char = queryString[i];\n foundIndex = lowerText.indexOf(char, furthestIndex);\n markedText += nodeText.slice(furthestIndex, foundIndex) + `<em>${nodeText[foundIndex]}</em>`;\n furthestIndex = foundIndex + 1;\n }\n return node$.html(markedText + nodeText.slice(furthestIndex));\n};\n\n// ## DOM Construction\n```", "response": "highlightMatch = (node$, queryString) ->\n nodeText = node$.text()\n lowerText = nodeText.toLowerCase()\n\n markedText = ''\n furthestIndex = 0\n\n for char in queryString\n foundIndex = lowerText.indexOf char, furthestIndex\n markedText += nodeText[furthestIndex...foundIndex] + \"<em>#{nodeText[foundIndex]}</em>\"\n furthestIndex = foundIndex + 1\n\n node$.html markedText + nodeText[furthestIndex...]\n\n\n# ## DOM Construction", "source_lang": "JavaScript", "target_lang": "CoffeeScript", "repo": "nevir/groc", "path": "lib/styles/default/behavior-old.coffee", "license": "MIT", "commit": "e2d2229cac05e6ef5625b636587ca61e21edc288", "stars": 579, "source_url": "https://github.com/nevir/groc/blob/e2d2229cac05e6ef5625b636587ca61e21edc288/lib/styles/default/behavior-old.coffee", "line_start": 52, "line_end": 67}1094{"id": "nevir/groc:lib/styles/default/behavior-old.coffee:4:completion", "type": "completion", "prompt": "highlightMatch = (node$, queryString) ->\n nodeText = node$.text()\n lowerText = nodeText.toLowerCase()\n\n markedText = ''\n furthestIndex = 0\n\n for char in queryString", "response": "foundIndex = lowerText.indexOf char, furthestIndex\n markedText += nodeText[furthestIndex...foundIndex] + \"<em>#{nodeText[foundIndex]}</em>\"\n furthestIndex = foundIndex + 1\n\n node$.html markedText + nodeText[furthestIndex...]\n\n\n# ## DOM Construction", "source_lang": "CoffeeScript", "target_lang": "CoffeeScript", "repo": "nevir/groc", "path": "lib/styles/default/behavior-old.coffee", "license": "MIT", "commit": "e2d2229cac05e6ef5625b636587ca61e21edc288", "stars": 579, "source_url": "https://github.com/nevir/groc/blob/e2d2229cac05e6ef5625b636587ca61e21edc288/lib/styles/default/behavior-old.coffee", "line_start": 52, "line_end": 67}1095{"id": "nevir/groc:lib/styles/default/behavior-old.coffee:5:raw_corpus", "type": "raw_corpus", "prompt": "", "response": "buildNav = (relativeRoot) ->\n nav$ = $(\"\"\"\n <nav>\n <ul class=\"tools\">\n <li class=\"toggle\">Table of Contents</li>\n <li class=\"search\"><input id=\"search\" type=\"search\"/></li>\n </ul>\n <ol class=\"toc\"/>\n </div>\n </nav>\n \"\"\").appendTo $('body')\n toc$ = nav$.find '.toc'\n\n files = (f for f of outline).sort()\n\n for file in files\n filePath = \"#{relativeRoot}#{file}.html\"\n\n fileNode$ = $(\"\"\"\n <li class=\"file\">\n <a href=\"#{filePath}\">#{file}</a>\n </li>\n \"\"\").appendTo toc$\n\n appendSearchNode fileNode$.find('a')\n appendHeaderNodes fileNode$, filePath, outline[file]\n\n nav$", "source_lang": "", "target_lang": "CoffeeScript", "repo": "nevir/groc", "path": "lib/styles/default/behavior-old.coffee", "license": "MIT", "commit": "e2d2229cac05e6ef5625b636587ca61e21edc288", "stars": 579, "source_url": "https://github.com/nevir/groc/blob/e2d2229cac05e6ef5625b636587ca61e21edc288/lib/styles/default/behavior-old.coffee", "line_start": 69, "line_end": 96}1096{"id": "nevir/groc:lib/styles/default/behavior-old.coffee:5:coffee_to_js", "type": "coffee_to_js", "prompt": "Convert this CoffeeScript to JavaScript.\n```coffeescript\nbuildNav = (relativeRoot) ->\n nav$ = $(\"\"\"\n <nav>\n <ul class=\"tools\">\n <li class=\"toggle\">Table of Contents</li>\n <li class=\"search\"><input id=\"search\" type=\"search\"/></li>\n </ul>\n <ol class=\"toc\"/>\n </div>\n </nav>\n \"\"\").appendTo $('body')\n toc$ = nav$.find '.toc'\n\n files = (f for f of outline).sort()\n\n for file in files\n filePath = \"#{relativeRoot}#{file}.html\"\n\n fileNode$ = $(\"\"\"\n <li class=\"file\">\n <a href=\"#{filePath}\">#{file}</a>\n </li>\n \"\"\").appendTo toc$\n\n appendSearchNode fileNode$.find('a')\n appendHeaderNodes fileNode$, filePath, outline[file]\n\n nav$\n```", "response": "var buildNav;\n\nbuildNav = function(relativeRoot) {\n var f, file, fileNode$, filePath, files, i, len, nav$, toc$;\n nav$ = $(`<nav>\n <ul class=\"tools\">\n <li class=\"toggle\">Table of Contents</li>\n <li class=\"search\"><input id=\"search\" type=\"search\"/></li>\n </ul>\n <ol class=\"toc\"/>\n </div>\n</nav>`).appendTo($('body'));\n toc$ = nav$.find('.toc');\n files = ((function() {\n var results;\n results = [];\n for (f in outline) {\n results.push(f);\n }\n return results;\n })()).sort();\n for (i = 0, len = files.length; i < len; i++) {\n file = files[i];\n filePath = `${relativeRoot}${file}.html`;\n fileNode$ = $(`<li class=\"file\">\n <a href=\"${filePath}\">${file}</a>\n</li>`).appendTo(toc$);\n appendSearchNode(fileNode$.find('a'));\n appendHeaderNodes(fileNode$, filePath, outline[file]);\n }\n return nav$;\n};", "source_lang": "CoffeeScript", "target_lang": "JavaScript", "repo": "nevir/groc", "path": "lib/styles/default/behavior-old.coffee", "license": "MIT", "commit": "e2d2229cac05e6ef5625b636587ca61e21edc288", "stars": 579, "source_url": "https://github.com/nevir/groc/blob/e2d2229cac05e6ef5625b636587ca61e21edc288/lib/styles/default/behavior-old.coffee", "line_start": 69, "line_end": 96}1097{"id": "nevir/groc:lib/styles/default/behavior-old.coffee:5:js_to_coffee", "type": "js_to_coffee", "prompt": "Convert this JavaScript to CoffeeScript.\n```javascript\nvar buildNav;\n\nbuildNav = function(relativeRoot) {\n var f, file, fileNode$, filePath, files, i, len, nav$, toc$;\n nav$ = $(`<nav>\n <ul class=\"tools\">\n <li class=\"toggle\">Table of Contents</li>\n <li class=\"search\"><input id=\"search\" type=\"search\"/></li>\n </ul>\n <ol class=\"toc\"/>\n </div>\n</nav>`).appendTo($('body'));\n toc$ = nav$.find('.toc');\n files = ((function() {\n var results;\n results = [];\n for (f in outline) {\n results.push(f);\n }\n return results;\n })()).sort();\n for (i = 0, len = files.length; i < len; i++) {\n file = files[i];\n filePath = `${relativeRoot}${file}.html`;\n fileNode$ = $(`<li class=\"file\">\n <a href=\"${filePath}\">${file}</a>\n</li>`).appendTo(toc$);\n appendSearchNode(fileNode$.find('a'));\n appendHeaderNodes(fileNode$, filePath, outline[file]);\n }\n return nav$;\n};\n```", "response": "buildNav = (relativeRoot) ->\n nav$ = $(\"\"\"\n <nav>\n <ul class=\"tools\">\n <li class=\"toggle\">Table of Contents</li>\n <li class=\"search\"><input id=\"search\" type=\"search\"/></li>\n </ul>\n <ol class=\"toc\"/>\n </div>\n </nav>\n \"\"\").appendTo $('body')\n toc$ = nav$.find '.toc'\n\n files = (f for f of outline).sort()\n\n for file in files\n filePath = \"#{relativeRoot}#{file}.html\"\n\n fileNode$ = $(\"\"\"\n <li class=\"file\">\n <a href=\"#{filePath}\">#{file}</a>\n </li>\n \"\"\").appendTo toc$\n\n appendSearchNode fileNode$.find('a')\n appendHeaderNodes fileNode$, filePath, outline[file]\n\n nav$", "source_lang": "JavaScript", "target_lang": "CoffeeScript", "repo": "nevir/groc", "path": "lib/styles/default/behavior-old.coffee", "license": "MIT", "commit": "e2d2229cac05e6ef5625b636587ca61e21edc288", "stars": 579, "source_url": "https://github.com/nevir/groc/blob/e2d2229cac05e6ef5625b636587ca61e21edc288/lib/styles/default/behavior-old.coffee", "line_start": 69, "line_end": 96}1098{"id": "nevir/groc:lib/styles/default/behavior-old.coffee:5:completion", "type": "completion", "prompt": "buildNav = (relativeRoot) ->\n nav$ = $(\"\"\"\n <nav>\n <ul class=\"tools\">\n <li class=\"toggle\">Table of Contents</li>\n <li class=\"search\"><input id=\"search\" type=\"search\"/></li>\n </ul>\n <ol class=\"toc\"/>\n </div>\n </nav>\n \"\"\").appendTo $('body')\n toc$ = nav$.find '.toc'\n\n files = (f for f of outline).sort()", "response": "for file in files\n filePath = \"#{relativeRoot}#{file}.html\"\n\n fileNode$ = $(\"\"\"\n <li class=\"file\">\n <a href=\"#{filePath}\">#{file}</a>\n </li>\n \"\"\").appendTo toc$\n\n appendSearchNode fileNode$.find('a')\n appendHeaderNodes fileNode$, filePath, outline[file]\n\n nav$", "source_lang": "CoffeeScript", "target_lang": "CoffeeScript", "repo": "nevir/groc", "path": "lib/styles/default/behavior-old.coffee", "license": "MIT", "commit": "e2d2229cac05e6ef5625b636587ca61e21edc288", "stars": 579, "source_url": "https://github.com/nevir/groc/blob/e2d2229cac05e6ef5625b636587ca61e21edc288/lib/styles/default/behavior-old.coffee", "line_start": 69, "line_end": 96}1099{"id": "nevir/groc:lib/styles/default/behavior-old.coffee:6:raw_corpus", "type": "raw_corpus", "prompt": "", "response": "appendHeaderNodes = (target$, filePath, nodeList) ->\n return unless nodeList.length > 0\n\n targetList$ = $('<ol/>').appendTo target$\n\n for node in nodeList\n node$ = $(\"\"\"\n <li class=\"header\">\n <a href=\"#{filePath}##{node.data.slug}\">#{node.data.title}</a>\n </li>\n \"\"\").appendTo targetList$\n appendSearchNode node$.find('a')\n\n appendHeaderNodes node$, filePath, node.children\n\n$ ->\n relativeRoot = $('meta[name=\"lidoc-relative-root\"]').attr('content')\n nav$ = buildNav relativeRoot\n\n search$ = $('#search')\n search$.bind 'keyup search', (evt) =>\n searchNodes search$.val()\n\n search$.keydown (evt) =>\n if evt.keyCode == 27 # Esc\n if search$.val().trim() == ''\n search$.blur()\n else\n search$.val ''\n\n search$.focus (evt) => nav$.addClass 'active'\n search$.blur (evt) => nav$.removeClass 'active'\n\n nav$.click (evt) =>\n search$.focus()\n\n nav$.mousedown (evt) =>\n if search$.is(':focus') and evt.target != search$[0]\n evt.preventDefault()", "source_lang": "", "target_lang": "CoffeeScript", "repo": "nevir/groc", "path": "lib/styles/default/behavior-old.coffee", "license": "MIT", "commit": "e2d2229cac05e6ef5625b636587ca61e21edc288", "stars": 579, "source_url": "https://github.com/nevir/groc/blob/e2d2229cac05e6ef5625b636587ca61e21edc288/lib/styles/default/behavior-old.coffee", "line_start": 98, "line_end": 136}1100{"id": "nevir/groc:lib/styles/default/behavior-old.coffee:6:coffee_to_js", "type": "coffee_to_js", "prompt": "Convert this CoffeeScript to JavaScript.\n```coffeescript\nappendHeaderNodes = (target$, filePath, nodeList) ->\n return unless nodeList.length > 0\n\n targetList$ = $('<ol/>').appendTo target$\n\n for node in nodeList\n node$ = $(\"\"\"\n <li class=\"header\">\n <a href=\"#{filePath}##{node.data.slug}\">#{node.data.title}</a>\n </li>\n \"\"\").appendTo targetList$\n appendSearchNode node$.find('a')\n\n appendHeaderNodes node$, filePath, node.children\n\n$ ->\n relativeRoot = $('meta[name=\"lidoc-relative-root\"]').attr('content')\n nav$ = buildNav relativeRoot\n\n search$ = $('#search')\n search$.bind 'keyup search', (evt) =>\n searchNodes search$.val()\n\n search$.keydown (evt) =>\n if evt.keyCode == 27 # Esc\n if search$.val().trim() == ''\n search$.blur()\n else\n search$.val ''\n\n search$.focus (evt) => nav$.addClass 'active'\n search$.blur (evt) => nav$.removeClass 'active'\n\n nav$.click (evt) =>\n search$.focus()\n\n nav$.mousedown (evt) =>\n if search$.is(':focus') and evt.target != search$[0]\n evt.preventDefault()\n```", "response": "var appendHeaderNodes;\n\nappendHeaderNodes = function(target$, filePath, nodeList) {\n var i, len, node, node$, results, targetList$;\n if (!(nodeList.length > 0)) {\n return;\n }\n targetList$ = $('<ol/>').appendTo(target$);\n results = [];\n for (i = 0, len = nodeList.length; i < len; i++) {\n node = nodeList[i];\n node$ = $(`<li class=\"header\">\n <a href=\"${filePath}#${node.data.slug}\">${node.data.title}</a>\n</li>`).appendTo(targetList$);\n appendSearchNode(node$.find('a'));\n results.push(appendHeaderNodes(node$, filePath, node.children));\n }\n return results;\n};\n\n$(function() {\n var nav$, relativeRoot, search$;\n relativeRoot = $('meta[name=\"lidoc-relative-root\"]').attr('content');\n nav$ = buildNav(relativeRoot);\n search$ = $('#search');\n search$.bind('keyup search', (evt) => {\n return searchNodes(search$.val());\n });\n search$.keydown((evt) => {\n if (evt.keyCode === 27) { // Esc\n if (search$.val().trim() === '') {\n return search$.blur();\n } else {\n return search$.val('');\n }\n }\n });\n search$.focus((evt) => {\n return nav$.addClass('active');\n });\n search$.blur((evt) => {\n return nav$.removeClass('active');\n });\n nav$.click((evt) => {\n return search$.focus();\n });\n return nav$.mousedown((evt) => {\n if (search$.is(':focus') && evt.target !== search$[0]) {\n return evt.preventDefault();\n }\n });\n});", "source_lang": "CoffeeScript", "target_lang": "JavaScript", "repo": "nevir/groc", "path": "lib/styles/default/behavior-old.coffee", "license": "MIT", "commit": "e2d2229cac05e6ef5625b636587ca61e21edc288", "stars": 579, "source_url": "https://github.com/nevir/groc/blob/e2d2229cac05e6ef5625b636587ca61e21edc288/lib/styles/default/behavior-old.coffee", "line_start": 98, "line_end": 136}1101{"id": "nevir/groc:lib/styles/default/behavior-old.coffee:6:js_to_coffee", "type": "js_to_coffee", "prompt": "Convert this JavaScript to CoffeeScript.\n```javascript\nvar appendHeaderNodes;\n\nappendHeaderNodes = function(target$, filePath, nodeList) {\n var i, len, node, node$, results, targetList$;\n if (!(nodeList.length > 0)) {\n return;\n }\n targetList$ = $('<ol/>').appendTo(target$);\n results = [];\n for (i = 0, len = nodeList.length; i < len; i++) {\n node = nodeList[i];\n node$ = $(`<li class=\"header\">\n <a href=\"${filePath}#${node.data.slug}\">${node.data.title}</a>\n</li>`).appendTo(targetList$);\n appendSearchNode(node$.find('a'));\n results.push(appendHeaderNodes(node$, filePath, node.children));\n }\n return results;\n};\n\n$(function() {\n var nav$, relativeRoot, search$;\n relativeRoot = $('meta[name=\"lidoc-relative-root\"]').attr('content');\n nav$ = buildNav(relativeRoot);\n search$ = $('#search');\n search$.bind('keyup search', (evt) => {\n return searchNodes(search$.val());\n });\n search$.keydown((evt) => {\n if (evt.keyCode === 27) { // Esc\n if (search$.val().trim() === '') {\n return search$.blur();\n } else {\n return search$.val('');\n }\n }\n });\n search$.focus((evt) => {\n return nav$.addClass('active');\n });\n search$.blur((evt) => {\n return nav$.removeClass('active');\n });\n nav$.click((evt) => {\n return search$.focus();\n });\n return nav$.mousedown((evt) => {\n if (search$.is(':focus') && evt.target !== search$[0]) {\n return evt.preventDefault();\n }\n });\n});\n```", "response": "appendHeaderNodes = (target$, filePath, nodeList) ->\n return unless nodeList.length > 0\n\n targetList$ = $('<ol/>').appendTo target$\n\n for node in nodeList\n node$ = $(\"\"\"\n <li class=\"header\">\n <a href=\"#{filePath}##{node.data.slug}\">#{node.data.title}</a>\n </li>\n \"\"\").appendTo targetList$\n appendSearchNode node$.find('a')\n\n appendHeaderNodes node$, filePath, node.children\n\n$ ->\n relativeRoot = $('meta[name=\"lidoc-relative-root\"]').attr('content')\n nav$ = buildNav relativeRoot\n\n search$ = $('#search')\n search$.bind 'keyup search', (evt) =>\n searchNodes search$.val()\n\n search$.keydown (evt) =>\n if evt.keyCode == 27 # Esc\n if search$.val().trim() == ''\n search$.blur()\n else\n search$.val ''\n\n search$.focus (evt) => nav$.addClass 'active'\n search$.blur (evt) => nav$.removeClass 'active'\n\n nav$.click (evt) =>\n search$.focus()\n\n nav$.mousedown (evt) =>\n if search$.is(':focus') and evt.target != search$[0]\n evt.preventDefault()", "source_lang": "JavaScript", "target_lang": "CoffeeScript", "repo": "nevir/groc", "path": "lib/styles/default/behavior-old.coffee", "license": "MIT", "commit": "e2d2229cac05e6ef5625b636587ca61e21edc288", "stars": 579, "source_url": "https://github.com/nevir/groc/blob/e2d2229cac05e6ef5625b636587ca61e21edc288/lib/styles/default/behavior-old.coffee", "line_start": 98, "line_end": 136}1102{"id": "nevir/groc:lib/styles/default/behavior-old.coffee:6:completion", "type": "completion", "prompt": "appendHeaderNodes = (target$, filePath, nodeList) ->\n return unless nodeList.length > 0\n\n targetList$ = $('<ol/>').appendTo target$\n\n for node in nodeList\n node$ = $(\"\"\"\n <li class=\"header\">\n <a href=\"#{filePath}##{node.data.slug}\">#{node.data.title}</a>\n </li>\n \"\"\").appendTo targetList$\n appendSearchNode node$.find('a')\n\n appendHeaderNodes node$, filePath, node.children\n\n$ ->\n relativeRoot = $('meta[name=\"lidoc-relative-root\"]').attr('content')\n nav$ = buildNav relativeRoot", "response": "search$ = $('#search')\n search$.bind 'keyup search', (evt) =>\n searchNodes search$.val()\n\n search$.keydown (evt) =>\n if evt.keyCode == 27 # Esc\n if search$.val().trim() == ''\n search$.blur()\n else\n search$.val ''\n\n search$.focus (evt) => nav$.addClass 'active'\n search$.blur (evt) => nav$.removeClass 'active'\n\n nav$.click (evt) =>\n search$.focus()\n\n nav$.mousedown (evt) =>\n if search$.is(':focus') and evt.target != search$[0]\n evt.preventDefault()", "source_lang": "CoffeeScript", "target_lang": "CoffeeScript", "repo": "nevir/groc", "path": "lib/styles/default/behavior-old.coffee", "license": "MIT", "commit": "e2d2229cac05e6ef5625b636587ca61e21edc288", "stars": 579, "source_url": "https://github.com/nevir/groc/blob/e2d2229cac05e6ef5625b636587ca61e21edc288/lib/styles/default/behavior-old.coffee", "line_start": 98, "line_end": 136}1103{"id": "abe33/atom-pigments:spec/utils-spec.coffee:1:raw_corpus", "type": "raw_corpus", "prompt": "", "response": "{findClosingIndex, split} = require '../lib/utils'\n\ndescribe '.split()', ->\n tests = [\n ['a,b,c', ['a', 'b', 'c']]\n ['a,b(),c', ['a', 'b()', 'c']]\n ['a,b(c)', ['a', 'b(c)']]\n ['a,(b, c)', ['a', '(b,c)']]\n ['a,(b, c())', ['a', '(b,c())']]\n ['a(b, c())', ['a(b,c())']]\n ['a,)(', ['a']]\n ['a(,', []]\n ['(,', []]\n ['(,(,(,)', []]\n ['a,(,', ['a']]\n ['a,((),', ['a']]\n ['a,()),', ['a', '()']]\n ]\n\n tests.forEach ([source, expected]) ->\n it \"splits #{jasmine.pp source} as #{jasmine.pp(expected)}\", ->\n expect(split(source)).toEqual(expected)\n\ndescribe '.findClosingIndex()', ->\n tests = [\n ['a(', -1]\n ['a()', 2]\n ['a(((()', -1]\n ]\n\n tests.forEach ([source, expected]) ->\n it \"returs the index of the closing character\", ->\n expect(findClosingIndex(source, 2, '(', ')')).toEqual(expected)", "source_lang": "", "target_lang": "CoffeeScript", "repo": "abe33/atom-pigments", "path": "spec/utils-spec.coffee", "license": "MIT", "commit": "4bdef2e1ebeaa492a6c353c2fd9e7adecdebadf4", "stars": 518, "source_url": "https://github.com/abe33/atom-pigments/blob/4bdef2e1ebeaa492a6c353c2fd9e7adecdebadf4/spec/utils-spec.coffee", "line_start": 1, "line_end": 33}1104{"id": "abe33/atom-pigments:spec/utils-spec.coffee:1:coffee_to_js", "type": "coffee_to_js", "prompt": "Convert this CoffeeScript to JavaScript.\n```coffeescript\n{findClosingIndex, split} = require '../lib/utils'\n\ndescribe '.split()', ->\n tests = [\n ['a,b,c', ['a', 'b', 'c']]\n ['a,b(),c', ['a', 'b()', 'c']]\n ['a,b(c)', ['a', 'b(c)']]\n ['a,(b, c)', ['a', '(b,c)']]\n ['a,(b, c())', ['a', '(b,c())']]\n ['a(b, c())', ['a(b,c())']]\n ['a,)(', ['a']]\n ['a(,', []]\n ['(,', []]\n ['(,(,(,)', []]\n ['a,(,', ['a']]\n ['a,((),', ['a']]\n ['a,()),', ['a', '()']]\n ]\n\n tests.forEach ([source, expected]) ->\n it \"splits #{jasmine.pp source} as #{jasmine.pp(expected)}\", ->\n expect(split(source)).toEqual(expected)\n\ndescribe '.findClosingIndex()', ->\n tests = [\n ['a(', -1]\n ['a()', 2]\n ['a(((()', -1]\n ]\n\n tests.forEach ([source, expected]) ->\n it \"returs the index of the closing character\", ->\n expect(findClosingIndex(source, 2, '(', ')')).toEqual(expected)\n```", "response": "var findClosingIndex, split;\n\n({findClosingIndex, split} = require('../lib/utils'));\n\ndescribe('.split()', function() {\n var tests;\n tests = [['a,b,c', ['a', 'b', 'c']], ['a,b(),c', ['a', 'b()', 'c']], ['a,b(c)', ['a', 'b(c)']], ['a,(b, c)', ['a', '(b,c)']], ['a,(b, c())', ['a', '(b,c())']], ['a(b, c())', ['a(b,c())']], ['a,)(', ['a']], ['a(,', []], ['(,', []], ['(,(,(,)', []], ['a,(,', ['a']], ['a,((),', ['a']], ['a,()),', ['a', '()']]];\n return tests.forEach(function([source, expected]) {\n return it(`splits ${jasmine.pp(source)} as ${jasmine.pp(expected)}`, function() {\n return expect(split(source)).toEqual(expected);\n });\n });\n});\n\ndescribe('.findClosingIndex()', function() {\n var tests;\n tests = [['a(', -1], ['a()', 2], ['a(((()', -1]];\n return tests.forEach(function([source, expected]) {\n return it(\"returs the index of the closing character\", function() {\n return expect(findClosingIndex(source, 2, '(', ')')).toEqual(expected);\n });\n });\n});", "source_lang": "CoffeeScript", "target_lang": "JavaScript", "repo": "abe33/atom-pigments", "path": "spec/utils-spec.coffee", "license": "MIT", "commit": "4bdef2e1ebeaa492a6c353c2fd9e7adecdebadf4", "stars": 518, "source_url": "https://github.com/abe33/atom-pigments/blob/4bdef2e1ebeaa492a6c353c2fd9e7adecdebadf4/spec/utils-spec.coffee", "line_start": 1, "line_end": 33}1105{"id": "abe33/atom-pigments:spec/utils-spec.coffee:1:js_to_coffee", "type": "js_to_coffee", "prompt": "Convert this JavaScript to CoffeeScript.\n```javascript\nvar findClosingIndex, split;\n\n({findClosingIndex, split} = require('../lib/utils'));\n\ndescribe('.split()', function() {\n var tests;\n tests = [['a,b,c', ['a', 'b', 'c']], ['a,b(),c', ['a', 'b()', 'c']], ['a,b(c)', ['a', 'b(c)']], ['a,(b, c)', ['a', '(b,c)']], ['a,(b, c())', ['a', '(b,c())']], ['a(b, c())', ['a(b,c())']], ['a,)(', ['a']], ['a(,', []], ['(,', []], ['(,(,(,)', []], ['a,(,', ['a']], ['a,((),', ['a']], ['a,()),', ['a', '()']]];\n return tests.forEach(function([source, expected]) {\n return it(`splits ${jasmine.pp(source)} as ${jasmine.pp(expected)}`, function() {\n return expect(split(source)).toEqual(expected);\n });\n });\n});\n\ndescribe('.findClosingIndex()', function() {\n var tests;\n tests = [['a(', -1], ['a()', 2], ['a(((()', -1]];\n return tests.forEach(function([source, expected]) {\n return it(\"returs the index of the closing character\", function() {\n return expect(findClosingIndex(source, 2, '(', ')')).toEqual(expected);\n });\n });\n});\n```", "response": "{findClosingIndex, split} = require '../lib/utils'\n\ndescribe '.split()', ->\n tests = [\n ['a,b,c', ['a', 'b', 'c']]\n ['a,b(),c', ['a', 'b()', 'c']]\n ['a,b(c)', ['a', 'b(c)']]\n ['a,(b, c)', ['a', '(b,c)']]\n ['a,(b, c())', ['a', '(b,c())']]\n ['a(b, c())', ['a(b,c())']]\n ['a,)(', ['a']]\n ['a(,', []]\n ['(,', []]\n ['(,(,(,)', []]\n ['a,(,', ['a']]\n ['a,((),', ['a']]\n ['a,()),', ['a', '()']]\n ]\n\n tests.forEach ([source, expected]) ->\n it \"splits #{jasmine.pp source} as #{jasmine.pp(expected)}\", ->\n expect(split(source)).toEqual(expected)\n\ndescribe '.findClosingIndex()', ->\n tests = [\n ['a(', -1]\n ['a()', 2]\n ['a(((()', -1]\n ]\n\n tests.forEach ([source, expected]) ->\n it \"returs the index of the closing character\", ->\n expect(findClosingIndex(source, 2, '(', ')')).toEqual(expected)", "source_lang": "JavaScript", "target_lang": "CoffeeScript", "repo": "abe33/atom-pigments", "path": "spec/utils-spec.coffee", "license": "MIT", "commit": "4bdef2e1ebeaa492a6c353c2fd9e7adecdebadf4", "stars": 518, "source_url": "https://github.com/abe33/atom-pigments/blob/4bdef2e1ebeaa492a6c353c2fd9e7adecdebadf4/spec/utils-spec.coffee", "line_start": 1, "line_end": 33}1106{"id": "abe33/atom-pigments:spec/utils-spec.coffee:1:completion", "type": "completion", "prompt": "{findClosingIndex, split} = require '../lib/utils'\n\ndescribe '.split()', ->\n tests = [\n ['a,b,c', ['a', 'b', 'c']]\n ['a,b(),c', ['a', 'b()', 'c']]\n ['a,b(c)', ['a', 'b(c)']]\n ['a,(b, c)', ['a', '(b,c)']]\n ['a,(b, c())', ['a', '(b,c())']]\n ['a(b, c())', ['a(b,c())']]\n ['a,)(', ['a']]\n ['a(,', []]\n ['(,', []]\n ['(,(,(,)', []]\n ['a,(,', ['a']]\n ['a,((),', ['a']]", "response": "['a,()),', ['a', '()']]\n ]\n\n tests.forEach ([source, expected]) ->\n it \"splits #{jasmine.pp source} as #{jasmine.pp(expected)}\", ->\n expect(split(source)).toEqual(expected)\n\ndescribe '.findClosingIndex()', ->\n tests = [\n ['a(', -1]\n ['a()', 2]\n ['a(((()', -1]\n ]\n\n tests.forEach ([source, expected]) ->\n it \"returs the index of the closing character\", ->\n expect(findClosingIndex(source, 2, '(', ')')).toEqual(expected)", "source_lang": "CoffeeScript", "target_lang": "CoffeeScript", "repo": "abe33/atom-pigments", "path": "spec/utils-spec.coffee", "license": "MIT", "commit": "4bdef2e1ebeaa492a6c353c2fd9e7adecdebadf4", "stars": 518, "source_url": "https://github.com/abe33/atom-pigments/blob/4bdef2e1ebeaa492a6c353c2fd9e7adecdebadf4/spec/utils-spec.coffee", "line_start": 1, "line_end": 33}1107{"id": "abe33/atom-pigments:spec/utils-spec.coffee:1:raw_corpus", "type": "raw_corpus", "prompt": "", "response": "{findClosingIndex, split} = require '../lib/utils'\n\ndescribe 'split', ->\n tests = [\n ['a,b,c', ['a', 'b', 'c']]\n ['a,b(),c', ['a', 'b()', 'c']]\n ['a,b(c)', ['a', 'b(c)']]\n ['a,(b, c)', ['a', '(b,c)']]\n ['a,(b, c())', ['a', '(b,c())']]\n ['a(b, c())', ['a(b,c())']]\n ['a,)(', ['a']]\n ['a(,', []]\n ['(,', []]\n ['a,(,', ['a']]\n ['a,((),', ['a']]\n ['a,()),', ['a', '()']]\n ]\n\n tests.forEach ([source, expected]) ->\n it \"splits #{jasmine.pp source} as #{jasmine.pp(expected)}\", ->\n expect(split(source)).toEqual(expected)", "source_lang": "", "target_lang": "CoffeeScript", "repo": "abe33/atom-pigments", "path": "spec/utils-spec.coffee", "license": "MIT", "commit": "4f52ba925ec5ef67d1cbf999cdecbec5a5ee76aa", "stars": 518, "source_url": "https://github.com/abe33/atom-pigments/blob/4f52ba925ec5ef67d1cbf999cdecbec5a5ee76aa/spec/utils-spec.coffee", "line_start": 1, "line_end": 21}1108{"id": "abe33/atom-pigments:spec/utils-spec.coffee:1:coffee_to_js", "type": "coffee_to_js", "prompt": "Convert this CoffeeScript to JavaScript.\n```coffeescript\n{findClosingIndex, split} = require '../lib/utils'\n\ndescribe 'split', ->\n tests = [\n ['a,b,c', ['a', 'b', 'c']]\n ['a,b(),c', ['a', 'b()', 'c']]\n ['a,b(c)', ['a', 'b(c)']]\n ['a,(b, c)', ['a', '(b,c)']]\n ['a,(b, c())', ['a', '(b,c())']]\n ['a(b, c())', ['a(b,c())']]\n ['a,)(', ['a']]\n ['a(,', []]\n ['(,', []]\n ['a,(,', ['a']]\n ['a,((),', ['a']]\n ['a,()),', ['a', '()']]\n ]\n\n tests.forEach ([source, expected]) ->\n it \"splits #{jasmine.pp source} as #{jasmine.pp(expected)}\", ->\n expect(split(source)).toEqual(expected)\n```", "response": "var findClosingIndex, split;\n\n({findClosingIndex, split} = require('../lib/utils'));\n\ndescribe('split', function() {\n var tests;\n tests = [['a,b,c', ['a', 'b', 'c']], ['a,b(),c', ['a', 'b()', 'c']], ['a,b(c)', ['a', 'b(c)']], ['a,(b, c)', ['a', '(b,c)']], ['a,(b, c())', ['a', '(b,c())']], ['a(b, c())', ['a(b,c())']], ['a,)(', ['a']], ['a(,', []], ['(,', []], ['a,(,', ['a']], ['a,((),', ['a']], ['a,()),', ['a', '()']]];\n return tests.forEach(function([source, expected]) {\n return it(`splits ${jasmine.pp(source)} as ${jasmine.pp(expected)}`, function() {\n return expect(split(source)).toEqual(expected);\n });\n });\n});", "source_lang": "CoffeeScript", "target_lang": "JavaScript", "repo": "abe33/atom-pigments", "path": "spec/utils-spec.coffee", "license": "MIT", "commit": "4f52ba925ec5ef67d1cbf999cdecbec5a5ee76aa", "stars": 518, "source_url": "https://github.com/abe33/atom-pigments/blob/4f52ba925ec5ef67d1cbf999cdecbec5a5ee76aa/spec/utils-spec.coffee", "line_start": 1, "line_end": 21}1109{"id": "abe33/atom-pigments:spec/utils-spec.coffee:1:js_to_coffee", "type": "js_to_coffee", "prompt": "Convert this JavaScript to CoffeeScript.\n```javascript\nvar findClosingIndex, split;\n\n({findClosingIndex, split} = require('../lib/utils'));\n\ndescribe('split', function() {\n var tests;\n tests = [['a,b,c', ['a', 'b', 'c']], ['a,b(),c', ['a', 'b()', 'c']], ['a,b(c)', ['a', 'b(c)']], ['a,(b, c)', ['a', '(b,c)']], ['a,(b, c())', ['a', '(b,c())']], ['a(b, c())', ['a(b,c())']], ['a,)(', ['a']], ['a(,', []], ['(,', []], ['a,(,', ['a']], ['a,((),', ['a']], ['a,()),', ['a', '()']]];\n return tests.forEach(function([source, expected]) {\n return it(`splits ${jasmine.pp(source)} as ${jasmine.pp(expected)}`, function() {\n return expect(split(source)).toEqual(expected);\n });\n });\n});\n```", "response": "{findClosingIndex, split} = require '../lib/utils'\n\ndescribe 'split', ->\n tests = [\n ['a,b,c', ['a', 'b', 'c']]\n ['a,b(),c', ['a', 'b()', 'c']]\n ['a,b(c)', ['a', 'b(c)']]\n ['a,(b, c)', ['a', '(b,c)']]\n ['a,(b, c())', ['a', '(b,c())']]\n ['a(b, c())', ['a(b,c())']]\n ['a,)(', ['a']]\n ['a(,', []]\n ['(,', []]\n ['a,(,', ['a']]\n ['a,((),', ['a']]\n ['a,()),', ['a', '()']]\n ]\n\n tests.forEach ([source, expected]) ->\n it \"splits #{jasmine.pp source} as #{jasmine.pp(expected)}\", ->\n expect(split(source)).toEqual(expected)", "source_lang": "JavaScript", "target_lang": "CoffeeScript", "repo": "abe33/atom-pigments", "path": "spec/utils-spec.coffee", "license": "MIT", "commit": "4f52ba925ec5ef67d1cbf999cdecbec5a5ee76aa", "stars": 518, "source_url": "https://github.com/abe33/atom-pigments/blob/4f52ba925ec5ef67d1cbf999cdecbec5a5ee76aa/spec/utils-spec.coffee", "line_start": 1, "line_end": 21}1110{"id": "abe33/atom-pigments:spec/utils-spec.coffee:1:completion", "type": "completion", "prompt": "{findClosingIndex, split} = require '../lib/utils'\n\ndescribe 'split', ->\n tests = [\n ['a,b,c', ['a', 'b', 'c']]\n ['a,b(),c', ['a', 'b()', 'c']]\n ['a,b(c)', ['a', 'b(c)']]\n ['a,(b, c)', ['a', '(b,c)']]\n ['a,(b, c())', ['a', '(b,c())']]\n ['a(b, c())', ['a(b,c())']]", "response": "['a,)(', ['a']]\n ['a(,', []]\n ['(,', []]\n ['a,(,', ['a']]\n ['a,((),', ['a']]\n ['a,()),', ['a', '()']]\n ]\n\n tests.forEach ([source, expected]) ->\n it \"splits #{jasmine.pp source} as #{jasmine.pp(expected)}\", ->\n expect(split(source)).toEqual(expected)", "source_lang": "CoffeeScript", "target_lang": "CoffeeScript", "repo": "abe33/atom-pigments", "path": "spec/utils-spec.coffee", "license": "MIT", "commit": "4f52ba925ec5ef67d1cbf999cdecbec5a5ee76aa", "stars": 518, "source_url": "https://github.com/abe33/atom-pigments/blob/4f52ba925ec5ef67d1cbf999cdecbec5a5ee76aa/spec/utils-spec.coffee", "line_start": 1, "line_end": 21}1111{"id": "abe33/atom-pigments:spec/utils-spec.coffee:1:raw_corpus", "type": "raw_corpus", "prompt": "", "response": "{findClosingIndex, split} = require '../lib/utils'\n\ndescribe 'split', ->\n it 'does not fail when there is parenthesis after', ->\n string = \"a,)(\"\n\n res = split(string)\n\n expect(res).toEqual(['a',''])", "source_lang": "", "target_lang": "CoffeeScript", "repo": "abe33/atom-pigments", "path": "spec/utils-spec.coffee", "license": "MIT", "commit": "6b9b5368e8a617bbb73ccdb1da96350aba9fd444", "stars": 518, "source_url": "https://github.com/abe33/atom-pigments/blob/6b9b5368e8a617bbb73ccdb1da96350aba9fd444/spec/utils-spec.coffee", "line_start": 1, "line_end": 9}1112{"id": "abe33/atom-pigments:spec/utils-spec.coffee:1:coffee_to_js", "type": "coffee_to_js", "prompt": "Convert this CoffeeScript to JavaScript.\n```coffeescript\n{findClosingIndex, split} = require '../lib/utils'\n\ndescribe 'split', ->\n it 'does not fail when there is parenthesis after', ->\n string = \"a,)(\"\n\n res = split(string)\n\n expect(res).toEqual(['a',''])\n```", "response": "var findClosingIndex, split;\n\n({findClosingIndex, split} = require('../lib/utils'));\n\ndescribe('split', function() {\n return it('does not fail when there is parenthesis after', function() {\n var res, string;\n string = \"a,)(\";\n res = split(string);\n return expect(res).toEqual(['a', '']);\n });\n});", "source_lang": "CoffeeScript", "target_lang": "JavaScript", "repo": "abe33/atom-pigments", "path": "spec/utils-spec.coffee", "license": "MIT", "commit": "6b9b5368e8a617bbb73ccdb1da96350aba9fd444", "stars": 518, "source_url": "https://github.com/abe33/atom-pigments/blob/6b9b5368e8a617bbb73ccdb1da96350aba9fd444/spec/utils-spec.coffee", "line_start": 1, "line_end": 9}1113{"id": "abe33/atom-pigments:spec/utils-spec.coffee:1:js_to_coffee", "type": "js_to_coffee", "prompt": "Convert this JavaScript to CoffeeScript.\n```javascript\nvar findClosingIndex, split;\n\n({findClosingIndex, split} = require('../lib/utils'));\n\ndescribe('split', function() {\n return it('does not fail when there is parenthesis after', function() {\n var res, string;\n string = \"a,)(\";\n res = split(string);\n return expect(res).toEqual(['a', '']);\n });\n});\n```", "response": "{findClosingIndex, split} = require '../lib/utils'\n\ndescribe 'split', ->\n it 'does not fail when there is parenthesis after', ->\n string = \"a,)(\"\n\n res = split(string)\n\n expect(res).toEqual(['a',''])", "source_lang": "JavaScript", "target_lang": "CoffeeScript", "repo": "abe33/atom-pigments", "path": "spec/utils-spec.coffee", "license": "MIT", "commit": "6b9b5368e8a617bbb73ccdb1da96350aba9fd444", "stars": 518, "source_url": "https://github.com/abe33/atom-pigments/blob/6b9b5368e8a617bbb73ccdb1da96350aba9fd444/spec/utils-spec.coffee", "line_start": 1, "line_end": 9}1114{"id": "abe33/atom-pigments:spec/utils-spec.coffee:1:completion", "type": "completion", "prompt": "{findClosingIndex, split} = require '../lib/utils'\n\ndescribe 'split', ->\n it 'does not fail when there is parenthesis after', ->", "response": "string = \"a,)(\"\n\n res = split(string)\n\n expect(res).toEqual(['a',''])", "source_lang": "CoffeeScript", "target_lang": "CoffeeScript", "repo": "abe33/atom-pigments", "path": "spec/utils-spec.coffee", "license": "MIT", "commit": "6b9b5368e8a617bbb73ccdb1da96350aba9fd444", "stars": 518, "source_url": "https://github.com/abe33/atom-pigments/blob/6b9b5368e8a617bbb73ccdb1da96350aba9fd444/spec/utils-spec.coffee", "line_start": 1, "line_end": 9}1115{"id": "js2coffee/js2coffee:test/parse.coffee:1:raw_corpus", "type": "raw_corpus", "prompt": "", "response": "require 'coffee-script/register'\nrequire './setup'\n\ndescribe 'parse()', ->\n it 'works', ->\n out = js2coffee.parse(\"// hi\\na=2\")\n expect(out.ast).be.an('object')\n expect(out.map).be.an('object')\n expect(out.code).be.a('string')\n # console.log(require('util').inspect(out, { depth: 1000 }))", "source_lang": "", "target_lang": "CoffeeScript", "repo": "js2coffee/js2coffee", "path": "test/parse.coffee", "license": "MIT", "commit": "bfc11f90ef657fdbfe40ad982a7361636fe887b4", "stars": 2082, "source_url": "https://github.com/js2coffee/js2coffee/blob/bfc11f90ef657fdbfe40ad982a7361636fe887b4/test/parse.coffee", "line_start": 1, "line_end": 10}1116{"id": "js2coffee/js2coffee:test/parse.coffee:1:coffee_to_js", "type": "coffee_to_js", "prompt": "Convert this CoffeeScript to JavaScript.\n```coffeescript\nrequire 'coffee-script/register'\nrequire './setup'\n\ndescribe 'parse()', ->\n it 'works', ->\n out = js2coffee.parse(\"// hi\\na=2\")\n expect(out.ast).be.an('object')\n expect(out.map).be.an('object')\n expect(out.code).be.a('string')\n # console.log(require('util').inspect(out, { depth: 1000 }))\n```", "response": "require('coffee-script/register');\n\nrequire('./setup');\n\ndescribe('parse()', function() {\n return it('works', function() {\n var out;\n out = js2coffee.parse(\"// hi\\na=2\");\n expect(out.ast).be.an('object');\n expect(out.map).be.an('object');\n return expect(out.code).be.a('string');\n });\n});\n\n// console.log(require('util').inspect(out, { depth: 1000 }))", "source_lang": "CoffeeScript", "target_lang": "JavaScript", "repo": "js2coffee/js2coffee", "path": "test/parse.coffee", "license": "MIT", "commit": "bfc11f90ef657fdbfe40ad982a7361636fe887b4", "stars": 2082, "source_url": "https://github.com/js2coffee/js2coffee/blob/bfc11f90ef657fdbfe40ad982a7361636fe887b4/test/parse.coffee", "line_start": 1, "line_end": 10}1117{"id": "js2coffee/js2coffee:test/parse.coffee:1:js_to_coffee", "type": "js_to_coffee", "prompt": "Convert this JavaScript to CoffeeScript.\n```javascript\nrequire('coffee-script/register');\n\nrequire('./setup');\n\ndescribe('parse()', function() {\n return it('works', function() {\n var out;\n out = js2coffee.parse(\"// hi\\na=2\");\n expect(out.ast).be.an('object');\n expect(out.map).be.an('object');\n return expect(out.code).be.a('string');\n });\n});\n\n// console.log(require('util').inspect(out, { depth: 1000 }))\n```", "response": "require 'coffee-script/register'\nrequire './setup'\n\ndescribe 'parse()', ->\n it 'works', ->\n out = js2coffee.parse(\"// hi\\na=2\")\n expect(out.ast).be.an('object')\n expect(out.map).be.an('object')\n expect(out.code).be.a('string')\n # console.log(require('util').inspect(out, { depth: 1000 }))", "source_lang": "JavaScript", "target_lang": "CoffeeScript", "repo": "js2coffee/js2coffee", "path": "test/parse.coffee", "license": "MIT", "commit": "bfc11f90ef657fdbfe40ad982a7361636fe887b4", "stars": 2082, "source_url": "https://github.com/js2coffee/js2coffee/blob/bfc11f90ef657fdbfe40ad982a7361636fe887b4/test/parse.coffee", "line_start": 1, "line_end": 10}1118{"id": "js2coffee/js2coffee:test/parse.coffee:1:completion", "type": "completion", "prompt": "require 'coffee-script/register'\nrequire './setup'\n\ndescribe 'parse()', ->\n it 'works', ->", "response": "out = js2coffee.parse(\"// hi\\na=2\")\n expect(out.ast).be.an('object')\n expect(out.map).be.an('object')\n expect(out.code).be.a('string')\n # console.log(require('util').inspect(out, { depth: 1000 }))", "source_lang": "CoffeeScript", "target_lang": "CoffeeScript", "repo": "js2coffee/js2coffee", "path": "test/parse.coffee", "license": "MIT", "commit": "bfc11f90ef657fdbfe40ad982a7361636fe887b4", "stars": 2082, "source_url": "https://github.com/js2coffee/js2coffee/blob/bfc11f90ef657fdbfe40ad982a7361636fe887b4/test/parse.coffee", "line_start": 1, "line_end": 10}1119{"id": "octoblu/meshblu:lib/SocketIOLimiter.coffee:1:raw_corpus", "type": "raw_corpus", "prompt": "", "response": "SocketIOThrottle = require './SocketIOThrottle'\n\nclass Limiter\n constructor: (@socket) ->\n\n throttle: (callback=->) =>\n ->\n originalArguments = arguments\n new SocketIOThrottle().throttle @socket, =>\n callback.apply this, originalArguments\n\nmodule.exports = Limiter", "source_lang": "", "target_lang": "CoffeeScript", "repo": "octoblu/meshblu", "path": "lib/SocketIOLimiter.coffee", "license": "MIT", "commit": "77687429c42e3a7e9bb2fcb9a04c9cbf8c7d91bc", "stars": 815, "source_url": "https://github.com/octoblu/meshblu/blob/77687429c42e3a7e9bb2fcb9a04c9cbf8c7d91bc/lib/SocketIOLimiter.coffee", "line_start": 1, "line_end": 12}1120{"id": "octoblu/meshblu:lib/SocketIOLimiter.coffee:1:coffee_to_js", "type": "coffee_to_js", "prompt": "Convert this CoffeeScript to JavaScript.\n```coffeescript\nSocketIOThrottle = require './SocketIOThrottle'\n\nclass Limiter\n constructor: (@socket) ->\n\n throttle: (callback=->) =>\n ->\n originalArguments = arguments\n new SocketIOThrottle().throttle @socket, =>\n callback.apply this, originalArguments\n\nmodule.exports = Limiter\n```", "response": "var Limiter, SocketIOThrottle;\n\nSocketIOThrottle = require('./SocketIOThrottle');\n\nLimiter = class Limiter {\n constructor(socket) {\n this.throttle = this.throttle.bind(this);\n this.socket = socket;\n }\n\n throttle(callback = function() {}) {\n return function() {\n var originalArguments;\n originalArguments = arguments;\n return new SocketIOThrottle().throttle(this.socket, () => {\n return callback.apply(this, originalArguments);\n });\n };\n }\n\n};\n\nmodule.exports = Limiter;", "source_lang": "CoffeeScript", "target_lang": "JavaScript", "repo": "octoblu/meshblu", "path": "lib/SocketIOLimiter.coffee", "license": "MIT", "commit": "77687429c42e3a7e9bb2fcb9a04c9cbf8c7d91bc", "stars": 815, "source_url": "https://github.com/octoblu/meshblu/blob/77687429c42e3a7e9bb2fcb9a04c9cbf8c7d91bc/lib/SocketIOLimiter.coffee", "line_start": 1, "line_end": 12}1121{"id": "octoblu/meshblu:lib/SocketIOLimiter.coffee:1:js_to_coffee", "type": "js_to_coffee", "prompt": "Convert this JavaScript to CoffeeScript.\n```javascript\nvar Limiter, SocketIOThrottle;\n\nSocketIOThrottle = require('./SocketIOThrottle');\n\nLimiter = class Limiter {\n constructor(socket) {\n this.throttle = this.throttle.bind(this);\n this.socket = socket;\n }\n\n throttle(callback = function() {}) {\n return function() {\n var originalArguments;\n originalArguments = arguments;\n return new SocketIOThrottle().throttle(this.socket, () => {\n return callback.apply(this, originalArguments);\n });\n };\n }\n\n};\n\nmodule.exports = Limiter;\n```", "response": "SocketIOThrottle = require './SocketIOThrottle'\n\nclass Limiter\n constructor: (@socket) ->\n\n throttle: (callback=->) =>\n ->\n originalArguments = arguments\n new SocketIOThrottle().throttle @socket, =>\n callback.apply this, originalArguments\n\nmodule.exports = Limiter", "source_lang": "JavaScript", "target_lang": "CoffeeScript", "repo": "octoblu/meshblu", "path": "lib/SocketIOLimiter.coffee", "license": "MIT", "commit": "77687429c42e3a7e9bb2fcb9a04c9cbf8c7d91bc", "stars": 815, "source_url": "https://github.com/octoblu/meshblu/blob/77687429c42e3a7e9bb2fcb9a04c9cbf8c7d91bc/lib/SocketIOLimiter.coffee", "line_start": 1, "line_end": 12}1122{"id": "octoblu/meshblu:lib/SocketIOLimiter.coffee:1:completion", "type": "completion", "prompt": "SocketIOThrottle = require './SocketIOThrottle'\n\nclass Limiter\n constructor: (@socket) ->\n\n throttle: (callback=->) =>", "response": "->\n originalArguments = arguments\n new SocketIOThrottle().throttle @socket, =>\n callback.apply this, originalArguments\n\nmodule.exports = Limiter", "source_lang": "CoffeeScript", "target_lang": "CoffeeScript", "repo": "octoblu/meshblu", "path": "lib/SocketIOLimiter.coffee", "license": "MIT", "commit": "77687429c42e3a7e9bb2fcb9a04c9cbf8c7d91bc", "stars": 815, "source_url": "https://github.com/octoblu/meshblu/blob/77687429c42e3a7e9bb2fcb9a04c9cbf8c7d91bc/lib/SocketIOLimiter.coffee", "line_start": 1, "line_end": 12}1123{"id": "octoblu/meshblu:lib/SocketIOLimiter.coffee:1:raw_corpus", "type": "raw_corpus", "prompt": "", "response": "SocketIOThrottle = require './SocketIOThrottle'\n\nclass Limiter\n constructor: (@socket) ->\n\n throttle: (@callback=->) =>\n @throttled\n\n throttled: =>\n originalArguments = arguments\n new SocketIOThrottle().throttle @socket, =>\n @callback.apply this, originalArguments\n\nmodule.exports = Limiter", "source_lang": "", "target_lang": "CoffeeScript", "repo": "octoblu/meshblu", "path": "lib/SocketIOLimiter.coffee", "license": "MIT", "commit": "edf1db3062b6872de5f1b418aced623e9dafa587", "stars": 815, "source_url": "https://github.com/octoblu/meshblu/blob/edf1db3062b6872de5f1b418aced623e9dafa587/lib/SocketIOLimiter.coffee", "line_start": 1, "line_end": 14}1124{"id": "octoblu/meshblu:lib/SocketIOLimiter.coffee:1:coffee_to_js", "type": "coffee_to_js", "prompt": "Convert this CoffeeScript to JavaScript.\n```coffeescript\nSocketIOThrottle = require './SocketIOThrottle'\n\nclass Limiter\n constructor: (@socket) ->\n\n throttle: (@callback=->) =>\n @throttled\n\n throttled: =>\n originalArguments = arguments\n new SocketIOThrottle().throttle @socket, =>\n @callback.apply this, originalArguments\n\nmodule.exports = Limiter\n```", "response": "var Limiter, SocketIOThrottle;\n\nSocketIOThrottle = require('./SocketIOThrottle');\n\nLimiter = class Limiter {\n constructor(socket) {\n this.throttle = this.throttle.bind(this);\n this.throttled = this.throttled.bind(this);\n this.socket = socket;\n }\n\n throttle(callback = function() {}) {\n this.callback = callback;\n return this.throttled;\n }\n\n throttled() {\n var originalArguments;\n originalArguments = arguments;\n return new SocketIOThrottle().throttle(this.socket, () => {\n return this.callback.apply(this, originalArguments);\n });\n }\n\n};\n\nmodule.exports = Limiter;", "source_lang": "CoffeeScript", "target_lang": "JavaScript", "repo": "octoblu/meshblu", "path": "lib/SocketIOLimiter.coffee", "license": "MIT", "commit": "edf1db3062b6872de5f1b418aced623e9dafa587", "stars": 815, "source_url": "https://github.com/octoblu/meshblu/blob/edf1db3062b6872de5f1b418aced623e9dafa587/lib/SocketIOLimiter.coffee", "line_start": 1, "line_end": 14}1125{"id": "octoblu/meshblu:lib/SocketIOLimiter.coffee:1:js_to_coffee", "type": "js_to_coffee", "prompt": "Convert this JavaScript to CoffeeScript.\n```javascript\nvar Limiter, SocketIOThrottle;\n\nSocketIOThrottle = require('./SocketIOThrottle');\n\nLimiter = class Limiter {\n constructor(socket) {\n this.throttle = this.throttle.bind(this);\n this.throttled = this.throttled.bind(this);\n this.socket = socket;\n }\n\n throttle(callback = function() {}) {\n this.callback = callback;\n return this.throttled;\n }\n\n throttled() {\n var originalArguments;\n originalArguments = arguments;\n return new SocketIOThrottle().throttle(this.socket, () => {\n return this.callback.apply(this, originalArguments);\n });\n }\n\n};\n\nmodule.exports = Limiter;\n```", "response": "SocketIOThrottle = require './SocketIOThrottle'\n\nclass Limiter\n constructor: (@socket) ->\n\n throttle: (@callback=->) =>\n @throttled\n\n throttled: =>\n originalArguments = arguments\n new SocketIOThrottle().throttle @socket, =>\n @callback.apply this, originalArguments\n\nmodule.exports = Limiter", "source_lang": "JavaScript", "target_lang": "CoffeeScript", "repo": "octoblu/meshblu", "path": "lib/SocketIOLimiter.coffee", "license": "MIT", "commit": "edf1db3062b6872de5f1b418aced623e9dafa587", "stars": 815, "source_url": "https://github.com/octoblu/meshblu/blob/edf1db3062b6872de5f1b418aced623e9dafa587/lib/SocketIOLimiter.coffee", "line_start": 1, "line_end": 14}1126{"id": "octoblu/meshblu:lib/SocketIOLimiter.coffee:1:completion", "type": "completion", "prompt": "SocketIOThrottle = require './SocketIOThrottle'\n\nclass Limiter\n constructor: (@socket) ->\n\n throttle: (@callback=->) =>\n @throttled", "response": "throttled: =>\n originalArguments = arguments\n new SocketIOThrottle().throttle @socket, =>\n @callback.apply this, originalArguments\n\nmodule.exports = Limiter", "source_lang": "CoffeeScript", "target_lang": "CoffeeScript", "repo": "octoblu/meshblu", "path": "lib/SocketIOLimiter.coffee", "license": "MIT", "commit": "edf1db3062b6872de5f1b418aced623e9dafa587", "stars": 815, "source_url": "https://github.com/octoblu/meshblu/blob/edf1db3062b6872de5f1b418aced623e9dafa587/lib/SocketIOLimiter.coffee", "line_start": 1, "line_end": 14}1127{"id": "linemanjs/lineman:lib/resolves-quietly.coffee:1:raw_corpus", "type": "raw_corpus", "prompt": "", "response": "resolve = require('resolve')\npath = require('path')\n\nmodule.exports =\n resolve: (requirable, opts) ->\n try\n path.dirname(resolve.sync(\"#{requirable}/package.json\", opts))\n catch e\n undefined", "source_lang": "", "target_lang": "CoffeeScript", "repo": "linemanjs/lineman", "path": "lib/resolves-quietly.coffee", "license": "MIT", "commit": "61d681532d9621e578d319c279006bbb728ece4b", "stars": 1168, "source_url": "https://github.com/linemanjs/lineman/blob/61d681532d9621e578d319c279006bbb728ece4b/lib/resolves-quietly.coffee", "line_start": 1, "line_end": 9}1128{"id": "linemanjs/lineman:lib/resolves-quietly.coffee:1:coffee_to_js", "type": "coffee_to_js", "prompt": "Convert this CoffeeScript to JavaScript.\n```coffeescript\nresolve = require('resolve')\npath = require('path')\n\nmodule.exports =\n resolve: (requirable, opts) ->\n try\n path.dirname(resolve.sync(\"#{requirable}/package.json\", opts))\n catch e\n undefined\n```", "response": "var path, resolve;\n\nresolve = require('resolve');\n\npath = require('path');\n\nmodule.exports = {\n resolve: function(requirable, opts) {\n var e;\n try {\n return path.dirname(resolve.sync(`${requirable}/package.json`, opts));\n } catch (error) {\n e = error;\n return void 0;\n }\n }\n};", "source_lang": "CoffeeScript", "target_lang": "JavaScript", "repo": "linemanjs/lineman", "path": "lib/resolves-quietly.coffee", "license": "MIT", "commit": "61d681532d9621e578d319c279006bbb728ece4b", "stars": 1168, "source_url": "https://github.com/linemanjs/lineman/blob/61d681532d9621e578d319c279006bbb728ece4b/lib/resolves-quietly.coffee", "line_start": 1, "line_end": 9}1129{"id": "linemanjs/lineman:lib/resolves-quietly.coffee:1:js_to_coffee", "type": "js_to_coffee", "prompt": "Convert this JavaScript to CoffeeScript.\n```javascript\nvar path, resolve;\n\nresolve = require('resolve');\n\npath = require('path');\n\nmodule.exports = {\n resolve: function(requirable, opts) {\n var e;\n try {\n return path.dirname(resolve.sync(`${requirable}/package.json`, opts));\n } catch (error) {\n e = error;\n return void 0;\n }\n }\n};\n```", "response": "resolve = require('resolve')\npath = require('path')\n\nmodule.exports =\n resolve: (requirable, opts) ->\n try\n path.dirname(resolve.sync(\"#{requirable}/package.json\", opts))\n catch e\n undefined", "source_lang": "JavaScript", "target_lang": "CoffeeScript", "repo": "linemanjs/lineman", "path": "lib/resolves-quietly.coffee", "license": "MIT", "commit": "61d681532d9621e578d319c279006bbb728ece4b", "stars": 1168, "source_url": "https://github.com/linemanjs/lineman/blob/61d681532d9621e578d319c279006bbb728ece4b/lib/resolves-quietly.coffee", "line_start": 1, "line_end": 9}1130{"id": "linemanjs/lineman:lib/resolves-quietly.coffee:1:completion", "type": "completion", "prompt": "resolve = require('resolve')\npath = require('path')\n\nmodule.exports =", "response": "resolve: (requirable, opts) ->\n try\n path.dirname(resolve.sync(\"#{requirable}/package.json\", opts))\n catch e\n undefined", "source_lang": "CoffeeScript", "target_lang": "CoffeeScript", "repo": "linemanjs/lineman", "path": "lib/resolves-quietly.coffee", "license": "MIT", "commit": "61d681532d9621e578d319c279006bbb728ece4b", "stars": 1168, "source_url": "https://github.com/linemanjs/lineman/blob/61d681532d9621e578d319c279006bbb728ece4b/lib/resolves-quietly.coffee", "line_start": 1, "line_end": 9}1131{"id": "linemanjs/lineman:lib/resolves-quietly.coffee:1:raw_corpus", "type": "raw_corpus", "prompt": "", "response": "resolve = require('resolve')\npath = require('path')\n\nmodule.exports =\n resolve: (requirable, opts) ->\n try\n path.dirname(resolve.sync(requirable, opts))\n catch e\n undefined", "source_lang": "", "target_lang": "CoffeeScript", "repo": "linemanjs/lineman", "path": "lib/resolves-quietly.coffee", "license": "MIT", "commit": "33f0d060d207ab07e032da98f88fc6a478b3bcd6", "stars": 1168, "source_url": "https://github.com/linemanjs/lineman/blob/33f0d060d207ab07e032da98f88fc6a478b3bcd6/lib/resolves-quietly.coffee", "line_start": 1, "line_end": 9}1132{"id": "linemanjs/lineman:lib/resolves-quietly.coffee:1:coffee_to_js", "type": "coffee_to_js", "prompt": "Convert this CoffeeScript to JavaScript.\n```coffeescript\nresolve = require('resolve')\npath = require('path')\n\nmodule.exports =\n resolve: (requirable, opts) ->\n try\n path.dirname(resolve.sync(requirable, opts))\n catch e\n undefined\n```", "response": "var path, resolve;\n\nresolve = require('resolve');\n\npath = require('path');\n\nmodule.exports = {\n resolve: function(requirable, opts) {\n var e;\n try {\n return path.dirname(resolve.sync(requirable, opts));\n } catch (error) {\n e = error;\n return void 0;\n }\n }\n};", "source_lang": "CoffeeScript", "target_lang": "JavaScript", "repo": "linemanjs/lineman", "path": "lib/resolves-quietly.coffee", "license": "MIT", "commit": "33f0d060d207ab07e032da98f88fc6a478b3bcd6", "stars": 1168, "source_url": "https://github.com/linemanjs/lineman/blob/33f0d060d207ab07e032da98f88fc6a478b3bcd6/lib/resolves-quietly.coffee", "line_start": 1, "line_end": 9}1133{"id": "linemanjs/lineman:lib/resolves-quietly.coffee:1:js_to_coffee", "type": "js_to_coffee", "prompt": "Convert this JavaScript to CoffeeScript.\n```javascript\nvar path, resolve;\n\nresolve = require('resolve');\n\npath = require('path');\n\nmodule.exports = {\n resolve: function(requirable, opts) {\n var e;\n try {\n return path.dirname(resolve.sync(requirable, opts));\n } catch (error) {\n e = error;\n return void 0;\n }\n }\n};\n```", "response": "resolve = require('resolve')\npath = require('path')\n\nmodule.exports =\n resolve: (requirable, opts) ->\n try\n path.dirname(resolve.sync(requirable, opts))\n catch e\n undefined", "source_lang": "JavaScript", "target_lang": "CoffeeScript", "repo": "linemanjs/lineman", "path": "lib/resolves-quietly.coffee", "license": "MIT", "commit": "33f0d060d207ab07e032da98f88fc6a478b3bcd6", "stars": 1168, "source_url": "https://github.com/linemanjs/lineman/blob/33f0d060d207ab07e032da98f88fc6a478b3bcd6/lib/resolves-quietly.coffee", "line_start": 1, "line_end": 9}1134{"id": "linemanjs/lineman:lib/resolves-quietly.coffee:1:completion", "type": "completion", "prompt": "resolve = require('resolve')\npath = require('path')\n\nmodule.exports =", "response": "resolve: (requirable, opts) ->\n try\n path.dirname(resolve.sync(requirable, opts))\n catch e\n undefined", "source_lang": "CoffeeScript", "target_lang": "CoffeeScript", "repo": "linemanjs/lineman", "path": "lib/resolves-quietly.coffee", "license": "MIT", "commit": "33f0d060d207ab07e032da98f88fc6a478b3bcd6", "stars": 1168, "source_url": "https://github.com/linemanjs/lineman/blob/33f0d060d207ab07e032da98f88fc6a478b3bcd6/lib/resolves-quietly.coffee", "line_start": 1, "line_end": 9}1135{"id": "jianliaoim/talk-os:talk-web/client/handlers/network.coffee:1:raw_corpus", "type": "raw_corpus", "prompt": "", "response": "Q = require 'q'\nrecorder = require 'actions-recorder'\n\napi = require '../network/api'\n\nactions = require '../actions/index'\nuserActions = require '../actions/user'\nteamActions = require '../actions/team'\nroomActions = require '../actions/room'\nstoryActions = require '../actions/story'\nmessageActions = require '../actions/message'\nnotificationActions = require '../actions/notification'\naccountActions = require '../actions/account'\n\nexports.newConnection = ->\n api.users.subscribe.post()\n\nexports.longReconnection = (cb) ->\n # 这个断线有个问题:\n # 当我们在其他没有 _teamId 的页面, 比如 /settings 页面\n # 这里断线重连就会挂掉\n store = recorder.getState()\n\n _teamId = store.getIn ['router', 'data', '_teamId']\n _roomId = store.getIn ['router', 'data', '_roomId']\n _toId = store.getIn ['router', 'data', '_toId']\n _storyId = store.getIn ['router', 'data', '_storyId']\n\n fetchUser = (success, fail) -> userActions.userMe(success, fail)\n fetchTeams = (success, fail) -> teamActions.teamsFetch(success, fail)\n fetchTeamMembers = (success, fail) -> teamActions.teamMembers(_teamId, success, fail)\n fetchTopics = (success, fail) -> teamActions.teamTopics(_teamId, success, fail)\n fetchAccounts = (success, fail) -> accountActions.fetch(success, fail)\n fetchInteSettings = (success, fail) -> actions.inte.getSettings(success, fail)\n fetchNotifications = (success, fail) -> notificationActions.read(_teamId, {}, success, fail)\n\n if _teamId?\n subscribeTeam = (success, fail) -> teamActions.teamSubscribe(_teamId, success, fail)\n if _roomId?\n fetchChannel = (success, fail) -> roomActions.fetch(_roomId, success, fail)\n else if _toId?\n fetchChannel = (success, fail) -> messageActions.messageReadChat(_teamId, _toId, success, fail)\n else if _storyId?\n fetchChannel = (success, fail) -> storyActions.read(_teamId, {}, success, fail)\n\n calls = [\n subscribeTeam, fetchUser, fetchAccounts, fetchTeams\n fetchTeamMembers, fetchTopics, fetchChannel, fetchNotifications, fetchInteSettings\n ]\n else", "source_lang": "", "target_lang": "CoffeeScript", "repo": "jianliaoim/talk-os", "path": "talk-web/client/handlers/network.coffee", "license": "MIT", "commit": "2545c4497865779a55762e03963a39237df9046b", "stars": 2703, "source_url": "https://github.com/jianliaoim/talk-os/blob/2545c4497865779a55762e03963a39237df9046b/talk-web/client/handlers/network.coffee", "line_start": 1, "line_end": 50}1136{"id": "jianliaoim/talk-os:talk-web/client/handlers/network.coffee:1:coffee_to_js", "type": "coffee_to_js", "prompt": "Convert this CoffeeScript to JavaScript.\n```coffeescript\nQ = require 'q'\nrecorder = require 'actions-recorder'\n\napi = require '../network/api'\n\nactions = require '../actions/index'\nuserActions = require '../actions/user'\nteamActions = require '../actions/team'\nroomActions = require '../actions/room'\nstoryActions = require '../actions/story'\nmessageActions = require '../actions/message'\nnotificationActions = require '../actions/notification'\naccountActions = require '../actions/account'\n\nexports.newConnection = ->\n api.users.subscribe.post()\n\nexports.longReconnection = (cb) ->\n # 这个断线有个问题:\n # 当我们在其他没有 _teamId 的页面, 比如 /settings 页面\n # 这里断线重连就会挂掉\n store = recorder.getState()\n\n _teamId = store.getIn ['router', 'data', '_teamId']\n _roomId = store.getIn ['router', 'data', '_roomId']\n _toId = store.getIn ['router', 'data', '_toId']\n _storyId = store.getIn ['router', 'data', '_storyId']\n\n fetchUser = (success, fail) -> userActions.userMe(success, fail)\n fetchTeams = (success, fail) -> teamActions.teamsFetch(success, fail)\n fetchTeamMembers = (success, fail) -> teamActions.teamMembers(_teamId, success, fail)\n fetchTopics = (success, fail) -> teamActions.teamTopics(_teamId, success, fail)\n fetchAccounts = (success, fail) -> accountActions.fetch(success, fail)\n fetchInteSettings = (success, fail) -> actions.inte.getSettings(success, fail)\n fetchNotifications = (success, fail) -> notificationActions.read(_teamId, {}, success, fail)\n\n if _teamId?\n subscribeTeam = (success, fail) -> teamActions.teamSubscribe(_teamId, success, fail)\n if _roomId?\n fetchChannel = (success, fail) -> roomActions.fetch(_roomId, success, fail)\n else if _toId?\n fetchChannel = (success, fail) -> messageActions.messageReadChat(_teamId, _toId, success, fail)\n else if _storyId?\n fetchChannel = (success, fail) -> storyActions.read(_teamId, {}, success, fail)\n\n calls = [\n subscribeTeam, fetchUser, fetchAccounts, fetchTeams\n fetchTeamMembers, fetchTopics, fetchChannel, fetchNotifications, fetchInteSettings\n ]\n else\n```", "response": "var Q, accountActions, actions, api, messageActions, notificationActions, recorder, roomActions, storyActions, teamActions, userActions;\n\nQ = require('q');\n\nrecorder = require('actions-recorder');\n\napi = require('../network/api');\n\nactions = require('../actions/index');\n\nuserActions = require('../actions/user');\n\nteamActions = require('../actions/team');\n\nroomActions = require('../actions/room');\n\nstoryActions = require('../actions/story');\n\nmessageActions = require('../actions/message');\n\nnotificationActions = require('../actions/notification');\n\naccountActions = require('../actions/account');\n\nexports.newConnection = function() {\n return api.users.subscribe.post();\n};\n\nexports.longReconnection = function(cb) {\n var _roomId, _storyId, _teamId, _toId, calls, fetchAccounts, fetchChannel, fetchInteSettings, fetchNotifications, fetchTeamMembers, fetchTeams, fetchTopics, fetchUser, store, subscribeTeam;\n // 这个断线有个问题:\n // 当我们在其他没有 _teamId 的页面, 比如 /settings 页面\n // 这里断线重连就会挂掉\n store = recorder.getState();\n _teamId = store.getIn(['router', 'data', '_teamId']);\n _roomId = store.getIn(['router', 'data', '_roomId']);\n _toId = store.getIn(['router', 'data', '_toId']);\n _storyId = store.getIn(['router', 'data', '_storyId']);\n fetchUser = function(success, fail) {\n return userActions.userMe(success, fail);\n };\n fetchTeams = function(success, fail) {\n return teamActions.teamsFetch(success, fail);\n };\n fetchTeamMembers = function(success, fail) {\n return teamActions.teamMembers(_teamId, success, fail);\n };\n fetchTopics = function(success, fail) {\n return teamActions.teamTopics(_teamId, success, fail);\n };\n fetchAccounts = function(success, fail) {\n return accountActions.fetch(success, fail);\n };\n fetchInteSettings = function(success, fail) {\n return actions.inte.getSettings(success, fail);\n };\n fetchNotifications = function(success, fail) {\n return notificationActions.read(_teamId, {}, success, fail);\n };\n if (_teamId != null) {\n subscribeTeam = function(success, fail) {\n return teamActions.teamSubscribe(_teamId, success, fail);\n };\n if (_roomId != null) {\n fetchChannel = function(success, fail) {\n return roomActions.fetch(_roomId, success, fail);\n };\n } else if (_toId != null) {\n fetchChannel = function(success, fail) {\n return messageActions.messageReadChat(_teamId, _toId, success, fail);\n };\n } else if (_storyId != null) {\n fetchChannel = function(success, fail) {\n return storyActions.read(_teamId, {}, success, fail);\n };\n }\n return calls = [subscribeTeam, fetchUser, fetchAccounts, fetchTeams, fetchTeamMembers, fetchTopics, fetchChannel, fetchNotifications, fetchInteSettings];\n } else {\n\n }\n};", "source_lang": "CoffeeScript", "target_lang": "JavaScript", "repo": "jianliaoim/talk-os", "path": "talk-web/client/handlers/network.coffee", "license": "MIT", "commit": "2545c4497865779a55762e03963a39237df9046b", "stars": 2703, "source_url": "https://github.com/jianliaoim/talk-os/blob/2545c4497865779a55762e03963a39237df9046b/talk-web/client/handlers/network.coffee", "line_start": 1, "line_end": 50}1137{"id": "jianliaoim/talk-os:talk-web/client/handlers/network.coffee:1:js_to_coffee", "type": "js_to_coffee", "prompt": "Convert this JavaScript to CoffeeScript.\n```javascript\nvar Q, accountActions, actions, api, messageActions, notificationActions, recorder, roomActions, storyActions, teamActions, userActions;\n\nQ = require('q');\n\nrecorder = require('actions-recorder');\n\napi = require('../network/api');\n\nactions = require('../actions/index');\n\nuserActions = require('../actions/user');\n\nteamActions = require('../actions/team');\n\nroomActions = require('../actions/room');\n\nstoryActions = require('../actions/story');\n\nmessageActions = require('../actions/message');\n\nnotificationActions = require('../actions/notification');\n\naccountActions = require('../actions/account');\n\nexports.newConnection = function() {\n return api.users.subscribe.post();\n};\n\nexports.longReconnection = function(cb) {\n var _roomId, _storyId, _teamId, _toId, calls, fetchAccounts, fetchChannel, fetchInteSettings, fetchNotifications, fetchTeamMembers, fetchTeams, fetchTopics, fetchUser, store, subscribeTeam;\n // 这个断线有个问题:\n // 当我们在其他没有 _teamId 的页面, 比如 /settings 页面\n // 这里断线重连就会挂掉\n store = recorder.getState();\n _teamId = store.getIn(['router', 'data', '_teamId']);\n _roomId = store.getIn(['router', 'data', '_roomId']);\n _toId = store.getIn(['router', 'data', '_toId']);\n _storyId = store.getIn(['router', 'data', '_storyId']);\n fetchUser = function(success, fail) {\n return userActions.userMe(success, fail);\n };\n fetchTeams = function(success, fail) {\n return teamActions.teamsFetch(success, fail);\n };\n fetchTeamMembers = function(success, fail) {\n return teamActions.teamMembers(_teamId, success, fail);\n };\n fetchTopics = function(success, fail) {\n return teamActions.teamTopics(_teamId, success, fail);\n };\n fetchAccounts = function(success, fail) {\n return accountActions.fetch(success, fail);\n };\n fetchInteSettings = function(success, fail) {\n return actions.inte.getSettings(success, fail);\n };\n fetchNotifications = function(success, fail) {\n return notificationActions.read(_teamId, {}, success, fail);\n };\n if (_teamId != null) {\n subscribeTeam = function(success, fail) {\n return teamActions.teamSubscribe(_teamId, success, fail);\n };\n if (_roomId != null) {\n fetchChannel = function(success, fail) {\n return roomActions.fetch(_roomId, success, fail);\n };\n } else if (_toId != null) {\n fetchChannel = function(success, fail) {\n return messageActions.messageReadChat(_teamId, _toId, success, fail);\n };\n } else if (_storyId != null) {\n fetchChannel = function(success, fail) {\n return storyActions.read(_teamId, {}, success, fail);\n };\n }\n return calls = [subscribeTeam, fetchUser, fetchAccounts, fetchTeams, fetchTeamMembers, fetchTopics, fetchChannel, fetchNotifications, fetchInteSettings];\n } else {\n\n }\n};\n```", "response": "Q = require 'q'\nrecorder = require 'actions-recorder'\n\napi = require '../network/api'\n\nactions = require '../actions/index'\nuserActions = require '../actions/user'\nteamActions = require '../actions/team'\nroomActions = require '../actions/room'\nstoryActions = require '../actions/story'\nmessageActions = require '../actions/message'\nnotificationActions = require '../actions/notification'\naccountActions = require '../actions/account'\n\nexports.newConnection = ->\n api.users.subscribe.post()\n\nexports.longReconnection = (cb) ->\n # 这个断线有个问题:\n # 当我们在其他没有 _teamId 的页面, 比如 /settings 页面\n # 这里断线重连就会挂掉\n store = recorder.getState()\n\n _teamId = store.getIn ['router', 'data', '_teamId']\n _roomId = store.getIn ['router', 'data', '_roomId']\n _toId = store.getIn ['router', 'data', '_toId']\n _storyId = store.getIn ['router', 'data', '_storyId']\n\n fetchUser = (success, fail) -> userActions.userMe(success, fail)\n fetchTeams = (success, fail) -> teamActions.teamsFetch(success, fail)\n fetchTeamMembers = (success, fail) -> teamActions.teamMembers(_teamId, success, fail)\n fetchTopics = (success, fail) -> teamActions.teamTopics(_teamId, success, fail)\n fetchAccounts = (success, fail) -> accountActions.fetch(success, fail)\n fetchInteSettings = (success, fail) -> actions.inte.getSettings(success, fail)\n fetchNotifications = (success, fail) -> notificationActions.read(_teamId, {}, success, fail)\n\n if _teamId?\n subscribeTeam = (success, fail) -> teamActions.teamSubscribe(_teamId, success, fail)\n if _roomId?\n fetchChannel = (success, fail) -> roomActions.fetch(_roomId, success, fail)\n else if _toId?\n fetchChannel = (success, fail) -> messageActions.messageReadChat(_teamId, _toId, success, fail)\n else if _storyId?\n fetchChannel = (success, fail) -> storyActions.read(_teamId, {}, success, fail)\n\n calls = [\n subscribeTeam, fetchUser, fetchAccounts, fetchTeams\n fetchTeamMembers, fetchTopics, fetchChannel, fetchNotifications, fetchInteSettings\n ]\n else", "source_lang": "JavaScript", "target_lang": "CoffeeScript", "repo": "jianliaoim/talk-os", "path": "talk-web/client/handlers/network.coffee", "license": "MIT", "commit": "2545c4497865779a55762e03963a39237df9046b", "stars": 2703, "source_url": "https://github.com/jianliaoim/talk-os/blob/2545c4497865779a55762e03963a39237df9046b/talk-web/client/handlers/network.coffee", "line_start": 1, "line_end": 50}1138{"id": "jianliaoim/talk-os:talk-web/client/handlers/network.coffee:1:completion", "type": "completion", "prompt": "Q = require 'q'\nrecorder = require 'actions-recorder'\n\napi = require '../network/api'\n\nactions = require '../actions/index'\nuserActions = require '../actions/user'\nteamActions = require '../actions/team'\nroomActions = require '../actions/room'\nstoryActions = require '../actions/story'\nmessageActions = require '../actions/message'\nnotificationActions = require '../actions/notification'\naccountActions = require '../actions/account'\n\nexports.newConnection = ->\n api.users.subscribe.post()\n\nexports.longReconnection = (cb) ->\n # 这个断线有个问题:\n # 当我们在其他没有 _teamId 的页面, 比如 /settings 页面\n # 这里断线重连就会挂掉\n store = recorder.getState()\n\n _teamId = store.getIn ['router', 'data', '_teamId']\n _roomId = store.getIn ['router', 'data', '_roomId']", "response": "_toId = store.getIn ['router', 'data', '_toId']\n _storyId = store.getIn ['router', 'data', '_storyId']\n\n fetchUser = (success, fail) -> userActions.userMe(success, fail)\n fetchTeams = (success, fail) -> teamActions.teamsFetch(success, fail)\n fetchTeamMembers = (success, fail) -> teamActions.teamMembers(_teamId, success, fail)\n fetchTopics = (success, fail) -> teamActions.teamTopics(_teamId, success, fail)\n fetchAccounts = (success, fail) -> accountActions.fetch(success, fail)\n fetchInteSettings = (success, fail) -> actions.inte.getSettings(success, fail)\n fetchNotifications = (success, fail) -> notificationActions.read(_teamId, {}, success, fail)\n\n if _teamId?\n subscribeTeam = (success, fail) -> teamActions.teamSubscribe(_teamId, success, fail)\n if _roomId?\n fetchChannel = (success, fail) -> roomActions.fetch(_roomId, success, fail)\n else if _toId?\n fetchChannel = (success, fail) -> messageActions.messageReadChat(_teamId, _toId, success, fail)\n else if _storyId?\n fetchChannel = (success, fail) -> storyActions.read(_teamId, {}, success, fail)\n\n calls = [\n subscribeTeam, fetchUser, fetchAccounts, fetchTeams\n fetchTeamMembers, fetchTopics, fetchChannel, fetchNotifications, fetchInteSettings\n ]\n else", "source_lang": "CoffeeScript", "target_lang": "CoffeeScript", "repo": "jianliaoim/talk-os", "path": "talk-web/client/handlers/network.coffee", "license": "MIT", "commit": "2545c4497865779a55762e03963a39237df9046b", "stars": 2703, "source_url": "https://github.com/jianliaoim/talk-os/blob/2545c4497865779a55762e03963a39237df9046b/talk-web/client/handlers/network.coffee", "line_start": 1, "line_end": 50}1139{"id": "jianliaoim/talk-os:talk-web/client/handlers/network.coffee:2:raw_corpus", "type": "raw_corpus", "prompt": "", "response": "calls = [fetchUser, fetchAccounts, fetchTeams, fetchInteSettings]\n\n Q.all(calls.map(Q))\n .then ->\n cb?()\n .done()", "source_lang": "", "target_lang": "CoffeeScript", "repo": "jianliaoim/talk-os", "path": "talk-web/client/handlers/network.coffee", "license": "MIT", "commit": "2545c4497865779a55762e03963a39237df9046b", "stars": 2703, "source_url": "https://github.com/jianliaoim/talk-os/blob/2545c4497865779a55762e03963a39237df9046b/talk-web/client/handlers/network.coffee", "line_start": 51, "line_end": 56}1140{"id": "jianliaoim/talk-os:talk-web/client/handlers/network.coffee:2:completion", "type": "completion", "prompt": "calls = [fetchUser, fetchAccounts, fetchTeams, fetchInteSettings]\n\n Q.all(calls.map(Q))", "response": ".then ->\n cb?()\n .done()", "source_lang": "CoffeeScript", "target_lang": "CoffeeScript", "repo": "jianliaoim/talk-os", "path": "talk-web/client/handlers/network.coffee", "license": "MIT", "commit": "2545c4497865779a55762e03963a39237df9046b", "stars": 2703, "source_url": "https://github.com/jianliaoim/talk-os/blob/2545c4497865779a55762e03963a39237df9046b/talk-web/client/handlers/network.coffee", "line_start": 51, "line_end": 56}1141{"id": "gterrono/houston:client/admin_login.coffee:1:raw_corpus", "type": "raw_corpus", "prompt": "", "response": "Template._houston_login.helpers(\n logged_in: -> Meteor.user()\n)\n\nTemplate._houston_login.events(\n 'submit #houston-sign-in-form': (e) ->\n e.preventDefault()\n email = $('input[name=\"houston-email\"]').val()\n password = $('input[name=\"houston-password\"]').val()\n\n afterLogin = (error) ->\n # TODO error case that properly displays\n if error\n alert error\n else\n Houston._go 'home'\n\n if Houston._admin_user_exists()\n Meteor.loginWithPassword email, password, afterLogin\n else\n Accounts.createUser {\n email: email\n password: password\n }, (error) ->\n return afterLogin(error) if error\n Houston.becomeAdmin()\n\n 'click #houston-logout': (e) ->\n e.preventDefault()\n Meteor.logout()\n # going 'home' clears the side nav\n Houston._go 'home'\n\n 'click #become-houston-admin': (e) ->\n e.preventDefault()\n Houston.becomeAdmin()\n)\n\nTemplate._houston_login.rendered = ->\n $(window).unbind('scroll')", "source_lang": "", "target_lang": "CoffeeScript", "repo": "gterrono/houston", "path": "client/admin_login.coffee", "license": "MIT", "commit": "581357048f3577f0487ed598e26eaf063c813183", "stars": 802, "source_url": "https://github.com/gterrono/houston/blob/581357048f3577f0487ed598e26eaf063c813183/client/admin_login.coffee", "line_start": 1, "line_end": 40}1142{"id": "gterrono/houston:client/admin_login.coffee:1:coffee_to_js", "type": "coffee_to_js", "prompt": "Convert this CoffeeScript to JavaScript.\n```coffeescript\nTemplate._houston_login.helpers(\n logged_in: -> Meteor.user()\n)\n\nTemplate._houston_login.events(\n 'submit #houston-sign-in-form': (e) ->\n e.preventDefault()\n email = $('input[name=\"houston-email\"]').val()\n password = $('input[name=\"houston-password\"]').val()\n\n afterLogin = (error) ->\n # TODO error case that properly displays\n if error\n alert error\n else\n Houston._go 'home'\n\n if Houston._admin_user_exists()\n Meteor.loginWithPassword email, password, afterLogin\n else\n Accounts.createUser {\n email: email\n password: password\n }, (error) ->\n return afterLogin(error) if error\n Houston.becomeAdmin()\n\n 'click #houston-logout': (e) ->\n e.preventDefault()\n Meteor.logout()\n # going 'home' clears the side nav\n Houston._go 'home'\n\n 'click #become-houston-admin': (e) ->\n e.preventDefault()\n Houston.becomeAdmin()\n)\n\nTemplate._houston_login.rendered = ->\n $(window).unbind('scroll')\n```", "response": "Template._houston_login.helpers({\n logged_in: function() {\n return Meteor.user();\n }\n});\n\nTemplate._houston_login.events({\n 'submit #houston-sign-in-form': function(e) {\n var afterLogin, email, password;\n e.preventDefault();\n email = $('input[name=\"houston-email\"]').val();\n password = $('input[name=\"houston-password\"]').val();\n afterLogin = function(error) {\n // TODO error case that properly displays\n if (error) {\n return alert(error);\n } else {\n return Houston._go('home');\n }\n };\n if (Houston._admin_user_exists()) {\n return Meteor.loginWithPassword(email, password, afterLogin);\n } else {\n return Accounts.createUser({\n email: email,\n password: password\n }, function(error) {\n if (error) {\n return afterLogin(error);\n }\n return Houston.becomeAdmin();\n });\n }\n },\n 'click #houston-logout': function(e) {\n e.preventDefault();\n Meteor.logout();\n // going 'home' clears the side nav\n return Houston._go('home');\n },\n 'click #become-houston-admin': function(e) {\n e.preventDefault();\n return Houston.becomeAdmin();\n }\n});\n\nTemplate._houston_login.rendered = function() {\n return $(window).unbind('scroll');\n};", "source_lang": "CoffeeScript", "target_lang": "JavaScript", "repo": "gterrono/houston", "path": "client/admin_login.coffee", "license": "MIT", "commit": "581357048f3577f0487ed598e26eaf063c813183", "stars": 802, "source_url": "https://github.com/gterrono/houston/blob/581357048f3577f0487ed598e26eaf063c813183/client/admin_login.coffee", "line_start": 1, "line_end": 40}1143{"id": "gterrono/houston:client/admin_login.coffee:1:js_to_coffee", "type": "js_to_coffee", "prompt": "Convert this JavaScript to CoffeeScript.\n```javascript\nTemplate._houston_login.helpers({\n logged_in: function() {\n return Meteor.user();\n }\n});\n\nTemplate._houston_login.events({\n 'submit #houston-sign-in-form': function(e) {\n var afterLogin, email, password;\n e.preventDefault();\n email = $('input[name=\"houston-email\"]').val();\n password = $('input[name=\"houston-password\"]').val();\n afterLogin = function(error) {\n // TODO error case that properly displays\n if (error) {\n return alert(error);\n } else {\n return Houston._go('home');\n }\n };\n if (Houston._admin_user_exists()) {\n return Meteor.loginWithPassword(email, password, afterLogin);\n } else {\n return Accounts.createUser({\n email: email,\n password: password\n }, function(error) {\n if (error) {\n return afterLogin(error);\n }\n return Houston.becomeAdmin();\n });\n }\n },\n 'click #houston-logout': function(e) {\n e.preventDefault();\n Meteor.logout();\n // going 'home' clears the side nav\n return Houston._go('home');\n },\n 'click #become-houston-admin': function(e) {\n e.preventDefault();\n return Houston.becomeAdmin();\n }\n});\n\nTemplate._houston_login.rendered = function() {\n return $(window).unbind('scroll');\n};\n```", "response": "Template._houston_login.helpers(\n logged_in: -> Meteor.user()\n)\n\nTemplate._houston_login.events(\n 'submit #houston-sign-in-form': (e) ->\n e.preventDefault()\n email = $('input[name=\"houston-email\"]').val()\n password = $('input[name=\"houston-password\"]').val()\n\n afterLogin = (error) ->\n # TODO error case that properly displays\n if error\n alert error\n else\n Houston._go 'home'\n\n if Houston._admin_user_exists()\n Meteor.loginWithPassword email, password, afterLogin\n else\n Accounts.createUser {\n email: email\n password: password\n }, (error) ->\n return afterLogin(error) if error\n Houston.becomeAdmin()\n\n 'click #houston-logout': (e) ->\n e.preventDefault()\n Meteor.logout()\n # going 'home' clears the side nav\n Houston._go 'home'\n\n 'click #become-houston-admin': (e) ->\n e.preventDefault()\n Houston.becomeAdmin()\n)\n\nTemplate._houston_login.rendered = ->\n $(window).unbind('scroll')", "source_lang": "JavaScript", "target_lang": "CoffeeScript", "repo": "gterrono/houston", "path": "client/admin_login.coffee", "license": "MIT", "commit": "581357048f3577f0487ed598e26eaf063c813183", "stars": 802, "source_url": "https://github.com/gterrono/houston/blob/581357048f3577f0487ed598e26eaf063c813183/client/admin_login.coffee", "line_start": 1, "line_end": 40}1144{"id": "gterrono/houston:client/admin_login.coffee:1:completion", "type": "completion", "prompt": "Template._houston_login.helpers(\n logged_in: -> Meteor.user()\n)\n\nTemplate._houston_login.events(\n 'submit #houston-sign-in-form': (e) ->\n e.preventDefault()\n email = $('input[name=\"houston-email\"]').val()\n password = $('input[name=\"houston-password\"]').val()\n\n afterLogin = (error) ->\n # TODO error case that properly displays\n if error\n alert error\n else\n Houston._go 'home'\n\n if Houston._admin_user_exists()\n Meteor.loginWithPassword email, password, afterLogin\n else", "response": "Accounts.createUser {\n email: email\n password: password\n }, (error) ->\n return afterLogin(error) if error\n Houston.becomeAdmin()\n\n 'click #houston-logout': (e) ->\n e.preventDefault()\n Meteor.logout()\n # going 'home' clears the side nav\n Houston._go 'home'\n\n 'click #become-houston-admin': (e) ->\n e.preventDefault()\n Houston.becomeAdmin()\n)\n\nTemplate._houston_login.rendered = ->\n $(window).unbind('scroll')", "source_lang": "CoffeeScript", "target_lang": "CoffeeScript", "repo": "gterrono/houston", "path": "client/admin_login.coffee", "license": "MIT", "commit": "581357048f3577f0487ed598e26eaf063c813183", "stars": 802, "source_url": "https://github.com/gterrono/houston/blob/581357048f3577f0487ed598e26eaf063c813183/client/admin_login.coffee", "line_start": 1, "line_end": 40}1145{"id": "gterrono/houston:client/admin_login.coffee:1:raw_corpus", "type": "raw_corpus", "prompt": "", "response": "Template._houston_login.helpers(\n logged_in: -> Meteor.user()\n)\n\nTemplate._houston_login.events(\n 'submit #houston-sign-in-form': (e) ->\n e.preventDefault()\n email = $('input[name=\"houston-email\"]').val()\n password = $('input[name=\"houston-password\"]').val()\n\n afterLogin = (error) ->\n # TODO error case that properly displays\n if error\n alert error\n else\n Houston._go 'home'\n\n if Houston._admin_user_exists()\n Meteor.loginWithPassword email, password, afterLogin\n else\n Accounts.createUser {\n email: email\n password: password\n }, (error) ->\n return afterLogin(error) if error\n # else - user got created\n Houston._call('make_admin', Meteor.userId(), afterLogin)\n\n 'click #houston-logout': (e) ->\n e.preventDefault()\n Meteor.logout()\n # going 'home' clears the side nav\n Houston._go 'home'\n\n 'click #become-houston-admin': (e) ->\n e.preventDefault()\n Houston._call('make_admin', Meteor.userId())\n Houston._go 'home'\n)\n\nTemplate._houston_login.rendered = ->\n $(window).unbind('scroll')", "source_lang": "", "target_lang": "CoffeeScript", "repo": "gterrono/houston", "path": "client/admin_login.coffee", "license": "MIT", "commit": "e7f3b45859baf942fb6681e5bfc48cba1ec1af6a", "stars": 802, "source_url": "https://github.com/gterrono/houston/blob/e7f3b45859baf942fb6681e5bfc48cba1ec1af6a/client/admin_login.coffee", "line_start": 1, "line_end": 42}1146{"id": "gterrono/houston:client/admin_login.coffee:1:coffee_to_js", "type": "coffee_to_js", "prompt": "Convert this CoffeeScript to JavaScript.\n```coffeescript\nTemplate._houston_login.helpers(\n logged_in: -> Meteor.user()\n)\n\nTemplate._houston_login.events(\n 'submit #houston-sign-in-form': (e) ->\n e.preventDefault()\n email = $('input[name=\"houston-email\"]').val()\n password = $('input[name=\"houston-password\"]').val()\n\n afterLogin = (error) ->\n # TODO error case that properly displays\n if error\n alert error\n else\n Houston._go 'home'\n\n if Houston._admin_user_exists()\n Meteor.loginWithPassword email, password, afterLogin\n else\n Accounts.createUser {\n email: email\n password: password\n }, (error) ->\n return afterLogin(error) if error\n # else - user got created\n Houston._call('make_admin', Meteor.userId(), afterLogin)\n\n 'click #houston-logout': (e) ->\n e.preventDefault()\n Meteor.logout()\n # going 'home' clears the side nav\n Houston._go 'home'\n\n 'click #become-houston-admin': (e) ->\n e.preventDefault()\n Houston._call('make_admin', Meteor.userId())\n Houston._go 'home'\n)\n\nTemplate._houston_login.rendered = ->\n $(window).unbind('scroll')\n```", "response": "Template._houston_login.helpers({\n logged_in: function() {\n return Meteor.user();\n }\n});\n\nTemplate._houston_login.events({\n 'submit #houston-sign-in-form': function(e) {\n var afterLogin, email, password;\n e.preventDefault();\n email = $('input[name=\"houston-email\"]').val();\n password = $('input[name=\"houston-password\"]').val();\n afterLogin = function(error) {\n // TODO error case that properly displays\n if (error) {\n return alert(error);\n } else {\n return Houston._go('home');\n }\n };\n if (Houston._admin_user_exists()) {\n return Meteor.loginWithPassword(email, password, afterLogin);\n } else {\n return Accounts.createUser({\n email: email,\n password: password\n }, function(error) {\n if (error) {\n return afterLogin(error);\n }\n // else - user got created\n return Houston._call('make_admin', Meteor.userId(), afterLogin);\n });\n }\n },\n 'click #houston-logout': function(e) {\n e.preventDefault();\n Meteor.logout();\n // going 'home' clears the side nav\n return Houston._go('home');\n },\n 'click #become-houston-admin': function(e) {\n e.preventDefault();\n Houston._call('make_admin', Meteor.userId());\n return Houston._go('home');\n }\n});\n\nTemplate._houston_login.rendered = function() {\n return $(window).unbind('scroll');\n};", "source_lang": "CoffeeScript", "target_lang": "JavaScript", "repo": "gterrono/houston", "path": "client/admin_login.coffee", "license": "MIT", "commit": "e7f3b45859baf942fb6681e5bfc48cba1ec1af6a", "stars": 802, "source_url": "https://github.com/gterrono/houston/blob/e7f3b45859baf942fb6681e5bfc48cba1ec1af6a/client/admin_login.coffee", "line_start": 1, "line_end": 42}1147{"id": "gterrono/houston:client/admin_login.coffee:1:js_to_coffee", "type": "js_to_coffee", "prompt": "Convert this JavaScript to CoffeeScript.\n```javascript\nTemplate._houston_login.helpers({\n logged_in: function() {\n return Meteor.user();\n }\n});\n\nTemplate._houston_login.events({\n 'submit #houston-sign-in-form': function(e) {\n var afterLogin, email, password;\n e.preventDefault();\n email = $('input[name=\"houston-email\"]').val();\n password = $('input[name=\"houston-password\"]').val();\n afterLogin = function(error) {\n // TODO error case that properly displays\n if (error) {\n return alert(error);\n } else {\n return Houston._go('home');\n }\n };\n if (Houston._admin_user_exists()) {\n return Meteor.loginWithPassword(email, password, afterLogin);\n } else {\n return Accounts.createUser({\n email: email,\n password: password\n }, function(error) {\n if (error) {\n return afterLogin(error);\n }\n // else - user got created\n return Houston._call('make_admin', Meteor.userId(), afterLogin);\n });\n }\n },\n 'click #houston-logout': function(e) {\n e.preventDefault();\n Meteor.logout();\n // going 'home' clears the side nav\n return Houston._go('home');\n },\n 'click #become-houston-admin': function(e) {\n e.preventDefault();\n Houston._call('make_admin', Meteor.userId());\n return Houston._go('home');\n }\n});\n\nTemplate._houston_login.rendered = function() {\n return $(window).unbind('scroll');\n};\n```", "response": "Template._houston_login.helpers(\n logged_in: -> Meteor.user()\n)\n\nTemplate._houston_login.events(\n 'submit #houston-sign-in-form': (e) ->\n e.preventDefault()\n email = $('input[name=\"houston-email\"]').val()\n password = $('input[name=\"houston-password\"]').val()\n\n afterLogin = (error) ->\n # TODO error case that properly displays\n if error\n alert error\n else\n Houston._go 'home'\n\n if Houston._admin_user_exists()\n Meteor.loginWithPassword email, password, afterLogin\n else\n Accounts.createUser {\n email: email\n password: password\n }, (error) ->\n return afterLogin(error) if error\n # else - user got created\n Houston._call('make_admin', Meteor.userId(), afterLogin)\n\n 'click #houston-logout': (e) ->\n e.preventDefault()\n Meteor.logout()\n # going 'home' clears the side nav\n Houston._go 'home'\n\n 'click #become-houston-admin': (e) ->\n e.preventDefault()\n Houston._call('make_admin', Meteor.userId())\n Houston._go 'home'\n)\n\nTemplate._houston_login.rendered = ->\n $(window).unbind('scroll')", "source_lang": "JavaScript", "target_lang": "CoffeeScript", "repo": "gterrono/houston", "path": "client/admin_login.coffee", "license": "MIT", "commit": "e7f3b45859baf942fb6681e5bfc48cba1ec1af6a", "stars": 802, "source_url": "https://github.com/gterrono/houston/blob/e7f3b45859baf942fb6681e5bfc48cba1ec1af6a/client/admin_login.coffee", "line_start": 1, "line_end": 42}1148{"id": "gterrono/houston:client/admin_login.coffee:1:completion", "type": "completion", "prompt": "Template._houston_login.helpers(\n logged_in: -> Meteor.user()\n)\n\nTemplate._houston_login.events(\n 'submit #houston-sign-in-form': (e) ->\n e.preventDefault()\n email = $('input[name=\"houston-email\"]').val()\n password = $('input[name=\"houston-password\"]').val()\n\n afterLogin = (error) ->\n # TODO error case that properly displays\n if error\n alert error\n else\n Houston._go 'home'\n\n if Houston._admin_user_exists()\n Meteor.loginWithPassword email, password, afterLogin\n else\n Accounts.createUser {", "response": "email: email\n password: password\n }, (error) ->\n return afterLogin(error) if error\n # else - user got created\n Houston._call('make_admin', Meteor.userId(), afterLogin)\n\n 'click #houston-logout': (e) ->\n e.preventDefault()\n Meteor.logout()\n # going 'home' clears the side nav\n Houston._go 'home'\n\n 'click #become-houston-admin': (e) ->\n e.preventDefault()\n Houston._call('make_admin', Meteor.userId())\n Houston._go 'home'\n)\n\nTemplate._houston_login.rendered = ->\n $(window).unbind('scroll')", "source_lang": "CoffeeScript", "target_lang": "CoffeeScript", "repo": "gterrono/houston", "path": "client/admin_login.coffee", "license": "MIT", "commit": "e7f3b45859baf942fb6681e5bfc48cba1ec1af6a", "stars": 802, "source_url": "https://github.com/gterrono/houston/blob/e7f3b45859baf942fb6681e5bfc48cba1ec1af6a/client/admin_login.coffee", "line_start": 1, "line_end": 42}1149{"id": "gterrono/houston:client/admin_login.coffee:1:raw_corpus", "type": "raw_corpus", "prompt": "", "response": "Template._houston_login.helpers(\n logged_in: -> Meteor.user()\n)\n\nTemplate._houston_login.events(\n 'submit #houston-sign-in-form': (e) ->\n e.preventDefault()\n email = $('input[name=\"houston-email\"]').val()\n password = $('input[name=\"houston-password\"]').val()\n\n afterLogin = (error) ->\n # TODO error case that properly displays\n if error\n alert error\n else\n Houston._go 'home'\n\n if Houston._admin_user_exists()\n Meteor.loginWithPassword email, password, afterLogin\n else\n Accounts.createUser {\n email: email\n password: password\n }, (error) ->\n return afterLogin(error) if error\n # else - user got created\n Houston._call('make_admin', Meteor.userId(), afterLogin)\n\n 'click #houston-logout': (e) ->\n e.preventDefault()\n Meteor.logout()\n # going 'home' clears the side nav\n Houston._go 'home'\n\n 'click #become-houston-admin': (e) ->\n e.preventDefault()\n Houston._call('make_admin', Meteor.userId())\n Houston._go 'home'\n)\n\nTemplate._houston_login.rendered = ->\n debugger\n $(window).unbind('scroll')", "source_lang": "", "target_lang": "CoffeeScript", "repo": "gterrono/houston", "path": "client/admin_login.coffee", "license": "MIT", "commit": "a32808b056df45e21fb59f9bce37162f03d626b1", "stars": 802, "source_url": "https://github.com/gterrono/houston/blob/a32808b056df45e21fb59f9bce37162f03d626b1/client/admin_login.coffee", "line_start": 1, "line_end": 43}1150{"id": "gterrono/houston:client/admin_login.coffee:1:coffee_to_js", "type": "coffee_to_js", "prompt": "Convert this CoffeeScript to JavaScript.\n```coffeescript\nTemplate._houston_login.helpers(\n logged_in: -> Meteor.user()\n)\n\nTemplate._houston_login.events(\n 'submit #houston-sign-in-form': (e) ->\n e.preventDefault()\n email = $('input[name=\"houston-email\"]').val()\n password = $('input[name=\"houston-password\"]').val()\n\n afterLogin = (error) ->\n # TODO error case that properly displays\n if error\n alert error\n else\n Houston._go 'home'\n\n if Houston._admin_user_exists()\n Meteor.loginWithPassword email, password, afterLogin\n else\n Accounts.createUser {\n email: email\n password: password\n }, (error) ->\n return afterLogin(error) if error\n # else - user got created\n Houston._call('make_admin', Meteor.userId(), afterLogin)\n\n 'click #houston-logout': (e) ->\n e.preventDefault()\n Meteor.logout()\n # going 'home' clears the side nav\n Houston._go 'home'\n\n 'click #become-houston-admin': (e) ->\n e.preventDefault()\n Houston._call('make_admin', Meteor.userId())\n Houston._go 'home'\n)\n\nTemplate._houston_login.rendered = ->\n debugger\n $(window).unbind('scroll')\n```", "response": "Template._houston_login.helpers({\n logged_in: function() {\n return Meteor.user();\n }\n});\n\nTemplate._houston_login.events({\n 'submit #houston-sign-in-form': function(e) {\n var afterLogin, email, password;\n e.preventDefault();\n email = $('input[name=\"houston-email\"]').val();\n password = $('input[name=\"houston-password\"]').val();\n afterLogin = function(error) {\n // TODO error case that properly displays\n if (error) {\n return alert(error);\n } else {\n return Houston._go('home');\n }\n };\n if (Houston._admin_user_exists()) {\n return Meteor.loginWithPassword(email, password, afterLogin);\n } else {\n return Accounts.createUser({\n email: email,\n password: password\n }, function(error) {\n if (error) {\n return afterLogin(error);\n }\n // else - user got created\n return Houston._call('make_admin', Meteor.userId(), afterLogin);\n });\n }\n },\n 'click #houston-logout': function(e) {\n e.preventDefault();\n Meteor.logout();\n // going 'home' clears the side nav\n return Houston._go('home');\n },\n 'click #become-houston-admin': function(e) {\n e.preventDefault();\n Houston._call('make_admin', Meteor.userId());\n return Houston._go('home');\n }\n});\n\nTemplate._houston_login.rendered = function() {\n debugger;\n return $(window).unbind('scroll');\n};", "source_lang": "CoffeeScript", "target_lang": "JavaScript", "repo": "gterrono/houston", "path": "client/admin_login.coffee", "license": "MIT", "commit": "a32808b056df45e21fb59f9bce37162f03d626b1", "stars": 802, "source_url": "https://github.com/gterrono/houston/blob/a32808b056df45e21fb59f9bce37162f03d626b1/client/admin_login.coffee", "line_start": 1, "line_end": 43}1151{"id": "gterrono/houston:client/admin_login.coffee:1:js_to_coffee", "type": "js_to_coffee", "prompt": "Convert this JavaScript to CoffeeScript.\n```javascript\nTemplate._houston_login.helpers({\n logged_in: function() {\n return Meteor.user();\n }\n});\n\nTemplate._houston_login.events({\n 'submit #houston-sign-in-form': function(e) {\n var afterLogin, email, password;\n e.preventDefault();\n email = $('input[name=\"houston-email\"]').val();\n password = $('input[name=\"houston-password\"]').val();\n afterLogin = function(error) {\n // TODO error case that properly displays\n if (error) {\n return alert(error);\n } else {\n return Houston._go('home');\n }\n };\n if (Houston._admin_user_exists()) {\n return Meteor.loginWithPassword(email, password, afterLogin);\n } else {\n return Accounts.createUser({\n email: email,\n password: password\n }, function(error) {\n if (error) {\n return afterLogin(error);\n }\n // else - user got created\n return Houston._call('make_admin', Meteor.userId(), afterLogin);\n });\n }\n },\n 'click #houston-logout': function(e) {\n e.preventDefault();\n Meteor.logout();\n // going 'home' clears the side nav\n return Houston._go('home');\n },\n 'click #become-houston-admin': function(e) {\n e.preventDefault();\n Houston._call('make_admin', Meteor.userId());\n return Houston._go('home');\n }\n});\n\nTemplate._houston_login.rendered = function() {\n debugger;\n return $(window).unbind('scroll');\n};\n```", "response": "Template._houston_login.helpers(\n logged_in: -> Meteor.user()\n)\n\nTemplate._houston_login.events(\n 'submit #houston-sign-in-form': (e) ->\n e.preventDefault()\n email = $('input[name=\"houston-email\"]').val()\n password = $('input[name=\"houston-password\"]').val()\n\n afterLogin = (error) ->\n # TODO error case that properly displays\n if error\n alert error\n else\n Houston._go 'home'\n\n if Houston._admin_user_exists()\n Meteor.loginWithPassword email, password, afterLogin\n else\n Accounts.createUser {\n email: email\n password: password\n }, (error) ->\n return afterLogin(error) if error\n # else - user got created\n Houston._call('make_admin', Meteor.userId(), afterLogin)\n\n 'click #houston-logout': (e) ->\n e.preventDefault()\n Meteor.logout()\n # going 'home' clears the side nav\n Houston._go 'home'\n\n 'click #become-houston-admin': (e) ->\n e.preventDefault()\n Houston._call('make_admin', Meteor.userId())\n Houston._go 'home'\n)\n\nTemplate._houston_login.rendered = ->\n debugger\n $(window).unbind('scroll')", "source_lang": "JavaScript", "target_lang": "CoffeeScript", "repo": "gterrono/houston", "path": "client/admin_login.coffee", "license": "MIT", "commit": "a32808b056df45e21fb59f9bce37162f03d626b1", "stars": 802, "source_url": "https://github.com/gterrono/houston/blob/a32808b056df45e21fb59f9bce37162f03d626b1/client/admin_login.coffee", "line_start": 1, "line_end": 43}1152{"id": "gterrono/houston:client/admin_login.coffee:1:completion", "type": "completion", "prompt": "Template._houston_login.helpers(\n logged_in: -> Meteor.user()\n)\n\nTemplate._houston_login.events(\n 'submit #houston-sign-in-form': (e) ->\n e.preventDefault()\n email = $('input[name=\"houston-email\"]').val()\n password = $('input[name=\"houston-password\"]').val()\n\n afterLogin = (error) ->\n # TODO error case that properly displays\n if error\n alert error\n else\n Houston._go 'home'\n\n if Houston._admin_user_exists()\n Meteor.loginWithPassword email, password, afterLogin\n else\n Accounts.createUser {", "response": "email: email\n password: password\n }, (error) ->\n return afterLogin(error) if error\n # else - user got created\n Houston._call('make_admin', Meteor.userId(), afterLogin)\n\n 'click #houston-logout': (e) ->\n e.preventDefault()\n Meteor.logout()\n # going 'home' clears the side nav\n Houston._go 'home'\n\n 'click #become-houston-admin': (e) ->\n e.preventDefault()\n Houston._call('make_admin', Meteor.userId())\n Houston._go 'home'\n)\n\nTemplate._houston_login.rendered = ->\n debugger\n $(window).unbind('scroll')", "source_lang": "CoffeeScript", "target_lang": "CoffeeScript", "repo": "gterrono/houston", "path": "client/admin_login.coffee", "license": "MIT", "commit": "a32808b056df45e21fb59f9bce37162f03d626b1", "stars": 802, "source_url": "https://github.com/gterrono/houston/blob/a32808b056df45e21fb59f9bce37162f03d626b1/client/admin_login.coffee", "line_start": 1, "line_end": 43}1153{"id": "gterrono/houston:client/admin_login.coffee:1:raw_corpus", "type": "raw_corpus", "prompt": "", "response": "Template._houston_login.helpers(\n logged_in: -> Meteor.user()\n)\n\nTemplate._houston_login.events(\n 'submit #houston-sign-in-form': (e) ->\n e.preventDefault()\n email = $('input[name=\"houston-email\"]').val()\n password = $('input[name=\"houston-password\"]').val()\n\n afterLogin = (error) ->\n # TODO error case that properly displays\n if error\n alert error\n else\n Houston._go 'home'\n\n if admin_user_exists()\n Meteor.loginWithPassword email, password, afterLogin\n else\n Accounts.createUser {\n email: email\n password: password\n }, (error) ->\n return afterLogin(error) if error\n # else - user got created\n Houston._call('make_admin', Meteor.userId(), afterLogin)\n\n 'click #houston-logout': (e) ->\n e.preventDefault()\n Meteor.logout()\n # going 'home' clears the side nav\n Houston._go 'home'\n\n 'click #become-houston-admin': (e) ->\n e.preventDefault()\n Houston._call('make_admin', Meteor.userId())\n Houston._go 'home'\n)\n\nTemplate._houston_login.rendered = ->\n $(window).unbind('scroll')", "source_lang": "", "target_lang": "CoffeeScript", "repo": "gterrono/houston", "path": "client/admin_login.coffee", "license": "MIT", "commit": "e0a2c35a38f51213a3155b576b41de2b73330ac4", "stars": 802, "source_url": "https://github.com/gterrono/houston/blob/e0a2c35a38f51213a3155b576b41de2b73330ac4/client/admin_login.coffee", "line_start": 1, "line_end": 42}1154{"id": "gterrono/houston:client/admin_login.coffee:1:coffee_to_js", "type": "coffee_to_js", "prompt": "Convert this CoffeeScript to JavaScript.\n```coffeescript\nTemplate._houston_login.helpers(\n logged_in: -> Meteor.user()\n)\n\nTemplate._houston_login.events(\n 'submit #houston-sign-in-form': (e) ->\n e.preventDefault()\n email = $('input[name=\"houston-email\"]').val()\n password = $('input[name=\"houston-password\"]').val()\n\n afterLogin = (error) ->\n # TODO error case that properly displays\n if error\n alert error\n else\n Houston._go 'home'\n\n if admin_user_exists()\n Meteor.loginWithPassword email, password, afterLogin\n else\n Accounts.createUser {\n email: email\n password: password\n }, (error) ->\n return afterLogin(error) if error\n # else - user got created\n Houston._call('make_admin', Meteor.userId(), afterLogin)\n\n 'click #houston-logout': (e) ->\n e.preventDefault()\n Meteor.logout()\n # going 'home' clears the side nav\n Houston._go 'home'\n\n 'click #become-houston-admin': (e) ->\n e.preventDefault()\n Houston._call('make_admin', Meteor.userId())\n Houston._go 'home'\n)\n\nTemplate._houston_login.rendered = ->\n $(window).unbind('scroll')\n```", "response": "Template._houston_login.helpers({\n logged_in: function() {\n return Meteor.user();\n }\n});\n\nTemplate._houston_login.events({\n 'submit #houston-sign-in-form': function(e) {\n var afterLogin, email, password;\n e.preventDefault();\n email = $('input[name=\"houston-email\"]').val();\n password = $('input[name=\"houston-password\"]').val();\n afterLogin = function(error) {\n // TODO error case that properly displays\n if (error) {\n return alert(error);\n } else {\n return Houston._go('home');\n }\n };\n if (admin_user_exists()) {\n return Meteor.loginWithPassword(email, password, afterLogin);\n } else {\n return Accounts.createUser({\n email: email,\n password: password\n }, function(error) {\n if (error) {\n return afterLogin(error);\n }\n // else - user got created\n return Houston._call('make_admin', Meteor.userId(), afterLogin);\n });\n }\n },\n 'click #houston-logout': function(e) {\n e.preventDefault();\n Meteor.logout();\n // going 'home' clears the side nav\n return Houston._go('home');\n },\n 'click #become-houston-admin': function(e) {\n e.preventDefault();\n Houston._call('make_admin', Meteor.userId());\n return Houston._go('home');\n }\n});\n\nTemplate._houston_login.rendered = function() {\n return $(window).unbind('scroll');\n};", "source_lang": "CoffeeScript", "target_lang": "JavaScript", "repo": "gterrono/houston", "path": "client/admin_login.coffee", "license": "MIT", "commit": "e0a2c35a38f51213a3155b576b41de2b73330ac4", "stars": 802, "source_url": "https://github.com/gterrono/houston/blob/e0a2c35a38f51213a3155b576b41de2b73330ac4/client/admin_login.coffee", "line_start": 1, "line_end": 42}1155{"id": "gterrono/houston:client/admin_login.coffee:1:js_to_coffee", "type": "js_to_coffee", "prompt": "Convert this JavaScript to CoffeeScript.\n```javascript\nTemplate._houston_login.helpers({\n logged_in: function() {\n return Meteor.user();\n }\n});\n\nTemplate._houston_login.events({\n 'submit #houston-sign-in-form': function(e) {\n var afterLogin, email, password;\n e.preventDefault();\n email = $('input[name=\"houston-email\"]').val();\n password = $('input[name=\"houston-password\"]').val();\n afterLogin = function(error) {\n // TODO error case that properly displays\n if (error) {\n return alert(error);\n } else {\n return Houston._go('home');\n }\n };\n if (admin_user_exists()) {\n return Meteor.loginWithPassword(email, password, afterLogin);\n } else {\n return Accounts.createUser({\n email: email,\n password: password\n }, function(error) {\n if (error) {\n return afterLogin(error);\n }\n // else - user got created\n return Houston._call('make_admin', Meteor.userId(), afterLogin);\n });\n }\n },\n 'click #houston-logout': function(e) {\n e.preventDefault();\n Meteor.logout();\n // going 'home' clears the side nav\n return Houston._go('home');\n },\n 'click #become-houston-admin': function(e) {\n e.preventDefault();\n Houston._call('make_admin', Meteor.userId());\n return Houston._go('home');\n }\n});\n\nTemplate._houston_login.rendered = function() {\n return $(window).unbind('scroll');\n};\n```", "response": "Template._houston_login.helpers(\n logged_in: -> Meteor.user()\n)\n\nTemplate._houston_login.events(\n 'submit #houston-sign-in-form': (e) ->\n e.preventDefault()\n email = $('input[name=\"houston-email\"]').val()\n password = $('input[name=\"houston-password\"]').val()\n\n afterLogin = (error) ->\n # TODO error case that properly displays\n if error\n alert error\n else\n Houston._go 'home'\n\n if admin_user_exists()\n Meteor.loginWithPassword email, password, afterLogin\n else\n Accounts.createUser {\n email: email\n password: password\n }, (error) ->\n return afterLogin(error) if error\n # else - user got created\n Houston._call('make_admin', Meteor.userId(), afterLogin)\n\n 'click #houston-logout': (e) ->\n e.preventDefault()\n Meteor.logout()\n # going 'home' clears the side nav\n Houston._go 'home'\n\n 'click #become-houston-admin': (e) ->\n e.preventDefault()\n Houston._call('make_admin', Meteor.userId())\n Houston._go 'home'\n)\n\nTemplate._houston_login.rendered = ->\n $(window).unbind('scroll')", "source_lang": "JavaScript", "target_lang": "CoffeeScript", "repo": "gterrono/houston", "path": "client/admin_login.coffee", "license": "MIT", "commit": "e0a2c35a38f51213a3155b576b41de2b73330ac4", "stars": 802, "source_url": "https://github.com/gterrono/houston/blob/e0a2c35a38f51213a3155b576b41de2b73330ac4/client/admin_login.coffee", "line_start": 1, "line_end": 42}1156{"id": "gterrono/houston:client/admin_login.coffee:1:completion", "type": "completion", "prompt": "Template._houston_login.helpers(\n logged_in: -> Meteor.user()\n)\n\nTemplate._houston_login.events(\n 'submit #houston-sign-in-form': (e) ->\n e.preventDefault()\n email = $('input[name=\"houston-email\"]').val()\n password = $('input[name=\"houston-password\"]').val()\n\n afterLogin = (error) ->\n # TODO error case that properly displays\n if error\n alert error\n else\n Houston._go 'home'\n\n if admin_user_exists()\n Meteor.loginWithPassword email, password, afterLogin\n else\n Accounts.createUser {", "response": "email: email\n password: password\n }, (error) ->\n return afterLogin(error) if error\n # else - user got created\n Houston._call('make_admin', Meteor.userId(), afterLogin)\n\n 'click #houston-logout': (e) ->\n e.preventDefault()\n Meteor.logout()\n # going 'home' clears the side nav\n Houston._go 'home'\n\n 'click #become-houston-admin': (e) ->\n e.preventDefault()\n Houston._call('make_admin', Meteor.userId())\n Houston._go 'home'\n)\n\nTemplate._houston_login.rendered = ->\n $(window).unbind('scroll')", "source_lang": "CoffeeScript", "target_lang": "CoffeeScript", "repo": "gterrono/houston", "path": "client/admin_login.coffee", "license": "MIT", "commit": "e0a2c35a38f51213a3155b576b41de2b73330ac4", "stars": 802, "source_url": "https://github.com/gterrono/houston/blob/e0a2c35a38f51213a3155b576b41de2b73330ac4/client/admin_login.coffee", "line_start": 1, "line_end": 42}1157{"id": "gterrono/houston:client/admin_login.coffee:1:raw_corpus", "type": "raw_corpus", "prompt": "", "response": "admin_user_exists = () -> Houston._admins.find().count() > 0\n\nTemplate._houston_login.helpers(\n logged_in: -> Meteor.user()\n admin_user_exists: -> admin_user_exists()\n current_user_is_admin: -> Houston._user_is_admin(Meteor.userId())\n)\n\nTemplate._houston_login.events(\n 'submit #houston-sign-in-form': (e) ->\n e.preventDefault()\n email = $('input[name=\"houston-email\"]').val()\n password = $('input[name=\"houston-password\"]').val()\n\n afterLogin = (error) ->\n # TODO error case that properly displays\n if error\n alert error\n else\n Houston._go 'home'\n\n if admin_user_exists()\n Meteor.loginWithPassword email, password, afterLogin\n else\n Accounts.createUser {\n email: email\n password: password\n }, (error) ->\n return afterLogin(error) if error\n # else - user got created\n Houston._call('make_admin', Meteor.userId(), afterLogin)\n\n 'click #houston-logout': (e) ->\n e.preventDefault()\n Meteor.logout()\n # going 'home' clears the side nav\n Houston._go 'home'\n\n 'click #become-houston-admin': (e) ->\n e.preventDefault()\n Houston._call('make_admin', Meteor.userId())\n Houston._go 'home'\n)\n\nTemplate._houston_login.rendered = ->\n $(window).unbind('scroll')", "source_lang": "", "target_lang": "CoffeeScript", "repo": "gterrono/houston", "path": "client/admin_login.coffee", "license": "MIT", "commit": "2eae6f2f5b0c84cee19ee4f568143177c0cef0e7", "stars": 802, "source_url": "https://github.com/gterrono/houston/blob/2eae6f2f5b0c84cee19ee4f568143177c0cef0e7/client/admin_login.coffee", "line_start": 1, "line_end": 46}1158{"id": "gterrono/houston:client/admin_login.coffee:1:coffee_to_js", "type": "coffee_to_js", "prompt": "Convert this CoffeeScript to JavaScript.\n```coffeescript\nadmin_user_exists = () -> Houston._admins.find().count() > 0\n\nTemplate._houston_login.helpers(\n logged_in: -> Meteor.user()\n admin_user_exists: -> admin_user_exists()\n current_user_is_admin: -> Houston._user_is_admin(Meteor.userId())\n)\n\nTemplate._houston_login.events(\n 'submit #houston-sign-in-form': (e) ->\n e.preventDefault()\n email = $('input[name=\"houston-email\"]').val()\n password = $('input[name=\"houston-password\"]').val()\n\n afterLogin = (error) ->\n # TODO error case that properly displays\n if error\n alert error\n else\n Houston._go 'home'\n\n if admin_user_exists()\n Meteor.loginWithPassword email, password, afterLogin\n else\n Accounts.createUser {\n email: email\n password: password\n }, (error) ->\n return afterLogin(error) if error\n # else - user got created\n Houston._call('make_admin', Meteor.userId(), afterLogin)\n\n 'click #houston-logout': (e) ->\n e.preventDefault()\n Meteor.logout()\n # going 'home' clears the side nav\n Houston._go 'home'\n\n 'click #become-houston-admin': (e) ->\n e.preventDefault()\n Houston._call('make_admin', Meteor.userId())\n Houston._go 'home'\n)\n\nTemplate._houston_login.rendered = ->\n $(window).unbind('scroll')\n```", "response": "var admin_user_exists;\n\nadmin_user_exists = function() {\n return Houston._admins.find().count() > 0;\n};\n\nTemplate._houston_login.helpers({\n logged_in: function() {\n return Meteor.user();\n },\n admin_user_exists: function() {\n return admin_user_exists();\n },\n current_user_is_admin: function() {\n return Houston._user_is_admin(Meteor.userId());\n }\n});\n\nTemplate._houston_login.events({\n 'submit #houston-sign-in-form': function(e) {\n var afterLogin, email, password;\n e.preventDefault();\n email = $('input[name=\"houston-email\"]').val();\n password = $('input[name=\"houston-password\"]').val();\n afterLogin = function(error) {\n // TODO error case that properly displays\n if (error) {\n return alert(error);\n } else {\n return Houston._go('home');\n }\n };\n if (admin_user_exists()) {\n return Meteor.loginWithPassword(email, password, afterLogin);\n } else {\n return Accounts.createUser({\n email: email,\n password: password\n }, function(error) {\n if (error) {\n return afterLogin(error);\n }\n // else - user got created\n return Houston._call('make_admin', Meteor.userId(), afterLogin);\n });\n }\n },\n 'click #houston-logout': function(e) {\n e.preventDefault();\n Meteor.logout();\n // going 'home' clears the side nav\n return Houston._go('home');\n },\n 'click #become-houston-admin': function(e) {\n e.preventDefault();\n Houston._call('make_admin', Meteor.userId());\n return Houston._go('home');\n }\n});\n\nTemplate._houston_login.rendered = function() {\n return $(window).unbind('scroll');\n};", "source_lang": "CoffeeScript", "target_lang": "JavaScript", "repo": "gterrono/houston", "path": "client/admin_login.coffee", "license": "MIT", "commit": "2eae6f2f5b0c84cee19ee4f568143177c0cef0e7", "stars": 802, "source_url": "https://github.com/gterrono/houston/blob/2eae6f2f5b0c84cee19ee4f568143177c0cef0e7/client/admin_login.coffee", "line_start": 1, "line_end": 46}1159{"id": "gterrono/houston:client/admin_login.coffee:1:js_to_coffee", "type": "js_to_coffee", "prompt": "Convert this JavaScript to CoffeeScript.\n```javascript\nvar admin_user_exists;\n\nadmin_user_exists = function() {\n return Houston._admins.find().count() > 0;\n};\n\nTemplate._houston_login.helpers({\n logged_in: function() {\n return Meteor.user();\n },\n admin_user_exists: function() {\n return admin_user_exists();\n },\n current_user_is_admin: function() {\n return Houston._user_is_admin(Meteor.userId());\n }\n});\n\nTemplate._houston_login.events({\n 'submit #houston-sign-in-form': function(e) {\n var afterLogin, email, password;\n e.preventDefault();\n email = $('input[name=\"houston-email\"]').val();\n password = $('input[name=\"houston-password\"]').val();\n afterLogin = function(error) {\n // TODO error case that properly displays\n if (error) {\n return alert(error);\n } else {\n return Houston._go('home');\n }\n };\n if (admin_user_exists()) {\n return Meteor.loginWithPassword(email, password, afterLogin);\n } else {\n return Accounts.createUser({\n email: email,\n password: password\n }, function(error) {\n if (error) {\n return afterLogin(error);\n }\n // else - user got created\n return Houston._call('make_admin', Meteor.userId(), afterLogin);\n });\n }\n },\n 'click #houston-logout': function(e) {\n e.preventDefault();\n Meteor.logout();\n // going 'home' clears the side nav\n return Houston._go('home');\n },\n 'click #become-houston-admin': function(e) {\n e.preventDefault();\n Houston._call('make_admin', Meteor.userId());\n return Houston._go('home');\n }\n});\n\nTemplate._houston_login.rendered = function() {\n return $(window).unbind('scroll');\n};\n```", "response": "admin_user_exists = () -> Houston._admins.find().count() > 0\n\nTemplate._houston_login.helpers(\n logged_in: -> Meteor.user()\n admin_user_exists: -> admin_user_exists()\n current_user_is_admin: -> Houston._user_is_admin(Meteor.userId())\n)\n\nTemplate._houston_login.events(\n 'submit #houston-sign-in-form': (e) ->\n e.preventDefault()\n email = $('input[name=\"houston-email\"]').val()\n password = $('input[name=\"houston-password\"]').val()\n\n afterLogin = (error) ->\n # TODO error case that properly displays\n if error\n alert error\n else\n Houston._go 'home'\n\n if admin_user_exists()\n Meteor.loginWithPassword email, password, afterLogin\n else\n Accounts.createUser {\n email: email\n password: password\n }, (error) ->\n return afterLogin(error) if error\n # else - user got created\n Houston._call('make_admin', Meteor.userId(), afterLogin)\n\n 'click #houston-logout': (e) ->\n e.preventDefault()\n Meteor.logout()\n # going 'home' clears the side nav\n Houston._go 'home'\n\n 'click #become-houston-admin': (e) ->\n e.preventDefault()\n Houston._call('make_admin', Meteor.userId())\n Houston._go 'home'\n)\n\nTemplate._houston_login.rendered = ->\n $(window).unbind('scroll')", "source_lang": "JavaScript", "target_lang": "CoffeeScript", "repo": "gterrono/houston", "path": "client/admin_login.coffee", "license": "MIT", "commit": "2eae6f2f5b0c84cee19ee4f568143177c0cef0e7", "stars": 802, "source_url": "https://github.com/gterrono/houston/blob/2eae6f2f5b0c84cee19ee4f568143177c0cef0e7/client/admin_login.coffee", "line_start": 1, "line_end": 46}1160{"id": "gterrono/houston:client/admin_login.coffee:1:completion", "type": "completion", "prompt": "admin_user_exists = () -> Houston._admins.find().count() > 0\n\nTemplate._houston_login.helpers(\n logged_in: -> Meteor.user()\n admin_user_exists: -> admin_user_exists()\n current_user_is_admin: -> Houston._user_is_admin(Meteor.userId())\n)\n\nTemplate._houston_login.events(\n 'submit #houston-sign-in-form': (e) ->\n e.preventDefault()\n email = $('input[name=\"houston-email\"]').val()\n password = $('input[name=\"houston-password\"]').val()\n\n afterLogin = (error) ->\n # TODO error case that properly displays\n if error\n alert error\n else\n Houston._go 'home'\n\n if admin_user_exists()\n Meteor.loginWithPassword email, password, afterLogin", "response": "else\n Accounts.createUser {\n email: email\n password: password\n }, (error) ->\n return afterLogin(error) if error\n # else - user got created\n Houston._call('make_admin', Meteor.userId(), afterLogin)\n\n 'click #houston-logout': (e) ->\n e.preventDefault()\n Meteor.logout()\n # going 'home' clears the side nav\n Houston._go 'home'\n\n 'click #become-houston-admin': (e) ->\n e.preventDefault()\n Houston._call('make_admin', Meteor.userId())\n Houston._go 'home'\n)\n\nTemplate._houston_login.rendered = ->\n $(window).unbind('scroll')", "source_lang": "CoffeeScript", "target_lang": "CoffeeScript", "repo": "gterrono/houston", "path": "client/admin_login.coffee", "license": "MIT", "commit": "2eae6f2f5b0c84cee19ee4f568143177c0cef0e7", "stars": 802, "source_url": "https://github.com/gterrono/houston/blob/2eae6f2f5b0c84cee19ee4f568143177c0cef0e7/client/admin_login.coffee", "line_start": 1, "line_end": 46}1161{"id": "gterrono/houston:client/admin_login.coffee:1:raw_corpus", "type": "raw_corpus", "prompt": "", "response": "admin_user_exists = () -> Houston._admins.find().count() > 0\n\nTemplate._houston_login.helpers(\n logged_in: -> Meteor.user()\n admin_user_exists: -> admin_user_exists()\n)\n\nTemplate._houston_login.events(\n 'submit #houston-sign-in-form': (e) ->\n e.preventDefault()\n email = $('input[name=\"houston-email\"]').val()\n password = $('input[name=\"houston-password\"]').val()\n\n afterLogin = (error) ->\n # TODO error case that properly displays\n if error\n alert error\n else\n Houston._go 'home'\n\n if admin_user_exists()\n Meteor.loginWithPassword email, password, afterLogin\n else\n Accounts.createUser {\n email: email\n password: password\n }, (error) ->\n return afterLogin(error) if error\n # else - user got created\n Houston._call('make_admin', Meteor.userId(), afterLogin)\n\n 'click #houston-logout': (e) ->\n e.preventDefault()\n Meteor.logout()\n # going 'home' clears the side nav\n Houston._go 'home'\n\n 'click #become-houston-admin': (e) ->\n e.preventDefault()\n Houston._call('make_admin', Meteor.userId())\n Houston._go 'home'\n)\n\nTemplate._houston_login.rendered = ->\n $(window).unbind('scroll')", "source_lang": "", "target_lang": "CoffeeScript", "repo": "gterrono/houston", "path": "client/admin_login.coffee", "license": "MIT", "commit": "75213c999ee4e09162310c20fc0217b78bd4068b", "stars": 802, "source_url": "https://github.com/gterrono/houston/blob/75213c999ee4e09162310c20fc0217b78bd4068b/client/admin_login.coffee", "line_start": 1, "line_end": 45}1162{"id": "gterrono/houston:client/admin_login.coffee:1:coffee_to_js", "type": "coffee_to_js", "prompt": "Convert this CoffeeScript to JavaScript.\n```coffeescript\nadmin_user_exists = () -> Houston._admins.find().count() > 0\n\nTemplate._houston_login.helpers(\n logged_in: -> Meteor.user()\n admin_user_exists: -> admin_user_exists()\n)\n\nTemplate._houston_login.events(\n 'submit #houston-sign-in-form': (e) ->\n e.preventDefault()\n email = $('input[name=\"houston-email\"]').val()\n password = $('input[name=\"houston-password\"]').val()\n\n afterLogin = (error) ->\n # TODO error case that properly displays\n if error\n alert error\n else\n Houston._go 'home'\n\n if admin_user_exists()\n Meteor.loginWithPassword email, password, afterLogin\n else\n Accounts.createUser {\n email: email\n password: password\n }, (error) ->\n return afterLogin(error) if error\n # else - user got created\n Houston._call('make_admin', Meteor.userId(), afterLogin)\n\n 'click #houston-logout': (e) ->\n e.preventDefault()\n Meteor.logout()\n # going 'home' clears the side nav\n Houston._go 'home'\n\n 'click #become-houston-admin': (e) ->\n e.preventDefault()\n Houston._call('make_admin', Meteor.userId())\n Houston._go 'home'\n)\n\nTemplate._houston_login.rendered = ->\n $(window).unbind('scroll')\n```", "response": "var admin_user_exists;\n\nadmin_user_exists = function() {\n return Houston._admins.find().count() > 0;\n};\n\nTemplate._houston_login.helpers({\n logged_in: function() {\n return Meteor.user();\n },\n admin_user_exists: function() {\n return admin_user_exists();\n }\n});\n\nTemplate._houston_login.events({\n 'submit #houston-sign-in-form': function(e) {\n var afterLogin, email, password;\n e.preventDefault();\n email = $('input[name=\"houston-email\"]').val();\n password = $('input[name=\"houston-password\"]').val();\n afterLogin = function(error) {\n // TODO error case that properly displays\n if (error) {\n return alert(error);\n } else {\n return Houston._go('home');\n }\n };\n if (admin_user_exists()) {\n return Meteor.loginWithPassword(email, password, afterLogin);\n } else {\n return Accounts.createUser({\n email: email,\n password: password\n }, function(error) {\n if (error) {\n return afterLogin(error);\n }\n // else - user got created\n return Houston._call('make_admin', Meteor.userId(), afterLogin);\n });\n }\n },\n 'click #houston-logout': function(e) {\n e.preventDefault();\n Meteor.logout();\n // going 'home' clears the side nav\n return Houston._go('home');\n },\n 'click #become-houston-admin': function(e) {\n e.preventDefault();\n Houston._call('make_admin', Meteor.userId());\n return Houston._go('home');\n }\n});\n\nTemplate._houston_login.rendered = function() {\n return $(window).unbind('scroll');\n};", "source_lang": "CoffeeScript", "target_lang": "JavaScript", "repo": "gterrono/houston", "path": "client/admin_login.coffee", "license": "MIT", "commit": "75213c999ee4e09162310c20fc0217b78bd4068b", "stars": 802, "source_url": "https://github.com/gterrono/houston/blob/75213c999ee4e09162310c20fc0217b78bd4068b/client/admin_login.coffee", "line_start": 1, "line_end": 45}1163{"id": "gterrono/houston:client/admin_login.coffee:1:js_to_coffee", "type": "js_to_coffee", "prompt": "Convert this JavaScript to CoffeeScript.\n```javascript\nvar admin_user_exists;\n\nadmin_user_exists = function() {\n return Houston._admins.find().count() > 0;\n};\n\nTemplate._houston_login.helpers({\n logged_in: function() {\n return Meteor.user();\n },\n admin_user_exists: function() {\n return admin_user_exists();\n }\n});\n\nTemplate._houston_login.events({\n 'submit #houston-sign-in-form': function(e) {\n var afterLogin, email, password;\n e.preventDefault();\n email = $('input[name=\"houston-email\"]').val();\n password = $('input[name=\"houston-password\"]').val();\n afterLogin = function(error) {\n // TODO error case that properly displays\n if (error) {\n return alert(error);\n } else {\n return Houston._go('home');\n }\n };\n if (admin_user_exists()) {\n return Meteor.loginWithPassword(email, password, afterLogin);\n } else {\n return Accounts.createUser({\n email: email,\n password: password\n }, function(error) {\n if (error) {\n return afterLogin(error);\n }\n // else - user got created\n return Houston._call('make_admin', Meteor.userId(), afterLogin);\n });\n }\n },\n 'click #houston-logout': function(e) {\n e.preventDefault();\n Meteor.logout();\n // going 'home' clears the side nav\n return Houston._go('home');\n },\n 'click #become-houston-admin': function(e) {\n e.preventDefault();\n Houston._call('make_admin', Meteor.userId());\n return Houston._go('home');\n }\n});\n\nTemplate._houston_login.rendered = function() {\n return $(window).unbind('scroll');\n};\n```", "response": "admin_user_exists = () -> Houston._admins.find().count() > 0\n\nTemplate._houston_login.helpers(\n logged_in: -> Meteor.user()\n admin_user_exists: -> admin_user_exists()\n)\n\nTemplate._houston_login.events(\n 'submit #houston-sign-in-form': (e) ->\n e.preventDefault()\n email = $('input[name=\"houston-email\"]').val()\n password = $('input[name=\"houston-password\"]').val()\n\n afterLogin = (error) ->\n # TODO error case that properly displays\n if error\n alert error\n else\n Houston._go 'home'\n\n if admin_user_exists()\n Meteor.loginWithPassword email, password, afterLogin\n else\n Accounts.createUser {\n email: email\n password: password\n }, (error) ->\n return afterLogin(error) if error\n # else - user got created\n Houston._call('make_admin', Meteor.userId(), afterLogin)\n\n 'click #houston-logout': (e) ->\n e.preventDefault()\n Meteor.logout()\n # going 'home' clears the side nav\n Houston._go 'home'\n\n 'click #become-houston-admin': (e) ->\n e.preventDefault()\n Houston._call('make_admin', Meteor.userId())\n Houston._go 'home'\n)\n\nTemplate._houston_login.rendered = ->\n $(window).unbind('scroll')", "source_lang": "JavaScript", "target_lang": "CoffeeScript", "repo": "gterrono/houston", "path": "client/admin_login.coffee", "license": "MIT", "commit": "75213c999ee4e09162310c20fc0217b78bd4068b", "stars": 802, "source_url": "https://github.com/gterrono/houston/blob/75213c999ee4e09162310c20fc0217b78bd4068b/client/admin_login.coffee", "line_start": 1, "line_end": 45}1164{"id": "gterrono/houston:client/admin_login.coffee:1:completion", "type": "completion", "prompt": "admin_user_exists = () -> Houston._admins.find().count() > 0\n\nTemplate._houston_login.helpers(\n logged_in: -> Meteor.user()\n admin_user_exists: -> admin_user_exists()\n)\n\nTemplate._houston_login.events(\n 'submit #houston-sign-in-form': (e) ->\n e.preventDefault()\n email = $('input[name=\"houston-email\"]').val()\n password = $('input[name=\"houston-password\"]').val()\n\n afterLogin = (error) ->\n # TODO error case that properly displays\n if error\n alert error\n else\n Houston._go 'home'\n\n if admin_user_exists()\n Meteor.loginWithPassword email, password, afterLogin", "response": "else\n Accounts.createUser {\n email: email\n password: password\n }, (error) ->\n return afterLogin(error) if error\n # else - user got created\n Houston._call('make_admin', Meteor.userId(), afterLogin)\n\n 'click #houston-logout': (e) ->\n e.preventDefault()\n Meteor.logout()\n # going 'home' clears the side nav\n Houston._go 'home'\n\n 'click #become-houston-admin': (e) ->\n e.preventDefault()\n Houston._call('make_admin', Meteor.userId())\n Houston._go 'home'\n)\n\nTemplate._houston_login.rendered = ->\n $(window).unbind('scroll')", "source_lang": "CoffeeScript", "target_lang": "CoffeeScript", "repo": "gterrono/houston", "path": "client/admin_login.coffee", "license": "MIT", "commit": "75213c999ee4e09162310c20fc0217b78bd4068b", "stars": 802, "source_url": "https://github.com/gterrono/houston/blob/75213c999ee4e09162310c20fc0217b78bd4068b/client/admin_login.coffee", "line_start": 1, "line_end": 45}1165{"id": "gterrono/houston:client/admin_login.coffee:1:raw_corpus", "type": "raw_corpus", "prompt": "", "response": "admin_user_exists = () -> Houston._admins.find().count() > 0\n\nTemplate._houston_login.helpers(\n logged_in: -> Meteor.user()\n admin_user_exists: -> admin_user_exists()\n)\n\nTemplate._houston_login.events(\n 'submit #houston-sign-in-form': (e) ->\n e.preventDefault()\n email = $('input[name=\"houston-email\"]').val()\n password = $('input[name=\"houston-password\"]').val()\n\n afterLogin = (error) ->\n # TODO error case that properly displays\n if error\n alert error\n else\n Houston._go 'home'\n\n if admin_user_exists()\n Meteor.loginWithPassword email, password, afterLogin\n else\n Accounts.createUser {\n email: email\n password: password\n }, (error) ->\n return afterLogin(error) if error\n # else - user got created\n Houston._call('make_admin', Meteor.userId(), afterLogin)\n\n 'click .houston-logout': (e) ->\n e.preventDefault()\n Meteor.logout()\n\n 'click .become-houston-admin': (e) ->\n e.preventDefault()\n Houston._call('make_admin', Meteor.userId())\n Houston._go 'home'\n)\n\nTemplate._houston_login.rendered = ->\n $(window).unbind('scroll')", "source_lang": "", "target_lang": "CoffeeScript", "repo": "gterrono/houston", "path": "client/admin_login.coffee", "license": "MIT", "commit": "b2075e2ad57a6d32837b542c1919488fa2f65d74", "stars": 802, "source_url": "https://github.com/gterrono/houston/blob/b2075e2ad57a6d32837b542c1919488fa2f65d74/client/admin_login.coffee", "line_start": 1, "line_end": 43}1166{"id": "gterrono/houston:client/admin_login.coffee:1:coffee_to_js", "type": "coffee_to_js", "prompt": "Convert this CoffeeScript to JavaScript.\n```coffeescript\nadmin_user_exists = () -> Houston._admins.find().count() > 0\n\nTemplate._houston_login.helpers(\n logged_in: -> Meteor.user()\n admin_user_exists: -> admin_user_exists()\n)\n\nTemplate._houston_login.events(\n 'submit #houston-sign-in-form': (e) ->\n e.preventDefault()\n email = $('input[name=\"houston-email\"]').val()\n password = $('input[name=\"houston-password\"]').val()\n\n afterLogin = (error) ->\n # TODO error case that properly displays\n if error\n alert error\n else\n Houston._go 'home'\n\n if admin_user_exists()\n Meteor.loginWithPassword email, password, afterLogin\n else\n Accounts.createUser {\n email: email\n password: password\n }, (error) ->\n return afterLogin(error) if error\n # else - user got created\n Houston._call('make_admin', Meteor.userId(), afterLogin)\n\n 'click .houston-logout': (e) ->\n e.preventDefault()\n Meteor.logout()\n\n 'click .become-houston-admin': (e) ->\n e.preventDefault()\n Houston._call('make_admin', Meteor.userId())\n Houston._go 'home'\n)\n\nTemplate._houston_login.rendered = ->\n $(window).unbind('scroll')\n```", "response": "var admin_user_exists;\n\nadmin_user_exists = function() {\n return Houston._admins.find().count() > 0;\n};\n\nTemplate._houston_login.helpers({\n logged_in: function() {\n return Meteor.user();\n },\n admin_user_exists: function() {\n return admin_user_exists();\n }\n});\n\nTemplate._houston_login.events({\n 'submit #houston-sign-in-form': function(e) {\n var afterLogin, email, password;\n e.preventDefault();\n email = $('input[name=\"houston-email\"]').val();\n password = $('input[name=\"houston-password\"]').val();\n afterLogin = function(error) {\n // TODO error case that properly displays\n if (error) {\n return alert(error);\n } else {\n return Houston._go('home');\n }\n };\n if (admin_user_exists()) {\n return Meteor.loginWithPassword(email, password, afterLogin);\n } else {\n return Accounts.createUser({\n email: email,\n password: password\n }, function(error) {\n if (error) {\n return afterLogin(error);\n }\n // else - user got created\n return Houston._call('make_admin', Meteor.userId(), afterLogin);\n });\n }\n },\n 'click .houston-logout': function(e) {\n e.preventDefault();\n return Meteor.logout();\n },\n 'click .become-houston-admin': function(e) {\n e.preventDefault();\n Houston._call('make_admin', Meteor.userId());\n return Houston._go('home');\n }\n});\n\nTemplate._houston_login.rendered = function() {\n return $(window).unbind('scroll');\n};", "source_lang": "CoffeeScript", "target_lang": "JavaScript", "repo": "gterrono/houston", "path": "client/admin_login.coffee", "license": "MIT", "commit": "b2075e2ad57a6d32837b542c1919488fa2f65d74", "stars": 802, "source_url": "https://github.com/gterrono/houston/blob/b2075e2ad57a6d32837b542c1919488fa2f65d74/client/admin_login.coffee", "line_start": 1, "line_end": 43}1167{"id": "gterrono/houston:client/admin_login.coffee:1:js_to_coffee", "type": "js_to_coffee", "prompt": "Convert this JavaScript to CoffeeScript.\n```javascript\nvar admin_user_exists;\n\nadmin_user_exists = function() {\n return Houston._admins.find().count() > 0;\n};\n\nTemplate._houston_login.helpers({\n logged_in: function() {\n return Meteor.user();\n },\n admin_user_exists: function() {\n return admin_user_exists();\n }\n});\n\nTemplate._houston_login.events({\n 'submit #houston-sign-in-form': function(e) {\n var afterLogin, email, password;\n e.preventDefault();\n email = $('input[name=\"houston-email\"]').val();\n password = $('input[name=\"houston-password\"]').val();\n afterLogin = function(error) {\n // TODO error case that properly displays\n if (error) {\n return alert(error);\n } else {\n return Houston._go('home');\n }\n };\n if (admin_user_exists()) {\n return Meteor.loginWithPassword(email, password, afterLogin);\n } else {\n return Accounts.createUser({\n email: email,\n password: password\n }, function(error) {\n if (error) {\n return afterLogin(error);\n }\n // else - user got created\n return Houston._call('make_admin', Meteor.userId(), afterLogin);\n });\n }\n },\n 'click .houston-logout': function(e) {\n e.preventDefault();\n return Meteor.logout();\n },\n 'click .become-houston-admin': function(e) {\n e.preventDefault();\n Houston._call('make_admin', Meteor.userId());\n return Houston._go('home');\n }\n});\n\nTemplate._houston_login.rendered = function() {\n return $(window).unbind('scroll');\n};\n```", "response": "admin_user_exists = () -> Houston._admins.find().count() > 0\n\nTemplate._houston_login.helpers(\n logged_in: -> Meteor.user()\n admin_user_exists: -> admin_user_exists()\n)\n\nTemplate._houston_login.events(\n 'submit #houston-sign-in-form': (e) ->\n e.preventDefault()\n email = $('input[name=\"houston-email\"]').val()\n password = $('input[name=\"houston-password\"]').val()\n\n afterLogin = (error) ->\n # TODO error case that properly displays\n if error\n alert error\n else\n Houston._go 'home'\n\n if admin_user_exists()\n Meteor.loginWithPassword email, password, afterLogin\n else\n Accounts.createUser {\n email: email\n password: password\n }, (error) ->\n return afterLogin(error) if error\n # else - user got created\n Houston._call('make_admin', Meteor.userId(), afterLogin)\n\n 'click .houston-logout': (e) ->\n e.preventDefault()\n Meteor.logout()\n\n 'click .become-houston-admin': (e) ->\n e.preventDefault()\n Houston._call('make_admin', Meteor.userId())\n Houston._go 'home'\n)\n\nTemplate._houston_login.rendered = ->\n $(window).unbind('scroll')", "source_lang": "JavaScript", "target_lang": "CoffeeScript", "repo": "gterrono/houston", "path": "client/admin_login.coffee", "license": "MIT", "commit": "b2075e2ad57a6d32837b542c1919488fa2f65d74", "stars": 802, "source_url": "https://github.com/gterrono/houston/blob/b2075e2ad57a6d32837b542c1919488fa2f65d74/client/admin_login.coffee", "line_start": 1, "line_end": 43}1168{"id": "gterrono/houston:client/admin_login.coffee:1:completion", "type": "completion", "prompt": "admin_user_exists = () -> Houston._admins.find().count() > 0\n\nTemplate._houston_login.helpers(\n logged_in: -> Meteor.user()\n admin_user_exists: -> admin_user_exists()\n)\n\nTemplate._houston_login.events(\n 'submit #houston-sign-in-form': (e) ->\n e.preventDefault()\n email = $('input[name=\"houston-email\"]').val()\n password = $('input[name=\"houston-password\"]').val()\n\n afterLogin = (error) ->\n # TODO error case that properly displays\n if error\n alert error\n else\n Houston._go 'home'\n\n if admin_user_exists()", "response": "Meteor.loginWithPassword email, password, afterLogin\n else\n Accounts.createUser {\n email: email\n password: password\n }, (error) ->\n return afterLogin(error) if error\n # else - user got created\n Houston._call('make_admin', Meteor.userId(), afterLogin)\n\n 'click .houston-logout': (e) ->\n e.preventDefault()\n Meteor.logout()\n\n 'click .become-houston-admin': (e) ->\n e.preventDefault()\n Houston._call('make_admin', Meteor.userId())\n Houston._go 'home'\n)\n\nTemplate._houston_login.rendered = ->\n $(window).unbind('scroll')", "source_lang": "CoffeeScript", "target_lang": "CoffeeScript", "repo": "gterrono/houston", "path": "client/admin_login.coffee", "license": "MIT", "commit": "b2075e2ad57a6d32837b542c1919488fa2f65d74", "stars": 802, "source_url": "https://github.com/gterrono/houston/blob/b2075e2ad57a6d32837b542c1919488fa2f65d74/client/admin_login.coffee", "line_start": 1, "line_end": 43}1169{"id": "gterrono/houston:client/admin_login.coffee:1:raw_corpus", "type": "raw_corpus", "prompt": "", "response": "admin_user_exists = () -> Houston._admins.find().count() > 0\n\nTemplate._houston_login.helpers(\n logged_in: -> Meteor.user()\n admin_user_exists: -> admin_user_exists()\n)\n\nTemplate._houston_login.events(\n 'submit #houston-sign-in-form': (e) ->\n e.preventDefault()\n email = $('input[name=\"email\"]').val()\n password = $('input[name=\"password\"]').val()\n\n afterLogin = (error) ->\n # TODO error case that properly displays\n if error\n alert error\n else\n Houston._go 'home'\n\n if admin_user_exists()\n Meteor.loginWithPassword email, password, afterLogin\n else\n Accounts.createUser {\n email: $('input[name=\"email\"]').val()\n password: $('input[name=\"password\"]').val()\n }, (error) ->\n return afterLogin(error) if error\n # else - user got created\n Houston._call('make_admin', Meteor.userId(), afterLogin)\n\n 'click .houston-logout': (e) ->\n e.preventDefault()\n Meteor.logout()\n\n 'click .become-houston-admin': (e) ->\n e.preventDefault()\n Houston._call('make_admin', Meteor.userId())\n Houston._go 'home'\n)\n\nTemplate._houston_login.rendered = ->\n $(window).unbind('scroll')", "source_lang": "", "target_lang": "CoffeeScript", "repo": "gterrono/houston", "path": "client/admin_login.coffee", "license": "MIT", "commit": "93e4884c3adaadbcf3cabe34bf4fc196e59d3001", "stars": 802, "source_url": "https://github.com/gterrono/houston/blob/93e4884c3adaadbcf3cabe34bf4fc196e59d3001/client/admin_login.coffee", "line_start": 1, "line_end": 43}1170{"id": "gterrono/houston:client/admin_login.coffee:1:coffee_to_js", "type": "coffee_to_js", "prompt": "Convert this CoffeeScript to JavaScript.\n```coffeescript\nadmin_user_exists = () -> Houston._admins.find().count() > 0\n\nTemplate._houston_login.helpers(\n logged_in: -> Meteor.user()\n admin_user_exists: -> admin_user_exists()\n)\n\nTemplate._houston_login.events(\n 'submit #houston-sign-in-form': (e) ->\n e.preventDefault()\n email = $('input[name=\"email\"]').val()\n password = $('input[name=\"password\"]').val()\n\n afterLogin = (error) ->\n # TODO error case that properly displays\n if error\n alert error\n else\n Houston._go 'home'\n\n if admin_user_exists()\n Meteor.loginWithPassword email, password, afterLogin\n else\n Accounts.createUser {\n email: $('input[name=\"email\"]').val()\n password: $('input[name=\"password\"]').val()\n }, (error) ->\n return afterLogin(error) if error\n # else - user got created\n Houston._call('make_admin', Meteor.userId(), afterLogin)\n\n 'click .houston-logout': (e) ->\n e.preventDefault()\n Meteor.logout()\n\n 'click .become-houston-admin': (e) ->\n e.preventDefault()\n Houston._call('make_admin', Meteor.userId())\n Houston._go 'home'\n)\n\nTemplate._houston_login.rendered = ->\n $(window).unbind('scroll')\n```", "response": "var admin_user_exists;\n\nadmin_user_exists = function() {\n return Houston._admins.find().count() > 0;\n};\n\nTemplate._houston_login.helpers({\n logged_in: function() {\n return Meteor.user();\n },\n admin_user_exists: function() {\n return admin_user_exists();\n }\n});\n\nTemplate._houston_login.events({\n 'submit #houston-sign-in-form': function(e) {\n var afterLogin, email, password;\n e.preventDefault();\n email = $('input[name=\"email\"]').val();\n password = $('input[name=\"password\"]').val();\n afterLogin = function(error) {\n // TODO error case that properly displays\n if (error) {\n return alert(error);\n } else {\n return Houston._go('home');\n }\n };\n if (admin_user_exists()) {\n return Meteor.loginWithPassword(email, password, afterLogin);\n } else {\n return Accounts.createUser({\n email: $('input[name=\"email\"]').val(),\n password: $('input[name=\"password\"]').val()\n }, function(error) {\n if (error) {\n return afterLogin(error);\n }\n // else - user got created\n return Houston._call('make_admin', Meteor.userId(), afterLogin);\n });\n }\n },\n 'click .houston-logout': function(e) {\n e.preventDefault();\n return Meteor.logout();\n },\n 'click .become-houston-admin': function(e) {\n e.preventDefault();\n Houston._call('make_admin', Meteor.userId());\n return Houston._go('home');\n }\n});\n\nTemplate._houston_login.rendered = function() {\n return $(window).unbind('scroll');\n};", "source_lang": "CoffeeScript", "target_lang": "JavaScript", "repo": "gterrono/houston", "path": "client/admin_login.coffee", "license": "MIT", "commit": "93e4884c3adaadbcf3cabe34bf4fc196e59d3001", "stars": 802, "source_url": "https://github.com/gterrono/houston/blob/93e4884c3adaadbcf3cabe34bf4fc196e59d3001/client/admin_login.coffee", "line_start": 1, "line_end": 43}1171{"id": "gterrono/houston:client/admin_login.coffee:1:js_to_coffee", "type": "js_to_coffee", "prompt": "Convert this JavaScript to CoffeeScript.\n```javascript\nvar admin_user_exists;\n\nadmin_user_exists = function() {\n return Houston._admins.find().count() > 0;\n};\n\nTemplate._houston_login.helpers({\n logged_in: function() {\n return Meteor.user();\n },\n admin_user_exists: function() {\n return admin_user_exists();\n }\n});\n\nTemplate._houston_login.events({\n 'submit #houston-sign-in-form': function(e) {\n var afterLogin, email, password;\n e.preventDefault();\n email = $('input[name=\"email\"]').val();\n password = $('input[name=\"password\"]').val();\n afterLogin = function(error) {\n // TODO error case that properly displays\n if (error) {\n return alert(error);\n } else {\n return Houston._go('home');\n }\n };\n if (admin_user_exists()) {\n return Meteor.loginWithPassword(email, password, afterLogin);\n } else {\n return Accounts.createUser({\n email: $('input[name=\"email\"]').val(),\n password: $('input[name=\"password\"]').val()\n }, function(error) {\n if (error) {\n return afterLogin(error);\n }\n // else - user got created\n return Houston._call('make_admin', Meteor.userId(), afterLogin);\n });\n }\n },\n 'click .houston-logout': function(e) {\n e.preventDefault();\n return Meteor.logout();\n },\n 'click .become-houston-admin': function(e) {\n e.preventDefault();\n Houston._call('make_admin', Meteor.userId());\n return Houston._go('home');\n }\n});\n\nTemplate._houston_login.rendered = function() {\n return $(window).unbind('scroll');\n};\n```", "response": "admin_user_exists = () -> Houston._admins.find().count() > 0\n\nTemplate._houston_login.helpers(\n logged_in: -> Meteor.user()\n admin_user_exists: -> admin_user_exists()\n)\n\nTemplate._houston_login.events(\n 'submit #houston-sign-in-form': (e) ->\n e.preventDefault()\n email = $('input[name=\"email\"]').val()\n password = $('input[name=\"password\"]').val()\n\n afterLogin = (error) ->\n # TODO error case that properly displays\n if error\n alert error\n else\n Houston._go 'home'\n\n if admin_user_exists()\n Meteor.loginWithPassword email, password, afterLogin\n else\n Accounts.createUser {\n email: $('input[name=\"email\"]').val()\n password: $('input[name=\"password\"]').val()\n }, (error) ->\n return afterLogin(error) if error\n # else - user got created\n Houston._call('make_admin', Meteor.userId(), afterLogin)\n\n 'click .houston-logout': (e) ->\n e.preventDefault()\n Meteor.logout()\n\n 'click .become-houston-admin': (e) ->\n e.preventDefault()\n Houston._call('make_admin', Meteor.userId())\n Houston._go 'home'\n)\n\nTemplate._houston_login.rendered = ->\n $(window).unbind('scroll')", "source_lang": "JavaScript", "target_lang": "CoffeeScript", "repo": "gterrono/houston", "path": "client/admin_login.coffee", "license": "MIT", "commit": "93e4884c3adaadbcf3cabe34bf4fc196e59d3001", "stars": 802, "source_url": "https://github.com/gterrono/houston/blob/93e4884c3adaadbcf3cabe34bf4fc196e59d3001/client/admin_login.coffee", "line_start": 1, "line_end": 43}1172{"id": "gterrono/houston:client/admin_login.coffee:1:completion", "type": "completion", "prompt": "admin_user_exists = () -> Houston._admins.find().count() > 0\n\nTemplate._houston_login.helpers(\n logged_in: -> Meteor.user()\n admin_user_exists: -> admin_user_exists()\n)\n\nTemplate._houston_login.events(\n 'submit #houston-sign-in-form': (e) ->\n e.preventDefault()\n email = $('input[name=\"email\"]').val()\n password = $('input[name=\"password\"]').val()\n\n afterLogin = (error) ->\n # TODO error case that properly displays\n if error\n alert error\n else\n Houston._go 'home'\n\n if admin_user_exists()", "response": "Meteor.loginWithPassword email, password, afterLogin\n else\n Accounts.createUser {\n email: $('input[name=\"email\"]').val()\n password: $('input[name=\"password\"]').val()\n }, (error) ->\n return afterLogin(error) if error\n # else - user got created\n Houston._call('make_admin', Meteor.userId(), afterLogin)\n\n 'click .houston-logout': (e) ->\n e.preventDefault()\n Meteor.logout()\n\n 'click .become-houston-admin': (e) ->\n e.preventDefault()\n Houston._call('make_admin', Meteor.userId())\n Houston._go 'home'\n)\n\nTemplate._houston_login.rendered = ->\n $(window).unbind('scroll')", "source_lang": "CoffeeScript", "target_lang": "CoffeeScript", "repo": "gterrono/houston", "path": "client/admin_login.coffee", "license": "MIT", "commit": "93e4884c3adaadbcf3cabe34bf4fc196e59d3001", "stars": 802, "source_url": "https://github.com/gterrono/houston/blob/93e4884c3adaadbcf3cabe34bf4fc196e59d3001/client/admin_login.coffee", "line_start": 1, "line_end": 43}1173{"id": "gterrono/houston:client/admin_login.coffee:1:raw_corpus", "type": "raw_corpus", "prompt": "", "response": "admin_user_exists = () -> Houston._admins.find().count() > 0\n\nTemplate._houston_login.helpers(\n logged_in: -> Meteor.user()\n admin_user_exists: -> admin_user_exists()\n)\n\nTemplate._houston_login.events(\n 'submit #houston-sign-in-form': (e) ->\n e.preventDefault()\n email = $('input[name=\"email\"]').val()\n password = $('input[name=\"password\"]').val()\n\n afterLogin = (error) ->\n # TODO error case that properly displays\n if error\n alert error\n else\n Houston._go 'home'\n\n if admin_user_exists()\n Meteor.loginWithPassword email, password, afterLogin\n else\n Accounts.createUser {\n email: $('input[name=\"email\"]').val()\n password: $('input[name=\"password\"]').val()\n }, afterLogin\n Houston._call('make_admin', Meteor.userId())\n\n 'click .houston-logout': (e) ->\n e.preventDefault()\n Meteor.logout()\n\n 'click .become-houston-admin': (e) ->\n Houston._call('make_admin', Meteor.userId())\n e.preventDefault()\n)\n\nTemplate._houston_login.rendered = ->\n $(window).unbind('scroll')", "source_lang": "", "target_lang": "CoffeeScript", "repo": "gterrono/houston", "path": "client/admin_login.coffee", "license": "MIT", "commit": "4b18561921e57c866348c671e76597b67f4ea52e", "stars": 802, "source_url": "https://github.com/gterrono/houston/blob/4b18561921e57c866348c671e76597b67f4ea52e/client/admin_login.coffee", "line_start": 1, "line_end": 40}1174{"id": "gterrono/houston:client/admin_login.coffee:1:coffee_to_js", "type": "coffee_to_js", "prompt": "Convert this CoffeeScript to JavaScript.\n```coffeescript\nadmin_user_exists = () -> Houston._admins.find().count() > 0\n\nTemplate._houston_login.helpers(\n logged_in: -> Meteor.user()\n admin_user_exists: -> admin_user_exists()\n)\n\nTemplate._houston_login.events(\n 'submit #houston-sign-in-form': (e) ->\n e.preventDefault()\n email = $('input[name=\"email\"]').val()\n password = $('input[name=\"password\"]').val()\n\n afterLogin = (error) ->\n # TODO error case that properly displays\n if error\n alert error\n else\n Houston._go 'home'\n\n if admin_user_exists()\n Meteor.loginWithPassword email, password, afterLogin\n else\n Accounts.createUser {\n email: $('input[name=\"email\"]').val()\n password: $('input[name=\"password\"]').val()\n }, afterLogin\n Houston._call('make_admin', Meteor.userId())\n\n 'click .houston-logout': (e) ->\n e.preventDefault()\n Meteor.logout()\n\n 'click .become-houston-admin': (e) ->\n Houston._call('make_admin', Meteor.userId())\n e.preventDefault()\n)\n\nTemplate._houston_login.rendered = ->\n $(window).unbind('scroll')\n```", "response": "var admin_user_exists;\n\nadmin_user_exists = function() {\n return Houston._admins.find().count() > 0;\n};\n\nTemplate._houston_login.helpers({\n logged_in: function() {\n return Meteor.user();\n },\n admin_user_exists: function() {\n return admin_user_exists();\n }\n});\n\nTemplate._houston_login.events({\n 'submit #houston-sign-in-form': function(e) {\n var afterLogin, email, password;\n e.preventDefault();\n email = $('input[name=\"email\"]').val();\n password = $('input[name=\"password\"]').val();\n afterLogin = function(error) {\n // TODO error case that properly displays\n if (error) {\n return alert(error);\n } else {\n return Houston._go('home');\n }\n };\n if (admin_user_exists()) {\n return Meteor.loginWithPassword(email, password, afterLogin);\n } else {\n Accounts.createUser({\n email: $('input[name=\"email\"]').val(),\n password: $('input[name=\"password\"]').val()\n }, afterLogin);\n return Houston._call('make_admin', Meteor.userId());\n }\n },\n 'click .houston-logout': function(e) {\n e.preventDefault();\n return Meteor.logout();\n },\n 'click .become-houston-admin': function(e) {\n Houston._call('make_admin', Meteor.userId());\n return e.preventDefault();\n }\n});\n\nTemplate._houston_login.rendered = function() {\n return $(window).unbind('scroll');\n};", "source_lang": "CoffeeScript", "target_lang": "JavaScript", "repo": "gterrono/houston", "path": "client/admin_login.coffee", "license": "MIT", "commit": "4b18561921e57c866348c671e76597b67f4ea52e", "stars": 802, "source_url": "https://github.com/gterrono/houston/blob/4b18561921e57c866348c671e76597b67f4ea52e/client/admin_login.coffee", "line_start": 1, "line_end": 40}1175{"id": "gterrono/houston:client/admin_login.coffee:1:js_to_coffee", "type": "js_to_coffee", "prompt": "Convert this JavaScript to CoffeeScript.\n```javascript\nvar admin_user_exists;\n\nadmin_user_exists = function() {\n return Houston._admins.find().count() > 0;\n};\n\nTemplate._houston_login.helpers({\n logged_in: function() {\n return Meteor.user();\n },\n admin_user_exists: function() {\n return admin_user_exists();\n }\n});\n\nTemplate._houston_login.events({\n 'submit #houston-sign-in-form': function(e) {\n var afterLogin, email, password;\n e.preventDefault();\n email = $('input[name=\"email\"]').val();\n password = $('input[name=\"password\"]').val();\n afterLogin = function(error) {\n // TODO error case that properly displays\n if (error) {\n return alert(error);\n } else {\n return Houston._go('home');\n }\n };\n if (admin_user_exists()) {\n return Meteor.loginWithPassword(email, password, afterLogin);\n } else {\n Accounts.createUser({\n email: $('input[name=\"email\"]').val(),\n password: $('input[name=\"password\"]').val()\n }, afterLogin);\n return Houston._call('make_admin', Meteor.userId());\n }\n },\n 'click .houston-logout': function(e) {\n e.preventDefault();\n return Meteor.logout();\n },\n 'click .become-houston-admin': function(e) {\n Houston._call('make_admin', Meteor.userId());\n return e.preventDefault();\n }\n});\n\nTemplate._houston_login.rendered = function() {\n return $(window).unbind('scroll');\n};\n```", "response": "admin_user_exists = () -> Houston._admins.find().count() > 0\n\nTemplate._houston_login.helpers(\n logged_in: -> Meteor.user()\n admin_user_exists: -> admin_user_exists()\n)\n\nTemplate._houston_login.events(\n 'submit #houston-sign-in-form': (e) ->\n e.preventDefault()\n email = $('input[name=\"email\"]').val()\n password = $('input[name=\"password\"]').val()\n\n afterLogin = (error) ->\n # TODO error case that properly displays\n if error\n alert error\n else\n Houston._go 'home'\n\n if admin_user_exists()\n Meteor.loginWithPassword email, password, afterLogin\n else\n Accounts.createUser {\n email: $('input[name=\"email\"]').val()\n password: $('input[name=\"password\"]').val()\n }, afterLogin\n Houston._call('make_admin', Meteor.userId())\n\n 'click .houston-logout': (e) ->\n e.preventDefault()\n Meteor.logout()\n\n 'click .become-houston-admin': (e) ->\n Houston._call('make_admin', Meteor.userId())\n e.preventDefault()\n)\n\nTemplate._houston_login.rendered = ->\n $(window).unbind('scroll')", "source_lang": "JavaScript", "target_lang": "CoffeeScript", "repo": "gterrono/houston", "path": "client/admin_login.coffee", "license": "MIT", "commit": "4b18561921e57c866348c671e76597b67f4ea52e", "stars": 802, "source_url": "https://github.com/gterrono/houston/blob/4b18561921e57c866348c671e76597b67f4ea52e/client/admin_login.coffee", "line_start": 1, "line_end": 40}1176{"id": "gterrono/houston:client/admin_login.coffee:1:completion", "type": "completion", "prompt": "admin_user_exists = () -> Houston._admins.find().count() > 0\n\nTemplate._houston_login.helpers(\n logged_in: -> Meteor.user()\n admin_user_exists: -> admin_user_exists()\n)\n\nTemplate._houston_login.events(\n 'submit #houston-sign-in-form': (e) ->\n e.preventDefault()\n email = $('input[name=\"email\"]').val()\n password = $('input[name=\"password\"]').val()\n\n afterLogin = (error) ->\n # TODO error case that properly displays\n if error\n alert error\n else\n Houston._go 'home'", "response": "if admin_user_exists()\n Meteor.loginWithPassword email, password, afterLogin\n else\n Accounts.createUser {\n email: $('input[name=\"email\"]').val()\n password: $('input[name=\"password\"]').val()\n }, afterLogin\n Houston._call('make_admin', Meteor.userId())\n\n 'click .houston-logout': (e) ->\n e.preventDefault()\n Meteor.logout()\n\n 'click .become-houston-admin': (e) ->\n Houston._call('make_admin', Meteor.userId())\n e.preventDefault()\n)\n\nTemplate._houston_login.rendered = ->\n $(window).unbind('scroll')", "source_lang": "CoffeeScript", "target_lang": "CoffeeScript", "repo": "gterrono/houston", "path": "client/admin_login.coffee", "license": "MIT", "commit": "4b18561921e57c866348c671e76597b67f4ea52e", "stars": 802, "source_url": "https://github.com/gterrono/houston/blob/4b18561921e57c866348c671e76597b67f4ea52e/client/admin_login.coffee", "line_start": 1, "line_end": 40}1177{"id": "gterrono/houston:client/admin_login.coffee:1:raw_corpus", "type": "raw_corpus", "prompt": "", "response": "admin_user_exists = () -> Houston._admins.find().count() > 0\n\nTemplate._houston_login.helpers(\n logged_in: -> Meteor.user()\n admin_user_exists: -> admin_user_exists()\n)\n\nTemplate._houston_login.events(\n 'submit #houston-sign-in-form': (e) ->\n e.preventDefault()\n email = $('input[name=\"email\"]').val()\n password = $('input[name=\"password\"]').val()\n\n afterLogin = (error) ->\n # TODO error case that properly displays\n if error\n alert error\n else\n Houston._go 'home'\n\n if admin_user_exists()\n Meteor.loginWithPassword email, password, afterLogin\n else\n Accounts.createUser {\n email: $('input[name=\"email\"]').val()\n password: $('input[name=\"password\"]').val()\n }, (error) ->\n return afterLogin(error) if error\n # else - make me an admin, then send me on my way.\n Houston._call 'make_admin', Meteor.userId(), afterLogin\n\n 'click .houston-logout': (e) ->\n e.preventDefault()\n Meteor.logout()\n\n 'click .become-houston-admin': (e) ->\n Houston._call('make_admin', Meteor.userId())\n e.preventDefault()\n)\n\nTemplate._houston_login.rendered = ->\n $(window).unbind('scroll')", "source_lang": "", "target_lang": "CoffeeScript", "repo": "gterrono/houston", "path": "client/admin_login.coffee", "license": "MIT", "commit": "920f222e080c04527c9e08c303c24c967f2a051c", "stars": 802, "source_url": "https://github.com/gterrono/houston/blob/920f222e080c04527c9e08c303c24c967f2a051c/client/admin_login.coffee", "line_start": 1, "line_end": 42}1178{"id": "gterrono/houston:client/admin_login.coffee:1:coffee_to_js", "type": "coffee_to_js", "prompt": "Convert this CoffeeScript to JavaScript.\n```coffeescript\nadmin_user_exists = () -> Houston._admins.find().count() > 0\n\nTemplate._houston_login.helpers(\n logged_in: -> Meteor.user()\n admin_user_exists: -> admin_user_exists()\n)\n\nTemplate._houston_login.events(\n 'submit #houston-sign-in-form': (e) ->\n e.preventDefault()\n email = $('input[name=\"email\"]').val()\n password = $('input[name=\"password\"]').val()\n\n afterLogin = (error) ->\n # TODO error case that properly displays\n if error\n alert error\n else\n Houston._go 'home'\n\n if admin_user_exists()\n Meteor.loginWithPassword email, password, afterLogin\n else\n Accounts.createUser {\n email: $('input[name=\"email\"]').val()\n password: $('input[name=\"password\"]').val()\n }, (error) ->\n return afterLogin(error) if error\n # else - make me an admin, then send me on my way.\n Houston._call 'make_admin', Meteor.userId(), afterLogin\n\n 'click .houston-logout': (e) ->\n e.preventDefault()\n Meteor.logout()\n\n 'click .become-houston-admin': (e) ->\n Houston._call('make_admin', Meteor.userId())\n e.preventDefault()\n)\n\nTemplate._houston_login.rendered = ->\n $(window).unbind('scroll')\n```", "response": "var admin_user_exists;\n\nadmin_user_exists = function() {\n return Houston._admins.find().count() > 0;\n};\n\nTemplate._houston_login.helpers({\n logged_in: function() {\n return Meteor.user();\n },\n admin_user_exists: function() {\n return admin_user_exists();\n }\n});\n\nTemplate._houston_login.events({\n 'submit #houston-sign-in-form': function(e) {\n var afterLogin, email, password;\n e.preventDefault();\n email = $('input[name=\"email\"]').val();\n password = $('input[name=\"password\"]').val();\n afterLogin = function(error) {\n // TODO error case that properly displays\n if (error) {\n return alert(error);\n } else {\n return Houston._go('home');\n }\n };\n if (admin_user_exists()) {\n return Meteor.loginWithPassword(email, password, afterLogin);\n } else {\n return Accounts.createUser({\n email: $('input[name=\"email\"]').val(),\n password: $('input[name=\"password\"]').val()\n }, function(error) {\n if (error) {\n return afterLogin(error);\n }\n // else - make me an admin, then send me on my way.\n return Houston._call('make_admin', Meteor.userId(), afterLogin);\n });\n }\n },\n 'click .houston-logout': function(e) {\n e.preventDefault();\n return Meteor.logout();\n },\n 'click .become-houston-admin': function(e) {\n Houston._call('make_admin', Meteor.userId());\n return e.preventDefault();\n }\n});\n\nTemplate._houston_login.rendered = function() {\n return $(window).unbind('scroll');\n};", "source_lang": "CoffeeScript", "target_lang": "JavaScript", "repo": "gterrono/houston", "path": "client/admin_login.coffee", "license": "MIT", "commit": "920f222e080c04527c9e08c303c24c967f2a051c", "stars": 802, "source_url": "https://github.com/gterrono/houston/blob/920f222e080c04527c9e08c303c24c967f2a051c/client/admin_login.coffee", "line_start": 1, "line_end": 42}1179{"id": "gterrono/houston:client/admin_login.coffee:1:js_to_coffee", "type": "js_to_coffee", "prompt": "Convert this JavaScript to CoffeeScript.\n```javascript\nvar admin_user_exists;\n\nadmin_user_exists = function() {\n return Houston._admins.find().count() > 0;\n};\n\nTemplate._houston_login.helpers({\n logged_in: function() {\n return Meteor.user();\n },\n admin_user_exists: function() {\n return admin_user_exists();\n }\n});\n\nTemplate._houston_login.events({\n 'submit #houston-sign-in-form': function(e) {\n var afterLogin, email, password;\n e.preventDefault();\n email = $('input[name=\"email\"]').val();\n password = $('input[name=\"password\"]').val();\n afterLogin = function(error) {\n // TODO error case that properly displays\n if (error) {\n return alert(error);\n } else {\n return Houston._go('home');\n }\n };\n if (admin_user_exists()) {\n return Meteor.loginWithPassword(email, password, afterLogin);\n } else {\n return Accounts.createUser({\n email: $('input[name=\"email\"]').val(),\n password: $('input[name=\"password\"]').val()\n }, function(error) {\n if (error) {\n return afterLogin(error);\n }\n // else - make me an admin, then send me on my way.\n return Houston._call('make_admin', Meteor.userId(), afterLogin);\n });\n }\n },\n 'click .houston-logout': function(e) {\n e.preventDefault();\n return Meteor.logout();\n },\n 'click .become-houston-admin': function(e) {\n Houston._call('make_admin', Meteor.userId());\n return e.preventDefault();\n }\n});\n\nTemplate._houston_login.rendered = function() {\n return $(window).unbind('scroll');\n};\n```", "response": "admin_user_exists = () -> Houston._admins.find().count() > 0\n\nTemplate._houston_login.helpers(\n logged_in: -> Meteor.user()\n admin_user_exists: -> admin_user_exists()\n)\n\nTemplate._houston_login.events(\n 'submit #houston-sign-in-form': (e) ->\n e.preventDefault()\n email = $('input[name=\"email\"]').val()\n password = $('input[name=\"password\"]').val()\n\n afterLogin = (error) ->\n # TODO error case that properly displays\n if error\n alert error\n else\n Houston._go 'home'\n\n if admin_user_exists()\n Meteor.loginWithPassword email, password, afterLogin\n else\n Accounts.createUser {\n email: $('input[name=\"email\"]').val()\n password: $('input[name=\"password\"]').val()\n }, (error) ->\n return afterLogin(error) if error\n # else - make me an admin, then send me on my way.\n Houston._call 'make_admin', Meteor.userId(), afterLogin\n\n 'click .houston-logout': (e) ->\n e.preventDefault()\n Meteor.logout()\n\n 'click .become-houston-admin': (e) ->\n Houston._call('make_admin', Meteor.userId())\n e.preventDefault()\n)\n\nTemplate._houston_login.rendered = ->\n $(window).unbind('scroll')", "source_lang": "JavaScript", "target_lang": "CoffeeScript", "repo": "gterrono/houston", "path": "client/admin_login.coffee", "license": "MIT", "commit": "920f222e080c04527c9e08c303c24c967f2a051c", "stars": 802, "source_url": "https://github.com/gterrono/houston/blob/920f222e080c04527c9e08c303c24c967f2a051c/client/admin_login.coffee", "line_start": 1, "line_end": 42}1180{"id": "gterrono/houston:client/admin_login.coffee:1:completion", "type": "completion", "prompt": "admin_user_exists = () -> Houston._admins.find().count() > 0\n\nTemplate._houston_login.helpers(\n logged_in: -> Meteor.user()\n admin_user_exists: -> admin_user_exists()\n)\n\nTemplate._houston_login.events(\n 'submit #houston-sign-in-form': (e) ->\n e.preventDefault()\n email = $('input[name=\"email\"]').val()\n password = $('input[name=\"password\"]').val()\n\n afterLogin = (error) ->\n # TODO error case that properly displays\n if error\n alert error\n else\n Houston._go 'home'\n\n if admin_user_exists()", "response": "Meteor.loginWithPassword email, password, afterLogin\n else\n Accounts.createUser {\n email: $('input[name=\"email\"]').val()\n password: $('input[name=\"password\"]').val()\n }, (error) ->\n return afterLogin(error) if error\n # else - make me an admin, then send me on my way.\n Houston._call 'make_admin', Meteor.userId(), afterLogin\n\n 'click .houston-logout': (e) ->\n e.preventDefault()\n Meteor.logout()\n\n 'click .become-houston-admin': (e) ->\n Houston._call('make_admin', Meteor.userId())\n e.preventDefault()\n)\n\nTemplate._houston_login.rendered = ->\n $(window).unbind('scroll')", "source_lang": "CoffeeScript", "target_lang": "CoffeeScript", "repo": "gterrono/houston", "path": "client/admin_login.coffee", "license": "MIT", "commit": "920f222e080c04527c9e08c303c24c967f2a051c", "stars": 802, "source_url": "https://github.com/gterrono/houston/blob/920f222e080c04527c9e08c303c24c967f2a051c/client/admin_login.coffee", "line_start": 1, "line_end": 42}1181{"id": "gterrono/houston:client/admin_login.coffee:1:raw_corpus", "type": "raw_corpus", "prompt": "", "response": "admin_user_exists = () -> Houston._admins.find().count() > 0\n\nTemplate._houston_login.helpers(\n logged_in: -> Meteor.user()\n admin_user_exists: -> admin_user_exists()\n)\n\nTemplate._houston_login.events(\n 'submit #houston-sign-in-form': (e) ->\n e.preventDefault()\n email = $('input[name=\"email\"]').val()\n password = $('input[name=\"password\"]').val()\n\n afterLogin = (error) ->\n # TODO error case that properly displays\n if error\n alert error\n else\n Houston._go 'home'\n\n if admin_user_exists()\n Meteor.loginWithPassword email, password, afterLogin\n else\n Accounts.createUser {\n email: $('input[name=\"email\"]').val()\n password: $('input[name=\"password\"]').val()\n }, afterLogin\n Houston._call('make_admin', Meteor.userId())\n\n 'click .houston-logout': (e) ->\n e.preventDefault()\n Meteor.logout()\n\n 'click .become-houston-admin': (e) ->\n e.preventDefault()\n Houston._call('make_admin', Meteor.userId())\n Houston._go 'home'\n)\n\nTemplate._houston_login.rendered = ->\n $(window).unbind('scroll')", "source_lang": "", "target_lang": "CoffeeScript", "repo": "gterrono/houston", "path": "client/admin_login.coffee", "license": "MIT", "commit": "a8407463c051c75abbcf8e7d884170bc012648e8", "stars": 802, "source_url": "https://github.com/gterrono/houston/blob/a8407463c051c75abbcf8e7d884170bc012648e8/client/admin_login.coffee", "line_start": 1, "line_end": 41}1182{"id": "gterrono/houston:client/admin_login.coffee:1:coffee_to_js", "type": "coffee_to_js", "prompt": "Convert this CoffeeScript to JavaScript.\n```coffeescript\nadmin_user_exists = () -> Houston._admins.find().count() > 0\n\nTemplate._houston_login.helpers(\n logged_in: -> Meteor.user()\n admin_user_exists: -> admin_user_exists()\n)\n\nTemplate._houston_login.events(\n 'submit #houston-sign-in-form': (e) ->\n e.preventDefault()\n email = $('input[name=\"email\"]').val()\n password = $('input[name=\"password\"]').val()\n\n afterLogin = (error) ->\n # TODO error case that properly displays\n if error\n alert error\n else\n Houston._go 'home'\n\n if admin_user_exists()\n Meteor.loginWithPassword email, password, afterLogin\n else\n Accounts.createUser {\n email: $('input[name=\"email\"]').val()\n password: $('input[name=\"password\"]').val()\n }, afterLogin\n Houston._call('make_admin', Meteor.userId())\n\n 'click .houston-logout': (e) ->\n e.preventDefault()\n Meteor.logout()\n\n 'click .become-houston-admin': (e) ->\n e.preventDefault()\n Houston._call('make_admin', Meteor.userId())\n Houston._go 'home'\n)\n\nTemplate._houston_login.rendered = ->\n $(window).unbind('scroll')\n```", "response": "var admin_user_exists;\n\nadmin_user_exists = function() {\n return Houston._admins.find().count() > 0;\n};\n\nTemplate._houston_login.helpers({\n logged_in: function() {\n return Meteor.user();\n },\n admin_user_exists: function() {\n return admin_user_exists();\n }\n});\n\nTemplate._houston_login.events({\n 'submit #houston-sign-in-form': function(e) {\n var afterLogin, email, password;\n e.preventDefault();\n email = $('input[name=\"email\"]').val();\n password = $('input[name=\"password\"]').val();\n afterLogin = function(error) {\n // TODO error case that properly displays\n if (error) {\n return alert(error);\n } else {\n return Houston._go('home');\n }\n };\n if (admin_user_exists()) {\n return Meteor.loginWithPassword(email, password, afterLogin);\n } else {\n Accounts.createUser({\n email: $('input[name=\"email\"]').val(),\n password: $('input[name=\"password\"]').val()\n }, afterLogin);\n return Houston._call('make_admin', Meteor.userId());\n }\n },\n 'click .houston-logout': function(e) {\n e.preventDefault();\n return Meteor.logout();\n },\n 'click .become-houston-admin': function(e) {\n e.preventDefault();\n Houston._call('make_admin', Meteor.userId());\n return Houston._go('home');\n }\n});\n\nTemplate._houston_login.rendered = function() {\n return $(window).unbind('scroll');\n};", "source_lang": "CoffeeScript", "target_lang": "JavaScript", "repo": "gterrono/houston", "path": "client/admin_login.coffee", "license": "MIT", "commit": "a8407463c051c75abbcf8e7d884170bc012648e8", "stars": 802, "source_url": "https://github.com/gterrono/houston/blob/a8407463c051c75abbcf8e7d884170bc012648e8/client/admin_login.coffee", "line_start": 1, "line_end": 41}1183{"id": "gterrono/houston:client/admin_login.coffee:1:js_to_coffee", "type": "js_to_coffee", "prompt": "Convert this JavaScript to CoffeeScript.\n```javascript\nvar admin_user_exists;\n\nadmin_user_exists = function() {\n return Houston._admins.find().count() > 0;\n};\n\nTemplate._houston_login.helpers({\n logged_in: function() {\n return Meteor.user();\n },\n admin_user_exists: function() {\n return admin_user_exists();\n }\n});\n\nTemplate._houston_login.events({\n 'submit #houston-sign-in-form': function(e) {\n var afterLogin, email, password;\n e.preventDefault();\n email = $('input[name=\"email\"]').val();\n password = $('input[name=\"password\"]').val();\n afterLogin = function(error) {\n // TODO error case that properly displays\n if (error) {\n return alert(error);\n } else {\n return Houston._go('home');\n }\n };\n if (admin_user_exists()) {\n return Meteor.loginWithPassword(email, password, afterLogin);\n } else {\n Accounts.createUser({\n email: $('input[name=\"email\"]').val(),\n password: $('input[name=\"password\"]').val()\n }, afterLogin);\n return Houston._call('make_admin', Meteor.userId());\n }\n },\n 'click .houston-logout': function(e) {\n e.preventDefault();\n return Meteor.logout();\n },\n 'click .become-houston-admin': function(e) {\n e.preventDefault();\n Houston._call('make_admin', Meteor.userId());\n return Houston._go('home');\n }\n});\n\nTemplate._houston_login.rendered = function() {\n return $(window).unbind('scroll');\n};\n```", "response": "admin_user_exists = () -> Houston._admins.find().count() > 0\n\nTemplate._houston_login.helpers(\n logged_in: -> Meteor.user()\n admin_user_exists: -> admin_user_exists()\n)\n\nTemplate._houston_login.events(\n 'submit #houston-sign-in-form': (e) ->\n e.preventDefault()\n email = $('input[name=\"email\"]').val()\n password = $('input[name=\"password\"]').val()\n\n afterLogin = (error) ->\n # TODO error case that properly displays\n if error\n alert error\n else\n Houston._go 'home'\n\n if admin_user_exists()\n Meteor.loginWithPassword email, password, afterLogin\n else\n Accounts.createUser {\n email: $('input[name=\"email\"]').val()\n password: $('input[name=\"password\"]').val()\n }, afterLogin\n Houston._call('make_admin', Meteor.userId())\n\n 'click .houston-logout': (e) ->\n e.preventDefault()\n Meteor.logout()\n\n 'click .become-houston-admin': (e) ->\n e.preventDefault()\n Houston._call('make_admin', Meteor.userId())\n Houston._go 'home'\n)\n\nTemplate._houston_login.rendered = ->\n $(window).unbind('scroll')", "source_lang": "JavaScript", "target_lang": "CoffeeScript", "repo": "gterrono/houston", "path": "client/admin_login.coffee", "license": "MIT", "commit": "a8407463c051c75abbcf8e7d884170bc012648e8", "stars": 802, "source_url": "https://github.com/gterrono/houston/blob/a8407463c051c75abbcf8e7d884170bc012648e8/client/admin_login.coffee", "line_start": 1, "line_end": 41}1184{"id": "gterrono/houston:client/admin_login.coffee:1:completion", "type": "completion", "prompt": "admin_user_exists = () -> Houston._admins.find().count() > 0\n\nTemplate._houston_login.helpers(\n logged_in: -> Meteor.user()\n admin_user_exists: -> admin_user_exists()\n)\n\nTemplate._houston_login.events(\n 'submit #houston-sign-in-form': (e) ->\n e.preventDefault()\n email = $('input[name=\"email\"]').val()\n password = $('input[name=\"password\"]').val()\n\n afterLogin = (error) ->\n # TODO error case that properly displays\n if error\n alert error\n else\n Houston._go 'home'", "response": "if admin_user_exists()\n Meteor.loginWithPassword email, password, afterLogin\n else\n Accounts.createUser {\n email: $('input[name=\"email\"]').val()\n password: $('input[name=\"password\"]').val()\n }, afterLogin\n Houston._call('make_admin', Meteor.userId())\n\n 'click .houston-logout': (e) ->\n e.preventDefault()\n Meteor.logout()\n\n 'click .become-houston-admin': (e) ->\n e.preventDefault()\n Houston._call('make_admin', Meteor.userId())\n Houston._go 'home'\n)\n\nTemplate._houston_login.rendered = ->\n $(window).unbind('scroll')", "source_lang": "CoffeeScript", "target_lang": "CoffeeScript", "repo": "gterrono/houston", "path": "client/admin_login.coffee", "license": "MIT", "commit": "a8407463c051c75abbcf8e7d884170bc012648e8", "stars": 802, "source_url": "https://github.com/gterrono/houston/blob/a8407463c051c75abbcf8e7d884170bc012648e8/client/admin_login.coffee", "line_start": 1, "line_end": 41}1185{"id": "gterrono/houston:client/admin_login.coffee:1:raw_corpus", "type": "raw_corpus", "prompt": "", "response": "Template._houston_login.helpers(\n logged_in: -> Meteor.user()\n admin_user_exists: -> Meteor.users.findOne 'profile.admin': true\n)\n\nTemplate._houston_login.events(\n 'submit #houston-sign-in-form': (e) ->\n e.preventDefault()\n email = $('input[name=\"email\"]').val()\n password = $('input[name=\"password\"]').val()\n\n afterLogin = (error) ->\n # TODO error case that properly displays\n if error\n alert error\n else\n Houston._go 'home'\n\n if Meteor.users.findOne('profile.admin': true)\n Meteor.loginWithPassword email, password, afterLogin\n else\n Accounts.createUser {\n email: $('input[name=\"email\"]').val()\n password: $('input[name=\"password\"]').val()\n profile:\n admin: true\n }, afterLogin\n\n 'click .houston-logout': (e) ->\n e.preventDefault()\n Meteor.logout()\n\n 'click .become-houston-admin': (e) ->\n Houston._call('make_admin', Meteor.userId())\n e.preventDefault()\n)\n\nTemplate._houston_login.rendered = ->\n $(window).unbind('scroll')", "source_lang": "", "target_lang": "CoffeeScript", "repo": "gterrono/houston", "path": "client/admin_login.coffee", "license": "MIT", "commit": "c64d37df458f49f3aec190bdf793fa665473895a", "stars": 802, "source_url": "https://github.com/gterrono/houston/blob/c64d37df458f49f3aec190bdf793fa665473895a/client/admin_login.coffee", "line_start": 1, "line_end": 39}1186{"id": "gterrono/houston:client/admin_login.coffee:1:coffee_to_js", "type": "coffee_to_js", "prompt": "Convert this CoffeeScript to JavaScript.\n```coffeescript\nTemplate._houston_login.helpers(\n logged_in: -> Meteor.user()\n admin_user_exists: -> Meteor.users.findOne 'profile.admin': true\n)\n\nTemplate._houston_login.events(\n 'submit #houston-sign-in-form': (e) ->\n e.preventDefault()\n email = $('input[name=\"email\"]').val()\n password = $('input[name=\"password\"]').val()\n\n afterLogin = (error) ->\n # TODO error case that properly displays\n if error\n alert error\n else\n Houston._go 'home'\n\n if Meteor.users.findOne('profile.admin': true)\n Meteor.loginWithPassword email, password, afterLogin\n else\n Accounts.createUser {\n email: $('input[name=\"email\"]').val()\n password: $('input[name=\"password\"]').val()\n profile:\n admin: true\n }, afterLogin\n\n 'click .houston-logout': (e) ->\n e.preventDefault()\n Meteor.logout()\n\n 'click .become-houston-admin': (e) ->\n Houston._call('make_admin', Meteor.userId())\n e.preventDefault()\n)\n\nTemplate._houston_login.rendered = ->\n $(window).unbind('scroll')\n```", "response": "Template._houston_login.helpers({\n logged_in: function() {\n return Meteor.user();\n },\n admin_user_exists: function() {\n return Meteor.users.findOne({\n 'profile.admin': true\n });\n }\n});\n\nTemplate._houston_login.events({\n 'submit #houston-sign-in-form': function(e) {\n var afterLogin, email, password;\n e.preventDefault();\n email = $('input[name=\"email\"]').val();\n password = $('input[name=\"password\"]').val();\n afterLogin = function(error) {\n // TODO error case that properly displays\n if (error) {\n return alert(error);\n } else {\n return Houston._go('home');\n }\n };\n if (Meteor.users.findOne({\n 'profile.admin': true\n })) {\n return Meteor.loginWithPassword(email, password, afterLogin);\n } else {\n return Accounts.createUser({\n email: $('input[name=\"email\"]').val(),\n password: $('input[name=\"password\"]').val(),\n profile: {\n admin: true\n }\n }, afterLogin);\n }\n },\n 'click .houston-logout': function(e) {\n e.preventDefault();\n return Meteor.logout();\n },\n 'click .become-houston-admin': function(e) {\n Houston._call('make_admin', Meteor.userId());\n return e.preventDefault();\n }\n});\n\nTemplate._houston_login.rendered = function() {\n return $(window).unbind('scroll');\n};", "source_lang": "CoffeeScript", "target_lang": "JavaScript", "repo": "gterrono/houston", "path": "client/admin_login.coffee", "license": "MIT", "commit": "c64d37df458f49f3aec190bdf793fa665473895a", "stars": 802, "source_url": "https://github.com/gterrono/houston/blob/c64d37df458f49f3aec190bdf793fa665473895a/client/admin_login.coffee", "line_start": 1, "line_end": 39}1187{"id": "gterrono/houston:client/admin_login.coffee:1:js_to_coffee", "type": "js_to_coffee", "prompt": "Convert this JavaScript to CoffeeScript.\n```javascript\nTemplate._houston_login.helpers({\n logged_in: function() {\n return Meteor.user();\n },\n admin_user_exists: function() {\n return Meteor.users.findOne({\n 'profile.admin': true\n });\n }\n});\n\nTemplate._houston_login.events({\n 'submit #houston-sign-in-form': function(e) {\n var afterLogin, email, password;\n e.preventDefault();\n email = $('input[name=\"email\"]').val();\n password = $('input[name=\"password\"]').val();\n afterLogin = function(error) {\n // TODO error case that properly displays\n if (error) {\n return alert(error);\n } else {\n return Houston._go('home');\n }\n };\n if (Meteor.users.findOne({\n 'profile.admin': true\n })) {\n return Meteor.loginWithPassword(email, password, afterLogin);\n } else {\n return Accounts.createUser({\n email: $('input[name=\"email\"]').val(),\n password: $('input[name=\"password\"]').val(),\n profile: {\n admin: true\n }\n }, afterLogin);\n }\n },\n 'click .houston-logout': function(e) {\n e.preventDefault();\n return Meteor.logout();\n },\n 'click .become-houston-admin': function(e) {\n Houston._call('make_admin', Meteor.userId());\n return e.preventDefault();\n }\n});\n\nTemplate._houston_login.rendered = function() {\n return $(window).unbind('scroll');\n};\n```", "response": "Template._houston_login.helpers(\n logged_in: -> Meteor.user()\n admin_user_exists: -> Meteor.users.findOne 'profile.admin': true\n)\n\nTemplate._houston_login.events(\n 'submit #houston-sign-in-form': (e) ->\n e.preventDefault()\n email = $('input[name=\"email\"]').val()\n password = $('input[name=\"password\"]').val()\n\n afterLogin = (error) ->\n # TODO error case that properly displays\n if error\n alert error\n else\n Houston._go 'home'\n\n if Meteor.users.findOne('profile.admin': true)\n Meteor.loginWithPassword email, password, afterLogin\n else\n Accounts.createUser {\n email: $('input[name=\"email\"]').val()\n password: $('input[name=\"password\"]').val()\n profile:\n admin: true\n }, afterLogin\n\n 'click .houston-logout': (e) ->\n e.preventDefault()\n Meteor.logout()\n\n 'click .become-houston-admin': (e) ->\n Houston._call('make_admin', Meteor.userId())\n e.preventDefault()\n)\n\nTemplate._houston_login.rendered = ->\n $(window).unbind('scroll')", "source_lang": "JavaScript", "target_lang": "CoffeeScript", "repo": "gterrono/houston", "path": "client/admin_login.coffee", "license": "MIT", "commit": "c64d37df458f49f3aec190bdf793fa665473895a", "stars": 802, "source_url": "https://github.com/gterrono/houston/blob/c64d37df458f49f3aec190bdf793fa665473895a/client/admin_login.coffee", "line_start": 1, "line_end": 39}1188{"id": "gterrono/houston:client/admin_login.coffee:1:completion", "type": "completion", "prompt": "Template._houston_login.helpers(\n logged_in: -> Meteor.user()\n admin_user_exists: -> Meteor.users.findOne 'profile.admin': true\n)\n\nTemplate._houston_login.events(\n 'submit #houston-sign-in-form': (e) ->\n e.preventDefault()\n email = $('input[name=\"email\"]').val()\n password = $('input[name=\"password\"]').val()\n\n afterLogin = (error) ->\n # TODO error case that properly displays\n if error\n alert error\n else\n Houston._go 'home'\n\n if Meteor.users.findOne('profile.admin': true)", "response": "Meteor.loginWithPassword email, password, afterLogin\n else\n Accounts.createUser {\n email: $('input[name=\"email\"]').val()\n password: $('input[name=\"password\"]').val()\n profile:\n admin: true\n }, afterLogin\n\n 'click .houston-logout': (e) ->\n e.preventDefault()\n Meteor.logout()\n\n 'click .become-houston-admin': (e) ->\n Houston._call('make_admin', Meteor.userId())\n e.preventDefault()\n)\n\nTemplate._houston_login.rendered = ->\n $(window).unbind('scroll')", "source_lang": "CoffeeScript", "target_lang": "CoffeeScript", "repo": "gterrono/houston", "path": "client/admin_login.coffee", "license": "MIT", "commit": "c64d37df458f49f3aec190bdf793fa665473895a", "stars": 802, "source_url": "https://github.com/gterrono/houston/blob/c64d37df458f49f3aec190bdf793fa665473895a/client/admin_login.coffee", "line_start": 1, "line_end": 39}1189{"id": "gterrono/houston:client/admin_login.coffee:1:raw_corpus", "type": "raw_corpus", "prompt": "", "response": "Template._houston_login.helpers(\n logged_in: -> Meteor.user()\n admin_user_exists: -> Meteor.users.findOne 'profile.admin': true\n)\n\nTemplate._houston_login.events(\n 'submit #houston-sign-in-form': (e) ->\n e.preventDefault()\n email = $('input[name=\"email\"]').val()\n password = $('input[name=\"password\"]').val()\n\n afterLogin = (error) ->\n # TODO error case that properly displays\n if error\n alert error\n else\n Houston._go 'home'\n\n if Meteor.users.findOne('profile.admin': true)\n Meteor.loginWithPassword email, password, afterLogin\n else\n Accounts.createUser {\n email: $('input[name=\"email\"]').val()\n password: $('input[name=\"password\"]').val()\n profile:\n admin: true\n }, afterLogin\n\n 'click .houston-logout': (e) ->\n e.preventDefault()\n Meteor.logout()\n\n 'click .become-houston-admin': (e) ->\n Meteor.call('_houston_make_admin', Meteor.userId())\n e.preventDefault()\n)\n\nTemplate._houston_login.rendered = ->\n $(window).unbind('scroll')", "source_lang": "", "target_lang": "CoffeeScript", "repo": "gterrono/houston", "path": "client/admin_login.coffee", "license": "MIT", "commit": "446fa960c31d33c521b881308100a6ac27b904d0", "stars": 802, "source_url": "https://github.com/gterrono/houston/blob/446fa960c31d33c521b881308100a6ac27b904d0/client/admin_login.coffee", "line_start": 1, "line_end": 39}1190{"id": "gterrono/houston:client/admin_login.coffee:1:coffee_to_js", "type": "coffee_to_js", "prompt": "Convert this CoffeeScript to JavaScript.\n```coffeescript\nTemplate._houston_login.helpers(\n logged_in: -> Meteor.user()\n admin_user_exists: -> Meteor.users.findOne 'profile.admin': true\n)\n\nTemplate._houston_login.events(\n 'submit #houston-sign-in-form': (e) ->\n e.preventDefault()\n email = $('input[name=\"email\"]').val()\n password = $('input[name=\"password\"]').val()\n\n afterLogin = (error) ->\n # TODO error case that properly displays\n if error\n alert error\n else\n Houston._go 'home'\n\n if Meteor.users.findOne('profile.admin': true)\n Meteor.loginWithPassword email, password, afterLogin\n else\n Accounts.createUser {\n email: $('input[name=\"email\"]').val()\n password: $('input[name=\"password\"]').val()\n profile:\n admin: true\n }, afterLogin\n\n 'click .houston-logout': (e) ->\n e.preventDefault()\n Meteor.logout()\n\n 'click .become-houston-admin': (e) ->\n Meteor.call('_houston_make_admin', Meteor.userId())\n e.preventDefault()\n)\n\nTemplate._houston_login.rendered = ->\n $(window).unbind('scroll')\n```", "response": "Template._houston_login.helpers({\n logged_in: function() {\n return Meteor.user();\n },\n admin_user_exists: function() {\n return Meteor.users.findOne({\n 'profile.admin': true\n });\n }\n});\n\nTemplate._houston_login.events({\n 'submit #houston-sign-in-form': function(e) {\n var afterLogin, email, password;\n e.preventDefault();\n email = $('input[name=\"email\"]').val();\n password = $('input[name=\"password\"]').val();\n afterLogin = function(error) {\n // TODO error case that properly displays\n if (error) {\n return alert(error);\n } else {\n return Houston._go('home');\n }\n };\n if (Meteor.users.findOne({\n 'profile.admin': true\n })) {\n return Meteor.loginWithPassword(email, password, afterLogin);\n } else {\n return Accounts.createUser({\n email: $('input[name=\"email\"]').val(),\n password: $('input[name=\"password\"]').val(),\n profile: {\n admin: true\n }\n }, afterLogin);\n }\n },\n 'click .houston-logout': function(e) {\n e.preventDefault();\n return Meteor.logout();\n },\n 'click .become-houston-admin': function(e) {\n Meteor.call('_houston_make_admin', Meteor.userId());\n return e.preventDefault();\n }\n});\n\nTemplate._houston_login.rendered = function() {\n return $(window).unbind('scroll');\n};", "source_lang": "CoffeeScript", "target_lang": "JavaScript", "repo": "gterrono/houston", "path": "client/admin_login.coffee", "license": "MIT", "commit": "446fa960c31d33c521b881308100a6ac27b904d0", "stars": 802, "source_url": "https://github.com/gterrono/houston/blob/446fa960c31d33c521b881308100a6ac27b904d0/client/admin_login.coffee", "line_start": 1, "line_end": 39}1191{"id": "gterrono/houston:client/admin_login.coffee:1:js_to_coffee", "type": "js_to_coffee", "prompt": "Convert this JavaScript to CoffeeScript.\n```javascript\nTemplate._houston_login.helpers({\n logged_in: function() {\n return Meteor.user();\n },\n admin_user_exists: function() {\n return Meteor.users.findOne({\n 'profile.admin': true\n });\n }\n});\n\nTemplate._houston_login.events({\n 'submit #houston-sign-in-form': function(e) {\n var afterLogin, email, password;\n e.preventDefault();\n email = $('input[name=\"email\"]').val();\n password = $('input[name=\"password\"]').val();\n afterLogin = function(error) {\n // TODO error case that properly displays\n if (error) {\n return alert(error);\n } else {\n return Houston._go('home');\n }\n };\n if (Meteor.users.findOne({\n 'profile.admin': true\n })) {\n return Meteor.loginWithPassword(email, password, afterLogin);\n } else {\n return Accounts.createUser({\n email: $('input[name=\"email\"]').val(),\n password: $('input[name=\"password\"]').val(),\n profile: {\n admin: true\n }\n }, afterLogin);\n }\n },\n 'click .houston-logout': function(e) {\n e.preventDefault();\n return Meteor.logout();\n },\n 'click .become-houston-admin': function(e) {\n Meteor.call('_houston_make_admin', Meteor.userId());\n return e.preventDefault();\n }\n});\n\nTemplate._houston_login.rendered = function() {\n return $(window).unbind('scroll');\n};\n```", "response": "Template._houston_login.helpers(\n logged_in: -> Meteor.user()\n admin_user_exists: -> Meteor.users.findOne 'profile.admin': true\n)\n\nTemplate._houston_login.events(\n 'submit #houston-sign-in-form': (e) ->\n e.preventDefault()\n email = $('input[name=\"email\"]').val()\n password = $('input[name=\"password\"]').val()\n\n afterLogin = (error) ->\n # TODO error case that properly displays\n if error\n alert error\n else\n Houston._go 'home'\n\n if Meteor.users.findOne('profile.admin': true)\n Meteor.loginWithPassword email, password, afterLogin\n else\n Accounts.createUser {\n email: $('input[name=\"email\"]').val()\n password: $('input[name=\"password\"]').val()\n profile:\n admin: true\n }, afterLogin\n\n 'click .houston-logout': (e) ->\n e.preventDefault()\n Meteor.logout()\n\n 'click .become-houston-admin': (e) ->\n Meteor.call('_houston_make_admin', Meteor.userId())\n e.preventDefault()\n)\n\nTemplate._houston_login.rendered = ->\n $(window).unbind('scroll')", "source_lang": "JavaScript", "target_lang": "CoffeeScript", "repo": "gterrono/houston", "path": "client/admin_login.coffee", "license": "MIT", "commit": "446fa960c31d33c521b881308100a6ac27b904d0", "stars": 802, "source_url": "https://github.com/gterrono/houston/blob/446fa960c31d33c521b881308100a6ac27b904d0/client/admin_login.coffee", "line_start": 1, "line_end": 39}1192{"id": "gterrono/houston:client/admin_login.coffee:1:completion", "type": "completion", "prompt": "Template._houston_login.helpers(\n logged_in: -> Meteor.user()\n admin_user_exists: -> Meteor.users.findOne 'profile.admin': true\n)\n\nTemplate._houston_login.events(\n 'submit #houston-sign-in-form': (e) ->\n e.preventDefault()\n email = $('input[name=\"email\"]').val()\n password = $('input[name=\"password\"]').val()\n\n afterLogin = (error) ->\n # TODO error case that properly displays\n if error\n alert error\n else\n Houston._go 'home'\n\n if Meteor.users.findOne('profile.admin': true)", "response": "Meteor.loginWithPassword email, password, afterLogin\n else\n Accounts.createUser {\n email: $('input[name=\"email\"]').val()\n password: $('input[name=\"password\"]').val()\n profile:\n admin: true\n }, afterLogin\n\n 'click .houston-logout': (e) ->\n e.preventDefault()\n Meteor.logout()\n\n 'click .become-houston-admin': (e) ->\n Meteor.call('_houston_make_admin', Meteor.userId())\n e.preventDefault()\n)\n\nTemplate._houston_login.rendered = ->\n $(window).unbind('scroll')", "source_lang": "CoffeeScript", "target_lang": "CoffeeScript", "repo": "gterrono/houston", "path": "client/admin_login.coffee", "license": "MIT", "commit": "446fa960c31d33c521b881308100a6ac27b904d0", "stars": 802, "source_url": "https://github.com/gterrono/houston/blob/446fa960c31d33c521b881308100a6ac27b904d0/client/admin_login.coffee", "line_start": 1, "line_end": 39}1193{"id": "gterrono/houston:client/admin_login.coffee:1:raw_corpus", "type": "raw_corpus", "prompt": "", "response": "Template._houston_login.helpers(\n logged_in: -> Meteor.user()\n admin_user_exists: -> Meteor.users.findOne 'profile.admin': true\n)\n\nTemplate._houston_login.events(\n 'submit #houston-sign-in-form': (e) ->\n e.preventDefault()\n email = $('input[name=\"email\"]').val()\n password = $('input[name=\"password\"]').val()\n\n afterLogin = (error) ->\n # TODO error case that properly displays\n if error\n alert error\n else\n houston_go 'home'\n\n if Meteor.users.findOne('profile.admin': true)\n Meteor.loginWithPassword email, password, afterLogin\n else\n Accounts.createUser {\n email: $('input[name=\"email\"]').val()\n password: $('input[name=\"password\"]').val()\n profile:\n admin: true\n }, afterLogin\n\n 'click .houston-logout': (e) ->\n e.preventDefault()\n Meteor.logout()\n\n 'click .become-houston-admin': (e) ->\n Meteor.call('_houston_make_admin', Meteor.userId())\n e.preventDefault()\n)\n\nTemplate._houston_login.rendered = ->\n $(window).unbind('scroll')", "source_lang": "", "target_lang": "CoffeeScript", "repo": "gterrono/houston", "path": "client/admin_login.coffee", "license": "MIT", "commit": "16ea359dbf8dfec50191fb5cf8c98d6c81120457", "stars": 802, "source_url": "https://github.com/gterrono/houston/blob/16ea359dbf8dfec50191fb5cf8c98d6c81120457/client/admin_login.coffee", "line_start": 1, "line_end": 39}1194{"id": "gterrono/houston:client/admin_login.coffee:1:coffee_to_js", "type": "coffee_to_js", "prompt": "Convert this CoffeeScript to JavaScript.\n```coffeescript\nTemplate._houston_login.helpers(\n logged_in: -> Meteor.user()\n admin_user_exists: -> Meteor.users.findOne 'profile.admin': true\n)\n\nTemplate._houston_login.events(\n 'submit #houston-sign-in-form': (e) ->\n e.preventDefault()\n email = $('input[name=\"email\"]').val()\n password = $('input[name=\"password\"]').val()\n\n afterLogin = (error) ->\n # TODO error case that properly displays\n if error\n alert error\n else\n houston_go 'home'\n\n if Meteor.users.findOne('profile.admin': true)\n Meteor.loginWithPassword email, password, afterLogin\n else\n Accounts.createUser {\n email: $('input[name=\"email\"]').val()\n password: $('input[name=\"password\"]').val()\n profile:\n admin: true\n }, afterLogin\n\n 'click .houston-logout': (e) ->\n e.preventDefault()\n Meteor.logout()\n\n 'click .become-houston-admin': (e) ->\n Meteor.call('_houston_make_admin', Meteor.userId())\n e.preventDefault()\n)\n\nTemplate._houston_login.rendered = ->\n $(window).unbind('scroll')\n```", "response": "Template._houston_login.helpers({\n logged_in: function() {\n return Meteor.user();\n },\n admin_user_exists: function() {\n return Meteor.users.findOne({\n 'profile.admin': true\n });\n }\n});\n\nTemplate._houston_login.events({\n 'submit #houston-sign-in-form': function(e) {\n var afterLogin, email, password;\n e.preventDefault();\n email = $('input[name=\"email\"]').val();\n password = $('input[name=\"password\"]').val();\n afterLogin = function(error) {\n // TODO error case that properly displays\n if (error) {\n return alert(error);\n } else {\n return houston_go('home');\n }\n };\n if (Meteor.users.findOne({\n 'profile.admin': true\n })) {\n return Meteor.loginWithPassword(email, password, afterLogin);\n } else {\n return Accounts.createUser({\n email: $('input[name=\"email\"]').val(),\n password: $('input[name=\"password\"]').val(),\n profile: {\n admin: true\n }\n }, afterLogin);\n }\n },\n 'click .houston-logout': function(e) {\n e.preventDefault();\n return Meteor.logout();\n },\n 'click .become-houston-admin': function(e) {\n Meteor.call('_houston_make_admin', Meteor.userId());\n return e.preventDefault();\n }\n});\n\nTemplate._houston_login.rendered = function() {\n return $(window).unbind('scroll');\n};", "source_lang": "CoffeeScript", "target_lang": "JavaScript", "repo": "gterrono/houston", "path": "client/admin_login.coffee", "license": "MIT", "commit": "16ea359dbf8dfec50191fb5cf8c98d6c81120457", "stars": 802, "source_url": "https://github.com/gterrono/houston/blob/16ea359dbf8dfec50191fb5cf8c98d6c81120457/client/admin_login.coffee", "line_start": 1, "line_end": 39}1195{"id": "gterrono/houston:client/admin_login.coffee:1:js_to_coffee", "type": "js_to_coffee", "prompt": "Convert this JavaScript to CoffeeScript.\n```javascript\nTemplate._houston_login.helpers({\n logged_in: function() {\n return Meteor.user();\n },\n admin_user_exists: function() {\n return Meteor.users.findOne({\n 'profile.admin': true\n });\n }\n});\n\nTemplate._houston_login.events({\n 'submit #houston-sign-in-form': function(e) {\n var afterLogin, email, password;\n e.preventDefault();\n email = $('input[name=\"email\"]').val();\n password = $('input[name=\"password\"]').val();\n afterLogin = function(error) {\n // TODO error case that properly displays\n if (error) {\n return alert(error);\n } else {\n return houston_go('home');\n }\n };\n if (Meteor.users.findOne({\n 'profile.admin': true\n })) {\n return Meteor.loginWithPassword(email, password, afterLogin);\n } else {\n return Accounts.createUser({\n email: $('input[name=\"email\"]').val(),\n password: $('input[name=\"password\"]').val(),\n profile: {\n admin: true\n }\n }, afterLogin);\n }\n },\n 'click .houston-logout': function(e) {\n e.preventDefault();\n return Meteor.logout();\n },\n 'click .become-houston-admin': function(e) {\n Meteor.call('_houston_make_admin', Meteor.userId());\n return e.preventDefault();\n }\n});\n\nTemplate._houston_login.rendered = function() {\n return $(window).unbind('scroll');\n};\n```", "response": "Template._houston_login.helpers(\n logged_in: -> Meteor.user()\n admin_user_exists: -> Meteor.users.findOne 'profile.admin': true\n)\n\nTemplate._houston_login.events(\n 'submit #houston-sign-in-form': (e) ->\n e.preventDefault()\n email = $('input[name=\"email\"]').val()\n password = $('input[name=\"password\"]').val()\n\n afterLogin = (error) ->\n # TODO error case that properly displays\n if error\n alert error\n else\n houston_go 'home'\n\n if Meteor.users.findOne('profile.admin': true)\n Meteor.loginWithPassword email, password, afterLogin\n else\n Accounts.createUser {\n email: $('input[name=\"email\"]').val()\n password: $('input[name=\"password\"]').val()\n profile:\n admin: true\n }, afterLogin\n\n 'click .houston-logout': (e) ->\n e.preventDefault()\n Meteor.logout()\n\n 'click .become-houston-admin': (e) ->\n Meteor.call('_houston_make_admin', Meteor.userId())\n e.preventDefault()\n)\n\nTemplate._houston_login.rendered = ->\n $(window).unbind('scroll')", "source_lang": "JavaScript", "target_lang": "CoffeeScript", "repo": "gterrono/houston", "path": "client/admin_login.coffee", "license": "MIT", "commit": "16ea359dbf8dfec50191fb5cf8c98d6c81120457", "stars": 802, "source_url": "https://github.com/gterrono/houston/blob/16ea359dbf8dfec50191fb5cf8c98d6c81120457/client/admin_login.coffee", "line_start": 1, "line_end": 39}1196{"id": "gterrono/houston:client/admin_login.coffee:1:completion", "type": "completion", "prompt": "Template._houston_login.helpers(\n logged_in: -> Meteor.user()\n admin_user_exists: -> Meteor.users.findOne 'profile.admin': true\n)\n\nTemplate._houston_login.events(\n 'submit #houston-sign-in-form': (e) ->\n e.preventDefault()\n email = $('input[name=\"email\"]').val()\n password = $('input[name=\"password\"]').val()\n\n afterLogin = (error) ->\n # TODO error case that properly displays\n if error\n alert error\n else\n houston_go 'home'\n\n if Meteor.users.findOne('profile.admin': true)", "response": "Meteor.loginWithPassword email, password, afterLogin\n else\n Accounts.createUser {\n email: $('input[name=\"email\"]').val()\n password: $('input[name=\"password\"]').val()\n profile:\n admin: true\n }, afterLogin\n\n 'click .houston-logout': (e) ->\n e.preventDefault()\n Meteor.logout()\n\n 'click .become-houston-admin': (e) ->\n Meteor.call('_houston_make_admin', Meteor.userId())\n e.preventDefault()\n)\n\nTemplate._houston_login.rendered = ->\n $(window).unbind('scroll')", "source_lang": "CoffeeScript", "target_lang": "CoffeeScript", "repo": "gterrono/houston", "path": "client/admin_login.coffee", "license": "MIT", "commit": "16ea359dbf8dfec50191fb5cf8c98d6c81120457", "stars": 802, "source_url": "https://github.com/gterrono/houston/blob/16ea359dbf8dfec50191fb5cf8c98d6c81120457/client/admin_login.coffee", "line_start": 1, "line_end": 39}1197{"id": "gterrono/houston:client/admin_login.coffee:1:raw_corpus", "type": "raw_corpus", "prompt": "", "response": "Template._houston_login.helpers(\n logged_in: -> Meteor.user()\n admin_user_exists: -> Meteor.users.findOne 'profile.admin': true\n)\n\nTemplate._houston_login.events(\n 'submit #houston-sign-in-form': (e) ->\n e.preventDefault()\n email = $('input[name=\"email\"]').val()\n password = $('input[name=\"password\"]').val()\n if Meteor.users.findOne('profile.admin': true)\n Meteor.loginWithPassword(email, password)\n else\n # TODO: unbreak if this fails\n Accounts.createUser\n email: $('input[name=\"email\"]').val()\n password: $('input[name=\"password\"]').val()\n profile:\n admin: true\n\n 'click .houston-logout': (e) ->\n e.preventDefault()\n Meteor.logout()\n\n 'click .become-houston-admin': (e) ->\n Meteor.call('_houston_make_admin', Meteor.userId())\n e.preventDefault()\n)\n\nTemplate._houston_login.rendered = ->\n $(window).unbind('scroll')", "source_lang": "", "target_lang": "CoffeeScript", "repo": "gterrono/houston", "path": "client/admin_login.coffee", "license": "MIT", "commit": "93e06a251afa99843d47e26f6bfde1ba3c93c47e", "stars": 802, "source_url": "https://github.com/gterrono/houston/blob/93e06a251afa99843d47e26f6bfde1ba3c93c47e/client/admin_login.coffee", "line_start": 1, "line_end": 31}1198{"id": "gterrono/houston:client/admin_login.coffee:1:coffee_to_js", "type": "coffee_to_js", "prompt": "Convert this CoffeeScript to JavaScript.\n```coffeescript\nTemplate._houston_login.helpers(\n logged_in: -> Meteor.user()\n admin_user_exists: -> Meteor.users.findOne 'profile.admin': true\n)\n\nTemplate._houston_login.events(\n 'submit #houston-sign-in-form': (e) ->\n e.preventDefault()\n email = $('input[name=\"email\"]').val()\n password = $('input[name=\"password\"]').val()\n if Meteor.users.findOne('profile.admin': true)\n Meteor.loginWithPassword(email, password)\n else\n # TODO: unbreak if this fails\n Accounts.createUser\n email: $('input[name=\"email\"]').val()\n password: $('input[name=\"password\"]').val()\n profile:\n admin: true\n\n 'click .houston-logout': (e) ->\n e.preventDefault()\n Meteor.logout()\n\n 'click .become-houston-admin': (e) ->\n Meteor.call('_houston_make_admin', Meteor.userId())\n e.preventDefault()\n)\n\nTemplate._houston_login.rendered = ->\n $(window).unbind('scroll')\n```", "response": "Template._houston_login.helpers({\n logged_in: function() {\n return Meteor.user();\n },\n admin_user_exists: function() {\n return Meteor.users.findOne({\n 'profile.admin': true\n });\n }\n});\n\nTemplate._houston_login.events({\n 'submit #houston-sign-in-form': function(e) {\n var email, password;\n e.preventDefault();\n email = $('input[name=\"email\"]').val();\n password = $('input[name=\"password\"]').val();\n if (Meteor.users.findOne({\n 'profile.admin': true\n })) {\n return Meteor.loginWithPassword(email, password);\n } else {\n // TODO: unbreak if this fails\n return Accounts.createUser({\n email: $('input[name=\"email\"]').val(),\n password: $('input[name=\"password\"]').val(),\n profile: {\n admin: true\n }\n });\n }\n },\n 'click .houston-logout': function(e) {\n e.preventDefault();\n return Meteor.logout();\n },\n 'click .become-houston-admin': function(e) {\n Meteor.call('_houston_make_admin', Meteor.userId());\n return e.preventDefault();\n }\n});\n\nTemplate._houston_login.rendered = function() {\n return $(window).unbind('scroll');\n};", "source_lang": "CoffeeScript", "target_lang": "JavaScript", "repo": "gterrono/houston", "path": "client/admin_login.coffee", "license": "MIT", "commit": "93e06a251afa99843d47e26f6bfde1ba3c93c47e", "stars": 802, "source_url": "https://github.com/gterrono/houston/blob/93e06a251afa99843d47e26f6bfde1ba3c93c47e/client/admin_login.coffee", "line_start": 1, "line_end": 31}1199{"id": "gterrono/houston:client/admin_login.coffee:1:js_to_coffee", "type": "js_to_coffee", "prompt": "Convert this JavaScript to CoffeeScript.\n```javascript\nTemplate._houston_login.helpers({\n logged_in: function() {\n return Meteor.user();\n },\n admin_user_exists: function() {\n return Meteor.users.findOne({\n 'profile.admin': true\n });\n }\n});\n\nTemplate._houston_login.events({\n 'submit #houston-sign-in-form': function(e) {\n var email, password;\n e.preventDefault();\n email = $('input[name=\"email\"]').val();\n password = $('input[name=\"password\"]').val();\n if (Meteor.users.findOne({\n 'profile.admin': true\n })) {\n return Meteor.loginWithPassword(email, password);\n } else {\n // TODO: unbreak if this fails\n return Accounts.createUser({\n email: $('input[name=\"email\"]').val(),\n password: $('input[name=\"password\"]').val(),\n profile: {\n admin: true\n }\n });\n }\n },\n 'click .houston-logout': function(e) {\n e.preventDefault();\n return Meteor.logout();\n },\n 'click .become-houston-admin': function(e) {\n Meteor.call('_houston_make_admin', Meteor.userId());\n return e.preventDefault();\n }\n});\n\nTemplate._houston_login.rendered = function() {\n return $(window).unbind('scroll');\n};\n```", "response": "Template._houston_login.helpers(\n logged_in: -> Meteor.user()\n admin_user_exists: -> Meteor.users.findOne 'profile.admin': true\n)\n\nTemplate._houston_login.events(\n 'submit #houston-sign-in-form': (e) ->\n e.preventDefault()\n email = $('input[name=\"email\"]').val()\n password = $('input[name=\"password\"]').val()\n if Meteor.users.findOne('profile.admin': true)\n Meteor.loginWithPassword(email, password)\n else\n # TODO: unbreak if this fails\n Accounts.createUser\n email: $('input[name=\"email\"]').val()\n password: $('input[name=\"password\"]').val()\n profile:\n admin: true\n\n 'click .houston-logout': (e) ->\n e.preventDefault()\n Meteor.logout()\n\n 'click .become-houston-admin': (e) ->\n Meteor.call('_houston_make_admin', Meteor.userId())\n e.preventDefault()\n)\n\nTemplate._houston_login.rendered = ->\n $(window).unbind('scroll')", "source_lang": "JavaScript", "target_lang": "CoffeeScript", "repo": "gterrono/houston", "path": "client/admin_login.coffee", "license": "MIT", "commit": "93e06a251afa99843d47e26f6bfde1ba3c93c47e", "stars": 802, "source_url": "https://github.com/gterrono/houston/blob/93e06a251afa99843d47e26f6bfde1ba3c93c47e/client/admin_login.coffee", "line_start": 1, "line_end": 31}1200{"id": "gterrono/houston:client/admin_login.coffee:1:completion", "type": "completion", "prompt": "Template._houston_login.helpers(\n logged_in: -> Meteor.user()\n admin_user_exists: -> Meteor.users.findOne 'profile.admin': true\n)\n\nTemplate._houston_login.events(\n 'submit #houston-sign-in-form': (e) ->\n e.preventDefault()\n email = $('input[name=\"email\"]').val()\n password = $('input[name=\"password\"]').val()\n if Meteor.users.findOne('profile.admin': true)\n Meteor.loginWithPassword(email, password)\n else\n # TODO: unbreak if this fails\n Accounts.createUser", "response": "email: $('input[name=\"email\"]').val()\n password: $('input[name=\"password\"]').val()\n profile:\n admin: true\n\n 'click .houston-logout': (e) ->\n e.preventDefault()\n Meteor.logout()\n\n 'click .become-houston-admin': (e) ->\n Meteor.call('_houston_make_admin', Meteor.userId())\n e.preventDefault()\n)\n\nTemplate._houston_login.rendered = ->\n $(window).unbind('scroll')", "source_lang": "CoffeeScript", "target_lang": "CoffeeScript", "repo": "gterrono/houston", "path": "client/admin_login.coffee", "license": "MIT", "commit": "93e06a251afa99843d47e26f6bfde1ba3c93c47e", "stars": 802, "source_url": "https://github.com/gterrono/houston/blob/93e06a251afa99843d47e26f6bfde1ba3c93c47e/client/admin_login.coffee", "line_start": 1, "line_end": 31}