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 🙏

© 2026 – Pkg Stats / Ryan Hefner

setter-mixin

v1.0.1

Published

Mixin a setter, and getter

Downloads

0

Readme

setter-mixin

Do getting, and setting of nested objects easily.

Install

npm install setter-mixin

Usage

import { mixinSetter, q } from 'setter-mixin';

class MyThing {
    constructor(){
        this.sub = {
            value: 'thing',
        };
        this.a = document.createElement('a');
        //See about masks below
        this.set('a.attr.href', window.location);
        //A dot in a property name between brackets
        this.set('[dotted.prop]', "I'm dotted");
    }
}

mixinSetter(MyThing.prototype, {
    //Masks forward get/set operations to
    //other getters, and setters.
    masks: {
        attr: {
            set: 'setAttribute',
            get: 'getAttribute',
            delete: 'removeAttribute'
        }
    },
    //When a property is undefined
    //a default can be used instead.
    defaults: {
        'sub.value2': 'value 2'
    }
});

const thing = new MyThing();
thing.set('one', 1);
console.log(thing.get('one')); //1
//Use dots to get property values from sub objects
console.log(thing.get('sub.value')); //thing
thing.set('sub.value', 'bla');
//Use brackets to get property values.
console.log(thing.get('sub[value]')); //bla
//Dots (periods) can be used in a property name
//between brackets.
console.log(thing.get('[dotted.prop]')); //I'm dotted
//A default is used here.
console.log(thing.get('sub.value2'));
//The mask for attr is used here.
console.log(thing.get('a.attr.href'));
//Sometimes you just want to get/set something.
//Use q to quickly set/get without
//modifying the object operated on.
console.log(q(thing).get('sub.value'));
//Defaults, and masks can be used
//on the quick accessor too.
console.log(q(thing, {defaults: {}, masks:{}}).get('sub.value'));
//delete a property
thing.delete('sub.value');
//When a sub object doesn't exist
//a new sub object will be created.
thing.set('some.value', 42);
console.log(thing.get('some.value')); //42
//object.has checks for undefined values
//Non-existing sub objects are still created
thing.has('some.undefined.property'); //false

Auto sub-object creation

While getting/setting, and when a sub object doesn't exist a new sub object will be created using raw-object. That level will use that new object.

//The some object does not initially exist.
thing.set('some.value', 42);
//But it still works.
console.log(thing.get('some.value')); //42

About

Object composition is pretty ubiquitous. Sometimes when there is a lot of sub-objects due to composition getting, and setting properties can get messy. So we have this module here that's meant to make things a little less messy.

Check out

There's a lot more modules than that. People like accessors.