npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

bamfstore

v0.3.1

Published

Easy Data Component Transfer

Downloads

6

Readme

Bamf-Store

Simple state management with minimalistic API. This is similar to how mongoose / sequalize (any orm) accesses and uses data on the backend. Bringing this functionality to the frontend is game changer since anyone familiar with an orm can ump right in.

Installation

npm i bamfstore

Purpose

This is made to access and store data in the browser that is easily retrieved from different components in Angular. This is very similar to a model base system like an ODM. the syntax is very similar to mongoose. It stores the data as a json string in the browser, and then queries and parses it to retrieve the data. This helps eliminate the need for redundant Http requests, and also complex ways of storing and retrieving data. This uses already familiar known backend language.

If you refresh the browser the data still exists inside, and is easily retrievable. Pretty awesome!

Example Model

import { Model } from 'bamfstore';

export class User extends Model {
    first;
    last;
    static SCHEMA = {
        _id:{type:'string', primary:true},
        first:{type:'string'},
        last:{type:'string'},
    }


    fullname(){
        return this.first + ' ' + this.last;
    }

}

Example Component

import { User } from './../models/user.model';

ngOnInit() {

  let user1 = User.findOneAndUpdate({first:'Scott', last:'Thomas'}, {}, {upsert:true});
  let user2 = User.findOneAndUpdate({first:'Brian', last:"Alois"},{}, {upsert:true});

  console.log('user1', user1.fullname());
  console.log('user2', user2.fullname());

  user1.first = 'Jordan';
  user1.save();

  console.log('user1', user1.fullname());
}

Instance Methods

save

saves instance in web storage

let company = Company.findOne({name:'facebook'});
company.value = 500;
company.save()

remove

Removes object from web storage

let company = Company.findOne({name:'facebook'});
company.remove()

toObject

converts model to Javascript Object

let company = Company.findOne({name:'facebook'});
obj = company.toObject();

reload

reloads models instance data to match what is in browser storage

let company = Company.findOne({name:'facebook'});
company.name = 'google';
company.reload()
console.log(company.name); // will print out facebook

company.name = 'google';
company.save()
console.log(company.name); // will print out google

storage and instance differences

reloads models instance data to match what is in browser storage

let company = Company.findOne({name:'facebook'});
company.name = 'google';

let storage_dif = company.storageDifference();
console.log(storage_dif);//log {name:'facebook'}

let instance_dif = company.instanceDifference();
console.log(instance_dif);//log {name:'google'}

Instance Hooks

onSave

company.onSave(()=>{
    console.log('company was saved');
});

or

company.on('save', ()=>{
    console.log('company was saved');
});

onRemove

company.onRemove(()=>{
    console.log('company was deleted');
});

or

company.on('remove', ()=>{
    console.log('company was deleted');
});

onReload

company.onReload(()=>{
    console.log('company was reloaded');
});

or

company.on('reload', ()=>{
    console.log('company was reloaded');
});

onChange

company.onChange(()=>{
    console.log('company was changed');
});

or

company.on('change', ()=>{
    console.log('company was changed');
});

Static Methods

create

creates new Instance of model

let company = Company.create({name:'google', value:'600'})

remove

Removes all instances with the given value from web storage

Company.remove({name:'microsoft'})

update

Updates all instances with given value in web storage Company.update([query params], [new_data])

Company.update({value:500}, {name:'Orange'});

updateOne

Updates one instances with given value in web storage Company.update([query params], [new_data])

Company.updateOne({value:500}, {name:'Orange'});

find

returns an array of company instances with given value from web storage

let companies = Company.find({value:500});

findOne

returns an instance with given value from web storage

let company = Company.findOne({value:500});

findOneAndUpdate

Searches web storage for instance and then updates it. if option upsert is set to true, if it doesn't find the instance with the given object in web storage, it will create it.

let user1 = User.findOneAndUpdate({first:'Scott', last:'Thomas'}, {}, {upsert:true});

findById

returns one instance with given id in webstorage

let user1 = User.findById(2);

Static Hooks

onCreate

Company.onCreate(()=>{
    console.log('A company was created and added to the web storage');
});

onRemove

Company.onRemove(()=>{
    console.log('a company was removed');
});

onChange

company.onChange(()=>{
    console.log('any company was changed');
});