utilitas 1989.9.43 → 1989.9.44

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.
@@ -1,4 +1,4 @@
1
- import * as utilitas from './utilitas.mjs';
1
+ import { ensureString } from './utilitas.mjs';
2
2
  import crypto from 'crypto';
3
3
  import fs from 'fs';
4
4
  import qs from 'qs';
@@ -49,7 +49,7 @@ const digestObject = (object, algorithm) => {
49
49
  };
50
50
 
51
51
  const hexToBigInt = (hex) => {
52
- hex = `0x${utilitas.ensureString(hex || '0').replace(/^0x/ig, '')}`;
52
+ hex = `0x${ensureString(hex || '0').replace(/^0x/ig, '')}`;
53
53
  return BigInt(hex, 16).toString(10);
54
54
  };
55
55
 
package/lib/uoid.mjs CHANGED
@@ -1,4 +1,4 @@
1
- import * as encryption from './encryption.mjs';
1
+ import { randomString, hexToBigInt } from './encryption.mjs';
2
2
  import * as utilitas from './utilitas.mjs';
3
3
  import * as uuid from 'uuid';
4
4
 
@@ -7,6 +7,8 @@ const fileURLToPath = (await import('url')).fileURLToPath
7
7
 
8
8
  const __filename = fileURLToPath(import.meta.url);
9
9
  const uuidRegTxt = '[0-9a-f]{8}-[0-9a-f]{4}-[1-5][0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}';
10
+ const compactUuid = (uuid) => uuid.replace(/\-/ig, '');
11
+ const uuidToBigInt = (uuid) => hexToBigInt(compactUuid(uuid));
10
12
 
11
13
  const getTimestampFromUuid = (uuid) => {
12
14
  return uuid ? Math.ceil((utilitas.convertFrom16to10(
@@ -22,7 +24,7 @@ const create = (options) => {
22
24
  }
23
25
  let id = options.id;
24
26
  if (options.security) {
25
- id += `-${encryption.randomString(options.security - id.length - 1)}`;
27
+ id += `-${randomString(options.security - id.length - 1)}`;
26
28
  }
27
29
  return `${options.type.toUpperCase()}|${id}`;
28
30
  };
@@ -34,8 +36,10 @@ const getRfcUrlNamespaceUuid = (url) => {
34
36
 
35
37
  export default create;
36
38
  export {
37
- uuidRegTxt,
39
+ compactUuid,
38
40
  create,
39
41
  getRfcUrlNamespaceUuid,
40
42
  getTimestampFromUuid,
43
+ uuidRegTxt,
44
+ uuidToBigInt,
41
45
  };
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "utilitas",
3
3
  "description": "Just another common utility for Node.js.",
4
- "version": "1989.9.43",
4
+ "version": "1989.9.44",
5
5
  "private": false,
6
6
  "homepage": "https://github.com/Leask/utilitas",
7
7
  "main": "index.mjs",