Object Library (Obj)
Linked with the "obj" type.
Example Usage
#[main]
fn main() {
const o = new {};
assert_eq(Obj.parent(o), self);
assert_eq(o.parent(), self);
}Obj.any(obj: obj) -> bool
const obj = new { x: 0, y: 0 };
assert(obj.any());Obj.at(obj: obj, index: int) -> (str, unknown)
const obj = new { x: 0, y: 0 };
assert_eq(obj[1], ("y", 0));Obj.attributes(obj: obj, path: str = null) -> map
Obj.children(obj: obj) -> list
Obj.contains(obj: obj, name: str) -> bool
Obj.create_type(obj: obj, typename: str) -> void
Obj.dbg_graph() -> void
Obj.dist(obj: obj, other: obj) -> int
Obj.empty(obj: obj) -> bool
Obj.exists(obj: obj) -> bool
Obj.fields(obj: obj) -> list
Obj.from_id(id: str) -> obj
Obj.from_map(map: map) -> obj
Obj.funcs(obj: obj, attributes: str | list | set = null) -> list
Obj.get(obj: obj, name: str) -> unknown
Obj.id(obj: obj) -> str
Obj.insert(obj: obj, path: str, value: unknown) -> void
Obj.instance_of(obj: obj, proto: str | obj) -> bool
Obj.is_parent(obj: obj, other: obj) -> bool
Obj.is_root(obj: obj) -> bool
Obj.len(obj: obj) -> int
Obj.move(obj: obj, dest: obj) -> bool
Obj.move_field(obj: obj, source: str, dest: str) -> bool
Obj.name(obj: obj) -> str
Obj.parent(obj: obj) -> obj
Obj.path(obj: obj) -> str
Obj.prototype(obj: obj) -> obj
Obj.remove(obj: obj, path: str, shallow: bool = false) -> bool
Shallow
Obj.remove_prototype(obj: obj) -> void
Obj.root(obj: obj) -> obj
Obj.run(obj: obj) -> void
Motivation
Concrete Example
Obj.schemafy(schema: obj, target: obj, remove_invalid: bool = false, remove_undefined: bool = false) -> bool
Use Cases
Obj.set_prototype(obj: obj, proto: obj | str) -> void
Obj.to_map(obj: obj) -> map
Obj.upcast(obj: obj) -> bool
Last updated