# @zionappsupport/core

> Helper Methods for Angular, Ionic and NgRx projects.

Latest version **0.3.3** (published 2018-10-30) · ISC license · 0 weekly downloads

## Install

```sh
npm install @zionappsupport/core
pnpm add @zionappsupport/core
yarn add @zionappsupport/core
bun add @zionappsupport/core
```

## Health

**Score 25/100 (F)** — status: abandoned.

Positive: has types; no vulnerabilities; high quality score.

Warnings: low downloads; no esm support; pre 1.0.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 0.3.3 |
| Published | 2018-10-30 |
| First published | 2018-08-21 |
| Weekly downloads | 0 |
| License | ISC |
| TypeScript types | bundled |
| Module format | CommonJS |
| Dependencies | 6 |
| Unpacked size | 27.3 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| Author | Zion App Support |
| Maintainers | zionappsupport |
| Keywords | core, angular, ionic, ngrx |

## Links

- npm: https://www.npmjs.com/package/@zionappsupport/core
- npm.io page: https://npm.io/package/@zionappsupport/core

## Dependencies (6)

- [lodash](https://npm.io/package/lodash.md) ^4.17.11
- [dasherize](https://npm.io/package/dasherize.md) ^2.0.0
- [title-case](https://npm.io/package/title-case.md) ^2.1.1
- [pascal-case](https://npm.io/package/pascal-case.md) ^2.0.1
- [constant-case](https://npm.io/package/constant-case.md) ^2.0.0
- [sentence-case](https://npm.io/package/sentence-case.md) ^2.1.1

## Alternatives

- [lodash.assign](https://npm.io/package/lodash.assign.md) — 2.3M weekly downloads
- [lodash.chunk](https://npm.io/package/lodash.chunk.md) — 1.8M weekly downloads
- [react-native-ios-utilities](https://npm.io/package/react-native-ios-utilities.md) — 138.5K weekly downloads
- [@technically/lodash](https://npm.io/package/@technically/lodash.md) — 50.9K weekly downloads
- [@fluid-topics/ft-icon](https://npm.io/package/@fluid-topics/ft-icon.md) — 20.6K weekly downloads

## Recent versions

- 0.3.3 (latest) — 2018-10-30
- 0.3.2 — 2018-10-29
- 0.3.1 — 2018-10-29
- 0.3.0 — 2018-10-28
- 0.2.4 — 2018-10-13
- 0.0.24 — 2018-10-12
- 0.2.1 — 2018-10-11
- 0.2.0 — 2018-10-10
- 0.1.1 — 2018-10-05
- 0.0.23 — 2018-09-30
- 0.0.21 — 2018-09-29
- 0.0.20 — 2018-09-29
- 0.0.19 — 2018-09-29
- 0.0.18 — 2018-09-29
- 0.0.17 — 2018-09-28
- … 14 more at https://npm.io/package/@zionappsupport/core/versions

## 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

---
_Source: https://npm.io/package/@zionappsupport/core · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
