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

mount-expressions

v1.0.1

Published

A simple ultility function to make working with values, arrays and objects chainable. All values are wrappered with accesser functions that accept callbacks. Making calls, chainable and fluent.

Downloads

9

Readme

Mount 2.0

Rewritten from scratch to improve and simplify the API and behavior of mounted objects.

Mount.js

Mount is a utility function to make working with values chainable and more Functional in style.

Mount will turn any inputs into a store object who's properties are accessor methods, that accept callbacks.

Each callback will be passed a standard set of arugments.

  • Value: the value of the prop of the original input.
  • Store: the mountStore which holds all the values, and their Accessor Functions.
  • Mount: a helper function to add additional values to the mountStore.
  • Prop: the prop by which one can access the value in the Store.
  • Input: the original source input, as it was passed in when mounted.

Accessor Functions will return whatever your callback explicitly returns, or the instance of mountStore.fx if undefined is returned.

##Examples:

/** ======================================
   Mounting Primatives
======================================= **/

// Strings
  var s = 'john doe';
      m = mount( s, 'name')
           .name(function( name, store, mount, prop, input ){
              mount(32, 'age'), console.log( 'Welcome back ' + name );
            })
            .age(function(age){
              console.log(age)
            });
    
/** ======================================
   Mounting Objects
======================================= **/

  var o = { name: "john doe", age: 22 },
      m = mount(o)
            .name(function( name, store, mount, prop, input ){
               console.log('the user\'s name is ' + name + ' and he is ' + store.age + ' years old' );
            }); 

/** ======================================
   Mounting Arrays
======================================= **/

  var a = ['john doe', 22 ];
      m = mount(a)[0](function( name, store, mount, prop, input ){
            console.log('Welcome back ' + name);
          })

// mapTo
      
  var a = ['john doe', 22 ];
      m = mount(a)
            .mapTo({name: 0, age: 1})
            .name(function(name, person){ console.log( 'hello ' + name + ', your age is ' + person.age )})

/** ======================================
   Remounting Mounted Stores
======================================= **/

  var o = { name: "john doe", age: 22 };
  var r = mount(o).name((name, person ) => { person.name = name.toUpperCase() } );
  var s = mount(r).name(function(name){ return name }); // explicit return value "JOHN DOE" returned

      console.log(s) // "JOHN DOE"


/** 
      Helper Functions
*/

// .has() checks for the presence of a property, and conditionaly calls one of two optional callbacks.
// .hasNot() checks for the absence of a property, and conditionaly calls one of two optional callbacks.


var o = {},
    m = mount(o).has('name', null, function(n,s,m) { m('John Doe', 'Name'); return s; });
    m = mount(o).hasNot('age', function(){ console.log('not found!')});