summaryrefslogtreecommitdiffstatshomepage
path: root/plugins/coro-wrapper
diff options
context:
space:
mode:
Diffstat (limited to 'plugins/coro-wrapper')
-rw-r--r--plugins/coro-wrapper/LICENSE22
-rw-r--r--plugins/coro-wrapper/README.md2
-rw-r--r--plugins/coro-wrapper/init.lua41
-rw-r--r--plugins/coro-wrapper/plugin.json8
4 files changed, 73 insertions, 0 deletions
diff --git a/plugins/coro-wrapper/LICENSE b/plugins/coro-wrapper/LICENSE
new file mode 100644
index 00000000000..5789b767285
--- /dev/null
+++ b/plugins/coro-wrapper/LICENSE
@@ -0,0 +1,22 @@
+The MIT License (MIT)
+
+Copyright (c) 2015 Tim Caswell
+
+Permission is hereby granted, free of charge, to any person obtaining a copy
+of this software and associated documentation files (the "Software"), to deal
+in the Software without restriction, including without limitation the rights
+to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+copies of the Software, and to permit persons to whom the Software is
+furnished to do so, subject to the following conditions:
+
+The above copyright notice and this permission notice shall be included in all
+copies or substantial portions of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+SOFTWARE.
+
diff --git a/plugins/coro-wrapper/README.md b/plugins/coro-wrapper/README.md
new file mode 100644
index 00000000000..a9351a7f531
--- /dev/null
+++ b/plugins/coro-wrapper/README.md
@@ -0,0 +1,2 @@
+# luv-coro-wrapper
+A luv port of lit's coro-wrapper module
diff --git a/plugins/coro-wrapper/init.lua b/plugins/coro-wrapper/init.lua
new file mode 100644
index 00000000000..aab2683baf3
--- /dev/null
+++ b/plugins/coro-wrapper/init.lua
@@ -0,0 +1,41 @@
+local exports = {}
+exports.name = "creationix/coro-wrapper"
+exports.version = "1.0.0-1"
+exports.homepage = "https://github.com/luvit/lit/blob/master/deps/coro-wrapper.lua"
+exports.description = "An adapter for applying decoders to coro-streams."
+exports.tags = {"coro", "decoder", "adapter"}
+exports.license = "MIT"
+exports.author = { name = "Tim Caswell" }
+
+function exports.reader(read, decode)
+ local buffer = ""
+ return function ()
+ while true do
+ local item, extra = decode(buffer)
+ if item then
+ buffer = extra
+ return item
+ end
+ local chunk = read()
+ if not chunk then return end
+ buffer = buffer .. chunk
+ end
+ end,
+ function (newDecode)
+ decode = newDecode
+ end
+end
+
+function exports.writer(write, encode)
+ return function (item)
+ if not item then
+ return write()
+ end
+ return write(encode(item))
+ end,
+ function (newEncode)
+ encode = newEncode
+ end
+end
+
+return exports
diff --git a/plugins/coro-wrapper/plugin.json b/plugins/coro-wrapper/plugin.json
new file mode 100644
index 00000000000..6075edba1fa
--- /dev/null
+++ b/plugins/coro-wrapper/plugin.json
@@ -0,0 +1,8 @@
+{
+ "plugin": {
+ "name": "coro-wrapper",
+ "version": "1.0.0-1",
+ "author": "Tim Caswell",
+ "type": "library",
+ }
+} \ No newline at end of file