Gathering detailed insights and metrics for @ngodings/ngx-pipes
Gathering detailed insights and metrics for @ngodings/ngx-pipes
Gathering detailed insights and metrics for @ngodings/ngx-pipes
Gathering detailed insights and metrics for @ngodings/ngx-pipes
npm install @ngodings/ngx-pipes
Typescript
Module System
Node Version
NPM Version
TypeScript (65.31%)
SCSS (28.52%)
HTML (6.1%)
JavaScript (0.07%)
Total Downloads
0
Last Day
0
Last Week
0
Last Month
0
Last Year
0
MIT License
3 Stars
68 Commits
1 Watchers
2 Branches
1 Contributors
Updated on Aug 31, 2024
Latest Version
15.0.9
Package Id
@ngodings/ngx-pipes@15.0.9
Unpacked Size
240.93 kB
Size
46.91 kB
File Count
55
NPM Version
9.2.0
Node Version
19.3.0
Cumulative downloads
Total Downloads
Last Day
0%
NaN
Compared to previous day
Last Week
0%
NaN
Compared to previous week
Last Month
0%
NaN
Compared to previous month
Last Year
0%
NaN
Compared to previous year
1
2
Useful pipes for Angular with no external dependencies with Latest Angular
https://npm.ngodings.com/packages/ngx-pipes
If you like this package I will be happy that you support me on Buy me a coffee :)
Buy me coffee: https://www.buymeacoffee.com/alidihaw
Indonesia People: https://sociabuzz.com/dihaw
Install the package by command:
1 npm install @ngodings/ngx-pipes --save
Import the module
1npm install @ngodings/ngx-pipes --save
imports
the NgxPipesModule
in order to add all of the pipes, Or add a specific module such as NgxArrayPipesModule
, NgxStringPipesModule
, NgxMathPipesModule
1import {NgxPipesModule} from '@ngodings/ngx-pipes'; 2 3@NgModule({ 4 // ... 5 imports: [ 6 // ... 7 NgxPipesModule 8 ] 9})
1import {ReversePipe} from 'ngx-pipes'; 2 3@Component({ 4 // .. 5 providers: [ReversePipe] 6}) 7export class AppComponent { 8 constructor(private reversePipe: ReversePipe) { 9 this.reversePipe.transform('foo'); // Returns: "oof" 10 } 11 // .. 12}
1<p>{{ 'foo' | reverse }}</p> <!-- Output: "oof" -->
and it's also possible to stack multiple pipes
1<p>{{ 'foo' | titlecase | reverse }}</p> <!-- Output: "Oof" -->
Time ago pipe converts date to 'just now', 'X days ago', 'last week', 'X days ago', etc..
Usage: string | timeAgo
1import * as moment from 'moment'; 2 3const now = new Date(); 4 5// timeAgo also supports moment.js objects 6const lastWeek = moment().subtract(10, 'days');
1<span>Updated: {{now | timeAgo}}</span> <!-- Output: "just now" --> 2<span>Updated: {{lastWeek | timeAgo}}</span> <!-- Output: "last week" -->
Prefixes input string with "a" or "an".
Usage: string | aOrAn
1<span>This is a picture of {{imageDescription | aOrAn}}</span>
Shortening a string by length and providing a custom string to denote an omission
Usage: string | shorten: length: [suffix|optional]: [wordBreak boolean|optional]
1<p>{{'Hey foo bar' | shorten: 3: '...'}}</p> <!-- Output: "Hey..." -->
Uppercase first letter of first word
1<p>{{'foo bar' | firstcase }}</p> <!-- Output: "Foo bar" -->
Uppercase first letter every word
1<p>{{'foo bar' | titlecase }}</p> <!-- Output: "Foo Bar" --> 2<p>{{'shaquille o'neal' | titlecase }}</p> <!-- Output: "Shaquille O'Neal" -->
Wrap a string between a prefix and a suffix
Usage: string | prefixsuffix: prefix: suffix
1<p>{{'Foo' | prefixsuffix: 'nice prefix ': ' and awesome suffix!'}}</p> <!-- Output: "nice prefix Foo and awesome suffix!" -->
Returns an array with range of numbers
Usage: range: [start: number, default = '1']: [count: number]: [step: number | optional, default = '1']
1this.items = this.rangePipe.transform(1, 5); // Returns: [1, 2, 3, 4, 5]
1<li *ngFor="let item of items"> <!-- Array: [1, 2, 3, 4, 5] -->
Reverses an array
Usage: array | reverse
1this.items = [1, 2, 3];
1<li *ngFor="let item of items | reverse"> <!-- Array: [3, 2, 1] -->
Removes duplicates from array
Usage: array | unique: 'Property (Optional)'
1this.items = [1, 2, 3, 1, 2, 3];
1<li *ngFor="let item of items | unique"> <!-- Array: [1, 2, 3] -->
Returns object array of grouped by items by discriminator
Usage: array | filterBy: [prop, nested.prop, ...]: search: [strict | optional]
1this.users = [ 2 {id: 1, first_name: 'John', last_name: 'Doe', work: { company: 'Foo Tech' }}, 3 {id: 2, first_name: 'Jane', last_name: 'West', work: { company: 'AAA Solutions' }}, 4 {id: 3, first_name: 'Bruce', last_name: 'John', work: { company: 'Bar Tech' }}, 5 {id: 4, first_name: 'William', last_name: 'Cent', work: { company: 'Foo Tech' }, arr: [{name: 'foo'}]} 6];
1<!-- Returns users with `id` of 1 --> 2<p>{{ users | filterBy: ['id']: 1 }}</p> 3<!-- Output: "[{id: 1, first_name: 'John', last_name: 'Doe', work: { company: 'Foo Tech', previous_company: '' }}]" --> 4 5<!-- filterBy also support nested properties --> 6<p>{{ users | filterBy: ['work.company']: 'Bar Tech' }}</p> 7<!-- Output: "[{ "id": 3, "first_name": "Bruce", "last_name": "John", "work": { "company": "Bar Tech", "previous_company": "" } }]" --> 8 9<!-- filterBy also support nested properties inside of an array --> 10<p>{{ users | filterBy: ['arr.name']: 'foo' }}</p> 11<!-- Output: "[{id: 4, first_name: 'William', last_name: 'Cent', work: { company: 'Foo Tech' }, arr: [{name: 'foo'}]}]" --> 12 13<!-- Return users whose first name or last name is 'John'. --> 14<p>{{ users | filterBy: ['first_name', 'last_name']: 'John' }}</p> 15<!-- Output: "[{id: 1, first_name: 'John', last_name: 'Doe', work: { company: 'Foo Tech', previous_company: '' }}]" --> 16 17<!-- Return users whose first name or last name is 'John' or 'Cent'. --> 18<p>{{ users | filterBy: ['first_name', 'last_name']: ['John', 'Cent'] }}</p> 19<!-- Output: "[{id: 1, first_name: 'John', last_name: 'Doe', work: { company: 'Foo Tech', previous_company: '' }}, {id: 3, first_name: 'Bruce', last_name: 'John', work: { company: 'Bar Tech' }}, {id: 4, first_name: 'William', last_name: 'Cent', work: { company: 'Foo Tech' }, arr: [{name: 'foo'}]}]" -->
Returns ordered array by configuration
Usage: array | orderBy: [prop, nested.prop, array of props, ...]
1const numbers = [2, 1, 3]; 2 3const obj = [ 4 {id: 4, name: 'Dave', amount: 2}, 5 {id: 2, name: 'Michael', amount: 2}, 6 {id: 3, name: 'Dan', amount: 1}, 7 {id: 1, name: 'John', amount: 1} 8]; 9 10const deepObj = [ 11 {id: 1, name: 'John', amount: 1337, deep: {prop: 4}}, 12 {id: 2, name: 'Michael', amount: 42, deep: {prop: 2}}, 13 {id: 3, name: 'Dan', amount: 1, deep: {prop: 1}}, 14 {id: 4, name: 'Dave', amount: 2, deep: {prop: 3}} 15];
1<!-- Returns array ordered by value --> 2<p>{{ numbers | orderBy }}</p> <!-- Output: [1, 2, 3] --> 3<p>{{ numbers | orderBy: '-' }}</p> <!-- Output: [3, 2, 1] --> 4 5<!-- Returns array ordered by value of property --> 6<p>{{ deepObj | orderBy: 'amount' }}</p> 7<!-- Output: [{id: 3, ...}, {id: 4, ...}, {id: 2, ...}, {id: 1, ...}] --> 8<p>{{ deepObj | orderBy: '-amount' }}</p> 9<!-- Output: [{id: 1, ...}, {id: 2, ...}, {id: 4, ...}, {id: 3, ...}] --> 10 11<!-- Returns array ordered by value of deep property --> 12<p>{{ deepObj | orderBy: 'deep.prop' }}</p> 13<!-- Output: [{id: 3, ...}, {id: 2, ...}, {id: 4, ...}, {id: 1, ...}] --> 14<p>{{ deepObj | orderBy: '-deep.prop' }}</p> 15<!-- Output: [{id: 1, ...}, {id: 4, ...}, {id: 2, ...}, {id: 3, ...}] --> 16 17<!-- Returns array ordered by mutliple properties --> 18<p>{{ obj | orderBy: ['amount', 'id'] }}</p> 19<!-- Output: [{id: 1, ...}, {id: 3, ...}, {id: 2, ...}, {id: 4, ...}] -->
Returns the minimum of a given array
Usage: array | min
1<p>{{ [1, 2, 3, 1, 2, 3] | min }}</p> <!-- Output: "1" -->
Returns the maximum of a given array
Usage: array | max
1<p>{{ [1, 2, 3, 1, 2, 3] | max }}</p> <!-- Output: "3" -->
Returns the sum of a given array
Usage: array | sum
1<p>{{ [1, 2, 3, 4] | sum }}</p> <!-- Output: "10" -->
Returns the average of a given array
Usage: array | average
1<p>{{ [1, 2, 3] | average }}</p> <!-- Output: "2" --> 2<p>{{ [1, 2] | average }}</p> <!-- Output: "1.5" -->
Returns round of a number by precision
Usage: number | precision: [precision | default = 0]
1<p>{{ 42.123 | precision }}</p> <!-- Output: "43" --> 2<p>{{ 42.123 | precision: 2 }}</p> <!-- Output: "42.12" -->
Returns bytes with a unit symbol
Usage: number | bytes: [precision]
1<p>{{ 10 | bytes }}</p> <!-- Output: "10 B" --> 2<p>{{ 1048576 | bytes }}</p> <!-- Output: "1 KB" --> 3<p>{{ 1073741824 | bytes }}</p> <!-- Output: "1 MB" --> 4<p>{{ 1.0995116e12 | bytes }}</p> <!-- Output: "1 GB" -->
npm install
while current directory is this repoMIT @ Ali Abdul Wahid
No vulnerabilities found.
No security vulnerabilities found.