@augment-vir/common 12.12.0 → 12.14.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.
@@ -1,6 +1,4 @@
1
- import { NoInputsFunction } from './function';
2
- import { AtLeastTuple } from './tuple';
3
- import { UnPromise } from './type';
1
+ import { AtLeastTuple, NoInputsFunction, UnPromise } from '..';
4
2
  export declare function combineErrors(errors: AtLeastTuple<Error, 1>): Error;
5
3
  export declare function combineErrors(errors: ReadonlyArray<never>): undefined;
6
4
  export declare function combineErrors(errors: ReadonlyArray<Error>): Error | undefined;
@@ -1,8 +1,7 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.executeAndReturnError = exports.ensureError = exports.extractErrorMessage = exports.combineErrorMessages = exports.combineErrors = void 0;
4
- const function_1 = require("./function");
5
- const promise_1 = require("./promise");
4
+ const __1 = require("..");
6
5
  function combineErrors(errors) {
7
6
  if (!errors || errors.length === 0) {
8
7
  return undefined;
@@ -18,7 +17,7 @@ function combineErrorMessages(errors) {
18
17
  if (!errors) {
19
18
  return '';
20
19
  }
21
- return errors.map(extractErrorMessage).filter(function_1.isTruthy).join('\n');
20
+ return errors.map(extractErrorMessage).filter(__1.isTruthy).join('\n');
22
21
  }
23
22
  exports.combineErrorMessages = combineErrorMessages;
24
23
  function extractErrorMessage(error) {
@@ -46,7 +45,7 @@ function executeAndReturnError(callback) {
46
45
  let caughtError;
47
46
  try {
48
47
  const result = callback();
49
- if ((0, promise_1.isPromiseLike)(result)) {
48
+ if ((0, __1.isPromiseLike)(result)) {
50
49
  return new Promise(async (resolve) => {
51
50
  try {
52
51
  const output = await result;
@@ -1,5 +1,4 @@
1
- import { UnPromise } from '../type';
2
- import { PropertyValueType } from './object';
1
+ import { PropertyValueType, UnPromise } from '../..';
3
2
  export type InnerMappedValues<EntireInputGeneric extends object, MappedValueGeneric> = {
4
3
  [MappedProp in keyof EntireInputGeneric]: MappedValueGeneric;
5
4
  };
@@ -1,7 +1,7 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.mapObjectValues = exports.mapObjectValuesSync = void 0;
4
- const object_entries_1 = require("./object-entries");
4
+ const __1 = require("../..");
5
5
  /**
6
6
  * Map an object's keys to new values synchronously. This is different from plain mapObjectValues in
7
7
  * that this will not wrap the return value in a promise if any of the new object values are
@@ -17,7 +17,7 @@ const object_entries_1 = require("./object-entries");
17
17
  */
18
18
  function mapObjectValuesSync(inputObject) {
19
19
  function innerMap(mapCallback) {
20
- const mappedObject = (0, object_entries_1.getObjectTypedKeys)(inputObject).reduce((accum, currentKey) => {
20
+ const mappedObject = (0, __1.getObjectTypedKeys)(inputObject).reduce((accum, currentKey) => {
21
21
  const mappedValue = mapCallback(currentKey, inputObject[currentKey], inputObject);
22
22
  return {
23
23
  ...accum,
@@ -35,7 +35,7 @@ exports.mapObjectValuesSync = mapObjectValuesSync;
35
35
  */
36
36
  function mapObjectValues(inputObject, mapCallback) {
37
37
  let gotAPromise = false;
38
- const mappedObject = (0, object_entries_1.getObjectTypedKeys)(inputObject).reduce((accum, currentKey) => {
38
+ const mappedObject = (0, __1.getObjectTypedKeys)(inputObject).reduce((accum, currentKey) => {
39
39
  const mappedValue = mapCallback(currentKey, inputObject[currentKey], inputObject);
40
40
  if (mappedValue instanceof Promise) {
41
41
  gotAPromise = true;
@@ -48,7 +48,7 @@ function mapObjectValues(inputObject, mapCallback) {
48
48
  if (gotAPromise) {
49
49
  return new Promise(async (resolve, reject) => {
50
50
  try {
51
- await Promise.all((0, object_entries_1.getObjectTypedKeys)(mappedObject).map(async (key) => {
51
+ await Promise.all((0, __1.getObjectTypedKeys)(mappedObject).map(async (key) => {
52
52
  const value = await mappedObject[key];
53
53
  mappedObject[key] = value;
54
54
  }));
@@ -1,6 +1,8 @@
1
1
  export declare function wait(delayMs: number): Promise<void>;
2
2
  export declare function waitValue<ResolutionValue>(delayMs: number, returnValue: ResolutionValue): Promise<ResolutionValue>;
3
3
  export declare function isPromiseLike<T>(input: T | unknown): input is T extends PromiseLike<infer ValueType> ? PromiseLike<ValueType> : PromiseLike<unknown>;
4
+ export type UnPromise<T> = T extends PromiseLike<infer PromiseType> ? Awaited<PromiseType> : T;
5
+ export type MaybePromise<T> = Promise<UnPromise<T>> | UnPromise<T>;
4
6
  export declare class PromiseTimeoutError extends Error {
5
7
  readonly durationMs: number;
6
8
  readonly message: string;
@@ -34,7 +34,6 @@ export type RequiredAndNotNullBy<T, K extends keyof T> = Omit<T, K> & Required<{
34
34
  }>;
35
35
  /** If type T = type U, then type Y. Else type N. */
36
36
  export type IfEquals<T, U, Y = unknown, N = never> = (<G>() => G extends T ? 1 : 2) extends <G>() => G extends U ? 1 : 2 ? Y : N;
37
- export type UnPromise<T> = T extends PromiseLike<infer PromiseType> ? Awaited<PromiseType> : T;
38
37
  /**
39
38
  * This function returns another function that simply returns whatever input it's given. However, it
40
39
  * also checks that the input matches the original wrapNarrowTypeWithTypeCheck's generic, while
@@ -1,6 +1,4 @@
1
- import { NoInputsFunction } from './function';
2
- import { AtLeastTuple } from './tuple';
3
- import { UnPromise } from './type';
1
+ import { AtLeastTuple, NoInputsFunction, UnPromise } from '..';
4
2
  export declare function combineErrors(errors: AtLeastTuple<Error, 1>): Error;
5
3
  export declare function combineErrors(errors: ReadonlyArray<never>): undefined;
6
4
  export declare function combineErrors(errors: ReadonlyArray<Error>): Error | undefined;
@@ -1,5 +1,4 @@
1
- import { isTruthy } from './function';
2
- import { isPromiseLike } from './promise';
1
+ import { isPromiseLike, isTruthy } from '..';
3
2
  export function combineErrors(errors) {
4
3
  if (!errors || errors.length === 0) {
5
4
  return undefined;
@@ -1,5 +1,4 @@
1
- import { UnPromise } from '../type';
2
- import { PropertyValueType } from './object';
1
+ import { PropertyValueType, UnPromise } from '../..';
3
2
  export type InnerMappedValues<EntireInputGeneric extends object, MappedValueGeneric> = {
4
3
  [MappedProp in keyof EntireInputGeneric]: MappedValueGeneric;
5
4
  };
@@ -1,4 +1,4 @@
1
- import { getObjectTypedKeys } from './object-entries';
1
+ import { getObjectTypedKeys } from '../..';
2
2
  /**
3
3
  * Map an object's keys to new values synchronously. This is different from plain mapObjectValues in
4
4
  * that this will not wrap the return value in a promise if any of the new object values are
@@ -1,6 +1,8 @@
1
1
  export declare function wait(delayMs: number): Promise<void>;
2
2
  export declare function waitValue<ResolutionValue>(delayMs: number, returnValue: ResolutionValue): Promise<ResolutionValue>;
3
3
  export declare function isPromiseLike<T>(input: T | unknown): input is T extends PromiseLike<infer ValueType> ? PromiseLike<ValueType> : PromiseLike<unknown>;
4
+ export type UnPromise<T> = T extends PromiseLike<infer PromiseType> ? Awaited<PromiseType> : T;
5
+ export type MaybePromise<T> = Promise<UnPromise<T>> | UnPromise<T>;
4
6
  export declare class PromiseTimeoutError extends Error {
5
7
  readonly durationMs: number;
6
8
  readonly message: string;
@@ -34,7 +34,6 @@ export type RequiredAndNotNullBy<T, K extends keyof T> = Omit<T, K> & Required<{
34
34
  }>;
35
35
  /** If type T = type U, then type Y. Else type N. */
36
36
  export type IfEquals<T, U, Y = unknown, N = never> = (<G>() => G extends T ? 1 : 2) extends <G>() => G extends U ? 1 : 2 ? Y : N;
37
- export type UnPromise<T> = T extends PromiseLike<infer PromiseType> ? Awaited<PromiseType> : T;
38
37
  /**
39
38
  * This function returns another function that simply returns whatever input it's given. However, it
40
39
  * also checks that the input matches the original wrapNarrowTypeWithTypeCheck's generic, while
@@ -1,6 +1,4 @@
1
- import { NoInputsFunction } from './function';
2
- import { AtLeastTuple } from './tuple';
3
- import { UnPromise } from './type';
1
+ import { AtLeastTuple, NoInputsFunction, UnPromise } from '..';
4
2
  export declare function combineErrors(errors: AtLeastTuple<Error, 1>): Error;
5
3
  export declare function combineErrors(errors: ReadonlyArray<never>): undefined;
6
4
  export declare function combineErrors(errors: ReadonlyArray<Error>): Error | undefined;
@@ -1,5 +1,4 @@
1
- import { UnPromise } from '../type';
2
- import { PropertyValueType } from './object';
1
+ import { PropertyValueType, UnPromise } from '../..';
3
2
  export type InnerMappedValues<EntireInputGeneric extends object, MappedValueGeneric> = {
4
3
  [MappedProp in keyof EntireInputGeneric]: MappedValueGeneric;
5
4
  };
@@ -1,6 +1,8 @@
1
1
  export declare function wait(delayMs: number): Promise<void>;
2
2
  export declare function waitValue<ResolutionValue>(delayMs: number, returnValue: ResolutionValue): Promise<ResolutionValue>;
3
3
  export declare function isPromiseLike<T>(input: T | unknown): input is T extends PromiseLike<infer ValueType> ? PromiseLike<ValueType> : PromiseLike<unknown>;
4
+ export type UnPromise<T> = T extends PromiseLike<infer PromiseType> ? Awaited<PromiseType> : T;
5
+ export type MaybePromise<T> = Promise<UnPromise<T>> | UnPromise<T>;
4
6
  export declare class PromiseTimeoutError extends Error {
5
7
  readonly durationMs: number;
6
8
  readonly message: string;
@@ -34,7 +34,6 @@ export type RequiredAndNotNullBy<T, K extends keyof T> = Omit<T, K> & Required<{
34
34
  }>;
35
35
  /** If type T = type U, then type Y. Else type N. */
36
36
  export type IfEquals<T, U, Y = unknown, N = never> = (<G>() => G extends T ? 1 : 2) extends <G>() => G extends U ? 1 : 2 ? Y : N;
37
- export type UnPromise<T> = T extends PromiseLike<infer PromiseType> ? Awaited<PromiseType> : T;
38
37
  /**
39
38
  * This function returns another function that simply returns whatever input it's given. However, it
40
39
  * also checks that the input matches the original wrapNarrowTypeWithTypeCheck's generic, while
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@augment-vir/common",
3
- "version": "12.12.0",
3
+ "version": "12.14.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"