Skip to content

Commit

Permalink
refactor(array): update
Browse files Browse the repository at this point in the history
  • Loading branch information
unadlib committed Jan 4, 2025
1 parent d1df210 commit aa048b2
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 7 deletions.
9 changes: 3 additions & 6 deletions src/draft.ts
Original file line number Diff line number Diff line change
Expand Up @@ -128,13 +128,13 @@ const proxyHandler: ProxyHandler<ProxyDraft> = {
(value === peek(target.original, key) ||
target.options.skipFinalization!.has(value))
) {
const has = target.options.skipFinalization!.has(value);
if (target.options.skipFinalization!.has(value)) {
const shouldSkip = target.options.skipFinalization!.has(value);
if (shouldSkip) {
target.options.skipFinalization!.delete(value);
}
ensureShallowCopy(target);
target.copy![key] = createDraft({
original: has ? target.copy![key] : target.original[key],
original: shouldSkip ? target.copy![key] : target.original[key],
parentDraft: target,
key: target.type === DraftType.Array ? Number(key) : key,
finalities: target.finalities,
Expand All @@ -153,9 +153,6 @@ const proxyHandler: ProxyHandler<ProxyDraft> = {
if (arrayHandling && !isDraft(value) && isDraftable(value)) {
target.options.skipFinalization!.add(value);
}
if (!arrayHandling && target.options.skipFinalization!.has(value)) {
target.options.skipFinalization!.delete(value);
}
return value;
},
set(target: ProxyDraft, key: string | number | symbol, value: any) {
Expand Down
2 changes: 1 addition & 1 deletion src/utils/finalize.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ export function handleValue(
!isDraftable(target, options) ||
handledSet.has(target) ||
Object.isFrozen(target) ||
options?.skipFinalization!.has(target)
(options!.skipFinalization!.has(target))
)
return;
const isSet = target instanceof Set;
Expand Down

0 comments on commit aa048b2

Please sign in to comment.