Module

x/dax/src/deps.ts>fs.detect

Cross-platform shell tools for Deno and Node.js inspired by zx.
Very Popular
Latest
function fs.detect
import { fs } from "https://dotland.deno.dev/x/dax@0.39.2/src/deps.ts";
const { detect } = fs;

Detect the EOL character for string input. returns null if no newline.

Examples

Example 1

import { detect, EOL } from "https://deno.land/std@$STD_VERSION/fs/mod.ts";

const CRLFinput = "deno\r\nis not\r\nnode";
const Mixedinput = "deno\nis not\r\nnode";
const LFinput = "deno\nis not\nnode";
const NoNLinput = "deno is not node";

detect(LFinput); // output EOL.LF
detect(CRLFinput); // output EOL.CRLF
detect(Mixedinput); // output EOL.CRLF
detect(NoNLinput); // output null

Parameters

content: string

Returns

EOL | null