Gathering detailed insights and metrics for js-guid
Gathering detailed insights and metrics for js-guid
Gathering detailed insights and metrics for js-guid
Gathering detailed insights and metrics for js-guid
typeid-js
Official implementation of the TypeID specification in TypeScript. TypeIDs are type-safe, K-sortable, and globally unique identifiers inspired by Stripe IDs
@zaidkindman/guid-handling
a small js package to handle some guid operations
striver-libs
前端开发常用js工具类
quosmolestiae
Javascript library that lets you generate and manage unique identifiers GUIDs
Javascript library that lets you generate and manage unique identifiers GUIDs.
npm install js-guid
Typescript
Module System
90.9
Supply Chain
100
Quality
75.4
Maintenance
100
Vulnerability
81.3
License
TypeScript (94.35%)
JavaScript (5.65%)
Total Downloads
1,447,500
Last Day
1,243
Last Week
12,466
Last Month
54,468
Last Year
667,290
GPL-3.0 License
3 Stars
13 Commits
1 Watchers
1 Branches
1 Contributors
Updated on Apr 17, 2023
Latest Version
1.0.2
Package Id
js-guid@1.0.2
Unpacked Size
55.96 kB
Size
16.78 kB
File Count
15
Cumulative downloads
Total Downloads
Last Day
2.5%
1,243
Compared to previous day
Last Week
-3.8%
12,466
Compared to previous week
Last Month
-0.4%
54,468
Compared to previous month
Last Year
86%
667,290
Compared to previous year
38
js-guid
is a javascript library that lets you generate and manage unique identifiers GUIDs written with TypeScript.
1npm install js-guid 2 3# or 4 5yarn add js-guid
In order to start using the library use the following statement:
1import { Guid } from 'js-guid'; 2 3// or 4 5const { Guid } = require('js-guid');
API | Description |
---|---|
Guid.EMPTY | (static) The Empty Guid string (all zeros). |
Guid.newGuid() | (static) Generate a new v4 Guid and return a new instance of the Guid. |
Guid.isValid(value) | (static) Checks if the given value is a valid GUID. |
Guid.parse(value) | (static) Parse the given value into the opposite type. |
new Guid(value?) | Instantiate a new Guid object. |
guid.toString() | Returns the string format of the Guid. |
guid.toByteArray() | Returns the Uint8Array of the Guid. |
guid.equals(value) | Compare the Given value with the current Guid. |
guid.isEmpty() | Return {True} if the Guid holds an empty value, False otherwise. |
The Empty Guid string (all zeros).
example
1import { Guid } from 'js-guid'; 2 3console.log(Guid.Empty); 4 5// Output 6// ⇨ '00000000-0000-0000-0000-000000000000'
Generate a new v4 Guid and return a new instance of the Guid.
Example
1import { Guid } from 'js-guid'; 2 3console.log(Guid.newGuid()); 4 5// Output 6// ⇨ '77eb3969-19fd-4223-907a-5749669f1178'
Checks if the given value is a valid GUID.
Key | Description |
---|---|
value | A valid Guid String or Uint8Array . |
returns | true if valid, false otherwise. |
throws | Error if value is not a valid Guid. |
Example
1import { Guid } from 'js-guid'; 2 3console.log(Guid.isValid('77eb3969-19fd-4223-907a-5749669f1178')); 4 5console.log(Guid.isValid(new Uint8Array([ 6 105, 57, 235, 119, 7 253, 25, 35, 66, 8 144, 122, 87, 73, 9 102, 159, 17, 120, 10])); 11 12// Output 13// ⇨ true 14// ⇨ true
Parse the given value into the opposite type.
Note : if value is string the function return a {Uint8Array of 16 elements}, otherwise it return a {string} if the value is a Uint8Array.
Key | Description |
---|---|
value | A valid Guid String or Uint8Array . |
returns | Uint8Array(16) if value is string . Or, returns string if value is Uint8Array(16) . |
throws | Error if value is not a valid Guid, or type is not supported. |
Example
1import { Guid } from 'js-guid'; 2 3console.log(Guid.parse('77eb3969-19fd-4223-907a-5749669f1178')); 4 5// Output 6// ⇨ [ 7// 105, 57, 235, 119, 8// 253, 25, 35, 66, 9// 144, 122, 87, 73, 10// 102, 159, 17, 120, 11// ] 12 13console.log(Guid.isValid(new Uint8Array([ 14 105, 57, 235, 119, 15 253, 25, 35, 66, 16 144, 122, 87, 73, 17 102, 159, 17, 120, 18])); 19 20// Output 21// ⇨ '77eb3969-19fd-4223-907a-5749669f1178'
Create a new instance of the Guid with the given value, or generate a new Guid if no value was given.
Key | Description |
---|---|
value | A valid Guid String or Uint8Array . |
returns | new Guid instance. |
throws | Error if value is not a valid Guid, or type is not supported. |
Example
1import { Guid } from 'js-guid'; 2 3let guid = new Guid(); 4console.log(guid.toString()); 5 6guid = new Guid('77eb3969-19fd-4223-907a-5749669f1178'); 7console.log(guid.toString()); 8 9guid = new Guid( 10 new Uint8Array([ 11 105, 57, 235, 119, 253, 25, 35, 66, 144, 122, 87, 73, 102, 159, 17, 120, 12 ]), 13); 14console.log(guid.toString()); 15 16// Output 17// ⇨ '77eb3969-19fd-4223-907a-5749669f1178' 18// ⇨ '77eb3969-19fd-4223-907a-5749669f1178' 19// ⇨ '77eb3969-19fd-4223-907a-5749669f1178'
Returns the string format of the Guid.
Key | Description |
---|---|
returns | string value of the Guid instance. |
Example
1import { Guid } from 'js-guid'; 2 3const guid = new Guid(); 4console.log(guid.toString()); 5 6// Output 7// ⇨ '77eb3969-19fd-4223-907a-5749669f1178'
Returns the Uint8Array of the Guid.
Key | Description |
---|---|
returns | Uint8Array(16) value of the Guid instance. |
Example
1import { Guid } from 'js-guid'; 2 3const guid = new Guid(); 4console.log(guid.toByteArray()); 5 6// Output 7// ⇨ [ 8// 105, 57, 235, 119, 9// 253, 25, 35, 66, 10// 144, 122, 87, 73, 11// 102, 159, 17, 120, 12// ]
Compare the Given value with the current Guid.
Key | Description |
---|---|
value | A valid Guid String , Uint8Array or Guid object. |
returns | true if equals, false otherwise. |
throws | Error if value is not a valid Guid. or type not spported. |
Example
1import { Guid } from 'js-guid'; 2 3const guid = new Guid('77eb3969-19fd-4223-907a-5749669f1178'); 4const guid2 = new Guid(); 5 6console.log(guid.equals(guid2)); 7console.log(guid.equals('77eb3969-19fd-4223-907a-5749669f1178')); 8console.log( 9 guid.equals( 10 new Uint8Array([ 11 105, 57, 235, 119, 253, 25, 35, 66, 144, 122, 87, 73, 102, 159, 17, 120, 12 ]), 13 ), 14); 15 16// Output 17// ⇨ false 18// ⇨ true 19// ⇨ true
Return {True} if the Guid holds an empty value, False otherwise.
Key | Description |
---|---|
returns | true if Guid equals Guid.Empty , false otherwise. |
Example
1import { Guid } from 'js-guid'; 2 3let guid = new Guid(); 4console.log(guid.isEmpty()); 5 6guid = new Guid(Guid.Empty); 7console.log(guid.isEmpty()); 8 9// Output 10// ⇨ false 11// ⇨ true
No vulnerabilities found.
Reason
no dangerous workflow patterns detected
Reason
no binaries found in the repo
Reason
license file detected
Details
Reason
8 existing vulnerabilities detected
Details
Reason
Found 0/13 approved changesets -- score normalized to 0
Reason
0 commit(s) and 0 issue activity found in the last 90 days -- score normalized to 0
Reason
detected GitHub workflow tokens with excessive permissions
Details
Reason
no SAST tool detected
Details
Reason
dependency not pinned by hash detected -- score normalized to 0
Details
Reason
no effort to earn an OpenSSF best practices badge detected
Reason
security policy file not detected
Details
Reason
project is not fuzzed
Details
Reason
branch protection not enabled on development/release branches
Details
Score
Last Scanned on 2025-06-30
The Open Source Security Foundation is a cross-industry collaboration to improve the security of open source software (OSS). The Scorecard provides security health metrics for open source projects.
Learn More