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

js-service

v1.0.1

Published

<!-- Generated by documentation.js. Update this documentation by updating the source code. -->

Downloads

5

Readme

Table of Contents

Service

Extends EventEmitter

An object with an operational state, plus #start() and #stop() lifecycle methods to transition between states. Example services include webservers, RPC servers and timers.

Parameters

failureReason

Returns the Error that caused this service to fail.

Type: Error?

state

Returns the lifecycle state of the service.

Returns State

isRunning

Returns {@code true} if this service is {@linkplain State#Running Running}.

Returns boolean

running

Returns a Promise that resolves when the service enters the 'Running' state.

Returns Promise<void>

terminated

Returns a Promise that is satisfied when the service enters the a terminal state ('Terminated' or 'Failed')

If the service enters 'Failed', the returned promise rejects with the failure reason

Returns Promise<void>

start

If the service state is State#New, this initiates service startup and returns immediately. A stopped service may not be restarted.

  • Throws any Error if the service is not State#New

stop

If the service is {@linkplain State#Starting Starting} or {@linkplain State#Running Running}, this initiates service shutdown and returns immediately. If the service is {@linkplain State#New New}, it is {@linkplain State#Terminated Terminated} without having been started nor stopped. If the service has already been stopped, this method returns immediately without taking action.

doStart

This method is called by #start to initiate service startup.

This method returns Promise which should resolve when the service is operational or reject with the reason of failure.

It is invoked exactly once on service startup, even when #start is called multiple times.

doStop

This method should be used to initiate service shutdown.

This method returns Promise which should resolve when the service is has shut down or reject with the reason of failure.

doCancel

This method should be used to cancel service startup if #stop() is called before the service has transitioned to #Running

This method returns Promise which should resolve when the service is has shut down or reject with the reason of failure.

resolve

A method to resolve the associated Promise with the value passed. If the promise is already settled it does nothing.

Type: function (any): void

Parameters

  • value any : This value is used to resolve the promise If the value is a Promise then the associated promise assumes the state of Promise passed as value.

reject

A method to reject the associated Promise with the value passed. If the promise is already settled it does nothing.

Type: function (any): void

Parameters

  • reason any : The reason for the rejection of the Promise. Generally its an Error object. If however a Promise is passed, then the Promise itself will be the reason for rejection no matter the state of the Promise.

promise

A newly created Promise object. Initially in pending state.

Type: Promise