ngx-transforms 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/LICENSE +21 -0
- package/README.md +114 -0
- package/fesm2022/ngx-transforms.mjs +1245 -0
- package/fesm2022/ngx-transforms.mjs.map +1 -0
- package/package.json +53 -0
- package/types/ngx-transforms.d.ts +658 -0
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2025-present Mofiro Jean
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
package/README.md
ADDED
|
@@ -0,0 +1,114 @@
|
|
|
1
|
+
# ngx-transforms
|
|
2
|
+
|
|
3
|
+
[](https://www.npmjs.com/package/ngx-transforms)
|
|
4
|
+
[](https://opensource.org/licenses/MIT)
|
|
5
|
+
[](https://angular.dev)
|
|
6
|
+
|
|
7
|
+
A collection of **standalone Angular pipes** for common data transformations such as text formatting, masking, encoding, sanitization, and more.
|
|
8
|
+
|
|
9
|
+
## Installation
|
|
10
|
+
|
|
11
|
+
```bash
|
|
12
|
+
npm install ngx-transforms
|
|
13
|
+
```
|
|
14
|
+
|
|
15
|
+
### Peer Dependencies
|
|
16
|
+
|
|
17
|
+
This library requires Angular 17+:
|
|
18
|
+
|
|
19
|
+
```bash
|
|
20
|
+
npm install @angular/core @angular/platform-browser
|
|
21
|
+
```
|
|
22
|
+
|
|
23
|
+
## Quick Start
|
|
24
|
+
|
|
25
|
+
All pipes are **standalone** and are tree-shakable, so import only what you need directly into your component:
|
|
26
|
+
|
|
27
|
+
```typescript
|
|
28
|
+
import { Component } from '@angular/core';
|
|
29
|
+
import { CamelCasePipe, ReversePipe } from 'ngx-transforms';
|
|
30
|
+
|
|
31
|
+
@Component({
|
|
32
|
+
selector: 'app-example',
|
|
33
|
+
standalone: true,
|
|
34
|
+
imports: [CamelCasePipe, ReversePipe],
|
|
35
|
+
template: `
|
|
36
|
+
<p>{{ 'hello world' | camelCase }}</p> <!-- helloWorld -->
|
|
37
|
+
<p>{{ 'angular' | reverse }}</p> <!-- ralunga -->
|
|
38
|
+
`,
|
|
39
|
+
})
|
|
40
|
+
export class ExampleComponent {}
|
|
41
|
+
```
|
|
42
|
+
|
|
43
|
+
## Available Pipes
|
|
44
|
+
|
|
45
|
+
### Text Transformation
|
|
46
|
+
|
|
47
|
+
| Pipe | Template Name | Description | Example |
|
|
48
|
+
|------|--------------|-------------|---------|
|
|
49
|
+
| `CamelCasePipe` | `camelCase` | Converts text to camelCase | `{{ 'hello world' \| camelCase }}` → `helloWorld` |
|
|
50
|
+
| `KebabCasePipe` | `kebabCase` | Converts text to kebab-case | `{{ 'hello world' \| kebabCase }}` → `hello-world` |
|
|
51
|
+
| `SnakeCasePipe` | `snakeCase` | Converts text to snake_case | `{{ 'hello world' \| snakeCase }}` → `hello_world` |
|
|
52
|
+
| `TitleCasePipe` | `titleCase` | Capitalizes first letter of each word | `{{ 'hello world' \| titleCase }}` → `Hello World` |
|
|
53
|
+
| `ReversePipe` | `reverse` | Reverses characters in a string | `{{ 'hello' \| reverse }}` → `olleh` |
|
|
54
|
+
| `TruncatePipe` | `truncate` | Truncates text to a max length | `{{ 'long text here' \| truncate:8 }}` → `long tex...` |
|
|
55
|
+
| `InitialsPipe` | `initials` | Extracts initials from a name | `{{ 'John Doe' \| initials }}` → `JD` |
|
|
56
|
+
| `CountPipe` | `count` | Counts elements in arrays, strings, or object keys | `{{ [1,2,3] \| count }}` → `3` |
|
|
57
|
+
|
|
58
|
+
### Data Masking
|
|
59
|
+
|
|
60
|
+
| Pipe | Template Name | Description | Example |
|
|
61
|
+
|------|--------------|-------------|---------|
|
|
62
|
+
| `CreditCardMaskPipe` | `creditCardMask` | Masks all but last 4 digits | `{{ '4111111111111111' \| creditCardMask }}` → `************1111` |
|
|
63
|
+
| `EmailMaskPipe` | `emailMask` | Masks the local part of an email | `{{ 'john@example.com' \| emailMask }}` → `j***n@example.com` |
|
|
64
|
+
| `IpAddressMaskPipe` | `ipAddressMask` | Masks last two octets of IPv4 | `{{ '192.168.1.1' \| ipAddressMask }}` → `192.168.*.*` |
|
|
65
|
+
|
|
66
|
+
### Encoding & Generation
|
|
67
|
+
|
|
68
|
+
| Pipe | Template Name | Description | Example |
|
|
69
|
+
|------|--------------|-------------|---------|
|
|
70
|
+
| `QrCodePipe` | `qrCode` | Generates a QR code data URL | `<img [src]="'data' \| qrCode \| async" />` |
|
|
71
|
+
| `BarcodePipe` | `barcode` | Generates a barcode (SVG/img/canvas) | `<div [innerHTML]="'123' \| barcode \| async"></div>` |
|
|
72
|
+
| `MorseCodePipe` | `morseCode` | Converts text to Morse code | `{{ 'SOS' \| morseCode }}` → `... --- ...` |
|
|
73
|
+
| `AsciiArtPipe` | `asciiArt` | Converts text to ASCII art | `{{ 'HI' \| asciiArt }}` |
|
|
74
|
+
| `GravatarPipe` | `gravatar` | Generates Gravatar URL from email | `<img [src]="email \| gravatar:100" />` |
|
|
75
|
+
| `ColorConvertPipe` | `colorConvert` | Converts colors between HEX, RGB, RGBA | `{{ '#FF0000' \| colorConvert:'rgb' }}` → `rgb(255, 0, 0)` |
|
|
76
|
+
|
|
77
|
+
### HTML & Security
|
|
78
|
+
|
|
79
|
+
| Pipe | Template Name | Description | Example |
|
|
80
|
+
|------|--------------|-------------|---------|
|
|
81
|
+
| `HtmlSanitizePipe` | `htmlSanitize` | Sanitizes HTML, removing unsafe elements | `<div [innerHTML]="html \| htmlSanitize"></div>` |
|
|
82
|
+
| `HtmlEscapePipe` | `htmlEscape` | Escapes HTML special characters | `{{ '<b>bold</b>' \| htmlEscape }}` → `<b>bold</b>` |
|
|
83
|
+
| `HighlightPipe` | `highlight` | Highlights search term matches in text | `<span [innerHTML]="text \| highlight:'term'"></span>` |
|
|
84
|
+
| `JsonPrettyPipe` | `jsonPretty` | Formats JSON with syntax highlighting | `<pre [innerHTML]="data \| jsonPretty"></pre>` |
|
|
85
|
+
| `ReplacePipe` | `replace` | Replaces or highlights text by pattern | `{{ 'hello' \| replace:'ello':'ola' }}` → `hola` |
|
|
86
|
+
|
|
87
|
+
### Device & Browser
|
|
88
|
+
|
|
89
|
+
| Pipe | Template Name | Description | Example |
|
|
90
|
+
|------|--------------|-------------|---------|
|
|
91
|
+
| `DeviceTypePipe` | `device` | Detects device type (mobile/tablet/desktop) | `{{ '' \| device }}` → `desktop` |
|
|
92
|
+
| `TextToSpeechPipe` | `textToSpeech` | Speaks text using the Web Speech API | `<button (click)="speak('Hello' \| textToSpeech)">` |
|
|
93
|
+
|
|
94
|
+
## Provide All Pipes
|
|
95
|
+
|
|
96
|
+
To make all pipes available via dependency injection:
|
|
97
|
+
|
|
98
|
+
```typescript
|
|
99
|
+
import { ALL_PIPES } from 'ngx-transforms';
|
|
100
|
+
|
|
101
|
+
bootstrapApplication(AppComponent, {
|
|
102
|
+
providers: [ALL_PIPES],
|
|
103
|
+
});
|
|
104
|
+
```
|
|
105
|
+
|
|
106
|
+
## Angular Compatibility
|
|
107
|
+
|
|
108
|
+
| ngx-transforms | Angular |
|
|
109
|
+
|----------|---------|
|
|
110
|
+
| 0.0.x | 17+ |
|
|
111
|
+
|
|
112
|
+
## License
|
|
113
|
+
|
|
114
|
+
[MIT](./LICENSE) - Mofiro Jean
|