wwl-js-utils

0.1.3 • Public • Published

WWL JS Utils

Current Version Master Develop
npm version Build Status Build Status

settings

Loading configurations/settings over cookie or script tag or by passing in the config directly.

Options

new (require('wwl-js-utils/lib/settings'))({
  # one of those is required: 
  data:         { test: 1 }
  cookieKey:    'id-of-config-cookie-key'
  selectorId:   'id-of-config-script-tag'
 
  # optional: 
  defaults:     { some: 'defaults' }    # default: {} 
  base64:       false                   # default: false 
  removeAfterParse: true                # default: true 
})

If you pass in data, selectorId and cookieKey, data will be used. If you pass selectorId and cookieKey, cookieKey will be used.

Getting config attributes

data =
  a:
    b: 1
    c:
      d: '2'
    e:
      f: 4
      g: false
 
config = new (require('wwl-js-utils/settings'))({ data: data })
 
config.get('a').b     # 1 
config.get('a').c.d   # '2' 
config.get('a').e.f   # 4 
config.get('a').e.g   # false 
config.get('a.b')     # 1 
config.get('a.c.d')   # '2' 
config.get('a.e.f')   # 4 
config.get('a.e.g')   # false 
 

Readme

Keywords

none

Package Sidebar

Install

npm i wwl-js-utils

Weekly Downloads

0

Version

0.1.3

License

MIT

Last publish

Collaborators

  • cocodercoder
  • wwlromain
  • wwlsascha