{"_id":"style-equal","_rev":"2798163","name":"style-equal","description":"An efficient equality algorithm for React Native inline styles","dist-tags":{"latest":"1.0.0"},"maintainers":[{"name":"intelligibabble","email":""},{"name":"npm:intelligibabble","email":""}],"time":{"modified":"2022-07-18T11:45:18.000Z","created":"2016-04-24T21:17:20.954Z","1.0.0":"2016-04-24T21:17:20.954Z"},"users":{},"author":{"name":"Leland Richardson","email":"leland.m.richardson@gmail.com"},"repository":{"type":"git","url":"git+https://github.com/lelandrichardson/style-equal.git"},"versions":{"1.0.0":{"name":"style-equal","version":"1.0.0","description":"An efficient equality algorithm for React Native inline styles","main":"index.js","directories":{"test":"tests"},"scripts":{"test":"mocha"},"repository":{"type":"git","url":"git+https://github.com/lelandrichardson/style-equal.git"},"keywords":["react","react-native","shallow-equal","shouldcomponentupdate","style","stylesheet"],"author":{"name":"Leland Richardson","email":"leland.m.richardson@gmail.com"},"license":"MIT","bugs":{"url":"https://github.com/lelandrichardson/style-equal/issues"},"homepage":"https://github.com/lelandrichardson/style-equal#readme","devDependencies":{"chai":"^3.5.0","mocha":"^2.4.5"},"gitHead":"34fc5a568fe62e3d3f7a2538f442e8d331883b7b","_id":"style-equal@1.0.0","_shasum":"98a1c5922226bfe13c196e73f1940e91b8e66595","_from":".","_npmVersion":"3.3.6","_nodeVersion":"5.0.0","_npmUser":{"name":"intelligibabble","email":"leland.m.richardson@gmail.com"},"dist":{"shasum":"98a1c5922226bfe13c196e73f1940e91b8e66595","size":8642,"noattachment":false,"key":"/style-equal/-/style-equal-1.0.0.tgz","tarball":"http://registry.cnpm.dingdandao.com/style-equal/download/style-equal-1.0.0.tgz"},"maintainers":[{"name":"intelligibabble","email":""},{"name":"npm:intelligibabble","email":""}],"_npmOperationalInternal":{"host":"packages-16-east.internal.npmjs.com","tmp":"tmp/style-equal-1.0.0.tgz_1461532637927_0.2461093058809638"},"publish_time":1461532640954,"_hasShrinkwrap":false,"_cnpm_publish_time":1461532640954,"_cnpmcore_publish_time":"2021-12-16T21:38:04.296Z"}},"readme":"# style-equal\n\nAn efficient equality algorithm for React Native inline styles\n\n\n# Why\n\n`shouldComponentUpdate` is a powerful way to improve performance of react and\nreact native applications, but often you will want to allow for a component to have\na style prop to make the style of something be configurable.\n\nSince `style` in react native can be of many forms (an object, a number, an array of both,\nor a nested array of both), it is not trivial or practical to implement an equality test for these props\nin the `shouldComponentUpdate` method.\n\n\n## Installation\n\n```sh\nnpm i style-equal --save\n```\n\n\n\n## Usage\n\n```\nimport styleEqual from 'style-equal';\n\n// ...\n\nshouldComponentUpdate(nextProps) {\n  return !styleEqual(this.props.style, nextProps.style);\n}\n\n```\n\n\n## Caveats\n\nThe `styleEqual` algorithm is implemented to be fast and efficient for usage\nwith `shouldComponentUpdate` methods in react. The algorithm will never give\na false-positive (ie, saying two things are equal when they are not), however,\nthere are things that are semantically equivalent that the algorithm will \nreturn false for. One example of this is when comparing two styles such as:\n\n```\nstyleEqual([1, false, 2], [1, 2]) // returns false\n```\n\nThe above will always render the same styles, however the algorithm is built\nto assume that the position of a style will not change \"slots\" of the array.\n","_attachments":{},"homepage":"https://github.com/lelandrichardson/style-equal#readme","bugs":{"url":"https://github.com/lelandrichardson/style-equal/issues"},"license":"MIT"}