mirror of
https://github.com/harttle/liquidjs.git
synced 2026-09-16 04:40:39 -07:00
Changes including: - will not call fs.resolve when normalizing `fs` - removed hardcoded `/` - mandatory `fs.dirname` for relative reference - mandatory `fs.sep`, defaults to '/'
This commit is contained in:
+4
-2
@@ -1,8 +1,10 @@
|
||||
import { AssertionError } from './error'
|
||||
|
||||
export function assert <T> (predicate: T | null | undefined, message?: () => string) {
|
||||
export function assert <T> (predicate: T | null | undefined, message?: string | (() => string)) {
|
||||
if (!predicate) {
|
||||
const msg = message ? message() : `expect ${predicate} to be true`
|
||||
const msg = typeof message === 'function'
|
||||
? message()
|
||||
: (message || `expect ${predicate} to be true`)
|
||||
throw new AssertionError(msg)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -11,6 +11,10 @@ export function isFunction (value: any): value is Function {
|
||||
return typeof value === 'function'
|
||||
}
|
||||
|
||||
export function escapeRegex (str: string) {
|
||||
return str.replace(/[-/\\^$*+?.()|[\]{}]/g, '\\$&')
|
||||
}
|
||||
|
||||
export function promisify<T1, T2> (fn: (arg1: T1, cb: (err: Error | null, result: T2) => void) => void): (arg1: T1) => Promise<T2>;
|
||||
export function promisify<T1, T2, T3> (fn: (arg1: T1, arg2: T2, cb: (err: Error | null, result: T3) => void) => void): (arg1: T1, arg2: T2) => Promise<T3>;
|
||||
export function promisify (fn: any) {
|
||||
|
||||
Reference in New Issue
Block a user