@xylabs/function-name 4.8.9 → 4.9.1

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.
@@ -1,5 +1,6 @@
1
1
  // src/functionName.ts
2
2
  import { handleError } from "@xylabs/error";
3
+ import { isNumber } from "@xylabs/typeof";
3
4
  var functionName = (depth = 2) => {
4
5
  try {
5
6
  throw new Error("Getting function name");
@@ -12,10 +13,10 @@ var functionName = (depth = 2) => {
12
13
  if (item === "new") {
13
14
  newIndex = index;
14
15
  }
15
- return item;
16
+ return true;
16
17
  }
17
18
  }) ?? "<unknown>";
18
- return newIndex ? `${funcName} ${stackParts?.[newIndex + 1]}` : funcName;
19
+ return isNumber(newIndex) ? `${funcName} ${stackParts?.[newIndex + 1]}` : funcName;
19
20
  });
20
21
  }
21
22
  };
@@ -1 +1 @@
1
- {"version":3,"sources":["../../src/functionName.ts"],"sourcesContent":["import { handleError } from '@xylabs/error'\n\nexport const functionName = (depth = 2) => {\n try {\n throw new Error('Getting function name')\n } catch (ex) {\n return handleError(ex, (error) => {\n let newIndex: number | undefined\n const stackParts = error.stack?.split('\\n')[depth].split(' ')\n const funcName\n = stackParts?.find((item, index) => {\n if (item.length > 0 && item !== 'at') {\n // check if constructor\n if (item === 'new') {\n newIndex = index\n }\n return item\n }\n }) ?? '<unknown>'\n return newIndex ? `${funcName} ${stackParts?.[newIndex + 1]}` : funcName\n })\n }\n}\n"],"mappings":";AAAA,SAAS,mBAAmB;AAErB,IAAM,eAAe,CAAC,QAAQ,MAAM;AACzC,MAAI;AACF,UAAM,IAAI,MAAM,uBAAuB;AAAA,EACzC,SAAS,IAAI;AACX,WAAO,YAAY,IAAI,CAAC,UAAU;AAChC,UAAI;AACJ,YAAM,aAAa,MAAM,OAAO,MAAM,IAAI,EAAE,KAAK,EAAE,MAAM,GAAG;AAC5D,YAAM,WACF,YAAY,KAAK,CAAC,MAAM,UAAU;AAClC,YAAI,KAAK,SAAS,KAAK,SAAS,MAAM;AAEpC,cAAI,SAAS,OAAO;AAClB,uBAAW;AAAA,UACb;AACA,iBAAO;AAAA,QACT;AAAA,MACF,CAAC,KAAK;AACR,aAAO,WAAW,GAAG,QAAQ,IAAI,aAAa,WAAW,CAAC,CAAC,KAAK;AAAA,IAClE,CAAC;AAAA,EACH;AACF;","names":[]}
1
+ {"version":3,"sources":["../../src/functionName.ts"],"sourcesContent":["import { handleError } from '@xylabs/error'\nimport { isNumber } from '@xylabs/typeof'\n\nexport const functionName = (depth = 2) => {\n try {\n throw new Error('Getting function name')\n } catch (ex) {\n return handleError(ex, (error) => {\n let newIndex: number | undefined\n const stackParts = error.stack?.split('\\n')[depth].split(' ')\n const funcName\n = stackParts?.find((item, index) => {\n if (item.length > 0 && item !== 'at') {\n // check if constructor\n if (item === 'new') {\n newIndex = index\n }\n return true\n }\n }) ?? '<unknown>'\n return isNumber(newIndex) ? `${funcName} ${stackParts?.[newIndex + 1]}` : funcName\n })\n }\n}\n"],"mappings":";AAAA,SAAS,mBAAmB;AAC5B,SAAS,gBAAgB;AAElB,IAAM,eAAe,CAAC,QAAQ,MAAM;AACzC,MAAI;AACF,UAAM,IAAI,MAAM,uBAAuB;AAAA,EACzC,SAAS,IAAI;AACX,WAAO,YAAY,IAAI,CAAC,UAAU;AAChC,UAAI;AACJ,YAAM,aAAa,MAAM,OAAO,MAAM,IAAI,EAAE,KAAK,EAAE,MAAM,GAAG;AAC5D,YAAM,WACF,YAAY,KAAK,CAAC,MAAM,UAAU;AAClC,YAAI,KAAK,SAAS,KAAK,SAAS,MAAM;AAEpC,cAAI,SAAS,OAAO;AAClB,uBAAW;AAAA,UACb;AACA,iBAAO;AAAA,QACT;AAAA,MACF,CAAC,KAAK;AACR,aAAO,SAAS,QAAQ,IAAI,GAAG,QAAQ,IAAI,aAAa,WAAW,CAAC,CAAC,KAAK;AAAA,IAC5E,CAAC;AAAA,EACH;AACF;","names":[]}
@@ -1 +1 @@
1
- {"version":3,"file":"functionName.d.ts","sourceRoot":"","sources":["../../src/functionName.ts"],"names":[],"mappings":"AAEA,eAAO,MAAM,YAAY,GAAI,cAAS,WAoBrC,CAAA"}
1
+ {"version":3,"file":"functionName.d.ts","sourceRoot":"","sources":["../../src/functionName.ts"],"names":[],"mappings":"AAGA,eAAO,MAAM,YAAY,GAAI,cAAS,WAoBrC,CAAA"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@xylabs/function-name",
3
- "version": "4.8.9",
3
+ "version": "4.9.1",
4
4
  "description": "Primary SDK for using XYO Protocol 2.0",
5
5
  "keywords": [
6
6
  "function",
@@ -37,13 +37,14 @@
37
37
  "module": "dist/neutral/index.mjs",
38
38
  "types": "dist/types/index.d.ts",
39
39
  "dependencies": {
40
- "@xylabs/error": "^4.8.9"
40
+ "@xylabs/error": "^4.9.1",
41
+ "@xylabs/typeof": "^4.9.1"
41
42
  },
42
43
  "devDependencies": {
43
- "@xylabs/ts-scripts-yarn3": "^6.4.5",
44
- "@xylabs/tsconfig": "^6.4.5",
44
+ "@xylabs/ts-scripts-yarn3": "^6.5.5",
45
+ "@xylabs/tsconfig": "^6.5.5",
45
46
  "typescript": "^5.8.3",
46
- "vitest": "^3.1.2"
47
+ "vitest": "^3.1.3"
47
48
  },
48
49
  "engines": {
49
50
  "node": ">=18"
@@ -1,4 +1,5 @@
1
1
  import { handleError } from '@xylabs/error'
2
+ import { isNumber } from '@xylabs/typeof'
2
3
 
3
4
  export const functionName = (depth = 2) => {
4
5
  try {
@@ -14,10 +15,10 @@ export const functionName = (depth = 2) => {
14
15
  if (item === 'new') {
15
16
  newIndex = index
16
17
  }
17
- return item
18
+ return true
18
19
  }
19
20
  }) ?? '<unknown>'
20
- return newIndex ? `${funcName} ${stackParts?.[newIndex + 1]}` : funcName
21
+ return isNumber(newIndex) ? `${funcName} ${stackParts?.[newIndex + 1]}` : funcName
21
22
  })
22
23
  }
23
24
  }