@9r3i/mfirebase

1.0.0-5 • Public • Published

Author License Forks Stars Issues Release Package

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@gmail.com','password',pre);
auth.signIn('email@gmail.com','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);
}

Package Sidebar

Install

npm i @9r3i/mfirebase

Weekly Downloads

2

Version

1.0.0-5

License

MIT

Unpacked Size

10.9 kB

Total Files

5

Last publish

Collaborators

  • 9r3i