1.0.12 • Published 6 years ago

util-box v1.0.12

Weekly downloads
3
License
MIT
Repository
github
Last release
6 years ago

Build Status

A minimal toolbox of helper methods

Usage

Add util-box to your project

$ npm install --save util-box

HTTP Handling

Minimal utility methods for HTTP Requests and Responses.

Http Util Example

Output Handling

Methods for color-coded logging.

Output Util Example

StopClock

Methods for logging how long an operation runs for.

Stop Clock Util

File Handling

Methods for basic file reading, writing, deleting, truncating

File Util

Documentation

httpUtil.removeTrailingSlash(url)

Removes a trailing slash from the end of a url, if present.

httpUtil.makeQueryString(reqParams)

Converts request parameters into a queryString. The input reqParams is an object with key-value pairs of each query parameter and their corresponding values.

httpUtil.handleApiResponse(response)

This handles a generic Api Response from different request libraries by returning a Promise. Additionally, it also rejects with an error for non-2xx responses.

outputUtil.success(message)

Logs the specified message to stdout in chalk green.:

outputUtil.error(message)

Logs the specied message to stdout as an error in chalk red.

outputUtil.debug(message)

Logs the specified message to stdout in chalk grey, only if the DEBUG variable is set in process.env

fileUtil.readFile(fileName, type)

type (optional) denotes char-set, default="UTF-8"

Read from an existing file. Returns a promise resolved with the data read from the file.

fileUtil.writeFile(fileName, data)

Create/write to a file. Returns a promise with the fileName after successfully writing to file.

fileUtil.truncateFile(fileName)

Truncates / Empties the contents of a file

fileUtil.deleteFile(fileName)

Deletes the specified file

1.0.12

6 years ago

1.0.11

6 years ago

1.0.10

6 years ago

1.0.9

6 years ago

1.0.8

6 years ago

1.0.7

6 years ago

1.0.6

6 years ago

1.0.5

6 years ago

1.0.4

6 years ago

1.0.3

6 years ago

1.0.2

6 years ago

1.0.1

6 years ago

1.0.0

6 years ago