{"name":"mixme","version":"2.0.1","keywords":["clone","copy","deep","extend","merge","objects","recursive"],"author":{"url":"https://www.adaltas.com","name":"David Worms","email":"david@adaltas.com"},"license":"MIT","_id":"mixme@2.0.1","maintainers":[{"name":"david","email":"david@adaltas.com"}],"contributors":[{"name":"Paul Farault","email":"paul.farault@gmail.com"}],"homepage":"https://github.com/adaltas/node-mixme","bugs":{"url":"https://github.com/adaltas/node-mixme/issues"},"dist":{"shasum":"a92af544eee35e990ab6f9856af3f8eb1b3b8d4a","tarball":"http://registry-npm.ywwl.com/mixme/download/mixme-2.0.1.tgz","fileCount":9,"integrity":"sha512-dKGjOvfKhG+rDZw1jSPED1T/M42CBdijZQBi1kQ/SJQirHCM4pfLBJa0bo3AVXwx0fa6QQN/NFFZHoLXxQmacg==","signatures":[{"sig":"MEYCIQDZIdF5swzuAbOp1uJZS2VKuBfKjeUsth4CBiZ3GHmqLAIhAOAoxKhG2l3V173UWMrrH7Kk9jGqcaJJjWNc4IBkD7/e","keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U"}],"unpackedSize":36158,"size":7305,"noattachment":false,"key":"/mixme/-/mixme-2.0.1.tgz"},"main":"./dist/cjs/index.cjs","type":"module","mocha":{"import":"tsx","timeout":40000,"reporter":"spec","recursive":true,"inline-diffs":true,"throw-deprecation":true},"types":"lib/index.d.ts","module":"dist/esm/index.js","engines":{"node":">= 8.0.0"},"exports":{".":{"types":"./dist/index.d.ts","import":"./dist/index.js","require":"./dist/index.cjs"}},"gitHead":"06194f07316d2fd91a403e4efbff630763418e2e","scripts":{"test":"mocha 'test/**/*.{js,ts}'","build":"tsup-node","prepare":"husky","release":"standard-version","lint:fix":"eslint --fix","lint:check":"eslint","lint:staged":"npx lint-staged","postrelease":"git push --follow-tags origin master","release:major":"standard-version --release-as major","release:minor":"standard-version --release-as minor","release:patch":"standard-version --release-as patch"},"_npmUser":{"name":"david","email":"david@adaltas.com"},"repository":{"url":"git+https://github.com/adaltas/node-mixme.git","type":"git"},"_npmVersion":"10.9.2","description":"A library for recursively merging JavaScript objects","directories":{},"lint-staged":{"*.js":"npm run lint:check","*.md":"prettier -w"},"_nodeVersion":"22.13.1","typesVersions":{"*":{".":["dist/esm/index.d.ts"]}},"_hasShrinkwrap":false,"devDependencies":{"tsx":"^4.19.2","chai":"^5.1.2","tsup":"^8.3.6","husky":"^9.1.7","mocha":"^11.1.0","eslint":"^9.19.0","prettier":"^3.4.2","@eslint/js":"^9.19.0","typescript":"^5.7.3","@types/chai":"^5.0.1","@types/node":"^22.10.10","lint-staged":"^15.4.3","@types/mocha":"^10.0.10","coffeescript":"^2.7.0","@commitlint/cli":"^19.6.1","standard-version":"^9.5.0","@types/eslint__js":"^8.42.3","typescript-eslint":"^8.22.0","eslint-plugin-mocha":"^10.5.0","eslint-config-prettier":"^10.0.1","eslint-plugin-prettier":"^5.2.3","@commitlint/config-conventional":"^19.6.0"},"_npmOperationalInternal":{"tmp":"tmp/mixme_2.0.1_1738659852076_0.3858621391759034","host":"s3://npm-registry-packages-npm-production"},"readme":"# Node.js mixme\n\n![Build Status](https://github.com/adaltas/node-mixme/actions/workflows/test.yml/badge.svg)\n\nMerge multiple object recursively, with TypeScript support. The last object takes precedence over the previous ones. Only objects are merged. Arrays are overwritten.\n\n- Zero dependencies\n- Small size\n- Pure functions\n- ESM and CommonJS support\n\n## API\n\nThe API is minimalist. The most popular functions are `merge`, `mutate` and `is_object_literal`.\n\n### Function `camelize(object)`\n\nClone a object and convert its properties into snake case.\n\n```js\nimport { snake_case } from \"mixme\"\n\nsnake_case({aA: \"1\", bB: cC: \"2\"})\n// Return {a_a: \"1\", b_b: c_c: \"2\"}\n```\n\n### Function `camelize_str(str)`\n\nConvert a camel case string to snake case, used internally by `snake_case`.\n\n```js\nimport { snake_case_str } from \"mixme\";\n\nsnake_case(\"myValue\");\n// Return \"my_value\"\n```\n\n### Function `compare(item_1, item_2)`\n\nCompare two items and return true if their values match.\n\n```js\nimport { compare } from \"mixme\";\n\ncompare([{ a: 1 }], [{ a: 1 }]);\n// Return true\n\ncompare({ a: 1 }, { a: 2 });\n// Return false\n```\n\n### Function `clone(data)`\n\nIt is possible to clone a literal object by simply calling `mixme` with this object as the first argument. Use the `clone` function in case you wish to clone any type of argument including arrays:\n\n```js\nimport { clone } from \"mixme\";\n\nconst target = clone([\"a\", \"b\"]);\n// target is now a copy of source\n```\n\n### Function `is_object_literal(object)`\n\nUse the `is_object_literal` function to ensure an object is literate.\n\n```js\nimport { is_object_literal } from \"mixme\";\n\n// {} is literate\nis_object_literal({});\n\n// error is not literate\nis_object_literal(new Error(\"Catch me\"));\n\n// Array is not literate\nis_object_literal([]);\n```\n\n### Function `merge(...data)`\n\nThe API is minimalist,\nMerge all literal object provided as arguments. This function is immutable, the source objects won't be altered.\n\n```js\nimport { merge } from \"mixme\";\n\nconst target = merge({ a: \"1\" }, { b: \"2\" });\n// target is {a: \"1\", b: \"2\"}\n```\n\n### Function `mutate(...data)`\n\nUse the `mutate` function to enrich an object. The first argument will be mutated:\n\n```js\nimport { mutate } from \"mixme\";\n\nconst source = { a: \"1\" };\nconst target = mutate(source, { b: \"2\" });\ntarget.c = \"3\";\n// source and target are both {a: \"1\", b: \"2\", c: \"3\"}\n```\n\n### Function `snake_case(object)`\n\nClone a object and convert its properties into snake case.\n\n```js\nimport { snake_case } from \"mixme\"\n\nsnake_case({aA: \"1\", bB: cC: \"2\"})\n// Return {a_a: \"1\", b_b: c_c: \"2\"}\n```\n\n### Function `snake_case_str(str)`\n\nConvert a camel case string to snake case, used internally by `snake_case`.\n\n```js\nimport { snake_case_str } from \"mixme\";\n\nsnake_case(\"myValue\");\n// Return \"my_value\"\n```\n\n## Example\n\nCreate a new object from two objects:\n\n```js\nimport { merge } from \"mixme\";\n\nconst obj1 = { a_key: \"a value\", b_key: \"b value\" };\nconst obj2 = { b_key: \"new b value\" };\nconst result = merge(obj1, obj2);\n\nassert.eql(result.b_key, \"new b value\");\n```\n\nMerge an existing object with a second one:\n\n```js\nimport { mutate } from \"mixme\";\n\nconst obj1 = { a_key: \"a value\", b_key: \"b value\" };\nconst obj2 = { b_key: \"new b value\" };\nconst result = mutate(obj1, obj2);\n\nassert.eql(result, obj1);\nassert.eql(obj1.b_key, \"new b value\");\n```\n\n## Testing\n\nClone the repo, install the development dependencies and run the tests:\n\n```bash\ngit clone http://github.com/wdavidw/node-mixme.git .\nnpm install\nnpm run test\n```\n\n## Developers\n\nTo automatically generate a new version:\n\n```bash\nnpm run release\n```\n\nPackage publication is handled by the CI/CD with GitHub action.\n\nNote:\n\n- On release, both the publish and test workflows run in parallel. Not very happy about it but I haven't found a better way.\n\n## Contributors\n\n- David Worms: <https://github.com/wdavidw>\n- Paul Farault: <https://github.com/PaulFarault>\n\nThis package is developed by [Adaltas](https://www.adaltas.com).\n","publish_time":1738659852290,"_cnpm_publish_time":1738659852290,"dist-tags":{"latest":"2.0.2"}}