From 4f7f908045bada1cefb81cdcaa06cacecbb9fc47 Mon Sep 17 00:00:00 2001 From: Roger Qiu Date: Thu, 21 Oct 2021 15:01:14 +1100 Subject: [PATCH 1/2] Fixed IdSortable's fixed point overflowing millisecond bits and demonstrated base64 does not preserve lexicographic-order --- src/index.ts | 1 + src/utils.ts | 14 +++++- tests/IdSortable.test.ts | 93 ++++++++++++++++++++++++++++------------ tests/utils.test.ts | 82 ++++++++++++++++++++++++++++++++++- 4 files changed, 158 insertions(+), 32 deletions(-) diff --git a/src/index.ts b/src/index.ts index 9f7ed88..7cc479d 100644 --- a/src/index.ts +++ b/src/index.ts @@ -1,3 +1,4 @@ +export { default as Id } from './Id'; export { default as IdRandom } from './IdRandom'; export { default as IdDeterministic } from './IdDeterministic'; export { default as IdSortable } from './IdSortable'; diff --git a/src/utils.ts b/src/utils.ts index 8036b4d..d1e273a 100644 --- a/src/utils.ts +++ b/src/utils.ts @@ -237,14 +237,24 @@ function toFixedPoint( size: number, precision?: number, ): [number, number] { - const integer = Math.trunc(floating); + let integer = Math.trunc(floating); let fractional: number; if (precision == null) { fractional = floating % 1; } else { fractional = roundPrecise(floating % 1, precision); } - const fractionalFixed = Math.round(fractional * 2 ** size); + // If the fractional is rounded to 1 + // then it should be added to the integer + if (fractional === 1) { + integer += fractional; + fractional = 0; + } + // Floor is used to round down to a number that can be represented by the bit size + // if ceil or round was used, it's possible to return a number that would overflow the bit size + // for example if 12 bits is used, then 4096 would overflow to all zeros + // the maximum for 12 bit is 4095 + const fractionalFixed = Math.floor(fractional * 2 ** size); return [integer, fractionalFixed]; } diff --git a/tests/IdSortable.test.ts b/tests/IdSortable.test.ts index 9ed4170..78b3c9b 100644 --- a/tests/IdSortable.test.ts +++ b/tests/IdSortable.test.ts @@ -46,14 +46,19 @@ describe('IdSortable', () => { expect(id.equals(id_)).toBe(true); }); test('ids in bytes are lexically sortable', () => { - const id = new IdSortable(); - const i1 = utils.toBuffer(id.get()); - const i2 = utils.toBuffer(id.get()); - const i3 = utils.toBuffer(id.get()); - const buffers = [i3, i1, i2]; - // Comparison is done on the bytes in lexicographic order - buffers.sort(Buffer.compare); - expect(buffers).toStrictEqual([i1, i2, i3]); + const idGen = new IdSortable(); + // This generating over 100,000 ids and checks that they maintain + // sort order for each 100 chunk of ids + let count = 1000; + while (count > 0) { + const idBuffers = [...utils.take(idGen, 100)]; + const idBuffersShuffled = idBuffers.slice(); + shuffle(idBuffersShuffled); + // Comparison is done on the bytes in lexicographic order + idBuffersShuffled.sort(Buffer.compare); + expect(idBuffersShuffled).toStrictEqual(idBuffers); + count--; + } }); test('ids in bytes are lexically sortable with time delay', async () => { const id = new IdSortable(); @@ -69,29 +74,61 @@ describe('IdSortable', () => { }); test('encoded id strings are lexically sortable', () => { const idGen = new IdSortable(); - const idStrings = [...utils.take(idGen, 100)].map((id) => id.toString()); + // This generating over 100,000 ids and checks that they maintain + // sort order for each 100 chunk of ids + let count = 1000; + while (count > 0) { + const idStrings = [...utils.take(idGen, 100)].map((id) => id.toString()); + const idStringsShuffled = idStrings.slice(); + shuffle(idStringsShuffled); + idStringsShuffled.sort(); + expect(idStringsShuffled).toStrictEqual(idStrings); + count--; + } + }); + test('encoded uuids are lexically sortable', () => { + // UUIDs are hex encoding, and the hex alphabet preserves order + const idGen = new IdSortable(); + // This generating over 100,000 ids and checks that they maintain + // sort order for each 100 chunk of ids + let count = 1000; + while (count > 0) { + const idUUIDs = [...utils.take(idGen, 100)].map(utils.toUUID); + const idUUIDsShuffled = idUUIDs.slice(); + shuffle(idUUIDsShuffled); + idUUIDsShuffled.sort(); + expect(idUUIDsShuffled).toStrictEqual(idUUIDs); + count--; + } + }); + test('encoded multibase strings may be lexically sortable (base58btc)', () => { + // Base58btc's alphabet preserves sort order + const idGen = new IdSortable(); + // This generating over 100,000 ids and checks that they maintain + // sort order for each 100 chunk of ids + let count = 1000; + while (count > 0) { + const idStrings = [...utils.take(idGen, 100)].map((id) => + utils.toMultibase(id, 'base58btc'), + ); + const idStringsShuffled = idStrings.slice(); + shuffle(idStringsShuffled); + idStringsShuffled.sort(); + expect(idStringsShuffled).toStrictEqual(idStrings); + count--; + } + }); + test('encoded multibase strings may not be lexically sortable (base64)', async () => { + // Base64's alphabet does not preserve sort order + const idGen = new IdSortable(); + const idStrings = [...utils.take(idGen, 100)].map((id) => + utils.toMultibase(id, 'base64'), + ); const idStringsShuffled = idStrings.slice(); shuffle(idStringsShuffled); idStringsShuffled.sort(); - expect(idStringsShuffled).toStrictEqual(idStrings); - }); - test('encoded uuids are lexically sortable', () => { - const id = new IdSortable(); - const i1 = utils.toUUID(id.get()); - const i2 = utils.toUUID(id.get()); - const i3 = utils.toUUID(id.get()); - const uuids = [i3, i2, i1]; - uuids.sort(); - expect(uuids).toStrictEqual([i1, i2, i3]); - }); - test('encoded multibase strings are lexically sortable', () => { - const id = new IdSortable(); - const i1 = utils.toMultibase(id.get(), 'base58btc'); - const i2 = utils.toMultibase(id.get(), 'base58btc'); - const i3 = utils.toMultibase(id.get(), 'base58btc'); - const encodings = [i3, i2, i1]; - encodings.sort(); - expect(encodings).toStrictEqual([i1, i2, i3]); + // It will not equal + expect(idStringsShuffled).not.toStrictEqual(idStrings); }); test('ids are monotonic within the same timestamp', () => { // To ensure that we it generates monotonic ids diff --git a/tests/utils.test.ts b/tests/utils.test.ts index 6a098c7..41fe9c0 100644 --- a/tests/utils.test.ts +++ b/tests/utils.test.ts @@ -85,20 +85,98 @@ describe('utils', () => { // we should expect .102 to be the resulting fractional const fp1 = 1633860855.1015312; const fixed1 = utils.toFixedPoint(fp1, 12, 3); - expect(fixed1[1]).toBe(418); + expect(fixed1[1]).toBe(417); const fp1_ = utils.fromFixedPoint(fixed1, 12, 3); expect(fp1_).toBe(utils.roundPrecise(fp1, 3)); // Also to 3 decimal places // expecting 0.101 now const fp2 = 1633860855.1014312; const fixed2 = utils.toFixedPoint(fp2, 12, 3); - expect(fixed2[1]).toBe(414); + expect(fixed2[1]).toBe(413); const fp2_ = utils.fromFixedPoint(fixed2, 12, 3); expect(fp2_).toBe(utils.roundPrecise(fp2, 3)); // 0 edge case expect(utils.toFixedPoint(0, 12, 3)).toStrictEqual([0, 0]); expect(utils.fromFixedPoint([0, 0], 12, 3)).toBe(0.0); }); + test('fixed point conversion when close to 1', () => { + // Highest number 12 digits can represent is 4095 + // a number of 4096 would result in overflow + // here we test when we get close to 4096 + // the conversion from toFixedPoint and fromFixedPoint will be lossy + // this is because toFixedPoint will round off precision and floor any number getting close to 4096 + let closeTo: number; + let fp: [number, number]; + // Exactly at 3 decimal points + closeTo = 0.999; + fp = utils.toFixedPoint(closeTo, 12, 3); + expect(fp).toStrictEqual([0, 4091]); + expect(utils.fromFixedPoint(fp, 12, 3)).toBe(0.999); + // Will round below + closeTo = 0.9994; + fp = utils.toFixedPoint(closeTo, 12, 3); + expect(fp).toStrictEqual([0, 4091]); + expect(utils.fromFixedPoint(fp, 12, 3)).toBe(0.999); + // Will round above to 1 + closeTo = 0.9995; + fp = utils.toFixedPoint(closeTo, 12, 3); + expect(fp).toStrictEqual([1, 0]); + expect(utils.fromFixedPoint(fp, 12, 3)).toBe(1); + // Will round above to 1 + closeTo = 0.9999; + fp = utils.toFixedPoint(closeTo, 12, 3); + expect(fp).toStrictEqual([1, 0]); + expect(utils.fromFixedPoint(fp, 12, 3)).toBe(1); + // Will round above to 1 + closeTo = 0.99999; + fp = utils.toFixedPoint(closeTo, 12, 3); + expect(fp).toStrictEqual([1, 0]); + expect(utils.fromFixedPoint(fp, 12, 3)).toBe(1); + // Exactly at 5 decimal points + closeTo = 0.99999; + fp = utils.toFixedPoint(closeTo, 12, 5); + expect(fp).toStrictEqual([0, 4095]); + expect(utils.fromFixedPoint(fp, 12, 5)).toBe(0.99976); + }); + test('fixed point conversion when close to 0', () => { + let closeTo: number; + let fp: [number, number]; + // Exactly 3 decimal places + closeTo = 0.001; + fp = utils.toFixedPoint(closeTo, 12, 3); + expect(fp).toStrictEqual([0, 4]); + expect(utils.fromFixedPoint(fp, 12, 3)).toBe(0.001); + // Will round to 0 + closeTo = 0.0001; + fp = utils.toFixedPoint(closeTo, 12, 3); + expect(fp).toStrictEqual([0, 0]); + expect(utils.fromFixedPoint(fp, 12, 3)).toBe(0); + // Will round to 0 + closeTo = 0.0004; + fp = utils.toFixedPoint(closeTo, 12, 3); + expect(fp).toStrictEqual([0, 0]); + expect(utils.fromFixedPoint(fp, 12, 3)).toBe(0); + // Will round to 0.001 + closeTo = 0.0005; + fp = utils.toFixedPoint(closeTo, 12, 3); + expect(fp).toStrictEqual([0, 4]); + expect(utils.fromFixedPoint(fp, 12, 3)).toBe(0.001); + // Will round to 0.001 + closeTo = 0.00055; + fp = utils.toFixedPoint(closeTo, 12, 3); + expect(fp).toStrictEqual([0, 4]); + expect(utils.fromFixedPoint(fp, 12, 3)).toBe(0.001); + // Will round to 0.001 + closeTo = 0.0009; + fp = utils.toFixedPoint(closeTo, 12, 3); + expect(fp).toStrictEqual([0, 4]); + expect(utils.fromFixedPoint(fp, 12, 3)).toBe(0.001); + // Will round to 0.002 + closeTo = 0.0015; + fp = utils.toFixedPoint(closeTo, 12, 3); + expect(fp).toStrictEqual([0, 8]); + expect(utils.fromFixedPoint(fp, 12, 3)).toBe(0.002); + }); test('multibase encoding and decoding', () => { const bytes = new Uint8Array([ 123, 124, 125, 126, 127, 128, 129, 130, 123, 124, 125, 126, 127, 128, 129, From 30d6f1bacf47420ac680f068153b00f8aff51f2c Mon Sep 17 00:00:00 2001 From: Roger Qiu Date: Thu, 21 Oct 2021 20:19:16 +1100 Subject: [PATCH 2/2] Updated docs and note on README.md about base encodings and lexicographic order --- README.md | 4 ++ docs/assets/js/search.js | 2 +- docs/classes/Id.default.html | 12 +++--- docs/classes/IdDeterministic.default.html | 10 ++--- docs/classes/IdRandom.default.html | 12 +++--- docs/classes/IdSortable.default.html | 26 ++++++------ docs/index.html | 2 + docs/modules/Id.html | 4 +- docs/modules/IdSortable.html | 6 +-- docs/modules/index.html | 9 +++++ docs/modules/utils.html | 48 +++++++++++------------ 11 files changed, 75 insertions(+), 60 deletions(-) diff --git a/README.md b/README.md index 1eb6628..a49d881 100644 --- a/README.md +++ b/README.md @@ -71,6 +71,10 @@ console.log(sortId1 < sortId2); console.log(sortId2 < sortId3); ``` +**Base Encoding and Lexicographic Order** + +It is important to realise that not all base-encodings preserve lexicographic sort order. The UUID (hex-encoding) and `base58btc` alphabet does, but the `base64` alphabet does not. Make sure to pick an appropriate base encoding if you are expecting to compare the `IdSortable` as base-encoded strings. + ## Installation ```sh diff --git a/docs/assets/js/search.js b/docs/assets/js/search.js index 05d6a29..9a47648 100644 --- a/docs/assets/js/search.js +++ b/docs/assets/js/search.js @@ -1 +1 @@ -window.searchData = {"kinds":{"1":"Module","64":"Function","128":"Class","512":"Constructor","1024":"Property","2048":"Method","65536":"Type literal","262144":"Accessor","4194304":"Type alias","16777216":"Reference"},"rows":[{"id":0,"kind":1,"name":"Id","url":"modules/Id.html","classes":"tsd-kind-module"},{"id":1,"kind":128,"name":"default","url":"classes/Id.default.html","classes":"tsd-kind-class tsd-parent-kind-module","parent":"Id"},{"id":2,"kind":2048,"name":"create","url":"classes/Id.default.html#create","classes":"tsd-kind-method tsd-parent-kind-class tsd-is-static","parent":"Id.default"},{"id":3,"kind":512,"name":"constructor","url":"classes/Id.default.html#constructor","classes":"tsd-kind-constructor tsd-parent-kind-class tsd-is-inherited","parent":"Id.default"},{"id":4,"kind":2048,"name":"toString","url":"classes/Id.default.html#toString","classes":"tsd-kind-method tsd-parent-kind-class tsd-is-overwrite","parent":"Id.default"},{"id":5,"kind":2048,"name":"[toPrimitive]","url":"classes/Id.default.html#_toPrimitive_","classes":"tsd-kind-method tsd-parent-kind-class","parent":"Id.default"},{"id":6,"kind":4194304,"name":"Id","url":"modules/Id.html#Id-1","classes":"tsd-kind-type-alias tsd-parent-kind-module","parent":"Id"},{"id":7,"kind":1,"name":"IdDeterministic","url":"modules/IdDeterministic.html","classes":"tsd-kind-module"},{"id":8,"kind":128,"name":"default","url":"classes/IdDeterministic.default.html","classes":"tsd-kind-class tsd-parent-kind-module","parent":"IdDeterministic"},{"id":9,"kind":512,"name":"constructor","url":"classes/IdDeterministic.default.html#constructor","classes":"tsd-kind-constructor tsd-parent-kind-class","parent":"IdDeterministic.default"},{"id":10,"kind":1024,"name":"namespaceData","url":"classes/IdDeterministic.default.html#namespaceData","classes":"tsd-kind-property tsd-parent-kind-class tsd-is-protected","parent":"IdDeterministic.default"},{"id":11,"kind":2048,"name":"get","url":"classes/IdDeterministic.default.html#get","classes":"tsd-kind-method tsd-parent-kind-class","parent":"IdDeterministic.default"},{"id":12,"kind":2048,"name":"next","url":"classes/IdDeterministic.default.html#next","classes":"tsd-kind-method tsd-parent-kind-class","parent":"IdDeterministic.default"},{"id":13,"kind":2048,"name":"[iterator]","url":"classes/IdDeterministic.default.html#_iterator_","classes":"tsd-kind-method tsd-parent-kind-class","parent":"IdDeterministic.default"},{"id":14,"kind":1,"name":"IdRandom","url":"modules/IdRandom.html","classes":"tsd-kind-module"},{"id":15,"kind":128,"name":"default","url":"classes/IdRandom.default.html","classes":"tsd-kind-class tsd-parent-kind-module","parent":"IdRandom"},{"id":16,"kind":512,"name":"constructor","url":"classes/IdRandom.default.html#constructor","classes":"tsd-kind-constructor tsd-parent-kind-class","parent":"IdRandom.default"},{"id":17,"kind":1024,"name":"randomSource","url":"classes/IdRandom.default.html#randomSource","classes":"tsd-kind-property tsd-parent-kind-class tsd-is-protected","parent":"IdRandom.default"},{"id":18,"kind":65536,"name":"__type","url":"classes/IdRandom.default.html#__type","classes":"tsd-kind-type-literal tsd-parent-kind-class","parent":"IdRandom.default"},{"id":19,"kind":2048,"name":"get","url":"classes/IdRandom.default.html#get","classes":"tsd-kind-method tsd-parent-kind-class","parent":"IdRandom.default"},{"id":20,"kind":2048,"name":"next","url":"classes/IdRandom.default.html#next","classes":"tsd-kind-method tsd-parent-kind-class","parent":"IdRandom.default"},{"id":21,"kind":2048,"name":"[iterator]","url":"classes/IdRandom.default.html#_iterator_","classes":"tsd-kind-method tsd-parent-kind-class","parent":"IdRandom.default"},{"id":22,"kind":1,"name":"IdSortable","url":"modules/IdSortable.html","classes":"tsd-kind-module"},{"id":23,"kind":128,"name":"default","url":"classes/IdSortable.default.html","classes":"tsd-kind-class tsd-parent-kind-module","parent":"IdSortable"},{"id":24,"kind":512,"name":"constructor","url":"classes/IdSortable.default.html#constructor","classes":"tsd-kind-constructor tsd-parent-kind-class","parent":"IdSortable.default"},{"id":25,"kind":1024,"name":"randomSource","url":"classes/IdSortable.default.html#randomSource","classes":"tsd-kind-property tsd-parent-kind-class tsd-is-protected","parent":"IdSortable.default"},{"id":26,"kind":65536,"name":"__type","url":"classes/IdSortable.default.html#__type-1","classes":"tsd-kind-type-literal tsd-parent-kind-class","parent":"IdSortable.default"},{"id":27,"kind":1024,"name":"clock","url":"classes/IdSortable.default.html#clock","classes":"tsd-kind-property tsd-parent-kind-class tsd-is-protected","parent":"IdSortable.default"},{"id":28,"kind":65536,"name":"__type","url":"classes/IdSortable.default.html#__type","classes":"tsd-kind-type-literal tsd-parent-kind-class","parent":"IdSortable.default"},{"id":29,"kind":1024,"name":"nodeBits","url":"classes/IdSortable.default.html#nodeBits","classes":"tsd-kind-property tsd-parent-kind-class tsd-is-protected","parent":"IdSortable.default"},{"id":30,"kind":1024,"name":"lastTs","url":"classes/IdSortable.default.html#lastTs","classes":"tsd-kind-property tsd-parent-kind-class tsd-is-protected","parent":"IdSortable.default"},{"id":31,"kind":1024,"name":"_lastId","url":"classes/IdSortable.default.html#_lastId","classes":"tsd-kind-property tsd-parent-kind-class tsd-is-protected","parent":"IdSortable.default"},{"id":32,"kind":1024,"name":"seqCounter","url":"classes/IdSortable.default.html#seqCounter","classes":"tsd-kind-property tsd-parent-kind-class tsd-is-protected","parent":"IdSortable.default"},{"id":33,"kind":262144,"name":"lastId","url":"classes/IdSortable.default.html#lastId","classes":"tsd-kind-get-signature tsd-parent-kind-class","parent":"IdSortable.default"},{"id":34,"kind":2048,"name":"get","url":"classes/IdSortable.default.html#get","classes":"tsd-kind-method tsd-parent-kind-class","parent":"IdSortable.default"},{"id":35,"kind":2048,"name":"next","url":"classes/IdSortable.default.html#next","classes":"tsd-kind-method tsd-parent-kind-class","parent":"IdSortable.default"},{"id":36,"kind":2048,"name":"[iterator]","url":"classes/IdSortable.default.html#_iterator_","classes":"tsd-kind-method tsd-parent-kind-class","parent":"IdSortable.default"},{"id":37,"kind":64,"name":"extractTs","url":"modules/IdSortable.html#extractTs","classes":"tsd-kind-function tsd-parent-kind-module","parent":"IdSortable"},{"id":38,"kind":64,"name":"extractSeq","url":"modules/IdSortable.html#extractSeq","classes":"tsd-kind-function tsd-parent-kind-module","parent":"IdSortable"},{"id":39,"kind":64,"name":"extractRand","url":"modules/IdSortable.html#extractRand","classes":"tsd-kind-function tsd-parent-kind-module","parent":"IdSortable"},{"id":40,"kind":1,"name":"index","url":"modules/index.html","classes":"tsd-kind-module"},{"id":41,"kind":1,"name":"utils","url":"modules/utils.html","classes":"tsd-kind-module"},{"id":42,"kind":64,"name":"randomBytes","url":"modules/utils.html#randomBytes","classes":"tsd-kind-function tsd-parent-kind-module","parent":"utils"},{"id":43,"kind":64,"name":"randomBits","url":"modules/utils.html#randomBits","classes":"tsd-kind-function tsd-parent-kind-module","parent":"utils"},{"id":44,"kind":64,"name":"nodeBits","url":"modules/utils.html#nodeBits","classes":"tsd-kind-function tsd-parent-kind-module","parent":"utils"},{"id":45,"kind":64,"name":"timeSource","url":"modules/utils.html#timeSource","classes":"tsd-kind-function tsd-parent-kind-module","parent":"utils"},{"id":46,"kind":64,"name":"take","url":"modules/utils.html#take","classes":"tsd-kind-function tsd-parent-kind-module tsd-has-type-parameter","parent":"utils"},{"id":47,"kind":64,"name":"toString","url":"modules/utils.html#toString","classes":"tsd-kind-function tsd-parent-kind-module","parent":"utils"},{"id":48,"kind":64,"name":"fromString","url":"modules/utils.html#fromString","classes":"tsd-kind-function tsd-parent-kind-module","parent":"utils"},{"id":49,"kind":64,"name":"toUUID","url":"modules/utils.html#toUUID","classes":"tsd-kind-function tsd-parent-kind-module","parent":"utils"},{"id":50,"kind":64,"name":"fromUUID","url":"modules/utils.html#fromUUID","classes":"tsd-kind-function tsd-parent-kind-module","parent":"utils"},{"id":51,"kind":64,"name":"toMultibase","url":"modules/utils.html#toMultibase","classes":"tsd-kind-function tsd-parent-kind-module","parent":"utils"},{"id":52,"kind":64,"name":"fromMultibase","url":"modules/utils.html#fromMultibase","classes":"tsd-kind-function tsd-parent-kind-module","parent":"utils"},{"id":53,"kind":64,"name":"toBuffer","url":"modules/utils.html#toBuffer","classes":"tsd-kind-function tsd-parent-kind-module","parent":"utils"},{"id":54,"kind":64,"name":"fromBuffer","url":"modules/utils.html#fromBuffer","classes":"tsd-kind-function tsd-parent-kind-module","parent":"utils"},{"id":55,"kind":64,"name":"bytes2hex","url":"modules/utils.html#bytes2hex","classes":"tsd-kind-function tsd-parent-kind-module","parent":"utils"},{"id":56,"kind":64,"name":"hex2bytes","url":"modules/utils.html#hex2bytes","classes":"tsd-kind-function tsd-parent-kind-module","parent":"utils"},{"id":57,"kind":64,"name":"bytes2bits","url":"modules/utils.html#bytes2bits","classes":"tsd-kind-function tsd-parent-kind-module","parent":"utils"},{"id":58,"kind":64,"name":"bits2bytes","url":"modules/utils.html#bits2bytes","classes":"tsd-kind-function tsd-parent-kind-module","parent":"utils"},{"id":59,"kind":64,"name":"dec2bits","url":"modules/utils.html#dec2bits","classes":"tsd-kind-function tsd-parent-kind-module","parent":"utils"},{"id":60,"kind":64,"name":"dec2hex","url":"modules/utils.html#dec2hex","classes":"tsd-kind-function tsd-parent-kind-module","parent":"utils"},{"id":61,"kind":64,"name":"strChunks","url":"modules/utils.html#strChunks","classes":"tsd-kind-function tsd-parent-kind-module","parent":"utils"},{"id":62,"kind":64,"name":"roundPrecise","url":"modules/utils.html#roundPrecise","classes":"tsd-kind-function tsd-parent-kind-module","parent":"utils"},{"id":63,"kind":64,"name":"toFixedPoint","url":"modules/utils.html#toFixedPoint","classes":"tsd-kind-function tsd-parent-kind-module","parent":"utils"},{"id":64,"kind":64,"name":"fromFixedPoint","url":"modules/utils.html#fromFixedPoint","classes":"tsd-kind-function tsd-parent-kind-module","parent":"utils"},{"id":65,"kind":4194304,"name":"MultibaseFormats","url":"modules/utils.html#MultibaseFormats","classes":"tsd-kind-type-alias tsd-parent-kind-module","parent":"utils"},{"id":66,"kind":16777216,"name":"IdRandom","url":"modules/index.html#IdRandom","classes":"tsd-kind-reference tsd-parent-kind-module","parent":"index"},{"id":67,"kind":16777216,"name":"IdDeterministic","url":"modules/index.html#IdDeterministic","classes":"tsd-kind-reference tsd-parent-kind-module","parent":"index"},{"id":68,"kind":16777216,"name":"IdSortable","url":"modules/index.html#IdSortable","classes":"tsd-kind-reference tsd-parent-kind-module","parent":"index"},{"id":69,"kind":16777216,"name":"utils","url":"modules/index.html#utils","classes":"tsd-kind-reference tsd-parent-kind-module","parent":"index"}],"index":{"version":"2.3.9","fields":["name","parent"],"fieldVectors":[["name/0",[0,27.586]],["parent/0",[]],["name/1",[1,27.586]],["parent/1",[0,2.657]],["name/2",[2,38.572]],["parent/2",[3,2.657]],["name/3",[4,27.586]],["parent/3",[3,2.657]],["name/4",[5,33.464]],["parent/4",[3,2.657]],["name/5",[6,38.572]],["parent/5",[3,2.657]],["name/6",[0,27.586]],["parent/6",[0,2.657]],["name/7",[7,30.099]],["parent/7",[]],["name/8",[1,27.586]],["parent/8",[7,2.899]],["name/9",[4,27.586]],["parent/9",[8,2.463]],["name/10",[9,38.572]],["parent/10",[8,2.463]],["name/11",[10,30.099]],["parent/11",[8,2.463]],["name/12",[11,30.099]],["parent/12",[8,2.463]],["name/13",[12,30.099]],["parent/13",[8,2.463]],["name/14",[13,30.099]],["parent/14",[]],["name/15",[1,27.586]],["parent/15",[13,2.899]],["name/16",[4,27.586]],["parent/16",[14,2.303]],["name/17",[15,33.464]],["parent/17",[14,2.303]],["name/18",[16,30.099]],["parent/18",[14,2.303]],["name/19",[10,30.099]],["parent/19",[14,2.303]],["name/20",[11,30.099]],["parent/20",[14,2.303]],["name/21",[12,30.099]],["parent/21",[14,2.303]],["name/22",[17,23.909]],["parent/22",[]],["name/23",[1,27.586]],["parent/23",[17,2.303]],["name/24",[4,27.586]],["parent/24",[18,1.599]],["name/25",[15,33.464]],["parent/25",[18,1.599]],["name/26",[16,30.099]],["parent/26",[18,1.599]],["name/27",[19,38.572]],["parent/27",[18,1.599]],["name/28",[16,30.099]],["parent/28",[18,1.599]],["name/29",[20,33.464]],["parent/29",[18,1.599]],["name/30",[21,38.572]],["parent/30",[18,1.599]],["name/31",[22,38.572]],["parent/31",[18,1.599]],["name/32",[23,38.572]],["parent/32",[18,1.599]],["name/33",[24,38.572]],["parent/33",[18,1.599]],["name/34",[10,30.099]],["parent/34",[18,1.599]],["name/35",[11,30.099]],["parent/35",[18,1.599]],["name/36",[12,30.099]],["parent/36",[18,1.599]],["name/37",[25,38.572]],["parent/37",[17,2.303]],["name/38",[26,38.572]],["parent/38",[17,2.303]],["name/39",[27,38.572]],["parent/39",[17,2.303]],["name/40",[28,25.579]],["parent/40",[]],["name/41",[29,9.855]],["parent/41",[]],["name/42",[30,38.572]],["parent/42",[29,0.949]],["name/43",[31,38.572]],["parent/43",[29,0.949]],["name/44",[20,33.464]],["parent/44",[29,0.949]],["name/45",[32,38.572]],["parent/45",[29,0.949]],["name/46",[33,38.572]],["parent/46",[29,0.949]],["name/47",[5,33.464]],["parent/47",[29,0.949]],["name/48",[34,38.572]],["parent/48",[29,0.949]],["name/49",[35,38.572]],["parent/49",[29,0.949]],["name/50",[36,38.572]],["parent/50",[29,0.949]],["name/51",[37,38.572]],["parent/51",[29,0.949]],["name/52",[38,38.572]],["parent/52",[29,0.949]],["name/53",[39,38.572]],["parent/53",[29,0.949]],["name/54",[40,38.572]],["parent/54",[29,0.949]],["name/55",[41,38.572]],["parent/55",[29,0.949]],["name/56",[42,38.572]],["parent/56",[29,0.949]],["name/57",[43,38.572]],["parent/57",[29,0.949]],["name/58",[44,38.572]],["parent/58",[29,0.949]],["name/59",[45,38.572]],["parent/59",[29,0.949]],["name/60",[46,38.572]],["parent/60",[29,0.949]],["name/61",[47,38.572]],["parent/61",[29,0.949]],["name/62",[48,38.572]],["parent/62",[29,0.949]],["name/63",[49,38.572]],["parent/63",[29,0.949]],["name/64",[50,38.572]],["parent/64",[29,0.949]],["name/65",[51,38.572]],["parent/65",[29,0.949]],["name/66",[13,30.099]],["parent/66",[28,2.463]],["name/67",[7,30.099]],["parent/67",[28,2.463]],["name/68",[17,23.909]],["parent/68",[28,2.463]],["name/69",[29,9.855]],["parent/69",[28,2.463]]],"invertedIndex":[["__type",{"_index":16,"name":{"18":{},"26":{},"28":{}},"parent":{}}],["_lastid",{"_index":22,"name":{"31":{}},"parent":{}}],["bits2bytes",{"_index":44,"name":{"58":{}},"parent":{}}],["bytes2bits",{"_index":43,"name":{"57":{}},"parent":{}}],["bytes2hex",{"_index":41,"name":{"55":{}},"parent":{}}],["clock",{"_index":19,"name":{"27":{}},"parent":{}}],["constructor",{"_index":4,"name":{"3":{},"9":{},"16":{},"24":{}},"parent":{}}],["create",{"_index":2,"name":{"2":{}},"parent":{}}],["dec2bits",{"_index":45,"name":{"59":{}},"parent":{}}],["dec2hex",{"_index":46,"name":{"60":{}},"parent":{}}],["default",{"_index":1,"name":{"1":{},"8":{},"15":{},"23":{}},"parent":{}}],["extractrand",{"_index":27,"name":{"39":{}},"parent":{}}],["extractseq",{"_index":26,"name":{"38":{}},"parent":{}}],["extractts",{"_index":25,"name":{"37":{}},"parent":{}}],["frombuffer",{"_index":40,"name":{"54":{}},"parent":{}}],["fromfixedpoint",{"_index":50,"name":{"64":{}},"parent":{}}],["frommultibase",{"_index":38,"name":{"52":{}},"parent":{}}],["fromstring",{"_index":34,"name":{"48":{}},"parent":{}}],["fromuuid",{"_index":36,"name":{"50":{}},"parent":{}}],["get",{"_index":10,"name":{"11":{},"19":{},"34":{}},"parent":{}}],["hex2bytes",{"_index":42,"name":{"56":{}},"parent":{}}],["id",{"_index":0,"name":{"0":{},"6":{}},"parent":{"1":{},"6":{}}}],["id.default",{"_index":3,"name":{},"parent":{"2":{},"3":{},"4":{},"5":{}}}],["iddeterministic",{"_index":7,"name":{"7":{},"67":{}},"parent":{"8":{}}}],["iddeterministic.default",{"_index":8,"name":{},"parent":{"9":{},"10":{},"11":{},"12":{},"13":{}}}],["idrandom",{"_index":13,"name":{"14":{},"66":{}},"parent":{"15":{}}}],["idrandom.default",{"_index":14,"name":{},"parent":{"16":{},"17":{},"18":{},"19":{},"20":{},"21":{}}}],["idsortable",{"_index":17,"name":{"22":{},"68":{}},"parent":{"23":{},"37":{},"38":{},"39":{}}}],["idsortable.default",{"_index":18,"name":{},"parent":{"24":{},"25":{},"26":{},"27":{},"28":{},"29":{},"30":{},"31":{},"32":{},"33":{},"34":{},"35":{},"36":{}}}],["index",{"_index":28,"name":{"40":{}},"parent":{"66":{},"67":{},"68":{},"69":{}}}],["iterator",{"_index":12,"name":{"13":{},"21":{},"36":{}},"parent":{}}],["lastid",{"_index":24,"name":{"33":{}},"parent":{}}],["lastts",{"_index":21,"name":{"30":{}},"parent":{}}],["multibaseformats",{"_index":51,"name":{"65":{}},"parent":{}}],["namespacedata",{"_index":9,"name":{"10":{}},"parent":{}}],["next",{"_index":11,"name":{"12":{},"20":{},"35":{}},"parent":{}}],["nodebits",{"_index":20,"name":{"29":{},"44":{}},"parent":{}}],["randombits",{"_index":31,"name":{"43":{}},"parent":{}}],["randombytes",{"_index":30,"name":{"42":{}},"parent":{}}],["randomsource",{"_index":15,"name":{"17":{},"25":{}},"parent":{}}],["roundprecise",{"_index":48,"name":{"62":{}},"parent":{}}],["seqcounter",{"_index":23,"name":{"32":{}},"parent":{}}],["strchunks",{"_index":47,"name":{"61":{}},"parent":{}}],["take",{"_index":33,"name":{"46":{}},"parent":{}}],["timesource",{"_index":32,"name":{"45":{}},"parent":{}}],["tobuffer",{"_index":39,"name":{"53":{}},"parent":{}}],["tofixedpoint",{"_index":49,"name":{"63":{}},"parent":{}}],["tomultibase",{"_index":37,"name":{"51":{}},"parent":{}}],["toprimitive",{"_index":6,"name":{"5":{}},"parent":{}}],["tostring",{"_index":5,"name":{"4":{},"47":{}},"parent":{}}],["touuid",{"_index":35,"name":{"49":{}},"parent":{}}],["utils",{"_index":29,"name":{"41":{},"69":{}},"parent":{"42":{},"43":{},"44":{},"45":{},"46":{},"47":{},"48":{},"49":{},"50":{},"51":{},"52":{},"53":{},"54":{},"55":{},"56":{},"57":{},"58":{},"59":{},"60":{},"61":{},"62":{},"63":{},"64":{},"65":{}}}]],"pipeline":[]}} \ No newline at end of file +window.searchData = {"kinds":{"1":"Module","64":"Function","128":"Class","512":"Constructor","1024":"Property","2048":"Method","65536":"Type literal","262144":"Accessor","4194304":"Type alias","16777216":"Reference"},"rows":[{"id":0,"kind":1,"name":"Id","url":"modules/Id.html","classes":"tsd-kind-module"},{"id":1,"kind":128,"name":"default","url":"classes/Id.default.html","classes":"tsd-kind-class tsd-parent-kind-module","parent":"Id"},{"id":2,"kind":2048,"name":"create","url":"classes/Id.default.html#create","classes":"tsd-kind-method tsd-parent-kind-class tsd-is-static","parent":"Id.default"},{"id":3,"kind":512,"name":"constructor","url":"classes/Id.default.html#constructor","classes":"tsd-kind-constructor tsd-parent-kind-class tsd-is-inherited","parent":"Id.default"},{"id":4,"kind":2048,"name":"toString","url":"classes/Id.default.html#toString","classes":"tsd-kind-method tsd-parent-kind-class tsd-is-overwrite","parent":"Id.default"},{"id":5,"kind":2048,"name":"[toPrimitive]","url":"classes/Id.default.html#_toPrimitive_","classes":"tsd-kind-method tsd-parent-kind-class","parent":"Id.default"},{"id":6,"kind":4194304,"name":"Id","url":"modules/Id.html#Id-1","classes":"tsd-kind-type-alias tsd-parent-kind-module","parent":"Id"},{"id":7,"kind":1,"name":"IdDeterministic","url":"modules/IdDeterministic.html","classes":"tsd-kind-module"},{"id":8,"kind":128,"name":"default","url":"classes/IdDeterministic.default.html","classes":"tsd-kind-class tsd-parent-kind-module","parent":"IdDeterministic"},{"id":9,"kind":512,"name":"constructor","url":"classes/IdDeterministic.default.html#constructor","classes":"tsd-kind-constructor tsd-parent-kind-class","parent":"IdDeterministic.default"},{"id":10,"kind":1024,"name":"namespaceData","url":"classes/IdDeterministic.default.html#namespaceData","classes":"tsd-kind-property tsd-parent-kind-class tsd-is-protected","parent":"IdDeterministic.default"},{"id":11,"kind":2048,"name":"get","url":"classes/IdDeterministic.default.html#get","classes":"tsd-kind-method tsd-parent-kind-class","parent":"IdDeterministic.default"},{"id":12,"kind":2048,"name":"next","url":"classes/IdDeterministic.default.html#next","classes":"tsd-kind-method tsd-parent-kind-class","parent":"IdDeterministic.default"},{"id":13,"kind":2048,"name":"[iterator]","url":"classes/IdDeterministic.default.html#_iterator_","classes":"tsd-kind-method tsd-parent-kind-class","parent":"IdDeterministic.default"},{"id":14,"kind":1,"name":"IdRandom","url":"modules/IdRandom.html","classes":"tsd-kind-module"},{"id":15,"kind":128,"name":"default","url":"classes/IdRandom.default.html","classes":"tsd-kind-class tsd-parent-kind-module","parent":"IdRandom"},{"id":16,"kind":512,"name":"constructor","url":"classes/IdRandom.default.html#constructor","classes":"tsd-kind-constructor tsd-parent-kind-class","parent":"IdRandom.default"},{"id":17,"kind":1024,"name":"randomSource","url":"classes/IdRandom.default.html#randomSource","classes":"tsd-kind-property tsd-parent-kind-class tsd-is-protected","parent":"IdRandom.default"},{"id":18,"kind":65536,"name":"__type","url":"classes/IdRandom.default.html#__type","classes":"tsd-kind-type-literal tsd-parent-kind-class","parent":"IdRandom.default"},{"id":19,"kind":2048,"name":"get","url":"classes/IdRandom.default.html#get","classes":"tsd-kind-method tsd-parent-kind-class","parent":"IdRandom.default"},{"id":20,"kind":2048,"name":"next","url":"classes/IdRandom.default.html#next","classes":"tsd-kind-method tsd-parent-kind-class","parent":"IdRandom.default"},{"id":21,"kind":2048,"name":"[iterator]","url":"classes/IdRandom.default.html#_iterator_","classes":"tsd-kind-method tsd-parent-kind-class","parent":"IdRandom.default"},{"id":22,"kind":1,"name":"IdSortable","url":"modules/IdSortable.html","classes":"tsd-kind-module"},{"id":23,"kind":128,"name":"default","url":"classes/IdSortable.default.html","classes":"tsd-kind-class tsd-parent-kind-module","parent":"IdSortable"},{"id":24,"kind":512,"name":"constructor","url":"classes/IdSortable.default.html#constructor","classes":"tsd-kind-constructor tsd-parent-kind-class","parent":"IdSortable.default"},{"id":25,"kind":1024,"name":"randomSource","url":"classes/IdSortable.default.html#randomSource","classes":"tsd-kind-property tsd-parent-kind-class tsd-is-protected","parent":"IdSortable.default"},{"id":26,"kind":65536,"name":"__type","url":"classes/IdSortable.default.html#__type-1","classes":"tsd-kind-type-literal tsd-parent-kind-class","parent":"IdSortable.default"},{"id":27,"kind":1024,"name":"clock","url":"classes/IdSortable.default.html#clock","classes":"tsd-kind-property tsd-parent-kind-class tsd-is-protected","parent":"IdSortable.default"},{"id":28,"kind":65536,"name":"__type","url":"classes/IdSortable.default.html#__type","classes":"tsd-kind-type-literal tsd-parent-kind-class","parent":"IdSortable.default"},{"id":29,"kind":1024,"name":"nodeBits","url":"classes/IdSortable.default.html#nodeBits","classes":"tsd-kind-property tsd-parent-kind-class tsd-is-protected","parent":"IdSortable.default"},{"id":30,"kind":1024,"name":"lastTs","url":"classes/IdSortable.default.html#lastTs","classes":"tsd-kind-property tsd-parent-kind-class tsd-is-protected","parent":"IdSortable.default"},{"id":31,"kind":1024,"name":"_lastId","url":"classes/IdSortable.default.html#_lastId","classes":"tsd-kind-property tsd-parent-kind-class tsd-is-protected","parent":"IdSortable.default"},{"id":32,"kind":1024,"name":"seqCounter","url":"classes/IdSortable.default.html#seqCounter","classes":"tsd-kind-property tsd-parent-kind-class tsd-is-protected","parent":"IdSortable.default"},{"id":33,"kind":262144,"name":"lastId","url":"classes/IdSortable.default.html#lastId","classes":"tsd-kind-get-signature tsd-parent-kind-class","parent":"IdSortable.default"},{"id":34,"kind":2048,"name":"get","url":"classes/IdSortable.default.html#get","classes":"tsd-kind-method tsd-parent-kind-class","parent":"IdSortable.default"},{"id":35,"kind":2048,"name":"next","url":"classes/IdSortable.default.html#next","classes":"tsd-kind-method tsd-parent-kind-class","parent":"IdSortable.default"},{"id":36,"kind":2048,"name":"[iterator]","url":"classes/IdSortable.default.html#_iterator_","classes":"tsd-kind-method tsd-parent-kind-class","parent":"IdSortable.default"},{"id":37,"kind":64,"name":"extractTs","url":"modules/IdSortable.html#extractTs","classes":"tsd-kind-function tsd-parent-kind-module","parent":"IdSortable"},{"id":38,"kind":64,"name":"extractSeq","url":"modules/IdSortable.html#extractSeq","classes":"tsd-kind-function tsd-parent-kind-module","parent":"IdSortable"},{"id":39,"kind":64,"name":"extractRand","url":"modules/IdSortable.html#extractRand","classes":"tsd-kind-function tsd-parent-kind-module","parent":"IdSortable"},{"id":40,"kind":1,"name":"index","url":"modules/index.html","classes":"tsd-kind-module"},{"id":41,"kind":1,"name":"utils","url":"modules/utils.html","classes":"tsd-kind-module"},{"id":42,"kind":64,"name":"randomBytes","url":"modules/utils.html#randomBytes","classes":"tsd-kind-function tsd-parent-kind-module","parent":"utils"},{"id":43,"kind":64,"name":"randomBits","url":"modules/utils.html#randomBits","classes":"tsd-kind-function tsd-parent-kind-module","parent":"utils"},{"id":44,"kind":64,"name":"nodeBits","url":"modules/utils.html#nodeBits","classes":"tsd-kind-function tsd-parent-kind-module","parent":"utils"},{"id":45,"kind":64,"name":"timeSource","url":"modules/utils.html#timeSource","classes":"tsd-kind-function tsd-parent-kind-module","parent":"utils"},{"id":46,"kind":64,"name":"take","url":"modules/utils.html#take","classes":"tsd-kind-function tsd-parent-kind-module tsd-has-type-parameter","parent":"utils"},{"id":47,"kind":64,"name":"toString","url":"modules/utils.html#toString","classes":"tsd-kind-function tsd-parent-kind-module","parent":"utils"},{"id":48,"kind":64,"name":"fromString","url":"modules/utils.html#fromString","classes":"tsd-kind-function tsd-parent-kind-module","parent":"utils"},{"id":49,"kind":64,"name":"toUUID","url":"modules/utils.html#toUUID","classes":"tsd-kind-function tsd-parent-kind-module","parent":"utils"},{"id":50,"kind":64,"name":"fromUUID","url":"modules/utils.html#fromUUID","classes":"tsd-kind-function tsd-parent-kind-module","parent":"utils"},{"id":51,"kind":64,"name":"toMultibase","url":"modules/utils.html#toMultibase","classes":"tsd-kind-function tsd-parent-kind-module","parent":"utils"},{"id":52,"kind":64,"name":"fromMultibase","url":"modules/utils.html#fromMultibase","classes":"tsd-kind-function tsd-parent-kind-module","parent":"utils"},{"id":53,"kind":64,"name":"toBuffer","url":"modules/utils.html#toBuffer","classes":"tsd-kind-function tsd-parent-kind-module","parent":"utils"},{"id":54,"kind":64,"name":"fromBuffer","url":"modules/utils.html#fromBuffer","classes":"tsd-kind-function tsd-parent-kind-module","parent":"utils"},{"id":55,"kind":64,"name":"bytes2hex","url":"modules/utils.html#bytes2hex","classes":"tsd-kind-function tsd-parent-kind-module","parent":"utils"},{"id":56,"kind":64,"name":"hex2bytes","url":"modules/utils.html#hex2bytes","classes":"tsd-kind-function tsd-parent-kind-module","parent":"utils"},{"id":57,"kind":64,"name":"bytes2bits","url":"modules/utils.html#bytes2bits","classes":"tsd-kind-function tsd-parent-kind-module","parent":"utils"},{"id":58,"kind":64,"name":"bits2bytes","url":"modules/utils.html#bits2bytes","classes":"tsd-kind-function tsd-parent-kind-module","parent":"utils"},{"id":59,"kind":64,"name":"dec2bits","url":"modules/utils.html#dec2bits","classes":"tsd-kind-function tsd-parent-kind-module","parent":"utils"},{"id":60,"kind":64,"name":"dec2hex","url":"modules/utils.html#dec2hex","classes":"tsd-kind-function tsd-parent-kind-module","parent":"utils"},{"id":61,"kind":64,"name":"strChunks","url":"modules/utils.html#strChunks","classes":"tsd-kind-function tsd-parent-kind-module","parent":"utils"},{"id":62,"kind":64,"name":"roundPrecise","url":"modules/utils.html#roundPrecise","classes":"tsd-kind-function tsd-parent-kind-module","parent":"utils"},{"id":63,"kind":64,"name":"toFixedPoint","url":"modules/utils.html#toFixedPoint","classes":"tsd-kind-function tsd-parent-kind-module","parent":"utils"},{"id":64,"kind":64,"name":"fromFixedPoint","url":"modules/utils.html#fromFixedPoint","classes":"tsd-kind-function tsd-parent-kind-module","parent":"utils"},{"id":65,"kind":4194304,"name":"MultibaseFormats","url":"modules/utils.html#MultibaseFormats","classes":"tsd-kind-type-alias tsd-parent-kind-module","parent":"utils"},{"id":66,"kind":16777216,"name":"Id","url":"modules/index.html#Id","classes":"tsd-kind-reference tsd-parent-kind-module","parent":"index"},{"id":67,"kind":16777216,"name":"IdRandom","url":"modules/index.html#IdRandom","classes":"tsd-kind-reference tsd-parent-kind-module","parent":"index"},{"id":68,"kind":16777216,"name":"IdDeterministic","url":"modules/index.html#IdDeterministic","classes":"tsd-kind-reference tsd-parent-kind-module","parent":"index"},{"id":69,"kind":16777216,"name":"IdSortable","url":"modules/index.html#IdSortable","classes":"tsd-kind-reference tsd-parent-kind-module","parent":"index"},{"id":70,"kind":16777216,"name":"utils","url":"modules/index.html#utils","classes":"tsd-kind-reference tsd-parent-kind-module","parent":"index"}],"index":{"version":"2.3.9","fields":["name","parent"],"fieldVectors":[["name/0",[0,25.719]],["parent/0",[]],["name/1",[1,27.726]],["parent/1",[0,2.478]],["name/2",[2,38.712]],["parent/2",[3,2.672]],["name/3",[4,27.726]],["parent/3",[3,2.672]],["name/4",[5,33.604]],["parent/4",[3,2.672]],["name/5",[6,38.712]],["parent/5",[3,2.672]],["name/6",[0,25.719]],["parent/6",[0,2.478]],["name/7",[7,30.239]],["parent/7",[]],["name/8",[1,27.726]],["parent/8",[7,2.914]],["name/9",[4,27.726]],["parent/9",[8,2.478]],["name/10",[9,38.712]],["parent/10",[8,2.478]],["name/11",[10,30.239]],["parent/11",[8,2.478]],["name/12",[11,30.239]],["parent/12",[8,2.478]],["name/13",[12,30.239]],["parent/13",[8,2.478]],["name/14",[13,30.239]],["parent/14",[]],["name/15",[1,27.726]],["parent/15",[13,2.914]],["name/16",[4,27.726]],["parent/16",[14,2.317]],["name/17",[15,33.604]],["parent/17",[14,2.317]],["name/18",[16,30.239]],["parent/18",[14,2.317]],["name/19",[10,30.239]],["parent/19",[14,2.317]],["name/20",[11,30.239]],["parent/20",[14,2.317]],["name/21",[12,30.239]],["parent/21",[14,2.317]],["name/22",[17,24.049]],["parent/22",[]],["name/23",[1,27.726]],["parent/23",[17,2.317]],["name/24",[4,27.726]],["parent/24",[18,1.613]],["name/25",[15,33.604]],["parent/25",[18,1.613]],["name/26",[16,30.239]],["parent/26",[18,1.613]],["name/27",[19,38.712]],["parent/27",[18,1.613]],["name/28",[16,30.239]],["parent/28",[18,1.613]],["name/29",[20,33.604]],["parent/29",[18,1.613]],["name/30",[21,38.712]],["parent/30",[18,1.613]],["name/31",[22,38.712]],["parent/31",[18,1.613]],["name/32",[23,38.712]],["parent/32",[18,1.613]],["name/33",[24,38.712]],["parent/33",[18,1.613]],["name/34",[10,30.239]],["parent/34",[18,1.613]],["name/35",[11,30.239]],["parent/35",[18,1.613]],["name/36",[12,30.239]],["parent/36",[18,1.613]],["name/37",[25,38.712]],["parent/37",[17,2.317]],["name/38",[26,38.712]],["parent/38",[17,2.317]],["name/39",[27,38.712]],["parent/39",[17,2.317]],["name/40",[28,24.049]],["parent/40",[]],["name/41",[29,9.995]],["parent/41",[]],["name/42",[30,38.712]],["parent/42",[29,0.963]],["name/43",[31,38.712]],["parent/43",[29,0.963]],["name/44",[20,33.604]],["parent/44",[29,0.963]],["name/45",[32,38.712]],["parent/45",[29,0.963]],["name/46",[33,38.712]],["parent/46",[29,0.963]],["name/47",[5,33.604]],["parent/47",[29,0.963]],["name/48",[34,38.712]],["parent/48",[29,0.963]],["name/49",[35,38.712]],["parent/49",[29,0.963]],["name/50",[36,38.712]],["parent/50",[29,0.963]],["name/51",[37,38.712]],["parent/51",[29,0.963]],["name/52",[38,38.712]],["parent/52",[29,0.963]],["name/53",[39,38.712]],["parent/53",[29,0.963]],["name/54",[40,38.712]],["parent/54",[29,0.963]],["name/55",[41,38.712]],["parent/55",[29,0.963]],["name/56",[42,38.712]],["parent/56",[29,0.963]],["name/57",[43,38.712]],["parent/57",[29,0.963]],["name/58",[44,38.712]],["parent/58",[29,0.963]],["name/59",[45,38.712]],["parent/59",[29,0.963]],["name/60",[46,38.712]],["parent/60",[29,0.963]],["name/61",[47,38.712]],["parent/61",[29,0.963]],["name/62",[48,38.712]],["parent/62",[29,0.963]],["name/63",[49,38.712]],["parent/63",[29,0.963]],["name/64",[50,38.712]],["parent/64",[29,0.963]],["name/65",[51,38.712]],["parent/65",[29,0.963]],["name/66",[0,25.719]],["parent/66",[28,2.317]],["name/67",[13,30.239]],["parent/67",[28,2.317]],["name/68",[7,30.239]],["parent/68",[28,2.317]],["name/69",[17,24.049]],["parent/69",[28,2.317]],["name/70",[29,9.995]],["parent/70",[28,2.317]]],"invertedIndex":[["__type",{"_index":16,"name":{"18":{},"26":{},"28":{}},"parent":{}}],["_lastid",{"_index":22,"name":{"31":{}},"parent":{}}],["bits2bytes",{"_index":44,"name":{"58":{}},"parent":{}}],["bytes2bits",{"_index":43,"name":{"57":{}},"parent":{}}],["bytes2hex",{"_index":41,"name":{"55":{}},"parent":{}}],["clock",{"_index":19,"name":{"27":{}},"parent":{}}],["constructor",{"_index":4,"name":{"3":{},"9":{},"16":{},"24":{}},"parent":{}}],["create",{"_index":2,"name":{"2":{}},"parent":{}}],["dec2bits",{"_index":45,"name":{"59":{}},"parent":{}}],["dec2hex",{"_index":46,"name":{"60":{}},"parent":{}}],["default",{"_index":1,"name":{"1":{},"8":{},"15":{},"23":{}},"parent":{}}],["extractrand",{"_index":27,"name":{"39":{}},"parent":{}}],["extractseq",{"_index":26,"name":{"38":{}},"parent":{}}],["extractts",{"_index":25,"name":{"37":{}},"parent":{}}],["frombuffer",{"_index":40,"name":{"54":{}},"parent":{}}],["fromfixedpoint",{"_index":50,"name":{"64":{}},"parent":{}}],["frommultibase",{"_index":38,"name":{"52":{}},"parent":{}}],["fromstring",{"_index":34,"name":{"48":{}},"parent":{}}],["fromuuid",{"_index":36,"name":{"50":{}},"parent":{}}],["get",{"_index":10,"name":{"11":{},"19":{},"34":{}},"parent":{}}],["hex2bytes",{"_index":42,"name":{"56":{}},"parent":{}}],["id",{"_index":0,"name":{"0":{},"6":{},"66":{}},"parent":{"1":{},"6":{}}}],["id.default",{"_index":3,"name":{},"parent":{"2":{},"3":{},"4":{},"5":{}}}],["iddeterministic",{"_index":7,"name":{"7":{},"68":{}},"parent":{"8":{}}}],["iddeterministic.default",{"_index":8,"name":{},"parent":{"9":{},"10":{},"11":{},"12":{},"13":{}}}],["idrandom",{"_index":13,"name":{"14":{},"67":{}},"parent":{"15":{}}}],["idrandom.default",{"_index":14,"name":{},"parent":{"16":{},"17":{},"18":{},"19":{},"20":{},"21":{}}}],["idsortable",{"_index":17,"name":{"22":{},"69":{}},"parent":{"23":{},"37":{},"38":{},"39":{}}}],["idsortable.default",{"_index":18,"name":{},"parent":{"24":{},"25":{},"26":{},"27":{},"28":{},"29":{},"30":{},"31":{},"32":{},"33":{},"34":{},"35":{},"36":{}}}],["index",{"_index":28,"name":{"40":{}},"parent":{"66":{},"67":{},"68":{},"69":{},"70":{}}}],["iterator",{"_index":12,"name":{"13":{},"21":{},"36":{}},"parent":{}}],["lastid",{"_index":24,"name":{"33":{}},"parent":{}}],["lastts",{"_index":21,"name":{"30":{}},"parent":{}}],["multibaseformats",{"_index":51,"name":{"65":{}},"parent":{}}],["namespacedata",{"_index":9,"name":{"10":{}},"parent":{}}],["next",{"_index":11,"name":{"12":{},"20":{},"35":{}},"parent":{}}],["nodebits",{"_index":20,"name":{"29":{},"44":{}},"parent":{}}],["randombits",{"_index":31,"name":{"43":{}},"parent":{}}],["randombytes",{"_index":30,"name":{"42":{}},"parent":{}}],["randomsource",{"_index":15,"name":{"17":{},"25":{}},"parent":{}}],["roundprecise",{"_index":48,"name":{"62":{}},"parent":{}}],["seqcounter",{"_index":23,"name":{"32":{}},"parent":{}}],["strchunks",{"_index":47,"name":{"61":{}},"parent":{}}],["take",{"_index":33,"name":{"46":{}},"parent":{}}],["timesource",{"_index":32,"name":{"45":{}},"parent":{}}],["tobuffer",{"_index":39,"name":{"53":{}},"parent":{}}],["tofixedpoint",{"_index":49,"name":{"63":{}},"parent":{}}],["tomultibase",{"_index":37,"name":{"51":{}},"parent":{}}],["toprimitive",{"_index":6,"name":{"5":{}},"parent":{}}],["tostring",{"_index":5,"name":{"4":{},"47":{}},"parent":{}}],["touuid",{"_index":35,"name":{"49":{}},"parent":{}}],["utils",{"_index":29,"name":{"41":{},"70":{}},"parent":{"42":{},"43":{},"44":{},"45":{},"46":{},"47":{},"48":{},"49":{},"50":{},"51":{},"52":{},"53":{},"54":{},"55":{},"56":{},"57":{},"58":{},"59":{},"60":{},"61":{},"62":{},"63":{},"64":{},"65":{}}}]],"pipeline":[]}} \ No newline at end of file diff --git a/docs/classes/Id.default.html b/docs/classes/Id.default.html index bac633f..9935ceb 100644 --- a/docs/classes/Id.default.html +++ b/docs/classes/Id.default.html @@ -373,7 +373,7 @@

