function(openControlledOntologyAcc, child) {
        const { tagName, textContent } = child;

        // using He.decode here, because some GPML at some point didn't use UTF-8
        // for things like author names.
        const textContentDecoded = He.decode(textContent);

        const key = BIOPAX_TO_PVJSON.hasOwnProperty(tagName)
          ? BIOPAX_TO_PVJSON[tagName]
          : tagName.replace(/^bp:/, "").toLowerCase();
        openControlledOntologyAcc[key] = textContentDecoded;
        return openControlledOntologyAcc;
      },
Example #2
0
  opts => {
    const parsed = parseSrcSet(he.decode(opts.srcset));
    const firstCandidate: { url?: string } = parsed[0];

    const { url } = firstCandidate || { url: null };
    let encodedUrl = '';

    // Must re-encode url prior to comparison with expected string.
    if (url !== null) {
      encodedUrl = he.encode(url);
    } else {
      encodedUrl = '';
    }

    expect(encodedUrl).toStrictEqual(opts.expect);
  },
        function(publicationXrefAcc, child) {
          const { tagName, textContent } = child;

          // using He.decode here, because some GPML at some point didn't use UTF-8
          // for things like author names.
          const textContentDecoded = He.decode(textContent);

          const key = BIOPAX_TO_PVJSON[tagName];
          if (
            [
              "xrefIdentifier",
              "xrefDataSource",
              "title",
              "source",
              "year"
            ].indexOf(key) > -1
          ) {
            publicationXrefAcc[key] = textContentDecoded;
          } else {
            publicationXrefAcc[key].push(textContentDecoded);
          }
          return publicationXrefAcc;
        },
Example #4
0
 expect(() => {
   parseSrcSet(he.decode(opts.srcset));
 }).toThrow(Error);
function decodeIfNotEmpty(input) {
  return isEmpty(input) ? input : decode(input);
}