nv-data-fullmesh
=================
- normal map cant send msg between map-elements
- nv-data-fullmesh creat a full-meshed(a-link-between-eachother) map



install
=======
- npm install nv-data-fullmesh

usage
=====

    const {Mesh} = require("nv-data-fullmesh");

###init

    var cfg = {
        'd':{},
        'a':[],
        'm':new Map(),
        'n':0,
        'f':()=>{},
        's':"str",
    }
    var mesh = new Mesh(cfg);
    > mesh
    Map {
      'd' => {},
      'a' => [],
      'm' => Map {},
      'n' => 0,
      'f' => [Function: f],
      's' => str
    }
    >
    > mesh.ls()
    [ 'd', 'a', 'm', 'n', 'f', 's' ]
    >

    > mesh.a
    []
    > mesh.d
    {}
    > mesh.f
    [Function: f]
    > mesh.m
    Map {}
    > mesh.n
    0
    >
    
### repr  and data

    > mesh.a.data.push(100)
    1
    > mesh.a
    [ 100 ]
    > mesh.a.data           //use .data to take real-data
    [ 100 ]
    >
    

### send and recv message between nodes

    mesh.a.recv_from_handler = (src,msg,self) => {console.log(src,msg,self)}
    > mesh.d.id
    'd'
    >

    mesh.d.send_to(mesh.a,"hello!")
    > mesh.d.send_to(mesh.a,"hello! i am "+mesh.d.id)
    {} hello! i am d [100]
    undefined
    >
    Array.from(mesh).forEach(nd=>{nd.recv_from_handler=(src,msg,self) => {console.log(src,msg,self)}})
    > mesh.a.broadcast("hi,every one")
    [ 100 ] hi,every one {}
    [ 100 ] hi,every one Map {}
    [ 100 ] hi,every one 0
    [ 100 ] hi,every one [Function: f]
    [ 100 ] hi,every one str
    undefined
    >

    > mesh.a.multicast([mesh.d,mesh.m],"youe are objects!!")
    [ 100 ] youe are objects!! {}
    [ 100 ] youe are objects!! Map {}
    undefined
    >

### send and recv between controller(mesh)  and nodes

    mesh.recv_from_nd_handler = (src,msg,self)=>{console.log(src,msg)}
    
    Array.from(mesh).forEach(nd=>{nd.recv_from_ctrl_handler=(ctrl,msg,self) => {console.log(msg,self)}})
    > mesh.broadcast("whos is function?")
    whos is function? {}
    whos is function? [ 100 ]
    whos is function? Map {}
    whos is function? 0
    whos is function? [Function: f]
    whos is function? str
    undefined
    >
    
    > mesh.f.send_to_ctrl("i am")
    [Function: f] i am
    undefined
    >


### rm/add(on mesh)  disconn(on node)

    > mesh.rm('f')
    [Function: f]
    > mesh.ls()
    [ 'd', 'a', 'm', 'n', 's' ]
    >
    > mesh.add(WeakMap,'c')
    [Function: WeakMap]
    >
    > mesh
    Map {
      'd' => {},
      'a' => [ 100 ],
      'm' => Map {},
      'n' => 0,
      's' => str,
      'c' => [Function: WeakMap]
    }
    >

    > mesh
    Map {
      'd' => {},
      'a' => [ 100 ],
      'm' => Map {},
      'n' => 0,
      's' => str,
      'c' => [Function: WeakMap]
    }
    > mesh.c.disconn()
    [Function: WeakMap]
    > mesh
    Map { 'd' => {}, 'a' => [ 100 ], 'm' => Map {}, 'n' => 0, 's' => str }
    >

### adj/neighbors

    > mesh.a.$$.d === mesh.d
    true
    > mesh.a.$$.m === mesh.m
    true
    >

    > mesh.a.neighbors()
    { d: {}, m: Map {}, n: 0, f: [Function: f], s: str }
    >
    >

METHODS
=======

### MESH (controller)

    mesh.add                   mesh.broadcast             
    mesh.init_with_array       mesh.init_with_dict
    mesh.init_with_map         mesh.length                
    mesh.ls                    mesh.multicast             
    mesh.recv_from_nd_handler  mesh.rm                    
    mesh.send_to               mesh.to_dict               
    mesh.to_map                mesh.to_weakmap

### NODE

    mesh.a.$$                      mesh.a.broadcast               
    mesh.a.data                    mesh.a.disconn                 
    mesh.a.id                      mesh.a.multicast               
    mesh.a.neighbors               mesh.a.recv_from_ctrl_handler  
    mesh.a.recv_from_handler       mesh.a.send_to                 
    mesh.a.send_to_ctrl


APIS
====
- nvmesh.ERROR\_DICT

LICENSE
=======
- ISC 
