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

lookat

v0.1.0

Published

An observer/observable library

Downloads

2

Readme

LookAt

An observer/observable library

API

Observable

const counter = observable(0); // returns counter.$ ($ is the reactive value accessor making the reactivity explicit in the naming). To mutate, use counter.$++ for example const person = observable({ firstname: "Ayoub", age: 28 }); // returns counter.$.age...

Observe

const voidValue = observe(() => console.log(counter * 2)); // side effects const isPair = observe(() => counter % 2 === 0); // computed reactive value => returns observable value observe(() => { console.log(isPair.$) })

Utilities

unwrap(isPair) // returns raw value of an observable

TODO

  • [x] Enable object like observable source
  • [x] Enable Array observable source
  • [ ] Enable Map observable source
  • [ ] Enable Set observable source
  • [x] Enable delete operator and other missing trap operators
  • [x] Do not call observers if impacted value is not modified (check inside the setter trap)
  • [x] Batch observer calls:
    • Avoid multiple same consecutive observable updates to trigger multiple observer calls (it should call one time): const counter = observable(0); const handleAdd = () => { <- Should be batched counter.$++; counter.$++; } observe(() => { counter.$ // <- Should be called one time and not two })
    • Optimize same observer calls if the side effect relies on computed observables const counter = observable(0); const counterSquare = observe(() => counter.$2); observe(() => { console.log("Counter Quatro = ", counter.$, " ", counterSquare.$); }); // => Currently, it's called two times since the observer relies on two observables but it could be improved with some predicates to be called once
  • [ ] Performance/Memory benchmark
  • [ ] Readme + Hosted documentation

Notes

Direct access via counter instead of counter.$ and non reactivity inside observe callback

API limitations and caveats with object like observable:

👉 Updates are always notified from top to bottom. Updating a child property won't notify its parent observers. But a parent update (such a new reference through object affectation) will notify its child property observers. And it's quite natural and aligned with JS runtime: => value and reference are managed from top to bottom: a child cannot update its parent reference.

👉 Parent update (eg. new object affectation) will notify its child observers if and only if all accessors to reach the targetted child property are specified inside the observe callback:

❌ const state = person.$ ❌ observe(() => { state.firstName }) ❌ person.$ = { firstName: "New" } ❌ // The observe callback won't be called

✔️ observe(() => { person.$.firstName }) ✔️ person.$ = { firstName: "New" } ✔️ // The observe callback will be called