Socket
Socket
Sign inDemoInstall

@sanity/diff-match-patch

Package Overview
Dependencies
Maintainers
33
Versions
14
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@sanity/diff-match-patch - npm Package Compare versions

Comparing version 0.0.7 to 0.0.8

15

lib/esm/patch/make.js
import { cleanupSemantic, cleanupEfficiency } from '../diff/cleanup.js';
import { diff, DiffType } from '../diff/diff.js';
import { diffText1 } from '../diff/diffText.js';
import { isLowSurrogate } from '../utils/surrogatePairs.js';
import { MAX_BITS } from './constants.js';

@@ -158,3 +159,8 @@ import { createPatchObject } from './createPatchObject.js';

// Add the prefix.
const prefix = text.substring(patch.start2 - padding, patch.start2);
// Avoid splitting inside a surrogate.
let prefixStart = patch.start2 - padding;
if (prefixStart >= 1 && isLowSurrogate(text[prefixStart])) {
prefixStart--;
}
const prefix = text.substring(prefixStart, patch.start2);
if (prefix) {

@@ -164,3 +170,8 @@ patch.diffs.unshift([DiffType.EQUAL, prefix]);

// Add the suffix.
const suffix = text.substring(patch.start2 + patch.length1, patch.start2 + patch.length1 + padding);
// Avoid splitting inside a surrogate.
let suffixEnd = patch.start2 + patch.length1 + padding;
if (suffixEnd < text.length && isLowSurrogate(text[suffixEnd])) {
suffixEnd++;
}
const suffix = text.substring(patch.start2 + patch.length1, suffixEnd);
if (suffix) {

@@ -167,0 +178,0 @@ patch.diffs.push([DiffType.EQUAL, suffix]);

2

package.json
{
"name": "@sanity/diff-match-patch",
"version": "0.0.7",
"version": "0.0.8",
"description": "Robust diff, match and patch algorithms to perform operations required for synchronizing plain text",

@@ -5,0 +5,0 @@ "sideEffects": false,

import { cleanupSemantic, cleanupEfficiency } from '../diff/cleanup.js'
import { diff, Diff, DiffType } from '../diff/diff.js'
import { diffText1 } from '../diff/diffText.js'
import { isLowSurrogate } from '../utils/surrogatePairs.js'
import { MAX_BITS } from './constants.js'

@@ -203,11 +204,23 @@ import { createPatchObject, Patch } from './createPatchObject.js'

// Add the prefix.
const prefix = text.substring(patch.start2 - padding, patch.start2)
// Avoid splitting inside a surrogate.
let prefixStart = patch.start2 - padding
if (prefixStart >= 1 && isLowSurrogate(text[prefixStart])) {
prefixStart--
}
const prefix = text.substring(prefixStart, patch.start2)
if (prefix) {
patch.diffs.unshift([DiffType.EQUAL, prefix])
}
// Add the suffix.
const suffix = text.substring(
patch.start2 + patch.length1,
patch.start2 + patch.length1 + padding,
)
// Avoid splitting inside a surrogate.
let suffixEnd = patch.start2 + patch.length1 + padding
if (suffixEnd < text.length && isLowSurrogate(text[suffixEnd])) {
suffixEnd++
}
const suffix = text.substring(patch.start2 + patch.length1, suffixEnd)
if (suffix) {

@@ -214,0 +227,0 @@ patch.diffs.push([DiffType.EQUAL, suffix])

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc