{"id":22249878,"url":"https://github.com/dantman/node-obj-mix","last_synced_at":"2025-03-25T12:15:40.912Z","repository":{"id":18203086,"uuid":"21335262","full_name":"dantman/node-obj-mix","owner":"dantman","description":"A simple function to merge methods and property getters/setters into prototypes.","archived":false,"fork":false,"pushed_at":"2014-06-30T09:22:38.000Z","size":208,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":2,"default_branch":"develop","last_synced_at":"2025-03-01T22:06:06.700Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":"https://www.npmjs.org/package/obj-mix","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/dantman.png","metadata":{"files":{"readme":"README.md","changelog":null,"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":"2014-06-30T00:24:15.000Z","updated_at":"2014-06-30T07:09:52.000Z","dependencies_parsed_at":"2022-08-25T14:50:57.542Z","dependency_job_id":null,"html_url":"https://github.com/dantman/node-obj-mix","commit_stats":null,"previous_names":[],"tags_count":5,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/dantman%2Fnode-obj-mix","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/dantman%2Fnode-obj-mix/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/dantman%2Fnode-obj-mix/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/dantman%2Fnode-obj-mix/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/dantman","download_url":"https://codeload.github.com/dantman/node-obj-mix/tar.gz/refs/heads/develop","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":245458701,"owners_count":20618697,"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","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-12-03T06:32:05.542Z","updated_at":"2025-03-25T12:15:40.865Z","avatar_url":"https://github.com/dantman.png","language":"JavaScript","readme":"# obj-mix\n\n  [![NPM version](https://badge.fury.io/js/obj-mix.svg)](http://badge.fury.io/js/obj-mix)\n  [![Build Status](https://travis-ci.org/dantman/node-obj-mix.svg?branch=develop)](https://travis-ci.org/dantman/node-obj-mix)\n  [![Coverage Status](https://coveralls.io/repos/dantman/node-obj-mix/badge.png?branch=develop)](https://coveralls.io/r/dantman/node-obj-mix?branch=develop)\n  [![devDependencies](https://david-dm.org/dantman/node-obj-mix/dev-status.svg)](https://david-dm.org/dantman/node-obj-mix#info=devDependencies)\n\n\n**objMix** is a simple utility that lets you merge methods, simple properties, and property descriptors into an object.\n\nI've embraced JavaScript's prototypal nature and hate high-level class systems that try to turn JavaScript into something it is not. However I do like to simplify setting methods and properties onto a prototype. Up to now I've simply been using lodash's `_.merge` to do this. However I've recently been using getters in some node based projects. And while I can define these with `Object.defineProperties` it separates the definition of related properties and methods from each other.\n\nobjMix is a solution to that problem, call it with a base object such as a prototype and another object. objMix will merge functions and simple properties from the other object into that base object and use `Object.defineProperty` for anything that looks like a property descriptor.\n\n```javascript\nvar objMix = require('obj-mix');\n\nfunction Foo() {\n\t// This is Foo\n}\n\nobjMix(Foo.prototype, {\n\tbar: function() {\n\t\treturn \"This is a method.\";\n\t},\n\tbaz: \"This is a property.\",\n\tqux: {\n\t\tget: function() {\n\t\t\treturn \"This is a property with a getter.\";\n\t\t}\n\t}\n});\n\nvar foo = new Foo();\nconsole.log(foo.bar()); // \"This is a method.\";\nconsole.log(foo.baz); // \"This is a property.\";\nconsole.log(foo.qux); // \"This is a property with a getter.\";\n```\n","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdantman%2Fnode-obj-mix","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fdantman%2Fnode-obj-mix","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdantman%2Fnode-obj-mix/lists"}