@12core/hyperid-wasm 中文文档教程
hyperid-wasm
以 ZZ 编写并编译为 WebAssembly (WASM) 格式的 HyperID 实现
Installation
Node
$ npm install @12core/hyperid-wasm
WAPM
$ wapm install jwerle/hyperid-wasm
Usage
const hyperid = require('hyperid-wasm')
hyperid.ready(() => {
const hid = hyperid({ fixedLength: true, startFrom: 1024 })
console.log(hid()) // atd1gpRDT1SJZnaOhdLR5Q/0000001024
console.log(hid()) // atd1gpRDT1SJZnaOhdLR5Q/0000001025
})
API
generator = hyperid([opts])
创建一个新的 hyperid
生成器,其中 opts
是相同的参数 赋予原始 hyperid。
const generator = hyperid({
fixedLength: false, // use a fixed length counter
startFrom: 0, // initial counter value
urlSafe: false, // use URL safe characters
})
id = generator()
从 hyperid
上下文生成一个 hyperid。 (见上文)
const id = generator()
Benchmark
这个原始模块比这个快 4 倍 .
hyperid generate - variable length (original) x 11,806,789 ops/sec ±1.59% (83 runs sampled)
hyperid generate - variable length (wasm) x 4,179,909 ops/sec ±0.95% (88 runs sampled)
hyperid generate - fixed length (original) x 9,347,663 ops/sec ±3.26% (88 runs sampled)
hyperid generate - fixed length (wasm) x 3,772,629 ops/sec ±2.14% (92 runs sampled)
Limits
Initial Memory
默认情况下,该模块为 WebAssembly 模块分配 2 页内存。 即 2 * 64 * 1024
字节。
Maximum Memory
该模块最多允许 256 页内存。 即 256 * 64 * 1024
字节。
See Also
- https://github.com/mcollina/hyperid
License
麻省理工学院
hyperid-wasm
A HyperID implementation written in ZZ compiled to WebAssembly (WASM) format
Installation
Node
$ npm install @12core/hyperid-wasm
WAPM
$ wapm install jwerle/hyperid-wasm
Usage
const hyperid = require('hyperid-wasm')
hyperid.ready(() => {
const hid = hyperid({ fixedLength: true, startFrom: 1024 })
console.log(hid()) // atd1gpRDT1SJZnaOhdLR5Q/0000001024
console.log(hid()) // atd1gpRDT1SJZnaOhdLR5Q/0000001025
})
API
generator = hyperid([opts])
Create a new hyperid
generator where opts
is the same arguments given to the original hyperid.
const generator = hyperid({
fixedLength: false, // use a fixed length counter
startFrom: 0, // initial counter value
urlSafe: false, // use URL safe characters
})
id = generator()
Generate a hyperid from hyperid
context. (See above)
const id = generator()
Benchmark
This original module is ~4x faster than this one.
hyperid generate - variable length (original) x 11,806,789 ops/sec ±1.59% (83 runs sampled)
hyperid generate - variable length (wasm) x 4,179,909 ops/sec ±0.95% (88 runs sampled)
hyperid generate - fixed length (original) x 9,347,663 ops/sec ±3.26% (88 runs sampled)
hyperid generate - fixed length (wasm) x 3,772,629 ops/sec ±2.14% (92 runs sampled)
Limits
Initial Memory
By default, this module allocates 2 pages of memory for the WebAssembly module. That is 2 * 64 * 1024
bytes.
Maximum Memory
This module allows at most 256 pages of memory. That is 256 * 64 * 1024
bytes.
See Also
- https://github.com/mcollina/hyperid
License
MIT
更多
你可能也喜欢
- 3box-profile-edit-react 中文文档教程
- 7tools 中文文档教程
- @12core/date-input-polyfill 中文文档教程
- @40three/kendo-angular-extensions 中文文档教程
- @4sellers/ngx-datatable 中文文档教程
- @4so-fourseasons/stylelint-config-sane-order 中文文档教程
- @aaron3993/lotide 中文文档教程
- @abi-software/mapcore-osparc-remote-interface 中文文档教程
- @abide-community/parcel-plugin-clean-out-dir 中文文档教程
- @abler/ats-front-resources-api 中文文档教程