@allkit/shared 0.0.3 → 0.0.5

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 (81) hide show
  1. package/package.json +21 -26
  2. package/dist/README.md +0 -1
  3. package/dist/package.json +0 -21
  4. package/eslint.config.js +0 -10
  5. package/scripts/build.mjs +0 -95
  6. package/skills/SKILL.md +0 -240
  7. package/skills/examples/usage.ts +0 -88
  8. package/skills/references/clipboard.md +0 -39
  9. package/skills/references/cloneDeep.md +0 -60
  10. package/skills/references/cookie.md +0 -56
  11. package/skills/references/date.md +0 -466
  12. package/skills/references/device.md +0 -138
  13. package/skills/references/element.md +0 -99
  14. package/skills/references/is.md +0 -415
  15. package/skills/references/lodash.md +0 -472
  16. package/skills/references/number.md +0 -248
  17. package/skills/references/storage.md +0 -113
  18. package/skills/references/string.md +0 -126
  19. package/skills/references/timer.md +0 -78
  20. package/src/clipboard/index.ts +0 -26
  21. package/src/cloneDeep/__test__/cloneDeep.test.ts +0 -92
  22. package/src/cloneDeep/index.ts +0 -168
  23. package/src/constants.ts +0 -27
  24. package/src/cookie/index.ts +0 -44
  25. package/src/date/__test__/date-diff.test.ts +0 -23
  26. package/src/date/__test__/date-duration.test.ts +0 -140
  27. package/src/date/__test__/date-from.test.ts +0 -64
  28. package/src/date/__test__/date.test.ts +0 -67
  29. package/src/date/index.ts +0 -331
  30. package/src/device/__test__/device.test.ts +0 -138
  31. package/src/device/index.ts +0 -125
  32. package/src/element/index.ts +0 -100
  33. package/src/index.ts +0 -14
  34. package/src/is/__test__/is.test.ts +0 -320
  35. package/src/is/index.ts +0 -293
  36. package/src/lodash/__test__/lodash.test.ts +0 -111
  37. package/src/lodash/__test__/obj-string.test.ts +0 -107
  38. package/src/lodash/__test__/uniqueId.test.ts +0 -40
  39. package/src/lodash/index.ts +0 -396
  40. package/src/number/__test__/number.test.ts +0 -137
  41. package/src/number/index.ts +0 -161
  42. package/src/storage/__test__/storage.test.ts +0 -44
  43. package/src/storage/index.ts +0 -185
  44. package/src/string/__test__/string.test.ts +0 -24
  45. package/src/string/index.ts +0 -49
  46. package/src/timer/index.ts +0 -15
  47. package/tsconfig.json +0 -25
  48. package/types/global.d.ts +0 -13
  49. package/vite.config.ts +0 -16
  50. package/vitest.config.ts +0 -28
  51. /package/{dist/clipboard → clipboard}/index.d.ts +0 -0
  52. /package/{dist/cloneDeep → cloneDeep}/index.d.ts +0 -0
  53. /package/{dist/constants.d.ts → constants.d.ts} +0 -0
  54. /package/{dist/cookie → cookie}/index.d.ts +0 -0
  55. /package/{dist/date → date}/index.d.ts +0 -0
  56. /package/{dist/device → device}/index.d.ts +0 -0
  57. /package/{dist/element → element}/index.d.ts +0 -0
  58. /package/{dist/index.d.ts → index.d.ts} +0 -0
  59. /package/{dist/is → is}/index.d.ts +0 -0
  60. /package/{dist/lodash → lodash}/index.d.ts +0 -0
  61. /package/{dist/number → number}/index.d.ts +0 -0
  62. /package/{dist/shared.es.d.ts → shared.es.d.ts} +0 -0
  63. /package/{dist/shared.es.js → shared.es.js} +0 -0
  64. /package/{dist/shared.umd.js → shared.umd.js} +0 -0
  65. /package/{dist/skills → skills/shared}/SKILL.md +0 -0
  66. /package/{dist/skills → skills/shared}/examples/usage.ts +0 -0
  67. /package/{dist/skills → skills/shared}/references/clipboard.md +0 -0
  68. /package/{dist/skills → skills/shared}/references/cloneDeep.md +0 -0
  69. /package/{dist/skills → skills/shared}/references/cookie.md +0 -0
  70. /package/{dist/skills → skills/shared}/references/date.md +0 -0
  71. /package/{dist/skills → skills/shared}/references/device.md +0 -0
  72. /package/{dist/skills → skills/shared}/references/element.md +0 -0
  73. /package/{dist/skills → skills/shared}/references/is.md +0 -0
  74. /package/{dist/skills → skills/shared}/references/lodash.md +0 -0
  75. /package/{dist/skills → skills/shared}/references/number.md +0 -0
  76. /package/{dist/skills → skills/shared}/references/storage.md +0 -0
  77. /package/{dist/skills → skills/shared}/references/string.md +0 -0
  78. /package/{dist/skills → skills/shared}/references/timer.md +0 -0
  79. /package/{dist/storage → storage}/index.d.ts +0 -0
  80. /package/{dist/string → string}/index.d.ts +0 -0
  81. /package/{dist/timer → timer}/index.d.ts +0 -0
