rajt 0.0.16 → 0.0.17

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.
Files changed (2) hide show
  1. package/package.json +3 -4
  2. package/src/utils/lenght.ts +28 -10
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "rajt",
3
3
  "description": "A serverless bundler layer, fully typed for AWS Lambda (Node.js and LLRT) and Cloudflare Workers.",
4
- "version": "0.0.16",
4
+ "version": "0.0.17",
5
5
  "type": "module",
6
6
  "main": "dist/index.js",
7
7
  "exports": {
@@ -11,9 +11,7 @@
11
11
  "./http": "./src/http.ts",
12
12
  "./types": "./src/types.ts"
13
13
  },
14
- "files": [
15
- "src"
16
- ],
14
+ "files": ["src"],
17
15
  "scripts": {
18
16
  "dev": "tsx watch src/dev.ts",
19
17
  "local": "bun run --silent build && bun run --silent sam:local",
@@ -55,6 +53,7 @@
55
53
  "registry": "https://registry.npmjs.org"
56
54
  },
57
55
  "author": "Zunq <open-source@zunq.com>",
56
+ "license": "MIT",
58
57
  "homepage": "https://zunq.dev",
59
58
  "repository": "git://github.com/attla/rajt",
60
59
  "bugs": "https://github.com/attla/rajt/issues",
@@ -1,14 +1,32 @@
1
1
  export default function getLength(item: any): number {
2
2
  const type = typeof item
3
3
 
4
- if (type === 'string')
5
- return item.length
6
- if (Array.isArray(item))
7
- return item.length
8
- if (type === 'object' && item !== null)
9
- return Object.keys(item).length
10
- if (type === 'number')
11
- return item.toString().length
12
-
13
- return 0
4
+ switch (type) {
5
+ case 'string':
6
+ return item.length
7
+
8
+ case 'number':
9
+ case 'bigint':
10
+ // case 'function':
11
+ return item.toString().length
12
+
13
+ // case 'boolean':
14
+ // return item ? 1 : 0
15
+
16
+ // case 'symbol':
17
+ // return item.toString().length - 8
18
+
19
+ case 'object':
20
+ if (item === null)
21
+ return 0
22
+
23
+ if (Array.isArray(item))
24
+ return item.length
25
+
26
+ return Object.keys(item).length
27
+
28
+ case 'undefined':
29
+ default:
30
+ return 0
31
+ }
14
32
  }