Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

mixme

Package Overview
Dependencies
Maintainers
1
Versions
21
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

mixme - npm Package Compare versions

Comparing version 0.5.9 to 0.5.10

4

dist/esm/index.d.ts

@@ -57,2 +57,6 @@ export function is_object(obj: unknown): boolean;

export function snake_case_str(
source: string,
): string;
type SnakeCase<S extends string> = S extends `${infer T}${infer U}`

@@ -59,0 +63,0 @@ ? `${T extends Uppercase<T> ? "_" : ""}${Lowercase<T>}${SnakeCase<U>}`

52

dist/esm/index.js

@@ -1,15 +0,9 @@

function _typeof(obj) {
function _typeof(o) {
"@babel/helpers - typeof";
if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") {
_typeof = function (obj) {
return typeof obj;
};
} else {
_typeof = function (obj) {
return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj;
};
}
return _typeof(obj);
return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (o) {
return typeof o;
} : function (o) {
return o && "function" == typeof Symbol && o.constructor === Symbol && o !== Symbol.prototype ? "symbol" : typeof o;
}, _typeof(o);
}

@@ -33,6 +27,4 @@

var target = arguments[0];
for (var i = 1; i < arguments.length; i++) {
var source = arguments[i];
if (is_object_literal(source)) {

@@ -42,6 +34,4 @@ if (!is_object_literal(target)) {

}
for (var _i = 0, _Object$keys = Object.keys(source); _i < _Object$keys.length; _i++) {
var name = _Object$keys[_i];
if (/__proto__|prototype/.test(name)) {

@@ -56,3 +46,2 @@ // See

}
target[name] = mutate(target[name], source[name]);

@@ -68,3 +57,2 @@ }

}
return target;

@@ -75,14 +63,10 @@ }

var target = {};
if (is_object_literal(source)) {
var u = typeof convert === "number" && convert > 0 ? convert - 1 : convert;
for (var _i2 = 0, _Object$keys2 = Object.keys(source); _i2 < _Object$keys2.length; _i2++) {
var name = _Object$keys2[_i2];
var src = source[name];
if (convert) {
name = _snake_case(name);
name = snake_case_str(name);
}
target[name] = snake_case(src, u);

@@ -93,3 +77,2 @@ }

}
return target;

