# just-simple

> Simple utilities for diagnostics and logging

Latest version **0.2.0** (published 2024-12-10) · MIT license · 0 weekly downloads

## Install

```sh
npm install just-simple
pnpm add just-simple
yarn add just-simple
bun add just-simple
```

## Health

**Score 25/100 (F)** — status: maintenance-mode.

Positive: no vulnerabilities.

Warnings: low downloads; no types; no esm support; pre 1.0.

Negative: stale; low maintenance score.

## Facts

| | |
|---|---|
| Version | 0.2.0 |
| Published | 2024-12-10 |
| First published | 2019-09-26 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 0 |
| Unpacked size | 11.6 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| Author | Karl Lew |
| Maintainers | firepick |
| Keywords | Javascript |

## Links

- npm: https://www.npmjs.com/package/just-simple
- Homepage: https://github.com/oyamist/just-simple
- npm.io page: https://npm.io/package/just-simple

## Recent versions

- 0.2.0 (latest) — 2024-12-10
- 0.1.11 — 2020-07-19
- 0.1.10 — 2020-05-31
- 0.1.9 — 2020-04-10
- 0.1.8 — 2019-11-30
- 0.1.7 — 2019-11-28
- 0.1.6 — 2019-10-31
- 0.1.5 — 2019-10-31
- 0.1.4 — 2019-10-10
- 0.1.3 — 2019-10-07
- 0.1.2 — 2019-10-06
- 0.1.1 — 2019-09-26
- 0.1.0 — 2019-09-26

## README

Simple utilities for diagnostics and logging

### Installation

```bash
git clone https://github.com/oyamist/just-simple.git
cd just-simple
npm install
npm run test
```

### Example `simpleString(value)`
Use `js.simpleString` to generate a simple string for a data value:

```js
const { js } = require('just-simple').JustSimple;
var addr = {city: "SFO");
js.simpleString(addr); // {city:SFO}
```

You can override the `toString` method of a class to print it simply:

```js
    class Observation {
        constructor(tag, value, text) {
            this.tag = tag;     // an important attribute
            this.value = value; // an important attribute
            this.text = text;   // annotational attribute
        }

        toString() {
            var {
                tag,
                value,
            } = this;
            return `<${tag}:${js.simpleString(value)}>`;
        }
    }

    var ob1 = new Observation('size', 42, 'a universal dimension');
    js.simpleString(ob1); // <size:42>
```

Here is a simple string for a complex value:

```js
var ob2 = new Observation('address', addr, 'an object');

js.simpleString([ob1,[ob2]]);
// [[<size:42>], <address:{city:SFO}>]
```

### Example `logger`
Setting up Winston consistently across different packages is tedious. 
JustSimple.logger provides a bare-bones utilitarian Winston logger instance.

```js
const { logger } = require("just-simple").JustSimple;

logger.info("Hello world");
// 20190926 08:40:17 I Hello world
```

### Example `LOCAL_DIR`
NodeJs applications often need application local file storage. 
Since the application folder is a well-known location created 
during `git clone ...`, it's simple and convenient to just create
a `local` folder for application local file storage.
Adding `local/` to `.gitignore` assures that the contents of `local` remain local.
This convention can also work for NodeJs libraries that store
information in the calling application's `local` folder.
`JustSimple.LOCAL_DIR` returns the application's local folder
for a NodeJs library or application.

```js
const { LOCAL_DIR } = require('just-simple').JustSimple;
```

---
_Source: https://npm.io/package/just-simple · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
