GeezerVisonThe World Wide Web, restored to 800 pixels of glory. |
| Home|About|Gaming cabinet|Archives|How it works|Starter sites |
GeezerVison is showing github.com — yaml/src/stringify/stringifyNumber.ts at main · eemeli/yaml Expand file tree/ Copy pathstringifyNumber.tsMore file actions 33 lines (32 loc) · 968 Bytes / Copy pathstringifyNumber.tsFile metadata and controls33 lines (32 loc) · 968 Bytes 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 import type { Scalar } from '../nodes/Scalar.ts' export function stringifyNumber( { format, minFractionDigits, source, tag, value }: Scalar, version: '1.1' | '1.2' = '1.2' ): string { if (typeof value === 'bigint') return String(value) const num = typeof value === 'number' ? value : Number(value) if (!isFinite(num)) { if (typeof value === 'number' && source) { const source_ = version === '1.1' ? source.replace(/_/g, '') : source if (parseFloat(source_) === num) return source } return isNaN(num) ? '.nan' : num < 0 ? '-.inf' : '.inf' } let n = Object.is(value, -0) ? '-0' : JSON.stringify(value) if ( !format && minFractionDigits && (!tag || tag === 'tag:yaml.org,2002:float') && /^-?\d/.test(n) && !n.includes('e') ) { let i = n.indexOf('.') if (i < 0) { i = n.length n += '.' } let d = minFractionDigits - (n.length - i - 1) while (d-- > 0) n += '0' } return n } |
| You are visitor 01402775 — GeezerVison does not store the pages you look up. Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required. |