biner
Version:
Declarative binary data encoder / decoder.
50 lines • 1.43 kB
JavaScript
;
Object.defineProperty(exports, "__esModule", { value: true });
function isObject(val) {
return val != null && typeof val === 'object' && !Array.isArray(val);
}
exports.isObject = isObject;
function isObjectObject(o) {
return isObject(o) === true && Object.prototype.toString.call(o) === '[object Object]';
}
function isPlainObject(o) {
let ctor, prot;
if (isObjectObject(o) === false)
return false;
ctor = o.constructor;
if (typeof ctor !== 'function')
return false;
prot = ctor.prototype;
if (isObjectObject(prot) === false)
return false;
if (!prot.hasOwnProperty('isPrototypeOf')) {
return false;
}
return true;
}
exports.isUserType = isPlainObject;
function isNull(value) {
return value == null;
}
exports.isNull = isNull;
function isNumber(value) {
return typeof value === 'number';
}
exports.isNumber = isNumber;
function isType(type) {
return isObject(type) && isFunction(type.encode) && isFunction(type.decode);
}
exports.isType = isType;
function isFunction(value) {
return typeof value === 'function';
}
exports.isFunction = isFunction;
function isDecodeType(type) {
return isObject(type) && isFunction(type.decode);
}
exports.isDecodeType = isDecodeType;
function isEncodeType(type) {
return isObject(type) && isFunction(type.encode);
}
exports.isEncodeType = isEncodeType;
//# sourceMappingURL=util.js.map