0.0.2-1 • Published 2 years ago

simple-collection-utils v0.0.2-1

Weekly downloads
-
License
MIT
Repository
github
Last release
2 years ago

Simple list of utilities to validate collections

This is meant to be a simple set of utility methods to do simple validations over collections. Something similar to the Apache StringUtils in Java.

Offers basic methods:

- isEmptyList()
- isNotEmptyList()
- isEmptyString()
- isBlankString()
- pathExistsInObject()

How to install:

npm install simple-collection-utils

How to use:

import SimpleCollectionUtils from 'simple-collection-utils';

const thisIsAnEmptyList: any[] = [];
const thisIsABlankString = '      ';

if (SimpleCollectionUtils.isEmptyList(thisIsAnEmptyList)) {
    // This collection is empty
}

if (SimpleCollectionUtils.isBlankString(thisIsAnEmptyList)) {
    // This string only contains whitespaces is empty
}

const object = {
    a: {
        b: {
            c: 'hello'
        }
    }
};

const result = CollectionUtils.pathExistsInObject('a.b.c', object);