Comparing version 2.1.1 to 2.1.2
import { RawPatch } from './patch'; | ||
export declare type Value<T> = { | ||
export type Value<T> = { | ||
data?: unknown; | ||
@@ -8,5 +8,5 @@ content?: Content<T>; | ||
}; | ||
export declare type Type = 'array' | 'string' | 'object' | 'number' | 'boolean' | 'null'; | ||
export declare type Content<T> = ObjectContent<T> | ArrayContent<T> | StringContent<T>; | ||
export declare type ObjectContent<T> = { | ||
export type Type = 'array' | 'string' | 'object' | 'number' | 'boolean' | 'null'; | ||
export type Content<T> = ObjectContent<T> | ArrayContent<T> | StringContent<T>; | ||
export type ObjectContent<T> = { | ||
type: 'object'; | ||
@@ -17,3 +17,3 @@ fields: { | ||
}; | ||
export declare type ArrayContent<T> = { | ||
export type ArrayContent<T> = { | ||
type: 'array'; | ||
@@ -23,7 +23,7 @@ elements: Value<T>[]; | ||
}; | ||
export declare type StringContent<T> = { | ||
export type StringContent<T> = { | ||
type: 'string'; | ||
parts: StringPart<T>[]; | ||
}; | ||
export declare type StringPart<T> = { | ||
export type StringPart<T> = { | ||
value: string; | ||
@@ -30,0 +30,0 @@ utf8size: number; |
@@ -31,3 +31,5 @@ "use strict"; | ||
if (!value.content) { | ||
var elements = value.data.map(function (item) { return _this.wrapWithMeta(item, value.startMeta); }); | ||
var elements = value.data.map(function (item) { | ||
return _this.wrapWithMeta(item, value.startMeta); | ||
}); | ||
var metas = elements.map(function () { return _this.meta; }); | ||
@@ -43,6 +45,6 @@ value.content = { type: 'array', elements: elements, metas: metas }; | ||
value: str, | ||
utf8size: utf8_1.utf8stringSize(str), | ||
utf8size: (0, utf8_1.utf8stringSize)(str), | ||
uses: [], | ||
startMeta: value.startMeta, | ||
endMeta: value.endMeta | ||
endMeta: value.endMeta, | ||
}; | ||
@@ -56,3 +58,3 @@ value.content = this.stringFromParts([part]); | ||
type: 'string', | ||
parts: parts | ||
parts: parts, | ||
}; | ||
@@ -124,3 +126,3 @@ for (var _i = 0, parts_1 = parts; _i < parts_1.length; _i++) { | ||
type: 'string', | ||
parts: [] | ||
parts: [], | ||
}; | ||
@@ -132,3 +134,3 @@ } | ||
type: 'object', | ||
fields: {} | ||
fields: {}, | ||
}; | ||
@@ -148,3 +150,3 @@ if (value) { | ||
elements: elements, | ||
metas: metas | ||
metas: metas, | ||
}; | ||
@@ -216,3 +218,3 @@ }; | ||
var code = part.value.codePointAt(idx); | ||
var size = utf8_1.utf8charSize(code); | ||
var size = (0, utf8_1.utf8charSize)(code); | ||
if (size === 4) | ||
@@ -230,3 +232,3 @@ idx++; // Surrogate pair. | ||
startMeta: part.startMeta, | ||
endMeta: part.endMeta | ||
endMeta: part.endMeta, | ||
}; | ||
@@ -353,6 +355,6 @@ part.value = leftValue; | ||
var result = rightModel.copyString(null); | ||
var prefix = utf8_1.commonPrefix(leftRaw, rightRaw); | ||
var suffix = utf8_1.commonSuffix(leftRaw, rightRaw, prefix); | ||
var rightLen = utf8_1.utf8stringSize(rightRaw); | ||
var leftLen = utf8_1.utf8stringSize(leftRaw); | ||
var prefix = (0, utf8_1.commonPrefix)(leftRaw, rightRaw); | ||
var suffix = (0, utf8_1.commonSuffix)(leftRaw, rightRaw, prefix); | ||
var rightLen = (0, utf8_1.utf8stringSize)(rightRaw); | ||
var leftLen = (0, utf8_1.utf8stringSize)(leftRaw); | ||
if (0 < prefix) { | ||
@@ -359,0 +361,0 @@ rightModel.stringAppendSlice(result, left, 0, prefix); |
"use strict"; | ||
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) { | ||
if (k2 === undefined) k2 = k; | ||
Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } }); | ||
}) : (function(o, m, k, k2) { | ||
if (k2 === undefined) k2 = k; | ||
o[k2] = m[k]; | ||
})); | ||
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) { | ||
Object.defineProperty(o, "default", { enumerable: true, value: v }); | ||
}) : function(o, v) { | ||
o["default"] = v; | ||
}); | ||
var __importStar = (this && this.__importStar) || function (mod) { | ||
if (mod && mod.__esModule) return mod; | ||
var result = {}; | ||
if (mod != null) for (var k in mod) if (k !== "default" && Object.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k); | ||
__setModuleDefault(result, mod); | ||
return result; | ||
}; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.incremental = __importStar(require("./incremental-patcher")); | ||
exports.applyPatch = exports.incremental = void 0; | ||
var tslib_1 = require("tslib"); | ||
exports.incremental = tslib_1.__importStar(require("./incremental-patcher")); | ||
var simple_patcher_1 = require("./simple-patcher"); | ||
Object.defineProperty(exports, "applyPatch", { enumerable: true, get: function () { return simple_patcher_1.applyPatch; } }); | ||
//# sourceMappingURL=index.js.map |
import { ObjectModel } from './object-model'; | ||
import { RawPatch } from './patch'; | ||
declare type InputEntry<V> = { | ||
type InputEntry<V> = { | ||
value: V; | ||
@@ -8,3 +8,3 @@ key?: string; | ||
}; | ||
declare type OutputEntry<V, S, O, A> = { | ||
type OutputEntry<V, S, O, A> = { | ||
value: V | null; | ||
@@ -11,0 +11,0 @@ writeValue?: S | O | A; |
@@ -28,3 +28,3 @@ "use strict"; | ||
'StringAppendString', | ||
'StringAppendSlice' | ||
'StringAppendSlice', | ||
]; | ||
@@ -50,4 +50,4 @@ var Patcher = /** @class */ (function () { | ||
if (!op) | ||
throw new Error("Unknown opcode: " + opcode); | ||
var processor = "process" + op; | ||
throw new Error("Unknown opcode: ".concat(opcode)); | ||
var processor = "process".concat(op); | ||
this[processor].apply(this); | ||
@@ -54,0 +54,0 @@ } |
@@ -1,2 +0,2 @@ | ||
export declare type RawOperation = any; | ||
export declare type RawPatch = RawOperation[]; | ||
export type RawOperation = any; | ||
export type RawPatch = RawOperation[]; |
@@ -33,3 +33,3 @@ "use strict"; | ||
type: 'object', | ||
data: {} | ||
data: {}, | ||
}; | ||
@@ -52,3 +52,3 @@ if (value !== null) { | ||
type: 'string', | ||
data: value === null ? '' : value | ||
data: value === null ? '' : value, | ||
}; | ||
@@ -70,4 +70,4 @@ }, | ||
var sourceString = source; | ||
var leftPos = utf8_1.utf8resolveIndex(sourceString, left); | ||
var rightPos = utf8_1.utf8resolveIndex(sourceString, right, leftPos); | ||
var leftPos = (0, utf8_1.utf8resolveIndex)(sourceString, left); | ||
var rightPos = (0, utf8_1.utf8resolveIndex)(sourceString, right, leftPos); | ||
target.data += sourceString.slice(leftPos, rightPos); | ||
@@ -77,3 +77,3 @@ }, | ||
target.data += value; | ||
} | ||
}, | ||
}; | ||
@@ -80,0 +80,0 @@ // Applies a patch on a JavaScript object. |
import { RawPatch } from './patch'; | ||
export declare type Value<T> = { | ||
export type Value<T> = { | ||
data?: unknown; | ||
@@ -8,5 +8,5 @@ content?: Content<T>; | ||
}; | ||
export declare type Type = 'array' | 'string' | 'object' | 'number' | 'boolean' | 'null'; | ||
export declare type Content<T> = ObjectContent<T> | ArrayContent<T> | StringContent<T>; | ||
export declare type ObjectContent<T> = { | ||
export type Type = 'array' | 'string' | 'object' | 'number' | 'boolean' | 'null'; | ||
export type Content<T> = ObjectContent<T> | ArrayContent<T> | StringContent<T>; | ||
export type ObjectContent<T> = { | ||
type: 'object'; | ||
@@ -17,3 +17,3 @@ fields: { | ||
}; | ||
export declare type ArrayContent<T> = { | ||
export type ArrayContent<T> = { | ||
type: 'array'; | ||
@@ -23,7 +23,7 @@ elements: Value<T>[]; | ||
}; | ||
export declare type StringContent<T> = { | ||
export type StringContent<T> = { | ||
type: 'string'; | ||
parts: StringPart<T>[]; | ||
}; | ||
export declare type StringPart<T> = { | ||
export type StringPart<T> = { | ||
value: string; | ||
@@ -30,0 +30,0 @@ utf8size: number; |
@@ -28,3 +28,5 @@ import { Patcher } from './internal-patcher'; | ||
if (!value.content) { | ||
var elements = value.data.map(function (item) { return _this.wrapWithMeta(item, value.startMeta); }); | ||
var elements = value.data.map(function (item) { | ||
return _this.wrapWithMeta(item, value.startMeta); | ||
}); | ||
var metas = elements.map(function () { return _this.meta; }); | ||
@@ -43,3 +45,3 @@ value.content = { type: 'array', elements: elements, metas: metas }; | ||
startMeta: value.startMeta, | ||
endMeta: value.endMeta | ||
endMeta: value.endMeta, | ||
}; | ||
@@ -53,3 +55,3 @@ value.content = this.stringFromParts([part]); | ||
type: 'string', | ||
parts: parts | ||
parts: parts, | ||
}; | ||
@@ -121,3 +123,3 @@ for (var _i = 0, parts_1 = parts; _i < parts_1.length; _i++) { | ||
type: 'string', | ||
parts: [] | ||
parts: [], | ||
}; | ||
@@ -129,3 +131,3 @@ } | ||
type: 'object', | ||
fields: {} | ||
fields: {}, | ||
}; | ||
@@ -145,3 +147,3 @@ if (value) { | ||
elements: elements, | ||
metas: metas | ||
metas: metas, | ||
}; | ||
@@ -226,3 +228,3 @@ }; | ||
startMeta: part.startMeta, | ||
endMeta: part.endMeta | ||
endMeta: part.endMeta, | ||
}; | ||
@@ -229,0 +231,0 @@ part.value = leftValue; |
import { ObjectModel } from './object-model'; | ||
import { RawPatch } from './patch'; | ||
declare type InputEntry<V> = { | ||
type InputEntry<V> = { | ||
value: V; | ||
@@ -8,3 +8,3 @@ key?: string; | ||
}; | ||
declare type OutputEntry<V, S, O, A> = { | ||
type OutputEntry<V, S, O, A> = { | ||
value: V | null; | ||
@@ -11,0 +11,0 @@ writeValue?: S | O | A; |
@@ -25,3 +25,3 @@ var OPS = [ | ||
'StringAppendString', | ||
'StringAppendSlice' | ||
'StringAppendSlice', | ||
]; | ||
@@ -47,4 +47,4 @@ var Patcher = /** @class */ (function () { | ||
if (!op) | ||
throw new Error("Unknown opcode: " + opcode); | ||
var processor = "process" + op; | ||
throw new Error("Unknown opcode: ".concat(opcode)); | ||
var processor = "process".concat(op); | ||
this[processor].apply(this); | ||
@@ -51,0 +51,0 @@ } |
@@ -0,1 +1,2 @@ | ||
export {}; | ||
//# sourceMappingURL=object-model.js.map |
@@ -1,2 +0,2 @@ | ||
export declare type RawOperation = any; | ||
export declare type RawPatch = RawOperation[]; | ||
export type RawOperation = any; | ||
export type RawPatch = RawOperation[]; |
@@ -0,1 +1,2 @@ | ||
export {}; | ||
//# sourceMappingURL=patch.js.map |
@@ -30,3 +30,3 @@ import { Patcher } from './internal-patcher'; | ||
type: 'object', | ||
data: {} | ||
data: {}, | ||
}; | ||
@@ -49,3 +49,3 @@ if (value !== null) { | ||
type: 'string', | ||
data: value === null ? '' : value | ||
data: value === null ? '' : value, | ||
}; | ||
@@ -73,3 +73,3 @@ }, | ||
target.data += value; | ||
} | ||
}, | ||
}; | ||
@@ -76,0 +76,0 @@ // Applies a patch on a JavaScript object. |
{ | ||
"name": "mendoza", | ||
"version": "2.1.1", | ||
"version": "2.1.2", | ||
"description": "Mendoza, differ for structured documents", | ||
@@ -12,2 +12,6 @@ "main": "./lib/cjs/index.js", | ||
}, | ||
"files": [ | ||
"lib", | ||
"src" | ||
], | ||
"scripts": { | ||
@@ -17,2 +21,4 @@ "prebuild": "npm run clean", | ||
"build:esm": "tsc --module es6 --outDir lib/esm", | ||
"lint": "echo todo", | ||
"coverage": "npm test", | ||
"build:cjs": "tsc --module commonjs --outDir lib/cjs", | ||
@@ -25,10 +31,13 @@ "prepublishOnly": "npm run build", | ||
"devDependencies": { | ||
"@sanity/semantic-release-preset": "^4.1.2", | ||
"@types/jest": "^26.0.15", | ||
"jest": "^26.6.1", | ||
"prettier": "^1.19.1", | ||
"ls-engines": "^0.9.0", | ||
"prettier": "^2.0.0", | ||
"rimraf": "^3.0.2", | ||
"ts-jest": "26.4.1", | ||
"semantic-release": "^21.0.7", | ||
"ts-jest": "^26.4.1", | ||
"ts-node": "^8.6.2", | ||
"tslib": "^2.0.3", | ||
"typescript": "^3.7.5" | ||
"tslib": "^2.6.1", | ||
"typescript": "^4.0.0" | ||
}, | ||
@@ -54,3 +63,7 @@ "repository": { | ||
"singleQuote": true | ||
}, | ||
"publishConfig": { | ||
"access": "public", | ||
"provenance": true | ||
} | ||
} |
@@ -45,3 +45,4 @@ import {ObjectModel} from './object-model' | ||
class Model<T> | ||
implements ObjectModel<Value<T>, StringContent<T>, ObjectContent<T>, ArrayContent<T>> { | ||
implements ObjectModel<Value<T>, StringContent<T>, ObjectContent<T>, ArrayContent<T>> | ||
{ | ||
private meta: T | ||
@@ -75,3 +76,5 @@ | ||
if (!value.content) { | ||
let elements = (value.data as unknown[]).map(item => this.wrapWithMeta(item, value.startMeta)) | ||
let elements = (value.data as unknown[]).map((item) => | ||
this.wrapWithMeta(item, value.startMeta) | ||
) | ||
let metas = elements.map(() => this.meta) | ||
@@ -93,3 +96,3 @@ value.content = {type: 'array', elements, metas} | ||
startMeta: value.startMeta, | ||
endMeta: value.endMeta | ||
endMeta: value.endMeta, | ||
} | ||
@@ -105,3 +108,3 @@ value.content = this.stringFromParts([part]) | ||
type: 'string', | ||
parts | ||
parts, | ||
} | ||
@@ -174,3 +177,3 @@ | ||
type: 'string', | ||
parts: [] | ||
parts: [], | ||
} | ||
@@ -183,3 +186,3 @@ } | ||
type: 'object', | ||
fields: {} | ||
fields: {}, | ||
} | ||
@@ -203,3 +206,3 @@ | ||
elements, | ||
metas | ||
metas, | ||
} | ||
@@ -298,3 +301,3 @@ } | ||
startMeta: part.startMeta, | ||
endMeta: part.endMeta | ||
endMeta: part.endMeta, | ||
} | ||
@@ -338,6 +341,6 @@ | ||
case 'string': | ||
result = content.parts.map(part => part.value).join('') | ||
result = content.parts.map((part) => part.value).join('') | ||
break | ||
case 'array': | ||
result = content.elements.map(val => unwrap(val)) | ||
result = content.elements.map((val) => unwrap(val)) | ||
break | ||
@@ -344,0 +347,0 @@ case 'object': { |
@@ -28,3 +28,3 @@ import {ObjectModel} from './object-model' | ||
'StringAppendString', | ||
'StringAppendSlice' | ||
'StringAppendSlice', | ||
] | ||
@@ -31,0 +31,0 @@ |
@@ -42,3 +42,3 @@ import {ObjectModel} from './object-model' | ||
type: 'object', | ||
data: {} | ||
data: {}, | ||
} | ||
@@ -61,3 +61,3 @@ if (value !== null) { | ||
type: 'string', | ||
data: value === null ? '' : (value as string) | ||
data: value === null ? '' : (value as string), | ||
} | ||
@@ -93,3 +93,3 @@ }, | ||
target.data += value as string | ||
} | ||
}, | ||
} | ||
@@ -96,0 +96,0 @@ |
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
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
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
New author
Supply chain riskA new npm collaborator published a version of the package for the first time. New collaborators are usually benign additions to a project, but do indicate a change to the security surface area of a package.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
138539
11
52
2489
1