Skip to content

Safe Firebase keys as it doesn't like ., $, #, [, ], or /. in it's keys

License

Notifications You must be signed in to change notification settings

yieme/firebase-safekey

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

25 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

firebase-safekey

Safe Firebase keys as it doesn't like ., $, #, [, ], or /. in it's keys

Installation

This module is installed via npm:

npm i firebase-safekey --save

Example Usage

var fkey     = require('firebase-safekey')
var safekey  = fkey.safe('hello.world') // hello<>dworld
var restored = fkey.restore(safekey)    // hello.world

Safe key an object

var obj      = { 'key#1': 'value1', 'key[2]': 'value2' }
var safekeys = fkey.safe(obj)         // { 'key<>p1': 'value1', 'key<>o2<>c': 'value2' }
var restored = fkey.restore(safekeys) // { 'key#1': 'value1', 'key[2]': 'value2' }

Configure key mapping

fkey.config({ // default mapping
  '.': '<>d',
  '$': '<>s',
  '#': '<>p',
  '[': '<>o',
  ']': '<>c',
  '/': '<>S'
})

Or apply your mapping during safe, restore operations

var safekey   = fkey.safe('1.1.2',   { '.': ':' }) // 1:1:2
var restored = fkey.restore(safekey, { ':': '.' }) // 1.1.2

Rights

Copyright (C) 2015 by yieme, License: MIT

About

Safe Firebase keys as it doesn't like ., $, #, [, ], or /. in it's keys

Resources

License

Stars

Watchers

Forks

Packages

No packages published