随笔分类 -  Compose

1 2 3 4 5 ··· 7 下一页
摘要:在转换AST节点的过程中,往往需要根据其子节点的情况来决定如何对当前节点进行转换,这就要求父节点的转换操作必须等待其所有子节点全部转换完毕之后再执行。 但是我们现在设计的转换流程并不支持这个能力,我们是从根节点开始,顺序往下执行的流程,如下图: 当一个节点被处理时,意味着它的子节点已经被处理完毕了, 阅读全文
posted @ 2025-06-26 13:51 Zhentiw 阅读(16) 评论(0) 推荐(0)
摘要:For example, we have following code doing AST transform from templateAST to Javascript AST function traverseNode(ast) { const currentNode = ast; // If 阅读全文
posted @ 2025-06-26 13:50 Zhentiw 阅读(13) 评论(0) 推荐(0)
摘要:const template = "<p>Vue</p>"; const State = { initial: 1, // init state tagOpen: 2, tagName: 3, text: 4, tagEnd: 5, tagEndName: 6, }; function isAlph 阅读全文
posted @ 2025-06-25 13:15 Zhentiw 阅读(10) 评论(0) 推荐(0)
摘要:function observe(obj) { for (const key in obj) { let internalValue = obj[key]; const funs = new Set() Object.defineProperty(obj, key, { configurable: 阅读全文
posted @ 2024-09-24 01:21 Zhentiw 阅读(18) 评论(0) 推荐(0)
摘要:https://www.npmjs.com/package/ses Lockdown The lockdown() function also tames some objects including regular expressions, locale methods, and errors. 阅读全文
posted @ 2023-11-08 03:31 Zhentiw 阅读(20) 评论(0) 推荐(0)
摘要:Concurrency + Channel (CSP): Concurrency is a way to run operation in isolated thread, a way to better utilize the CPU resources and handle multi simu 阅读全文
posted @ 2023-10-31 15:10 Zhentiw 阅读(17) 评论(0) 推荐(0)
摘要:function getData(d) { setTimeout(() => { if (typeof d "number") { run.next(d/2) } else { run.next(d) } }, 500) } function* gen() { var x = 1 + (yield 阅读全文
posted @ 2023-10-26 14:43 Zhentiw 阅读(14) 评论(0) 推荐(0)
摘要:Thunks Sync thunk: A blocker of code which has everything ready and can return the value directly. function add(x, y) { return x + y } const thunk = f 阅读全文
posted @ 2023-10-18 14:52 Zhentiw 阅读(28) 评论(0) 推荐(0)
摘要:An example of callback implemnetation for handling async flow: function fakeAjax(url, cb) { var fake_responses = { file1: "The first text", file2: "Th 阅读全文
posted @ 2023-10-17 15:03 Zhentiw 阅读(26) 评论(0) 推荐(0)
摘要:1. Basic version of signals We have a basic version of signal: const stack = [] export function createSignal(value) { const subscribers = new Set(); c 阅读全文
posted @ 2023-10-06 15:07 Zhentiw 阅读(23) 评论(0) 推荐(0)
摘要:Implement two functions of Signals createSignal: return a tuple with read function and wrtie function createEffect: accept a function which will be ex 阅读全文
posted @ 2023-10-05 16:16 Zhentiw 阅读(15) 评论(0) 推荐(0)
摘要:PubSub is one of the most foundational patterns for reactivity. Firing an event out with publish() allows anyone to listen to that event subscribe() a 阅读全文
posted @ 2023-10-04 02:19 Zhentiw 阅读(21) 评论(0) 推荐(0)
摘要:Requirements: function strBuilder(str) { return strBuilder; // TODO } var hello = strBuilder("Hello, "); var kyle = hello("Kyle"); var susan = hello(" 阅读全文
posted @ 2022-08-03 19:56 Zhentiw 阅读(30) 评论(0) 推荐(0)
摘要:function f(...args) { return args; } function flip(fn) { return function flipped (arg1, arg2, ...args) { return fn(arg2, arg1, ...args) } } let z = fl 阅读全文
posted @ 2022-07-31 16:45 Zhentiw 阅读(34) 评论(0) 推荐(0)
摘要:New broadcaster: compose: export let combine = (broadcaster1, broadcaster2) => listener => { let value1; let value2; let cancel1 = broadcaster1(value 阅读全文
posted @ 2020-12-17 15:49 Zhentiw 阅读(114) 评论(0) 推荐(0)
摘要:To build out our word game, we will have to be able to share the word across a few places. This means we have to set up a broadcaster that will push t 阅读全文
posted @ 2020-12-10 17:00 Zhentiw 阅读(131) 评论(0) 推荐(0)
摘要:Caches exist to make things faster (at the expense of taking up more memory and possibly outdated results). Our live search is a great use case for im 阅读全文
posted @ 2020-12-09 15:40 Zhentiw 阅读(98) 评论(0) 推荐(0)
摘要:In previous post, we check how to use ifElse to branch out the logic: https://www.cnblogs.com/Answer1215/p/14093562.html let inputToBooks = pipe( wait 阅读全文
posted @ 2020-12-08 22:28 Zhentiw 阅读(117) 评论(0) 推荐(0)
摘要:So far, we've used filter to prevent values when a condition is met. Sometimes you want two different behaviors based on a condition which is where yo 阅读全文
posted @ 2020-12-06 18:05 Zhentiw 阅读(159) 评论(0) 推荐(0)
摘要:export let mapError = transform => broadcaster => listener => { return broadcaster((value) => { if (value instanceof Error) { listener(transform(value 阅读全文
posted @ 2020-11-26 03:15 Zhentiw 阅读(78) 评论(0) 推荐(0)

1 2 3 4 5 ··· 7 下一页