forked from hyoo-ru/mam_mol
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathobject.ts
55 lines (40 loc) · 1.16 KB
/
object.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
namespace $ {
export namespace $$ { let $ }
export class $mol_object {
static $ : $mol_ambient_context = $ as any
get $() {
const owner = this.object_owner()
return ( owner && owner.$ || $ ) as $mol_ambient_context
}
public static make< Instance >( this : { new() : Instance } , config : Partial< Instance > ) : Instance {
const instance = new this
for( let key in config ) instance[ key ] = config[ key ]!
return instance
}
static toString() : string {
return this.name
}
'object_owner()' : any
object_owner( next? : any ) {
return this[ 'object_owner()' ] || ( this[ 'object_owner()' ] = next )
}
'object_host()' : any
object_host( next? : any ) {
return this[ 'object_host()' ] || ( this[ 'object_host()' ] = next )
}
'object_field()' : string
object_field( next? : string ) {
return this[ 'object_field()' ] || ( this[ 'object_field()' ] = next! ) || ''
}
object_id( next? : string ) {
return this[ Symbol.toStringTag ] || ( this[ Symbol.toStringTag ] = next ) || ''
}
toString() {
return this.object_id()
}
toJSON() {
return this.toString()
}
destructor() { }
}
}