npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

@ashetm/ng-utility

v15.0.1

Published

``@ashetm/ng-utility`` is a library that provide some utilities classes, like pipes.

Downloads

4

Readme

@ashetm/ng-utility

@ashetm/ng-utility is a library that provide some utilities classes, like pipes.

It works with Angular 14 and above

Install

You can install it with npm:

npm install @ashetm/ng-utility

Import

You only need to import UtilityModule.

...
import { UtilityModule } from '@ashetm/ng-utility';
...
@NgModule({
  ...
  imports: [
    ...
    UtilityModule, 
    ...
  ]
  ...
})
export class AppModule { }

API

@ashetm/ng-utility exposes the following:

Modules

  • UtilityModule, that needs to import in order to use the library.

Pipes

All pipes are standalone pipes.

ArrayFilter

<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']

ArrayFrom

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]

ArrayPluck

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]

CapitalCase

transform(value: string): string { ... }

Use on string.

Example:

{{ 'Lorum ipsum' | capitalCase }} // 'Lorum Ipson'

CoerciveBoolean

transform(value?: any): boolean { ... }

Use on any type.

Example:

{{ undefined | coerciveBoolean }} // true
{{ null | coerciveBoolean }} // false
{{ 'true' | coerciveBoolean }} // true

ControlErrors

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!']

ControlValue

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 }

Initial

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'

IsDate

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

ObjectEntries

transform(value: Record<string | number, any>): [string | number, any][] { ... }

Use on a object.

Example:

Same as Object.entries.

ObjectKeys

transform(value: Record<string | number, any>): Array<string> { ... }

Use on a object.

Example:

Same as Object.keys.

ObjectValues

transform(value: Record<string | number, any>): any[] { ... }

Use on a string, and needs an optional argument of type number.

Example:

Same as Object.values.

Issue

LOOKING FOR MAINTAINER OR IF THERE IS AN ISSUE OR ANY IDEA TO ADD. PLEASE CREATE ISSUE IN GITHUB REPOSITORY.