@@ -102,17 +85,12 @@ }

}
var keys1 = Object.keys(el1).sort();
var keys2 = Object.keys(el2).sort();
if (keys1.length !== keys2.length) {
return false;
}
for (var i = 0; i < keys1.length; i++) {
var key = keys1[i];
if (key !== keys2[i]) {
return false;
}
if (!compare(el1[key], el2[key])) {

@@ -126,7 +104,5 @@ return false;

}
if (el1.length !== el2.length) {
return false;
}
for (var _i3 = 0; _i3 < el1.length; _i3++) {

@@ -140,12 +116,7 @@ if (!compare(el1[_i3], el2[_i3])) {

}
return true;
}
function _snake_case(str) {
return str.replace(/([A-Z])/g, function (_, match) {
return "_" + match.toLowerCase();
});
function snake_case_str(str) {
return str.replace(/([a-z\d])([A-Z]+)/g, "$1_$2").replace(/[-\s]+/g, "_").toLowerCase();
}
function is_object(obj) {

@@ -156,3 +127,2 @@ return obj && _typeof(obj) === "object" && !Array.isArray(obj);

var test = obj;
if (_typeof(obj) !== "object" || obj === null) {

@@ -164,6 +134,4 @@ return false;

}
while (Object.getPrototypeOf(test = Object.getPrototypeOf(test)) !== null) {
}
return Object.getPrototypeOf(obj) === test;

@@ -173,2 +141,2 @@ }

export { clone, compare, is_object, is_object_literal, merge, mutate, snake_case };
export { clone, compare, is_object, is_object_literal, merge, mutate, snake_case, snake_case_str };

@@ -5,18 +5,12 @@ (function (global, factory) {

(global = typeof globalThis !== 'undefined' ? globalThis : global || self, factory(global.mixme = {}));
}(this, (function (exports) { 'use strict';
})(this, (function (exports) { 'use strict';
function _typeof(obj) {
function _typeof(o) {
"@babel/helpers - typeof";
if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") {
_typeof = function (obj) {
return typeof obj;
};
} else {
_typeof = function (obj) {
return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj;
};
}
return _typeof(obj);
return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (o) {
return typeof o;
} : function (o) {
return o && "function" == typeof Symbol && o.constructor === Symbol && o !== Symbol.prototype ? "symbol" : typeof o;
}, _typeof(o);
}

@@ -40,6 +34,4 @@

var target = arguments[0];
for (var i = 1; i < arguments.length; i++) {
var source = arguments[i];
if (is_object_literal(source)) {

@@ -49,6 +41,4 @@ if (!is_object_literal(target)) {

}
for (var _i = 0, _Object$keys = Object.keys(source); _i < _Object$keys.length; _i++) {
var name = _Object$keys[_i];
if (/__proto__|prototype/.test(name)) {

@@ -63,3 +53,2 @@ // See

}
target[name] = mutate(target[name], source[name]);

@@ -75,3 +64,2 @@ }

}
return target;

@@ -82,14 +70,10 @@ }

var target = {};
if (is_object_literal(source)) {
var u = typeof convert === "number" && convert > 0 ? convert - 1 : convert;
for (var _i2 = 0, _Object$keys2 = Object.keys(source); _i2 < _Object$keys2.length; _i2++) {
var name = _Object$keys2[_i2];
var src = source[name];
if (convert) {
name = _snake_case(name);
name = snake_case_str(name);
}
target[name] = snake_case(src, u);

@@ -100,3 +84,2 @@ }

}
return target;

@@ -109,17 +92,12 @@ }

}
var keys1 = Object.keys(el1).sort();
var keys2 = Object.keys(el2).sort();
if (keys1.length !== keys2.length) {
return false;
}
for (var i = 0; i < keys1.length; i++) {
var key = keys1[i];
if (key !== keys2[i]) {
return false;
}
if (!compare(el1[key], el2[key])) {

@@ -133,7 +111,5 @@ return false;

}
if (el1.length !== el2.length) {
return false;
}
for (var _i3 = 0; _i3 < el1.length; _i3++) {

@@ -147,12 +123,7 @@ if (!compare(el1[_i3], el2[_i3])) {

}
return true;
}
function _snake_case(str) {
return str.replace(/([A-Z])/g, function (_, match) {
return "_" + match.toLowerCase();
});
function snake_case_str(str) {
return str.replace(/([a-z\d])([A-Z]+)/g, "$1_$2").replace(/[-\s]+/g, "_").toLowerCase();
}
function is_object(obj) {

@@ -163,3 +134,2 @@ return obj && _typeof(obj) === "object" && !Array.isArray(obj);

var test = obj;
if (_typeof(obj) !== "object" || obj === null) {

@@ -171,6 +141,4 @@ return false;

}
while (Object.getPrototypeOf(test = Object.getPrototypeOf(test)) !== null) {
}
return Object.getPrototypeOf(obj) === test;

@@ -187,5 +155,4 @@ }

exports.snake_case = snake_case;
exports.snake_case_str = snake_case_str;
Object.defineProperty(exports, '__esModule', { value: true });
})));
}));

@@ -57,2 +57,6 @@ export function is_object(obj: unknown): boolean;

export function snake_case_str(
source: string,
): string;
type SnakeCase<S extends string> = S extends `${infer T}${infer U}`

@@ -59,0 +63,0 @@ ? `${T extends Uppercase<T> ? "_" : ""}${Lowercase<T>}${SnakeCase<U>}`

