-
-
Save SherryQueen/26e57c99f80675a4c7828a58252ea988 to your computer and use it in GitHub Desktop.
编码相关
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| require/exports 社区规范 可动态加载模块 地址可寻找 传递值或引用 | |
| import/export es6规范 静态编译 地址不可寻 强制 值绑定 即 将所有模块加载到一个js里面 | |
| 隐藏类 | |
| v8 会将拥有相同属性的(按相同顺序声明的同类型的对象 在vm中构建一个隐藏类 从而加快读取优化) 采用地址偏移从而避免高消耗的寻址 | |
| 内联缓存 | |
| 基于隐藏类, 在两次查找隐藏类后直接将偏移地址添加到对象上从而直接使用 | |
| 事件队列 | |
| 每个tick检查事件是否需要处理(检查已加入队列中的回调(完成的回调事件 | |
| 1. idle 观察者(早已等待的事件 | |
| 2. I/O观察者(调用I/O线程池执行I/O操作 | |
| 3. check观察者(定时任务等 | |
| setImmediate 本次tick结束后 下次tick开始前执行(tick执行时间可能过长 | |
| setTimeout 若设为0 将会呗等价于1ms | |
| child_process | |
| spawn 返回的时候标准输入输出, 子进程有数据生成就会讲数据输送给返回流对象 | |
| exec 子进程执行完毕后,将缓冲区的数据一次性返回给对象(有数据上限) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| //// | |
| //// 同个定时执行的函数的回调函数在事件队列中只保留一个 | |
| //// 每调用一次定时或间隔, 对应的回调函数都会被执行 | |
| //// 若定时回调函数执行时间过长, 再执行完后会立即检查时间间隔并再一次执行定时的回调函数 | |
| //// | |
| const fun1 = () => { | |
| console.log('start fun1') | |
| let i = 10 ** 10 | |
| while (--i) {} | |
| console.log('end fun1') | |
| } | |
| const fun2 = () => { | |
| console.log('start fun2') | |
| let i = 10 ** 10 | |
| while (--i) {} | |
| console.log('end fun2') | |
| } | |
| // setTimeout(fun1, 1000) | |
| // setTimeout(fun1, 1000) | |
| // setTimeout(fun1, 1000) | |
| // setTimeout(fun2, 1000) | |
| // setInterval(fun1, 1000) | |
| // setInterval(fun1, 1000) | |
| // setInterval(fun1, 1000) | |
| // setInterval(fun2, 1000) | |
| setInterval(fun1, 1000) | |
| // setTimeout(fun2, 1000) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| ### 字符集 | |
| - 字库表 | |
| - 编码字符集 (Unicode) | |
| 编码值 表示 文字在字库表的位置 | |
| - 字符编码 (UTF-8) | |
| 将编码值转为另一种格式进行存储 | |
| #### UTF-8 编码(只支持到三字节,若是emoj 这种 则需要采用 4四字节的编码) | |
| - 0 开头 表示单字节编码 | |
| - 110 开头 表示双字节 | |
| - 1110 开头 表示 三字节 | |
| - 10 多字节 符的 第二个 字节开头 | |
| 各种编码方式 可以 通过编码规则 互相转化成 | |
| iconv-lite库 进行编码转换 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment