bson 5.2.0 → 5.4.0

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.
@@ -0,0 +1,37 @@
1
+ {
2
+ "name": "text-encoding",
3
+ "author": "Joshua Bell <inexorabletash@gmail.com>",
4
+ "contributors": [
5
+ "Joshua Bell <inexorabletash@gmail.com>",
6
+ "Rick Eyre <rick.eyre@outlook.com>",
7
+ "Eugen Podaru <eugen.podaru@live.com>",
8
+ "Filip Dupanović <filip.dupanovic@gmail.com>",
9
+ "Anne van Kesteren <annevk@annevk.nl>",
10
+ "Author: Francis Avila <francisga@gmail.com>",
11
+ "Michael J. Ryan <tracker1@gmail.com>",
12
+ "Pierre Queinnec <pierre@queinnec.org>",
13
+ "Zack Weinberg <zackw@panix.com>"
14
+ ],
15
+ "version": "0.7.0",
16
+ "description": "Polyfill for the Encoding Living Standard's API.",
17
+ "main": "index.js",
18
+ "files": [
19
+ "index.js",
20
+ "lib/encoding.js",
21
+ "lib/encoding-indexes.js"
22
+ ],
23
+ "repository": {
24
+ "type": "git",
25
+ "url": "https://github.com/inexorabletash/text-encoding.git"
26
+ },
27
+ "keywords": [
28
+ "encoding",
29
+ "decoding",
30
+ "living standard"
31
+ ],
32
+ "bugs": {
33
+ "url": "https://github.com/inexorabletash/text-encoding/issues"
34
+ },
35
+ "homepage": "https://github.com/inexorabletash/text-encoding",
36
+ "license": "(Unlicense OR Apache-2.0)"
37
+ }
package/src/uuid_utils.ts DELETED
@@ -1,33 +0,0 @@
1
- import { BSONError } from './error';
2
- import { ByteUtils } from './utils/byte_utils';
3
-
4
- // Validation regex for v4 uuid (validates with or without dashes)
5
- const VALIDATION_REGEX =
6
- /^(?:[0-9a-f]{8}-[0-9a-f]{4}-4[0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}|[0-9a-f]{12}4[0-9a-f]{3}[89ab][0-9a-f]{15})$/i;
7
-
8
- export const uuidValidateString = (str: string): boolean =>
9
- typeof str === 'string' && VALIDATION_REGEX.test(str);
10
-
11
- export const uuidHexStringToBuffer = (hexString: string): Uint8Array => {
12
- if (!uuidValidateString(hexString)) {
13
- throw new BSONError(
14
- 'UUID string representations must be a 32 or 36 character hex string (dashes excluded/included). Format: "xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx" or "xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx".'
15
- );
16
- }
17
-
18
- const sanitizedHexString = hexString.replace(/-/g, '');
19
- return ByteUtils.fromHex(sanitizedHexString);
20
- };
21
-
22
- export function bufferToUuidHexString(buffer: Uint8Array, includeDashes = true): string {
23
- if (includeDashes) {
24
- return [
25
- ByteUtils.toHex(buffer.subarray(0, 4)),
26
- ByteUtils.toHex(buffer.subarray(4, 6)),
27
- ByteUtils.toHex(buffer.subarray(6, 8)),
28
- ByteUtils.toHex(buffer.subarray(8, 10)),
29
- ByteUtils.toHex(buffer.subarray(10, 16))
30
- ].join('-');
31
- }
32
- return ByteUtils.toHex(buffer);
33
- }