{"_id":"supermixer@1.0.6","bugs":{"url":"https://github.com/stampit-org/supermixer/issues"},"dist":{"shasum":"2b4dfb516b65b151d63189afb9cacc931af4e9f8","tarball":"http://registry-npm.ywwl.com/supermixer/download/supermixer-1.0.6.tgz","fileCount":4,"integrity":"sha512-Nce6y8qoC/eGe18VRKl8GhDieaEeTdWXXBO2dkIt5i16QznUBQAG5YysrRKRJ69S0AmTrfIn7JtyKJVXLhbUEQ==","signatures":[{"sig":"MEQCIHaRvq/OwWeDuOtFUgNZ1u3Qzw2l6HWhbBH6LmH3+bZvAiBEGYh5jstGhkFw5lJA8mSojzYNUcNDwgOXgeGZ8cITjA==","keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U"},{"keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U","sig":"MEQCIGUD4qCBIfjjIk7PSs165a/96ebzBzOI6XGcOdNN+vraAiBKtLMA2JQ2/Jyrq3w0/xfyWuxi8yGFe6ZSdZ3Yjv2d6w=="}],"unpackedSize":9613,"size":3157,"noattachment":false,"key":"/supermixer/-/supermixer-1.0.6.tgz"},"main":"dist/index.js","name":"supermixer","author":{"name":"koresar"},"gitHead":"dbb697e3a775ce99cc8d369a47169e369b739804","license":"MIT","scripts":{"lint":"eslint src test","test":"npm run lint && babel-node test/","build":"npm run clean && babel src --out-dir dist","clean":"rimraf dist","prepublish":"npm run test && npm run build"},"version":"1.0.6","_npmUser":{"name":"koresar","email":"kore.sar@gmail.com"},"homepage":"https://github.com/stampit-org/supermixer#readme","keywords":["merge","extend","assign","deep"],"repository":{"url":"git+https://github.com/stampit-org/supermixer.git","type":"git"},"_npmVersion":"11.17.0","description":"Mix JS objects deep, shallow, traversing prototypes, selectively, etc.","directories":{},"maintainers":[{"name":"koresar","email":"kore.sar@gmail.com"}],"_nodeVersion":"24.19.0","dependencies":{"lodash":"^4.17.20"},"_hasShrinkwrap":false,"devDependencies":{"tape":"^4.0.0","babel":"^5.4.7","eslint":"^0.21.2","rimraf":"^2.3.4","require-all":"^1.1.0","babel-eslint":"^4.1.7"},"_npmOperationalInternal":{"host":"s3://npm-registry-packages-npm-production","tmp":"tmp/supermixer_1.0.6_1793234525647_0.7991355587633073"},"readme":"# Super Mixer\n\nMixes/merges/extends your object in multiple ways.\n\nUnlike underscore/lodash utility methods this module allows you to:\n* mix or deep merge objects' **prototype chain**. Regular mixin/extend/assign implementations can't do that.\n* mix or deep merge **unique** properties only. I.e. data will **not be overwritten** if a property already exists.\n* filter each individual property by **target value**, **source value**, and **key**. See API.\n* transform each value by **resulting value**, **source value**, and **key**. See API.\n\n## Install\n```sh\n$ npm install supermixer\n```\n\n```js\nvar mixer = require('supermixer');\n```\n\n\n## API\n\n_**NB! All functions always mutate the first argument.**_\n\n### supermixer(opts = {})\nThe `opts`:\n```\n * @param {Object} opts\n * @param {Function} opts.filter Function which filters value and key.\n * @param {Function} opts.transform Function which transforms each value.\n * @param {Boolean} opts.chain Loop through prototype properties too.\n * @param {Boolean} opts.deep Deep looping through the nested properties.\n * @param {Boolean} opts.noOverwrite Do not overwrite any existing data (aka first one wins).\n```\n\nUsage:\n```js\nconst mix = supermixer({\n  filter: (sourceValue, targetValue, key) => key[0] !== '_', // do not copy \"private\" values\n  transform(resultValue, targetValue, key) { console.log(key); return resultValue; }, // log each key which gets set\n  chain: true,\n  deep: true,\n  noOverwrite: true\n});\n\nconst johnStream = mix({}, new Stream(), { name: \"John Stream\"; })\n```\n\n### Regular mixin, aka `Object.assign`, aka `$.extend`.\n```js\n // the regular Object.assign function\nvar extend = supermixer();\n// OR\nextend = supermixer.mixin;\n\nextend({}, { a: 1 }, { b: 2 });\n// { a: 1, b: 2 }\n```\n\n### Mixin functions only.\n```js\n// assigns own functions only\nvar functionMixer = supermixer({\n  filter: (sourceValue) => sourceValue === 'function'\n});\n// OR\nfunctionMixer = supermixer.mixinFunctions;\n\nfunctionMixer({}, { a: \"x\" },  { b: function(){} });\n// { b() }\n```\n\n### Mixin functions including prototype chain.\n```js\n// assigns functions only, but traverse through the prototype chain\nvar chainFunctionMixer = supermixer({\n  filter: (sourceValue) => typeof sourceValue === 'function',\n  chain: true\n});\n// OR\nchainFunctionMixer = supermixer.mixinChainFunctions;\n\nchainFunctionMixer({}, new EventEmitter());\n// { on(), off(), emit(), ... }\n```\n\n### Deep merge\n```js\n// deep merge own properties\nvar mergeDeep = supermixer({\n  deep: true\n});\n// OR\nmergeDeep = supermixer.merge;\n\nmergeDeep({ url: { host: \"example.com\" } }, { url: { port: 81 } });\n// { url: { host: \"example.com\", port: 81 } }\n```\n\n### Deep merge but do not overwrite existing values.\n```js\n// deep merge own properties\nvar mergeDeep = supermixer({\n  deep: true,\n  noOverwrite: true\n});\n// OR\nmergeUnique = supermixer.mergeUnique;\n\nmergeUnique({ url: { host: \"example.com\" } }, { url: { host: \"evil.com\" } });\n// { url: { host: \"example.com\" } }\n```\n\n### Deep merge non functions including prototype chain.\n```js\n// deeply merges data properties, traversing through prototype chain\nvar mergeChainData =  supermixer({\n  filter: (sourceValue) => typeof sourceValue !== 'function',\n  deep: true,\n  chain: true\n});\n// OR\nmergeChainData = supermixer.mergeChainNonFunctions;\n\nEventEmitter.prototype.hello = \"world\";\nmergeChainData({}, new EventEmitter());\n// { hello: \"world\" }\n```\n\n## Want to contribute?\nThis project is Open Open Source. This means whoever submits an accepted PR will receive write permissions to the project.\n","publish_time":1793234525737,"_cnpm_publish_time":1793234525737,"dist-tags":{"latest":"1.0.6"}}