Chalarangelo/30-seconds-of-code

View on GitHub
src/serializers/searchResultSerializer.js

Summary

Maintainability
A
0 mins
Test Coverage
import Serializer from '#src/core/serializer.js';

export default class SearchResultSerializer extends Serializer {
  static {
    Serializer.prepare(this, [
      ['title', 'shortTitle'],
      'url',
      [
        'tag',
        object => {
          return object.isSnippet
            ? object.formattedMiniPreviewTag
            : object.formattedSnippetCount;
        },
      ],
      'searchTokens',
      'type',
    ]);
  }
}