@9r3i/mfirebase
v1.0.0-5
Published
Mobile Firebase
Downloads
11
Maintainers
Readme
Mobile Firebase
Simple way to use firebase library.
Usage
const Firebase=new MFirebase;
Firebase.init(firebaseConfig);
Primitive Usage
<script type="module" src="mfirebase.js"></script>
Installation
npm i @9r3i/mfirebase
Test
/* authentication */
const auth=new Firebase.Auth;
auth.createUser('[email protected]','password',pre);
auth.signIn('[email protected]','password',pre);
auth.signOut(pre);
/* database */
const db=new Firebase.DB('users'),
id='0001',
username='9r3i',
password=password;
db.set(id,{username:username,password:password},pre);
db.get(id,pre);
/* storage */
const storage=new Firebase.Storage('images'),
input=document.createElement('input');
storage.get('grey.jpg',url=>{
var img=new Image;
img.src=url;
img.style.maxWidth='300px';
document.body.appendChild(img);
});
document.body.appendChild(input);
input.type='file';
input.onchange=function(e){
var file=this.files[0],
fr=new FileReader;
fr.onloadend=function(e){
var data=e.target.result;
pre({
type:'reader',
data:file,
url_length:data.length,
upto:Math.ceil(data.length/file.size*100),
});
storage.set(file.name,data,pre);
};
fr.readAsDataURL(file);
};
/* output log */
function pre(e){
console.log(e);
}