{"name":"compare-func","version":"1.3.4","description":"Get a compare function for array to sort","homepage":"https://github.com/stevemao/compare-func","author":{"name":"Steve Mao","email":"maochenyan@gmail.com","url":"https://github.com/stevemao"},"repository":{"type":"git","url":"git+https://github.com/stevemao/compare-func.git"},"license":"MIT","keywords":["compare-func","arr","array","by","compare","dot","get","obj","object","prop","property","sort","sorting"],"dependencies":{"array-ify":"^1.0.0","dot-prop":"^3.0.0"},"devDependencies":{"coveralls":"^2.11.2","istanbul":"^0.4.4","jscs":"^3.0.5","jshint":"^2.7.0","mocha":"^2.5.1"},"scripts":{"coverage":"istanbul cover _mocha -- -R spec && rm -rf ./coverage","lint":"jshint *.js --exclude node_modules && jscs *.js","test":"npm run-script lint && mocha"},"gitHead":"a04010a32bd7aaf895771016ea21d8c190af0f29","bugs":{"url":"https://github.com/stevemao/compare-func/issues"},"_id":"compare-func@1.3.4","_nodeVersion":"12.16.1","_npmVersion":"6.13.4","dist":{"integrity":"sha512-sq2sWtrqKPkEXAC8tEJA1+BqAH9GbFkGBtUOqrUX57VSfwp8xyktctk+uLoRy5eccTdxzDcVIztlYDpKs3Jv1Q==","shasum":"6b07c4c5e8341119baf44578085bda0f4a823516","tarball":"http://registry-npm.ywwl.com/compare-func/download/compare-func-1.3.4.tgz","fileCount":4,"unpackedSize":4762,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.4\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJevpnxCRA9TVsSAnZWagAANDQQAIzS1gppodIjgRea02UY\nILx5HelBkTHC7c5ujlsAdwXH8SQPoFeyAC/3KEGz9ux2zcOEi0f4UdUmW1ij\nBFAaDZXqGvPMA3RZFBDVEJYvYCL+ptLuFgKiLD6M8o840UqIWuuLQfqOr7I4\nyD2crTBwEo1XxHncBV8/MxTk4DTKG1M1z5hHIeS6vVQbA6lYwcwVSfEqxDaO\n3yriVFf3Xyj5MPFU9bhC5udC/iqqz4h7InhEE8ELDLcQXTopTjRspaEIM37l\nxHbxAUAXyixdY6qdF2b7pITybZH8qtz83+cCN6qNUfV2Coi+D3AafoPV7+NX\nnVBd+0CAe8IHxmvIpNOwkgsuiwoGs8LlHNl+gvIzYZKZTZk7/qZexD8UFv7y\nSmh7ssyPXJp5tat0saFCJMpiZ28b74ZZuZGngwJUEFUHdTdQj8mA1oUi5Itt\nj9OtP/aJvLpmX7kU0yzS7/ZLEl0/LvDD7TxWTip1U4wZSMRDUbgZy9XLI/vH\njbcPgsjTRvQKSiU7cRsQma/pWUI1h5sULMp6yefo6Ik0jKkZW+yJyZsQmdbW\nkHPnRtbHE1FrHxwdhOgWUVT+AcHU4TFkxbDaiqoB1TkHh7SDcMW2KvapC5W1\npD8e+/bCtdgheIKHyc/A4WFfIS20E8dLbKA9N2nYJ/AsJ9w2JCmbS6mt9wid\nYMBO\r\n=+h1m\r\n-----END PGP SIGNATURE-----\r\n","signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEUCIDaBLPmyUzbKziFx6hd3tGjZm82x6SAdGftya6rAxYl5AiEAhzduMnaIip9efp+0Zdi+wO9IoZVHlgpf2JJ5kOvscu0="}],"size":2170,"noattachment":false,"key":"/compare-func/-/compare-func-1.3.4.tgz"},"maintainers":[{"name":"stevemao","email":"steve.mao@healthinteract.com.au"}],"_npmUser":{"name":"stevemao","email":"maochenyan@gmail.com"},"directories":{},"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/compare-func_1.3.4_1589549553194_0.9922857999180084"},"_hasShrinkwrap":false,"readme":"#  [![NPM version][npm-image]][npm-url] [![Build Status][travis-image]][travis-url] [![Dependency Status][daviddm-image]][daviddm-url] [![Coverage Status][coveralls-image]][coveralls-url]\n\n> Get a compare function for array to sort\n\n\n## Install\n\n```sh\n$ npm install --save compare-func\n```\n\n\n## Usage\n\n```js\nvar compareFunc = require('compare-func');\n\n// sort by an object property\n[{x: 'b'}, {x: 'a'}, {x: 'c'}].sort(compareFunc('x'));\n//=> [{x: 'a'}, {x: 'b'}, {x: 'c'}]\n\n// sort by a nested object property\n[{x: {y: 'b'}}, {x: {y: 'a'}}].sort(compareFunc('x.y'));\n//=> [{x: {y: 'a'}}, {x: {y: 'b'}}]\n\n// sort by the `x` propery, then `y`\n[{x: 'c', y: 'c'}, {x: 'b', y: 'a'}, {x: 'b', y: 'b'}].sort(compareFunc(['x', 'y']));\n//=> [{x: 'b', y: 'a'}, {x: 'b', y: 'b'}, {x: 'c', y: 'c'}]\n\n// sort by the returned value\n[{x: 'b'}, {x: 'a'}, {x: 'c'}].sort(compareFunc(function(el) {\n  return el.x;\n}));\n//=> [{x: 'a'}, {x: 'b'}, {x: 'c'}]\n```\n\n\n## API\n\n### compareFunc([property])\n\nReturns a compare function for array to sort\n\n#### property\n\nType: `string`, `function` or `array` of either\n\nIf missing it sorts on itself.\n\nThe string can be a [dot path](https://github.com/sindresorhus/dot-prop) to a nested object property.\n\n\n## Related\n\n- [sort-on](https://github.com/sindresorhus/sort-on) - Sort an array on an object property\n\n\n## License\n\nMIT © [Steve Mao](https://github.com/stevemao)\n\n\n[npm-image]: https://badge.fury.io/js/compare-func.svg\n[npm-url]: https://npmjs.org/package/compare-func\n[travis-image]: https://travis-ci.org/stevemao/compare-func.svg?branch=master\n[travis-url]: https://travis-ci.org/stevemao/compare-func\n[daviddm-image]: https://david-dm.org/stevemao/compare-func.svg?theme=shields.io\n[daviddm-url]: https://david-dm.org/stevemao/compare-func\n[coveralls-image]: https://coveralls.io/repos/stevemao/compare-func/badge.svg\n[coveralls-url]: https://coveralls.io/r/stevemao/compare-func\n","publish_time":1589549553317,"_cnpm_publish_time":1589549553317,"dist-tags":{"latest":"2.0.0"}}