规范化.js
零依赖性 Ethereum 名称服务 (ENS)名称"常态".
npm i @adraffy/ens-normalize ✓
- QQ 跟踪 ENSIP-15 (英语): ENS 名称规范化标准
- 统一码 :
17.0.0• 批准:47 - 其他执行:
- 蟒蛇—— 名称hash/普通化-平通
- 脏- 7个/规范化 - r
- 齐格.. evmts/ (单位:千美元)z - 感通性
- C # - 开始吧.. 严重/ENSNORMORICE.cs (英语)
- 爪哇语 - 严重/(原始内容存档于2019-10-21) (英语). ENSNormarize.java
- 挥 -- -- 严重/ENSNORMORIZE.swift (英语)
- 开始.. 严重/正常运行
- 挥 -- -- 严重/ENSNORMORIZE.swift (英语)
- 先前执行:
- 爪哇语- 内域/名称
- ENSIP-1报告细目
- 统一码 :
- 传球 100% ENSIP-15 验证测试
- 传球 100% Unicode 规范化测试
- 已缩小的文件大小 :
- 包含 Apps :
- 相关项目:
- 最近的.eth登记 二. 支助 续 二. 支助 过期
- 标签数据库 二. 支助 标签- 1 二. 支助 野蛮武力
- Emoji 频率探索器
- 严重/punycode.js (英语) 二. 支助 Punycode 编码器
- 严重/(中文(简体) ) 二. 支助 凯查克・哈舍
- 严重/emoji.js (英语) 二. 支助 Emoji 解析器
- 下方更多链接 解析器Demo
import {ens_normalize} from '@adraffy/ens-normalize'; // or require()
// browser: https://cdn.jsdelivr.net/npm/@adraffy/ens-normalize@latest/dist/index.min.mjs (or .cjs)
// *** ALL errors thrown by this library are safe to print ***
// - characters are shown as {HEX} if should_escape()
// - potentially different bidi directions inside "quotes"
// - 200E is used near "quotes" to prevent spillover
// - an "error type" can be extracted by slicing up to the first (:)
// - labels are middle-truncated with ellipsis (…) at 63 cps
// string -> string
// throws on invalid names
// output ready for namehash
let normalized = ens_normalize('RaFFY🚴♂️.eTh');
// => "raffy🚴♂.eth"
// note: does not enforce .eth registrar 3-character minimum
用完全合格的emoji格式化名称 :
// works like ens_normalize()
// output ready for display
let pretty = ens_beautify('1⃣2⃣.eth');
// => "1️⃣2️⃣.eth"
// note: normalization is unchanged:
// ens_normalize(ens_beautify(x)) == ens_normalize(x)
将名称片断规范化 子字符串搜索数字 :
// these fragments fail ens_normalize()
// but will normalize fine as fragments
let frag1 = ens_normalize_fragment('AB--'); // expected error: label ext
let frag2 = ens_normalize_fragment('\u{303}'); // expected error: leading cm
let frag3 = ens_normalize_fragment('οо'); // expected error: mixture
基于输入的符号化 :
// string -> Token[]
// never throws
let tokens = ens_tokenize('_R💩\u{FE0F}a\u{FE0F}\u{304}\u{AD}./');
// [
// { type: 'valid', cps: [ 95 ] }, // valid (as-is)
// {
// type: 'mapped',
// cp: 82, // input
// cps: [ 114 ] // output
// },
// {
// type: 'emoji',
// input: Emoji(2) [ 128169, 65039 ], // input
// emoji: [ 128169, 65039 ], // fully-qualified
// cps: Emoji(1) [ 128169 ] // output (normalized)
// },
// {
// type: 'nfc',
// input: [ 97, 772 ], // input (before nfc)
// cps: [ 257 ], // output (after nfc)
// tokens0: [ // tokens (before nfc)
// { type: 'valid', cps: [ 97 ] },
// { type: 'ignored', cp: 65039 },
// { type: 'valid', cps: [ 772 ] }
// ],
// tokens: [ // tokens (after nfc)
// { type: 'valid', cps: [ 257 ] }
// ]
// },
// { type: 'ignored', cp: 173 },
// { type: 'stop', cp: 46 },
// { type: 'disallowed', cp: 47 }
// ]
// note: if name is normalizable, then:
// ens_normalize(ens_tokenize(name).map(token => {
// ** convert valid/mapped/nfc/stop to string **
// }).join('')) == ens_normalize(name)
基于输出的符号化 :
// string -> Label[]
// never throws
let labels = ens_split('💩Raffy.eth_');
// [
// {
// input: [ 128169, 82, 97, 102, 102, 121 ],
// offset: 0, // index of codepoint, not substring index!
// // (corresponding length can be inferred from input)
// tokens: [
// Emoji(2) [ 128169, 65039 ], // emoji
// [ 114, 97, 102, 102, 121 ] // nfc-text
// ],
// output: [ 128169, 114, 97, 102, 102, 121 ],
// emoji: true,
// type: 'Latin'
// },
// {
// input: [ 101, 116, 104, 95 ],
// offset: 7,
// tokens: [ [ 101, 116, 104, 95 ] ],
// output: [ 101, 116, 104, 95 ],
// error: Error('underscore allowed only at start')
// }
// ]
生成一个被排序的(被beauized)支持的emoji编码点数组 :
// () -> number[][]
let emojis = ens_emoji();
// [
// [ 2764 ],
// [ 128169, 65039 ],
// [ 128105, 127997, 8205, 9877, 65039 ],
// ...
// ]
确定一个字符是否不应被直接打印 :
// number -> bool
should_escape(0x202E); // eg. RIGHT-TO-LEFT OVERRIDE => true
确定字符是否为组合标记 :
// number -> bool
is_combining_mark(0x20E3); // eg. COMBINING ENCLOSING KEYCAP => true
将代码点格式化为打印安全字符串 :
// number[] -> string
safe_str_from_cps([0x300, 0, 32, 97]); // "◌̀{00} a"
safe_str_from_cps(Array(100).fill(97), 4); // "aa…aa" => middle-truncated
构建
git clone那么,这个雷波npm install- 执行指令 /贬损/ 生成数据文件
npm run derive
npm run make——从压缩数据文件 /衍生/产出/- 执行指令 /验证/ 生成验证测试
npm run validate
npm run test进行验证测试npm run build——创建 盘点/盘点npm run rebuild- 运行上面的所有命令npm run order——再创建最佳组顺序并重建
警卫
- 构建 比较 包含版本.js
spec_hash—— SHA-256,第256页 spec.json (英语) 字节ens_hash_base64—— SHA-256,第256页 包含 -ens.js 基数64升nf_hash_base64—— SHA-256,第256页 包含-nf.js 基数64升