simple-collection-utils
v0.0.2-1
Published
Group of small tools to do validations over a collection
Downloads
2
Maintainers
Readme
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);