/*
Synchronous clean
774050
function() {
    // Cleans all cache files
    if (fs.existsSync(this.dir)) {
      var files = fs.readdirSync(this.dir);

      files.forEach(function(file) {
        fs.unlinkSync(path.join(this.dir, file));
      }.bind(this));
    }
  }
978401
function cleanPath(cleanPath) {
    const removePath = path.resolve(process.cwd(), cleanPath)
    rimraf(removePath, () => {
        console.log(removePath, "cleaned");
    });
}
888078
function cleanDom(dom) {
  var result = [];
  for(var i=0;i<dom.length;i++) {
    var node = dom[i];
    //console.log(node);
    if(node.type=='directive') continue;
    if(node.type=='tag') {
      var k = node.name;
      var v = node.attribs || {};
      var obj = {};
      obj[k] = v;
      if(node.hasOwnProperty("children")) {
        //console.log(node.children);
        //console.log(cleanDom(node.children));
        _.each(cleanDom(node.children), function(o) { 
          if(!_.isObject(o) || !_.isObject(v)) {
            if(_.isObject(v)) {
              if(_.size(v)==0) {
                v=o;
              } else {
                v['_text']=o;
              }
            }  else if(_.isArray(v)) {
              v.push(o); 
            } else {
              v=[v];
              v.push(o);
            }
            obj[k] = v;
          } else {
            // first step is to merge same key items
            // basically convert them to arrays
            var sameKeys = _.intersection(_.keys(o), _.keys(v));
            _.each(sameKeys, function(k) {
              if(!_.isArray(v[k])) {
                v[k]=[v[k]];
              }
              v[k]=v[k].concat(o[k]);
            });
            var remainingObj = _.omit(o, sameKeys);
            _.extend(v, remainingObj); 
          }
        });
      }
      result.push(obj);
    }
    if(node.type=='text') {
      result.push(node.data);
    }
  }
  //console.log(result);
  return result;
}
1191901
def clean(self):
        
        if self.cleaners:
            yield from asyncio.wait([x() for x in self.cleaners],
                                    loop=self.loop)
272660
function ensureExistsAndClean (dir) {
  if (!fs.existsSync(dir)) {
    fs.mkdirSync(dir)
  } else {
    cleanDir(dir)
  }
}
720964
protected void cleanAndReindex( boolean async ) {
        final IndexWriter writer = getIndexWriter();
        scan(async, getIndexWriter(), new Callable<Void>() {
            @SuppressWarnings( "synthetic-access" )
            @Override
            public Void call() throws Exception {
                writer.clearAllIndexes();
                reindexContent(true, writer);
                return null;
            }
        });
    }
777006
@Override
  public void cleanup() {
    // @formatter:off
    this
      .setMLSupporter(null)
      .setStatisticsSupporter(null)
      .setIndexingHandler(null)
      .setJoinsHandler(null)
      .setMetaDataHandler(null)
      .setMiscellanyHandler(null)
      .setMissingDataHandler(null)
      .setMutabilityHandler(null)
      .setSqlHandler(null)
      .setPersistenceHandler(null)
      .setRepresentationHandler(null)
      .setReshapingHandler(null)
      .setSchemaHandler(null)
      .setStreamingDataHandler(null)
      .setTimeSeriesHandler(null)
      ;
    // @formatter:on
  }
1291823
function clean(test) {
  var err = test.err || {};
  if (err instanceof Error) {
    err = errorJSON(err);
  }

  return {
    title: test.title,
    fullTitle: test.fullTitle(),
    duration: test.duration,
    currentRetry: test.currentRetry(),
    err: cleanCycles(err)
  };
}
925488
public static void clean() {
        try {
            if (singleServer != null) {
                singleServer.shutdown();
            }
        } catch (Exception e) {
            // do nothing
        }
        singleServer = null;
        httpClient = null;
        try {
            getHttpCollector().clean0();
        } catch (Exception e) {
            e.printStackTrace();
        }
        httpCollector = null;
    }
485683
function clean(svgString, options) {
  var aSVGCleaner = new SVGCleaner(options);
  aSVGCleaner.load(svgString);
  return aSVGCleaner.clean().svgString();
}
1302748
void clean(QNode pred, QNode s) {
        Thread w = s.waiter;
        if (w != null) {             // Wake up thread
            s.waiter = null;
            if (w != Thread.currentThread()) {
                LockSupport.unpark(w);
            }
        }
        /*
         * At any given time, exactly one node on list cannot be
         * deleted -- the last inserted node. To accommodate this, if
         * we cannot delete s, we save its predecessor as "cleanMe",
         * processing the previously saved version first. At least one
         * of node s or the node previously saved can always be
         * processed, so this always terminates.
         */
        while (pred.next == s) {
            QNode oldpred = reclean();  // First, help get rid of cleanMe
            QNode t = getValidatedTail();
            if (s != t) {               // If not tail, try to unsplice
                QNode sn = s.next;      // s.next == s means s already off list
                if (sn == s || pred.casNext(s, sn)) {
                    break;
                }
            }
            else if (oldpred == pred || // Already saved
                     oldpred == null && this.cleanMe.compareAndSet(null, pred)) {
                break;                  // Postpone cleaning
            }
        }
    }
