Comparing version 0.5.5 to 0.5.6
{ | ||
"name": "mixme", | ||
"description": "A library for recursive merging of Javascript objects", | ||
"version": "0.5.5", | ||
"description": "A library for recursively merging JavaScript objects", | ||
"version": "0.5.6", | ||
"author": "David Worms <david@adaltas.com> (https://www.adaltas.com)", | ||
"contributors": [], | ||
"contributors": [ | ||
"Paul Farault <paul.farault@gmail.com>" | ||
], | ||
"devDependencies": { | ||
"@babel/core": "^7.15.5", | ||
"@babel/preset-env": "^7.15.6", | ||
"@commitlint/cli": "^13.1.0", | ||
"@commitlint/config-conventional": "^13.1.0", | ||
"@babel/core": "^7.15.5", | ||
"@babel/preset-env": "^7.15.6", | ||
"@types/mocha": "^10.0.1", | ||
"@types/node": "^18.15.3", | ||
"coffeescript": "^2.6.0", | ||
@@ -19,3 +23,5 @@ "husky": "^7.0.2", | ||
"should": "^13.2.3", | ||
"standard-version": "^9.3.1" | ||
"standard-version": "^9.3.1", | ||
"ts-node": "^10.9.1", | ||
"typescript": "^4.9.5" | ||
}, | ||
@@ -29,8 +35,21 @@ "engines": { | ||
}, | ||
"exports": { | ||
".": { | ||
"import": { | ||
"types": "./lib/index.d.ts", | ||
"default": "./lib/index.js" | ||
}, | ||
"require": { | ||
"types": "./dist/cjs/index.d.cts", | ||
"default": "./dist/cjs/index.cjs" | ||
} | ||
} | ||
}, | ||
"keywords": [ | ||
"merge", | ||
"clone", | ||
"copy", | ||
"deep", | ||
"extend", | ||
"copy", | ||
"clone", | ||
"merge", | ||
"objects", | ||
"recursive" | ||
@@ -42,14 +61,13 @@ ], | ||
"license": "MIT", | ||
"main": "dist/mixme.cjs.js", | ||
"module": "dist/mixme.esm.js", | ||
"main": "dist/cjs/mixme.js", | ||
"mocha": { | ||
"throw-deprecation": true, | ||
"inline-diffs": true, | ||
"loader": "ts-node/esm", | ||
"recursive": true, | ||
"reporter": "spec", | ||
"require": [ | ||
"should", | ||
"./coffee.config.js" | ||
"should" | ||
], | ||
"inline-diffs": true, | ||
"timeout": 40000, | ||
"reporter": "spec", | ||
"recursive": true | ||
"throw-deprecation": true, | ||
"timeout": 40000 | ||
}, | ||
@@ -64,5 +82,4 @@ "repository": { | ||
"postpublish": "pinst --enable", | ||
"build": "coffee -b -o lib src src && rollup -c", | ||
"pretest": "npm run build", | ||
"test": "mocha 'test/**/*.coffee'", | ||
"build": "rollup -c && cp lib/index.d.ts dist/cjs/index.d.cts", | ||
"test": "mocha 'test/**/*.{js,ts}'", | ||
"release": "standard-version", | ||
@@ -72,3 +89,6 @@ "release:minor": "standard-version --release-as minor", | ||
"release:major": "standard-version --release-as major" | ||
} | ||
}, | ||
"type": "module", | ||
"types": "lib/index.d.ts", | ||
"dependencies": {} | ||
} |
# Node.js mixme | ||
[![Build Status](https://secure.travis-ci.org/adaltas/node-mixme.png)](http://travis-ci.org/adaltas/node-mixme) | ||
![Build Status](https://github.com/adaltas/node-mixme/actions/workflows/test.yml/badge.svg) | ||
Merge multiple object recursively. The last object takes precedence over the | ||
previous ones. Only objects are merged. Arrays are overwritten. | ||
Merge multiple object recursively, with TypeScript support. The last object takes precedence over the previous ones. Only objects are merged. Arrays are overwritten. | ||
@@ -18,7 +17,7 @@ - Zero dependencies | ||
The API is minimalist, pass as many literal objects as you wish, they will all be | ||
merged. This function is immutable, the source objects won't be altered. | ||
The API is minimalist, pass as many literal objects as you wish, they will all be merged. This function is immutable, the source objects won't be altered. | ||
```js | ||
const { merge } = require('mixme') | ||
import { merge } from 'mixme' | ||
const target = merge({a: '1'}, {b: '2'}); | ||
@@ -33,7 +32,8 @@ // target is {a: '1', b: '2'} | ||
```js | ||
const { mutate } = require('mixme') | ||
import { mutate } from 'mixme' | ||
const source = {a: '1'}; | ||
const target = mutate(source, {b: '2'}); | ||
// target is the same as source | ||
// source and target are now {a: '1', b: '2'} | ||
target.c = '3'; | ||
// source and target are both {a: '1', b: '2', c: '3'} | ||
``` | ||
@@ -46,3 +46,4 @@ | ||
```js | ||
const { clone } = require('mixme') | ||
import { clone } from 'mixme' | ||
const target = clone(['a', 'b']) | ||
@@ -57,7 +58,10 @@ // target is now a copy of source | ||
```js | ||
const { is_object_literal } = require('mixme') | ||
import { is_object_literal } from 'mixme' | ||
// {} is literate | ||
is_object_literal({}) | ||
// error is not literate | ||
is_object_literal(new Error('Catch me')) | ||
// Array is not literate | ||
@@ -72,3 +76,4 @@ is_object_literal([]) | ||
```js | ||
const { snake_case } = require('mixme') | ||
import { snake_case } from 'mixme' | ||
snake_case({aA: '1', bB: cC: '2'}) | ||
@@ -83,5 +88,7 @@ // Return {a_a: '1', b_b: c_c: '2'} | ||
```js | ||
const { compare } = require('mixme') | ||
import { compare } from 'mixme' | ||
compare([{a: 1}], [{a: 1}]) | ||
// Return true | ||
compare({a: 1}, {a: 2}) | ||
@@ -95,18 +102,24 @@ // Return false | ||
```js | ||
import { merge } from 'mixme' | ||
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') | ||
``` | ||
obj1 = { a_key: 'a value', b_key: 'b value'} | ||
obj2 = { b_key: 'new b value'} | ||
result = misc.merge obj1, obj2 | ||
assert.eql result.b_key, 'new b value' | ||
``` | ||
Merge an existing object with a second one: | ||
```js | ||
import { mutate } from 'mixme' | ||
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') | ||
``` | ||
obj1 = { a_key: 'a value', b_key: 'b value'}; | ||
obj2 = { b_key: 'new b value'}; | ||
result = mixme.mutate obj1, obj2 | ||
assert.eql result, obj1 | ||
assert.eql obj1.b_key, 'new b value' | ||
``` | ||
@@ -120,3 +133,3 @@ ## Testing | ||
npm install | ||
make test | ||
npm run test | ||
``` | ||
@@ -128,3 +141,3 @@ | ||
``` | ||
```bash | ||
yarn run release | ||
@@ -137,2 +150,3 @@ git push --follow-tags origin master | ||
Note: | ||
- On release, both the publish and test workflows run in parallel. Not very happy about it but I haven't found a better way. | ||
@@ -143,4 +157,5 @@ - `yarn` does not call the "postrelease" script and `npm` fails if the `package-lock.json` file is present and git ignored. | ||
* David Worms: <https://github.com/wdavidw> | ||
- David Worms: <https://github.com/wdavidw> | ||
- Paul Farault: <https://github.com/PaulFarault> | ||
This package is developed by [Adaltas](https://www.adaltas.com). |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
Major refactor
Supply chain riskPackage has recently undergone a major refactor. It may be unstable or indicate significant internal changes. Use caution when updating to versions that include significant changes.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
21743
7
151
Yes
16
423
1