2.4.1 • Published 5 years ago

tn-vue-lstore v2.4.1

Weekly downloads
-
License
MIT
Repository
-
Last release
5 years ago

Bundle Size

BabelMinifiedGzippedNote
Uncompiled5.35 Kb2.01 Kb
Polyfill2.55 Kb901 byteIncreased 31%
Compiled7.91 Kb2.91 KbCompressed 63%
Core JSMinifiedGzippedNote
Before12.6 Kb4.26 KbIncluding dependencies
core-js14.5 Kb5.02 KbIncreased 54%
After27.4 Kb9.27 KbCompressed 66%

Usage

import {
  lstore,     // lstore core
  lsInit,     // to initate lstore
  lsOptions,  // creating options (typescript helper)
  lsInstance, // creating an instance (typescript helper)
  lsSchema    // creating an schema (typescript helper)
} from 'tn-vue-lstore'

// Initiate lstore
let init = lsInit(options, ...instances[])

// Install the plugin
Vue.use(lstore, init)

lsOptions() - Typescript helper

lsOptions(UserOptions)

type UserOptions = {
  dev: {
    package: string
    loglimit?: number // 300
    loggerChunk?: number // 50
    disablelogging?: Method[] // ['get']
  }
  prod?: {} /* future plans */
}

Method list

lsInstance() - Typescript helper

lsInstance(UserInstance)

type UserInstance = {
  namespace: string
  schema: UserSchema
  storetype?: Storetype // 'local'
}

type Storetype = 'local' | 'session'

lsSchema() - Typescript helper

lsSchema(UserSchema)

type UserSchema = {
  [prop: string]: Schemaval
}

type Schemaval = Checker | Checker[] | SchemaSimple | SchemaNested

type SchemaSimple = {
  nested?: never
  default?: any
  checker?: Checker | Checker[]
  removable?: boolean
}

type SchemaNested = {
  nested: UserSchema
  unknown?: {
    keyname?: RegExp | RegExp[]
    checker?: Checker | Checker[]
  }
}

Checker list

Usage in Vue

/**
 * Namespace   : foo/bar
 * Schema path : baz > far
 **/
this.$lstore.foo.bar('baz.far').method()

/**
 * CheckError & Success callback
 * Only for setter methods (See Methods)
 **/
const cberror = function(){ ... }
const cbsuccess = function(){ ... }

this.$lstore.foo.bar('baz.far', cberror, cbsuccess).setter()

/**
 * Also lstore can be accessed as a global variable
 **/
$lstore

Method list

Devtools Commands

> $lstore
> $lstorelog
> $lstorelogFull

Checker list

  • String
  • Number
  • Boolean
  • Array
  • Object
  • RegExp
  • 'json'
  • 'null'
  • function(val){ return Boolean }

Method list

  • Getters
    • get()
    • getNest()
  • Setters
    • set(any)
    • setQuery(function)
    • increase(increaseby?)
    • decrease(decreaseby?)
    • push(...any[])
    • unshift(...any[])
    • pop(howmany?)
    • shift(howmany?)
  • Objs
    • assign({...})
    • remove(...keys[])
2.4.1

5 years ago

2.4.0

5 years ago

2.3.4

5 years ago

2.3.3

5 years ago

2.3.2

5 years ago

2.3.1

5 years ago

2.3.0

5 years ago

2.2.0

5 years ago

2.1.0

5 years ago

2.0.0

5 years ago

1.0.2

5 years ago

1.0.1

5 years ago

1.0.0

5 years ago