a8m / ng-pipes

Bunch of useful pipes for Angular2 (with no external dependencies!)
https://a8m.github.io/ng-pipes/
MIT License
118 stars 24 forks source link

Pipe aliases #12

Open SteveVanOpstal opened 7 years ago

SteveVanOpstal commented 7 years ago

In recent events the SnakeCasePipe is renamed to UnderscorePipe (https://github.com/a8m/ng-pipes/commit/a103dd8b3bd15a64aaa0850b23cbb1a6d1afc944).

In my opinion the name SnakeCasePipe makes a lot of sense. @rafaelss95 apparently thinks UnderscorePipe to be more suitable.

But looking at it from the user perspective both are equally correct names. I suggest we allow multiple names for the same pipes by creating aliases.

Alias suggestions

capitalize -- ucFirst snakeCase -- underscore camelCase -- camelize

a8m commented 7 years ago

I like it. Also, there are several more aliases in angular-filter that I like to add:

rafaelss95 commented 7 years ago

I agree with these aliases, but... is it allowed to use multiple names in the @Pipe decorator?

SteveVanOpstal commented 7 years ago

Something in the form of the following should be possible (untested code):

import {Pipe, PipeTransform} from '@angular/core';

@Pipe({name: 'somePipe'})
export class SomePipe implements PipeTransform {
  transform() {}
}

@Pipe({name: 'someOtherPipe'})
export class SomeOtherPipe implements PipeTransform {
  somePipe = new SomePipe();
  transform() {
    return somePipe.transform();
  }
}