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

isotropic-mixin

v0.13.1

Published

Mixin function copies property descriptors from one object to another

Downloads

30

Readme

isotropic-mixin

npm version License

A utility that copies property descriptors from one object to another, preserving getters, setters, and property attributes.

Why Use This?

  • Complete Property Copying: Copies the entire property descriptor, not just values
  • Preserves Getters & Setters: Maintains accessors and their shared state
  • Respects Property Attributes: Preserves configurable, enumerable, and writable settings
  • Simple Implementation: Uses modern JavaScript reflection APIs for clarity and reliability

Installation

npm install isotropic-mixin

Usage

import _mixin from 'isotropic-mixin';

// Objects to work with
const _source = {
        name: 'Source Object',
        getValue () {
            return 42;
        }
    },
    _target = {
        id: 'target-123'
    };

// Mix source properties into target
_mixin(_source, _target);

// Target now has all properties from source
console.log(_target.name); // 'Source Object'
console.log(_target.getValue()); // 42
console.log(_target.id); // 'target-123' (original properties remain)

How It Works

isotropic-mixin uses the Reflect API to:

  1. Get all own property names from the source object (including non-enumerable properties)
  2. Retrieve the full property descriptor for each property
  3. Define each property on the target object with the same descriptor

This approach ensures all property characteristics (such as getters, setters, and property attributes) are preserved during the copy operation.

API

mixin(from, to)

Copies all own properties from the source object to the target object.

Parameters

  • from (Object): The source object to copy properties from
  • to (Object): The target object to copy properties to

Returns

  • (undefined): The function doesn't return a value, but modifies the target object

Examples

Working with Getters and Setters

import _mixin from 'isotropic-mixin';

// Source object with getter/setter
const _source = {
        get value () {
            return this._value;
        },
        set value (v) {
            this._value = v;
        },
        _value: 0
    },
    // Target object
    _target = {};

// Mix properties
_mixin(_source, _target);

// The getter/setter behavior is preserved
_target.value = 42;
console.log(_target.value); // 42
console.log(_target._value); // 42

// Changes to the internal state are shared
_source.value = 100;
console.log(_target.value); // 100

Copying Non-Enumerable Properties

import _mixin from 'isotropic-mixin';

const _source = {},
    _target = {};

// Source with non-enumerable property
Object.defineProperty(_source, 'hidden', {
    enumerable: false,
    value: 'I am hidden'
});

// Standard Object.assign doesn't copy non-enumerable properties
Object.assign(_target, _source);
console.log(Object.getOwnPropertyNames(_target)); // []

// isotropic-mixin does copy non-enumerable properties
_mixin(_source, _target);
console.log(Object.getOwnPropertyNames(_target)); // ['hidden']
console.log(target.hidden); // 'I am hidden'

Extending Configuration Objects

import _mixin from 'isotropic-mixin';

// Default configuration
const _defaultConfig = {
        fontSize: 14,
        get isDarkMode () {
            return this.theme === 'dark';
        }
        showNotifications: true,
        theme: 'light'
    },

    // Apply user configuration
    _createConfig = userConfig => {
        const config = {};

        // Apply defaults first
        _mixin(_defaultConfig, config);

        // Then apply user overrides
        if (userConfig) {
            _mixin(userConfig, config);
        }

        return config;
    };

{
    // Create configurations
    const defaultUserConfig = _createConfig();

    console.log(defaultUserConfig.theme); // 'light'
    console.log(defaultUserConfig.isDarkMode); // false

    const darkModeConfig = _createConfig({
        theme: 'dark'
    });

    console.log(darkModeConfig.theme); // 'dark'
    console.log(darkModeConfig.isDarkMode); // true
}

Contributing

Please refer to CONTRIBUTING.md for contribution guidelines.

Issues

If you encounter any issues, please file them at https://github.com/ibi-group/isotropic-mixin/issues