Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

0.4.0 #38

Merged
merged 12 commits into from
Aug 1, 2020
86 changes: 85 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -93,10 +93,15 @@ export class YourComponent {
- [avg](#avg)
- [max](#max)
- [min](#min)
- [pct](#pct)
- [pow](#pow)
- [round](#round)
- [sqrt](#sqrt)
- [sum](#sum)
- [Generic Pipes](#generic-pipes)
- [length](#length)
- [reverse](#reverse)
- [typeOf](#typeof)


## String Pipes
Expand Down Expand Up @@ -132,7 +137,7 @@ Range of position is from 0 (default) to n-1, where n is length of the string.

### concat

Concatenates one or more string(s) to current string at the end.\
Concatenates one or more string(s) to current string at the end.

Usage: `string | concat:string1[:string2]...`

Expand Down Expand Up @@ -345,6 +350,69 @@ Usage: `array | min`
```


### pct

Returns how much percent is a number of the given total. If not specified default value is 100.\
Optionally, number of decimal places (integer) may be specified to round-off the percentage.

Usage: `number | pct [:total] [:decimalPlaces]`

```html
{{ 25 | pct : 483 : 2 }}
<!-- Returns 5.18 -->
```


### pow

Returns the value of the base raised to a specified power.\
Default value of exponent is 0.

Usage: `base | pow [:exponent]`

```html
{{ 4 | pow: 3 }}
<!-- Returns 64 -->
```


### round

Returns the rounded value of given number. By default the value is rounded to the nearest integer.

It also accepts an optional argument `RoundType` for rounding the value up or down.\
`RoundType.Default` = Default rounding as in `Math.round()`
`RoundType.Floor` = Round down as in `Math.floor()`
`RoundType.Ceil` = Round up as in `Math.ceil()`

Optionally, the number of decimal places to which the result should be rounded may also be specified.

Usage: `number | round [:decimalPlaces][:roundType]`

```html
{{ 1234.56789 | round }}
<!-- Returns 1235 -->

{{ 1234.56789 | round : 3 : RoundType.Floor }}
<!-- Returns 1234.567 -->

{{ 9876.54321 | round : 2 : RoundType.Ceil }}
<!-- Returns 9876.54 -->
```


### sqrt

Returns the square root of given number.

Usage: `number | sqrt`

```html
{{ 625 | sqrt }}
<!-- Returns 25 -->
```


### sum

Returns the sum of all numbers in a given array.
Expand Down Expand Up @@ -394,5 +462,21 @@ Usage: `value | reverse`
<!-- Returns ['e', 'd', 'c', 'b', 'a'] -->
```


### typeOf

Returns the type of given value.\
Returns the name of the type in string. All types are supported.

Usage: `value | typeOf`

```html
{{ 'This is a test string!' | typeOf }}
<!-- Returns 'string' -->

{{ { foo: 'bar' } | typeOf }}
<!-- Returns 'object' -->
```

\
For more information on pipes, refer to [Angular - pipes](https://angular.io/guide/pipes) documentation.
76 changes: 17 additions & 59 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

10 changes: 6 additions & 4 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@nglrx/pipes",
"version": "0.3.1",
"version": "0.4.0",
"author": "Kapil Neurgaonkar",
"description": "A collection of pipes for Angular apps.",
"license": "MIT",
Expand All @@ -12,10 +12,12 @@
"bugs": "https://github.com/nglrx/pipes/issues",
"keywords": [
"ng",
"ngx",
"angular",
"pipes",
"angular pipes",
"library",
"angular library",
"filters",
"angular filters"
],
Expand Down Expand Up @@ -51,12 +53,12 @@
"@angular/language-service": "^10.0.5",
"@types/jasmine": "^3.5.11",
"@types/jasminewd2": "~2.0.8",
"@types/node": "^14.0.24",
"@types/node": "^14.0.26",
"codecov": "^3.7.2",
"codelyzer": "^6.0.0",
"jasmine-core": "~3.5.0",
"jasmine-core": "~3.6.0",
"jasmine-spec-reporter": "~5.0.2",
"karma": "~5.1.0",
"karma": "~5.1.1",
"karma-chrome-launcher": "~3.1.0",
"karma-coverage-istanbul-reporter": "~3.0.3",
"karma-jasmine": "~3.3.1",
Expand Down
Loading