Skip to content

Instantly share code, notes, and snippets.

@apaleslimghost
Created August 14, 2013 14:20
Show Gist options
  • Save apaleslimghost/6231500 to your computer and use it in GitHub Desktop.
Save apaleslimghost/6231500 to your computer and use it in GitHub Desktop.
Readable.of = (body)->
new class extends Readable
offset: 0
_read: (size)->
@push body.slice @offset,@offset+size-1
@offset += size-1
if @offset > body.length then return @push null # end the Readable
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment