@augment-vir/common 15.4.1 → 15.5.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,20 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.ifTruthy = exports.isFalsy = exports.isTruthy = void 0;
4
+ function isTruthy(input) {
5
+ return !!input;
6
+ }
7
+ exports.isTruthy = isTruthy;
8
+ function isFalsy(input) {
9
+ return !input;
10
+ }
11
+ exports.isFalsy = isFalsy;
12
+ function ifTruthy(checkThis, ifTruthyCallback, ifFalsyCallback) {
13
+ if (isTruthy(checkThis)) {
14
+ return ifTruthyCallback(checkThis);
15
+ }
16
+ else {
17
+ return ifFalsyCallback(checkThis);
18
+ }
19
+ }
20
+ exports.ifTruthy = ifTruthy;
@@ -1,7 +1,2 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.isTruthy = void 0;
4
- function isTruthy(input) {
5
- return !!input;
6
- }
7
- exports.isTruthy = isTruthy;
@@ -1,8 +1,8 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.assertMatchesObjectShape = exports.matchesObjectShape = void 0;
4
+ const boolean_1 = require("../boolean");
4
5
  const error_1 = require("../error");
5
- const function_1 = require("../function");
6
6
  const object_1 = require("./object");
7
7
  const object_entries_1 = require("./object-entries");
8
8
  const typed_has_property_1 = require("./typed-has-property");
@@ -104,7 +104,7 @@ function compareInnerValue(testValue, matchValue, throwKeyError, allowExtraProps
104
104
  return new Error(`entry at index "${index}" did not match expected shape: ${(0, error_1.extractErrorMessage)(error)}`);
105
105
  }
106
106
  })
107
- .filter(function_1.isTruthy);
107
+ .filter(boolean_1.isTruthy);
108
108
  if (errors.length === matchValue.length) {
109
109
  throw new Error(`entry at index "${index}" did not match any of the possible types from "${matchValue.join(', ')}"`);
110
110
  }
package/dist/cjs/index.js CHANGED
@@ -17,6 +17,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
17
17
  __exportStar(require("./augments/ansi"), exports);
18
18
  __exportStar(require("./augments/array"), exports);
19
19
  __exportStar(require("./augments/async"), exports);
20
+ __exportStar(require("./augments/boolean"), exports);
20
21
  __exportStar(require("./augments/common-number"), exports);
21
22
  __exportStar(require("./augments/common-string"), exports);
22
23
  __exportStar(require("./augments/environment"), exports);
@@ -0,0 +1,14 @@
1
+ export function isTruthy(input) {
2
+ return !!input;
3
+ }
4
+ export function isFalsy(input) {
5
+ return !input;
6
+ }
7
+ export function ifTruthy(checkThis, ifTruthyCallback, ifFalsyCallback) {
8
+ if (isTruthy(checkThis)) {
9
+ return ifTruthyCallback(checkThis);
10
+ }
11
+ else {
12
+ return ifFalsyCallback(checkThis);
13
+ }
14
+ }
@@ -1,3 +1 @@
1
- export function isTruthy(input) {
2
- return !!input;
3
- }
1
+ export {};
@@ -1,5 +1,5 @@
1
+ import { isTruthy } from '../boolean';
1
2
  import { extractErrorMessage } from '../error';
2
- import { isTruthy } from '../function';
3
3
  import { isObject } from './object';
4
4
  import { getObjectTypedKeys } from './object-entries';
5
5
  import { typedHasProperty } from './typed-has-property';
package/dist/esm/index.js CHANGED
@@ -1,6 +1,7 @@
1
1
  export * from './augments/ansi';
2
2
  export * from './augments/array';
3
3
  export * from './augments/async';
4
+ export * from './augments/boolean';
4
5
  export * from './augments/common-number';
5
6
  export * from './augments/common-string';
6
7
  export * from './augments/environment';
@@ -0,0 +1,6 @@
1
+ export type FalsyTypes = undefined | null | false | 0 | '' | -0 | 0n;
2
+ export type Truthy<T> = Exclude<T, FalsyTypes>;
3
+ export type Falsy<T> = Extract<T, FalsyTypes>;
4
+ export declare function isTruthy<T>(input: T): input is Truthy<T>;
5
+ export declare function isFalsy<T>(input: T): input is Falsy<T>;
6
+ export declare function ifTruthy<const InputType, IfTruthyType, IfFalsyType>(checkThis: InputType, ifTruthyCallback: (truthyInput: Truthy<InputType>) => IfTruthyType, ifFalsyCallback: (truthyInput: Falsy<InputType>) => IfFalsyType): IfTruthyType | IfFalsyType;
@@ -23,4 +23,3 @@ export type NoInputsFunction<ReturnGeneric = any> = () => ReturnGeneric;
23
23
  * TypedFunction<[string | undefined], number>; // (input1: string|undefined) => number
24
24
  */
25
25
  export type TypedFunction<Arguments, Return> = Arguments extends readonly any[] ? number extends Arguments['length'] ? (...args: ArrayElement<Arguments>[]) => Return : (...args: Arguments) => Return : void extends Arguments ? () => Return : (arg: Arguments) => Return;
26
- export declare function isTruthy<T>(input: T): input is Exclude<T, undefined | null | false | 0 | '' | -0 | 0n>;
@@ -1,6 +1,7 @@
1
1
  export * from './augments/ansi';
2
2
  export * from './augments/array';
3
3
  export * from './augments/async';
4
+ export * from './augments/boolean';
4
5
  export * from './augments/common-number';
5
6
  export * from './augments/common-string';
6
7
  export * from './augments/environment';
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@augment-vir/common",
3
- "version": "15.4.1",
3
+ "version": "15.5.0",
4
4
  "homepage": "https://github.com/electrovir/augment-vir/tree/main/packages/common",
5
5
  "bugs": {
6
6
  "url": "https://github.com/electrovir/augment-vir/issues"