ng-pipes icon indicating copy to clipboard operation
ng-pipes copied to clipboard

Pipe aliases

Open SteveVanOpstal opened this issue 7 years ago • 3 comments

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

SteveVanOpstal avatar Feb 09 '17 13:02 SteveVanOpstal

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

a8m avatar Feb 09 '17 13:02 a8m

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

rafaelss95 avatar Feb 15 '17 03:02 rafaelss95

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();
  }
}

SteveVanOpstal avatar Feb 15 '17 09:02 SteveVanOpstal