BVB Source Codes

reactide Show index.js Source code

Return Download reactide: download index.js Source code - Download reactide Source code - Type:.js
  1. 'use strict';
  2.  
  3. var arrify = require('arrify');
  4. var micromatch = require('micromatch');
  5. var path = require('path');
  6.  
  7. var anymatch = function(criteria, value, returnIndex, startIndex, endIndex) {
  8.   criteria = arrify(criteria);
  9.   value = arrify(value);
  10.   if (arguments.length === 1) {
  11.     return anymatch.bind(null, criteria.map(function(criterion) {
  12.       return typeof criterion === 'string' && criterion[0] !== '!' ?
  13.         micromatch.matcher(criterion) : criterion;
  14.     }));
  15.   }
  16.   startIndex = startIndex || 0;
  17.   var string = value[0];
  18.   var altString;
  19.   var matched = false;
  20.   var matchIndex = -1;
  21.   function testCriteria (criterion, index) {
  22.     var result;
  23.     switch (toString.call(criterion)) {
  24.     case '[object String]':
  25.       result = string === criterion || altString && altString === criterion;
  26.       result = result || micromatch.isMatch(string, criterion);
  27.       break;
  28.     case '[object RegExp]':
  29.       result = criterion.test(string) || altString && criterion.test(altString);
  30.       break;
  31.     case '[object Function]':
  32.       result = criterion.apply(null, value);
  33.       break;
  34.     default:
  35.       result = false;
  36.     }
  37.     if (result) {
  38.       matchIndex = index + startIndex;
  39.     }
  40.     return result;
  41.   }
  42.   var crit = criteria;
  43.   var negGlobs = crit.reduce(function(arr, criterion, index) {
  44.     if (typeof criterion === 'string' && criterion[0] === '!') {
  45.       if (crit === criteria) {
  46.         // make a copy before modifying
  47.         crit = crit.slice();
  48.       }
  49.       crit[index] = null;
  50.       arr.push(criterion.substr(1));
  51.     }
  52.     return arr;
  53.   }, []);
  54.   if (!negGlobs.length || !micromatch.any(string, negGlobs)) {
  55.     if (path.sep === '\\' && typeof string === 'string') {
  56.       altString = string.split('\\').join('/');
  57.       altString = altString === string ? null : altString;
  58.     }
  59.     matched = crit.slice(startIndex, endIndex).some(testCriteria);
  60.   }
  61.   return returnIndex === true ? matchIndex : matched;
  62. };
  63.  
  64. module.exports = anymatch;
  65.  
downloadindex.js Source code - Download reactide Source code
Related Source Codes/Software:
rkt - rkt is a pod-native container engine for Linux. It... 2017-06-11
uWebSockets - Tiny WebSockets https://for... 2017-06-11
realworld - TodoMVC for the RealWorld - Exemplary fullstack Me... 2017-06-11
goreplay - GoReplay is an open-source tool for capturing and ... 2017-06-10
pyenv - Simple Python version management 2017-06-10
postal - 2017-06-11
CRYENGINE - CRYENGINE is a powerful real-time game development... 2017-06-11
reactide - Reactide is the first dedicated IDE for React web ... 2017-06-11
redux-saga - An alternative side effect model for Redux apps ... 2017-06-10
angular-starter - 2017-06-10

 Back to top