mirror of
https://github.com/harttle/liquidjs.git
synced 2026-10-03 00:55:13 -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 path from 'path'
|
||||||
import {anySeries} from './util/promise.js'
|
import {anySeries} from './util/promise.js'
|
||||||
import fs from 'fs'
|
import fs from 'fs'
|
||||||
import {promisify} from 'util'
|
|
||||||
|
|
||||||
const statFileAsync = promisify(fs.stat)
|
const statFileAsync = _.promisify(fs.stat)
|
||||||
const readFileAsync = promisify(fs.readFile)
|
const readFileAsync = _.promisify(fs.readFile)
|
||||||
|
|
||||||
export async function resolve (filepath, root, options) {
|
export async function resolve (filepath, root, options) {
|
||||||
if (!path.extname(filepath)) {
|
if (!path.extname(filepath)) {
|
||||||
|
|||||||
@@ -9,6 +9,16 @@ export function isString (value) {
|
|||||||
return toStr.call(value) === '[object String]'
|
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) {
|
export function stringify (value) {
|
||||||
if (isNil(value)) {
|
if (isNil(value)) {
|
||||||
return String(value)
|
return String(value)
|
||||||
|
|||||||
Reference in New Issue
Block a user