{"name":"highlight-words-core","description":"Utility functions shared by react-highlight-words and react-native-highlight-words","version":"1.2.1","author":{"name":"Brian Vaughn","email":"brian.david.vaughn@gmail.com"},"license":"MIT","main":"dist/index.js","scripts":{"build":"yarn build:source && yarn build:flow","build:flow":"cp flow-template dist/index.js.flow","build:source":"webpack --config webpack.config.dist.js --bail","lint":"standard","prebuild":"rimraf dist","prepublish":"npm run build","test":"mocha --compilers js:babel-register \"src/**/*.test.js\""},"keywords":["highlighter","highlight","text","words","matches","substring","occurrences","search"],"repository":{"type":"git","url":"github.com/bvaughn/highlight-words-core.git"},"standard":{"parser":"babel-eslint","ignore":["build","dist","node_modules"],"global":["afterAll","afterEach","beforeAll","beforeEach","describe","it"]},"devDependencies":{"babel-cli":"6.8.0","babel-core":"^6.5.1","babel-eslint":"^6.0.4","babel-loader":"^6.2.3","babel-preset-es2015":"^6.14.0","cross-env":"^1.0.7","expect.js":"^0.3.1","latinize":"^0.3.0","mocha":"^3.0.2","rimraf":"^2.4.3","standard":"^7.0.1","webpack":"^1.9.6"},"dependencies":{"babel-preset-flow":"^6"},"gitHead":"c2b1faa922903eb9a95b1bb02f8514c019f4f4f2","_id":"highlight-words-core@1.2.1","_npmVersion":"6.4.1","_nodeVersion":"10.12.0","_npmUser":{"name":"brianvaughn","email":"briandavidvaughn@gmail.com"},"dist":{"integrity":"sha512-iJVOcqPbHNf2VFhAgrKCQ8g7BMUK53BqIZX8NmvMsGeEMRCcrJxbbWJrFvEApJ8vlirz2dMbwcxQhhLJebb/zw==","shasum":"623830004c93f3731e108dfd8a5d3d9b7e6c01f4","tarball":"http://registry-npm.ywwl.com/highlight-words-core/download/highlight-words-core-1.2.1.tgz","fileCount":9,"unpackedSize":31374,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.4\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJb6GQZCRA9TVsSAnZWagAAL9kP/1Rd9FsgzKfRtjfNJb6l\nW8N9eqY0/aVfbuFg3F4XAuESjEmUft/Cg0CdA14Ot+d6tr6aI2FK7vVtd6qp\nSPu46Gji1mU7nwMXD7dNr4690mVf08XlVdcndXlU+XI6QmxiiR78TVUBom1x\nQeUryBldzIXag2iezWPOKBNxvhHgW7XL5vzsnIyW+CAruAi/pvTNo2b9dUO4\nFRxGtIHLuDh9ZNC26k9cYIzpNj2YNs1RxjyaaDfP3Qb0Gn4bV3s7A48QMx8Q\n2ak+zIwB5ZvJh2XLSY3jUCvbKrWeRSE6j0mu4Tx92WmfZ3Dh/yse7p+AxWJQ\n5pQ6gUIDnsnR4eCdxQRsEvw5XKZY0H9vjFVOlE16KC+w2pFk9Fq3hBU8Of6U\nW7HfG1ZM8kGzK+VDxH8tVUW6MJcxL1c7F1NdU4264r9oFHRx7a8BgLe/0L3M\nGGpXQbRY3XWZZRZCF09awLPKBMb2e77GhL6OdgbSKUU77U3+r586APvMYlzR\n48mhBn4K3vsoieYeI9+oRIWXBlj6bvDDM3CtfmaNnx2VLiiggPwuCVI8OMlc\ne9djRSapWyXr4EYrHTgLIKzYf/Bz6LusOyUKlpYuTDcXHZgNORBZg9vpn7zs\ni1k1e7unPxe9k38y5UNuZcw+nCYBCZgIWeE/Wl3iitKrSOK/3xm6fK2e4ruZ\njZ2m\r\n=zYUQ\r\n-----END PGP SIGNATURE-----\r\n","signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEYCIQDwSf3M/JgGwHkkYuAMyYF+5WuLvQ7J9gSl2HoXIyhZyQIhAOAFOcl3dKGuixdqLXPB1h0Lmmc3KGLHQA5JpQXqWu9s"}],"size":8839,"noattachment":false,"key":"/highlight-words-core/-/highlight-words-core-1.2.1.tgz"},"maintainers":[{"name":"brianvaughn","email":"briandavidvaughn@gmail.com"},{"name":"clauderic","email":"clauderic.d@gmail.com"}],"directories":{},"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/highlight-words-core_1.2.1_1541956633046_0.4267505777558953"},"_hasShrinkwrap":false,"readme":"Utility functions shared by [`react-highlight-words`](https://github.com/bvaughn/react-highlight-words) and [`react-native-highlight-words`](https://github.com/clauderic/react-native-highlight-words).\n\n## API\n\nThe primary API for this package is a function exported as `findAll`. This method searches a string of text for a set of search terms and returns an array of \"chunks\" that describe the matches found.\n\nEach \"chunk\" is an object consisting of a pair of indices (`chunk.start` and `chunk.end`) and a boolean specfifying whether the chunk is a match (`chunk.highlight`). For example:\n\n```js\nimport { findAll } from \"highlight-words-core\";\n\nconst textToHighlight = \"This is some text to highlight.\";\nconst searchWords = [\"This\", \"i\"];\n\nconst chunks = findAll({\n  searchWords,\n  textToHighlight\n});\n\nconst highlightedText = chunks\n  .map(chunk => {\n    const { end, highlight, start } = chunk;\n    const text = textToHighlight.substr(start, end - start);\n    if (highlight) {\n      return `<mark>${text}</mark>`;\n    } else {\n      return text;\n    }\n  })\n  .join(\"\");\n```\n\n[Run this example on Code Sandbox.](https://codesandbox.io/s/ykwrzrl6wx)\n\n### `findAll`\n\nThe `findAll` function accepts several parameters, although only the `searchWords` array and `textToHighlight` string are required.\n\n| Parameter | Required? | Type | Description |\n| --- | :---: | --- | --- |\n| autoEscape |  | `boolean` | Escape special regular expression characters |\n| caseSensitive |  | `boolean` | Search should be case sensitive |\n| findChunks |  | `Function` | Custom find function (advanced) |\n| sanitize |  | `Function` | Custom sanitize function (advanced) |\n| searchWords | ✅ | `Array<string>` | Array of words to search for |\n| textToHighlight | ✅ | `string` | Text to search and highlight |\n\n\n## License\nMIT License - fork, modify and use however you want.\n","publish_time":1541956633178,"_cnpm_publish_time":1541956633178,"dist-tags":{"latest":"2.0.0"}}