positions-in-text

returns the words and the index of its appearances in the given text

Usage no npm install needed!

<script type="module">
  import positionsInText from 'https://cdn.skypack.dev/positions-in-text';
</script>

README

Positions in text

build coverage dependencies devDependencies npm module

npm

Returns the words and the index of its appearances in the given text.

Usage

$ npm install positions-in-text
positions-in-text@1.0.0 node_modules/positions-in-text
$ node
> var positionsInText = require('positions-in-text')
undefined
> positionsInText('not ignorance but ignorance of ignorance is the death of knowledge')
{ not: [ 0 ],
  ignorance: [ 1, 3, 5 ],
  but: [ 2 ],
  of: [ 4, 9 ],
  is: [ 6 ],
  the: [ 7 ],
  death: [ 8 ],
  knowledge: [ 10 ] }