ngx-transforms 0.3.0 → 0.3.2

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 CHANGED
@@ -1,101 +1,76 @@
1
1
  # ngx-transforms
2
2
 
3
- [![npm version](https://img.shields.io/npm/v/ngx-transforms.svg)](https://www.npmjs.com/package/ngx-transforms)
4
- [![License: MIT](https://img.shields.io/badge/License-MIT-yellow.svg)](https://opensource.org/licenses/MIT)
5
- [![Angular](https://img.shields.io/badge/Angular-21+-dd0031.svg)](https://angular.dev)
3
+ [![npm](https://img.shields.io/npm/v/ngx-transforms.svg)](https://www.npmjs.com/package/ngx-transforms)
4
+ [![Angular](https://img.shields.io/badge/Angular-17+-dd0031.svg)](https://angular.dev)
5
+ [![gzip](https://img.shields.io/badge/gzip-28_KB-success.svg)](#bundle-size)
6
+ [![License](https://img.shields.io/badge/License-MIT-yellow.svg)](https://opensource.org/licenses/MIT)
6
7
 
7
- A collection of **standalone Angular pipes** for common data transformations such as text formatting, masking, encoding, sanitization, and more.
8
+ > 90 standalone, tree-shakable Angular pipes for text, arrays, math, objects, and more.
8
9
 
9
- ## Installation
10
+ **[Docs & live playground →](https://ngx-transforms.vercel.app)**
10
11
 
11
- ```bash
12
- npm install ngx-transforms
13
- ```
12
+ ---
14
13
 
15
- ### Peer Dependencies
16
-
17
- This library requires Angular 17+:
14
+ ## Install
18
15
 
19
16
  ```bash
20
- npm install @angular/core @angular/platform-browser
17
+ npm install ngx-transforms
21
18
  ```
22
19
 
23
- ## Quick Start
20
+ ## Use
24
21
 
25
- All pipes are **standalone** and are tree-shakable, so import only what you need directly into your component:
26
-
27
- ```typescript
22
+ ```ts
28
23
  import { Component } from '@angular/core';
29
- import { CamelCasePipe, ReversePipe } from 'ngx-transforms';
24
+ import { TruncatePipe, TimeAgoPipe } from 'ngx-transforms';
30
25
 
31
26
  @Component({
32
- selector: 'app-example',
33
27
  standalone: true,
34
- imports: [CamelCasePipe, ReversePipe],
28
+ imports: [TruncatePipe, TimeAgoPipe],
35
29
  template: `
36
- <p>{{ 'hello world' | camelCase }}</p> <!-- helloWorld -->
37
- <p>{{ 'angular' | reverse }}</p> <!-- ralunga -->
30
+ <p>{{ post.body | truncate:80 }}</p>
31
+ <small>{{ post.createdAt | timeAgo }}</small>
38
32
  `,
39
33
  })
40
- export class ExampleComponent {}
34
+ export class PostCard {}
41
35
  ```
42
36
 
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 }}` &rarr; `helloWorld` |
50
- | `KebabCasePipe` | `kebabCase` | Converts text to kebab-case | `{{ 'hello world' \| kebabCase }}` &rarr; `hello-world` |
51
- | `SnakeCasePipe` | `snakeCase` | Converts text to snake_case | `{{ 'hello world' \| snakeCase }}` &rarr; `hello_world` |
52
- | `TitleCasePipe` | `titleCase` | Capitalizes first letter of each word | `{{ 'hello world' \| titleCase }}` &rarr; `Hello World` |
53
- | `ReversePipe` | `reverse` | Reverses characters in a string | `{{ 'hello' \| reverse }}` &rarr; `olleh` |
54
- | `TruncatePipe` | `truncate` | Truncates text to a max length | `{{ 'long text here' \| truncate:8 }}` &rarr; `long tex...` |
55
- | `InitialsPipe` | `initials` | Extracts initials from a name | `{{ 'John Doe' \| initials }}` &rarr; `JD` |
56
- | `CountPipe` | `count` | Counts elements in arrays, strings, or object keys | `{{ [1,2,3] \| count }}` &rarr; `3` |
37
+ Every pipe is standalone meaning you import only what you use, the rest is tree-shaken.
57
38
 
58
- ### Data Masking
39
+ ## What's inside
59
40
 
60
- | Pipe | Template Name | Description | Example |
61
- |------|--------------|-------------|---------|
62
- | `CreditCardMaskPipe` | `creditCardMask` | Masks all but last 4 digits | `{{ '4111111111111111' \| creditCardMask }}` &rarr; `************1111` |
63
- | `EmailMaskPipe` | `emailMask` | Masks the local part of an email | `{{ 'john@example.com' \| emailMask }}` &rarr; `j***n@example.com` |
64
- | `IpAddressMaskPipe` | `ipAddressMask` | Masks last two octets of IPv4 | `{{ '192.168.1.1' \| ipAddressMask }}` &rarr; `192.168.*.*` |
41
+ | Category | Count | Examples |
42
+ | ------------ | ----- | -------------------------------------------------------------- |
43
+ | **Text** | 27 | `truncate`, `slugify`, `latinize`, `template`, `wrap` |
44
+ | **Array** | 20 | `groupBy`, `orderBy`, `unique`, `chunk`, `intersection` |
45
+ | **Math** | 13 | `min`, `max`, `sum`, `average`, `bytes`, `percentage` |
46
+ | **Object** | 8 | `keys`, `pairs`, `pick`, `omit`, `invert`, `diffObj` |
47
+ | **Boolean** | 8 | `isDefined`, `isString`, `isArray`, `isObject`, `isEmpty` |
48
+ | **Data** | 5 | `count`, `timeAgo`, `jsonPretty`, `device`, `textToSpeech` |
49
+ | **Security** | 5 | `htmlSanitize`, `creditCardMask`, `emailMask`, `ipAddressMask` |
50
+ | **Media** | 4 | `qrCode`, `barcode`, `gravatar`, `colorConvert` |
65
51
 
66
- ### Encoding & Generation
52
+ Full API reference at **[ngx-transforms.vercel.app](https://ngx-transforms.vercel.app)**.
67
53
 
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 }}` &rarr; `... --- ...` |
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' }}` &rarr; `rgb(255, 0, 0)` |
54
+ ## Bundle size
76
55
 
77
- ### HTML & Security
56
+ The complete library includes all 90 pipes, and it is **27.9 KB gzipped** / **23.3 KB brotli**. What you actually ship is much smaller, because Angular's CLI tree-shakes any pipe you don't import.
78
57
 
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 }}` &rarr; `&lt;b&gt;bold&lt;/b&gt;` |
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' }}` &rarr; `hola` |
58
+ | Measure | Size |
59
+ | -------------------- | -------- |
60
+ | FESM bundle (raw) | 169 KB |
61
+ | FESM bundle (gzip) | 27.9 KB |
62
+ | FESM bundle (brotli) | 23.3 KB |
86
63
 
87
- ### Device & Browser
88
-
89
- | Pipe | Template Name | Description | Example |
90
- |------|--------------|-------------|---------|
91
- | `DeviceTypePipe` | `device` | Detects device type (mobile/tablet/desktop) | `{{ '' \| device }}` &rarr; `desktop` |
92
- | `TextToSpeechPipe` | `textToSpeech` | Speaks text using the Web Speech API | `<button (click)="speak('Hello' \| textToSpeech)">` |
64
+ ```ts
65
+ // Only TruncatePipe and its transitive imports lands in your bundle.
66
+ import { TruncatePipe } from 'ngx-transforms';
67
+ ```
93
68
 
94
- ## Provide All Pipes
69
+ A handful of pipes pull their own dependencies — `qrCode` (qrcode), `barcode` (jsbarcode), `gravatar` (js-md5), `asciiArt` (ts-ascii-engine). If you skip those, the rest of the library is pure standalone-pipe code.
95
70
 
96
- To make all pipes available via dependency injection:
71
+ ## Provide all at once
97
72
 
98
- ```typescript
73
+ ```ts
99
74
  import { ALL_PIPES } from 'ngx-transforms';
100
75
 
101
76
  bootstrapApplication(AppComponent, {
@@ -103,12 +78,10 @@ bootstrapApplication(AppComponent, {
103
78
  });
104
79
  ```
105
80
 
106
- ## Angular Compatibility
81
+ ## Compatibility
107
82
 
108
- | ngx-transforms | Angular |
109
- |----------|---------|
110
- | 0.0.x | 17+ |
83
+ Supports **Angular 17–21**. Pipes use only the stable standalone-pipe API.
111
84
 
112
85
  ## License
113
86
 
114
- [MIT](./LICENSE) - Mofiro Jean
87
+ MIT © [Mofiro Jean](https://github.com/mofirojean)