@actually_connor/uuid
Advanced tools
Comparing version 0.3.2 to 0.3.3
@@ -26,3 +26,3 @@ "use strict"; | ||
* | ||
* @param uuid The Array-like collection of 16 values (starting from offset) between 0-255 | ||
* @param {ArrayLike<number>} uuid The Array-like collection of 16 values (starting from offset) between 0-255 | ||
*/ | ||
@@ -33,3 +33,5 @@ constructor(uuid) { | ||
/** | ||
* @inheritDoc | ||
* Returns the Array-like collection of 16 values (starting from offset) between 0-255 | ||
* | ||
* @return {ArrayLike<number>} | ||
*/ | ||
@@ -42,6 +44,7 @@ | ||
/** | ||
* Creates a UUID from the string standard representation | ||
* | ||
* @param uuid | ||
* @param {string} uuid A hexadecimal string | ||
* | ||
* @return UuidInterface | ||
* @return {UuidInterface} A UuidInterface instance created from a hexadecimal string representation | ||
*/ | ||
@@ -54,3 +57,5 @@ | ||
/** | ||
* @inheritDoc | ||
* Returns the string standard representation of the UUID | ||
* | ||
* @return {string} | ||
*/ | ||
@@ -63,3 +68,5 @@ | ||
/** | ||
* @inheritDoc | ||
* Returns the hexadecimal representation of the UUID | ||
* | ||
* @return {string} | ||
*/ | ||
@@ -74,5 +81,5 @@ | ||
* | ||
* @param bytes A binary string | ||
* @param {string} bytes A binary string | ||
* | ||
* @return UuidInterface A UuidInterface instance created from a binary string representation | ||
* @return {UuidInterface} A UuidInterface instance created from a binary string representation | ||
*/ | ||
@@ -100,3 +107,5 @@ | ||
/** | ||
* @inheritDoc | ||
* Returns the binary string representation of the UUID | ||
* | ||
* @return {string} | ||
*/ | ||
@@ -117,3 +126,3 @@ | ||
* | ||
* @return UuidInterface A UuidInterface instance that represents a version 4 UUID | ||
* @return {UuidInterface} A UuidInterface instance that represents a version 4 UUID | ||
*/ | ||
@@ -128,5 +137,5 @@ | ||
* | ||
* @param uuid A string to validate as a UUID | ||
* @param {string} uuid A string to validate as a UUID | ||
* | ||
* @return boolean | ||
* @return {boolean} | ||
*/ | ||
@@ -139,3 +148,10 @@ | ||
/** | ||
* @inheritDoc | ||
* Returns true if the UUID is equal to the provided object | ||
* | ||
* The result is true if and only if the argument is not null, is a UUID object, has the same variant, and contains | ||
* the same value, bit for bit, as the UUID. | ||
* | ||
* @param {object|null} other An object to test for equality with this UUID | ||
* | ||
* @return {boolean} True if the other object is equal to this UUID | ||
*/ | ||
@@ -152,3 +168,12 @@ | ||
/** | ||
* @inheritDoc | ||
* Returns -1, 0, or 1 if the UUID is less than, equal to, or greater than the other UUID | ||
* | ||
* The first of two UUIDs is greater than the second if the most significant field in which the UUIDs differ | ||
* is greater for the first UUID. | ||
* | ||
* * Q. What's the value of being able to sort UUIDs? | ||
* * A. Use them as keys in a B-Tree or similar mapping. | ||
* @param {UuidInterface} other The UUID to compare | ||
* | ||
* @return {number} -1, 0, or 1 if the UUID is less than, equal to, or greater than the other | ||
*/ | ||
@@ -155,0 +180,0 @@ |
@@ -26,3 +26,3 @@ "use strict"; | ||
* | ||
* @param uuid The Array-like collection of 16 values (starting from offset) between 0-255 | ||
* @param {ArrayLike<number>} uuid The Array-like collection of 16 values (starting from offset) between 0-255 | ||
*/ | ||
@@ -33,3 +33,5 @@ constructor(uuid) { | ||
/** | ||
* @inheritDoc | ||
* Returns the Array-like collection of 16 values (starting from offset) between 0-255 | ||
* | ||
* @return {ArrayLike<number>} | ||
*/ | ||
@@ -42,6 +44,7 @@ | ||
/** | ||
* Creates a UUID from the string standard representation | ||
* | ||
* @param uuid | ||
* @param {string} uuid A hexadecimal string | ||
* | ||
* @return UuidInterface | ||
* @return {UuidInterface} A UuidInterface instance created from a hexadecimal string representation | ||
*/ | ||
@@ -54,3 +57,5 @@ | ||
/** | ||
* @inheritDoc | ||
* Returns the string standard representation of the UUID | ||
* | ||
* @return {string} | ||
*/ | ||
@@ -63,3 +68,5 @@ | ||
/** | ||
* @inheritDoc | ||
* Returns the hexadecimal representation of the UUID | ||
* | ||
* @return {string} | ||
*/ | ||
@@ -74,5 +81,5 @@ | ||
* | ||
* @param bytes A binary string | ||
* @param {string} bytes A binary string | ||
* | ||
* @return UuidInterface A UuidInterface instance created from a binary string representation | ||
* @return {UuidInterface} A UuidInterface instance created from a binary string representation | ||
*/ | ||
@@ -100,3 +107,5 @@ | ||
/** | ||
* @inheritDoc | ||
* Returns the binary string representation of the UUID | ||
* | ||
* @return {string} | ||
*/ | ||
@@ -117,3 +126,3 @@ | ||
* | ||
* @return UuidInterface A UuidInterface instance that represents a version 4 UUID | ||
* @return {UuidInterface} A UuidInterface instance that represents a version 4 UUID | ||
*/ | ||
@@ -128,5 +137,5 @@ | ||
* | ||
* @param uuid A string to validate as a UUID | ||
* @param {string} uuid A string to validate as a UUID | ||
* | ||
* @return boolean | ||
* @return {boolean} | ||
*/ | ||
@@ -139,3 +148,10 @@ | ||
/** | ||
* @inheritDoc | ||
* Returns true if the UUID is equal to the provided object | ||
* | ||
* The result is true if and only if the argument is not null, is a UUID object, has the same variant, and contains | ||
* the same value, bit for bit, as the UUID. | ||
* | ||
* @param {object|null} other An object to test for equality with this UUID | ||
* | ||
* @return {boolean} True if the other object is equal to this UUID | ||
*/ | ||
@@ -152,3 +168,12 @@ | ||
/** | ||
* @inheritDoc | ||
* Returns -1, 0, or 1 if the UUID is less than, equal to, or greater than the other UUID | ||
* | ||
* The first of two UUIDs is greater than the second if the most significant field in which the UUIDs differ | ||
* is greater for the first UUID. | ||
* | ||
* * Q. What's the value of being able to sort UUIDs? | ||
* * A. Use them as keys in a B-Tree or similar mapping. | ||
* @param {UuidInterface} other The UUID to compare | ||
* | ||
* @return {number} -1, 0, or 1 if the UUID is less than, equal to, or greater than the other | ||
*/ | ||
@@ -155,0 +180,0 @@ |
@@ -26,3 +26,3 @@ "use strict"; | ||
* | ||
* @param uuid The Array-like collection of 16 values (starting from offset) between 0-255 | ||
* @param {ArrayLike<number>} uuid The Array-like collection of 16 values (starting from offset) between 0-255 | ||
*/ | ||
@@ -33,3 +33,5 @@ constructor(uuid) { | ||
/** | ||
* @inheritDoc | ||
* Returns the Array-like collection of 16 values (starting from offset) between 0-255 | ||
* | ||
* @return {ArrayLike<number>} | ||
*/ | ||
@@ -42,6 +44,7 @@ | ||
/** | ||
* Creates a UUID from the string standard representation | ||
* | ||
* @param uuid | ||
* @param {string} uuid A hexadecimal string | ||
* | ||
* @return UuidInterface | ||
* @return {UuidInterface} A UuidInterface instance created from a hexadecimal string representation | ||
*/ | ||
@@ -54,3 +57,5 @@ | ||
/** | ||
* @inheritDoc | ||
* Returns the string standard representation of the UUID | ||
* | ||
* @return {string} | ||
*/ | ||
@@ -63,3 +68,5 @@ | ||
/** | ||
* @inheritDoc | ||
* Returns the hexadecimal representation of the UUID | ||
* | ||
* @return {string} | ||
*/ | ||
@@ -74,5 +81,5 @@ | ||
* | ||
* @param bytes A binary string | ||
* @param {string} bytes A binary string | ||
* | ||
* @return UuidInterface A UuidInterface instance created from a binary string representation | ||
* @return {UuidInterface} A UuidInterface instance created from a binary string representation | ||
*/ | ||
@@ -100,3 +107,5 @@ | ||
/** | ||
* @inheritDoc | ||
* Returns the binary string representation of the UUID | ||
* | ||
* @return {string} | ||
*/ | ||
@@ -117,3 +126,3 @@ | ||
* | ||
* @return UuidInterface A UuidInterface instance that represents a version 4 UUID | ||
* @return {UuidInterface} A UuidInterface instance that represents a version 4 UUID | ||
*/ | ||
@@ -128,5 +137,5 @@ | ||
* | ||
* @param uuid A string to validate as a UUID | ||
* @param {string} uuid A string to validate as a UUID | ||
* | ||
* @return boolean | ||
* @return {boolean} | ||
*/ | ||
@@ -139,3 +148,10 @@ | ||
/** | ||
* @inheritDoc | ||
* Returns true if the UUID is equal to the provided object | ||
* | ||
* The result is true if and only if the argument is not null, is a UUID object, has the same variant, and contains | ||
* the same value, bit for bit, as the UUID. | ||
* | ||
* @param {object|null} other An object to test for equality with this UUID | ||
* | ||
* @return {boolean} True if the other object is equal to this UUID | ||
*/ | ||
@@ -152,3 +168,12 @@ | ||
/** | ||
* @inheritDoc | ||
* Returns -1, 0, or 1 if the UUID is less than, equal to, or greater than the other UUID | ||
* | ||
* The first of two UUIDs is greater than the second if the most significant field in which the UUIDs differ | ||
* is greater for the first UUID. | ||
* | ||
* * Q. What's the value of being able to sort UUIDs? | ||
* * A. Use them as keys in a B-Tree or similar mapping. | ||
* @param {UuidInterface} other The UUID to compare | ||
* | ||
* @return {number} -1, 0, or 1 if the UUID is less than, equal to, or greater than the other | ||
*/ | ||
@@ -155,0 +180,0 @@ |
{ | ||
"name": "@actually_connor/uuid", | ||
"version": "0.3.2", | ||
"version": "0.3.3", | ||
"description": "A JavaScript library that provides a 'ramsey/uuid'-like interface for the uuid package", | ||
@@ -37,3 +37,4 @@ "keywords": [ | ||
"lint-fix": "eslint --ext .ts src --fix", | ||
"build": "./scripts/build.sh" | ||
"build": "./scripts/build.sh", | ||
"docs": "./scripts/docs.sh" | ||
}, | ||
@@ -55,2 +56,3 @@ "author": { | ||
"@typescript-eslint/parser": "^5.13.0", | ||
"docdash": "^1.2.0", | ||
"eslint": "^8.10.0", | ||
@@ -60,2 +62,3 @@ "eslint-plugin-import": "^2.25.4", | ||
"jest": "^27.5.1", | ||
"jsdoc-to-markdown": "^7.1.1", | ||
"ts-jest": "^27.1.3", | ||
@@ -62,0 +65,0 @@ "ts-node": "^10.6.0" |
106
README.md
@@ -33,106 +33,6 @@ <h1 align="center">@actually_connor/uuid</h1> | ||
## API Summary | ||
## Documentation | ||
### getUuid() | ||
[@actually_connor/uuid docs](https://uuid.connorsmyth.com/Uuid.html) | ||
Returns the array of bytes of the UUID | ||
| | | | ||
| --------- | ---------------------------------------- | | ||
| _returns_ | `Uint8Array[16]` | | ||
| _throws_ | `TypeError` if `str` is not a valid UUID | | ||
Example: | ||
```javascript | ||
import { Uuid } from '@actually_connor/uuid'; | ||
const uuid = Uuid.uuid4(); | ||
const byteArray = uuid.getUuid(); | ||
``` | ||
### fromString(str) | ||
Convert a UUID string to array of bytes | ||
| | | | ||
| --------- | ---------------------------------------- | | ||
| `str` | A valid UUID `String` | | ||
| _returns_ | `Uint8Array[16]` | | ||
| _throws_ | `TypeError` if `str` is not a valid UUID | | ||
Example: | ||
```javascript | ||
import { Uuid } from '@actually_connor/uuid'; | ||
const uuid = Uuid.fromString('6ec0bd7f-11c0-43da-975e-2a8ad9ebae0b'); | ||
``` | ||
### toString() | ||
Convert array of bytes to UUID string | ||
| | | | ||
| -------------- | ---------------------------------------------------------------------------- | | ||
| _returns_ | `String` | | ||
| _throws_ | `TypeError` if a valid UUID string cannot be generated | | ||
Example: | ||
```javascript | ||
import { Uuid } from '@actually_connor/uuid'; | ||
const uuid = Uuid.uuid4(); | ||
uuid.toString(); // ⇨ '6ec0bd7f-11c0-43da-975e-2a8ad9ebae0b' | ||
``` | ||
### getHex | ||
Convert array of bytes to UUID hexadecimal string | ||
| | | | ||
| -------------- | ---------------------------------------------------------------------------- | | ||
| _returns_ | `String` | | ||
| _throws_ | `TypeError` if a valid UUID string cannot be generated | | ||
Example: | ||
```javascript | ||
import { Uuid } from '@actually_connor/uuid'; | ||
const uuid = Uuid.uuid4(); | ||
uuid.getHex(); // ⇨ '6EC0BD7F11C043DA975E2A8AD9EBAE0B' | ||
``` | ||
### fromBytes(str) | ||
Convert a UUID byte string to array of bytes | ||
| | | | ||
| --------- | ---------------------------------------- | | ||
| `str` | A valid UUID byte string `String` | ||
| _returns_ | `Uint8Array[16]` | | ||
| _throws_ | `TypeError` if `str` is not a valid UUID | | ||
Example: | ||
```javascript | ||
import { Uuid } from '@actually_connor/uuid'; | ||
const uuid = Uuid.fromString('acCäügF¥ÜsÃ?4'); | ||
``` | ||
### getBytes() | ||
Convert an array of bytes to a binary string representation of the UUID | ||
| | | | ||
| -------------- | ---------------------------------------------------------------------------- | | ||
| _returns_ | `String` | | ||
| _throws_ | `TypeError` if a valid UUID string cannot be generated | | ||
Example: | ||
```javascript | ||
import { Uuid } from '@actually_connor/uuid'; | ||
const uuid = Uuid.uuid4(); | ||
uuid.getBytes(); // ⇨ 'acCäügF¥ÜsÃ?4' | ||
``` | ||
## Use in Database - MySQL | ||
@@ -150,3 +50,3 @@ | ||
.values({ | ||
uuid: () => `UNHEX('${Uuid.uuid4().toHex()}')`, | ||
uuid: () => `UNHEX('${Uuid.uuid4().getHex()}')`, | ||
}) | ||
@@ -153,0 +53,0 @@ .execute(); |
19489
516
14
78