diff --git a/spec/lazy-types/polymorphism-abstract-class.spec.ts b/spec/lazy-types/polymorphism-abstract-class.spec.ts index fb8b317..4744671 100644 --- a/spec/lazy-types/polymorphism-abstract-class.spec.ts +++ b/spec/lazy-types/polymorphism-abstract-class.spec.ts @@ -1,8 +1,8 @@ -import {jsonArrayMember, jsonMember, jsonObject, jsonObjectInheritance, TypedJSON} from '../../src'; +import {jsonArrayMember, jsonInheritance, jsonMember, jsonObject, TypedJSON} from '../../src'; import {isEqual} from '../utils/object-compare'; describe('lazy, polymorphic abstract classes', () => { - @jsonObjectInheritance({ + @jsonInheritance({ resolveType: data => { if ('inputType' in data) { return SmallNode; diff --git a/spec/lazy-types/polymorphism-custom-names.spec.ts b/spec/lazy-types/polymorphism-custom-names.spec.ts index d948106..16c5926 100644 --- a/spec/lazy-types/polymorphism-custom-names.spec.ts +++ b/spec/lazy-types/polymorphism-custom-names.spec.ts @@ -1,8 +1,8 @@ -import {jsonArrayMember, jsonMember, jsonObject, jsonObjectInheritance, TypedJSON} from '../../src'; +import {jsonArrayMember, jsonInheritance, jsonMember, jsonObject, TypedJSON} from '../../src'; import {isEqual} from '../utils/object-compare'; describe('lazy, polymorphic custom names', () => { - @jsonObjectInheritance({ + @jsonInheritance({ resolveType: data => { if ('invest-amount' in data) { return Investor; @@ -27,7 +27,7 @@ describe('lazy, polymorphic custom names', () => { } } - @jsonObjectInheritance({ + @jsonInheritance({ resolveType: data => { if ('work-hours' in data) { return PartTimeEmployee; diff --git a/spec/lazy-types/polymorphism-nested-arrays.spec.ts b/spec/lazy-types/polymorphism-nested-arrays.spec.ts index c5c6a4c..f507782 100644 --- a/spec/lazy-types/polymorphism-nested-arrays.spec.ts +++ b/spec/lazy-types/polymorphism-nested-arrays.spec.ts @@ -1,8 +1,8 @@ -import {jsonArrayMember, jsonMember, jsonObject, jsonObjectInheritance, TypedJSON} from '../../src'; +import {jsonArrayMember, jsonInheritance, jsonMember, jsonObject, TypedJSON} from '../../src'; import {isEqual} from '../utils/object-compare'; describe('lazy, polymorphism in nested arrays', () => { - @jsonObjectInheritance({ + @jsonInheritance({ resolveType: data => { if ('inputType' in data) { return SmallNode; diff --git a/spec/lazy-types/polymorphism.spec.ts b/spec/lazy-types/polymorphism.spec.ts index 20a405f..a95362c 100644 --- a/spec/lazy-types/polymorphism.spec.ts +++ b/spec/lazy-types/polymorphism.spec.ts @@ -1,8 +1,8 @@ -import {jsonArrayMember, jsonMember, jsonObject, jsonObjectInheritance, TypedJSON} from '../../src'; +import {jsonArrayMember, jsonInheritance, jsonMember, jsonObject, TypedJSON} from '../../src'; import {isEqual} from '../utils/object-compare'; describe('lazy, polymorphism', () => { - @jsonObjectInheritance({ + @jsonInheritance({ resolveType: data => { if ('investAmount' in data) { return Investor; diff --git a/spec/polymorphism-abstract-class.spec.ts b/spec/polymorphism-abstract-class.spec.ts index b9c8544..5ac067a 100644 --- a/spec/polymorphism-abstract-class.spec.ts +++ b/spec/polymorphism-abstract-class.spec.ts @@ -1,8 +1,8 @@ -import {jsonArrayMember, jsonMember, jsonObject, jsonObjectInheritance, TypedJSON} from '../src'; +import {jsonArrayMember, jsonInheritance, jsonMember, jsonObject, TypedJSON} from '../src'; import {isEqual} from './utils/object-compare'; describe('polymorphic abstract classes', () => { - @jsonObjectInheritance({ + @jsonInheritance({ resolveType: data => { if ('inputType' in data) { return SmallNode; diff --git a/spec/polymorphism-custom-names.spec.ts b/spec/polymorphism-custom-names.spec.ts index 2c36a23..9478b0c 100644 --- a/spec/polymorphism-custom-names.spec.ts +++ b/spec/polymorphism-custom-names.spec.ts @@ -1,8 +1,8 @@ -import {jsonArrayMember, jsonMember, jsonObject, jsonObjectInheritance, TypedJSON} from '../src'; +import {jsonArrayMember, jsonInheritance, jsonMember, jsonObject, TypedJSON} from '../src'; import {isEqual} from './utils/object-compare'; describe('polymorphic custom names', () => { - @jsonObjectInheritance({ + @jsonInheritance({ resolveType: data => { if ('invest-amount' in data) { return Investor; @@ -27,7 +27,7 @@ describe('polymorphic custom names', () => { } } - @jsonObjectInheritance({ + @jsonInheritance({ resolveType: data => { if ('work-hours' in data) { return PartTimeEmployee; diff --git a/spec/polymorphism-nested-arrays.spec.ts b/spec/polymorphism-nested-arrays.spec.ts index 76f2e80..3487bd0 100644 --- a/spec/polymorphism-nested-arrays.spec.ts +++ b/spec/polymorphism-nested-arrays.spec.ts @@ -1,8 +1,8 @@ -import {jsonArrayMember, jsonMember, jsonObject, jsonObjectInheritance, TypedJSON} from '../src'; +import {jsonArrayMember, jsonInheritance, jsonMember, jsonObject, TypedJSON} from '../src'; import {isEqual} from './utils/object-compare'; describe('polymorphism in nested arrays', () => { - @jsonObjectInheritance({ + @jsonInheritance({ resolveType: data => { if ('inputType' in data) { return SmallNode; diff --git a/spec/polymorphism-root-abstract-class.spec.ts b/spec/polymorphism-root-abstract-class.spec.ts index d932dab..1fff393 100644 --- a/spec/polymorphism-root-abstract-class.spec.ts +++ b/spec/polymorphism-root-abstract-class.spec.ts @@ -1,7 +1,7 @@ -import {jsonMember, jsonObject, jsonObjectInheritance, TypedJSON} from '../src'; +import {jsonArrayMember, jsonInheritance, jsonMember, jsonObject, TypedJSON} from '../src'; describe('single class', () => { - @jsonObjectInheritance({ + @jsonInheritance({ resolveType: data => { return Bob; }, diff --git a/spec/polymorphism.spec.ts b/spec/polymorphism.spec.ts index 352a838..52f9ef8 100644 --- a/spec/polymorphism.spec.ts +++ b/spec/polymorphism.spec.ts @@ -1,8 +1,8 @@ -import {jsonArrayMember, jsonMember, jsonObject, jsonObjectInheritance, TypedJSON} from '../src'; +import {jsonArrayMember, jsonInheritance, jsonMember, jsonObject, TypedJSON} from '../src'; import {isEqual} from './utils/object-compare'; describe('polymorphism', () => { - @jsonObjectInheritance({ + @jsonInheritance({ resolveType: data => { if ('investAmount' in data) { return Investor; @@ -29,7 +29,7 @@ describe('polymorphism', () => { } } - @jsonObjectInheritance({ + @jsonInheritance({ resolveType: data => { if ('workHours' in data) { return PartTimeEmployee; diff --git a/src/index.ts b/src/index.ts index 0b4e65f..4d77742 100644 --- a/src/index.ts +++ b/src/index.ts @@ -13,7 +13,7 @@ export { } from './json-object'; export {jsonMember, IJsonMemberOptions} from './json-member'; export {jsonArrayMember, IJsonArrayMemberOptions} from './json-array-member'; -export {jsonObjectInheritance} from './json-object-inheritance'; +export {jsonInheritance} from './json-inheritance'; export {jsonSetMember, IJsonSetMemberOptions} from './json-set-member'; export {jsonMapMember, IJsonMapMemberOptions} from './json-map-member'; export {toJson, IToJsonOptions} from './to-json'; diff --git a/src/json-object-inheritance.ts b/src/json-inheritance.ts similarity index 86% rename from src/json-object-inheritance.ts rename to src/json-inheritance.ts index 2d4b7a7..18d328b 100644 --- a/src/json-object-inheritance.ts +++ b/src/json-inheritance.ts @@ -9,7 +9,7 @@ export interface ObjectInheritanceOptions { resolveType: (type: any) => Serializable | undefined; } -export function jsonObjectInheritance(options: ObjectInheritanceOptions) { +export function jsonInheritance(options: ObjectInheritanceOptions) { return (target: Serializable) => { const objectMetadata = JsonObjectMetadata.ensurePresentInPrototype(target.prototype);