UNPKG

@sphereon/ssi-types

Version:

SSI Common Types

28 lines 1.04 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.ObjectUtils = void 0; const BASE64_REGEX = /^[-A-Za-z0-9+_/]*={0,3}$/g; class ObjectUtils { static asArray(value) { return Array.isArray(value) ? value : [value]; } static isObject(value) { return typeof value === 'object' || Object.prototype.toString.call(value) === '[object Object]'; } static isUrlAbsolute(url) { // regex to check for absolute IRI (starting scheme and ':') or blank node IRI const isAbsoluteRegex = /^([A-Za-z][A-Za-z0-9+-.]*|_):[^\s]*$/; ObjectUtils.isString(url) && isAbsoluteRegex.test(url); } static isString(value) { return typeof value === 'string' || Object.prototype.toString.call(value) === '[object String]'; } static isBase64(value) { if (!ObjectUtils.isString(value)) { return false; } return value.match(BASE64_REGEX) !== null; } } exports.ObjectUtils = ObjectUtils; //# sourceMappingURL=object.js.map