Search code examples
typescriptuuid

Generating a UUID with the NPM package UUID?


Trying to generate a set of UUIDs using the UUID package on NPM. With typescript I try this:

  import v1 from "uuid/v1";

  console.log(v1());
  console.log(v1());
  console.log(v1());
  console.log(v1());
  console.log(v1());

This prints:

ef1f74d0-aff3-11e8-9466-0db0429140ee
ef1f74d1-aff3-11e8-9466-0db0429140ee
ef1f74d2-aff3-11e8-9466-0db0429140ee
ef1f74d3-aff3-11e8-9466-0db0429140ee
ef1f74d4-aff3-11e8-9466-0db0429140ee

So even though each console log calls v1() it still generates the same UUID. Thoughts?


Solution

  • Those aren't the same uuids. Notice the first part of each uuid is different ef1f74d0 ef1f74d1 ef1f74d2 ef1f74d3 ef1f74d4