sinew

    1.0.2 • Public • Published
      ██████  ██▓ ███▄    █ ▓█████  █     █░
    ▒██    ▒ ▓██▒ ██ ▀█   █ ▓█   ▀ ▓█░ █ ░█░
    ░ ▓██▄   ▒██▒▓██  ▀█ ██▒▒███   ▒█░ █ ░█ 
      ▒   ██▒░██░▓██▒  ▐▌██▒▒▓█  ▄ ░█░ █ ░█ 
    ▒██████▒▒░██░▒██░   ▓██░░▒████▒░░██▒██▓ 
    ▒ ▒▓▒ ▒ ░░▓  ░ ▒░   ▒ ▒ ░░ ▒░ ░░ ▓░▒ ▒  
    ░ ░▒  ░ ░ ▒ ░░ ░░   ░ ▒░ ░ ░  ░  ▒ ░ ░  
    ░  ░  ░   ▒ ░   ░   ░ ░    ░     ░   ░  
          ░   ░           ░    ░  ░    ░    
    

    sinew

    command-line-interface-tools

    API

    Table of Contents

    helpWithOptions

    Convert a yargs-parser object and a config into a help string

    Parameters
    • conf object a configuration object
    • argv object a yargs-parser parsed argv

    Returns string formatted string

    readRaw

    fs.readFile but curried

    Parameters
    • path string path-to-a-file
    • format string file format
    • callback function standard nodeback style callback
    Examples
    import { readRaw } from "sinew"
    import { pipe, map, __ as skip } from "ramda"
    import { node } from "fluture"
    
    export readFileAndDoStuff = pipe(
      pipe(
        readRaw(skip, 'utf8'),
        node
      ),
      map(x => "preamble:\n" + x)
    )

    Returns any null

    readUTF8

    fs.readFile but curried and with utf8 format chosen

    Parameters
    • path string path-to-a-file
    • callback function a node-style nodeback function
    Examples
    import { readUTF8 } from "sinew"
    import { pipe, map, __ as skip } from "ramda"
    import { node } from "fluture"
    
    export readFileAndDoStuff = pipe(
      pipe(
        readUTF8(skip),
        node
      ),
      map(x => "preamble:\n" + x)
    )

    Returns string a future value of a string

    readFile

    fs.readFile but utf8 and returning a Future

    Parameters
    Examples
    import { readFile } from "sinew"
    import { pipe, map } from "ramda"
    
    export readFileAndDoStuff = pipe(
      readFile,
      map(x => "preamble:\n" + x)
    )

    Returns Future<string> a future value of a string

    writeRaw

    fs.readFile but curried; arity 4

    Parameters
    • path string path-to-a-file
    • data any data to write to a path
    • format (string | object) format or opts
    • callback function a nodeback-style callback function
    Examples
    import {writeRaw} from "sinew"
    writeRaw("my-file.md", "cool", "utf8", (e) => {
      if(e) console.warn(e)
      // done
    })

    writeRaw

    fs.readFile but curried; format utf8

    Parameters
    • path string path-to-a-file
    • data any data to write to a path
    • callback function a nodeback-style callback function
    Examples
    import { writeUTF8 } from "sinew"
    
    writeUTF8('my-file.md', 'cool', (e) => {
      if(e) console.warn(e)
      // done
    })

    writeFile

    Write a utf8 file and wrap the action in a future

    Parameters
    Examples
    import { writeFile, readFile } from "sinew"
    import { curry, pipe, map, chain } from "ramda"
    
    const prepend = curry((pre, file, data) => pipe(
      readFile(file),
      map(raw => pre = raw),
      chain(writeFile)
    ))

    Returns Future<string> a future-wrapped value(?)

    is

    expect(actual).toEqual(expected) but curried

    Parameters
    • expected any an expected value
    • actual any the actual value

    Returns boolean

    matches

    expect(actual).toMatchSnapshot alias as a unary function

    Parameters
    • x any a value

    Returns boolean a boolean value

    testCLI

    A simplified way of testing asynchronous command-line calls using execa.shell Designed for jest testing

    Parameters
    • cli Array<string> commands and flags to pass to execa
    • testName string the name of your test
    • assertion function an assertion function. receives actual value as only param

    testCLI

    A simplified way of testing asynchronous command-line calls Designed for jest testing

    Parameters
    • cli Array<string> commands and flags to pass to execa
    • testName string the name of your test
    • assertion function an assertion function. receives actual value as only param

    Keywords

    none

    Install

    npm i sinew

    DownloadsWeekly Downloads

    7

    Version

    1.0.2

    License

    MIT

    Unpacked Size

    1.84 MB

    Total Files

    73

    Last publish

    Collaborators

    • brekk