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

multimix

v6.0.0

Published

Objects with auto-generated property chains

Downloads

105

Readme

MultiMix

Table of Contents generated with DocToc

MultiMix

  • Objects with auto-generated property chains

  • class Hedge

    • purpose: enable turning property access to function calls
      • propoerties may be predefined

      • or auto-generated, either

        • as plain objects
        • or by calling a custom factory function
      • example:

        handler = ( hedges, a, b, c ) ->
          log hedges, [ a, b, c, ]
          return null
        h = new Hedge { handler, }
        h.foo
        # [ 'foo',  ]
  • since hubs and properties are proxies, can do things on property access, no call needed, so both d.foo and d.foo 42 can potentially do things

  • cfg:

    • cfg.handler: mandatory property; function to be called on prop access, call, or both

      • d = new Multimix { handler, } returns the handler wrapped into a proxy
      • the Multimix instance is accessible as d[Multimix.symbol]. Multimix.symbol is a private symbol and thus guaranteed not to overwrite or shadow an existing property
      • existing properties of handler will be returned
      • non-existant properties of handler will be auto-generated on first access; these will be functions that, when called with any number of arguments f P..., will in turn call handler props, P...
      • handler will be called in the context of hub where given; otherwise, its context will be the Multimix instance.
    • hub: optional reference / base object (re 'hub': as if props were spokes)

    • cfg.create:

      • true (default): missing props will be auto-generated as functions that call handler in the context of cfg.hub where given (or else the Multimix instance)
      • false: no missing props will be generated
      • a function: to be called as create key, target when a new property is first accessed; this function may or may not create a new property as seen fit. The MultiMix proxy will, at any rate, return target[ key ] which may or may not be undefined.
    • cfg.strict: (default false) if set to true, trying to access an unset property will cause an error. This setting is only valid when used in conjunction with create: false.

    • cfg.oneshot: (default false) if set to true, trying to re-assign any value to an existing property will cause an error

    • cfg.deletion: (default true) if set to false, trying to delete any property will cause an error

    • cfg.hide: (default true) if set to true, will make auto-generated properties non-enumerable so they don't show up in console output

To Do

  • [–] documentation

Is Done

  • [+] cfg.strict
  • [+] cfg.oneshot
  • [+] cfg.deletion