@koine/utils 2.0.0-beta.20 → 2.0.0-beta.22

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.
package/areEqual.js CHANGED
@@ -7,9 +7,7 @@ function areEqualArrays(a, b) {
7
7
  if (a.length !== b.length)
8
8
  return false;
9
9
  for (var i = 0; i < a.length; i++) {
10
- var aValue = a[i];
11
- var bValue = b[i];
12
- if (!areEqual(aValue, bValue))
10
+ if (!areEqual(a[i], b[i]))
13
11
  return false;
14
12
  }
15
13
  return true;
@@ -19,17 +17,11 @@ function areEqualObjects(a, b) {
19
17
  if (!b)
20
18
  return false;
21
19
  var aKeys = Object.keys(a);
22
- var bKeys = Object.keys(b);
23
- if (aKeys.length !== bKeys.length) {
24
- return false;
25
- }
26
20
  try {
27
21
  for (var aKeys_1 = __values(aKeys), aKeys_1_1 = aKeys_1.next(); !aKeys_1_1.done; aKeys_1_1 = aKeys_1.next()) {
28
22
  var _key = aKeys_1_1.value;
29
23
  var key = _key;
30
- var aValue = a[key];
31
- var bValue = b[key];
32
- if (!areEqual(aValue, bValue)) {
24
+ if (!areEqual(a[key], b[key])) {
33
25
  return false;
34
26
  }
35
27
  }
@@ -0,0 +1,2 @@
1
+ export declare function arrayFilterFalsy<T extends unknown[]>(list?: null | T): Exclude<NonNullable<T>[number], false | "" | 0 | undefined>[];
2
+ export default arrayFilterFalsy;
@@ -0,0 +1,4 @@
1
+ export function arrayFilterFalsy(list) {
2
+ return (list ? list.filter(function (r) { return !!r; }) : []);
3
+ }
4
+ export default arrayFilterFalsy;
package/cjs/areEqual.js CHANGED
@@ -10,9 +10,7 @@ function areEqualArrays(a, b) {
10
10
  if (a.length !== b.length)
11
11
  return false;
12
12
  for (var i = 0; i < a.length; i++) {
13
- var aValue = a[i];
14
- var bValue = b[i];
15
- if (!areEqual(aValue, bValue))
13
+ if (!areEqual(a[i], b[i]))
16
14
  return false;
17
15
  }
18
16
  return true;
@@ -22,17 +20,11 @@ function areEqualObjects(a, b) {
22
20
  if (!b)
23
21
  return false;
24
22
  var aKeys = Object.keys(a);
25
- var bKeys = Object.keys(b);
26
- if (aKeys.length !== bKeys.length) {
27
- return false;
28
- }
29
23
  try {
30
24
  for (var aKeys_1 = tslib_1.__values(aKeys), aKeys_1_1 = aKeys_1.next(); !aKeys_1_1.done; aKeys_1_1 = aKeys_1.next()) {
31
25
  var _key = aKeys_1_1.value;
32
26
  var key = _key;
33
- var aValue = a[key];
34
- var bValue = b[key];
35
- if (!areEqual(aValue, bValue)) {
27
+ if (!areEqual(a[key], b[key])) {
36
28
  return false;
37
29
  }
38
30
  }
@@ -0,0 +1,2 @@
1
+ export declare function arrayFilterFalsy<T extends unknown[]>(list?: null | T): Exclude<NonNullable<T>[number], false | "" | 0 | undefined>[];
2
+ export default arrayFilterFalsy;
@@ -0,0 +1,8 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.arrayFilterFalsy = void 0;
4
+ function arrayFilterFalsy(list) {
5
+ return (list ? list.filter(function (r) { return !!r; }) : []);
6
+ }
7
+ exports.arrayFilterFalsy = arrayFilterFalsy;
8
+ exports.default = arrayFilterFalsy;
package/cjs/index.d.ts CHANGED
@@ -1,6 +1,7 @@
1
1
  export { accentsSets, type AccentsSet } from "./accentSets";
2
2
  export { addOrReplaceAtIdx } from "./addOrReplaceAtIdx";
3
3
  export { areEqual } from "./areEqual";
4
+ export { arrayFilterFalsy } from "./arrayFilterFalsy";
4
5
  export { arrayOfAll } from "./arrayOfAll";
5
6
  export { arraySum } from "./arraySum";
6
7
  export { arrayToLookup } from "./arrayToLookup";
package/cjs/index.js CHANGED
@@ -1,14 +1,16 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.isEmptyArray = exports.isDate = exports.isBrowserNow = exports.isBrowser = exports.isBoolean = exports.isBlob = exports.isArray = exports.isAnyObject = exports.imgEmptyPixel = exports.getUrlQueryParams = exports.getUrlPathnameParts = exports.getUrlHashPathname = exports.getUrlHashParams = exports.getType = exports.getParamAsString = exports.getParamAsInt = exports.getParamAmong = exports.getNonce = exports.getMediaQueryWidthTailwindScreens = exports.getMediaQueryWidthResolvers = exports.getKeys = exports.getEmptyArray = exports.gbToBytes = exports.forin = exports.findDuplicatedIndexes = exports.errorToString = exports.ensureInt = exports.encode = exports.Emitter = exports.Defer = exports.decode = exports.debouncePromise = exports.debounceRaf = exports.debounce = exports.createPalette = exports.convertRange = exports.clsx = exports.clamp = exports.chunkBySize = exports.chunkByChunks = exports.changeUrlPath = exports.capitalize = exports.buildUrlQueryString = exports.arrayUniqueByProperties = exports.arrayToLookup = exports.arraySum = exports.arrayOfAll = exports.areEqual = exports.addOrReplaceAtIdx = exports.accentsSets = void 0;
4
- exports.objectToArray = exports.objectOmit = exports.objectPick = exports.objectFlip = exports.normaliseUrl = exports.normaliseUrlPathname = exports.noop = exports.moveSortableArrayItemByKey = exports.mergeUrlQueryParams = exports.mergeObjects = exports.mbToBytes = exports.matchSorter = exports.mapListBy = exports.lowercase = exports.kbToBytes = exports.isWeakSet = exports.isWeakMap = exports.isUndefined = exports.isType = exports.isSymbol = exports.isString = exports.isSet = exports.isServerNow = exports.isServer = exports.isRegExp = exports.isPromise = exports.isPrimitive = exports.isPositiveNumber = exports.isPlainObject = exports.isOneOf = exports.isObject = exports.isObjectLike = exports.isNumber = exports.isNull = exports.isNullOrUndefined = exports.isNegativeNumber = exports.isNaNValue = exports.isMap = exports.isInt = exports.isFunction = exports.isFullString = exports.isFullObject = exports.isFullArray = exports.isFormData = exports.isFloat = exports.isFile = exports.isExternalUrl = exports.isError = exports.isEmptyString = exports.isEmptyObject = void 0;
5
- exports.wait = exports.uuidNumeric = exports.uuid = exports.uppercase = exports.updateUrlQueryParams = exports.updateLinkParams = exports.uid = exports.tryUntil = exports.truncate = exports.transformToUrlPathname = exports.toRgba = exports.toNumber = exports.titleCase = exports.throttle = exports.swapMap = exports.split = exports.slugify = exports.shuffle = exports.setCookie = exports.serializeCookie = exports.roundTo = exports.round = exports.removeUrlQueryParams = exports.removeTralingSlash = exports.removeIndexesFromArray = exports.removeDuplicatesComparing = exports.removeDuplicatesByKey = exports.removeCookie = exports.removeAccents = exports.readCookie = exports.randomKey = exports.randomInt = exports.quaranteneProps = exports.parseURL = exports.parseCookie = void 0;
3
+ exports.isDate = exports.isBrowserNow = exports.isBrowser = exports.isBoolean = exports.isBlob = exports.isArray = exports.isAnyObject = exports.imgEmptyPixel = exports.getUrlQueryParams = exports.getUrlPathnameParts = exports.getUrlHashPathname = exports.getUrlHashParams = exports.getType = exports.getParamAsString = exports.getParamAsInt = exports.getParamAmong = exports.getNonce = exports.getMediaQueryWidthTailwindScreens = exports.getMediaQueryWidthResolvers = exports.getKeys = exports.getEmptyArray = exports.gbToBytes = exports.forin = exports.findDuplicatedIndexes = exports.errorToString = exports.ensureInt = exports.encode = exports.Emitter = exports.Defer = exports.decode = exports.debouncePromise = exports.debounceRaf = exports.debounce = exports.createPalette = exports.convertRange = exports.clsx = exports.clamp = exports.chunkBySize = exports.chunkByChunks = exports.changeUrlPath = exports.capitalize = exports.buildUrlQueryString = exports.arrayUniqueByProperties = exports.arrayToLookup = exports.arraySum = exports.arrayOfAll = exports.arrayFilterFalsy = exports.areEqual = exports.addOrReplaceAtIdx = exports.accentsSets = void 0;
4
+ exports.objectOmit = exports.objectPick = exports.objectFlip = exports.normaliseUrl = exports.normaliseUrlPathname = exports.noop = exports.moveSortableArrayItemByKey = exports.mergeUrlQueryParams = exports.mergeObjects = exports.mbToBytes = exports.matchSorter = exports.mapListBy = exports.lowercase = exports.kbToBytes = exports.isWeakSet = exports.isWeakMap = exports.isUndefined = exports.isType = exports.isSymbol = exports.isString = exports.isSet = exports.isServerNow = exports.isServer = exports.isRegExp = exports.isPromise = exports.isPrimitive = exports.isPositiveNumber = exports.isPlainObject = exports.isOneOf = exports.isObject = exports.isObjectLike = exports.isNumber = exports.isNull = exports.isNullOrUndefined = exports.isNegativeNumber = exports.isNaNValue = exports.isMap = exports.isInt = exports.isFunction = exports.isFullString = exports.isFullObject = exports.isFullArray = exports.isFormData = exports.isFloat = exports.isFile = exports.isExternalUrl = exports.isError = exports.isEmptyString = exports.isEmptyObject = exports.isEmptyArray = void 0;
5
+ exports.wait = exports.uuidNumeric = exports.uuid = exports.uppercase = exports.updateUrlQueryParams = exports.updateLinkParams = exports.uid = exports.tryUntil = exports.truncate = exports.transformToUrlPathname = exports.toRgba = exports.toNumber = exports.titleCase = exports.throttle = exports.swapMap = exports.split = exports.slugify = exports.shuffle = exports.setCookie = exports.serializeCookie = exports.roundTo = exports.round = exports.removeUrlQueryParams = exports.removeTralingSlash = exports.removeIndexesFromArray = exports.removeDuplicatesComparing = exports.removeDuplicatesByKey = exports.removeCookie = exports.removeAccents = exports.readCookie = exports.randomKey = exports.randomInt = exports.quaranteneProps = exports.parseURL = exports.parseCookie = exports.objectToArray = void 0;
6
6
  var accentSets_1 = require("./accentSets");
7
7
  Object.defineProperty(exports, "accentsSets", { enumerable: true, get: function () { return accentSets_1.accentsSets; } });
8
8
  var addOrReplaceAtIdx_1 = require("./addOrReplaceAtIdx");
9
9
  Object.defineProperty(exports, "addOrReplaceAtIdx", { enumerable: true, get: function () { return addOrReplaceAtIdx_1.addOrReplaceAtIdx; } });
10
10
  var areEqual_1 = require("./areEqual");
11
11
  Object.defineProperty(exports, "areEqual", { enumerable: true, get: function () { return areEqual_1.areEqual; } });
12
+ var arrayFilterFalsy_1 = require("./arrayFilterFalsy");
13
+ Object.defineProperty(exports, "arrayFilterFalsy", { enumerable: true, get: function () { return arrayFilterFalsy_1.arrayFilterFalsy; } });
12
14
  var arrayOfAll_1 = require("./arrayOfAll");
13
15
  Object.defineProperty(exports, "arrayOfAll", { enumerable: true, get: function () { return arrayOfAll_1.arrayOfAll; } });
14
16
  var arraySum_1 = require("./arraySum");
package/cjs/invariant.js CHANGED
@@ -2,7 +2,7 @@
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.invariant = void 0;
4
4
  function invariant(condition, message, lib, prefix) {
5
- if (process.env["NODE_ENV"] !== "production") {
5
+ if (process.env["NODE_ENV"] === "development") {
6
6
  if (condition) {
7
7
  return;
8
8
  }
package/cjs/package.json CHANGED
@@ -2,5 +2,5 @@
2
2
  "name": "@koine/utils",
3
3
  "sideEffects": false,
4
4
  "main": "./index.js",
5
- "types": "./index.d.ts"
5
+ "type": "commonjs"
6
6
  }
package/cjs/readCookie.js CHANGED
@@ -9,7 +9,7 @@ function converterRead(value) {
9
9
  }
10
10
  function readCookie(name) {
11
11
  if (typeof document === "undefined") {
12
- if (process.env["NODE_ENV"] !== "production") {
12
+ if (process.env["NODE_ENV"] === "development") {
13
13
  console.warn("[@koine/utils:readCookie] document is undefined");
14
14
  }
15
15
  return name ? "" : {};
@@ -27,7 +27,7 @@ function readCookie(name) {
27
27
  }
28
28
  }
29
29
  catch (e) {
30
- if (process.env["NODE_ENV"] !== "production") {
30
+ if (process.env["NODE_ENV"] === "development") {
31
31
  console.warn("[@koine/utils:readCookie] failed to decode", value);
32
32
  }
33
33
  }
package/cjs/render.js CHANGED
@@ -112,7 +112,7 @@ var render = function (tmpl, def) {
112
112
  return new Function(varname, str);
113
113
  }
114
114
  catch (e) {
115
- if (process.env["NODE_ENV"] !== "production") {
115
+ if (process.env["NODE_ENV"] === "development") {
116
116
  console.log("Could not create a template function: " + str);
117
117
  throw e;
118
118
  }
package/cjs/roundTo.js CHANGED
@@ -7,7 +7,7 @@ function roundTo(num, decimals) {
7
7
  var multiplicator = Math.pow(10, decimals);
8
8
  return Math.round(num * multiplicator) / multiplicator + "";
9
9
  }
10
- if (process.env["NODE_ENV"] !== "production") {
10
+ if (process.env["NODE_ENV"] === "development") {
11
11
  console.warn("[@koine/utils] math:roundTo -> given not a finite number as first arg");
12
12
  }
13
13
  return "";
@@ -8,7 +8,7 @@ function serializeCookie(name, val, attributes) {
8
8
  var _a = attributes.encode, encode = _a === void 0 ? encodeURIComponent : _a, domain = attributes.domain, path = attributes.path, httpOnly = attributes.httpOnly, secure = attributes.secure, sameSite = attributes.sameSite;
9
9
  var maxAge = attributes.maxAge, expires = attributes.expires;
10
10
  var value = encode(val);
11
- if (process.env["NODE_ENV"] !== "production") {
11
+ if (process.env["NODE_ENV"] === "development") {
12
12
  if (!fieldContentRegExp.test(name)) {
13
13
  throw new TypeError("argument name is invalid");
14
14
  }
@@ -28,7 +28,7 @@ function serializeCookie(name, val, attributes) {
28
28
  str += "; Max-Age=" + Math.floor(maxAge);
29
29
  }
30
30
  if (domain) {
31
- if (process.env["NODE_ENV"] !== "production") {
31
+ if (process.env["NODE_ENV"] === "development") {
32
32
  if (!fieldContentRegExp.test(domain)) {
33
33
  throw new TypeError("option domain is invalid");
34
34
  }
@@ -36,7 +36,7 @@ function serializeCookie(name, val, attributes) {
36
36
  str += "; Domain=" + domain;
37
37
  }
38
38
  if (path) {
39
- if (process.env["NODE_ENV"] !== "production") {
39
+ if (process.env["NODE_ENV"] === "development") {
40
40
  if (!fieldContentRegExp.test(path)) {
41
41
  throw new TypeError("option path is invalid");
42
42
  }
package/cjs/setCookie.js CHANGED
@@ -13,7 +13,7 @@ function setCookie(name, value, attributes) {
13
13
  var expires = attributes.expires, restAttrs = tslib_1.__rest(attributes, ["expires"]);
14
14
  var cleanedAttrs = tslib_1.__assign(tslib_1.__assign({ expires: "" }, cookie_1.defaultAttributesClient), restAttrs);
15
15
  if ((0, isUndefined_1.default)(document)) {
16
- if (process.env["NODE_ENV"] !== "production") {
16
+ if (process.env["NODE_ENV"] === "development") {
17
17
  console.warn("[@koine/utils:setCookie] document is undefined");
18
18
  }
19
19
  return undefined;
package/cjs/throttle.d.ts CHANGED
@@ -1,2 +1,3 @@
1
+ /// <reference types="node" />
1
2
  export declare function throttle<TFn extends Function, TContext>(fn: TFn, limit: number, context?: TContext): (this: TContext, ...args: any[]) => NodeJS.Timeout | undefined;
2
3
  export default throttle;
package/index.d.ts CHANGED
@@ -1,6 +1,7 @@
1
1
  export { accentsSets, type AccentsSet } from "./accentSets.js";
2
2
  export { addOrReplaceAtIdx } from "./addOrReplaceAtIdx.js";
3
3
  export { areEqual } from "./areEqual.js";
4
+ export { arrayFilterFalsy } from "./arrayFilterFalsy.js";
4
5
  export { arrayOfAll } from "./arrayOfAll.js";
5
6
  export { arraySum } from "./arraySum.js";
6
7
  export { arrayToLookup } from "./arrayToLookup.js";
package/index.js CHANGED
@@ -1,6 +1,7 @@
1
1
  export { accentsSets } from "./accentSets.js";
2
2
  export { addOrReplaceAtIdx } from "./addOrReplaceAtIdx.js";
3
3
  export { areEqual } from "./areEqual.js";
4
+ export { arrayFilterFalsy } from "./arrayFilterFalsy.js";
4
5
  export { arrayOfAll } from "./arrayOfAll.js";
5
6
  export { arraySum } from "./arraySum.js";
6
7
  export { arrayToLookup } from "./arrayToLookup.js";
package/invariant.js CHANGED
@@ -1,5 +1,5 @@
1
1
  export function invariant(condition, message, lib, prefix) {
2
- if (process.env["NODE_ENV"] !== "production") {
2
+ if (process.env["NODE_ENV"] === "development") {
3
3
  if (condition) {
4
4
  return;
5
5
  }
package/package.json CHANGED
@@ -1,10 +1,9 @@
1
1
  {
2
2
  "name": "@koine/utils",
3
3
  "sideEffects": false,
4
- "main": "./cjs/index.js",
5
- "types": "./index.d.ts",
6
- "type": "module",
7
4
  "module": "./index.js",
5
+ "type": "module",
6
+ "main": "./cjs/index.js",
8
7
  "exports": {
9
8
  ".": {
10
9
  "require": "./cjs/index.js",
@@ -30,6 +29,10 @@
30
29
  "require": "./cjs/areEqual.js",
31
30
  "import": "./areEqual.js"
32
31
  },
32
+ "./arrayFilterFalsy": {
33
+ "require": "./cjs/arrayFilterFalsy.js",
34
+ "import": "./arrayFilterFalsy.js"
35
+ },
33
36
  "./arrayOfAll": {
34
37
  "require": "./cjs/arrayOfAll.js",
35
38
  "import": "./arrayOfAll.js"
@@ -584,6 +587,5 @@
584
587
  }
585
588
  },
586
589
  "dependencies": {},
587
- "version": "2.0.0-beta.20",
588
- "peerDependencies": {}
590
+ "version": "2.0.0-beta.22"
589
591
  }
package/readCookie.js CHANGED
@@ -6,7 +6,7 @@ function converterRead(value) {
6
6
  }
7
7
  export function readCookie(name) {
8
8
  if (typeof document === "undefined") {
9
- if (process.env["NODE_ENV"] !== "production") {
9
+ if (process.env["NODE_ENV"] === "development") {
10
10
  console.warn("[@koine/utils:readCookie] document is undefined");
11
11
  }
12
12
  return name ? "" : {};
@@ -24,7 +24,7 @@ export function readCookie(name) {
24
24
  }
25
25
  }
26
26
  catch (e) {
27
- if (process.env["NODE_ENV"] !== "production") {
27
+ if (process.env["NODE_ENV"] === "development") {
28
28
  console.warn("[@koine/utils:readCookie] failed to decode", value);
29
29
  }
30
30
  }
package/render.js CHANGED
@@ -109,7 +109,7 @@ export var render = function (tmpl, def) {
109
109
  return new Function(varname, str);
110
110
  }
111
111
  catch (e) {
112
- if (process.env["NODE_ENV"] !== "production") {
112
+ if (process.env["NODE_ENV"] === "development") {
113
113
  console.log("Could not create a template function: " + str);
114
114
  throw e;
115
115
  }
package/roundTo.js CHANGED
@@ -4,7 +4,7 @@ export function roundTo(num, decimals) {
4
4
  var multiplicator = Math.pow(10, decimals);
5
5
  return Math.round(num * multiplicator) / multiplicator + "";
6
6
  }
7
- if (process.env["NODE_ENV"] !== "production") {
7
+ if (process.env["NODE_ENV"] === "development") {
8
8
  console.warn("[@koine/utils] math:roundTo -> given not a finite number as first arg");
9
9
  }
10
10
  return "";
@@ -5,7 +5,7 @@ export function serializeCookie(name, val, attributes) {
5
5
  var _a = attributes.encode, encode = _a === void 0 ? encodeURIComponent : _a, domain = attributes.domain, path = attributes.path, httpOnly = attributes.httpOnly, secure = attributes.secure, sameSite = attributes.sameSite;
6
6
  var maxAge = attributes.maxAge, expires = attributes.expires;
7
7
  var value = encode(val);
8
- if (process.env["NODE_ENV"] !== "production") {
8
+ if (process.env["NODE_ENV"] === "development") {
9
9
  if (!fieldContentRegExp.test(name)) {
10
10
  throw new TypeError("argument name is invalid");
11
11
  }
@@ -25,7 +25,7 @@ export function serializeCookie(name, val, attributes) {
25
25
  str += "; Max-Age=" + Math.floor(maxAge);
26
26
  }
27
27
  if (domain) {
28
- if (process.env["NODE_ENV"] !== "production") {
28
+ if (process.env["NODE_ENV"] === "development") {
29
29
  if (!fieldContentRegExp.test(domain)) {
30
30
  throw new TypeError("option domain is invalid");
31
31
  }
@@ -33,7 +33,7 @@ export function serializeCookie(name, val, attributes) {
33
33
  str += "; Domain=" + domain;
34
34
  }
35
35
  if (path) {
36
- if (process.env["NODE_ENV"] !== "production") {
36
+ if (process.env["NODE_ENV"] === "development") {
37
37
  if (!fieldContentRegExp.test(path)) {
38
38
  throw new TypeError("option path is invalid");
39
39
  }
package/setCookie.js CHANGED
@@ -10,7 +10,7 @@ export function setCookie(name, value, attributes) {
10
10
  var expires = attributes.expires, restAttrs = __rest(attributes, ["expires"]);
11
11
  var cleanedAttrs = __assign(__assign({ expires: "" }, defaultAttributesClient), restAttrs);
12
12
  if (isUndefined(document)) {
13
- if (process.env["NODE_ENV"] !== "production") {
13
+ if (process.env["NODE_ENV"] === "development") {
14
14
  console.warn("[@koine/utils:setCookie] document is undefined");
15
15
  }
16
16
  return undefined;
package/throttle.d.ts CHANGED
@@ -1,2 +1,3 @@
1
+ /// <reference types="node" />
1
2
  export declare function throttle<TFn extends Function, TContext>(fn: TFn, limit: number, context?: TContext): (this: TContext, ...args: any[]) => NodeJS.Timeout | undefined;
2
3
  export default throttle;
package/typings.d.ts CHANGED
@@ -2,3 +2,56 @@
2
2
  * List here the global variables used by third party scripts supported within
3
3
  * the `koine` ecosystem.
4
4
  */
5
+ /**
6
+ * List here the global variables used by third party scripts supported within
7
+ * the `koine` ecosystem.
8
+ */
9
+
10
+ // as in type-fest start
11
+ type Simplify<T> = { [KeyType in keyof T]: T[KeyType] };
12
+ type IsEqual<A, B> = (<G>() => G extends A ? 1 : 2) extends <G>() => G extends B
13
+ ? 1
14
+ : 2
15
+ ? true
16
+ : false;
17
+ type Filter<KeyType, ExcludeType> = IsEqual<KeyType, ExcludeType> extends true
18
+ ? never
19
+ : KeyType extends ExcludeType
20
+ ? never
21
+ : KeyType;
22
+ type Except<ObjectType, KeysType extends keyof ObjectType> = {
23
+ [KeyType in keyof ObjectType as Filter<
24
+ KeyType,
25
+ KeysType
26
+ >]: ObjectType[KeyType];
27
+ };
28
+ // as in type-fest end
29
+
30
+ /**
31
+ * Tweak a model by making some properties required (not `optional` and not `nullable`)
32
+ *
33
+ * This is useful to tweak/correct the types generated from Swagger.
34
+ */
35
+ declare type Tweak<
36
+ TModel extends object,
37
+ TRequiredKeys extends keyof TModel | false,
38
+ TReplacements extends Partial<Record<keyof TModel, unknown>> | false = false,
39
+ > = TReplacements extends false
40
+ ? Simplify<
41
+ TRequiredKeys extends false ? TModel :
42
+ Except<TModel, TRequiredKeys> &
43
+ Required<{
44
+ [K in TRequiredKeys]: NonNullable<TModel[K]>;
45
+ }>
46
+ >
47
+ : Simplify<
48
+ TRequiredKeys extends false ? TModel & TReplacements :
49
+ Omit<
50
+ Except<TModel, TRequiredKeys> &
51
+ Required<{
52
+ [K in TRequiredKeys]: NonNullable<TModel[K]>;
53
+ }>,
54
+ keyof TReplacements
55
+ >
56
+ & TReplacements
57
+ >;