@myparcel/ts-utils
Advanced tools
Comparing version 1.5.0 to 1.5.1
@@ -75,5 +75,15 @@ /** | ||
/** | ||
* Returns true if given value is undefined. | ||
*/ | ||
declare const isUndefined: (value: unknown) => value is undefined; | ||
declare const partitionArray: <I>(array: I[] | null | undefined, predicate: (item: I) => boolean) => I[][]; | ||
/** | ||
* Removes keys and values from an object if predicate(value) returns true | ||
*/ | ||
declare const removePropertiesWith: <T extends Record<string, unknown>>(object: T, predicate: (value: unknown) => boolean | Promise<boolean>) => Omit<T, keyof T>; | ||
/** | ||
* Convert input to an array, if it's not already an array. | ||
@@ -83,2 +93,2 @@ */ | ||
export { ArrayWithOneOrMore, MakeOptional, OneOrMore, PromiseOr, ReadonlyOr, RecursivePartial, RecursiveRequired, Replace, RequireOnly, ResolvePromise, asyncEvery, asyncSome, isEnumValue, isInArray, isOfType, partitionArray, toArray }; | ||
export { ArrayWithOneOrMore, MakeOptional, OneOrMore, PromiseOr, ReadonlyOr, RecursivePartial, RecursiveRequired, Replace, RequireOnly, ResolvePromise, asyncEvery, asyncSome, isEnumValue, isInArray, isOfType, isUndefined, partitionArray, removePropertiesWith, toArray }; |
@@ -34,2 +34,5 @@ // src/type-guards/isEnumValue.ts | ||
// src/utils/isUndefined.ts | ||
var isUndefined = (value) => value === void 0; | ||
// src/utils/partitionArray.ts | ||
@@ -46,2 +49,12 @@ var partitionArray = (array, predicate) => { | ||
// src/utils/removePropertiesWith.ts | ||
var removePropertiesWith = (object, predicate) => { | ||
return Object.entries(object).reduce((acc, [key, value]) => { | ||
if (!predicate(value)) { | ||
acc[key] = value; | ||
} | ||
return acc; | ||
}, {}); | ||
}; | ||
// src/utils/toArray.ts | ||
@@ -63,4 +76,6 @@ var toArray = (itemOrItems, separator) => { | ||
isOfType, | ||
isUndefined, | ||
partitionArray, | ||
removePropertiesWith, | ||
toArray | ||
}; |
{ | ||
"name": "@myparcel/ts-utils", | ||
"version": "1.5.0", | ||
"version": "1.5.1", | ||
"description": "TypeScript utilities", | ||
@@ -28,2 +28,3 @@ "keywords": [ | ||
"*.{js,ts}": "eslint --fix", | ||
"*.{json,md,yml}": "prettier --write", | ||
"package.json": "sort-package-json" | ||
@@ -30,0 +31,0 @@ }, |
Sorry, the diff of this file is not supported yet
12239
246