Safe Firebase keys as it doesn't like ., $, #, [, ], or /. in it's keys
This module is installed via npm:
npm i firebase-safekey --save
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
Copyright (C) 2015 by yieme, License: MIT