{"version":3,"file":"is-deep-key.mjs","names":[],"sources":["../src/is-deep-key.ts"],"sourcesContent":["/* -------------------------------------------------------------------\n\n                       🗲 Storm Software - Stryke\n\n This code was released as part of the Stryke project. Stryke\n is maintained by Storm Software under the Apache-2.0 license, and is\n free for commercial and private use. For more information, please visit\n our licensing page at https://stormsoftware.com/licenses/projects/stryke.\n\n Website:                  https://stormsoftware.com\n Repository:               https://github.com/storm-software/stryke\n Documentation:            https://docs.stormsoftware.com/projects/stryke\n Contact:                  https://stormsoftware.com/contact\n\n SPDX-License-Identifier:  Apache-2.0\n\n ------------------------------------------------------------------- */\n\nimport type { DeepKey } from \"@stryke/types\";\n\n/**\n * Checks if a given key is a deep key.\n *\n * A deep key is a string that contains a dot (.) or square brackets with a property accessor.\n *\n * @example\n * isDeepKey('a.b') // true\n * isDeepKey('a[b]') // true\n * isDeepKey('a') // false\n * isDeepKey(123) // false\n * isDeepKey('a.b.c') // true\n * isDeepKey('a[b][c]') // true\n *\n * @param key - The key to check.\n * @returns Returns true if the key is a deep key, otherwise false.\n */\nexport function isDeepKey(key: PropertyKey): key is DeepKey<any> {\n  switch (typeof key) {\n    case \"number\":\n    case \"symbol\": {\n      return false;\n    }\n    case \"string\": {\n      return key.includes(\".\") || key.includes(\"[\") || key.includes(\"]\");\n    }\n    case \"bigint\":\n    case \"boolean\":\n    case \"function\":\n    case \"object\":\n    case \"undefined\":\n    default: {\n      return false;\n    }\n  }\n}\n\n/**\n * Checks if a given key is a deep key or normal (shallow key).\n *\n * A deep key is a string that contains a dot (.) or square brackets with a property accessor.\n *\n * @example\n * isDeepKey('a.b') // true\n * isDeepKey('a[b]') // true\n * isDeepKey('a') // true\n * isDeepKey(123) // false\n * isDeepKey('a.b.c') // true\n * isDeepKey('a[b][c]') // true\n *\n * @param key - The key to check.\n * @returns Returns true if the key is a deep key, otherwise false.\n */\nexport function isKeyOrDeepKey(key: PropertyKey): key is DeepKey<any> {\n  switch (typeof key) {\n    case \"number\": {\n      return true;\n    }\n    case \"symbol\": {\n      return false;\n    }\n    case \"string\": {\n      return true;\n    }\n    case \"bigint\":\n    case \"boolean\":\n    case \"function\":\n    case \"object\":\n    case \"undefined\":\n    default: {\n      return false;\n    }\n  }\n}\n"],"mappings":";;;;;;;;;;;;;;;;;AAoCA,SAAgB,UAAU,KAAuC;AAC/D,SAAQ,OAAO,KAAf;EACE,KAAK;EACL,KAAK,SACH,QAAO;EAET,KAAK,SACH,QAAO,IAAI,SAAS,IAAI,IAAI,IAAI,SAAS,IAAI,IAAI,IAAI,SAAS,IAAI;EAOpE,QACE,QAAO;;;;;;;;;;;;;;;;;;;AAqBb,SAAgB,eAAe,KAAuC;AACpE,SAAQ,OAAO,KAAf;EACE,KAAK,SACH,QAAO;EAET,KAAK,SACH,QAAO;EAET,KAAK,SACH,QAAO;EAOT,QACE,QAAO"}