Ecosyste.ms: Awesome

An open API service indexing awesome lists of open source software.

Awesome Lists | Featured Topics | Projects

https://github.com/berkmann18/nclr

Mini NPM package with coloured log functions
https://github.com/berkmann18/nclr

colors colours console log npm

Last synced: 13 days ago
JSON representation

Mini NPM package with coloured log functions

Awesome Lists containing this project

README

        

# nclr

[![NPM](https://nodei.co/npm/nclr.png)](https://nodei.co/npm/nclr/)

[![GitHub package version](https://img.shields.io/github/package-json/v/Berkmann18/nclr.svg)](https://github.com/Berkmann18/nclr)
[![devDependencies Status](https://david-dm.org/berkmann18/nclr/dev-status.svg)](https://david-dm.org/berkmann18/nclr?type=dev)
[![dependencies Status](https://david-dm.org/berkmann18/nclr/status.svg)](https://david-dm.org/berkmann18/nclr)

[![GH Downloads](https://img.shields.io/github/downloads/Berkmann18/nclr/total.svg)](https://github.com/Berkmann18/nclr/network/members)
[![GitHub commit activity the past year](https://img.shields.io/github/commit-activity/y/Berkmann18/nclr.svg)](https://github.com/Berkmann18/nclr/graphs/commit-activity)
[![GitHub contributors](https://img.shields.io/github/contributors/Berkmann18/nclr.svg)](https://github.com/Berkmann18/nclr/graphs/contributors)
[![Github search hit counter](https://img.shields.io/github/search/Berkmann18/nclr/goto.svg)](https://github.com/Berkmann18/nclr/graphs/traffic)

[![Build Status](https://travis-ci.org/Berkmann18/nclr.svg?branch=master)](https://travis-ci.org/Berkmann18/nclr)
[![codecov.io Code Coverage](https://img.shields.io/codecov/c/github/Berkmann18/nclr.svg?maxAge=2592000)](https://codecov.io/github/Berkmann18/nclr?branch=master)
[![tested with jest](https://img.shields.io/badge/tested_with-jest-99424f.svg)](https://github.com/facebook/jest)
[![Known Vulnerabilities](https://snyk.io/test/github/Berkmann18/nclr/badge.svg?targetFile=package.json)](https://snyk.io/test/github/Berkmann18/nclr?targetFile=package.json)

[![GitHub](https://img.shields.io/github/license/Berkmann18/nclr.svg)](https://github.com/Berkmann18/nclr/blob/master/LICENSE)
[![contributions welcome](https://img.shields.io/badge/contributions-welcome-brightgreen.svg?style=flat)](https://github.com/Berkmann18/nclr/issues)
[![Commitizen friendly](https://img.shields.io/badge/commitizen-friendly-brightgreen.svg)](http://commitizen.github.io/cz-cli/)

[![GitHub top language](https://img.shields.io/github/languages/top/Berkmann18/nclr.svg)](https://github.com/Berkmann18/nclr)
[![GitHub language count](https://img.shields.io/github/languages/count/Berkmann18/nclr.svg)](https://github.com/Berkmann18/nclr)
[![GitHub code size in bytes](https://img.shields.io/github/languages/code-size/Berkmann18/nclr.svg)](https://github.com/Berkmann18/nclr)

[![BCH compliance](https://bettercodehub.com/edge/badge/Berkmann18/nclr?branch=master)](https://bettercodehub.com/results/Berkmann18/nclr)
[![Codacy Badge](https://api.codacy.com/project/badge/Grade/2a8e3e98d3bb47f29abbc3df7174675d)](https://app.codacy.com/app/maxieberkmann/nclr?utm_source=github.com&utm_medium=referral&utm_content=Berkmann18/nclr&utm_campaign=Badge_Grade_Dashboard)

Mini NPM package with coloured log functions and more.

# Contributions

Please refer to [the contribution guideline](.github/CONTRIBUTING.md).

## Contributors

| [
Maximilian Berkmann](http://maxcubing.wordpress.com)
[🐛](https://github.com/Berkmann18/nclr/issues?q=author%3ABerkmann18 "Bug reports") [💻](https://github.com/Berkmann18/nclr/commits?author=Berkmann18 "Code") [📖](https://github.com/Berkmann18/nclr/commits?author=Berkmann18 "Documentation") [🤔](#ideas-Berkmann18 "Ideas, Planning, & Feedback") [💬](#question-Berkmann18 "Answering Questions") [👀](#review-Berkmann18 "Reviewed Pull Requests") [🛡️](#security-Berkmann18 "Security") [⚠️](https://github.com/Berkmann18/nclr/commits?author=Berkmann18 "Tests") | [
Dependabot](https://dependabot.com)
[🔧](#tool-dependabot-bot "Tools") | [
Semantic Release Bot](http://semantic-release.org/)
[📖](https://github.com/Berkmann18/nclr/commits?author=semantic-release-bot "Documentation") [📦](#platform-semantic-release-bot "Packaging/porting to new platform") | [
Codacy Badger](https://www.codacy.com)
[📖](https://github.com/Berkmann18/nclr/commits?author=codacy-badger "Documentation") |
| :--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------: | :-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------: | :--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------: | :-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------: |

# Documentation

### Table of Contents

- [index](#index)
- [Parameters](#parameters)
- [error](#error)
- [Parameters](#parameters-1)
- [Examples](#examples)
- [info](#info)
- [Parameters](#parameters-2)
- [Examples](#examples-1)
- [dbg](#dbg)
- [Parameters](#parameters-3)
- [Examples](#examples-2)
- [out](#out)
- [Parameters](#parameters-4)
- [Examples](#examples-3)
- [inp](#inp)
- [Parameters](#parameters-5)
- [Examples](#examples-4)
- [warn](#warn)
- [Parameters](#parameters-6)
- [Examples](#examples-5)
- [quest](#quest)
- [Parameters](#parameters-7)
- [Examples](#examples-6)
- [succ](#succ)
- [Parameters](#parameters-8)
- [Examples](#examples-7)
- [extend](#extend)
- [Parameters](#parameters-9)
- [Examples](#examples-8)
- [clr](#clr)
- [clr](#clr-1)
- [lib](#lib)
- [log](#log)
- [Parameters](#parameters-10)
- [Examples](#examples-9)
- [use](#use)
- [Parameters](#parameters-11)
- [Examples](#examples-10)
- [restoreTheme](#restoretheme)

## index

Set of functions for coloured logs.

### Parameters

- `data` **...any**

## error

- **See: log**

Print an error.

### Parameters

- `data` **...any** Data to print

### Examples

```javascript
error('Something wrong happened with', new Error(this));
```

Returns **[boolean](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Boolean)** Did it happened?

## info

- **See: log**

Print an information.

### Parameters

- `data` **...any** Data to print

### Examples

```javascript
info('Welcome John');
```

Returns **[boolean](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Boolean)** Did it happened?

## dbg

- **See: log**

Print a debug message.

### Parameters

- `data` **...any** Data to print

### Examples

```javascript
dbg('i=', i);
```

Returns **[boolean](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Boolean)** Did it happened?

## out

- **See: log**

Print an output.

### Parameters

- `data` **...any** Data to print

### Examples

```javascript
out(`1 + 1 = ${rpc('1 1 +')}`);
```

Returns **[boolean](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Boolean)** Did it happened?

## inp

- **See: log**

Print an input.

### Parameters

- `data` **...any** Data to print

### Examples

```javascript
inp(name);
```

Returns **[boolean](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Boolean)** Did it happened?

## warn

- **See: log**

Print a warning.

### Parameters

- `data` **...any** Data to print

### Examples

```javascript
warn('The following function is deprecated');
```

Returns **[boolean](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Boolean)** Did it happened?

## quest

- **See: log**

Print a question.

### Parameters

- `data` **...any** Data to print

### Examples

```javascript
quest('What is your username?');
```

Returns **[boolean](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Boolean)** Did it happened?

## succ

- **See: log**

Print a success log.

### Parameters

- `data` **...any** Data to print

### Examples

```javascript
succ('Achievement unlocked');
```

Returns **[boolean](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Boolean)** Did it happened?

## extend

Extend the current theme.

### Parameters

- `extension` **{string: ([string](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/String) \| [Array](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Array)<[string](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/String)>)}** Theme to add

### Examples

Using extensions as methods:

```javascript
const nclr = require('nclr');
nclr.extend({
suc: ['green', 'underline'],
data: 'magenta'
});
nclr.suc('Yay!');
nclr.data(42);
```

Using extensions as functions:

```javascript
const nclr = require('nclr');
nclr.extend({
suc: ['green', 'underline'],
data: 'magenta'
});
const { suc, data } = nclr;
suc('Yay!');
data(42);
```

- Throws **[Error](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Error)** Invalid extension key

## clr

CLI colours.

## clr

Colour/style theme for the CLI.

Type: {inp: [string](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/String), out: [Array](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Array)<[string](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/String)>, info: [string](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/String), error: [string](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/String), warn: [string](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/String), dbg: [string](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/String), quest: [string](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/String)}

## lib

Set of library functions for nclr.

## log

STDOUT log.

### Parameters

- `data` **any** Data to print

### Examples

```javascript
log('Lorem ipsum dolore sit amet');
```

Returns **[boolean](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Boolean)** Did it happened?

## use

Colourise something.

### Parameters

- `name` **[string](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/String)** Name of the log in the theme
- `data` **...any** Data

### Examples

```javascript
let information = use('info', 'Some info styled text');
```

Nesting

```javascript
log('Something', use('warn', 'really ', use('info', 'cool!')));
```

- Throws **[Error](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Error)** Invalid name

Returns **[string](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/String)** Coloured output

## restoreTheme

Restore the default fields of the theme.