{"version":3,"file":"internal.utils-BBB-b6Ud.mjs","names":[],"sources":["../src/common/traverse.ts","../src/common/is-empty-object.ts","../src/common/index.ts","../src/internal.utils.ts"],"sourcesContent":["import _traverse from 'neotraverse'\n\n/**\n * Recursively traverses items (or an array of items) and applies a converter function\n * to every node using `neotraverse`. Modifications happen in place.\n *\n * @example\n * ```ts\n * traverse(items, function () { if (this.key === 'secret') this.remove() })\n * ```\n */\nexport function traverse<T extends Record<string, any>>(\n  items: T | T[],\n  converter: (item: T) => void,\n) {\n  ;(Array.isArray(items) ? items : [items]).forEach((item) => {\n    _traverse(item).forEach(converter) // replacement is in place\n  })\n}\n","/**\n * Returns `true` only for a plain empty object (`{}`). Arrays, `null`, primitives\n * and non-empty objects are all `false`.\n *\n * @example\n * ```ts\n * isEmptyObject({}) // => true\n * isEmptyObject({ a: 1 }) // => false\n * isEmptyObject([]) // => false\n * ```\n */\nexport const isEmptyObject = (obj: unknown): boolean =>\n  !!obj &&\n  typeof obj === 'object' &&\n  !Array.isArray(obj) &&\n  Object.keys(obj).length === 0\n\nif (import.meta.vitest) {\n  const { describe, it, expect } = import.meta.vitest\n\n  describe('isEmptyObject', () => {\n    it('is true only for a plain empty object', () => {\n      expect(isEmptyObject({})).toBe(true)\n    })\n\n    it('is false for a non-empty object', () => {\n      expect(isEmptyObject({ a: 1 })).toBe(false)\n    })\n\n    it('is false for arrays, null, undefined and primitives', () => {\n      expect(isEmptyObject([])).toBe(false)\n      expect(isEmptyObject(null)).toBe(false)\n      expect(isEmptyObject(undefined)).toBe(false)\n      expect(isEmptyObject('')).toBe(false)\n      expect(isEmptyObject(0)).toBe(false)\n    })\n  })\n}\n","/**\n * Type guard that checks if a value is a `Promise` instance.\n *\n * @example\n * ```ts\n * const result = maybeSyncFn()\n * if (isPromise(result)) {\n *   await result\n * }\n * ```\n */\nexport function isPromise(p: any): p is Promise<any> {\n  return p instanceof Promise\n}\n\nexport { traverse } from './traverse.js'\nexport { clone } from './clone.js'\nexport { isEmptyObject } from './is-empty-object.js'\n","import type { HookContext } from '@feathersjs/feathers'\n\nexport const hasOwnProperty = (\n  obj: Record<string, unknown>,\n  ...keys: string[]\n): boolean => {\n  return keys.some((x) => Object.prototype.hasOwnProperty.call(obj, x))\n}\n\nexport type MaybeArray<T> = T | readonly T[]\nexport type UnpackMaybeArray<T> = T extends readonly (infer E)[] ? E : T\n/**\n * Normalizes a value or array into an array. The returned array MUST be treated\n * as read-only — when the input is already an array it is returned as-is (no copy)\n * to avoid a per-call allocation on hook hot paths.\n */\nexport const toArray = <T>(value: T | readonly T[]): T[] =>\n  Array.isArray(value) ? (value as T[]) : [value as T]\n\nexport type Promisable<T> = T | Promise<T>\nexport type KeyOf<T> = Extract<keyof T, string>\n\nexport type UnwrapArray<T> = T extends Array<infer U> ? U : T\n\nexport type IsAny<T> = 0 extends 1 & T ? true : false\n\nexport type AnyFallback<T, Fallback> = IsAny<T> extends true ? Fallback : T\n\nexport type NeverFallback<Never, Fallback> = [Never] extends [never]\n  ? Fallback\n  : Never\n\nexport type KeyOfOrDotNotation<D> = KeyOf<D> | `${KeyOf<D>}.${string}`\n\n/**+\n * Can be used to early return a hook.\n *\n * If it's an around hook, it will call `next` if provided.\n */\nexport const early = <H extends HookContext>(\n  context: H,\n  next?: (context: H) => Promisable<void>,\n): Promisable<void> => {\n  if (next) {\n    return next(context)\n  }\n  return\n}\n"],"mappings":";;;;;;;;;;;AAWA,SAAgB,SACd,OACA,WACA;CACC,CAAC,MAAM,QAAQ,KAAK,IAAI,QAAQ,CAAC,KAAK,EAAA,CAAG,SAAS,SAAS;EAC1D,UAAU,IAAI,CAAC,CAAC,QAAQ,SAAS;CACnC,CAAC;AACH;;;;;;;;;;;;;;ACPA,MAAa,iBAAiB,QAC5B,CAAC,CAAC,OACF,OAAO,QAAQ,YACf,CAAC,MAAM,QAAQ,GAAG,KAClB,OAAO,KAAK,GAAG,CAAC,CAAC,WAAW;;;;;;;;;;;;;;ACJ9B,SAAgB,UAAU,GAA2B;CACnD,OAAO,aAAa;AACtB;;;ACXA,MAAa,kBACX,KACA,GAAG,SACS;CACZ,OAAO,KAAK,MAAM,MAAM,OAAO,UAAU,eAAe,KAAK,KAAK,CAAC,CAAC;AACtE;;;;;;AASA,MAAa,WAAc,UACzB,MAAM,QAAQ,KAAK,IAAK,QAAgB,CAAC,KAAU;;;;;;AAsBrD,MAAa,SACX,SACA,SACqB;CACrB,IAAI,MACF,OAAO,KAAK,OAAO;AAGvB"}