Back to Explore

sindresorhus/detect-newline

GitHub
1 watchersOpen source

Last release:

Detect-newline is a small JavaScript utility that inspects a string and returns the dominant newline character it contains (such as `\n` or `\r\n`). It is useful for normalizing or handling text files when you need to detect whether lines are separated by a specific newline style, and returns `undefined` when no newline is found (or `\n` in the “graceful” variant).

Project status

  • This repo (sindresorhus/detect-newline) appears quiet or in maintenance mode, with the most recent upstream push and published update on 2023-09-23, which is far in the past relative to today (2026-08-12).
  • Update cadence is sparse, with a major update in 2021-10-14 (v4.0.0) and then only a documentation-only update in 2023-09-23 (v4.0.1), suggesting no active feature or bugfix flow recently.

AI summary generated

AI-generated from public sources. May be inaccurate. Report

Recent updates

  • v4.0.1

    Release v4.0.1 contains documentation-only updates. The code diff shows changes limited to README text and TypeScript declaration (JSDoc) comments, plus adding GitHub metadata files (funding and security policy). No functional logic changes are present in the diff.

  • v4.0.0

    v4.0.0 is a major release of detect-newline that switches the package to pure ESM and raises the minimum supported Node.js version. The code diff also changes the public API shape, replacing the previous `graceful` attached property with a separate named export.

    Breaking
  • v3.1.0

    v3.1.0 updates detect-newline to handle non-string inputs more safely. The `graceful` helper now returns `\n` instead of failing when given values that are not strings.

  • v3.0.0

    v3.0.0 introduces a small API behavior change for newline detection, changing the return value when no newline is found. It also raises the minimum supported Node.js version and adds TypeScript type definitions for better developer experience.

    BreakingFeatures