项目原始demo,不改动
Nelze vybrat více než 25 témat Téma musí začínat písmenem nebo číslem, může obsahovat pomlčky („-“) a může být dlouhé až 35 znaků.
Tento repozitář je archivovaný. Můžete prohlížet soubory, klonovat, ale nemůžete nahrávat a vytvářet nové úkoly a požadavky na natažení.
 
 
 
 

35 řádky
664 B

  1. 'use strict';
  2. var toRegex = require('to-regex');
  3. var regexNot = require('regex-not');
  4. var cached;
  5. /**
  6. * Get the last element from `array`
  7. * @param {Array} `array`
  8. * @return {*}
  9. */
  10. exports.last = function(arr) {
  11. return arr[arr.length - 1];
  12. };
  13. /**
  14. * Create and cache regex to use for text nodes
  15. */
  16. exports.createRegex = function(pattern, include) {
  17. if (cached) return cached;
  18. var opts = {contains: true, strictClose: false};
  19. var not = regexNot.create(pattern, opts);
  20. var re;
  21. if (typeof include === 'string') {
  22. re = toRegex('^(?:' + include + '|' + not + ')', opts);
  23. } else {
  24. re = toRegex(not, opts);
  25. }
  26. return (cached = re);
  27. };