{"version":3,"sources":["../../src/functions/compact/compact.ts","../../src/functions/assert/assert.ts"],"names":[],"mappings":";AAYO,SAAS,QAAW,OAA8C;AACvE,SAAQ,OAAO,OAAO,OAAO,KAAyB,CAAC;AACzD;;;ACSO,SAAS,OACd,WACA,SACmB;AACnB,MAAI,UAAU,WAAW,GAAG;AAC1B;AAAA,EACF;AAEA,MAAI,CAAC,WAAW;AACd,UAAM,IAAI,eAAe,OAAO;AAAA,EAClC;AACF;AAMO,IAAM,iBAAN,cAA6B,MAAM;AAAA,EACxC,YAAY,SAAkB;AAC5B;AAAA,MACE,QAAQ;AAAA,QACN;AAAA,QACA,UAAU,MAAM,OAAO,MAAM;AAAA,MAC/B,CAAC,EAAE,KAAK,EAAE;AAAA,IACZ;AAAA,EACF;AACF","sourcesContent":["import { Falsey, Maybe } from '../../types';\n\n/**\n * Creates an array with all falsey values removed.\n * The values `false`, `null`, `0`, `\"\"`, `undefined`, and `NaN` are falsey.\n * @param array The array to compact.\n * @returns The new array of filtered values.\n * @example\n * ```ts\n * compact([0, 1, false, 2, '', 3, null, 4, undefined]) // [1, 2, 3, 4]\n * ```\n */\nexport function compact<T>(array: Maybe<ReadonlyArray<T | Falsey>>): T[] {\n  return (array?.filter(Boolean) as T[] | undefined) ?? [];\n}\n","import { compact } from '../compact';\n\n/**\n * Asserts that a condition is true, throwing an Error if it is not.\n * @param condition A condition that should be true\n * @param message A message to use in the Error that will be thrown if the condition is falsy\n * @throws An `AssertionError` if the condition is falsy\n * @example\n * ```ts\n * function doWork(value: number | undefined) {\n *   assert(value !== undefined, 'value should be defined');\n *   // value is now narrowed to number\n *\n *   return value + 1;\n * }\n * ```\n * @example\n * ```ts\n * assert(1 === 1); // OK\n * assert(1 === 2); // throws AssertionError\n * assert(1 === 2, '1 should equal 2'); // throws AssertionError: 1 should equal 2\n * ```\n */\nexport function assert(\n  condition?: unknown,\n  message?: string\n): asserts condition {\n  if (arguments.length === 0) {\n    return;\n  }\n\n  if (!condition) {\n    throw new AssertionError(message);\n  }\n}\n\n/**\n * An error that is thrown when an assertion is not satisfied.\n * Thrown by {@link assert}.\n */\nexport class AssertionError extends Error {\n  constructor(message?: string) {\n    super(\n      compact([\n        `Assertion not satisfied`,\n        message ? `: \"${message}\"` : '',\n      ]).join('')\n    );\n  }\n}\n"]}