Research
Security News
Kill Switch Hidden in npm Packages Typosquatting Chalk and Chokidar
Socket researchers found several malicious npm packages typosquatting Chalk and Chokidar, targeting Node.js developers with kill switches and data theft.
Cursores allows you to get and replace the token under the cursor in a textarea, text input, or string.
It does so by trying to match separate regexes for the text on the left side of the cursor and the text on the right. For performance reasons, the number of characters examined on either side of the cursor is restricted.
For example, if we match a whitespace delimited token in the string
the quick brown fo|x jumps
(where |
denotes the cursor), the token
under the cursor is fox
.
By default new instances match whitespace delimited tokens:
> var cursor = new Cursores()
You can also create an instance that matches a whitespace delimited token that starts with a specific character:
> var cursor = Cursores.startsWith('@')
Finally, the Cursores
constructor accepts the left regex, right
regex, and maximum search window length either side of the cursor.
One can get the token under the cursor in a textarea or text input by
calling cursor.token(el)
. Alternatively, you can pass in a string
and the index of the cursor within that string:
> var split = 'The quick brown fo|x jumps'.split('|')
> var cursor = new Cursores()
> cursor.token(split.join(''), split[0].length)
{"value": "fox", "prefix": "fo", "suffix": "x"}
To replace the token under the cursor in a textarea or text input,
call cursor.replace(el, replacement)
. You can also replace the token
in a string:
> cursor.replace(split.join(''), split[0].length, 'Fantastic Mr. Fox')
"The quick brown Fantastic Mr. Fox jumps"
Cursores supports modern browsers, including Internet Explorer 9, that
implement selectionStart
and setSelectionRange()
.
Cursores is licensed under Apache 2.0.
FAQs
http://cursores.bitbucket.org
We found that cursores demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 3 open source maintainers collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Research
Security News
Socket researchers found several malicious npm packages typosquatting Chalk and Chokidar, targeting Node.js developers with kill switches and data theft.
Security News
pnpm 10 blocks lifecycle scripts by default to improve security, addressing supply chain attack risks but sparking debate over compatibility and workflow changes.
Product
Socket now supports uv.lock files to ensure consistent, secure dependency resolution for Python projects and enhance supply chain security.