How to use universalify - 10 common examples

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 alan-ai / alan-sdk-reactnative / testtools / node_modules / fs-extra / lib / json / index.js View on Github external
'use strict'

const u = require('universalify').fromCallback
const jsonFile = require('./jsonfile')

jsonFile.outputJson = u(require('./output-json'))
jsonFile.outputJsonSync = require('./output-json-sync')
// aliases
jsonFile.outputJSON = jsonFile.outputJson
jsonFile.outputJSONSync = jsonFile.outputJsonSync
jsonFile.writeJSON = jsonFile.writeJson
jsonFile.writeJSONSync = jsonFile.writeJsonSync
jsonFile.readJSON = jsonFile.readJson
jsonFile.readJSONSync = jsonFile.readJsonSync

module.exports = jsonFile
github alan-ai / alan-sdk-reactnative / testtools / node_modules / @expo / config / node_modules / @react-native-community / cli-platform-android / node_modules / fs-extra / lib / mkdirs / index.js View on Github external
'use strict'
const u = require('universalify').fromCallback
const mkdirs = u(require('./mkdirs'))
const mkdirsSync = require('./mkdirs-sync')

module.exports = {
  mkdirs,
  mkdirsSync,
  // alias
  mkdirp: mkdirs,
  mkdirpSync: mkdirsSync,
  ensureDir: mkdirs,
  ensureDirSync: mkdirsSync
}
github polakowo / datadocs / website / node_modules / fs-extra / lib / fs / index.js View on Github external
exports.write = function (fd, buffer, ...args) {
  if (typeof args[args.length - 1] === 'function') {
    return fs.write(fd, buffer, ...args)
  }

  return new Promise((resolve, reject) => {
    fs.write(fd, buffer, ...args, (err, bytesWritten, buffer) => {
      if (err) return reject(err)
      resolve({ bytesWritten, buffer })
    })
  })
}

// fs.realpath.native only available in Node v9.2+
if (typeof fs.realpath.native === 'function') {
  exports.realpath.native = u(fs.realpath.native)
}
github tidys / CocosCreatorPlugins / packages / excel-killer / node_modules / fs-extra / lib / json / jsonfile.js View on Github external
'use strict'

const u = require('universalify').fromCallback
const jsonFile = require('jsonfile')

module.exports = {
  // jsonfile exports
  readJson: u(jsonFile.readFile),
  readJsonSync: jsonFile.readFileSync,
  writeJson: u(jsonFile.writeFile),
  writeJsonSync: jsonFile.writeFileSync
}
github ladjs / custom-fonts-in-emails / src / index.js View on Github external
supportsFallback: true,
  resizeToFontSize: false,
  trim: false,
  trimTolerance: 10,
  attrs: {},
  textToSvg: {
    x: 0,
    y: 0,
    anchor: 'left top',
    attributes: {
      stroke: 'none'
    }
  }
};

const load = universalify.fromCallback(TextToSvg.load);

function setDefaults(options) {
  defaults = _.defaultsDeep(options, defaults);
  return defaults;
}

// eslint-disable-next-line complexity
async function setOptions(options) {
  // Clone to prevent interference
  options = _.cloneDeep(options);

  // Set deep defaults
  options = _.defaultsDeep(options, defaults);

  // Ensure `text` is a string
  if (!_.isString(options.text)) throw new Error('`text` must be a String');
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 jprichardson / node-fs-extra / lib / remove / index.js View on Github external
'use strict'

const u = require('universalify').fromCallback
const rimraf = require('./rimraf')

module.exports = {
  remove: u(rimraf),
  removeSync: rimraf.sync
}
github victorporof / Sublime-HTMLPrettify / build / js-transpiled / node_modules / fs-extra / lib / copy / index.js View on Github external
'use strict'

const u = require('universalify').fromCallback
module.exports = {
  copy: u(require('./copy'))
}
github jprichardson / node-fs-extra / lib / move / index.js View on Github external
'use strict'

const u = require('universalify').fromCallback
module.exports = {
  move: u(require('./move'))
}

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