API Reference / @dasch-ng/utils
@dasch-ng/utils
A collection of useful Angular utilities including standalone pipes, dependency injection helpers, and type guards. Built with modern Angular patterns and full TypeScript support.
Installation
bash
npm install @dasch-ng/utilsor with bun:
bash
bun add @dasch-ng/utilsFeatures
- 🔧 Standalone Pipes - Ready-to-use pipes for common operations
- 🎯 Type-Safe - Full TypeScript support with proper type inference
- 📦 Tree-Shakeable - Import only what you need
- 🚀 Modern Angular - Built for Angular 16+ with standalone components
- 🔄 FxTS Integration - Leverages @fxts/core for functional utilities
- 💉 DI Helpers - Simplified dependency injection patterns
Quick Start
typescript
import { Component } from '@angular/core';
import { DecimalBytesPipe, ReversePipe, IsNilPipe } from '@dasch-ng/utils';
@Component({
selector: 'app-example',
imports: [DecimalBytesPipe, ReversePipe, IsNilPipe],
template: `
<p>File size: {{ 1536000 | decimalBytes }}</p>
<!-- Output: "1.54 MB" -->
<div *ngFor="let item of items | reverse">
{{ item }}
</div>
<!-- Displays items in reverse order -->
<div *ngIf="data | isNil">No data available</div>
`,
})
export class ExampleComponent {
items = ['a', 'b', 'c'];
data: string | null = null;
}Available Utilities
Pipes
Array Manipulation:
reverse- Reverse arrays without mutationjoin- Join array elements with separatornth- Get nth element from iterablesortBy- Sort by property (case-insensitive)
Collection Utilities:
size- Get size of any iterableincludes- Check if array includes valueincludedIn- Check if value is in array
Object Utilities:
prop- Extract property from object
Type Checking:
isNil- Check for null or undefinedisNull- Check for nullisUndefined- Check for undefinedisEmpty- Check if value is empty
Formatting:
decimalBytes- Format bytes to human-readable sizes
Symbol Utilities:
symbolKeyFor- Get key for global symbol
Functions
Dependency Injection Helpers:
provideValue- Create type-safe value providersprovideFactory- Create type-safe factory providersprovideClass- Create type-safe class providersprovideExisting- Create type-safe existing providers (aliases)provideType- Create type-safe constructor providers
Resource Utilities:
resourceValueGuard- Safe value extraction from Angular Resources
Documentation
Full documentation is available at dasch.ng
API Reference
TypeDoc API documentation: dasch.ng/api/@dasch-ng/utils
License
MIT
Running unit tests
Run nx test ng-utils to execute the unit tests.
Classes
- DecimalBytesPipe
- IncludedInPipe
- IncludesPipe
- IsEmptyPipe
- IsNilPipe
- JoinPipe
- NgUtilsModule
- NthPipe
- PropPipe
- ReversePipe
- SizePipe
- SortByPipe
- SymbolKeyForPipe