
A lightweight TypeScript library for wrapped property descriptor.
- Installation
- Api
- Abstract
PlainWrappedDescriptorBase
WrappedDescriptorBase
WrappedDescriptorCore
- Class
PlainWrappedDescriptor
WrappedDescriptor
- Abstract
- Contributing
- Support
- Code of Conduct
- Git
- License
- Related packages
npm install @typescript-package/descriptor --save-peer
npm install @typescript-package/wrapped-descriptor --save-peer
import {
// Abstract.
PlainWrappedDescriptorBase,
WrappedDescriptorBase,
WrappedDescriptorCore,
// Class.
PlainWrappedDescriptor,
WrappedDescriptor,
} from '@typescript-package/wrapped-descriptor';
import { WrappedDescriptor } from '@typescript-package/wrapped-descriptor';
export class Person {
public age = 27;
name = 'Someone';
work = 'Gig';
_age = 37;
_firstName = 'John';
}
// Initialize `Person`.
const person = new Person();
// Wrap the `age`.
const firstWrap = new WrappedDescriptor(person, 'age', {
active: true as boolean,
onGet: (key, previousValue, value) => (
console.debug(`#1. Get value: ${value} for key: ${key}`, previousValue),
value
),
onSet: (value, previousValue, key) => (
console.debug(`#1. Set value: ${value}`, previousValue, key),
value
),
previousDescriptor: Object.getOwnPropertyDescriptor(person, 'age'),
});
Your contributions are valued! If you'd like to contribute, please feel free to submit a pull request. Help is always appreciated.
If you find this package useful and would like to support its and general development, you can contribute through one of the following payment methods. Your support helps maintain the packages and continue adding new.
Support via:
or via Trust Wallet
By participating in this project, you agree to follow Code of Conduct.
Please follow the following commit message conventions:
The package follows Semantic Versioning 2.0.0 for all releases. The versioning format is:
Given a version number MAJOR.MINOR.PATCH, increment the:
- MAJOR version when you make incompatible API changes,
- MINOR version when you add functionality in a backwards-compatible manner, and
- PATCH version when you make backwards-compatible bug fixes.
Additional labels for pre-release and build metadata are available as extensions to the MAJOR.MINOR.PATCH format.
FAQ How should I deal with revisions in the 0.y.z initial development phase?
The simplest thing to do is start your initial development release at 0.1.0 and then increment the minor version for each subsequent release.
How do I know when to release 1.0.0?
If your software is being used in production, it should probably already be 1.0.0. If you have a stable API on which users have come to depend, you should be 1.0.0. If you’re worrying a lot about backwards compatibility, you should probably already be 1.0.0.
MIT © typescript-package (license)
- @typescript-package/chain-descriptor: A TypeScript library for chain property descriptor.
- @typescript-package/controller: A TypeScript package with for various kind of controllers.
- @typescript-package/descriptor: A TypeScript library for property descriptor.
- @typescript-package/descriptor-chain: A TypeScript library for property descriptor chain.
- @typescript-package/descriptors: A TypeScript library for property descriptors.
- @typescript-package/property: A TypeScript package with features to handle object properties.
- @typescript-package/wrap-descriptor: A TypeScript package for wrapping object descriptors.
- @typescript-package/wrap-property: A TypeScript package for wrapping object properties.
- @xtypescript/property - A comprehensive, reactive TypeScript library for precise and extensible object property control.