@rt-tools/utils 0.0.1
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 +99 -0
- package/fesm2022/rt-tools-utils.mjs +1567 -0
- package/fesm2022/rt-tools-utils.mjs.map +1 -0
- package/package.json +51 -0
- package/types/rt-tools-utils.d.ts +625 -0
package/README.md
ADDED
|
@@ -0,0 +1,99 @@
|
|
|
1
|
+
# @rt-tools/utils
|
|
2
|
+
|
|
3
|
+
Utility functions, pipes, directives, validators and services for Angular applications.
|
|
4
|
+
|
|
5
|
+
## Installation
|
|
6
|
+
|
|
7
|
+
```bash
|
|
8
|
+
npm install @rt-tools/utils @rt-tools/core
|
|
9
|
+
# or
|
|
10
|
+
pnpm add @rt-tools/utils @rt-tools/core
|
|
11
|
+
```
|
|
12
|
+
|
|
13
|
+
## Features
|
|
14
|
+
|
|
15
|
+
### Functions
|
|
16
|
+
|
|
17
|
+
```typescript
|
|
18
|
+
import { isEqual, isEmpty, isString, isNumber, debounce } from '@rt-tools/utils';
|
|
19
|
+
|
|
20
|
+
// Check equality
|
|
21
|
+
isEqual(obj1, obj2);
|
|
22
|
+
|
|
23
|
+
// Check if value is empty
|
|
24
|
+
isEmpty(value);
|
|
25
|
+
|
|
26
|
+
// Type guards
|
|
27
|
+
isString(value);
|
|
28
|
+
isNumber(value);
|
|
29
|
+
|
|
30
|
+
// Debounce function calls
|
|
31
|
+
const debouncedFn = debounce(() => { /* ... */ }, 300);
|
|
32
|
+
```
|
|
33
|
+
|
|
34
|
+
### Pipes
|
|
35
|
+
|
|
36
|
+
```typescript
|
|
37
|
+
import { BreakStringPipe, SanitizePipe, EqualPipe, TernaryPipe } from '@rt-tools/utils';
|
|
38
|
+
|
|
39
|
+
@Component({
|
|
40
|
+
imports: [BreakStringPipe, SanitizePipe, EqualPipe, TernaryPipe],
|
|
41
|
+
template: `
|
|
42
|
+
{{ 'camelCaseString' | breakString }}
|
|
43
|
+
{{ htmlContent | sanitize }}
|
|
44
|
+
{{ value | equal:compareValue }}
|
|
45
|
+
{{ condition | ternary:'yes':'no' }}
|
|
46
|
+
`
|
|
47
|
+
})
|
|
48
|
+
```
|
|
49
|
+
|
|
50
|
+
### Directives
|
|
51
|
+
|
|
52
|
+
```typescript
|
|
53
|
+
import { RtIconOutlinedDirective, ScrollToElementDirective } from '@rt-tools/utils';
|
|
54
|
+
|
|
55
|
+
@Component({
|
|
56
|
+
imports: [RtIconOutlinedDirective, ScrollToElementDirective],
|
|
57
|
+
template: `
|
|
58
|
+
<mat-icon rtIconOutlined>settings</mat-icon>
|
|
59
|
+
<div rtScrollToElement [scrollTarget]="target"></div>
|
|
60
|
+
`
|
|
61
|
+
})
|
|
62
|
+
```
|
|
63
|
+
|
|
64
|
+
### Services
|
|
65
|
+
|
|
66
|
+
```typescript
|
|
67
|
+
import { BreakpointService, DeviceDetectorService } from '@rt-tools/utils';
|
|
68
|
+
|
|
69
|
+
@Component({ /* ... */ })
|
|
70
|
+
export class MyComponent {
|
|
71
|
+
private breakpointService = inject(BreakpointService);
|
|
72
|
+
private deviceDetector = inject(DeviceDetectorService);
|
|
73
|
+
|
|
74
|
+
isMobile = this.breakpointService.isMobile;
|
|
75
|
+
isDesktop = this.breakpointService.isDesktop;
|
|
76
|
+
}
|
|
77
|
+
```
|
|
78
|
+
|
|
79
|
+
### Providers
|
|
80
|
+
|
|
81
|
+
```typescript
|
|
82
|
+
import { provideRtUtils } from '@rt-tools/utils';
|
|
83
|
+
|
|
84
|
+
bootstrapApplication(RootComponent, {
|
|
85
|
+
providers: [
|
|
86
|
+
provideRtUtils()
|
|
87
|
+
]
|
|
88
|
+
});
|
|
89
|
+
```
|
|
90
|
+
|
|
91
|
+
## Requirements
|
|
92
|
+
|
|
93
|
+
- Angular 21+
|
|
94
|
+
- @rt-tools/core ^0.0.1
|
|
95
|
+
- RxJS 7.8+
|
|
96
|
+
|
|
97
|
+
## License
|
|
98
|
+
|
|
99
|
+
Apache-2.0
|