New Research: Supply Chain Attack on Axios Pulls Malicious Dependency from npm.Details →
Socket
Book a DemoSign in
Socket

http-timing

Package Overview
Dependencies
Maintainers
1
Versions
7
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

http-timing

generate the http timing(server timing) view

latest
Source
npmnpm
Version
2.0.1
Version published
Maintainers
1
Created
Source

http-timing

Generate the http timing(Server-Timing)

Build Status Coverage Status npm Github Releases

API

Constructor

The HTTPTiming constructor

  • options The constructor options
    • options.max The max time(ms), use for the time line bar, default is 10 * 1000
    • options.size The cache size, default is 10
const HTTPTiming = require('http-timing');
const httpTiming = new HTTPTiming({
  max: 5 * 1000,
  size: 5,
});

add

Add the data to timing view, return function to change the value of data

  • data The setting of http timing
    • data.url The http request url
    • data.method The http request method
    • data.status The http response status
    • data.use The http response time
    • data.serverTiming The http server timing
const HTTPTiming = require('http-timing');
const httpTiming = new HTTPTiming();
const set = httpTiming.add({
  method: 'GET',
  url: '/users/me',
  status: 200,
  use: 3000,
  serverTiming: 'A;dur=2521.46147;desc="/users/me",B;dur=102.022688;desc="getUser",C;dur=33.468153;desc="mongodb:get",D;dur=54.064163;desc="validate:user"',
});
set('use', 5000);
set({
  use: 5000,
});

get

Get the timing by index

  • index the timing index
const HTTPTiming = require('http-timing');
const httpTiming = new HTTPTiming();
httpTiming.add({
  method: 'GET',
  url: '/users/me',
  status: 200,
  use: 3000,
  serverTiming: 'A;dur=2521.46147;desc="/users/me",B;dur=102.022688;desc"getUser",C;dur=33.468153;desc"mongodb:get",D;dur=54.064163;desc="validate:user"',
});
console.info(httpTiming.get(0));

length

Get the cache length

const HTTPTiming = require('http-timing');
const httpTiming = new HTTPTiming();
// 0
console.info(httpTiming.length);

empty

Remove all cache

const HTTPTiming = require('http-timing');
const httpTiming = new HTTPTiming();
httpTiming.add({
  method: 'GET',
  url: '/users/me',
  status: 200,
  use: 3000,
  serverTiming: 'A;dur=2521.46147;desc="/users/me",B;dur=102.022688;desc="getUser",C;dur=33.468153;desc="mongodb:get",D;dur=54.064163;desc="validate:user"',
});
// 1
console.info(httpTiming.length)
httpTiming.empty();
// 0
console.info(httpTiming.length)

toHTML

Get the html of http timing

const HTTPTiming = require('http-timing');
const httpTiming = new HTTPTiming();
httpTiming.add({
  method: 'GET',
  url: '/users/me',
  status: 200,
  use: 3000,
  serverTiming: 'A;dur=2521.46147;desc="/users/me",B;dur=102.022688;desc="getUser",C;dur=33.468153;desc="mongodb:get",D;dur=54.064163;desc="validate:user"',
});
const html = httpTiming.toHTML();
console.info(html);

License

MIT

Keywords

timing

FAQs

Package last updated on 08 Jun 2019

Did you know?

Socket

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