摘要: Creational patterns provide object creation mechanisms that increase flexibility and reuse of existing code. Factory method: Provides an interface for 阅读全文
posted @ 2024-01-23 15:11 Zhentiw 阅读(24) 评论(0) 推荐(0)
摘要: Just for fun... Given a number (always positive) as a type. Your type should return the number decreased by one. For example: type Zero = MinusOne<1> 阅读全文
posted @ 2022-10-07 22:57 Zhentiw 阅读(64) 评论(0) 推荐(0)
摘要: Blog: https://www.geeksforgeeks.org/es6-trampoline-function/ Stackoverflow problem for recursion: const sumBelow = (number, sum = 0) => ( number 0 ? s 阅读全文
posted @ 2022-08-18 14:32 Zhentiw 阅读(51) 评论(0) 推荐(0)
摘要: Serverless framework with AWS Link to each sections Table of Content: Part 0: Serverless Project structure Part 1: DynamoDB & ApiGateway Part 2: Event 阅读全文
posted @ 2021-05-17 15:15 Zhentiw 阅读(166) 评论(0) 推荐(0)
摘要: Storage Services: S3 Glacier CloudFront Elastic Block Store (EBS) Storage Gateway Snow family Database Overview Block storage: Used on local networks 阅读全文
posted @ 2021-03-15 03:06 Zhentiw 阅读(158) 评论(0) 推荐(0)
摘要: S3 Features Prefiees and delimiters For example: the file name in S3 can be: `marking/plans/kpi_2021_1.pdf`. The point is make it looks like a folder 阅读全文
posted @ 2021-03-12 17:34 Zhentiw 阅读(163) 评论(0) 推荐(0)
摘要: In our previous code, we have seen this partten for operators: // #region operators const concat = curry((broadcaster, listener) => { let string = ''; 阅读全文
posted @ 2020-10-25 21:54 Zhentiw 阅读(162) 评论(0) 推荐(0)
该文被密码保护。 阅读全文
posted @ 2020-05-07 18:22 Zhentiw 阅读(0) 评论(0) 推荐(0)
摘要: Generators can yield promises which can work with the "for await of" loop syntax. This lesson shows how all the pieces fit together and explains why t 阅读全文
posted @ 2020-03-22 02:59 Zhentiw 阅读(174) 评论(0) 推荐(0)
摘要: In this post, we are going to see how to use Ramda Lens. For example, we have data: R.lens: R.lens takes a getter and a setter: R.lensProp: There is a 阅读全文
posted @ 2019-02-24 20:12 Zhentiw 阅读(721) 评论(0) 推荐(0)
摘要: Just like the State ADT an Array is also an Applicative Functor. That means we can do the same tricks with liftA2 with Array that we have been doing w 阅读全文
posted @ 2019-01-16 16:30 Zhentiw 阅读(718) 评论(0) 推荐(0)
摘要: Use custom Cypress command for reusable assertions We’re duplicating quite a few commands between the registration and login of our user for assertion 阅读全文
posted @ 2018-12-06 21:13 Zhentiw 阅读(437) 评论(0) 推荐(0)
摘要: Use Cypress to test user registration Let’s write a test to fill out our registration form. Because we’ll be running this against a live backend, we n 阅读全文
posted @ 2018-12-05 15:54 Zhentiw 阅读(361) 评论(0) 推荐(0)
摘要: Despite the fact that Cypress is an application that runs natively on your machine, you can install it and add it as a dependency just like all other 阅读全文
posted @ 2018-12-05 02:38 Zhentiw 阅读(586) 评论(0) 推荐(0)
摘要: Ensure Functions are Called Correctly with JavaScript Mocks Often when writing JavaScript tests and mocking dependencies, you’ll want to verify that t 阅读全文
posted @ 2018-11-06 04:25 Zhentiw 阅读(437) 评论(0) 推荐(0)
摘要: 1. Color Picker (Chrome) You might know how to use color picker in Chrome, recently there is a feature inside color picker which is "Contrast Ratio", 阅读全文
posted @ 2018-07-15 18:41 Zhentiw 阅读(250) 评论(0) 推荐(0)
摘要: We'll examine how to unnest function calls, capture assignment, and create a linear data flow with a type we call Box. This is our introduction to wor 阅读全文
posted @ 2016-12-11 21:47 Zhentiw 阅读(339) 评论(0) 推荐(0)
摘要: Well, this stuff will be a little bit strange if you deal with it first time. Container Object: Just a wrapper / contianer for values No Method No Nou 阅读全文
posted @ 2016-09-06 04:23 Zhentiw 阅读(347) 评论(0) 推荐(0)
摘要: First, what is 'High Order function', basic just a function, inside the function return another fuction. For example: Decorators is a subset of high o 阅读全文
posted @ 2016-06-14 03:10 Zhentiw 阅读(386) 评论(0) 推荐(0)
摘要: Somehow it looks like reflect in Java. For example: We define an mothod on the Object, it called defineMethod(). It accepts two arguements, one is met 阅读全文
posted @ 2016-05-02 03:06 Zhentiw 阅读(389) 评论(0) 推荐(0)
摘要: 作者:谢杰 该文章是并发异步操作系列文章第五篇。 有了前面几篇文章所介绍的知识铺垫后,本系列最终篇,我们来封装一个能够指定并发上限的方法。 需求 先来过一下需求,封装一个异步方法 runWithConcurrency,如下: async function runWithConcurrency(ite 阅读全文
posted @ 2025-10-30 14:43 Zhentiw 阅读(4) 评论(0) 推荐(0)
摘要: 作者:谢杰 该文章是并发异步操作系列文章第四篇。 今天我们来解决一个很多同学经常搞混的概念对:并发和并行。 这两个词在日常交流中常常被混用,但在编程领域,它们指的是完全不同的执行模式。理解它们的区别,不仅能帮你正确选型,还能在调优性能时少走弯路。 先抛一个问题: 你一边刷手机一边等外卖,这是并发还是 阅读全文
posted @ 2025-10-30 14:35 Zhentiw 阅读(6) 评论(0) 推荐(0)
摘要: 作者:谢杰 该文章是并发异步操作系列文章第三篇。 前面介绍了关于 Promise 的相关静态方法,本篇文章来做一个实战,封装一个超时工具方法。 需求 先说一下需求,非常简单,执行异步任务的时候,异步任务完成的时间是不定的,因此我们做一个超时的功能。 超时函数(异步任务, 能接受的时间, 遥控器) 超 阅读全文
posted @ 2025-10-29 14:44 Zhentiw 阅读(7) 评论(0) 推荐(0)
摘要: 作者:谢杰 该文章是并发异步操作系列文章第二篇。 早期大家学习 Promise 的时候,都是从最基础的例子开始的,例如: // 创建一个 Promise 实例 const myPromise = new Promise((resolve, reject) => { // 模拟异步任务,例如 2 秒后 阅读全文
posted @ 2025-10-29 14:37 Zhentiw 阅读(7) 评论(0) 推荐(0)
摘要: 异步任务取消机制 作者:谢杰 该文章是并发异步操作系列文章第一篇。 为什么需要取消异步任务 在现代的 Web 和 Node.js 应用中,我们经常需要启动一些耗时较长的异步任务,比如: 下载大文件 进行高强度的计算 持续监听一个长时间的事件流 然而,一旦任务开始运行,传统上我们只能等待它结束或因异常 阅读全文
posted @ 2025-10-29 14:32 Zhentiw 阅读(8) 评论(0) 推荐(0)
摘要: LangChain Expression Language,是 LangChain 提供的一种声明式构建 链式 调用流程的方式。它允许开发者用 .pipe() 操作符将不同的模块(如提示模板、模型、解析器等)连接起来,形成一个完整的“链(Chain)”。 LCEL 的设计理念: 所有模块都实现统一接 阅读全文
posted @ 2025-10-26 16:04 Zhentiw 阅读(3) 评论(0) 推荐(0)
摘要: LangChain.js v1.0 Streaming Guide Overview In LangChain.js v1.0, streaming has changed significantly from v0.x. This guide shows you how to properly i 阅读全文
posted @ 2025-10-26 16:01 Zhentiw 阅读(3) 评论(0) 推荐(0)
摘要: 在做聊天应用时,我们的提示词往往是一串按角色分好的消息 [ SystemMessage { "content": "xxx", }, HumanMessage { "content": "xxx", }, 占位符1 AIMessage { "content": "xxx", }, 占位符2 Huma 阅读全文
posted @ 2025-10-23 14:33 Zhentiw 阅读(5) 评论(0) 推荐(0)
摘要: 类名 用途 ChatPromptTemplate 构造整个多轮提示词结构 SystemMessagePromptTemplate 设置系统规则 / 行为模式 HumanMessagePromptTemplate 模拟用户输入 AIMessagePromptTemplate 模拟模型输出(上下文中使用 阅读全文
posted @ 2025-10-23 13:40 Zhentiw 阅读(7) 评论(0) 推荐(0)
摘要: 在跟各种 聊天模型 交互的时候,在构建聊天信息时,不仅仅包含了像上文中的文本内容,也需要与每条消息关联的角色信息。 例如这条信息是由 人类、AI、还是给 chatbot 指定的 system 信息,这种结构化的消息输入有助于模型更好地理解对话的上下文和流程,从而生成更准确、更自然的回应。 为了方便地 阅读全文
posted @ 2025-10-21 13:42 Zhentiw 阅读(5) 评论(0) 推荐(0)