Skip to content

Commit 85f4df5

Browse files
committed
[delta] purify
1 parent 620b2ae commit 85f4df5

File tree

2 files changed

+9
-9
lines changed

2 files changed

+9
-9
lines changed

bundle.test.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11

2-
import * as s from './hash/rabin.js'
2+
import * as b from './delta/delta.js'
33

4-
console.log(s.StandardIrreducible8)
4+
console.log(b.create().insert('hi').toJSON())
55

delta/delta.js

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -37,14 +37,14 @@ import * as prng from '../prng.js'
3737
/**
3838
* @type {s.Schema<Attribution>}
3939
*/
40-
export const $attribution = s.$object({
40+
export const $attribution = /*@__PURE__*/(()=>s.$object({
4141
insert: s.$array(s.$string).optional,
4242
insertAt: s.$number.optional,
4343
delete: s.$array(s.$string).optional,
4444
deleteAt: s.$number.optional,
4545
format: s.$record(s.$string, s.$array(s.$string)).optional,
4646
formatAt: s.$number.optional
47-
})
47+
}))()
4848

4949
/**
5050
* @typedef {s.Unwrap<$anyOp>} DeltaOps
@@ -86,11 +86,11 @@ export const $attribution = s.$object({
8686
/**
8787
* @type {s.Schema<DeltaAttrOpJSON>}
8888
*/
89-
export const $deltaMapChangeJson = s.$union(
89+
export const $deltaMapChangeJson = /*@__PURE__*/(()=>s.$union(
9090
s.$object({ type: s.$literal('insert'), value: s.$any, prevValue: s.$any.optional, attribution: $attribution.optional }),
9191
s.$object({ type: s.$literal('modify'), value: s.$any }),
9292
s.$object({ type: s.$literal('delete'), prevValue: s.$any.optional, attribution: $attribution.optional })
93-
)
93+
))()
9494

9595
/**
9696
* @template {{[key:string]: any} | null} Attrs
@@ -1969,7 +1969,7 @@ export const $delta = ({ name, attrs, children, text, formats, recursiveChildren
19691969
formats == null ? s.$any : s.$(formats)
19701970
))
19711971

1972-
export const $$delta = s.$constructedBy($Delta)
1972+
export const $$delta = /*@__PURE__*/s.$constructedBy($Delta)
19731973

19741974
/**
19751975
* @todo remove this
@@ -2020,8 +2020,8 @@ export const _$delta = ({ name, attrs, children, text, recursive }) => {
20202020
return /** @type {any} */ ($d)
20212021
}
20222022

2023-
export const $deltaAny = /** @type {s.Schema<DeltaAny>} */ (s.$type('delta'))
2024-
export const $deltaBuilderAny = /** @type {s.Schema<DeltaBuilderAny>} */ (s.$custom(o => $deltaAny.check(o) && !o.isDone))
2023+
export const $deltaAny = /** @type {s.Schema<DeltaAny>} */ (/*@__PURE__*/s.$type('delta'))
2024+
export const $deltaBuilderAny = /** @type {s.Schema<DeltaBuilderAny>} */ (/*@__PURE__*/s.$custom(o => $deltaAny.check(o) && !o.isDone))
20252025

20262026
/**
20272027
* Helper function to merge attribution and attributes. The latter input "wins".

0 commit comments

Comments
 (0)