227416
function clean(node, newObj) {
  [
    "loc",
    "range",
    "raw",
    "comments",
    "leadingComments",
    "trailingComments",
    "parenthesizedExpression",
    "parent",
    "prev",
    "start",
    "end",
    "tokens",
    "errors",
    "extra"
  ].forEach(name => {
    delete newObj[name];
  });

  if (node.kind === "string") {
    // TODO if options are available in this method, replace with
    // newObj.isDoubleQuote = !util.useSingleQuote(node, options);
    delete newObj.isDoubleQuote;
  }

  if (node.kind === "inline") {
    if (node.value.includes("___PSEUDO_INLINE_PLACEHOLDER___")) {
      return null;
    }

    newObj.value = newObj.value.replace(/\r\n?|\n/g, "");
  }

  // continue ((2)); -> continue 2;
  // continue 1; -> continue;
  if ((node.kind === "continue" || node.kind === "break") && node.level) {
    const { level } = newObj;

    if (level.kind === "number") {
      newObj.level = level.value === "1" ? null : level;
    }
  }

  // if () {{ }} -> if () {}
  if (node.kind === "block") {
    if (node.children.length === 1 && node.children[0].kind === "block") {
      while (newObj.children[0].kind === "block") {
        newObj.children = newObj.children[0].children;
      }
    }
  }

  // Normalize numbers
  if (node.kind === "number") {
    newObj.value = util.printNumber(node.value);
  }

  const statements = ["foreach", "for", "if", "while", "do"];

  if (statements.includes(node.kind)) {
    if (node.body && node.body.kind !== "block") {
      newObj.body = {
        kind: "block",
        children: [newObj.body]
      };
    } else {
      newObj.body = newObj.body ? newObj.body : null;
    }

    if (node.alternate && node.alternate.kind !== "block") {
      newObj.alternate = {
        kind: "block",
        children: [newObj.alternate]
      };
    } else {
      newObj.alternate = newObj.alternate ? newObj.alternate : null;
    }
  }

  if (node.kind === "usegroup" && typeof node.name === "string") {
    newObj.name = newObj.name.replace(/^\\/, "");
  }

  if (node.kind === "useitem") {
    newObj.name = newObj.name.replace(/^\\/, "");
  }

  if (node.kind === "method" && node.name.kind === "identifier") {
    newObj.name.name = util.normalizeMagicMethodName(newObj.name.name);
  }

  // @TODO: We need special node for `null` value to avoid ast compare problem
  if (node.kind === "classreference" && node.name.toLowerCase() === "null") {
    delete newObj.name;
  }
}
125431
function(to_clean) {
    _.map(to_clean, function(value, key, to_clean) {
      if (value === undefined) {
        delete to_clean[key];
      }
    });
    return to_clean;
  }
543540
function cleanContent() {
    function transform(file, cb) {
        file.contents = new Buffer((function (src) {
            var lines = src.replace('_.mixin({\n','').split('\n'),
                last = lines.pop();
            // handle empty lines at the end of the file
            while(last===''){
                last = lines.pop();
            }
            return lines.join('\n');
        })(String(file.contents)));
        cb(null, file);
    }

    return require('event-stream').map(transform);
}
972123
function cleanjQueryData(node) {
      var jQueryCleanNodeFn = jQueryInstance
          ? jQueryInstance.cleanData : null;

      if (jQueryCleanNodeFn) {
          jQueryCleanNodeFn([node]);
      }
  }
622488
function cleanup(cleanups, start = 0) {
    for(let i = start; i < cleanups.length; ++i) {
        const res = cleanups[i]();
        if(res && res.then)
            return res.then(() => cleanup(cleanups, i+1));
    }
}
276937
def maybe_clean(self):
        """"""

        now = time.time()
        if self.next_cleaning <= now:
            keys_to_delete = []
            for (k, v) in self.data.iteritems():
                if v.expiration <= now:
                    keys_to_delete.append(k)
            for k in keys_to_delete:
                del self.data[k]
            now = time.time()
            self.next_cleaning = now + self.cleaning_interval