@@ -1,138 +0,0 @@
1
- import { describe, expect, test } from 'vitest'
2
- import { getDeviceBrand, EnumDeviceBrand } from '../'
3
-
4
- describe('device.ts', () => {
5
- test('getDeviceBrand - iPhone设备', () => {
6
- // 模拟iPhone的userAgent
7
- Object.defineProperty(navigator, 'userAgent', {
8
- writable: true,
9
- configurable: true,
10
- value: 'Mozilla/5.0 (iPhone; CPU iPhone OS 14_0 like Mac OS X)',
11
- })
12
-
13
- const brand = getDeviceBrand()
14
- expect(brand).toBe(EnumDeviceBrand.IPHONE)
15
- })
16
-
17
- test('getDeviceBrand - 小米设备', () => {
18
- // 模拟小米设备的userAgent
19
- Object.defineProperty(navigator, 'userAgent', {
20
- writable: true,
21
- configurable: true,
22
- value:
23
- 'Mozilla/5.0 (Linux; U; Android 15; zh-cn; 23116PN5BC Build/AQ3A.240627.003) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/122.0.6261.119 Mobile Safari/537.36 XiaoMi/MiuiBrowser/19.7.30708',
24
- })
25
-
26
- const brand = getDeviceBrand()
27
- expect(brand).toBe(EnumDeviceBrand.XIAOMI)
28
- })
29
-
30
- test('getDeviceBrand - OPPO设备', () => {
31
- // 模拟OPPO设备的userAgent
32
- Object.defineProperty(navigator, 'userAgent', {
33
- writable: true,
34
- configurable: true,
35
- value: 'Mozilla/5.0 (Linux; Android 10; OPPO R11)',
36
- })
37
-
38
- const brand = getDeviceBrand()
39
- expect(brand).toBe(EnumDeviceBrand.OPPO)
40
- })
41
-
42
- test('getDeviceBrand - VIVO设备', () => {
43
- // 模拟VIVO设备的userAgent
44
- Object.defineProperty(navigator, 'userAgent', {
45
- writable: true,
46
- configurable: true,
47
- value:
48
- 'Mozilla/5.0 (Linux; Android 15; V2227A) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/131.0.6778.200 Mobile Safari/537.36 VivoBrowser/26.3.3.0',
49
- })
50
-
51
- const brand = getDeviceBrand()
52
- expect(brand).toBe(EnumDeviceBrand.VIVO)
53
- })
54
-
55
- test('getDeviceBrand - 华为设备', () => {
56
- // 模拟华为设备的userAgent
57
- Object.defineProperty(navigator, 'userAgent', {
58
- writable: true,
59
- configurable: true,
60
- value: 'Mozilla/5.0 (Linux; Android 10; HUAWEI P40)',
61
- })
62
-
63
- const brand = getDeviceBrand()
64
- expect(brand).toBe(EnumDeviceBrand.HUAWEI)
65
- })
66
-
67
- test('getDeviceBrand - 荣耀设备', () => {
68
- // 模拟荣耀设备的userAgent
69
- Object.defineProperty(navigator, 'userAgent', {
70
- writable: true,
71
- configurable: true,
72
- value: 'Mozilla/5.0 (Linux; Android 10; Honor 30)',
73
- })
74
-
75
- const brand = getDeviceBrand()
76
- expect(brand).toBe(EnumDeviceBrand.HONOR)
77
- })
78
-
79
- test('getDeviceBrand - 一加设备', () => {
80
- // 模拟一加设备的userAgent
81
- Object.defineProperty(navigator, 'userAgent', {
82
- writable: true,
83
- configurable: true,
84
- value: 'Mozilla/5.0 (Linux; Android 10; ONEPLUS A6000)',
85
- })
86
-
87
- const brand = getDeviceBrand()
88
- expect(brand).toBe(EnumDeviceBrand.ONE_PLUS)
89
- })
90
-
91
- test('getDeviceBrand - 三星设备', () => {
92
- // 模拟三星设备的userAgent
93
- Object.defineProperty(navigator, 'userAgent', {
94
- writable: true,
95
- configurable: true,
96
- value: 'Mozilla/5.0 (Linux; Android 10; SAMSUNG Galaxy S21)',
97
- })
98
-
99
- const brand = getDeviceBrand()
100
- expect(brand).toBe(EnumDeviceBrand.SAMSUNG)
101
- })
102
-
103
- test('getDeviceBrand - 魅族设备', () => {
104
- // 模拟魅族设备的userAgent
105
- Object.defineProperty(navigator, 'userAgent', {
106
- writable: true,
107
- configurable: true,
108
- value: 'Mozilla/5.0 (Linux; Android 10; MEIZU 18)',
109
- })
110
-
111
- const brand = getDeviceBrand()
112
- expect(brand).toBe(EnumDeviceBrand.MEIZU)
113
- })
114
-
115
- test('getDeviceBrand - 联想设备', () => {
116
- // 模拟联想设备的userAgent
117
- Object.defineProperty(navigator, 'userAgent', {
118
- writable: true,
119
- configurable: true,
120
- value: 'Mozilla/5.0 (Linux; Android 10; LENOVO Legion)',
121
- })
122
-
123
- const brand = getDeviceBrand()
124
- expect(brand).toBe(EnumDeviceBrand.LENOVO)
125
- })
126
-
127
- test('getDeviceBrand - 未知设备', () => {
128
- // 模拟未知设备的userAgent
129
- Object.defineProperty(navigator, 'userAgent', {
130
- writable: true,
131
- configurable: true,
132
- value: 'Mozilla/5.0 (Unknown Device)',
133
- })
134
-
135
- const brand = getDeviceBrand()
136
- expect(brand).toBe(undefined)
137
- })
138
- })
@@ -1,125 +0,0 @@
1
- /**
2
- * 是否是Android客户端
3
- * @example
4
- * ```ts
5
- * let result= isAndroid()
6
- * ```
7
- */
8
-
9
- export function isAndroid() {
10
- return navigator.userAgent.indexOf('Android') > -1
11
- }
12
- /**
13
- * 是否是ios客户端
14
- * @example
15
- * ```ts
16
- * let result= isIos()
17
- * ```
18
- */
19
- export function isIos() {
20
- return /(iPhone|iPad|iPod)/i.test(navigator.userAgent)
21
- }
22
-
23
- /**
24
- * 是否是鸿蒙系统
25
- * @example
26
- * ```ts
27
- * let result= isHarmony()
28
- * ```
29
- */
30
- export function isHarmony() {
31
- return window.navigator.userAgent.includes('OpenHarmony')
32
- }
33
-
34
- /**
35
- * 是否是微信客户端
36
- * @example
37
- * ```ts
38
- * let result= isWeChat()
39
- * ```
40
- */
41
- export function isWeChat() {
42
- return navigator.userAgent.toLowerCase().indexOf('micromessenger') !== -1
43
- }
44
- /**
45
- * 是否是微信小程序
46
- * @example
47
- * ```ts
48
- * let result= isWxMiniProgram()
49
- * ```
50
- */
51
- export function isWxMiniProgram() {
52
- return isWeChat() && window.navigator.userAgent.includes('miniProgram')
53
- }
54
-
55
- export enum EnumDeviceBrand {
56
- /** 小米 */
57
- XIAOMI = 'xiaomi',
58
- /** OPPO */
59
- OPPO = 'oppo',
60
- /** Vivo */
61
- VIVO = 'vivo',
62
- /** 华为 */
63
- HUAWEI = 'huawei',
64
- /** 荣耀 */
65
- HONOR = 'honor',
66
- /** 一加 */
67
- ONE_PLUS = 'oneplus',
68
- /** 三星 */
69
- SAMSUNG = 'samsung',
70
- /** 苹果 */
71
- IPHONE = 'iphone',
72
- /** 魅族 */
73
- MEIZU = 'meizu',
74
- /** 联想 */
75
- LENOVO = 'lenovo',
76
- }
77
-
78
- /**
79
- * 获取设备厂商
80
- * @example
81
- * ```ts
82
- * let brand = getDeviceBrand()
83
- * ```
84
- */
85
- export function getDeviceBrand() {
86
- const userAgent = navigator.userAgent.toLowerCase()
87
- if (userAgent.includes('iphone') || userAgent.includes('ipad') || userAgent.includes('ipod')) {
88
- return EnumDeviceBrand.IPHONE
89
- }
90
-
91
- if (
92
- userAgent.includes('xiaomi') ||
93
- userAgent.includes('miui') ||
94
- userAgent.includes('redmi') ||
95
- userAgent.includes('mix')
96
- ) {
97
- return EnumDeviceBrand.XIAOMI
98
- }
99
- if (userAgent.includes('oppo') || userAgent.includes('realme') || userAgent.includes('heytap')) {
100
- return EnumDeviceBrand.OPPO
101
- }
102
- if (userAgent.includes('vivo')) {
103
- return EnumDeviceBrand.VIVO
104
- }
105
- if (userAgent.includes('huawei')) {
106
- return EnumDeviceBrand.HUAWEI
107
- }
108
- if (userAgent.includes('oneplus')) {
109
- return EnumDeviceBrand.ONE_PLUS
110
- }
111
- if (userAgent.includes('honor')) {
112
- return EnumDeviceBrand.HONOR
113
- }
114
-
115
- if (userAgent.includes('samsung')) {
116
- return EnumDeviceBrand.SAMSUNG
117
- }
118
- if (userAgent.includes('meizu')) {
119
- return EnumDeviceBrand.MEIZU
120
- }
121
- if (userAgent.includes('lenovo')) {
122
- return EnumDeviceBrand.LENOVO
123
- }
124
- return undefined
125
- }
@@ -1,100 +0,0 @@
1
- import { isClient, isWindow } from '../is'
2
-
3
- export const getGlobalThis = () => {
4
- if (typeof globalThis !== 'undefined') {
5
- return globalThis
6
- }
7
-
8
- if (isClient) {
9
- return window
10
- }
11
- //@ts-ignore
12
- return typeof global !== 'undefined' ? global : self
13
- }
14
-
15
- export const requestAnimationFrame = (fn: FrameRequestCallback): number => {
16
- const globalThis = getGlobalThis()
17
-
18
- return globalThis.requestAnimationFrame
19
- ? globalThis.requestAnimationFrame(fn)
20
- : globalThis.setTimeout(fn)
21
- }
22
-
23
- export const cancelAnimationFrame = (handle: number) => {
24
- const globalThis = getGlobalThis()
25
-
26
- globalThis.cancelAnimationFrame
27
- ? globalThis.cancelAnimationFrame(handle)
28
- : globalThis.clearTimeout(handle)
29
- }
30
-
31
- export const raf = () =>
32
- new Promise((resolve) => {
33
- requestAnimationFrame(resolve)
34
- })
35
-
36
- export const doubleRaf = () =>
37
- new Promise((resolve) => {
38
- requestAnimationFrame(() => {
39
- requestAnimationFrame(resolve)
40
- })
41
- })
42
-
43
- // shorthand only
44
- export const getStyle = (element: Element) => window.getComputedStyle(element)
45
-
46
- /** 获取dom的rect */
47
- export const getRect = (element: Element | Window): DOMRect => {
48
- if (isWindow(element)) {
49
- const width = element.innerWidth
50
- const height = element.innerHeight
51
- const rect = {
52
- x: 0,
53
- y: 0,
54
- top: 0,
55
- left: 0,
56
- right: width,
57
- bottom: height,
58
- width,
59
- height,
60
- }
61
-
62
- return {
63
- ...rect,
64
- toJSON: () => rect,
65
- }
66
- }
67
-
68
- return element.getBoundingClientRect()
69
- }
70
-
71
- export const inViewport = (element: HTMLElement) => {
72
- const { top, bottom, left, right } = getRect(element)
73
- const { width, height } = getRect(window)
74
-
75
- const xInViewport = left <= width && right >= 0
76
- const yInViewport = top <= height && bottom >= 0
77
-
78
- return xInViewport && yInViewport
79
- }
80
-
81
- export const preventDefault = (event: Event) => {
82
- if (event.cancelable === false) {
83
- return
84
- }
85
-
86
- event.preventDefault()
87
- }
88
-
89
- export const getScrollTop = (element: Element | Window) => {
90
- const top = 'scrollTop' in element ? element.scrollTop : element.scrollY
91
-
92
- // iOS scroll bounce cause minus scrollTop
93
- return Math.max(top, 0)
94
- }
95
-
96
- export const getScrollLeft = (element: Element | Window) => {
97
- const left = 'scrollLeft' in element ? element.scrollLeft : element.scrollX
98
-
99
- return Math.max(left, 0)
100
- }
package/src/index.ts DELETED
@@ -1,14 +0,0 @@
1
- export * from './clipboard'
2
- export * from './cloneDeep'
3
- export * from './cookie'
4
- export * from './date'
5
- export * from './device'
6
- export * from './element'
7
- export * from './is'
8
- export * from './lodash'
9
- export * from './number'
10
- export * from './storage'
11
- export * from './string'
12
- export * from './timer'
13
-
14
- export * from './constants'
@@ -1,320 +0,0 @@
1
- import { describe, expect, test } from 'vitest'
2
- import { isEmpty, isEmptyValue, isInteger, isNumeric, isObject, isPlainObject } from '../'
3
-
4
- describe('is.ts', () => {
5
- test('isObject - param simple object', () => {
6
- const obj = {
7
- a: 1,
8
- b: 2,
9
- }
10
- expect(isObject(obj)).toBe(true)
11
- })
12
- test('isObject - param not object', () => {
13
- const obj = 1
14
- expect(isObject(obj)).toBe(false)
15
- })
16
- test('isObject - param null', () => {
17
- const obj = null
18
- expect(isObject(obj)).toBe(false)
19
- })
20
- test('isObject - param undefined', () => {
21
- const obj = undefined
22
- expect(isObject(obj)).toBe(false)
23
- })
24
- test('isObject - param array', () => {
25
- const obj = [1, 2, 3]
26
- expect(isObject(obj)).toBe(true)
27
- })
28
- test('isObject - param function', () => {
29
- const obj = () => {
30
- console.log('111')
31
- }
32
- expect(isObject(obj)).toBe(false)
33
- })
34
- test('isObject - param date', () => {
35
- const obj = new Date()
36
- expect(isObject(obj)).toBe(true)
37
- })
38
- test('isObject - param map', () => {
39
- const obj = new Map()
40
- expect(isObject(obj)).toBe(true)
41
- })
42
- test('isObject - param set', () => {
43
- const obj = new Set()
44
- expect(isObject(obj)).toBe(true)
45
- })
46
-
47
- test('isPlainObject - param simple object', () => {
48
- const obj = {
49
- a: 1,
50
- b: 2,
51
- }
52
- expect(isPlainObject(obj)).toBe(true)
53
- })
54
- test('isPlainObject - param not object', () => {
55
- const obj = 1
56
- expect(isPlainObject(obj)).toBe(false)
57
- })
58
- test('isPlainObject - param null', () => {
59
- const obj = null
60
- expect(isPlainObject(obj)).toBe(false)
61
- })
62
- test('isPlainObject - param undefined', () => {
63
- const obj = undefined
64
- expect(isPlainObject(obj)).toBe(false)
65
- })
66
- test('isPlainObject - param array', () => {
67
- const obj = [1, 2, 3]
68
- expect(isPlainObject(obj)).toBe(false)
69
- })
70
-
71
- test('isEmpty - param not object', () => {
72
- const obj = 1
73
- expect(isEmpty(obj)).toBe(false)
74
- })
75
- test('isEmpty - param empty object', () => {
76
- const obj = {}
77
- expect(isEmpty(obj)).toBe(true)
78
- })
79
- test('isEmpty - param empty array', () => {
80
- const obj = [] as any[]
81
- expect(isEmpty(obj)).toBe(true)
82
- })
83
- test('isEmpty - param empty map', () => {
84
- const obj = new Map()
85
- expect(isEmpty(obj)).toBe(true)
86
- })
87
- test('isEmpty - param empty set', () => {
88
- const obj = new Set()
89
- expect(isEmpty(obj)).toBe(true)
90
- })
91
- test('isEmpty - param empty string', () => {
92
- const obj = ''
93
- expect(isEmpty(obj)).toBe(true)
94
- })
95
-
96
- test('isEmptyValue - param not object', () => {
97
- const obj = 1
98
- expect(isEmptyValue(obj)).toBe(false)
99
- })
100
- test('isEmptyValue - param empty string', () => {
101
- const obj = ''
102
- expect(isEmptyValue(obj)).toBe(true)
103
- })
104
- test('isEmptyValue - param null', () => {
105
- const obj = null
106
- expect(isEmptyValue(obj)).toBe(true)
107
- })
108
- test('isEmptyValue - param undefined', () => {
109
- const obj = undefined
110
- expect(isEmptyValue(obj)).toBe(true)
111
- })
112
-
113
- test('isEmptyValue - param 0', () => {
114
- const obj = 0
115
- expect(isEmptyValue(obj)).toBe(false)
116
- })
117
-
118
- test('isNumeric - param null', () => {
119
- const obj = null
120
- expect(isNumeric(obj)).toBe(false)
121
- })
122
- test('isNumeric - param undefined', () => {
123
- const obj = undefined
124
- expect(isNumeric(obj)).toBe(false)
125
- })
126
-
127
- test('isNumeric - param is object', () => {
128
- const obj = {}
129
- expect(isNumeric(obj)).toBe(false)
130
- })
131
-
132
- test('isNumeric - param 0', () => {
133
- const obj = 0
134
- expect(isNumeric(obj)).toBe(true)
135
- })
136
- test('isNumeric - param 0', () => {
137
- const obj = '0'
138
- expect(isNumeric(obj)).toBe(true)
139
- })
140
- test('isNumeric - param 1', () => {
141
- const obj = 1
142
- expect(isNumeric(obj)).toBe(true)
143
- })
144
- test('isNumeric - param 1 string', () => {
145
- const obj = '1'
146
- expect(isNumeric(obj)).toBe(true)
147
- })
148
-
149
- test('isNumeric - param 1.1 string', () => {
150
- const obj = '1.1'
151
- expect(isNumeric(obj)).toBe(true)
152
- })
153
-
154
- test('isNumeric - param 1.1.1', () => {
155
- const obj = '1.1.1'
156
- expect(isNumeric(obj)).toBe(false)
157
- })
158
-
159
- // isInteger 测试
160
- test('isInteger - param positive integer number', () => {
161
- expect(isInteger(123)).toBe(true)
162
- })
163
-
164
- test('isInteger - param negative integer number', () => {
165
- expect(isInteger(-456)).toBe(true)
166
- })
167
-
168
- test('isInteger - param zero', () => {
169
- expect(isInteger(0)).toBe(true)
170
- })
171
-
172
- test('isInteger - param positive integer string', () => {
173
- expect(isInteger('123')).toBe(true)
174
- })
175
-
176
- test('isInteger - param negative integer string', () => {
177
- expect(isInteger('-456')).toBe(true)
178
- })
179
-
180
- test('isInteger - param zero string', () => {
181
- expect(isInteger('0')).toBe(true)
182
- })
183
-
184
- test('isInteger - param float number', () => {
185
- expect(isInteger(3.14)).toBe(false)
186
- })
187
-
188
- test('isInteger - param float string', () => {
189
- expect(isInteger('3.14')).toBe(false)
190
- })
191
-
192
- test('isInteger - param string with trailing dot', () => {
193
- expect(isInteger('1.')).toBe(false)
194
- })
195
-
196
- test('isInteger - param string with leading dot', () => {
197
- expect(isInteger('.5')).toBe(false)
198
- })
199
-
200
- test('isInteger - param NaN', () => {
201
- expect(isInteger(NaN)).toBe(false)
202
- })
203
-
204
- test('isInteger - param Infinity', () => {
205
- expect(isInteger(Infinity)).toBe(false)
206
- })
207
-
208
- test('isInteger - param -Infinity', () => {
209
- expect(isInteger(-Infinity)).toBe(false)
210
- })
211
-
212
- test('isInteger - param empty string', () => {
213
- expect(isInteger('')).toBe(false)
214
- })
215
-
216
- test('isInteger - param non-numeric string', () => {
217
- expect(isInteger('abc')).toBe(false)
218
- })
219
-
220
- test('isInteger - param null', () => {
221
- expect(isInteger(null)).toBe(false)
222
- })
223
-
224
- test('isInteger - param undefined', () => {
225
- expect(isInteger(undefined)).toBe(false)
226
- })
227
-
228
- test('isInteger - param object', () => {
229
- expect(isInteger({})).toBe(false)
230
- })
231
-
232
- test('isInteger - param array', () => {
233
- expect(isInteger([1, 2, 3])).toBe(false)
234
- })
235
-
236
- test('isInteger - param string with leading zeros', () => {
237
- expect(isInteger('007')).toBe(false)
238
- })
239
-
240
- test('isInteger - param string with spaces', () => {
241
- expect(isInteger(' 123 ')).toBe(false)
242
- })
243
-
244
- test('isInteger - param string with plus sign', () => {
245
- expect(isInteger('+123')).toBe(false)
246
- })
247
-
248
- // isNumeric 额外测试
249
- test('isNumeric - param positive float number', () => {
250
- expect(isNumeric(3.14)).toBe(true)
251
- })
252
-
253
- test('isNumeric - param negative float number', () => {
254
- expect(isNumeric(-0.5)).toBe(true)
255
- })
256
-
257
- test('isNumeric - param positive float string', () => {
258
- expect(isNumeric('3.14')).toBe(true)
259
- })
260
-
261
- test('isNumeric - param negative float string', () => {
262
- expect(isNumeric('-0.5')).toBe(true)
263
- })
264
-
265
- test('isNumeric - param negative integer string', () => {
266
- expect(isNumeric('-789')).toBe(true)
267
- })
268
-
269
- test('isNumeric - param string with trailing dot', () => {
270
- expect(isNumeric('1.')).toBe(false)
271
- })
272
-
273
- test('isNumeric - param string with leading dot', () => {
274
- expect(isNumeric('.5')).toBe(false)
275
- })
276
-
277
- test('isNumeric - param NaN', () => {
278
- expect(isNumeric(NaN)).toBe(false)
279
- })
280
-
281
- test('isNumeric - param Infinity', () => {
282
- expect(isNumeric(Infinity)).toBe(false)
283
- })
284
-
285
- test('isNumeric - param -Infinity', () => {
286
- expect(isNumeric(-Infinity)).toBe(false)
287
- })
288
-
289
- test('isNumeric - param empty string', () => {
290
- expect(isNumeric('')).toBe(false)
291
- })
292
-
293
- test('isNumeric - param non-numeric string', () => {
294
- expect(isNumeric('abc')).toBe(false)
295
- })
296
-
297
- test('isNumeric - param array', () => {
298
- expect(isNumeric([1, 2, 3])).toBe(false)
299
- })
300
-
301
- test('isNumeric - param string with leading zeros', () => {
302
- expect(isNumeric('007')).toBe(false)
303
- })
304
-
305
- test('isNumeric - param string with spaces', () => {
306
- expect(isNumeric(' 123 ')).toBe(false)
307
- })
308
-
309
- test('isNumeric - param string with plus sign', () => {
310
- expect(isNumeric('+123')).toBe(false)
311
- })
312
-
313
- test('isNumeric - param scientific notation string', () => {
314
- expect(isNumeric('1e10')).toBe(false)
315
- })
316
-
317
- test('isNumeric - param multiple dots', () => {
318
- expect(isNumeric('1.2.3')).toBe(false)
319
- })
320
- })