Skip to content

Instantly share code, notes, and snippets.

View Mapaler's full-sized avatar
🎯
主要开发PADDashFormation

枫谷剑仙 Mapaler

🎯
主要开发PADDashFormation
View GitHub Profile
@Mapaler
Mapaler / binary-flags.js
Created April 25, 2024 14:19
二进制和Flags转换类
class Bin extends Set {
static #typeError_Constructor = "传入的不是 number 和 bigint 类型或这个两个类型的数组";
static #typeError_FlagsNum = "传入的不是 number 和 bigint 类型";
static #typeError_FlagsArray = "传入的不是 number 类型的数组";
static #typeError_NotInteger = "传入的不是 整数";
static #rangeError_NotSafe = "传入的 number 大于 53 位";
/**
* 构建函数
* @param {(number | bigint | number[])} arg 传入参数
*/
@Mapaler
Mapaler / CustomTokenList.js
Created August 4, 2022 12:30
Simplified custom DOMTokenList implementation. 自己实现的具有 DOMTokenList 功能的类。
/*
* Detail: 仿照 DOMTokenList 功能实现的自定义 CustomTokenList Version2 (extends Array)
* Reference: https://gist.github.com/dimitarnestorov/48b69a918288e9098db1aab904a2722a
* Use:
let span = document.querySelector("span");
let _ctl = new CustomTokenList(span, "custom-token");
span.customTokenList = _ctl;
span.customTokenList.add("token1","token2");
console.log(span.getAttribute("custom-token"));
// token1 token2