{"_id":"jquery-extendext","_rev":"5-e505870261960ecb7f80c739faab7f50","name":"jquery-extendext","description":"jQuery.extend with configurable behaviour for arrays","dist-tags":{"latest":"1.0.0"},"versions":{"0.1.2":{"name":"jquery-extendext","version":"0.1.2","description":"jQuery.extend with configurable behaviour for arrays","authors":[{"name":"Damien \"Mistic\" Sorel","email":"contact@git.strangeplanet.fr","homepage":"http://www.strangeplanet.fr"}],"main":"jQuery.extendext.js","dependencies":{"jquery":">=1.9.1"},"devDependencies":{"grunt":"~1.0.0","grunt-contrib-qunit":"~0.7.0","grunt-contrib-uglify":"~1.0.0","grunt-contrib-jshint":"~1.0.0","grunt-qunit-blanket-lcov":"~0.3.1","grunt-coveralls":"~1.0.0"},"keywords":["jQuery","extend","arrays"],"license":"MIT","homepage":"https://github.com/mistic100/jQuery.extendext","repository":{"type":"git","url":"git://github.com/mistic100/jQuery.extendext.git"},"bugs":{"url":"https://github.com/mistic100/jQuery.extendext/issues"},"scripts":{"test":"grunt test"},"gitHead":"0769fb9e05c63fa567b7f920438b9ca0ffdf4ec0","_id":"jquery-extendext@0.1.2","_shasum":"d45b548b512d174a2a733d7ac2448b90456c7156","_from":".","_npmVersion":"3.10.8","_nodeVersion":"6.9.1","_npmUser":{"name":"mistic100","email":"contact@git.strangeplanet.fr"},"dist":{"shasum":"d45b548b512d174a2a733d7ac2448b90456c7156","tarball":"https://registry.npmjs.org/jquery-extendext/-/jquery-extendext-0.1.2.tgz","integrity":"sha512-soAVxmj/07pQUkkGqAPoBLKBT26BaYavHVe7ilqyYhcGQalPbpszS4RRU7XEyEuiZdE/V9HZT0a4wumZfxb9bg==","signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEUCIA+E83XUhxnF2uMq3UZBRR3UTFsLWKUXpFUcQz2jzyqeAiEA9jvT9XpGQff2h1rvgo03Q6CLzUDyr7KAWuf55ogXues="}]},"maintainers":[{"name":"mistic100","email":"contact@git.strangeplanet.fr"}],"_npmOperationalInternal":{"host":"packages-12-west.internal.npmjs.com","tmp":"tmp/jquery-extendext-0.1.2.tgz_1478283977441_0.4415671513415873"},"directories":{}},"1.0.0":{"name":"jquery-extendext","version":"1.0.0","description":"jQuery.extend with configurable behaviour for arrays","authors":[{"name":"Damien \"Mistic\" Sorel","email":"contact@git.strangeplanet.fr","homepage":"http://www.strangeplanet.fr"}],"main":"jquery-extendext.js","dependencies":{"jquery":">=1.9.1"},"devDependencies":{"jest":"^24.9.0","jest-expect-message":"^1.0.2"},"keywords":["jQuery","extend","arrays"],"license":"MIT","homepage":"https://github.com/mistic100/jQuery.extendext","repository":{"type":"git","url":"git://github.com/mistic100/jQuery.extendext.git"},"bugs":{"url":"https://github.com/mistic100/jQuery.extendext/issues"},"scripts":{"test":"jest tests/*.spec.js"},"gitHead":"4a2c42dc3ef59c3b53f2fe57e421aceb0849dd21","_id":"jquery-extendext@1.0.0","_nodeVersion":"10.16.2","_npmVersion":"6.10.3","_npmUser":{"name":"mistic100","email":"contact@git.strangeplanet.fr"},"dist":{"integrity":"sha512-gDJjpQ8ISd4ZMwSn0yXSuyufsPMCeWtWJ8kmqE85VromJqyVT2sdkHzS5yL0w1GK81UpOzmr2f9JgFln2sbJSg==","shasum":"00d6615e2ef7da630fbced293910002a1b281ee1","tarball":"https://registry.npmjs.org/jquery-extendext/-/jquery-extendext-1.0.0.tgz","fileCount":4,"unpackedSize":10606,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.4\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJd5lhuCRA9TVsSAnZWagAAeI8QAJmFWFtkjb8A0W7ePxW5\nLubEMiu8Iabz0euyshA+Lo/pq1w+cDsXcPAL5RCESxcIBYjBogsf0hCiBm0u\nvr/r6ae+lHWXdos5jYskCBCO7NAm1HXHeH0iq5NFVfmwlCIpdZlmSAv9IxQV\nYG6x2/KVcO2MSsVaLYOjzJEFKbUEcpsVofmL94+5IzfjtAB/wLGCRv+XR7QD\npJ/+5GF+Js+FYx62kS1V64jH6DkdykND2mH/AxHsH+MWqWTPg9hMGuXCB2r+\nkAx5FkEu71EkykbwI6ZcNMmiMmmRi0WodQJZjaTwFTICYwTGfnMvqDBOIQ6P\nf3L07+ZzEhVDwcXPoPFXQZhhLd07lO/7id7LJ9uSGQaTXChLr37pJ7nNVd6x\nh2Sauz6VMi+HUD7N3puOmRCNggexWGuqtIvOEGqTN0L8AP0uu17j9xB/XGf9\nnfVpdL3Xu62xNf45vpeOndL5b+mNNwKvDQDPwVgLOJegaWWQIyagp+1E2/6I\nisBHK3hmXiETzcAwklnm7/d8Byxl1Nl0eGfbwnAeYbcOBEcaymJV92mknsf8\nAhCIxGax6yqii/PDcpVua7DAswBcUvsTvFc/ZtHdMTYQ86Inoswif9uN2eKb\nku//C1w7Lt6SVoBsICja8jrcDgCe/L+wId1ql0F4o5g6sCNsQ5QoG86mEQ1c\nlKFq\r\n=9LVb\r\n-----END PGP SIGNATURE-----\r\n","signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEQCIAXBZ9QmyzliBxB11UxIHDbypB442Eyt4mKMn1DQpyfWAiBqn4XpVTtJFaLZh8JpfgD8GqEq+PMkk+LEo6gSwivyoQ=="}]},"maintainers":[{"name":"mistic100","email":"contact@git.strangeplanet.fr"}],"directories":{},"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/jquery-extendext_1.0.0_1575377006038_0.8473706840872695"},"_hasShrinkwrap":false}},"readme":"# jQuery.extendext\n\n[![npm version](https://img.shields.io/npm/v/jquery-extendext.svg?style=flat-square)](https://www.npmjs.com/package/jquery-extendext)\n[![jsDelivr CDN](https://data.jsdelivr.com/v1/package/npm/jquery-extendext/badge)](https://www.jsdelivr.com/package/npm/jquery-extendext)\n[![Build Status](https://github.com/mistic100/jQuery.extendext/workflows/CI/badge.svg)](https://github.com/mistic100/jQuery.extendext/actions)\n\njQuery.extend with configurable behaviour for arrays.\n\n## Isn't $.extend good enough ?\n\nWell, it's actually pretty good, and is generally sufficient, but it merges arrays in a strange way depending of what you want. Example:\n\n```js\nvar DEFAULTS = {\n  operators: ['AND', 'OR', 'XOR']\n};\n\nvar config = {\n  operators: ['OR', 'XOR']\n};\n\nconfig = $.extend(true, {}, DEFAULTS, config);\n```\n\nWhen executing this code, one will expects to get `config.operators = ['OR', 'XOR']`, but instead you get `['OR', 'XOR', 'XOR]`, because `$.extend` merges arrays like objects as per spec.\n\nOther deep merging utilities I found either have the same behaviour or perform both merge and append on array values ([nrf110/deepmerge](https://github.com/nrf110/deepmerge) for example).\n\n## Usage\n\n**jQuery.extendext.js** contains a new `$.extendext` function with the exact same behaviour as `$.extend` if not additional config is provided.\n\nThe difference is that it accepts a optional second string argument to specify how arrays should be merged.\n\n```js\njQuery.extendext([deep ,][arrayMode ,] target, object1 [, objectN ] )\n```\n\n* **deep** _boolean_ — If true, the merge becomes recursive (aka. deep copy).\n* **arrayMode** _string_ — Specify the arrays merge operation, either `replace`, `concat`, `extend` or `default`\n* **target** _object_ — The object to extend. It will receive the new properties.\n* **object1** _object_ — An object containing additional properties to merge in.\n* **objectN** _object_ — Additional objects containing properties to merge in.\n\n### \"replace\" mode\n\nIn this mode, every Array values in `target` is replaced by a copy of the same value found in `objectN`. The copy is recursive if `deep` is true.\n\n```js\nvar DEFAULTS = {\n  operators: ['AND', 'OR', 'XOR']\n};\n\nvar config = {\n  operators: ['OR', 'XOR']\n};\n\nconfig = $.extendext(true, 'replace', {}, DEFAULTS, config);\n\nassert.deepEqual(config, {\n  operators: ['OR', 'XOR']\n}) // true;\n```\n\n### \"concat\" mode\n\nIn this mode, Arrays found in both `target` and `objectN` are always concatenated. If `deep` is true, a recursive copy of each value if concatenated instead of the value itself.\n\n```js\nvar DEFAULTS = {\n  operators: ['AND', 'OR', 'XOR']\n};\n\nvar config = {\n  operators: ['OR', 'XOR']\n};\n\nconfig = $.extendext(true, 'concat', {}, DEFAULTS, config);\n\nassert.deepEqual(config, {\n  operators: ['AND', 'OR', 'XOR', 'OR', 'XOR']\n}) // true;\n```\n\n### \"extend\" mode\n\nThis is how [nrf110/deepmerge](https://github.com/nrf110/deepmerge) works. In this mode, Arrays values are treated a bit differently:\n\n* If plain objects are found at the same position in both `target` and `objectN` they are merged recursively or not (depending on `deep` option).\n* Otherwise, if the value in `objectN` is not found in `target`, it is pushed at the end of the array.\n\n```js\nvar DEFAULTS = {\n  operators: ['AND', 'OR', 'XOR']\n};\n\nvar config = {\n  operators: ['XOR', 'NAND']\n};\n\nconfig = $.extendext(true, 'extend', {}, DEFAULTS, config);\n\nassert.deepEqual(config, {\n  operators: ['AND', 'OR', 'XOR', 'NAND']\n}) // true;\n```\n\n### \"default\" mode\n\nSame as `$.extend`.\n\n```js\nvar DEFAULTS = {\n  operators: ['AND', 'OR', 'XOR']\n};\n\nvar config = {\n  operators: ['OR', 'XOR']\n};\n\nconfig = $.extendext(true, 'default', {}, DEFAULTS, config);\n\nassert.deepEqual(config, {\n  operators: ['OR', 'XOR', 'XOR']\n}) // true;\n```\n\n## Tests\n\nA jest test suite is provided in `tests` directory.\n\n`$.extendext` is tested against core jQuery tests for `$.extend` and `nrf110/deepmerge` tests (with the difference that extendext, like extend, modifies the first argument where deepmerge does not touch it).\n","maintainers":[{"name":"mistic100","email":"contact@git.strangeplanet.fr"}],"time":{"modified":"2022-06-19T05:02:42.290Z","created":"2016-11-04T18:26:19.029Z","0.1.2":"2016-11-04T18:26:19.029Z","1.0.0":"2019-12-03T12:43:26.163Z"},"homepage":"https://github.com/mistic100/jQuery.extendext","keywords":["jQuery","extend","arrays"],"repository":{"type":"git","url":"git://github.com/mistic100/jQuery.extendext.git"},"bugs":{"url":"https://github.com/mistic100/jQuery.extendext/issues"},"license":"MIT","readmeFilename":"README.md"}