Skip to content

Commit 0102c81

Browse files
Move helper to infer-data-type.ts
1 parent 51e9bf7 commit 0102c81

File tree

4 files changed

+11
-8
lines changed

4 files changed

+11
-8
lines changed

packages/tailwindcss/src/compat/default-theme.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import type { NamedUtilityValue } from '../candidate'
2-
import { isPositiveInteger } from '../utilities'
2+
import { isPositiveInteger } from '../utils/infer-data-type'
33
import { segment } from '../utils/segment'
44
import colors from './colors'
55
import type { UserConfig } from './config/types'

packages/tailwindcss/src/utilities.ts

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ import { decl, rule, type AstNode, type Rule } from './ast'
22
import type { Candidate, CandidateModifier, NamedUtilityValue } from './candidate'
33
import type { Theme, ThemeKey } from './theme'
44
import { DefaultMap } from './utils/default-map'
5-
import { inferDataType } from './utils/infer-data-type'
5+
import { inferDataType, isPositiveInteger } from './utils/infer-data-type'
66
import { replaceShadowColors } from './utils/replace-shadow-colors'
77
import { segment } from './utils/segment'
88

@@ -4658,8 +4658,3 @@ export function createUtilities(theme: Theme) {
46584658

46594659
return utilities
46604660
}
4661-
4662-
export function isPositiveInteger(value: any) {
4663-
let num = Number(value)
4664-
return Number.isInteger(num) && num >= 0
4665-
}

packages/tailwindcss/src/utils/infer-data-type.ts

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -320,3 +320,11 @@ const IS_VECTOR = new RegExp(`^${HAS_NUMBER.source} +${HAS_NUMBER.source} +${HAS
320320
function isVector(value: string) {
321321
return IS_VECTOR.test(value)
322322
}
323+
324+
/**
325+
* Returns true of the value can be parsed as a positive whole number.
326+
*/
327+
export function isPositiveInteger(value: any) {
328+
let num = Number(value)
329+
return Number.isInteger(num) && num >= 0
330+
}

packages/tailwindcss/src/variants.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
import { WalkAction, decl, rule, walk, type AstNode, type Rule } from './ast'
22
import { type Variant } from './candidate'
33
import type { Theme } from './theme'
4-
import { isPositiveInteger } from './utilities'
54
import { DefaultMap } from './utils/default-map'
5+
import { isPositiveInteger } from './utils/infer-data-type'
66
import { segment } from './utils/segment'
77

88
type VariantFn<T extends Variant['kind']> = (

0 commit comments

Comments
 (0)