UNPKG

kawkab-frontend

Version:

Kawkab frontend is a frontend library for the Kawkab framework

22 lines (21 loc) 553 B
export class Str { static ucfirst(value) { if (!value) return ''; return value.charAt(0).toUpperCase() + value.slice(1); } static slug(value) { return value .toLowerCase() .trim() .replace(/[^\w\s-]/g, '') .replace(/[\s_-]+/g, '-') .replace(/^-+|-+$/g, ''); } static limit(value, limit = 100, end = '...') { if (value.length <= limit) { return value; } return value.substring(0, limit) + end; } }