Git Product home page Git Product logo

uuid's People

Contributors

0xflotus avatar alex-sokolov avatar awwit avatar bpo avatar broofa avatar commanderroot avatar ctavan avatar danorton-cubic-austin avatar defunctzombie avatar dependabot[bot] avatar drewthaler avatar dylans avatar eagleeye avatar g-rath avatar gokaygurcan avatar jasonwoof avatar jonkoops avatar jonpulsifer avatar kenhkan avatar linusu avatar mearman avatar mrjbq7 avatar nschonni avatar puzpuzpuz avatar raynos avatar rush avatar sobrinho avatar trysound avatar watadarkstar avatar yonifra avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

uuid's Issues

Possible extension of v1 UUIDs

A thing came in mind when I was running some tests with v1 UUIDs: Should we allow the user of the v1() method to optionally specify a timestamp that will be used instead of Date().getTime()?

There are two cases in which this might make sense:

  1. For testing (clock sequence stuff)
  2. If you want to do range selections on a range of v1 UUID's and need to generate the corresponding start- and end-UUID's.

I see that we're getting to a point where we're tempted to make node-uuid bloated which should be avoided IMO. I therefore had the idea of using node-uuid as the underlying fast & lightweight uuid generator for a wrapper similar to uuid-js that provides you with some convenience methods like conversion between string- and buffer-representation, validation, extraction of the timestamp, etc, see my discussion with @pnegri: https://github.com/pnegri/uuid-js/issues/10

He also had the brilliant idea of naming it node-uuid-utils which I really like.

Being able to specify the timestamp when calling v1() would be the only addition to node-uuid I can think of right now that would be needed to build node-uuid-utils. What do you think?

IDs sequenced by time?

Hi there

I'm using uuid.v1() for keys within my LevelDB + node.js app. Whenever I list entries from the LevelDB, the sorting happens by these keys and unfortunately it is very random.

I mean, in a boring relational DB you increment the primary keys. Whenever you query the rows, the are sorted by these primary keys as a default behavior. This is good, you always know that recently inserted rows appear on top.

But with UUIDs v1 as keys, the sequence is pretty random.

Is there a solution for that? Do I need to fine-tune some options to achieve that behavior or can this be implemented at all in a new version?

provide a .verify(uuid) method

Thoughts on providing a .verify method which will return true or false if the string or buffer is a valid uuid? Maybe only relevant for strings? but I think it is useful for basic error checking of user input.

1.3.2 : crash on load

I'm using node v0.4.11

Everything works with node-uuid 1.3.0

But when I used node-uuid 1.3.2, on launch of my app :

node.js:134

    throw e; // process.nextTick error, or 'error' event on first tick

    ^

TypeError: undefined is not a function
at CALL_NON_FUNCTION (native)
at /xxx/node_modules/node-uuid/uuid.js:47:14
at /xxx/node_modules/node-uuid/uuid.js:103:20
at Object. (/xxx/node_modules/node-uuid/uuid.js:249:1)
at Module._compile (module.js:402:26)
at Object..js (module.js:408:10)
at Module.load (module.js:334:31)
at Function._load (module.js:293:12)
at require (module.js:346:19)
at Object. (/xxx/server/lib/server.js:16:12)

If create two UUID in exactly the same time... what happend?

I'm trying to see what happens if you create two UUID at exactly same time (hours, minutes, seconds and milliseconds)... but I can't be sure about.

create the same UUID?
or the math.random (but random based on time) minimize this probability?

Thanks in advance!

Re-export RNG functions

35aa0a2 removes symbolic RNG exports uuid.{mathRNG,nodeRNG,whatwgRNG}, but they are still mentioned in README.md.

Rather than fixing the docs, I think re-exporting them would be preferable. For example, I would like to force v4 to use the crypto RNG.

Support base64 or 62

It would be great to have uuid's in base62/64 format for docs, urls, or for couchdb _id

node-uuid is url safe?

hello, node-uuid result can be use it in a url?

I mean, if I need to encode it before using it on a url.

var uuid = require ('node-uuid'),
      token = uuid.v4(),
      url; 

// is this ok?
url = 'http://localhost/myurl/' + token; 

// or this:
url = 'http://localhost/myurl/' + functionToBase64url (token);

about the `-`

why

