{"version":3,"sources":["../src/isEmpty.ts","../src/nonEmpty.ts"],"sourcesContent":["/**\n * Returns true if `t` is empty.\n */\nexport function isEmpty(t: unknown): boolean {\n  // Anything falsy is considered empty.\n  if (!t) {\n    return true;\n  }\n\n  // Arrays are also of type `object`.\n  if (typeof t !== \"object\") {\n    return false;\n  }\n\n  // `length` includes arrays as well.\n  if (\"length\" in t) {\n    return t.length === 0;\n  }\n\n  // `size` is for Set, Map, Blob etc.\n  if (\"size\" in t) {\n    return t.size === 0;\n  }\n\n  // Super fast check for object emptiness.\n  // https://stackoverflow.com/questions/679915/how-do-i-test-for-an-empty-javascript-object\n  for (const k in t) {\n    return false;\n  }\n\n  return true;\n}\n","import { isEmpty } from \"./isEmpty\";\n\n/**\n * Type asserts that `t` is truthy.\n * Throws an error if `t` is null or undefined.\n *\n * @param varName The variable name to include in the error to throw when t is\n *   empty. Defaults to 'value'.\n */\nexport function nonEmpty<T>(\n  t: T | null | undefined | \"\" | 0 | -0 | 0n | false | typeof NaN,\n  varName = \"value\",\n): T {\n  if (isEmpty(t)) {\n    throw new Error(`Empty ${varName}: ${t}`);\n  }\n  return t as T;\n}\n"],"mappings":"AAGO,SAASA,EAAQC,EAAqB,CAE3C,GAAI,CAACA,EACH,MAAO,GAIT,GAAI,OAAOA,GAAM,SACf,MAAO,GAIT,GAAI,WAAYA,EACd,OAAOA,EAAE,SAAW,EAItB,GAAI,SAAUA,EACZ,OAAOA,EAAE,OAAS,EAKpB,QAAWC,KAAKD,EACd,MAAO,GAGT,MAAO,EACT,CCtBO,SAASE,EACdC,EACAC,EAAU,QACP,CACH,GAAIC,EAAQF,CAAC,EACX,MAAM,IAAI,MAAM,SAASC,CAAO,KAAKD,CAAC,EAAE,EAE1C,OAAOA,CACT","names":["isEmpty","t","k","nonEmpty","t","varName","isEmpty"]}