{"name":"highlight-words-core","description":"Utility functions shared by react-highlight-words and react-native-highlight-words","version":"1.2.0","author":{"name":"Brian Vaughn","email":"brian.david.vaughn@gmail.com"},"license":"MIT","main":"dist/index.js","scripts":{"build":"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"},"gitHead":"7995e9af288c33118537a6344bbacd9ae7f13d11","_id":"highlight-words-core@1.2.0","_npmVersion":"5.3.0","_nodeVersion":"8.4.0","_npmUser":{"name":"brianvaughn","email":"briandavidvaughn@gmail.com"},"dist":{"integrity":"sha512-nu5bMsWIgpsrlXEMNKSvbJMeUPhFxCOVT28DnI8UCVfhm3e98LC8oeyMNrc7E18+QQ4l/PvbeN7ojyN4XsmBdA==","shasum":"232bec301cbf2a4943d335dc748ce70e9024f3b1","tarball":"http://registry-npm.ywwl.com/highlight-words-core/download/highlight-words-core-1.2.0.tgz","fileCount":9,"unpackedSize":132072,"signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEUCID03cNoF12hcEE9kSGkAnBcg7LP+l/xlZQZABnHU6yc+AiEAw4PwsLTJ2vMLpYzLGqIVzZjJ5BDGbQaALLGFKOCgdqo="}],"size":38890,"noattachment":false,"key":"/highlight-words-core/-/highlight-words-core-1.2.0.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.0_1519058164974_0.9796598767191198"},"_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":1519058165365,"_cnpm_publish_time":1519058165365,"dist-tags":{"latest":"2.0.0"}}