Socket
Socket
Sign inDemoInstall

koa-range

Package Overview
Dependencies
1
Maintainers
1
Versions
14
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

    koa-range

range request implementation for koa


Version published
Weekly downloads
163K
decreased by-24.68%
Maintainers
1
Install size
16.3 kB
Created
Weekly downloads
 

Readme

Source

koa-range

range request implementation for koa

NPM version Build status Test coverage License Dependency status

NPM NPM

Installation

$ npm install koa-range

Usage (with koa@2)

var fs = require('fs');
var range = require('koa-range');
var route = require('koa-route');
var Koa = require('koa');
var app = new Koa();

app.use(range);

// via buffer
app.use(route.get('/', async function (ctx) {
  ctx.body = new Buffer(100);
}));

// via object
app.use(route.get('/json', async function (ctx) {
  ctx.body = {
    'foo': 'bar'
  };
}));

// via readable stream
app.use(route.get('/stream', async function (ctx) {
  ctx.body = fs.createReadStream('your path');
}));

Until async/await is supported by default, you will need to do one of the following:

  • Transpile your code with somehting like Babel
  • Use node v7 with --harmony-async-await flag

License

MIT

Keywords

FAQs

Last updated on 04 Feb 2017

Did you know?

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc