{"name":"highlight-words-core","description":"Utility functions shared by react-highlight-words and react-native-highlight-words","version":"1.2.2","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","babel-preset-flow":"^6","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"},"gitHead":"ab3abe11ed118d0cee18786395300a6f5290dcb9","_id":"highlight-words-core@1.2.2","_npmVersion":"6.4.1","_nodeVersion":"10.12.0","_npmUser":{"name":"brianvaughn","email":"briandavidvaughn@gmail.com"},"dist":{"integrity":"sha512-BXUKIkUuh6cmmxzi5OIbUJxrG8OAk2MqoL1DtO3Wo9D2faJg2ph5ntyuQeLqaHJmzER6H5tllCDA9ZnNe9BVGg==","shasum":"1eff6d7d9f0a22f155042a00791237791b1eeaaa","tarball":"http://registry-npm.ywwl.com/highlight-words-core/download/highlight-words-core-1.2.2.tgz","fileCount":9,"unpackedSize":31347,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.4\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJb6Z3uCRA9TVsSAnZWagAAGkMP/2JdtNlvQpcXcgsLg6kC\nA0lGiehJGVOK/F2ROxpbb19nJhwuTCX1q9Mv6T70RQOpnPLxHTE23dzVEMAv\nGvO6bfYUnJuqBvlPhCWE8vJWh18cbYrtsQsVsAMPkoczHSi5fbEjqvqZE48p\no80JsgjJg3SxCsOxUktlrjHdFhGcr1jmfr2nBMG0o5/TqWykMDlWv4//d/A7\n8OIGHwdPNA9fMcQGQAFjZfL0dDgzNSbMoKnkg4ZN4GpAUSHOa44hi3tGCBTE\nVEfLkWrHOSJJANo7kCJ0RZiIVgTlZUtLXdXuQ6nx87StRxl0jNNqsvljF7eH\nRJIb9aIlFAVCfeTF12BwH0SWUfqw9vrVjO1BcACHJOS5gJeYemqNns8OfpUJ\nRwCwfuSoEeCQlbDdnDtq/QZuoe5GF2e4U+TtfHR5xePViOSQNdJo6uA2KxRM\njsz+1QIeyBsCYAcz+xgWXqLeITyD58hVitW3K4+uz73QjFobD9TBq3SoPhui\nuwH3PP6uo7sSDOqFnh9QRAtdy7G/xvAB8XYuNQeL6RV3wQCyurtGDBRcLX1I\nAuSrWgqUPKd20Vgf9w5ixQMYkNAfmDedywfxspr5mmYMPiqxxV1IgsIlTr5R\nzgVsGgstMTVS1EJ+9UCV/eenJMib6VNAQcvVUZAx7Gd09gjkibZHUxpi36Bl\n2foD\r\n=ka/x\r\n-----END PGP SIGNATURE-----\r\n","signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEQCIGJkaMORdPA0DdoMRAXKZnU/czxisDSx+xb5Z/PCy6v5AiAA+8yPVzEpVJTOfTYQtCaYpUYrtjMsw6o5JfzRMl4lFA=="}],"size":8835,"noattachment":false,"key":"/highlight-words-core/-/highlight-words-core-1.2.2.tgz"},"maintainers":[{"email":"briandavidvaughn@gmail.com","name":"brianvaughn"},{"email":"clauderic.d@gmail.com","name":"clauderic"},{"email":"rpflorence@gmail.com","name":"ryanflorence"}],"directories":{},"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/highlight-words-core_1.2.2_1542036974090_0.06718657030282671"},"_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":1542036974298,"_cnpm_publish_time":1542036974298,"dist-tags":{"latest":"2.0.0"}}