How to use the get-stdin.buffer function in get-stdin

To help you get started, we’ve selected a few get-stdin 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 flow-typed / flow-typed / definitions / npm / get-stdin_v5.x.x / test_get-stdin_v5.x.x.js View on Github external
import getStdin from 'get-stdin';

getStdin().then((str: string) => {});
getStdin.buffer().then((str: Buffer) => {});

// $ExpectError
(getStdin(): number);

// $ExpectError
(getStdin.buffer(): number);
github itgalaxy / imagemin-power-cli / cli.js View on Github external
if (cli.flags.recursive) {
    optionsBase.recursive = cli.flags.recursive;
}

if (cli.flags.ignoreErrors) {
    optionsBase.ignoreErrors = cli.flags.ignoreErrors;
}

if (cli.input.length > 0) {
    run(cli.input, cli.flags).catch(error => {
        console.error(error.stack); // eslint-disable-line no-console
        process.exit(1); // eslint-disable-line no-process-exit
    });
} else {
    getStdin.buffer().then(buf => run(buf, cli.flags)).catch(error => {
        console.error(error.stack); // eslint-disable-line no-console

        const exitCode = typeof error.code === "number" ? error.code : 1;

        process.exit(exitCode); // eslint-disable-line no-process-exit
    });
}
github kubernetes-sigs / cluster-api-provider-digitalocean / vendor / github.com / googleapis / gnostic / linters / node / gnostic-lint-operations / gnostic-lint-operations.js View on Github external
// import libraries
const protobuf = require("protobufjs")
const getStdin = require('get-stdin')

// import messages
const root = protobuf.Root.fromJSON(require("./bundle.json"))
const Request = root.lookupType("gnostic.plugin.v1.Request")
const Response = root.lookupType("gnostic.plugin.v1.Response")
const Document = root.lookupType("openapi.v2.Document")

getStdin.buffer().then(buffer => {
	const request = Request.decode(buffer)
	messages = []
	for (var j in request.models) {
		const m = request.models[j]
		if (m.type_url == "openapi.v2.Document") {
			const openapi2 = Document.decode(m.value)
			const paths = openapi2.paths.path
			for (var i in paths) {
				const path = paths[i]
				//console.error('path %s\n\n', path.name)
				const getOperation = path.value.get
				if (getOperation && getOperation.operationId == "") {
					messages.push({level:3, code:"NOOPERATIONID", text:"No operation id.", keys:["paths", path.name, "get"]})
				}
				const postOperation = path.value.post
				if (postOperation && postOperation.operationId == "") {
github twardoch / svgop / src / svgop-pkg.js View on Github external
'removeScriptElement',
                    'removeStyleElement',
                    'removeTitle',
                    'removeUnknownsAndDefaults',
                    'removeUnusedNS',
                    'removeUselessDefs',
                    'removeUselessStrokeAndFill',
                    'removeViewBox',
                    'removeXMLNS',
                    'removeXMLProcInst',
                    'sortAttrs'
                ]
        }
    );

getStdin.buffer().then(data => {
//    var doctype = data.toString('utf8').substring(0,5); 
//    if (doctype == "%PDF-") { 
//        pdfjsLib.getDocument({
//                data: data.buffer,
//                nativeImageDecoderSupport: pdfjsLib.NativeImageDecoding.DISPLAY
//            }).then(function (pdfDoc) {
//                var lastPromise = Promise.resolve();
//                var loadPage = function (pageNum) {
//                    return pdfDoc.getPage(pageNum).then(function (page) {
//                        var viewport = page.getViewport(1.0);
//                        var svgGfx = new PDFJS.SVGGraphics(page.commonObjs, page.objs);
//                        svgGfx.embedFonts = true;
//                        return page.getOperatorList().then(function (opList) {
//                            return svgGfx.getSVG(opList, viewport).then(function (svg) {
//                                var svgstr = svg.toString().replace(/svg:/g, '');
//                                svgo.optimize(svgstr).then(function(result) {
github webtorrent / parse-torrent / bin / cmd.js View on Github external
}

function error (err) {
  console.error(err.message)
  process.exit(1)
}

const arg = process.argv[2]

if (!arg) {
  console.error('Missing required argument')
  usage()
  process.exit(1)
}

if (arg === '--stdin' || arg === '-') stdin.buffer().then(onTorrentId).catch(error)
else if (arg === '--version' || arg === '-v') console.log(require('../package.json').version)
else onTorrentId(arg)

function onTorrentId (torrentId) {
  parseTorrent.remote(torrentId, function (err, parsedTorrent) {
    if (err) return error(err)

    delete parsedTorrent.info
    delete parsedTorrent.infoBuffer
    delete parsedTorrent.infoHashBuffer
    console.log(JSON.stringify(parsedTorrent, undefined, 2))
  })
}
github neocotic / convert-svg / packages / convert-svg-core / src / CLI.js View on Github external
if (command.args.length) {
        const filePaths = [];

        for (const arg of command.args) {
          const files = await findFiles(arg, {
            absolute: true,
            cwd: this[_baseDir],
            nodir: true
          });

          filePaths.push(...files);
        }

        await this[_convertFiles](converter, filePaths, omit(options, 'puppeteer'));
      } else {
        const input = await getStdin();

        await this[_convertInput](converter, input, omit(options, 'puppeteer'),
          command.filename ? path.resolve(this[_baseDir], command.filename) : null);
      }
    } finally {
      await converter.destroy();
    }
  }
github Jam3 / devtool-examples / to-wav.js View on Github external
/*
  Convert MP3/OGG/etc to WAV files with WebAudio.
 */

var toArrayBuffer = require('buffer-to-arraybuffer');
var toBuffer = require('arraybuffer-to-buffer');
var toWav = require('audiobuffer-to-wav');
var getStdin = require('get-stdin').buffer;

var audioContext = new (window.AudioContext || window.webkitAudioContext)();

getStdin()
  .then(function (buf) {
    var data = toArrayBuffer(buf);
    audioContext.decodeAudioData(data, function (audioBuffer) {
      var wavData = toWav(audioBuffer);
      var wavBuffer = toBuffer(wavData);
      process.stdout.write(wavBuffer, function () {
        window.close();
      });
    }, fail);
  });

function fail (err) {
  process.stderr.write(err.message + '\n');
  process.exit(1);
}
github imagemin / imagemin / cli.js View on Github external
if (src.length > 1 && !isFile(src[src.length - 1])) {
		dest = src[src.length - 1];
		src.pop();
	}

	src = src.map(function (s) {
		if (!isFile(s) && pathExists.sync(s)) {
			return path.join(s, '**/*');
		}

		return s;
	});

	run(src, dest);
} else {
	getStdin.buffer(run);
}
github anandthakker / gjv / get-stdin.js View on Github external
module.exports = function getStdin (cb) {
  if (!_stdin) {
    stdin.buffer().then(function (data) {
      _stdin = data
      cb(_stdin)
    })
  } else {
    cb(_stdin)
  }
}
github marp-team / marp-cli / src / file.ts View on Github external
static async stdin(): Promise {
    this.stdinBuffer = this.stdinBuffer || (await getStdin.buffer())
    if (this.stdinBuffer.length === 0) return undefined

    return this.initialize('-', f => {
      f.buffer = this.stdinBuffer
      f.type = FileType.StandardIO
    })
  }

get-stdin

Get stdin as a string or buffer

MIT
Latest version published 3 years ago

Package Health Score

73 / 100
Full package analysis

Popular get-stdin functions