{"id":19560671,"url":"https://github.com/zoubin/util-mix","last_synced_at":"2026-06-09T01:03:55.196Z","repository":{"id":31970490,"uuid":"35540600","full_name":"zoubin/util-mix","owner":"zoubin","description":"Object mixing methods","archived":false,"fork":false,"pushed_at":"2015-10-05T05:23:05.000Z","size":224,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-09-21T07:37:28.652Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"JavaScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/zoubin.png","metadata":{"files":{"readme":"README.md","changelog":"changelog.md","contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2015-05-13T09:39:34.000Z","updated_at":"2015-05-13T10:28:07.000Z","dependencies_parsed_at":"2022-09-26T16:22:21.462Z","dependency_job_id":null,"html_url":"https://github.com/zoubin/util-mix","commit_stats":null,"previous_names":[],"tags_count":9,"template":false,"template_full_name":null,"purl":"pkg:github/zoubin/util-mix","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/zoubin%2Futil-mix","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/zoubin%2Futil-mix/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/zoubin%2Futil-mix/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/zoubin%2Futil-mix/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/zoubin","download_url":"https://codeload.github.com/zoubin/util-mix/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/zoubin%2Futil-mix/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":285354107,"owners_count":27157395,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","status":"online","status_checked_at":"2025-11-19T02:00:05.673Z","response_time":65,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2024-11-11T05:08:26.372Z","updated_at":"2025-11-20T01:03:49.286Z","avatar_url":"https://github.com/zoubin.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# util-mix\nObject mixing methods\n\n## Usage\n\n```javascript\nvar mix = require('util-mix');\nvar Mixer = require('util-mix/Mixer');\n\nvar o = mix({ a: 1 }, { b: 2 }); // { a: 1, b: 2 }\n\nvar mixer = Mixer({ a: 0, b: 0 });\no = mixer.mix({}); // { a: 0, b: 0 }\no = mixer.mix({ c: 1 }); // { a: 0, b: 0, c: 1 }\n```\n\n## mix(receiver, src1, src2,...)\nMix own properties supplied by *src1*, *src2*,..., into *receiver*, which must be a non-null object.\n\nSame key causes overwriting, the later appearance in *arguments* the winner.\n\nThe *receiver* will be returned.\n\n```javascript\nvar r = {};\nvar o = mix(r, { x:1, y:1 }, { y:2 });\n\no === r; // true\no; // { x:1, y:2 }\n```\n\n## mix-undef(receiver, src1, src2,...)\nSame with `mix`, except that properties are only mixed when not defined in `receiver`.\n\n```javascript\nvar mix = require('util-mix/mix-undef');\nvar o = { x: 1 };\nmix(o, { x: 2 }, { y: 2 }, { z: 3 }, { x: 3 });\n\no; // { x: 1, y: 2, z: 3 }\n```\n\n## merge(src1, src2,...)\nSame as `mix({}, src1, src2,...)`.\n\n```javascript\nvar r = {};\nvar o = merge(r, { x:1, y:1 }, { y:2 });\n\nr; // {}\no; // { x:1, y:2 }\n```\n\n## copy(src)\nSame as `merge`.\n\n## pick(filter, src1, src2,...)\n\n### filter\n\nType: `String`, `Array`\n\nSame as `merge(src1, src2,...)`, but only keys specified in `filter` appear in the result.\n\n```javascript\nvar o = pick(['x', 'y'], { x:1, y:1 }, { y:2 }, { z:3 });\n\no; // { x:1, y:2 }\n```\n\n## unpick(filter, src1, src2,...)\n\n### filter\n\nType: `String`, `Array`\n\n\nMerge all properties from  `src1, src2,...` except those appear in `filter`\n\n```javascript\nvar o = unpick(['x', 'y'], { x:1, y:1 }, { y:2 }, { z:3 });\n\no; // { z:3 }\n```\n\n## chop(filter, o)\n\n### filter\n\nType: `String`, `Array`\n\n`pick` keys specified by `filter` from `o`, and delete them from `o`.\n\n```javascript\nvar o = { x:1, y:2, z:3 };\nvar chopped = chop(['x', 'y'], o);\n\nchopped; // { x:1, y:2 }\no; // { z:3 }\n```\n\n## Class: Mixer\n\n### methods\n\n#### mix(receiver, src1, src2,...)\n\n#### merge(src1, src2,...)\n\n### mixer = Mixer(filter, defaults)\n\n#### filter\n\nType: `Array`\n\nOnly mix keys contained in `filter`.\n\n#### defaults\n\nType: `Object`\n\nAlways mix `defaults`, and it will always be overwritten.\n\n```javascript\nvar mixer = Mixer(['x', 'y'], { x:1 });\nvar opts = {};\nvar o = mixer.mix(opts, { y:2, z:3 });\n\no === opts; // true\no; // { x:1, y:2 }\n```\n\n### mixer = Mixer(o)\n\n#### o\n\nType: `Object`\n\nSame as `Mixer(Object.keys(o), o)`\n\n```javascript\nvar mixer = Mixer({ x:1, y:1 });\nvar o = mixer.merge({ y:2 }, { z:3 });\n\no === opts; // true\no; // { x:1, y:2 }\n```\n\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fzoubin%2Futil-mix","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fzoubin%2Futil-mix","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fzoubin%2Futil-mix/lists"}