Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

add usage.js

fix README
  • Loading branch information...
commit 783da6681f4a34401d30390fde52a5536161233f 1 parent 5fed182
@KOBA789 authored
Showing with 26 additions and 1 deletion.
  1. +1 −1  README.md
  2. +1 −0  test/foo.txt
  3. +24 −0 test/usage.js
View
2  README.md
@@ -18,7 +18,7 @@ fs.readFile('foo.txt', 'utf8', function (err, data) {
if (err) {
evsync.open('error', err);
} else {
- evsync.open('load', file);
+ evsync.open('load', data);
}
});
View
1  test/foo.txt
@@ -0,0 +1 @@
+hogehoge
View
24 test/usage.js
@@ -0,0 +1,24 @@
+var fs = require('fs'),
+ http = require('http'),
+ EventSync = require('../');
+
+var evsync = new EventSync();
+
+fs.readFile('foo.txt', 'utf8', function (err, data) {
+ if (err) {
+ evsync.open('error', err);
+ } else {
+ evsync.open('load', data);
+ }
+});
+
+http.createServer(function (req, res) {
+ evsync.once('load', function (file) {
+ res.writeHead(200);
+ res.end(file);
+ });
+ evsync.once('error', function (err) {
+ res.writeHead(500);
+ res.end('Failed to load the file.');
+ });
+}).listen(8124);
Please sign in to comment.
Something went wrong with that request. Please try again.