Skip to content

Instantly share code, notes, and snippets.

View ylc395's full-sized avatar
😎

叡山电车 ylc395

😎
View GitHub Profile
@BrianHung
BrianHung / changedDescendants.ts
Created April 4, 2021 07:55
prosemirror changed nodes / part of document by transaction
/**
* Helper for iterating through the nodes in a document that changed compared
* to the given previous document. Useful for avoiding duplicate work on each transaction.
* Source: https://github.com/ProseMirror/prosemirror-tables/blob/master/src/fixtables.js
*/
import type { Node as PMNode } from "prosemirror-model"
export function changedDescendants(old: PMNode, cur: PMNode, offset: number, f: (node: PMNode, pos: number) => void) {
let oldSize = old.childCount, curSize = cur.childCount
outer: for (let i = 0, j = 0; i < curSize; i++) {
@sindresorhus
sindresorhus / esm-package.md
Last active November 15, 2024 15:20
Pure ESM package

Pure ESM package

The package that linked you here is now pure ESM. It cannot be require()'d from CommonJS.

This means you have the following choices:

  1. Use ESM yourself. (preferred)
    Use import foo from 'foo' instead of const foo = require('foo') to import the package. You also need to put "type": "module" in your package.json and more. Follow the below guide.
  2. If the package is used in an async context, you could use await import(…) from CommonJS instead of require(…).
  3. Stay on the existing version of the package until you can move to ESM.
@lvxianchao
lvxianchao / npm.taobao.sh
Last active October 14, 2024 13:34
设置 npm 和 yarn 的镜像源为淘宝镜像源
# ==========================================================
# NPM
# ==========================================================
npm set registry https://registry.npmmirror.com # 注册模块镜像
npm set disturl https://npmmirror.com/mirrors/node # node-gyp 编译依赖的 node 源码镜像
## 以下选择添加
npm set sass_binary_site https://registry.npmmirror.com/mirrors/node-sass # node-sass 二进制包镜像
npm set electron_mirror https://registry.npmmirror.com/mirrors/electron/ # electron 二进制包镜像

What is an FRP application.

An FRP application has the following properties

  • Functional, pure, immutable.
  • Reactive, your application is a DAG, you react to "core" inputs and from new outputs.

Being an immutable DAG

If your application is an immutable DAG it has certain properties

@brettz9
brettz9 / html5-dataset.js
Last active April 29, 2023 14:58
Dataset Shim
/**
* Add dataset support to elements
* No globals, no overriding prototype with non-standard methods,
* handles CamelCase properly, attempts to use standard
* Object.defineProperty() (and Function bind()) methods,
* falls back to native implementation when existing
* Inspired by http://code.eligrey.com/html5/dataset/
* (via https://github.com/adalgiso/html5-dataset/blob/master/html5-dataset.js )
* Depends on Function.bind and Object.defineProperty/Object.getOwnPropertyDescriptor (polyfills below)
* All code below is Licensed under the X11/MIT License