npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

eshttp

v0.5.2

Published

ES6-style pure JavaScript HTTP library

Downloads

19

Readme

eshttp

Build Status

Portable pure JavaScript ES6 HTTP library. Includes fast streaming regex-free parser for HTTP/1.0 and HTTP/1.1.

  • pure JavaScript (ES6/2015)
  • high-performance and low-level, no stream abstractions
  • portable, multiple backends support (Node.js/other platforms)

USAGE

npm install eshttp

Requires ES6/2015 JS engine (Node.js 4.0). Example web server using eshttp:

'use strict';
const eshttp = require('eshttp');
const server = new eshttp.HttpServer();
const response = new eshttp.HttpResponse(200, { 'x-header': 'value' }, 'hello');

server.onrequest = request => {
  request.respondWith(response);
};

server.listen(8080);

TODO

  • parser improvements
  • chunked responses
  • fetch api

BENCHMARK

$ node -v
v4.2.1

Node.js builtin http module:

$ wrk -t12 -c400 -d30s http://127.0.0.1:8080/
Running 30s test @ http://127.0.0.1:8080/
  12 threads and 400 connections
  Thread Stats   Avg      Stdev     Max   +/- Stdev
    Latency    21.12ms    2.32ms  98.16ms   88.23%
    Req/Sec     1.25k   489.35     4.03k    83.52%
  336337 requests in 30.09s, 38.81MB read
  Socket errors: connect 155, read 181, write 0, timeout 0
Requests/sec:  11177.42
Transfer/sec:      1.29MB

eshttp:

$ wrk -t12 -c400 -d30s http://127.0.0.1:8080/
Running 30s test @ http://127.0.0.1:8080/
  12 threads and 400 connections
  Thread Stats   Avg      Stdev     Max   +/- Stdev
    Latency    11.46ms    1.75ms  76.40ms   94.03%
    Req/Sec     1.76k     1.36k    5.97k    62.83%
  630789 requests in 30.10s, 72.79MB read
  Socket errors: connect 155, read 130, write 21, timeout 0
Requests/sec:  20959.47
Transfer/sec:      2.42MB

API

const eshttp = require('eshttp');

eshttp.HttpResponse

Represents immutable HTTP response.

HttpResponse.constructor(code, headers, body)

Construct immutable HTTP response object that can be reused multiple times to serve different clients.

Argument | Type | Description --- | --- | --- code | number | HTTP code headers | Headers | object | Response headers object body | string | Response body string

const response = new eshttp.HttpResponse(200, { server: 'eshttp' }, 'OK.');

eshttp.HttpRequest

Represents immutable HTTP request.

HttpRequest.constructor(method, path, headers, body)

Construct immutable HTTP request object that can be reused multiple times.

Argument | Type | Description --- | --- | --- method | string | HTTP request method (e.g. 'GET') path | string | Request path headers | Headers | object | Request headers object body | string | Request body string (optional)

const request = new eshttp.HttpRequest('GET', '/', { 'User-Agent': 'eshttp' });

eshttp.HttpServer

Represents HTTP server.

HttpServer.constructor()

Construct HTTP server object.

const server = new eshttp.HttpServer();

HttpServer.listen(port)

Start listening to HTTP requests.

server.listen(8080);

HttpServer.close()

Stop listening.

server.close();

HttpServer.onrequest = function(request)

Request handler callback.

server.onrequest = request => {
  console.log('new incoming request');
};

##LICENSE

MIT