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.1.9 #20

Merged
merged 4 commits into from
Jul 5, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4,581 changes: 2,481 additions & 2,100 deletions package-lock.json

Large diffs are not rendered by default.

50 changes: 25 additions & 25 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "pipes",
"version": "0.1.8",
"version": "0.1.9",
"author": "Kapil Neurgaonkar",
"description": "A collection of Angular libraries",
"license": "MIT",
Expand All @@ -25,39 +25,39 @@
},
"private": true,
"dependencies": {
"@angular/animations": "^9.1.7",
"@angular/common": "^9.1.7",
"@angular/compiler": "^9.1.7",
"@angular/core": "^9.1.7",
"@angular/forms": "^9.1.7",
"@angular/platform-browser": "^9.1.7",
"@angular/platform-browser-dynamic": "^9.1.7",
"@angular/router": "^9.1.7",
"rxjs": "^6.5.5",
"tslib": "^1.11.2",
"@angular/animations": "^10.0.2",
"@angular/common": "^10.0.2",
"@angular/compiler": "^10.0.2",
"@angular/core": "^10.0.2",
"@angular/forms": "^10.0.2",
"@angular/platform-browser": "^10.0.2",
"@angular/platform-browser-dynamic": "^10.0.2",
"@angular/router": "^10.0.2",
"rxjs": "^6.6.0",
"tslib": "^2.0.0",
"zone.js": "^0.10.3"
},
"devDependencies": {
"@angular-devkit/build-angular": "^0.901.6",
"@angular-devkit/build-ng-packagr": "^0.901.6",
"@angular/cli": "^9.1.6",
"@angular/compiler-cli": "^9.1.7",
"@angular/language-service": "^9.1.7",
"@types/jasmine": "^3.5.10",
"@angular-devkit/build-angular": "^0.1000.1",
"@angular-devkit/build-ng-packagr": "^0.1000.1",
"@angular/cli": "^10.0.1",
"@angular/compiler-cli": "^10.0.2",
"@angular/language-service": "^10.0.2",
"@types/jasmine": "^3.5.11",
"@types/jasminewd2": "~2.0.8",
"@types/node": "^14.0.3",
"codelyzer": "^5.2.2",
"@types/node": "^14.0.14",
"codelyzer": "^6.0.0",
"jasmine-core": "~3.5.0",
"jasmine-spec-reporter": "~5.0.2",
"karma": "~5.0.8",
"karma": "~5.1.0",
"karma-chrome-launcher": "~3.1.0",
"karma-coverage-istanbul-reporter": "~3.0.2",
"karma-jasmine": "~3.1.1",
"karma-coverage-istanbul-reporter": "~3.0.3",
"karma-jasmine": "~3.3.1",
"karma-jasmine-html-reporter": "^1.5.4",
"ng-packagr": "^9.1.5",
"ng-packagr": "^10.0.0",
"protractor": "~7.0.0",
"ts-node": "^8.10.1",
"ts-node": "^8.10.2",
"tslint": "^6.1.2",
"typescript": "^3.8.3"
"typescript": "^3.9.6"
}
}
4 changes: 2 additions & 2 deletions packages/pipes/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@nglrx/pipes",
"version": "0.1.8",
"version": "0.1.9",
"author": "Kapil Neurgaonkar",
"description": "A collection of Angular pipes",
"license": "MIT",
Expand All @@ -16,6 +16,6 @@
"library"
],
"peerDependencies": {
"@angular/core": "^4.0.0 || ^5.0.0 || ^6.0.0 || ^7.0.0 || ^8.0.0 || ^9.0.0"
"@angular/core": "^4.0.0 || ^5.0.0 || ^6.0.0 || ^7.0.0 || ^8.0.0 || ^9.0.0 || ^10.0.0"
}
}
1 change: 1 addition & 0 deletions packages/pipes/src/lib/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,3 +23,4 @@ export { UpperCasePipe } from './string/upper-case/upper-case.pipe';
export { NglrxNumberPipesModule } from './number/nglrx-number-pipes.module';
export { MaxPipe } from './number/max/max.pipe';
export { MinPipe } from './number/min/min.pipe';
export { SumPipe } from './number/sum/sum.pipe';
10 changes: 5 additions & 5 deletions packages/pipes/src/lib/number/max/max.pipe.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,23 +20,23 @@ describe('MaxPipe', () => {
});

