varHarrie

Results 42 issues of varHarrie

一、 追加组件 - [ ] Collapse - [ ] Menu - [ ] Radio - [ ] Radio.Group - [ ] Radio.RadioButton - [ ] Step - [ ] Slider...

```typescript template="vanilla-ts" function asyncThrottle(tasks: Array Promise>, concurrency = 1) { return new Promise((resolve) => { const entries = tasks.entries(); let remains = tasks.length; const run = () => { const...

Javascript

实现`withProps`函数,用于提前注入组件属性。 ```tsx import { ComponentProps, ComponentType, ForwardRefExoticComponent, forwardRef, memo } from 'react'; type ElementType = keyof JSX.IntrinsicElements | ComponentType; type GetProps = | Partial | ((props: ComponentProps & E) =>...

React

> 笔记内容大多引用于: > - [Rust官网](https://www.rust-lang.org/) > - [Rust语言圣经](https://course.rs/about-book.html) > - [Rust 程序设计语言](https://kaisery.github.io/trpl-zh-cn/title-page.html) ### 1、Cargo常用命令 ```bash # 创建项目 cargo new # 创建库 cargo new --lib # 构建项目 cargo build # 构建并运行项目...

Rust

```js const fs = require('fs'); const path = require('path'); async function traverse(dir, callback) { const items = await fs.promises.readdir(dir, { withFileTypes: true }); return Promise.all( items.map((item) => { const fullPath...

Node.js

> 最后更新于:2021-05-31 > 转载请说明出处,谢谢 ## 一、食用说明 - 相似功能的插件,不推荐全都装上,请挑选一个使用 - 本列表所有插件均已测试使用过,但不代表不存在问题 - 任何插件本身的问题,请到对于代码仓库提交issue ## 二、拓展 名称 | 简述 ---- | ---- [Auto Close Tag](https://marketplace.visualstudio.com/items?itemName=formulahendry.auto-close-tag) | 自动闭合HTML标签 [Auto Import](https://marketplace.visualstudio.com/items?itemName=steoates.autoimport) | import提示 [Auto...

Tools

```typescript template="vanilla-ts" function clamp (value: number, min: number, max: number) { return Math.max(min, Math.min(max, value)) } function formatBytes(bytes: number) { const units = ['Bytes', 'KB', 'MB', /** 'GB', 'TB', 'PB',...

Javascript

```javascript template="vanilla" // 根据正负判断是之前还是之后 function toText (val, before, after) { return Math.abs(val) + (val > 0 ? before : after) } function fromNow (date, format) { let ms = Date.now()...

Javascript

**实现** ```javascript template="vanilla" function format (str, ...args) { return args.reduce((str, arg, index) => { // 当参数是字符串,则用参数的值替换{i}的位置 if (typeof arg === 'string') return str.replace(new RegExp('\\{' + index + '\\}'), arg) //...

Javascript

> [上一个教程中](https://github.com/varHarrie/Dawn-Blossoms/issues/13),我们已经把一个react项目跑起来了,但是怎么看都觉得太过于敷衍,在这次教程中我们将使用webpack配置一个称心的开发环境 > 本教程webpack版本号为2+ > 接下来的教程,将在上一个教程项目的基础上完成 > > 主要完成以下改进: > > 1. 引入webpack,实现模块管理 > > 2. 实现监听文件改动,自动编译并刷新浏览器 > > 3. 实现热替换(HMR) ## 1. 初步引入webpack:实现模块管理 在根目录下创建`webpack.dev.js`文件: ```javascript const path = require('path')...

Javascript
React