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

response-giver

v1.0.0

Published

A module that, given an error string, returns a response message

Downloads

1

Readme

response-giver

Response-giver is a typescript/javascript library that allows to get pre-configured response messages given an error string

Getting Started

After you installed response-giver using npm, you should expect to find a response-giver forder into node_modules directory.

An example on how to use response-giver in Typescript:

import * as responseGiver from "response-giver";

const dictionary : Object = {
    "An error message" : "A possible response"
}

responseGiver.setDictionary(dictionary);

const response : String = responseGiver.getMessage("An error message");

// Output: A possible response
console.log(response);

An example on how to use response-giver in Javascript:

"use strict";

Object.defineProperty(exports, "__esModule", { value: true });

var responseGiver = require("response-giver");

var dictionary = {
    "An error message": "A possible response"
};

responseGiver.setDictionary(dictionary);

var response = responseGiver.getMessage("An error message");

// Output: A possible response
console.log(response);

For further functionalities, please read the API.

API

setDictionary(_dictionary: object): void

This function allows to set a valid dictionary. The dictionary has to be a JSON where the value can belong to any type. For example:

const dictionary = {
    "Error 1" : "Response 1",
    "Error 2" : ["A", "B", "C"]
};

getMessage(error: string): any

This function returns a response based on the dictionary.

setLoggerLevel(level: string): void

This function allows to set the logger level. It can be: "none", "error", "warn", "info", "verbose", "debug" and "silly".

"error" is the default value.

on(event: string, handler: any): void

If you want to handle good or bad events of response-giver, you can use the on function to subscribe.

removeListener(event: string, handler: any): void

The counterparty of on function.

Running the tests

To run all unit tests, just type:

npm test

If you see green, everything is working as expected. If you see red, it means that there is some problem. If you are not trying to make changes to response-giver, the library could be corrupted. In this case, installing it again is strongly advised. However, if it keeps not working, please open an issue or propose a bugfix.

Versioning

SemVer is used for versioning.

License

This project is licensed under the ISC License - see the LICENSE.md file for details.