[toPrimitive]

  • Parameters

    @@ -1710,7 +1710,7 @@

    toString

    Returns string

    @@ -1776,7 +1776,7 @@

    Static create

  • Returns Id

    @@ -1784,7 +1784,7 @@

    Returns

    Parameters

    @@ -1798,7 +1798,7 @@

    Returns

    Parameters

    @@ -1812,7 +1812,7 @@

    Returns

    Parameters

    diff --git a/docs/classes/IdDeterministic.default.html b/docs/classes/IdDeterministic.default.html index 3f51407..0b333b3 100644 --- a/docs/classes/IdDeterministic.default.html +++ b/docs/classes/IdDeterministic.default.html @@ -133,7 +133,7 @@

    constructor

  • Parameters

    @@ -160,7 +160,7 @@

    Protected namespaceData<
    namespaceData: Uint8Array
    @@ -178,7 +178,7 @@

    [iterator]

    Returns IterableIterator<Id>

    @@ -195,7 +195,7 @@

    get

  • Parameters

    @@ -219,7 +219,7 @@

    next

    Parameters

    diff --git a/docs/classes/IdRandom.default.html b/docs/classes/IdRandom.default.html index deb6041..0255b45 100644 --- a/docs/classes/IdRandom.default.html +++ b/docs/classes/IdRandom.default.html @@ -121,7 +121,7 @@

    constructor

  • Parameters

    @@ -138,7 +138,7 @@
    randomSource: function
  • Parameters

    @@ -167,7 +167,7 @@

    Protected randomSourcerandomSource: (size: number) => Uint8Array
    @@ -206,7 +206,7 @@

    [iterator]

    Returns IterableIterator<Id>

    @@ -223,7 +223,7 @@

    get

  • Returns Id

    @@ -241,7 +241,7 @@

    next

    Returns IteratorResult<Id, void>

    diff --git a/docs/classes/IdSortable.default.html b/docs/classes/IdSortable.default.html index 1c6ea98..7543f0d 100644 --- a/docs/classes/IdSortable.default.html +++ b/docs/classes/IdSortable.default.html @@ -144,7 +144,7 @@

    constructor

  • Parameters

    @@ -167,7 +167,7 @@
    randomSource: function
  • Parameters

    @@ -189,7 +189,7 @@
    timeSource: function
  • Parameters

    @@ -230,7 +230,7 @@

    Protected _lastId: Id

  • @@ -240,7 +240,7 @@

    Protected clock

    clock: () => number
    @@ -265,7 +265,7 @@

    Protected lastTs: [number, number]

    @@ -275,7 +275,7 @@

    Protected nodeBits: string @@ -285,7 +285,7 @@

    Protected randomSourcerandomSource: (size: number) => Uint8Array
    @@ -316,7 +316,7 @@

    Protected seqCounter

    seqCounter: number
    @@ -333,7 +333,7 @@

    lastId

  • Returns Id

    @@ -354,7 +354,7 @@

    [iterator]

    Returns IterableIterator<Id>

    @@ -371,7 +371,7 @@

    get

  • Returns Id

    @@ -389,7 +389,7 @@

    next

    Returns IteratorResult<Id, void>

    diff --git a/docs/index.html b/docs/index.html index 3c17a18..9f654aa 100644 --- a/docs/index.html +++ b/docs/index.html @@ -127,6 +127,8 @@

    js-id

    console.log(sortId1 < sortId2); console.log(sortId2 < sortId3); +

    Base Encoding and Lexicographic Order

    +

    It is important to realise that not all base-encodings preserve lexicographic sort order. The UUID (hex-encoding) and base58btc alphabet does, but the base64 alphabet does not. Make sure to pick an appropriate base encoding if you are expecting to compare the IdSortable as base-encoded strings.

    Installation

    diff --git a/docs/modules/Id.html b/docs/modules/Id.html index b9815c8..e839891 100644 --- a/docs/modules/Id.html +++ b/docs/modules/Id.html @@ -92,13 +92,13 @@

    Id

    Id: default & number

    IdInternal can be used as a string primitive - This type hack prevents TS from complaining + This type hack (as a number) prevents TS from complaining See: https://github.com/microsoft/TypeScript/issues/4538

    diff --git a/docs/modules/IdSortable.html b/docs/modules/IdSortable.html index 97a0571..c3c2d1c 100644 --- a/docs/modules/IdSortable.html +++ b/docs/modules/IdSortable.html @@ -98,7 +98,7 @@

    extractRand

  • Parameters

    @@ -121,7 +121,7 @@

    extractSeq

  • Parameters

    @@ -144,7 +144,7 @@

    extractTs

  • Parameters

    diff --git a/docs/modules/index.html b/docs/modules/index.html index 04e911a..ecf3eeb 100644 --- a/docs/modules/index.html +++ b/docs/modules/index.html @@ -72,6 +72,7 @@

    Index

    References

    References

    +
    + +

    Id

    + Renames and exports default +

    IdDeterministic

    @@ -133,6 +139,9 @@

    utils

    @@ -131,7 +131,7 @@

    bits2bytes

  • @@ -159,7 +159,7 @@

    bytes2bits

  • @@ -187,7 +187,7 @@

    bytes2hex

  • @@ -215,7 +215,7 @@

    dec2bits

  • @@ -247,7 +247,7 @@

    dec2hex

  • @@ -279,7 +279,7 @@

    fromBuffer

  • @@ -307,7 +307,7 @@

    fromFixedPoint

  • @@ -343,7 +343,7 @@

    fromMultibase

  • @@ -372,7 +372,7 @@

    fromString

  • Parameters

    @@ -395,7 +395,7 @@

    fromUUID

  • Parameters

    @@ -418,7 +418,7 @@

    hex2bytes

  • Parameters

    @@ -441,7 +441,7 @@

    nodeBits

  • Parameters

    @@ -467,7 +467,7 @@

    randomBits

  • @@ -516,7 +516,7 @@

    randomBytes

  • @@ -544,7 +544,7 @@

    roundPrecise

  • @@ -578,7 +578,7 @@

    strChunks

  • @@ -610,7 +610,7 @@

    take

  • @@ -647,7 +647,7 @@

    timeSource

  • @@ -696,7 +696,7 @@

    toBuffer

  • @@ -724,7 +724,7 @@

    toFixedPoint

  • @@ -760,7 +760,7 @@

    toMultibase

  • @@ -791,7 +791,7 @@

    toString

  • Parameters

    @@ -814,7 +814,7 @@

    toUUID

  • Parameters