return  bth[buf[i++]] + bth[buf[i++]] +
          bth[buf[i++]] + bth[buf[i++]] + '-' +
          bth[buf[i++]] + bth[buf[i++]] + '-' +
          bth[buf[i++]] + bth[buf[i++]] + '-' +
          bth[buf[i++]] + bth[buf[i++]] + '-' +
          bth[buf[i++]] + bth[buf[i++]] +
          bth[buf[i++]] + bth[buf[i++]] +
          bth[buf[i++]] + bth[buf[i++]];

not

return  bth[buf[i++]] + bth[buf[i++]] +
          bth[buf[i++]] + bth[buf[i++]] +
          bth[buf[i++]] + bth[buf[i++]] +
          bth[buf[i++]] + bth[buf[i++]] +
          bth[buf[i++]] + bth[buf[i++]] +
          bth[buf[i++]] + bth[buf[i++]] +
          bth[buf[i++]] + bth[buf[i++]] +
          bth[buf[i++]] + bth[buf[i++]];

I think 02a2ce90143211e185580b488e4fc115 is more beautiful than 02a2ce90-1432-11e1-8558-0b488e4fc115

RFI: Add option for RNG method. Annotated source code.

Since v4 performance is so dependent on which RNG is used, it seemed appropriate to allow this aspect of the code to be testable. Hence broofa/node-uuid@master...rng_refactor includes ...

  • Expose the feature-detected RNG methods
  • Allow them to be set in the v4() options.rng object
  • Updated tests to test each generator

And while I was at it ...

Uniqueness of v1 UUIDs if msecs is set.

While implementing node-uuid with node-cassandra-client I came across this test written by the node-cassandra-client authors: https://github.com/ctavan/node-cassandra-client/blob/node-uuid/test/test_uuid.js#L13-29

It fails with node-uuid since setting msecs bypasses the internal clockseq-counter. What was the particular reason for you to put it that way? The only reason I can see is code readability.

Reading through the RFC again, IMO setting msecs and nsecs to a value in the future and then to a value lower than that future-value can just be interpreted as "setting the clock backwards". So unless the clockseq is explicitly specified I think node-uuid should take care of setting the clockseq according to the RFC (and not the calling application, which would be necessary at the moment).

I admit that this will add complexity to the v1 logic, but still I think it would be more in the sense of the RFC... What are your thoughts?

Confusion about dual MIT + GPL Licence

MIT admit things that GPL don't admit. Then can you clarify to me...

Can I use this code in a commercial development?
What are the conditions to use it?

DP: Sorry my English isn't very good.

uuid.v1() not working properly in browser

When creating v1 uuids in the browser (with browserify), only the first part of the id changes, while the rest is static, e.g:

ae355c10-6109-11e4-9d2c-85cd1908178e
ae68a110-6109-11e4-9d2c-85cd1908178e
ae872590-6109-11e4-9d2c-85cd1908178e
aea69470-6109-11e4-9d2c-85cd1908178e
aec08510-6109-11e4-9d2c-85cd1908178e
aedc7180-6109-11e4-9d2c-85cd1908178e
aef77390-6109-11e4-9d2c-85cd1908178e
af111610-6109-11e4-9d2c-85cd1908178e
531d64c0-610a-11e4-9d2c-85cd1908178e

6109-11e4-9d2c-85cd1908178e never changes whether generated milliseconds or minutes apart. v1 generator works fine when run by nodejs.

npm warning at install time

 npm install
npm WARN [email protected] dependencies field should be hash of <name>:<version-range> pairs

I think you want your package.json dependencies to change to this:

...
dependencies: {},
...

Addition: isValid()

Can you add a function that checks if a string is a valid uuid? If you receive a uuid from the user, before sending it to the databse you typically want to check if it's a valid uuid. If it's not valid it makes no sense to send it to the database and slow down the user experience.

function isValid (s){
    return /^[a-z0-9]{8}-[a-z0-9]{4}-[a-z0-9]{4}-[a-z0-9]{4}-[a-z0-9]{12}$/i
            .test (s);
};

please tag releases

npmjs.org cliams this project is at version 1.4.0 but that version does not exist as a tag here at github.

Please always tag releases, to ease tracking by distributors (some prefer to use other package handling than npm - like me: I maintain the official Debian package for this project).

node-uuid 1.3.2 not working with node v0.4.12

crypto.randomBytes wasn't added until node v0.6.0. The compatibility check (try/catch) doesn't work.

_rb gets set as undefined and doesn't fail until it's later called (outside of the try/catch).

https://github.com/broofa/node-uuid/blob/master/uuid.js#L44

resulting error:

node.js:134
        throw e; // process.nextTick error, or 'error' event on first tick
        ^
