How to use the universalify.fromPromise function in universalify

To help you get started, we’ve selected a few universalify 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 przemyslawpluta / node-youtube-dl / lib / youtube-dl.js View on Github external
const request = require('request')
const hms = require('hh-mm-ss')
const http = require('http')
const url = require('url')

const {
  isYouTubeRegex,
  isWin,
  formatDuration,
  has,
  isString
} = require('./util')

let ytdlBinary = require('./get-binary')()

const execa = universalify.fromPromise(require('execa'))

function youtubeDl (args, options, cb) {
  return execa(ytdlBinary, args, options, function done (err, { stdout }) {
    if (err) return cb(err)
    return cb(null, stdout.trim().split(/\r?\n/))
  })
}

/**
 * Processes data
 *
 * @param {Object} data
 * @param {Object} options
 * @param {Object} stream
 */
github tidys / CocosCreatorPlugins / packages / excel-killer / node_modules / fs-extra / lib / path-exists / index.js View on Github external
'use strict'
const u = require('universalify').fromPromise
const fs = require('../fs')

function pathExists (path) {
  return fs.access(path).then(() => true).catch(() => false)
}

module.exports = {
  pathExists: u(pathExists),
  pathExistsSync: fs.existsSync
}

universalify

Make a callback- or promise-based function support both promises and callbacks.

MIT
Latest version published 1 year ago

Package Health Score

67 / 100
Full package analysis