Surround constructor.

@param {Object} Object
@param {Pattern} pattern
@constructor
437458
function Surround(obj, pattern) {
  var self = this;

  var regEX = new RegExp(pattern);

  for(var fn in obj) {
    var orig = obj[fn];

    if (typeof(orig) != "function" || !regEX.test(fn))
      continue;

    // Already surrouneded.
    if (obj[fn].__stacks) {
      this.stacks = obj[fn].__stacks;
      return this;
    }

    this.stacks = this.defaults();

    // The replace of the original function.
    obj[fn] = function() {
      self.stacks.before
        .concat([orig], self.stacks.after)
        .forEach(function(fn) {
          fn.apply(obj, arguments);
        });
    };

    // Resets the stack and returns the basic func back.
    obj[fn].reset = function() {
      obj[fn] = orig;
      self.stacks = self.defaults();
    };

    // The stacks are cached in the func itself.
    obj[fn].__stacks = this.stacks;
  }
}
412884
function renderPatternPartial(patternId, drizzleData, Handlebars) {
  const patternObj = deepPattern(patternId, drizzleData.patterns);
  const localContext = patternContext(patternObj, drizzleData);
  let template = Handlebars.partials[patternId];
  if (typeof template !== 'undefined') {
    if (typeof template !== 'function') {
      template = Handlebars.compile(template);
    }
    // Render and return
    return template(localContext);
  }
  DrizzleError.error(
    new DrizzleError(
      `Partial for pattern ${patternId} not found`,
      DrizzleError.LEVELS.ERROR
    ),
    drizzleData.options.debug
  );
}
323568
private static void initPattern(PPattern result, ILexLocation location)
	{
		result.setLocation(location);
		result.setResolved(false);

	}
273286
public void addInclude(PathPatternType pattern)
  {
    if (_includeList == null)
      _includeList = new ArrayList<PathPatternType>();

    _includeList.add(pattern);
  }
125040
async function isInPattern(filePath, pattern, options, callback) {
  if (!pattern) {
    callback(null, false);
  } else {
    options = options || {};
    // var result = false;
    var isDirectory = await exports.isDirectory(filePath);
    if (isDirectory) {
      options.includeFolders = true;
    }
    if (!Array.isArray(pattern)) {
      var inPattern = await isInPatternSingle(filePath, pattern, options);
      callback(null, inPattern);
    } else {
      var isIn = false;
      for (const patt of pattern) {
        var inPattern = await isInPatternSingle(filePath, patt, options);
        if (inPattern) {
          isIn = true;
        }
      }
      callback(null, isIn);
    }
  }
}
802709
private void setBrowserPattern(List<Pattern> pattern) {

        if ((pattern == null) || (pattern.size() == 0)) {
            setValidConfiguration(false);
            LOG.error(Messages.get().getBundle().key(Messages.LOG_EDITOR_CONFIG_NO_PATTERN_0));
        }
        m_browserPattern = pattern;
    }
1104566
def addpattern(base_func):
    """"""
    def pattern_adder(func):
        @_coconut.functools.wraps(func)
        @_coconut_tco
        def add_pattern_func(*args, **kwargs):
            try:
                return base_func(*args, **kwargs)
            except _coconut_MatchError:
                raise _coconut_tail_call(func, *args, **kwargs)
        return add_pattern_func
    return pattern_adder
1312604
protected void setStopPattern (String pattern)
    {
        _stopMatcher = Pattern.compile(pattern, Pattern.CASE_INSENSITIVE).matcher("");
    }
893836
function compilePattern(pattern) {
  // pass estree syntax tree obj
  if (pattern && pattern.type) return pattern;

  if (typeof pattern !== 'string') {
    throw new Error('input pattern is neither a string nor an estree node.');
  }

  let exp = parser(pattern);

  if (exp.type !== 'Program' || !exp.body) {
    throw new Error(`Not a valid expression:  "${pattern}".`);
  }

  if (exp.body.length === 0) {
    throw new Error(`There is no statement in pattern "${pattern}".`);
  }

  if (exp.body.length > 1) {
    throw new Error(`Multiple statements is not supported "${pattern}".`);
  }

  exp = exp.body[0];
  // get the real expression underneath
  if (exp.type === 'ExpressionStatement') exp = exp.expression;
  return exp;
}
112778
private void visitObjectPattern(Node pattern) {
    JSType patternType = getJSType(pattern);
    validator.expectObject(pattern, patternType, "cannot destructure 'null' or 'undefined'");
    for (Node child : pattern.children()) {
      DestructuredTarget target = DestructuredTarget.createTarget(typeRegistry, patternType, child);

      if (target.hasComputedProperty()) {
        Node computedProperty = target.getComputedProperty();
        validator.expectIndexMatch(
            computedProperty, patternType, getJSType(computedProperty.getFirstChild()));
      } else if (target.hasStringKey()) {
        Node stringKey = target.getStringKey();
        if (!stringKey.isQuotedString()) {
          if (patternType.isDict()) {
            report(stringKey, TypeValidator.ILLEGAL_PROPERTY_ACCESS, "unquoted", "dict");
          }
          // check for missing properties given `const {a} = obj;` but not `const {'a': a} = obj;`
          checkPropertyAccessForDestructuring(
              pattern, patternType, stringKey, getJSType(target.getNode()));
        } else if (patternType.isStruct()) {
          // check that we are not accessing a struct with a quoted string
          report(stringKey, TypeValidator.ILLEGAL_PROPERTY_ACCESS, "quoted", "struct");
        }
      }
    }
    ensureTyped(pattern);
  }