TypeError: undefined is not a function
    at CALL_NON_FUNCTION (native)
    at /app/node_modules/node-uuid/uuid.js:47:14
    at /app/node_modules/node-uuid/uuid.js:103:20
    at Object.<anonymous> (/app/node_modules/node-uuid/uuid.js:249:1)
    at Module._compile (module.js:411:26)
    at Object..js (module.js:417:10)
    at Module.load (module.js:343:31)
    at Function._load (module.js:302:12)
    at require (module.js:355:19)

Add bower.json

Bower.json is missing in the project, you should add one.

can't run uuid after npm install -g

I'm using nvm & node v0.10.30
after npm install -g node-uuid
there is no uuid link in ~/.nvm/v0.10.30/bin neither the ~/.nvm/v0.10.30/lib/node_modules/node-uuid/bin directory

failing in yui compressor

Hi
fails in yui compressor, due to use of future reserved keyword 'byte'. simply use another variable name to solve the yui compressor compatibility.

s.toLowerCase().replace(/[0-9a-f]{2}/g, function(byte).....

Kind regards
Jari Berg

Implement k-ordered IDs a la Flake

Take inspiration from:

https://github.com/boundary/flake

"Flake ids are 128-bits wide described here from most significant to least significant bits.

64-bit timestamp - milliseconds since the epoch (Jan 1 1970)
48-bit worker id - MAC address from a configurable device
16-bit sequence # - usually 0, incremented when more than one id is requested in the same millisecond and reset to 0 when the clock ticks forward

UUID-1 is an odd beast. First, the timestamp is based on the number of 100 nanosecond intervals since October 15, 1582. This is not how most of us familiar with Unix timestamps reason about time. If that isn't bad enough, the timestamp is an odd 60-bits in length with the most significant bits shifted to the least significant bits of the UUID. This property makes lexical ordering essentially meaningless. The remaining bits contain a clock id (initially set to a random number) and a node id (usually the MAC address).

The first problem is the timestamp. We could rearrange the bits to get some k-ordering love, but reasoning on timestamps of this nature makes reasoning about the resulting ids more complex than it needs to be. This is why flake uses a standard 64-bit Unix timestamp, unaltered, as the most significant bits."

I realise that this project is focused on UUIDs as defined in RFC4122, so this sort of ID generation wouldn't fit within that goal - but I hadn't seen a similar Node.js project as yet and thought I'd check to see if you wanted to implement it here.

Got collisions for v1() when generating many IDs

Hi,

I have been using node-uuid for a while, and it has in total generated about 500k IDs that I use. I now ran a check and found, to my surprise, 2 collisions among those IDs.

The collisions were generated in a sequence where 5-10 IDs are created synchronously and stored in the same database document. For one of the collisions it happened directly following the original entry. For the other collision there were 2 entries between them.

One of the collisions was:
e7a69040-b412-11e2-ad2c-57e3dd379c2d

Should this really be possible? Perhaps there is some flaw in the implementation.

I was using Node 0.8 at the time, if that matters.

no symlink to /build/default/uuid.node

I run npm to install this module with no error.
node panics after it cannot require("uuid").
I know you provide main script in package.json but nothing exists at '/build/default/uuid.node'.
uuid.node is still located at /build/Release/

node 0.8.1
npm 1.1.33
macos 10.8

Please update your README

If you would please update your README to reflect how it's intended to be called. uuid() instead of uuid.v1() or v4()

Add "license" and "licenses" to package.json

Specifying your license in package.json makes it a lot easier for your users to find and comply with GNU Affero licenses.

Also giving licenses (an array of objects with type and url keys) helps users whose legal departments request both the license name and the text. See this example from async:

  "licenses": [{
    "type": "MIT",
    "url": "https://github.com/caolan/async/raw/master/LICENSE"
  }]

Though licenses isn't specified in the npm package.json spec, it is supported by the NPM site, as you'll see if you check async's NPM page.

Thanks!

NPM package includes x86-64 binary file

When installing by npm install node-uuid (version 1.1.0, per npm info node-uuid), the distributed package includes a x86-64 binary file, test/benchmark-native, which my (puny 32-bit) machine refuses to include in a debian package.

> wget http://registry.npmjs.org/node-uuid/-/node-uuid-1.1.0.tgz
> tar -zxf node-uuid-1.1.0.tgz
> file package/test/benchmark-native
package/test/benchmark-native: ELF 64-bit LSB executable, x86-64, version 1 (SYSV), dynamically linked (uses shared libs), for GNU/Linux 2.6.9, not stripped

While I'm no NPM expert, the executable should either be compiled install-time, or it should not be included at all.

(For good measure, I'm trying to use npm bundle install as a hack to build quick debian packages for Node.js programs.)

What's the point of returning the same uuid on each call to v1?

Apparently this is by design: The randomly generated node id is only guaranteed to stay constant for the lifetime of the current JS runtime. But what is the point of this? It also kind of conflicts with the description of the msec option which says: Default: The current time is used._ But apparently the current time is only used on the first call to v1 and then that uuid is cached and returned over and over on each call to v1. So now if I want to generate a fresh v1 I have to always call nodeuuid.v1({msec: new Date().getTime()})

version in npm seems old

Not sure if this belongs here but when doing npm install node-uuid it seems to get a pretty old version of the package (no v1, v4 methods etc) the version I get is 1.2

Non-RFC random IDs

Is it possible to extend this to be like your Math.uuid.js so it can also generate random IDs of any length?

Error installing via npm

Not sure whether I should report it here on the npm forum but I am unable to install node-uuid using npm. The system is running Centos-5.5 x86_64. I was able to install other things using npm so the problem seems to be just with this tgz file.

npm info it worked if it ends with ok
npm info using [email protected]
npm info using [email protected]
npm info fetch http://registry.npmjs.org/node-uuid/-/node-uuid-1.1.0.tgz
npm info calculating sha1 /tmp/npm-1296348137194/1296348137194-0.9728793394751847/tmp.tgz
npm info shasum 9a7027279bc670e50980e94c55958117272c4f37
npm ERR! Failed unpacking the tarball.
npm ERR! This is very rare. Perhaps the 'gzip' or 'tar' configs
npm ERR! are set improperly?
npm ERR!
npm ERR! couldn't unpack /tmp/npm-1296348137194/1296348137194-0.9728793394751847/tmp.tgz to /tmp/npm-1296348137194/1296348137194-0.9728793394751847/contents
npm ERR! Error installing [email protected]
npm ERR! Error: Failed /bin/gtar "-vxpf" "-" "-C" "/tmp/npm-1296348137194/1296348137194-0.9728793394751847/contents"
npm ERR! exited with 2
npm ERR! at ChildProcess. (/usr/local/lib/node/.npm/npm/0.2.16/package/lib/utils/exec.js:48:8)
npm ERR! at ChildProcess.emit (events.js:45:17)
npm ERR! at ChildProcess.onexit (child_process.js:171:12)
npm ERR! Report this entire log at http://github.com/isaacs/npm/issues
npm ERR! or email it to [email protected]
npm ERR! Just tweeting a tiny part of the error will not be helpful.
npm not ok

Add isValid methods

Hi Broofa, nice project here. ;) Just a suggestion. It would be nice if there was a method sort of like:

nodeUuid.isV4(someUuidString);

That way it would be easy to know if a string is a valid UUID v4. Right now, I have to resort to something janky like this:

if (!uuid || uuid.length < 32 || uuid.indexOf("-") < 0) {
    uuid = nodeUuid.v4();
}

npm install uuid fails

Hi,

installing uuid through npm install uuid fails:

Build failed:  -> task failed (err #1): 
    {task: cxx uuid.cc -> uuid_1.o}
npm ERR! error installing [email protected]

npm ERR! [email protected] preinstall: `node-waf configure && node-waf build`
npm ERR! `sh "-c" "node-waf configure && node-waf build"` failed with 1
npm ERR! 
npm ERR! Failed at the [email protected] preinstall script.
npm ERR! This is most likely a problem with the uuid package,
npm ERR! not with npm itself.
npm ERR! Tell the author that this fails on your system:
npm ERR!     node-waf configure && node-waf build
npm ERR! You can get their info via:
npm ERR!     npm owner ls uuid
npm ERR! There is likely additional logging output above.
npm ERR! 
npm ERR! System Linux 3.2.0-32-generic
npm ERR! command "node" "/usr/bin/npm" "install" "uuid"
npm ERR! cwd /home/vk/code/javascript/jsuggest
npm ERR! node -v v0.6.12
npm ERR! npm -v 1.1.4
npm ERR! code ELIFECYCLE
npm ERR! message [email protected] preinstall: `node-waf configure && node-waf build`
npm ERR! message `sh "-c" "node-waf configure && node-waf build"` failed with 1
npm ERR! errno {}

I can provide additional information if necessary

-- ooxi

Release notes

Hi, could you update the release notes for the latest release?

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.