Skip to content

Commit

Permalink
add difference method declaration
Browse files Browse the repository at this point in the history
  • Loading branch information
AnthonyGiretti committed May 25, 2018
1 parent a6965f7 commit 2762539
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 0 deletions.
3 changes: 3 additions & 0 deletions src/app/app.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,9 @@ export class AppComponent implements OnInit {
console.log('compact sample :');
console.log(this._arraysService.compact(['Apple', 0, 'Banana', '', 'Grapefruit']));

console.log('concat sample :');
console.log(this._arraysService.concat(['Apple', 'Banana'], 'Grapefruit', 'Lemon'));

}

}
8 changes: 8 additions & 0 deletions src/services/Arrays.ts
Original file line number Diff line number Diff line change
Expand Up @@ -38,4 +38,12 @@ export class ArraysService {
public concat<T>(array: Array<T>, ...values: Array<T>): Array<T> {
return _.concat(array, ...values);
}

/**
* Creates an array of array values not included in the other given arrays using SameValueZero for equality comparisons.
* The order and references of result values are determined by the first array.
*/
public difference<T>(array: Array<T>, ...values: Array<T>): Array<T> {
return _.difference(array, ...values);
}
}

0 comments on commit 2762539

Please sign in to comment.