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

  • Maintenance status: The last upstream push and latest recorded updates are from 2023-09-23, which is nearly three years ago as of 2026-08-13, so the repository appears quiet/dormant rather than actively maintained.
  • Update cadence: Updates are sparse, with a major change in 2021-10-14 (v4.0.0) and only a documentation-only v4.0.1 in 2023-09-23, suggesting no ongoing frequent development.

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