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

@zionappsupport/core

v0.3.3

Published

Helper Methods for Angular, Ionic and NgRx projects.

Downloads

33

Readme

@zionappsupport/core

Helper Methods for Angular, Ionic, NgRx or any TypeScript projects. This library is designed to prevent bugs from null and undefined variables and properties. Key areas of use include, but are not limited to:

  • NgRx selectors
  • Utility functions
npm install @zionappsupport/core --save

Methods

Item

1. Strings

a. Case-Insensitive Equals

Do two strings match with case-insensitivity?

caseInsensitiveEquals: (s1: string, s2: string) => boolean;
b. Case-Insensitive Includes

Find if a substring of a string value exists with case insensitive matching

caseInsensitiveIncludes: (value: string, query: string) => boolean;

2. Objects

a. getPropertyValue

Get a property of an object specifying a default value.

getPropertyValue: (item: any, key: string, defaultValue: any) => any;

b. getBooleanPropertyValue, getNumericPropertyValue, getStringPropertyValue

Get a property of an object expecting a specific type

getBooleanPropertyValue: (item: any, key: string) => boolean;
/ Default is false
getGuidPropertyValue: (item: any, key: string) => string;
// Default is null
getIdPropertyValue: (item: any, key: string) => number;
// Default is null
getNumericPropertyValue: (item: any, key: string) => number;
// Default is 0
getStringPropertyValue: (item: any, key: string) => string; 
// Default is ''
c. isPropertyDefined

Does an object exist and is a specific property truthy?

isPropertyDefined: (item: any, key: string) => boolean;

3. Any Type

a. isItemDefined

Is a variable is falsy?

isItemDefined: (item: any) => boolean;
b. isItemNotDefined

Is a variable truthy?

isItemNotDefined: (item: any) => boolean;

List

1. hasAnyItems

Is your list truthy and does it have any items?

hasAnyItems: (list: any[]) => boolean;

2. hasNoItems

Is your list falsy or does it have no items?

hasNoItems: (list: any[]) => boolean;

3. hasAllItemsInList

Do all ids match the ids of items a list?

hasAllItemsInList: (list: string[], idProperty: string, idValues: any[]) => boolean;

Example

const list = [{ id: 1, name: 'Apples'}, { id: 2, name: 'Oranges')];

console.log(hasAllItemsInList(list, 'id', [1, 2])); // Outputs 'true'
console.log(hasAllItemsInList(list, 'id', [1, 3])); // Outputs 'false'

4. hasAllQueryValuesInList

Do all query strings match as a substring of at least 1 string in a list?

hasAllQueryValuesInList: (list: string[], queries: string[]) => boolean;

Example

const list = ['Apples', 'Oranges'];

console.log(hasAllQueryValuesInList(list, ['Apples'])); // Outputs 'true'
console.log(hasAllQueryValuesInList(list, ['Apples', 'Oranges'])); // Outputs 'false'

5. hasItemInList

Does an id match the ids of at least 1 item a list?

hasItemInList: (list: any[], idProperty: string, idValue: any) => boolean;

Example

const list = [{ id: 1, name: 'Apples'}, { id: 2, name: 'Oranges')];
const list = [{ id: 1, name: 'Apples'}, { id: 2, name: 'Oranges')];

console.log(hasItemInList(list, 'id', 1)); // Outputs 'true'
console.log(hasItemInList(list, 'id', 3)); // Outputs 'false'

6. hasQueryValueInList

Does a query match as a substring of at least 1 string in a list?

hasQueryValueInList: (list: string[], query: string) => boolean;

Example

const list = ['Apples', 'Oranges'];

console.log(hasQueryValueInList(list, 'Apples')); // Outputs 'true'
console.log(hasQueryValueInList(list, 'Pears')); // Outputs 'false'
  • compareKeyFunctionAsc: Sort ascending helper function.
  • compareKeyFunctionDesc: Sort descending helper function.
  • getSortedItemsByKeyAsc: Get a new sorted ascending list by any property.
  • getSortedItemsByKeyDesc: Get a new sorted descending list by any property.
  • sanitizeList: Get a list ensuring if it is null or undefined, it will return an empty array.

Time

  • getISOTimestamp: Get an ISO timestamp string. Format: YYYY-MM-DDTHH:MM:SS.sssZ