@knotx/utils 0.2.10 → 0.2.12
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.cjs +3 -3
- package/dist/index.d.cts +2 -2
- package/dist/index.d.mts +2 -2
- package/dist/index.d.ts +2 -2
- package/dist/index.js +3 -3
- package/package.json +5 -5
package/dist/index.cjs
CHANGED
|
@@ -31,7 +31,7 @@ function flattenOperations(operations) {
|
|
|
31
31
|
function emptyOperation() {
|
|
32
32
|
return { type: "batch", operations: [] };
|
|
33
33
|
}
|
|
34
|
-
function
|
|
34
|
+
function buildDiffOperation(previousDataMap, dataMap, compare = Object.is) {
|
|
35
35
|
const operations = [];
|
|
36
36
|
previousDataMap.forEach((_, id) => {
|
|
37
37
|
if (!dataMap.has(id)) {
|
|
@@ -42,7 +42,7 @@ function buildResetOperation(previousDataMap, dataMap) {
|
|
|
42
42
|
if (!previousDataMap.has(id)) {
|
|
43
43
|
operations.push({ type: "add", data });
|
|
44
44
|
}
|
|
45
|
-
if (previousDataMap.has(id) && !
|
|
45
|
+
if (previousDataMap.has(id) && !compare(previousDataMap.get(id), data)) {
|
|
46
46
|
operations.push({ type: "update", id, data });
|
|
47
47
|
}
|
|
48
48
|
});
|
|
@@ -55,7 +55,7 @@ function getSymbol(name) {
|
|
|
55
55
|
|
|
56
56
|
exports.addBemModifier = addBemModifier;
|
|
57
57
|
exports.bem = bem;
|
|
58
|
-
exports.
|
|
58
|
+
exports.buildDiffOperation = buildDiffOperation;
|
|
59
59
|
exports.emptyOperation = emptyOperation;
|
|
60
60
|
exports.flattenOperations = flattenOperations;
|
|
61
61
|
exports.generateId = generateId;
|
package/dist/index.d.cts
CHANGED
|
@@ -22,10 +22,10 @@ declare function isDraftOperation<T extends IData>(operation: DataOperation<T>):
|
|
|
22
22
|
declare function isEmptyBatchOperation<T extends IData>(operation: DataOperation<T>): operation is DataEmptyBatchOperation<T>;
|
|
23
23
|
declare function flattenOperations<T extends IData>(operations: DataOperation<T>[]): DataOperation<T>[];
|
|
24
24
|
declare function emptyOperation<T extends IData>(): DataEmptyBatchOperation<T>;
|
|
25
|
-
declare function
|
|
25
|
+
declare function buildDiffOperation<T extends IData>(previousDataMap: Map<string, T>, dataMap: Map<string, T>, compare?: (a: T | undefined, b: T | undefined) => boolean): DataBatchOperation<T>;
|
|
26
26
|
|
|
27
27
|
declare function getSymbol<TName extends string>(name: TName): symbol & {
|
|
28
28
|
__knotx__?: TName;
|
|
29
29
|
};
|
|
30
30
|
|
|
31
|
-
export { type DataEmptyBatchOperation, type DataInitBatchOperation, addBemModifier, bem,
|
|
31
|
+
export { type DataEmptyBatchOperation, type DataInitBatchOperation, addBemModifier, bem, buildDiffOperation, emptyOperation, flattenOperations, generateId, getSymbol, isDraftOperation, isEmptyBatchOperation, isInitOperation };
|
package/dist/index.d.mts
CHANGED
|
@@ -22,10 +22,10 @@ declare function isDraftOperation<T extends IData>(operation: DataOperation<T>):
|
|
|
22
22
|
declare function isEmptyBatchOperation<T extends IData>(operation: DataOperation<T>): operation is DataEmptyBatchOperation<T>;
|
|
23
23
|
declare function flattenOperations<T extends IData>(operations: DataOperation<T>[]): DataOperation<T>[];
|
|
24
24
|
declare function emptyOperation<T extends IData>(): DataEmptyBatchOperation<T>;
|
|
25
|
-
declare function
|
|
25
|
+
declare function buildDiffOperation<T extends IData>(previousDataMap: Map<string, T>, dataMap: Map<string, T>, compare?: (a: T | undefined, b: T | undefined) => boolean): DataBatchOperation<T>;
|
|
26
26
|
|
|
27
27
|
declare function getSymbol<TName extends string>(name: TName): symbol & {
|
|
28
28
|
__knotx__?: TName;
|
|
29
29
|
};
|
|
30
30
|
|
|
31
|
-
export { type DataEmptyBatchOperation, type DataInitBatchOperation, addBemModifier, bem,
|
|
31
|
+
export { type DataEmptyBatchOperation, type DataInitBatchOperation, addBemModifier, bem, buildDiffOperation, emptyOperation, flattenOperations, generateId, getSymbol, isDraftOperation, isEmptyBatchOperation, isInitOperation };
|
package/dist/index.d.ts
CHANGED
|
@@ -22,10 +22,10 @@ declare function isDraftOperation<T extends IData>(operation: DataOperation<T>):
|
|
|
22
22
|
declare function isEmptyBatchOperation<T extends IData>(operation: DataOperation<T>): operation is DataEmptyBatchOperation<T>;
|
|
23
23
|
declare function flattenOperations<T extends IData>(operations: DataOperation<T>[]): DataOperation<T>[];
|
|
24
24
|
declare function emptyOperation<T extends IData>(): DataEmptyBatchOperation<T>;
|
|
25
|
-
declare function
|
|
25
|
+
declare function buildDiffOperation<T extends IData>(previousDataMap: Map<string, T>, dataMap: Map<string, T>, compare?: (a: T | undefined, b: T | undefined) => boolean): DataBatchOperation<T>;
|
|
26
26
|
|
|
27
27
|
declare function getSymbol<TName extends string>(name: TName): symbol & {
|
|
28
28
|
__knotx__?: TName;
|
|
29
29
|
};
|
|
30
30
|
|
|
31
|
-
export { type DataEmptyBatchOperation, type DataInitBatchOperation, addBemModifier, bem,
|
|
31
|
+
export { type DataEmptyBatchOperation, type DataInitBatchOperation, addBemModifier, bem, buildDiffOperation, emptyOperation, flattenOperations, generateId, getSymbol, isDraftOperation, isEmptyBatchOperation, isInitOperation };
|
package/dist/index.js
CHANGED
|
@@ -29,7 +29,7 @@ function flattenOperations(operations) {
|
|
|
29
29
|
function emptyOperation() {
|
|
30
30
|
return { type: "batch", operations: [] };
|
|
31
31
|
}
|
|
32
|
-
function
|
|
32
|
+
function buildDiffOperation(previousDataMap, dataMap, compare = Object.is) {
|
|
33
33
|
const operations = [];
|
|
34
34
|
previousDataMap.forEach((_, id) => {
|
|
35
35
|
if (!dataMap.has(id)) {
|
|
@@ -40,7 +40,7 @@ function buildResetOperation(previousDataMap, dataMap) {
|
|
|
40
40
|
if (!previousDataMap.has(id)) {
|
|
41
41
|
operations.push({ type: "add", data });
|
|
42
42
|
}
|
|
43
|
-
if (previousDataMap.has(id) && !
|
|
43
|
+
if (previousDataMap.has(id) && !compare(previousDataMap.get(id), data)) {
|
|
44
44
|
operations.push({ type: "update", id, data });
|
|
45
45
|
}
|
|
46
46
|
});
|
|
@@ -51,4 +51,4 @@ function getSymbol(name) {
|
|
|
51
51
|
return Symbol.for(`knotx:${name}`);
|
|
52
52
|
}
|
|
53
53
|
|
|
54
|
-
export { addBemModifier, bem,
|
|
54
|
+
export { addBemModifier, bem, buildDiffOperation, emptyOperation, flattenOperations, generateId, getSymbol, isDraftOperation, isEmptyBatchOperation, isInitOperation };
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@knotx/utils",
|
|
3
|
-
"version": "0.2.
|
|
3
|
+
"version": "0.2.12",
|
|
4
4
|
"description": "Utils for Knotx",
|
|
5
5
|
"author": "boenfu",
|
|
6
6
|
"license": "MIT",
|
|
@@ -28,12 +28,12 @@
|
|
|
28
28
|
"dist"
|
|
29
29
|
],
|
|
30
30
|
"dependencies": {
|
|
31
|
-
"@knotx/data": "0.2.
|
|
31
|
+
"@knotx/data": "0.2.12"
|
|
32
32
|
},
|
|
33
33
|
"devDependencies": {
|
|
34
|
-
"@knotx/build-config": "0.2.
|
|
35
|
-
"@knotx/eslint-config": "0.2.
|
|
36
|
-
"@knotx/typescript-config": "0.2.
|
|
34
|
+
"@knotx/build-config": "0.2.12",
|
|
35
|
+
"@knotx/eslint-config": "0.2.12",
|
|
36
|
+
"@knotx/typescript-config": "0.2.12"
|
|
37
37
|
},
|
|
38
38
|
"scripts": {
|
|
39
39
|
"build": "unbuild",
|