![Create React App Officially Deprecated Amid React 19 Compatibility Issues](https://cdn.sanity.io/images/cgdhsj6q/production/04fa08cf844d798abc0e1a6391c129363cc7e2ab-1024x1024.webp?w=400&fit=max&auto=format)
Security News
Create React App Officially Deprecated Amid React 19 Compatibility Issues
Create React App is officially deprecated due to React 19 issues and lack of maintenance—developers should switch to Vite or other modern alternatives.
[![Build Status](https://travis-ci.org/danrevah/ng2-pipes.svg?branch=master)](https://travis-ci.org/danrevah/ng2-pipes) [![npm version](https://badge.fury.io/js/ng2-pipes.svg)](https://badge.fury.io/js/ng2-pipes)
Useful pipes for Angular2.
$ npm install ng2-pipes --save
imports
the PipesModuleimport {NgPipesModule} from 'ng2-pipes';
@NgModule({
// ...
imports: [
// ...
NgPipesModule
]
})
Repeats a string n times
Api: string | repeat: times: [separator|optional]
Example:
<p>{{ 'example' | repeat: 3: '@' }}</p> <!-- Output: "example@example@example" -->
Scans string and replace {i}
placeholders by equivalent member of the array
Api: string | scan: [ARRAY]
<p>{{'Hey {0}, {1}' | scan: ['foo', 'bar']}}</p> <!-- Output: "Hey foo, bar" -->
Shortening a string by length and providing a custom string to denote an omission
Api: string | shorten: length: [suffix|optional]: [wordBreak boolean|optional]
<p>{{'Hey foo bar' | shorten: 3: '...'}}</p> <!-- Output: "Hey..." -->
Strips a HTML tags from string and providing which tags should not be removed
Api: string | strip-tags: [ARRAY]
<p>{{'<a href="">foo</a> <p class="foo">bar</p>' | strip-tags }}</p> <!-- Output: "foo bar" -->
<p>{{'<a href="">foo</a> <p class="foo">bar</p>' | strip-tags: ['p']}}</p> <!-- Output: foo <p class="foo">bar</p> -->
Uppercase first letter of first word
<p>{{'foo bar' | ucfirst }}</p> <!-- Output: "Foo bar" -->
Uppercase first letter every word
<p>{{'foo bar' | ucwords }}</p> <!-- Output: "Foo Bar" -->
Strips characters from the beginning and end of a string (default character is space).
Api: string | trim: [characters|optional]
<p>{{' foo ' | trim }}</p> <!-- Output: "foo" -->
<p>{{'foobarfoo' | ltrim: 'foo' }}</p> <!-- Output: "bar" -->
Strips characters from the beginning of a string (default character is space).
Api: string | ltrim: [characters|optional]
<p>{{' foo ' | ltrim }}</p> <!-- Output: "foo " -->
<p>{{'foobarfoo' | ltrim: 'foo' }}</p> <!-- Output: "barfoo" -->
Strips characters from the end of a string (default character is space).
Api: string | rtrim: [characters|optional]
<p>{{' foo ' | rtrim }}</p> <!-- Output: " foo" -->
<p>{{'foobarfoo' | rtrim: 'foo' }}</p> <!-- Output: "foobar" -->
Reverses a string
Api: string | reverse
<p>{{'foo bar' | reverse }}</p> <!-- Output: "rab oof" -->
Returns array of diff between arrays
Api: array | diff: [ARRAY]: [ARRAY]: ... : [ARRAY]
this.items = [1, 2, 3, 4];
<li *ngFor="let item of items | diff: [[1, 2]]"> <-- Array: [3, 4] -->
Flattens nested array, passing shallow will mean it will only be flattened a single level
Api: array | flatten: [shallow|optional]
this.items = [1,2,3,[4,5,6,[7,8,9],[10,11,12,13,[14],[15],[16, [17]]]]];
<li *ngFor="let item of items | flatten">
<-- Array: [1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17] -->
Slicing off the end of the array by n elements
Api: array | initial: n
this.items = [first, second, third];
<li *ngFor="let item of items | initial: 1"> <-- Array: [first, second] -->
Slicing off the start of the array by n elements
Api: array | tail: n
this.items = [first, second, third];
<li *ngFor="let item of items | tail: 1"> <-- Array: [second, third] -->
Returns the intersections of an arrays
Api: array | intersection: [ARRAY]: [ARRAY]: ... : [ARRAY]
this.items = [1, 2, 3, 4, 5];
<li *ngFor="let item of items | intersection: [1, 2]: [3, 6]"> <-- Array: [1, 2, 3] -->
Reverses an array
Api: array | reverse
this.items = [1, 2, 3];
<li *ngFor="let item of items | reverse"> <-- Array: [3, 2, 1] -->
Removes un-truthy values from array
Api: array | truthify
this.items = [null, 1, false, undefined, 2, 0, 3, NaN, 4, ''];
<li *ngFor="let item of items | truthify"> <-- Array: [1, 2, 3, 4] -->
Removes un-truthy values from array
Api: array | union: [ARRAY]
this.items = [1, 2, 3];
<li *ngFor="let item of items | union: [[4]]"> <-- Array: [1, 2, 3, 4] -->
Removes duplicates from array
Api: array | unique
this.items = [1, 2, 3, 1, 2, 3];
<li *ngFor="let item of items | unique"> <-- Array: [1, 2, 3] -->
Returns array without specific elements
Api: array | without: [ARRAY]
this.items = [1, 2, 3, 1, 2, 3];
<li *ngFor="let item of items | without: [1,3]"> <-- Array: [2, 2] -->
Returns the minimum of a given array
Api: array | min
{{ [1, 2, 3, 1, 2, 3] | min }} <-- Output: "1" -->
Returns the maximum of a given array
Api: array | max
{{ [1, 2, 3, 1, 2, 3] | max }} <-- Output: "3" -->
Returns the sum of a given array
Api: array | sum
{{ [1, 2, 3, 4] | sum }} <-- Output: "10" -->
Returns percent between numbers
Api: number | percentage: [total | default = 100]: [floor | default = false]
{{ 5 | percentage }} <-- Output: "5" -->
{{ 5 | percentage: 160 }} <-- Output: "3.125" -->
{{ 5 | percentage: 160: true }} <-- Output: "3" -->
Returns floor of a number by precision
Api: number | floor: [precision | default = 0]
{{ 42.123 | floor }} <-- Output: "42" -->
{{ 42.123 | floor: 2 }} <-- Output: "42.12" -->x
Returns round of a number by precision
Api: number | round: [precision | default = 0]
{{ 42.4 | round }} <-- Output: "42" -->
{{ 42.5 | round }} <-- Output: "43" -->
{{ 42.123 | round: 2 }} <-- Output: "42.12" -->x
Returns the square root of a number
Api: number | sqrt
{{ 9 | sqrt }} <-- Output: "3" -->
Returns the power of a number
Api: number | pow: [power | default = 2]
{{ 3 | pow }} <-- Output: "9" -->
{{ 3 | pow: 3 }} <-- Output: "27" -->
FAQs
Useful angular2 pipes
The npm package ng2-pipes receives a total of 0 weekly downloads. As such, ng2-pipes popularity was classified as not popular.
We found that ng2-pipes demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
Create React App is officially deprecated due to React 19 issues and lack of maintenance—developers should switch to Vite or other modern alternatives.
Security News
Oracle seeks to dismiss fraud claims in the JavaScript trademark dispute, delaying the case and avoiding questions about its right to the name.
Security News
The Linux Foundation is warning open source developers that compliance with global sanctions is mandatory, highlighting legal risks and restrictions on contributions.