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

partial-obj

v1.0.3

Published

Manipulate some objects that are not finished yet and that wait for other objects to be finished (or created).

Downloads

7

Readme

Naming :

Hydration :

Providing a Resource to a PartialItem. So a Hydrator has an attribute "target" and will only interact with that target.

Irrigation :

Providing a Resource to a bunch of PartialItems. Contrary to Hydrators, Irrigators doesn't have a target and will instead provide Resources to every PartialItems that are interested.

Introduction :

A PartialObj is a wrapper around an object. It represents an object that is not "finished".

What is an unfinished object :

In short, an object is considered as "unfinished" if some of its attributes contains some objects that are themselves unfinished OR contains some objects that doesn't even exist yet (only a string to refer to an object).

So in reality, an object is unfinished if it contains any unfinished Field (a Field is representation of a single attribute of a PartialObj). A Field is unfinished if it contains an object that it itself unfinished OR if it only contains a Reference to an object (explained later).

Hydrator :

The purpose of a Hydrator is to provide some Resources to a set of PartialObjs and/or PartialLists. You should use the class Hydrator to create a new Hydrator. Classes named "RestrictedHydrator", "HydrationsManager" and "VersatileHydrator" are utilities used by the parent class Hydrator.

Do not manually provide Resources to PartialObjs :

You should not ever manually provide Resources to a PartialObj. Instead, always use an instance of Hydrator.

Specific cases and default patterns :

Transform a Rough-Resource into a Resource :

Some methods of Hydrator to provide Rough-Resources will automatically upgrade those Roughs to Resources when possible. To do so, the default pattern is to replace the Rough Resource by a Resource whose value equal to Rough.core.

However, that might not be the expected pattern. Most likely if you want your Resource to be typed instances. In that case you should do stuff in a more imperative approach :

  • Create you PartialObj

Mutable PartialObj vs Static PartialObj :

A PartialObj is considered as mutable if some fields might be added to it. While it's mutable, checking its status is never relevant (while it can change if some new fields are added to it). A PartialObj doesn't have any attribute to define it as mutable. This is defined when you add it to a Hydrator by calling the method addMutablePartialObj. You can then use the method freezeMutablePartialObj to define that it's not mutable anymore.

ProgressiveAsset :

It can be tedious to manage PartialObj that are used as Rough Resource. You might want to replace that Rough Resource by a Plain Resource when the PartialObj is fulfilled. You so need to add a listener for upgrades of the PartialObj to remove the previous Rough Resource. Maybe you want your Plain Resource to be typed. You so need to add some extra stuff in you upgrade callback. Using ProgressiveAsset is a utility to really simplify and abstract the work when you want to use a PartialObj as a Resource. It's named progressive because we expect it to become a Plain Resource.