How to use util-promisify - 6 common examples

To help you get started, we’ve selected a few util-promisify 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 dat-land / dat-desktop / app / actions / dat-middleware.js View on Github external
'use strict'

import Dat from 'dat-node'
import { encode } from 'dat-encoding'
import fs from 'fs'
import { basename, join as joinPath } from 'path'
import { ipcRenderer, shell } from 'electron'
import mkdirp from 'mkdirp-promise'
import mirror from 'mirror-folder'
import promisify from 'util-promisify'

const readFile = promisify(fs.readFile)
const writeFile = promisify(fs.writeFile)
const { Notification } = window

async function readJSON (file) {
  try {
    const blob = await readFile(file, 'utf8')
    if (!blob) {
      return {}
    }
    return JSON.parse(blob)
  } catch (_) {}
  return {}
}

export default class DatMiddleware {
  constructor ({ downloadsDir, dataDir }) {
    this.downloadsDir = downloadsDir
github okdistribute / chatmesh-desktop / app / actions.js View on Github external
import { homedir } from 'os'
import { decode, encode } from 'dat-encoding'
import to from 'to2'
import pump from 'pump'
import Swarm from 'chatmesh-db/swarm'
import Mesh from 'chatmesh-db'
import catnames from 'cat-names'
import path from 'path'
import promisify from 'util-promisify'
import fs from 'fs'

const readFile = promisify(fs.readFile)
const writeFile = promisify(fs.writeFile)
const mkdir = promisify(fs.mkdir)

var meshes = {}

export const viewMesh = ({addr}) => dispatch => {
  var mesh = meshes[addr]
  if (mesh) {
    dispatch({type: 'VIEW_MESH', addr})
    //storeOnDisk()
  }
}

export const cancelDeleteMesh = () => ({ type: 'DIALOGS_DELETE_CLOSE' })
export const deleteMesh = addr => ({ type: 'DIALOGS_DELETE_OPEN', addr })
export const confirmDeleteMesh = addr => dispatch => {
github okdistribute / chatmesh-desktop / app / actions.js View on Github external
import { homedir } from 'os'
import { decode, encode } from 'dat-encoding'
import to from 'to2'
import pump from 'pump'
import Swarm from 'chatmesh-db/swarm'
import Mesh from 'chatmesh-db'
import catnames from 'cat-names'
import path from 'path'
import promisify from 'util-promisify'
import fs from 'fs'

const readFile = promisify(fs.readFile)
const writeFile = promisify(fs.writeFile)
const mkdir = promisify(fs.mkdir)

var meshes = {}

export const viewMesh = ({addr}) => dispatch => {
  var mesh = meshes[addr]
  if (mesh) {
    dispatch({type: 'VIEW_MESH', addr})
    //storeOnDisk()
  }
}

export const cancelDeleteMesh = () => ({ type: 'DIALOGS_DELETE_CLOSE' })
export const deleteMesh = addr => ({ type: 'DIALOGS_DELETE_OPEN', addr })
export const confirmDeleteMesh = addr => dispatch => {
  const { mesh } = meshes[addr]
github dat-land / dat-desktop / app / actions / index.js View on Github external
'use strict'

import { encode } from 'dat-encoding'
import { clipboard, remote, shell } from 'electron'
import fs from 'fs'
import promisify from 'util-promisify'
import path from 'path'

const stat = promisify(fs.stat)

function showOpenDialog (props) {
  if (process.env.RUNNING_IN_SPECTRON && process.env.OPEN_RESULT) {
    return [path.resolve(__dirname, process.env.OPEN_RESULT)]
  }
  return remote.dialog.showOpenDialog(props)
}

export const shareDat = key => ({ type: 'DIALOGS_LINK_OPEN', key })
export const copyLink = link => {
  clipboard.writeText(link)
  return { type: 'DIALOGS_LINK_COPY' }
}
export const closeShareDat = () => ({ type: 'DIALOGS_LINK_CLOSE' })

export const createDat = () => dispatch => {
github okdistribute / chatmesh-desktop / app / actions.js View on Github external
import { homedir } from 'os'
import { decode, encode } from 'dat-encoding'
import to from 'to2'
import pump from 'pump'
import Swarm from 'chatmesh-db/swarm'
import Mesh from 'chatmesh-db'
import catnames from 'cat-names'
import path from 'path'
import promisify from 'util-promisify'
import fs from 'fs'

const readFile = promisify(fs.readFile)
const writeFile = promisify(fs.writeFile)
const mkdir = promisify(fs.mkdir)

var meshes = {}

export const viewMesh = ({addr}) => dispatch => {
  var mesh = meshes[addr]
  if (mesh) {
    dispatch({type: 'VIEW_MESH', addr})
    //storeOnDisk()
  }
}

export const cancelDeleteMesh = () => ({ type: 'DIALOGS_DELETE_CLOSE' })
export const deleteMesh = addr => ({ type: 'DIALOGS_DELETE_OPEN', addr })
export const confirmDeleteMesh = addr => dispatch => {
  const { mesh } = meshes[addr]
github dat-land / dat-desktop / app / actions / dat-middleware.js View on Github external
'use strict'

import Dat from 'dat-node'
import { encode } from 'dat-encoding'
import fs from 'fs'
import { basename, join as joinPath } from 'path'
import { ipcRenderer, shell } from 'electron'
import mkdirp from 'mkdirp-promise'
import mirror from 'mirror-folder'
import promisify from 'util-promisify'

const readFile = promisify(fs.readFile)
const writeFile = promisify(fs.writeFile)
const { Notification } = window

async function readJSON (file) {
  try {
    const blob = await readFile(file, 'utf8')
    if (!blob) {
      return {}
    }
    return JSON.parse(blob)
  } catch (_) {}
  return {}
}

export default class DatMiddleware {
  constructor ({ downloadsDir, dataDir }) {

util-promisify

Node 8's util.promisify, as a node module

MIT
Latest version published 3 years ago

Package Health Score

62 / 100
Full package analysis

Popular util-promisify functions

Similar packages