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

brikz

v0.0.5

Published

Reconfigurable micro composition of object APIs

Downloads

5

Readme

Brikz

Reconfigurable micro composition system.

Why

The motivation for creating bricks was splitting big monolithic code into pieces. I wanted the tool that builds up an equvivalent of big legacy object (containing working code as well as API) from small parts. Additionally, I wanted to be able to change the parts involved at runtime (like, loading the system, then taking loader away). This is important not primarily from memory or performance PoV, even if it can help for embedded devices, but primarily from the design PoV. The less parts are actually needed to successfully run the system, the less spaghetti the code is. I also believe that trying to achieve this, I must do the refactorings that fix lots of other things in the code as a by-product.

What

Brikz is the system that assembles the resulting object (API) from parts. These parts are simply put into the brikz object. At any time you can reconfigure the parts (by simple assigment/deletion) and ask brikz object to rebuild; the rebuilding process reassembles the API object on the fly.

How

Brikz aims to be minimal, so just copy it and include it where appropriate (it is just one Brikz function). Then instantiate it:

  var api = {}/* skeleton of my object */;
  var brikz = Brikz(api);

Then, you should have some parts:

function Foo(brikz, api) {
  this.internalFoo = function () { ... }:
  api.publishedFoo = function () { ... }:
}

function Bar(brikz, api) {
  this.internalBar = function () { ... };
  api.publishedBar = function () {
    ...;
    // use brikz.foo and brikz.foo.internalFoo as you see fit
    // it now contains the object, not the factory
    // You can _not_ use api.publishedFoo directly in Bar,
    // but you can use it in any code to be run later.
    ...;
  };
}
Bar.deps = ["foo"];

The deps array synchronously tries to process part named foo before processing bar. Thus, if you have circular dependencies, you end up with stack overflow. Don't have them. :wink:

You then put the parts in brikz object, rebuild it and you have api ready for use:

  brikz.foo = Foo;
  brikz.bar = Bar;
  brikz();

  api.publishedBar(...);

You can add / delete / change parts later and call brikz again to rebuild. Parts that are not functions, are left as is (their internal as well as API part); parts that are functions are instantiated again and merged in. Parts that are nulled are removed.

Advanced use

TBD