UNPKG

tiny-types

Version:

A tiny library that brings Tiny Types to JavaScript and TypeScript

27 lines 749 B
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.endsWith = endsWith; const Predicate_1 = require("./Predicate"); /** * @desc Ensures that the `value` ends with a given suffix. * * @example * import { endsWith, ensure, TinyType } from 'tiny-types'; * * class TextFileName extends TinyType { * constructor(public readonly value: string) { * super(); * * ensure('TextFileName', value, endsWith('.txt')); * } * } * * @param {string} suffix * * @returns {Predicate<string>} */ function endsWith(suffix) { return Predicate_1.Predicate.to(`end with '${suffix}'`, (value) => typeof value === 'string' && value.endsWith(suffix)); } //# sourceMappingURL=endsWith.js.map