{"name":"highlight-words-core","description":"Utility functions shared by react-highlight-words and react-native-highlight-words","version":"1.0.2","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"]},"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","latinize":"^0.3.0","mocha":"^3.0.2","rimraf":"^2.4.3","standard":"^7.0.1","watch":"^0.18.0","webpack":"^1.9.6"},"gitHead":"8f62255065df91242062ed13f1040c90de4702f9","_id":"highlight-words-core@1.0.2","_shasum":"db2eaa52c8afc3056478a7c6f51858c5481e8ed6","_from":".","_npmVersion":"3.10.3","_nodeVersion":"6.5.0","_npmUser":{"name":"brianvaughn","email":"briandavidvaughn@gmail.com"},"dist":{"shasum":"db2eaa52c8afc3056478a7c6f51858c5481e8ed6","tarball":"http://registry-npm.ywwl.com/highlight-words-core/download/highlight-words-core-1.0.2.tgz","integrity":"sha512-c688z5cniEnCwSxc3x7lVVN17tIpNcvqy2y1UqanakgrQfxCUz/qc5RalSiSaD/rfpyZOR80gPiAfKJabb+O3g==","signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEQCICe/pXOmOZ+bcWqYLd0iIrp1rWSsDtLaQtmkr+2myLXjAiBbSV3q6thRh8t4/lBgEFQydWRvAXEf990iKe1E/b87gg=="}],"size":6285,"noattachment":false,"key":"/highlight-words-core/-/highlight-words-core-1.0.2.tgz"},"maintainers":[{"name":"brianvaughn","email":"briandavidvaughn@gmail.com"}],"_npmOperationalInternal":{"host":"packages-12-west.internal.npmjs.com","tmp":"tmp/highlight-words-core-1.0.2.tgz_1474509491186_0.8488617793191224"},"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":1474509491429,"_cnpm_publish_time":1474509491429,"dist-tags":{"latest":"2.0.0"}}