hammerspoon2-docs
    Preparing search index...

    Function eachLine

    • Call a function for each line of a file. This behaves exactly like opening the file and calling HSFile.eachLine(): line endings (\n or \r\n) are stripped; the callback may return false (and only false) to stop early; if the callback throws, iteration stops and the exception propagates to you; and invalid UTF-8 stops iteration with hs.fs.lastError.code === "EILSEQ".

      Parameters

      • path: string

        Path to the file. ~ is expanded.

      • callback: (line: string) => boolean | void

        Called once per line. Return false to stop.

      Returns boolean

      true if iteration completed or was stopped by the callback returning false; false if the file could not be opened or read (see hs.fs.lastError), or if the callback threw.