{"action":"created","comment":{"url":"https://api.github.com/repos/xseignard/thermalPrinter/pulls/comments/32891815","id":32891815,"diff_hunk":"@@ -65,12 +64,14 @@ Printer.prototype.print = function(callback) {\n \tasync.eachSeries(\n \t\t_self.commandQueue,\n \t\tfunction(command, callback) {\n-\t\t\tif (_self.commandDelay !== 0) {\n-\t\t\t\tsleep.usleep(_self.commandDelay);\n+\t\t\tfunction write() {\n+\t\t\t\t_self.serialPort.write(command, function() {\n+\t\t\t\t\t_self.serialPort.drain(callback);\n+\t\t\t\t});\n \t\t\t}\n-\t\t\t_self.serialPort.write(command, function() {\n-\t\t\t\t_self.serialPort.drain(callback);\n-\t\t\t});\n+\n+\t\t\tif (_self.commandDelay === 0) return write()","path":"src/printer.js","position":23,"original_position":23,"commit_id":"91552958d2c1857903840462400eb1e14294da96","original_commit_id":"91552958d2c1857903840462400eb1e14294da96","user":{"login":"LinusU","id":189580,"avatar_url":"https://avatars.githubusercontent.com/u/189580?v=3","gravatar_id":"","url":"https://api.github.com/users/LinusU","html_url":"https://github.com/LinusU","followers_url":"https://api.github.com/users/LinusU/followers","following_url":"https://api.github.com/users/LinusU/following{/other_user}","gists_url":"https://api.github.com/users/LinusU/gists{/gist_id}","starred_url":"https://api.github.com/users/LinusU/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/LinusU/subscriptions","organizations_url":"https://api.github.com/users/LinusU/orgs","repos_url":"https://api.github.com/users/LinusU/repos","events_url":"https://api.github.com/users/LinusU/events{/privacy}","received_events_url":"https://api.github.com/users/LinusU/received_events","type":"User","site_admin":false},"body":"`setTimeout(..., 0)` still produces a timeout of a few millisecond due to how scheduling works in javascript. I think that it would be best to just let it write as soon as possible.","created_at":"2015-06-21T08:54:42Z","updated_at":"2015-06-21T08:54:42Z","html_url":"https://github.com/xseignard/thermalPrinter/pull/12#discussion_r32891815","pull_request_url":"https://api.github.com/repos/xseignard/thermalPrinter/pulls/12","_links":{"self":{"href":"https://api.github.com/repos/xseignard/thermalPrinter/pulls/comments/32891815"},"html":{"href":"https://github.com/xseignard/thermalPrinter/pull/12#discussion_r32891815"},"pull_request":{"href":"https://api.github.com/repos/xseignard/thermalPrinter/pulls/12"}}},"pull_request":{"url":"https://api.github.com/repos/xseignard/thermalPrinter/pulls/12","id":37996742,"html_url":"https://github.com/xseignard/thermalPrinter/pull/12","diff_url":"https://github.com/xseignard/thermalPrinter/pull/12.diff","patch_url":"https://github.com/xseignard/thermalPrinter/pull/12.patch","issue_url":"https://api.github.com/repos/xseignard/thermalPrinter/issues/12","number":12,"state":"open","locked":false,"title":"lib: get rid of sleep","user":{"login":"LinusU","id":189580,"avatar_url":"https://avatars.githubusercontent.com/u/189580?v=3","gravatar_id":"","url":"https://api.github.com/users/LinusU","html_url":"https://github.com/LinusU","followers_url":"https://api.github.com/users/LinusU/followers","following_url":"https://api.github.com/users/LinusU/following{/other_user}","gists_url":"https://api.github.com/users/LinusU/gists{/gist_id}","starred_url":"https://api.github.com/users/LinusU/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/LinusU/subscriptions","organizations_url":"https://api.github.com/users/LinusU/orgs","repos_url":"https://api.github.com/users/LinusU/repos","events_url":"https://api.github.com/users/LinusU/events{/privacy}","received_events_url":"https://api.github.com/users/LinusU/received_events","type":"User","site_admin":false},"body":"Get rid of the sleep dependency.\r\n\r\nThe only downside is that this reduces the resolution of the sleep. It will round it upwards to the nearest millisecond.\r\n\r\n*Work towards supporting Tessel (#7)*","created_at":"2015-06-18T11:32:18Z","updated_at":"2015-06-21T08:54:42Z","closed_at":null,"merged_at":null,"merge_commit_sha":"1da788a5c0dd6bdc2c8cb387950ea42f0f3a5fc3","assignee":null,"milestone":null,"commits_url":"https://api.github.com/repos/xseignard/thermalPrinter/pulls/12/commits","review_comments_url":"https://api.github.com/repos/xseignard/thermalPrinter/pulls/12/comments","review_comment_url":"https://api.github.com/repos/xseignard/thermalPrinter/pulls/comments{/number}","comments_url":"https://api.github.com/repos/xseignard/thermalPrinter/issues/12/comments","statuses_url":"https://api.github.com/repos/xseignard/thermalPrinter/statuses/91552958d2c1857903840462400eb1e14294da96","head":{"label":"LinusU:patch-4","ref":"patch-4","sha":"91552958d2c1857903840462400eb1e14294da96","user":{"login":"LinusU","id":189580,"avatar_url":"https://avatars.githubusercontent.com/u/189580?v=3","gravatar_id":"","url":"https://api.github.com/users/LinusU","html_url":"https://github.com/LinusU","followers_url":"https://api.github.com/users/LinusU/followers","following_url":"https://api.github.com/users/LinusU/following{/other_user}","gists_url":"https://api.github.com/users/LinusU/gists{/gist_id}","starred_url":"https://api.github.com/users/LinusU/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/LinusU/subscriptions","organizations_url":"https://api.github.com/users/LinusU/orgs","repos_url":"https://api.github.com/users/LinusU/repos","events_url":"https://api.github.com/users/LinusU/events{/privacy}","received_events_url":"https://api.github.com/users/LinusU/received_events","type":"User","site_admin":false},"repo":{"id":37644128,"name":"thermalPrinter","full_name":"LinusU/thermalPrinter","owner":{"login":"LinusU","id":189580,"avatar_url":"https://avatars.githubusercontent.com/u/189580?v=3","gravatar_id":"","url":"https://api.github.com/users/LinusU","html_url":"https://github.com/LinusU","followers_url":"https://api.github.com/users/LinusU/followers","following_url":"https://api.github.com/users/LinusU/following{/other_user}","gists_url":"https://api.github.com/users/LinusU/gists{/gist_id}","starred_url":"https://api.github.com/users/LinusU/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/LinusU/subscriptions","organizations_url":"https://api.github.com/users/LinusU/orgs","repos_url":"https://api.github.com/users/LinusU/repos","events_url":"https://api.github.com/users/LinusU/events{/privacy}","received_events_url":"https://api.github.com/users/LinusU/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/LinusU/thermalPrinter","description":"Use node.js to communicate with Adafruit/Sparkfun Thermal Printer","fork":true,"url":"https://api.github.com/repos/LinusU/thermalPrinter","forks_url":"https://api.github.com/repos/LinusU/thermalPrinter/forks","keys_url":"https://api.github.com/repos/LinusU/thermalPrinter/keys{/key_id}","collaborators_url":"https://api.github.com/repos/LinusU/thermalPrinter/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/LinusU/thermalPrinter/teams","hooks_url":"https://api.github.com/repos/LinusU/thermalPrinter/hooks","issue_events_url":"https://api.github.com/repos/LinusU/thermalPrinter/issues/events{/number}","events_url":"https://api.github.com/repos/LinusU/thermalPrinter/events","assignees_url":"https://api.github.com/repos/LinusU/thermalPrinter/assignees{/user}","branches_url":"https://api.github.com/repos/LinusU/thermalPrinter/branches{/branch}","tags_url":"https://api.github.com/repos/LinusU/thermalPrinter/tags","blobs_url":"https://api.github.com/repos/LinusU/thermalPrinter/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/LinusU/thermalPrinter/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/LinusU/thermalPrinter/git/refs{/sha}","trees_url":"https://api.github.com/repos/LinusU/thermalPrinter/git/trees{/sha}","statuses_url":"https://api.github.com/repos/LinusU/thermalPrinter/statuses/{sha}","languages_url":"https://api.github.com/repos/LinusU/thermalPrinter/languages","stargazers_url":"https://api.github.com/repos/LinusU/thermalPrinter/stargazers","contributors_url":"https://api.github.com/repos/LinusU/thermalPrinter/contributors","subscribers_url":"https://api.github.com/repos/LinusU/thermalPrinter/subscribers","subscription_url":"https://api.github.com/repos/LinusU/thermalPrinter/subscription","commits_url":"https://api.github.com/repos/LinusU/thermalPrinter/commits{/sha}","git_commits_url":"https://api.github.com/repos/LinusU/thermalPrinter/git/commits{/sha}","comments_url":"https://api.github.com/repos/LinusU/thermalPrinter/comments{/number}","issue_comment_url":"https://api.github.com/repos/LinusU/thermalPrinter/issues/comments{/number}","contents_url":"https://api.github.com/repos/LinusU/thermalPrinter/contents/{+path}","compare_url":"https://api.github.com/repos/LinusU/thermalPrinter/compare/{base}...{head}","merges_url":"https://api.github.com/repos/LinusU/thermalPrinter/merges","archive_url":"https://api.github.com/repos/LinusU/thermalPrinter/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/LinusU/thermalPrinter/downloads","issues_url":"https://api.github.com/repos/LinusU/thermalPrinter/issues{/number}","pulls_url":"https://api.github.com/repos/LinusU/thermalPrinter/pulls{/number}","milestones_url":"https://api.github.com/repos/LinusU/thermalPrinter/milestones{/number}","notifications_url":"https://api.github.com/repos/LinusU/thermalPrinter/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/LinusU/thermalPrinter/labels{/name}","releases_url":"https://api.github.com/repos/LinusU/thermalPrinter/releases{/id}","created_at":"2015-06-18T07:20:28Z","updated_at":"2015-06-18T07:20:29Z","pushed_at":"2015-06-18T11:30:56Z","git_url":"git://github.com/LinusU/thermalPrinter.git","ssh_url":"git@github.com:LinusU/thermalPrinter.git","clone_url":"https://github.com/LinusU/thermalPrinter.git","svn_url":"https://github.com/LinusU/thermalPrinter","homepage":"","size":3309,"stargazers_count":0,"watchers_count":0,"language":"JavaScript","has_issues":false,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":0,"mirror_url":null,"open_issues_count":0,"forks":0,"open_issues":0,"watchers":0,"default_branch":"master"}},"base":{"label":"xseignard:master","ref":"master","sha":"7b1fd876ca5dcdc0c711b0ca6210966a92fb3343","user":{"login":"xseignard","id":515603,"avatar_url":"https://avatars.githubusercontent.com/u/515603?v=3","gravatar_id":"","url":"https://api.github.com/users/xseignard","html_url":"https://github.com/xseignard","followers_url":"https://api.github.com/users/xseignard/followers","following_url":"https://api.github.com/users/xseignard/following{/other_user}","gists_url":"https://api.github.com/users/xseignard/gists{/gist_id}","starred_url":"https://api.github.com/users/xseignard/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/xseignard/subscriptions","organizations_url":"https://api.github.com/users/xseignard/orgs","repos_url":"https://api.github.com/users/xseignard/repos","events_url":"https://api.github.com/users/xseignard/events{/privacy}","received_events_url":"https://api.github.com/users/xseignard/received_events","type":"User","site_admin":false},"repo":{"id":20006597,"name":"thermalPrinter","full_name":"xseignard/thermalPrinter","owner":{"login":"xseignard","id":515603,"avatar_url":"https://avatars.githubusercontent.com/u/515603?v=3","gravatar_id":"","url":"https://api.github.com/users/xseignard","html_url":"https://github.com/xseignard","followers_url":"https://api.github.com/users/xseignard/followers","following_url":"https://api.github.com/users/xseignard/following{/other_user}","gists_url":"https://api.github.com/users/xseignard/gists{/gist_id}","starred_url":"https://api.github.com/users/xseignard/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/xseignard/subscriptions","organizations_url":"https://api.github.com/users/xseignard/orgs","repos_url":"https://api.github.com/users/xseignard/repos","events_url":"https://api.github.com/users/xseignard/events{/privacy}","received_events_url":"https://api.github.com/users/xseignard/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/xseignard/thermalPrinter","description":"Use node.js to communicate with Adafruit/Sparkfun Thermal Printer","fork":false,"url":"https://api.github.com/repos/xseignard/thermalPrinter","forks_url":"https://api.github.com/repos/xseignard/thermalPrinter/forks","keys_url":"https://api.github.com/repos/xseignard/thermalPrinter/keys{/key_id}","collaborators_url":"https://api.github.com/repos/xseignard/thermalPrinter/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/xseignard/thermalPrinter/teams","hooks_url":"https://api.github.com/repos/xseignard/thermalPrinter/hooks","issue_events_url":"https://api.github.com/repos/xseignard/thermalPrinter/issues/events{/number}","events_url":"https://api.github.com/repos/xseignard/thermalPrinter/events","assignees_url":"https://api.github.com/repos/xseignard/thermalPrinter/assignees{/user}","branches_url":"https://api.github.com/repos/xseignard/thermalPrinter/branches{/branch}","tags_url":"https://api.github.com/repos/xseignard/thermalPrinter/tags","blobs_url":"https://api.github.com/repos/xseignard/thermalPrinter/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/xseignard/thermalPrinter/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/xseignard/thermalPrinter/git/refs{/sha}","trees_url":"https://api.github.com/repos/xseignard/thermalPrinter/git/trees{/sha}","statuses_url":"https://api.github.com/repos/xseignard/thermalPrinter/statuses/{sha}","languages_url":"https://api.github.com/repos/xseignard/thermalPrinter/languages","stargazers_url":"https://api.github.com/repos/xseignard/thermalPrinter/stargazers","contributors_url":"https://api.github.com/repos/xseignard/thermalPrinter/contributors","subscribers_url":"https://api.github.com/repos/xseignard/thermalPrinter/subscribers","subscription_url":"https://api.github.com/repos/xseignard/thermalPrinter/subscription","commits_url":"https://api.github.com/repos/xseignard/thermalPrinter/commits{/sha}","git_commits_url":"https://api.github.com/repos/xseignard/thermalPrinter/git/commits{/sha}","comments_url":"https://api.github.com/repos/xseignard/thermalPrinter/comments{/number}","issue_comment_url":"https://api.github.com/repos/xseignard/thermalPrinter/issues/comments{/number}","contents_url":"https://api.github.com/repos/xseignard/thermalPrinter/contents/{+path}","compare_url":"https://api.github.com/repos/xseignard/thermalPrinter/compare/{base}...{head}","merges_url":"https://api.github.com/repos/xseignard/thermalPrinter/merges","archive_url":"https://api.github.com/repos/xseignard/thermalPrinter/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/xseignard/thermalPrinter/downloads","issues_url":"https://api.github.com/repos/xseignard/thermalPrinter/issues{/number}","pulls_url":"https://api.github.com/repos/xseignard/thermalPrinter/pulls{/number}","milestones_url":"https://api.github.com/repos/xseignard/thermalPrinter/milestones{/number}","notifications_url":"https://api.github.com/repos/xseignard/thermalPrinter/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/xseignard/thermalPrinter/labels{/name}","releases_url":"https://api.github.com/repos/xseignard/thermalPrinter/releases{/id}","created_at":"2014-05-21T03:26:32Z","updated_at":"2015-06-14T22:07:21Z","pushed_at":"2015-06-18T11:32:19Z","git_url":"git://github.com/xseignard/thermalPrinter.git","ssh_url":"git@github.com:xseignard/thermalPrinter.git","clone_url":"https://github.com/xseignard/thermalPrinter.git","svn_url":"https://github.com/xseignard/thermalPrinter","homepage":"","size":3420,"stargazers_count":26,"watchers_count":26,"language":"JavaScript","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":9,"mirror_url":null,"open_issues_count":4,"forks":9,"open_issues":4,"watchers":26,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/xseignard/thermalPrinter/pulls/12"},"html":{"href":"https://github.com/xseignard/thermalPrinter/pull/12"},"issue":{"href":"https://api.github.com/repos/xseignard/thermalPrinter/issues/12"},"comments":{"href":"https://api.github.com/repos/xseignard/thermalPrinter/issues/12/comments"},"review_comments":{"href":"https://api.github.com/repos/xseignard/thermalPrinter/pulls/12/comments"},"review_comment":{"href":"https://api.github.com/repos/xseignard/thermalPrinter/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/xseignard/thermalPrinter/pulls/12/commits"},"statuses":{"href":"https://api.github.com/repos/xseignard/thermalPrinter/statuses/91552958d2c1857903840462400eb1e14294da96"}}}}