@vertexvis/utils 0.15.1-canary.3 → 0.15.1-canary.6

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -4679,8 +4679,24 @@ function v4(options, buf, offset) {
4679
4679
  function create() {
4680
4680
  return v4();
4681
4681
  }
4682
+ function fromMsbLsb(msb, lsb) {
4683
+ function digits(val, ds) {
4684
+ var hi = BigInt(1) << (ds * BigInt(4));
4685
+ return (hi | (val & (hi - BigInt(1)))).toString(16).substring(1);
4686
+ }
4687
+ var msbB = typeof msb === 'string' ? BigInt(msb) : msb;
4688
+ var lsbB = typeof lsb === 'string' ? BigInt(lsb) : lsb;
4689
+ var sec1 = digits(msbB >> BigInt(32), BigInt(8));
4690
+ var sec2 = digits(msbB >> BigInt(16), BigInt(4));
4691
+ var sec3 = digits(msbB, BigInt(4));
4692
+ var sec4 = digits(lsbB >> BigInt(48), BigInt(4));
4693
+ var sec5 = digits(lsbB, BigInt(12));
4694
+ return "".concat(sec1, "-").concat(sec2, "-").concat(sec3, "-").concat(sec4, "-").concat(sec5);
4695
+ }
4682
4696
  function toMsbLsb(id) {
4683
4697
  var bytes = parse(id);
4698
+ // I don't know why, but BigInt bitwise ops are produce incorrect values, so
4699
+ // using Long.
4684
4700
  var msb = Long.fromInt(0);
4685
4701
  var lsb = Long.fromInt(0);
4686
4702
  for (var i = 0; i < 8; i++) {
@@ -4695,6 +4711,7 @@ function toMsbLsb(id) {
4695
4711
  var uuid = /*#__PURE__*/Object.freeze({
4696
4712
  __proto__: null,
4697
4713
  create: create,
4714
+ fromMsbLsb: fromMsbLsb,
4698
4715
  toMsbLsb: toMsbLsb
4699
4716
  });
4700
4717