UNPKG

@atproto/api

Version:

Client library for atproto and Bluesky

33 lines 1.01 kB
/** * GENERATED CODE - DO NOT MODIFY */ function isObject(v) { return v != null && typeof v === 'object'; } function is$type($type, id, hash) { return hash === 'main' ? $type === id : // $type === `${id}#${hash}` typeof $type === 'string' && $type.length === id.length + 1 + hash.length && $type.charCodeAt(id.length) === 35 /* '#' */ && $type.startsWith(id) && $type.endsWith(hash); } export function is$typed(v, id, hash) { return isObject(v) && '$type' in v && is$type(v.$type, id, hash); } export function maybe$typed(v, id, hash) { return (isObject(v) && ('$type' in v ? v.$type === undefined || is$type(v.$type, id, hash) : true)); } /** * Utility function that allows to convert a "validate*" utility function into a * type predicate. */ export function asPredicate(validate) { return function (v) { return validate(v).success; }; } //# sourceMappingURL=util.js.map