@@ -52,3 +52,3 @@ export function merge() {

if (convert) {
name = _snake_case(name);
name = snake_case_str(name);
}

@@ -100,6 +100,7 @@ target[name] = snake_case(src, u);

function _snake_case(str) {
return str.replace(/([A-Z])/g, (_, match) => {
return "_" + match.toLowerCase();
});
export function snake_case_str(str) {
return str
.replace(/([a-z\d])([A-Z]+)/g, "$1_$2")
.replace(/[-\s]+/g, "_")
.toLowerCase();
}

@@ -106,0 +107,0 @@

{
"name": "mixme",
"description": "A library for recursively merging JavaScript objects",
"version": "0.5.9",
"version": "0.5.10",
"author": "David Worms <david@adaltas.com> (https://www.adaltas.com)",

@@ -10,18 +10,18 @@ "contributors": [

"devDependencies": {
"@babel/core": "^7.15.5",
"@babel/preset-env": "^7.15.6",
"@commitlint/cli": "^13.1.0",
"@commitlint/config-conventional": "^13.1.0",
"@types/mocha": "^10.0.1",
"@types/node": "^18.15.3",
"coffeescript": "^2.6.0",
"husky": "^7.0.2",
"mocha": "^9.1.1",
"pinst": "^2.1.6",
"rollup": "^2.56.3",
"rollup-plugin-babel": "^4.4.0",
"@babel/core": "^7.23.3",
"@babel/preset-env": "^7.23.3",
"@commitlint/cli": "^18.4.2",
"@commitlint/config-conventional": "^18.4.2",
"@rollup/plugin-babel": "^6.0.4",
"@types/mocha": "^10.0.4",
"@types/node": "^20.9.1",
"coffeescript": "^2.7.0",
"husky": "^8.0.3",
"mocha": "^10.2.0",
"pinst": "^3.0.0",
"rollup": "^4.5.0",
"should": "^13.2.3",
"standard-version": "^9.3.1",
"standard-version": "^9.5.0",
"ts-node": "^10.9.1",
"typescript": "^4.9.5"
"typescript": "^5.2.2"
},

@@ -62,2 +62,3 @@ "engines": {

"main": "./dist/cjs/index.cjs",
"module": "dist/esm/index.js",
"mocha": {

@@ -89,3 +90,4 @@ "inline-diffs": true,

"release:patch": "standard-version --release-as patch",
"release:major": "standard-version --release-as major"
"release:major": "standard-version --release-as major",
"postrelease": "git push --follow-tags origin master"
},

@@ -92,0 +94,0 @@ "type": "module",

@@ -20,6 +20,6 @@

```js
import { merge } from 'mixme'
import { merge } from "mixme"
const target = merge({a: '1'}, {b: '2'});
// target is {a: '1', b: '2'}
const target = merge({a: "1"}, {b: "2"});
// target is {a: "1", b: "2"}
```

@@ -32,8 +32,8 @@

```js
import { mutate } from 'mixme'
import { mutate } from "mixme"
const source = {a: '1'};
const target = mutate(source, {b: '2'});
target.c = '3';
// source and target are both {a: '1', b: '2', c: '3'}
const source = {a: "1"};
const target = mutate(source, {b: "2"});
target.c = "3";
// source and target are both {a: "1", b: "2", c: "3"}
```

@@ -46,5 +46,5 @@

```js
import { clone } from 'mixme'
import { clone } from "mixme"
const target = clone(['a', 'b'])
const target = clone(["a", "b"])
// target is now a copy of source

@@ -58,3 +58,3 @@ ```

```js
import { is_object_literal } from 'mixme'
import { is_object_literal } from "mixme"

@@ -65,3 +65,3 @@ // {} is literate

// error is not literate
is_object_literal(new Error('Catch me'))
is_object_literal(new Error("Catch me"))

@@ -72,2 +72,13 @@ // Array is not literate

### Function `snake_case_str(str)`
Convert a camel case string to snake case, used internally by `snake_case`.
```js
import { snake_case_str } from "mixme"
snake_case("myValue")
// Return "my_value"
```
### Function `snake_case(object)`

@@ -78,6 +89,6 @@

```js
import { snake_case } from 'mixme'
import { snake_case } from "mixme"
snake_case({aA: '1', bB: cC: '2'})
// Return {a_a: '1', b_b: c_c: '2'}
snake_case({aA: "1", bB: cC: "2"})
// Return {a_a: "1", b_b: c_c: "2"}
```

@@ -90,3 +101,3 @@

```js
import { compare } from 'mixme'
import { compare } from "mixme"

@@ -105,9 +116,9 @@ compare([{a: 1}], [{a: 1}])

```js
import { merge } from 'mixme'
import { merge } from "mixme"
const obj1 = { a_key: 'a value', b_key: 'b value'}
const obj2 = { b_key: 'new b value'}
const obj1 = { a_key: "a value", b_key: "b value"}
const obj2 = { b_key: "new b value"}
const result = merge(obj1, obj2)
assert.eql(result.b_key, 'new b value')
assert.eql(result.b_key, "new b value")
```

@@ -118,10 +129,10 @@

```js
import { mutate } from 'mixme'
import { mutate } from "mixme"
const obj1 = { a_key: 'a value', b_key: 'b value'};
const obj2 = { b_key: 'new b value'};
const obj1 = { a_key: "a value", b_key: "b value"};
const obj2 = { b_key: "new b value"};
const result = mutate(obj1, obj2)
assert.eql(result, obj1)
assert.eql(obj1.b_key, 'new b value')
assert.eql(obj1.b_key, "new b value")
```

@@ -145,3 +156,2 @@

yarn run release
git push --follow-tags origin master
```

@@ -148,0 +158,0 @@

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc