Build NapCat Artifacts / Windows Loader Test (push) Canceled after 0s
Build NapCat Artifacts / Type Check & Test (push) Canceled after 0s
Build NapCat Artifacts / Build NapCat.Framework (push) Canceled after 0s
Build NapCat Artifacts / Build NapCat.Shell (push) Canceled after 0s
23 lines
842 B
Plaintext
23 lines
842 B
Plaintext
import { CreateType } from '../create/type.mjs';
|
|
import { ReadonlyKind } from '../symbols/index.mjs';
|
|
import { Discard } from '../discard/index.mjs';
|
|
import { ReadonlyFromMappedResult } from './readonly-from-mapped-result.mjs';
|
|
import { IsMappedResult } from '../guard/kind.mjs';
|
|
function RemoveReadonly(schema) {
|
|
return CreateType(Discard(schema, [ReadonlyKind]));
|
|
}
|
|
function AddReadonly(schema) {
|
|
return CreateType({ ...schema, [ReadonlyKind]: 'Readonly' });
|
|
}
|
|
// prettier-ignore
|
|
function ReadonlyWithFlag(schema, F) {
|
|
return (F === false
|
|
? RemoveReadonly(schema)
|
|
: AddReadonly(schema));
|
|
}
|
|
/** `[Json]` Creates a Readonly property */
|
|
export function Readonly(schema, enable) {
|
|
const F = enable ?? true;
|
|
return IsMappedResult(schema) ? ReadonlyFromMappedResult(schema, F) : ReadonlyWithFlag(schema, F);
|
|
}
|