{"name":"highlight-words-core","description":"Utility functions shared by react-highlight-words and react-native-highlight-words","version":"1.0.1","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","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"]},"dependencies":{"babel-runtime":"^6.11.6"},"devDependencies":{"babel-cli":"6.8.0","babel-core":"^6.5.1","babel-eslint":"^6.0.4","babel-loader":"^6.2.3","babel-plugin-transform-runtime":"^6.15.0","babel-plugin-typecheck":"^3.9.0","babel-polyfill":"^6.5.0","babel-preset-es2015":"^6.14.0","babel-preset-es2015-rollup":"^1.1.1","babel-preset-stage-1":"^6.5.0","cross-env":"^1.0.7","expect.js":"^0.3.1","mocha":"^3.0.2","rimraf":"^2.4.3","standard":"^7.0.1","watch":"^0.18.0","webpack":"^1.9.6"},"gitHead":"54893283d79ac80bf4c7cff3b49a8d7eb706d71b","_id":"highlight-words-core@1.0.1","_shasum":"cdf0a600a25c72c95d65a86fcd6924ed7e459c05","_from":".","_npmVersion":"3.10.3","_nodeVersion":"6.5.0","_npmUser":{"name":"brianvaughn","email":"briandavidvaughn@gmail.com"},"dist":{"shasum":"cdf0a600a25c72c95d65a86fcd6924ed7e459c05","tarball":"http://registry-npm.ywwl.com/highlight-words-core/download/highlight-words-core-1.0.1.tgz","integrity":"sha512-bEZGP5lgI5WOOr4D8cbRmbhkxdija/n2cfR7m2Ln3R66Z2AIIP2g8fbVLN040IoIQnTsnoTSh88E1q73MwFiEQ==","signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEUCIQCEF2hfaVZMOluTB7Sqjr51d8Z6OOM3btHdeP1R0NWEOwIgZcfoxc7gDpsTmj52d0u1C7GDGcYQyznJ1YBiSl5Ls1A="}],"size":6363,"noattachment":false,"key":"/highlight-words-core/-/highlight-words-core-1.0.1.tgz"},"maintainers":[{"name":"brianvaughn","email":"briandavidvaughn@gmail.com"}],"_npmOperationalInternal":{"host":"packages-16-east.internal.npmjs.com","tmp":"tmp/highlight-words-core-1.0.1.tgz_1474508924680_0.5149156216066331"},"directories":{},"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":1474508926671,"_cnpm_publish_time":1474508926671,"dist-tags":{"latest":"2.0.0"}}