{"_id":"knockout.merge","_rev":"14-57a29a541ae7805ce7cccc8578967551","name":"knockout.merge","description":"A KnockoutJS Plugin for merging of json into existing objects or object hierarchies, helpful for using knockout.validation models with json data","dist-tags":{"latest":"1.5.8"},"versions":{"1.4.0":{"name":"knockout.merge","version":"1.4.0","description":"A KnockoutJS Plugin for merging of json into existing objects or object hierarchies, helpful for using knockout.validation models with json data","main":"src/knockout.merge.js","files":["src/knockout.merge.js"],"dependencies":{"knockout":"3.2.0"},"repository":{"type":"git","url":"https://github.com/grofit/knockout.merge.git"},"author":{"name":"Grofit","email":"grofit1@yahoo.com"},"license":"MIT","bugs":{"url":"https://github.com/grofit/knockout.merge/issues"},"keywords":["knockout"],"gitHead":"5ac1216b1ed7f9b9d270712785cf1cd72d74747f","homepage":"https://github.com/grofit/knockout.merge","_id":"knockout.merge@1.4.0","scripts":{},"_shasum":"87a8ba953d0d53645d0b516cf82d65d5bf4ba1d5","_from":".","_npmVersion":"1.4.28","_npmUser":{"name":"grofit","email":"grofit1@yahoo.com"},"maintainers":[{"name":"grofit","email":"grofit1@yahoo.com"}],"dist":{"shasum":"87a8ba953d0d53645d0b516cf82d65d5bf4ba1d5","tarball":"https://registry.npmjs.org/knockout.merge/-/knockout.merge-1.4.0.tgz","integrity":"sha512-ZAkr2R0WpfNKVkaSPwdqvrLzqi8qoEkcmsBdbTbYyuNxJK3rPBuhHiCqibxw1Ub1szxdKk92sitn+Uy1EGwJJQ==","signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEUCIDgOJl5AwHAPNGHUYvkSVdvpk7zhvZ75OhZ41Ss2GjCIAiEAiN8C6uwK4m6eUEVgX+wCeu3s0EPAkG6DRvkG6VeXwKQ="}]}},"1.4.2":{"name":"knockout.merge","version":"1.4.2","description":"A KnockoutJS Plugin for merging of json into existing objects or object hierarchies, helpful for using knockout.validation models with json data","main":"src/knockout.merge.js","files":["src/knockout.merge.js"],"peerDependencies":{"knockout":"3.x"},"repository":{"type":"git","url":"https://github.com/grofit/knockout.merge.git"},"author":{"name":"Grofit","email":"grofit1@yahoo.com"},"license":"MIT","bugs":{"url":"https://github.com/grofit/knockout.merge/issues"},"keywords":["knockout"],"gitHead":"dc07fd08b23008a14d45b8567dabf8d89942fa9d","homepage":"https://github.com/grofit/knockout.merge","_id":"knockout.merge@1.4.2","scripts":{},"_shasum":"4badba91c038f65c14409cf5663ed69f064e9ba5","_from":".","_npmVersion":"2.7.1","_nodeVersion":"0.12.0","_npmUser":{"name":"grofit","email":"grofit1@yahoo.com"},"dist":{"shasum":"4badba91c038f65c14409cf5663ed69f064e9ba5","tarball":"https://registry.npmjs.org/knockout.merge/-/knockout.merge-1.4.2.tgz","integrity":"sha512-ZAAT/lK3YcvlegO+JKUYOZHzlyQPKSl90LapVWSzsWbcYjj+K2AhucezMPZ6agKpj05PU8Uqq3xR6hObpduY+g==","signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEYCIQDq5zFiwNt6U4bRTVbt8D3PC/IEraqVuJTiNx1JMAlOSAIhANGUhnzPueEFbdMNPISMpPb0pZLoLU8cLAGs0TsrTtj3"}]},"maintainers":[{"name":"grofit","email":"grofit1@yahoo.com"}]},"1.5.0":{"name":"knockout.merge","version":"1.5.0","description":"A KnockoutJS Plugin for merging of json into existing objects or object hierarchies, helpful for using knockout.validation models with json data","main":"src/knockout.merge.js","files":["src/knockout.merge.js"],"peerDependencies":{"knockout":"3.x"},"repository":{"type":"git","url":"git+https://github.com/grofit/knockout.merge.git"},"author":{"name":"Grofit","email":"grofit1@yahoo.com"},"license":"MIT","bugs":{"url":"https://github.com/grofit/knockout.merge/issues"},"keywords":["knockout"],"gitHead":"7507060beeee1fab0f47be21318427ec1d2c6e59","homepage":"https://github.com/grofit/knockout.merge#readme","_id":"knockout.merge@1.5.0","scripts":{},"_shasum":"9e42d3d8d086f30332f318260dbb7bcb170f81d0","_from":".","_npmVersion":"2.13.2","_nodeVersion":"0.12.0","_npmUser":{"name":"grofit","email":"grofit1@yahoo.com"},"dist":{"shasum":"9e42d3d8d086f30332f318260dbb7bcb170f81d0","tarball":"https://registry.npmjs.org/knockout.merge/-/knockout.merge-1.5.0.tgz","integrity":"sha512-8IGWiYblgS0OM6XO+7rR+t4PkLGedBAG+Qs8XglBdLgbwiHk19QzawONZaWx2gMe/6Pcb6WXuUcf/B3MJa5Rww==","signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEUCIQDDoVk0ou1DE2gPoSy196jVxQzMq9RCN04Wtm7jGxqY6gIgMPw7xqVcqBTZxOpyRQi0kLJdQqymDfFjlgHPJ0imY/o="}]},"maintainers":[{"name":"grofit","email":"grofit1@yahoo.com"}]},"1.5.1":{"name":"knockout.merge","version":"1.5.1","description":"A KnockoutJS Plugin for merging of json into existing objects or object hierarchies, helpful for using knockout.validation models with json data","main":"src/knockout.merge.js","files":["src/knockout.merge.js"],"peerDependencies":{"knockout":"3.x"},"repository":{"type":"git","url":"git+https://github.com/grofit/knockout.merge.git"},"author":{"name":"Grofit","email":"grofit1@yahoo.com"},"license":"MIT","bugs":{"url":"https://github.com/grofit/knockout.merge/issues"},"keywords":["knockout"],"gitHead":"4a75903eb285fca7d0fffb031af6b2a4009e4d2b","homepage":"https://github.com/grofit/knockout.merge#readme","_id":"knockout.merge@1.5.1","scripts":{},"_shasum":"1d402723794dca48cd25f2fdbe281e794e6bf3ef","_from":".","_npmVersion":"2.13.2","_nodeVersion":"0.12.0","_npmUser":{"name":"grofit","email":"grofit1@yahoo.com"},"dist":{"shasum":"1d402723794dca48cd25f2fdbe281e794e6bf3ef","tarball":"https://registry.npmjs.org/knockout.merge/-/knockout.merge-1.5.1.tgz","integrity":"sha512-HpXAGYLSSQJOd890kSlI7jAmbj6h5cXe5BFUTPhHF626reDL8WJCcGNFzidx0ZHawlPbD8d0vvg6qUZbVJaNzg==","signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEQCIHNDijnf9hOTphqMZoyafB+jZxWvJ2WCY7tgNfK3wMx8AiAaQ4CjCOMrsFcIDPgFoRty32/VBUeN+4fahrTzP0xM/Q=="}]},"maintainers":[{"name":"grofit","email":"grofit1@yahoo.com"}]},"1.5.2":{"name":"knockout.merge","version":"1.5.2","description":"A KnockoutJS Plugin for merging of json into existing objects or object hierarchies, helpful for using knockout.validation models with json data","main":"src/knockout.merge.js","files":["src/knockout.merge.js"],"peerDependencies":{"knockout":"3.x"},"repository":{"type":"git","url":"git+https://github.com/grofit/knockout.merge.git"},"author":{"name":"Grofit","email":"grofit1@yahoo.com"},"license":"MIT","bugs":{"url":"https://github.com/grofit/knockout.merge/issues"},"keywords":["knockout"],"gitHead":"5db73ba33779de5c3f57fa3d0d750bcb8f9dd99f","homepage":"https://github.com/grofit/knockout.merge#readme","_id":"knockout.merge@1.5.2","scripts":{},"_shasum":"1239ac2c7b3ecd649cdffa8367fc80df5cb7cb52","_from":".","_npmVersion":"2.13.2","_nodeVersion":"0.12.0","_npmUser":{"name":"grofit","email":"grofit1@yahoo.com"},"dist":{"shasum":"1239ac2c7b3ecd649cdffa8367fc80df5cb7cb52","tarball":"https://registry.npmjs.org/knockout.merge/-/knockout.merge-1.5.2.tgz","integrity":"sha512-fcsYPj07hdXIfsG3ZeU04eFTmN73UyvqO+DFGY/QjuVBo6aEep8frycf3yEozvk6kvgHDFrtZT9IORq6ke+new==","signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEYCIQCmYAjqnYR3ZAtRW+wjoYZ3YwWXYX0idKnMPe0ErVgpWAIhAOtL01pwczLkuAD04t3rFi7kLuLa2VBxRbYnSrB5YUwE"}]},"maintainers":[{"name":"grofit","email":"grofit1@yahoo.com"}]},"1.5.3":{"name":"knockout.merge","version":"1.5.3","description":"A KnockoutJS Plugin for merging of json into existing objects or object hierarchies, helpful for using knockout.validation models with json data","main":"src/knockout.merge.js","files":["src/knockout.merge.js"],"peerDependencies":{"knockout":"3.x"},"repository":{"type":"git","url":"git+https://github.com/grofit/knockout.merge.git"},"author":{"name":"Grofit","email":"grofit1@yahoo.com"},"license":"MIT","bugs":{"url":"https://github.com/grofit/knockout.merge/issues"},"keywords":["knockout"],"gitHead":"e723dff034329255fbf36e093323909e823e10a4","homepage":"https://github.com/grofit/knockout.merge#readme","_id":"knockout.merge@1.5.3","scripts":{},"_shasum":"7bee4fa78a41d397df3d56d2d8b68a13ee434efe","_from":".","_npmVersion":"2.13.2","_nodeVersion":"0.12.0","_npmUser":{"name":"grofit","email":"grofit1@yahoo.com"},"dist":{"shasum":"7bee4fa78a41d397df3d56d2d8b68a13ee434efe","tarball":"https://registry.npmjs.org/knockout.merge/-/knockout.merge-1.5.3.tgz","integrity":"sha512-WTss33j/eMJTHxRTxOje8Eg6+oEDOtgr7ZkEEAOjnNZyt4NzCNHob9E+FCXlfbx66o4Nn1qOHAjjVvlZeuaN4g==","signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEYCIQCoJyBn8cYPrR+ytT41IrmLjVUU4mGu+Udg3MTDRCkpuQIhALIo/qPDxOOGMlHRTy+Eq4H/0dsOHK6n6NDrbibjneXr"}]},"maintainers":[{"name":"grofit","email":"grofit1@yahoo.com"}]},"1.5.4":{"name":"knockout.merge","version":"1.5.4","description":"A KnockoutJS Plugin for merging of json into existing objects or object hierarchies, helpful for using knockout.validation models with json data","main":"src/knockout.merge.js","files":["src/knockout.merge.js"],"peerDependencies":{"knockout":"3.x"},"repository":{"type":"git","url":"git+https://github.com/grofit/knockout.merge.git"},"author":{"name":"Grofit","email":"grofit1@yahoo.com"},"license":"MIT","bugs":{"url":"https://github.com/grofit/knockout.merge/issues"},"keywords":["knockout"],"gitHead":"12989220985abd7d28a5328b7c3cdefb8c4894ed","homepage":"https://github.com/grofit/knockout.merge#readme","_id":"knockout.merge@1.5.4","scripts":{},"_shasum":"cff186534a611ec51c412c4bf7bc559c7144d368","_from":".","_npmVersion":"2.13.2","_nodeVersion":"0.12.0","_npmUser":{"name":"grofit","email":"grofit1@yahoo.com"},"dist":{"shasum":"cff186534a611ec51c412c4bf7bc559c7144d368","tarball":"https://registry.npmjs.org/knockout.merge/-/knockout.merge-1.5.4.tgz","integrity":"sha512-kGqwYB+TknEAsPNy19FhaS5zoK9p/zAXSdy/XuLa2OLUed5Q6C68Cxe07WFzobxeQiHgnUcPoBuWfp6dIdkDqA==","signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEUCIQC2KWk8z6xSweU+/8ZuYMuZunyPx0kVN+nVmWgKSGPuigIgWOc5n+bN2tjVjruNpg0z/OFqDtZqtPanHeSywcoNnKY="}]},"maintainers":[{"name":"grofit","email":"grofit1@yahoo.com"}]},"1.5.5":{"name":"knockout.merge","version":"1.5.5","description":"A KnockoutJS Plugin for merging of json into existing objects or object hierarchies, helpful for using knockout.validation models with json data","main":"src/knockout.merge.js","files":["src/knockout.merge.js"],"peerDependencies":{"knockout":"3.x"},"repository":{"type":"git","url":"git+https://github.com/grofit/knockout.merge.git"},"author":{"name":"Grofit","email":"grofit1@yahoo.com"},"license":"MIT","bugs":{"url":"https://github.com/grofit/knockout.merge/issues"},"keywords":["knockout"],"gitHead":"125d833ea682bb5fadc47046367345c3f5b8908a","homepage":"https://github.com/grofit/knockout.merge#readme","_id":"knockout.merge@1.5.5","scripts":{},"_shasum":"ef320142de7e792739ed05ccf405d6d01cce998c","_from":".","_npmVersion":"2.13.2","_nodeVersion":"0.12.0","_npmUser":{"name":"grofit","email":"grofit1@yahoo.com"},"dist":{"shasum":"ef320142de7e792739ed05ccf405d6d01cce998c","tarball":"https://registry.npmjs.org/knockout.merge/-/knockout.merge-1.5.5.tgz","integrity":"sha512-RnNuOCwJwveiyeSTAnV+nk244VyFLYtQhxNMLmBoLrs3Ea41QPYwgAlDnZqi/8g74boE4GAiEgHJsggnpB+V2Q==","signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEUCIAQEw7F/Necr3IlsvGOttsQy8lMSZlgEzITKTWzxo0itAiEAnhgR/ZrYKZ6m3gCrt8qJpcTFQC4NFHTJzYI6a9tmT1g="}]},"maintainers":[{"name":"grofit","email":"grofit1@yahoo.com"}]},"1.5.6":{"name":"knockout.merge","version":"1.5.6","description":"A KnockoutJS Plugin for merging of json into existing objects or object hierarchies, helpful for using knockout.validation models with json data","main":"src/knockout.merge.js","files":["src/knockout.merge.js"],"peerDependencies":{"knockout":"3.x"},"repository":{"type":"git","url":"git+https://github.com/grofit/knockout.merge.git"},"author":{"name":"Grofit","email":"grofit1@yahoo.com"},"license":"MIT","bugs":{"url":"https://github.com/grofit/knockout.merge/issues"},"keywords":["knockout"],"gitHead":"bb2905033196c6242899416b1bf1f2483a4ac5c5","homepage":"https://github.com/grofit/knockout.merge#readme","_id":"knockout.merge@1.5.6","scripts":{},"_shasum":"9a0602480c2070570f99637375eb486492dcd930","_from":".","_npmVersion":"3.10.8","_nodeVersion":"6.8.1","_npmUser":{"name":"grofit","email":"grofit1@yahoo.com"},"dist":{"shasum":"9a0602480c2070570f99637375eb486492dcd930","tarball":"https://registry.npmjs.org/knockout.merge/-/knockout.merge-1.5.6.tgz","integrity":"sha512-2f2Rv7K/ogRp7Mcm5/Diqx7w2gQnDwvcP9BF1Cnn2LBRYVc2ytW4Ay3IiqP3jHSvgcb0GuWaI9/GKQs8OPzcXA==","signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEQCIEiCWnkBB7webvvr5omQI+8wg6Znca/VpOffqUJrItAjAiA8/9juxZdudempT9aZRPLe1jSxtl2di12JZvObBfQlrQ=="}]},"maintainers":[{"name":"grofit","email":"grofit1@yahoo.com"}],"_npmOperationalInternal":{"host":"packages-18-east.internal.npmjs.com","tmp":"tmp/knockout.merge-1.5.6.tgz_1493731992738_0.15190012892708182"}},"1.5.7":{"name":"knockout.merge","version":"1.5.7","description":"A KnockoutJS Plugin for merging of json into existing objects or object hierarchies, helpful for using knockout.validation models with json data","main":"src/knockout.merge.js","typings":"index.d.ts","files":["src/knockout.merge.js","index.d.ts"],"peerDependencies":{"knockout":"3.x"},"repository":{"type":"git","url":"git+https://github.com/grofit/knockout.merge.git"},"author":{"name":"Grofit","email":"grofit1@yahoo.com"},"license":"MIT","bugs":{"url":"https://github.com/grofit/knockout.merge/issues"},"keywords":["knockout"],"gitHead":"1338f25e9da1ba26081935e07537a8ddfe0e0719","homepage":"https://github.com/grofit/knockout.merge#readme","_id":"knockout.merge@1.5.7","scripts":{},"_shasum":"259313e4b5c4cec7d53a267fec4c47a9f686b202","_from":".","_npmVersion":"3.10.8","_nodeVersion":"6.8.1","_npmUser":{"name":"grofit","email":"grofit1@yahoo.com"},"dist":{"shasum":"259313e4b5c4cec7d53a267fec4c47a9f686b202","tarball":"https://registry.npmjs.org/knockout.merge/-/knockout.merge-1.5.7.tgz","integrity":"sha512-lKINUpT8+pzy1dOrPO+FJzMiN4/Fl/MCSBH4DfHhacPO2d52pAFr8ieV9qRy3WGgpJR+ZWCg20XZQBzzVpz9Mw==","signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEUCIQD0T+H3xuPbOvDSXWLNdjHxOG8D0A7E59V/aK8XkvElNgIgdjxws81kpb2W72VNVyijGay8LSr4uX8p3pny4d7HvLE="}]},"maintainers":[{"name":"grofit","email":"grofit1@yahoo.com"}],"_npmOperationalInternal":{"host":"packages-12-west.internal.npmjs.com","tmp":"tmp/knockout.merge-1.5.7.tgz_1493733582310_0.8180373886134475"}},"1.5.8":{"name":"knockout.merge","version":"1.5.8","description":"A KnockoutJS Plugin for merging of json into existing objects or object hierarchies, helpful for using knockout.validation models with json data","main":"src/knockout.merge.js","types":"index.d.ts","peerDependencies":{"knockout":"3.x"},"repository":{"type":"git","url":"git+https://github.com/grofit/knockout.merge.git"},"author":{"name":"Grofit","email":"grofit1@yahoo.com"},"license":"MIT","bugs":{"url":"https://github.com/grofit/knockout.merge/issues"},"keywords":["knockout"],"gitHead":"fb5e89848ad9f68c0d3c5228b2072f849a713c1c","homepage":"https://github.com/grofit/knockout.merge#readme","_id":"knockout.merge@1.5.8","scripts":{},"_shasum":"59ec34d408760208382849b4859d3bb7f18c3bcd","_from":".","_npmVersion":"3.10.8","_nodeVersion":"6.8.1","_npmUser":{"name":"grofit","email":"grofit1@yahoo.com"},"dist":{"shasum":"59ec34d408760208382849b4859d3bb7f18c3bcd","tarball":"https://registry.npmjs.org/knockout.merge/-/knockout.merge-1.5.8.tgz","integrity":"sha512-PGVzq3M/c6cE+G/PvXo3eQ90340qOQoFyUmq32jCoAQogSFSxkD81LlGFaOrjsmggXbsSCk0qQNfKIhFb8rltw==","signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEUCIF1OWX3fjm5WseZz6u53YjEAY2p0da0wbI0O/zwJ6entAiEAzDnOE/nVNAB1gNHVpZQBCBbNWntr/JpY6FE9uKVnesw="}]},"maintainers":[{"name":"grofit","email":"grofit1@yahoo.com"}],"_npmOperationalInternal":{"host":"packages-18-east.internal.npmjs.com","tmp":"tmp/knockout.merge-1.5.8.tgz_1493801679996_0.1749463297892362"}}},"readme":"# Knockout.Merge\r\n\r\nA simple addition to to the ko namespace to allow merging data into an existing object.\r\n\r\nI was finding working with models which exposed bindings in a nested nature would not cope well with \r\ndynamic json data. It was either use the mapping plugin to generate the model which removed the ability\r\nto use computed observables without attaching them to the instance or manually writing the mapping logic\r\nto map data against a given model.\r\n\r\nSo this simple plugin was designed to take the effort out of working with external data sources which use \r\nsome form of model as a contract. It will auto merge any data into the bindings without destroying or replacing\r\nany of the underlying objects functions. It works fine with nested objects and complex arrays, just make \r\nsure that the names of the json keys match the binding names.\r\n\r\nSince version 1.5.0 it also works with knockout-es5 module so you can marge in and it will work on the observable\r\nbehind the scenes so all your existing functionality (custom rules/methods/constructors) will work with them,\r\nalthough its all optional, if you dont use knockout-es5 then it will just operate as normal.\r\n\r\nThis can be used in nodejs by using `npm install knockout.merge`, then just require it after knockout\r\nand it will extend the object internally.\r\n\r\n## BREAKING CHANGE SINCE VERSION 1.4.0\r\n\r\nSince version 1.4.0 the dependency on knockout.mapping has been completely removed as it relies upon no functionality\r\nfrom the library it was just in there to make it more familiar to developers. Now it has been moved to its own property\r\nupon the knockout object, so now it should be:\r\n\r\n```\r\nko.merge.fromJS(model, data);\r\n```\r\n\r\nAlso the name of the file has been changed to reflect this to now be `knockout.merge.js`.\r\n\r\n## BREAKING CHANGE SINCE VERSION 1.3.0\r\n\r\nSince version 1.3.0 to improve requirejs and module loading capabilities the merge logic is no longer merged into the\r\n`knockout.mapping namespace` it is now in its own namespace `knockout.mapping.merge`. This is mainly done because\r\nin certain situations you would load knockout.mapping.merge as a module via a resource loader you may have all your\r\nobjects isolated i.e:\r\n\r\n```\r\nvar ko = require(\"knockout\");\r\nko.mapping = require(\"knockout.mapping\");\r\nko.mapping = require(\"knockout.mapping.merge\"); // wont work as you overwrite the mapping var\r\n```\r\n\r\nSo instead we moved all logic into its own namespace so it should now be:\r\n```\r\nvar ko = require(\"knockout\");\r\nko.mapping = require(\"knockout.mapping\");\r\nko.mapping.merge = require(\"knockout.mapping.merge\"); // will work as you are not merging functionality into ko.mapping\r\n```\r\n\r\nAnyway that aside there are now some changes to the method names as it makes no sense to have `ko.mapping.merge.mergeFromJs`, \r\nso it has now been changed to `ko.mapping.merge.fromJS` and `ko.mapping.merge.rules` (for your custom rules).\r\n\r\nThe knockout observable extensions remain unchanged so you wont need to worry about changing any of that stuff.\r\n\r\nThe examples are all updated to reflect this so check out the source code if you are unsure what I mean.\r\n\r\nFinally there is an update to the d.ts file for typescript, which should be compatible with DefinitelyTyped stuff,\r\nso just whack it in a folder and feel free to change the references to whatever you want them to be.\r\n\r\n## Example\r\n\r\nA simple example of merging some Json data into an existing model:\r\n```\r\nfunction User() {\r\n    var self = this;\r\n    \r\n    self.Firstname = ko.observable();\r\n    self.Surname = ko.observable();\r\n    \r\n    self.Fullname = ko.computed(function() {\r\n        return self.Firstname() + \" \" + self.Surname();\r\n    });\r\n}\r\n\r\nvar someJson = {\r\n\tFirstname: \"James\",\r\n\tSurname: \"Bond\"\r\n};\r\n\r\nvar someUser = new User();\r\nko.merge.fromJS(someUser, someJson);\r\n\r\n// Will output \"James Bond\"\r\nalert(someUser.Fullname());\r\n```\r\n\r\nThis should also solve the problem when using Knockout Validation, as the model remains intact so you \r\ncan map from json or complex objects without worrying about losing your bindings:\r\n\r\n```\r\nfunction User() {\r\n    var self = this;\r\n    \r\n\tself.Age = ko.observable().extend({ digits: true });\r\n    self.Firstname = ko.observable().extend({ maxLength: 20 });\r\n    self.Surname = ko.observable().extend({ maxLength: 20 });\r\n    \r\n    self.Fullname = ko.computed(function() {\r\n        return self.Firstname() + \" \" + self.Surname();\r\n    });\r\n}\r\n\r\nvar someJson = {\r\n\tFirstname: \"James\",\r\n\tSurname: \"Bond\",\r\n\tAge: 40\r\n};\r\n\r\nvar someUser = new User();\r\nko.merge.fromJS(someUser, someJson);\r\n\r\n```\r\n\r\nThere is also an option to infer the types for observable arrays so you can just auto-merge array elements into \r\nyour observables, however this functionality will not be able to distinguish between existing elements and new elements\r\nso this will currently just append elements to the array not merge them.\r\n\r\nYou can do this like this:\r\n\r\n```\r\nfunction SomeChildModel()\r\n{\r\n   this.Name = ko.observable();\r\n}\r\n\r\nfunction SomeModel()\r\n{\r\n   this.someArray = ko.observableArray().withMergeConstructor(SomeChildModel);\r\n}\r\n```\r\n\r\nThere has been some new additions to allow you to write custom merging logic, this is useful for certain\r\nsituations such as mapping date strings to date objects, or do anything more complicated than a simple data replacement. \r\nYou can either do this by embedding your own method into the merging logic such as:\r\n\r\n```\r\nfunction SomeModel()\r\n{\r\n\tthis.Date = ko.observable(new Date()).withMergeMethod(function(knockoutElement, dataElement, options) {\r\n\t\tknockoutElement(new Date(dataElement));\r\n\t});\r\n}\r\n```\r\n\r\nPersonally I am not a massive fan of this as you will rarely want to embed your mapping logic into your pojo models, so\r\nif you want to use more of an AOP style approach and have your logic elsewhere then use the merging rules style settings:\r\n\r\n```\r\n// This can go anywhere, just make sure you include the required libs first \r\nko.merge.mergeRules[\"Date\"] = function(knockoutElement, dataElement, options) {\r\n\tknockoutElement(new Date(dataElement));\r\n};\r\n\r\nfunction SomeModel()\r\n{\r\n\tthis.Date = ko.observable(new Date()).withMergeRule(\"Date\");\r\n}\r\n```\r\n\r\n### Global Handlers\r\n\r\nIn version 1.5.1 you can also use global handlers, which are provided the current elements to see if it can deal with them,\r\nin most cases you will not need to use these. However lets imagine you have `Date` objects in your models and you do not\r\nwant to have to constantly add `.withMergeRule(\"my-date-rule\")` you can make a handler to check if it is a date object, and\r\nif so do something useful with it. Handlers should return a true if they have handled the data or a false if they are not.\r\n\r\nA global handler should be a function taking the knockout element and data element and returning a bool as mentioned above,\r\nhere is a simple example of one:\r\n\r\n```\r\nvar globalDateHandler = function(knockoutElement, dataElement, options) {\r\n    if(knockoutElement() instanceof Date) {\r\n        knockoutElement(new Date(dataElement));\r\n        return true; // We handled it so no need to check with other handling mechanisms\r\n    }\r\n    return false; // It is not a date type, so delegate to normal handlers\r\n}\r\n\r\nko.merge.globalHandlers.push(globalDateHandler);\r\n```\r\n\r\nThis is for niche scenarios where you do want to do system wide stuff and remember these global handlers will be iterated\r\nover for EVERY entry in the data model, so if you are doing some resource intensive stuff in there expect some slowdown.\r\nHowever in most cases *\"Fast is fast enough\"* so I wouldn't worry, and if there are no handlers then the normal merging\r\npredicates are used.\r\n\r\nYou can omit the options, and they are for you to be able to write your own options for passing into rules, however\r\nthere is one rule the native merge uses `mergeMissingAsObservables: true | false`, if it is true then if you were to\r\nhave an empty json containing object, it would end up creating it with observable fields not primitive ones.\r\n\r\nFinally there is also a typescript descriptor file available in the source folder to give you compile time safety.\r\n\r\nHere is an example of what it does and how to use it, but you will need to check out the source code.\r\n[View Example](https://rawgithub.com/grofit/knockout.merge/master/example.html)\r\n\r\nHere are the tests which you can run in your own browser:\r\n[View Tests] (https://rawgit.com/grofit/knockout.merge/master/tests/test-runner.html)\r\n","maintainers":[{"name":"grofit","email":"grofit1@yahoo.com"}],"time":{"modified":"2022-06-19T09:06:13.597Z","created":"2014-11-18T20:15:52.617Z","1.4.0":"2014-11-18T20:15:52.617Z","1.4.2":"2015-05-13T14:39:02.969Z","1.5.0":"2015-08-13T13:37:08.050Z","1.5.1":"2015-08-13T15:35:53.201Z","1.5.2":"2015-08-20T20:25:45.340Z","1.5.3":"2015-09-11T15:09:31.434Z","1.5.4":"2015-10-12T12:45:39.963Z","1.5.5":"2015-10-12T13:32:25.197Z","1.5.6":"2017-05-02T13:33:13.513Z","1.5.7":"2017-05-02T13:59:44.294Z","1.5.8":"2017-05-03T08:54:40.757Z"},"homepage":"https://github.com/grofit/knockout.merge#readme","keywords":["knockout"],"repository":{"type":"git","url":"git+https://github.com/grofit/knockout.merge.git"},"author":{"name":"Grofit","email":"grofit1@yahoo.com"},"bugs":{"url":"https://github.com/grofit/knockout.merge/issues"},"license":"MIT","readmeFilename":"readme.md"}