sinew
v1.0.2
Published
██████ ██▓ ███▄ █ ▓█████ █ █░ ▒██ ▒ ▓██▒ ██ ▀█ █ ▓█ ▀ ▓█░ █ ░█░ ░ ▓██▄ ▒██▒▓██ ▀█ ██▒▒███ ▒█░ █ ░█ ▒ ██▒░██░▓██▒ ▐▌██▒▒▓█ ▄ ░█░ █ ░█ ▒██████▒▒░██░▒██░ ▓██░░▒████▒░░██▒██▓ ▒ ▒▓▒ ▒ ░░▓ ░ ▒░ ▒ ▒ ░░ ▒░ ░░
Downloads
2
Readme
██████ ██▓ ███▄ █ ▓█████ █ █░
▒██ ▒ ▓██▒ ██ ▀█ █ ▓█ ▀ ▓█░ █ ░█░
░ ▓██▄ ▒██▒▓██ ▀█ ██▒▒███ ▒█░ █ ░█
▒ ██▒░██░▓██▒ ▐▌██▒▒▓█ ▄ ░█░ █ ░█
▒██████▒▒░██░▒██░ ▓██░░▒████▒░░██▒██▓
▒ ▒▓▒ ▒ ░░▓ ░ ▒░ ▒ ▒ ░░ ▒░ ░░ ▓░▒ ▒
░ ░▒ ░ ░ ▒ ░░ ░░ ░ ▒░ ░ ░ ░ ▒ ░ ░
░ ░ ░ ▒ ░ ░ ░ ░ ░ ░ ░
░ ░ ░ ░ ░ ░
sinew
command-line-interface-tools
API
Table of Contents
helpWithOptions
Convert a yargs-parser object and a config into a help string
Parameters
Returns string formatted string
readRaw
fs.readFile but curried
Parameters
path
string path-to-a-fileformat
string file formatcallback
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
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
path
string path-to-a-file
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-filedata
any data to write to a pathformat
(string | object) format or optscallback
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-filedata
any data to write to a pathcallback
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 valueactual
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 execatestName
string the name of your testassertion
function an assertion function. receives actual value as only param
testCLI
A simplified way of testing asynchronous command-line calls Designed for jest testing