410523
function any(/* patterns... */) {
        var patterns = [].slice.call(arguments, 0);
        var name = '(' + patterns.join(' | ') + ')';

        return new Pattern(name, function (str, pos) {
            var r, i;
            for (i = 0; i < patterns.length && !r; i++)
                r = patterns[i].exec(str, pos);
            return r;
        });
    }
883350
@Nonnull
	public DataBuilder appendBrowserPattern(@Nonnull final BrowserPattern pattern) {
		Check.notNull(pattern, "pattern");
		if (!browserPatterns.containsKey(pattern.getId())) {
			browserPatterns.put(pattern.getId(), new TreeSet<BrowserPattern>(BROWSER_PATTERN_COMPARATOR));
		}

		browserPatterns.get(pattern.getId()).add(pattern);
		return this;
	}
1325644
function (pattern, options) {
    var self = this;
    function find() {
      var isMatch = lazy.mm.matcher(pattern, options);
      for (var key in self) {
        var val = self[key];
        if (typeof val === 'object' && isMatch(key)) {
          return val;
        }
      }
    }
    var res = this.fragmentCache(pattern, find);
    res.__proto__ = this;
    return res;
  }
409250
function walker(context, pattern) {
  var args = Array.prototype.splice.call(arguments, 0);

  if (isUndefined(context)) {
    throw {
      name: 'Error',
      message: 'Expected context to be defined',
      arguments: args
    };
  } else if (!isObject(context)) {
    throw {
      name: 'Error',
      message: 'Expected context to be an object, but got something else',
      arguments: args
    };
  }

  if (isUndefined(pattern)) {
    throw {
      name: 'Error',
      message: 'Expected pattern to be defined',
      arguments: args
    };
  } else if (!isNumber(pattern) && !isString(pattern)) {
    throw {
      name: 'Error',
      message: 'Expected pattern to be a number or a string, but got ' +
        'something else',
      arguments: args
    };
  }

  var current;
  if (isNumber(pattern)) {
    current = pattern;
  } else {
    var aborting = false;
    var parts = pattern.split('.');
    while (aborting === false && parts.length) {
      var head = parts.shift();
      current = context[head];
      if (!isUndefined(current)) {
        context = current;
      } else {
        current = undefined;
        aborting = true;
      }
    }
  }
  return current;
}
465287
public void add(SeqPattern style) {
    style.setGenerator(this);
    patterns.put(style.getLevel(), style);
  }
364331
private String[] fillNonPatternSet(Set set, String[] patterns) {
        ArrayList al = new ArrayList(patterns.length);
        for (int i = 0; i < patterns.length; i++) {
            if (!SelectorUtils.hasWildcards(patterns[i])) {
                set.add(isCaseSensitive() ? patterns[i]
                    : patterns[i].toUpperCase());
            } else {
                al.add(patterns[i]);
            }
        }
        return set.size() == 0 ? patterns
            : (String[]) al.toArray(new String[al.size()]);
    }
94319
@SuppressWarnings("unchecked")
	public static void registerPattern(String id, String pattern, ParserContext parserContext) {
		if (!"".equals(id)) { // add to sitemap only if it has an id
			BeanDefinitionRegistry registry = parserContext.getRegistry();
			BeanDefinition sitemapBean;
			try {
				sitemapBean = registry.getBeanDefinition(BEAN_ID);
			} catch (NoSuchBeanDefinitionException e) {
				sitemapBean = BeanDefinitionBuilder.genericBeanDefinition(Sitemap.class)
					.addPropertyValue(BEAN_PROP_ENTRIES, new HashMap<String, String>())
					.getBeanDefinition();
				registry.registerBeanDefinition(BEAN_ID, sitemapBean);
			}
			((Map<String, String>) sitemapBean.getPropertyValues().getPropertyValue(BEAN_PROP_ENTRIES).getValue()).put(id, pattern);
		}
	}