@typedly/data-traits
v2.0.0
Published
A TypeScript type definitions package for configurable data traits, providing various kinds of configurable data interfaces.
Maintainers
Readme
@typedly/data-traits
A TypeScript type definitions package for configurable data traits, providing various kinds of configurable data interfaces.
Features
- Adaptable: Use custom adapters to define how data is stored and retrieved (localStorage, API, memory, etc.)
- Cacheable: Built-in caching support with configurable expiration and refresh capabilities
- Cleanable: Clear data, and cleanup resources
- Cloneable: Create deep, or shallow copies of data instances
- Collection: Base collection shape
- Comparable: Compare data instances for equality and ordering
- Compressible: Compress and decompress data
- Configurable: Flexible configuration system for customizing data behavior and constraints
- Encryptable: Encrypt and decrypt sensitive data with built-in security support
- Exportable: Export data to multiple formats (JSON, XML, CSV, etc.)
- Freezable: Control immutability by freezing and unfreezing data instances
- Identifiable: Identify data object by tag or
ID - Indexable: Access and manage data elements by numeric or key-based indices
- Measurable: Track data size, memory usage, and performance metrics
- Mergeable: Merge data from multiple sources with customizable merge strategies
- Observable: Subscribe to data changes with reactive programming support
- Paginated: Navigate large datasets with page-based chunking and iteration
- Persistable: Persist data to storage automatically with save/load capabilities
- Printable: Format and output data in human-readable formats for display or debugging
- Queryable: Query and filter complex data structures with predicate functions
- Resettable: Reset data to initial state and track modifications
- Revertible: Undo changes and revert to previous states with rollback support
- Serializable: Serialize and deserialize data values with async support
- Timestamped: Automatic tracking of creation, modification, and access times
- Transformable: Transform values with
mapandflatMapoperations - Traversable: Adds required iterable iterator, and optional async iterable iterator
- Validatable: Comprehensive validation system with custom validators and error reporting
- Versionable: Version control with history tracking, snapshots, and rollback support
Table of contents
Related packages
- @typedly/adaptable-data: A TypeScript type definitions for data adapter.
- @typedly/collection: A TypeScript type definitions package for data collections with customizable storage.
- @typedly/configurable-data: A TypeScript type definitions for configurable data.
- @typedly/data-adapter: A TypeScript type definitions for data adapter.
- @typedly/data: A TypeScript type definitions for
@typescript-package/data. - @typescript-package/data: A lightweight TypeScript library for basic data management.
- @typescript-package/collection: A lightweight TypeScript library for data collection.
Installation
npm install @typedly/data-traits --save-peerApi
import {
// Interface.
Adaptable,
Cacheable,
Collection,
Comparable,
Compressible,
Configurable,
Encryptable,
Exportable,
Freezable,
Identifiable,
Indexable,
Measurable,
Mergeable,
Observable,
Paginated,
Persistable,
Printable,
Queryable,
Resettable,
Revertible,
Serializable,
Timestamped,
Transformable,
Traversable,
Validatable,
Versionable,
} from '@typedly/data-traits';Interface
Adaptable
The interface for adaptable data types, which can optionally use a data adapter to manage their value and behavior.
import { Adaptable } from '@typedly/data-traits';Cacheable
The interface for cacheable data types, which can be cached with an optional expiration time and invalidated or refreshed as needed.
import { Cacheable } from '@typedly/data-traits';Cleanable
Capability for objects that can be cleaned or cleared.
import { Cleanable } from '@typedly/data-traits';Cloneable
Capability for objects that can be cloned.
import { Cloneable } from '@typedly/data-traits';Collection
Comparable interface for data types that can be compared.
import { Collection } from '@typedly/data-traits';Comparable
Comparable interface for data types that can be compared.
import { Comparable } from '@typedly/data-traits';Compressible
Interface for data types that can be compressed and decompressed, allowing for efficient storage and transmission of data.
import { Compressible } from '@typedly/data-traits';Configurable
The interface for configurable data types, which can optionally have a configuration object.
import { Configurable } from '@typedly/data-traits';Encryptable
Interface for data types that can be encrypted and decrypted.
import { Encryptable } from '@typedly/data-traits';Exportable
The interface for exportable data types, which can be exported to various formats.
import { Exportable } from '@typedly/data-traits';Freezable
The interface for freezable data types, which can be frozen to prevent modifications and optionally unfrozen.
import { Freezable } from '@typedly/data-traits';Identifiable
Trait for objects that have an ID or unique identifier.x
import { Identifiable } from '@typedly/data-traits';Indexable
Trait for objects that support indexing or retrieving by numeric or string index.
import { Indexable } from '@typedly/data-traits';Measurable
Interface for data types that can be measured in terms of size and memory usage, allowing for efficient management of resources and optimization of performance.
import { Measurable } from '@typedly/data-traits';Mergeable
The interface for mergeable data types, which can be combined with other instances of the same type using a defined strategy.
import { Mergeable } from '@typedly/data-traits';Observable
The interface for observable data types, which allow subscribers to be notified of changes to their value.
import { Observable } from '@typedly/data-traits';Paginated
Trait for objects that support pagination.
import { Paginated } from '@typedly/data-traits';Persistable
Trait for objects that can be persisted and restored.
import { Persistable } from '@typedly/data-traits';Printable
Trait for objects that can be printed as a string or in a formatted way.
import { Printable } from '@typedly/data-traits';Queryable
Interfaces for data types that can be queried using a defined query format, allowing for flexible and efficient retrieval of information based on specific criteria.
import { Queryable } from '@typedly/data-traits';Resettable
Interface for data types that can be reset to an initial value and track if they have been modified (dirty state).
import { Resettable } from '@typedly/data-traits';Revertible
Trait for objects that can revert or undo changes.
import { Revertible } from '@typedly/data-traits';Serializable
Serializable interface for data types that can be serialized and deserialized.
import { Serializable } from '@typedly/data-traits';Timestamped
Interface representing timestamped data.
import { Timestamped } from '@typedly/data-traits';Transformable
Transformable interface for data types that can be transformed.
import { Transformable } from '@typedly/data-traits';Traversable
Capability for objects that can be traversed/iterated.
import { Traversable } from '@typedly/data-traits';Validatable
Interface for data types that can be validated with custom rules and track validation errors.
import { Validatable } from '@typedly/data-traits';Versionable
The interface for versionable data types, which maintain a history of changes and can revert to previous versions.
import { Versionable } from '@typedly/data-traits';Contributing
Your contributions are valued! If you'd like to contribute, please feel free to submit a pull request. Help is always appreciated.
Support
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
Thanks for your support!
Code of Conduct
By participating in this project, you agree to follow Code of Conduct.
GIT
Commit
Versioning
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.
License
MIT © typedly (license)
Packages
- @typedly/array: A TypeScript type definitions package to handle array-related operations.
- @typedly/callback: A TypeScript type definitions package for asynchronous and synchronous callback functions of various types.
- @typedly/character: A TypeScript type definitions package for various character types.
- @typedly/context: A TypeScript type definitions package for context data structures.
- @typedly/descriptor: A TypeScript type definitions package for property descriptor.
- @typedly/digit: A TypeScript type definitions package for digit types.
- @typedly/letter: A TypeScript type definitions package for handling letter types.
- @typedly/object: A TypeScript type definitions package to handle object-related operations.
- @typedly/payload: A TypeScript type definitions package for payload data structures.
- @typedly/property: A TypeScript type definitions package to handle object property-related operations.
- @typedly/regexp: A TypeScript type definitions package for
RegExp. - @typedly/symbol: A TypeScript type definitions package for various symbols.
