3.0.0 • Published 5 years ago

@hafdon/lib v3.0.0

Weekly downloads
-
License
ISC
Repository
github
Last release
5 years ago

installation

npm i @hafdon/lib

exports

readfile

An async function wrapper of fs-extra that reads a file's contents and returns a data object of type :

const DATATYPE = ['file:utf8']

const Package = {
    error: Object, // Error() object
    _error: Boolean, // true if Error() object attached
    data: Object, // the file contents
    datatype: String, // string of enum DATATYPE
}

use like this:

const { readfile } = require('@hafdon/lib')

async function main() {
    const file = `${__dirname}/query1.sql`
    const package = await readfile(filename)

    if (!package._error && package.datatype === 'file:utf-8') {
        console.log(package.data)
    } else {
        console.log(package.error)
    }
}

main()
3.0.0

5 years ago

2.1.0

5 years ago

2.0.0

5 years ago

1.2.0

5 years ago

1.1.0

5 years ago

1.0.1

5 years ago

1.0.0

5 years ago