var features = require("./features.json");

// ignoreCase default to true
function contains(string, query, ignoreCase) {
  if (ignoreCase !== false) {
    string = string.toLowerCase();
    query = query.toLowerCase();
  }
  return string.indexOf(query) !== -1;
}

function toArray (item) {
  return (item instanceof Array) ? item : [item];
}

function find (query) {
  if(!query) {
    return features;
  }

  return features.filter(function (feature) {
    //return example.code.indexOf(query) > -1;
    return Object.keys(feature.examples).some(function (technology) {
      var snippets = toArray(feature.examples[technology]);

      return snippets.some(function (snippet) {
        return contains(snippet, query);
      });
    });
  });
  //return new Array(_.findWhere(exports.getLibraries(), { name: names }));
}

module.exports = { toArray: toArray, find: find };

@@ -254,24 +254,204 @@
  !== -1;%0A%7D%0A%0A
+// ignoreCase default to true%0Afunction someContain(strings, query, ignoreCase) %7B%0A  return strings.some(function (string) %7B%0A    return contains(string, query, ignoreCase);%0A  %7D);%0A%7D%0A%0A
 function toA
@@ -824,73 +824,26 @@
 rn s
-nippets.some(function (snippet) %7B%0A        return c
+omeC
 ontain
-s
 (snippet
 , qu
@@ -838,16 +838,17 @@
 (snippet
+s
 , query)
@@ -853,18 +853,8 @@
 y);%0A
-      %7D);%0A
     

Extract a new someContain() function