snico-dev / guid-typescript Goto Github PK
View Code? Open in Web Editor NEWguid generator to typescript
guid generator to typescript
I'm getting this error when I'm executing npm run build
in angular cli project
ERROR in ./node_modules/guid-typescript/src/guid.ts
Module build failed (from ./node_modules/@ngtools/webpack/src/index.js):
Error: /.../dev/management/mgmt-console/node_modules/guid-typescript/src/guid.ts is missing from the TypeScript compilation. Please make sure it is in your tsconfig via the 'files' or 'include' property.
The missing file seems to be part of a third party library. TS files in published libraries are often a sign of a badly packaged library. Please open an issue in the library repository to alert its author and ask them to package the library using the Angular Package Format (https://goo.gl/jB3GVv).
at AngularCompilerPlugin.getCompiledFile (/.../dev/management/mgmt-console/node_modules/@ngtools/webpack/src/angular_compiler_plugin.js:834:23)
at /.../dev/management/mgmt-console/node_modules/@ngtools/webpack/src/loader.js:41:31
at processTicksAndRejections (internal/process/task_queues.js:89:5)
Although I appreciate the existence of this package, there are multiple problems with it:
any
on toJSON() with a property:value
structure. This is not how I would serialize, and it is quite a dealbreaker. I would serialize in a flat manner value
directly, which is consistent with f.e. C#. Now I have to intercept the Guid and fix it.doesnt fit all
. Having total control over the guid's serialization setting is a must.Again, I really appreciate the package and the effort, but the fact that there are so many downloads made me very worried. This is one of the most used primitives on an API side (especially .NET Core).
I can PR something, but looking at the current amount of open PR's those should be processed first. I understand the backwards-compatible
hold-up, but this is a limbo state.
I love this library but am having issues getting it approved for use in a production environment.
At https://www.npmjs.com/package/guid-typescript you indicate that the license is ISC but there is no License file within the repository. Would it be possible to add one?
Also, would it be possible to tag the commits that form each new version? There are 10 versions in npm but it is awkward to find historically what the last commit was for each version. Basically the managers want snapshots of the repository with the License file at a particular point in time so they can approve those.
Many thanks
5c5e04ea-21ce-41b1-956a-43ee07200xxx is not a valid GUID (x is not allowed as character), but isGuid() still returns true.
Using this regex to test should fix the problem: ^[a-f0-9]{8}-[a-f0-9]{4}-[a-f0-9]{4}-[a-f0-9]{4}-[a-f0-9]{12}$
;
import { Guid } from "guid-typescript";
causes error TS2307: Cannot find module 'guid-typescript'.
import { Guid } from "guid-typescript/dist/guid";
fixes it
The Equals is case sensitive. Can we make this case invariant?
it('test guid library', () => {
const lowerCaseGuid: Guid = Guid.parse('00000001-0001-5365-7276-70726f496e63');
const upperCaseGuid: Guid = Guid.parse('00000001-0001-5365-7276-70726F496E63');
const areEqual = lowerCaseGuid.equals(upperCaseGuid);
expect(areEqual).toBe(true);
});
The unit test above is failing.
Hi, I'm using this in Ionic 4 and wasn't able to get the value of the GUID using .toString(), as it returns "[Object object]" as though it's using the normal toString instead of your class one, although hovering on it does indicate it uses the right one. using .toJSON also didn't work, as it said "is not a function".
I was only able to get the value using
var stringId = JSON.stringify(id);
var json =JSON.parse(stringId);
Right now "isGuid()" throws an exception if you pass it null or undefined... and this function (which is defined as returning a boolean) returns a blank string if you pass it a blank string (which makes no sense).
"isGuid()" should return FALSE for null, undefined, or blank string.
Hi,
Could you consider to switch the constructor from private
to protected
in order to extend the Guid class to override some methods (in my case the toJSON method).
Thanks
as title.
Guids can be, and are in some cases, represented without dashes. Under the covers they are a 128 bit integer and the dashes are primarily there for readability and segmentation of their source components. Would you be willing to update the regex to consider the dashes optional, or to include a statement with and without the dashes so they are either all there or all not there?
For some reference, RFC 4122 does specify that the format should include dashes, but in real world implementation many libraries I've used support native handling of non-dashed values. For instance, .NET allows for:
Guid.NewGuid().ToString("N") // outputs: 603626753d4a4d53bdb3c4374b49aa3e
And this value can be successfully parsed using
Guid.Parse("603626753d4a4d53bdb3c4374b49aa3e");
For usage cases, I've often used Guids without the dashes to represent a random token without the added complexity of dashes when they aren't adding value.
Thanks for creating this package!
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.