@jamashita/anden-object
Advanced tools
Comparing version 2.3.0 to 2.4.0
import { Cloneable } from '@jamashita/anden-type'; | ||
import { Objet } from './Objet'; | ||
export declare abstract class Entity<I, T extends Entity<I, T, N>, N extends string = string> extends Objet<N> implements Cloneable<T> { | ||
export declare abstract class Entity<I, T extends Entity<I, T>> extends Objet implements Cloneable<T> { | ||
abstract getIdentifier(): I; | ||
abstract duplicate(): T; | ||
abstract serialize(): string; | ||
equals(other: unknown): boolean; | ||
hashCode(): number; | ||
abstract serialize(): string; | ||
} | ||
//# sourceMappingURL=Entity.d.ts.map |
import { RuntimeError } from '@jamashita/anden-error'; | ||
export declare class RecursiveReferenceError extends RuntimeError<'RecursiveReferenceError'> { | ||
readonly noun: 'RecursiveReferenceError'; | ||
export declare class RecursiveReferenceError extends RuntimeError { | ||
constructor(message: string, cause?: Error); | ||
} | ||
//# sourceMappingURL=RecursiveReferenceError.d.ts.map |
@@ -8,3 +8,2 @@ "use strict"; | ||
super(message, cause); | ||
this.noun = 'RecursiveReferenceError'; | ||
} | ||
@@ -11,0 +10,0 @@ } |
import { ObjectLiteral } from '@jamashita/anden-type'; | ||
import { Entity } from '../Entity'; | ||
export declare class MockEntity<V> extends Entity<V, MockEntity<V>, 'MockEntity'> { | ||
readonly noun: 'MockEntity'; | ||
export declare class MockEntity<V> extends Entity<V, MockEntity<V>> { | ||
private readonly id; | ||
@@ -6,0 +5,0 @@ private other; |
@@ -9,3 +9,2 @@ "use strict"; | ||
super(); | ||
this.noun = 'MockEntity'; | ||
this.id = id; | ||
@@ -12,0 +11,0 @@ this.other = other; |
import { ValueObject } from '../ValueObject'; | ||
export declare class MockValueObject<V> extends ValueObject<'MockValueObject'> { | ||
readonly noun: 'MockValueObject'; | ||
export declare class MockValueObject<V> extends ValueObject { | ||
private readonly value; | ||
@@ -5,0 +4,0 @@ constructor(value: V); |
@@ -9,3 +9,2 @@ "use strict"; | ||
super(); | ||
this.noun = 'MockValueObject'; | ||
this.value = value; | ||
@@ -12,0 +11,0 @@ } |
import { Nominative } from '@jamashita/anden-type'; | ||
export declare abstract class Objet<N extends string = string> implements Nominative<N> { | ||
abstract readonly noun: N; | ||
export declare abstract class Objet implements Nominative { | ||
static identify(n: unknown): string; | ||
protected constructor(); | ||
abstract equals(other: unknown): boolean; | ||
hashCode(): number; | ||
abstract serialize(): string; | ||
hashCode(): number; | ||
toString(): string; | ||
@@ -10,0 +9,0 @@ protected hashor<T>(value: T): T | number; |
import { Objet } from './Objet'; | ||
export declare abstract class ValueObject<N extends string = string> extends Objet<N> { | ||
export declare abstract class ValueObject extends Objet { | ||
private code?; | ||
hashCode(): number; | ||
abstract serialize(): string; | ||
hashCode(): number; | ||
} | ||
//# sourceMappingURL=ValueObject.d.ts.map |
import { Cloneable } from '@jamashita/anden-type'; | ||
import { Objet } from './Objet'; | ||
export declare abstract class Entity<I, T extends Entity<I, T, N>, N extends string = string> extends Objet<N> implements Cloneable<T> { | ||
export declare abstract class Entity<I, T extends Entity<I, T>> extends Objet implements Cloneable<T> { | ||
abstract getIdentifier(): I; | ||
abstract duplicate(): T; | ||
abstract serialize(): string; | ||
equals(other: unknown): boolean; | ||
hashCode(): number; | ||
abstract serialize(): string; | ||
} | ||
//# sourceMappingURL=Entity.d.ts.map |
import { RuntimeError } from '@jamashita/anden-error'; | ||
export declare class RecursiveReferenceError extends RuntimeError<'RecursiveReferenceError'> { | ||
readonly noun: 'RecursiveReferenceError'; | ||
export declare class RecursiveReferenceError extends RuntimeError { | ||
constructor(message: string, cause?: Error); | ||
} | ||
//# sourceMappingURL=RecursiveReferenceError.d.ts.map |
@@ -5,5 +5,4 @@ import { RuntimeError } from '@jamashita/anden-error'; | ||
super(message, cause); | ||
this.noun = 'RecursiveReferenceError'; | ||
} | ||
} | ||
//# sourceMappingURL=RecursiveReferenceError.js.map |
import { ObjectLiteral } from '@jamashita/anden-type'; | ||
import { Entity } from '../Entity'; | ||
export declare class MockEntity<V> extends Entity<V, MockEntity<V>, 'MockEntity'> { | ||
readonly noun: 'MockEntity'; | ||
export declare class MockEntity<V> extends Entity<V, MockEntity<V>> { | ||
private readonly id; | ||
@@ -6,0 +5,0 @@ private other; |
@@ -6,3 +6,2 @@ import { Entity } from '../Entity'; | ||
super(); | ||
this.noun = 'MockEntity'; | ||
this.id = id; | ||
@@ -9,0 +8,0 @@ this.other = other; |
import { ValueObject } from '../ValueObject'; | ||
export declare class MockValueObject<V> extends ValueObject<'MockValueObject'> { | ||
readonly noun: 'MockValueObject'; | ||
export declare class MockValueObject<V> extends ValueObject { | ||
private readonly value; | ||
@@ -5,0 +4,0 @@ constructor(value: V); |
@@ -6,3 +6,2 @@ import { Objet } from '../Objet'; | ||
super(); | ||
this.noun = 'MockValueObject'; | ||
this.value = value; | ||
@@ -9,0 +8,0 @@ } |
import { Nominative } from '@jamashita/anden-type'; | ||
export declare abstract class Objet<N extends string = string> implements Nominative<N> { | ||
abstract readonly noun: N; | ||
export declare abstract class Objet implements Nominative { | ||
static identify(n: unknown): string; | ||
protected constructor(); | ||
abstract equals(other: unknown): boolean; | ||
hashCode(): number; | ||
abstract serialize(): string; | ||
hashCode(): number; | ||
toString(): string; | ||
@@ -10,0 +9,0 @@ protected hashor<T>(value: T): T | number; |
import { Objet } from './Objet'; | ||
export declare abstract class ValueObject<N extends string = string> extends Objet<N> { | ||
export declare abstract class ValueObject extends Objet { | ||
private code?; | ||
hashCode(): number; | ||
abstract serialize(): string; | ||
hashCode(): number; | ||
} | ||
//# sourceMappingURL=ValueObject.d.ts.map |
{ | ||
"name": "@jamashita/anden-object", | ||
"version": "2.3.0", | ||
"version": "2.4.0", | ||
"private": false, | ||
@@ -29,4 +29,4 @@ "repository": { | ||
"dependencies": { | ||
"@jamashita/anden-error": "^2.1.1", | ||
"@jamashita/anden-type": "^2.1.2", | ||
"@jamashita/anden-error": "^2.2.0", | ||
"@jamashita/anden-type": "^2.2.0", | ||
"hash-it": "5.0.2" | ||
@@ -33,0 +33,0 @@ }, |
@@ -7,4 +7,2 @@ import { MockEntity } from '../Mock/MockEntity'; | ||
it('returns true when the same instance given', () => { | ||
expect.assertions(1); | ||
const vo: MockValueObject<boolean> = new MockValueObject<boolean>(true); | ||
@@ -18,4 +16,2 @@ | ||
it('returns false when the different class instance given', () => { | ||
expect.assertions(1); | ||
const vo: MockValueObject<boolean> = new MockValueObject<boolean>(true); | ||
@@ -29,4 +25,2 @@ | ||
it('returns true when the ids equal', () => { | ||
expect.assertions(2); | ||
const vo1: MockValueObject<boolean> = new MockValueObject<boolean>(true); | ||
@@ -47,4 +41,2 @@ const vo2: MockValueObject<boolean> = new MockValueObject<boolean>(false); | ||
it('returns same value of the hashCode of id', () => { | ||
expect.assertions(1); | ||
const vo: MockValueObject<undefined> = new MockValueObject<undefined>(undefined); | ||
@@ -58,4 +50,2 @@ | ||
it('only depends on the id value, even if the other values are changed, returns same hashCode', () => { | ||
expect.assertions(2); | ||
const vo: MockValueObject<null> = new MockValueObject<null>(null); | ||
@@ -62,0 +52,0 @@ |
@@ -8,4 +8,2 @@ import { asyncRandom, sequence } from '@jamashita/anden-helper'; | ||
it('describes undefined', () => { | ||
expect.assertions(1); | ||
expect(Objet.identify(undefined)).toBe('undefined'); | ||
@@ -15,4 +13,2 @@ }); | ||
it('describes null', () => { | ||
expect.assertions(1); | ||
expect(Objet.identify(null)).toBe('null'); | ||
@@ -22,4 +18,2 @@ }); | ||
it('describes boolean', () => { | ||
expect.assertions(2); | ||
expect(Objet.identify(false)).toBe('false'); | ||
@@ -30,4 +24,2 @@ expect(Objet.identify(true)).toBe('true'); | ||
it('describes number', () => { | ||
expect.assertions(201); | ||
for (let i: number = -100; i <= 100; i++) { | ||
@@ -39,4 +31,2 @@ expect(Objet.identify(i)).toBe(`${i}`); | ||
it('describes string', () => { | ||
expect.assertions(100); | ||
const dones: Array<Promise<void>> = sequence(100).map<Promise<void>>(async () => { | ||
@@ -52,4 +42,2 @@ const str: string = await asyncRandom(40); | ||
it('describes symbol', () => { | ||
expect.assertions(100); | ||
const dones: Array<Promise<void>> = sequence(100).map<Promise<void>>(async () => { | ||
@@ -65,4 +53,2 @@ const sym: symbol = Symbol(await asyncRandom(40)); | ||
it('describes bigint', () => { | ||
expect.assertions(201); | ||
for (let i: bigint = -100n; i <= 100n; i++) { | ||
@@ -74,4 +60,2 @@ expect(Objet.identify(i)).toBe(`${i}`); | ||
it('describes object literal', async () => { | ||
expect.assertions(2); | ||
expect(Objet.identify({})).toBe('[object Object]'); | ||
@@ -82,3 +66,3 @@ | ||
const dones: Array<Promise<void>> = sequence(100).map<Promise<void>>(async (i: number) => { | ||
const [key, value]: [string, string] = await Promise.all<string, string>([ | ||
const [key, value]: Array<string> = await Promise.all<string>([ | ||
asyncRandom(i), | ||
@@ -88,3 +72,4 @@ asyncRandom(i) | ||
obj[key] = value; | ||
// eslint-disable-next-line @typescript-eslint/no-non-null-assertion | ||
obj[key!] = value; | ||
}); | ||
@@ -98,4 +83,2 @@ | ||
it('describes object.create(null)', async () => { | ||
expect.assertions(2); | ||
expect(Objet.identify(Object.create(null))).toBe('[object Object]'); | ||
@@ -106,3 +89,3 @@ | ||
const dones: Array<Promise<void>> = sequence(100).map<Promise<void>>(async (i: number) => { | ||
const [key, value]: [string, string] = await Promise.all<string, string>([ | ||
const [key, value]: Array<string> = await Promise.all<string>([ | ||
asyncRandom(i), | ||
@@ -112,3 +95,4 @@ asyncRandom(i) | ||
obj[key] = value; | ||
// eslint-disable-next-line @typescript-eslint/no-non-null-assertion | ||
obj[key!] = value; | ||
}); | ||
@@ -122,4 +106,2 @@ | ||
it('returns itself when it has toString()', () => { | ||
expect.assertions(100); | ||
const dones: Array<Promise<void>> = sequence(100).map<Promise<void>>(async () => { | ||
@@ -126,0 +108,0 @@ const str: string = await asyncRandom(40); |
@@ -7,4 +7,2 @@ import { PlainObject, PlainObjectItem } from '@jamashita/anden-type'; | ||
it('returns false if given objects do not have recursive reference', () => { | ||
expect.assertions(18); | ||
expect(Reference.isCircular({})).toBe(false); | ||
@@ -96,4 +94,2 @@ expect( | ||
it('returns true if objects have recursive references', () => { | ||
expect.assertions(6); | ||
const obj1: PlainObject = { | ||
@@ -100,0 +96,0 @@ a: 'noi' |
@@ -5,3 +5,3 @@ import { Cloneable, Kind } from '@jamashita/anden-type'; | ||
export abstract class Entity<I, T extends Entity<I, T, N>, N extends string = string> extends Objet<N> implements Cloneable<T> { | ||
export abstract class Entity<I, T extends Entity<I, T>> extends Objet implements Cloneable<T> { | ||
public abstract getIdentifier(): I; | ||
@@ -11,4 +11,2 @@ | ||
public abstract override serialize(): string; | ||
public equals(other: unknown): boolean { | ||
@@ -37,2 +35,4 @@ if (this === other) { | ||
} | ||
public abstract override serialize(): string; | ||
} |
import { RuntimeError } from '@jamashita/anden-error'; | ||
export class RecursiveReferenceError extends RuntimeError<'RecursiveReferenceError'> { | ||
public readonly noun: 'RecursiveReferenceError' = 'RecursiveReferenceError'; | ||
export class RecursiveReferenceError extends RuntimeError { | ||
public constructor(message: string, cause?: Error) { | ||
@@ -7,0 +5,0 @@ super(message, cause); |
@@ -5,4 +5,3 @@ import { ObjectLiteral } from '@jamashita/anden-type'; | ||
export class MockEntity<V> extends Entity<V, MockEntity<V>, 'MockEntity'> { | ||
public readonly noun: 'MockEntity' = 'MockEntity'; | ||
export class MockEntity<V> extends Entity<V, MockEntity<V>> { | ||
private readonly id: V; | ||
@@ -9,0 +8,0 @@ private other: ObjectLiteral; |
import { Objet } from '../Objet'; | ||
import { ValueObject } from '../ValueObject'; | ||
export class MockValueObject<V> extends ValueObject<'MockValueObject'> { | ||
public readonly noun: 'MockValueObject' = 'MockValueObject'; | ||
export class MockValueObject<V> extends ValueObject { | ||
private readonly value: V; | ||
@@ -7,0 +6,0 @@ |
import { isNominative, Kind, Nominative } from '@jamashita/anden-type'; | ||
import hash from 'hash-it'; | ||
export abstract class Objet<N extends string = string> implements Nominative<N> { | ||
public abstract readonly noun: N; | ||
export abstract class Objet implements Nominative { | ||
public static identify(n: unknown): string { | ||
@@ -25,4 +23,2 @@ if (Kind.isObject<Object>(n)) { | ||
public abstract serialize(): string; | ||
public hashCode(): number { | ||
@@ -32,2 +28,3 @@ return hash(this); | ||
public abstract serialize(): string; | ||
@@ -34,0 +31,0 @@ public toString(): string { |
import { Kind } from '@jamashita/anden-type'; | ||
import { Objet } from './Objet'; | ||
export abstract class ValueObject<N extends string = string> extends Objet<N> { | ||
export abstract class ValueObject extends Objet { | ||
private code?: number; | ||
public abstract override serialize(): string; | ||
public override hashCode(): number { | ||
@@ -18,2 +16,4 @@ if (!Kind.isUndefined(this.code)) { | ||
} | ||
public abstract override serialize(): string; | ||
} |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
92758
895