lib/core.js
function $file(params, fn) {
    if (params == null) {
        return params;
    }
    let file, encoding;
    if (typeof params === 'string') {
        file = params;
    } else if (Array.isArray(params) && params.length === 2) {
        file = params[0];
        encoding = params[1];
    }
    if (
        typeof file === 'string' &&
        (encoding === undefined || typeof encoding === 'string')
    ) {
        file = fn.$path(file);
        const fs = require('fs');
        if (fs.existsSync(file) && fs.lstatSync(file).isFile()) {
            return fs.readFileSync(file, { encoding });
        }
    }
    throw new Error(
        '$file expects a string or an array with two string elements'
    );
}
function $file(params, fn) {
    if (params == null) {
        return params;
    }
    let file, encoding;
    if (typeof params === 'string') {
        file = params;
    } else if (Array.isArray(params) && params.length === 2) {
        file = params[0];
        encoding = params[1];
    }
    if (
        typeof file === 'string' &&
        (encoding === undefined || typeof encoding === 'string')
    ) {
        file = fn.$path(file);
        const fs = require('fs');
        if (fs.existsSync(file) && fs.lstatSync(file).isFile()) {
            return fs.readFileSync(file, { encoding });
        }
    }
    throw new Error(
        '$file expects a string or an array with two string elements'
    );
}
function $file ( params , fn ) { if ( params == null ) { return params ; } let file , encoding ; if ( typeof params === 'string' ) { file = params ; } else if ( Array . isArray ( params ) && params . length === 2 ) { file = params [ 0 ] ; encoding = params [ 1 ] ; } if ( typeof file === 'string' && ( encoding === undefined || typeof encoding === 'string' ) ) { file = fn . $path ( file ) ; const fs = require ( 'fs' ) ; if ( fs . existsSync ( file ) && fs . lstatSync ( file ) . isFile ( ) ) { return fs . readFileSync ( file , { encoding } ) ; } } throw new Error ( '$file expects a string or an array with two string elements' ) ; }
Resolve the path and read the file with an optional encoding

@param {string|[string, string]} params
@returns {string|Buffer}
Resolve the path and read the file with an optional encoding