How to use the istextorbinary.isBinary function in istextorbinary

To help you get started, we’ve selected a few istextorbinary examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github frctl / fractal / src / core / fs.js View on Github external
'use strict';

const Promise = require('bluebird');
const Path = require('path');
const co = require('co');
const _ = require('lodash');
const fs = Promise.promisifyAll(require('fs'));
const readFile = Promise.promisify(fs.readFile);
const isBinary = Promise.promisify(require('istextorbinary').isBinary);
const utils = require('./utils');
const glob = require('globby');

const notBinary = ['.nunj', '.nunjucks', '.hbs', '.handlebars', '.jsx', '.twig']; // TODO: handle this in a scalable, extendable way

module.exports = {

    describe(dir, relDir, filter) {
        filter = filter || (filePath => !(/(^|\/)\.[^\/\.]/g).test(filePath));

        return dirscribe(dir, {
            filter: filter,
            after: files => _.orderBy(files, ['isDirectory', 'order', 'path'], ['desc', 'asc', 'asc']),
            build: build,
        });
github frctl / fractal / src / fs.js View on Github external
'use strict';

const Promise   = require('bluebird');
const Path      = require('path');
const co        = require('co');
const _         = require('lodash');
const dirscribe = require('@allmarkedup/dirscribe');
const fs        = require('fs');
const readFile  = Promise.promisify(fs.readFile);
const isBinary  = Promise.promisify(require('istextorbinary').isBinary);
const utils     = require('./utils');
const console       = require('./console');

module.exports = {

    describe(dir, noCache) {

        dir = Path.resolve(dir);

        return dirscribe(dir, {
            filter: filePath => !(/(^|\/)\.[^\/\.]/g).test(filePath),
            after:  files => _.orderBy(files, ['type', 'order', 'path'], ['desc', 'asc', 'asc']),
            build:  build
        });

        function build(filePath, stat) {

istextorbinary

Determine if a filename and/or buffer is text or binary. Smarter detection than the other solutions.

Artistic-2.0
Latest version published 4 months ago

Package Health Score

77 / 100
Full package analysis