mirror of
https://github.com/harttle/liquidjs.git
synced 2026-09-15 04:10:40 -07:00
remove dependency from 'util'
This commit is contained in:
+2
-3
@@ -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)) {
|
||||
|
||||
@@ -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)
|
||||
|
||||
Reference in New Issue
Block a user