@tldraw/utils
Advanced tools
Comparing version 3.8.0-canary.13edafe3f1e3 to 3.8.0-canary.14f2faba6b93
@@ -392,2 +392,4 @@ import { default as throttle } from 'lodash.throttle'; | ||
/* Excluded from this release type: mergeArraysAndReplaceDefaults */ | ||
/* Excluded from this release type: minBy */ | ||
@@ -394,0 +396,0 @@ |
@@ -92,2 +92,3 @@ "use strict"; | ||
measureDuration: () => import_perf.measureDuration, | ||
mergeArraysAndReplaceDefaults: () => import_array.mergeArraysAndReplaceDefaults, | ||
minBy: () => import_array.minBy, | ||
@@ -161,5 +162,5 @@ mockUniqueId: () => import_id.mockUniqueId, | ||
"@tldraw/utils", | ||
"3.8.0-canary.13edafe3f1e3", | ||
"3.8.0-canary.14f2faba6b93", | ||
"cjs" | ||
); | ||
//# sourceMappingURL=index.js.map |
@@ -26,2 +26,3 @@ "use strict"; | ||
maxBy: () => maxBy, | ||
mergeArraysAndReplaceDefaults: () => mergeArraysAndReplaceDefaults, | ||
minBy: () => minBy, | ||
@@ -99,2 +100,14 @@ partition: () => partition, | ||
} | ||
function mergeArraysAndReplaceDefaults(key, customEntries, defaults) { | ||
const overrideTypes = new Set(customEntries.map((entry) => entry[key])); | ||
const result = []; | ||
for (const defaultEntry of defaults) { | ||
if (overrideTypes.has(defaultEntry[key])) continue; | ||
result.push(defaultEntry); | ||
} | ||
for (const customEntry of customEntries) { | ||
result.push(customEntry); | ||
} | ||
return result; | ||
} | ||
//# sourceMappingURL=array.js.map |
{ | ||
"name": "@tldraw/utils", | ||
"description": "A tiny little drawing app (private utilities).", | ||
"version": "3.8.0-canary.13edafe3f1e3", | ||
"version": "3.8.0-canary.14f2faba6b93", | ||
"author": { | ||
@@ -6,0 +6,0 @@ "name": "tldraw Inc.", |
@@ -13,2 +13,3 @@ import { registerTldrawLibraryVersion } from './lib/version' | ||
maxBy, | ||
mergeArraysAndReplaceDefaults, | ||
minBy, | ||
@@ -15,0 +16,0 @@ partition, |
@@ -100,1 +100,21 @@ /** | ||
} | ||
/** @internal */ | ||
export function mergeArraysAndReplaceDefaults< | ||
const Key extends string, | ||
T extends { [K in Key]: string }, | ||
>(key: Key, customEntries: readonly T[], defaults: readonly T[]) { | ||
const overrideTypes = new Set(customEntries.map((entry) => entry[key])) | ||
const result = [] | ||
for (const defaultEntry of defaults) { | ||
if (overrideTypes.has(defaultEntry[key])) continue | ||
result.push(defaultEntry) | ||
} | ||
for (const customEntry of customEntries) { | ||
result.push(customEntry) | ||
} | ||
return result | ||
} |
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
537214
8033