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

gun-synclist

v1.0.2

Published

Gun module

Downloads

12

Readme

gun-synclist

Intro

gun-synclist is a module for Gun(^0.9.x) using Gun.chain. It is basicly the same as the open() module included in Gun/lib. But where open() gives you the full document ( Object ) on every change, gun-synclist behaves a little different.

  • On initial run gun-synclist will return the full set as an Array! ( including the internally used 'lookup' { soul:index })

  • On every change after the initial run it only returns the changed node. but...It gives you the soul of the node, the index in the Array and the full node ( Yeah...including nested properties )

    eg: { soul: "AbCd123..." ,idx: 112, node: {...}

Why?

If you have a list with a lot of items you don't want to rebuild your DOM on every change. Instead you only need to change the changed item.

eg: items.splice( idx,1,node )

What you could do with gun-synclist

Setup

Prerequisites

You need Gun ^0.9.x

 npm install gun-synclist

Node.js

var Gun = require('gun');
require('gun-synclist');

Browser

Just include it as a script tag, and gun-synclist takes care of the rest.

<!-- AFTER you load Gun -->
<script src="node_modules/gun-synclist/gun-synclist.js"></script>

Example

Not much to it..

var items;
var gun = Gun();
var CONTACTS = gun.get('CONTACTS');
CONTACTS.set( { name:'Stefdv',age: 44,profile:{email:"[email protected]"}} )

CONTACTS.synclist( obj => {
  if(obj.list) {
    // initial only!
    items = obj.list;
  } 
  if(obj.node) {
    // on every change.
    items.splice(obj.idx,1,obj.node)
  }
})

Note:

gun-synclist will automatically load everything it can find on the context. This may sound convenient, but may be unnecessary and excessive - resulting in more bandwidth and slower load times for larger data. It could also result in your entire database being loaded, if your app is highly interconnected. Therefore gun-synclist should be used on a set.

That being said... tell me what you want to do and - maybe- i can advise you. I'm not much of an email reader so ping me in gitter @Stefdv

Credits

Thanks to Mark Nadal for writing Gun and for helping out whenever i need.