Options
All
  • Public
  • Public/Protected
  • All
Menu

Build Status Greenkeeper badge Maintainability Coverage Status

NPM package

MetaphaseJS

Super easy, efficient and agnostic state management for Javascript

Demo

Usage

// Install
yarn add metaphasejs // Yarn
npm install metaphasejs // NPM

// Build
yarn / npm build

// Test
yarn / npm test

API Docs

Packages Analysis

  • Without gzip compression: Link

Test Coverage

Contributing

  1. Fork it
  2. Create your feature branch: git checkout -b my-new-feature
  3. Commit your changes: git commit -am 'Add some feature'
  4. Push to the branch: git push origin my-new-feature
  5. Submit a pull request :D

Caveats

  • IMPORTANT: at this moment MetaphaseJS is not totally compatible with create-react-app (CRA) . The use of constructor.name breaks the compiled code by the CRA build script. The uglifying process has to be made with an ad hoc script called build.js. This script avoids to mangle funcion names using the option mangle: {keep_fnames: true}. Open an issue for more information. Pull requests are welcome.
  • At this moment there are not polyfills for old browsers, but there will be in the future.
  • If Typescript and decorators are used, its configuration file tsconfig.json must have:
    • experimentalDecorators = true
    • emitDecoratorMetadata = true
    • If flag strict = true is used, model properties (columns in db) must be initialized with values

License

MIT

Back to top ↑

Index

Variables

Const DEFAULT_LOG_STATE

DEFAULT_LOG_STATE: string = "false"

Controls default logger behaviour. Pass a 'false' value to avoid logger. This is the desired behaviour for production.

type

{string}

Const FileSaver

FileSaver: any = require('file-saver')

Const SQL

SQL: any

Const knex

knex: any = require('knex')

Let queryBuilder

queryBuilder: any

Const sql

sql: any = require('sql.js')

Let urlLogParam

urlLogParam: string = getUrlParameter('logger')

Functions

column

  • column(colData?: undefined | object): (Anonymous function)
  • Parameters

    • Optional colData: undefined | object

    Returns (Anonymous function)

disableConsole

  • disableConsole(): void
  • Disables console output messages (except error). Used for production mode

    Returns void

getDBTypeFromPropType

  • getDBTypeFromPropType(jsPropType?: undefined | string): DBtype
  • Maps javascript model prop type to SQLite column type.

    Type correspondence:

    Javascript type SQLite type

    number REAL, INTEGER boolean INTEGER string TEXT Array Uint8Array BLOB

    null NULL

    Ref.: https://www.sqlite.org/datatype3.html

    Parameters

    • Optional jsPropType: undefined | string

      JavaScript type

    Returns DBtype

    DBtype SQLite type

Const getUrlParameter

  • getUrlParameter(paramName: string): string
  • Gets url query parameter form URL

    Parameters

    • paramName: string

    Returns string

Const loadDbFromFile

  • loadDbFromFile(fileNamePath: string, actionFn: Function): void
  • Parameters

    • fileNamePath: string
    • actionFn: Function

    Returns void

log

  • log(msg: string, format: string): void
  • General Fn to apply format to a log message

    Parameters

    • msg: string
    • format: string

    Returns void

logQuery

  • logQuery(msg: string, format: "query" | "result" | string): void
  • Logs sql query strings and query results, appling two formats: Input (query): blue colors Output (result): yellow colors

    Parameters

    • msg: string
    • format: "query" | "result" | string

    Returns void

Const saveDbToFile

  • saveDbToFile(fileNamePath: string): void

updateQueryStringParameter

  • updateQueryStringParameter(uri: string, key: string, value: string): string
  • Update query string parameter

    Parameters

    • uri: string
    • key: string
    • value: string

    Returns string

Object literals

Const LOG_FORMAT

LOG_FORMAT: object

Logs message formats: foreground color, background color CSS syntax is used to format messages

type

{Object}

BG_YELLOW

BG_YELLOW: string = "background-color: yellow"

BLUE

BLUE: string = "background: ghostwhite; color: cornflowerblue; font-size: 12px; font-weight: bold"

ORANGE

ORANGE: string = "color: orange"

Legend

  • Module
  • Object literal
  • Variable
  • Function
  • Function with type parameter
  • Index signature
  • Type alias
  • Enumeration
  • Enumeration member
  • Property
  • Method
  • Interface
  • Interface with type parameter
  • Constructor
  • Property
  • Method
  • Index signature
  • Class
  • Class with type parameter
  • Constructor
  • Property
  • Method
  • Accessor
  • Index signature
  • Inherited constructor
  • Inherited property
  • Inherited method
  • Inherited accessor
  • Protected property
  • Protected method
  • Protected accessor
  • Private property
  • Private method
  • Private accessor
  • Static property
  • Static method

Generated using TypeDoc