MCPcopy Create free account
hub / github.com/denoland/std / binary

Function binary

toml/_parser.ts:631–639  ·  view source on GitHub ↗
(scanner: Scanner)

Source from the content-addressed store, hash-verified

629
630const BINARY_REGEXP = /0b[01]+(?:_[01]+)*\b/y;
631export function binary(scanner: Scanner): ParseResult<number | string> {
632 scanner.skipWhitespaces();
633 const match = scanner.match(BINARY_REGEXP)?.[0];
634 if (!match) return failure();
635 scanner.next(match.length);
636 const value = match.slice(2).replaceAll("_", "");
637 const number = parseInt(value, 2);
638 return isNaN(number) ? failure() : success(number);
639}
640
641const OCTAL_REGEXP = /0o[0-7]+(?:_[0-7]+)*\b/y;
642export function octal(scanner: Scanner): ParseResult<number | string> {

Callers

nothing calls this directly

Calls 6

failureFunction · 0.85
successFunction · 0.85
matchMethod · 0.80
skipWhitespacesMethod · 0.45
nextMethod · 0.45
sliceMethod · 0.45

Tested by

no test coverage detected