Product
Introducing SSO
Streamline your login process and enhance security by enabling Single Sign-On (SSO) on the Socket platform, now available for all customers on the Enterprise plan, supporting 20+ identity providers.
@ashetm/ng-utility
Advanced tools
Readme
@ashetm/ng-utility
is a library that provide some utilities classes, like pipes.
It works with Angular 14 and above
You can install it with npm:
npm install @ashetm/ng-utility
You only need to import UtilityModule
.
...
import { UtilityModule } from '@ashetm/ng-utility';
...
@NgModule({
...
imports: [
...
UtilityModule,
...
]
...
})
export class AppModule { }
@ashetm/ng-utility
exposes the following:
UtilityModule
, that needs to import in order to use the library.All pipes are standalone pipes.
<T extends string | number | boolean> transform(
value: T[],
filterBy?: string | number | boolean
): (string | number | boolean)[] { ... }
Use on array of string, number or boolean items, and needs an optional argument of type string, number or boolean. If no argument provided, it will return the same array.
Example:
{{ [0, 'test', false, 100, 'texts'] | arrayfilter }} // [0, 'test', false, 100, 'texts']
{{ [0, 'test', false, 100, 'texts'] | arrayfilter:'te' }} // ['test', 'texts']
transform(length: number, fill?: number): number[] { ... }
Use on a number, and needs an optional argument of type number. If no argument provided, it will return an array with index as value.
Example:
{{ 5 | arrayFrom }} // [0, 1, 2, 3, 4]
{{ 5 | arrayFrom:10 }} // [10, 10, 10, 10, 10]
transform(
value: Array<Record<string | number, any>>,
key: (string | number)
): Array<any> { ... }
Use on array of object items, and needs an argument of type number or string.
Example:
{{ [{ a: 1, b: 5 }, { a: 2, c: 4 }, { a: true, b: 'test', c: {} }] | arrayPluck:'b' }} // [5, 'test']
{{ [{ a: 1, b: 5 }, { a: 2, c: 4 }, { a: true, b: 'test', c: {} }] | arrayPluck:'a' }} // [1, 2, true]
transform(value: string): string { ... }
Use on string.
Example:
{{ 'Lorum ipsum' | capitalCase }} // 'Lorum Ipson'
transform(value?: any): boolean { ... }
Use on any type.
Example:
{{ undefined | coerciveBoolean }} // true
{{ null | coerciveBoolean }} // false
{{ 'true' | coerciveBoolean }} // true
transform(controls: AbstractControl): (string | any)[] { ... }
Use on any AbstractControl
type.
Example:
formControl = new FormControl(null, {
validators: [Validators.required, () => ({ customValidator: 'Custom Error Message in any key name!' })]
});
...
{{ formControl | controlErrors }} // ['This field is required', 'Custom Error Message in any key name!']
transform(value: AbstractControl): any { ... }
Use on any AbstractControl
type.
Example:
formGroup = new FormGroup({
test1: new FormControl('test'),
test2: new FormControl(null),
});
...
{{ formGroup | controlValue }} // { test1: 'test', test2: null }
transform(value: string, max: number = Infinity): string { ... }
Use on a string, and needs an optional argument of type number. If no argument provided, it will return string with initial of all words.
Example:
{{ 'abc Def Ghi Jkl' | initial }} // 'aDGJ'
{{ 'abc Def Ghi Jkl' | initial:2 }} // 'aD'
transform(value: any): boolean { ... }
Use on a string, and needs an optional argument of type number. If no argument provided, it will return string with initial of all words.
Example:
{{ 1676808350561 | isDate }} // true
{{ 'Sun Feb 19 2023 13:05:50 GMT+0100 (UTC+01:00)' | isDate }} // true
{{ 'WRONG' | isDate }} // false
transform(value: Record<string | number, any>): [string | number, any][] { ... }
Use on a object.
Example:
Same as Object.entries
.
transform(value: Record<string | number, any>): Array<string> { ... }
Use on a object.
Example:
Same as Object.keys
.
transform(value: Record<string | number, any>): any[] { ... }
Use on a string, and needs an optional argument of type number.
Example:
Same as Object.values
.
LOOKING FOR MAINTAINER OR IF THERE IS AN ISSUE OR ANY IDEA TO ADD. PLEASE CREATE ISSUE IN GITHUB REPOSITORY.
FAQs
``@ashetm/ng-utility`` is a library that provide some utilities classes, like pipes.
The npm package @ashetm/ng-utility receives a total of 0 weekly downloads. As such, @ashetm/ng-utility popularity was classified as not popular.
We found that @ashetm/ng-utility demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Product
Streamline your login process and enhance security by enabling Single Sign-On (SSO) on the Socket platform, now available for all customers on the Enterprise plan, supporting 20+ identity providers.
Security News
Tea.xyz, a crypto project aimed at rewarding open source contributions, is once again facing backlash due to an influx of spam packages flooding public package registries.
Security News
As cyber threats become more autonomous, AI-powered defenses are crucial for businesses to stay ahead of attackers who can exploit software vulnerabilities at scale.