{"id":17983468,"url":"https://github.com/techjacker/mitsubishi","last_synced_at":"2025-04-04T02:13:02.161Z","repository":{"id":9710285,"uuid":"11663386","full_name":"techjacker/mitsubishi","owner":"techjacker","description":"Mixin utilities for extending prototypes","archived":false,"fork":false,"pushed_at":"2013-08-05T17:51:00.000Z","size":260,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-03-29T07:35:12.967Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":"","language":"JavaScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/techjacker.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2013-07-25T15:02:42.000Z","updated_at":"2014-04-07T21:39:50.000Z","dependencies_parsed_at":"2022-07-08T03:40:49.002Z","dependency_job_id":null,"html_url":"https://github.com/techjacker/mitsubishi","commit_stats":null,"previous_names":[],"tags_count":12,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/techjacker%2Fmitsubishi","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/techjacker%2Fmitsubishi/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/techjacker%2Fmitsubishi/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/techjacker%2Fmitsubishi/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/techjacker","download_url":"https://codeload.github.com/techjacker/mitsubishi/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":247107828,"owners_count":20884797,"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-10-29T18:17:20.038Z","updated_at":"2025-04-04T02:13:02.138Z","avatar_url":"https://github.com/techjacker.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# mitsubishi\n\nMixin utilities for extending prototypes\n\n\n[![Build Status](https://secure.travis-ci.org/techjacker/mitsubishi.png)](http://travis-ci.org/techjacker/mitsubishi)\n\n[![Sauce Labs Browser Test Status](https://saucelabs.com/buildstatus/mitsubishi)](https://saucelabs.com/u/mitsubishi)\n[![Sauce Labs Browser Test Status](https://saucelabs.com/browser-matrix/mitsubishi.svg)](https://saucelabs.com/u/mitsubishi)\n\n\n### Install\n\n#### Node\n\n```Shell\nnpm install mitsubishi\n```\n\n#### Browser\n\n```Shell\ncomponent install mitsubishi\n```\n\n```Shell\nbower install mitsubishi\n```\n\n## Usage\n\n#### mitsubishi.props(class, [classes])\n\nMixin JUST instance props (not proto props) from Obj literals + Classes.\n\n```JavaScript\nvar myStaticClass = {};\n\n/* .mixinInstanceProps() */\nmitsubishi.props(myStaticClass, [{hello:true}, {world:true}]);\n\nconsole.log('myStaticClass', myStaticClass);\n// outputs: {{hello:true, world:true}\n```\n\n#### mitsubishi.proto(class, [classes])\n\nMixin proto props of UNinstantiated Classes (and Obj literals) NOT instance props\n\n```JavaScript\nvar myDynamicClass = function () {};\nvar parentDynamicClass = function () {};\n\nparentDynamicClass.prototype.awesome = blah;\n\nmitsubishi.proto(myDynamicClass, [parentDynamicClass, {world:true}]);\n\nconsole.log('myDynamicClass', myDynamicClass);\n// outputs: {{awesome:\"blah\", world:true}\n```\n\n\n#### mitsubishi.protoInstantiated(class, [classes])\n\nMixin proto props of INSTANTIATED Classes (and Obj literals) NOT instance props\n\n\n```JavaScript\nvar myDynamicClass = function () {};\nvar parentDynamicClass = function () {};\n\nparentDynamicClass.prototype.awesome = blah;\nmyDynamicClass.hello = true;\n\nmitsubishi.protoInstance(myDynamicClass, [(new parentDynamicClass), {world:true}]);\n\nconsole.log('myDynamicClass', myDynamicClass);\n// outputs: {{awesome:\"blah\", world:true, hello:true}\n```\n\n\n### Docs\n[Yuidocs documentation here](docs/index.html)\n- fire up the connect server ```$ grunt docs```\n- navigate your browser to the [docs](http://localhost:9001)\n\n### API\n   - [mitsubishi](#mitsubishi)\n\u003ca name=\"\"\u003e\u003c/a\u003e\n \n\u003ca name=\"mitsubishi\"\u003e\u003c/a\u003e\n### mitsubishi\nshould export all needed API methods.\n\n```js\nexpect(mitsubishi).to.only.have.keys('proto', 'protoInstantiated', 'props', 'instancePropsFromInstantiated', 'protoPropsFromInstantiated', 'protoPropsFromUninstantiated');\ndone();\n```\n\n##### mitsubishi.instancePropsFromInstantiated() - copy instance properties from instantiated dynamic classes as well as object literals.\n\n```js\nexpect(mitsubishi.instancePropsFromInstantiated({}, [fixtures.A, fixtures.C])).to.only.have.keys('foo', 'bar', 'marbel');\nexpect(mitsubishi.instancePropsFromInstantiated({}, [fixtures.A, fixtures.B])).to.only.have.keys('foo', 'bar');\nexpect(mitsubishi.instancePropsFromInstantiated({}, fixtures.A)).to.only.have.keys('foo', 'bar');\nexpect(mitsubishi.instancePropsFromInstantiated({}, [fixtures.A, (new fixtures.B)])).to.only.have.keys('foo', 'bar', 'blah');\nexpect(mitsubishi.instancePropsFromInstantiated({}, [(new fixtures.B), fixtures.C])).to.only.have.keys('blah', 'marbel');\n\n// doesn't mix in proto props\nexpect(mitsubishi.instancePropsFromInstantiated({}, (new fixtures.B()))).to.not.have.key('protoproperty');\n\ndone();\n```\n\n##### mitsubishi.protoPropsFromInstantiated() - copy poto properties from dynamic classes (if instantiated) as well as object literals.\n\n```js\nexpect(mitsubishi.protoPropsFromInstantiated({}, [fixtures.A, fixtures.C])).to.have.key('foo', 'bar', 'marbel');\nexpect(mitsubishi.protoPropsFromInstantiated({}, [(new fixtures.B()), fixtures.C])).to.have.key('marbel');\nexpect(mitsubishi.protoPropsFromInstantiated({}, (new fixtures.B()))).to.have.key('protoproperty');\n\n///////////////////////////////////////////////////////////////////////////////////////////\n// MUST BE AN INSTANCE OF A DYNAMIC CLASS\n// to add a prototype of an uninstantiated dynamic class then....\n// use instancePropsFromInstantiated and....\n// directly reference its prototype\n/////////////////////////////////////////////////////////////////////////////////////////////\nexpect(mitsubishi.protoPropsFromInstantiated({}, fixtures.B)).to.not.have.key('protoproperty');\nexpect(mitsubishi.instancePropsFromInstantiated({}, fixtures.B.prototype)).to.have.key('protoproperty');\n// better to use .protoPropsFromUninstantiated()\nexpect(mitsubishi.protoPropsFromUninstantiated({}, fixtures.B)).to.have.key('protoproperty');\ndone();\n```\n\n##### mitsubishi.protoPropsFromUninstantiated() - copy poto properties from dynamic classes (if UNinstantiated) as well as object literals.\n\n```js\n// dynamic classes\n\t\tvar res = function () {};\n\t\t mitsubishi.protoPropsFromUninstantiated(res.prototype, fixtures.B);\n\t\texpect(res.prototype).to.have.key('protoproperty');\n// works with object literals too\n\t\texpect(mitsubishi.protoPropsFromUninstantiated({}, fixtures.B)).to.have.key('protoproperty');\n\t\tdone();\n```\n\nshould not copy instance props when using proto methods.\n\n```js\nfixtures.B.bull = true;\nBInst = new fixtures.B;\nBInst.cow = true;\n// expect(mitsubishi.protoPropsFromUninstantiated({}, BI)).to.not.have.key('bull');\nexpect(mitsubishi.protoPropsFromUninstantiated({}, fixtures.B)).to.not.have.key('bull');\nexpect(mitsubishi.instancePropsFromInstantiated({}, fixtures.B)).to.have.key('bull');\nexpect(mitsubishi.protoPropsFromInstantiated({}, fixtures.B)).to.not.have.key('bull');\nexpect(mitsubishi.instancePropsFromInstantiated({}, BInst)).to.have.key('cow');\nexpect(mitsubishi.protoPropsFromInstantiated({}, BInst)).to.not.have.key('cow');\n```\n\n## License\nCopyright (c) 2013 Andrew Griffiths \u003cmail@andrewgriffithsonline.com\u003e\n\nPermission is hereby granted, free of charge, to any person obtaining\na copy of this software and associated documentation files (the\n\"Software\"), to deal in the Software without restriction, including\nwithout limitation the rights to use, copy, modify, merge, publish,\ndistribute, sublicense, and/or sell copies of the Software, and to\npermit persons to whom the Software is furnished to do so, subject to\nthe following conditions:\n\nThe above copyright notice and this permission notice shall be\nincluded in all copies or substantial portions of the Software.\n\nTHE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND,\nEXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF\nMERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND\nNONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE\nLIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION\nOF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION\nWITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ftechjacker%2Fmitsubishi","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Ftechjacker%2Fmitsubishi","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ftechjacker%2Fmitsubishi/lists"}