summaly/built/utils/clip.js
2023-02-12 12:20:19 +00:00

14 lines
259 B
JavaScript

import nullOrEmpty from './null-or-empty.js';
export default function (s, max) {
if (nullOrEmpty(s)) {
return s;
}
s = s.trim();
if (s.length > max) {
return s.substr(0, max) + '...';
}
else {
return s;
}
}