it(`should find maximum from an array of numbers`, () => {
expect(pipe.transform(...arr)).toEqual(maxOfArr);
expect(pipe.transform(arr)).toEqual(maxOfArr);
});

it(`should find maximum from an array of both positive and negative numbers`, () => {
expect(pipe.transform(...mixedArr)).toEqual(maxOfMixedArr);
expect(pipe.transform(mixedArr)).toEqual(maxOfMixedArr);
});

it(`should find maximum from an array with single value`, () => {
expect(pipe.transform(...singleValueArr)).toEqual(maxOfSingleValueArr);
expect(pipe.transform(singleValueArr)).toEqual(maxOfSingleValueArr);
});

it(`should return null for an empty array`, () => {
expect(pipe.transform(...emptyArr)).toBeNull();
expect(pipe.transform(emptyArr)).toBeNull();
});

it(`should be null safe`, () => {
expect(pipe.transform()).toBeNull();
expect(pipe.transform(null)).toBeNull();
});

});
10 changes: 5 additions & 5 deletions packages/pipes/src/lib/number/min/min.pipe.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,23 +20,23 @@ describe('MinPipe', () => {
});

it(`should find minimum from an array of numbers`, () => {
expect(pipe.transform(...arr)).toEqual(minOfArr);
expect(pipe.transform(arr)).toEqual(minOfArr);
});

it(`should find minimum from an array of both positive and negative numbers`, () => {
expect(pipe.transform(...mixedArr)).toEqual(minOfMixedArr);
expect(pipe.transform(mixedArr)).toEqual(minOfMixedArr);
});

it(`should find minimum from an array with single value`, () => {
expect(pipe.transform(...singleValueArr)).toEqual(minOfSingleValueArr);
expect(pipe.transform(singleValueArr)).toEqual(minOfSingleValueArr);
});

it(`should return null for an empty array`, () => {
expect(pipe.transform(...emptyArr)).toBeNull();
expect(pipe.transform(emptyArr)).toBeNull();
});

it(`should be null safe`, () => {
expect(pipe.transform()).toBeNull();
expect(pipe.transform(null)).toBeNull();
});

});
2 changes: 2 additions & 0 deletions packages/pipes/src/lib/number/nglrx-number-pipes.module.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,12 @@ import { NgModule } from '@angular/core';

import { MaxPipe } from './max/max.pipe';
import { MinPipe } from './min/min.pipe';
import { SumPipe } from './sum/sum.pipe';

const NUMBER_PIPES = [
MaxPipe,
MinPipe,
SumPipe,
];

@NgModule({
Expand Down
42 changes: 42 additions & 0 deletions packages/pipes/src/lib/number/sum/sum.pipe.spec.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
import { SumPipe } from './sum.pipe';

describe('SumPipe', () => {
let pipe: SumPipe;

const arr = [10, 45, 200, 5, 92];
const sumOfArr = 352;
const mixedArr = [30, 0, -99, -52, -9];
const sumOfMixedArr = -130;
const singleValueArr = [2];
const sumOfSingleValueArr = 2
const emptyArr = [];

beforeEach(() => {
pipe = new SumPipe();
});

it('should create an instance', () => {
expect(pipe).toBeTruthy();
});

it(`should find sum from an array of numbers`, () => {
expect(pipe.transform(arr)).toEqual(sumOfArr);
});

it(`should find sum from an array of both positive and negative numbers`, () => {
expect(pipe.transform(mixedArr)).toEqual(sumOfMixedArr);
});

it(`should find sum from an array with single value`, () => {
expect(pipe.transform(singleValueArr)).toEqual(sumOfSingleValueArr);
});

it(`should return null for an empty array`, () => {
expect(pipe.transform(emptyArr)).toBeNull();
});

it(`should be null safe`, () => {
expect(pipe.transform(null)).toBeNull();
});

});
12 changes: 12 additions & 0 deletions packages/pipes/src/lib/number/sum/sum.pipe.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
import { Pipe, PipeTransform } from '@angular/core';

@Pipe({
name: 'sum'
})
export class SumPipe implements PipeTransform {

transform(values: number[]): number {
return values && values.length > 0 ? values.reduce((sum, value) => sum + value, 0) : null;
}

}
2 changes: 1 addition & 1 deletion tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
"experimentalDecorators": true,
"module": "esnext",
"moduleResolution": "node",
"importHelpers": true,
"importHelpers": false,
"target": "es2015",
"typeRoots": [
"node_modules/@types"
Expand Down