uni-types 1.5.0 → 1.7.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +335 -1
- package/dist/index.d.cts +12307 -4377
- package/dist/index.d.mts +12307 -4377
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -18,7 +18,7 @@ A comprehensive collection of type helpers for TypeScript development
|
|
|
18
18
|
|
|
19
19
|
## Features
|
|
20
20
|
|
|
21
|
-
- 🎯 **
|
|
21
|
+
- 🎯 **700+ Type Utilities** - Comprehensive type helpers for every use case
|
|
22
22
|
- 🔒 **Type Safe** - Full TypeScript support with strict type checking
|
|
23
23
|
- 📦 **Zero Dependencies** - Lightweight and tree-shakeable
|
|
24
24
|
- 🚀 **TypeScript 5.x** - Built with the latest TypeScript features
|
|
@@ -704,6 +704,340 @@ type Result = If<true, 'success', 'error'> // 'success'
|
|
|
704
704
|
| `BPMNGateway<T>` | BPMN gateway |
|
|
705
705
|
| `BPMNEvent<T>` | BPMN event |
|
|
706
706
|
|
|
707
|
+
### AI/ML Types *(v1.6.0)*
|
|
708
|
+
|
|
709
|
+
| Type | Description |
|
|
710
|
+
|------|-------------|
|
|
711
|
+
| `Tensor<Shape, DType>` | Tensor with shape and data type |
|
|
712
|
+
| `TensorShape` | Tensor shape type |
|
|
713
|
+
| `TensorDType` | Tensor data types (float32, int32, etc.) |
|
|
714
|
+
| `Model<Input, Output>` | Model type |
|
|
715
|
+
| `ModelConfig<T>` | Model configuration |
|
|
716
|
+
| `Layer<T>` | Neural network layer |
|
|
717
|
+
| `LayerType` | Layer types (dense, conv2d, lstm, etc.) |
|
|
718
|
+
| `Optimizer` | Optimizer types (adam, sgd, rmsprop) |
|
|
719
|
+
| `LossFunction` | Loss functions (mse, crossentropy) |
|
|
720
|
+
| `MLMetric` | ML metrics (accuracy, precision, recall) |
|
|
721
|
+
| `Dataset<T>` | Dataset type |
|
|
722
|
+
| `DataLoader<T>` | Data loader type |
|
|
723
|
+
| `Batch<T>` | Batch type |
|
|
724
|
+
| `InferenceResult<T>` | Inference result |
|
|
725
|
+
| `Prediction<T>` | Prediction result |
|
|
726
|
+
|
|
727
|
+
### Functional Programming *(v1.6.0)*
|
|
728
|
+
|
|
729
|
+
| Type | Description |
|
|
730
|
+
|------|-------------|
|
|
731
|
+
| `Functor<T>` | Functor type |
|
|
732
|
+
| `Monad<T>` | Monad type |
|
|
733
|
+
| `Applicative<T>` | Applicative type |
|
|
734
|
+
| `Maybe<T>` | Maybe monad (Some/None) |
|
|
735
|
+
| `Either<L, R>` | Either monad (Left/Right) |
|
|
736
|
+
| `IO<T>` | IO monad |
|
|
737
|
+
| `Reader<R, T>` | Reader monad |
|
|
738
|
+
| `Writer<W, T>` | Writer monad |
|
|
739
|
+
| `State<S, T>` | State monad |
|
|
740
|
+
| `Result<T, E>` | Result type (Ok/Err) |
|
|
741
|
+
| `Lens<S, A>` | Lens for deep access |
|
|
742
|
+
| `Semigroup<T>` | Semigroup type |
|
|
743
|
+
| `Monoid<T>` | Monoid type |
|
|
744
|
+
| `Compose` | Function composition |
|
|
745
|
+
| `Pipe` | Pipeline composition |
|
|
746
|
+
| `Curry` | Curried function |
|
|
747
|
+
|
|
748
|
+
### Type-Level Compiler *(v1.6.0)*
|
|
749
|
+
|
|
750
|
+
| Type | Description |
|
|
751
|
+
|------|-------------|
|
|
752
|
+
| `ASTNode<T>` | AST node type |
|
|
753
|
+
| `ASTNodeType` | AST node types |
|
|
754
|
+
| `Token<T>` | Token type |
|
|
755
|
+
| `TokenType` | Token types (keyword, identifier, etc.) |
|
|
756
|
+
| `Parser<T>` | Parser type |
|
|
757
|
+
| `ParserResult<T>` | Parser result |
|
|
758
|
+
| `CodeGenerator<T>` | Code generator |
|
|
759
|
+
| `GeneratedCode` | Generated code type |
|
|
760
|
+
| `Transformer<T>` | AST transformer |
|
|
761
|
+
| `Formatter` | Code formatter |
|
|
762
|
+
|
|
763
|
+
### Distributed Systems *(v1.6.0)*
|
|
764
|
+
|
|
765
|
+
| Type | Description |
|
|
766
|
+
|------|-------------|
|
|
767
|
+
| `Consensus<T>` | Consensus protocol |
|
|
768
|
+
| `ConsensusState` | Consensus states (leader, follower, candidate) |
|
|
769
|
+
| `Replica<T>` | Replica type |
|
|
770
|
+
| `ReplicationStrategy` | Replication strategies (sync, async) |
|
|
771
|
+
| `Partition<T>` | Partition type |
|
|
772
|
+
| `PartitionStrategy` | Partition strategies (hash, range) |
|
|
773
|
+
| `ConsistencyLevel` | Consistency levels (strong, eventual) |
|
|
774
|
+
| `DistributedLock<T>` | Distributed lock |
|
|
775
|
+
| `TwoPhaseCommit<T>` | Two-phase commit protocol |
|
|
776
|
+
| `TransactionState` | Transaction states |
|
|
777
|
+
| `FailureDetector<T>` | Failure detector |
|
|
778
|
+
| `Heartbeat<T>` | Heartbeat type |
|
|
779
|
+
|
|
780
|
+
### Security Types *(v1.6.0)*
|
|
781
|
+
|
|
782
|
+
| Type | Description |
|
|
783
|
+
|------|-------------|
|
|
784
|
+
| `Authentication<T>` | Authentication configuration |
|
|
785
|
+
| `AuthType` | Auth types (bearer, jwt, oauth2) |
|
|
786
|
+
| `AuthStatus` | Auth status (authenticated, failed) |
|
|
787
|
+
| `Session<T>` | Session type |
|
|
788
|
+
| `Encryption<T>` | Encryption configuration |
|
|
789
|
+
| `EncryptionAlgorithm` | Encryption algorithms |
|
|
790
|
+
| `Hash<T>` | Hash type |
|
|
791
|
+
| `HashAlgorithm` | Hash algorithms (sha256, blake3) |
|
|
792
|
+
| `Signature<T>` | Signature type |
|
|
793
|
+
| `SignatureAlgorithm` | Signature algorithms |
|
|
794
|
+
| `JWT<T>` | JWT token type |
|
|
795
|
+
| `OAuthToken` | OAuth token |
|
|
796
|
+
| `CSRFToken` | CSRF token |
|
|
797
|
+
|
|
798
|
+
### Internationalization *(v1.6.0)*
|
|
799
|
+
|
|
800
|
+
| Type | Description |
|
|
801
|
+
|------|-------------|
|
|
802
|
+
| `Locale` | Locale configuration |
|
|
803
|
+
| `LocaleCode` | Locale codes (en-US, zh-CN, etc.) |
|
|
804
|
+
| `LanguageCode` | Language codes |
|
|
805
|
+
| `CountryCode` | Country codes |
|
|
806
|
+
| `Translation<T>` | Translation mapping |
|
|
807
|
+
| `PluralForm` | Plural forms (one, many, etc.) |
|
|
808
|
+
| `Currency` | Currency types (USD, EUR, CNY) |
|
|
809
|
+
| `TimeZone` | Time zone types |
|
|
810
|
+
| `DateFormat` | Date format configuration |
|
|
811
|
+
| `NumberFormat` | Number format configuration |
|
|
812
|
+
| `Direction` | Text direction (ltr, rtl) |
|
|
813
|
+
|
|
814
|
+
### Testing Framework *(v1.6.0)*
|
|
815
|
+
|
|
816
|
+
| Type | Description |
|
|
817
|
+
|------|-------------|
|
|
818
|
+
| `TestSuite<T>` | Test suite type |
|
|
819
|
+
| `TestCase<T>` | Test case type |
|
|
820
|
+
| `TestResultType` | Test result (passed, failed, skipped) |
|
|
821
|
+
| `Assertion<T>` | Assertion type |
|
|
822
|
+
| `Mock<T>` | Mock type |
|
|
823
|
+
| `Spy<T>` | Spy type |
|
|
824
|
+
| `Fixture<T>` | Fixture type |
|
|
825
|
+
| `Coverage` | Coverage configuration |
|
|
826
|
+
| `CoverageReport<T>` | Coverage report |
|
|
827
|
+
| `Snapshot<T>` | Snapshot type |
|
|
828
|
+
| `Benchmark<T>` | Benchmark type |
|
|
829
|
+
| `BenchmarkResult<T>` | Benchmark result |
|
|
830
|
+
|
|
831
|
+
### Plugin System *(v1.6.0)*
|
|
832
|
+
|
|
833
|
+
| Type | Description |
|
|
834
|
+
|------|-------------|
|
|
835
|
+
| `Plugin<T>` | Plugin type |
|
|
836
|
+
| `PluginLifecycle` | Plugin lifecycle events |
|
|
837
|
+
| `Hook<T>` | Hook type |
|
|
838
|
+
| `HookResult<T>` | Hook result |
|
|
839
|
+
| `Extension<T>` | Extension type |
|
|
840
|
+
| `ExtensionPoint<T>` | Extension point |
|
|
841
|
+
| `Middleware<T>` | Middleware type |
|
|
842
|
+
| `MiddlewarePipeline<T>` | Middleware pipeline |
|
|
843
|
+
| `Module<T>` | Module type |
|
|
844
|
+
| `Registry<T>` | Registry type |
|
|
845
|
+
|
|
846
|
+
### Type Inference *(v1.6.0)*
|
|
847
|
+
|
|
848
|
+
| Type | Description |
|
|
849
|
+
|------|-------------|
|
|
850
|
+
| `Infer<T>` | Extract type from wrapper |
|
|
851
|
+
| `InferReturn<T>` | Extract return type |
|
|
852
|
+
| `InferArgs<T>` | Extract function arguments |
|
|
853
|
+
| `ExtractFunction<T>` | Extract function type |
|
|
854
|
+
| `ExtractClass<T>` | Extract class type |
|
|
855
|
+
| `Reconstruct<T>` | Reconstruct type |
|
|
856
|
+
| `Narrow<T>` | Narrow type with predicate |
|
|
857
|
+
| `Widen<T>` | Widen literal to primitive |
|
|
858
|
+
| `IsAny<T>` | Check if type is any |
|
|
859
|
+
| `IsNever<T>` | Check if type is never |
|
|
860
|
+
| `IsUnknown<T>` | Check if type is unknown |
|
|
861
|
+
| `IsFunction<T>` | Check if type is function |
|
|
862
|
+
| `IsArray<T>` | Check if type is array |
|
|
863
|
+
| `IsUnion<T>` | Check if type is union |
|
|
864
|
+
| `Equals<X, Y>` | Check type equality |
|
|
865
|
+
| `TypeName<T>` | Get type name |
|
|
866
|
+
| `TypeCategory` | Type category |
|
|
867
|
+
|
|
868
|
+
### Performance Monitoring *(v1.6.0)*
|
|
869
|
+
|
|
870
|
+
| Type | Description |
|
|
871
|
+
|------|-------------|
|
|
872
|
+
| `Performance` | Performance monitoring |
|
|
873
|
+
| `PerformanceMetric<T>` | Performance metric |
|
|
874
|
+
| `Timing` | Timing operations |
|
|
875
|
+
| `TimingResult` | Timing result |
|
|
876
|
+
| `MemoryUsage` | Memory usage type |
|
|
877
|
+
| `MemoryMetric<T>` | Memory metric |
|
|
878
|
+
| `CPUUsage` | CPU usage type |
|
|
879
|
+
| `Profiler` | Profiler type |
|
|
880
|
+
| `ProfileResult<T>` | Profile result |
|
|
881
|
+
| `TraceSpan<T>` | Tracing span |
|
|
882
|
+
| `PerformanceTrace<T>` | Performance trace |
|
|
883
|
+
| `PerformanceAlert` | Performance alert |
|
|
884
|
+
|
|
885
|
+
### Metaprogramming *(v1.7.0)*
|
|
886
|
+
|
|
887
|
+
| Type | Description |
|
|
888
|
+
|------|-------------|
|
|
889
|
+
| `MetaType<T>` | Meta type wrapper |
|
|
890
|
+
| `TypeRepr<T>` | Type representation |
|
|
891
|
+
| `GetType<T>` | Extract type from meta |
|
|
892
|
+
| `HasType<T, U>` | Check if type has nested type |
|
|
893
|
+
| `TypePath<T>` | Path to nested type |
|
|
894
|
+
| `TypeDepth<T>` | Maximum nesting depth |
|
|
895
|
+
| `TypeSize<T>` | Type size estimation |
|
|
896
|
+
| `TypeComplexity<T>` | Type complexity score |
|
|
897
|
+
| `AnalyzeType<T>` | Full type analysis |
|
|
898
|
+
| `TypeStats<T>` | Type statistics |
|
|
899
|
+
|
|
900
|
+
### Decorator Types *(v1.7.0)*
|
|
901
|
+
|
|
902
|
+
| Type | Description |
|
|
903
|
+
|------|-------------|
|
|
904
|
+
| `ClassDecorator<T>` | Class decorator type |
|
|
905
|
+
| `MethodDecorator<T>` | Method decorator type |
|
|
906
|
+
| `PropertyDecorator<T>` | Property decorator type |
|
|
907
|
+
| `ParameterDecorator<T>` | Parameter decorator type |
|
|
908
|
+
| `DecoratorResult<T>` | Decorator result type |
|
|
909
|
+
| `DecoratorMetadata<T>` | Decorator metadata |
|
|
910
|
+
| `DecoratorChain<T>` | Decorator chain |
|
|
911
|
+
| `ComposableDecorator<T>` | Composable decorator |
|
|
912
|
+
|
|
913
|
+
### Type Generation *(v1.7.0)*
|
|
914
|
+
|
|
915
|
+
| Type | Description |
|
|
916
|
+
|------|-------------|
|
|
917
|
+
| `GenerateType<T>` | Generate type from schema |
|
|
918
|
+
| `GeneratedType<T>` | Generated type result |
|
|
919
|
+
| `TypeBuilder<T>` | Type builder interface |
|
|
920
|
+
| `SchemaToType<S>` | Convert schema to type |
|
|
921
|
+
| `TypeFromSchema<T, S>` | Type from schema definition |
|
|
922
|
+
| `GeneratedClass<T>` | Generated class type |
|
|
923
|
+
| `GeneratedInterface<T>` | Generated interface |
|
|
924
|
+
| `GeneratedEnum<T>` | Generated enum type |
|
|
925
|
+
|
|
926
|
+
### Framework Types *(v1.7.0)*
|
|
927
|
+
|
|
928
|
+
| Type | Description |
|
|
929
|
+
|------|-------------|
|
|
930
|
+
| `NestModule<T>` | NestJS module type |
|
|
931
|
+
| `NestController<T>` | NestJS controller type |
|
|
932
|
+
| `NestService<T>` | NestJS service type |
|
|
933
|
+
| `ExpressApp<T>` | Express app type |
|
|
934
|
+
| `ExpressRouter<T>` | Express router type |
|
|
935
|
+
| `ExpressMiddleware<T>` | Express middleware |
|
|
936
|
+
| `FastifyApp<T>` | Fastify app type |
|
|
937
|
+
| `FastifyPlugin<T>` | Fastify plugin type |
|
|
938
|
+
| `KoaApp<T>` | Koa app type |
|
|
939
|
+
| `KoaMiddleware<T>` | Koa middleware type |
|
|
940
|
+
|
|
941
|
+
### TypeSafe Config *(v1.7.0)*
|
|
942
|
+
|
|
943
|
+
| Type | Description |
|
|
944
|
+
|------|-------------|
|
|
945
|
+
| `SafeConfig<T>` | Type-safe configuration |
|
|
946
|
+
| `ConfigDefinition<T>` | Config definition |
|
|
947
|
+
| `ConfigValue<T, K>` | Typed config value |
|
|
948
|
+
| `ConfigSchema<T>` | Config schema type |
|
|
949
|
+
| `EnvDefinition<T>` | Environment definition |
|
|
950
|
+
| `EnvValue<K>` | Environment variable value |
|
|
951
|
+
| `ConfigPath<T>` | Config path type |
|
|
952
|
+
| `ValidateConfig<T>` | Config validation type |
|
|
953
|
+
| `MergeConfig<A, B>` | Merge configurations |
|
|
954
|
+
| `DeepConfig<T>` | Deep config type |
|
|
955
|
+
|
|
956
|
+
### Type Visualization *(v1.7.0)*
|
|
957
|
+
|
|
958
|
+
| Type | Description |
|
|
959
|
+
|------|-------------|
|
|
960
|
+
| `VisualizeType<T>` | Visualize type structure |
|
|
961
|
+
| `TypeDiagram<T>` | Type diagram representation |
|
|
962
|
+
| `TypeTree<T>` | Type tree visualization |
|
|
963
|
+
| `PrintType<T>` | Printable type string |
|
|
964
|
+
| `TypeFormat<T>` | Type formatting options |
|
|
965
|
+
| `TypeName<T>` | Extract type name |
|
|
966
|
+
| `TypeStructure<T>` | Type structure info |
|
|
967
|
+
| `ExpandType<T>` | Expanded type display |
|
|
968
|
+
|
|
969
|
+
### Crypto Types *(v1.7.0)*
|
|
970
|
+
|
|
971
|
+
| Type | Description |
|
|
972
|
+
|------|-------------|
|
|
973
|
+
| `HashAlgorithm` | Hash algorithm types |
|
|
974
|
+
| `HashOutput<L>` | Hash output type |
|
|
975
|
+
| `CryptoKey<T>` | Cryptographic key type |
|
|
976
|
+
| `KeyPair<T>` | Key pair type |
|
|
977
|
+
| `Signature<T>` | Signature type |
|
|
978
|
+
| `EncryptedData<T>` | Encrypted data type |
|
|
979
|
+
| `CryptoConfig<T>` | Crypto configuration |
|
|
980
|
+
| `CryptoProvider<T>` | Crypto provider interface |
|
|
981
|
+
| `HashFunction<T>` | Hash function type |
|
|
982
|
+
| `EncryptFunction<T>` | Encryption function |
|
|
983
|
+
| `DecryptFunction<T>` | Decryption function |
|
|
984
|
+
|
|
985
|
+
### Date/Time Types *(v1.7.0)*
|
|
986
|
+
|
|
987
|
+
| Type | Description |
|
|
988
|
+
|------|-------------|
|
|
989
|
+
| `DateTime<T>` | DateTime type |
|
|
990
|
+
| `DateFormat<T>` | Date format type |
|
|
991
|
+
| `TimeFormat<T>` | Time format type |
|
|
992
|
+
| `Timestamp<T>` | Timestamp type |
|
|
993
|
+
| `Duration<T>` | Duration type |
|
|
994
|
+
| `DateRange<T>` | Date range type |
|
|
995
|
+
| `TimeZoneType` | Time zone type |
|
|
996
|
+
| `UTCDate<T>` | UTC date type |
|
|
997
|
+
| `LocalDate<T>` | Local date type |
|
|
998
|
+
| `ISODateString` | ISO date string |
|
|
999
|
+
| `ParsedDate<T>` | Parsed date type |
|
|
1000
|
+
| `FormatDate<T, F>` | Formatted date type |
|
|
1001
|
+
|
|
1002
|
+
### Advanced Math *(v1.7.0)*
|
|
1003
|
+
|
|
1004
|
+
| Type | Description |
|
|
1005
|
+
|------|-------------|
|
|
1006
|
+
| `Add<A, B>` | Type-level addition |
|
|
1007
|
+
| `Subtract<A, B>` | Type-level subtraction |
|
|
1008
|
+
| `Multiply<A, B>` | Type-level multiplication |
|
|
1009
|
+
| `Divide<A, B>` | Type-level division |
|
|
1010
|
+
| `Power<A, B>` | Power operation |
|
|
1011
|
+
| `Sqrt<N>` | Square root |
|
|
1012
|
+
| `Sin<N>`, `Cos<N>` | Trigonometric functions |
|
|
1013
|
+
| `PI`, `E` | Math constants |
|
|
1014
|
+
| `Factorial<N>` | Factorial |
|
|
1015
|
+
| `Fibonacci<N>` | Fibonacci number |
|
|
1016
|
+
| `IsPrime<N>` | Prime check |
|
|
1017
|
+
| `Mean<T>`, `Median<T>` | Statistical functions |
|
|
1018
|
+
| `IsEven<N>`, `IsOdd<N>` | Even/Odd check |
|
|
1019
|
+
|
|
1020
|
+
### Type-Level Search *(v1.7.0)*
|
|
1021
|
+
|
|
1022
|
+
| Type | Description |
|
|
1023
|
+
|------|-------------|
|
|
1024
|
+
| `Sort<T, Order>` | Sort tuple |
|
|
1025
|
+
| `QuickSort<T>` | Quick sort algorithm |
|
|
1026
|
+
| `MergeSort<T>` | Merge sort algorithm |
|
|
1027
|
+
| `BinarySearch<T, V>` | Binary search |
|
|
1028
|
+
| `Includes<T, V>` | Check inclusion |
|
|
1029
|
+
| `Filter<T, P>` | Filter by predicate |
|
|
1030
|
+
| `Take<T, N>` | Take first N elements |
|
|
1031
|
+
| `Drop<T, N>` | Drop first N elements |
|
|
1032
|
+
| `Chunk<T, N>` | Chunk into sublists |
|
|
1033
|
+
| `Union<A, B>` | Set union |
|
|
1034
|
+
| `Intersection<A, B>` | Set intersection |
|
|
1035
|
+
| `Unique<T>` | Unique elements |
|
|
1036
|
+
| `Reverse<T>` | Reverse tuple |
|
|
1037
|
+
| `Zip<A, B>` | Zip tuples |
|
|
1038
|
+
| `Flatten<T>` | Flatten nested tuples |
|
|
1039
|
+
| `MinElement<T>`, `MaxElement<T>` | Min/Max element |
|
|
1040
|
+
|
|
707
1041
|
## Examples
|
|
708
1042
|
|
|
709
1043
|
```typescript
|