wenye

Results 9 comments of wenye

不会啊 写的很好 楼上是因为没有看第一篇文章才觉得牵强吧

用了koa大半年,看了楼主写的东西很是震惊(特别是洋葱结构那块),很惭愧自己只是停留在使用的方面。大神,受我一拜!!

```ts type GetArrayItemTypes = T extends Array ? A : never; type Includes = E extends GetArrayItemTypes ? true : false; // 你的实现代码 type I0 = Includes; // false type...

```ts type Tail = T extends [any, ... infer Rest] ? Rest : []; // 你的实现代码 // 测试用例 type T0 = Tail // [] type T1 = Tail // [2]...

```ts type Unshift = [E, ...T] // 你的实现代码 // 测试用例 type Arr0 = Unshift; // [1] type Arr1 = Unshift; // [0, 1, 2, 3] ```

```ts type Head = T extends [infer First, ...any[]] ? First : never; // 测试用例 type H0 = Head; // never type H1 = Head; // 1 type H2 =...

```ts type Person = { id: string; name: string; age: number; from?: string; speak?: string; }; type OptionalKeys = NonNullable< { [K in keyof T]: undefined extends T[K] ? K...

```ts type Push = [...T, V] // 你的实现代码 // 测试用例 type Arr0 = Push // [1] type Arr1 = Push // [1, 2, 3, 4] ```

自问自答,其实就是相比较vue的实现,watcher的update方法少了一个判断,改成这样就行了。 只有在值不同,值是对象或本身是deep的watcher中,才会触发回调 ``` update() { const value = this.get(); if (value !== this.value || isObject(value) || this.deep) { const oldValue = this.value; this.value = value; this.cb.call(this.vm, this.value, oldValue); } }...