0.2.5 • Published 7 years ago

qm-state-simple v0.2.5

Weekly downloads
1
License
MIT
Repository
github
Last release
7 years ago

logo-qm

qm-state-simple npm version Build Status code style: prettier

Simple and flexible state contener for simple apps.

Installation

Using npm:

$ npm i -S qm-state-simple

Usage

import { createState, addOptions, returnAPI, getVersion } from 'qm-state-simple'

const state = createState();

Creates default state object:

{
  cwd: ...              // absolute current working directory path
  dryRun: false,        // flag for switching I/O operations
  logger: fales,        // placeholder for external logger 
  exposeState: false, 
  mwd: ...              // absolute module working directory (__dirname) path
  silence: false        // silence all logging
};

Additional state properties

You can add custom properties to state by passing args object:

const args = { feed: true };

const state = createState(args);

Add options

Additional options can be also added by using addOptions() method:

const newState = addOptions(state, { someOption: true});

Return API

At the end of app execution there is possibility of return different forms of state by using returnAPI() method:

const stateToReturn = returnAPI(state, result) // => {result}

When exposeState flag is set on true then:

const stateToReturn = returnAPI(state, result) // => {result, state}

Get version

Use getVersion() method to pull from app version from package.json file. Version number is written to the state in version property.

const updatedState = getVersion(state);

Above method returns Pormise object.

Tests

Run npm script for performing tests:

npm run start:test

License

MIT © qaraluch

0.2.5

7 years ago

0.2.4

7 years ago

0.2.3

7 years ago

0.2.2

7 years ago

0.2.1

7 years ago

0.2.0

7 years ago

0.1.2

7 years ago

0.1.1

7 years ago

0.1.0

7 years ago