![Oracle Drags Its Feet in the JavaScript Trademark Dispute](https://cdn.sanity.io/images/cgdhsj6q/production/919c3b22c24f93884c548d60cbb338e819ff2435-1024x1024.webp?w=400&fit=max&auto=format)
Security News
Oracle Drags Its Feet in the JavaScript Trademark Dispute
Oracle seeks to dismiss fraud claims in the JavaScript trademark dispute, delaying the case and avoiding questions about its right to the name.
code-point-mapping
Advanced tools
Map between javascript string indices and unicode code point offsets effectively
code-point-mapping provides a way to map between utf16 string indices and unicode code point offsets effectively.
Unicode code points require either one or two utf16 code units to represent them. Characters outside the Basic Multilingual Plane are represented as two surrogate pairs. This means as soon as you use characters (like Emoji) that are in this state, you need to do some work to map between utf16 indexes and unicode code point offsets.
This package was designed for use with automerge, which requires that you specify offsets in terms of unicode code points, and so only the APIs I needed to make that work are here.
For example:
import CodePointMapping from 'code-point-mapping'
import * as automerge from '@automerge/automerge'
let doc1 = automerge.from({ str: new automerge.Text('😀🎉✈️') })
let cpm = new CodePointMapping(doc1.str)
cpm.indexForCodepoint(1) // => 2
doc1 = automerge.change(doc1, d => {
d.str.deleteAt(...cpm.deleteAt(0, 2)) // d.str.deleteAt(0, 1)
d.str.insertAt(...cpm.insertAt(2, '🧟♀️')) // d.str.insertAt(1, ..."🧟♀️")
})
NOTE: This library assumes that your strings are valid unicode and do not contain unpaired surrogates.
FAQs
Map between javascript string indices and unicode code point offsets effectively
The npm package code-point-mapping receives a total of 1 weekly downloads. As such, code-point-mapping popularity was classified as not popular.
We found that code-point-mapping demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer 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.
Security News
Oracle seeks to dismiss fraud claims in the JavaScript trademark dispute, delaying the case and avoiding questions about its right to the name.
Security News
The Linux Foundation is warning open source developers that compliance with global sanctions is mandatory, highlighting legal risks and restrictions on contributions.
Security News
Maven Central now validates Sigstore signatures, making it easier for developers to verify the provenance of Java packages.