{"size": 422, "ext": "js", "max_stars_repo_path": "src/filters/truncateWordsHtml.js", "max_stars_repo_name": "ogonkov/djanjucks", "max_stars_repo_stars_event_min_datetime": "2019-07-15T09:40:14.000Z", "max_stars_repo_stars_event_max_datetime": "2021-07-01T15:29:01.000Z", "max_issues_repo_path": "src/filters/truncateWordsHtml.js", "max_issues_repo_name": "ogonkov/djanjucks", "max_issues_repo_issues_event_min_datetime": "2019-09-10T20:32:43.000Z", "max_issues_repo_issues_event_max_datetime": "2021-05-10T01:38:05.000Z", "max_forks_repo_path": "src/filters/truncateWordsHtml.js", "max_forks_repo_name": "ogonkov/djanjucks", "max_forks_repo_forks_event_min_datetime": "2019-09-10T20:16:16.000Z", "max_forks_repo_forks_event_max_datetime": "2019-10-27T22:45:26.000Z"}
{"max_stars_count": 6, "max_issues_count": 5, "max_forks_count": 2, "avg_line_length": 24.8235294118, "max_line_length": 72, "alphanum_fraction": 0.682464455}
import { runtime } from '..';
import Truncator from '../truncator';

const truncateWordsHtml = (value, arg) => {
  const length = parseInt(arg, 10);
  const parsedValue = String(value);
  if (isNaN(length) || length >= parsedValue.length) {
    return value;
  }

  const output = new Truncator(parsedValue).words(length, ' ...', true);

  return runtime.copySafeness(value, output);
};

export default truncateWordsHtml;
