From a34d14abfe9bc1358f404b48dd301ef72a4bd505 Mon Sep 17 00:00:00 2001 From: Orlando Date: Tue, 5 Sep 2023 22:08:57 +0100 Subject: [PATCH] guard bool --- CHANGELOG.md | 6 ++++++ package.json | 2 +- src/helpers/dir.ts | 6 ++++++ src/helpers/index.ts | 1 + src/helpers/pretty.ts | 1 + src/validators/isBoolean.ts | 2 +- src/validators/isLastIndex.ts | 2 +- src/validators/isValue.ts | 2 +- 8 files changed, 18 insertions(+), 4 deletions(-) create mode 100644 src/helpers/dir.ts diff --git a/CHANGELOG.md b/CHANGELOG.md index 3aa4c8e..7e2cb00 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,11 @@ # deverything +## 0.27.1 + +### Patch Changes + +- guard bool + ## 0.27.0 ### Minor Changes diff --git a/package.json b/package.json index 960003d..2d2b770 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "deverything", - "version": "0.27.0", + "version": "0.27.1", "description": "Everything you need for Dev", "main": "./dist/index.js", "module": "./dist/index.mjs", diff --git a/src/helpers/dir.ts b/src/helpers/dir.ts new file mode 100644 index 0000000..1c6476a --- /dev/null +++ b/src/helpers/dir.ts @@ -0,0 +1,6 @@ +/** + * Print or log helper that does not break on circular references, and expands nested objects. + */ +export const dir = (arg: any, depth = 5): void => { + console.dir(arg, { depth }); +}; diff --git a/src/helpers/index.ts b/src/helpers/index.ts index e78d974..ed1acc2 100644 --- a/src/helpers/index.ts +++ b/src/helpers/index.ts @@ -4,6 +4,7 @@ export * from "./arrayIntersection"; export * from "./capitalize"; export * from "./clamp"; export * from "./cleanSpaces"; +export * from "./dir"; export * from "./first"; export * from "./firstKey"; export * from "./firstValue"; diff --git a/src/helpers/pretty.ts b/src/helpers/pretty.ts index 3217eb4..ad7bf19 100644 --- a/src/helpers/pretty.ts +++ b/src/helpers/pretty.ts @@ -1,5 +1,6 @@ import { objectSerializer } from "../_internals/objectSerializer"; +// TODO: deprecate and rename to stringify export const pretty = (arg?: any) => { return JSON.stringify(arg, objectSerializer(), 2); }; diff --git a/src/validators/isBoolean.ts b/src/validators/isBoolean.ts index 839a8bf..76a0d48 100644 --- a/src/validators/isBoolean.ts +++ b/src/validators/isBoolean.ts @@ -1,2 +1,2 @@ -export const isBoolean = (arg: any) => +export const isBoolean = (arg: any): arg is boolean => Object.prototype.toString.call(arg) === "[object Boolean]"; diff --git a/src/validators/isLastIndex.ts b/src/validators/isLastIndex.ts index 56b083f..6dc2802 100644 --- a/src/validators/isLastIndex.ts +++ b/src/validators/isLastIndex.ts @@ -1,3 +1,3 @@ -export const isLastIndex = (index: number, array: any[]) => { +export const isLastIndex = (index: number, array: any[]): boolean => { return index === array.length - 1; }; diff --git a/src/validators/isValue.ts b/src/validators/isValue.ts index 5fcddcb..ca011e3 100644 --- a/src/validators/isValue.ts +++ b/src/validators/isValue.ts @@ -1,5 +1,5 @@ import { Maybe } from "../types"; -export const isValue = (arg?: Maybe) => { +export const isValue = (arg?: Maybe): boolean => { return arg !== undefined && arg !== null && !Number.isNaN(arg); };