mirror of
https://github.com/yume-chan/ya-webadb.git
synced 2025-10-04 18:29:23 +02:00
refactor(struct): rename runtime to basic
This commit is contained in:
parent
5569a874eb
commit
f9502f0e6f
10 changed files with 0 additions and 0 deletions
28
packages/struct/src/basic/runtime-value.ts
Normal file
28
packages/struct/src/basic/runtime-value.ts
Normal file
|
@ -0,0 +1,28 @@
|
|||
import { FieldRuntimeValue } from './runtime-type';
|
||||
|
||||
const RuntimeValues = Symbol('RuntimeValues');
|
||||
|
||||
export interface WithRuntimeValues {
|
||||
[RuntimeValues]: Record<string, FieldRuntimeValue>;
|
||||
}
|
||||
|
||||
export function createObjectWithRuntimeValues(): WithRuntimeValues {
|
||||
const object = {} as any;
|
||||
object[RuntimeValues] = {};
|
||||
return object;
|
||||
}
|
||||
|
||||
export function getRuntimeValue(object: WithRuntimeValues, field: string): FieldRuntimeValue {
|
||||
return (object as any)[RuntimeValues][field] as FieldRuntimeValue;
|
||||
}
|
||||
|
||||
export function setRuntimeValue(object: WithRuntimeValues, field: string, runtimeValue: FieldRuntimeValue): void {
|
||||
(object as any)[RuntimeValues][field] = runtimeValue;
|
||||
delete (object as any)[field];
|
||||
Object.defineProperty(object, field, {
|
||||
configurable: true,
|
||||
enumerable: true,
|
||||
get() { return runtimeValue.get(); },
|
||||
set(value) { runtimeValue.set(value); },
|
||||
});
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue