Research
Security News
Malicious npm Package Targets Solana Developers and Hijacks Funds
A malicious npm package targets Solana developers, rerouting funds in 2% of transactions to a hardcoded address.
typescript-angular-utilities
Advanced tools
Contains a list of reusable TypeScript libraries, services, and general utilities. These are all defined as angular services and can be injected via the angular dependency injector.
Angular directives that are applied as attributes to an element in order to modify the element's behavior.
Absorbs the passed in DOM event so that it will not propogate outside of the current element. Generally useful for restricting click events within an element so that the click events on parent elements are not triggered.
<div class="my-parent-div" click="doSomething()">
<button class="child-button" click="doSomethingDifferent()" stop-event-propogation="click">Click me</button>
</div>
<span>{{myMoney | currency}}</span>
IFilter
Tests the provided value to see if it is null or empty using the object utility to call isNullOrEmpty on the value. Returns true if the item is empty. If you specify isEmpty:false
, returns true for non-empty values.
<span ng-if="myArray | isEmpty:false">
My array has values!
</span>
Converts the input value to a string using .toString()
and then limits the length of the string to the truncate length. Can optionally add an ellipses to the end (...).
<span>{{myString | truncate:10:true}}</span>
Contains generic operations for any objects.
isNullOrEmpty(object: any): boolean
Returns true if the object is null. Returns true if the object is an empty array. Returns true if the object is NaN. Returns true if the object is an empty string.
####isNullOrWhitespace(object: any): boolean
If the object is a string, first trims it then passes the object into isNullOrEmpty().
####areEqual(obj1: any, obj2: any): boolean
Recursively compares all of the properties on the two objects and returns true if they are equal.
####toString(object: any) string
Converts any object to a string.
####valueOrDefault(value: any, defaultValue: any): any
If the value is not null, returns it, otherwise returns the default value.
Contains generic operations for arrays. Some of these are redundant with libraries like lodash and underscore, but available here if needed.
findIndexOf<TDataType>(array: TDataType[], predicate: { (item: TDataType): boolean }): number
Pass in the array to search and a predicate to test against each item. Returns the index of the first item that the predicate returns true for, or -1 if the predicate never returns true.
remove<TDataType>(array: TDataType[], item: TDataType | { (obj: TDataType): boolean }): TDataType
The first parameter is the array to remove the item from, the second is either the item to remove or a predicate. If you give pass in a predicate the first item that returns true will be removed.
replace<TDataType>(array: TDataType[], oldItem: TDataType, newItem: TDataType): void
Takes the array passed in as the first parameter and replaces the second parameter with the third parameter in this array.
sum<TDataType>(array: TDataType[], transform?: { (item: TDataType): number }): number
Adds all of the items in the array and returns the sum. The second parameter can optionally transform each item before adding.
let myArray = [
{ id: 0, num: 1 },
{ id: 1, num: 5 },
{ id: 2, num: 4 },
{ id: 3, num: 8 },
];
let mySum = arrayService.sum(myArray, (item): number => item.num);
expect(mySum).to.equal(18);
toDictionary<TDataType>(array: TDataType[], keySelector: { (item: TDataType): string }): { [index: string]: TDataType }
Converts the array into a dictionary. The second parameter is a function that takes each item and returns a dictionary key.
last<TDataType>(array: TDataType[]): TDataType
Returns the last element in the array.
import { services } from 'typescript-angular-utilities';
import objectNamespace = services.object;
export class MyController {
static $inject: string[] = [objectNamespace.serviceName];
constructor(private objectService: objectNamespace.IObjectUtility): void {
}
...
private testForEmpty(): boolean {
return this.objectService.isNullOrEmpty(this.someValue);
}
}
angular.module('moduleName', [objectNamespace.moduleName])
.controller('controllerName', MyController);
Clone the repository into your working directory.
Node must be installed.
Install the karma client:
npm install karma -g
Install the typescript compiler:
npm install typescript -g
Navigate to the root of the repo in a cmd prompt and run:
npm run update
Please always test new builds to ensure non-breaking commits and PRs
To build: npm run build
To test: npm test
To debug tests: npm run test.debug
To run tests against additional browsers: npm run test.full
FAQs
Typescript utility classes published as angular services
We found that typescript-angular-utilities demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 3 open source maintainers 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.
Research
Security News
A malicious npm package targets Solana developers, rerouting funds in 2% of transactions to a hardcoded address.
Security News
Research
Socket researchers have discovered malicious npm packages targeting crypto developers, stealing credentials and wallet data using spyware delivered through typosquats of popular cryptographic libraries.
Security News
Socket's package search now displays weekly downloads for npm packages, helping developers quickly assess popularity and make more informed decisions.