nv-buf-func-serde
v1.0.1
Published
nv-buf-func-serde ======================= - only work in nodejs - for serialize a function, - this is just for test, similiar to eval
Downloads
5
Readme
nv-buf-func-serde
- only work in nodejs
- for serialize a function,
- this is just for test, similiar to eval
install
- npm install nv-buf-func-serde
usage
const x = require("nv-buf-func-serde");
example
0
var src_code_str = `
() => {
console.log(new Date);
var psj = Promise.withResolvers();
setTimeout(
()=>{
console.log(new Date);
psj.resolve(9999)
},
3000
);
return(psj.promise)
}
`;
var buf = x.compile_src_code_to_buf(src_code_str);
// > buf
//<Buffer f2 05 de c0 6e 55 fc b4 dd 00 00 00 17 1c c0 e2 a0 15 f5 af a8 03 00 00 00 00 00 00 00 00 00 00 01 20 54 01 20 06 ac 60 00 00 00 00 06 00 00 00 01 0c ... 918 more bytes>
//>
var f = x.load_from_buf(buf);
> f()
2024-07-06T12:54:46.287Z
Promise {
<pending>,
[Symbol(async_id_symbol)]: 409,
[Symbol(trigger_async_id_symbol)]: 6
}
> 2024-07-06T12:54:49.292Z
0_0
0_1
1
1_0
1_1
METHODS
APIS
LICENSE
- ISC