lines-unlines
    TypeScript icon, indicating that this package has built-in type declarations

    1.0.0 • Public • Published

    lines-unlines

    Haskell's lines and unlines in TypeScript.

    NPM Version Downloads Stats

    Installation

    npm install --save lines-unlines
    

    Usage

    import { lines, unlines } from "lines-unlines";
     
    lines("one\ntwo\n"); // ["one","two"]
     
    unlines(["one", "two"]); // "one\ntwo\n"

    For details, refer to the Haskell documentation. Note in particular that lines is not the same function as _ => _.split("\n"), and unlines is not the same as _ => _.join("\n").

    Note also that, strictly speaking, neither lines nor unlines is the other's inverse, even though Hackage (as of 2019‑07‑26) says that "unlines is an inverse operation to lines". For example, unlines (lines "a") evaluates to "a\n", and lines (unlines ["\n"]) evaluates to ["", ""].

    Contribute

    npm run verify lints, builds and tests the package.

    Test cases can be generated using GHCi* (Haskell's REPL, included in the Haskell Platform):

    $ ghci Spec.hs
    *Main> spec lines ["", "one"]
    *Main> spec unlines [[], ["one"]]
    

    The output can then be pasted into index.test.ts.

    * If you have the Nix package manager, you can run nix-shell to get a shell with ghci on the path.

    Install

    npm i lines-unlines

    DownloadsWeekly Downloads

    82

    Version

    1.0.0

    License

    MIT

    Unpacked Size

    5.46 kB

    Total Files

    7

    Last publish

    Collaborators

    • avatar