New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

@barbuza/kebakaran

Package Overview
Dependencies
Maintainers
1
Versions
5
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@barbuza/kebakaran

strongly typed high level utilities for consuming data from firebase

  • 2.4.0
  • latest
  • npm
  • Socket score

Version published
Maintainers
1
Created
Source

kebakaran

Build Status Coverage Status Npm package

strongly typed high level utilities for consuming data from firebase

usage

following firebase data

{
  "ages": {
    "1": 10,
    "2": 20
  },
  "names": {
    "1": "foo",
    "2": "bar"
  },
  "users": {
    "1": true,
    "2": true
  }
}

may be accessed like that

Struct

import { Struct, Transform } from "kebakaran";

const database = firebase.database();

interface IUserData {
  age: number | undefined;
  name: string | undefined;
}

const struct = new Struct<IUserData>({
  age: Transform.val(database.ref("ages").child("1")),
  name: Transform.val(database.ref("names").child("1")),
});

struct.on("value", (value: IUserData) => {
  // handle data
});

List

import { Emitter, List, Struct, Transform } from "kebakaran";

const database = firebase.database();

interface IUserData {
  age: number | undefined;
  name: string | undefined;
}

interface IUser extends IUserData {
  id: number;
}

function makeUserData(userId: string): Emitter<IUserData> {
  return new Struct<IUserData>({
    age: Transform.val(database.ref("ages").child(userId)),
    name: Transform.val(database.ref("names").child(userId)),
  });
}

function makeUser(userId: string): Emitter<IUser> {
  return new Transform<IUserData, IUser>(makeUserData(userId), (userData) => ({
    age: userData.age,
    id: parseInt(userId, 10),
    name: userData.name,
  }));
}

const userListRef = Transform.keys(database.ref("users"));
const list = new List<string, IUser>(userListRef, makeUser);

list.on("value", (value: IUser[]) => {
  // handle data
});

FAQs

Package last updated on 28 Dec 2017

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc