remove dependency from 'util'

This commit is contained in:
Jun Yang
2018-10-01 23:08:39 +08:00
parent 22a7a85d50
commit c0181aec31
2 changed files with 12 additions and 3 deletions
+2 -3
View File
@@ -2,10 +2,9 @@ import * as _ from './util/underscore.js'
import path from 'path'
import {anySeries} from './util/promise.js'
import fs from 'fs'
import {promisify} from 'util'
const statFileAsync = promisify(fs.stat)
const readFileAsync = promisify(fs.readFile)
const statFileAsync = _.promisify(fs.stat)
const readFileAsync = _.promisify(fs.readFile)
export async function resolve (filepath, root, options) {
if (!path.extname(filepath)) {
+10
View File
@@ -9,6 +9,16 @@ export function isString (value) {
return toStr.call(value) === '[object String]'
}
export function promisify (fn) {
return function () {
return new Promise((resolve, reject) => {
fn(...arguments, (err, result) => {
err ? reject(err) : resolve(result)
})
})
}
}
export function stringify (value) {
if (isNil(value)) {
return String(value)