pid / puid Goto Github PK
View Code? Open in Web Editor NEWGenerate an unique ID depending on time, machine and process for use in a distributed environment.
Home Page: http://pid.github.io/puid/
License: MIT License
Generate an unique ID depending on time, machine and process for use in a distributed environment.
Home Page: http://pid.github.io/puid/
License: MIT License
Hi
You're asking for feedback about the "counter" part of the uid. So here's one :)
Maybe you could use a user-defined salt string in some config file and bake it into the counter part or the whole thing. What do you think ?
Either by using .npmignore
or the files
key in package.json
Could we add typescript type definitions to this repo? Would you prefer types be published to https://github.com/DefinitelyTyped/DefinitelyTyped instead?
http://www.w3.org/TR/http://www.w3.org/TR/hr-time//
http://www.w3.org/TR/hr-time/#sec-DOMHighResTimeStamphttps://developer.mozilla.org/en-US/docs/Web/API/DOMHighResTimeStamp
https://gist.github.com/paulirish/5438650 // polyfill
http://www.sitepoint.com/discovering-the-high-resolution-time-api/
http://updates.html5rocks.com/2012/08/When-milliseconds-are-not-enough-performance-now
created the task only as reminder.... actually I don't need it on client-side
If you have input/thoughts, feel free to contribute ;-)
The default value for the epoch value until v0.4.x is "1999-07-02 03:00:00 pm", there was a foul, because the timezone isn't set, so it differ from the local timezone on the machine it was generated. I fix/change this in version v0.5.x to "1999-06-07 03:00:00 pm GMT". The new datetime is before the old one, so it won't break IDs generated with earlier versions of puid.
The possibility that a ID with v0.4 will collide, is only possible if
So, there isn't really a chance for a collision ;-)
But it should be fixed ;-)
Please update to v0.5.x
As stated in the title, you are using Date.now()
to get the timestamp and encode it. Date.now()
returns milliseconds based timestamp instead of microseconds
Reference:
https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Date/now
var Puid = require('puid');
var puid = new Puid(false);
var schema = mongoose.Schema({
_id:{
type: String,
default: puid.generate,
},
});
------
//Got below error when try to use the mongoose model
TypeError: Cannot read property '0' of undefined
at model.generate (C:\Workspace\Ioko\Node\yiiep\node_modules\puid\lib\puid.js:64:18)
That dose not seems the make sens.
Why no just
Puid.generate()
instead of
var puid = new Puid();
puid.generate();
Is it possible to see this in bower? Thinking of using it client-side.
Not sure if you are aware, but there is a uuid module:
https://github.com/shtylman/node-uuid
Which generates uuids based on the RFC. This is more standard and doesn't involve having to make a custom scheme. I would recommend using it :)
I'm confused as you do not state anything about the relationships of PUIDs to UUIDs and from your PUID description I also do not see what benefit PUIDs provide over UUIDs. Can you please add some description about the relationships between PUIDs and UUIDs to your project, because UUIDs are standardized since a decade and seem to solve the same problem as PUIDs, hence it is vital to easily understand what different problem PUIDs seem to solve or why they solve the same problem better. Thanks.
This looks neato.
How appropriate might it be, to use a puid as a nonce in an HMAC protocol exchange?
Iโm curious why create a new kind of identifier that seemingly solves the same problem as UUID. Is it because of Javascript library availability?
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.