Registry / serialization / mixme
library2.0.2jsnpmunverified

Mixme is a JavaScript/TypeScript library (currently at v2.0.2) designed for recursively merging and manipulating JavaScript objects. It provides immutable merging via `merge` and mutable in-place modification via `mutate`. Key differentiators include its zero-dependency footprint, minimal size, and pure function approach for `merge`. It offers comprehensive TypeScript type definitions and supports both ES Modules (ESM) and CommonJS environments. While a specific release cadence isn't explicitly published, the project appears actively maintained with a streamlined release process via GitHub Actions. A notable behavior is that arrays are always overwritten during merges, not recursively combined, which is a common point of confusion for users expecting deep array merging.

npm install mixme
INSTALL
IMPORT
SIG · MIXME
M
mixme
serializationjavascriptv2.0.2
Install
Import
Disk
Pass rate
0/ 6
Env Coverage0 / 6
glibc
1822
musl
1822
Install & Compatibility
Where this runs
tested against v? · npm install
Install × environment matrix
Each cell = how many times install + import succeeded across repeated harness runs. Partial = flaky.
glibc = Debian/Ubuntu slim · musl = Alpine Linux
musl
node 18226 runs
build_error
glibc
node 18226 runs
build_error
Code
Verified usage

Verified import paths — ran on the pinned version, not inferred.

merge
import { merge } from 'mixme';
const merge = require('mixme').merge;
Mixme v2 supports both ESM and CommonJS. For CommonJS, named exports like `merge` must be accessed as properties of the `require` result.
mutate
import { mutate } from 'mixme';
import mutate from 'mixme';
All primary functions (`merge`, `mutate`, `clone`, etc.) are named exports, not default exports. Attempting a default import will result in `undefined`.
clone
import { clone } from 'mixme';
const { clone } = require('mixme');
While `const { clone } = require('mixme');` works in CommonJS, `const clone = require('mixme').clone;` is also common but slightly less idiomatic for multiple exports.

Demonstrates `merge` for immutable object combination, `mutate` for in-place modification, and `snake_case` utility, highlighting how arrays are overwritten.

import { merge, mutate, clone, snake_case } from 'mixme'; interface Config { appName: string; version: string; settings: { theme: string; notifications: boolean; }; features: string[]; } const defaultAppConfig: Config = { appName: 'My App', version: '1.0.0', settings: { theme: 'dark', notifications: true, }, features: ['dashboard', 'reports'], }; const userConfig: Partial<Config> = { appName: 'My Custom App', settings: { theme: 'light', }, features: ['dashboard', 'analytics'], }; // Immutable merge: creates a new object const finalConfig = merge(defaultAppConfig, userConfig); console.log('Final Config (merged):', finalConfig); // Expected: { appName: 'My Custom App', version: '1.0.0', settings: { theme: 'light', notifications: true }, features: ['dashboard', 'analytics'] } // Mutable merge: modifies the first object const baseConfigCopy = clone(defaultAppConfig); // Clone to avoid modifying original defaultAppConfig mutate(baseConfigCopy, userConfig); console.log('Mutated Config:', baseConfigCopy); // Expected: { appName: 'My Custom App', version: '1.0.0', settings: { theme: 'light', notifications: true }, features: ['dashboard', 'analytics'] } // Example of snake_case utility const camelCaseObject = { userFirstName: 'John', userLastName: 'Doe' }; const snakeCaseObject = snake_case(camelCaseObject); console.log('Snake Case Object:', snakeCaseObject); // Expected: { user_first_name: 'John', user_last_name: 'Doe' }
Debug
Known issues
gotchaWhen merging objects with `merge` or `mutate`, arrays are always overwritten by the subsequent object's array value, not recursively merged. This differs from some other deep merge utilities.
fix
If deep array merging is required, you must preprocess arrays manually before passing them to `mixme` or use a different library designed for deep array merging.
affects: >=1.0.0
gotchaThe `mutate` function directly modifies its first argument. If you need to preserve the original object, always pass a `clone()` of the original object as the first argument to `mutate`.
fix
Use `const myObjectCopy = clone(myObject); mutate(myObjectCopy, changes);` if you intend to keep the original object intact. Use `merge` for an immutable approach that always returns a new object.
affects: >=1.0.0
breakingWhile `mixme` v2 supports both ESM and CommonJS, migrating older CommonJS-only projects to `import` statements may require configuring 'type': 'module' in `package.json` or changing file extensions to `.mjs` for Node.js environments.
fix
Ensure your project's module system is correctly configured. For ESM, use `import { func } from 'mixme';`. For CJS, use `const { func } = require('mixme');`. Refer to Node.js documentation on ESM/CJS interoperability.
affects: >=2.0.0
Errors
Common errors & fixes
Cannot use import statement outside a module
Attempting to use `import` syntax in a CommonJS file or a Node.js project not configured for ES Modules.
fix
Ensure your `package.json` contains `"type": "module"` for ESM, or rename `.js` files using `import` to `.mjs`. Alternatively, if staying with CommonJS, use `const { merge } = require('mixme');`.
TypeError: mixme.merge is not a function
This typically happens when trying to `require('mixme')` and then calling `mixme.merge()` without destructuring or accessing the named export properly in a CommonJS environment.
fix
In CommonJS, you must destructure the named export: `const { merge } = require('mixme');` or access it as a property: `const mixme = require('mixme'); const result = mixme.merge(...);`.
ReferenceError: require is not defined
This occurs when trying to use `require()` in an ES Module context (e.g., a file with `"type": "module"` or `.mjs` extension).
fix
Switch to `import` syntax: `import { merge } from 'mixme';` instead of `const { merge } = require('mixme');`. If legacy CommonJS modules are needed in an ESM project, consider dynamic `import()` or specific tools like `createRequire`.
Upgrade
Version history
2.0.2latest on npm
Audit
Dependencies

No dependency data recorded yet.

Agent activity
3 hits · last 30 days
node
2
Amazon
1
Resources
mixme — npm install mixme · libregistry