mirror of
https://github.com/harttle/liquidjs.git
synced 2026-09-16 21:00:40 -07:00
cover all
This commit is contained in:
@@ -2,9 +2,6 @@ const AssertionError = require('./error.js').AssertionError
|
||||
|
||||
function assert (predicate, message) {
|
||||
if (!predicate) {
|
||||
if (message instanceof Error) {
|
||||
throw message
|
||||
}
|
||||
message = message || `expect ${predicate} to be true`
|
||||
throw new AssertionError(message)
|
||||
}
|
||||
|
||||
+13
-1
@@ -1,3 +1,5 @@
|
||||
const toStr = Object.prototype.toString
|
||||
|
||||
/*
|
||||
* Checks if value is classified as a String primitive or object.
|
||||
* @param {any} value The value to check.
|
||||
@@ -7,6 +9,15 @@ function isString (value) {
|
||||
return value instanceof String || typeof value === 'string'
|
||||
}
|
||||
|
||||
function isNil (value) {
|
||||
return value === null || value === undefined
|
||||
}
|
||||
|
||||
function isArray (value) {
|
||||
// be compatible with IE 8
|
||||
return toStr.call(value) === '[object Array]'
|
||||
}
|
||||
|
||||
function isError (value) {
|
||||
var signature = Object.prototype.toString.call(value)
|
||||
// [object XXXError]
|
||||
@@ -53,7 +64,6 @@ function assign (object) {
|
||||
}
|
||||
|
||||
function _assignBinary (dst, src) {
|
||||
if (!dst) return dst
|
||||
forOwn(src, function (v, k) {
|
||||
dst[k] = v
|
||||
})
|
||||
@@ -115,6 +125,8 @@ function range (start, stop, step) {
|
||||
|
||||
exports.isString = isString
|
||||
exports.isObject = isObject
|
||||
exports.isArray = isArray
|
||||
exports.isNil = isNil
|
||||
exports.isError = isError
|
||||
|
||||
exports.range = range
|
||||
|
||||
Reference in New Issue
Block a user