1.0.5 • Published 5 months ago

@atlantjs.dev/uuid v1.0.5

Weekly downloads
-
License
MIT
Repository
-
Last release
5 months ago

Uuid

The main difference between this and this package on npm is that it defines a Uuid class and can be used to enforce typing.

Install

npm install @atlantjs.dev/uuid
yarn add @atlantjs.dev/uuid

Using

Usage example:

import { Uuid } from "@atlantjs.dev/uuid";

class User {
  constructor(public readonly id: Uuid) {}

  public isSame(anotherUser: User): boolean {
    return this.id.equals(anotherUser.id);
  }
}

const foo = new User(Uuid.new());
const bar = new User(Uuid.new());

console.log(foo.id.toString()); // 388b932f-0800-412c-a70d-68af2f8e54c8

foo.isSame(bar); // false

new User(Uuid.new()); // This is OK
new User(new Uuid("388b932f-0800-412c-a70d-68af2f8e54c8")); // This is OK
new User(new Uuid("foobar")); // Will throw a TypeError

new User(1); // Can't compile
new User("foobar"); // Can't compile
new User("388b932f-0800-412c-a70d-68af2f8e54c8"); // Can't compile
1.0.5

5 months ago

1.0.4

5 months ago

1.0.2

6 months ago

1.0.1

6 months ago

1.0.3

6 months ago

1.0.0

6 months ago