react-native-navigation的迁移库

linkify.js 769B

12345678910
  1. const URL = 'https://wix.github.io/react-native-navigation/v2/#/docs/';
  2. const isLetter = (c) => c.toLowerCase() !== c.toUpperCase();
  3. const isClass = (type) => isLetter(type[0]) && (type.includes(':') || type[0] === type[0].toUpperCase());
  4. const stripArray = (type) => type.substring(type.indexOf('<') + 1, type.indexOf('>'));
  5. const classUrl = (type) => URL + (type.includes('Array.<') ? stripArray(type) : type).replace(':', '/');
  6. const className = (type) => type.includes('Array.<') ? className(stripArray(type)) + '[]' : type.substring(type.indexOf(':') + 1);
  7. const url = (type) => `<a href="${classUrl(type)}">${className(type)}</a>`;
  8. const simpleString = (type) => `<code>${type}</code>`;
  9. exports.linkify = (type) => isClass(type) ? url(type) : simpleString(type);